aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/8021q/vlan.c6
-rw-r--r--net/8021q/vlan.h1
-rw-r--r--net/8021q/vlan_dev.c26
-rw-r--r--net/bridge/br_netfilter.c3
-rw-r--r--net/bridge/netfilter/ebt_arp.c2
-rw-r--r--net/core/dev.c9
-rw-r--r--net/core/dev_mcast.c16
-rw-r--r--net/core/dst.c1
-rw-r--r--net/core/fib_rules.c22
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/net_namespace.c46
-rw-r--r--net/core/sock.c73
-rw-r--r--net/dccp/ipv4.c3
-rw-r--r--net/dccp/ipv6.c3
-rw-r--r--net/dccp/proto.c9
-rw-r--r--net/decnet/dn_dev.c2
-rw-r--r--net/decnet/dn_route.c16
-rw-r--r--net/decnet/dn_rules.c13
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c1
-rw-r--r--net/ieee80211/ieee80211_crypt_wep.c1
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c2
-rw-r--r--net/ipv4/fib_frontend.c15
-rw-r--r--net/ipv4/fib_rules.c51
-rw-r--r--net/ipv4/inet_diag.c9
-rw-r--r--net/ipv4/inet_hashtables.c7
-rw-r--r--net/ipv4/inet_timewait_sock.c13
-rw-r--r--net/ipv4/inetpeer.c42
-rw-r--r--net/ipv4/ip_output.c28
-rw-r--r--net/ipv4/ip_sockglue.c39
-rw-r--r--net/ipv4/ipcomp.c3
-rw-r--r--net/ipv4/ipvs/ip_vs_conn.c18
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c20
-rw-r--r--net/ipv4/ipvs/ip_vs_ctl.c25
-rw-r--r--net/ipv4/ipvs/ip_vs_sync.c24
-rw-r--r--net/ipv4/netfilter/Makefile20
-rw-r--r--net/ipv4/netfilter/ip_queue.c37
-rw-r--r--net/ipv4/netfilter/nf_nat_amanda.c2
-rw-r--r--net/ipv4/netfilter/nf_nat_core.c2
-rw-r--r--net/ipv4/netfilter/nf_nat_ftp.c2
-rw-r--r--net/ipv4/netfilter/nf_nat_h323.c18
-rw-r--r--net/ipv4/netfilter/nf_nat_irc.c2
-rw-r--r--net/ipv4/netfilter/nf_nat_pptp.c8
-rw-r--r--net/ipv4/netfilter/nf_nat_sip.c4
-rw-r--r--net/ipv4/netfilter/nf_nat_tftp.c2
-rw-r--r--net/ipv4/proc.c19
-rw-r--r--net/ipv4/raw.c3
-rw-r--r--net/ipv4/route.c20
-rw-r--r--net/ipv4/tcp.c4
-rw-r--r--net/ipv4/tcp_input.c115
-rw-r--r--net/ipv4/tcp_ipv4.c14
-rw-r--r--net/ipv4/tunnel4.c24
-rw-r--r--net/ipv4/udp.c3
-rw-r--r--net/ipv4/udplite.c3
-rw-r--r--net/ipv6/fib6_rules.c37
-rw-r--r--net/ipv6/inet6_hashtables.c19
-rw-r--r--net/ipv6/ip6_output.c36
-rw-r--r--net/ipv6/ipcomp6.c3
-rw-r--r--net/ipv6/ndisc.c1
-rw-r--r--net/ipv6/netfilter/Makefile28
-rw-r--r--net/ipv6/netfilter/ip6_queue.c37
-rw-r--r--net/ipv6/proc.c19
-rw-r--r--net/ipv6/raw.c3
-rw-r--r--net/ipv6/route.c97
-rw-r--r--net/ipv6/tcp_ipv6.c3
-rw-r--r--net/ipv6/udp.c8
-rw-r--r--net/ipv6/udplite.c3
-rw-r--r--net/ipx/af_ipx.c22
-rw-r--r--net/mac80211/Kconfig12
-rw-r--r--net/mac80211/Makefile3
-rw-r--r--net/mac80211/ieee80211.c16
-rw-r--r--net/mac80211/ieee80211_common.h91
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/ieee80211_ioctl.c21
-rw-r--r--net/mac80211/ieee80211_rate.c24
-rw-r--r--net/mac80211/ieee80211_rate.h3
-rw-r--r--net/mac80211/ieee80211_sta.c18
-rw-r--r--net/mac80211/rc80211_simple.c25
-rw-r--r--net/mac80211/rx.c2
-rw-r--r--net/mac80211/wep.c2
-rw-r--r--net/mac80211/wpa.c18
-rw-r--r--net/netfilter/Makefile14
-rw-r--r--net/netfilter/nf_sockopt.c117
-rw-r--r--net/netfilter/xt_connlimit.c5
-rw-r--r--net/netfilter/xt_time.c5
-rw-r--r--net/netfilter/xt_u32.c5
-rw-r--r--net/netlink/af_netlink.c12
-rw-r--r--net/packet/af_packet.c31
-rw-r--r--net/rfkill/rfkill.c37
-rw-r--r--net/rxrpc/ar-local.c4
-rw-r--r--net/sched/cls_u32.c14
-rw-r--r--net/sched/sch_generic.c5
-rw-r--r--net/sched/sch_teql.c3
-rw-r--r--net/sctp/associola.c10
-rw-r--r--net/sctp/bind_addr.c13
-rw-r--r--net/sctp/endpointola.c35
-rw-r--r--net/sctp/input.c43
-rw-r--r--net/sctp/inqueue.c4
-rw-r--r--net/sctp/outqueue.c41
-rw-r--r--net/sctp/proc.c6
-rw-r--r--net/sctp/protocol.c7
-rw-r--r--net/sctp/sm_make_chunk.c170
-rw-r--r--net/sctp/sm_sideeffect.c10
-rw-r--r--net/sctp/sm_statefuns.c12
-rw-r--r--net/sctp/socket.c22
-rw-r--r--net/sctp/sysctl.c9
-rw-r--r--net/sctp/transport.c5
-rw-r--r--net/sctp/ulpqueue.c2
-rw-r--r--net/socket.c6
-rw-r--r--net/sunrpc/xprtrdma/transport.c2
-rw-r--r--net/unix/af_unix.c9
-rw-r--r--net/unix/garbage.c26
111 files changed, 1086 insertions, 1004 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 3fe4fc86055f..6567213959cb 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -376,6 +376,7 @@ void vlan_setup(struct net_device *new_dev)
376 new_dev->init = vlan_dev_init; 376 new_dev->init = vlan_dev_init;
377 new_dev->open = vlan_dev_open; 377 new_dev->open = vlan_dev_open;
378 new_dev->stop = vlan_dev_stop; 378 new_dev->stop = vlan_dev_stop;
379 new_dev->set_mac_address = vlan_set_mac_address;
379 new_dev->set_multicast_list = vlan_dev_set_multicast_list; 380 new_dev->set_multicast_list = vlan_dev_set_multicast_list;
380 new_dev->change_rx_flags = vlan_change_rx_flags; 381 new_dev->change_rx_flags = vlan_change_rx_flags;
381 new_dev->destructor = free_netdev; 382 new_dev->destructor = free_netdev;
@@ -636,6 +637,10 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
636 if (!vlandev) 637 if (!vlandev)
637 continue; 638 continue;
638 639
640 flgs = vlandev->flags;
641 if (!(flgs & IFF_UP))
642 continue;
643
639 vlan_sync_address(dev, vlandev); 644 vlan_sync_address(dev, vlandev);
640 } 645 }
641 break; 646 break;
@@ -747,6 +752,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
747 vlan_dev_set_ingress_priority(dev, 752 vlan_dev_set_ingress_priority(dev,
748 args.u.skb_priority, 753 args.u.skb_priority,
749 args.vlan_qos); 754 args.vlan_qos);
755 err = 0;
750 break; 756 break;
751 757
752 case SET_VLAN_EGRESS_PRIORITY_CMD: 758 case SET_VLAN_EGRESS_PRIORITY_CMD:
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index cf4a80d06b35..2cd1393073ec 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -60,6 +60,7 @@ int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev
60int vlan_dev_change_mtu(struct net_device *dev, int new_mtu); 60int vlan_dev_change_mtu(struct net_device *dev, int new_mtu);
61int vlan_dev_open(struct net_device* dev); 61int vlan_dev_open(struct net_device* dev);
62int vlan_dev_stop(struct net_device* dev); 62int vlan_dev_stop(struct net_device* dev);
63int vlan_set_mac_address(struct net_device *dev, void *p);
63int vlan_dev_ioctl(struct net_device* dev, struct ifreq *ifr, int cmd); 64int vlan_dev_ioctl(struct net_device* dev, struct ifreq *ifr, int cmd);
64void vlan_dev_set_ingress_priority(const struct net_device *dev, 65void vlan_dev_set_ingress_priority(const struct net_device *dev,
65 u32 skb_prio, short vlan_prio); 66 u32 skb_prio, short vlan_prio);
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 1a1740aa9a8b..7a36878241da 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -665,6 +665,32 @@ int vlan_dev_stop(struct net_device *dev)
665 return 0; 665 return 0;
666} 666}
667 667
668int vlan_set_mac_address(struct net_device *dev, void *p)
669{
670 struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
671 struct sockaddr *addr = p;
672 int err;
673
674 if (!is_valid_ether_addr(addr->sa_data))
675 return -EADDRNOTAVAIL;
676
677 if (!(dev->flags & IFF_UP))
678 goto out;
679
680 if (compare_ether_addr(addr->sa_data, real_dev->dev_addr)) {
681 err = dev_unicast_add(real_dev, addr->sa_data, ETH_ALEN);
682 if (err < 0)
683 return err;
684 }
685
686 if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr))
687 dev_unicast_delete(real_dev, dev->dev_addr, ETH_ALEN);
688
689out:
690 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
691 return 0;
692}
693
668int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 694int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
669{ 695{
670 struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev; 696 struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index da22f900e89d..c1757c79dfbb 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -766,6 +766,9 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff *skb,
766 if (!nf_bridge) 766 if (!nf_bridge)
767 return NF_ACCEPT; 767 return NF_ACCEPT;
768 768
769 if (!(nf_bridge->mask & (BRNF_BRIDGED | BRNF_BRIDGED_DNAT)))
770 return NF_ACCEPT;
771
769 if (!realoutdev) 772 if (!realoutdev)
770 return NF_DROP; 773 return NF_DROP;
771 774
diff --git a/net/bridge/netfilter/ebt_arp.c b/net/bridge/netfilter/ebt_arp.c
index 1a46952a56d9..18141392a9b4 100644
--- a/net/bridge/netfilter/ebt_arp.c
+++ b/net/bridge/netfilter/ebt_arp.c
@@ -34,7 +34,7 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in
34 ah->ar_pro, EBT_ARP_PTYPE)) 34 ah->ar_pro, EBT_ARP_PTYPE))
35 return EBT_NOMATCH; 35 return EBT_NOMATCH;
36 36
37 if (info->bitmask & (EBT_ARP_SRC_IP | EBT_ARP_DST_IP)) { 37 if (info->bitmask & (EBT_ARP_SRC_IP | EBT_ARP_DST_IP | EBT_ARP_GRAT)) {
38 __be32 saddr, daddr, *sap, *dap; 38 __be32 saddr, daddr, *sap, *dap;
39 39
40 if (ah->ar_pln != sizeof(__be32) || ah->ar_pro != htons(ETH_P_IP)) 40 if (ah->ar_pln != sizeof(__be32) || ah->ar_pro != htons(ETH_P_IP))
diff --git a/net/core/dev.c b/net/core/dev.c
index be6cedab5aa8..86d62611f2fc 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1171,6 +1171,8 @@ rollback:
1171 nb->notifier_call(nb, NETDEV_UNREGISTER, dev); 1171 nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
1172 } 1172 }
1173 } 1173 }
1174
1175 raw_notifier_chain_unregister(&netdev_chain, nb);
1174 goto unlock; 1176 goto unlock;
1175} 1177}
1176 1178
@@ -2688,7 +2690,7 @@ static void __net_exit dev_proc_net_exit(struct net *net)
2688 proc_net_remove(net, "dev"); 2690 proc_net_remove(net, "dev");
2689} 2691}
2690 2692
2691static struct pernet_operations dev_proc_ops = { 2693static struct pernet_operations __net_initdata dev_proc_ops = {
2692 .init = dev_proc_net_init, 2694 .init = dev_proc_net_init,
2693 .exit = dev_proc_net_exit, 2695 .exit = dev_proc_net_exit,
2694}; 2696};
@@ -4330,7 +4332,6 @@ static struct hlist_head *netdev_create_hash(void)
4330static int __net_init netdev_init(struct net *net) 4332static int __net_init netdev_init(struct net *net)
4331{ 4333{
4332 INIT_LIST_HEAD(&net->dev_base_head); 4334 INIT_LIST_HEAD(&net->dev_base_head);
4333 rwlock_init(&dev_base_lock);
4334 4335
4335 net->dev_name_head = netdev_create_hash(); 4336 net->dev_name_head = netdev_create_hash();
4336 if (net->dev_name_head == NULL) 4337 if (net->dev_name_head == NULL)
@@ -4354,7 +4355,7 @@ static void __net_exit netdev_exit(struct net *net)
4354 kfree(net->dev_index_head); 4355 kfree(net->dev_index_head);
4355} 4356}
4356 4357
4357static struct pernet_operations netdev_net_ops = { 4358static struct pernet_operations __net_initdata netdev_net_ops = {
4358 .init = netdev_init, 4359 .init = netdev_init,
4359 .exit = netdev_exit, 4360 .exit = netdev_exit,
4360}; 4361};
@@ -4385,7 +4386,7 @@ static void __net_exit default_device_exit(struct net *net)
4385 rtnl_unlock(); 4386 rtnl_unlock();
4386} 4387}
4387 4388
4388static struct pernet_operations default_device_ops = { 4389static struct pernet_operations __net_initdata default_device_ops = {
4389 .exit = default_device_exit, 4390 .exit = default_device_exit,
4390}; 4391};
4391 4392
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c
index ae354057d84c..69fff16ece10 100644
--- a/net/core/dev_mcast.c
+++ b/net/core/dev_mcast.c
@@ -168,13 +168,13 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from)
168 da = from->mc_list; 168 da = from->mc_list;
169 while (da != NULL) { 169 while (da != NULL) {
170 next = da->next; 170 next = da->next;
171 if (!da->da_synced) 171 if (da->da_synced) {
172 continue; 172 __dev_addr_delete(&to->mc_list, &to->mc_count,
173 __dev_addr_delete(&to->mc_list, &to->mc_count, 173 da->da_addr, da->da_addrlen, 0);
174 da->da_addr, da->da_addrlen, 0); 174 da->da_synced = 0;
175 da->da_synced = 0; 175 __dev_addr_delete(&from->mc_list, &from->mc_count,
176 __dev_addr_delete(&from->mc_list, &from->mc_count, 176 da->da_addr, da->da_addrlen, 0);
177 da->da_addr, da->da_addrlen, 0); 177 }
178 da = next; 178 da = next;
179 } 179 }
180 __dev_set_rx_mode(to); 180 __dev_set_rx_mode(to);
@@ -285,7 +285,7 @@ static void __net_exit dev_mc_net_exit(struct net *net)
285 proc_net_remove(net, "dev_mcast"); 285 proc_net_remove(net, "dev_mcast");
286} 286}
287 287
288static struct pernet_operations dev_mc_net_ops = { 288static struct pernet_operations __net_initdata dev_mc_net_ops = {
289 .init = dev_mc_net_init, 289 .init = dev_mc_net_init,
290 .exit = dev_mc_net_exit, 290 .exit = dev_mc_net_exit,
291}; 291};
diff --git a/net/core/dst.c b/net/core/dst.c
index 16958e64e577..03daead3592a 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -18,7 +18,6 @@
18#include <linux/types.h> 18#include <linux/types.h>
19#include <net/net_namespace.h> 19#include <net/net_namespace.h>
20 20
21#include <net/net_namespace.h>
22#include <net/dst.h> 21#include <net/dst.h>
23 22
24/* 23/*
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 13de6f53f098..848132b6cb73 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -18,6 +18,28 @@
18static LIST_HEAD(rules_ops); 18static LIST_HEAD(rules_ops);
19static DEFINE_SPINLOCK(rules_mod_lock); 19static DEFINE_SPINLOCK(rules_mod_lock);
20 20
21int fib_default_rule_add(struct fib_rules_ops *ops,
22 u32 pref, u32 table, u32 flags)
23{
24 struct fib_rule *r;
25
26 r = kzalloc(ops->rule_size, GFP_KERNEL);
27 if (r == NULL)
28 return -ENOMEM;
29
30 atomic_set(&r->refcnt, 1);
31 r->action = FR_ACT_TO_TBL;
32 r->pref = pref;
33 r->table = table;
34 r->flags = flags;
35
36 /* The lock is not required here, the list in unreacheable
37 * at the moment this function is called */
38 list_add_tail(&r->list, &ops->rules_list);
39 return 0;
40}
41EXPORT_SYMBOL(fib_default_rule_add);
42
21static void notify_rule_change(int event, struct fib_rule *rule, 43static void notify_rule_change(int event, struct fib_rule *rule,
22 struct fib_rules_ops *ops, struct nlmsghdr *nlh, 44 struct fib_rules_ops *ops, struct nlmsghdr *nlh,
23 u32 pid); 45 u32 pid);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 05979e356963..29b8ee4e35d6 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1435,6 +1435,8 @@ int neigh_table_clear(struct neigh_table *tbl)
1435 kfree(tbl->phash_buckets); 1435 kfree(tbl->phash_buckets);
1436 tbl->phash_buckets = NULL; 1436 tbl->phash_buckets = NULL;
1437 1437
1438 remove_proc_entry(tbl->id, init_net.proc_net_stat);
1439
1438 free_percpu(tbl->stats); 1440 free_percpu(tbl->stats);
1439 tbl->stats = NULL; 1441 tbl->stats = NULL;
1440 1442
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index e9f0964ce70b..383252b50411 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -64,6 +64,20 @@ static struct net *net_alloc(void)
64 return kmem_cache_zalloc(net_cachep, GFP_KERNEL); 64 return kmem_cache_zalloc(net_cachep, GFP_KERNEL);
65} 65}
66 66
67static void net_free(struct net *net)
68{
69 if (!net)
70 return;
71
72 if (unlikely(atomic_read(&net->use_count) != 0)) {
73 printk(KERN_EMERG "network namespace not free! Usage: %d\n",
74 atomic_read(&net->use_count));
75 return;
76 }
77
78 kmem_cache_free(net_cachep, net);
79}
80
67struct net *copy_net_ns(unsigned long flags, struct net *old_net) 81struct net *copy_net_ns(unsigned long flags, struct net *old_net)
68{ 82{
69 struct net *new_net = NULL; 83 struct net *new_net = NULL;
@@ -100,20 +114,6 @@ out:
100 return new_net; 114 return new_net;
101} 115}
102 116
103static void net_free(struct net *net)
104{
105 if (!net)
106 return;
107
108 if (unlikely(atomic_read(&net->use_count) != 0)) {
109 printk(KERN_EMERG "network namespace not free! Usage: %d\n",
110 atomic_read(&net->use_count));
111 return;
112 }
113
114 kmem_cache_free(net_cachep, net);
115}
116
117static void cleanup_net(struct work_struct *work) 117static void cleanup_net(struct work_struct *work)
118{ 118{
119 struct pernet_operations *ops; 119 struct pernet_operations *ops;
@@ -188,6 +188,7 @@ static int __init net_ns_init(void)
188 188
189pure_initcall(net_ns_init); 189pure_initcall(net_ns_init);
190 190
191#ifdef CONFIG_NET_NS
191static int register_pernet_operations(struct list_head *list, 192static int register_pernet_operations(struct list_head *list,
192 struct pernet_operations *ops) 193 struct pernet_operations *ops)
193{ 194{
@@ -228,6 +229,23 @@ static void unregister_pernet_operations(struct pernet_operations *ops)
228 ops->exit(net); 229 ops->exit(net);
229} 230}
230 231
232#else
233
234static int register_pernet_operations(struct list_head *list,
235 struct pernet_operations *ops)
236{
237 if (ops->init == NULL)
238 return 0;
239 return ops->init(&init_net);
240}
241
242static void unregister_pernet_operations(struct pernet_operations *ops)
243{
244 if (ops->exit)
245 ops->exit(&init_net);
246}
247#endif
248
231/** 249/**
232 * register_pernet_subsys - register a network namespace subsystem 250 * register_pernet_subsys - register a network namespace subsystem
233 * @ops: pernet operations structure for the subsystem 251 * @ops: pernet operations structure for the subsystem
diff --git a/net/core/sock.c b/net/core/sock.c
index 12ad2067a988..c519b439b8b1 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1801,11 +1801,65 @@ EXPORT_SYMBOL(sk_common_release);
1801static DEFINE_RWLOCK(proto_list_lock); 1801static DEFINE_RWLOCK(proto_list_lock);
1802static LIST_HEAD(proto_list); 1802static LIST_HEAD(proto_list);
1803 1803
1804#ifdef CONFIG_SMP
1805/*
1806 * Define default functions to keep track of inuse sockets per protocol
1807 * Note that often used protocols use dedicated functions to get a speed increase.
1808 * (see DEFINE_PROTO_INUSE/REF_PROTO_INUSE)
1809 */
1810static void inuse_add(struct proto *prot, int inc)
1811{
1812 per_cpu_ptr(prot->inuse_ptr, smp_processor_id())[0] += inc;
1813}
1814
1815static int inuse_get(const struct proto *prot)
1816{
1817 int res = 0, cpu;
1818 for_each_possible_cpu(cpu)
1819 res += per_cpu_ptr(prot->inuse_ptr, cpu)[0];
1820 return res;
1821}
1822
1823static int inuse_init(struct proto *prot)
1824{
1825 if (!prot->inuse_getval || !prot->inuse_add) {
1826 prot->inuse_ptr = alloc_percpu(int);
1827 if (prot->inuse_ptr == NULL)
1828 return -ENOBUFS;
1829
1830 prot->inuse_getval = inuse_get;
1831 prot->inuse_add = inuse_add;
1832 }
1833 return 0;
1834}
1835
1836static void inuse_fini(struct proto *prot)
1837{
1838 if (prot->inuse_ptr != NULL) {
1839 free_percpu(prot->inuse_ptr);
1840 prot->inuse_ptr = NULL;
1841 prot->inuse_getval = NULL;
1842 prot->inuse_add = NULL;
1843 }
1844}
1845#else
1846static inline int inuse_init(struct proto *prot)
1847{
1848 return 0;
1849}
1850
1851static inline void inuse_fini(struct proto *prot)
1852{
1853}
1854#endif
1855
1804int proto_register(struct proto *prot, int alloc_slab) 1856int proto_register(struct proto *prot, int alloc_slab)
1805{ 1857{
1806 char *request_sock_slab_name = NULL; 1858 char *request_sock_slab_name = NULL;
1807 char *timewait_sock_slab_name; 1859 char *timewait_sock_slab_name;
1808 int rc = -ENOBUFS; 1860
1861 if (inuse_init(prot))
1862 goto out;
1809 1863
1810 if (alloc_slab) { 1864 if (alloc_slab) {
1811 prot->slab = kmem_cache_create(prot->name, prot->obj_size, 0, 1865 prot->slab = kmem_cache_create(prot->name, prot->obj_size, 0,
@@ -1814,7 +1868,7 @@ int proto_register(struct proto *prot, int alloc_slab)
1814 if (prot->slab == NULL) { 1868 if (prot->slab == NULL) {
1815 printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n", 1869 printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n",
1816 prot->name); 1870 prot->name);
1817 goto out; 1871 goto out_free_inuse;
1818 } 1872 }
1819 1873
1820 if (prot->rsk_prot != NULL) { 1874 if (prot->rsk_prot != NULL) {
@@ -1858,9 +1912,8 @@ int proto_register(struct proto *prot, int alloc_slab)
1858 write_lock(&proto_list_lock); 1912 write_lock(&proto_list_lock);
1859 list_add(&prot->node, &proto_list); 1913 list_add(&prot->node, &proto_list);
1860 write_unlock(&proto_list_lock); 1914 write_unlock(&proto_list_lock);
1861 rc = 0; 1915 return 0;
1862out: 1916
1863 return rc;
1864out_free_timewait_sock_slab_name: 1917out_free_timewait_sock_slab_name:
1865 kfree(timewait_sock_slab_name); 1918 kfree(timewait_sock_slab_name);
1866out_free_request_sock_slab: 1919out_free_request_sock_slab:
@@ -1873,7 +1926,10 @@ out_free_request_sock_slab_name:
1873out_free_sock_slab: 1926out_free_sock_slab:
1874 kmem_cache_destroy(prot->slab); 1927 kmem_cache_destroy(prot->slab);
1875 prot->slab = NULL; 1928 prot->slab = NULL;
1876 goto out; 1929out_free_inuse:
1930 inuse_fini(prot);
1931out:
1932 return -ENOBUFS;
1877} 1933}
1878 1934
1879EXPORT_SYMBOL(proto_register); 1935EXPORT_SYMBOL(proto_register);
@@ -1884,6 +1940,7 @@ void proto_unregister(struct proto *prot)
1884 list_del(&prot->node); 1940 list_del(&prot->node);
1885 write_unlock(&proto_list_lock); 1941 write_unlock(&proto_list_lock);
1886 1942
1943 inuse_fini(prot);
1887 if (prot->slab != NULL) { 1944 if (prot->slab != NULL) {
1888 kmem_cache_destroy(prot->slab); 1945 kmem_cache_destroy(prot->slab);
1889 prot->slab = NULL; 1946 prot->slab = NULL;
@@ -2040,7 +2097,3 @@ EXPORT_SYMBOL(sock_wmalloc);
2040EXPORT_SYMBOL(sock_i_uid); 2097EXPORT_SYMBOL(sock_i_uid);
2041EXPORT_SYMBOL(sock_i_ino); 2098EXPORT_SYMBOL(sock_i_ino);
2042EXPORT_SYMBOL(sysctl_optmem_max); 2099EXPORT_SYMBOL(sysctl_optmem_max);
2043#ifdef CONFIG_SYSCTL
2044EXPORT_SYMBOL(sysctl_rmem_max);
2045EXPORT_SYMBOL(sysctl_wmem_max);
2046#endif
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 01a6a808bdb7..db17b83e8d3e 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -922,6 +922,8 @@ static struct timewait_sock_ops dccp_timewait_sock_ops = {
922 .twsk_obj_size = sizeof(struct inet_timewait_sock), 922 .twsk_obj_size = sizeof(struct inet_timewait_sock),
923}; 923};
924 924
925DEFINE_PROTO_INUSE(dccp_v4)
926
925static struct proto dccp_v4_prot = { 927static struct proto dccp_v4_prot = {
926 .name = "DCCP", 928 .name = "DCCP",
927 .owner = THIS_MODULE, 929 .owner = THIS_MODULE,
@@ -950,6 +952,7 @@ static struct proto dccp_v4_prot = {
950 .compat_setsockopt = compat_dccp_setsockopt, 952 .compat_setsockopt = compat_dccp_setsockopt,
951 .compat_getsockopt = compat_dccp_getsockopt, 953 .compat_getsockopt = compat_dccp_getsockopt,
952#endif 954#endif
955 REF_PROTO_INUSE(dccp_v4)
953}; 956};
954 957
955static struct net_protocol dccp_v4_protocol = { 958static struct net_protocol dccp_v4_protocol = {
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 62428ff137dd..87c98fb86fa8 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1107,6 +1107,8 @@ static struct timewait_sock_ops dccp6_timewait_sock_ops = {
1107 .twsk_obj_size = sizeof(struct dccp6_timewait_sock), 1107 .twsk_obj_size = sizeof(struct dccp6_timewait_sock),
1108}; 1108};
1109 1109
1110DEFINE_PROTO_INUSE(dccp_v6)
1111
1110static struct proto dccp_v6_prot = { 1112static struct proto dccp_v6_prot = {
1111 .name = "DCCPv6", 1113 .name = "DCCPv6",
1112 .owner = THIS_MODULE, 1114 .owner = THIS_MODULE,
@@ -1135,6 +1137,7 @@ static struct proto dccp_v6_prot = {
1135 .compat_setsockopt = compat_dccp_setsockopt, 1137 .compat_setsockopt = compat_dccp_setsockopt,
1136 .compat_getsockopt = compat_dccp_getsockopt, 1138 .compat_getsockopt = compat_dccp_getsockopt,
1137#endif 1139#endif
1140 REF_PROTO_INUSE(dccp_v6)
1138}; 1141};
1139 1142
1140static struct inet6_protocol dccp_v6_protocol = { 1143static struct inet6_protocol dccp_v6_protocol = {
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index d84973928033..7a3bea9c28c1 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -1072,11 +1072,13 @@ static int __init dccp_init(void)
1072 } 1072 }
1073 1073
1074 for (i = 0; i < dccp_hashinfo.ehash_size; i++) { 1074 for (i = 0; i < dccp_hashinfo.ehash_size; i++) {
1075 rwlock_init(&dccp_hashinfo.ehash[i].lock);
1076 INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].chain); 1075 INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].chain);
1077 INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].twchain); 1076 INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].twchain);
1078 } 1077 }
1079 1078
1079 if (inet_ehash_locks_alloc(&dccp_hashinfo))
1080 goto out_free_dccp_ehash;
1081
1080 bhash_order = ehash_order; 1082 bhash_order = ehash_order;
1081 1083
1082 do { 1084 do {
@@ -1091,7 +1093,7 @@ static int __init dccp_init(void)
1091 1093
1092 if (!dccp_hashinfo.bhash) { 1094 if (!dccp_hashinfo.bhash) {
1093 DCCP_CRIT("Failed to allocate DCCP bind hash table"); 1095 DCCP_CRIT("Failed to allocate DCCP bind hash table");
1094 goto out_free_dccp_ehash; 1096 goto out_free_dccp_locks;
1095 } 1097 }
1096 1098
1097 for (i = 0; i < dccp_hashinfo.bhash_size; i++) { 1099 for (i = 0; i < dccp_hashinfo.bhash_size; i++) {
@@ -1121,6 +1123,8 @@ out_free_dccp_mib:
1121out_free_dccp_bhash: 1123out_free_dccp_bhash:
1122 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order); 1124 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
1123 dccp_hashinfo.bhash = NULL; 1125 dccp_hashinfo.bhash = NULL;
1126out_free_dccp_locks:
1127 inet_ehash_locks_free(&dccp_hashinfo);
1124out_free_dccp_ehash: 1128out_free_dccp_ehash:
1125 free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order); 1129 free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order);
1126 dccp_hashinfo.ehash = NULL; 1130 dccp_hashinfo.ehash = NULL;
@@ -1139,6 +1143,7 @@ static void __exit dccp_fini(void)
1139 free_pages((unsigned long)dccp_hashinfo.ehash, 1143 free_pages((unsigned long)dccp_hashinfo.ehash,
1140 get_order(dccp_hashinfo.ehash_size * 1144 get_order(dccp_hashinfo.ehash_size *
1141 sizeof(struct inet_ehash_bucket))); 1145 sizeof(struct inet_ehash_bucket)));
1146 inet_ehash_locks_free(&dccp_hashinfo);
1142 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); 1147 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
1143 dccp_ackvec_exit(); 1148 dccp_ackvec_exit();
1144 dccp_sysctl_exit(); 1149 dccp_sysctl_exit();
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 26130afd8029..66e266fb5908 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -1439,7 +1439,7 @@ static const struct file_operations dn_dev_seq_fops = {
1439 1439
1440#endif /* CONFIG_PROC_FS */ 1440#endif /* CONFIG_PROC_FS */
1441 1441
1442static int __initdata addr[2]; 1442static int addr[2];
1443module_param_array(addr, int, NULL, 0444); 1443module_param_array(addr, int, NULL, 0444);
1444MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node"); 1444MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node");
1445 1445
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 97eee5e8fbbe..66663e5d7acd 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -293,9 +293,7 @@ static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route *
293 dn_rt_hash_table[hash].chain); 293 dn_rt_hash_table[hash].chain);
294 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth); 294 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth);
295 295
296 rth->u.dst.__use++; 296 dst_use(&rth->u.dst, now);
297 dst_hold(&rth->u.dst);
298 rth->u.dst.lastuse = now;
299 spin_unlock_bh(&dn_rt_hash_table[hash].lock); 297 spin_unlock_bh(&dn_rt_hash_table[hash].lock);
300 298
301 dnrt_drop(rt); 299 dnrt_drop(rt);
@@ -308,9 +306,7 @@ static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route *
308 rcu_assign_pointer(rt->u.dst.dn_next, dn_rt_hash_table[hash].chain); 306 rcu_assign_pointer(rt->u.dst.dn_next, dn_rt_hash_table[hash].chain);
309 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt); 307 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt);
310 308
311 dst_hold(&rt->u.dst); 309 dst_use(&rt->u.dst, now);
312 rt->u.dst.__use++;
313 rt->u.dst.lastuse = now;
314 spin_unlock_bh(&dn_rt_hash_table[hash].lock); 310 spin_unlock_bh(&dn_rt_hash_table[hash].lock);
315 *rp = rt; 311 *rp = rt;
316 return 0; 312 return 0;
@@ -1182,9 +1178,7 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *fl
1182 (flp->mark == rt->fl.mark) && 1178 (flp->mark == rt->fl.mark) &&
1183 (rt->fl.iif == 0) && 1179 (rt->fl.iif == 0) &&
1184 (rt->fl.oif == flp->oif)) { 1180 (rt->fl.oif == flp->oif)) {
1185 rt->u.dst.lastuse = jiffies; 1181 dst_use(&rt->u.dst, jiffies);
1186 dst_hold(&rt->u.dst);
1187 rt->u.dst.__use++;
1188 rcu_read_unlock_bh(); 1182 rcu_read_unlock_bh();
1189 *pprt = &rt->u.dst; 1183 *pprt = &rt->u.dst;
1190 return 0; 1184 return 0;
@@ -1456,9 +1450,7 @@ int dn_route_input(struct sk_buff *skb)
1456 (rt->fl.oif == 0) && 1450 (rt->fl.oif == 0) &&
1457 (rt->fl.mark == skb->mark) && 1451 (rt->fl.mark == skb->mark) &&
1458 (rt->fl.iif == cb->iif)) { 1452 (rt->fl.iif == cb->iif)) {
1459 rt->u.dst.lastuse = jiffies; 1453 dst_use(&rt->u.dst, jiffies);
1460 dst_hold(&rt->u.dst);
1461 rt->u.dst.__use++;
1462 rcu_read_unlock(); 1454 rcu_read_unlock();
1463 skb->dst = (struct dst_entry *)rt; 1455 skb->dst = (struct dst_entry *)rt;
1464 return 0; 1456 return 0;
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index ddd3f04f0919..ffebea04cc99 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -48,15 +48,6 @@ struct dn_fib_rule
48 u8 flags; 48 u8 flags;
49}; 49};
50 50
51static struct dn_fib_rule default_rule = {
52 .common = {
53 .refcnt = ATOMIC_INIT(2),
54 .pref = 0x7fff,
55 .table = RT_TABLE_MAIN,
56 .action = FR_ACT_TO_TBL,
57 },
58};
59
60 51
61int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res) 52int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res)
62{ 53{
@@ -262,8 +253,8 @@ static struct fib_rules_ops dn_fib_rules_ops = {
262 253
263void __init dn_fib_rules_init(void) 254void __init dn_fib_rules_init(void)
264{ 255{
265 list_add_tail(&default_rule.common.list, 256 BUG_ON(fib_default_rule_add(&dn_fib_rules_ops, 0x7fff,
266 &dn_fib_rules_ops.rules_list); 257 RT_TABLE_MAIN, 0));
267 fib_rules_register(&dn_fib_rules_ops); 258 fib_rules_register(&dn_fib_rules_ops);
268} 259}
269 260
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 4cce3534e408..58b22619ab15 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -25,7 +25,6 @@
25#include <net/ieee80211.h> 25#include <net/ieee80211.h>
26 26
27#include <linux/crypto.h> 27#include <linux/crypto.h>
28#include <linux/scatterlist.h>
29#include <linux/crc32.h> 28#include <linux/crc32.h>
30 29
31MODULE_AUTHOR("Jouni Malinen"); 30MODULE_AUTHOR("Jouni Malinen");
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c
index 866fc04c44f9..3fa30c40779f 100644
--- a/net/ieee80211/ieee80211_crypt_wep.c
+++ b/net/ieee80211/ieee80211_crypt_wep.c
@@ -22,7 +22,6 @@
22#include <net/ieee80211.h> 22#include <net/ieee80211.h>
23 23
24#include <linux/crypto.h> 24#include <linux/crypto.h>
25#include <linux/scatterlist.h>
26#include <linux/crc32.h> 25#include <linux/crc32.h>
27 26
28MODULE_AUTHOR("Jouni Malinen"); 27MODULE_AUTHOR("Jouni Malinen");
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index ac36767b56e8..e01b59aedc54 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -470,7 +470,7 @@ ieee80211softmac_wx_set_mlme(struct net_device *dev,
470{ 470{
471 struct ieee80211softmac_device *mac = ieee80211_priv(dev); 471 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
472 struct iw_mlme *mlme = (struct iw_mlme *)extra; 472 struct iw_mlme *mlme = (struct iw_mlme *)extra;
473 u16 reason = cpu_to_le16(mlme->reason_code); 473 u16 reason = mlme->reason_code;
474 struct ieee80211softmac_network *net; 474 struct ieee80211softmac_network *net;
475 int err = -EINVAL; 475 int err = -EINVAL;
476 476
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 60123905dbbf..732d8f088b13 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -59,6 +59,13 @@ struct fib_table *ip_fib_main_table;
59#define FIB_TABLE_HASHSZ 1 59#define FIB_TABLE_HASHSZ 1
60static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ]; 60static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ];
61 61
62static void __init fib4_rules_init(void)
63{
64 ip_fib_local_table = fib_hash_init(RT_TABLE_LOCAL);
65 hlist_add_head_rcu(&ip_fib_local_table->tb_hlist, &fib_table_hash[0]);
66 ip_fib_main_table = fib_hash_init(RT_TABLE_MAIN);
67 hlist_add_head_rcu(&ip_fib_main_table->tb_hlist, &fib_table_hash[0]);
68}
62#else 69#else
63 70
64#define FIB_TABLE_HASHSZ 256 71#define FIB_TABLE_HASHSZ 256
@@ -905,14 +912,8 @@ void __init ip_fib_init(void)
905 912
906 for (i = 0; i < FIB_TABLE_HASHSZ; i++) 913 for (i = 0; i < FIB_TABLE_HASHSZ; i++)
907 INIT_HLIST_HEAD(&fib_table_hash[i]); 914 INIT_HLIST_HEAD(&fib_table_hash[i]);
908#ifndef CONFIG_IP_MULTIPLE_TABLES 915
909 ip_fib_local_table = fib_hash_init(RT_TABLE_LOCAL);
910 hlist_add_head_rcu(&ip_fib_local_table->tb_hlist, &fib_table_hash[0]);
911 ip_fib_main_table = fib_hash_init(RT_TABLE_MAIN);
912 hlist_add_head_rcu(&ip_fib_main_table->tb_hlist, &fib_table_hash[0]);
913#else
914 fib4_rules_init(); 916 fib4_rules_init();
915#endif
916 917
917 register_netdevice_notifier(&fib_netdev_notifier); 918 register_netdevice_notifier(&fib_netdev_notifier);
918 register_inetaddr_notifier(&fib_inetaddr_notifier); 919 register_inetaddr_notifier(&fib_inetaddr_notifier);
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index f16839c6a721..a0ada3a8d8dd 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -49,33 +49,6 @@ struct fib4_rule
49#endif 49#endif
50}; 50};
51 51
52static struct fib4_rule default_rule = {
53 .common = {
54 .refcnt = ATOMIC_INIT(2),
55 .pref = 0x7FFF,
56 .table = RT_TABLE_DEFAULT,
57 .action = FR_ACT_TO_TBL,
58 },
59};
60
61static struct fib4_rule main_rule = {
62 .common = {
63 .refcnt = ATOMIC_INIT(2),
64 .pref = 0x7FFE,
65 .table = RT_TABLE_MAIN,
66 .action = FR_ACT_TO_TBL,
67 },
68};
69
70static struct fib4_rule local_rule = {
71 .common = {
72 .refcnt = ATOMIC_INIT(2),
73 .table = RT_TABLE_LOCAL,
74 .action = FR_ACT_TO_TBL,
75 .flags = FIB_RULE_PERMANENT,
76 },
77};
78
79#ifdef CONFIG_NET_CLS_ROUTE 52#ifdef CONFIG_NET_CLS_ROUTE
80u32 fib_rules_tclass(struct fib_result *res) 53u32 fib_rules_tclass(struct fib_result *res)
81{ 54{
@@ -319,11 +292,27 @@ static struct fib_rules_ops fib4_rules_ops = {
319 .owner = THIS_MODULE, 292 .owner = THIS_MODULE,
320}; 293};
321 294
322void __init fib4_rules_init(void) 295static int __init fib_default_rules_init(void)
323{ 296{
324 list_add_tail(&local_rule.common.list, &fib4_rules_ops.rules_list); 297 int err;
325 list_add_tail(&main_rule.common.list, &fib4_rules_ops.rules_list); 298
326 list_add_tail(&default_rule.common.list, &fib4_rules_ops.rules_list); 299 err = fib_default_rule_add(&fib4_rules_ops, 0,
300 RT_TABLE_LOCAL, FIB_RULE_PERMANENT);
301 if (err < 0)
302 return err;
303 err = fib_default_rule_add(&fib4_rules_ops, 0x7FFE,
304 RT_TABLE_MAIN, 0);
305 if (err < 0)
306 return err;
307 err = fib_default_rule_add(&fib4_rules_ops, 0x7FFF,
308 RT_TABLE_DEFAULT, 0);
309 if (err < 0)
310 return err;
311 return 0;
312}
327 313
314void __init fib4_rules_init(void)
315{
316 BUG_ON(fib_default_rules_init());
328 fib_rules_register(&fib4_rules_ops); 317 fib_rules_register(&fib4_rules_ops);
329} 318}
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index dc429b6b0ba6..b0170732b5e9 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -747,13 +747,14 @@ skip_listen_ht:
747 747
748 for (i = s_i; i < hashinfo->ehash_size; i++) { 748 for (i = s_i; i < hashinfo->ehash_size; i++) {
749 struct inet_ehash_bucket *head = &hashinfo->ehash[i]; 749 struct inet_ehash_bucket *head = &hashinfo->ehash[i];
750 rwlock_t *lock = inet_ehash_lockp(hashinfo, i);
750 struct sock *sk; 751 struct sock *sk;
751 struct hlist_node *node; 752 struct hlist_node *node;
752 753
753 if (i > s_i) 754 if (i > s_i)
754 s_num = 0; 755 s_num = 0;
755 756
756 read_lock_bh(&head->lock); 757 read_lock_bh(lock);
757 num = 0; 758 num = 0;
758 sk_for_each(sk, node, &head->chain) { 759 sk_for_each(sk, node, &head->chain) {
759 struct inet_sock *inet = inet_sk(sk); 760 struct inet_sock *inet = inet_sk(sk);
@@ -769,7 +770,7 @@ skip_listen_ht:
769 r->id.idiag_dport) 770 r->id.idiag_dport)
770 goto next_normal; 771 goto next_normal;
771 if (inet_csk_diag_dump(sk, skb, cb) < 0) { 772 if (inet_csk_diag_dump(sk, skb, cb) < 0) {
772 read_unlock_bh(&head->lock); 773 read_unlock_bh(lock);
773 goto done; 774 goto done;
774 } 775 }
775next_normal: 776next_normal:
@@ -791,14 +792,14 @@ next_normal:
791 r->id.idiag_dport) 792 r->id.idiag_dport)
792 goto next_dying; 793 goto next_dying;
793 if (inet_twsk_diag_dump(tw, skb, cb) < 0) { 794 if (inet_twsk_diag_dump(tw, skb, cb) < 0) {
794 read_unlock_bh(&head->lock); 795 read_unlock_bh(lock);
795 goto done; 796 goto done;
796 } 797 }
797next_dying: 798next_dying:
798 ++num; 799 ++num;
799 } 800 }
800 } 801 }
801 read_unlock_bh(&head->lock); 802 read_unlock_bh(lock);
802 } 803 }
803 804
804done: 805done:
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 16eecc7046a3..67704da04fc4 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -204,12 +204,13 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
204 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport); 204 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
205 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); 205 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
206 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); 206 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
207 rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
207 struct sock *sk2; 208 struct sock *sk2;
208 const struct hlist_node *node; 209 const struct hlist_node *node;
209 struct inet_timewait_sock *tw; 210 struct inet_timewait_sock *tw;
210 211
211 prefetch(head->chain.first); 212 prefetch(head->chain.first);
212 write_lock(&head->lock); 213 write_lock(lock);
213 214
214 /* Check TIME-WAIT sockets first. */ 215 /* Check TIME-WAIT sockets first. */
215 sk_for_each(sk2, node, &head->twchain) { 216 sk_for_each(sk2, node, &head->twchain) {
@@ -239,7 +240,7 @@ unique:
239 BUG_TRAP(sk_unhashed(sk)); 240 BUG_TRAP(sk_unhashed(sk));
240 __sk_add_node(sk, &head->chain); 241 __sk_add_node(sk, &head->chain);
241 sock_prot_inc_use(sk->sk_prot); 242 sock_prot_inc_use(sk->sk_prot);
242 write_unlock(&head->lock); 243 write_unlock(lock);
243 244
244 if (twp) { 245 if (twp) {
245 *twp = tw; 246 *twp = tw;
@@ -255,7 +256,7 @@ unique:
255 return 0; 256 return 0;
256 257
257not_unique: 258not_unique:
258 write_unlock(&head->lock); 259 write_unlock(lock);
259 return -EADDRNOTAVAIL; 260 return -EADDRNOTAVAIL;
260} 261}
261 262
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 4e189e28f306..a60b99e0ebdc 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -20,16 +20,16 @@ static void __inet_twsk_kill(struct inet_timewait_sock *tw,
20 struct inet_bind_hashbucket *bhead; 20 struct inet_bind_hashbucket *bhead;
21 struct inet_bind_bucket *tb; 21 struct inet_bind_bucket *tb;
22 /* Unlink from established hashes. */ 22 /* Unlink from established hashes. */
23 struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, tw->tw_hash); 23 rwlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash);
24 24
25 write_lock(&ehead->lock); 25 write_lock(lock);
26 if (hlist_unhashed(&tw->tw_node)) { 26 if (hlist_unhashed(&tw->tw_node)) {
27 write_unlock(&ehead->lock); 27 write_unlock(lock);
28 return; 28 return;
29 } 29 }
30 __hlist_del(&tw->tw_node); 30 __hlist_del(&tw->tw_node);
31 sk_node_init(&tw->tw_node); 31 sk_node_init(&tw->tw_node);
32 write_unlock(&ehead->lock); 32 write_unlock(lock);
33 33
34 /* Disassociate with bind bucket. */ 34 /* Disassociate with bind bucket. */
35 bhead = &hashinfo->bhash[inet_bhashfn(tw->tw_num, hashinfo->bhash_size)]; 35 bhead = &hashinfo->bhash[inet_bhashfn(tw->tw_num, hashinfo->bhash_size)];
@@ -59,6 +59,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
59 const struct inet_sock *inet = inet_sk(sk); 59 const struct inet_sock *inet = inet_sk(sk);
60 const struct inet_connection_sock *icsk = inet_csk(sk); 60 const struct inet_connection_sock *icsk = inet_csk(sk);
61 struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash); 61 struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash);
62 rwlock_t *lock = inet_ehash_lockp(hashinfo, sk->sk_hash);
62 struct inet_bind_hashbucket *bhead; 63 struct inet_bind_hashbucket *bhead;
63 /* Step 1: Put TW into bind hash. Original socket stays there too. 64 /* Step 1: Put TW into bind hash. Original socket stays there too.
64 Note, that any socket with inet->num != 0 MUST be bound in 65 Note, that any socket with inet->num != 0 MUST be bound in
@@ -71,7 +72,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
71 inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); 72 inet_twsk_add_bind_node(tw, &tw->tw_tb->owners);
72 spin_unlock(&bhead->lock); 73 spin_unlock(&bhead->lock);
73 74
74 write_lock(&ehead->lock); 75 write_lock(lock);
75 76
76 /* Step 2: Remove SK from established hash. */ 77 /* Step 2: Remove SK from established hash. */
77 if (__sk_del_node_init(sk)) 78 if (__sk_del_node_init(sk))
@@ -81,7 +82,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
81 inet_twsk_add_node(tw, &ehead->twchain); 82 inet_twsk_add_node(tw, &ehead->twchain);
82 atomic_inc(&tw->tw_refcnt); 83 atomic_inc(&tw->tw_refcnt);
83 84
84 write_unlock(&ehead->lock); 85 write_unlock(lock);
85} 86}
86 87
87EXPORT_SYMBOL_GPL(__inet_twsk_hashdance); 88EXPORT_SYMBOL_GPL(__inet_twsk_hashdance);
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 771031dfbd0f..af995198f643 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -61,7 +61,7 @@
61 * 4. Global variable peer_total is modified under the pool lock. 61 * 4. Global variable peer_total is modified under the pool lock.
62 * 5. struct inet_peer fields modification: 62 * 5. struct inet_peer fields modification:
63 * avl_left, avl_right, avl_parent, avl_height: pool lock 63 * avl_left, avl_right, avl_parent, avl_height: pool lock
64 * unused_next, unused_prevp: unused node list lock 64 * unused: unused node list lock
65 * refcnt: atomically against modifications on other CPU; 65 * refcnt: atomically against modifications on other CPU;
66 * usually under some other lock to prevent node disappearing 66 * usually under some other lock to prevent node disappearing
67 * dtime: unused node list lock 67 * dtime: unused node list lock
@@ -94,8 +94,7 @@ int inet_peer_maxttl __read_mostly = 10 * 60 * HZ; /* usual time to live: 10 min
94int inet_peer_gc_mintime __read_mostly = 10 * HZ; 94int inet_peer_gc_mintime __read_mostly = 10 * HZ;
95int inet_peer_gc_maxtime __read_mostly = 120 * HZ; 95int inet_peer_gc_maxtime __read_mostly = 120 * HZ;
96 96
97static struct inet_peer *inet_peer_unused_head; 97static LIST_HEAD(unused_peers);
98static struct inet_peer **inet_peer_unused_tailp = &inet_peer_unused_head;
99static DEFINE_SPINLOCK(inet_peer_unused_lock); 98static DEFINE_SPINLOCK(inet_peer_unused_lock);
100 99
101static void peer_check_expire(unsigned long dummy); 100static void peer_check_expire(unsigned long dummy);
@@ -138,15 +137,7 @@ void __init inet_initpeers(void)
138static void unlink_from_unused(struct inet_peer *p) 137static void unlink_from_unused(struct inet_peer *p)
139{ 138{
140 spin_lock_bh(&inet_peer_unused_lock); 139 spin_lock_bh(&inet_peer_unused_lock);
141 if (p->unused_prevp != NULL) { 140 list_del_init(&p->unused);
142 /* On unused list. */
143 *p->unused_prevp = p->unused_next;
144 if (p->unused_next != NULL)
145 p->unused_next->unused_prevp = p->unused_prevp;
146 else
147 inet_peer_unused_tailp = p->unused_prevp;
148 p->unused_prevp = NULL; /* mark it as removed */
149 }
150 spin_unlock_bh(&inet_peer_unused_lock); 141 spin_unlock_bh(&inet_peer_unused_lock);
151} 142}
152 143
@@ -337,24 +328,24 @@ static void unlink_from_pool(struct inet_peer *p)
337/* May be called with local BH enabled. */ 328/* May be called with local BH enabled. */
338static int cleanup_once(unsigned long ttl) 329static int cleanup_once(unsigned long ttl)
339{ 330{
340 struct inet_peer *p; 331 struct inet_peer *p = NULL;
341 332
342 /* Remove the first entry from the list of unused nodes. */ 333 /* Remove the first entry from the list of unused nodes. */
343 spin_lock_bh(&inet_peer_unused_lock); 334 spin_lock_bh(&inet_peer_unused_lock);
344 p = inet_peer_unused_head; 335 if (!list_empty(&unused_peers)) {
345 if (p != NULL) { 336 __u32 delta;
346 __u32 delta = (__u32)jiffies - p->dtime; 337
338 p = list_first_entry(&unused_peers, struct inet_peer, unused);
339 delta = (__u32)jiffies - p->dtime;
340
347 if (delta < ttl) { 341 if (delta < ttl) {
348 /* Do not prune fresh entries. */ 342 /* Do not prune fresh entries. */
349 spin_unlock_bh(&inet_peer_unused_lock); 343 spin_unlock_bh(&inet_peer_unused_lock);
350 return -1; 344 return -1;
351 } 345 }
352 inet_peer_unused_head = p->unused_next; 346
353 if (p->unused_next != NULL) 347 list_del_init(&p->unused);
354 p->unused_next->unused_prevp = p->unused_prevp; 348
355 else
356 inet_peer_unused_tailp = p->unused_prevp;
357 p->unused_prevp = NULL; /* mark as not on the list */
358 /* Grab an extra reference to prevent node disappearing 349 /* Grab an extra reference to prevent node disappearing
359 * before unlink_from_pool() call. */ 350 * before unlink_from_pool() call. */
360 atomic_inc(&p->refcnt); 351 atomic_inc(&p->refcnt);
@@ -412,7 +403,7 @@ struct inet_peer *inet_getpeer(__be32 daddr, int create)
412 403
413 /* Link the node. */ 404 /* Link the node. */
414 link_to_pool(n); 405 link_to_pool(n);
415 n->unused_prevp = NULL; /* not on the list */ 406 INIT_LIST_HEAD(&n->unused);
416 peer_total++; 407 peer_total++;
417 write_unlock_bh(&peer_pool_lock); 408 write_unlock_bh(&peer_pool_lock);
418 409
@@ -467,10 +458,7 @@ void inet_putpeer(struct inet_peer *p)
467{ 458{
468 spin_lock_bh(&inet_peer_unused_lock); 459 spin_lock_bh(&inet_peer_unused_lock);
469 if (atomic_dec_and_test(&p->refcnt)) { 460 if (atomic_dec_and_test(&p->refcnt)) {
470 p->unused_prevp = inet_peer_unused_tailp; 461 list_add_tail(&p->unused, &unused_peers);
471 p->unused_next = NULL;
472 *inet_peer_unused_tailp = p;
473 inet_peer_unused_tailp = &p->unused_next;
474 p->dtime = (__u32)jiffies; 462 p->dtime = (__u32)jiffies;
475 } 463 }
476 spin_unlock_bh(&inet_peer_unused_lock); 464 spin_unlock_bh(&inet_peer_unused_lock);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index e5f7dc2de303..fd99fbd685ea 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1183,6 +1183,17 @@ error:
1183 return err; 1183 return err;
1184} 1184}
1185 1185
1186static void ip_cork_release(struct inet_sock *inet)
1187{
1188 inet->cork.flags &= ~IPCORK_OPT;
1189 kfree(inet->cork.opt);
1190 inet->cork.opt = NULL;
1191 if (inet->cork.rt) {
1192 ip_rt_put(inet->cork.rt);
1193 inet->cork.rt = NULL;
1194 }
1195}
1196
1186/* 1197/*
1187 * Combined all pending IP fragments on the socket as one IP datagram 1198 * Combined all pending IP fragments on the socket as one IP datagram
1188 * and push them out. 1199 * and push them out.
@@ -1276,13 +1287,7 @@ int ip_push_pending_frames(struct sock *sk)
1276 } 1287 }
1277 1288
1278out: 1289out:
1279 inet->cork.flags &= ~IPCORK_OPT; 1290 ip_cork_release(inet);
1280 kfree(inet->cork.opt);
1281 inet->cork.opt = NULL;
1282 if (inet->cork.rt) {
1283 ip_rt_put(inet->cork.rt);
1284 inet->cork.rt = NULL;
1285 }
1286 return err; 1291 return err;
1287 1292
1288error: 1293error:
@@ -1295,19 +1300,12 @@ error:
1295 */ 1300 */
1296void ip_flush_pending_frames(struct sock *sk) 1301void ip_flush_pending_frames(struct sock *sk)
1297{ 1302{
1298 struct inet_sock *inet = inet_sk(sk);
1299 struct sk_buff *skb; 1303 struct sk_buff *skb;
1300 1304
1301 while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL) 1305 while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL)
1302 kfree_skb(skb); 1306 kfree_skb(skb);
1303 1307
1304 inet->cork.flags &= ~IPCORK_OPT; 1308 ip_cork_release(inet_sk(sk));
1305 kfree(inet->cork.opt);
1306 inet->cork.opt = NULL;
1307 if (inet->cork.rt) {
1308 ip_rt_put(inet->cork.rt);
1309 inet->cork.rt = NULL;
1310 }
1311} 1309}
1312 1310
1313 1311
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index f51f20e487c8..82817e554363 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -437,10 +437,8 @@ static int do_ip_setsockopt(struct sock *sk, int level,
437 437
438 /* If optlen==0, it is equivalent to val == 0 */ 438 /* If optlen==0, it is equivalent to val == 0 */
439 439
440#ifdef CONFIG_IP_MROUTE 440 if (ip_mroute_opt(optname))
441 if (optname >= MRT_BASE && optname <= (MRT_BASE + 10))
442 return ip_mroute_setsockopt(sk,optname,optval,optlen); 441 return ip_mroute_setsockopt(sk,optname,optval,optlen);
443#endif
444 442
445 err = 0; 443 err = 0;
446 lock_sock(sk); 444 lock_sock(sk);
@@ -909,11 +907,9 @@ int ip_setsockopt(struct sock *sk, int level,
909#ifdef CONFIG_NETFILTER 907#ifdef CONFIG_NETFILTER
910 /* we need to exclude all possible ENOPROTOOPTs except default case */ 908 /* we need to exclude all possible ENOPROTOOPTs except default case */
911 if (err == -ENOPROTOOPT && optname != IP_HDRINCL && 909 if (err == -ENOPROTOOPT && optname != IP_HDRINCL &&
912 optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY 910 optname != IP_IPSEC_POLICY &&
913#ifdef CONFIG_IP_MROUTE 911 optname != IP_XFRM_POLICY &&
914 && (optname < MRT_BASE || optname > (MRT_BASE + 10)) 912 !ip_mroute_opt(optname)) {
915#endif
916 ) {
917 lock_sock(sk); 913 lock_sock(sk);
918 err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); 914 err = nf_setsockopt(sk, PF_INET, optname, optval, optlen);
919 release_sock(sk); 915 release_sock(sk);
@@ -935,11 +931,9 @@ int compat_ip_setsockopt(struct sock *sk, int level, int optname,
935#ifdef CONFIG_NETFILTER 931#ifdef CONFIG_NETFILTER
936 /* we need to exclude all possible ENOPROTOOPTs except default case */ 932 /* we need to exclude all possible ENOPROTOOPTs except default case */
937 if (err == -ENOPROTOOPT && optname != IP_HDRINCL && 933 if (err == -ENOPROTOOPT && optname != IP_HDRINCL &&
938 optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY 934 optname != IP_IPSEC_POLICY &&
939#ifdef CONFIG_IP_MROUTE 935 optname != IP_XFRM_POLICY &&
940 && (optname < MRT_BASE || optname > (MRT_BASE + 10)) 936 !ip_mroute_opt(optname)) {
941#endif
942 ) {
943 lock_sock(sk); 937 lock_sock(sk);
944 err = compat_nf_setsockopt(sk, PF_INET, optname, 938 err = compat_nf_setsockopt(sk, PF_INET, optname,
945 optval, optlen); 939 optval, optlen);
@@ -967,11 +961,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
967 if (level != SOL_IP) 961 if (level != SOL_IP)
968 return -EOPNOTSUPP; 962 return -EOPNOTSUPP;
969 963
970#ifdef CONFIG_IP_MROUTE 964 if (ip_mroute_opt(optname))
971 if (optname >= MRT_BASE && optname <= MRT_BASE+10) {
972 return ip_mroute_getsockopt(sk,optname,optval,optlen); 965 return ip_mroute_getsockopt(sk,optname,optval,optlen);
973 }
974#endif
975 966
976 if (get_user(len,optlen)) 967 if (get_user(len,optlen))
977 return -EFAULT; 968 return -EFAULT;
@@ -1171,11 +1162,8 @@ int ip_getsockopt(struct sock *sk, int level,
1171 err = do_ip_getsockopt(sk, level, optname, optval, optlen); 1162 err = do_ip_getsockopt(sk, level, optname, optval, optlen);
1172#ifdef CONFIG_NETFILTER 1163#ifdef CONFIG_NETFILTER
1173 /* we need to exclude all possible ENOPROTOOPTs except default case */ 1164 /* we need to exclude all possible ENOPROTOOPTs except default case */
1174 if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS 1165 if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS &&
1175#ifdef CONFIG_IP_MROUTE 1166 !ip_mroute_opt(optname)) {
1176 && (optname < MRT_BASE || optname > MRT_BASE+10)
1177#endif
1178 ) {
1179 int len; 1167 int len;
1180 1168
1181 if (get_user(len,optlen)) 1169 if (get_user(len,optlen))
@@ -1200,11 +1188,8 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname,
1200 int err = do_ip_getsockopt(sk, level, optname, optval, optlen); 1188 int err = do_ip_getsockopt(sk, level, optname, optval, optlen);
1201#ifdef CONFIG_NETFILTER 1189#ifdef CONFIG_NETFILTER
1202 /* we need to exclude all possible ENOPROTOOPTs except default case */ 1190 /* we need to exclude all possible ENOPROTOOPTs except default case */
1203 if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS 1191 if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS &&
1204#ifdef CONFIG_IP_MROUTE 1192 !ip_mroute_opt(optname)) {
1205 && (optname < MRT_BASE || optname > MRT_BASE+10)
1206#endif
1207 ) {
1208 int len; 1193 int len;
1209 1194
1210 if (get_user(len, optlen)) 1195 if (get_user(len, optlen))
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index ca1b5fdb8d31..2c44a94c2135 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <asm/semaphore.h> 17#include <asm/semaphore.h>
18#include <linux/crypto.h> 18#include <linux/crypto.h>
19#include <linux/err.h>
19#include <linux/pfkeyv2.h> 20#include <linux/pfkeyv2.h>
20#include <linux/percpu.h> 21#include <linux/percpu.h>
21#include <linux/smp.h> 22#include <linux/smp.h>
@@ -344,7 +345,7 @@ static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name)
344 for_each_possible_cpu(cpu) { 345 for_each_possible_cpu(cpu) {
345 struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, 346 struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
346 CRYPTO_ALG_ASYNC); 347 CRYPTO_ALG_ASYNC);
347 if (!tfm) 348 if (IS_ERR(tfm))
348 goto error; 349 goto error;
349 *per_cpu_ptr(tfms, cpu) = tfm; 350 *per_cpu_ptr(tfms, cpu) = tfm;
350 } 351 }
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
index 4b702f708d30..0a9f3c37e18d 100644
--- a/net/ipv4/ipvs/ip_vs_conn.c
+++ b/net/ipv4/ipvs/ip_vs_conn.c
@@ -426,6 +426,24 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
426 426
427 427
428/* 428/*
429 * Check if there is a destination for the connection, if so
430 * bind the connection to the destination.
431 */
432struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp)
433{
434 struct ip_vs_dest *dest;
435
436 if ((cp) && (!cp->dest)) {
437 dest = ip_vs_find_dest(cp->daddr, cp->dport,
438 cp->vaddr, cp->vport, cp->protocol);
439 ip_vs_bind_dest(cp, dest);
440 return dest;
441 } else
442 return NULL;
443}
444
445
446/*
429 * Unbind a connection entry with its VS destination 447 * Unbind a connection entry with its VS destination
430 * Called by the ip_vs_conn_expire function. 448 * Called by the ip_vs_conn_expire function.
431 */ 449 */
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c
index c6ed7654e839..20c884a57721 100644
--- a/net/ipv4/ipvs/ip_vs_core.c
+++ b/net/ipv4/ipvs/ip_vs_core.c
@@ -979,15 +979,23 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb,
979 ret = NF_ACCEPT; 979 ret = NF_ACCEPT;
980 } 980 }
981 981
982 /* increase its packet counter and check if it is needed 982 /* Increase its packet counter and check if it is needed
983 to be synchronized */ 983 * to be synchronized
984 *
985 * Sync connection if it is about to close to
986 * encorage the standby servers to update the connections timeout
987 */
984 atomic_inc(&cp->in_pkts); 988 atomic_inc(&cp->in_pkts);
985 if ((ip_vs_sync_state & IP_VS_STATE_MASTER) && 989 if ((ip_vs_sync_state & IP_VS_STATE_MASTER) &&
986 (cp->protocol != IPPROTO_TCP || 990 (((cp->protocol != IPPROTO_TCP ||
987 cp->state == IP_VS_TCP_S_ESTABLISHED) && 991 cp->state == IP_VS_TCP_S_ESTABLISHED) &&
988 (atomic_read(&cp->in_pkts) % sysctl_ip_vs_sync_threshold[1] 992 (atomic_read(&cp->in_pkts) % sysctl_ip_vs_sync_threshold[1]
989 == sysctl_ip_vs_sync_threshold[0])) 993 == sysctl_ip_vs_sync_threshold[0])) ||
994 ((cp->protocol == IPPROTO_TCP) && (cp->old_state != cp->state) &&
995 ((cp->state == IP_VS_TCP_S_FIN_WAIT) ||
996 (cp->state == IP_VS_TCP_S_CLOSE)))))
990 ip_vs_sync_conn(cp); 997 ip_vs_sync_conn(cp);
998 cp->old_state = cp->state;
991 999
992 ip_vs_conn_put(cp); 1000 ip_vs_conn_put(cp);
993 return ret; 1001 return ret;
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index 7345fc252a23..b64cf45a9ead 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -579,6 +579,31 @@ ip_vs_lookup_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport)
579 return NULL; 579 return NULL;
580} 580}
581 581
582/*
583 * Find destination by {daddr,dport,vaddr,protocol}
584 * Cretaed to be used in ip_vs_process_message() in
585 * the backup synchronization daemon. It finds the
586 * destination to be bound to the received connection
587 * on the backup.
588 *
589 * ip_vs_lookup_real_service() looked promissing, but
590 * seems not working as expected.
591 */
592struct ip_vs_dest *ip_vs_find_dest(__be32 daddr, __be16 dport,
593 __be32 vaddr, __be16 vport, __u16 protocol)
594{
595 struct ip_vs_dest *dest;
596 struct ip_vs_service *svc;
597
598 svc = ip_vs_service_get(0, protocol, vaddr, vport);
599 if (!svc)
600 return NULL;
601 dest = ip_vs_lookup_dest(svc, daddr, dport);
602 if (dest)
603 atomic_inc(&dest->refcnt);
604 ip_vs_service_put(svc);
605 return dest;
606}
582 607
583/* 608/*
584 * Lookup dest by {svc,addr,port} in the destination trash. 609 * Lookup dest by {svc,addr,port} in the destination trash.
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
index 0d4d9721cbd4..bd930efc18da 100644
--- a/net/ipv4/ipvs/ip_vs_sync.c
+++ b/net/ipv4/ipvs/ip_vs_sync.c
@@ -284,6 +284,7 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen)
284 struct ip_vs_sync_conn_options *opt; 284 struct ip_vs_sync_conn_options *opt;
285 struct ip_vs_conn *cp; 285 struct ip_vs_conn *cp;
286 struct ip_vs_protocol *pp; 286 struct ip_vs_protocol *pp;
287 struct ip_vs_dest *dest;
287 char *p; 288 char *p;
288 int i; 289 int i;
289 290
@@ -317,20 +318,34 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen)
317 s->caddr, s->cport, 318 s->caddr, s->cport,
318 s->vaddr, s->vport); 319 s->vaddr, s->vport);
319 if (!cp) { 320 if (!cp) {
321 /*
322 * Find the appropriate destination for the connection.
323 * If it is not found the connection will remain unbound
324 * but still handled.
325 */
326 dest = ip_vs_find_dest(s->daddr, s->dport,
327 s->vaddr, s->vport,
328 s->protocol);
320 cp = ip_vs_conn_new(s->protocol, 329 cp = ip_vs_conn_new(s->protocol,
321 s->caddr, s->cport, 330 s->caddr, s->cport,
322 s->vaddr, s->vport, 331 s->vaddr, s->vport,
323 s->daddr, s->dport, 332 s->daddr, s->dport,
324 flags, NULL); 333 flags, dest);
334 if (dest)
335 atomic_dec(&dest->refcnt);
325 if (!cp) { 336 if (!cp) {
326 IP_VS_ERR("ip_vs_conn_new failed\n"); 337 IP_VS_ERR("ip_vs_conn_new failed\n");
327 return; 338 return;
328 } 339 }
329 cp->state = ntohs(s->state); 340 cp->state = ntohs(s->state);
330 } else if (!cp->dest) { 341 } else if (!cp->dest) {
331 /* it is an entry created by the synchronization */ 342 dest = ip_vs_try_bind_dest(cp);
332 cp->state = ntohs(s->state); 343 if (!dest) {
333 cp->flags = flags | IP_VS_CONN_F_HASHED; 344 /* it is an unbound entry created by
345 * synchronization */
346 cp->flags = flags | IP_VS_CONN_F_HASHED;
347 } else
348 atomic_dec(&dest->refcnt);
334 } /* Note that we don't touch its state and flags 349 } /* Note that we don't touch its state and flags
335 if it is a normal entry. */ 350 if it is a normal entry. */
336 351
@@ -342,6 +357,7 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen)
342 p += SIMPLE_CONN_SIZE; 357 p += SIMPLE_CONN_SIZE;
343 358
344 atomic_set(&cp->in_pkts, sysctl_ip_vs_sync_threshold[0]); 359 atomic_set(&cp->in_pkts, sysctl_ip_vs_sync_threshold[0]);
360 cp->state = ntohs(s->state);
345 pp = ip_vs_proto_get(s->protocol); 361 pp = ip_vs_proto_get(s->protocol);
346 cp->timeout = pp->timeout_table[cp->state]; 362 cp->timeout = pp->timeout_table[cp->state];
347 ip_vs_conn_put(cp); 363 ip_vs_conn_put(cp);
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
index 409d273f6f82..7456833d6ade 100644
--- a/net/ipv4/netfilter/Makefile
+++ b/net/ipv4/netfilter/Makefile
@@ -41,27 +41,27 @@ obj-$(CONFIG_NF_NAT) += iptable_nat.o
41obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o 41obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o
42 42
43# matches 43# matches
44obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o
45obj-$(CONFIG_IP_NF_MATCH_AH) += ipt_ah.o
46obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o
44obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o 47obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o
45obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o 48obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o
46obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o
47obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o 49obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o
48obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o 50obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o
49obj-$(CONFIG_IP_NF_MATCH_AH) += ipt_ah.o
50obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o 51obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
51obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o
52 52
53# targets 53# targets
54obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o 54obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
55obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
56obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o 55obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
56obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
57obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o 57obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
58obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
59obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o 58obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
59obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
60obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
60obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o 61obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o
61obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o 62obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
62obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
63obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
64obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o 63obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o
64obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
65 65
66# generic ARP tables 66# generic ARP tables
67obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o 67obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 10a2ce09fd8e..14d64a383db1 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -22,6 +22,7 @@
22#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/sysctl.h> 23#include <linux/sysctl.h>
24#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
25#include <linux/seq_file.h>
25#include <linux/security.h> 26#include <linux/security.h>
26#include <linux/mutex.h> 27#include <linux/mutex.h>
27#include <net/net_namespace.h> 28#include <net/net_namespace.h>
@@ -607,15 +608,11 @@ static ctl_table ipq_root_table[] = {
607 { .ctl_name = 0 } 608 { .ctl_name = 0 }
608}; 609};
609 610
610#ifdef CONFIG_PROC_FS 611static int ip_queue_show(struct seq_file *m, void *v)
611static int
612ipq_get_info(char *buffer, char **start, off_t offset, int length)
613{ 612{
614 int len;
615
616 read_lock_bh(&queue_lock); 613 read_lock_bh(&queue_lock);
617 614
618 len = sprintf(buffer, 615 seq_printf(m,
619 "Peer PID : %d\n" 616 "Peer PID : %d\n"
620 "Copy mode : %hu\n" 617 "Copy mode : %hu\n"
621 "Copy range : %u\n" 618 "Copy range : %u\n"
@@ -632,16 +629,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
632 queue_user_dropped); 629 queue_user_dropped);
633 630
634 read_unlock_bh(&queue_lock); 631 read_unlock_bh(&queue_lock);
632 return 0;
633}
635 634
636 *start = buffer + offset; 635static int ip_queue_open(struct inode *inode, struct file *file)
637 len -= offset; 636{
638 if (len > length) 637 return single_open(file, ip_queue_show, NULL);
639 len = length;
640 else if (len < 0)
641 len = 0;
642 return len;
643} 638}
644#endif /* CONFIG_PROC_FS */ 639
640static const struct file_operations ip_queue_proc_fops = {
641 .open = ip_queue_open,
642 .read = seq_read,
643 .llseek = seq_lseek,
644 .release = single_release,
645 .owner = THIS_MODULE,
646};
645 647
646static struct nf_queue_handler nfqh = { 648static struct nf_queue_handler nfqh = {
647 .name = "ip_queue", 649 .name = "ip_queue",
@@ -661,10 +663,11 @@ static int __init ip_queue_init(void)
661 goto cleanup_netlink_notifier; 663 goto cleanup_netlink_notifier;
662 } 664 }
663 665
664 proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info); 666 proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
665 if (proc) 667 if (proc) {
666 proc->owner = THIS_MODULE; 668 proc->owner = THIS_MODULE;
667 else { 669 proc->proc_fops = &ip_queue_proc_fops;
670 } else {
668 printk(KERN_ERR "ip_queue: failed to create proc entry\n"); 671 printk(KERN_ERR "ip_queue: failed to create proc entry\n");
669 goto cleanup_ipqnl; 672 goto cleanup_ipqnl;
670 } 673 }
diff --git a/net/ipv4/netfilter/nf_nat_amanda.c b/net/ipv4/netfilter/nf_nat_amanda.c
index 35a5aa69cd92..c31b87668250 100644
--- a/net/ipv4/netfilter/nf_nat_amanda.c
+++ b/net/ipv4/netfilter/nf_nat_amanda.c
@@ -69,7 +69,7 @@ static void __exit nf_nat_amanda_fini(void)
69 69
70static int __init nf_nat_amanda_init(void) 70static int __init nf_nat_amanda_init(void)
71{ 71{
72 BUG_ON(rcu_dereference(nf_nat_amanda_hook)); 72 BUG_ON(nf_nat_amanda_hook != NULL);
73 rcu_assign_pointer(nf_nat_amanda_hook, help); 73 rcu_assign_pointer(nf_nat_amanda_hook, help);
74 return 0; 74 return 0;
75} 75}
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index 56e93f692e82..70e7997ea284 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -681,7 +681,7 @@ static int clean_nat(struct nf_conn *i, void *data)
681 681
682 if (!nat) 682 if (!nat)
683 return 0; 683 return 0;
684 memset(nat, 0, sizeof(nat)); 684 memset(nat, 0, sizeof(*nat));
685 i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK | IPS_SEQ_ADJUST); 685 i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK | IPS_SEQ_ADJUST);
686 return 0; 686 return 0;
687} 687}
diff --git a/net/ipv4/netfilter/nf_nat_ftp.c b/net/ipv4/netfilter/nf_nat_ftp.c
index e1a16d3ea4cb..a1d5d58a58bf 100644
--- a/net/ipv4/netfilter/nf_nat_ftp.c
+++ b/net/ipv4/netfilter/nf_nat_ftp.c
@@ -147,7 +147,7 @@ static void __exit nf_nat_ftp_fini(void)
147 147
148static int __init nf_nat_ftp_init(void) 148static int __init nf_nat_ftp_init(void)
149{ 149{
150 BUG_ON(rcu_dereference(nf_nat_ftp_hook)); 150 BUG_ON(nf_nat_ftp_hook != NULL);
151 rcu_assign_pointer(nf_nat_ftp_hook, nf_nat_ftp); 151 rcu_assign_pointer(nf_nat_ftp_hook, nf_nat_ftp);
152 return 0; 152 return 0;
153} 153}
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c
index a868c8c41328..93e18ef114f2 100644
--- a/net/ipv4/netfilter/nf_nat_h323.c
+++ b/net/ipv4/netfilter/nf_nat_h323.c
@@ -544,15 +544,15 @@ static int nat_callforwarding(struct sk_buff *skb, struct nf_conn *ct,
544/****************************************************************************/ 544/****************************************************************************/
545static int __init init(void) 545static int __init init(void)
546{ 546{
547 BUG_ON(rcu_dereference(set_h245_addr_hook) != NULL); 547 BUG_ON(set_h245_addr_hook != NULL);
548 BUG_ON(rcu_dereference(set_h225_addr_hook) != NULL); 548 BUG_ON(set_h225_addr_hook != NULL);
549 BUG_ON(rcu_dereference(set_sig_addr_hook) != NULL); 549 BUG_ON(set_sig_addr_hook != NULL);
550 BUG_ON(rcu_dereference(set_ras_addr_hook) != NULL); 550 BUG_ON(set_ras_addr_hook != NULL);
551 BUG_ON(rcu_dereference(nat_rtp_rtcp_hook) != NULL); 551 BUG_ON(nat_rtp_rtcp_hook != NULL);
552 BUG_ON(rcu_dereference(nat_t120_hook) != NULL); 552 BUG_ON(nat_t120_hook != NULL);
553 BUG_ON(rcu_dereference(nat_h245_hook) != NULL); 553 BUG_ON(nat_h245_hook != NULL);
554 BUG_ON(rcu_dereference(nat_callforwarding_hook) != NULL); 554 BUG_ON(nat_callforwarding_hook != NULL);
555 BUG_ON(rcu_dereference(nat_q931_hook) != NULL); 555 BUG_ON(nat_q931_hook != NULL);
556 556
557 rcu_assign_pointer(set_h245_addr_hook, set_h245_addr); 557 rcu_assign_pointer(set_h245_addr_hook, set_h245_addr);
558 rcu_assign_pointer(set_h225_addr_hook, set_h225_addr); 558 rcu_assign_pointer(set_h225_addr_hook, set_h225_addr);
diff --git a/net/ipv4/netfilter/nf_nat_irc.c b/net/ipv4/netfilter/nf_nat_irc.c
index 766e2c16c6b9..fe6f9cef6c85 100644
--- a/net/ipv4/netfilter/nf_nat_irc.c
+++ b/net/ipv4/netfilter/nf_nat_irc.c
@@ -74,7 +74,7 @@ static void __exit nf_nat_irc_fini(void)
74 74
75static int __init nf_nat_irc_init(void) 75static int __init nf_nat_irc_init(void)
76{ 76{
77 BUG_ON(rcu_dereference(nf_nat_irc_hook)); 77 BUG_ON(nf_nat_irc_hook != NULL);
78 rcu_assign_pointer(nf_nat_irc_hook, help); 78 rcu_assign_pointer(nf_nat_irc_hook, help);
79 return 0; 79 return 0;
80} 80}
diff --git a/net/ipv4/netfilter/nf_nat_pptp.c b/net/ipv4/netfilter/nf_nat_pptp.c
index e1385a099079..6817e7995f35 100644
--- a/net/ipv4/netfilter/nf_nat_pptp.c
+++ b/net/ipv4/netfilter/nf_nat_pptp.c
@@ -281,16 +281,16 @@ static int __init nf_nat_helper_pptp_init(void)
281{ 281{
282 nf_nat_need_gre(); 282 nf_nat_need_gre();
283 283
284 BUG_ON(rcu_dereference(nf_nat_pptp_hook_outbound)); 284 BUG_ON(nf_nat_pptp_hook_outbound != NULL);
285 rcu_assign_pointer(nf_nat_pptp_hook_outbound, pptp_outbound_pkt); 285 rcu_assign_pointer(nf_nat_pptp_hook_outbound, pptp_outbound_pkt);
286 286
287 BUG_ON(rcu_dereference(nf_nat_pptp_hook_inbound)); 287 BUG_ON(nf_nat_pptp_hook_inbound != NULL);
288 rcu_assign_pointer(nf_nat_pptp_hook_inbound, pptp_inbound_pkt); 288 rcu_assign_pointer(nf_nat_pptp_hook_inbound, pptp_inbound_pkt);
289 289
290 BUG_ON(rcu_dereference(nf_nat_pptp_hook_exp_gre)); 290 BUG_ON(nf_nat_pptp_hook_exp_gre != NULL);
291 rcu_assign_pointer(nf_nat_pptp_hook_exp_gre, pptp_exp_gre); 291 rcu_assign_pointer(nf_nat_pptp_hook_exp_gre, pptp_exp_gre);
292 292
293 BUG_ON(rcu_dereference(nf_nat_pptp_hook_expectfn)); 293 BUG_ON(nf_nat_pptp_hook_expectfn != NULL);
294 rcu_assign_pointer(nf_nat_pptp_hook_expectfn, pptp_nat_expected); 294 rcu_assign_pointer(nf_nat_pptp_hook_expectfn, pptp_nat_expected);
295 return 0; 295 return 0;
296} 296}
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c
index ce9edbcc01e3..3ca98971a1e9 100644
--- a/net/ipv4/netfilter/nf_nat_sip.c
+++ b/net/ipv4/netfilter/nf_nat_sip.c
@@ -293,8 +293,8 @@ static void __exit nf_nat_sip_fini(void)
293 293
294static int __init nf_nat_sip_init(void) 294static int __init nf_nat_sip_init(void)
295{ 295{
296 BUG_ON(rcu_dereference(nf_nat_sip_hook)); 296 BUG_ON(nf_nat_sip_hook != NULL);
297 BUG_ON(rcu_dereference(nf_nat_sdp_hook)); 297 BUG_ON(nf_nat_sdp_hook != NULL);
298 rcu_assign_pointer(nf_nat_sip_hook, ip_nat_sip); 298 rcu_assign_pointer(nf_nat_sip_hook, ip_nat_sip);
299 rcu_assign_pointer(nf_nat_sdp_hook, ip_nat_sdp); 299 rcu_assign_pointer(nf_nat_sdp_hook, ip_nat_sdp);
300 return 0; 300 return 0;
diff --git a/net/ipv4/netfilter/nf_nat_tftp.c b/net/ipv4/netfilter/nf_nat_tftp.c
index 0ecec701cb44..1360a94766dd 100644
--- a/net/ipv4/netfilter/nf_nat_tftp.c
+++ b/net/ipv4/netfilter/nf_nat_tftp.c
@@ -43,7 +43,7 @@ static void __exit nf_nat_tftp_fini(void)
43 43
44static int __init nf_nat_tftp_init(void) 44static int __init nf_nat_tftp_init(void)
45{ 45{
46 BUG_ON(rcu_dereference(nf_nat_tftp_hook)); 46 BUG_ON(nf_nat_tftp_hook != NULL);
47 rcu_assign_pointer(nf_nat_tftp_hook, help); 47 rcu_assign_pointer(nf_nat_tftp_hook, help);
48 return 0; 48 return 0;
49} 49}
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index ffdccc0972e0..ce34b281803f 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -46,17 +46,6 @@
46#include <net/sock.h> 46#include <net/sock.h>
47#include <net/raw.h> 47#include <net/raw.h>
48 48
49static int fold_prot_inuse(struct proto *proto)
50{
51 int res = 0;
52 int cpu;
53
54 for_each_possible_cpu(cpu)
55 res += proto->stats[cpu].inuse;
56
57 return res;
58}
59
60/* 49/*
61 * Report socket allocation statistics [mea@utu.fi] 50 * Report socket allocation statistics [mea@utu.fi]
62 */ 51 */
@@ -64,12 +53,12 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
64{ 53{
65 socket_seq_show(seq); 54 socket_seq_show(seq);
66 seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n", 55 seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n",
67 fold_prot_inuse(&tcp_prot), atomic_read(&tcp_orphan_count), 56 sock_prot_inuse(&tcp_prot), atomic_read(&tcp_orphan_count),
68 tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated), 57 tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated),
69 atomic_read(&tcp_memory_allocated)); 58 atomic_read(&tcp_memory_allocated));
70 seq_printf(seq, "UDP: inuse %d\n", fold_prot_inuse(&udp_prot)); 59 seq_printf(seq, "UDP: inuse %d\n", sock_prot_inuse(&udp_prot));
71 seq_printf(seq, "UDPLITE: inuse %d\n", fold_prot_inuse(&udplite_prot)); 60 seq_printf(seq, "UDPLITE: inuse %d\n", sock_prot_inuse(&udplite_prot));
72 seq_printf(seq, "RAW: inuse %d\n", fold_prot_inuse(&raw_prot)); 61 seq_printf(seq, "RAW: inuse %d\n", sock_prot_inuse(&raw_prot));
73 seq_printf(seq, "FRAG: inuse %d memory %d\n", 62 seq_printf(seq, "FRAG: inuse %d memory %d\n",
74 ip_frag_nqueues(), ip_frag_mem()); 63 ip_frag_nqueues(), ip_frag_mem());
75 return 0; 64 return 0;
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 3916faca3afe..66b42f547bf9 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -760,6 +760,8 @@ static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg)
760 } 760 }
761} 761}
762 762
763DEFINE_PROTO_INUSE(raw)
764
763struct proto raw_prot = { 765struct proto raw_prot = {
764 .name = "RAW", 766 .name = "RAW",
765 .owner = THIS_MODULE, 767 .owner = THIS_MODULE,
@@ -781,6 +783,7 @@ struct proto raw_prot = {
781 .compat_setsockopt = compat_raw_setsockopt, 783 .compat_setsockopt = compat_raw_setsockopt,
782 .compat_getsockopt = compat_raw_getsockopt, 784 .compat_getsockopt = compat_raw_getsockopt,
783#endif 785#endif
786 REF_PROTO_INUSE(raw)
784}; 787};
785 788
786#ifdef CONFIG_PROC_FS 789#ifdef CONFIG_PROC_FS
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 21b12de9e653..1bff9ed349ff 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -578,6 +578,9 @@ static void rt_check_expire(struct work_struct *work)
578 i = (i + 1) & rt_hash_mask; 578 i = (i + 1) & rt_hash_mask;
579 rthp = &rt_hash_table[i].chain; 579 rthp = &rt_hash_table[i].chain;
580 580
581 if (need_resched())
582 cond_resched();
583
581 if (*rthp == NULL) 584 if (*rthp == NULL)
582 continue; 585 continue;
583 spin_lock_bh(rt_hash_lock_addr(i)); 586 spin_lock_bh(rt_hash_lock_addr(i));
@@ -851,9 +854,7 @@ restart:
851 */ 854 */
852 rcu_assign_pointer(rt_hash_table[hash].chain, rth); 855 rcu_assign_pointer(rt_hash_table[hash].chain, rth);
853 856
854 rth->u.dst.__use++; 857 dst_use(&rth->u.dst, now);
855 dst_hold(&rth->u.dst);
856 rth->u.dst.lastuse = now;
857 spin_unlock_bh(rt_hash_lock_addr(hash)); 858 spin_unlock_bh(rt_hash_lock_addr(hash));
858 859
859 rt_drop(rt); 860 rt_drop(rt);
@@ -1813,11 +1814,6 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1813 goto martian_destination; 1814 goto martian_destination;
1814 1815
1815 err = ip_mkroute_input(skb, &res, &fl, in_dev, daddr, saddr, tos); 1816 err = ip_mkroute_input(skb, &res, &fl, in_dev, daddr, saddr, tos);
1816 if (err == -ENOBUFS)
1817 goto e_nobufs;
1818 if (err == -EINVAL)
1819 goto e_inval;
1820
1821done: 1817done:
1822 in_dev_put(in_dev); 1818 in_dev_put(in_dev);
1823 if (free_res) 1819 if (free_res)
@@ -1935,9 +1931,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1935 rth->fl.oif == 0 && 1931 rth->fl.oif == 0 &&
1936 rth->fl.mark == skb->mark && 1932 rth->fl.mark == skb->mark &&
1937 rth->fl.fl4_tos == tos) { 1933 rth->fl.fl4_tos == tos) {
1938 rth->u.dst.lastuse = jiffies; 1934 dst_use(&rth->u.dst, jiffies);
1939 dst_hold(&rth->u.dst);
1940 rth->u.dst.__use++;
1941 RT_CACHE_STAT_INC(in_hit); 1935 RT_CACHE_STAT_INC(in_hit);
1942 rcu_read_unlock(); 1936 rcu_read_unlock();
1943 skb->dst = (struct dst_entry*)rth; 1937 skb->dst = (struct dst_entry*)rth;
@@ -2331,9 +2325,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
2331 rth->fl.mark == flp->mark && 2325 rth->fl.mark == flp->mark &&
2332 !((rth->fl.fl4_tos ^ flp->fl4_tos) & 2326 !((rth->fl.fl4_tos ^ flp->fl4_tos) &
2333 (IPTOS_RT_MASK | RTO_ONLINK))) { 2327 (IPTOS_RT_MASK | RTO_ONLINK))) {
2334 rth->u.dst.lastuse = jiffies; 2328 dst_use(&rth->u.dst, jiffies);
2335 dst_hold(&rth->u.dst);
2336 rth->u.dst.__use++;
2337 RT_CACHE_STAT_INC(out_hit); 2329 RT_CACHE_STAT_INC(out_hit);
2338 rcu_read_unlock_bh(); 2330 rcu_read_unlock_bh();
2339 *rp = rth; 2331 *rp = rth;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c64072bb504b..8e65182f7af1 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2456,11 +2456,11 @@ void __init tcp_init(void)
2456 thash_entries ? 0 : 512 * 1024); 2456 thash_entries ? 0 : 512 * 1024);
2457 tcp_hashinfo.ehash_size = 1 << tcp_hashinfo.ehash_size; 2457 tcp_hashinfo.ehash_size = 1 << tcp_hashinfo.ehash_size;
2458 for (i = 0; i < tcp_hashinfo.ehash_size; i++) { 2458 for (i = 0; i < tcp_hashinfo.ehash_size; i++) {
2459 rwlock_init(&tcp_hashinfo.ehash[i].lock);
2460 INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].chain); 2459 INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].chain);
2461 INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].twchain); 2460 INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].twchain);
2462 } 2461 }
2463 2462 if (inet_ehash_locks_alloc(&tcp_hashinfo))
2463 panic("TCP: failed to alloc ehash_locks");
2464 tcp_hashinfo.bhash = 2464 tcp_hashinfo.bhash =
2465 alloc_large_system_hash("TCP bind", 2465 alloc_large_system_hash("TCP bind",
2466 sizeof(struct inet_bind_hashbucket), 2466 sizeof(struct inet_bind_hashbucket),
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index ca9590f4f520..0f0c1c9829a1 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1269,6 +1269,9 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
1269 if (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window)) 1269 if (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window))
1270 return 0; 1270 return 0;
1271 1271
1272 if (!tp->packets_out)
1273 goto out;
1274
1272 /* SACK fastpath: 1275 /* SACK fastpath:
1273 * if the only SACK change is the increase of the end_seq of 1276 * if the only SACK change is the increase of the end_seq of
1274 * the first block then only apply that SACK block 1277 * the first block then only apply that SACK block
@@ -1400,11 +1403,9 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
1400 /* DSACK info lost if out-of-mem, try SACK still */ 1403 /* DSACK info lost if out-of-mem, try SACK still */
1401 if (in_sack <= 0) 1404 if (in_sack <= 0)
1402 in_sack = tcp_match_skb_to_sack(sk, skb, start_seq, end_seq); 1405 in_sack = tcp_match_skb_to_sack(sk, skb, start_seq, end_seq);
1403 if (in_sack < 0) 1406 if (unlikely(in_sack < 0))
1404 break; 1407 break;
1405 1408
1406 fack_count += tcp_skb_pcount(skb);
1407
1408 sacked = TCP_SKB_CB(skb)->sacked; 1409 sacked = TCP_SKB_CB(skb)->sacked;
1409 1410
1410 /* Account D-SACK for retransmitted packet. */ 1411 /* Account D-SACK for retransmitted packet. */
@@ -1419,19 +1420,17 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
1419 if ((dup_sack && in_sack) && 1420 if ((dup_sack && in_sack) &&
1420 (sacked&TCPCB_SACKED_ACKED)) 1421 (sacked&TCPCB_SACKED_ACKED))
1421 reord = min(fack_count, reord); 1422 reord = min(fack_count, reord);
1422 } else {
1423 /* If it was in a hole, we detected reordering. */
1424 if (fack_count < prior_fackets &&
1425 !(sacked&TCPCB_SACKED_ACKED))
1426 reord = min(fack_count, reord);
1427 } 1423 }
1428 1424
1429 /* Nothing to do; acked frame is about to be dropped. */ 1425 /* Nothing to do; acked frame is about to be dropped. */
1426 fack_count += tcp_skb_pcount(skb);
1430 continue; 1427 continue;
1431 } 1428 }
1432 1429
1433 if (!in_sack) 1430 if (!in_sack) {
1431 fack_count += tcp_skb_pcount(skb);
1434 continue; 1432 continue;
1433 }
1435 1434
1436 if (!(sacked&TCPCB_SACKED_ACKED)) { 1435 if (!(sacked&TCPCB_SACKED_ACKED)) {
1437 if (sacked & TCPCB_SACKED_RETRANS) { 1436 if (sacked & TCPCB_SACKED_RETRANS) {
@@ -1448,12 +1447,17 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
1448 tp->retransmit_skb_hint = NULL; 1447 tp->retransmit_skb_hint = NULL;
1449 } 1448 }
1450 } else { 1449 } else {
1451 /* New sack for not retransmitted frame, 1450 if (!(sacked & TCPCB_RETRANS)) {
1452 * which was in hole. It is reordering. 1451 /* New sack for not retransmitted frame,
1453 */ 1452 * which was in hole. It is reordering.
1454 if (!(sacked & TCPCB_RETRANS) && 1453 */
1455 fack_count < prior_fackets) 1454 if (fack_count < prior_fackets)
1456 reord = min(fack_count, reord); 1455 reord = min(fack_count, reord);
1456
1457 /* SACK enhanced F-RTO (RFC4138; Appendix B) */
1458 if (!after(TCP_SKB_CB(skb)->end_seq, tp->frto_highmark))
1459 flag |= FLAG_ONLY_ORIG_SACKED;
1460 }
1457 1461
1458 if (sacked & TCPCB_LOST) { 1462 if (sacked & TCPCB_LOST) {
1459 TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST; 1463 TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST;
@@ -1462,24 +1466,13 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
1462 /* clear lost hint */ 1466 /* clear lost hint */
1463 tp->retransmit_skb_hint = NULL; 1467 tp->retransmit_skb_hint = NULL;
1464 } 1468 }
1465 /* SACK enhanced F-RTO detection.
1466 * Set flag if and only if non-rexmitted
1467 * segments below frto_highmark are
1468 * SACKed (RFC4138; Appendix B).
1469 * Clearing correct due to in-order walk
1470 */
1471 if (after(end_seq, tp->frto_highmark)) {
1472 flag &= ~FLAG_ONLY_ORIG_SACKED;
1473 } else {
1474 if (!(sacked & TCPCB_RETRANS))
1475 flag |= FLAG_ONLY_ORIG_SACKED;
1476 }
1477 } 1469 }
1478 1470
1479 TCP_SKB_CB(skb)->sacked |= TCPCB_SACKED_ACKED; 1471 TCP_SKB_CB(skb)->sacked |= TCPCB_SACKED_ACKED;
1480 flag |= FLAG_DATA_SACKED; 1472 flag |= FLAG_DATA_SACKED;
1481 tp->sacked_out += tcp_skb_pcount(skb); 1473 tp->sacked_out += tcp_skb_pcount(skb);
1482 1474
1475 fack_count += tcp_skb_pcount(skb);
1483 if (fack_count > tp->fackets_out) 1476 if (fack_count > tp->fackets_out)
1484 tp->fackets_out = fack_count; 1477 tp->fackets_out = fack_count;
1485 1478
@@ -1490,6 +1483,8 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
1490 } else { 1483 } else {
1491 if (dup_sack && (sacked&TCPCB_RETRANS)) 1484 if (dup_sack && (sacked&TCPCB_RETRANS))
1492 reord = min(fack_count, reord); 1485 reord = min(fack_count, reord);
1486
1487 fack_count += tcp_skb_pcount(skb);
1493 } 1488 }
1494 1489
1495 /* D-SACK. We can detect redundant retransmission 1490 /* D-SACK. We can detect redundant retransmission
@@ -1504,6 +1499,12 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
1504 tp->retransmit_skb_hint = NULL; 1499 tp->retransmit_skb_hint = NULL;
1505 } 1500 }
1506 } 1501 }
1502
1503 /* SACK enhanced FRTO (RFC4138, Appendix B): Clearing correct
1504 * due to in-order walk
1505 */
1506 if (after(end_seq, tp->frto_highmark))
1507 flag &= ~FLAG_ONLY_ORIG_SACKED;
1507 } 1508 }
1508 1509
1509 if (tp->retrans_out && 1510 if (tp->retrans_out &&
@@ -1515,7 +1516,9 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
1515 1516
1516 if ((reord < tp->fackets_out) && icsk->icsk_ca_state != TCP_CA_Loss && 1517 if ((reord < tp->fackets_out) && icsk->icsk_ca_state != TCP_CA_Loss &&
1517 (!tp->frto_highmark || after(tp->snd_una, tp->frto_highmark))) 1518 (!tp->frto_highmark || after(tp->snd_una, tp->frto_highmark)))
1518 tcp_update_reordering(sk, ((tp->fackets_out + 1) - reord), 0); 1519 tcp_update_reordering(sk, tp->fackets_out - reord, 0);
1520
1521out:
1519 1522
1520#if FASTRETRANS_DEBUG > 0 1523#if FASTRETRANS_DEBUG > 0
1521 BUG_TRAP((int)tp->sacked_out >= 0); 1524 BUG_TRAP((int)tp->sacked_out >= 0);
@@ -1671,6 +1674,9 @@ void tcp_enter_frto(struct sock *sk)
1671 } 1674 }
1672 tcp_verify_left_out(tp); 1675 tcp_verify_left_out(tp);
1673 1676
1677 /* Too bad if TCP was application limited */
1678 tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp) + 1);
1679
1674 /* Earlier loss recovery underway (see RFC4138; Appendix B). 1680 /* Earlier loss recovery underway (see RFC4138; Appendix B).
1675 * The last condition is necessary at least in tp->frto_counter case. 1681 * The last condition is necessary at least in tp->frto_counter case.
1676 */ 1682 */
@@ -1703,6 +1709,8 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag)
1703 tcp_for_write_queue(skb, sk) { 1709 tcp_for_write_queue(skb, sk) {
1704 if (skb == tcp_send_head(sk)) 1710 if (skb == tcp_send_head(sk))
1705 break; 1711 break;
1712
1713 TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST;
1706 /* 1714 /*
1707 * Count the retransmission made on RTO correctly (only when 1715 * Count the retransmission made on RTO correctly (only when
1708 * waiting for the first ACK and did not get it)... 1716 * waiting for the first ACK and did not get it)...
@@ -1716,7 +1724,7 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag)
1716 } else { 1724 } else {
1717 if (TCP_SKB_CB(skb)->sacked & TCPCB_RETRANS) 1725 if (TCP_SKB_CB(skb)->sacked & TCPCB_RETRANS)
1718 tp->undo_marker = 0; 1726 tp->undo_marker = 0;
1719 TCP_SKB_CB(skb)->sacked &= ~(TCPCB_LOST|TCPCB_SACKED_RETRANS); 1727 TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS;
1720 } 1728 }
1721 1729
1722 /* Don't lost mark skbs that were fwd transmitted after RTO */ 1730 /* Don't lost mark skbs that were fwd transmitted after RTO */
@@ -2630,7 +2638,8 @@ static u32 tcp_tso_acked(struct sock *sk, struct sk_buff *skb)
2630 * is before the ack sequence we can discard it as it's confirmed to have 2638 * is before the ack sequence we can discard it as it's confirmed to have
2631 * arrived at the other end. 2639 * arrived at the other end.
2632 */ 2640 */
2633static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p) 2641static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p,
2642 int prior_fackets)
2634{ 2643{
2635 struct tcp_sock *tp = tcp_sk(sk); 2644 struct tcp_sock *tp = tcp_sk(sk);
2636 const struct inet_connection_sock *icsk = inet_csk(sk); 2645 const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -2639,6 +2648,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p)
2639 int fully_acked = 1; 2648 int fully_acked = 1;
2640 int flag = 0; 2649 int flag = 0;
2641 int prior_packets = tp->packets_out; 2650 int prior_packets = tp->packets_out;
2651 u32 cnt = 0;
2652 u32 reord = tp->packets_out;
2642 s32 seq_rtt = -1; 2653 s32 seq_rtt = -1;
2643 ktime_t last_ackt = net_invalid_timestamp(); 2654 ktime_t last_ackt = net_invalid_timestamp();
2644 2655
@@ -2679,10 +2690,14 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p)
2679 if ((flag & FLAG_DATA_ACKED) || 2690 if ((flag & FLAG_DATA_ACKED) ||
2680 (packets_acked > 1)) 2691 (packets_acked > 1))
2681 flag |= FLAG_NONHEAD_RETRANS_ACKED; 2692 flag |= FLAG_NONHEAD_RETRANS_ACKED;
2682 } else if (seq_rtt < 0) { 2693 } else {
2683 seq_rtt = now - scb->when; 2694 if (seq_rtt < 0) {
2684 if (fully_acked) 2695 seq_rtt = now - scb->when;
2685 last_ackt = skb->tstamp; 2696 if (fully_acked)
2697 last_ackt = skb->tstamp;
2698 }
2699 if (!(sacked & TCPCB_SACKED_ACKED))
2700 reord = min(cnt, reord);
2686 } 2701 }
2687 2702
2688 if (sacked & TCPCB_SACKED_ACKED) 2703 if (sacked & TCPCB_SACKED_ACKED)
@@ -2693,12 +2708,16 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p)
2693 if ((sacked & TCPCB_URG) && tp->urg_mode && 2708 if ((sacked & TCPCB_URG) && tp->urg_mode &&
2694 !before(end_seq, tp->snd_up)) 2709 !before(end_seq, tp->snd_up))
2695 tp->urg_mode = 0; 2710 tp->urg_mode = 0;
2696 } else if (seq_rtt < 0) { 2711 } else {
2697 seq_rtt = now - scb->when; 2712 if (seq_rtt < 0) {
2698 if (fully_acked) 2713 seq_rtt = now - scb->when;
2699 last_ackt = skb->tstamp; 2714 if (fully_acked)
2715 last_ackt = skb->tstamp;
2716 }
2717 reord = min(cnt, reord);
2700 } 2718 }
2701 tp->packets_out -= packets_acked; 2719 tp->packets_out -= packets_acked;
2720 cnt += packets_acked;
2702 2721
2703 /* Initial outgoing SYN's get put onto the write_queue 2722 /* Initial outgoing SYN's get put onto the write_queue
2704 * just like anything else we transmit. It is not 2723 * just like anything else we transmit. It is not
@@ -2730,13 +2749,18 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p)
2730 tcp_ack_update_rtt(sk, flag, seq_rtt); 2749 tcp_ack_update_rtt(sk, flag, seq_rtt);
2731 tcp_rearm_rto(sk); 2750 tcp_rearm_rto(sk);
2732 2751
2752 if (tcp_is_reno(tp)) {
2753 tcp_remove_reno_sacks(sk, pkts_acked);
2754 } else {
2755 /* Non-retransmitted hole got filled? That's reordering */
2756 if (reord < prior_fackets)
2757 tcp_update_reordering(sk, tp->fackets_out - reord, 0);
2758 }
2759
2733 tp->fackets_out -= min(pkts_acked, tp->fackets_out); 2760 tp->fackets_out -= min(pkts_acked, tp->fackets_out);
2734 /* hint's skb might be NULL but we don't need to care */ 2761 /* hint's skb might be NULL but we don't need to care */
2735 tp->fastpath_cnt_hint -= min_t(u32, pkts_acked, 2762 tp->fastpath_cnt_hint -= min_t(u32, pkts_acked,
2736 tp->fastpath_cnt_hint); 2763 tp->fastpath_cnt_hint);
2737 if (tcp_is_reno(tp))
2738 tcp_remove_reno_sacks(sk, pkts_acked);
2739
2740 if (ca_ops->pkts_acked) { 2764 if (ca_ops->pkts_acked) {
2741 s32 rtt_us = -1; 2765 s32 rtt_us = -1;
2742 2766
@@ -3019,6 +3043,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
3019 u32 ack_seq = TCP_SKB_CB(skb)->seq; 3043 u32 ack_seq = TCP_SKB_CB(skb)->seq;
3020 u32 ack = TCP_SKB_CB(skb)->ack_seq; 3044 u32 ack = TCP_SKB_CB(skb)->ack_seq;
3021 u32 prior_in_flight; 3045 u32 prior_in_flight;
3046 u32 prior_fackets;
3022 s32 seq_rtt; 3047 s32 seq_rtt;
3023 int prior_packets; 3048 int prior_packets;
3024 int frto_cwnd = 0; 3049 int frto_cwnd = 0;
@@ -3043,6 +3068,8 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
3043 tp->bytes_acked += min(ack - prior_snd_una, tp->mss_cache); 3068 tp->bytes_acked += min(ack - prior_snd_una, tp->mss_cache);
3044 } 3069 }
3045 3070
3071 prior_fackets = tp->fackets_out;
3072
3046 if (!(flag&FLAG_SLOWPATH) && after(ack, prior_snd_una)) { 3073 if (!(flag&FLAG_SLOWPATH) && after(ack, prior_snd_una)) {
3047 /* Window is constant, pure forward advance. 3074 /* Window is constant, pure forward advance.
3048 * No more checks are required. 3075 * No more checks are required.
@@ -3084,13 +3111,13 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
3084 prior_in_flight = tcp_packets_in_flight(tp); 3111 prior_in_flight = tcp_packets_in_flight(tp);
3085 3112
3086 /* See if we can take anything off of the retransmit queue. */ 3113 /* See if we can take anything off of the retransmit queue. */
3087 flag |= tcp_clean_rtx_queue(sk, &seq_rtt); 3114 flag |= tcp_clean_rtx_queue(sk, &seq_rtt, prior_fackets);
3088 3115
3116 if (tp->frto_counter)
3117 frto_cwnd = tcp_process_frto(sk, flag);
3089 /* Guarantee sacktag reordering detection against wrap-arounds */ 3118 /* Guarantee sacktag reordering detection against wrap-arounds */
3090 if (before(tp->frto_highmark, tp->snd_una)) 3119 if (before(tp->frto_highmark, tp->snd_una))
3091 tp->frto_highmark = 0; 3120 tp->frto_highmark = 0;
3092 if (tp->frto_counter)
3093 frto_cwnd = tcp_process_frto(sk, flag);
3094 3121
3095 if (tcp_ack_is_dubious(sk, flag)) { 3122 if (tcp_ack_is_dubious(sk, flag)) {
3096 /* Advance CWND, if state allows this. */ 3123 /* Advance CWND, if state allows this. */
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index d438dfb0c8f3..e566f3c67677 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2049,8 +2049,9 @@ static void *established_get_first(struct seq_file *seq)
2049 struct sock *sk; 2049 struct sock *sk;
2050 struct hlist_node *node; 2050 struct hlist_node *node;
2051 struct inet_timewait_sock *tw; 2051 struct inet_timewait_sock *tw;
2052 rwlock_t *lock = inet_ehash_lockp(&tcp_hashinfo, st->bucket);
2052 2053
2053 read_lock_bh(&tcp_hashinfo.ehash[st->bucket].lock); 2054 read_lock_bh(lock);
2054 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) { 2055 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
2055 if (sk->sk_family != st->family) { 2056 if (sk->sk_family != st->family) {
2056 continue; 2057 continue;
@@ -2067,7 +2068,7 @@ static void *established_get_first(struct seq_file *seq)
2067 rc = tw; 2068 rc = tw;
2068 goto out; 2069 goto out;
2069 } 2070 }
2070 read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock); 2071 read_unlock_bh(lock);
2071 st->state = TCP_SEQ_STATE_ESTABLISHED; 2072 st->state = TCP_SEQ_STATE_ESTABLISHED;
2072 } 2073 }
2073out: 2074out:
@@ -2094,11 +2095,11 @@ get_tw:
2094 cur = tw; 2095 cur = tw;
2095 goto out; 2096 goto out;
2096 } 2097 }
2097 read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock); 2098 read_unlock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
2098 st->state = TCP_SEQ_STATE_ESTABLISHED; 2099 st->state = TCP_SEQ_STATE_ESTABLISHED;
2099 2100
2100 if (++st->bucket < tcp_hashinfo.ehash_size) { 2101 if (++st->bucket < tcp_hashinfo.ehash_size) {
2101 read_lock_bh(&tcp_hashinfo.ehash[st->bucket].lock); 2102 read_lock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
2102 sk = sk_head(&tcp_hashinfo.ehash[st->bucket].chain); 2103 sk = sk_head(&tcp_hashinfo.ehash[st->bucket].chain);
2103 } else { 2104 } else {
2104 cur = NULL; 2105 cur = NULL;
@@ -2206,7 +2207,7 @@ static void tcp_seq_stop(struct seq_file *seq, void *v)
2206 case TCP_SEQ_STATE_TIME_WAIT: 2207 case TCP_SEQ_STATE_TIME_WAIT:
2207 case TCP_SEQ_STATE_ESTABLISHED: 2208 case TCP_SEQ_STATE_ESTABLISHED:
2208 if (v) 2209 if (v)
2209 read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock); 2210 read_unlock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
2210 break; 2211 break;
2211 } 2212 }
2212} 2213}
@@ -2417,6 +2418,8 @@ void tcp4_proc_exit(void)
2417} 2418}
2418#endif /* CONFIG_PROC_FS */ 2419#endif /* CONFIG_PROC_FS */
2419 2420
2421DEFINE_PROTO_INUSE(tcp)
2422
2420struct proto tcp_prot = { 2423struct proto tcp_prot = {
2421 .name = "TCP", 2424 .name = "TCP",
2422 .owner = THIS_MODULE, 2425 .owner = THIS_MODULE,
@@ -2451,6 +2454,7 @@ struct proto tcp_prot = {
2451 .compat_setsockopt = compat_tcp_setsockopt, 2454 .compat_setsockopt = compat_tcp_setsockopt,
2452 .compat_getsockopt = compat_tcp_getsockopt, 2455 .compat_getsockopt = compat_tcp_getsockopt,
2453#endif 2456#endif
2457 REF_PROTO_INUSE(tcp)
2454}; 2458};
2455 2459
2456void __init tcp_v4_init(struct net_proto_family *ops) 2460void __init tcp_v4_init(struct net_proto_family *ops)
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c
index a794a8ca8b4f..978b3fd61e65 100644
--- a/net/ipv4/tunnel4.c
+++ b/net/ipv4/tunnel4.c
@@ -17,6 +17,11 @@ static struct xfrm_tunnel *tunnel4_handlers;
17static struct xfrm_tunnel *tunnel64_handlers; 17static struct xfrm_tunnel *tunnel64_handlers;
18static DEFINE_MUTEX(tunnel4_mutex); 18static DEFINE_MUTEX(tunnel4_mutex);
19 19
20static inline struct xfrm_tunnel **fam_handlers(unsigned short family)
21{
22 return (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers;
23}
24
20int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family) 25int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family)
21{ 26{
22 struct xfrm_tunnel **pprev; 27 struct xfrm_tunnel **pprev;
@@ -25,8 +30,7 @@ int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family)
25 30
26 mutex_lock(&tunnel4_mutex); 31 mutex_lock(&tunnel4_mutex);
27 32
28 for (pprev = (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; 33 for (pprev = fam_handlers(family); *pprev; pprev = &(*pprev)->next) {
29 *pprev; pprev = &(*pprev)->next) {
30 if ((*pprev)->priority > priority) 34 if ((*pprev)->priority > priority)
31 break; 35 break;
32 if ((*pprev)->priority == priority) 36 if ((*pprev)->priority == priority)
@@ -53,8 +57,7 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family)
53 57
54 mutex_lock(&tunnel4_mutex); 58 mutex_lock(&tunnel4_mutex);
55 59
56 for (pprev = (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; 60 for (pprev = fam_handlers(family); *pprev; pprev = &(*pprev)->next) {
57 *pprev; pprev = &(*pprev)->next) {
58 if (*pprev == handler) { 61 if (*pprev == handler) {
59 *pprev = handler->next; 62 *pprev = handler->next;
60 ret = 0; 63 ret = 0;
@@ -118,6 +121,17 @@ static void tunnel4_err(struct sk_buff *skb, u32 info)
118 break; 121 break;
119} 122}
120 123
124#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
125static void tunnel64_err(struct sk_buff *skb, u32 info)
126{
127 struct xfrm_tunnel *handler;
128
129 for (handler = tunnel64_handlers; handler; handler = handler->next)
130 if (!handler->err_handler(skb, info))
131 break;
132}
133#endif
134
121static struct net_protocol tunnel4_protocol = { 135static struct net_protocol tunnel4_protocol = {
122 .handler = tunnel4_rcv, 136 .handler = tunnel4_rcv,
123 .err_handler = tunnel4_err, 137 .err_handler = tunnel4_err,
@@ -127,7 +141,7 @@ static struct net_protocol tunnel4_protocol = {
127#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 141#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
128static struct net_protocol tunnel64_protocol = { 142static struct net_protocol tunnel64_protocol = {
129 .handler = tunnel64_rcv, 143 .handler = tunnel64_rcv,
130 .err_handler = tunnel4_err, 144 .err_handler = tunnel64_err,
131 .no_policy = 1, 145 .no_policy = 1,
132}; 146};
133#endif 147#endif
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 4bc25b46f33f..03c400ca14c5 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1430,6 +1430,8 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
1430 1430
1431} 1431}
1432 1432
1433DEFINE_PROTO_INUSE(udp)
1434
1433struct proto udp_prot = { 1435struct proto udp_prot = {
1434 .name = "UDP", 1436 .name = "UDP",
1435 .owner = THIS_MODULE, 1437 .owner = THIS_MODULE,
@@ -1452,6 +1454,7 @@ struct proto udp_prot = {
1452 .compat_setsockopt = compat_udp_setsockopt, 1454 .compat_setsockopt = compat_udp_setsockopt,
1453 .compat_getsockopt = compat_udp_getsockopt, 1455 .compat_getsockopt = compat_udp_getsockopt,
1454#endif 1456#endif
1457 REF_PROTO_INUSE(udp)
1455}; 1458};
1456 1459
1457/* ------------------------------------------------------------------------ */ 1460/* ------------------------------------------------------------------------ */
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index 94977205abb4..f5baeb3e8b85 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -44,6 +44,8 @@ static struct net_protocol udplite_protocol = {
44 .no_policy = 1, 44 .no_policy = 1,
45}; 45};
46 46
47DEFINE_PROTO_INUSE(udplite)
48
47struct proto udplite_prot = { 49struct proto udplite_prot = {
48 .name = "UDP-Lite", 50 .name = "UDP-Lite",
49 .owner = THIS_MODULE, 51 .owner = THIS_MODULE,
@@ -67,6 +69,7 @@ struct proto udplite_prot = {
67 .compat_setsockopt = compat_udp_setsockopt, 69 .compat_setsockopt = compat_udp_setsockopt,
68 .compat_getsockopt = compat_udp_getsockopt, 70 .compat_getsockopt = compat_udp_getsockopt,
69#endif 71#endif
72 REF_PROTO_INUSE(udplite)
70}; 73};
71 74
72static struct inet_protosw udplite4_protosw = { 75static struct inet_protosw udplite4_protosw = {
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 706622af206f..428c6b0e26d8 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -31,25 +31,6 @@ struct fib6_rule
31 31
32static struct fib_rules_ops fib6_rules_ops; 32static struct fib_rules_ops fib6_rules_ops;
33 33
34static struct fib6_rule main_rule = {
35 .common = {
36 .refcnt = ATOMIC_INIT(2),
37 .pref = 0x7FFE,
38 .action = FR_ACT_TO_TBL,
39 .table = RT6_TABLE_MAIN,
40 },
41};
42
43static struct fib6_rule local_rule = {
44 .common = {
45 .refcnt = ATOMIC_INIT(2),
46 .pref = 0,
47 .action = FR_ACT_TO_TBL,
48 .table = RT6_TABLE_LOCAL,
49 .flags = FIB_RULE_PERMANENT,
50 },
51};
52
53struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags, 34struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags,
54 pol_lookup_t lookup) 35 pol_lookup_t lookup)
55{ 36{
@@ -270,11 +251,23 @@ static struct fib_rules_ops fib6_rules_ops = {
270 .owner = THIS_MODULE, 251 .owner = THIS_MODULE,
271}; 252};
272 253
273void __init fib6_rules_init(void) 254static int __init fib6_default_rules_init(void)
274{ 255{
275 list_add_tail(&local_rule.common.list, &fib6_rules_ops.rules_list); 256 int err;
276 list_add_tail(&main_rule.common.list, &fib6_rules_ops.rules_list); 257
258 err = fib_default_rule_add(&fib6_rules_ops, 0,
259 RT6_TABLE_LOCAL, FIB_RULE_PERMANENT);
260 if (err < 0)
261 return err;
262 err = fib_default_rule_add(&fib6_rules_ops, 0x7FFE, RT6_TABLE_MAIN, 0);
263 if (err < 0)
264 return err;
265 return 0;
266}
277 267
268void __init fib6_rules_init(void)
269{
270 BUG_ON(fib6_default_rules_init());
278 fib_rules_register(&fib6_rules_ops); 271 fib_rules_register(&fib6_rules_ops);
279} 272}
280 273
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index d6f1026f1943..adc73adadfae 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -37,9 +37,8 @@ void __inet6_hash(struct inet_hashinfo *hashinfo,
37 } else { 37 } else {
38 unsigned int hash; 38 unsigned int hash;
39 sk->sk_hash = hash = inet6_sk_ehashfn(sk); 39 sk->sk_hash = hash = inet6_sk_ehashfn(sk);
40 hash &= (hashinfo->ehash_size - 1); 40 list = &inet_ehash_bucket(hashinfo, hash)->chain;
41 list = &hashinfo->ehash[hash].chain; 41 lock = inet_ehash_lockp(hashinfo, hash);
42 lock = &hashinfo->ehash[hash].lock;
43 write_lock(lock); 42 write_lock(lock);
44 } 43 }
45 44
@@ -70,9 +69,10 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
70 */ 69 */
71 unsigned int hash = inet6_ehashfn(daddr, hnum, saddr, sport); 70 unsigned int hash = inet6_ehashfn(daddr, hnum, saddr, sport);
72 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); 71 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
72 rwlock_t *lock = inet_ehash_lockp(hashinfo, hash);
73 73
74 prefetch(head->chain.first); 74 prefetch(head->chain.first);
75 read_lock(&head->lock); 75 read_lock(lock);
76 sk_for_each(sk, node, &head->chain) { 76 sk_for_each(sk, node, &head->chain) {
77 /* For IPV6 do the cheaper port and family tests first. */ 77 /* For IPV6 do the cheaper port and family tests first. */
78 if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif)) 78 if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif))
@@ -92,12 +92,12 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
92 goto hit; 92 goto hit;
93 } 93 }
94 } 94 }
95 read_unlock(&head->lock); 95 read_unlock(lock);
96 return NULL; 96 return NULL;
97 97
98hit: 98hit:
99 sock_hold(sk); 99 sock_hold(sk);
100 read_unlock(&head->lock); 100 read_unlock(lock);
101 return sk; 101 return sk;
102} 102}
103EXPORT_SYMBOL(__inet6_lookup_established); 103EXPORT_SYMBOL(__inet6_lookup_established);
@@ -175,12 +175,13 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
175 const unsigned int hash = inet6_ehashfn(daddr, lport, saddr, 175 const unsigned int hash = inet6_ehashfn(daddr, lport, saddr,
176 inet->dport); 176 inet->dport);
177 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); 177 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
178 rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
178 struct sock *sk2; 179 struct sock *sk2;
179 const struct hlist_node *node; 180 const struct hlist_node *node;
180 struct inet_timewait_sock *tw; 181 struct inet_timewait_sock *tw;
181 182
182 prefetch(head->chain.first); 183 prefetch(head->chain.first);
183 write_lock(&head->lock); 184 write_lock(lock);
184 185
185 /* Check TIME-WAIT sockets first. */ 186 /* Check TIME-WAIT sockets first. */
186 sk_for_each(sk2, node, &head->twchain) { 187 sk_for_each(sk2, node, &head->twchain) {
@@ -216,7 +217,7 @@ unique:
216 __sk_add_node(sk, &head->chain); 217 __sk_add_node(sk, &head->chain);
217 sk->sk_hash = hash; 218 sk->sk_hash = hash;
218 sock_prot_inc_use(sk->sk_prot); 219 sock_prot_inc_use(sk->sk_prot);
219 write_unlock(&head->lock); 220 write_unlock(lock);
220 221
221 if (twp != NULL) { 222 if (twp != NULL) {
222 *twp = tw; 223 *twp = tw;
@@ -231,7 +232,7 @@ unique:
231 return 0; 232 return 0;
232 233
233not_unique: 234not_unique:
234 write_unlock(&head->lock); 235 write_unlock(lock);
235 return -EADDRNOTAVAIL; 236 return -EADDRNOTAVAIL;
236} 237}
237 238
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 653fc0a8235b..86e1835ce4e4 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1339,6 +1339,19 @@ error:
1339 return err; 1339 return err;
1340} 1340}
1341 1341
1342static void ip6_cork_release(struct inet_sock *inet, struct ipv6_pinfo *np)
1343{
1344 inet->cork.flags &= ~IPCORK_OPT;
1345 kfree(np->cork.opt);
1346 np->cork.opt = NULL;
1347 if (np->cork.rt) {
1348 dst_release(&np->cork.rt->u.dst);
1349 np->cork.rt = NULL;
1350 inet->cork.flags &= ~IPCORK_ALLFRAG;
1351 }
1352 memset(&inet->cork.fl, 0, sizeof(inet->cork.fl));
1353}
1354
1342int ip6_push_pending_frames(struct sock *sk) 1355int ip6_push_pending_frames(struct sock *sk)
1343{ 1356{
1344 struct sk_buff *skb, *tmp_skb; 1357 struct sk_buff *skb, *tmp_skb;
@@ -1415,15 +1428,7 @@ int ip6_push_pending_frames(struct sock *sk)
1415 } 1428 }
1416 1429
1417out: 1430out:
1418 inet->cork.flags &= ~IPCORK_OPT; 1431 ip6_cork_release(inet, np);
1419 kfree(np->cork.opt);
1420 np->cork.opt = NULL;
1421 if (np->cork.rt) {
1422 dst_release(&np->cork.rt->u.dst);
1423 np->cork.rt = NULL;
1424 inet->cork.flags &= ~IPCORK_ALLFRAG;
1425 }
1426 memset(&inet->cork.fl, 0, sizeof(inet->cork.fl));
1427 return err; 1432 return err;
1428error: 1433error:
1429 goto out; 1434 goto out;
@@ -1431,8 +1436,6 @@ error:
1431 1436
1432void ip6_flush_pending_frames(struct sock *sk) 1437void ip6_flush_pending_frames(struct sock *sk)
1433{ 1438{
1434 struct inet_sock *inet = inet_sk(sk);
1435 struct ipv6_pinfo *np = inet6_sk(sk);
1436 struct sk_buff *skb; 1439 struct sk_buff *skb;
1437 1440
1438 while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL) { 1441 while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL) {
@@ -1442,14 +1445,5 @@ void ip6_flush_pending_frames(struct sock *sk)
1442 kfree_skb(skb); 1445 kfree_skb(skb);
1443 } 1446 }
1444 1447
1445 inet->cork.flags &= ~IPCORK_OPT; 1448 ip6_cork_release(inet_sk(sk), inet6_sk(sk));
1446
1447 kfree(np->cork.opt);
1448 np->cork.opt = NULL;
1449 if (np->cork.rt) {
1450 dst_release(&np->cork.rt->u.dst);
1451 np->cork.rt = NULL;
1452 inet->cork.flags &= ~IPCORK_ALLFRAG;
1453 }
1454 memset(&inet->cork.fl, 0, sizeof(inet->cork.fl));
1455} 1449}
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 85eb4798d8d2..0cd4056f9127 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -36,6 +36,7 @@
36#include <net/ipcomp.h> 36#include <net/ipcomp.h>
37#include <asm/semaphore.h> 37#include <asm/semaphore.h>
38#include <linux/crypto.h> 38#include <linux/crypto.h>
39#include <linux/err.h>
39#include <linux/pfkeyv2.h> 40#include <linux/pfkeyv2.h>
40#include <linux/random.h> 41#include <linux/random.h>
41#include <linux/percpu.h> 42#include <linux/percpu.h>
@@ -358,7 +359,7 @@ static struct crypto_comp **ipcomp6_alloc_tfms(const char *alg_name)
358 for_each_possible_cpu(cpu) { 359 for_each_possible_cpu(cpu) {
359 struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, 360 struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
360 CRYPTO_ALG_ASYNC); 361 CRYPTO_ALG_ASYNC);
361 if (!tfm) 362 if (IS_ERR(tfm))
362 goto error; 363 goto error;
363 *per_cpu_ptr(tfms, cpu) = tfm; 364 *per_cpu_ptr(tfms, cpu) = tfm;
364 } 365 }
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 36f7dbfb6dbb..67997a74ddce 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1037,6 +1037,7 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
1037 1037
1038 ndmsg = nlmsg_data(nlh); 1038 ndmsg = nlmsg_data(nlh);
1039 ndmsg->nduseropt_family = AF_INET6; 1039 ndmsg->nduseropt_family = AF_INET6;
1040 ndmsg->nduseropt_ifindex = ra->dev->ifindex;
1040 ndmsg->nduseropt_icmp_type = icmp6h->icmp6_type; 1041 ndmsg->nduseropt_icmp_type = icmp6h->icmp6_type;
1041 ndmsg->nduseropt_icmp_code = icmp6h->icmp6_code; 1042 ndmsg->nduseropt_icmp_code = icmp6h->icmp6_code;
1042 ndmsg->nduseropt_opts_len = opt->nd_opt_len << 3; 1043 ndmsg->nduseropt_opts_len = opt->nd_opt_len << 3;
diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile
index 4513eab77397..e789ec44d23b 100644
--- a/net/ipv6/netfilter/Makefile
+++ b/net/ipv6/netfilter/Makefile
@@ -4,25 +4,29 @@
4 4
5# Link order matters here. 5# Link order matters here.
6obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o 6obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
7obj-$(CONFIG_IP6_NF_MATCH_RT) += ip6t_rt.o
8obj-$(CONFIG_IP6_NF_MATCH_OPTS) += ip6t_hbh.o
9obj-$(CONFIG_IP6_NF_MATCH_IPV6HEADER) += ip6t_ipv6header.o
10obj-$(CONFIG_IP6_NF_MATCH_FRAG) += ip6t_frag.o
11obj-$(CONFIG_IP6_NF_MATCH_AH) += ip6t_ah.o
12obj-$(CONFIG_IP6_NF_MATCH_EUI64) += ip6t_eui64.o
13obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o
14obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o 7obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
15obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o 8obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
16obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o
17obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o 9obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
18obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
19obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o 10obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
20obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o
21obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o
22obj-$(CONFIG_IP6_NF_MATCH_MH) += ip6t_mh.o
23 11
24# objects for l3 independent conntrack 12# objects for l3 independent conntrack
25nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o 13nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o
26 14
27# l3 independent conntrack 15# l3 independent conntrack
28obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o 16obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o
17
18# matches
19obj-$(CONFIG_IP6_NF_MATCH_AH) += ip6t_ah.o
20obj-$(CONFIG_IP6_NF_MATCH_EUI64) += ip6t_eui64.o
21obj-$(CONFIG_IP6_NF_MATCH_FRAG) += ip6t_frag.o
22obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o
23obj-$(CONFIG_IP6_NF_MATCH_IPV6HEADER) += ip6t_ipv6header.o
24obj-$(CONFIG_IP6_NF_MATCH_MH) += ip6t_mh.o
25obj-$(CONFIG_IP6_NF_MATCH_OPTS) += ip6t_hbh.o
26obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o
27obj-$(CONFIG_IP6_NF_MATCH_RT) += ip6t_rt.o
28
29# targets
30obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o
31obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
32obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index 6413a30d9f68..e273605eef85 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -23,6 +23,7 @@
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/sysctl.h> 24#include <linux/sysctl.h>
25#include <linux/proc_fs.h> 25#include <linux/proc_fs.h>
26#include <linux/seq_file.h>
26#include <linux/mutex.h> 27#include <linux/mutex.h>
27#include <net/net_namespace.h> 28#include <net/net_namespace.h>
28#include <net/sock.h> 29#include <net/sock.h>
@@ -596,15 +597,11 @@ static ctl_table ipq_root_table[] = {
596 { .ctl_name = 0 } 597 { .ctl_name = 0 }
597}; 598};
598 599
599#ifdef CONFIG_PROC_FS 600static int ip6_queue_show(struct seq_file *m, void *v)
600static int
601ipq_get_info(char *buffer, char **start, off_t offset, int length)
602{ 601{
603 int len;
604
605 read_lock_bh(&queue_lock); 602 read_lock_bh(&queue_lock);
606 603
607 len = sprintf(buffer, 604 seq_printf(m,
608 "Peer PID : %d\n" 605 "Peer PID : %d\n"
609 "Copy mode : %hu\n" 606 "Copy mode : %hu\n"
610 "Copy range : %u\n" 607 "Copy range : %u\n"
@@ -621,16 +618,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
621 queue_user_dropped); 618 queue_user_dropped);
622 619
623 read_unlock_bh(&queue_lock); 620 read_unlock_bh(&queue_lock);
621 return 0;
622}
624 623
625 *start = buffer + offset; 624static int ip6_queue_open(struct inode *inode, struct file *file)
626 len -= offset; 625{
627 if (len > length) 626 return single_open(file, ip6_queue_show, NULL);
628 len = length;
629 else if (len < 0)
630 len = 0;
631 return len;
632} 627}
633#endif /* CONFIG_PROC_FS */ 628
629static const struct file_operations ip6_queue_proc_fops = {
630 .open = ip6_queue_open,
631 .read = seq_read,
632 .llseek = seq_lseek,
633 .release = single_release,
634 .owner = THIS_MODULE,
635};
634 636
635static struct nf_queue_handler nfqh = { 637static struct nf_queue_handler nfqh = {
636 .name = "ip6_queue", 638 .name = "ip6_queue",
@@ -650,10 +652,11 @@ static int __init ip6_queue_init(void)
650 goto cleanup_netlink_notifier; 652 goto cleanup_netlink_notifier;
651 } 653 }
652 654
653 proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info); 655 proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
654 if (proc) 656 if (proc) {
655 proc->owner = THIS_MODULE; 657 proc->owner = THIS_MODULE;
656 else { 658 proc->proc_fops = &ip6_queue_proc_fops;
659 } else {
657 printk(KERN_ERR "ip6_queue: failed to create proc entry\n"); 660 printk(KERN_ERR "ip6_queue: failed to create proc entry\n");
658 goto cleanup_ipqnl; 661 goto cleanup_ipqnl;
659 } 662 }
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index be526ad92543..8631ed7fe8a9 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -32,27 +32,16 @@
32 32
33static struct proc_dir_entry *proc_net_devsnmp6; 33static struct proc_dir_entry *proc_net_devsnmp6;
34 34
35static int fold_prot_inuse(struct proto *proto)
36{
37 int res = 0;
38 int cpu;
39
40 for_each_possible_cpu(cpu)
41 res += proto->stats[cpu].inuse;
42
43 return res;
44}
45
46static int sockstat6_seq_show(struct seq_file *seq, void *v) 35static int sockstat6_seq_show(struct seq_file *seq, void *v)
47{ 36{
48 seq_printf(seq, "TCP6: inuse %d\n", 37 seq_printf(seq, "TCP6: inuse %d\n",
49 fold_prot_inuse(&tcpv6_prot)); 38 sock_prot_inuse(&tcpv6_prot));
50 seq_printf(seq, "UDP6: inuse %d\n", 39 seq_printf(seq, "UDP6: inuse %d\n",
51 fold_prot_inuse(&udpv6_prot)); 40 sock_prot_inuse(&udpv6_prot));
52 seq_printf(seq, "UDPLITE6: inuse %d\n", 41 seq_printf(seq, "UDPLITE6: inuse %d\n",
53 fold_prot_inuse(&udplitev6_prot)); 42 sock_prot_inuse(&udplitev6_prot));
54 seq_printf(seq, "RAW6: inuse %d\n", 43 seq_printf(seq, "RAW6: inuse %d\n",
55 fold_prot_inuse(&rawv6_prot)); 44 sock_prot_inuse(&rawv6_prot));
56 seq_printf(seq, "FRAG6: inuse %d memory %d\n", 45 seq_printf(seq, "FRAG6: inuse %d memory %d\n",
57 ip6_frag_nqueues(), ip6_frag_mem()); 46 ip6_frag_nqueues(), ip6_frag_mem());
58 return 0; 47 return 0;
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index ca24ef19cd8f..807260d03586 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1144,6 +1144,8 @@ static int rawv6_init_sk(struct sock *sk)
1144 return(0); 1144 return(0);
1145} 1145}
1146 1146
1147DEFINE_PROTO_INUSE(rawv6)
1148
1147struct proto rawv6_prot = { 1149struct proto rawv6_prot = {
1148 .name = "RAWv6", 1150 .name = "RAWv6",
1149 .owner = THIS_MODULE, 1151 .owner = THIS_MODULE,
@@ -1166,6 +1168,7 @@ struct proto rawv6_prot = {
1166 .compat_setsockopt = compat_rawv6_setsockopt, 1168 .compat_setsockopt = compat_rawv6_setsockopt,
1167 .compat_getsockopt = compat_rawv6_getsockopt, 1169 .compat_getsockopt = compat_rawv6_getsockopt,
1168#endif 1170#endif
1171 REF_PROTO_INUSE(rawv6)
1169}; 1172};
1170 1173
1171#ifdef CONFIG_PROC_FS 1174#ifdef CONFIG_PROC_FS
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 95f8e4a62f68..6ecb5e6fae2e 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -38,12 +38,8 @@
38#include <linux/in6.h> 38#include <linux/in6.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/if_arp.h> 40#include <linux/if_arp.h>
41
42#ifdef CONFIG_PROC_FS
43#include <linux/proc_fs.h> 41#include <linux/proc_fs.h>
44#include <linux/seq_file.h> 42#include <linux/seq_file.h>
45#endif
46
47#include <net/net_namespace.h> 43#include <net/net_namespace.h>
48#include <net/snmp.h> 44#include <net/snmp.h>
49#include <net/ipv6.h> 45#include <net/ipv6.h>
@@ -548,12 +544,8 @@ restart:
548 rt = rt6_device_match(rt, fl->oif, flags); 544 rt = rt6_device_match(rt, fl->oif, flags);
549 BACKTRACK(&fl->fl6_src); 545 BACKTRACK(&fl->fl6_src);
550out: 546out:
551 dst_hold(&rt->u.dst); 547 dst_use(&rt->u.dst, jiffies);
552 read_unlock_bh(&table->tb6_lock); 548 read_unlock_bh(&table->tb6_lock);
553
554 rt->u.dst.lastuse = jiffies;
555 rt->u.dst.__use++;
556
557 return rt; 549 return rt;
558 550
559} 551}
@@ -2288,71 +2280,50 @@ struct rt6_proc_arg
2288 2280
2289static int rt6_info_route(struct rt6_info *rt, void *p_arg) 2281static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2290{ 2282{
2291 struct rt6_proc_arg *arg = (struct rt6_proc_arg *) p_arg; 2283 struct seq_file *m = p_arg;
2292
2293 if (arg->skip < arg->offset / RT6_INFO_LEN) {
2294 arg->skip++;
2295 return 0;
2296 }
2297
2298 if (arg->len >= arg->length)
2299 return 0;
2300 2284
2301 arg->len += sprintf(arg->buffer + arg->len, 2285 seq_printf(m, NIP6_SEQFMT " %02x ", NIP6(rt->rt6i_dst.addr),
2302 NIP6_SEQFMT " %02x ", 2286 rt->rt6i_dst.plen);
2303 NIP6(rt->rt6i_dst.addr),
2304 rt->rt6i_dst.plen);
2305 2287
2306#ifdef CONFIG_IPV6_SUBTREES 2288#ifdef CONFIG_IPV6_SUBTREES
2307 arg->len += sprintf(arg->buffer + arg->len, 2289 seq_printf(m, NIP6_SEQFMT " %02x ", NIP6(rt->rt6i_src.addr),
2308 NIP6_SEQFMT " %02x ", 2290 rt->rt6i_src.plen);
2309 NIP6(rt->rt6i_src.addr),
2310 rt->rt6i_src.plen);
2311#else 2291#else
2312 arg->len += sprintf(arg->buffer + arg->len, 2292 seq_puts(m, "00000000000000000000000000000000 00 ");
2313 "00000000000000000000000000000000 00 ");
2314#endif 2293#endif
2315 2294
2316 if (rt->rt6i_nexthop) { 2295 if (rt->rt6i_nexthop) {
2317 arg->len += sprintf(arg->buffer + arg->len, 2296 seq_printf(m, NIP6_SEQFMT,
2318 NIP6_SEQFMT, 2297 NIP6(*((struct in6_addr *)rt->rt6i_nexthop->primary_key)));
2319 NIP6(*((struct in6_addr *)rt->rt6i_nexthop->primary_key)));
2320 } else { 2298 } else {
2321 arg->len += sprintf(arg->buffer + arg->len, 2299 seq_puts(m, "00000000000000000000000000000000");
2322 "00000000000000000000000000000000");
2323 } 2300 }
2324 arg->len += sprintf(arg->buffer + arg->len, 2301 seq_printf(m, " %08x %08x %08x %08x %8s\n",
2325 " %08x %08x %08x %08x %8s\n", 2302 rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
2326 rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt), 2303 rt->u.dst.__use, rt->rt6i_flags,
2327 rt->u.dst.__use, rt->rt6i_flags, 2304 rt->rt6i_dev ? rt->rt6i_dev->name : "");
2328 rt->rt6i_dev ? rt->rt6i_dev->name : "");
2329 return 0; 2305 return 0;
2330} 2306}
2331 2307
2332static int rt6_proc_info(char *buffer, char **start, off_t offset, int length) 2308static int ipv6_route_show(struct seq_file *m, void *v)
2333{ 2309{
2334 struct rt6_proc_arg arg = { 2310 fib6_clean_all(rt6_info_route, 0, m);
2335 .buffer = buffer, 2311 return 0;
2336 .offset = offset, 2312}
2337 .length = length,
2338 };
2339
2340 fib6_clean_all(rt6_info_route, 0, &arg);
2341
2342 *start = buffer;
2343 if (offset)
2344 *start += offset % RT6_INFO_LEN;
2345
2346 arg.len -= offset % RT6_INFO_LEN;
2347
2348 if (arg.len > length)
2349 arg.len = length;
2350 if (arg.len < 0)
2351 arg.len = 0;
2352 2313
2353 return arg.len; 2314static int ipv6_route_open(struct inode *inode, struct file *file)
2315{
2316 return single_open(file, ipv6_route_show, NULL);
2354} 2317}
2355 2318
2319static const struct file_operations ipv6_route_proc_fops = {
2320 .owner = THIS_MODULE,
2321 .open = ipv6_route_open,
2322 .read = seq_read,
2323 .llseek = seq_lseek,
2324 .release = single_release,
2325};
2326
2356static int rt6_stats_seq_show(struct seq_file *seq, void *v) 2327static int rt6_stats_seq_show(struct seq_file *seq, void *v)
2357{ 2328{
2358 seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n", 2329 seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n",
@@ -2489,22 +2460,14 @@ ctl_table ipv6_route_table[] = {
2489 2460
2490void __init ip6_route_init(void) 2461void __init ip6_route_init(void)
2491{ 2462{
2492#ifdef CONFIG_PROC_FS
2493 struct proc_dir_entry *p;
2494#endif
2495 ip6_dst_ops.kmem_cachep = 2463 ip6_dst_ops.kmem_cachep =
2496 kmem_cache_create("ip6_dst_cache", sizeof(struct rt6_info), 0, 2464 kmem_cache_create("ip6_dst_cache", sizeof(struct rt6_info), 0,
2497 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 2465 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
2498 ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep; 2466 ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep;
2499 2467
2500 fib6_init(); 2468 fib6_init();
2501#ifdef CONFIG_PROC_FS 2469 proc_net_fops_create(&init_net, "ipv6_route", 0, &ipv6_route_proc_fops);
2502 p = proc_net_create(&init_net, "ipv6_route", 0, rt6_proc_info);
2503 if (p)
2504 p->owner = THIS_MODULE;
2505
2506 proc_net_fops_create(&init_net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops); 2470 proc_net_fops_create(&init_net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops);
2507#endif
2508#ifdef CONFIG_XFRM 2471#ifdef CONFIG_XFRM
2509 xfrm6_init(); 2472 xfrm6_init();
2510#endif 2473#endif
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 06be2a1f2730..3aad861975a0 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2107,6 +2107,8 @@ void tcp6_proc_exit(void)
2107} 2107}
2108#endif 2108#endif
2109 2109
2110DEFINE_PROTO_INUSE(tcpv6)
2111
2110struct proto tcpv6_prot = { 2112struct proto tcpv6_prot = {
2111 .name = "TCPv6", 2113 .name = "TCPv6",
2112 .owner = THIS_MODULE, 2114 .owner = THIS_MODULE,
@@ -2141,6 +2143,7 @@ struct proto tcpv6_prot = {
2141 .compat_setsockopt = compat_tcp_setsockopt, 2143 .compat_setsockopt = compat_tcp_setsockopt,
2142 .compat_getsockopt = compat_tcp_getsockopt, 2144 .compat_getsockopt = compat_tcp_getsockopt,
2143#endif 2145#endif
2146 REF_PROTO_INUSE(tcpv6)
2144}; 2147};
2145 2148
2146static struct inet6_protocol tcpv6_protocol = { 2149static struct inet6_protocol tcpv6_protocol = {
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index caebad6ee510..ee1cc3f8599f 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -205,12 +205,11 @@ out:
205 return err; 205 return err;
206 206
207csum_copy_err: 207csum_copy_err:
208 UDP6_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite);
208 skb_kill_datagram(sk, skb, flags); 209 skb_kill_datagram(sk, skb, flags);
209 210
210 if (flags & MSG_DONTWAIT) { 211 if (flags & MSG_DONTWAIT)
211 UDP6_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite);
212 return -EAGAIN; 212 return -EAGAIN;
213 }
214 goto try_again; 213 goto try_again;
215} 214}
216 215
@@ -971,6 +970,8 @@ void udp6_proc_exit(void) {
971 970
972/* ------------------------------------------------------------------------ */ 971/* ------------------------------------------------------------------------ */
973 972
973DEFINE_PROTO_INUSE(udpv6)
974
974struct proto udpv6_prot = { 975struct proto udpv6_prot = {
975 .name = "UDPv6", 976 .name = "UDPv6",
976 .owner = THIS_MODULE, 977 .owner = THIS_MODULE,
@@ -992,6 +993,7 @@ struct proto udpv6_prot = {
992 .compat_setsockopt = compat_udpv6_setsockopt, 993 .compat_setsockopt = compat_udpv6_setsockopt,
993 .compat_getsockopt = compat_udpv6_getsockopt, 994 .compat_getsockopt = compat_udpv6_getsockopt,
994#endif 995#endif
996 REF_PROTO_INUSE(udpv6)
995}; 997};
996 998
997static struct inet_protosw udpv6_protosw = { 999static struct inet_protosw udpv6_protosw = {
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 766566f7de47..5a0379f71415 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -40,6 +40,8 @@ static int udplite_v6_get_port(struct sock *sk, unsigned short snum)
40 return udplite_get_port(sk, snum, ipv6_rcv_saddr_equal); 40 return udplite_get_port(sk, snum, ipv6_rcv_saddr_equal);
41} 41}
42 42
43DEFINE_PROTO_INUSE(udplitev6)
44
43struct proto udplitev6_prot = { 45struct proto udplitev6_prot = {
44 .name = "UDPLITEv6", 46 .name = "UDPLITEv6",
45 .owner = THIS_MODULE, 47 .owner = THIS_MODULE,
@@ -62,6 +64,7 @@ struct proto udplitev6_prot = {
62 .compat_setsockopt = compat_udpv6_setsockopt, 64 .compat_setsockopt = compat_udpv6_setsockopt,
63 .compat_getsockopt = compat_udpv6_getsockopt, 65 .compat_getsockopt = compat_udpv6_getsockopt,
64#endif 66#endif
67 REF_PROTO_INUSE(udplitev6)
65}; 68};
66 69
67static struct inet_protosw udplite6_protosw = { 70static struct inet_protosw udplite6_protosw = {
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index a195a66e0cc7..c76a9523091b 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -92,11 +92,6 @@ extern int ipxrtr_route_skb(struct sk_buff *skb);
92extern struct ipx_route *ipxrtr_lookup(__be32 net); 92extern struct ipx_route *ipxrtr_lookup(__be32 net);
93extern int ipxrtr_ioctl(unsigned int cmd, void __user *arg); 93extern int ipxrtr_ioctl(unsigned int cmd, void __user *arg);
94 94
95#undef IPX_REFCNT_DEBUG
96#ifdef IPX_REFCNT_DEBUG
97atomic_t ipx_sock_nr;
98#endif
99
100struct ipx_interface *ipx_interfaces_head(void) 95struct ipx_interface *ipx_interfaces_head(void)
101{ 96{
102 struct ipx_interface *rc = NULL; 97 struct ipx_interface *rc = NULL;
@@ -151,14 +146,7 @@ static void ipx_destroy_socket(struct sock *sk)
151{ 146{
152 ipx_remove_socket(sk); 147 ipx_remove_socket(sk);
153 skb_queue_purge(&sk->sk_receive_queue); 148 skb_queue_purge(&sk->sk_receive_queue);
154#ifdef IPX_REFCNT_DEBUG 149 sk_refcnt_debug_dec(sk);
155 atomic_dec(&ipx_sock_nr);
156 printk(KERN_DEBUG "IPX socket %p released, %d are still alive\n", sk,
157 atomic_read(&ipx_sock_nr));
158 if (atomic_read(&sk->sk_refcnt) != 1)
159 printk(KERN_DEBUG "Destruction sock ipx %p delayed, cnt=%d\n",
160 sk, atomic_read(&sk->sk_refcnt));
161#endif
162 sock_put(sk); 150 sock_put(sk);
163} 151}
164 152
@@ -1384,11 +1372,8 @@ static int ipx_create(struct net *net, struct socket *sock, int protocol)
1384 sk = sk_alloc(net, PF_IPX, GFP_KERNEL, &ipx_proto); 1372 sk = sk_alloc(net, PF_IPX, GFP_KERNEL, &ipx_proto);
1385 if (!sk) 1373 if (!sk)
1386 goto out; 1374 goto out;
1387#ifdef IPX_REFCNT_DEBUG 1375
1388 atomic_inc(&ipx_sock_nr); 1376 sk_refcnt_debug_inc(sk);
1389 printk(KERN_DEBUG "IPX socket %p created, now we have %d alive\n", sk,
1390 atomic_read(&ipx_sock_nr));
1391#endif
1392 sock_init_data(sock, sk); 1377 sock_init_data(sock, sk);
1393 sk->sk_no_check = 1; /* Checksum off by default */ 1378 sk->sk_no_check = 1; /* Checksum off by default */
1394 sock->ops = &ipx_dgram_ops; 1379 sock->ops = &ipx_dgram_ops;
@@ -1409,6 +1394,7 @@ static int ipx_release(struct socket *sock)
1409 1394
1410 sock_set_flag(sk, SOCK_DEAD); 1395 sock_set_flag(sk, SOCK_DEAD);
1411 sock->sk = NULL; 1396 sock->sk = NULL;
1397 sk_refcnt_debug_release(sk);
1412 ipx_destroy_socket(sk); 1398 ipx_destroy_socket(sk);
1413out: 1399out:
1414 return 0; 1400 return 0;
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index 6fffb3845ab6..ce176e691afe 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -13,6 +13,18 @@ config MAC80211
13 This option enables the hardware independent IEEE 802.11 13 This option enables the hardware independent IEEE 802.11
14 networking stack. 14 networking stack.
15 15
16config MAC80211_RCSIMPLE
17 bool "'simple' rate control algorithm" if EMBEDDED
18 default y
19 depends on MAC80211
20 help
21 This option allows you to turn off the 'simple' rate
22 control algorithm in mac80211. If you do turn it off,
23 you absolutely need another rate control algorithm.
24
25 Say Y unless you know you will have another algorithm
26 available.
27
16config MAC80211_LEDS 28config MAC80211_LEDS
17 bool "Enable LED triggers" 29 bool "Enable LED triggers"
18 depends on MAC80211 && LEDS_TRIGGERS 30 depends on MAC80211 && LEDS_TRIGGERS
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile
index 219cd9f9341f..1e6237b34846 100644
--- a/net/mac80211/Makefile
+++ b/net/mac80211/Makefile
@@ -1,8 +1,9 @@
1obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o 1obj-$(CONFIG_MAC80211) += mac80211.o
2 2
3mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o 3mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o
4mac80211-objs-$(CONFIG_MAC80211_DEBUGFS) += debugfs.o debugfs_sta.o debugfs_netdev.o debugfs_key.o 4mac80211-objs-$(CONFIG_MAC80211_DEBUGFS) += debugfs.o debugfs_sta.o debugfs_netdev.o debugfs_key.o
5mac80211-objs-$(CONFIG_NET_SCHED) += wme.o 5mac80211-objs-$(CONFIG_NET_SCHED) += wme.o
6mac80211-objs-$(CONFIG_MAC80211_RCSIMPLE) += rc80211_simple.o
6 7
7mac80211-objs := \ 8mac80211-objs := \
8 ieee80211.o \ 9 ieee80211.o \
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c
index f484ca7ade9c..e0ee65a969bc 100644
--- a/net/mac80211/ieee80211.c
+++ b/net/mac80211/ieee80211.c
@@ -1072,7 +1072,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
1072 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); 1072 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
1073 ieee80211_if_set_type(local->mdev, IEEE80211_IF_TYPE_AP); 1073 ieee80211_if_set_type(local->mdev, IEEE80211_IF_TYPE_AP);
1074 1074
1075 result = ieee80211_init_rate_ctrl_alg(local, NULL); 1075 result = ieee80211_init_rate_ctrl_alg(local,
1076 hw->rate_control_algorithm);
1076 if (result < 0) { 1077 if (result < 0) {
1077 printk(KERN_DEBUG "%s: Failed to initialize rate control " 1078 printk(KERN_DEBUG "%s: Failed to initialize rate control "
1078 "algorithm\n", wiphy_name(local->hw.wiphy)); 1079 "algorithm\n", wiphy_name(local->hw.wiphy));
@@ -1233,8 +1234,17 @@ static int __init ieee80211_init(void)
1233 1234
1234 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb)); 1235 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
1235 1236
1237#ifdef CONFIG_MAC80211_RCSIMPLE
1238 ret = ieee80211_rate_control_register(&mac80211_rcsimple);
1239 if (ret)
1240 return ret;
1241#endif
1242
1236 ret = ieee80211_wme_register(); 1243 ret = ieee80211_wme_register();
1237 if (ret) { 1244 if (ret) {
1245#ifdef CONFIG_MAC80211_RCSIMPLE
1246 ieee80211_rate_control_unregister(&mac80211_rcsimple);
1247#endif
1238 printk(KERN_DEBUG "ieee80211_init: failed to " 1248 printk(KERN_DEBUG "ieee80211_init: failed to "
1239 "initialize WME (err=%d)\n", ret); 1249 "initialize WME (err=%d)\n", ret);
1240 return ret; 1250 return ret;
@@ -1248,6 +1258,10 @@ static int __init ieee80211_init(void)
1248 1258
1249static void __exit ieee80211_exit(void) 1259static void __exit ieee80211_exit(void)
1250{ 1260{
1261#ifdef CONFIG_MAC80211_RCSIMPLE
1262 ieee80211_rate_control_unregister(&mac80211_rcsimple);
1263#endif
1264
1251 ieee80211_wme_unregister(); 1265 ieee80211_wme_unregister();
1252 ieee80211_debugfs_netdev_exit(); 1266 ieee80211_debugfs_netdev_exit();
1253} 1267}
diff --git a/net/mac80211/ieee80211_common.h b/net/mac80211/ieee80211_common.h
deleted file mode 100644
index c15295d43d87..000000000000
--- a/net/mac80211/ieee80211_common.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * IEEE 802.11 driver (80211.o) -- hostapd interface
3 * Copyright 2002-2004, Instant802 Networks, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#ifndef IEEE80211_COMMON_H
11#define IEEE80211_COMMON_H
12
13#include <linux/types.h>
14
15/*
16 * This is common header information with user space. It is used on all
17 * frames sent to wlan#ap interface.
18 */
19
20#define IEEE80211_FI_VERSION 0x80211001
21
22struct ieee80211_frame_info {
23 __be32 version;
24 __be32 length;
25 __be64 mactime;
26 __be64 hosttime;
27 __be32 phytype;
28 __be32 channel;
29 __be32 datarate;
30 __be32 antenna;
31 __be32 priority;
32 __be32 ssi_type;
33 __be32 ssi_signal;
34 __be32 ssi_noise;
35 __be32 preamble;
36 __be32 encoding;
37
38 /* Note: this structure is otherwise identical to capture format used
39 * in linux-wlan-ng, but this additional field is used to provide meta
40 * data about the frame to hostapd. This was the easiest method for
41 * providing this information, but this might change in the future. */
42 __be32 msg_type;
43} __attribute__ ((packed));
44
45
46enum ieee80211_msg_type {
47 ieee80211_msg_normal = 0,
48 ieee80211_msg_tx_callback_ack = 1,
49 ieee80211_msg_tx_callback_fail = 2,
50 /* hole at 3, was ieee80211_msg_passive_scan but unused */
51 /* hole at 4, was ieee80211_msg_wep_frame_unknown_key but now unused */
52 ieee80211_msg_michael_mic_failure = 5,
53 /* hole at 6, was monitor but never sent to userspace */
54 ieee80211_msg_sta_not_assoc = 7,
55 /* 8 was ieee80211_msg_set_aid_for_sta */
56 /* 9 was ieee80211_msg_key_threshold_notification */
57 /* 11 was ieee80211_msg_radar */
58};
59
60struct ieee80211_msg_key_notification {
61 int tx_rx_count;
62 char ifname[IFNAMSIZ];
63 u8 addr[ETH_ALEN]; /* ff:ff:ff:ff:ff:ff for broadcast keys */
64};
65
66
67enum ieee80211_phytype {
68 ieee80211_phytype_fhss_dot11_97 = 1,
69 ieee80211_phytype_dsss_dot11_97 = 2,
70 ieee80211_phytype_irbaseband = 3,
71 ieee80211_phytype_dsss_dot11_b = 4,
72 ieee80211_phytype_pbcc_dot11_b = 5,
73 ieee80211_phytype_ofdm_dot11_g = 6,
74 ieee80211_phytype_pbcc_dot11_g = 7,
75 ieee80211_phytype_ofdm_dot11_a = 8,
76};
77
78enum ieee80211_ssi_type {
79 ieee80211_ssi_none = 0,
80 ieee80211_ssi_norm = 1, /* normalized, 0-1000 */
81 ieee80211_ssi_dbm = 2,
82 ieee80211_ssi_raw = 3, /* raw SSI */
83};
84
85struct ieee80211_radar_info {
86 int channel;
87 int radar;
88 int radar_type;
89};
90
91#endif /* IEEE80211_COMMON_H */
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index d575ccd67e91..72e1c93dd87e 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -230,6 +230,7 @@ struct ieee80211_if_vlan {
230#define IEEE80211_STA_AUTO_SSID_SEL BIT(10) 230#define IEEE80211_STA_AUTO_SSID_SEL BIT(10)
231#define IEEE80211_STA_AUTO_BSSID_SEL BIT(11) 231#define IEEE80211_STA_AUTO_BSSID_SEL BIT(11)
232#define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12) 232#define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
233#define IEEE80211_STA_PRIVACY_INVOKED BIT(13)
233struct ieee80211_if_sta { 234struct ieee80211_if_sta {
234 enum { 235 enum {
235 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE, 236 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
@@ -261,7 +262,6 @@ struct ieee80211_if_sta {
261 unsigned long request; 262 unsigned long request;
262 struct sk_buff_head skb_queue; 263 struct sk_buff_head skb_queue;
263 264
264 int key_management_enabled;
265 unsigned long last_probe; 265 unsigned long last_probe;
266 266
267#define IEEE80211_AUTH_ALG_OPEN BIT(0) 267#define IEEE80211_AUTH_ALG_OPEN BIT(0)
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c
index 6caa3ec2cff7..7027eed4d4ae 100644
--- a/net/mac80211/ieee80211_ioctl.c
+++ b/net/mac80211/ieee80211_ioctl.c
@@ -917,7 +917,6 @@ static int ieee80211_ioctl_siwauth(struct net_device *dev,
917 struct iw_request_info *info, 917 struct iw_request_info *info,
918 struct iw_param *data, char *extra) 918 struct iw_param *data, char *extra)
919{ 919{
920 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
921 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 920 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
922 int ret = 0; 921 int ret = 0;
923 922
@@ -927,18 +926,21 @@ static int ieee80211_ioctl_siwauth(struct net_device *dev,
927 case IW_AUTH_CIPHER_GROUP: 926 case IW_AUTH_CIPHER_GROUP:
928 case IW_AUTH_WPA_ENABLED: 927 case IW_AUTH_WPA_ENABLED:
929 case IW_AUTH_RX_UNENCRYPTED_EAPOL: 928 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
930 break;
931 case IW_AUTH_KEY_MGMT: 929 case IW_AUTH_KEY_MGMT:
930 break;
931 case IW_AUTH_PRIVACY_INVOKED:
932 if (sdata->type != IEEE80211_IF_TYPE_STA) 932 if (sdata->type != IEEE80211_IF_TYPE_STA)
933 ret = -EINVAL; 933 ret = -EINVAL;
934 else { 934 else {
935 sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
935 /* 936 /*
936 * Key management was set by wpa_supplicant, 937 * Privacy invoked by wpa_supplicant, store the
937 * we only need this to associate to a network 938 * value and allow associating to a protected
938 * that has privacy enabled regardless of not 939 * network without having a key up front.
939 * having a key.
940 */ 940 */
941 sdata->u.sta.key_management_enabled = !!data->value; 941 if (data->value)
942 sdata->u.sta.flags |=
943 IEEE80211_STA_PRIVACY_INVOKED;
942 } 944 }
943 break; 945 break;
944 case IW_AUTH_80211_AUTH_ALG: 946 case IW_AUTH_80211_AUTH_ALG:
@@ -948,11 +950,6 @@ static int ieee80211_ioctl_siwauth(struct net_device *dev,
948 else 950 else
949 ret = -EOPNOTSUPP; 951 ret = -EOPNOTSUPP;
950 break; 952 break;
951 case IW_AUTH_PRIVACY_INVOKED:
952 if (local->ops->set_privacy_invoked)
953 ret = local->ops->set_privacy_invoked(
954 local_to_hw(local), data->value);
955 break;
956 default: 953 default:
957 ret = -EOPNOTSUPP; 954 ret = -EOPNOTSUPP;
958 break; 955 break;
diff --git a/net/mac80211/ieee80211_rate.c b/net/mac80211/ieee80211_rate.c
index 93abb8fff141..7254bd609839 100644
--- a/net/mac80211/ieee80211_rate.c
+++ b/net/mac80211/ieee80211_rate.c
@@ -25,13 +25,25 @@ int ieee80211_rate_control_register(struct rate_control_ops *ops)
25{ 25{
26 struct rate_control_alg *alg; 26 struct rate_control_alg *alg;
27 27
28 if (!ops->name)
29 return -EINVAL;
30
31 mutex_lock(&rate_ctrl_mutex);
32 list_for_each_entry(alg, &rate_ctrl_algs, list) {
33 if (!strcmp(alg->ops->name, ops->name)) {
34 /* don't register an algorithm twice */
35 WARN_ON(1);
36 return -EALREADY;
37 }
38 }
39
28 alg = kzalloc(sizeof(*alg), GFP_KERNEL); 40 alg = kzalloc(sizeof(*alg), GFP_KERNEL);
29 if (alg == NULL) { 41 if (alg == NULL) {
42 mutex_unlock(&rate_ctrl_mutex);
30 return -ENOMEM; 43 return -ENOMEM;
31 } 44 }
32 alg->ops = ops; 45 alg->ops = ops;
33 46
34 mutex_lock(&rate_ctrl_mutex);
35 list_add_tail(&alg->list, &rate_ctrl_algs); 47 list_add_tail(&alg->list, &rate_ctrl_algs);
36 mutex_unlock(&rate_ctrl_mutex); 48 mutex_unlock(&rate_ctrl_mutex);
37 49
@@ -61,9 +73,12 @@ ieee80211_try_rate_control_ops_get(const char *name)
61 struct rate_control_alg *alg; 73 struct rate_control_alg *alg;
62 struct rate_control_ops *ops = NULL; 74 struct rate_control_ops *ops = NULL;
63 75
76 if (!name)
77 return NULL;
78
64 mutex_lock(&rate_ctrl_mutex); 79 mutex_lock(&rate_ctrl_mutex);
65 list_for_each_entry(alg, &rate_ctrl_algs, list) { 80 list_for_each_entry(alg, &rate_ctrl_algs, list) {
66 if (!name || !strcmp(alg->ops->name, name)) 81 if (!strcmp(alg->ops->name, name))
67 if (try_module_get(alg->ops->module)) { 82 if (try_module_get(alg->ops->module)) {
68 ops = alg->ops; 83 ops = alg->ops;
69 break; 84 break;
@@ -80,9 +95,12 @@ ieee80211_rate_control_ops_get(const char *name)
80{ 95{
81 struct rate_control_ops *ops; 96 struct rate_control_ops *ops;
82 97
98 if (!name)
99 name = "simple";
100
83 ops = ieee80211_try_rate_control_ops_get(name); 101 ops = ieee80211_try_rate_control_ops_get(name);
84 if (!ops) { 102 if (!ops) {
85 request_module("rc80211_%s", name ? name : "default"); 103 request_module("rc80211_%s", name);
86 ops = ieee80211_try_rate_control_ops_get(name); 104 ops = ieee80211_try_rate_control_ops_get(name);
87 } 105 }
88 return ops; 106 return ops;
diff --git a/net/mac80211/ieee80211_rate.h b/net/mac80211/ieee80211_rate.h
index 7cd1ebab4f83..23688139ffb3 100644
--- a/net/mac80211/ieee80211_rate.h
+++ b/net/mac80211/ieee80211_rate.h
@@ -65,6 +65,9 @@ struct rate_control_ref {
65 struct kref kref; 65 struct kref kref;
66}; 66};
67 67
68/* default 'simple' algorithm */
69extern struct rate_control_ops mac80211_rcsimple;
70
68int ieee80211_rate_control_register(struct rate_control_ops *ops); 71int ieee80211_rate_control_register(struct rate_control_ops *ops);
69void ieee80211_rate_control_unregister(struct rate_control_ops *ops); 72void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
70 73
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index fc6a3ff3d902..015b3f879aa9 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -704,10 +704,11 @@ static int ieee80211_privacy_mismatch(struct net_device *dev,
704{ 704{
705 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 705 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
706 struct ieee80211_sta_bss *bss; 706 struct ieee80211_sta_bss *bss;
707 int res = 0; 707 int bss_privacy;
708 int wep_privacy;
709 int privacy_invoked;
708 710
709 if (!ifsta || (ifsta->flags & IEEE80211_STA_MIXED_CELL) || 711 if (!ifsta || (ifsta->flags & IEEE80211_STA_MIXED_CELL))
710 ifsta->key_management_enabled)
711 return 0; 712 return 0;
712 713
713 bss = ieee80211_rx_bss_get(dev, ifsta->bssid, local->hw.conf.channel, 714 bss = ieee80211_rx_bss_get(dev, ifsta->bssid, local->hw.conf.channel,
@@ -715,13 +716,16 @@ static int ieee80211_privacy_mismatch(struct net_device *dev,
715 if (!bss) 716 if (!bss)
716 return 0; 717 return 0;
717 718
718 if (ieee80211_sta_wep_configured(dev) != 719 bss_privacy = !!(bss->capability & WLAN_CAPABILITY_PRIVACY);
719 !!(bss->capability & WLAN_CAPABILITY_PRIVACY)) 720 wep_privacy = !!ieee80211_sta_wep_configured(dev);
720 res = 1; 721 privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED);
721 722
722 ieee80211_rx_bss_put(dev, bss); 723 ieee80211_rx_bss_put(dev, bss);
723 724
724 return res; 725 if ((bss_privacy == wep_privacy) || (bss_privacy == privacy_invoked))
726 return 0;
727
728 return 1;
725} 729}
726 730
727 731
diff --git a/net/mac80211/rc80211_simple.c b/net/mac80211/rc80211_simple.c
index 314b8de88862..da72737364e4 100644
--- a/net/mac80211/rc80211_simple.c
+++ b/net/mac80211/rc80211_simple.c
@@ -7,7 +7,6 @@
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 */ 8 */
9 9
10#include <linux/module.h>
11#include <linux/init.h> 10#include <linux/init.h>
12#include <linux/netdevice.h> 11#include <linux/netdevice.h>
13#include <linux/types.h> 12#include <linux/types.h>
@@ -29,8 +28,6 @@
29#define RATE_CONTROL_INTERVAL (HZ / 20) 28#define RATE_CONTROL_INTERVAL (HZ / 20)
30#define RATE_CONTROL_MIN_TX 10 29#define RATE_CONTROL_MIN_TX 10
31 30
32MODULE_ALIAS("rc80211_default");
33
34static void rate_control_rate_inc(struct ieee80211_local *local, 31static void rate_control_rate_inc(struct ieee80211_local *local,
35 struct sta_info *sta) 32 struct sta_info *sta)
36{ 33{
@@ -394,8 +391,7 @@ static void rate_control_simple_remove_sta_debugfs(void *priv, void *priv_sta)
394} 391}
395#endif 392#endif
396 393
397static struct rate_control_ops rate_control_simple = { 394struct rate_control_ops mac80211_rcsimple = {
398 .module = THIS_MODULE,
399 .name = "simple", 395 .name = "simple",
400 .tx_status = rate_control_simple_tx_status, 396 .tx_status = rate_control_simple_tx_status,
401 .get_rate = rate_control_simple_get_rate, 397 .get_rate = rate_control_simple_get_rate,
@@ -410,22 +406,3 @@ static struct rate_control_ops rate_control_simple = {
410 .remove_sta_debugfs = rate_control_simple_remove_sta_debugfs, 406 .remove_sta_debugfs = rate_control_simple_remove_sta_debugfs,
411#endif 407#endif
412}; 408};
413
414
415static int __init rate_control_simple_init(void)
416{
417 return ieee80211_rate_control_register(&rate_control_simple);
418}
419
420
421static void __exit rate_control_simple_exit(void)
422{
423 ieee80211_rate_control_unregister(&rate_control_simple);
424}
425
426
427subsys_initcall(rate_control_simple_init);
428module_exit(rate_control_simple_exit);
429
430MODULE_DESCRIPTION("Simple rate control algorithm for ieee80211");
431MODULE_LICENSE("GPL");
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index ece77766ea2b..428a9fcf57d6 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -509,9 +509,11 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
509 rx->key->tx_rx_count++; 509 rx->key->tx_rx_count++;
510 /* TODO: add threshold stuff again */ 510 /* TODO: add threshold stuff again */
511 } else { 511 } else {
512#ifdef CONFIG_MAC80211_DEBUG
512 if (net_ratelimit()) 513 if (net_ratelimit())
513 printk(KERN_DEBUG "%s: RX protected frame," 514 printk(KERN_DEBUG "%s: RX protected frame,"
514 " but have no key\n", rx->dev->name); 515 " but have no key\n", rx->dev->name);
516#endif /* CONFIG_MAC80211_DEBUG */
515 return TXRX_DROP; 517 return TXRX_DROP;
516 } 518 }
517 519
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index a84a23310ff4..9bf0e1cc530a 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -314,9 +314,11 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx)
314 314
315 if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) { 315 if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) {
316 if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) { 316 if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) {
317#ifdef CONFIG_MAC80211_DEBUG
317 if (net_ratelimit()) 318 if (net_ratelimit())
318 printk(KERN_DEBUG "%s: RX WEP frame, decrypt " 319 printk(KERN_DEBUG "%s: RX WEP frame, decrypt "
319 "failed\n", rx->dev->name); 320 "failed\n", rx->dev->name);
321#endif /* CONFIG_MAC80211_DEBUG */
320 return TXRX_DROP; 322 return TXRX_DROP;
321 } 323 }
322 } else if (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) { 324 } else if (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) {
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 6695efba57ec..20cec1cb956f 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -323,9 +323,12 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx)
323 &rx->u.rx.tkip_iv32, 323 &rx->u.rx.tkip_iv32,
324 &rx->u.rx.tkip_iv16); 324 &rx->u.rx.tkip_iv16);
325 if (res != TKIP_DECRYPT_OK || wpa_test) { 325 if (res != TKIP_DECRYPT_OK || wpa_test) {
326 printk(KERN_DEBUG "%s: TKIP decrypt failed for RX frame from " 326#ifdef CONFIG_MAC80211_DEBUG
327 "%s (res=%d)\n", 327 if (net_ratelimit())
328 rx->dev->name, print_mac(mac, rx->sta->addr), res); 328 printk(KERN_DEBUG "%s: TKIP decrypt failed for RX "
329 "frame from %s (res=%d)\n", rx->dev->name,
330 print_mac(mac, rx->sta->addr), res);
331#endif /* CONFIG_MAC80211_DEBUG */
329 return TXRX_DROP; 332 return TXRX_DROP;
330 } 333 }
331 334
@@ -594,9 +597,12 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx)
594 skb->data + hdrlen + CCMP_HDR_LEN, data_len, 597 skb->data + hdrlen + CCMP_HDR_LEN, data_len,
595 skb->data + skb->len - CCMP_MIC_LEN, 598 skb->data + skb->len - CCMP_MIC_LEN,
596 skb->data + hdrlen + CCMP_HDR_LEN)) { 599 skb->data + hdrlen + CCMP_HDR_LEN)) {
597 printk(KERN_DEBUG "%s: CCMP decrypt failed for RX " 600#ifdef CONFIG_MAC80211_DEBUG
598 "frame from %s\n", rx->dev->name, 601 if (net_ratelimit())
599 print_mac(mac, rx->sta->addr)); 602 printk(KERN_DEBUG "%s: CCMP decrypt failed "
603 "for RX frame from %s\n", rx->dev->name,
604 print_mac(mac, rx->sta->addr));
605#endif /* CONFIG_MAC80211_DEBUG */
600 return TXRX_DROP; 606 return TXRX_DROP;
601 } 607 }
602 } 608 }
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
index 93c58f973831..ad0e36ebea3d 100644
--- a/net/netfilter/Makefile
+++ b/net/netfilter/Makefile
@@ -40,15 +40,15 @@ obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
40# targets 40# targets
41obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o 41obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o
42obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o 42obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o
43obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o
43obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o 44obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o
44obj-$(CONFIG_NETFILTER_XT_TARGET_MARK) += xt_MARK.o 45obj-$(CONFIG_NETFILTER_XT_TARGET_MARK) += xt_MARK.o
45obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o
46obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG) += xt_NFLOG.o 46obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG) += xt_NFLOG.o
47obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o
47obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o 48obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o
48obj-$(CONFIG_NETFILTER_XT_TARGET_TRACE) += xt_TRACE.o
49obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o 49obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o
50obj-$(CONFIG_NETFILTER_XT_TARGET_TCPMSS) += xt_TCPMSS.o 50obj-$(CONFIG_NETFILTER_XT_TARGET_TCPMSS) += xt_TCPMSS.o
51obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o 51obj-$(CONFIG_NETFILTER_XT_TARGET_TRACE) += xt_TRACE.o
52 52
53# matches 53# matches
54obj-$(CONFIG_NETFILTER_XT_MATCH_COMMENT) += xt_comment.o 54obj-$(CONFIG_NETFILTER_XT_MATCH_COMMENT) += xt_comment.o
@@ -59,22 +59,22 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_CONNTRACK) += xt_conntrack.o
59obj-$(CONFIG_NETFILTER_XT_MATCH_DCCP) += xt_dccp.o 59obj-$(CONFIG_NETFILTER_XT_MATCH_DCCP) += xt_dccp.o
60obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o 60obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
61obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o 61obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
62obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
62obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o 63obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
63obj-$(CONFIG_NETFILTER_XT_MATCH_LENGTH) += xt_length.o 64obj-$(CONFIG_NETFILTER_XT_MATCH_LENGTH) += xt_length.o
64obj-$(CONFIG_NETFILTER_XT_MATCH_LIMIT) += xt_limit.o 65obj-$(CONFIG_NETFILTER_XT_MATCH_LIMIT) += xt_limit.o
65obj-$(CONFIG_NETFILTER_XT_MATCH_MAC) += xt_mac.o 66obj-$(CONFIG_NETFILTER_XT_MATCH_MAC) += xt_mac.o
66obj-$(CONFIG_NETFILTER_XT_MATCH_MARK) += xt_mark.o 67obj-$(CONFIG_NETFILTER_XT_MATCH_MARK) += xt_mark.o
67obj-$(CONFIG_NETFILTER_XT_MATCH_MULTIPORT) += xt_multiport.o 68obj-$(CONFIG_NETFILTER_XT_MATCH_MULTIPORT) += xt_multiport.o
68obj-$(CONFIG_NETFILTER_XT_MATCH_POLICY) += xt_policy.o 69obj-$(CONFIG_NETFILTER_XT_MATCH_PHYSDEV) += xt_physdev.o
69obj-$(CONFIG_NETFILTER_XT_MATCH_PKTTYPE) += xt_pkttype.o 70obj-$(CONFIG_NETFILTER_XT_MATCH_PKTTYPE) += xt_pkttype.o
71obj-$(CONFIG_NETFILTER_XT_MATCH_POLICY) += xt_policy.o
70obj-$(CONFIG_NETFILTER_XT_MATCH_QUOTA) += xt_quota.o 72obj-$(CONFIG_NETFILTER_XT_MATCH_QUOTA) += xt_quota.o
71obj-$(CONFIG_NETFILTER_XT_MATCH_REALM) += xt_realm.o 73obj-$(CONFIG_NETFILTER_XT_MATCH_REALM) += xt_realm.o
72obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o 74obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o
73obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o 75obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o
74obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o 76obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o
75obj-$(CONFIG_NETFILTER_XT_MATCH_STRING) += xt_string.o 77obj-$(CONFIG_NETFILTER_XT_MATCH_STRING) += xt_string.o
76obj-$(CONFIG_NETFILTER_XT_MATCH_TIME) += xt_time.o
77obj-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += xt_tcpmss.o 78obj-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += xt_tcpmss.o
78obj-$(CONFIG_NETFILTER_XT_MATCH_PHYSDEV) += xt_physdev.o 79obj-$(CONFIG_NETFILTER_XT_MATCH_TIME) += xt_time.o
79obj-$(CONFIG_NETFILTER_XT_MATCH_U32) += xt_u32.o 80obj-$(CONFIG_NETFILTER_XT_MATCH_U32) += xt_u32.o
80obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
index aa2831587b82..87bc1443c520 100644
--- a/net/netfilter/nf_sockopt.c
+++ b/net/netfilter/nf_sockopt.c
@@ -23,14 +23,13 @@ static inline int overlap(int min1, int max1, int min2, int max2)
23/* Functions to register sockopt ranges (exclusive). */ 23/* Functions to register sockopt ranges (exclusive). */
24int nf_register_sockopt(struct nf_sockopt_ops *reg) 24int nf_register_sockopt(struct nf_sockopt_ops *reg)
25{ 25{
26 struct list_head *i; 26 struct nf_sockopt_ops *ops;
27 int ret = 0; 27 int ret = 0;
28 28
29 if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0) 29 if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
30 return -EINTR; 30 return -EINTR;
31 31
32 list_for_each(i, &nf_sockopts) { 32 list_for_each_entry(ops, &nf_sockopts, list) {
33 struct nf_sockopt_ops *ops = (struct nf_sockopt_ops *)i;
34 if (ops->pf == reg->pf 33 if (ops->pf == reg->pf
35 && (overlap(ops->set_optmin, ops->set_optmax, 34 && (overlap(ops->set_optmin, ops->set_optmax,
36 reg->set_optmin, reg->set_optmax) 35 reg->set_optmin, reg->set_optmax)
@@ -61,48 +60,57 @@ void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
61} 60}
62EXPORT_SYMBOL(nf_unregister_sockopt); 61EXPORT_SYMBOL(nf_unregister_sockopt);
63 62
64/* Call get/setsockopt() */ 63static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, int pf,
65static int nf_sockopt(struct sock *sk, int pf, int val, 64 int val, int get)
66 char __user *opt, int *len, int get)
67{ 65{
68 struct list_head *i;
69 struct nf_sockopt_ops *ops; 66 struct nf_sockopt_ops *ops;
70 int ret;
71 67
72 if (sk->sk_net != &init_net) 68 if (sk->sk_net != &init_net)
73 return -ENOPROTOOPT; 69 return ERR_PTR(-ENOPROTOOPT);
74 70
75 if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0) 71 if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
76 return -EINTR; 72 return ERR_PTR(-EINTR);
77 73
78 list_for_each(i, &nf_sockopts) { 74 list_for_each_entry(ops, &nf_sockopts, list) {
79 ops = (struct nf_sockopt_ops *)i;
80 if (ops->pf == pf) { 75 if (ops->pf == pf) {
81 if (!try_module_get(ops->owner)) 76 if (!try_module_get(ops->owner))
82 goto out_nosup; 77 goto out_nosup;
78
83 if (get) { 79 if (get) {
84 if (val >= ops->get_optmin 80 if (val >= ops->get_optmin &&
85 && val < ops->get_optmax) { 81 val < ops->get_optmax)
86 mutex_unlock(&nf_sockopt_mutex);
87 ret = ops->get(sk, val, opt, len);
88 goto out; 82 goto out;
89 }
90 } else { 83 } else {
91 if (val >= ops->set_optmin 84 if (val >= ops->set_optmin &&
92 && val < ops->set_optmax) { 85 val < ops->set_optmax)
93 mutex_unlock(&nf_sockopt_mutex);
94 ret = ops->set(sk, val, opt, *len);
95 goto out; 86 goto out;
96 }
97 } 87 }
98 module_put(ops->owner); 88 module_put(ops->owner);
99 } 89 }
100 } 90 }
101 out_nosup: 91out_nosup:
92 ops = ERR_PTR(-ENOPROTOOPT);
93out:
102 mutex_unlock(&nf_sockopt_mutex); 94 mutex_unlock(&nf_sockopt_mutex);
103 return -ENOPROTOOPT; 95 return ops;
96}
97
98/* Call get/setsockopt() */
99static int nf_sockopt(struct sock *sk, int pf, int val,
100 char __user *opt, int *len, int get)
101{
102 struct nf_sockopt_ops *ops;
103 int ret;
104
105 ops = nf_sockopt_find(sk, pf, val, get);
106 if (IS_ERR(ops))
107 return PTR_ERR(ops);
108
109 if (get)
110 ret = ops->get(sk, val, opt, len);
111 else
112 ret = ops->set(sk, val, opt, *len);
104 113
105 out:
106 module_put(ops->owner); 114 module_put(ops->owner);
107 return ret; 115 return ret;
108} 116}
@@ -124,56 +132,25 @@ EXPORT_SYMBOL(nf_getsockopt);
124static int compat_nf_sockopt(struct sock *sk, int pf, int val, 132static int compat_nf_sockopt(struct sock *sk, int pf, int val,
125 char __user *opt, int *len, int get) 133 char __user *opt, int *len, int get)
126{ 134{
127 struct list_head *i;
128 struct nf_sockopt_ops *ops; 135 struct nf_sockopt_ops *ops;
129 int ret; 136 int ret;
130 137
131 if (sk->sk_net != &init_net) 138 ops = nf_sockopt_find(sk, pf, val, get);
132 return -ENOPROTOOPT; 139 if (IS_ERR(ops))
133 140 return PTR_ERR(ops);
134 141
135 if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0) 142 if (get) {
136 return -EINTR; 143 if (ops->compat_get)
137 144 ret = ops->compat_get(sk, val, opt, len);
138 list_for_each(i, &nf_sockopts) { 145 else
139 ops = (struct nf_sockopt_ops *)i; 146 ret = ops->get(sk, val, ops, len);
140 if (ops->pf == pf) { 147 } else {
141 if (!try_module_get(ops->owner)) 148 if (ops->compat_set)
142 goto out_nosup; 149 ret = ops->compat_set(sk, val, ops, *len);
143 150 else
144 if (get) { 151 ret = ops->set(sk, val, ops, *len);
145 if (val >= ops->get_optmin
146 && val < ops->get_optmax) {
147 mutex_unlock(&nf_sockopt_mutex);
148 if (ops->compat_get)
149 ret = ops->compat_get(sk,
150 val, opt, len);
151 else
152 ret = ops->get(sk,
153 val, opt, len);
154 goto out;
155 }
156 } else {
157 if (val >= ops->set_optmin
158 && val < ops->set_optmax) {
159 mutex_unlock(&nf_sockopt_mutex);
160 if (ops->compat_set)
161 ret = ops->compat_set(sk,
162 val, opt, *len);
163 else
164 ret = ops->set(sk,
165 val, opt, *len);
166 goto out;
167 }
168 }
169 module_put(ops->owner);
170 }
171 } 152 }
172 out_nosup:
173 mutex_unlock(&nf_sockopt_mutex);
174 return -ENOPROTOOPT;
175 153
176 out:
177 module_put(ops->owner); 154 module_put(ops->owner);
178 return ret; 155 return ret;
179} 156}
diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c
index 06cff1d13690..d7becf08a93a 100644
--- a/net/netfilter/xt_connlimit.c
+++ b/net/netfilter/xt_connlimit.c
@@ -4,7 +4,8 @@
4 * (c) 2000 Gerd Knorr <kraxel@bytesex.org> 4 * (c) 2000 Gerd Knorr <kraxel@bytesex.org>
5 * Nov 2002: Martin Bene <martin.bene@icomedias.com>: 5 * Nov 2002: Martin Bene <martin.bene@icomedias.com>:
6 * only ignore TIME_WAIT or gone connections 6 * only ignore TIME_WAIT or gone connections
7 * Copyright © Jan Engelhardt <jengelh@gmx.de>, 2007 7 * (C) CC Computer Consultants GmbH, 2007
8 * Contact: <jengelh@computergmbh.de>
8 * 9 *
9 * based on ... 10 * based on ...
10 * 11 *
@@ -306,7 +307,7 @@ static void __exit xt_connlimit_exit(void)
306 307
307module_init(xt_connlimit_init); 308module_init(xt_connlimit_init);
308module_exit(xt_connlimit_exit); 309module_exit(xt_connlimit_exit);
309MODULE_AUTHOR("Jan Engelhardt <jengelh@gmx.de>"); 310MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>");
310MODULE_DESCRIPTION("netfilter xt_connlimit match module"); 311MODULE_DESCRIPTION("netfilter xt_connlimit match module");
311MODULE_LICENSE("GPL"); 312MODULE_LICENSE("GPL");
312MODULE_ALIAS("ipt_connlimit"); 313MODULE_ALIAS("ipt_connlimit");
diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c
index ef48bbd93573..f9c55dcd894b 100644
--- a/net/netfilter/xt_time.c
+++ b/net/netfilter/xt_time.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * xt_time 2 * xt_time
3 * Copyright © Jan Engelhardt <jengelh@computergmbh.de>, 2007 3 * Copyright © CC Computer Consultants GmbH, 2007
4 * Contact: <jengelh@computergmbh.de>
4 * 5 *
5 * based on ipt_time by Fabrice MARIE <fabrice@netfilter.org> 6 * based on ipt_time by Fabrice MARIE <fabrice@netfilter.org>
6 * This is a module which is used for time matching 7 * This is a module which is used for time matching
@@ -169,7 +170,7 @@ static bool xt_time_match(const struct sk_buff *skb,
169 if (skb->tstamp.tv64 == 0) 170 if (skb->tstamp.tv64 == 0)
170 __net_timestamp((struct sk_buff *)skb); 171 __net_timestamp((struct sk_buff *)skb);
171 172
172 stamp = skb->tstamp.tv64; 173 stamp = ktime_to_ns(skb->tstamp);
173 do_div(stamp, NSEC_PER_SEC); 174 do_div(stamp, NSEC_PER_SEC);
174 175
175 if (info->flags & XT_TIME_LOCAL_TZ) 176 if (info->flags & XT_TIME_LOCAL_TZ)
diff --git a/net/netfilter/xt_u32.c b/net/netfilter/xt_u32.c
index bec427915b30..af75b8c3f20b 100644
--- a/net/netfilter/xt_u32.c
+++ b/net/netfilter/xt_u32.c
@@ -2,7 +2,8 @@
2 * xt_u32 - kernel module to match u32 packet content 2 * xt_u32 - kernel module to match u32 packet content
3 * 3 *
4 * Original author: Don Cohen <don@isis.cs3-inc.com> 4 * Original author: Don Cohen <don@isis.cs3-inc.com>
5 * © Jan Engelhardt <jengelh@gmx.de>, 2007 5 * (C) CC Computer Consultants GmbH, 2007
6 * Contact: <jengelh@computergmbh.de>
6 */ 7 */
7 8
8#include <linux/module.h> 9#include <linux/module.h>
@@ -129,7 +130,7 @@ static void __exit xt_u32_exit(void)
129 130
130module_init(xt_u32_init); 131module_init(xt_u32_init);
131module_exit(xt_u32_exit); 132module_exit(xt_u32_exit);
132MODULE_AUTHOR("Jan Engelhardt <jengelh@gmx.de>"); 133MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>");
133MODULE_DESCRIPTION("netfilter u32 match module"); 134MODULE_DESCRIPTION("netfilter u32 match module");
134MODULE_LICENSE("GPL"); 135MODULE_LICENSE("GPL");
135MODULE_ALIAS("ipt_u32"); 136MODULE_ALIAS("ipt_u32");
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 260171255576..de3988ba1f46 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -752,7 +752,7 @@ struct sock *netlink_getsockbyfilp(struct file *filp)
752 * 1: repeat lookup - reference dropped while waiting for socket memory. 752 * 1: repeat lookup - reference dropped while waiting for socket memory.
753 */ 753 */
754int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock, 754int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
755 long timeo, struct sock *ssk) 755 long *timeo, struct sock *ssk)
756{ 756{
757 struct netlink_sock *nlk; 757 struct netlink_sock *nlk;
758 758
@@ -761,7 +761,7 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
761 if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf || 761 if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf ||
762 test_bit(0, &nlk->state)) { 762 test_bit(0, &nlk->state)) {
763 DECLARE_WAITQUEUE(wait, current); 763 DECLARE_WAITQUEUE(wait, current);
764 if (!timeo) { 764 if (!*timeo) {
765 if (!ssk || netlink_is_kernel(ssk)) 765 if (!ssk || netlink_is_kernel(ssk))
766 netlink_overrun(sk); 766 netlink_overrun(sk);
767 sock_put(sk); 767 sock_put(sk);
@@ -775,7 +775,7 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
775 if ((atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf || 775 if ((atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf ||
776 test_bit(0, &nlk->state)) && 776 test_bit(0, &nlk->state)) &&
777 !sock_flag(sk, SOCK_DEAD)) 777 !sock_flag(sk, SOCK_DEAD))
778 timeo = schedule_timeout(timeo); 778 *timeo = schedule_timeout(*timeo);
779 779
780 __set_current_state(TASK_RUNNING); 780 __set_current_state(TASK_RUNNING);
781 remove_wait_queue(&nlk->wait, &wait); 781 remove_wait_queue(&nlk->wait, &wait);
@@ -783,7 +783,7 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
783 783
784 if (signal_pending(current)) { 784 if (signal_pending(current)) {
785 kfree_skb(skb); 785 kfree_skb(skb);
786 return sock_intr_errno(timeo); 786 return sock_intr_errno(*timeo);
787 } 787 }
788 return 1; 788 return 1;
789 } 789 }
@@ -877,7 +877,7 @@ retry:
877 if (netlink_is_kernel(sk)) 877 if (netlink_is_kernel(sk))
878 return netlink_unicast_kernel(sk, skb); 878 return netlink_unicast_kernel(sk, skb);
879 879
880 err = netlink_attachskb(sk, skb, nonblock, timeo, ssk); 880 err = netlink_attachskb(sk, skb, nonblock, &timeo, ssk);
881 if (err == 1) 881 if (err == 1)
882 goto retry; 882 goto retry;
883 if (err) 883 if (err)
@@ -1888,7 +1888,7 @@ static void __net_exit netlink_net_exit(struct net *net)
1888#endif 1888#endif
1889} 1889}
1890 1890
1891static struct pernet_operations netlink_net_ops = { 1891static struct pernet_operations __net_initdata netlink_net_ops = {
1892 .init = netlink_net_init, 1892 .init = netlink_net_init,
1893 .exit = netlink_net_exit, 1893 .exit = netlink_net_exit,
1894}; 1894};
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4cb2dfba0993..8a7807dbba01 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -139,9 +139,6 @@ dev->hard_header == NULL (ll header is added by device, we cannot control it)
139static HLIST_HEAD(packet_sklist); 139static HLIST_HEAD(packet_sklist);
140static DEFINE_RWLOCK(packet_sklist_lock); 140static DEFINE_RWLOCK(packet_sklist_lock);
141 141
142static atomic_t packet_socks_nr;
143
144
145/* Private packet socket structures. */ 142/* Private packet socket structures. */
146 143
147struct packet_mclist 144struct packet_mclist
@@ -236,10 +233,7 @@ static void packet_sock_destruct(struct sock *sk)
236 return; 233 return;
237 } 234 }
238 235
239 atomic_dec(&packet_socks_nr); 236 sk_refcnt_debug_dec(sk);
240#ifdef PACKET_REFCNT_DEBUG
241 printk(KERN_DEBUG "PACKET socket %p is free, %d are alive\n", sk, atomic_read(&packet_socks_nr));
242#endif
243} 237}
244 238
245 239
@@ -515,7 +509,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet
515 sll->sll_hatype = dev->type; 509 sll->sll_hatype = dev->type;
516 sll->sll_protocol = skb->protocol; 510 sll->sll_protocol = skb->protocol;
517 sll->sll_pkttype = skb->pkt_type; 511 sll->sll_pkttype = skb->pkt_type;
518 if (unlikely(po->origdev) && skb->pkt_type == PACKET_HOST) 512 if (unlikely(po->origdev))
519 sll->sll_ifindex = orig_dev->ifindex; 513 sll->sll_ifindex = orig_dev->ifindex;
520 else 514 else
521 sll->sll_ifindex = dev->ifindex; 515 sll->sll_ifindex = dev->ifindex;
@@ -661,7 +655,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
661 sll->sll_hatype = dev->type; 655 sll->sll_hatype = dev->type;
662 sll->sll_protocol = skb->protocol; 656 sll->sll_protocol = skb->protocol;
663 sll->sll_pkttype = skb->pkt_type; 657 sll->sll_pkttype = skb->pkt_type;
664 if (unlikely(po->origdev) && skb->pkt_type == PACKET_HOST) 658 if (unlikely(po->origdev))
665 sll->sll_ifindex = orig_dev->ifindex; 659 sll->sll_ifindex = orig_dev->ifindex;
666 else 660 else
667 sll->sll_ifindex = dev->ifindex; 661 sll->sll_ifindex = dev->ifindex;
@@ -849,6 +843,7 @@ static int packet_release(struct socket *sock)
849 /* Purge queues */ 843 /* Purge queues */
850 844
851 skb_queue_purge(&sk->sk_receive_queue); 845 skb_queue_purge(&sk->sk_receive_queue);
846 sk_refcnt_debug_release(sk);
852 847
853 sock_put(sk); 848 sock_put(sk);
854 return 0; 849 return 0;
@@ -886,20 +881,14 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
886 if (protocol == 0) 881 if (protocol == 0)
887 goto out_unlock; 882 goto out_unlock;
888 883
889 if (dev) { 884 if (!dev || (dev->flags & IFF_UP)) {
890 if (dev->flags&IFF_UP) {
891 dev_add_pack(&po->prot_hook);
892 sock_hold(sk);
893 po->running = 1;
894 } else {
895 sk->sk_err = ENETDOWN;
896 if (!sock_flag(sk, SOCK_DEAD))
897 sk->sk_error_report(sk);
898 }
899 } else {
900 dev_add_pack(&po->prot_hook); 885 dev_add_pack(&po->prot_hook);
901 sock_hold(sk); 886 sock_hold(sk);
902 po->running = 1; 887 po->running = 1;
888 } else {
889 sk->sk_err = ENETDOWN;
890 if (!sock_flag(sk, SOCK_DEAD))
891 sk->sk_error_report(sk);
903 } 892 }
904 893
905out_unlock: 894out_unlock:
@@ -1010,7 +999,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol)
1010 po->num = proto; 999 po->num = proto;
1011 1000
1012 sk->sk_destruct = packet_sock_destruct; 1001 sk->sk_destruct = packet_sock_destruct;
1013 atomic_inc(&packet_socks_nr); 1002 sk_refcnt_debug_inc(sk);
1014 1003
1015 /* 1004 /*
1016 * Attach a protocol block 1005 * Attach a protocol block
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 51d151c0e962..73d60a307129 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -27,6 +27,10 @@
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/rfkill.h> 28#include <linux/rfkill.h>
29 29
30/* Get declaration of rfkill_switch_all() to shut up sparse. */
31#include "rfkill-input.h"
32
33
30MODULE_AUTHOR("Ivo van Doorn <IvDoorn@gmail.com>"); 34MODULE_AUTHOR("Ivo van Doorn <IvDoorn@gmail.com>");
31MODULE_VERSION("1.0"); 35MODULE_VERSION("1.0");
32MODULE_DESCRIPTION("RF switch support"); 36MODULE_DESCRIPTION("RF switch support");
@@ -276,21 +280,17 @@ static struct class rfkill_class = {
276 280
277static int rfkill_add_switch(struct rfkill *rfkill) 281static int rfkill_add_switch(struct rfkill *rfkill)
278{ 282{
279 int retval; 283 int error;
280
281 retval = mutex_lock_interruptible(&rfkill_mutex);
282 if (retval)
283 return retval;
284 284
285 retval = rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type]); 285 mutex_lock(&rfkill_mutex);
286 if (retval)
287 goto out;
288 286
289 list_add_tail(&rfkill->node, &rfkill_list); 287 error = rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type]);
288 if (!error)
289 list_add_tail(&rfkill->node, &rfkill_list);
290 290
291 out:
292 mutex_unlock(&rfkill_mutex); 291 mutex_unlock(&rfkill_mutex);
293 return retval; 292
293 return error;
294} 294}
295 295
296static void rfkill_remove_switch(struct rfkill *rfkill) 296static void rfkill_remove_switch(struct rfkill *rfkill)
@@ -387,20 +387,23 @@ int rfkill_register(struct rfkill *rfkill)
387 387
388 if (!rfkill->toggle_radio) 388 if (!rfkill->toggle_radio)
389 return -EINVAL; 389 return -EINVAL;
390 if (rfkill->type >= RFKILL_TYPE_MAX)
391 return -EINVAL;
392
393 snprintf(dev->bus_id, sizeof(dev->bus_id),
394 "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1);
395
396 rfkill_led_trigger_register(rfkill);
390 397
391 error = rfkill_add_switch(rfkill); 398 error = rfkill_add_switch(rfkill);
392 if (error) 399 if (error)
393 return error; 400 return error;
394 401
395 snprintf(dev->bus_id, sizeof(dev->bus_id),
396 "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1);
397
398 error = device_add(dev); 402 error = device_add(dev);
399 if (error) { 403 if (error) {
400 rfkill_remove_switch(rfkill); 404 rfkill_remove_switch(rfkill);
401 return error; 405 return error;
402 } 406 }
403 rfkill_led_trigger_register(rfkill);
404 407
405 return 0; 408 return 0;
406} 409}
@@ -416,9 +419,9 @@ EXPORT_SYMBOL(rfkill_register);
416 */ 419 */
417void rfkill_unregister(struct rfkill *rfkill) 420void rfkill_unregister(struct rfkill *rfkill)
418{ 421{
419 rfkill_led_trigger_unregister(rfkill);
420 device_del(&rfkill->dev); 422 device_del(&rfkill->dev);
421 rfkill_remove_switch(rfkill); 423 rfkill_remove_switch(rfkill);
424 rfkill_led_trigger_unregister(rfkill);
422 put_device(&rfkill->dev); 425 put_device(&rfkill->dev);
423} 426}
424EXPORT_SYMBOL(rfkill_unregister); 427EXPORT_SYMBOL(rfkill_unregister);
@@ -448,5 +451,5 @@ static void __exit rfkill_exit(void)
448 class_unregister(&rfkill_class); 451 class_unregister(&rfkill_class);
449} 452}
450 453
451module_init(rfkill_init); 454subsys_initcall(rfkill_init);
452module_exit(rfkill_exit); 455module_exit(rfkill_exit);
diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
index fe03f71f17da..f3a2bd747a8f 100644
--- a/net/rxrpc/ar-local.c
+++ b/net/rxrpc/ar-local.c
@@ -114,7 +114,7 @@ static int rxrpc_create_local(struct rxrpc_local *local)
114 return 0; 114 return 0;
115 115
116error: 116error:
117 local->socket->ops->shutdown(local->socket, 2); 117 kernel_sock_shutdown(local->socket, SHUT_RDWR);
118 local->socket->sk->sk_user_data = NULL; 118 local->socket->sk->sk_user_data = NULL;
119 sock_release(local->socket); 119 sock_release(local->socket);
120 local->socket = NULL; 120 local->socket = NULL;
@@ -267,7 +267,7 @@ static void rxrpc_destroy_local(struct work_struct *work)
267 /* finish cleaning up the local descriptor */ 267 /* finish cleaning up the local descriptor */
268 rxrpc_purge_queue(&local->accept_queue); 268 rxrpc_purge_queue(&local->accept_queue);
269 rxrpc_purge_queue(&local->reject_queue); 269 rxrpc_purge_queue(&local->reject_queue);
270 local->socket->ops->shutdown(local->socket, 2); 270 kernel_sock_shutdown(local->socket, SHUT_RDWR);
271 sock_release(local->socket); 271 sock_release(local->socket);
272 272
273 up_read(&rxrpc_local_sem); 273 up_read(&rxrpc_local_sem);
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 9e98c6e567dd..c39008209164 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -91,7 +91,7 @@ static struct tc_u_common *u32_list;
91 91
92static __inline__ unsigned u32_hash_fold(u32 key, struct tc_u32_sel *sel, u8 fshift) 92static __inline__ unsigned u32_hash_fold(u32 key, struct tc_u32_sel *sel, u8 fshift)
93{ 93{
94 unsigned h = (key & sel->hmask)>>fshift; 94 unsigned h = ntohl(key & sel->hmask)>>fshift;
95 95
96 return h; 96 return h;
97} 97}
@@ -613,17 +613,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
613 memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key)); 613 memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key));
614 n->ht_up = ht; 614 n->ht_up = ht;
615 n->handle = handle; 615 n->handle = handle;
616{ 616 n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0;
617 u8 i = 0;
618 u32 mask = s->hmask;
619 if (mask) {
620 while (!(mask & 1)) {
621 i++;
622 mask>>=1;
623 }
624 }
625 n->fshift = i;
626}
627 617
628#ifdef CONFIG_CLS_U32_MARK 618#ifdef CONFIG_CLS_U32_MARK
629 if (tb[TCA_U32_MARK-1]) { 619 if (tb[TCA_U32_MARK-1]) {
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index fa1a6f45dc41..e595e6570ce0 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -134,7 +134,7 @@ static inline int qdisc_restart(struct net_device *dev)
134{ 134{
135 struct Qdisc *q = dev->qdisc; 135 struct Qdisc *q = dev->qdisc;
136 struct sk_buff *skb; 136 struct sk_buff *skb;
137 int ret; 137 int ret = NETDEV_TX_BUSY;
138 138
139 /* Dequeue packet */ 139 /* Dequeue packet */
140 if (unlikely((skb = dev_dequeue_skb(dev, q)) == NULL)) 140 if (unlikely((skb = dev_dequeue_skb(dev, q)) == NULL))
@@ -145,7 +145,8 @@ static inline int qdisc_restart(struct net_device *dev)
145 spin_unlock(&dev->queue_lock); 145 spin_unlock(&dev->queue_lock);
146 146
147 HARD_TX_LOCK(dev, smp_processor_id()); 147 HARD_TX_LOCK(dev, smp_processor_id());
148 ret = dev_hard_start_xmit(skb, dev); 148 if (!netif_subqueue_stopped(dev, skb))
149 ret = dev_hard_start_xmit(skb, dev);
149 HARD_TX_UNLOCK(dev); 150 HARD_TX_UNLOCK(dev);
150 151
151 spin_lock(&dev->queue_lock); 152 spin_lock(&dev->queue_lock);
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index 421281d9dd1d..c0ed06d4a504 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -252,6 +252,9 @@ __teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res, struct net_device *
252static inline int teql_resolve(struct sk_buff *skb, 252static inline int teql_resolve(struct sk_buff *skb,
253 struct sk_buff *skb_res, struct net_device *dev) 253 struct sk_buff *skb_res, struct net_device *dev)
254{ 254{
255 if (dev->qdisc == &noop_qdisc)
256 return -ENODEV;
257
255 if (dev->header_ops == NULL || 258 if (dev->header_ops == NULL ||
256 skb->dst == NULL || 259 skb->dst == NULL ||
257 skb->dst->neighbour == NULL) 260 skb->dst->neighbour == NULL)
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 03158e3665da..013e3d3ab0f1 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -262,10 +262,14 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
262 */ 262 */
263 asoc->peer.sack_needed = 1; 263 asoc->peer.sack_needed = 1;
264 264
265 /* Assume that the peer recongizes ASCONF until reported otherwise 265 /* Assume that the peer will tell us if he recognizes ASCONF
266 * via an ERROR chunk. 266 * as part of INIT exchange.
267 * The sctp_addip_noauth option is there for backward compatibilty
268 * and will revert old behavior.
267 */ 269 */
268 asoc->peer.asconf_capable = 1; 270 asoc->peer.asconf_capable = 0;
271 if (sctp_addip_noauth)
272 asoc->peer.asconf_capable = 1;
269 273
270 /* Create an input queue. */ 274 /* Create an input queue. */
271 sctp_inq_init(&asoc->base.inqueue); 275 sctp_inq_init(&asoc->base.inqueue);
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index dfffa94fb9f6..cae95af9a8cc 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -180,9 +180,7 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
180/* Delete an address from the bind address list in the SCTP_bind_addr 180/* Delete an address from the bind address list in the SCTP_bind_addr
181 * structure. 181 * structure.
182 */ 182 */
183int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr, 183int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr)
184 void fastcall (*rcu_call)(struct rcu_head *head,
185 void (*func)(struct rcu_head *head)))
186{ 184{
187 struct sctp_sockaddr_entry *addr, *temp; 185 struct sctp_sockaddr_entry *addr, *temp;
188 186
@@ -198,15 +196,10 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr,
198 } 196 }
199 } 197 }
200 198
201 /* Call the rcu callback provided in the args. This function is
202 * called by both BH packet processing and user side socket option
203 * processing, but it works on different lists in those 2 contexts.
204 * Each context provides it's own callback, whether call_rcu_bh()
205 * or call_rcu(), to make sure that we wait for an appropriate time.
206 */
207 if (addr && !addr->valid) { 199 if (addr && !addr->valid) {
208 rcu_call(&addr->rcu, sctp_local_addr_free); 200 call_rcu(&addr->rcu, sctp_local_addr_free);
209 SCTP_DBG_OBJCNT_DEC(addr); 201 SCTP_DBG_OBJCNT_DEC(addr);
202 return 0;
210 } 203 }
211 204
212 return -EINVAL; 205 return -EINVAL;
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 2d2d81ef4a69..de6f505d6ff8 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -328,24 +328,35 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc(
328 const union sctp_addr *paddr, 328 const union sctp_addr *paddr,
329 struct sctp_transport **transport) 329 struct sctp_transport **transport)
330{ 330{
331 struct sctp_association *asoc = NULL;
332 struct sctp_transport *t = NULL;
333 struct sctp_hashbucket *head;
334 struct sctp_ep_common *epb;
335 struct hlist_node *node;
336 int hash;
331 int rport; 337 int rport;
332 struct sctp_association *asoc;
333 struct list_head *pos;
334 338
339 *transport = NULL;
335 rport = ntohs(paddr->v4.sin_port); 340 rport = ntohs(paddr->v4.sin_port);
336 341
337 list_for_each(pos, &ep->asocs) { 342 hash = sctp_assoc_hashfn(ep->base.bind_addr.port, rport);
338 asoc = list_entry(pos, struct sctp_association, asocs); 343 head = &sctp_assoc_hashtable[hash];
339 if (rport == asoc->peer.port) { 344 read_lock(&head->lock);
340 *transport = sctp_assoc_lookup_paddr(asoc, paddr); 345 sctp_for_each_hentry(epb, node, &head->chain) {
341 346 asoc = sctp_assoc(epb);
342 if (*transport) 347 if (asoc->ep != ep || rport != asoc->peer.port)
343 return asoc; 348 goto next;
349
350 t = sctp_assoc_lookup_paddr(asoc, paddr);
351 if (t) {
352 *transport = t;
353 break;
344 } 354 }
355next:
356 asoc = NULL;
345 } 357 }
346 358 read_unlock(&head->lock);
347 *transport = NULL; 359 return asoc;
348 return NULL;
349} 360}
350 361
351/* Lookup association on an endpoint based on a peer address. BH-safe. */ 362/* Lookup association on an endpoint based on a peer address. BH-safe. */
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 86503e7fa21e..91ae463b079b 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -656,7 +656,6 @@ discard:
656/* Insert endpoint into the hash table. */ 656/* Insert endpoint into the hash table. */
657static void __sctp_hash_endpoint(struct sctp_endpoint *ep) 657static void __sctp_hash_endpoint(struct sctp_endpoint *ep)
658{ 658{
659 struct sctp_ep_common **epp;
660 struct sctp_ep_common *epb; 659 struct sctp_ep_common *epb;
661 struct sctp_hashbucket *head; 660 struct sctp_hashbucket *head;
662 661
@@ -666,12 +665,7 @@ static void __sctp_hash_endpoint(struct sctp_endpoint *ep)
666 head = &sctp_ep_hashtable[epb->hashent]; 665 head = &sctp_ep_hashtable[epb->hashent];
667 666
668 sctp_write_lock(&head->lock); 667 sctp_write_lock(&head->lock);
669 epp = &head->chain; 668 hlist_add_head(&epb->node, &head->chain);
670 epb->next = *epp;
671 if (epb->next)
672 (*epp)->pprev = &epb->next;
673 *epp = epb;
674 epb->pprev = epp;
675 sctp_write_unlock(&head->lock); 669 sctp_write_unlock(&head->lock);
676} 670}
677 671
@@ -691,19 +685,15 @@ static void __sctp_unhash_endpoint(struct sctp_endpoint *ep)
691 685
692 epb = &ep->base; 686 epb = &ep->base;
693 687
688 if (hlist_unhashed(&epb->node))
689 return;
690
694 epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); 691 epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);
695 692
696 head = &sctp_ep_hashtable[epb->hashent]; 693 head = &sctp_ep_hashtable[epb->hashent];
697 694
698 sctp_write_lock(&head->lock); 695 sctp_write_lock(&head->lock);
699 696 __hlist_del(&epb->node);
700 if (epb->pprev) {
701 if (epb->next)
702 epb->next->pprev = epb->pprev;
703 *epb->pprev = epb->next;
704 epb->pprev = NULL;
705 }
706
707 sctp_write_unlock(&head->lock); 697 sctp_write_unlock(&head->lock);
708} 698}
709 699
@@ -721,12 +711,13 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l
721 struct sctp_hashbucket *head; 711 struct sctp_hashbucket *head;
722 struct sctp_ep_common *epb; 712 struct sctp_ep_common *epb;
723 struct sctp_endpoint *ep; 713 struct sctp_endpoint *ep;
714 struct hlist_node *node;
724 int hash; 715 int hash;
725 716
726 hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port)); 717 hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port));
727 head = &sctp_ep_hashtable[hash]; 718 head = &sctp_ep_hashtable[hash];
728 read_lock(&head->lock); 719 read_lock(&head->lock);
729 for (epb = head->chain; epb; epb = epb->next) { 720 sctp_for_each_hentry(epb, node, &head->chain) {
730 ep = sctp_ep(epb); 721 ep = sctp_ep(epb);
731 if (sctp_endpoint_is_match(ep, laddr)) 722 if (sctp_endpoint_is_match(ep, laddr))
732 goto hit; 723 goto hit;
@@ -744,7 +735,6 @@ hit:
744/* Insert association into the hash table. */ 735/* Insert association into the hash table. */
745static void __sctp_hash_established(struct sctp_association *asoc) 736static void __sctp_hash_established(struct sctp_association *asoc)
746{ 737{
747 struct sctp_ep_common **epp;
748 struct sctp_ep_common *epb; 738 struct sctp_ep_common *epb;
749 struct sctp_hashbucket *head; 739 struct sctp_hashbucket *head;
750 740
@@ -756,12 +746,7 @@ static void __sctp_hash_established(struct sctp_association *asoc)
756 head = &sctp_assoc_hashtable[epb->hashent]; 746 head = &sctp_assoc_hashtable[epb->hashent];
757 747
758 sctp_write_lock(&head->lock); 748 sctp_write_lock(&head->lock);
759 epp = &head->chain; 749 hlist_add_head(&epb->node, &head->chain);
760 epb->next = *epp;
761 if (epb->next)
762 (*epp)->pprev = &epb->next;
763 *epp = epb;
764 epb->pprev = epp;
765 sctp_write_unlock(&head->lock); 750 sctp_write_unlock(&head->lock);
766} 751}
767 752
@@ -790,14 +775,7 @@ static void __sctp_unhash_established(struct sctp_association *asoc)
790 head = &sctp_assoc_hashtable[epb->hashent]; 775 head = &sctp_assoc_hashtable[epb->hashent];
791 776
792 sctp_write_lock(&head->lock); 777 sctp_write_lock(&head->lock);
793 778 __hlist_del(&epb->node);
794 if (epb->pprev) {
795 if (epb->next)
796 epb->next->pprev = epb->pprev;
797 *epb->pprev = epb->next;
798 epb->pprev = NULL;
799 }
800
801 sctp_write_unlock(&head->lock); 779 sctp_write_unlock(&head->lock);
802} 780}
803 781
@@ -822,6 +800,7 @@ static struct sctp_association *__sctp_lookup_association(
822 struct sctp_ep_common *epb; 800 struct sctp_ep_common *epb;
823 struct sctp_association *asoc; 801 struct sctp_association *asoc;
824 struct sctp_transport *transport; 802 struct sctp_transport *transport;
803 struct hlist_node *node;
825 int hash; 804 int hash;
826 805
827 /* Optimize here for direct hit, only listening connections can 806 /* Optimize here for direct hit, only listening connections can
@@ -830,7 +809,7 @@ static struct sctp_association *__sctp_lookup_association(
830 hash = sctp_assoc_hashfn(ntohs(local->v4.sin_port), ntohs(peer->v4.sin_port)); 809 hash = sctp_assoc_hashfn(ntohs(local->v4.sin_port), ntohs(peer->v4.sin_port));
831 head = &sctp_assoc_hashtable[hash]; 810 head = &sctp_assoc_hashtable[hash];
832 read_lock(&head->lock); 811 read_lock(&head->lock);
833 for (epb = head->chain; epb; epb = epb->next) { 812 sctp_for_each_hentry(epb, node, &head->chain) {
834 asoc = sctp_assoc(epb); 813 asoc = sctp_assoc(epb);
835 transport = sctp_assoc_is_match(asoc, local, peer); 814 transport = sctp_assoc_is_match(asoc, local, peer);
836 if (transport) 815 if (transport)
diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c
index f10fe7fbf24c..cf4b7eb023b3 100644
--- a/net/sctp/inqueue.c
+++ b/net/sctp/inqueue.c
@@ -90,6 +90,10 @@ void sctp_inq_free(struct sctp_inq *queue)
90void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk) 90void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk)
91{ 91{
92 /* Directly call the packet handling routine. */ 92 /* Directly call the packet handling routine. */
93 if (chunk->rcvr->dead) {
94 sctp_chunk_free(chunk);
95 return;
96 }
93 97
94 /* We are now calling this either from the soft interrupt 98 /* We are now calling this either from the soft interrupt
95 * or from the backlog processing. 99 * or from the backlog processing.
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 28f4fe77ceee..fa76f235169b 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -382,7 +382,7 @@ static void sctp_insert_list(struct list_head *head, struct list_head *new)
382/* Mark all the eligible packets on a transport for retransmission. */ 382/* Mark all the eligible packets on a transport for retransmission. */
383void sctp_retransmit_mark(struct sctp_outq *q, 383void sctp_retransmit_mark(struct sctp_outq *q,
384 struct sctp_transport *transport, 384 struct sctp_transport *transport,
385 __u8 fast_retransmit) 385 __u8 reason)
386{ 386{
387 struct list_head *lchunk, *ltemp; 387 struct list_head *lchunk, *ltemp;
388 struct sctp_chunk *chunk; 388 struct sctp_chunk *chunk;
@@ -412,20 +412,20 @@ void sctp_retransmit_mark(struct sctp_outq *q,
412 continue; 412 continue;
413 } 413 }
414 414
415 /* If we are doing retransmission due to a fast retransmit, 415 /* If we are doing retransmission due to a timeout or pmtu
416 * only the chunk's that are marked for fast retransmit 416 * discovery, only the chunks that are not yet acked should
417 * should be added to the retransmit queue. If we are doing 417 * be added to the retransmit queue.
418 * retransmission due to a timeout or pmtu discovery, only the
419 * chunks that are not yet acked should be added to the
420 * retransmit queue.
421 */ 418 */
422 if ((fast_retransmit && (chunk->fast_retransmit > 0)) || 419 if ((reason == SCTP_RTXR_FAST_RTX &&
423 (!fast_retransmit && !chunk->tsn_gap_acked)) { 420 (chunk->fast_retransmit > 0)) ||
421 (reason != SCTP_RTXR_FAST_RTX && !chunk->tsn_gap_acked)) {
424 /* If this chunk was sent less then 1 rto ago, do not 422 /* If this chunk was sent less then 1 rto ago, do not
425 * retransmit this chunk, but give the peer time 423 * retransmit this chunk, but give the peer time
426 * to acknowlege it. 424 * to acknowlege it. Do this only when
425 * retransmitting due to T3 timeout.
427 */ 426 */
428 if ((jiffies - chunk->sent_at) < transport->rto) 427 if (reason == SCTP_RTXR_T3_RTX &&
428 (jiffies - chunk->sent_at) < transport->last_rto)
429 continue; 429 continue;
430 430
431 /* RFC 2960 6.2.1 Processing a Received SACK 431 /* RFC 2960 6.2.1 Processing a Received SACK
@@ -467,10 +467,10 @@ void sctp_retransmit_mark(struct sctp_outq *q,
467 } 467 }
468 } 468 }
469 469
470 SCTP_DEBUG_PRINTK("%s: transport: %p, fast_retransmit: %d, " 470 SCTP_DEBUG_PRINTK("%s: transport: %p, reason: %d, "
471 "cwnd: %d, ssthresh: %d, flight_size: %d, " 471 "cwnd: %d, ssthresh: %d, flight_size: %d, "
472 "pba: %d\n", __FUNCTION__, 472 "pba: %d\n", __FUNCTION__,
473 transport, fast_retransmit, 473 transport, reason,
474 transport->cwnd, transport->ssthresh, 474 transport->cwnd, transport->ssthresh,
475 transport->flight_size, 475 transport->flight_size,
476 transport->partial_bytes_acked); 476 transport->partial_bytes_acked);
@@ -484,7 +484,6 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
484 sctp_retransmit_reason_t reason) 484 sctp_retransmit_reason_t reason)
485{ 485{
486 int error = 0; 486 int error = 0;
487 __u8 fast_retransmit = 0;
488 487
489 switch(reason) { 488 switch(reason) {
490 case SCTP_RTXR_T3_RTX: 489 case SCTP_RTXR_T3_RTX:
@@ -499,16 +498,18 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
499 case SCTP_RTXR_FAST_RTX: 498 case SCTP_RTXR_FAST_RTX:
500 SCTP_INC_STATS(SCTP_MIB_FAST_RETRANSMITS); 499 SCTP_INC_STATS(SCTP_MIB_FAST_RETRANSMITS);
501 sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX); 500 sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX);
502 fast_retransmit = 1;
503 break; 501 break;
504 case SCTP_RTXR_PMTUD: 502 case SCTP_RTXR_PMTUD:
505 SCTP_INC_STATS(SCTP_MIB_PMTUD_RETRANSMITS); 503 SCTP_INC_STATS(SCTP_MIB_PMTUD_RETRANSMITS);
506 break; 504 break;
505 case SCTP_RTXR_T1_RTX:
506 SCTP_INC_STATS(SCTP_MIB_T1_RETRANSMITS);
507 break;
507 default: 508 default:
508 BUG(); 509 BUG();
509 } 510 }
510 511
511 sctp_retransmit_mark(q, transport, fast_retransmit); 512 sctp_retransmit_mark(q, transport, reason);
512 513
513 /* PR-SCTP A5) Any time the T3-rtx timer expires, on any destination, 514 /* PR-SCTP A5) Any time the T3-rtx timer expires, on any destination,
514 * the sender SHOULD try to advance the "Advanced.Peer.Ack.Point" by 515 * the sender SHOULD try to advance the "Advanced.Peer.Ack.Point" by
@@ -641,7 +642,8 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
641 642
642 /* If we are here due to a retransmit timeout or a fast 643 /* If we are here due to a retransmit timeout or a fast
643 * retransmit and if there are any chunks left in the retransmit 644 * retransmit and if there are any chunks left in the retransmit
644 * queue that could not fit in the PMTU sized packet, they need * to be marked as ineligible for a subsequent fast retransmit. 645 * queue that could not fit in the PMTU sized packet, they need
646 * to be marked as ineligible for a subsequent fast retransmit.
645 */ 647 */
646 if (rtx_timeout && !lchunk) { 648 if (rtx_timeout && !lchunk) {
647 list_for_each(lchunk1, lqueue) { 649 list_for_each(lchunk1, lqueue) {
@@ -660,10 +662,9 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
660int sctp_outq_uncork(struct sctp_outq *q) 662int sctp_outq_uncork(struct sctp_outq *q)
661{ 663{
662 int error = 0; 664 int error = 0;
663 if (q->cork) { 665 if (q->cork)
664 q->cork = 0; 666 q->cork = 0;
665 error = sctp_outq_flush(q, 0); 667 error = sctp_outq_flush(q, 0);
666 }
667 return error; 668 return error;
668} 669}
669 670
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index e4cd841a22e4..249973204070 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -225,6 +225,7 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
225 struct sctp_ep_common *epb; 225 struct sctp_ep_common *epb;
226 struct sctp_endpoint *ep; 226 struct sctp_endpoint *ep;
227 struct sock *sk; 227 struct sock *sk;
228 struct hlist_node *node;
228 int hash = *(loff_t *)v; 229 int hash = *(loff_t *)v;
229 230
230 if (hash >= sctp_ep_hashsize) 231 if (hash >= sctp_ep_hashsize)
@@ -233,7 +234,7 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
233 head = &sctp_ep_hashtable[hash]; 234 head = &sctp_ep_hashtable[hash];
234 sctp_local_bh_disable(); 235 sctp_local_bh_disable();
235 read_lock(&head->lock); 236 read_lock(&head->lock);
236 for (epb = head->chain; epb; epb = epb->next) { 237 sctp_for_each_hentry(epb, node, &head->chain) {
237 ep = sctp_ep(epb); 238 ep = sctp_ep(epb);
238 sk = epb->sk; 239 sk = epb->sk;
239 seq_printf(seq, "%8p %8p %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk, 240 seq_printf(seq, "%8p %8p %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk,
@@ -328,6 +329,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
328 struct sctp_ep_common *epb; 329 struct sctp_ep_common *epb;
329 struct sctp_association *assoc; 330 struct sctp_association *assoc;
330 struct sock *sk; 331 struct sock *sk;
332 struct hlist_node *node;
331 int hash = *(loff_t *)v; 333 int hash = *(loff_t *)v;
332 334
333 if (hash >= sctp_assoc_hashsize) 335 if (hash >= sctp_assoc_hashsize)
@@ -336,7 +338,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
336 head = &sctp_assoc_hashtable[hash]; 338 head = &sctp_assoc_hashtable[hash];
337 sctp_local_bh_disable(); 339 sctp_local_bh_disable();
338 read_lock(&head->lock); 340 read_lock(&head->lock);
339 for (epb = head->chain; epb; epb = epb->next) { 341 sctp_for_each_hentry(epb, node, &head->chain) {
340 assoc = sctp_assoc(epb); 342 assoc = sctp_assoc(epb);
341 sk = epb->sk; 343 sk = epb->sk;
342 seq_printf(seq, 344 seq_printf(seq,
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 40c1a47d1b8d..d50f610d1b02 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1137,7 +1137,7 @@ SCTP_STATIC __init int sctp_init(void)
1137 } 1137 }
1138 for (i = 0; i < sctp_assoc_hashsize; i++) { 1138 for (i = 0; i < sctp_assoc_hashsize; i++) {
1139 rwlock_init(&sctp_assoc_hashtable[i].lock); 1139 rwlock_init(&sctp_assoc_hashtable[i].lock);
1140 sctp_assoc_hashtable[i].chain = NULL; 1140 INIT_HLIST_HEAD(&sctp_assoc_hashtable[i].chain);
1141 } 1141 }
1142 1142
1143 /* Allocate and initialize the endpoint hash table. */ 1143 /* Allocate and initialize the endpoint hash table. */
@@ -1151,7 +1151,7 @@ SCTP_STATIC __init int sctp_init(void)
1151 } 1151 }
1152 for (i = 0; i < sctp_ep_hashsize; i++) { 1152 for (i = 0; i < sctp_ep_hashsize; i++) {
1153 rwlock_init(&sctp_ep_hashtable[i].lock); 1153 rwlock_init(&sctp_ep_hashtable[i].lock);
1154 sctp_ep_hashtable[i].chain = NULL; 1154 INIT_HLIST_HEAD(&sctp_ep_hashtable[i].chain);
1155 } 1155 }
1156 1156
1157 /* Allocate and initialize the SCTP port hash table. */ 1157 /* Allocate and initialize the SCTP port hash table. */
@@ -1170,7 +1170,7 @@ SCTP_STATIC __init int sctp_init(void)
1170 } 1170 }
1171 for (i = 0; i < sctp_port_hashsize; i++) { 1171 for (i = 0; i < sctp_port_hashsize; i++) {
1172 spin_lock_init(&sctp_port_hashtable[i].lock); 1172 spin_lock_init(&sctp_port_hashtable[i].lock);
1173 sctp_port_hashtable[i].chain = NULL; 1173 INIT_HLIST_HEAD(&sctp_port_hashtable[i].chain);
1174 } 1174 }
1175 1175
1176 printk(KERN_INFO "SCTP: Hash tables configured " 1176 printk(KERN_INFO "SCTP: Hash tables configured "
@@ -1179,6 +1179,7 @@ SCTP_STATIC __init int sctp_init(void)
1179 1179
1180 /* Disable ADDIP by default. */ 1180 /* Disable ADDIP by default. */
1181 sctp_addip_enable = 0; 1181 sctp_addip_enable = 0;
1182 sctp_addip_noauth = 0;
1182 1183
1183 /* Enable PR-SCTP by default. */ 1184 /* Enable PR-SCTP by default. */
1184 sctp_prsctp_enable = 1; 1185 sctp_prsctp_enable = 1;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index c377e4e8f653..5a9783c38de1 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1788,9 +1788,14 @@ static int sctp_process_inv_paramlength(const struct sctp_association *asoc,
1788 sizeof(sctp_paramhdr_t); 1788 sizeof(sctp_paramhdr_t);
1789 1789
1790 1790
1791 /* This is a fatal error. Any accumulated non-fatal errors are
1792 * not reported.
1793 */
1794 if (*errp)
1795 sctp_chunk_free(*errp);
1796
1791 /* Create an error chunk and fill it in with our payload. */ 1797 /* Create an error chunk and fill it in with our payload. */
1792 if (!*errp) 1798 *errp = sctp_make_op_error_space(asoc, chunk, payload_len);
1793 *errp = sctp_make_op_error_space(asoc, chunk, payload_len);
1794 1799
1795 if (*errp) { 1800 if (*errp) {
1796 sctp_init_cause(*errp, SCTP_ERROR_PROTO_VIOLATION, 1801 sctp_init_cause(*errp, SCTP_ERROR_PROTO_VIOLATION,
@@ -1813,9 +1818,15 @@ static int sctp_process_hn_param(const struct sctp_association *asoc,
1813{ 1818{
1814 __u16 len = ntohs(param.p->length); 1819 __u16 len = ntohs(param.p->length);
1815 1820
1816 /* Make an ERROR chunk. */ 1821 /* Processing of the HOST_NAME parameter will generate an
1817 if (!*errp) 1822 * ABORT. If we've accumulated any non-fatal errors, they
1818 *errp = sctp_make_op_error_space(asoc, chunk, len); 1823 * would be unrecognized parameters and we should not include
1824 * them in the ABORT.
1825 */
1826 if (*errp)
1827 sctp_chunk_free(*errp);
1828
1829 *errp = sctp_make_op_error_space(asoc, chunk, len);
1819 1830
1820 if (*errp) { 1831 if (*errp) {
1821 sctp_init_cause(*errp, SCTP_ERROR_DNS_FAILED, len); 1832 sctp_init_cause(*errp, SCTP_ERROR_DNS_FAILED, len);
@@ -1847,7 +1858,7 @@ static void sctp_process_ext_param(struct sctp_association *asoc,
1847 break; 1858 break;
1848 case SCTP_CID_ASCONF: 1859 case SCTP_CID_ASCONF:
1849 case SCTP_CID_ASCONF_ACK: 1860 case SCTP_CID_ASCONF_ACK:
1850 asoc->peer.addip_capable = 1; 1861 asoc->peer.asconf_capable = 1;
1851 break; 1862 break;
1852 default: 1863 default:
1853 break; 1864 break;
@@ -1862,56 +1873,40 @@ static void sctp_process_ext_param(struct sctp_association *asoc,
1862 * taken if the processing endpoint does not recognize the 1873 * taken if the processing endpoint does not recognize the
1863 * Parameter Type. 1874 * Parameter Type.
1864 * 1875 *
1865 * 00 - Stop processing this SCTP chunk and discard it, 1876 * 00 - Stop processing this parameter; do not process any further
1866 * do not process any further chunks within it. 1877 * parameters within this chunk
1867 * 1878 *
1868 * 01 - Stop processing this SCTP chunk and discard it, 1879 * 01 - Stop processing this parameter, do not process any further
1869 * do not process any further chunks within it, and report 1880 * parameters within this chunk, and report the unrecognized
1870 * the unrecognized parameter in an 'Unrecognized 1881 * parameter in an 'Unrecognized Parameter' ERROR chunk.
1871 * Parameter Type' (in either an ERROR or in the INIT ACK).
1872 * 1882 *
1873 * 10 - Skip this parameter and continue processing. 1883 * 10 - Skip this parameter and continue processing.
1874 * 1884 *
1875 * 11 - Skip this parameter and continue processing but 1885 * 11 - Skip this parameter and continue processing but
1876 * report the unrecognized parameter in an 1886 * report the unrecognized parameter in an
1877 * 'Unrecognized Parameter Type' (in either an ERROR or in 1887 * 'Unrecognized Parameter' ERROR chunk.
1878 * the INIT ACK).
1879 * 1888 *
1880 * Return value: 1889 * Return value:
1881 * 0 - discard the chunk 1890 * SCTP_IERROR_NO_ERROR - continue with the chunk
1882 * 1 - continue with the chunk 1891 * SCTP_IERROR_ERROR - stop and report an error.
1892 * SCTP_IERROR_NOMEME - out of memory.
1883 */ 1893 */
1884static int sctp_process_unk_param(const struct sctp_association *asoc, 1894static sctp_ierror_t sctp_process_unk_param(const struct sctp_association *asoc,
1885 union sctp_params param, 1895 union sctp_params param,
1886 struct sctp_chunk *chunk, 1896 struct sctp_chunk *chunk,
1887 struct sctp_chunk **errp) 1897 struct sctp_chunk **errp)
1888{ 1898{
1889 int retval = 1; 1899 int retval = SCTP_IERROR_NO_ERROR;
1890 1900
1891 switch (param.p->type & SCTP_PARAM_ACTION_MASK) { 1901 switch (param.p->type & SCTP_PARAM_ACTION_MASK) {
1892 case SCTP_PARAM_ACTION_DISCARD: 1902 case SCTP_PARAM_ACTION_DISCARD:
1893 retval = 0; 1903 retval = SCTP_IERROR_ERROR;
1894 break;
1895 case SCTP_PARAM_ACTION_DISCARD_ERR:
1896 retval = 0;
1897 /* Make an ERROR chunk, preparing enough room for
1898 * returning multiple unknown parameters.
1899 */
1900 if (NULL == *errp)
1901 *errp = sctp_make_op_error_space(asoc, chunk,
1902 ntohs(chunk->chunk_hdr->length));
1903
1904 if (*errp) {
1905 sctp_init_cause(*errp, SCTP_ERROR_UNKNOWN_PARAM,
1906 WORD_ROUND(ntohs(param.p->length)));
1907 sctp_addto_chunk(*errp,
1908 WORD_ROUND(ntohs(param.p->length)),
1909 param.v);
1910 }
1911
1912 break; 1904 break;
1913 case SCTP_PARAM_ACTION_SKIP: 1905 case SCTP_PARAM_ACTION_SKIP:
1914 break; 1906 break;
1907 case SCTP_PARAM_ACTION_DISCARD_ERR:
1908 retval = SCTP_IERROR_ERROR;
1909 /* Fall through */
1915 case SCTP_PARAM_ACTION_SKIP_ERR: 1910 case SCTP_PARAM_ACTION_SKIP_ERR:
1916 /* Make an ERROR chunk, preparing enough room for 1911 /* Make an ERROR chunk, preparing enough room for
1917 * returning multiple unknown parameters. 1912 * returning multiple unknown parameters.
@@ -1932,9 +1927,8 @@ static int sctp_process_unk_param(const struct sctp_association *asoc,
1932 * to the peer and the association won't be 1927 * to the peer and the association won't be
1933 * established. 1928 * established.
1934 */ 1929 */
1935 retval = 0; 1930 retval = SCTP_IERROR_NOMEM;
1936 } 1931 }
1937
1938 break; 1932 break;
1939 default: 1933 default:
1940 break; 1934 break;
@@ -1943,18 +1937,20 @@ static int sctp_process_unk_param(const struct sctp_association *asoc,
1943 return retval; 1937 return retval;
1944} 1938}
1945 1939
1946/* Find unrecognized parameters in the chunk. 1940/* Verify variable length parameters
1947 * Return values: 1941 * Return values:
1948 * 0 - discard the chunk 1942 * SCTP_IERROR_ABORT - trigger an ABORT
1949 * 1 - continue with the chunk 1943 * SCTP_IERROR_NOMEM - out of memory (abort)
1944 * SCTP_IERROR_ERROR - stop processing, trigger an ERROR
1945 * SCTP_IERROR_NO_ERROR - continue with the chunk
1950 */ 1946 */
1951static int sctp_verify_param(const struct sctp_association *asoc, 1947static sctp_ierror_t sctp_verify_param(const struct sctp_association *asoc,
1952 union sctp_params param, 1948 union sctp_params param,
1953 sctp_cid_t cid, 1949 sctp_cid_t cid,
1954 struct sctp_chunk *chunk, 1950 struct sctp_chunk *chunk,
1955 struct sctp_chunk **err_chunk) 1951 struct sctp_chunk **err_chunk)
1956{ 1952{
1957 int retval = 1; 1953 int retval = SCTP_IERROR_NO_ERROR;
1958 1954
1959 /* FIXME - This routine is not looking at each parameter per the 1955 /* FIXME - This routine is not looking at each parameter per the
1960 * chunk type, i.e., unrecognized parameters should be further 1956 * chunk type, i.e., unrecognized parameters should be further
@@ -1976,7 +1972,9 @@ static int sctp_verify_param(const struct sctp_association *asoc,
1976 1972
1977 case SCTP_PARAM_HOST_NAME_ADDRESS: 1973 case SCTP_PARAM_HOST_NAME_ADDRESS:
1978 /* Tell the peer, we won't support this param. */ 1974 /* Tell the peer, we won't support this param. */
1979 return sctp_process_hn_param(asoc, param, chunk, err_chunk); 1975 sctp_process_hn_param(asoc, param, chunk, err_chunk);
1976 retval = SCTP_IERROR_ABORT;
1977 break;
1980 1978
1981 case SCTP_PARAM_FWD_TSN_SUPPORT: 1979 case SCTP_PARAM_FWD_TSN_SUPPORT:
1982 if (sctp_prsctp_enable) 1980 if (sctp_prsctp_enable)
@@ -1993,9 +1991,11 @@ static int sctp_verify_param(const struct sctp_association *asoc,
1993 * cause 'Protocol Violation'. 1991 * cause 'Protocol Violation'.
1994 */ 1992 */
1995 if (SCTP_AUTH_RANDOM_LENGTH != 1993 if (SCTP_AUTH_RANDOM_LENGTH !=
1996 ntohs(param.p->length) - sizeof(sctp_paramhdr_t)) 1994 ntohs(param.p->length) - sizeof(sctp_paramhdr_t)) {
1997 return sctp_process_inv_paramlength(asoc, param.p, 1995 sctp_process_inv_paramlength(asoc, param.p,
1998 chunk, err_chunk); 1996 chunk, err_chunk);
1997 retval = SCTP_IERROR_ABORT;
1998 }
1999 break; 1999 break;
2000 2000
2001 case SCTP_PARAM_CHUNKS: 2001 case SCTP_PARAM_CHUNKS:
@@ -2007,9 +2007,11 @@ static int sctp_verify_param(const struct sctp_association *asoc,
2007 * INIT-ACK chunk if the sender wants to receive authenticated 2007 * INIT-ACK chunk if the sender wants to receive authenticated
2008 * chunks. Its maximum length is 260 bytes. 2008 * chunks. Its maximum length is 260 bytes.
2009 */ 2009 */
2010 if (260 < ntohs(param.p->length)) 2010 if (260 < ntohs(param.p->length)) {
2011 return sctp_process_inv_paramlength(asoc, param.p, 2011 sctp_process_inv_paramlength(asoc, param.p,
2012 chunk, err_chunk); 2012 chunk, err_chunk);
2013 retval = SCTP_IERROR_ABORT;
2014 }
2013 break; 2015 break;
2014 2016
2015 case SCTP_PARAM_HMAC_ALGO: 2017 case SCTP_PARAM_HMAC_ALGO:
@@ -2020,8 +2022,7 @@ fallthrough:
2020 default: 2022 default:
2021 SCTP_DEBUG_PRINTK("Unrecognized param: %d for chunk %d.\n", 2023 SCTP_DEBUG_PRINTK("Unrecognized param: %d for chunk %d.\n",
2022 ntohs(param.p->type), cid); 2024 ntohs(param.p->type), cid);
2023 return sctp_process_unk_param(asoc, param, chunk, err_chunk); 2025 retval = sctp_process_unk_param(asoc, param, chunk, err_chunk);
2024
2025 break; 2026 break;
2026 } 2027 }
2027 return retval; 2028 return retval;
@@ -2036,6 +2037,7 @@ int sctp_verify_init(const struct sctp_association *asoc,
2036{ 2037{
2037 union sctp_params param; 2038 union sctp_params param;
2038 int has_cookie = 0; 2039 int has_cookie = 0;
2040 int result;
2039 2041
2040 /* Verify stream values are non-zero. */ 2042 /* Verify stream values are non-zero. */
2041 if ((0 == peer_init->init_hdr.num_outbound_streams) || 2043 if ((0 == peer_init->init_hdr.num_outbound_streams) ||
@@ -2043,8 +2045,7 @@ int sctp_verify_init(const struct sctp_association *asoc,
2043 (0 == peer_init->init_hdr.init_tag) || 2045 (0 == peer_init->init_hdr.init_tag) ||
2044 (SCTP_DEFAULT_MINWINDOW > ntohl(peer_init->init_hdr.a_rwnd))) { 2046 (SCTP_DEFAULT_MINWINDOW > ntohl(peer_init->init_hdr.a_rwnd))) {
2045 2047
2046 sctp_process_inv_mandatory(asoc, chunk, errp); 2048 return sctp_process_inv_mandatory(asoc, chunk, errp);
2047 return 0;
2048 } 2049 }
2049 2050
2050 /* Check for missing mandatory parameters. */ 2051 /* Check for missing mandatory parameters. */
@@ -2062,29 +2063,29 @@ int sctp_verify_init(const struct sctp_association *asoc,
2062 * VIOLATION error. We build the ERROR chunk here and let the normal 2063 * VIOLATION error. We build the ERROR chunk here and let the normal
2063 * error handling code build and send the packet. 2064 * error handling code build and send the packet.
2064 */ 2065 */
2065 if (param.v != (void*)chunk->chunk_end) { 2066 if (param.v != (void*)chunk->chunk_end)
2066 sctp_process_inv_paramlength(asoc, param.p, chunk, errp); 2067 return sctp_process_inv_paramlength(asoc, param.p, chunk, errp);
2067 return 0;
2068 }
2069 2068
2070 /* The only missing mandatory param possible today is 2069 /* The only missing mandatory param possible today is
2071 * the state cookie for an INIT-ACK chunk. 2070 * the state cookie for an INIT-ACK chunk.
2072 */ 2071 */
2073 if ((SCTP_CID_INIT_ACK == cid) && !has_cookie) { 2072 if ((SCTP_CID_INIT_ACK == cid) && !has_cookie)
2074 sctp_process_missing_param(asoc, SCTP_PARAM_STATE_COOKIE, 2073 return sctp_process_missing_param(asoc, SCTP_PARAM_STATE_COOKIE,
2075 chunk, errp); 2074 chunk, errp);
2076 return 0;
2077 }
2078
2079 /* Find unrecognized parameters. */
2080 2075
2076 /* Verify all the variable length parameters */
2081 sctp_walk_params(param, peer_init, init_hdr.params) { 2077 sctp_walk_params(param, peer_init, init_hdr.params) {
2082 2078
2083 if (!sctp_verify_param(asoc, param, cid, chunk, errp)) { 2079 result = sctp_verify_param(asoc, param, cid, chunk, errp);
2084 if (SCTP_PARAM_HOST_NAME_ADDRESS == param.p->type) 2080 switch (result) {
2081 case SCTP_IERROR_ABORT:
2082 case SCTP_IERROR_NOMEM:
2085 return 0; 2083 return 0;
2086 else 2084 case SCTP_IERROR_ERROR:
2087 return 1; 2085 return 1;
2086 case SCTP_IERROR_NO_ERROR:
2087 default:
2088 break;
2088 } 2089 }
2089 2090
2090 } /* for (loop through all parameters) */ 2091 } /* for (loop through all parameters) */
@@ -2137,11 +2138,14 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
2137 2138
2138 /* If the peer claims support for ADD-IP without support 2139 /* If the peer claims support for ADD-IP without support
2139 * for AUTH, disable support for ADD-IP. 2140 * for AUTH, disable support for ADD-IP.
2141 * Do this only if backward compatible mode is turned off.
2140 */ 2142 */
2141 if (asoc->peer.addip_capable && !asoc->peer.auth_capable) { 2143 if (!sctp_addip_noauth &&
2144 (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) {
2142 asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP | 2145 asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP |
2143 SCTP_PARAM_DEL_IP | 2146 SCTP_PARAM_DEL_IP |
2144 SCTP_PARAM_SET_PRIMARY); 2147 SCTP_PARAM_SET_PRIMARY);
2148 asoc->peer.asconf_capable = 0;
2145 } 2149 }
2146 2150
2147 /* Walk list of transports, removing transports in the UNKNOWN state. */ 2151 /* Walk list of transports, removing transports in the UNKNOWN state. */
@@ -2848,10 +2852,11 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
2848 2852
2849 __be16 err_code; 2853 __be16 err_code;
2850 int length = 0; 2854 int length = 0;
2851 int chunk_len = asconf->skb->len; 2855 int chunk_len;
2852 __u32 serial; 2856 __u32 serial;
2853 int all_param_pass = 1; 2857 int all_param_pass = 1;
2854 2858
2859 chunk_len = ntohs(asconf->chunk_hdr->length) - sizeof(sctp_chunkhdr_t);
2855 hdr = (sctp_addiphdr_t *)asconf->skb->data; 2860 hdr = (sctp_addiphdr_t *)asconf->skb->data;
2856 serial = ntohl(hdr->serial); 2861 serial = ntohl(hdr->serial);
2857 2862
@@ -2952,13 +2957,17 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
2952 /* This is always done in BH context with a socket lock 2957 /* This is always done in BH context with a socket lock
2953 * held, so the list can not change. 2958 * held, so the list can not change.
2954 */ 2959 */
2960 local_bh_disable();
2955 list_for_each_entry(saddr, &bp->address_list, list) { 2961 list_for_each_entry(saddr, &bp->address_list, list) {
2956 if (sctp_cmp_addr_exact(&saddr->a, &addr)) 2962 if (sctp_cmp_addr_exact(&saddr->a, &addr))
2957 saddr->use_as_src = 1; 2963 saddr->use_as_src = 1;
2958 } 2964 }
2965 local_bh_enable();
2959 break; 2966 break;
2960 case SCTP_PARAM_DEL_IP: 2967 case SCTP_PARAM_DEL_IP:
2961 retval = sctp_del_bind_addr(bp, &addr, call_rcu_bh); 2968 local_bh_disable();
2969 retval = sctp_del_bind_addr(bp, &addr);
2970 local_bh_enable();
2962 list_for_each(pos, &asoc->peer.transport_addr_list) { 2971 list_for_each(pos, &asoc->peer.transport_addr_list) {
2963 transport = list_entry(pos, struct sctp_transport, 2972 transport = list_entry(pos, struct sctp_transport,
2964 transports); 2973 transports);
@@ -2990,7 +2999,7 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
2990 sctp_addip_param_t *asconf_ack_param; 2999 sctp_addip_param_t *asconf_ack_param;
2991 sctp_errhdr_t *err_param; 3000 sctp_errhdr_t *err_param;
2992 int length; 3001 int length;
2993 int asconf_ack_len = asconf_ack->skb->len; 3002 int asconf_ack_len;
2994 __be16 err_code; 3003 __be16 err_code;
2995 3004
2996 if (no_err) 3005 if (no_err)
@@ -2998,6 +3007,9 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
2998 else 3007 else
2999 err_code = SCTP_ERROR_REQ_REFUSED; 3008 err_code = SCTP_ERROR_REQ_REFUSED;
3000 3009
3010 asconf_ack_len = ntohs(asconf_ack->chunk_hdr->length) -
3011 sizeof(sctp_chunkhdr_t);
3012
3001 /* Skip the addiphdr from the asconf_ack chunk and store a pointer to 3013 /* Skip the addiphdr from the asconf_ack chunk and store a pointer to
3002 * the first asconf_ack parameter. 3014 * the first asconf_ack parameter.
3003 */ 3015 */
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index bbdc938da86f..78d1a8a49bd0 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -453,6 +453,7 @@ static void sctp_do_8_2_transport_strike(struct sctp_association *asoc,
453 * maximum value discussed in rule C7 above (RTO.max) may be 453 * maximum value discussed in rule C7 above (RTO.max) may be
454 * used to provide an upper bound to this doubling operation. 454 * used to provide an upper bound to this doubling operation.
455 */ 455 */
456 transport->last_rto = transport->rto;
456 transport->rto = min((transport->rto * 2), transport->asoc->rto_max); 457 transport->rto = min((transport->rto * 2), transport->asoc->rto_max);
457} 458}
458 459
@@ -1267,6 +1268,12 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1267 sctp_ootb_pkt_free(packet); 1268 sctp_ootb_pkt_free(packet);
1268 break; 1269 break;
1269 1270
1271 case SCTP_CMD_T1_RETRAN:
1272 /* Mark a transport for retransmission. */
1273 sctp_retransmit(&asoc->outqueue, cmd->obj.transport,
1274 SCTP_RTXR_T1_RTX);
1275 break;
1276
1270 case SCTP_CMD_RETRAN: 1277 case SCTP_CMD_RETRAN:
1271 /* Mark a transport for retransmission. */ 1278 /* Mark a transport for retransmission. */
1272 sctp_retransmit(&asoc->outqueue, cmd->obj.transport, 1279 sctp_retransmit(&asoc->outqueue, cmd->obj.transport,
@@ -1393,7 +1400,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1393 list_for_each(pos, &asoc->peer.transport_addr_list) { 1400 list_for_each(pos, &asoc->peer.transport_addr_list) {
1394 t = list_entry(pos, struct sctp_transport, 1401 t = list_entry(pos, struct sctp_transport,
1395 transports); 1402 transports);
1396 sctp_retransmit_mark(&asoc->outqueue, t, 0); 1403 sctp_retransmit_mark(&asoc->outqueue, t,
1404 SCTP_RTXR_T1_RTX);
1397 } 1405 }
1398 1406
1399 sctp_add_cmd_sf(commands, 1407 sctp_add_cmd_sf(commands,
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index f01b408508ff..5ebbe808d801 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -2305,7 +2305,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep,
2305 /* If we've sent any data bundled with COOKIE-ECHO we will need to 2305 /* If we've sent any data bundled with COOKIE-ECHO we will need to
2306 * resend 2306 * resend
2307 */ 2307 */
2308 sctp_add_cmd_sf(commands, SCTP_CMD_RETRAN, 2308 sctp_add_cmd_sf(commands, SCTP_CMD_T1_RETRAN,
2309 SCTP_TRANSPORT(asoc->peer.primary_path)); 2309 SCTP_TRANSPORT(asoc->peer.primary_path));
2310 2310
2311 /* Cast away the const modifier, as we want to just 2311 /* Cast away the const modifier, as we want to just
@@ -4064,11 +4064,6 @@ static sctp_disposition_t sctp_sf_abort_violation(
4064 struct sctp_chunk *chunk = arg; 4064 struct sctp_chunk *chunk = arg;
4065 struct sctp_chunk *abort = NULL; 4065 struct sctp_chunk *abort = NULL;
4066 4066
4067 /* Make the abort chunk. */
4068 abort = sctp_make_abort_violation(asoc, chunk, payload, paylen);
4069 if (!abort)
4070 goto nomem;
4071
4072 /* SCTP-AUTH, Section 6.3: 4067 /* SCTP-AUTH, Section 6.3:
4073 * It should be noted that if the receiver wants to tear 4068 * It should be noted that if the receiver wants to tear
4074 * down an association in an authenticated way only, the 4069 * down an association in an authenticated way only, the
@@ -4083,6 +4078,11 @@ static sctp_disposition_t sctp_sf_abort_violation(
4083 if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) 4078 if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc))
4084 goto discard; 4079 goto discard;
4085 4080
4081 /* Make the abort chunk. */
4082 abort = sctp_make_abort_violation(asoc, chunk, payload, paylen);
4083 if (!abort)
4084 goto nomem;
4085
4086 if (asoc) { 4086 if (asoc) {
4087 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); 4087 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort));
4088 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 4088 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index bd6f42a15a4b..ff8bc95670ed 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -660,7 +660,7 @@ static int sctp_bindx_rem(struct sock *sk, struct sockaddr *addrs, int addrcnt)
660 * socket routing and failover schemes. Refer to comments in 660 * socket routing and failover schemes. Refer to comments in
661 * sctp_do_bind(). -daisy 661 * sctp_do_bind(). -daisy
662 */ 662 */
663 retval = sctp_del_bind_addr(bp, sa_addr, call_rcu); 663 retval = sctp_del_bind_addr(bp, sa_addr);
664 664
665 addr_buf += af->sockaddr_len; 665 addr_buf += af->sockaddr_len;
666err_bindx_rem: 666err_bindx_rem:
@@ -5307,6 +5307,7 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
5307{ 5307{
5308 struct sctp_bind_hashbucket *head; /* hash list */ 5308 struct sctp_bind_hashbucket *head; /* hash list */
5309 struct sctp_bind_bucket *pp; /* hash list port iterator */ 5309 struct sctp_bind_bucket *pp; /* hash list port iterator */
5310 struct hlist_node *node;
5310 unsigned short snum; 5311 unsigned short snum;
5311 int ret; 5312 int ret;
5312 5313
@@ -5331,7 +5332,7 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
5331 index = sctp_phashfn(rover); 5332 index = sctp_phashfn(rover);
5332 head = &sctp_port_hashtable[index]; 5333 head = &sctp_port_hashtable[index];
5333 sctp_spin_lock(&head->lock); 5334 sctp_spin_lock(&head->lock);
5334 for (pp = head->chain; pp; pp = pp->next) 5335 sctp_for_each_hentry(pp, node, &head->chain)
5335 if (pp->port == rover) 5336 if (pp->port == rover)
5336 goto next; 5337 goto next;
5337 break; 5338 break;
@@ -5358,7 +5359,7 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
5358 */ 5359 */
5359 head = &sctp_port_hashtable[sctp_phashfn(snum)]; 5360 head = &sctp_port_hashtable[sctp_phashfn(snum)];
5360 sctp_spin_lock(&head->lock); 5361 sctp_spin_lock(&head->lock);
5361 for (pp = head->chain; pp; pp = pp->next) { 5362 sctp_for_each_hentry(pp, node, &head->chain) {
5362 if (pp->port == snum) 5363 if (pp->port == snum)
5363 goto pp_found; 5364 goto pp_found;
5364 } 5365 }
@@ -5702,10 +5703,7 @@ static struct sctp_bind_bucket *sctp_bucket_create(
5702 pp->port = snum; 5703 pp->port = snum;
5703 pp->fastreuse = 0; 5704 pp->fastreuse = 0;
5704 INIT_HLIST_HEAD(&pp->owner); 5705 INIT_HLIST_HEAD(&pp->owner);
5705 if ((pp->next = head->chain) != NULL) 5706 hlist_add_head(&pp->node, &head->chain);
5706 pp->next->pprev = &pp->next;
5707 head->chain = pp;
5708 pp->pprev = &head->chain;
5709 } 5707 }
5710 return pp; 5708 return pp;
5711} 5709}
@@ -5714,9 +5712,7 @@ static struct sctp_bind_bucket *sctp_bucket_create(
5714static void sctp_bucket_destroy(struct sctp_bind_bucket *pp) 5712static void sctp_bucket_destroy(struct sctp_bind_bucket *pp)
5715{ 5713{
5716 if (pp && hlist_empty(&pp->owner)) { 5714 if (pp && hlist_empty(&pp->owner)) {
5717 if (pp->next) 5715 __hlist_del(&pp->node);
5718 pp->next->pprev = pp->pprev;
5719 *(pp->pprev) = pp->next;
5720 kmem_cache_free(sctp_bucket_cachep, pp); 5716 kmem_cache_free(sctp_bucket_cachep, pp);
5721 SCTP_DBG_OBJCNT_DEC(bind_bucket); 5717 SCTP_DBG_OBJCNT_DEC(bind_bucket);
5722 } 5718 }
@@ -6455,6 +6451,8 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
6455} 6451}
6456 6452
6457 6453
6454DEFINE_PROTO_INUSE(sctp)
6455
6458/* This proto struct describes the ULP interface for SCTP. */ 6456/* This proto struct describes the ULP interface for SCTP. */
6459struct proto sctp_prot = { 6457struct proto sctp_prot = {
6460 .name = "SCTP", 6458 .name = "SCTP",
@@ -6483,9 +6481,12 @@ struct proto sctp_prot = {
6483 .memory_pressure = &sctp_memory_pressure, 6481 .memory_pressure = &sctp_memory_pressure,
6484 .enter_memory_pressure = sctp_enter_memory_pressure, 6482 .enter_memory_pressure = sctp_enter_memory_pressure,
6485 .memory_allocated = &sctp_memory_allocated, 6483 .memory_allocated = &sctp_memory_allocated,
6484 REF_PROTO_INUSE(sctp)
6486}; 6485};
6487 6486
6488#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 6487#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
6488DEFINE_PROTO_INUSE(sctpv6)
6489
6489struct proto sctpv6_prot = { 6490struct proto sctpv6_prot = {
6490 .name = "SCTPv6", 6491 .name = "SCTPv6",
6491 .owner = THIS_MODULE, 6492 .owner = THIS_MODULE,
@@ -6513,5 +6514,6 @@ struct proto sctpv6_prot = {
6513 .memory_pressure = &sctp_memory_pressure, 6514 .memory_pressure = &sctp_memory_pressure,
6514 .enter_memory_pressure = sctp_enter_memory_pressure, 6515 .enter_memory_pressure = sctp_enter_memory_pressure,
6515 .memory_allocated = &sctp_memory_allocated, 6516 .memory_allocated = &sctp_memory_allocated,
6517 REF_PROTO_INUSE(sctpv6)
6516}; 6518};
6517#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ 6519#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 0669778e4335..da4f15734fb1 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -263,6 +263,15 @@ static ctl_table sctp_table[] = {
263 .proc_handler = &proc_dointvec, 263 .proc_handler = &proc_dointvec,
264 .strategy = &sysctl_intvec 264 .strategy = &sysctl_intvec
265 }, 265 },
266 {
267 .ctl_name = CTL_UNNUMBERED,
268 .procname = "addip_noauth_enable",
269 .data = &sctp_addip_noauth,
270 .maxlen = sizeof(int),
271 .mode = 0644,
272 .proc_handler = &proc_dointvec,
273 .strategy = &sysctl_intvec
274 },
266 { .ctl_name = 0 } 275 { .ctl_name = 0 }
267}; 276};
268 277
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 5f467c914f80..d55ce83a020b 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -74,8 +74,8 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
74 * given destination transport address, set RTO to the protocol 74 * given destination transport address, set RTO to the protocol
75 * parameter 'RTO.Initial'. 75 * parameter 'RTO.Initial'.
76 */ 76 */
77 peer->last_rto = peer->rto = msecs_to_jiffies(sctp_rto_initial);
77 peer->rtt = 0; 78 peer->rtt = 0;
78 peer->rto = msecs_to_jiffies(sctp_rto_initial);
79 peer->rttvar = 0; 79 peer->rttvar = 0;
80 peer->srtt = 0; 80 peer->srtt = 0;
81 peer->rto_pending = 0; 81 peer->rto_pending = 0;
@@ -385,6 +385,7 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
385 tp->rto = tp->asoc->rto_max; 385 tp->rto = tp->asoc->rto_max;
386 386
387 tp->rtt = rtt; 387 tp->rtt = rtt;
388 tp->last_rto = tp->rto;
388 389
389 /* Reset rto_pending so that a new RTT measurement is started when a 390 /* Reset rto_pending so that a new RTT measurement is started when a
390 * new data chunk is sent. 391 * new data chunk is sent.
@@ -578,7 +579,7 @@ void sctp_transport_reset(struct sctp_transport *t)
578 */ 579 */
579 t->cwnd = min(4*asoc->pathmtu, max_t(__u32, 2*asoc->pathmtu, 4380)); 580 t->cwnd = min(4*asoc->pathmtu, max_t(__u32, 2*asoc->pathmtu, 4380));
580 t->ssthresh = asoc->peer.i.a_rwnd; 581 t->ssthresh = asoc->peer.i.a_rwnd;
581 t->rto = asoc->rto_initial; 582 t->last_rto = t->rto = asoc->rto_initial;
582 t->rtt = 0; 583 t->rtt = 0;
583 t->srtt = 0; 584 t->srtt = 0;
584 t->rttvar = 0; 585 t->rttvar = 0;
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 4be92d0a2cab..4908041ffb31 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -862,7 +862,7 @@ static inline void sctp_ulpq_reap_ordered(struct sctp_ulpq *ulpq, __u16 sid)
862 continue; 862 continue;
863 863
864 /* see if this ssn has been marked by skipping */ 864 /* see if this ssn has been marked by skipping */
865 if (!SSN_lt(cssn, sctp_ssn_peek(in, csid))) 865 if (!SSN_lte(cssn, sctp_ssn_peek(in, csid)))
866 break; 866 break;
867 867
868 __skb_unlink(pos, &ulpq->lobby); 868 __skb_unlink(pos, &ulpq->lobby);
diff --git a/net/socket.c b/net/socket.c
index 5d879fd3d01d..74784dfe8e5b 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2319,6 +2319,11 @@ int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg)
2319 return err; 2319 return err;
2320} 2320}
2321 2321
2322int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how)
2323{
2324 return sock->ops->shutdown(sock, how);
2325}
2326
2322/* ABI emulation layers need these two */ 2327/* ABI emulation layers need these two */
2323EXPORT_SYMBOL(move_addr_to_kernel); 2328EXPORT_SYMBOL(move_addr_to_kernel);
2324EXPORT_SYMBOL(move_addr_to_user); 2329EXPORT_SYMBOL(move_addr_to_user);
@@ -2345,3 +2350,4 @@ EXPORT_SYMBOL(kernel_getsockopt);
2345EXPORT_SYMBOL(kernel_setsockopt); 2350EXPORT_SYMBOL(kernel_setsockopt);
2346EXPORT_SYMBOL(kernel_sendpage); 2351EXPORT_SYMBOL(kernel_sendpage);
2347EXPORT_SYMBOL(kernel_sock_ioctl); 2352EXPORT_SYMBOL(kernel_sock_ioctl);
2353EXPORT_SYMBOL(kernel_sock_shutdown);
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index dc55cc974c90..1afeb3eb8e4c 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -320,9 +320,9 @@ xprt_setup_rdma(struct xprt_create *args)
320 xprt->slot = kcalloc(xprt->max_reqs, 320 xprt->slot = kcalloc(xprt->max_reqs,
321 sizeof(struct rpc_rqst), GFP_KERNEL); 321 sizeof(struct rpc_rqst), GFP_KERNEL);
322 if (xprt->slot == NULL) { 322 if (xprt->slot == NULL) {
323 kfree(xprt);
324 dprintk("RPC: %s: couldn't allocate %d slots\n", 323 dprintk("RPC: %s: couldn't allocate %d slots\n",
325 __func__, xprt->max_reqs); 324 __func__, xprt->max_reqs);
325 kfree(xprt);
326 return ERR_PTR(-ENOMEM); 326 return ERR_PTR(-ENOMEM);
327 } 327 }
328 328
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 515e7a692f9b..e835da8fc091 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -457,7 +457,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
457 * What the above comment does talk about? --ANK(980817) 457 * What the above comment does talk about? --ANK(980817)
458 */ 458 */
459 459
460 if (atomic_read(&unix_tot_inflight)) 460 if (unix_tot_inflight)
461 unix_gc(); /* Garbage collect fds */ 461 unix_gc(); /* Garbage collect fds */
462 462
463 return 0; 463 return 0;
@@ -599,15 +599,14 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
599 struct sock *sk = NULL; 599 struct sock *sk = NULL;
600 struct unix_sock *u; 600 struct unix_sock *u;
601 601
602 if (atomic_read(&unix_nr_socks) >= 2*get_max_files()) 602 atomic_inc(&unix_nr_socks);
603 if (atomic_read(&unix_nr_socks) > 2 * get_max_files())
603 goto out; 604 goto out;
604 605
605 sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto); 606 sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto);
606 if (!sk) 607 if (!sk)
607 goto out; 608 goto out;
608 609
609 atomic_inc(&unix_nr_socks);
610
611 sock_init_data(sock,sk); 610 sock_init_data(sock,sk);
612 lockdep_set_class(&sk->sk_receive_queue.lock, 611 lockdep_set_class(&sk->sk_receive_queue.lock,
613 &af_unix_sk_receive_queue_lock_key); 612 &af_unix_sk_receive_queue_lock_key);
@@ -625,6 +624,8 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
625 init_waitqueue_head(&u->peer_wait); 624 init_waitqueue_head(&u->peer_wait);
626 unix_insert_socket(unix_sockets_unbound, sk); 625 unix_insert_socket(unix_sockets_unbound, sk);
627out: 626out:
627 if (sk == NULL)
628 atomic_dec(&unix_nr_socks);
628 return sk; 629 return sk;
629} 630}
630 631
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 406b6433e467..ebdff3d877a1 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -92,7 +92,7 @@ static LIST_HEAD(gc_inflight_list);
92static LIST_HEAD(gc_candidates); 92static LIST_HEAD(gc_candidates);
93static DEFINE_SPINLOCK(unix_gc_lock); 93static DEFINE_SPINLOCK(unix_gc_lock);
94 94
95atomic_t unix_tot_inflight = ATOMIC_INIT(0); 95unsigned int unix_tot_inflight;
96 96
97 97
98static struct sock *unix_get_socket(struct file *filp) 98static struct sock *unix_get_socket(struct file *filp)
@@ -133,7 +133,7 @@ void unix_inflight(struct file *fp)
133 } else { 133 } else {
134 BUG_ON(list_empty(&u->link)); 134 BUG_ON(list_empty(&u->link));
135 } 135 }
136 atomic_inc(&unix_tot_inflight); 136 unix_tot_inflight++;
137 spin_unlock(&unix_gc_lock); 137 spin_unlock(&unix_gc_lock);
138 } 138 }
139} 139}
@@ -147,7 +147,7 @@ void unix_notinflight(struct file *fp)
147 BUG_ON(list_empty(&u->link)); 147 BUG_ON(list_empty(&u->link));
148 if (atomic_dec_and_test(&u->inflight)) 148 if (atomic_dec_and_test(&u->inflight))
149 list_del_init(&u->link); 149 list_del_init(&u->link);
150 atomic_dec(&unix_tot_inflight); 150 unix_tot_inflight--;
151 spin_unlock(&unix_gc_lock); 151 spin_unlock(&unix_gc_lock);
152 } 152 }
153} 153}
@@ -161,7 +161,7 @@ static inline struct sk_buff *sock_queue_head(struct sock *sk)
161 for (skb = sock_queue_head(sk)->next, next = skb->next; \ 161 for (skb = sock_queue_head(sk)->next, next = skb->next; \
162 skb != sock_queue_head(sk); skb = next, next = skb->next) 162 skb != sock_queue_head(sk); skb = next, next = skb->next)
163 163
164static void scan_inflight(struct sock *x, void (*func)(struct sock *), 164static void scan_inflight(struct sock *x, void (*func)(struct unix_sock *),
165 struct sk_buff_head *hitlist) 165 struct sk_buff_head *hitlist)
166{ 166{
167 struct sk_buff *skb; 167 struct sk_buff *skb;
@@ -185,9 +185,9 @@ static void scan_inflight(struct sock *x, void (*func)(struct sock *),
185 * if it indeed does so 185 * if it indeed does so
186 */ 186 */
187 struct sock *sk = unix_get_socket(*fp++); 187 struct sock *sk = unix_get_socket(*fp++);
188 if(sk) { 188 if (sk) {
189 hit = true; 189 hit = true;
190 func(sk); 190 func(unix_sk(sk));
191 } 191 }
192 } 192 }
193 if (hit && hitlist != NULL) { 193 if (hit && hitlist != NULL) {
@@ -199,7 +199,7 @@ static void scan_inflight(struct sock *x, void (*func)(struct sock *),
199 spin_unlock(&x->sk_receive_queue.lock); 199 spin_unlock(&x->sk_receive_queue.lock);
200} 200}
201 201
202static void scan_children(struct sock *x, void (*func)(struct sock *), 202static void scan_children(struct sock *x, void (*func)(struct unix_sock *),
203 struct sk_buff_head *hitlist) 203 struct sk_buff_head *hitlist)
204{ 204{
205 if (x->sk_state != TCP_LISTEN) 205 if (x->sk_state != TCP_LISTEN)
@@ -235,20 +235,18 @@ static void scan_children(struct sock *x, void (*func)(struct sock *),
235 } 235 }
236} 236}
237 237
238static void dec_inflight(struct sock *sk) 238static void dec_inflight(struct unix_sock *usk)
239{ 239{
240 atomic_dec(&unix_sk(sk)->inflight); 240 atomic_dec(&usk->inflight);
241} 241}
242 242
243static void inc_inflight(struct sock *sk) 243static void inc_inflight(struct unix_sock *usk)
244{ 244{
245 atomic_inc(&unix_sk(sk)->inflight); 245 atomic_inc(&usk->inflight);
246} 246}
247 247
248static void inc_inflight_move_tail(struct sock *sk) 248static void inc_inflight_move_tail(struct unix_sock *u)
249{ 249{
250 struct unix_sock *u = unix_sk(sk);
251
252 atomic_inc(&u->inflight); 250 atomic_inc(&u->inflight);
253 /* 251 /*
254 * If this is still a candidate, move it to the end of the 252 * If this is still a candidate, move it to the end of the