diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -82,7 +82,6 @@ #include #include #include -#include #include @@ -448,7 +447,6 @@ void ip_input(struct mbuf *m) { - MROUTER_RLOCK_TRACKER; struct ip *ip = NULL; struct in_ifaddr *ia = NULL; struct ifaddr *ifa; @@ -744,7 +742,6 @@ ia = NULL; } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { - MROUTER_RLOCK(); /* * RFC 3927 2.7: Do not forward multicast packets from * IN_LINKLOCAL. @@ -759,7 +756,6 @@ * must be discarded, else it may be accepted below. */ if (ip_mforward && ip_mforward(ip, ifp, m, 0) != 0) { - MROUTER_RUNLOCK(); IPSTAT_INC(ips_cantforward); m_freem(m); return; @@ -771,12 +767,10 @@ * host belongs to their destination groups. */ if (ip->ip_p == IPPROTO_IGMP) { - MROUTER_RUNLOCK(); goto ours; } IPSTAT_INC(ips_forward); } - MROUTER_RUNLOCK(); /* * Assume the packet is for us, to avoid prematurely taking * a lock on the in_multi hash. Protocols must perform diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h --- a/sys/netinet/ip_mroute.h +++ b/sys/netinet/ip_mroute.h @@ -363,16 +363,9 @@ extern int (*ip_mrouter_set)(struct socket *, struct sockopt *); extern int (*ip_mrouter_get)(struct socket *, struct sockopt *); -extern int (*ip_mrouter_done)(void *); +extern int (*ip_mrouter_done)(void); extern int (*mrt_ioctl)(u_long, caddr_t, int); -#define MROUTER_RLOCK_TRACKER struct epoch_tracker mrouter_et -#define MROUTER_RLOCK_PARAM_PTR &mrouter_et -#define MROUTER_RLOCK() epoch_enter_preempt(net_epoch_preempt, &mrouter_et) -#define MROUTER_RUNLOCK() epoch_exit_preempt(net_epoch_preempt, &mrouter_et) -#define MROUTER_RUNLOCK_PARAM(param) epoch_exit_preempt(net_epoch_preempt, param) -#define MROUTER_WAIT() epoch_wait_preempt(net_epoch_preempt) - #endif /* _KERNEL */ #endif /* _NETINET_IP_MROUTE_H_ */ diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -300,7 +300,7 @@ static u_long X_ip_mcast_src(int); static int X_ip_mforward(struct ip *, struct ifnet *, struct mbuf *, struct ip_moptions *); -static int X_ip_mrouter_done(void *); +static int X_ip_mrouter_done(void); static int X_ip_mrouter_get(struct socket *, struct sockopt *); static int X_ip_mrouter_set(struct socket *, struct sockopt *); static int X_legal_vif_num(int); @@ -431,7 +431,7 @@ break; case MRT_DONE: - error = ip_mrouter_done(NULL); + error = ip_mrouter_done(); break; case MRT_ADD_VIF: @@ -734,20 +734,15 @@ * Disable multicast forwarding. */ static int -X_ip_mrouter_done(void *locked) +X_ip_mrouter_done(void) { struct ifnet *ifp; u_long i; vifi_t vifi; struct bw_upcall *bu; - if (V_ip_mrouter == NULL) { - if (locked) { - struct epoch_tracker *mrouter_et = locked; - MROUTER_RUNLOCK_PARAM(mrouter_et); - } - return EINVAL; - } + if (V_ip_mrouter == NULL) + return (EINVAL); /* * Detach/disable hooks to the reset of the system. @@ -756,12 +751,11 @@ atomic_subtract_int(&ip_mrouter_cnt, 1); V_mrt_api_config = 0; - if (locked) { - struct epoch_tracker *mrouter_et = locked; - MROUTER_RUNLOCK_PARAM(mrouter_et); - } - - MROUTER_WAIT(); + /* + * Wait for all epoch sections to complete to ensure + * V_ip_mrouter = NULL is visible to others. + */ + epoch_wait_preempt(net_epoch_preempt); /* Stop and drain task queue */ taskqueue_block(V_task_queue); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -82,7 +82,6 @@ #include #include #include -#include #include #include @@ -321,7 +320,6 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, struct ip_moptions *imo, struct inpcb *inp) { - MROUTER_RLOCK_TRACKER; struct ip *ip; struct ifnet *ifp = NULL; /* keep compiler happy */ struct mbuf *m0; @@ -609,7 +607,6 @@ * above, will be forwarded by the ip_input() routine, * if necessary. */ - MROUTER_RLOCK(); if (V_ip_mrouter && (flags & IP_FORWARDING) == 0) { /* * If rsvp daemon is not running, do not @@ -621,12 +618,10 @@ imo = NULL; if (ip_mforward && ip_mforward(ip, ifp, m, imo) != 0) { - MROUTER_RUNLOCK(); m_freem(m); goto done; } } - MROUTER_RUNLOCK(); } /* diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -119,7 +119,7 @@ */ int (*ip_mrouter_set)(struct socket *, struct sockopt *); int (*ip_mrouter_get)(struct socket *, struct sockopt *); -int (*ip_mrouter_done)(void *locked); +int (*ip_mrouter_done)(void); int (*ip_mforward)(struct ip *, struct ifnet *, struct mbuf *, struct ip_moptions *); int (*mrt_ioctl)(u_long, caddr_t, int); @@ -879,19 +879,15 @@ rip_detach(struct socket *so) { struct inpcb *inp; - MROUTER_RLOCK_TRACKER; inp = sotoinpcb(so); KASSERT(inp != NULL, ("rip_detach: inp == NULL")); KASSERT(inp->inp_faddr.s_addr == INADDR_ANY, ("rip_detach: not closed")); - /* Disable mrouter first, lock released inside ip_mrouter_done */ - MROUTER_RLOCK(); + /* Disable mrouter first */ if (so == V_ip_mrouter && ip_mrouter_done) - ip_mrouter_done(MROUTER_RLOCK_PARAM_PTR); - else - MROUTER_RUNLOCK(); + ip_mrouter_done(); INP_WLOCK(inp); INP_HASH_WLOCK(&V_ripcbinfo);