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

xfrm: ipv6: move mip6_rthdr_offset into xfrm core

Place the call into the xfrm core. After this all remaining users
set the hdr_offset function pointer to the same function which opens
the possiblity to remove the indirection.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

authored by

Florian Westphal and committed by
Steffen Klassert
848b18fb 37b9e7eb

+49 -48
-48
net/ipv6/mip6.c
··· 333 333 return 0; 334 334 } 335 335 336 - static int mip6_rthdr_offset(struct xfrm_state *x, struct sk_buff *skb, 337 - u8 **nexthdr) 338 - { 339 - u16 offset = sizeof(struct ipv6hdr); 340 - struct ipv6_opt_hdr *exthdr = 341 - (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1); 342 - const unsigned char *nh = skb_network_header(skb); 343 - unsigned int packet_len = skb_tail_pointer(skb) - 344 - skb_network_header(skb); 345 - int found_rhdr = 0; 346 - 347 - *nexthdr = &ipv6_hdr(skb)->nexthdr; 348 - 349 - while (offset + 1 <= packet_len) { 350 - 351 - switch (**nexthdr) { 352 - case NEXTHDR_HOP: 353 - break; 354 - case NEXTHDR_ROUTING: 355 - if (offset + 3 <= packet_len) { 356 - struct ipv6_rt_hdr *rt; 357 - rt = (struct ipv6_rt_hdr *)(nh + offset); 358 - if (rt->type != 0) 359 - return offset; 360 - } 361 - found_rhdr = 1; 362 - break; 363 - case NEXTHDR_DEST: 364 - if (ipv6_find_tlv(skb, offset, IPV6_TLV_HAO) >= 0) 365 - return offset; 366 - 367 - if (found_rhdr) 368 - return offset; 369 - 370 - break; 371 - default: 372 - return offset; 373 - } 374 - 375 - offset += ipv6_optlen(exthdr); 376 - *nexthdr = &exthdr->nexthdr; 377 - exthdr = (struct ipv6_opt_hdr *)(nh + offset); 378 - } 379 - 380 - return offset; 381 - } 382 - 383 336 static int mip6_rthdr_init_state(struct xfrm_state *x) 384 337 { 385 338 if (x->id.spi) { ··· 366 413 .destructor = mip6_rthdr_destroy, 367 414 .input = mip6_rthdr_input, 368 415 .output = mip6_rthdr_output, 369 - .hdr_offset = mip6_rthdr_offset, 370 416 }; 371 417 372 418 static int __init mip6_init(void)
+49
net/xfrm/xfrm_output.c
··· 123 123 124 124 return offset; 125 125 } 126 + 127 + static int mip6_rthdr_offset(struct xfrm_state *x, struct sk_buff *skb, 128 + u8 **nexthdr) 129 + { 130 + u16 offset = sizeof(struct ipv6hdr); 131 + struct ipv6_opt_hdr *exthdr = 132 + (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1); 133 + const unsigned char *nh = skb_network_header(skb); 134 + unsigned int packet_len = skb_tail_pointer(skb) - 135 + skb_network_header(skb); 136 + int found_rhdr = 0; 137 + 138 + *nexthdr = &ipv6_hdr(skb)->nexthdr; 139 + 140 + while (offset + 1 <= packet_len) { 141 + switch (**nexthdr) { 142 + case NEXTHDR_HOP: 143 + break; 144 + case NEXTHDR_ROUTING: 145 + if (offset + 3 <= packet_len) { 146 + struct ipv6_rt_hdr *rt; 147 + 148 + rt = (struct ipv6_rt_hdr *)(nh + offset); 149 + if (rt->type != 0) 150 + return offset; 151 + } 152 + found_rhdr = 1; 153 + break; 154 + case NEXTHDR_DEST: 155 + if (ipv6_find_tlv(skb, offset, IPV6_TLV_HAO) >= 0) 156 + return offset; 157 + 158 + if (found_rhdr) 159 + return offset; 160 + 161 + break; 162 + default: 163 + return offset; 164 + } 165 + 166 + offset += ipv6_optlen(exthdr); 167 + *nexthdr = &exthdr->nexthdr; 168 + exthdr = (struct ipv6_opt_hdr *)(nh + offset); 169 + } 170 + 171 + return offset; 172 + } 126 173 #endif 127 174 128 175 static int xfrm6_hdr_offset(struct xfrm_state *x, struct sk_buff *skb, u8 **prevhdr) ··· 178 131 #if IS_ENABLED(CONFIG_IPV6_MIP6) 179 132 case IPPROTO_DSTOPTS: 180 133 return mip6_destopt_offset(x, skb, prevhdr); 134 + case IPPROTO_ROUTING: 135 + return mip6_rthdr_offset(x, skb, prevhdr); 181 136 #endif 182 137 default: 183 138 break;