Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/ip_carp.c
Show First 20 Lines • Show All 569 Lines • ▼ Show 20 Lines | if (m->m_len < *offp + sizeof(*ch)) { | ||||
len = m->m_len; | len = m->m_len; | ||||
m = m_pullup(m, *offp + sizeof(*ch)); | m = m_pullup(m, *offp + sizeof(*ch)); | ||||
if (m == NULL) { | if (m == NULL) { | ||||
CARPSTATS_INC(carps_badlen); | CARPSTATS_INC(carps_badlen); | ||||
CARP_DEBUG("%s: packet size %u too small\n", __func__, len); | CARP_DEBUG("%s: packet size %u too small\n", __func__, len); | ||||
return (IPPROTO_DONE); | return (IPPROTO_DONE); | ||||
} | } | ||||
} | } | ||||
ch = (struct carp_header *)(mtod(m, caddr_t) + *offp); | ch = (struct carp_header *)(mtod(m, char *) + *offp); | ||||
/* verify the CARP checksum */ | /* verify the CARP checksum */ | ||||
m->m_data += *offp; | m->m_data += *offp; | ||||
if (in_cksum(m, sizeof(*ch))) { | if (in_cksum(m, sizeof(*ch))) { | ||||
CARPSTATS_INC(carps_badsum); | CARPSTATS_INC(carps_badsum); | ||||
CARP_DEBUG("%s: checksum failed, on %s\n", __func__, | CARP_DEBUG("%s: checksum failed, on %s\n", __func__, | ||||
m->m_pkthdr.rcvif->if_xname); | m->m_pkthdr.rcvif->if_xname); | ||||
▲ Show 20 Lines • Show All 386 Lines • ▼ Show 20 Lines | if (sc->sc_naddrs) { | ||||
CARPSTATS_INC(carps_opackets); | CARPSTATS_INC(carps_opackets); | ||||
carp_send_ad_error(sc, ip_output(m, NULL, NULL, IP_RAWOUTPUT, | carp_send_ad_error(sc, ip_output(m, NULL, NULL, IP_RAWOUTPUT, | ||||
&sc->sc_carpdev->if_carp->cif_imo, NULL)); | &sc->sc_carpdev->if_carp->cif_imo, NULL)); | ||||
} | } | ||||
#endif /* INET */ | #endif /* INET */ | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (sc->sc_naddrs6) { | if (sc->sc_naddrs6) { | ||||
struct epoch_tracker et; | |||||
struct ip6_hdr *ip6; | struct ip6_hdr *ip6; | ||||
m = m_gethdr(M_NOWAIT, MT_DATA); | m = m_gethdr(M_NOWAIT, MT_DATA); | ||||
if (m == NULL) { | if (m == NULL) { | ||||
CARPSTATS_INC(carps_onomem); | CARPSTATS_INC(carps_onomem); | ||||
goto resched; | goto resched; | ||||
} | } | ||||
len = sizeof(*ip6) + sizeof(ch); | len = sizeof(*ip6) + sizeof(ch); | ||||
Show All 37 Lines | if (carp_prepare_ad(m, sc, ch_ptr)) | ||||
goto resched; | goto resched; | ||||
m->m_data += sizeof(*ip6); | m->m_data += sizeof(*ip6); | ||||
ch_ptr->carp_cksum = in_cksum(m, len - sizeof(*ip6)); | ch_ptr->carp_cksum = in_cksum(m, len - sizeof(*ip6)); | ||||
m->m_data -= sizeof(*ip6); | m->m_data -= sizeof(*ip6); | ||||
CARPSTATS_INC(carps_opackets6); | CARPSTATS_INC(carps_opackets6); | ||||
NET_EPOCH_ENTER(et); | |||||
carp_send_ad_error(sc, ip6_output(m, NULL, NULL, 0, | carp_send_ad_error(sc, ip6_output(m, NULL, NULL, 0, | ||||
&sc->sc_carpdev->if_carp->cif_im6o, NULL, NULL)); | &sc->sc_carpdev->if_carp->cif_im6o, NULL, NULL)); | ||||
NET_EPOCH_EXIT(et); | |||||
} | } | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
resched: | resched: | ||||
callout_reset(&sc->sc_ad_tmo, tvtohz(&tv), carp_send_ad, sc); | callout_reset(&sc->sc_ad_tmo, tvtohz(&tv), carp_send_ad, sc); | ||||
} | } | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { | ||||
else | else | ||||
ifa_ref(ifa); | ifa_ref(ifa); | ||||
break; | break; | ||||
} | } | ||||
return (ifa); | return (ifa); | ||||
} | } | ||||
caddr_t | char * | ||||
carp_macmatch6(struct ifnet *ifp, struct mbuf *m, const struct in6_addr *taddr) | carp_macmatch6(struct ifnet *ifp, struct mbuf *m, const struct in6_addr *taddr) | ||||
{ | { | ||||
struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
NET_EPOCH_ASSERT(); | NET_EPOCH_ASSERT(); | ||||
IFNET_FOREACH_IFA(ifp, ifa) | IFNET_FOREACH_IFA(ifp, ifa) | ||||
if (ifa->ifa_addr->sa_family == AF_INET6 && | if (ifa->ifa_addr->sa_family == AF_INET6 && | ||||
▲ Show 20 Lines • Show All 640 Lines • ▼ Show 20 Lines | if (carpr.carpr_vhid != 0) { | ||||
break; | break; | ||||
} | } | ||||
i = 0; | i = 0; | ||||
IFNET_FOREACH_CARP(ifp, sc) { | IFNET_FOREACH_CARP(ifp, sc) { | ||||
carp_carprcp(&carpr, sc, priveleged); | carp_carprcp(&carpr, sc, priveleged); | ||||
carpr.carpr_count = count; | carpr.carpr_count = count; | ||||
error = copyout(&carpr, | error = copyout(&carpr, | ||||
(caddr_t)ifr_data_get_ptr(ifr) + | (char *)ifr_data_get_ptr(ifr) + | ||||
(i * sizeof(carpr)), sizeof(carpr)); | (i * sizeof(carpr)), sizeof(carpr)); | ||||
if (error) { | if (error) { | ||||
CIF_UNLOCK(ifp->if_carp); | CIF_UNLOCK(ifp->if_carp); | ||||
break; | break; | ||||
} | } | ||||
i++; | i++; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 442 Lines • Show Last 20 Lines |