On Mon, May 15, 2017 at 03:23:02PM +0200, Martin Pieuchot wrote:
> Kill unused global list of softc and protect the global array of
> interface by the NET_LOCK().
> 
> ok?

OK bluhm@

> 
> Index: net/if_pflog.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_pflog.c,v
> retrieving revision 1.78
> diff -u -p -r1.78 if_pflog.c
> --- net/if_pflog.c    24 Jan 2017 10:08:30 -0000      1.78
> +++ net/if_pflog.c    15 May 2017 13:19:39 -0000
> @@ -83,7 +83,6 @@ int pflog_clone_create(struct if_clone *
>  int  pflog_clone_destroy(struct ifnet *);
>  void pflog_bpfcopy(const void *, void *, size_t);
>  
> -LIST_HEAD(, pflog_softc)     pflogif_list;
>  struct if_clone      pflog_cloner =
>      IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy);
>  
> @@ -94,7 +93,6 @@ struct mbuf  *pflog_mhdr = NULL, *pflog_
>  void
>  pflogattach(int npflog)
>  {
> -     LIST_INIT(&pflogif_list);
>       if (pflog_mhdr == NULL)
>               if ((pflog_mhdr = m_get(M_DONTWAIT, MT_HEADER)) == NULL)
>                       panic("pflogattach: no mbuf");
> @@ -110,6 +108,8 @@ pflogifs_resize(size_t n)
>       struct ifnet    **p;
>       int               i;
>  
> +     NET_ASSERT_LOCKED();
> +
>       if (n > SIZE_MAX / sizeof(*p))
>               return (EINVAL);
>       if (n == 0)
> @@ -161,14 +161,13 @@ pflog_clone_create(struct if_clone *ifc,
>       bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN);
>  #endif
>  
> -     s = splnet();
> -     LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list);
> +     NET_LOCK(s);
>       if (unit + 1 > npflogifs && pflogifs_resize(unit + 1) != 0) {
> -             splx(s);
> +             NET_UNLOCK(s);
>               return (ENOMEM);
>       }
>       pflogifs[unit] = ifp;
> -     splx(s);
> +     NET_UNLOCK(s);
>  
>       return (0);
>  }
> @@ -179,15 +178,13 @@ pflog_clone_destroy(struct ifnet *ifp)
>       struct pflog_softc      *pflogif = ifp->if_softc;
>       int                      s, i;
>  
> -     s = splnet();
> +     NET_LOCK(s);
>       pflogifs[pflogif->sc_unit] = NULL;
> -     LIST_REMOVE(pflogif, sc_list);
> -
>       for (i = npflogifs; i > 0 && pflogifs[i - 1] == NULL; i--)
>               ; /* nothing */
>       if (i < npflogifs)
>               pflogifs_resize(i);     /* error harmless here */
> -     splx(s);
> +     NET_UNLOCK(s);
>  
>       if_detach(ifp);
>       free(pflogif, M_DEVBUF, 0);
> Index: net/if_pflog.h
> ===================================================================
> RCS file: /cvs/src/sys/net/if_pflog.h,v
> retrieving revision 1.26
> diff -u -p -r1.26 if_pflog.h
> --- net/if_pflog.h    12 Feb 2015 01:24:10 -0000      1.26
> +++ net/if_pflog.h    15 May 2017 13:21:13 -0000
> @@ -64,7 +64,6 @@ struct pfloghdr {
>  struct pflog_softc {
>       struct ifnet            sc_if;          /* the interface */
>       int                     sc_unit;
> -     LIST_ENTRY(pflog_softc) sc_list;
>  };
>  
>  #if NPFLOG > 0

Reply via email to