[SK_BUFF]: More skb_reset_transport_header conversions
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 13 Mar 2007 20:10:43 +0000 (17:10 -0300)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:25:29 +0000 (22:25 -0700)
These are a bit more subtle, they are of this type:

-       skb->h.raw = payload;
        __skb_pull(skb, payload - skb->data);
+       skb_reset_transport_header(skb);

__skb_pull results in:

skb->data = skb->data + payload - skb->data;
skb->data = payload;

So after __skb_pull we have skb->data pointing to payload and we can
just call skb_reset_transport_header(skb), that will do:

skb->h.raw = payload;

The others are similar, allowing us to get rid of some more cases where a
pointer was being attributed to the layer headers.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_sockglue.c
net/ipv6/datagram.c

index ccdc59df015fe443c0caa9fa617fa6cc5778ea09..fcb35cd5ccfd0d9346227c32a3afe22b87422d3b 100644 (file)
@@ -278,10 +278,12 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
                                   skb_network_header(skb);
        serr->port = port;
 
-       skb->h.raw = payload;
-       if (!skb_pull(skb, payload - skb->data) ||
-           sock_queue_err_skb(sk, skb))
-               kfree_skb(skb);
+       if (skb_pull(skb, payload - skb->data) != NULL) {
+               skb_reset_transport_header(skb);
+               if (sock_queue_err_skb(sk, skb) == 0)
+                       return;
+       }
+       kfree_skb(skb);
 }
 
 void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 info)
@@ -314,8 +316,8 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 inf
        serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb);
        serr->port = port;
 
-       skb->h.raw = skb->tail;
        __skb_pull(skb, skb->tail - skb->data);
+       skb_reset_transport_header(skb);
 
        if (sock_queue_err_skb(sk, skb))
                kfree_skb(skb);
index feba6b197fe903feba2c1d3ff210be5ff50549fb..f16f4f0c5814fd8cc35540349043342d6bee70af 100644 (file)
@@ -231,8 +231,8 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
                                  skb_network_header(skb);
        serr->port = port;
 
-       skb->h.raw = payload;
        __skb_pull(skb, payload - skb->data);
+       skb_reset_transport_header(skb);
 
        if (sock_queue_err_skb(sk, skb))
                kfree_skb(skb);
@@ -268,8 +268,8 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
        serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb);
        serr->port = fl->fl_ip_dport;
 
-       skb->h.raw = skb->tail;
        __skb_pull(skb, skb->tail - skb->data);
+       skb_reset_transport_header(skb);
 
        if (sock_queue_err_skb(sk, skb))
                kfree_skb(skb);