Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv6: Store Router Alert option in IP6CB directly.

Router Alert option is very small and we can store the value
itself in the skb.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

YOSHIFUJI Hideaki / 吉藤英明 and committed by
David S. Miller
dd3332bf 2b464f61

+8 -5
+2 -1
include/linux/ipv6.h
··· 84 84 85 85 struct inet6_skb_parm { 86 86 int iif; 87 - __u16 ra; 87 + __be16 ra; 88 88 __u16 hop; 89 89 __u16 dst0; 90 90 __u16 srcrt; ··· 100 100 #define IP6SKB_XFRM_TRANSFORMED 1 101 101 #define IP6SKB_FORWARDED 2 102 102 #define IP6SKB_REROUTED 4 103 + #define IP6SKB_ROUTERALERT 8 103 104 }; 104 105 105 106 #define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
+2
include/uapi/linux/ipv6.h
··· 63 63 #define ipv6_destopt_hdr ipv6_opt_hdr 64 64 #define ipv6_hopopt_hdr ipv6_opt_hdr 65 65 66 + /* Router Alert option values (RFC2711) */ 67 + #define IPV6_OPT_ROUTERALERT_MLD 0x0000 /* MLD(RFC2710) */ 66 68 67 69 /* 68 70 * routing header type 0 (used in cmsghdr struct)
+2 -1
net/ipv6/exthdrs.c
··· 553 553 const unsigned char *nh = skb_network_header(skb); 554 554 555 555 if (nh[optoff + 1] == 2) { 556 - IP6CB(skb)->ra = optoff; 556 + IP6CB(skb)->flags |= IP6SKB_ROUTERALERT; 557 + memcpy(&IP6CB(skb)->ra, nh + optoff + 2, sizeof(IP6CB(skb)->ra)); 557 558 return true; 558 559 } 559 560 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n",
+2 -3
net/ipv6/ip6_input.c
··· 280 280 struct inet6_skb_parm *opt = IP6CB(skb); 281 281 282 282 /* Check for MLD */ 283 - if (unlikely(opt->ra)) { 283 + if (unlikely(opt->flags & IP6SKB_ROUTERALERT)) { 284 284 /* Check if this is a mld message */ 285 - u8 *ptr = skb_network_header(skb) + opt->ra; 286 285 u8 nexthdr = hdr->nexthdr; 287 286 __be16 frag_off; 288 287 int offset; ··· 289 290 /* Check if the value of Router Alert 290 291 * is for MLD (0x0000). 291 292 */ 292 - if ((ptr[2] | ptr[3]) == 0) { 293 + if (opt->ra == htons(IPV6_OPT_ROUTERALERT_MLD)) { 293 294 deliver = false; 294 295 295 296 if (!ipv6_ext_hdr(nexthdr)) {