From 99af9c6710185ee143a630c7808df75eaf140934 Mon Sep 17 00:00:00 2001 From: will Date: Mon, 6 Sep 2010 21:06:06 +0000 Subject: Fix CARP in backup mode by properly registering its hooks for INET and INET6 using ipproto_{un,}register() and the newly created ip6proto_{un,}register() so that it can again receive IPPROTO_CARP packets allowing its state machine to work. Reviewed by: bz Approved by: ken (mentor) --- sys/netinet/ip_carp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sys') diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 08c3257..569f6b3 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -2313,6 +2313,7 @@ carp_mod_cleanup(void) if_clone_detach(&carp_cloner); #ifdef INET if (proto_reg[CARP_INET] == 0) { + (void)ipproto_unregister(IPPROTO_CARP); pf_proto_unregister(PF_INET, IPPROTO_CARP, SOCK_RAW); proto_reg[CARP_INET] = -1; } @@ -2320,6 +2321,7 @@ carp_mod_cleanup(void) #endif #ifdef INET6 if (proto_reg[CARP_INET6] == 0) { + (void)ip6proto_unregister(IPPROTO_CARP); pf_proto_unregister(PF_INET6, IPPROTO_CARP, SOCK_RAW); proto_reg[CARP_INET6] = -1; } @@ -2335,6 +2337,7 @@ carp_mod_cleanup(void) static int carp_mod_load(void) { + int err; if_detach_event_tag = EVENTHANDLER_REGISTER(ifnet_departure_event, carp_ifdetach, NULL, EVENTHANDLER_PRI_ANY); @@ -2357,6 +2360,12 @@ carp_mod_load(void) carp_mod_cleanup(); return (EINVAL); } + err = ip6proto_register(IPPROTO_CARP); + if (err) { + printf("carp: error %d registering with INET6\n", err); + carp_mod_cleanup(); + return (EINVAL); + } #endif #ifdef INET carp_iamatch_p = carp_iamatch; @@ -2367,6 +2376,12 @@ carp_mod_load(void) carp_mod_cleanup(); return (EINVAL); } + err = ipproto_register(IPPROTO_CARP); + if (err) { + printf("carp: error %d registering with INET\n", err); + carp_mod_cleanup(); + return (EINVAL); + } #endif return 0; } -- cgit v1.1