Commit ac9d8a66 authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by Jakub Kicinski

ipv6: rpl: Remove pskb(_may)?_pull() in ipv6_rpl_srh_rcv().

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: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 9a94d764
...@@ -23,9 +23,6 @@ static inline int rpl_init(void) ...@@ -23,9 +23,6 @@ static inline int rpl_init(void)
static inline void rpl_exit(void) {} static inline void rpl_exit(void) {}
#endif #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, void ipv6_rpl_srh_decompress(struct ipv6_rpl_sr_hdr *outhdr,
const struct ipv6_rpl_sr_hdr *inhdr, const struct ipv6_rpl_sr_hdr *inhdr,
const struct in6_addr *daddr, unsigned char n); const struct in6_addr *daddr, unsigned char n);
......
...@@ -517,11 +517,7 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb) ...@@ -517,11 +517,7 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)
skb_postpull_rcsum(skb, skb_network_header(skb), skb_postpull_rcsum(skb, skb_network_header(skb),
skb_network_header_len(skb)); skb_network_header_len(skb));
skb_pull(skb, offset);
if (!pskb_pull(skb, offset)) {
kfree_skb(skb);
return -1;
}
skb_postpull_rcsum(skb, skb_transport_header(skb), skb_postpull_rcsum(skb, skb_transport_header(skb),
offset); offset);
...@@ -543,11 +539,6 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb) ...@@ -543,11 +539,6 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)
return 1; return 1;
} }
if (!pskb_may_pull(skb, sizeof(*hdr))) {
kfree_skb(skb);
return -1;
}
n = (hdr->hdrlen << 3) - hdr->pad - (16 - hdr->cmpre); n = (hdr->hdrlen << 3) - hdr->pad - (16 - hdr->cmpre);
r = do_div(n, (16 - hdr->cmpri)); r = do_div(n, (16 - hdr->cmpri));
/* checks if calculation was without remainder and n fits into /* checks if calculation was without remainder and n fits into
...@@ -567,12 +558,6 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb) ...@@ -567,12 +558,6 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)
return -1; return -1;
} }
if (!pskb_may_pull(skb, ipv6_rpl_srh_size(n, hdr->cmpri,
hdr->cmpre))) {
kfree_skb(skb);
return -1;
}
hdr->segments_left--; hdr->segments_left--;
i = n - hdr->segments_left; i = n - hdr->segments_left;
......
...@@ -29,13 +29,6 @@ static void *ipv6_rpl_segdata_pos(const struct ipv6_rpl_sr_hdr *hdr, int i) ...@@ -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)]; 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, void ipv6_rpl_srh_decompress(struct ipv6_rpl_sr_hdr *outhdr,
const struct ipv6_rpl_sr_hdr *inhdr, const struct ipv6_rpl_sr_hdr *inhdr,
const struct in6_addr *daddr, unsigned char n) const struct in6_addr *daddr, unsigned char n)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment