Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_carp.c
Show First 20 Lines • Show All 1,365 Lines • ▼ Show 20 Lines | carp_multicast_setup(struct carp_if *cif, sa_family_t sa) | ||||
struct ifnet *ifp = cif->cif_ifp; | struct ifnet *ifp = cif->cif_ifp; | ||||
int error = 0; | int error = 0; | ||||
switch (sa) { | switch (sa) { | ||||
#ifdef INET | #ifdef INET | ||||
case AF_INET: | case AF_INET: | ||||
{ | { | ||||
struct ip_moptions *imo = &cif->cif_imo; | struct ip_moptions *imo = &cif->cif_imo; | ||||
struct in_mfilter *imf; | |||||
struct in_addr addr; | struct in_addr addr; | ||||
if (imo->imo_membership) | if (ip_first_mfilter(&imo->imo_head) != NULL) | ||||
return (0); | return (0); | ||||
imo->imo_membership = (struct in_multi **)malloc( | imf = ip_alloc_mfilter(M_WAITOK, 0, 0); | ||||
(sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_CARP, | STAILQ_INIT(&imo->imo_head); | ||||
M_WAITOK); | |||||
imo->imo_mfilters = NULL; | |||||
imo->imo_max_memberships = IP_MIN_MEMBERSHIPS; | |||||
imo->imo_multicast_vif = -1; | imo->imo_multicast_vif = -1; | ||||
addr.s_addr = htonl(INADDR_CARP_GROUP); | addr.s_addr = htonl(INADDR_CARP_GROUP); | ||||
if ((error = in_joingroup(ifp, &addr, NULL, | if ((error = in_joingroup(ifp, &addr, NULL, | ||||
&imo->imo_membership[0])) != 0) { | &imf->imf_inm)) != 0) { | ||||
free(imo->imo_membership, M_CARP); | ip_free_mfilter(imf); | ||||
break; | break; | ||||
} | } | ||||
imo->imo_num_memberships++; | |||||
ip_insert_mfilter(&imo->imo_head, imf); | |||||
imo->imo_multicast_ifp = ifp; | imo->imo_multicast_ifp = ifp; | ||||
imo->imo_multicast_ttl = CARP_DFLTTL; | imo->imo_multicast_ttl = CARP_DFLTTL; | ||||
imo->imo_multicast_loop = 0; | imo->imo_multicast_loop = 0; | ||||
break; | break; | ||||
} | } | ||||
#endif | #endif | ||||
#ifdef INET6 | #ifdef INET6 | ||||
case AF_INET6: | case AF_INET6: | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | carp_multicast_cleanup(struct carp_if *cif, sa_family_t sa) | ||||
sx_assert(&carp_sx, SA_XLOCKED); | sx_assert(&carp_sx, SA_XLOCKED); | ||||
switch (sa) { | switch (sa) { | ||||
#ifdef INET | #ifdef INET | ||||
case AF_INET: | case AF_INET: | ||||
if (cif->cif_naddrs == 0) { | if (cif->cif_naddrs == 0) { | ||||
struct ip_moptions *imo = &cif->cif_imo; | struct ip_moptions *imo = &cif->cif_imo; | ||||
struct in_mfilter *imf; | |||||
in_leavegroup(imo->imo_membership[0], NULL); | imf = ip_first_mfilter(&imo->imo_head); | ||||
KASSERT(imo->imo_mfilters == NULL, | |||||
("%s: imo_mfilters != NULL", __func__)); | |||||
free(imo->imo_membership, M_CARP); | |||||
imo->imo_membership = NULL; | |||||
KASSERT(imf != NULL, | |||||
("%s: first filter is NULL", __func__)); | |||||
ip_remove_mfilter(&imo->imo_head, imf); | |||||
in_leavegroup(imf->imf_inm, NULL); | |||||
ip_free_mfilter(imf); | |||||
markj: This line is too long, ditto below. | |||||
} | } | ||||
break; | break; | ||||
#endif | #endif | ||||
#ifdef INET6 | #ifdef INET6 | ||||
case AF_INET6: | case AF_INET6: | ||||
if (cif->cif_naddrs6 == 0) { | if (cif->cif_naddrs6 == 0) { | ||||
struct ip6_moptions *im6o = &cif->cif_im6o; | struct ip6_moptions *im6o = &cif->cif_im6o; | ||||
▲ Show 20 Lines • Show All 827 Lines • Show Last 20 Lines |
This line is too long, ditto below.