]> git.neil.brown.name Git - history.git/commitdiff
[IPSEC]: Use "sizeof" for header sizes.
authorTom Lendacky <toml@us.ibm.com>
Mon, 31 Mar 2003 02:18:10 +0000 (18:18 -0800)
committerDavid S. Miller <davem@nuts.ninka.net>
Mon, 31 Mar 2003 02:18:10 +0000 (18:18 -0800)
net/ipv4/ah.c
net/ipv4/esp.c
net/ipv6/ah6.c
net/ipv6/esp6.c

index e7404e9ff2d7e25a3f63f0b6ec1941d6c31068b7..e967d4d4a947ed549179420aa7a9bc68ecebb1d4 100644 (file)
@@ -18,7 +18,7 @@
 static int ip_clear_mutable_options(struct iphdr *iph, u32 *daddr)
 {
        unsigned char * optptr = (unsigned char*)(iph+1);
-       int  l = iph->ihl*4 - 20;
+       int  l = iph->ihl*4 - sizeof(struct iphdr);
        int  optlen;
 
        while (l > 0) {
@@ -132,7 +132,7 @@ static int ah_output(struct sk_buff *skb)
                top_iph->frag_off = iph->frag_off;
                top_iph->daddr = iph->daddr;
                if (iph->ihl != 5)
-                       memcpy(top_iph+1, iph+1, iph->ihl*5 - 20);
+                       memcpy(top_iph+1, iph+1, iph->ihl*4 - sizeof(struct iphdr));
        }
        ip_send_check(top_iph);
 
@@ -288,7 +288,7 @@ static int ah_init_state(struct xfrm_state *x, void *args)
        
        x->props.header_len = XFRM_ALIGN8(ahp->icv_trunc_len + AH_HLEN_NOICV);
        if (x->props.mode)
-               x->props.header_len += 20;
+               x->props.header_len += sizeof(struct iphdr);
        x->data = ahp;
 
        return 0;
index 5464dc0c94e9a2de412221d82f1011b8a5d58c26..cae05e7c01567500472bdfbb21d738c98d55e9de 100644 (file)
@@ -367,7 +367,7 @@ int esp_init_state(struct xfrm_state *x, void *args)
        crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len);
        x->props.header_len = 8 + esp->conf.ivlen;
        if (x->props.mode)
-               x->props.header_len += 20;
+               x->props.header_len += sizeof(struct iphdr);
        x->data = esp;
        x->props.trailer_len = esp4_get_max_size(x, 0) - x->props.header_len;
        return 0;
index f1c7436efb14b2a2eb888b7814d33b05c1765add..9ad87386052f6add7f2564d426f514e965fa1214 100644 (file)
@@ -287,7 +287,7 @@ static int ah6_init_state(struct xfrm_state *x, void *args)
        
        x->props.header_len = XFRM_ALIGN8(ahp->icv_trunc_len + AH_HLEN_NOICV);
        if (x->props.mode)
-               x->props.header_len += 40;
+               x->props.header_len += sizeof(struct ipv6hdr);
        x->data = ahp;
 
        return 0;
index fdc88cc1ea58630c75813355f8031d8c4f2b1fb2..e1cbbaae62fcf7e7ed5fdb6413787ef739bab2c6 100644 (file)
@@ -468,7 +468,7 @@ int esp6_init_state(struct xfrm_state *x, void *args)
        crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len);
        x->props.header_len = 8 + esp->conf.ivlen;
        if (x->props.mode)
-               x->props.header_len += 40;  /* XXX ext hdr */
+               x->props.header_len += sizeof(struct ipv6hdr);
        x->data = esp;
        return 0;