]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/xfrm4_output.c
[INET]: Consolidate xxx_frag_intern
[linux-2.6-omap-h63xx.git] / net / ipv4 / xfrm4_output.c
index 04403fb01a5890abb1d1d8c41b8812b6d9c9b5d4..a4edd666318b0f85bb9efb166df3512f78bce8d5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * xfrm4_output.c - Common IPsec encapsulation code for IPv4.
  * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au>
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version
@@ -12,7 +12,6 @@
 #include <linux/if_ether.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
-#include <linux/spinlock.h>
 #include <linux/netfilter_ipv4.h>
 #include <net/ip.h>
 #include <net/xfrm.h>
@@ -22,14 +21,13 @@ static int xfrm4_tunnel_check_size(struct sk_buff *skb)
 {
        int mtu, ret = 0;
        struct dst_entry *dst;
-       struct iphdr *iph = skb->nh.iph;
 
        if (IPCB(skb)->flags & IPSKB_XFRM_TUNNEL_SIZE)
                goto out;
 
        IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE;
-       
-       if (!(iph->frag_off & htons(IP_DF)) || skb->local_df)
+
+       if (!(ip_hdr(skb)->frag_off & htons(IP_DF)) || skb->local_df)
                goto out;
 
        dst = skb->dst;
@@ -42,17 +40,12 @@ out:
        return ret;
 }
 
-static int xfrm4_output_one(struct sk_buff *skb)
+static inline int xfrm4_output_one(struct sk_buff *skb)
 {
        struct dst_entry *dst = skb->dst;
        struct xfrm_state *x = dst->xfrm;
+       struct iphdr *iph;
        int err;
-       
-       if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               err = skb_checksum_help(skb);
-               if (err)
-                       goto error_nolock;
-       }
 
        if (x->props.mode == XFRM_MODE_TUNNEL) {
                err = xfrm4_tunnel_check_size(skb);
@@ -60,40 +53,19 @@ static int xfrm4_output_one(struct sk_buff *skb)
                        goto error_nolock;
        }
 
-       do {
-               spin_lock_bh(&x->lock);
-               err = xfrm_state_check(x, skb);
-               if (err)
-                       goto error;
+       err = xfrm_output(skb);
+       if (err)
+               goto error_nolock;
 
-               err = x->mode->output(x, skb);
-               if (err)
-                       goto error;
-
-               err = x->type->output(x, skb);
-               if (err)
-                       goto error;
-
-               x->curlft.bytes += skb->len;
-               x->curlft.packets++;
-
-               spin_unlock_bh(&x->lock);
-       
-               if (!(skb->dst = dst_pop(dst))) {
-                       err = -EHOSTUNREACH;
-                       goto error_nolock;
-               }
-               dst = skb->dst;
-               x = dst->xfrm;
-       } while (x && (x->props.mode != XFRM_MODE_TUNNEL));
+       iph = ip_hdr(skb);
+       iph->tot_len = htons(skb->len);
+       ip_send_check(iph);
 
        IPCB(skb)->flags |= IPSKB_XFRM_TRANSFORMED;
        err = 0;
 
 out_exit:
        return err;
-error:
-       spin_unlock_bh(&x->lock);
 error_nolock:
        kfree_skb(skb);
        goto out_exit;
@@ -106,7 +78,7 @@ static int xfrm4_output_finish2(struct sk_buff *skb)
        while (likely((err = xfrm4_output_one(skb)) == 0)) {
                nf_reset(skb);
 
-               err = nf_hook(PF_INET, NF_IP_LOCAL_OUT, &skb, NULL,
+               err = nf_hook(PF_INET, NF_IP_LOCAL_OUT, skb, NULL,
                              skb->dst->dev, dst_output);
                if (unlikely(err != 1))
                        break;
@@ -114,7 +86,7 @@ static int xfrm4_output_finish2(struct sk_buff *skb)
                if (!skb->dst->xfrm)
                        return dst_output(skb);
 
-               err = nf_hook(PF_INET, NF_IP_POST_ROUTING, &skb, NULL,
+               err = nf_hook(PF_INET, NF_IP_POST_ROUTING, skb, NULL,
                              skb->dst->dev, xfrm4_output_finish2);
                if (unlikely(err != 1))
                        break;