]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Merge branch 'master' of /repos/git/net-next-2.6
authorPatrick McHardy <kaber@trash.net>
Tue, 15 Jun 2010 15:31:06 +0000 (17:31 +0200)
committerPatrick McHardy <kaber@trash.net>
Tue, 15 Jun 2010 15:31:06 +0000 (17:31 +0200)
Conflicts:
include/net/netfilter/xt_rateest.h
net/bridge/br_netfilter.c
net/netfilter/nf_conntrack_core.c

Signed-off-by: Patrick McHardy <kaber@trash.net>
1  2 
include/net/netfilter/nf_conntrack.h
include/net/netfilter/xt_rateest.h
net/bridge/br_netfilter.c
net/ipv4/netfilter.c
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c
net/netfilter/nf_conntrack_core.c
net/netfilter/xt_TEE.c

index 84a4b6fec99d46b678f08b93f02ec41e8c343252,bbfdd9453087c8fbdcc23d6a92e989b64f9d532b..e624dae54fa49b7d713b78641c7f18c2e3cfbae2
@@@ -152,11 -152,7 +152,7 @@@ extern struct net init_net
  
  static inline struct net *nf_ct_net(const struct nf_conn *ct)
  {
- #ifdef CONFIG_NET_NS
-       return ct->ct_net;
- #else
-       return &init_net;
- #endif
+       return read_pnet(&ct->ct_net);
  }
  
  /* Alter reply tuple (maybe alter helper). */
@@@ -261,12 -257,7 +257,12 @@@ extern s16 (*nf_ct_nat_offset)(const st
                               u32 seq);
  
  /* Fake conntrack entry for untracked connections */
 -extern struct nf_conn nf_conntrack_untracked;
 +DECLARE_PER_CPU(struct nf_conn, nf_conntrack_untracked);
 +static inline struct nf_conn *nf_ct_untracked_get(void)
 +{
 +      return &__raw_get_cpu_var(nf_conntrack_untracked);
 +}
 +extern void nf_ct_untracked_status_or(unsigned long bits);
  
  /* Iterate over all conntracks: if iter returns true, it's deleted. */
  extern void
@@@ -294,9 -285,9 +290,9 @@@ static inline int nf_ct_is_dying(struc
        return test_bit(IPS_DYING_BIT, &ct->status);
  }
  
 -static inline int nf_ct_is_untracked(const struct sk_buff *skb)
 +static inline int nf_ct_is_untracked(const struct nf_conn *ct)
  {
 -      return (skb->nfct == &nf_conntrack_untracked.ct_general);
 +      return test_bit(IPS_UNTRACKED_BIT, &ct->status);
  }
  
  extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp);
index b1d780e21ce3bf2b2089559fc1529083994d9331,5e1427795928541d3eb37bd3c46e87b4b90c434d..5a2978d1cb22ae8713d43688b74370e44727725e
@@@ -2,17 -2,14 +2,18 @@@
  #define _XT_RATEEST_H
  
  struct xt_rateest {
 +      /* keep lock and bstats on same cache line to speedup xt_rateest_tg() */
 +      struct gnet_stats_basic_packed  bstats;
 +      spinlock_t                      lock;
 +      /* keep rstats and lock on same cache line to speedup xt_rateest_mt() */
 +      struct gnet_stats_rate_est      rstats;
 +
 +      /* following fields not accessed in hot path */
        struct hlist_node               list;
        char                            name[IFNAMSIZ];
        unsigned int                    refcnt;
 -      spinlock_t                      lock;
        struct gnet_estimator           params;
 -      struct gnet_stats_rate_est      rstats;
 -      struct gnet_stats_basic_packed  bstats;
+       struct rcu_head                 rcu;
  };
  
  extern struct xt_rateest *xt_rateest_lookup(const char *name);
index cbea5af24ce6b3cce4cfb77805692e620702e0c8,0685b2558ab507bcc976d2bbaa41169f23f28dc8..6bb6f7c9e6e1afe4b00fdfadc1caef68b01d1c7e
@@@ -117,12 -117,12 +117,12 @@@ void br_netfilter_rtable_init(struct ne
  {
        struct rtable *rt = &br->fake_rtable;
  
-       atomic_set(&rt->u.dst.__refcnt, 1);
-       rt->u.dst.dev = br->dev;
-       rt->u.dst.path = &rt->u.dst;
-       rt->u.dst.metrics[RTAX_MTU - 1] = 1500;
-       rt->u.dst.flags = DST_NOXFRM;
-       rt->u.dst.ops = &fake_dst_ops;
+       atomic_set(&rt->dst.__refcnt, 1);
+       rt->dst.dev = br->dev;
+       rt->dst.path = &rt->dst;
+       rt->dst.metrics[RTAX_MTU - 1] = 1500;
+       rt->dst.flags   = DST_NOXFRM;
+       rt->dst.ops = &fake_dst_ops;
  }
  
  static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)
@@@ -244,7 -244,8 +244,7 @@@ static int br_nf_pre_routing_finish_ipv
                kfree_skb(skb);
                return 0;
        }
-       skb_dst_set_noref(skb, &rt->u.dst);
 -      dst_hold(&rt->dst);
 -      skb_dst_set(skb, &rt->dst);
++      skb_dst_set_noref(skb, &rt->dst);
  
        skb->dev = nf_bridge->physindev;
        nf_bridge_update_protocol(skb);
@@@ -395,7 -396,8 +395,7 @@@ bridged_dnat
                        kfree_skb(skb);
                        return 0;
                }
-               skb_dst_set_noref(skb, &rt->u.dst);
 -              dst_hold(&rt->dst);
 -              skb_dst_set(skb, &rt->dst);
++              skb_dst_set_noref(skb, &rt->dst);
        }
  
        skb->dev = nf_bridge->physindev;
diff --combined net/ipv4/netfilter.c
index acd1ea87ba51bda60f7aa3f14d809fa33eeffde5,cfbc79af21c3093ee3ba87e94963500564fdec85..d88a46c54fd1bbb62a6f9ed13570c518940666b5
@@@ -43,7 -43,7 +43,7 @@@ int ip_route_me_harder(struct sk_buff *
  
                /* Drop old route. */
                skb_dst_drop(skb);
-               skb_dst_set(skb, &rt->u.dst);
+               skb_dst_set(skb, &rt->dst);
        } else {
                /* non-local src, find valid iif to satisfy
                 * rp-filter when calling ip_route_input. */
  
                orefdst = skb->_skb_refdst;
                if (ip_route_input(skb, iph->daddr, iph->saddr,
-                                  RT_TOS(iph->tos), rt->u.dst.dev) != 0) {
-                       dst_release(&rt->u.dst);
+                                  RT_TOS(iph->tos), rt->dst.dev) != 0) {
+                       dst_release(&rt->dst);
                        return -1;
                }
-               dst_release(&rt->u.dst);
+               dst_release(&rt->dst);
                refdst_drop(orefdst);
        }
  
@@@ -212,7 -212,9 +212,7 @@@ static __sum16 nf_ip_checksum_partial(s
                skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr, protocol,
                                               skb->len - dataoff, 0);
                skb->ip_summed = CHECKSUM_NONE;
 -              csum = __skb_checksum_complete_head(skb, dataoff + len);
 -              if (!csum)
 -                      skb->ip_summed = CHECKSUM_UNNECESSARY;
 +              return __skb_checksum_complete_head(skb, dataoff + len);
        }
        return csum;
  }
index 7c0b8ad61f9dc4b2ab6e1002116253e64c42106c,4b6c5ca610fc0a463db4995e8b58393916e0a35c..b38c11810c65938513282a9e8a0699317dad231a
@@@ -336,7 -336,7 +336,7 @@@ ipt_do_table(struct sk_buff *skb
        cpu        = smp_processor_id();
        table_base = private->entries[cpu];
        jumpstack  = (struct ipt_entry **)private->jumpstack[cpu];
-       stackptr   = &private->stackptr[cpu];
+       stackptr   = per_cpu_ptr(private->stackptr, cpu);
        origptr    = *stackptr;
  
        e = get_entry(table_base, private->hook_entry[hook]);
@@@ -928,7 -928,7 +928,7 @@@ static struct xt_counters *alloc_counte
           (other than comefrom, which userspace doesn't care
           about). */
        countersize = sizeof(struct xt_counters) * private->number;
 -      counters = vmalloc_node(countersize, numa_node_id());
 +      counters = vmalloc(countersize);
  
        if (counters == NULL)
                return ERR_PTR(-ENOMEM);
@@@ -1352,7 -1352,7 +1352,7 @@@ do_add_counters(struct net *net, const 
        if (len != size + num_counters * sizeof(struct xt_counters))
                return -EINVAL;
  
 -      paddc = vmalloc_node(len - size, numa_node_id());
 +      paddc = vmalloc(len - size);
        if (!paddc)
                return -ENOMEM;
  
index 82945ef6c9fc44b8c9c1b75915213e3faa430914,9d2d68f0e6053d97fdfc3f350135604309a35808..dc41d6d3c6c6a6fb6e74b57fe12575362123aedf
@@@ -363,7 -363,7 +363,7 @@@ ip6t_do_table(struct sk_buff *skb
        cpu        = smp_processor_id();
        table_base = private->entries[cpu];
        jumpstack  = (struct ip6t_entry **)private->jumpstack[cpu];
-       stackptr   = &private->stackptr[cpu];
+       stackptr   = per_cpu_ptr(private->stackptr, cpu);
        origptr    = *stackptr;
  
        e = get_entry(table_base, private->hook_entry[hook]);
@@@ -943,7 -943,7 +943,7 @@@ static struct xt_counters *alloc_counte
           (other than comefrom, which userspace doesn't care
           about). */
        countersize = sizeof(struct xt_counters) * private->number;
 -      counters = vmalloc_node(countersize, numa_node_id());
 +      counters = vmalloc(countersize);
  
        if (counters == NULL)
                return ERR_PTR(-ENOMEM);
@@@ -1213,7 -1213,8 +1213,7 @@@ __do_replace(struct net *net, const cha
        struct ip6t_entry *iter;
  
        ret = 0;
 -      counters = vmalloc_node(num_counters * sizeof(struct xt_counters),
 -                              numa_node_id());
 +      counters = vmalloc(num_counters * sizeof(struct xt_counters));
        if (!counters) {
                ret = -ENOMEM;
                goto out;
@@@ -1367,7 -1368,7 +1367,7 @@@ do_add_counters(struct net *net, const 
        if (len != size + num_counters * sizeof(struct xt_counters))
                return -EINVAL;
  
 -      paddc = vmalloc_node(len - size, numa_node_id());
 +      paddc = vmalloc(len - size);
        if (!paddc)
                return -ENOMEM;
  
index 9c661413b826b50bbebcceff360fcab4fa92a261,77288980fae017d8694df9d4c5efccd8b18d23b4..16b41b4e2a3c18a4b7979f19d51a91a9427761ae
@@@ -62,8 -62,8 +62,8 @@@ EXPORT_SYMBOL_GPL(nf_conntrack_htable_s
  unsigned int nf_conntrack_max __read_mostly;
  EXPORT_SYMBOL_GPL(nf_conntrack_max);
  
 -struct nf_conn nf_conntrack_untracked __read_mostly;
 -EXPORT_SYMBOL_GPL(nf_conntrack_untracked);
 +DEFINE_PER_CPU(struct nf_conn, nf_conntrack_untracked);
 +EXPORT_PER_CPU_SYMBOL(nf_conntrack_untracked);
  
  static int nf_conntrack_hash_rnd_initted;
  static unsigned int nf_conntrack_hash_rnd;
@@@ -619,9 -619,7 +619,7 @@@ struct nf_conn *nf_conntrack_alloc(stru
        ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev = NULL;
        /* Don't set timer yet: wait for confirmation */
        setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct);
- #ifdef CONFIG_NET_NS
-       ct->ct_net = net;
- #endif
+       write_pnet(&ct->ct_net, net);
  #ifdef CONFIG_NF_CONNTRACK_ZONES
        if (zone) {
                struct nf_conntrack_zone *nf_ct_zone;
@@@ -1183,21 -1181,10 +1181,21 @@@ static void nf_ct_release_dying_list(st
        spin_unlock_bh(&nf_conntrack_lock);
  }
  
 +static int untrack_refs(void)
 +{
 +      int cnt = 0, cpu;
 +
 +      for_each_possible_cpu(cpu) {
 +              struct nf_conn *ct = &per_cpu(nf_conntrack_untracked, cpu);
 +
 +              cnt += atomic_read(&ct->ct_general.use) - 1;
 +      }
 +      return cnt;
 +}
 +
  static void nf_conntrack_cleanup_init_net(void)
  {
 -      /* wait until all references to nf_conntrack_untracked are dropped */
 -      while (atomic_read(&nf_conntrack_untracked.ct_general.use) > 1)
 +      while (untrack_refs() > 0)
                schedule();
  
        nf_conntrack_helper_fini();
@@@ -1332,19 -1319,10 +1330,19 @@@ EXPORT_SYMBOL_GPL(nf_conntrack_set_hash
  module_param_call(hashsize, nf_conntrack_set_hashsize, param_get_uint,
                  &nf_conntrack_htable_size, 0600);
  
 +void nf_ct_untracked_status_or(unsigned long bits)
 +{
 +      int cpu;
 +
 +      for_each_possible_cpu(cpu)
 +              per_cpu(nf_conntrack_untracked, cpu).status |= bits;
 +}
 +EXPORT_SYMBOL_GPL(nf_ct_untracked_status_or);
 +
  static int nf_conntrack_init_init_net(void)
  {
        int max_factor = 8;
 -      int ret;
 +      int ret, cpu;
  
        /* Idea from tcp.c: use 1/16384 of memory.  On i386: 32MB
         * machine has 512 buckets. >= 1GB machines have 16384 buckets. */
                goto err_extend;
  #endif
        /* Set up fake conntrack: to never be deleted, not in any hashes */
 -      write_pnet(&nf_conntrack_untracked.ct_net, &init_net);
 -      atomic_set(&nf_conntrack_untracked.ct_general.use, 1);
 +      for_each_possible_cpu(cpu) {
 +              struct nf_conn *ct = &per_cpu(nf_conntrack_untracked, cpu);
 +              write_pnet(&ct->ct_net, &init_net);
 +              atomic_set(&ct->ct_general.use, 1);
 +      }
        /*  - and look it like as a confirmed connection */
 -      set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status);
 -
 +      nf_ct_untracked_status_or(IPS_CONFIRMED | IPS_UNTRACKED);
        return 0;
  
  #ifdef CONFIG_NF_CONNTRACK_ZONES
diff --combined net/netfilter/xt_TEE.c
index 7a118267c4c4ff4b0ec3874cf086d1cf9a7189c4,c77a85bbd9ebc4b6bd10e95ebd19c663ab2ee9ef..22a2d421e7ebc5172761d51caea4298d47d7ebfb
@@@ -77,8 -77,8 +77,8 @@@ tee_tg_route4(struct sk_buff *skb, cons
                return false;
  
        skb_dst_drop(skb);
-       skb_dst_set(skb, &rt->u.dst);
-       skb->dev      = rt->u.dst.dev;
+       skb_dst_set(skb, &rt->dst);
+       skb->dev      = rt->dst.dev;
        skb->protocol = htons(ETH_P_IP);
        return true;
  }
@@@ -104,7 -104,7 +104,7 @@@ tee_tg4(struct sk_buff *skb, const stru
  #ifdef WITH_CONNTRACK
        /* Avoid counting cloned packets towards the original connection. */
        nf_conntrack_put(skb->nfct);
 -      skb->nfct     = &nf_conntrack_untracked.ct_general;
 +      skb->nfct     = &nf_ct_untracked_get()->ct_general;
        skb->nfctinfo = IP_CT_NEW;
        nf_conntrack_get(skb->nfct);
  #endif
@@@ -177,7 -177,7 +177,7 @@@ tee_tg6(struct sk_buff *skb, const stru
  
  #ifdef WITH_CONNTRACK
        nf_conntrack_put(skb->nfct);
 -      skb->nfct     = &nf_conntrack_untracked.ct_general;
 +      skb->nfct     = &nf_ct_untracked_get()->ct_general;
        skb->nfctinfo = IP_CT_NEW;
        nf_conntrack_get(skb->nfct);
  #endif