Date: Mon, 17 May 2010 10:31:09 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 178379 for review Message-ID: <201005171031.o4HAV9EX099207@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@178379?ac=10 Change 178379 by zec@zec_nxlab on 2010/05/17 10:30:56 Add a global counter of all V_ip_mrouter instances, which we consult when making a decission on wheter or not to allow the module to be kldunloaded. Introduce a global flag which we set when starting to kldunload the module, in order to prevent new V_ip_mrouter sockets to become attached. All of this is completely untested. Affected files ... .. //depot/projects/vimage/src/sys/netinet/ip_mroute.c#34 edit Differences ... ==== //depot/projects/vimage/src/sys/netinet/ip_mroute.c#34 (text+ko) ==== @@ -142,6 +142,9 @@ mtx_init(&mrouter_mtx, "IPv4 multicast forwarding", NULL, MTX_DEF) #define MROUTER_LOCK_DESTROY() mtx_destroy(&mrouter_mtx) +static int ip_mrouter_cnt; /* # of vnets with active mrouters */ +static int ip_mrouter_unloading; /* Allow no more V_ip_mrouter sockets */ + static VNET_DEFINE(struct mrtstat, mrtstat); #define V_mrtstat VNET(mrtstat) SYSCTL_VNET_STRUCT(_net_inet_ip, OID_AUTO, mrtstat, CTLFLAG_RW, @@ -673,6 +676,11 @@ MROUTER_LOCK(); + if (ip_mrouter_unloading) { + MROUTER_UNLOCK(); + return ENOPROTOOPT; + } + if (V_ip_mrouter != NULL) { MROUTER_UNLOCK(); return EADDRINUSE; @@ -694,6 +702,7 @@ callout_reset(&bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, curvnet); V_ip_mrouter = so; + ip_mrouter_cnt++; MROUTER_UNLOCK(); @@ -724,6 +733,7 @@ * Detach/disable hooks to the reset of the system. */ V_ip_mrouter = NULL; + ip_mrouter_cnt--; mrt_api_config = 0; VIF_LOCK(); @@ -2890,8 +2900,13 @@ * just loaded and then unloaded w/o starting up a user * process we still need to cleanup. */ - if (V_ip_mrouter != NULL) + MROUTER_LOCK(); + if (ip_mrouter_cnt != 0) { + MROUTER_UNLOCK(); return (EINVAL); + } + ip_mrouter_unloading = 1; + MROUTER_UNLOCK(); if (pim_encap_cookie) { encap_detach(pim_encap_cookie);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005171031.o4HAV9EX099207>