Commit b1109bf085c8dd69537b7876ea83f914dd1fe46a

Authored by David S. Miller

Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

Showing 27 changed files Side-by-side Diff

... ... @@ -3836,6 +3836,7 @@
3836 3836 L: netdev@vger.kernel.org
3837 3837 W: http://www.linuxfoundation.org/en/Net
3838 3838 T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git
  3839 +T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
3839 3840 S: Odd Fixes
3840 3841 F: drivers/net/
3841 3842 F: include/linux/if_*
drivers/bluetooth/btmrvl_sdio.c
... ... @@ -808,6 +808,7 @@
808 808  
809 809 exit:
810 810 sdio_release_host(card->func);
  811 + kfree(tmpbuf);
811 812  
812 813 return ret;
813 814 }
drivers/net/ax88796.c
... ... @@ -921,7 +921,7 @@
921 921 size = (res->end - res->start) + 1;
922 922  
923 923 ax->mem2 = request_mem_region(res->start, size, pdev->name);
924   - if (ax->mem == NULL) {
  924 + if (ax->mem2 == NULL) {
925 925 dev_err(&pdev->dev, "cannot reserve registers\n");
926 926 ret = -ENXIO;
927 927 goto exit_mem1;
drivers/net/cxgb3/sge.c
... ... @@ -2080,6 +2080,7 @@
2080 2080 struct sge_fl *fl, int len, int complete)
2081 2081 {
2082 2082 struct rx_sw_desc *sd = &fl->sdesc[fl->cidx];
  2083 + struct port_info *pi = netdev_priv(qs->netdev);
2083 2084 struct sk_buff *skb = NULL;
2084 2085 struct cpl_rx_pkt *cpl;
2085 2086 struct skb_frag_struct *rx_frag;
2086 2087  
2087 2088  
... ... @@ -2117,12 +2118,19 @@
2117 2118  
2118 2119 if (!nr_frags) {
2119 2120 offset = 2 + sizeof(struct cpl_rx_pkt);
2120   - qs->lro_va = sd->pg_chunk.va + 2;
2121   - }
2122   - len -= offset;
  2121 + cpl = qs->lro_va = sd->pg_chunk.va + 2;
2123 2122  
2124   - prefetch(qs->lro_va);
  2123 + if ((pi->rx_offload & T3_RX_CSUM) &&
  2124 + cpl->csum_valid && cpl->csum == htons(0xffff)) {
  2125 + skb->ip_summed = CHECKSUM_UNNECESSARY;
  2126 + qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++;
  2127 + } else
  2128 + skb->ip_summed = CHECKSUM_NONE;
  2129 + } else
  2130 + cpl = qs->lro_va;
2125 2131  
  2132 + len -= offset;
  2133 +
2126 2134 rx_frag += nr_frags;
2127 2135 rx_frag->page = sd->pg_chunk.page;
2128 2136 rx_frag->page_offset = sd->pg_chunk.offset + offset;
2129 2137  
... ... @@ -2137,12 +2145,8 @@
2137 2145 return;
2138 2146  
2139 2147 skb_record_rx_queue(skb, qs - &adap->sge.qs[0]);
2140   - skb->ip_summed = CHECKSUM_UNNECESSARY;
2141   - cpl = qs->lro_va;
2142 2148  
2143 2149 if (unlikely(cpl->vlan_valid)) {
2144   - struct net_device *dev = qs->netdev;
2145   - struct port_info *pi = netdev_priv(dev);
2146 2150 struct vlan_group *grp = pi->vlan_grp;
2147 2151  
2148 2152 if (likely(grp != NULL)) {
drivers/net/igb/igb_main.c
... ... @@ -421,6 +421,8 @@
421 421 msixbm = E1000_EICR_RX_QUEUE0 << rx_queue;
422 422 if (tx_queue > IGB_N0_QUEUE)
423 423 msixbm |= E1000_EICR_TX_QUEUE0 << tx_queue;
  424 + if (!adapter->msix_entries && msix_vector == 0)
  425 + msixbm |= E1000_EIMS_OTHER;
424 426 array_wr32(E1000_MSIXBM(0), msix_vector, msixbm);
425 427 q_vector->eims_value = msixbm;
426 428 break;
... ... @@ -877,7 +879,6 @@
877 879 {
878 880 struct net_device *netdev = adapter->netdev;
879 881 struct pci_dev *pdev = adapter->pdev;
880   - struct e1000_hw *hw = &adapter->hw;
881 882 int err = 0;
882 883  
883 884 if (adapter->msix_entries) {
... ... @@ -909,20 +910,7 @@
909 910 igb_setup_all_tx_resources(adapter);
910 911 igb_setup_all_rx_resources(adapter);
911 912 } else {
912   - switch (hw->mac.type) {
913   - case e1000_82575:
914   - wr32(E1000_MSIXBM(0),
915   - (E1000_EICR_RX_QUEUE0 |
916   - E1000_EICR_TX_QUEUE0 |
917   - E1000_EIMS_OTHER));
918   - break;
919   - case e1000_82580:
920   - case e1000_82576:
921   - wr32(E1000_IVAR0, E1000_IVAR_VALID);
922   - break;
923   - default:
924   - break;
925   - }
  913 + igb_assign_vector(adapter->q_vector[0], 0);
926 914 }
927 915  
928 916 if (adapter->flags & IGB_FLAG_HAS_MSI) {
... ... @@ -1140,6 +1128,8 @@
1140 1128 }
1141 1129 if (adapter->msix_entries)
1142 1130 igb_configure_msix(adapter);
  1131 + else
  1132 + igb_assign_vector(adapter->q_vector[0], 0);
1143 1133  
1144 1134 /* Clear any pending interrupts. */
1145 1135 rd32(E1000_ICR);
include/net/netns/conntrack.h
... ... @@ -11,6 +11,8 @@
11 11 struct netns_ct {
12 12 atomic_t count;
13 13 unsigned int expect_count;
  14 + unsigned int htable_size;
  15 + struct kmem_cache *nf_conntrack_cachep;
14 16 struct hlist_nulls_head *hash;
15 17 struct hlist_head *expect_hash;
16 18 struct hlist_nulls_head unconfirmed;
... ... @@ -28,6 +30,7 @@
28 30 #endif
29 31 int hash_vmalloc;
30 32 int expect_vmalloc;
  33 + char *slabname;
31 34 };
32 35 #endif
include/net/netns/ipv4.h
... ... @@ -40,6 +40,7 @@
40 40 struct xt_table *iptable_security;
41 41 struct xt_table *nat_table;
42 42 struct hlist_head *nat_bysource;
  43 + unsigned int nat_htable_size;
43 44 int nat_vmalloced;
44 45 #endif
45 46  
net/bluetooth/hci_conn.c
... ... @@ -377,6 +377,9 @@
377 377  
378 378 if (acl->state == BT_CONNECTED &&
379 379 (sco->state == BT_OPEN || sco->state == BT_CLOSED)) {
  380 + acl->power_save = 1;
  381 + hci_conn_enter_active_mode(acl);
  382 +
380 383 if (lmp_esco_capable(hdev))
381 384 hci_setup_sync(sco, acl->handle);
382 385 else
net/bluetooth/hci_event.c
... ... @@ -1699,6 +1699,7 @@
1699 1699 break;
1700 1700  
1701 1701 case 0x1c: /* SCO interval rejected */
  1702 + case 0x1a: /* Unsupported Remote Feature */
1702 1703 case 0x1f: /* Unspecified error */
1703 1704 if (conn->out && conn->attempt < 2) {
1704 1705 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) |
net/bluetooth/hidp/core.c
... ... @@ -703,29 +703,9 @@
703 703 static int hidp_parse(struct hid_device *hid)
704 704 {
705 705 struct hidp_session *session = hid->driver_data;
706   - struct hidp_connadd_req *req = session->req;
707   - unsigned char *buf;
708   - int ret;
709 706  
710   - buf = kmalloc(req->rd_size, GFP_KERNEL);
711   - if (!buf)
712   - return -ENOMEM;
713   -
714   - if (copy_from_user(buf, req->rd_data, req->rd_size)) {
715   - kfree(buf);
716   - return -EFAULT;
717   - }
718   -
719   - ret = hid_parse_report(session->hid, buf, req->rd_size);
720   -
721   - kfree(buf);
722   -
723   - if (ret)
724   - return ret;
725   -
726   - session->req = NULL;
727   -
728   - return 0;
  707 + return hid_parse_report(session->hid, session->rd_data,
  708 + session->rd_size);
729 709 }
730 710  
731 711 static int hidp_start(struct hid_device *hid)
732 712  
733 713  
... ... @@ -770,12 +750,24 @@
770 750 bdaddr_t src, dst;
771 751 int err;
772 752  
  753 + session->rd_data = kzalloc(req->rd_size, GFP_KERNEL);
  754 + if (!session->rd_data)
  755 + return -ENOMEM;
  756 +
  757 + if (copy_from_user(session->rd_data, req->rd_data, req->rd_size)) {
  758 + err = -EFAULT;
  759 + goto fault;
  760 + }
  761 + session->rd_size = req->rd_size;
  762 +
773 763 hid = hid_allocate_device();
774   - if (IS_ERR(hid))
775   - return PTR_ERR(hid);
  764 + if (IS_ERR(hid)) {
  765 + err = PTR_ERR(hid);
  766 + goto fault;
  767 + }
776 768  
777 769 session->hid = hid;
778   - session->req = req;
  770 +
779 771 hid->driver_data = session;
780 772  
781 773 baswap(&src, &bt_sk(session->ctrl_sock->sk)->src);
... ... @@ -806,6 +798,10 @@
806 798 hid_destroy_device(hid);
807 799 session->hid = NULL;
808 800  
  801 +fault:
  802 + kfree(session->rd_data);
  803 + session->rd_data = NULL;
  804 +
809 805 return err;
810 806 }
811 807  
... ... @@ -899,6 +895,9 @@
899 895 hid_destroy_device(session->hid);
900 896 session->hid = NULL;
901 897 }
  898 +
  899 + kfree(session->rd_data);
  900 + session->rd_data = NULL;
902 901  
903 902 purge:
904 903 skb_queue_purge(&session->ctrl_transmit);
net/bluetooth/hidp/hidp.h
... ... @@ -154,7 +154,9 @@
154 154 struct sk_buff_head ctrl_transmit;
155 155 struct sk_buff_head intr_transmit;
156 156  
157   - struct hidp_connadd_req *req;
  157 + /* Report descriptor */
  158 + __u8 *rd_data;
  159 + uint rd_size;
158 160 };
159 161  
160 162 static inline void hidp_schedule(struct hidp_session *session)
net/bluetooth/rfcomm/core.c
... ... @@ -252,7 +252,6 @@
252 252 BT_DBG("session %p state %ld", s, s->state);
253 253  
254 254 set_bit(RFCOMM_TIMED_OUT, &s->flags);
255   - rfcomm_session_put(s);
256 255 rfcomm_schedule(RFCOMM_SCHED_TIMEO);
257 256 }
258 257  
... ... @@ -1151,7 +1150,11 @@
1151 1150 break;
1152 1151  
1153 1152 case BT_DISCONN:
1154   - rfcomm_session_put(s);
  1153 + /* When socket is closed and we are not RFCOMM
  1154 + * initiator rfcomm_process_rx already calls
  1155 + * rfcomm_session_put() */
  1156 + if (s->sock->sk->sk_state != BT_CLOSED)
  1157 + rfcomm_session_put(s);
1155 1158 break;
1156 1159 }
1157 1160 }
... ... @@ -1920,6 +1923,7 @@
1920 1923 if (test_and_clear_bit(RFCOMM_TIMED_OUT, &s->flags)) {
1921 1924 s->state = BT_DISCONN;
1922 1925 rfcomm_send_disc(s, 0);
  1926 + rfcomm_session_put(s);
1923 1927 continue;
1924 1928 }
1925 1929  
... ... @@ -17,6 +17,7 @@
17 17 #include <linux/string.h>
18 18 #include <linux/types.h>
19 19 #include <net/net_namespace.h>
  20 +#include <linux/sched.h>
20 21  
21 22 #include <net/dst.h>
22 23  
... ... @@ -79,6 +80,7 @@
79 80 while ((dst = next) != NULL) {
80 81 next = dst->next;
81 82 prefetch(&next->next);
  83 + cond_resched();
82 84 if (likely(atomic_read(&dst->__refcnt))) {
83 85 last->next = dst;
84 86 last = dst;
... ... @@ -3524,6 +3524,7 @@
3524 3524 wait_event_interruptible_timeout(t->queue,
3525 3525 t->control != 0,
3526 3526 HZ/10);
  3527 + try_to_freeze();
3527 3528 continue;
3528 3529 }
3529 3530  
net/ipv4/netfilter/arp_tables.c
... ... @@ -925,10 +925,10 @@
925 925 if (t && !IS_ERR(t)) {
926 926 struct arpt_getinfo info;
927 927 const struct xt_table_info *private = t->private;
928   -
929 928 #ifdef CONFIG_COMPAT
  929 + struct xt_table_info tmp;
  930 +
930 931 if (compat) {
931   - struct xt_table_info tmp;
932 932 ret = compat_table_info(private, &tmp);
933 933 xt_compat_flush_offsets(NFPROTO_ARP);
934 934 private = &tmp;
net/ipv4/netfilter/ip_tables.c
... ... @@ -1132,10 +1132,10 @@
1132 1132 if (t && !IS_ERR(t)) {
1133 1133 struct ipt_getinfo info;
1134 1134 const struct xt_table_info *private = t->private;
1135   -
1136 1135 #ifdef CONFIG_COMPAT
  1136 + struct xt_table_info tmp;
  1137 +
1137 1138 if (compat) {
1138   - struct xt_table_info tmp;
1139 1139 ret = compat_table_info(private, &tmp);
1140 1140 xt_compat_flush_offsets(AF_INET);
1141 1141 private = &tmp;
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
... ... @@ -210,7 +210,7 @@
210 210 },
211 211 {
212 212 .procname = "ip_conntrack_buckets",
213   - .data = &nf_conntrack_htable_size,
  213 + .data = &init_net.ct.htable_size,
214 214 .maxlen = sizeof(unsigned int),
215 215 .mode = 0444,
216 216 .proc_handler = proc_dointvec,
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
... ... @@ -32,7 +32,7 @@
32 32 struct hlist_nulls_node *n;
33 33  
34 34 for (st->bucket = 0;
35   - st->bucket < nf_conntrack_htable_size;
  35 + st->bucket < net->ct.htable_size;
36 36 st->bucket++) {
37 37 n = rcu_dereference(net->ct.hash[st->bucket].first);
38 38 if (!is_a_nulls(n))
... ... @@ -50,7 +50,7 @@
50 50 head = rcu_dereference(head->next);
51 51 while (is_a_nulls(head)) {
52 52 if (likely(get_nulls_value(head) == st->bucket)) {
53   - if (++st->bucket >= nf_conntrack_htable_size)
  53 + if (++st->bucket >= net->ct.htable_size)
54 54 return NULL;
55 55 }
56 56 head = rcu_dereference(net->ct.hash[st->bucket].first);
net/ipv4/netfilter/nf_nat_core.c
... ... @@ -35,9 +35,6 @@
35 35  
36 36 static struct nf_conntrack_l3proto *l3proto __read_mostly;
37 37  
38   -/* Calculated at init based on memory size */
39   -static unsigned int nf_nat_htable_size __read_mostly;
40   -
41 38 #define MAX_IP_NAT_PROTO 256
42 39 static const struct nf_nat_protocol *nf_nat_protos[MAX_IP_NAT_PROTO]
43 40 __read_mostly;
... ... @@ -72,7 +69,7 @@
72 69  
73 70 /* We keep an extra hash for each conntrack, for fast searching. */
74 71 static inline unsigned int
75   -hash_by_src(const struct nf_conntrack_tuple *tuple)
  72 +hash_by_src(const struct net *net, const struct nf_conntrack_tuple *tuple)
76 73 {
77 74 unsigned int hash;
78 75  
... ... @@ -80,7 +77,7 @@
80 77 hash = jhash_3words((__force u32)tuple->src.u3.ip,
81 78 (__force u32)tuple->src.u.all,
82 79 tuple->dst.protonum, 0);
83   - return ((u64)hash * nf_nat_htable_size) >> 32;
  80 + return ((u64)hash * net->ipv4.nat_htable_size) >> 32;
84 81 }
85 82  
86 83 /* Is this tuple already taken? (not by us) */
... ... @@ -147,7 +144,7 @@
147 144 struct nf_conntrack_tuple *result,
148 145 const struct nf_nat_range *range)
149 146 {
150   - unsigned int h = hash_by_src(tuple);
  147 + unsigned int h = hash_by_src(net, tuple);
151 148 const struct nf_conn_nat *nat;
152 149 const struct nf_conn *ct;
153 150 const struct hlist_node *n;
... ... @@ -330,7 +327,7 @@
330 327 if (have_to_hash) {
331 328 unsigned int srchash;
332 329  
333   - srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
  330 + srchash = hash_by_src(net, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
334 331 spin_lock_bh(&nf_nat_lock);
335 332 /* nf_conntrack_alter_reply might re-allocate exntension aera */
336 333 nat = nfct_nat(ct);
... ... @@ -679,8 +676,10 @@
679 676  
680 677 static int __net_init nf_nat_net_init(struct net *net)
681 678 {
682   - net->ipv4.nat_bysource = nf_ct_alloc_hashtable(&nf_nat_htable_size,
683   - &net->ipv4.nat_vmalloced, 0);
  679 + /* Leave them the same for the moment. */
  680 + net->ipv4.nat_htable_size = net->ct.htable_size;
  681 + net->ipv4.nat_bysource = nf_ct_alloc_hashtable(&net->ipv4.nat_htable_size,
  682 + &net->ipv4.nat_vmalloced, 0);
684 683 if (!net->ipv4.nat_bysource)
685 684 return -ENOMEM;
686 685 return 0;
... ... @@ -703,7 +702,7 @@
703 702 nf_ct_iterate_cleanup(net, &clean_nat, NULL);
704 703 synchronize_rcu();
705 704 nf_ct_free_hashtable(net->ipv4.nat_bysource, net->ipv4.nat_vmalloced,
706   - nf_nat_htable_size);
  705 + net->ipv4.nat_htable_size);
707 706 }
708 707  
709 708 static struct pernet_operations nf_nat_net_ops = {
... ... @@ -723,9 +722,6 @@
723 722 printk(KERN_ERR "nf_nat_core: Unable to register extension\n");
724 723 return ret;
725 724 }
726   -
727   - /* Leave them the same for the moment. */
728   - nf_nat_htable_size = nf_conntrack_htable_size;
729 725  
730 726 ret = register_pernet_subsys(&nf_nat_net_ops);
731 727 if (ret < 0)
net/ipv6/netfilter/ip6_tables.c
... ... @@ -1164,10 +1164,10 @@
1164 1164 if (t && !IS_ERR(t)) {
1165 1165 struct ip6t_getinfo info;
1166 1166 const struct xt_table_info *private = t->private;
1167   -
1168 1167 #ifdef CONFIG_COMPAT
  1168 + struct xt_table_info tmp;
  1169 +
1169 1170 if (compat) {
1170   - struct xt_table_info tmp;
1171 1171 ret = compat_table_info(private, &tmp);
1172 1172 xt_compat_flush_offsets(AF_INET6);
1173 1173 private = &tmp;
net/irda/irnet/irnet_ppp.c
... ... @@ -698,15 +698,18 @@
698 698  
699 699 /* Query PPP channel and unit number */
700 700 case PPPIOCGCHAN:
  701 + lock_kernel();
701 702 if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan),
702 703 (int __user *)argp))
703 704 err = 0;
  705 + unlock_kernel();
704 706 break;
705 707 case PPPIOCGUNIT:
706 708 lock_kernel();
707 709 if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan),
708 710 (int __user *)argp))
709   - err = 0;
  711 + err = 0;
  712 + unlock_kernel();
710 713 break;
711 714  
712 715 /* All these ioctls can be passed both directly and from ppp_generic,
net/netfilter/nf_conntrack_core.c
... ... @@ -30,6 +30,7 @@
30 30 #include <linux/netdevice.h>
31 31 #include <linux/socket.h>
32 32 #include <linux/mm.h>
  33 +#include <linux/nsproxy.h>
33 34 #include <linux/rculist_nulls.h>
34 35  
35 36 #include <net/netfilter/nf_conntrack.h>
... ... @@ -63,8 +64,6 @@
63 64 struct nf_conn nf_conntrack_untracked __read_mostly;
64 65 EXPORT_SYMBOL_GPL(nf_conntrack_untracked);
65 66  
66   -static struct kmem_cache *nf_conntrack_cachep __read_mostly;
67   -
68 67 static int nf_conntrack_hash_rnd_initted;
69 68 static unsigned int nf_conntrack_hash_rnd;
70 69  
71 70  
... ... @@ -86,9 +85,10 @@
86 85 return ((u64)h * size) >> 32;
87 86 }
88 87  
89   -static inline u_int32_t hash_conntrack(const struct nf_conntrack_tuple *tuple)
  88 +static inline u_int32_t hash_conntrack(const struct net *net,
  89 + const struct nf_conntrack_tuple *tuple)
90 90 {
91   - return __hash_conntrack(tuple, nf_conntrack_htable_size,
  91 + return __hash_conntrack(tuple, net->ct.htable_size,
92 92 nf_conntrack_hash_rnd);
93 93 }
94 94  
... ... @@ -296,7 +296,7 @@
296 296 {
297 297 struct nf_conntrack_tuple_hash *h;
298 298 struct hlist_nulls_node *n;
299   - unsigned int hash = hash_conntrack(tuple);
  299 + unsigned int hash = hash_conntrack(net, tuple);
300 300  
301 301 /* Disable BHs the entire time since we normally need to disable them
302 302 * at least once for the stats anyway.
303 303  
... ... @@ -366,10 +366,11 @@
366 366  
367 367 void nf_conntrack_hash_insert(struct nf_conn *ct)
368 368 {
  369 + struct net *net = nf_ct_net(ct);
369 370 unsigned int hash, repl_hash;
370 371  
371   - hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
372   - repl_hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
  372 + hash = hash_conntrack(net, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
  373 + repl_hash = hash_conntrack(net, &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
373 374  
374 375 __nf_conntrack_hash_insert(ct, hash, repl_hash);
375 376 }
... ... @@ -397,8 +398,8 @@
397 398 if (CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL)
398 399 return NF_ACCEPT;
399 400  
400   - hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
401   - repl_hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
  401 + hash = hash_conntrack(net, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
  402 + repl_hash = hash_conntrack(net, &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
402 403  
403 404 /* We're not in hash table, and we refuse to set up related
404 405 connections for unconfirmed conns. But packet copies and
... ... @@ -468,7 +469,7 @@
468 469 struct net *net = nf_ct_net(ignored_conntrack);
469 470 struct nf_conntrack_tuple_hash *h;
470 471 struct hlist_nulls_node *n;
471   - unsigned int hash = hash_conntrack(tuple);
  472 + unsigned int hash = hash_conntrack(net, tuple);
472 473  
473 474 /* Disable BHs the entire time since we need to disable them at
474 475 * least once for the stats anyway.
... ... @@ -503,7 +504,7 @@
503 504 int dropped = 0;
504 505  
505 506 rcu_read_lock();
506   - for (i = 0; i < nf_conntrack_htable_size; i++) {
  507 + for (i = 0; i < net->ct.htable_size; i++) {
507 508 hlist_nulls_for_each_entry_rcu(h, n, &net->ct.hash[hash],
508 509 hnnode) {
509 510 tmp = nf_ct_tuplehash_to_ctrack(h);
... ... @@ -523,7 +524,7 @@
523 524 if (cnt >= NF_CT_EVICTION_RANGE)
524 525 break;
525 526  
526   - hash = (hash + 1) % nf_conntrack_htable_size;
  527 + hash = (hash + 1) % net->ct.htable_size;
527 528 }
528 529 rcu_read_unlock();
529 530  
... ... @@ -557,7 +558,7 @@
557 558  
558 559 if (nf_conntrack_max &&
559 560 unlikely(atomic_read(&net->ct.count) > nf_conntrack_max)) {
560   - unsigned int hash = hash_conntrack(orig);
  561 + unsigned int hash = hash_conntrack(net, orig);
561 562 if (!early_drop(net, hash)) {
562 563 atomic_dec(&net->ct.count);
563 564 if (net_ratelimit())
... ... @@ -572,7 +573,7 @@
572 573 * Do not use kmem_cache_zalloc(), as this cache uses
573 574 * SLAB_DESTROY_BY_RCU.
574 575 */
575   - ct = kmem_cache_alloc(nf_conntrack_cachep, gfp);
  576 + ct = kmem_cache_alloc(net->ct.nf_conntrack_cachep, gfp);
576 577 if (ct == NULL) {
577 578 pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n");
578 579 atomic_dec(&net->ct.count);
... ... @@ -611,7 +612,7 @@
611 612 nf_ct_ext_destroy(ct);
612 613 atomic_dec(&net->ct.count);
613 614 nf_ct_ext_free(ct);
614   - kmem_cache_free(nf_conntrack_cachep, ct);
  615 + kmem_cache_free(net->ct.nf_conntrack_cachep, ct);
615 616 }
616 617 EXPORT_SYMBOL_GPL(nf_conntrack_free);
617 618  
... ... @@ -1014,7 +1015,7 @@
1014 1015 struct hlist_nulls_node *n;
1015 1016  
1016 1017 spin_lock_bh(&nf_conntrack_lock);
1017   - for (; *bucket < nf_conntrack_htable_size; (*bucket)++) {
  1018 + for (; *bucket < net->ct.htable_size; (*bucket)++) {
1018 1019 hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) {
1019 1020 ct = nf_ct_tuplehash_to_ctrack(h);
1020 1021 if (iter(ct, data))
1021 1022  
... ... @@ -1113,9 +1114,12 @@
1113 1114  
1114 1115 static void nf_conntrack_cleanup_init_net(void)
1115 1116 {
  1117 + /* wait until all references to nf_conntrack_untracked are dropped */
  1118 + while (atomic_read(&nf_conntrack_untracked.ct_general.use) > 1)
  1119 + schedule();
  1120 +
1116 1121 nf_conntrack_helper_fini();
1117 1122 nf_conntrack_proto_fini();
1118   - kmem_cache_destroy(nf_conntrack_cachep);
1119 1123 }
1120 1124  
1121 1125 static void nf_conntrack_cleanup_net(struct net *net)
1122 1126  
1123 1127  
... ... @@ -1127,15 +1131,14 @@
1127 1131 schedule();
1128 1132 goto i_see_dead_people;
1129 1133 }
1130   - /* wait until all references to nf_conntrack_untracked are dropped */
1131   - while (atomic_read(&nf_conntrack_untracked.ct_general.use) > 1)
1132   - schedule();
1133 1134  
1134 1135 nf_ct_free_hashtable(net->ct.hash, net->ct.hash_vmalloc,
1135   - nf_conntrack_htable_size);
  1136 + net->ct.htable_size);
1136 1137 nf_conntrack_ecache_fini(net);
1137 1138 nf_conntrack_acct_fini(net);
1138 1139 nf_conntrack_expect_fini(net);
  1140 + kmem_cache_destroy(net->ct.nf_conntrack_cachep);
  1141 + kfree(net->ct.slabname);
1139 1142 free_percpu(net->ct.stat);
1140 1143 }
1141 1144  
1142 1145  
... ... @@ -1190,10 +1193,12 @@
1190 1193 {
1191 1194 int i, bucket, vmalloced, old_vmalloced;
1192 1195 unsigned int hashsize, old_size;
1193   - int rnd;
1194 1196 struct hlist_nulls_head *hash, *old_hash;
1195 1197 struct nf_conntrack_tuple_hash *h;
1196 1198  
  1199 + if (current->nsproxy->net_ns != &init_net)
  1200 + return -EOPNOTSUPP;
  1201 +
1197 1202 /* On boot, we can set this without any fancy locking. */
1198 1203 if (!nf_conntrack_htable_size)
1199 1204 return param_set_uint(val, kp);
1200 1205  
1201 1206  
1202 1207  
1203 1208  
1204 1209  
... ... @@ -1206,33 +1211,29 @@
1206 1211 if (!hash)
1207 1212 return -ENOMEM;
1208 1213  
1209   - /* We have to rehahs for the new table anyway, so we also can
1210   - * use a newrandom seed */
1211   - get_random_bytes(&rnd, sizeof(rnd));
1212   -
1213 1214 /* Lookups in the old hash might happen in parallel, which means we
1214 1215 * might get false negatives during connection lookup. New connections
1215 1216 * created because of a false negative won't make it into the hash
1216 1217 * though since that required taking the lock.
1217 1218 */
1218 1219 spin_lock_bh(&nf_conntrack_lock);
1219   - for (i = 0; i < nf_conntrack_htable_size; i++) {
  1220 + for (i = 0; i < init_net.ct.htable_size; i++) {
1220 1221 while (!hlist_nulls_empty(&init_net.ct.hash[i])) {
1221 1222 h = hlist_nulls_entry(init_net.ct.hash[i].first,
1222 1223 struct nf_conntrack_tuple_hash, hnnode);
1223 1224 hlist_nulls_del_rcu(&h->hnnode);
1224   - bucket = __hash_conntrack(&h->tuple, hashsize, rnd);
  1225 + bucket = __hash_conntrack(&h->tuple, hashsize,
  1226 + nf_conntrack_hash_rnd);
1225 1227 hlist_nulls_add_head_rcu(&h->hnnode, &hash[bucket]);
1226 1228 }
1227 1229 }
1228   - old_size = nf_conntrack_htable_size;
  1230 + old_size = init_net.ct.htable_size;
1229 1231 old_vmalloced = init_net.ct.hash_vmalloc;
1230 1232 old_hash = init_net.ct.hash;
1231 1233  
1232   - nf_conntrack_htable_size = hashsize;
  1234 + init_net.ct.htable_size = nf_conntrack_htable_size = hashsize;
1233 1235 init_net.ct.hash_vmalloc = vmalloced;
1234 1236 init_net.ct.hash = hash;
1235   - nf_conntrack_hash_rnd = rnd;
1236 1237 spin_unlock_bh(&nf_conntrack_lock);
1237 1238  
1238 1239 nf_ct_free_hashtable(old_hash, old_vmalloced, old_size);
... ... @@ -1271,15 +1272,6 @@
1271 1272 NF_CONNTRACK_VERSION, nf_conntrack_htable_size,
1272 1273 nf_conntrack_max);
1273 1274  
1274   - nf_conntrack_cachep = kmem_cache_create("nf_conntrack",
1275   - sizeof(struct nf_conn),
1276   - 0, SLAB_DESTROY_BY_RCU, NULL);
1277   - if (!nf_conntrack_cachep) {
1278   - printk(KERN_ERR "Unable to create nf_conn slab cache\n");
1279   - ret = -ENOMEM;
1280   - goto err_cache;
1281   - }
1282   -
1283 1275 ret = nf_conntrack_proto_init();
1284 1276 if (ret < 0)
1285 1277 goto err_proto;
1286 1278  
... ... @@ -1288,13 +1280,19 @@
1288 1280 if (ret < 0)
1289 1281 goto err_helper;
1290 1282  
  1283 + /* Set up fake conntrack: to never be deleted, not in any hashes */
  1284 +#ifdef CONFIG_NET_NS
  1285 + nf_conntrack_untracked.ct_net = &init_net;
  1286 +#endif
  1287 + atomic_set(&nf_conntrack_untracked.ct_general.use, 1);
  1288 + /* - and look it like as a confirmed connection */
  1289 + set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status);
  1290 +
1291 1291 return 0;
1292 1292  
1293 1293 err_helper:
1294 1294 nf_conntrack_proto_fini();
1295 1295 err_proto:
1296   - kmem_cache_destroy(nf_conntrack_cachep);
1297   -err_cache:
1298 1296 return ret;
1299 1297 }
1300 1298  
... ... @@ -1316,7 +1314,24 @@
1316 1314 ret = -ENOMEM;
1317 1315 goto err_stat;
1318 1316 }
1319   - net->ct.hash = nf_ct_alloc_hashtable(&nf_conntrack_htable_size,
  1317 +
  1318 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
  1319 + if (!net->ct.slabname) {
  1320 + ret = -ENOMEM;
  1321 + goto err_slabname;
  1322 + }
  1323 +
  1324 + net->ct.nf_conntrack_cachep = kmem_cache_create(net->ct.slabname,
  1325 + sizeof(struct nf_conn), 0,
  1326 + SLAB_DESTROY_BY_RCU, NULL);
  1327 + if (!net->ct.nf_conntrack_cachep) {
  1328 + printk(KERN_ERR "Unable to create nf_conn slab cache\n");
  1329 + ret = -ENOMEM;
  1330 + goto err_cache;
  1331 + }
  1332 +
  1333 + net->ct.htable_size = nf_conntrack_htable_size;
  1334 + net->ct.hash = nf_ct_alloc_hashtable(&net->ct.htable_size,
1320 1335 &net->ct.hash_vmalloc, 1);
1321 1336 if (!net->ct.hash) {
1322 1337 ret = -ENOMEM;
... ... @@ -1333,15 +1348,6 @@
1333 1348 if (ret < 0)
1334 1349 goto err_ecache;
1335 1350  
1336   - /* Set up fake conntrack:
1337   - - to never be deleted, not in any hashes */
1338   -#ifdef CONFIG_NET_NS
1339   - nf_conntrack_untracked.ct_net = &init_net;
1340   -#endif
1341   - atomic_set(&nf_conntrack_untracked.ct_general.use, 1);
1342   - /* - and look it like as a confirmed connection */
1343   - set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status);
1344   -
1345 1351 return 0;
1346 1352  
1347 1353 err_ecache:
1348 1354  
... ... @@ -1350,8 +1356,12 @@
1350 1356 nf_conntrack_expect_fini(net);
1351 1357 err_expect:
1352 1358 nf_ct_free_hashtable(net->ct.hash, net->ct.hash_vmalloc,
1353   - nf_conntrack_htable_size);
  1359 + net->ct.htable_size);
1354 1360 err_hash:
  1361 + kmem_cache_destroy(net->ct.nf_conntrack_cachep);
  1362 +err_cache:
  1363 + kfree(net->ct.slabname);
  1364 +err_slabname:
1355 1365 free_percpu(net->ct.stat);
1356 1366 err_stat:
1357 1367 return ret;
net/netfilter/nf_conntrack_expect.c
... ... @@ -569,7 +569,7 @@
569 569 #endif /* CONFIG_PROC_FS */
570 570 }
571 571  
572   -module_param_named(expect_hashsize, nf_ct_expect_hsize, uint, 0600);
  572 +module_param_named(expect_hashsize, nf_ct_expect_hsize, uint, 0400);
573 573  
574 574 int nf_conntrack_expect_init(struct net *net)
575 575 {
... ... @@ -577,7 +577,7 @@
577 577  
578 578 if (net_eq(net, &init_net)) {
579 579 if (!nf_ct_expect_hsize) {
580   - nf_ct_expect_hsize = nf_conntrack_htable_size / 256;
  580 + nf_ct_expect_hsize = net->ct.htable_size / 256;
581 581 if (!nf_ct_expect_hsize)
582 582 nf_ct_expect_hsize = 1;
583 583 }
net/netfilter/nf_conntrack_helper.c
... ... @@ -192,7 +192,7 @@
192 192 /* Get rid of expecteds, set helpers to NULL. */
193 193 hlist_nulls_for_each_entry(h, nn, &net->ct.unconfirmed, hnnode)
194 194 unhelp(h, me);
195   - for (i = 0; i < nf_conntrack_htable_size; i++) {
  195 + for (i = 0; i < net->ct.htable_size; i++) {
196 196 hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode)
197 197 unhelp(h, me);
198 198 }
net/netfilter/nf_conntrack_netlink.c
... ... @@ -594,7 +594,7 @@
594 594  
595 595 rcu_read_lock();
596 596 last = (struct nf_conn *)cb->args[1];
597   - for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++) {
  597 + for (; cb->args[0] < init_net.ct.htable_size; cb->args[0]++) {
598 598 restart:
599 599 hlist_nulls_for_each_entry_rcu(h, n, &init_net.ct.hash[cb->args[0]],
600 600 hnnode) {
net/netfilter/nf_conntrack_standalone.c
... ... @@ -51,7 +51,7 @@
51 51 struct hlist_nulls_node *n;
52 52  
53 53 for (st->bucket = 0;
54   - st->bucket < nf_conntrack_htable_size;
  54 + st->bucket < net->ct.htable_size;
55 55 st->bucket++) {
56 56 n = rcu_dereference(net->ct.hash[st->bucket].first);
57 57 if (!is_a_nulls(n))
... ... @@ -69,7 +69,7 @@
69 69 head = rcu_dereference(head->next);
70 70 while (is_a_nulls(head)) {
71 71 if (likely(get_nulls_value(head) == st->bucket)) {
72   - if (++st->bucket >= nf_conntrack_htable_size)
  72 + if (++st->bucket >= net->ct.htable_size)
73 73 return NULL;
74 74 }
75 75 head = rcu_dereference(net->ct.hash[st->bucket].first);
... ... @@ -355,7 +355,7 @@
355 355 },
356 356 {
357 357 .procname = "nf_conntrack_buckets",
358   - .data = &nf_conntrack_htable_size,
  358 + .data = &init_net.ct.htable_size,
359 359 .maxlen = sizeof(unsigned int),
360 360 .mode = 0444,
361 361 .proc_handler = proc_dointvec,
... ... @@ -421,6 +421,7 @@
421 421 goto out_kmemdup;
422 422  
423 423 table[1].data = &net->ct.count;
  424 + table[2].data = &net->ct.htable_size;
424 425 table[3].data = &net->ct.sysctl_checksum;
425 426 table[4].data = &net->ct.sysctl_log_invalid;
426 427  
... ... @@ -433,7 +433,7 @@
433 433 module.
434 434  
435 435 To compile this code as a module, choose M here: the
436   - module will be called police.
  436 + module will be called act_police.
437 437  
438 438 config NET_ACT_GACT
439 439 tristate "Generic actions"
... ... @@ -443,7 +443,7 @@
443 443 accepting packets.
444 444  
445 445 To compile this code as a module, choose M here: the
446   - module will be called gact.
  446 + module will be called act_gact.
447 447  
448 448 config GACT_PROB
449 449 bool "Probability support"
... ... @@ -459,7 +459,7 @@
459 459 other devices.
460 460  
461 461 To compile this code as a module, choose M here: the
462   - module will be called mirred.
  462 + module will be called act_mirred.
463 463  
464 464 config NET_ACT_IPT
465 465 tristate "IPtables targets"
... ... @@ -469,7 +469,7 @@
469 469 classification.
470 470  
471 471 To compile this code as a module, choose M here: the
472   - module will be called ipt.
  472 + module will be called act_ipt.
473 473  
474 474 config NET_ACT_NAT
475 475 tristate "Stateless NAT"
... ... @@ -479,7 +479,7 @@
479 479 netfilter for NAT unless you know what you are doing.
480 480  
481 481 To compile this code as a module, choose M here: the
482   - module will be called nat.
  482 + module will be called act_nat.
483 483  
484 484 config NET_ACT_PEDIT
485 485 tristate "Packet Editing"
... ... @@ -488,7 +488,7 @@
488 488 Say Y here if you want to mangle the content of packets.
489 489  
490 490 To compile this code as a module, choose M here: the
491   - module will be called pedit.
  491 + module will be called act_pedit.
492 492  
493 493 config NET_ACT_SIMP
494 494 tristate "Simple Example (Debug)"
... ... @@ -502,7 +502,7 @@
502 502 If unsure, say N.
503 503  
504 504 To compile this code as a module, choose M here: the
505   - module will be called simple.
  505 + module will be called act_simple.
506 506  
507 507 config NET_ACT_SKBEDIT
508 508 tristate "SKB Editing"
... ... @@ -513,7 +513,7 @@
513 513 If unsure, say N.
514 514  
515 515 To compile this code as a module, choose M here: the
516   - module will be called skbedit.
  516 + module will be called act_skbedit.
517 517  
518 518 config NET_CLS_IND
519 519 bool "Incoming device classification"