I currently cannot access the local IP of an interface on rdomain 1:

Script started on Fri Oct 28 15:02:20 2016
$ doas pfctl -d    
pfctl: pf not enabled  
$ doas ifconfig vether0    
vether0: no such interface  
$ doas ifconfig vether0 rdomain 1    
$ doas ifconfig vether0 inet 192.168.42.2    
$ doas ifconfig vether0    
vether0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> rdomain 1 mtu 1500  
        lladdr fe:e1:ba:d1:73:55  
        index 7 priority 0 llprio 3  
        groups: vether  
        media: Ethernet autoselect  
        status: active  
        inet 192.168.42.2 netmask 0xffffff00 broadcast 192.168.42.255  
$ route -T1 -n show -inet    
Routing tables  

Internet:  
Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface  
192.168.42/24      192.168.42.2       UCn        0        0     -     4 vether0 
192.168.42.2       fe:e1:ba:d1:73:55  UHLl       0        0     -     1 vether0
192.168.42.255     192.168.42.2       UHb        0        0     -     1 vether0 
$ ping -V1 192.168.42.2    
PING 192.168.42.2 (192.168.42.2): 56 data bytes  
^C  
--- 192.168.42.2 ping statistics ---  
4 packets transmitted, 0 packets received, 100.0% packet loss  
$ ^D    

Script done on Fri Oct 28 15:04:16 2016

Connecting to other boxes via routes on rdomain 1 works as usual
(not shown in the script output above).

I tracked the problem to being caused by v1.455 of if.c. It seems
that ifp->if_rdomain == 0 when running the ping above. In this case,
m->m_pkthdr.ph_rtableid should be set back to 1 after the reset
though (as it was before m_resethdr(m)). Shouldn't ifp->if_rdomain
be equal to 1 in this case? If yes, there must be a bug earlier in
the code.

The following diff fixes things for me, but I don't know if
ifp->if_rdomain isn't the one that needs to be fixed:

Index: net/if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.456
diff -u -r1.456 if.c
--- net/if.c    19 Oct 2016 02:05:49 -0000      1.456
+++ net/if.c    28 Oct 2016 13:46:02 -0000
@@ -649,6 +649,7 @@
 if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af)
 {
        struct niqueue *ifq = NULL;
+       u_int rtableid = m->m_pkthdr.ph_rtableid;
 
 #if NBPFILTER > 0
        /*
@@ -667,7 +668,7 @@
 #endif
        m_resethdr(m);
        m->m_pkthdr.ph_ifidx = ifp->if_index;
-       m->m_pkthdr.ph_rtableid = ifp->if_rdomain;
+       m->m_pkthdr.ph_rtableid = rtableid;
 
        ifp->if_opackets++;
        ifp->if_obytes += m->m_pkthdr.len;

Reply via email to