Re: tun(4) and if_input()

2015-05-31 Thread Norman Golisz
On Thu May 28 2015 11:28, Martin Pieuchot wrote:
 Replace the last ether_input_mbuf() by if_input().

Successfully tested with OpenVPN.



Re: tun(4) and if_input()

2015-05-30 Thread mxb

Don’t have tun(4), but applied.
As well as latest carp and bridge patches.
So far no problems, except that I see following in dmesg :

arpresolve: unresolved and rt_expire == 0

but this is probably not related to new diffs.

//mxb

 On 28 maj 2015, at 11:28, Martin Pieuchot m...@openbsd.org wrote:
 
 Replace the last ether_input_mbuf() by if_input().
 
 Index: net/if_tun.c
 ===
 RCS file: /cvs/src/sys/net/if_tun.c,v
 retrieving revision 1.144
 diff -u -p -r1.144 if_tun.c
 --- net/if_tun.c  26 May 2015 11:36:26 -  1.144
 +++ net/if_tun.c  28 May 2015 09:25:52 -
 @@ -871,32 +871,34 @@ tunwrite(dev_t dev, struct uio *uio, int
   }
 
   top-m_pkthdr.len = tlen;
 - top-m_pkthdr.rcvif = ifp;
 -
 -#if NBPFILTER  0
 - if (ifp-if_bpf) {
 - s = splnet();
 - bpf_mtap(ifp-if_bpf, top, BPF_DIRECTION_IN);
 - splx(s);
 - }
 -#endif
 
   if (tp-tun_flags  TUN_LAYER2) {
 + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
 +
 + ml_enqueue(ml, top);
   s = splnet();
 - ether_input_mbuf(ifp, top);
 + if_input(ifp, ml);
   splx(s);
 -
   ifp-if_ipackets++;
 
   return (0);
   }
 
 +#if NBPFILTER  0
 + if (ifp-if_bpf) {
 + s = splnet();
 + bpf_mtap(ifp-if_bpf, top, BPF_DIRECTION_IN);
 + splx(s);
 + }
 +#endif
 +
   th = mtod(top, u_int32_t *);
   /* strip the tunnel header */
   top-m_data += sizeof(*th);
   top-m_len  -= sizeof(*th);
   top-m_pkthdr.len -= sizeof(*th);
   top-m_pkthdr.ph_rtableid = ifp-if_rdomain;
 + top-m_pkthdr.rcvif = ifp;
 
   switch (ntohl(*th)) {
   case AF_INET:
 




tun(4) and if_input()

2015-05-28 Thread Martin Pieuchot
Replace the last ether_input_mbuf() by if_input().

Index: net/if_tun.c
===
RCS file: /cvs/src/sys/net/if_tun.c,v
retrieving revision 1.144
diff -u -p -r1.144 if_tun.c
--- net/if_tun.c26 May 2015 11:36:26 -  1.144
+++ net/if_tun.c28 May 2015 09:25:52 -
@@ -871,32 +871,34 @@ tunwrite(dev_t dev, struct uio *uio, int
}
 
top-m_pkthdr.len = tlen;
-   top-m_pkthdr.rcvif = ifp;
-
-#if NBPFILTER  0
-   if (ifp-if_bpf) {
-   s = splnet();
-   bpf_mtap(ifp-if_bpf, top, BPF_DIRECTION_IN);
-   splx(s);
-   }
-#endif
 
if (tp-tun_flags  TUN_LAYER2) {
+   struct mbuf_list ml = MBUF_LIST_INITIALIZER();
+
+   ml_enqueue(ml, top);
s = splnet();
-   ether_input_mbuf(ifp, top);
+   if_input(ifp, ml);
splx(s);
-
ifp-if_ipackets++;
 
return (0);
}
 
+#if NBPFILTER  0
+   if (ifp-if_bpf) {
+   s = splnet();
+   bpf_mtap(ifp-if_bpf, top, BPF_DIRECTION_IN);
+   splx(s);
+   }
+#endif
+
th = mtod(top, u_int32_t *);
/* strip the tunnel header */
top-m_data += sizeof(*th);
top-m_len  -= sizeof(*th);
top-m_pkthdr.len -= sizeof(*th);
top-m_pkthdr.ph_rtableid = ifp-if_rdomain;
+   top-m_pkthdr.rcvif = ifp;
 
switch (ntohl(*th)) {
case AF_INET: