On Mon, May 15, 2017 at 03:06:08PM +0200, Martin Pieuchot wrote:
> They all need to be audited and possibly changed to a solution that work
> with the NET_LOCK(). Just saying, enc(4) is a nightmare.
>
> Here's a diff fro gre(4). The 'softnet' iterates over ``gre_softc_list''
> so we need to make sure it isn't modified when this happen. We need the
> NET_LOCK() were splnet() was used.
>
> ok?
OK bluhm@
>
> Index: net/if_gre.c
> ===
> RCS file: /cvs/src/sys/net/if_gre.c,v
> retrieving revision 1.84
> diff -u -p -r1.84 if_gre.c
> --- net/if_gre.c 24 Jan 2017 10:08:30 - 1.84
> +++ net/if_gre.c 15 May 2017 12:45:25 -
> @@ -165,9 +165,9 @@ gre_clone_create(struct if_clone *ifc, i
> #if NBPFILTER > 0
> bpfattach(>sc_if.if_bpf, >sc_if, DLT_LOOP, sizeof(u_int32_t));
> #endif
> - s = splnet();
> + NET_LOCK(s);
> LIST_INSERT_HEAD(_softc_list, sc, sc_list);
> - splx(s);
> + NET_UNLOCK(s);
>
> return (0);
> }
> @@ -178,11 +178,11 @@ gre_clone_destroy(struct ifnet *ifp)
> struct gre_softc *sc = ifp->if_softc;
> int s;
>
> - s = splnet();
> timeout_del(>sc_ka_snd);
> timeout_del(>sc_ka_hold);
> + NET_LOCK(s);
> LIST_REMOVE(sc, sc_list);
> - splx(s);
> + NET_UNLOCK(s);
>
> if_detach(ifp);
>