Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F159680068
D34030.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D34030.diff
View Options
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 <machine/in_cksum.h>
#include <netinet/ip_carp.h>
#include <netinet/in_rss.h>
-#include <netinet/ip_mroute.h>
#include <netipsec/ipsec_support.h>
@@ -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 <netinet/in_var.h>
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
-#include <netinet/ip_mroute.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
@@ -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);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jun 18, 12:37 AM (8 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34038213
Default Alt Text
D34030.diff (5 KB)
Attached To
Mode
D34030: ip_mroute: refactor epoch-based locking
Attached
Detach File
Event Timeline
Log In to Comment