| 536 | |
| 537 | #ifdef INET6 |
| 538 | int |
| 539 | carp6_input(struct mbuf **mp, int *offp, int proto) |
| 540 | { |
| 541 | struct mbuf *m = *mp; |
| 542 | struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); |
| 543 | struct carp_header *ch; |
| 544 | u_int len; |
| 545 | |
| 546 | CARPSTATS_INC(carps_ipackets6); |
| 547 | |
| 548 | if (!V_carp_allow) { |
| 549 | m_freem(m); |
| 550 | return (IPPROTO_DONE); |
| 551 | } |
| 552 | |
| 553 | /* check if received on a valid carp interface */ |
| 554 | if (m->m_pkthdr.rcvif->if_carp == NULL) { |
| 555 | CARPSTATS_INC(carps_badif); |
| 556 | CARP_DEBUG("%s: packet received on non-carp interface: %s\n", |
| 557 | __func__, m->m_pkthdr.rcvif->if_xname); |
| 558 | m_freem(m); |
| 559 | return (IPPROTO_DONE); |
| 560 | } |
| 561 | |
| 562 | /* verify that the IP TTL is 255 */ |
| 563 | if (ip6->ip6_hlim != CARP_DFLTTL) { |
| 564 | CARPSTATS_INC(carps_badttl); |
| 565 | CARP_DEBUG("%s: received ttl %d != 255 on %s\n", __func__, |
| 566 | ip6->ip6_hlim, m->m_pkthdr.rcvif->if_xname); |
| 567 | m_freem(m); |
| 568 | return (IPPROTO_DONE); |
| 569 | } |
| 570 | |
| 571 | /* verify that we have a complete carp packet */ |
| 572 | if (m->m_len < *offp + sizeof(*ch)) { |
| 573 | len = m->m_len; |
| 574 | m = m_pullup(m, *offp + sizeof(*ch)); |
| 575 | if (m == NULL) { |
| 576 | CARPSTATS_INC(carps_badlen); |
| 577 | CARP_DEBUG("%s: packet size %u too small\n", __func__, len); |
| 578 | return (IPPROTO_DONE); |
| 579 | } |
| 580 | } |
| 581 | ch = (struct carp_header *)(mtod(m, char *) + *offp); |
| 582 | |
| 583 | /* verify the CARP checksum */ |
| 584 | m->m_data += *offp; |
| 585 | if (in_cksum(m, sizeof(*ch))) { |
| 586 | CARPSTATS_INC(carps_badsum); |
| 587 | CARP_DEBUG("%s: checksum failed, on %s\n", __func__, |
| 588 | m->m_pkthdr.rcvif->if_xname); |
| 589 | m_freem(m); |
| 590 | return (IPPROTO_DONE); |
| 591 | } |
| 592 | m->m_data -= *offp; |
| 593 | |
| 594 | carp_input_c(m, ch, AF_INET6); |
| 595 | return (IPPROTO_DONE); |
nothing calls this directly
no test coverage detected