]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/bridge/netfilter/ebt_snat.c
[NETFILTER]: Avoid skb_copy/pskb_copy/skb_realloc_headroom
[net-next-2.6.git] / net / bridge / netfilter / ebt_snat.c
index a50722182bfe401c62727d5b768c02de794c709c..b0c63684e2f58994b18657037e1449aba1e5e5ec 100644 (file)
@@ -8,6 +8,7 @@
  *
  */
 
+#include <linux/netfilter.h>
 #include <linux/netfilter_bridge/ebtables.h>
 #include <linux/netfilter_bridge/ebt_nat.h>
 #include <linux/module.h>
@@ -21,17 +22,9 @@ static int ebt_target_snat(struct sk_buff **pskb, unsigned int hooknr,
 {
        struct ebt_nat_info *info = (struct ebt_nat_info *) data;
 
-       if (skb_shared(*pskb) || skb_cloned(*pskb)) {
-               struct sk_buff *nskb;
+       if (skb_make_writable(*pskb, 0))
+               return NF_DROP;
 
-               nskb = skb_copy(*pskb, GFP_ATOMIC);
-               if (!nskb)
-                       return NF_DROP;
-               if ((*pskb)->sk)
-                       skb_set_owner_w(nskb, (*pskb)->sk);
-               kfree_skb(*pskb);
-               *pskb = nskb;
-       }
        memcpy(eth_hdr(*pskb)->h_source, info->mac, ETH_ALEN);
        if (!(info->target & NAT_ARP_BIT) &&
            eth_hdr(*pskb)->h_proto == htons(ETH_P_ARP)) {