git: netinet: Auto add loopback routes to interface addresses

Aaron LI aly at crater.dragonflybsd.org
Wed Mar 20 08:33:50 PDT 2024


commit 951ecd7f55e2edd33258ad6d9593c9f81c92b42e
Author: Aaron LI <aly at aaronly.me>
Date:   Mon Mar 18 11:43:41 2024 +0800

    netinet: Auto add loopback routes to interface addresses
    
    When adding an address to an interface, a loopback route will be created
    to route the traffic targeting it through the lo0 interface.  The
    loopback route will also be removed when the corresponding interface
    address is deleted.
    
    In principle, this can help simplify the network input and output paths
    by avoiding special handling of local addresses.  That deserves some
    further efforts.
    
    Nonetheless, an immediate benefit goes to wg(4).  Now we can access
    (e.g., ping) from localhost a wg(4) interface's IPv4 addresses.
    Previously it was broken because wg(4) is a virtual device and doesn't
    have/use ARP.  For Ethernet devices, the ether_output() function will
    redirect the traffic targeting its own address to the loopback interface
    by calling if_simloop().
    
    Derived from FreeBSD; the major commits are:
    - This patch adds a host route to an interface address ...
      https://github.com/freebsd/freebsd-src/commit/ebc90701ac6c1f814c5bd6f3e19f0113ebe06156
    - Self pointing routes are installed for configured interface addr ...
      https://github.com/freebsd/freebsd-src/commit/9bb7d0f47a3265a1782a64837ae93dde4c550a6a
    - Unify loopback route switching
      https://github.com/freebsd/freebsd-src/commit/59c180c35c1ddc1d544a1c73c789d126a8fbac78
    - Fix rt_ifa selection during loopback route insertion process
      https://github.com/freebsd/freebsd-src/commit/2ad7ed6e4a84448234e9aaef3c9fa884848f7387
    
    Discussed-with: dillon

Summary of changes:
 sys/net/if.c         | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 sys/net/if_var.h     |  3 +++
 sys/netinet/in.c     | 18 +++++++++++++
 sys/netinet/in_rmx.c | 27 ++++++++++++--------
 4 files changed, 109 insertions(+), 11 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/951ecd7f55e2edd33258ad6d9593c9f81c92b42e


-- 
DragonFly BSD source repository


More information about the Commits mailing list