ipv6: rpl: Remove redundant multicast tests in ipv6_rpl_srh_rcv().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 14 Jun 2023 23:01:04 +0000 (16:01 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 19 Jun 2023 18:32:58 +0000 (11:32 -0700)
ipv6_rpl_srh_rcv() checks if ipv6_hdr(skb)->daddr or ohdr->rpl_segaddr[i]
is the multicast address with ipv6_addr_type().

We have the same check for ipv6_hdr(skb)->daddr in ipv6_rthdr_rcv(), so we
need not recheck it in ipv6_rpl_srh_rcv().

Also, we should use ipv6_addr_is_multicast() for ohdr->rpl_segaddr[i]
instead of ipv6_addr_type().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv6/exthdrs.c

index 65adc11b59aaf8b9d99980330ea0b083b2028e9f..6259e907f0d9f06748432ec0f349cde3277fc94e 100644 (file)
@@ -571,8 +571,7 @@ looped_back:
        ipv6_rpl_srh_decompress(ohdr, hdr, &ipv6_hdr(skb)->daddr, n);
        chdr = (struct ipv6_rpl_sr_hdr *)(buf + ((ohdr->hdrlen + 1) << 3));
 
-       if ((ipv6_addr_type(&ipv6_hdr(skb)->daddr) & IPV6_ADDR_MULTICAST) ||
-           (ipv6_addr_type(&ohdr->rpl_segaddr[i]) & IPV6_ADDR_MULTICAST)) {
+       if (ipv6_addr_is_multicast(&ohdr->rpl_segaddr[i])) {
                kfree_skb(skb);
                kfree(buf);
                return -1;