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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'ipv6-random-cleanup-for-extension-header'

Kuniyuki Iwashima says:

====================
ipv6: Random cleanup for Extension Header.

This series (1) cleans up pskb_may_pull() in some functions, where needed
data are already pulled by their caller, (2) removes redundant multicast
test, and (3) optimises reload timing of the header.
====================

Link: https://lore.kernel.org/r/20230614230107.22301-1-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+5 -38
-3
include/net/rpl.h
··· 23 23 static inline void rpl_exit(void) {} 24 24 #endif 25 25 26 - size_t ipv6_rpl_srh_size(unsigned char n, unsigned char cmpri, 27 - unsigned char cmpre); 28 - 29 26 void ipv6_rpl_srh_decompress(struct ipv6_rpl_sr_hdr *outhdr, 30 27 const struct ipv6_rpl_sr_hdr *inhdr, 31 28 const struct in6_addr *daddr, unsigned char n);
+5 -28
net/ipv6/exthdrs.c
··· 126 126 max_count = -max_count; 127 127 } 128 128 129 - if (skb_transport_offset(skb) + len > skb_headlen(skb)) 130 - goto bad; 131 - 132 129 off += 2; 133 130 len -= 2; 134 131 ··· 399 402 400 403 skb_postpull_rcsum(skb, skb_network_header(skb), 401 404 skb_network_header_len(skb)); 402 - 403 - if (!pskb_pull(skb, offset)) { 404 - kfree_skb(skb); 405 - return -1; 406 - } 405 + skb_pull(skb, offset); 407 406 skb_postpull_rcsum(skb, skb_transport_header(skb), 408 407 offset); 409 408 ··· 437 444 kfree_skb(skb); 438 445 return -1; 439 446 } 440 - } 441 447 442 - hdr = (struct ipv6_sr_hdr *)skb_transport_header(skb); 448 + hdr = (struct ipv6_sr_hdr *)skb_transport_header(skb); 449 + } 443 450 444 451 hdr->segments_left--; 445 452 addr = hdr->segments + hdr->segments_left; ··· 510 517 511 518 skb_postpull_rcsum(skb, skb_network_header(skb), 512 519 skb_network_header_len(skb)); 513 - 514 - if (!pskb_pull(skb, offset)) { 515 - kfree_skb(skb); 516 - return -1; 517 - } 520 + skb_pull(skb, offset); 518 521 skb_postpull_rcsum(skb, skb_transport_header(skb), 519 522 offset); 520 523 ··· 532 543 return 1; 533 544 } 534 545 535 - if (!pskb_may_pull(skb, sizeof(*hdr))) { 536 - kfree_skb(skb); 537 - return -1; 538 - } 539 - 540 546 n = (hdr->hdrlen << 3) - hdr->pad - (16 - hdr->cmpre); 541 547 r = do_div(n, (16 - hdr->cmpri)); 542 548 /* checks if calculation was without remainder and n fits into ··· 551 567 return -1; 552 568 } 553 569 554 - if (!pskb_may_pull(skb, ipv6_rpl_srh_size(n, hdr->cmpri, 555 - hdr->cmpre))) { 556 - kfree_skb(skb); 557 - return -1; 558 - } 559 - 560 570 hdr->segments_left--; 561 571 i = n - hdr->segments_left; 562 572 ··· 564 586 ipv6_rpl_srh_decompress(ohdr, hdr, &ipv6_hdr(skb)->daddr, n); 565 587 chdr = (struct ipv6_rpl_sr_hdr *)(buf + ((ohdr->hdrlen + 1) << 3)); 566 588 567 - if ((ipv6_addr_type(&ipv6_hdr(skb)->daddr) & IPV6_ADDR_MULTICAST) || 568 - (ipv6_addr_type(&ohdr->rpl_segaddr[i]) & IPV6_ADDR_MULTICAST)) { 589 + if (ipv6_addr_is_multicast(&ohdr->rpl_segaddr[i])) { 569 590 kfree_skb(skb); 570 591 kfree(buf); 571 592 return -1;
-7
net/ipv6/rpl.c
··· 29 29 return (void *)&hdr->rpl_segdata[i * IPV6_PFXTAIL_LEN(hdr->cmpri)]; 30 30 } 31 31 32 - size_t ipv6_rpl_srh_size(unsigned char n, unsigned char cmpri, 33 - unsigned char cmpre) 34 - { 35 - return sizeof(struct ipv6_rpl_sr_hdr) + (n * IPV6_PFXTAIL_LEN(cmpri)) + 36 - IPV6_PFXTAIL_LEN(cmpre); 37 - } 38 - 39 32 void ipv6_rpl_srh_decompress(struct ipv6_rpl_sr_hdr *outhdr, 40 33 const struct ipv6_rpl_sr_hdr *inhdr, 41 34 const struct in6_addr *daddr, unsigned char n)