On Sun, May 28, 2017 at 11:09:39AM +0200, Martin Pieuchot wrote:
> - if_deactivate() needs the NET_LOCK() for carp_ifdetach().  splnet() is
>   not need here since if_deactivate() deals with pseudo-interface hooks.
>  
> - carp_clone_destroy() needs to grab the NET_LOCK().
> 
> In both cases we want to protect the list of joined IP multicast groups.
> This list is accessed in the packet processing path.
> 
> ok?

OK bluhm@

> 
> Index: net/if.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.497
> diff -u -p -r1.497 if.c
> --- net/if.c  16 May 2017 12:24:01 -0000      1.497
> +++ net/if.c  28 May 2017 09:02:21 -0000
> @@ -977,8 +977,7 @@ if_deactivate(struct ifnet *ifp)
>  {
>       int s;
>  
> -     s = splnet();
> -
> +     NET_LOCK(s);
>       /*
>        * Call detach hooks from head to tail.  To make sure detach
>        * hooks are executed in the reverse order they were added, all
> @@ -991,8 +990,7 @@ if_deactivate(struct ifnet *ifp)
>       if (ifp->if_carp && ifp->if_type != IFT_CARP)
>               carp_ifdetach(ifp);
>  #endif
> -
> -     splx(s);
> +     NET_UNLOCK(s);
>  }
>  
>  /*
> Index: netinet/ip_carp.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_carp.c,v
> retrieving revision 1.310
> diff -u -p -r1.310 ip_carp.c
> --- netinet/ip_carp.c 27 May 2017 21:55:52 -0000      1.310
> +++ netinet/ip_carp.c 28 May 2017 09:05:47 -0000
> @@ -870,8 +870,12 @@ int
>  carp_clone_destroy(struct ifnet *ifp)
>  {
>       struct carp_softc *sc = ifp->if_softc;
> +     int s;
>  
> +     NET_LOCK(s);
>       carpdetach(sc);
> +     NET_UNLOCK(s);
> +
>       ether_ifdetach(ifp);
>       if_detach(ifp);
>       carp_destroy_vhosts(ifp->if_softc);

Reply via email to