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

ipv6: use flag instead of u16 for hop in inet6_skb_parm

Hop was always either 0 or sizeof(struct ipv6hdr).

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Florian Westphal and committed by
David S. Miller
8b58a398 7c3d0d67

+8 -8
+1 -1
include/linux/ipv6.h
··· 94 94 struct inet6_skb_parm { 95 95 int iif; 96 96 __be16 ra; 97 - __u16 hop; 98 97 __u16 dst0; 99 98 __u16 srcrt; 100 99 __u16 dst1; ··· 110 111 #define IP6SKB_REROUTED 4 111 112 #define IP6SKB_ROUTERALERT 8 112 113 #define IP6SKB_FRAGMENTED 16 114 + #define IP6SKB_HOPBYHOP 32 113 115 }; 114 116 115 117 #define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
+2 -2
net/ipv6/af_inet6.c
··· 679 679 const struct ipv6_pinfo *np = inet6_sk(sk); 680 680 681 681 if (np->rxopt.all) { 682 - if ((opt->hop && (np->rxopt.bits.hopopts || 683 - np->rxopt.bits.ohopopts)) || 682 + if (((opt->flags & IP6SKB_HOPBYHOP) && 683 + (np->rxopt.bits.hopopts || np->rxopt.bits.ohopopts)) || 684 684 (ip6_flowinfo((struct ipv6hdr *) skb_network_header(skb)) && 685 685 np->rxopt.bits.rxflow) || 686 686 (opt->srcrt && (np->rxopt.bits.srcrt ||
+4 -4
net/ipv6/datagram.c
··· 558 558 } 559 559 560 560 /* HbH is allowed only once */ 561 - if (np->rxopt.bits.hopopts && opt->hop) { 562 - u8 *ptr = nh + opt->hop; 561 + if (np->rxopt.bits.hopopts && (opt->flags & IP6SKB_HOPBYHOP)) { 562 + u8 *ptr = nh + sizeof(struct ipv6hdr); 563 563 put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); 564 564 } 565 565 ··· 620 620 int hlim = ipv6_hdr(skb)->hop_limit; 621 621 put_cmsg(msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); 622 622 } 623 - if (np->rxopt.bits.ohopopts && opt->hop) { 624 - u8 *ptr = nh + opt->hop; 623 + if (np->rxopt.bits.ohopopts && (opt->flags & IP6SKB_HOPBYHOP)) { 624 + u8 *ptr = nh + sizeof(struct ipv6hdr); 625 625 put_cmsg(msg, SOL_IPV6, IPV6_2292HOPOPTS, (ptr[1]+1)<<3, ptr); 626 626 } 627 627 if (np->rxopt.bits.odstopts && opt->dst0) {
+1 -1
net/ipv6/exthdrs.c
··· 632 632 return -1; 633 633 } 634 634 635 - opt->hop = sizeof(struct ipv6hdr); 635 + opt->flags |= IP6SKB_HOPBYHOP; 636 636 if (ip6_parse_tlv(tlvprochopopt_lst, skb)) { 637 637 skb->transport_header += (skb_transport_header(skb)[1] + 1) << 3; 638 638 opt = IP6CB(skb);