MCPcopy Create free account
hub / github.com/F-Stack/f-stack / carp_mod_load

Function carp_mod_load

freebsd/netinet/ip_carp.c:2232–2284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2230}
2231
2232static int
2233carp_mod_load(void)
2234{
2235 int err;
2236
2237 mtx_init(&carp_mtx, "carp_mtx", NULL, MTX_DEF);
2238 sx_init(&carp_sx, "carp_sx");
2239 LIST_INIT(&carp_list);
2240 carp_get_vhid_p = carp_get_vhid;
2241 carp_forus_p = carp_forus;
2242 carp_output_p = carp_output;
2243 carp_linkstate_p = carp_linkstate;
2244 carp_ioctl_p = carp_ioctl;
2245 carp_attach_p = carp_attach;
2246 carp_detach_p = carp_detach;
2247 carp_demote_adj_p = carp_demote_adj;
2248 carp_master_p = carp_master;
2249#ifdef INET6
2250 carp_iamatch6_p = carp_iamatch6;
2251 carp_macmatch6_p = carp_macmatch6;
2252 proto_reg[CARP_INET6] = pf_proto_register(PF_INET6,
2253 (struct protosw *)&in6_carp_protosw);
2254 if (proto_reg[CARP_INET6]) {
2255 printf("carp: error %d attaching to PF_INET6\n",
2256 proto_reg[CARP_INET6]);
2257 carp_mod_cleanup();
2258 return (proto_reg[CARP_INET6]);
2259 }
2260 err = ip6proto_register(IPPROTO_CARP);
2261 if (err) {
2262 printf("carp: error %d registering with INET6\n", err);
2263 carp_mod_cleanup();
2264 return (err);
2265 }
2266#endif
2267#ifdef INET
2268 carp_iamatch_p = carp_iamatch;
2269 proto_reg[CARP_INET] = pf_proto_register(PF_INET, &in_carp_protosw);
2270 if (proto_reg[CARP_INET]) {
2271 printf("carp: error %d attaching to PF_INET\n",
2272 proto_reg[CARP_INET]);
2273 carp_mod_cleanup();
2274 return (proto_reg[CARP_INET]);
2275 }
2276 err = ipproto_register(IPPROTO_CARP);
2277 if (err) {
2278 printf("carp: error %d registering with INET\n", err);
2279 carp_mod_cleanup();
2280 return (err);
2281 }
2282#endif
2283 return (0);
2284}
2285
2286static int
2287carp_modevent(module_t mod, int type, void *data)

Callers 1

carp_modeventFunction · 0.85

Calls 6

mtx_initFunction · 0.85
pf_proto_registerFunction · 0.85
carp_mod_cleanupFunction · 0.85
ip6proto_registerFunction · 0.85
ipproto_registerFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected