ipv6: fix incorrent ipv6 ipsec packet fragment
authorGao feng <gaofeng@cn.fujitsu.com>
Mon, 19 Mar 2012 22:36:10 +0000 (22:36 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 20 Mar 2012 09:39:34 +0000 (05:39 -0400)
Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem)
In func ip6_append_data,after call skb_put(skb, fraglen + dst_exthdrlen)
the skb->len contains dst_exthdrlen,and we don't reduce dst_exthdrlen at last
This will make fraggap>0 in next "while cycle",and cause the size of skb incorrent

Fix this by reserve headroom for dst_exthdrlen.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ip6_output.c

index 7a98fc2a5d97115d79512cac3b8eb19b05e0c0f9..b7ca46161cb9b587d02c056f3236ae5725bf21f5 100644 (file)
@@ -1414,8 +1414,9 @@ alloc_new_skb:
                         */
                        skb->ip_summed = csummode;
                        skb->csum = 0;
-                       /* reserve for fragmentation */
-                       skb_reserve(skb, hh_len+sizeof(struct frag_hdr));
+                       /* reserve for fragmentation and ipsec header */
+                       skb_reserve(skb, hh_len + sizeof(struct frag_hdr) +
+                                   dst_exthdrlen);
 
                        if (sk->sk_type == SOCK_DGRAM)
                                skb_shinfo(skb)->tx_flags = tx_flags;
@@ -1423,9 +1424,9 @@ alloc_new_skb:
                        /*
                         *      Find where to start putting bytes
                         */
-                       data = skb_put(skb, fraglen + dst_exthdrlen);
-                       skb_set_network_header(skb, exthdrlen + dst_exthdrlen);
-                       data += fragheaderlen + dst_exthdrlen;
+                       data = skb_put(skb, fraglen);
+                       skb_set_network_header(skb, exthdrlen);
+                       data += fragheaderlen;
                        skb->transport_header = (skb->network_header +
                                                 fragheaderlen);
                        if (fraggap) {