HomeFreeBSD

netlink: fix ifconfig P2P inet ADDR ADDR netmask 255.255.255.255 addition

Description

netlink: fix ifconfig P2P inet ADDR ADDR netmask 255.255.255.255 addition

Adding P2P addresses is complex in both ioctl and Netlink.
In the ioctl interface, "broadcast" field is the same field as the
"peer". In is possible to specify non-p2p address for the p2p
interface in IPv6, but not in IPv4.
In the Netlink interface, "address" field means "peer" address.
As a result, a common notion for the Netlink users is to submit
same address/peer for non-P2P interfaces.

This change customises mapping the attribute on per-family basis.
Specifically,
for IPv4 - if the interface is P2P, assume "address" is p2p and
"local" is the address. If the interfase is non-p2p, use "local"
attribute as the address. If it's not set, use "address" attribute.
for IPv6 - start with "local" attribute as the address. If it's not set,
use use "address" attribute. If both are set and both are the same,
assume non p2p, otherwise add as p2p.

MFC after: 2 weeks
Reported by: jkim

Details

Provenance
melifaroAuthored on May 31 2023, 9:58 AM
Parents
rG5ab151574c8a: netinet*: Fix redirects for connections from localhost
Branches
Unknown
Tags
Unknown