The global group list keeps being protected by the net lock, but calling
into netinet/ip_carp.c:carp_ifgattr_ioctl() still needs the big lock.

Only carp(4) uses group attributes, so this unlocks just a small part of
if_setgroupattribs(), but it also clarifies what is locked and why.

Feedback? OK?

diff --git a/sys/net/if.c b/sys/net/if.c
index 6b13c2800fb..7b5b27b776c 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1910,11 +1910,9 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, 
struct proc *p)
        case SIOCSIFGATTR:
                if ((error = suser(p)) != 0)
                        return (error);
-               KERNEL_LOCK();
                NET_LOCK();
                error = if_setgroupattribs(data);
                NET_UNLOCK();
-               KERNEL_UNLOCK();
                return (error);
        case SIOCGIFCONF:
        case SIOCIFGCLONERS:
@@ -2964,8 +2962,10 @@ if_setgroupattribs(caddr_t data)
 
        ifg->ifg_carp_demoted += demote;
 
+       KERNEL_LOCK();  /* for carp_ifgattr_ioctl() only */
        TAILQ_FOREACH(ifgm, &ifg->ifg_members, ifgm_next)
                ifgm->ifgm_ifp->if_ioctl(ifgm->ifgm_ifp, SIOCSIFGATTR, data);
+       KERNEL_UNLOCK();
 
        return (0);
 }

Reply via email to