Re: ppp vs splnet()

2017-05-27 Thread Alexandr Nedvedicky
Hello,

this looks good to me too.

OK sashan@

On Fri, May 26, 2017 at 04:22:29PM +0200, Martin Pieuchot wrote:
> The global list of softc is used in the input path and need to be
> protected by the NET_LOCK().
> 
> ok?
> 



ppp vs splnet()

2017-05-26 Thread Martin Pieuchot
The global list of softc is used in the input path and need to be
protected by the NET_LOCK().

ok?

Index: net/if_ppp.c
===
RCS file: /cvs/src/sys/net/if_ppp.c,v
retrieving revision 1.106
diff -u -p -r1.106 if_ppp.c
--- net/if_ppp.c16 May 2017 12:24:01 -  1.106
+++ net/if_ppp.c26 May 2017 14:21:28 -
@@ -230,9 +230,9 @@ ppp_clone_create(struct if_clone *ifc, i
 #if NBPFILTER > 0
bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
 #endif
-   s = splnet();
+   NET_LOCK(s);
LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_list);
-   splx(s);
+   NET_UNLOCK(s);
 
return (0);
 }
@@ -246,9 +246,9 @@ ppp_clone_destroy(struct ifnet *ifp)
if (sc->sc_devp != NULL)
return (EBUSY);
 
-   s = splnet();
+   NET_LOCK(s);
LIST_REMOVE(sc, sc_list);
-   splx(s);
+   NET_UNLOCK(s);
 
if_detach(ifp);
 
@@ -262,12 +262,14 @@ ppp_clone_destroy(struct ifnet *ifp)
 struct ppp_softc *
 pppalloc(pid_t pid)
 {
-   int i;
+   int i, s;
struct ppp_softc *sc;
 
+   NET_LOCK(s);
LIST_FOREACH(sc, &ppp_softc_list, sc_list) {
if (sc->sc_xfer == pid) {
sc->sc_xfer = 0;
+   NET_UNLOCK(s);
return sc;
}
}
@@ -275,6 +277,7 @@ pppalloc(pid_t pid)
if (sc->sc_devp == NULL)
break;
}
+   NET_UNLOCK(s);
if (sc == NULL)
return NULL;