Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Sep 2020 22:38:22 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 249261] Kernel ignores RTAX_IFP if an exact RTAX_IFA match is found
Message-ID:  <bug-249261-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D249261

            Bug ID: 249261
           Summary: Kernel ignores RTAX_IFP if an exact RTAX_IFA match is
                    found
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: demiobenour@gmail.com

If an RTM_ADD command on a routing socket includes an RTA_IFA sockaddr,
and that sockaddr is an exact match for one of the interfaces in the
relevant routing domain, the RTA_IFP sockaddr is ignored.  If there are
multiple interfaces with the same IP address, this can cause packets to
be sent out the wrong interface.

I expected that an RTA_IFP sockaddr will always be honored.  That is,
the route will always use the interface supplied, regardless of what the
other sockaddrs in the message are.  If the kernel is not able to ensure
this, it should return an error.

I found this bug on OpenBSD.  I don=E2=80=99t have access to a FreeBSD mach=
ine, but a
cursory look at the source code [1] indicates that FreeBSD likely has the s=
ame
bug, so I decided to report it just in case.  I did manage to create a shell
script that reproduces the bug:

        # replace these by any unused Ethernet pseudo-interfaces
        IF1=3Dtap0 IF2=3Dtap1
        ifconfig "$IF1" destroy 2>/dev/null
        ifconfig "$IF2" destroy 2>/dev/null
        dummy_mac=3Dfe:ff:ff:ff:ff:ff dummy_ip=3D192.0.2.5
        ifconfig vether0 create lladdr "$dummy_mac"
        ifconfig "$IF2" create lladdr "$dummy_mac"
        ifconfig vether0 inet "$dummy_ip" prefixlen 32
        route -n delete "$dummy_ip/32" "$dummy_ip"
        ifconfig "$IF2" inet "$dummy_ip" prefixlen 32
        route -n delete "$dummy_ip/32" "$dummy_ip"
        route -n add -inet 192.0.2.6 -static -iface -llinfo -link "$IF2" -i=
fp
vether1 -inet -ifa "$dummy_ip"
        route -n show -inet

If the bug affects FreeBSD, the route to 192.0.2.6 will be via $IF2, wherea=
s if
the bug does not affect FreeBSD, it will be via $IF1.

[1]:
https://github.com/freebsd/freebsd/blob/9b858c384885d7431a5c82ec28d6142d142=
c8bbd/sys/net/route.c#L644-L645

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-249261-227>