Re: svn commit: r211157 - in head/sys: modules modules/if_carp net netinet netinet6
On 2010.08.11 00:51:51 +, Will Andrews wrote: Author: will Date: Wed Aug 11 00:51:50 2010 New Revision: 211157 URL: http://svn.freebsd.org/changeset/base/211157 Log: Allow carp(4) to be loaded as a kernel module. Follow precedent set by bridge(4), lagg(4) etc. and make use of function pointers and pf_proto_register() to hook carp into the network stack. Yay! Thanks! I'm really looking forward to not having to handle compile kernels when upgrading to 8.2 on all my CARP based systems :-). -- Simon L. Nielsen ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r211157 - in head/sys: modules modules/if_carp net netinet netinet6
On Wed, Aug 11, 2010 at 12:51:51AM +, Will Andrews wrote: Author: will Date: Wed Aug 11 00:51:50 2010 New Revision: 211157 URL: http://svn.freebsd.org/changeset/base/211157 Log: Allow carp(4) to be loaded as a kernel module. Follow precedent set by bridge(4), lagg(4) etc. and make use of function pointers and pf_proto_register() to hook carp into the network stack. Currently, because of the uncertainty about whether the unload path is free of race condition panics, unloads are disallowed by default. Compiling with CARPMOD_CAN_UNLOAD in CFLAGS removes this anti foot shooting measure. Wouldn't it be better to allow unload only if there are no carp(4) interfaces? I'd be glad to destroy my carp interfaces before unloading the module, but recompiling the kernel to unload it? Not so much. -- Pawel Jakub Dawidek http://www.wheelsystems.com p...@freebsd.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! pgp5qhokYFKRK.pgp Description: PGP signature
Re: svn commit: r211157 - in head/sys: modules modules/if_carp net netinet netinet6
Will Andrews wrote: Author: will Date: Wed Aug 11 00:51:50 2010 New Revision: 211157 URL: http://svn.freebsd.org/changeset/base/211157 Log: Allow carp(4) to be loaded as a kernel module. Follow precedent set by bridge(4), lagg(4) etc. and make use of function pointers and pf_proto_register() to hook carp into the network stack. Currently, because of the uncertainty about whether the unload path is free of race condition panics, unloads are disallowed by default. Compiling with CARPMOD_CAN_UNLOAD in CFLAGS removes this anti foot shooting measure. This commit requires IP6PROTOSPACER, introduced in r25. This doesn't compile due to duplicate function pointer definitions (e.g. if_bridge.c and if_ether.c). You should move all the function pointer definitions to net/if.c and add declarations for them to a header instead of a bunch of 'extern' declarations in if_carp.c itself. -- John Baldwin ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r211157 - in head/sys: modules modules/if_carp net netinet netinet6
On Wed, Aug 11, 2010 at 12:36 PM, John Baldwin j...@freebsd.org wrote: This doesn't compile due to duplicate function pointer definitions (e.g. if_bridge.c and if_ether.c). You should move all the function pointer definitions to net/if.c and add declarations for them to a header instead of a bunch of 'extern' declarations in if_carp.c itself. Working on it. --Will. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r211157 - in head/sys: modules modules/if_carp net netinet netinet6
On Wed, 11 Aug 2010, Will Andrews wrote: On Wed, Aug 11, 2010 at 8:34 AM, Pawel Jakub Dawidek p...@freebsd.org wrote: Wouldn't it be better to allow unload only if there are no carp(4) interfaces? I'd be glad to destroy my carp interfaces before unloading the module, but recompiling the kernel to unload it? Not so much. Well, in theory, if_clone_detach() is supposed to do that, and it's called during the unload process prior to NULLing the fp's. But I've been unable to verify whether that is enough to prevent races. In addition only the module, not the kernel needs to be recompiled. Maybe I should add some more blah ... Actually destroying most (cloned) interfaces is not save at the moment. There could be an mbuf in a netisr queue with an ifp to that interface, or just a packet being processed on another PU, so there is more to this entire picture. Assume that the current way and what is under the #ifdef is a temporary thing and that we'll be able to flip the switch in the future. But there's still quite a bit of work into infratructure and details ahead, some of that will come with more VIMAGE/vnet work on network stack teardown, some might be done independently. SeND will have the cleanup/check to allow to unload under #ifdef __noyet__ as well, once it'll hit the tree, but for that the hooks will need proper ND6 locking as well. The point is, it's currently just not 100% save to just unload and we've been very lenient and lazy with that in the past. It's just that times have changed and the races become true more easily so adding new code/features need to be made aware of that or the pile will just grow. Unfortunately adding extra locking for all those things is nothing you'd want either. If you accept the risk for now that's fine but for the majority of our users we'll have to err on the save side, while allowing them to use freebsd-update now if it was only carp they needed (and not say IPSEC as well) and they can just load the module and be happy w/o having to recompile their own kernel. /bz -- Bjoern A. Zeeb This signature is about you not me. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r211157 - in head/sys: modules modules/if_carp net netinet netinet6
Author: will Date: Wed Aug 11 00:51:50 2010 New Revision: 211157 URL: http://svn.freebsd.org/changeset/base/211157 Log: Allow carp(4) to be loaded as a kernel module. Follow precedent set by bridge(4), lagg(4) etc. and make use of function pointers and pf_proto_register() to hook carp into the network stack. Currently, because of the uncertainty about whether the unload path is free of race condition panics, unloads are disallowed by default. Compiling with CARPMOD_CAN_UNLOAD in CFLAGS removes this anti foot shooting measure. This commit requires IP6PROTOSPACER, introduced in r25. Reviewed by: bz, simon Approved by: ken (mentor) MFC after:2 weeks Added: head/sys/modules/if_carp/ head/sys/modules/if_carp/Makefile (contents, props changed) Modified: head/sys/modules/Makefile head/sys/net/if.c head/sys/net/if_bridge.c head/sys/net/if_ethersubr.c head/sys/netinet/if_ether.c head/sys/netinet/in.c head/sys/netinet/in_proto.c head/sys/netinet/ip_carp.c head/sys/netinet/ip_carp.h head/sys/netinet/ip_input.c head/sys/netinet6/in6_proto.c head/sys/netinet6/nd6_nbr.c Modified: head/sys/modules/Makefile == --- head/sys/modules/Makefile Tue Aug 10 22:57:43 2010(r211156) +++ head/sys/modules/Makefile Wed Aug 11 00:51:50 2010(r211157) @@ -112,6 +112,7 @@ SUBDIR= ${_3dfx} \ ${_ida} \ ${_ie} \ if_bridge \ + if_carp \ if_disc \ if_edsc \ if_ef \ Added: head/sys/modules/if_carp/Makefile == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/if_carp/Makefile Wed Aug 11 00:51:50 2010 (r211157) @@ -0,0 +1,21 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../netinet + +.include bsd.own.mk + +KMOD= if_carp +SRCS= ip_carp.c +SRCS+= opt_carp.h opt_bpf.h opt_inet.h opt_inet6.h vnode_if.h + +.if !defined(KERNBUILDDIR) +opt_inet.h: + @echo #define INET 1 ${.TARGET} + +.if ${MK_INET6_SUPPORT} != no +opt_inet6.h: + @echo #define INET6 1 ${.TARGET} +.endif +.endif + +.include bsd.kmod.mk Modified: head/sys/net/if.c == --- head/sys/net/if.c Tue Aug 10 22:57:43 2010(r211156) +++ head/sys/net/if.c Wed Aug 11 00:51:50 2010(r211157) @@ -33,7 +33,6 @@ #include opt_compat.h #include opt_inet6.h #include opt_inet.h -#include opt_carp.h #include opt_ddb.h #include sys/param.h @@ -89,11 +88,6 @@ #ifdef INET #include netinet/if_ether.h #endif -#if defined(INET) || defined(INET6) -#ifdef DEV_CARP -#include netinet/ip_carp.h -#endif -#endif #include security/mac/mac_framework.h @@ -130,6 +124,7 @@ SX_SYSINIT(ifdescr_sx, ifdescr_sx, ifn void (*bstp_linkstate_p)(struct ifnet *ifp, int state); void (*ng_ether_link_state_p)(struct ifnet *ifp, int state); void (*lagg_linkstate_p)(struct ifnet *ifp, int state); +void (*carp_linkstate_p)(struct ifnet *ifp); struct mbuf *(*tbr_dequeue_ptr)(struct ifaltq *, int) = NULL; @@ -1813,12 +1808,8 @@ if_unroute(struct ifnet *ifp, int flag, pfctlinput(PRC_IFDOWN, ifa-ifa_addr); ifp-if_qflush(ifp); -#if defined(INET) || defined(INET6) -#ifdef DEV_CARP if (ifp-if_carp) - carp_carpdev_state(ifp-if_carp); -#endif -#endif + (*carp_linkstate_p)(ifp); rt_ifmsg(ifp); } @@ -1839,12 +1830,8 @@ if_route(struct ifnet *ifp, int flag, in TAILQ_FOREACH(ifa, ifp-if_addrhead, ifa_link) if (fam == PF_UNSPEC || (fam == ifa-ifa_addr-sa_family)) pfctlinput(PRC_IFUP, ifa-ifa_addr); -#if defined(INET) || defined(INET6) -#ifdef DEV_CARP if (ifp-if_carp) - carp_carpdev_state(ifp-if_carp); -#endif -#endif + (*carp_linkstate_p)(ifp); rt_ifmsg(ifp); #ifdef INET6 in6_if_up(ifp); @@ -1887,12 +1874,8 @@ do_link_state_change(void *arg, int pend if ((ifp-if_type == IFT_ETHER || ifp-if_type == IFT_L2VLAN) IFP2AC(ifp)-ac_netgraph != NULL) (*ng_ether_link_state_p)(ifp, link_state); -#if defined(INET) || defined(INET6) -#ifdef DEV_CARP if (ifp-if_carp) - carp_carpdev_state(ifp-if_carp); -#endif -#endif + (*carp_linkstate_p)(ifp); if (ifp-if_bridge) { KASSERT(bstp_linkstate_p != NULL,(if_bridge bstp not loaded!)); (*bstp_linkstate_p)(ifp, link_state); Modified: head/sys/net/if_bridge.c == --- head/sys/net/if_bridge.cTue Aug 10 22:57:43 2010(r211156) +++ head/sys/net/if_bridge.cWed Aug 11 00:51:50 2010(r211157) @@ -79,7 +79,6 @@ __FBSDID($FreeBSD$); #include opt_inet.h #include