]> git.ozlabs.org Git - ppp.git/commit
pppd: Fix setting IPv6 peer address (#212)
authorpali <7141871+pali@users.noreply.github.com>
Sun, 3 Jan 2021 23:01:44 +0000 (00:01 +0100)
committerGitHub <noreply@github.com>
Sun, 3 Jan 2021 23:01:44 +0000 (10:01 +1100)
commitc3af52231184ade3cf728ec60c9de9e87c2622ad
tree3d4ea175441341747f8fde2bc806989be601fd93
parent86eaed93a40528859aa19a172ae633987e9f2248
pppd: Fix setting IPv6 peer address (#212)

On Linux IPv6 peer address cannot be set via SIOCSIFDSTADDR ioctl like it
is for IPv4 peer address. Linux kernel does not support SIOCSIFDSTADDR for
AF_INET6 PPP interfaces.

The only way how to set IPv6 peer address on Linux is via kernel netlink
interface which is just a little bit complicated compared to one ioctl
call.

Linux kernel for a long time automatically adds IPv6 peer address from
interface into route table so it is not needed to explicitly set routing
for remote peer address. pppd already does not do it for kernel versions
newer than 2.1.16. So the same check is used also for IPv6 peer route
address.

Prior this patch ppp interface was configured as:

    $ ip -6 address show dev ppp0
    2: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 state UNKNOWN qlen 3
        inet6 fe80::2/128 scope link
           valid_lft forever preferred_lft forever

    $ ip -6 route show dev ppp0
    fe80::1 metric 1 pref medium
    fe80::2 proto kernel metric 256 pref medium

And after applying this patch as:

    $ ip -6 address show dev ppp0
    2: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 state UNKNOWN qlen 3
        inet6 fe80::2 peer fe80::1/128 scope link
           valid_lft forever preferred_lft forever

    $ ip -6 route show dev ppp0
    fe80::1 proto kernel metric 256 pref medium
    fe80::2 proto kernel metric 256 pref medium

As can be seen IPv6 peer address is now correctly set on the interface and
also kernel correctly fill route table for IPv6 peer address.

Please note that old ifconfig utility cannot show nor change IPv6 peer
address. Peer address is supported only for IPv4 addresses as opposite of
the local addresses where both IPv4 and IPv6 are supported. It is because
old ifconfig utility is also using ioctl interface which cannot handle it.
Therefore for any testing it is really required ip utility or other utility
with netlink interface (and not ioctl interface).

Signed-off-by: Pali Rohár <pali@kernel.org>
pppd/sys-linux.c