Skip to content

Commit

Permalink
ipv6: rpl: Remove pskb(_may)?_pull() in ipv6_rpl_srh_rcv().
Browse files Browse the repository at this point in the history
As Eric Dumazet pointed out [0], ipv6_rthdr_rcv() pulls these data

  - Segment Routing Header : 8
  - Hdr Ext Len            : skb_transport_header(skb)[1] << 3

needed by ipv6_rpl_srh_rcv().  We can remove pskb_may_pull() and
replace pskb_pull() with skb_pull() in ipv6_rpl_srh_rcv().

Link: https://lore.kernel.org/netdev/CANn89iLboLwLrHXeHJucAqBkEL_S0rJFog68t7wwwXO-aNf5Mg@mail.gmail.com/ [0]
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Kuniyuki Iwashima authored and Jakub Kicinski committed Jun 19, 2023
1 parent 9a94d76 commit ac9d8a6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 26 deletions.
3 changes: 0 additions & 3 deletions include/net/rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ static inline int rpl_init(void)
static inline void rpl_exit(void) {}
#endif

size_t ipv6_rpl_srh_size(unsigned char n, unsigned char cmpri,
unsigned char cmpre);

void ipv6_rpl_srh_decompress(struct ipv6_rpl_sr_hdr *outhdr,
const struct ipv6_rpl_sr_hdr *inhdr,
const struct in6_addr *daddr, unsigned char n);
Expand Down
17 changes: 1 addition & 16 deletions net/ipv6/exthdrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,7 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)

skb_postpull_rcsum(skb, skb_network_header(skb),
skb_network_header_len(skb));

if (!pskb_pull(skb, offset)) {
kfree_skb(skb);
return -1;
}
skb_pull(skb, offset);
skb_postpull_rcsum(skb, skb_transport_header(skb),
offset);

Expand All @@ -543,11 +539,6 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)
return 1;
}

if (!pskb_may_pull(skb, sizeof(*hdr))) {
kfree_skb(skb);
return -1;
}

n = (hdr->hdrlen << 3) - hdr->pad - (16 - hdr->cmpre);
r = do_div(n, (16 - hdr->cmpri));
/* checks if calculation was without remainder and n fits into
Expand All @@ -567,12 +558,6 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)
return -1;
}

if (!pskb_may_pull(skb, ipv6_rpl_srh_size(n, hdr->cmpri,
hdr->cmpre))) {
kfree_skb(skb);
return -1;
}

hdr->segments_left--;
i = n - hdr->segments_left;

Expand Down
7 changes: 0 additions & 7 deletions net/ipv6/rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ static void *ipv6_rpl_segdata_pos(const struct ipv6_rpl_sr_hdr *hdr, int i)
return (void *)&hdr->rpl_segdata[i * IPV6_PFXTAIL_LEN(hdr->cmpri)];
}

size_t ipv6_rpl_srh_size(unsigned char n, unsigned char cmpri,
unsigned char cmpre)
{
return sizeof(struct ipv6_rpl_sr_hdr) + (n * IPV6_PFXTAIL_LEN(cmpri)) +
IPV6_PFXTAIL_LEN(cmpre);
}

void ipv6_rpl_srh_decompress(struct ipv6_rpl_sr_hdr *outhdr,
const struct ipv6_rpl_sr_hdr *inhdr,
const struct in6_addr *daddr, unsigned char n)
Expand Down

0 comments on commit ac9d8a6

Please sign in to comment.