* Process a received MLDv1 general or address-specific query. * Assumes that the query header has been pulled up to sizeof(mld_hdr). * * NOTE: Can't be fully const correct as we temporarily embed scope ID in * mld_addr. This is OK as we own the mbuf chain. */
| 634 | * mld_addr. This is OK as we own the mbuf chain. |
| 635 | */ |
| 636 | static int |
| 637 | mld_v1_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6, |
| 638 | /*const*/ struct mld_hdr *mld) |
| 639 | { |
| 640 | struct ifmultiaddr *ifma; |
| 641 | struct mld_ifsoftc *mli; |
| 642 | struct in6_multi *inm; |
| 643 | int is_general_query; |
| 644 | uint16_t timer; |
| 645 | #ifdef KTR |
| 646 | char ip6tbuf[INET6_ADDRSTRLEN]; |
| 647 | #endif |
| 648 | |
| 649 | NET_EPOCH_ASSERT(); |
| 650 | |
| 651 | is_general_query = 0; |
| 652 | |
| 653 | if (!mld_v1enable) { |
| 654 | CTR3(KTR_MLD, "ignore v1 query %s on ifp %p(%s)", |
| 655 | ip6_sprintf(ip6tbuf, &mld->mld_addr), |
| 656 | ifp, if_name(ifp)); |
| 657 | return (0); |
| 658 | } |
| 659 | |
| 660 | /* |
| 661 | * RFC3810 Section 6.2: MLD queries must originate from |
| 662 | * a router's link-local address. |
| 663 | */ |
| 664 | if (!IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_src)) { |
| 665 | CTR3(KTR_MLD, "ignore v1 query src %s on ifp %p(%s)", |
| 666 | ip6_sprintf(ip6tbuf, &ip6->ip6_src), |
| 667 | ifp, if_name(ifp)); |
| 668 | return (0); |
| 669 | } |
| 670 | |
| 671 | /* |
| 672 | * Do address field validation upfront before we accept |
| 673 | * the query. |
| 674 | */ |
| 675 | if (IN6_IS_ADDR_UNSPECIFIED(&mld->mld_addr)) { |
| 676 | /* |
| 677 | * MLDv1 General Query. |
| 678 | * If this was not sent to the all-nodes group, ignore it. |
| 679 | */ |
| 680 | struct in6_addr dst; |
| 681 | |
| 682 | dst = ip6->ip6_dst; |
| 683 | in6_clearscope(&dst); |
| 684 | if (!IN6_ARE_ADDR_EQUAL(&dst, &in6addr_linklocal_allnodes)) |
| 685 | return (EINVAL); |
| 686 | is_general_query = 1; |
| 687 | } else { |
| 688 | /* |
| 689 | * Embed scope ID of receiving interface in MLD query for |
| 690 | * lookup whilst we don't hold other locks. |
| 691 | */ |
| 692 | in6_setscope(&mld->mld_addr, ifp, NULL); |
| 693 | } |
no test coverage detected