[SK_BUFF]: Introduce skb_network_header()
For the places where we need a pointer to the network header, it is still legal to touch skb->nh.raw directly if just adding to, subtracting from or setting it to another layer header. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
bbe735e424
commit
d56f90a7c9
@@ -374,7 +374,8 @@ static int check_hbh_len(struct sk_buff *skb)
|
||||
{
|
||||
unsigned char *raw = (u8 *) (skb->nh.ipv6h + 1);
|
||||
u32 pkt_len;
|
||||
int off = raw - skb->nh.raw;
|
||||
const unsigned char *nh = skb_network_header(skb);
|
||||
int off = raw - nh;
|
||||
int len = (raw[1] + 1) << 3;
|
||||
|
||||
if ((raw + len) - skb->data > skb_headlen(skb))
|
||||
@@ -384,9 +385,9 @@ static int check_hbh_len(struct sk_buff *skb)
|
||||
len -= 2;
|
||||
|
||||
while (len > 0) {
|
||||
int optlen = skb->nh.raw[off + 1] + 2;
|
||||
int optlen = nh[off + 1] + 2;
|
||||
|
||||
switch (skb->nh.raw[off]) {
|
||||
switch (nh[off]) {
|
||||
case IPV6_TLV_PAD0:
|
||||
optlen = 1;
|
||||
break;
|
||||
@@ -395,9 +396,9 @@ static int check_hbh_len(struct sk_buff *skb)
|
||||
break;
|
||||
|
||||
case IPV6_TLV_JUMBO:
|
||||
if (skb->nh.raw[off + 1] != 4 || (off & 3) != 2)
|
||||
if (nh[off + 1] != 4 || (off & 3) != 2)
|
||||
goto bad;
|
||||
pkt_len = ntohl(*(__be32 *) (skb->nh.raw + off + 2));
|
||||
pkt_len = ntohl(*(__be32 *) (nh + off + 2));
|
||||
if (pkt_len <= IPV6_MAXPLEN ||
|
||||
skb->nh.ipv6h->payload_len)
|
||||
goto bad;
|
||||
@@ -406,6 +407,7 @@ static int check_hbh_len(struct sk_buff *skb)
|
||||
if (pskb_trim_rcsum(skb,
|
||||
pkt_len + sizeof(struct ipv6hdr)))
|
||||
goto bad;
|
||||
nh = skb_network_header(skb);
|
||||
break;
|
||||
default:
|
||||
if (optlen > len)
|
||||
|
Reference in New Issue
Block a user