Re: vether(4): move `ifnet' out of KERNEL_LOCK()

2020-08-08 Thread Klemens Nanni
On Sun, Aug 09, 2020 at 03:16:50AM +0300, Vitaliy Makkoveev wrote:
> vether(4) is pretty dummy. Nothing denies it to be `IFXF_MPSAFE'.
OK kn



vether(4): move `ifnet' out of KERNEL_LOCK()

2020-08-08 Thread Vitaliy Makkoveev
vether(4) is pretty dummy. Nothing denies it to be `IFXF_MPSAFE'.

Index: sys/net/if_vether.c
===
RCS file: /cvs/src/sys/net/if_vether.c,v
retrieving revision 1.33
diff -u -p -r1.33 if_vether.c
--- sys/net/if_vether.c 28 Jul 2020 09:52:32 -  1.33
+++ sys/net/if_vether.c 9 Aug 2020 00:13:17 -
@@ -36,7 +36,7 @@
 
 void   vetherattach(int);
 intvetherioctl(struct ifnet *, u_long, caddr_t);
-void   vetherstart(struct ifnet *);
+void   vetherqstart(struct ifqueue *);
 intvether_clone_create(struct if_clone *, int);
 intvether_clone_destroy(struct ifnet *);
 intvether_media_change(struct ifnet *);
@@ -83,12 +83,12 @@ vether_clone_create(struct if_clone *ifc
 
ifp->if_softc = sc;
ifp->if_ioctl = vetherioctl;
-   ifp->if_start = vetherstart;
+   ifp->if_qstart = vetherqstart;
ifq_set_maxlen(>if_snd, IFQ_MAXLEN);
 
ifp->if_hardmtu = ETHER_MAX_HARDMTU_LEN;
ifp->if_capabilities = IFCAP_VLAN_MTU;
-   ifp->if_xflags = IFXF_CLONED;
+   ifp->if_xflags = IFXF_CLONED | IFXF_MPSAFE;
 
ifmedia_init(>sc_media, 0, vether_media_change,
vether_media_status);
@@ -117,15 +117,12 @@ vether_clone_destroy(struct ifnet *ifp)
  * and we only need to discard the packets.
  */
 void
-vetherstart(struct ifnet *ifp)
+vetherqstart(struct ifqueue *ifq)
 {
+   struct ifnet*ifp = ifq->ifq_if;
struct mbuf *m;
 
-   for (;;) {
-   m = ifq_dequeue(>if_snd);
-   if (m == NULL)
-   return;
-
+   while ((m = ifq_dequeue(ifq)) != NULL) {
 #if NBPFILTER > 0
if (ifp->if_bpf)
bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);