aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-04-03 18:49:14 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-03 18:49:14 -0400
commit87e8b821ed8db3dab03d96cd542e29666bf210aa (patch)
tree0027060473aafbbb125655ba027319c8a1a665fc /net
parent33cd9dfa3a13e3d8e41aef225a9f98169816723b (diff)
parent5e11611a5d22252f3f9c169a3c9377eac0c32033 (diff)
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Diffstat (limited to 'net')
-rw-r--r--net/8021q/vlan.c2
-rw-r--r--net/8021q/vlan_core.c4
-rw-r--r--net/8021q/vlan_dev.c71
-rw-r--r--net/9p/client.c114
-rw-r--r--net/9p/protocol.c74
-rw-r--r--net/9p/protocol.h6
-rw-r--r--net/9p/trans_virtio.c142
-rw-r--r--net/bluetooth/hci_sysfs.c44
-rw-r--r--net/bluetooth/l2cap.c46
-rw-r--r--net/bluetooth/rfcomm/core.c39
-rw-r--r--net/bluetooth/rfcomm/sock.c36
-rw-r--r--net/bluetooth/sco.c36
-rw-r--r--net/bridge/Kconfig1
-rw-r--r--net/bridge/br_device.c2
-rw-r--r--net/bridge/br_forward.c18
-rw-r--r--net/bridge/br_input.c4
-rw-r--r--net/bridge/br_multicast.c37
-rw-r--r--net/bridge/br_private.h12
-rw-r--r--net/bridge/br_sysfs_if.c2
-rw-r--r--net/core/dev.c8
-rw-r--r--net/core/dev_mcast.c5
-rw-r--r--net/core/ethtool.c103
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/netpoll.c11
-rw-r--r--net/core/sock.c19
-rw-r--r--net/dccp/ipv4.c8
-rw-r--r--net/dccp/ipv6.c8
-rw-r--r--net/dccp/minisocks.c2
-rw-r--r--net/dccp/proto.c16
-rw-r--r--net/ipv4/devinet.c2
-rw-r--r--net/ipv4/fib_trie.c4
-rw-r--r--net/ipv4/ip_gre.c11
-rw-r--r--net/ipv4/ipconfig.c57
-rw-r--r--net/ipv4/ipmr.c14
-rw-r--r--net/ipv4/proc.c2
-rw-r--r--net/ipv4/route.c104
-rw-r--r--net/ipv4/tcp.c65
-rw-r--r--net/ipv4/tcp_input.c3
-rw-r--r--net/ipv4/tcp_ipv4.c20
-rw-r--r--net/ipv4/tcp_minisocks.c2
-rw-r--r--net/ipv4/tcp_output.c18
-rw-r--r--net/ipv4/tcp_timer.c2
-rw-r--r--net/ipv4/udp.c6
-rw-r--r--net/ipv4/xfrm4_policy.c5
-rw-r--r--net/ipv6/addrconf.c106
-rw-r--r--net/ipv6/fib6_rules.c11
-rw-r--r--net/ipv6/ip6mr.c14
-rw-r--r--net/ipv6/netfilter/ip6table_raw.c2
-rw-r--r--net/ipv6/route.c26
-rw-r--r--net/ipv6/tcp_ipv6.c7
-rw-r--r--net/ipv6/udp.c28
-rw-r--r--net/ipv6/xfrm6_policy.c3
-rw-r--r--net/key/af_key.c8
-rw-r--r--net/llc/llc_c_ac.c2
-rw-r--r--net/llc/llc_conn.c3
-rw-r--r--net/mac80211/debugfs_netdev.c10
-rw-r--r--net/mac80211/mesh_plink.c2
-rw-r--r--net/mac80211/mlme.c32
-rw-r--r--net/mac80211/rate.h5
-rw-r--r--net/mac80211/sta_info.c1
-rw-r--r--net/netfilter/nf_conntrack_netlink.c4
-rw-r--r--net/netfilter/nf_conntrack_sip.c4
-rw-r--r--net/netfilter/nfnetlink.c4
-rw-r--r--net/netfilter/xt_hashlimit.c6
-rw-r--r--net/netfilter/xt_recent.c2
-rw-r--r--net/netlink/af_netlink.c17
-rw-r--r--net/packet/af_packet.c6
-rw-r--r--net/phonet/pn_dev.c3
-rw-r--r--net/phonet/pn_netlink.c3
-rw-r--r--net/rfkill/input.c8
-rw-r--r--net/rxrpc/ar-accept.c6
-rw-r--r--net/sched/Kconfig5
-rw-r--r--net/sched/cls_cgroup.c36
-rw-r--r--net/sctp/input.c42
-rw-r--r--net/sctp/sm_sideeffect.c2
-rw-r--r--net/sctp/socket.c3
-rw-r--r--net/socket.c4
-rw-r--r--net/sunrpc/addr.c8
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c16
-rw-r--r--net/sunrpc/bc_svc.c15
-rw-r--r--net/sunrpc/clnt.c1
-rw-r--r--net/sunrpc/rpc_pipe.c11
-rw-r--r--net/sunrpc/svc.c6
-rw-r--r--net/sunrpc/svc_xprt.c27
-rw-r--r--net/sunrpc/svcauth_unix.c49
-rw-r--r--net/sunrpc/svcsock.c3
-rw-r--r--net/sunrpc/xprt.c22
-rw-r--r--net/sunrpc/xprtrdma/transport.c7
-rw-r--r--net/sunrpc/xprtsock.c29
-rw-r--r--net/tipc/bearer.c37
-rw-r--r--net/tipc/bearer.h2
-rw-r--r--net/tipc/link.c9
-rw-r--r--net/tipc/net.c25
-rw-r--r--net/tipc/ref.c26
-rw-r--r--net/tipc/socket.c6
-rw-r--r--net/tipc/subscr.c57
-rw-r--r--net/tipc/subscr.h2
-rw-r--r--net/x25/x25_dev.c2
-rw-r--r--net/xfrm/xfrm_policy.c7
99 files changed, 1255 insertions, 714 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 453512266ea..db783d7af5a 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -378,6 +378,8 @@ static void vlan_transfer_features(struct net_device *dev,
378#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) 378#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
379 vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid; 379 vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid;
380#endif 380#endif
381 vlandev->real_num_tx_queues = dev->real_num_tx_queues;
382 BUG_ON(vlandev->real_num_tx_queues > vlandev->num_tx_queues);
381 383
382 if (old_features != vlandev->features) 384 if (old_features != vlandev->features)
383 netdev_features_change(vlandev); 385 netdev_features_change(vlandev);
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index c0316e0ca6e..c584a0af77d 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -11,7 +11,7 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
11 if (netpoll_rx(skb)) 11 if (netpoll_rx(skb))
12 return NET_RX_DROP; 12 return NET_RX_DROP;
13 13
14 if (skb_bond_should_drop(skb)) 14 if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
15 goto drop; 15 goto drop;
16 16
17 skb->skb_iif = skb->dev->ifindex; 17 skb->skb_iif = skb->dev->ifindex;
@@ -83,7 +83,7 @@ vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp,
83{ 83{
84 struct sk_buff *p; 84 struct sk_buff *p;
85 85
86 if (skb_bond_should_drop(skb)) 86 if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
87 goto drop; 87 goto drop;
88 88
89 skb->skb_iif = skb->dev->ifindex; 89 skb->skb_iif = skb->dev->ifindex;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 9e83272fc5b..2fd057c81bb 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -361,6 +361,14 @@ static netdev_tx_t vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
361 return ret; 361 return ret;
362} 362}
363 363
364static u16 vlan_dev_select_queue(struct net_device *dev, struct sk_buff *skb)
365{
366 struct net_device *rdev = vlan_dev_info(dev)->real_dev;
367 const struct net_device_ops *ops = rdev->netdev_ops;
368
369 return ops->ndo_select_queue(rdev, skb);
370}
371
364static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu) 372static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
365{ 373{
366 /* TODO: gotta make sure the underlying layer can handle it, 374 /* TODO: gotta make sure the underlying layer can handle it,
@@ -688,7 +696,8 @@ static const struct header_ops vlan_header_ops = {
688 .parse = eth_header_parse, 696 .parse = eth_header_parse,
689}; 697};
690 698
691static const struct net_device_ops vlan_netdev_ops, vlan_netdev_accel_ops; 699static const struct net_device_ops vlan_netdev_ops, vlan_netdev_accel_ops,
700 vlan_netdev_ops_sq, vlan_netdev_accel_ops_sq;
692 701
693static int vlan_dev_init(struct net_device *dev) 702static int vlan_dev_init(struct net_device *dev)
694{ 703{
@@ -722,11 +731,17 @@ static int vlan_dev_init(struct net_device *dev)
722 if (real_dev->features & NETIF_F_HW_VLAN_TX) { 731 if (real_dev->features & NETIF_F_HW_VLAN_TX) {
723 dev->header_ops = real_dev->header_ops; 732 dev->header_ops = real_dev->header_ops;
724 dev->hard_header_len = real_dev->hard_header_len; 733 dev->hard_header_len = real_dev->hard_header_len;
725 dev->netdev_ops = &vlan_netdev_accel_ops; 734 if (real_dev->netdev_ops->ndo_select_queue)
735 dev->netdev_ops = &vlan_netdev_accel_ops_sq;
736 else
737 dev->netdev_ops = &vlan_netdev_accel_ops;
726 } else { 738 } else {
727 dev->header_ops = &vlan_header_ops; 739 dev->header_ops = &vlan_header_ops;
728 dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN; 740 dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
729 dev->netdev_ops = &vlan_netdev_ops; 741 if (real_dev->netdev_ops->ndo_select_queue)
742 dev->netdev_ops = &vlan_netdev_ops_sq;
743 else
744 dev->netdev_ops = &vlan_netdev_ops;
730 } 745 }
731 746
732 if (is_vlan_dev(real_dev)) 747 if (is_vlan_dev(real_dev))
@@ -865,6 +880,56 @@ static const struct net_device_ops vlan_netdev_accel_ops = {
865#endif 880#endif
866}; 881};
867 882
883static const struct net_device_ops vlan_netdev_ops_sq = {
884 .ndo_select_queue = vlan_dev_select_queue,
885 .ndo_change_mtu = vlan_dev_change_mtu,
886 .ndo_init = vlan_dev_init,
887 .ndo_uninit = vlan_dev_uninit,
888 .ndo_open = vlan_dev_open,
889 .ndo_stop = vlan_dev_stop,
890 .ndo_start_xmit = vlan_dev_hard_start_xmit,
891 .ndo_validate_addr = eth_validate_addr,
892 .ndo_set_mac_address = vlan_dev_set_mac_address,
893 .ndo_set_rx_mode = vlan_dev_set_rx_mode,
894 .ndo_set_multicast_list = vlan_dev_set_rx_mode,
895 .ndo_change_rx_flags = vlan_dev_change_rx_flags,
896 .ndo_do_ioctl = vlan_dev_ioctl,
897 .ndo_neigh_setup = vlan_dev_neigh_setup,
898 .ndo_get_stats = vlan_dev_get_stats,
899#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
900 .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
901 .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
902 .ndo_fcoe_enable = vlan_dev_fcoe_enable,
903 .ndo_fcoe_disable = vlan_dev_fcoe_disable,
904 .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn,
905#endif
906};
907
908static const struct net_device_ops vlan_netdev_accel_ops_sq = {
909 .ndo_select_queue = vlan_dev_select_queue,
910 .ndo_change_mtu = vlan_dev_change_mtu,
911 .ndo_init = vlan_dev_init,
912 .ndo_uninit = vlan_dev_uninit,
913 .ndo_open = vlan_dev_open,
914 .ndo_stop = vlan_dev_stop,
915 .ndo_start_xmit = vlan_dev_hwaccel_hard_start_xmit,
916 .ndo_validate_addr = eth_validate_addr,
917 .ndo_set_mac_address = vlan_dev_set_mac_address,
918 .ndo_set_rx_mode = vlan_dev_set_rx_mode,
919 .ndo_set_multicast_list = vlan_dev_set_rx_mode,
920 .ndo_change_rx_flags = vlan_dev_change_rx_flags,
921 .ndo_do_ioctl = vlan_dev_ioctl,
922 .ndo_neigh_setup = vlan_dev_neigh_setup,
923 .ndo_get_stats = vlan_dev_get_stats,
924#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
925 .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
926 .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
927 .ndo_fcoe_enable = vlan_dev_fcoe_enable,
928 .ndo_fcoe_disable = vlan_dev_fcoe_disable,
929 .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn,
930#endif
931};
932
868void vlan_setup(struct net_device *dev) 933void vlan_setup(struct net_device *dev)
869{ 934{
870 ether_setup(dev); 935 ether_setup(dev);
diff --git a/net/9p/client.c b/net/9p/client.c
index 09d4f1e2e4a..e3e5bf4469c 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -46,6 +46,7 @@ enum {
46 Opt_msize, 46 Opt_msize,
47 Opt_trans, 47 Opt_trans,
48 Opt_legacy, 48 Opt_legacy,
49 Opt_version,
49 Opt_err, 50 Opt_err,
50}; 51};
51 52
@@ -53,9 +54,42 @@ static const match_table_t tokens = {
53 {Opt_msize, "msize=%u"}, 54 {Opt_msize, "msize=%u"},
54 {Opt_legacy, "noextend"}, 55 {Opt_legacy, "noextend"},
55 {Opt_trans, "trans=%s"}, 56 {Opt_trans, "trans=%s"},
57 {Opt_version, "version=%s"},
56 {Opt_err, NULL}, 58 {Opt_err, NULL},
57}; 59};
58 60
61inline int p9_is_proto_dotl(struct p9_client *clnt)
62{
63 return (clnt->proto_version == p9_proto_2000L);
64}
65EXPORT_SYMBOL(p9_is_proto_dotl);
66
67inline int p9_is_proto_dotu(struct p9_client *clnt)
68{
69 return (clnt->proto_version == p9_proto_2000u);
70}
71EXPORT_SYMBOL(p9_is_proto_dotu);
72
73/* Interpret mount option for protocol version */
74static unsigned char get_protocol_version(const substring_t *name)
75{
76 unsigned char version = -EINVAL;
77 if (!strncmp("9p2000", name->from, name->to-name->from)) {
78 version = p9_proto_legacy;
79 P9_DPRINTK(P9_DEBUG_9P, "Protocol version: Legacy\n");
80 } else if (!strncmp("9p2000.u", name->from, name->to-name->from)) {
81 version = p9_proto_2000u;
82 P9_DPRINTK(P9_DEBUG_9P, "Protocol version: 9P2000.u\n");
83 } else if (!strncmp("9p2000.L", name->from, name->to-name->from)) {
84 version = p9_proto_2000L;
85 P9_DPRINTK(P9_DEBUG_9P, "Protocol version: 9P2000.L\n");
86 } else {
87 P9_DPRINTK(P9_DEBUG_ERROR, "Unknown protocol version %s. ",
88 name->from);
89 }
90 return version;
91}
92
59static struct p9_req_t * 93static struct p9_req_t *
60p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...); 94p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...);
61 95
@@ -75,7 +109,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
75 int option; 109 int option;
76 int ret = 0; 110 int ret = 0;
77 111
78 clnt->dotu = 1; 112 clnt->proto_version = p9_proto_2000u;
79 clnt->msize = 8192; 113 clnt->msize = 8192;
80 114
81 if (!opts) 115 if (!opts)
@@ -118,7 +152,13 @@ static int parse_opts(char *opts, struct p9_client *clnt)
118 } 152 }
119 break; 153 break;
120 case Opt_legacy: 154 case Opt_legacy:
121 clnt->dotu = 0; 155 clnt->proto_version = p9_proto_legacy;
156 break;
157 case Opt_version:
158 ret = get_protocol_version(&args[0]);
159 if (ret == -EINVAL)
160 goto free_and_return;
161 clnt->proto_version = ret;
122 break; 162 break;
123 default: 163 default:
124 continue; 164 continue;
@@ -410,14 +450,15 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
410 int ecode; 450 int ecode;
411 char *ename; 451 char *ename;
412 452
413 err = p9pdu_readf(req->rc, c->dotu, "s?d", &ename, &ecode); 453 err = p9pdu_readf(req->rc, c->proto_version, "s?d",
454 &ename, &ecode);
414 if (err) { 455 if (err) {
415 P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse error%d\n", 456 P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse error%d\n",
416 err); 457 err);
417 return err; 458 return err;
418 } 459 }
419 460
420 if (c->dotu) 461 if (p9_is_proto_dotu(c))
421 err = -ecode; 462 err = -ecode;
422 463
423 if (!err || !IS_ERR_VALUE(err)) 464 if (!err || !IS_ERR_VALUE(err))
@@ -515,7 +556,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
515 /* marshall the data */ 556 /* marshall the data */
516 p9pdu_prepare(req->tc, tag, type); 557 p9pdu_prepare(req->tc, tag, type);
517 va_start(ap, fmt); 558 va_start(ap, fmt);
518 err = p9pdu_vwritef(req->tc, c->dotu, fmt, ap); 559 err = p9pdu_vwritef(req->tc, c->proto_version, fmt, ap);
519 va_end(ap); 560 va_end(ap);
520 p9pdu_finalize(req->tc); 561 p9pdu_finalize(req->tc);
521 562
@@ -627,14 +668,31 @@ int p9_client_version(struct p9_client *c)
627 char *version; 668 char *version;
628 int msize; 669 int msize;
629 670
630 P9_DPRINTK(P9_DEBUG_9P, ">>> TVERSION msize %d extended %d\n", 671 P9_DPRINTK(P9_DEBUG_9P, ">>> TVERSION msize %d protocol %d\n",
631 c->msize, c->dotu); 672 c->msize, c->proto_version);
632 req = p9_client_rpc(c, P9_TVERSION, "ds", c->msize, 673
633 c->dotu ? "9P2000.u" : "9P2000"); 674 switch (c->proto_version) {
675 case p9_proto_2000L:
676 req = p9_client_rpc(c, P9_TVERSION, "ds",
677 c->msize, "9P2000.L");
678 break;
679 case p9_proto_2000u:
680 req = p9_client_rpc(c, P9_TVERSION, "ds",
681 c->msize, "9P2000.u");
682 break;
683 case p9_proto_legacy:
684 req = p9_client_rpc(c, P9_TVERSION, "ds",
685 c->msize, "9P2000");
686 break;
687 default:
688 return -EINVAL;
689 break;
690 }
691
634 if (IS_ERR(req)) 692 if (IS_ERR(req))
635 return PTR_ERR(req); 693 return PTR_ERR(req);
636 694
637 err = p9pdu_readf(req->rc, c->dotu, "ds", &msize, &version); 695 err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version);
638 if (err) { 696 if (err) {
639 P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); 697 P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err);
640 p9pdu_dump(1, req->rc); 698 p9pdu_dump(1, req->rc);
@@ -642,10 +700,12 @@ int p9_client_version(struct p9_client *c)
642 } 700 }
643 701
644 P9_DPRINTK(P9_DEBUG_9P, "<<< RVERSION msize %d %s\n", msize, version); 702 P9_DPRINTK(P9_DEBUG_9P, "<<< RVERSION msize %d %s\n", msize, version);
645 if (!memcmp(version, "9P2000.u", 8)) 703 if (!strncmp(version, "9P2000.L", 8))
646 c->dotu = 1; 704 c->proto_version = p9_proto_2000L;
647 else if (!memcmp(version, "9P2000", 6)) 705 else if (!strncmp(version, "9P2000.u", 8))
648 c->dotu = 0; 706 c->proto_version = p9_proto_2000u;
707 else if (!strncmp(version, "9P2000", 6))
708 c->proto_version = p9_proto_legacy;
649 else { 709 else {
650 err = -EREMOTEIO; 710 err = -EREMOTEIO;
651 goto error; 711 goto error;
@@ -700,8 +760,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
700 goto put_trans; 760 goto put_trans;
701 } 761 }
702 762
703 P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", 763 P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d protocol %d\n",
704 clnt, clnt->trans_mod, clnt->msize, clnt->dotu); 764 clnt, clnt->trans_mod, clnt->msize, clnt->proto_version);
705 765
706 err = clnt->trans_mod->create(clnt, dev_name, options); 766 err = clnt->trans_mod->create(clnt, dev_name, options);
707 if (err) 767 if (err)
@@ -784,7 +844,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
784 goto error; 844 goto error;
785 } 845 }
786 846
787 err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); 847 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
788 if (err) { 848 if (err) {
789 p9pdu_dump(1, req->rc); 849 p9pdu_dump(1, req->rc);
790 p9_free_req(clnt, req); 850 p9_free_req(clnt, req);
@@ -833,7 +893,7 @@ p9_client_auth(struct p9_client *clnt, char *uname, u32 n_uname, char *aname)
833 goto error; 893 goto error;
834 } 894 }
835 895
836 err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); 896 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
837 if (err) { 897 if (err) {
838 p9pdu_dump(1, req->rc); 898 p9pdu_dump(1, req->rc);
839 p9_free_req(clnt, req); 899 p9_free_req(clnt, req);
@@ -891,7 +951,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames,
891 goto error; 951 goto error;
892 } 952 }
893 953
894 err = p9pdu_readf(req->rc, clnt->dotu, "R", &nwqids, &wqids); 954 err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids);
895 if (err) { 955 if (err) {
896 p9pdu_dump(1, req->rc); 956 p9pdu_dump(1, req->rc);
897 p9_free_req(clnt, req); 957 p9_free_req(clnt, req);
@@ -952,7 +1012,7 @@ int p9_client_open(struct p9_fid *fid, int mode)
952 goto error; 1012 goto error;
953 } 1013 }
954 1014
955 err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); 1015 err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit);
956 if (err) { 1016 if (err) {
957 p9pdu_dump(1, req->rc); 1017 p9pdu_dump(1, req->rc);
958 goto free_and_error; 1018 goto free_and_error;
@@ -997,7 +1057,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
997 goto error; 1057 goto error;
998 } 1058 }
999 1059
1000 err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); 1060 err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit);
1001 if (err) { 1061 if (err) {
1002 p9pdu_dump(1, req->rc); 1062 p9pdu_dump(1, req->rc);
1003 goto free_and_error; 1063 goto free_and_error;
@@ -1098,7 +1158,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
1098 goto error; 1158 goto error;
1099 } 1159 }
1100 1160
1101 err = p9pdu_readf(req->rc, clnt->dotu, "D", &count, &dataptr); 1161 err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr);
1102 if (err) { 1162 if (err) {
1103 p9pdu_dump(1, req->rc); 1163 p9pdu_dump(1, req->rc);
1104 goto free_and_error; 1164 goto free_and_error;
@@ -1159,7 +1219,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
1159 goto error; 1219 goto error;
1160 } 1220 }
1161 1221
1162 err = p9pdu_readf(req->rc, clnt->dotu, "d", &count); 1222 err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count);
1163 if (err) { 1223 if (err) {
1164 p9pdu_dump(1, req->rc); 1224 p9pdu_dump(1, req->rc);
1165 goto free_and_error; 1225 goto free_and_error;
@@ -1199,7 +1259,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
1199 goto error; 1259 goto error;
1200 } 1260 }
1201 1261
1202 err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret); 1262 err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret);
1203 if (err) { 1263 if (err) {
1204 p9pdu_dump(1, req->rc); 1264 p9pdu_dump(1, req->rc);
1205 p9_free_req(clnt, req); 1265 p9_free_req(clnt, req);
@@ -1226,7 +1286,7 @@ error:
1226} 1286}
1227EXPORT_SYMBOL(p9_client_stat); 1287EXPORT_SYMBOL(p9_client_stat);
1228 1288
1229static int p9_client_statsize(struct p9_wstat *wst, int optional) 1289static int p9_client_statsize(struct p9_wstat *wst, int proto_version)
1230{ 1290{
1231 int ret; 1291 int ret;
1232 1292
@@ -1245,7 +1305,7 @@ static int p9_client_statsize(struct p9_wstat *wst, int optional)
1245 if (wst->muid) 1305 if (wst->muid)
1246 ret += strlen(wst->muid); 1306 ret += strlen(wst->muid);
1247 1307
1248 if (optional) { 1308 if (proto_version == p9_proto_2000u) {
1249 ret += 2+4+4+4; /* extension[s] n_uid[4] n_gid[4] n_muid[4] */ 1309 ret += 2+4+4+4; /* extension[s] n_uid[4] n_gid[4] n_muid[4] */
1250 if (wst->extension) 1310 if (wst->extension)
1251 ret += strlen(wst->extension); 1311 ret += strlen(wst->extension);
@@ -1262,7 +1322,7 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst)
1262 1322
1263 err = 0; 1323 err = 0;
1264 clnt = fid->clnt; 1324 clnt = fid->clnt;
1265 wst->size = p9_client_statsize(wst, clnt->dotu); 1325 wst->size = p9_client_statsize(wst, clnt->proto_version);
1266 P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid); 1326 P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid);
1267 P9_DPRINTK(P9_DEBUG_9P, 1327 P9_DPRINTK(P9_DEBUG_9P,
1268 " sz=%x type=%x dev=%x qid=%x.%llx.%x\n" 1328 " sz=%x type=%x dev=%x qid=%x.%llx.%x\n"
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index fc70147c771..94f5a8f65e9 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -52,7 +52,7 @@
52#endif 52#endif
53 53
54static int 54static int
55p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...); 55p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
56 56
57#ifdef CONFIG_NET_9P_DEBUG 57#ifdef CONFIG_NET_9P_DEBUG
58void 58void
@@ -144,7 +144,8 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size)
144*/ 144*/
145 145
146static int 146static int
147p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) 147p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
148 va_list ap)
148{ 149{
149 const char *ptr; 150 const char *ptr;
150 int errcode = 0; 151 int errcode = 0;
@@ -194,7 +195,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
194 int16_t len; 195 int16_t len;
195 int size; 196 int size;
196 197
197 errcode = p9pdu_readf(pdu, optional, "w", &len); 198 errcode = p9pdu_readf(pdu, proto_version,
199 "w", &len);
198 if (errcode) 200 if (errcode)
199 break; 201 break;
200 202
@@ -217,7 +219,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
217 struct p9_qid *qid = 219 struct p9_qid *qid =
218 va_arg(ap, struct p9_qid *); 220 va_arg(ap, struct p9_qid *);
219 221
220 errcode = p9pdu_readf(pdu, optional, "bdq", 222 errcode = p9pdu_readf(pdu, proto_version, "bdq",
221 &qid->type, &qid->version, 223 &qid->type, &qid->version,
222 &qid->path); 224 &qid->path);
223 } 225 }
@@ -230,7 +232,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
230 stbuf->n_uid = stbuf->n_gid = stbuf->n_muid = 232 stbuf->n_uid = stbuf->n_gid = stbuf->n_muid =
231 -1; 233 -1;
232 errcode = 234 errcode =
233 p9pdu_readf(pdu, optional, 235 p9pdu_readf(pdu, proto_version,
234 "wwdQdddqssss?sddd", 236 "wwdQdddqssss?sddd",
235 &stbuf->size, &stbuf->type, 237 &stbuf->size, &stbuf->type,
236 &stbuf->dev, &stbuf->qid, 238 &stbuf->dev, &stbuf->qid,
@@ -250,7 +252,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
250 void **data = va_arg(ap, void **); 252 void **data = va_arg(ap, void **);
251 253
252 errcode = 254 errcode =
253 p9pdu_readf(pdu, optional, "d", count); 255 p9pdu_readf(pdu, proto_version, "d", count);
254 if (!errcode) { 256 if (!errcode) {
255 *count = 257 *count =
256 MIN(*count, 258 MIN(*count,
@@ -263,8 +265,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
263 int16_t *nwname = va_arg(ap, int16_t *); 265 int16_t *nwname = va_arg(ap, int16_t *);
264 char ***wnames = va_arg(ap, char ***); 266 char ***wnames = va_arg(ap, char ***);
265 267
266 errcode = 268 errcode = p9pdu_readf(pdu, proto_version,
267 p9pdu_readf(pdu, optional, "w", nwname); 269 "w", nwname);
268 if (!errcode) { 270 if (!errcode) {
269 *wnames = 271 *wnames =
270 kmalloc(sizeof(char *) * *nwname, 272 kmalloc(sizeof(char *) * *nwname,
@@ -278,7 +280,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
278 280
279 for (i = 0; i < *nwname; i++) { 281 for (i = 0; i < *nwname; i++) {
280 errcode = 282 errcode =
281 p9pdu_readf(pdu, optional, 283 p9pdu_readf(pdu,
284 proto_version,
282 "s", 285 "s",
283 &(*wnames)[i]); 286 &(*wnames)[i]);
284 if (errcode) 287 if (errcode)
@@ -306,7 +309,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
306 *wqids = NULL; 309 *wqids = NULL;
307 310
308 errcode = 311 errcode =
309 p9pdu_readf(pdu, optional, "w", nwqid); 312 p9pdu_readf(pdu, proto_version, "w", nwqid);
310 if (!errcode) { 313 if (!errcode) {
311 *wqids = 314 *wqids =
312 kmalloc(*nwqid * 315 kmalloc(*nwqid *
@@ -321,7 +324,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
321 324
322 for (i = 0; i < *nwqid; i++) { 325 for (i = 0; i < *nwqid; i++) {
323 errcode = 326 errcode =
324 p9pdu_readf(pdu, optional, 327 p9pdu_readf(pdu,
328 proto_version,
325 "Q", 329 "Q",
326 &(*wqids)[i]); 330 &(*wqids)[i]);
327 if (errcode) 331 if (errcode)
@@ -336,7 +340,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
336 } 340 }
337 break; 341 break;
338 case '?': 342 case '?':
339 if (!optional) 343 if (proto_version != p9_proto_2000u)
340 return 0; 344 return 0;
341 break; 345 break;
342 default: 346 default:
@@ -352,7 +356,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
352} 356}
353 357
354int 358int
355p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) 359p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
360 va_list ap)
356{ 361{
357 const char *ptr; 362 const char *ptr;
358 int errcode = 0; 363 int errcode = 0;
@@ -389,7 +394,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
389 if (sptr) 394 if (sptr)
390 len = MIN(strlen(sptr), USHORT_MAX); 395 len = MIN(strlen(sptr), USHORT_MAX);
391 396
392 errcode = p9pdu_writef(pdu, optional, "w", len); 397 errcode = p9pdu_writef(pdu, proto_version,
398 "w", len);
393 if (!errcode && pdu_write(pdu, sptr, len)) 399 if (!errcode && pdu_write(pdu, sptr, len))
394 errcode = -EFAULT; 400 errcode = -EFAULT;
395 } 401 }
@@ -398,7 +404,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
398 const struct p9_qid *qid = 404 const struct p9_qid *qid =
399 va_arg(ap, const struct p9_qid *); 405 va_arg(ap, const struct p9_qid *);
400 errcode = 406 errcode =
401 p9pdu_writef(pdu, optional, "bdq", 407 p9pdu_writef(pdu, proto_version, "bdq",
402 qid->type, qid->version, 408 qid->type, qid->version,
403 qid->path); 409 qid->path);
404 } break; 410 } break;
@@ -406,7 +412,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
406 const struct p9_wstat *stbuf = 412 const struct p9_wstat *stbuf =
407 va_arg(ap, const struct p9_wstat *); 413 va_arg(ap, const struct p9_wstat *);
408 errcode = 414 errcode =
409 p9pdu_writef(pdu, optional, 415 p9pdu_writef(pdu, proto_version,
410 "wwdQdddqssss?sddd", 416 "wwdQdddqssss?sddd",
411 stbuf->size, stbuf->type, 417 stbuf->size, stbuf->type,
412 stbuf->dev, &stbuf->qid, 418 stbuf->dev, &stbuf->qid,
@@ -421,8 +427,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
421 int32_t count = va_arg(ap, int32_t); 427 int32_t count = va_arg(ap, int32_t);
422 const void *data = va_arg(ap, const void *); 428 const void *data = va_arg(ap, const void *);
423 429
424 errcode = 430 errcode = p9pdu_writef(pdu, proto_version, "d",
425 p9pdu_writef(pdu, optional, "d", count); 431 count);
426 if (!errcode && pdu_write(pdu, data, count)) 432 if (!errcode && pdu_write(pdu, data, count))
427 errcode = -EFAULT; 433 errcode = -EFAULT;
428 } 434 }
@@ -431,8 +437,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
431 int32_t count = va_arg(ap, int32_t); 437 int32_t count = va_arg(ap, int32_t);
432 const char __user *udata = 438 const char __user *udata =
433 va_arg(ap, const void __user *); 439 va_arg(ap, const void __user *);
434 errcode = 440 errcode = p9pdu_writef(pdu, proto_version, "d",
435 p9pdu_writef(pdu, optional, "d", count); 441 count);
436 if (!errcode && pdu_write_u(pdu, udata, count)) 442 if (!errcode && pdu_write_u(pdu, udata, count))
437 errcode = -EFAULT; 443 errcode = -EFAULT;
438 } 444 }
@@ -441,14 +447,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
441 int16_t nwname = va_arg(ap, int); 447 int16_t nwname = va_arg(ap, int);
442 const char **wnames = va_arg(ap, const char **); 448 const char **wnames = va_arg(ap, const char **);
443 449
444 errcode = 450 errcode = p9pdu_writef(pdu, proto_version, "w",
445 p9pdu_writef(pdu, optional, "w", nwname); 451 nwname);
446 if (!errcode) { 452 if (!errcode) {
447 int i; 453 int i;
448 454
449 for (i = 0; i < nwname; i++) { 455 for (i = 0; i < nwname; i++) {
450 errcode = 456 errcode =
451 p9pdu_writef(pdu, optional, 457 p9pdu_writef(pdu,
458 proto_version,
452 "s", 459 "s",
453 wnames[i]); 460 wnames[i]);
454 if (errcode) 461 if (errcode)
@@ -462,14 +469,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
462 struct p9_qid *wqids = 469 struct p9_qid *wqids =
463 va_arg(ap, struct p9_qid *); 470 va_arg(ap, struct p9_qid *);
464 471
465 errcode = 472 errcode = p9pdu_writef(pdu, proto_version, "w",
466 p9pdu_writef(pdu, optional, "w", nwqid); 473 nwqid);
467 if (!errcode) { 474 if (!errcode) {
468 int i; 475 int i;
469 476
470 for (i = 0; i < nwqid; i++) { 477 for (i = 0; i < nwqid; i++) {
471 errcode = 478 errcode =
472 p9pdu_writef(pdu, optional, 479 p9pdu_writef(pdu,
480 proto_version,
473 "Q", 481 "Q",
474 &wqids[i]); 482 &wqids[i]);
475 if (errcode) 483 if (errcode)
@@ -479,7 +487,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
479 } 487 }
480 break; 488 break;
481 case '?': 489 case '?':
482 if (!optional) 490 if (proto_version != p9_proto_2000u)
483 return 0; 491 return 0;
484 break; 492 break;
485 default: 493 default:
@@ -494,32 +502,32 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
494 return errcode; 502 return errcode;
495} 503}
496 504
497int p9pdu_readf(struct p9_fcall *pdu, int optional, const char *fmt, ...) 505int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...)
498{ 506{
499 va_list ap; 507 va_list ap;
500 int ret; 508 int ret;
501 509
502 va_start(ap, fmt); 510 va_start(ap, fmt);
503 ret = p9pdu_vreadf(pdu, optional, fmt, ap); 511 ret = p9pdu_vreadf(pdu, proto_version, fmt, ap);
504 va_end(ap); 512 va_end(ap);
505 513
506 return ret; 514 return ret;
507} 515}
508 516
509static int 517static int
510p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...) 518p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...)
511{ 519{
512 va_list ap; 520 va_list ap;
513 int ret; 521 int ret;
514 522
515 va_start(ap, fmt); 523 va_start(ap, fmt);
516 ret = p9pdu_vwritef(pdu, optional, fmt, ap); 524 ret = p9pdu_vwritef(pdu, proto_version, fmt, ap);
517 va_end(ap); 525 va_end(ap);
518 526
519 return ret; 527 return ret;
520} 528}
521 529
522int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) 530int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version)
523{ 531{
524 struct p9_fcall fake_pdu; 532 struct p9_fcall fake_pdu;
525 int ret; 533 int ret;
@@ -529,7 +537,7 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu)
529 fake_pdu.sdata = buf; 537 fake_pdu.sdata = buf;
530 fake_pdu.offset = 0; 538 fake_pdu.offset = 0;
531 539
532 ret = p9pdu_readf(&fake_pdu, dotu, "S", st); 540 ret = p9pdu_readf(&fake_pdu, proto_version, "S", st);
533 if (ret) { 541 if (ret) {
534 P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); 542 P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret);
535 p9pdu_dump(1, &fake_pdu); 543 p9pdu_dump(1, &fake_pdu);
diff --git a/net/9p/protocol.h b/net/9p/protocol.h
index ccde462e7ac..2431c0f38d5 100644
--- a/net/9p/protocol.h
+++ b/net/9p/protocol.h
@@ -25,9 +25,9 @@
25 * 25 *
26 */ 26 */
27 27
28int 28int p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
29p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap); 29 va_list ap);
30int p9pdu_readf(struct p9_fcall *pdu, int optional, const char *fmt, ...); 30int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
31int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type); 31int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type);
32int p9pdu_finalize(struct p9_fcall *pdu); 32int p9pdu_finalize(struct p9_fcall *pdu);
33void p9pdu_dump(int, struct p9_fcall *); 33void p9pdu_dump(int, struct p9_fcall *);
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index cb50f4ae5ee..afde1a89fbb 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -49,8 +49,6 @@
49 49
50/* a single mutex to manage channel initialization and attachment */ 50/* a single mutex to manage channel initialization and attachment */
51static DEFINE_MUTEX(virtio_9p_lock); 51static DEFINE_MUTEX(virtio_9p_lock);
52/* global which tracks highest initialized channel */
53static int chan_index;
54 52
55/** 53/**
56 * struct virtio_chan - per-instance transport information 54 * struct virtio_chan - per-instance transport information
@@ -68,8 +66,7 @@ static int chan_index;
68 * 66 *
69 */ 67 */
70 68
71static struct virtio_chan { 69struct virtio_chan {
72 bool initialized;
73 bool inuse; 70 bool inuse;
74 71
75 spinlock_t lock; 72 spinlock_t lock;
@@ -80,7 +77,17 @@ static struct virtio_chan {
80 77
81 /* Scatterlist: can be too big for stack. */ 78 /* Scatterlist: can be too big for stack. */
82 struct scatterlist sg[VIRTQUEUE_NUM]; 79 struct scatterlist sg[VIRTQUEUE_NUM];
83} channels[MAX_9P_CHAN]; 80
81 int tag_len;
82 /*
83 * tag name to identify a mount Non-null terminated
84 */
85 char *tag;
86
87 struct list_head chan_list;
88};
89
90static struct list_head virtio_chan_list;
84 91
85/* How many bytes left in this page. */ 92/* How many bytes left in this page. */
86static unsigned int rest_of_page(void *data) 93static unsigned int rest_of_page(void *data)
@@ -213,30 +220,38 @@ p9_virtio_request(struct p9_client *client, struct p9_req_t *req)
213 return 0; 220 return 0;
214} 221}
215 222
223static ssize_t p9_mount_tag_show(struct device *dev,
224 struct device_attribute *attr, char *buf)
225{
226 struct virtio_chan *chan;
227 struct virtio_device *vdev;
228
229 vdev = dev_to_virtio(dev);
230 chan = vdev->priv;
231
232 return snprintf(buf, chan->tag_len + 1, "%s", chan->tag);
233}
234
235static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL);
236
216/** 237/**
217 * p9_virtio_probe - probe for existence of 9P virtio channels 238 * p9_virtio_probe - probe for existence of 9P virtio channels
218 * @vdev: virtio device to probe 239 * @vdev: virtio device to probe
219 * 240 *
220 * This probes for existing virtio channels. At present only 241 * This probes for existing virtio channels.
221 * a single channel is in use, so in the future more work may need
222 * to be done here.
223 * 242 *
224 */ 243 */
225 244
226static int p9_virtio_probe(struct virtio_device *vdev) 245static int p9_virtio_probe(struct virtio_device *vdev)
227{ 246{
247 __u16 tag_len;
248 char *tag;
228 int err; 249 int err;
229 struct virtio_chan *chan; 250 struct virtio_chan *chan;
230 int index;
231 251
232 mutex_lock(&virtio_9p_lock); 252 chan = kmalloc(sizeof(struct virtio_chan), GFP_KERNEL);
233 index = chan_index++; 253 if (!chan) {
234 chan = &channels[index]; 254 printk(KERN_ERR "9p: Failed to allocate virtio 9P channel\n");
235 mutex_unlock(&virtio_9p_lock);
236
237 if (chan_index > MAX_9P_CHAN) {
238 printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n");
239 BUG();
240 err = -ENOMEM; 255 err = -ENOMEM;
241 goto fail; 256 goto fail;
242 } 257 }
@@ -255,15 +270,37 @@ static int p9_virtio_probe(struct virtio_device *vdev)
255 sg_init_table(chan->sg, VIRTQUEUE_NUM); 270 sg_init_table(chan->sg, VIRTQUEUE_NUM);
256 271
257 chan->inuse = false; 272 chan->inuse = false;
258 chan->initialized = true; 273 if (virtio_has_feature(vdev, VIRTIO_9P_MOUNT_TAG)) {
274 vdev->config->get(vdev,
275 offsetof(struct virtio_9p_config, tag_len),
276 &tag_len, sizeof(tag_len));
277 } else {
278 err = -EINVAL;
279 goto out_free_vq;
280 }
281 tag = kmalloc(tag_len, GFP_KERNEL);
282 if (!tag) {
283 err = -ENOMEM;
284 goto out_free_vq;
285 }
286 vdev->config->get(vdev, offsetof(struct virtio_9p_config, tag),
287 tag, tag_len);
288 chan->tag = tag;
289 chan->tag_len = tag_len;
290 err = sysfs_create_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr);
291 if (err) {
292 kfree(tag);
293 goto out_free_vq;
294 }
295 mutex_lock(&virtio_9p_lock);
296 list_add_tail(&chan->chan_list, &virtio_chan_list);
297 mutex_unlock(&virtio_9p_lock);
259 return 0; 298 return 0;
260 299
261out_free_vq: 300out_free_vq:
262 vdev->config->del_vqs(vdev); 301 vdev->config->del_vqs(vdev);
302 kfree(chan);
263fail: 303fail:
264 mutex_lock(&virtio_9p_lock);
265 chan_index--;
266 mutex_unlock(&virtio_9p_lock);
267 return err; 304 return err;
268} 305}
269 306
@@ -280,35 +317,31 @@ fail:
280 * We use a simple reference count mechanism to ensure that only a single 317 * We use a simple reference count mechanism to ensure that only a single
281 * mount has a channel open at a time. 318 * mount has a channel open at a time.
282 * 319 *
283 * Bugs: doesn't allow identification of a specific channel
284 * to allocate, channels are allocated sequentially. This was
285 * a pragmatic decision to get things rolling, but ideally some
286 * way of identifying the channel to attach to would be nice
287 * if we are going to support multiple channels.
288 *
289 */ 320 */
290 321
291static int 322static int
292p9_virtio_create(struct p9_client *client, const char *devname, char *args) 323p9_virtio_create(struct p9_client *client, const char *devname, char *args)
293{ 324{
294 struct virtio_chan *chan = channels; 325 struct virtio_chan *chan;
295 int index = 0; 326 int ret = -ENOENT;
327 int found = 0;
296 328
297 mutex_lock(&virtio_9p_lock); 329 mutex_lock(&virtio_9p_lock);
298 while (index < MAX_9P_CHAN) { 330 list_for_each_entry(chan, &virtio_chan_list, chan_list) {
299 if (chan->initialized && !chan->inuse) { 331 if (!strncmp(devname, chan->tag, chan->tag_len)) {
300 chan->inuse = true; 332 if (!chan->inuse) {
301 break; 333 chan->inuse = true;
302 } else { 334 found = 1;
303 index++; 335 break;
304 chan = &channels[index]; 336 }
337 ret = -EBUSY;
305 } 338 }
306 } 339 }
307 mutex_unlock(&virtio_9p_lock); 340 mutex_unlock(&virtio_9p_lock);
308 341
309 if (index >= MAX_9P_CHAN) { 342 if (!found) {
310 printk(KERN_ERR "9p: no channels available\n"); 343 printk(KERN_ERR "9p: no channels available\n");
311 return -ENODEV; 344 return ret;
312 } 345 }
313 346
314 client->trans = (void *)chan; 347 client->trans = (void *)chan;
@@ -329,11 +362,15 @@ static void p9_virtio_remove(struct virtio_device *vdev)
329 struct virtio_chan *chan = vdev->priv; 362 struct virtio_chan *chan = vdev->priv;
330 363
331 BUG_ON(chan->inuse); 364 BUG_ON(chan->inuse);
365 vdev->config->del_vqs(vdev);
366
367 mutex_lock(&virtio_9p_lock);
368 list_del(&chan->chan_list);
369 mutex_unlock(&virtio_9p_lock);
370 sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr);
371 kfree(chan->tag);
372 kfree(chan);
332 373
333 if (chan->initialized) {
334 vdev->config->del_vqs(vdev);
335 chan->initialized = false;
336 }
337} 374}
338 375
339static struct virtio_device_id id_table[] = { 376static struct virtio_device_id id_table[] = {
@@ -341,13 +378,19 @@ static struct virtio_device_id id_table[] = {
341 { 0 }, 378 { 0 },
342}; 379};
343 380
381static unsigned int features[] = {
382 VIRTIO_9P_MOUNT_TAG,
383};
384
344/* The standard "struct lguest_driver": */ 385/* The standard "struct lguest_driver": */
345static struct virtio_driver p9_virtio_drv = { 386static struct virtio_driver p9_virtio_drv = {
346 .driver.name = KBUILD_MODNAME, 387 .feature_table = features,
347 .driver.owner = THIS_MODULE, 388 .feature_table_size = ARRAY_SIZE(features),
348 .id_table = id_table, 389 .driver.name = KBUILD_MODNAME,
349 .probe = p9_virtio_probe, 390 .driver.owner = THIS_MODULE,
350 .remove = p9_virtio_remove, 391 .id_table = id_table,
392 .probe = p9_virtio_probe,
393 .remove = p9_virtio_remove,
351}; 394};
352 395
353static struct p9_trans_module p9_virtio_trans = { 396static struct p9_trans_module p9_virtio_trans = {
@@ -364,10 +407,7 @@ static struct p9_trans_module p9_virtio_trans = {
364/* The standard init function */ 407/* The standard init function */
365static int __init p9_virtio_init(void) 408static int __init p9_virtio_init(void)
366{ 409{
367 int count; 410 INIT_LIST_HEAD(&virtio_chan_list);
368
369 for (count = 0; count < MAX_9P_CHAN; count++)
370 channels[count].initialized = false;
371 411
372 v9fs_register_trans(&p9_virtio_trans); 412 v9fs_register_trans(&p9_virtio_trans);
373 return register_virtio_driver(&p9_virtio_drv); 413 return register_virtio_driver(&p9_virtio_drv);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 1a79a6c7e30..05fd125f74f 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -3,12 +3,12 @@
3#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <linux/init.h> 4#include <linux/init.h>
5#include <linux/debugfs.h> 5#include <linux/debugfs.h>
6#include <linux/seq_file.h>
6 7
7#include <net/bluetooth/bluetooth.h> 8#include <net/bluetooth/bluetooth.h>
8#include <net/bluetooth/hci_core.h> 9#include <net/bluetooth/hci_core.h>
9 10
10struct class *bt_class = NULL; 11static struct class *bt_class;
11EXPORT_SYMBOL_GPL(bt_class);
12 12
13struct dentry *bt_debugfs = NULL; 13struct dentry *bt_debugfs = NULL;
14EXPORT_SYMBOL_GPL(bt_debugfs); 14EXPORT_SYMBOL_GPL(bt_debugfs);
@@ -405,20 +405,11 @@ static struct device_type bt_host = {
405 .release = bt_host_release, 405 .release = bt_host_release,
406}; 406};
407 407
408static int inquiry_cache_open(struct inode *inode, struct file *file) 408static int inquiry_cache_show(struct seq_file *f, void *p)
409{
410 file->private_data = inode->i_private;
411 return 0;
412}
413
414static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf,
415 size_t count, loff_t *ppos)
416{ 409{
417 struct hci_dev *hdev = file->private_data; 410 struct hci_dev *hdev = f->private;
418 struct inquiry_cache *cache = &hdev->inq_cache; 411 struct inquiry_cache *cache = &hdev->inq_cache;
419 struct inquiry_entry *e; 412 struct inquiry_entry *e;
420 char buf[4096];
421 int n = 0;
422 413
423 hci_dev_lock_bh(hdev); 414 hci_dev_lock_bh(hdev);
424 415
@@ -426,23 +417,30 @@ static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf,
426 struct inquiry_data *data = &e->data; 417 struct inquiry_data *data = &e->data;
427 bdaddr_t bdaddr; 418 bdaddr_t bdaddr;
428 baswap(&bdaddr, &data->bdaddr); 419 baswap(&bdaddr, &data->bdaddr);
429 n += sprintf(buf + n, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", 420 seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
430 batostr(&bdaddr), 421 batostr(&bdaddr),
431 data->pscan_rep_mode, data->pscan_period_mode, 422 data->pscan_rep_mode, data->pscan_period_mode,
432 data->pscan_mode, data->dev_class[2], 423 data->pscan_mode, data->dev_class[2],
433 data->dev_class[1], data->dev_class[0], 424 data->dev_class[1], data->dev_class[0],
434 __le16_to_cpu(data->clock_offset), 425 __le16_to_cpu(data->clock_offset),
435 data->rssi, data->ssp_mode, e->timestamp); 426 data->rssi, data->ssp_mode, e->timestamp);
436 } 427 }
437 428
438 hci_dev_unlock_bh(hdev); 429 hci_dev_unlock_bh(hdev);
439 430
440 return simple_read_from_buffer(userbuf, count, ppos, buf, n); 431 return 0;
432}
433
434static int inquiry_cache_open(struct inode *inode, struct file *file)
435{
436 return single_open(file, inquiry_cache_show, inode->i_private);
441} 437}
442 438
443static const struct file_operations inquiry_cache_fops = { 439static const struct file_operations inquiry_cache_fops = {
444 .open = inquiry_cache_open, 440 .open = inquiry_cache_open,
445 .read = inquiry_cache_read, 441 .read = seq_read,
442 .llseek = seq_lseek,
443 .release = single_release,
446}; 444};
447 445
448int hci_register_sysfs(struct hci_dev *hdev) 446int hci_register_sysfs(struct hci_dev *hdev)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 400efa26ddb..7794a2e2adc 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -40,6 +40,8 @@
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/list.h> 41#include <linux/list.h>
42#include <linux/device.h> 42#include <linux/device.h>
43#include <linux/debugfs.h>
44#include <linux/seq_file.h>
43#include <linux/uaccess.h> 45#include <linux/uaccess.h>
44#include <linux/crc16.h> 46#include <linux/crc16.h>
45#include <net/sock.h> 47#include <net/sock.h>
@@ -2830,6 +2832,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2830 int len = cmd->len - sizeof(*rsp); 2832 int len = cmd->len - sizeof(*rsp);
2831 char req[64]; 2833 char req[64];
2832 2834
2835 if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) {
2836 l2cap_send_disconn_req(conn, sk);
2837 goto done;
2838 }
2839
2833 /* throw out any old stored conf requests */ 2840 /* throw out any old stored conf requests */
2834 result = L2CAP_CONF_SUCCESS; 2841 result = L2CAP_CONF_SUCCESS;
2835 len = l2cap_parse_conf_rsp(sk, rsp->data, 2842 len = l2cap_parse_conf_rsp(sk, rsp->data,
@@ -3937,29 +3944,42 @@ drop:
3937 return 0; 3944 return 0;
3938} 3945}
3939 3946
3940static ssize_t l2cap_sysfs_show(struct class *dev, char *buf) 3947static int l2cap_debugfs_show(struct seq_file *f, void *p)
3941{ 3948{
3942 struct sock *sk; 3949 struct sock *sk;
3943 struct hlist_node *node; 3950 struct hlist_node *node;
3944 char *str = buf;
3945 3951
3946 read_lock_bh(&l2cap_sk_list.lock); 3952 read_lock_bh(&l2cap_sk_list.lock);
3947 3953
3948 sk_for_each(sk, node, &l2cap_sk_list.head) { 3954 sk_for_each(sk, node, &l2cap_sk_list.head) {
3949 struct l2cap_pinfo *pi = l2cap_pi(sk); 3955 struct l2cap_pinfo *pi = l2cap_pi(sk);
3950 3956
3951 str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n", 3957 seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
3952 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 3958 batostr(&bt_sk(sk)->src),
3953 sk->sk_state, __le16_to_cpu(pi->psm), pi->scid, 3959 batostr(&bt_sk(sk)->dst),
3954 pi->dcid, pi->imtu, pi->omtu, pi->sec_level); 3960 sk->sk_state, __le16_to_cpu(pi->psm),
3961 pi->scid, pi->dcid,
3962 pi->imtu, pi->omtu, pi->sec_level);
3955 } 3963 }
3956 3964
3957 read_unlock_bh(&l2cap_sk_list.lock); 3965 read_unlock_bh(&l2cap_sk_list.lock);
3958 3966
3959 return str - buf; 3967 return 0;
3960} 3968}
3961 3969
3962static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); 3970static int l2cap_debugfs_open(struct inode *inode, struct file *file)
3971{
3972 return single_open(file, l2cap_debugfs_show, inode->i_private);
3973}
3974
3975static const struct file_operations l2cap_debugfs_fops = {
3976 .open = l2cap_debugfs_open,
3977 .read = seq_read,
3978 .llseek = seq_lseek,
3979 .release = single_release,
3980};
3981
3982static struct dentry *l2cap_debugfs;
3963 3983
3964static const struct proto_ops l2cap_sock_ops = { 3984static const struct proto_ops l2cap_sock_ops = {
3965 .family = PF_BLUETOOTH, 3985 .family = PF_BLUETOOTH,
@@ -4019,8 +4039,12 @@ static int __init l2cap_init(void)
4019 goto error; 4039 goto error;
4020 } 4040 }
4021 4041
4022 if (class_create_file(bt_class, &class_attr_l2cap) < 0) 4042 if (bt_debugfs) {
4023 BT_ERR("Failed to create L2CAP info file"); 4043 l2cap_debugfs = debugfs_create_file("l2cap", 0444,
4044 bt_debugfs, NULL, &l2cap_debugfs_fops);
4045 if (!l2cap_debugfs)
4046 BT_ERR("Failed to create L2CAP debug file");
4047 }
4024 4048
4025 BT_INFO("L2CAP ver %s", VERSION); 4049 BT_INFO("L2CAP ver %s", VERSION);
4026 BT_INFO("L2CAP socket layer initialized"); 4050 BT_INFO("L2CAP socket layer initialized");
@@ -4034,7 +4058,7 @@ error:
4034 4058
4035static void __exit l2cap_exit(void) 4059static void __exit l2cap_exit(void)
4036{ 4060{
4037 class_remove_file(bt_class, &class_attr_l2cap); 4061 debugfs_remove(l2cap_debugfs);
4038 4062
4039 if (bt_sock_unregister(BTPROTO_L2CAP) < 0) 4063 if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
4040 BT_ERR("L2CAP socket unregistration failed"); 4064 BT_ERR("L2CAP socket unregistration failed");
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 89f4a59eb82..13f114e8b0f 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -33,6 +33,8 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/wait.h> 34#include <linux/wait.h>
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/debugfs.h>
37#include <linux/seq_file.h>
36#include <linux/net.h> 38#include <linux/net.h>
37#include <linux/mutex.h> 39#include <linux/mutex.h>
38#include <linux/kthread.h> 40#include <linux/kthread.h>
@@ -2098,11 +2100,10 @@ static struct hci_cb rfcomm_cb = {
2098 .security_cfm = rfcomm_security_cfm 2100 .security_cfm = rfcomm_security_cfm
2099}; 2101};
2100 2102
2101static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, char *buf) 2103static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
2102{ 2104{
2103 struct rfcomm_session *s; 2105 struct rfcomm_session *s;
2104 struct list_head *pp, *p; 2106 struct list_head *pp, *p;
2105 char *str = buf;
2106 2107
2107 rfcomm_lock(); 2108 rfcomm_lock();
2108 2109
@@ -2112,18 +2113,32 @@ static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, char *buf)
2112 struct sock *sk = s->sock->sk; 2113 struct sock *sk = s->sock->sk;
2113 struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); 2114 struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list);
2114 2115
2115 str += sprintf(str, "%s %s %ld %d %d %d %d\n", 2116 seq_printf(f, "%s %s %ld %d %d %d %d\n",
2116 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 2117 batostr(&bt_sk(sk)->src),
2117 d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits); 2118 batostr(&bt_sk(sk)->dst),
2119 d->state, d->dlci, d->mtu,
2120 d->rx_credits, d->tx_credits);
2118 } 2121 }
2119 } 2122 }
2120 2123
2121 rfcomm_unlock(); 2124 rfcomm_unlock();
2122 2125
2123 return (str - buf); 2126 return 0;
2124} 2127}
2125 2128
2126static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL); 2129static int rfcomm_dlc_debugfs_open(struct inode *inode, struct file *file)
2130{
2131 return single_open(file, rfcomm_dlc_debugfs_show, inode->i_private);
2132}
2133
2134static const struct file_operations rfcomm_dlc_debugfs_fops = {
2135 .open = rfcomm_dlc_debugfs_open,
2136 .read = seq_read,
2137 .llseek = seq_lseek,
2138 .release = single_release,
2139};
2140
2141static struct dentry *rfcomm_dlc_debugfs;
2127 2142
2128/* ---- Initialization ---- */ 2143/* ---- Initialization ---- */
2129static int __init rfcomm_init(void) 2144static int __init rfcomm_init(void)
@@ -2140,8 +2155,12 @@ static int __init rfcomm_init(void)
2140 goto unregister; 2155 goto unregister;
2141 } 2156 }
2142 2157
2143 if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) 2158 if (bt_debugfs) {
2144 BT_ERR("Failed to create RFCOMM info file"); 2159 rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444,
2160 bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops);
2161 if (!rfcomm_dlc_debugfs)
2162 BT_ERR("Failed to create RFCOMM debug file");
2163 }
2145 2164
2146 err = rfcomm_init_ttys(); 2165 err = rfcomm_init_ttys();
2147 if (err < 0) 2166 if (err < 0)
@@ -2169,7 +2188,7 @@ unregister:
2169 2188
2170static void __exit rfcomm_exit(void) 2189static void __exit rfcomm_exit(void)
2171{ 2190{
2172 class_remove_file(bt_class, &class_attr_rfcomm_dlc); 2191 debugfs_remove(rfcomm_dlc_debugfs);
2173 2192
2174 hci_unregister_cb(&rfcomm_cb); 2193 hci_unregister_cb(&rfcomm_cb);
2175 2194
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 4b5968dda67..7f439765403 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -40,6 +40,8 @@
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/list.h> 41#include <linux/list.h>
42#include <linux/device.h> 42#include <linux/device.h>
43#include <linux/debugfs.h>
44#include <linux/seq_file.h>
43#include <net/sock.h> 45#include <net/sock.h>
44 46
45#include <asm/system.h> 47#include <asm/system.h>
@@ -1061,26 +1063,38 @@ done:
1061 return result; 1063 return result;
1062} 1064}
1063 1065
1064static ssize_t rfcomm_sock_sysfs_show(struct class *dev, char *buf) 1066static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
1065{ 1067{
1066 struct sock *sk; 1068 struct sock *sk;
1067 struct hlist_node *node; 1069 struct hlist_node *node;
1068 char *str = buf;
1069 1070
1070 read_lock_bh(&rfcomm_sk_list.lock); 1071 read_lock_bh(&rfcomm_sk_list.lock);
1071 1072
1072 sk_for_each(sk, node, &rfcomm_sk_list.head) { 1073 sk_for_each(sk, node, &rfcomm_sk_list.head) {
1073 str += sprintf(str, "%s %s %d %d\n", 1074 seq_printf(f, "%s %s %d %d\n",
1074 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 1075 batostr(&bt_sk(sk)->src),
1076 batostr(&bt_sk(sk)->dst),
1075 sk->sk_state, rfcomm_pi(sk)->channel); 1077 sk->sk_state, rfcomm_pi(sk)->channel);
1076 } 1078 }
1077 1079
1078 read_unlock_bh(&rfcomm_sk_list.lock); 1080 read_unlock_bh(&rfcomm_sk_list.lock);
1079 1081
1080 return (str - buf); 1082 return 0;
1081} 1083}
1082 1084
1083static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL); 1085static int rfcomm_sock_debugfs_open(struct inode *inode, struct file *file)
1086{
1087 return single_open(file, rfcomm_sock_debugfs_show, inode->i_private);
1088}
1089
1090static const struct file_operations rfcomm_sock_debugfs_fops = {
1091 .open = rfcomm_sock_debugfs_open,
1092 .read = seq_read,
1093 .llseek = seq_lseek,
1094 .release = single_release,
1095};
1096
1097static struct dentry *rfcomm_sock_debugfs;
1084 1098
1085static const struct proto_ops rfcomm_sock_ops = { 1099static const struct proto_ops rfcomm_sock_ops = {
1086 .family = PF_BLUETOOTH, 1100 .family = PF_BLUETOOTH,
@@ -1120,8 +1134,12 @@ int __init rfcomm_init_sockets(void)
1120 if (err < 0) 1134 if (err < 0)
1121 goto error; 1135 goto error;
1122 1136
1123 if (class_create_file(bt_class, &class_attr_rfcomm) < 0) 1137 if (bt_debugfs) {
1124 BT_ERR("Failed to create RFCOMM info file"); 1138 rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444,
1139 bt_debugfs, NULL, &rfcomm_sock_debugfs_fops);
1140 if (!rfcomm_sock_debugfs)
1141 BT_ERR("Failed to create RFCOMM debug file");
1142 }
1125 1143
1126 BT_INFO("RFCOMM socket layer initialized"); 1144 BT_INFO("RFCOMM socket layer initialized");
1127 1145
@@ -1135,7 +1153,7 @@ error:
1135 1153
1136void rfcomm_cleanup_sockets(void) 1154void rfcomm_cleanup_sockets(void)
1137{ 1155{
1138 class_remove_file(bt_class, &class_attr_rfcomm); 1156 debugfs_remove(rfcomm_sock_debugfs);
1139 1157
1140 if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) 1158 if (bt_sock_unregister(BTPROTO_RFCOMM) < 0)
1141 BT_ERR("RFCOMM socket layer unregistration failed"); 1159 BT_ERR("RFCOMM socket layer unregistration failed");
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index dd8f6ec57dc..e5b16b76b22 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -38,6 +38,8 @@
38#include <linux/socket.h> 38#include <linux/socket.h>
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <linux/device.h> 40#include <linux/device.h>
41#include <linux/debugfs.h>
42#include <linux/seq_file.h>
41#include <linux/list.h> 43#include <linux/list.h>
42#include <net/sock.h> 44#include <net/sock.h>
43 45
@@ -953,26 +955,36 @@ drop:
953 return 0; 955 return 0;
954} 956}
955 957
956static ssize_t sco_sysfs_show(struct class *dev, char *buf) 958static int sco_debugfs_show(struct seq_file *f, void *p)
957{ 959{
958 struct sock *sk; 960 struct sock *sk;
959 struct hlist_node *node; 961 struct hlist_node *node;
960 char *str = buf;
961 962
962 read_lock_bh(&sco_sk_list.lock); 963 read_lock_bh(&sco_sk_list.lock);
963 964
964 sk_for_each(sk, node, &sco_sk_list.head) { 965 sk_for_each(sk, node, &sco_sk_list.head) {
965 str += sprintf(str, "%s %s %d\n", 966 seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src),
966 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 967 batostr(&bt_sk(sk)->dst), sk->sk_state);
967 sk->sk_state);
968 } 968 }
969 969
970 read_unlock_bh(&sco_sk_list.lock); 970 read_unlock_bh(&sco_sk_list.lock);
971 971
972 return (str - buf); 972 return 0;
973} 973}
974 974
975static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL); 975static int sco_debugfs_open(struct inode *inode, struct file *file)
976{
977 return single_open(file, sco_debugfs_show, inode->i_private);
978}
979
980static const struct file_operations sco_debugfs_fops = {
981 .open = sco_debugfs_open,
982 .read = seq_read,
983 .llseek = seq_lseek,
984 .release = single_release,
985};
986
987static struct dentry *sco_debugfs;
976 988
977static const struct proto_ops sco_sock_ops = { 989static const struct proto_ops sco_sock_ops = {
978 .family = PF_BLUETOOTH, 990 .family = PF_BLUETOOTH,
@@ -1030,8 +1042,12 @@ static int __init sco_init(void)
1030 goto error; 1042 goto error;
1031 } 1043 }
1032 1044
1033 if (class_create_file(bt_class, &class_attr_sco) < 0) 1045 if (bt_debugfs) {
1034 BT_ERR("Failed to create SCO info file"); 1046 sco_debugfs = debugfs_create_file("sco", 0444,
1047 bt_debugfs, NULL, &sco_debugfs_fops);
1048 if (!sco_debugfs)
1049 BT_ERR("Failed to create SCO debug file");
1050 }
1035 1051
1036 BT_INFO("SCO (Voice Link) ver %s", VERSION); 1052 BT_INFO("SCO (Voice Link) ver %s", VERSION);
1037 BT_INFO("SCO socket layer initialized"); 1053 BT_INFO("SCO socket layer initialized");
@@ -1045,7 +1061,7 @@ error:
1045 1061
1046static void __exit sco_exit(void) 1062static void __exit sco_exit(void)
1047{ 1063{
1048 class_remove_file(bt_class, &class_attr_sco); 1064 debugfs_remove(sco_debugfs);
1049 1065
1050 if (bt_sock_unregister(BTPROTO_SCO) < 0) 1066 if (bt_sock_unregister(BTPROTO_SCO) < 0)
1051 BT_ERR("SCO socket unregistration failed"); 1067 BT_ERR("SCO socket unregistration failed");
diff --git a/net/bridge/Kconfig b/net/bridge/Kconfig
index 19a6b9629c5..d115d5cea5b 100644
--- a/net/bridge/Kconfig
+++ b/net/bridge/Kconfig
@@ -35,6 +35,7 @@ config BRIDGE
35config BRIDGE_IGMP_SNOOPING 35config BRIDGE_IGMP_SNOOPING
36 bool "IGMP snooping" 36 bool "IGMP snooping"
37 depends on BRIDGE 37 depends on BRIDGE
38 depends on INET
38 default y 39 default y
39 ---help--- 40 ---help---
40 If you say Y here, then the Ethernet bridge will be able selectively 41 If you say Y here, then the Ethernet bridge will be able selectively
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index eb7062d2e9e..90a9024e5c1 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -40,7 +40,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
40 goto out; 40 goto out;
41 41
42 mdst = br_mdb_get(br, skb); 42 mdst = br_mdb_get(br, skb);
43 if (mdst || BR_INPUT_SKB_CB(skb)->mrouters_only) 43 if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb))
44 br_multicast_deliver(mdst, skb); 44 br_multicast_deliver(mdst, skb);
45 else 45 else
46 br_flood_deliver(br, skb); 46 br_flood_deliver(br, skb);
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index d61e6f74112..8dbec83e50c 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -19,6 +19,11 @@
19#include <linux/netfilter_bridge.h> 19#include <linux/netfilter_bridge.h>
20#include "br_private.h" 20#include "br_private.h"
21 21
22static int deliver_clone(const struct net_bridge_port *prev,
23 struct sk_buff *skb,
24 void (*__packet_hook)(const struct net_bridge_port *p,
25 struct sk_buff *skb));
26
22/* Don't forward packets to originating port or forwarding diasabled */ 27/* Don't forward packets to originating port or forwarding diasabled */
23static inline int should_deliver(const struct net_bridge_port *p, 28static inline int should_deliver(const struct net_bridge_port *p,
24 const struct sk_buff *skb) 29 const struct sk_buff *skb)
@@ -94,17 +99,22 @@ void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
94} 99}
95 100
96/* called with rcu_read_lock */ 101/* called with rcu_read_lock */
97void br_forward(const struct net_bridge_port *to, struct sk_buff *skb) 102void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0)
98{ 103{
99 if (should_deliver(to, skb)) { 104 if (should_deliver(to, skb)) {
100 __br_forward(to, skb); 105 if (skb0)
106 deliver_clone(to, skb, __br_forward);
107 else
108 __br_forward(to, skb);
101 return; 109 return;
102 } 110 }
103 111
104 kfree_skb(skb); 112 if (!skb0)
113 kfree_skb(skb);
105} 114}
106 115
107static int deliver_clone(struct net_bridge_port *prev, struct sk_buff *skb, 116static int deliver_clone(const struct net_bridge_port *prev,
117 struct sk_buff *skb,
108 void (*__packet_hook)(const struct net_bridge_port *p, 118 void (*__packet_hook)(const struct net_bridge_port *p,
109 struct sk_buff *skb)) 119 struct sk_buff *skb))
110{ 120{
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 53b39851d87..d74d570fc84 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -70,7 +70,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
70 70
71 if (is_multicast_ether_addr(dest)) { 71 if (is_multicast_ether_addr(dest)) {
72 mdst = br_mdb_get(br, skb); 72 mdst = br_mdb_get(br, skb);
73 if (mdst || BR_INPUT_SKB_CB(skb)->mrouters_only) { 73 if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) {
74 if ((mdst && !hlist_unhashed(&mdst->mglist)) || 74 if ((mdst && !hlist_unhashed(&mdst->mglist)) ||
75 br_multicast_is_router(br)) 75 br_multicast_is_router(br))
76 skb2 = skb; 76 skb2 = skb;
@@ -90,7 +90,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
90 90
91 if (skb) { 91 if (skb) {
92 if (dst) 92 if (dst)
93 br_forward(dst->dst, skb); 93 br_forward(dst->dst, skb, skb2);
94 else 94 else
95 br_flood_forward(br, skb, skb2); 95 br_flood_forward(br, skb, skb2);
96 } 96 }
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 2559fb53983..6980625537c 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -38,7 +38,7 @@ static struct net_bridge_mdb_entry *__br_mdb_ip_get(
38 struct net_bridge_mdb_entry *mp; 38 struct net_bridge_mdb_entry *mp;
39 struct hlist_node *p; 39 struct hlist_node *p;
40 40
41 hlist_for_each_entry(mp, p, &mdb->mhash[hash], hlist[mdb->ver]) { 41 hlist_for_each_entry_rcu(mp, p, &mdb->mhash[hash], hlist[mdb->ver]) {
42 if (dst == mp->addr) 42 if (dst == mp->addr)
43 return mp; 43 return mp;
44 } 44 }
@@ -49,22 +49,23 @@ static struct net_bridge_mdb_entry *__br_mdb_ip_get(
49static struct net_bridge_mdb_entry *br_mdb_ip_get( 49static struct net_bridge_mdb_entry *br_mdb_ip_get(
50 struct net_bridge_mdb_htable *mdb, __be32 dst) 50 struct net_bridge_mdb_htable *mdb, __be32 dst)
51{ 51{
52 if (!mdb)
53 return NULL;
54
52 return __br_mdb_ip_get(mdb, dst, br_ip_hash(mdb, dst)); 55 return __br_mdb_ip_get(mdb, dst, br_ip_hash(mdb, dst));
53} 56}
54 57
55struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br, 58struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
56 struct sk_buff *skb) 59 struct sk_buff *skb)
57{ 60{
58 struct net_bridge_mdb_htable *mdb = br->mdb; 61 if (br->multicast_disabled)
59
60 if (!mdb || br->multicast_disabled)
61 return NULL; 62 return NULL;
62 63
63 switch (skb->protocol) { 64 switch (skb->protocol) {
64 case htons(ETH_P_IP): 65 case htons(ETH_P_IP):
65 if (BR_INPUT_SKB_CB(skb)->igmp) 66 if (BR_INPUT_SKB_CB(skb)->igmp)
66 break; 67 break;
67 return br_mdb_ip_get(mdb, ip_hdr(skb)->daddr); 68 return br_mdb_ip_get(br->mdb, ip_hdr(skb)->daddr);
68 } 69 }
69 70
70 return NULL; 71 return NULL;
@@ -627,8 +628,8 @@ static void br_multicast_port_query_expired(unsigned long data)
627 struct net_bridge *br = port->br; 628 struct net_bridge *br = port->br;
628 629
629 spin_lock(&br->multicast_lock); 630 spin_lock(&br->multicast_lock);
630 if (port && (port->state == BR_STATE_DISABLED || 631 if (port->state == BR_STATE_DISABLED ||
631 port->state == BR_STATE_BLOCKING)) 632 port->state == BR_STATE_BLOCKING)
632 goto out; 633 goto out;
633 634
634 if (port->multicast_startup_queries_sent < 635 if (port->multicast_startup_queries_sent <
@@ -823,6 +824,7 @@ static int br_multicast_query(struct net_bridge *br,
823 unsigned long max_delay; 824 unsigned long max_delay;
824 unsigned long now = jiffies; 825 unsigned long now = jiffies;
825 __be32 group; 826 __be32 group;
827 int err = 0;
826 828
827 spin_lock(&br->multicast_lock); 829 spin_lock(&br->multicast_lock);
828 if (!netif_running(br->dev) || 830 if (!netif_running(br->dev) ||
@@ -841,15 +843,17 @@ static int br_multicast_query(struct net_bridge *br,
841 group = 0; 843 group = 0;
842 } 844 }
843 } else { 845 } else {
844 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) 846 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) {
845 return -EINVAL; 847 err = -EINVAL;
848 goto out;
849 }
846 850
847 ih3 = igmpv3_query_hdr(skb); 851 ih3 = igmpv3_query_hdr(skb);
848 if (ih3->nsrcs) 852 if (ih3->nsrcs)
849 return 0; 853 goto out;
850 854
851 max_delay = ih3->code ? 1 : 855 max_delay = ih3->code ?
852 IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE); 856 IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE) : 1;
853 } 857 }
854 858
855 if (!group) 859 if (!group)
@@ -876,7 +880,7 @@ static int br_multicast_query(struct net_bridge *br,
876 880
877out: 881out:
878 spin_unlock(&br->multicast_lock); 882 spin_unlock(&br->multicast_lock);
879 return 0; 883 return err;
880} 884}
881 885
882static void br_multicast_leave_group(struct net_bridge *br, 886static void br_multicast_leave_group(struct net_bridge *br,
@@ -987,7 +991,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
987 991
988 err = pskb_trim_rcsum(skb2, len); 992 err = pskb_trim_rcsum(skb2, len);
989 if (err) 993 if (err)
990 return err; 994 goto err_out;
991 } 995 }
992 996
993 len -= ip_hdrlen(skb2); 997 len -= ip_hdrlen(skb2);
@@ -1009,7 +1013,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
1009 case CHECKSUM_NONE: 1013 case CHECKSUM_NONE:
1010 skb2->csum = 0; 1014 skb2->csum = 0;
1011 if (skb_checksum_complete(skb2)) 1015 if (skb_checksum_complete(skb2))
1012 return -EINVAL; 1016 goto out;
1013 } 1017 }
1014 1018
1015 err = 0; 1019 err = 0;
@@ -1036,6 +1040,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
1036 1040
1037out: 1041out:
1038 __skb_push(skb2, offset); 1042 __skb_push(skb2, offset);
1043err_out:
1039 if (skb2 != skb) 1044 if (skb2 != skb)
1040 kfree_skb(skb2); 1045 kfree_skb(skb2);
1041 return err; 1046 return err;
@@ -1135,7 +1140,7 @@ void br_multicast_stop(struct net_bridge *br)
1135 1140
1136 if (mdb->old) { 1141 if (mdb->old) {
1137 spin_unlock_bh(&br->multicast_lock); 1142 spin_unlock_bh(&br->multicast_lock);
1138 synchronize_rcu_bh(); 1143 rcu_barrier_bh();
1139 spin_lock_bh(&br->multicast_lock); 1144 spin_lock_bh(&br->multicast_lock);
1140 WARN_ON(mdb->old); 1145 WARN_ON(mdb->old);
1141 } 1146 }
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 1cf2cef7858..846d7d1e207 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -206,12 +206,20 @@ struct net_bridge
206 206
207struct br_input_skb_cb { 207struct br_input_skb_cb {
208 struct net_device *brdev; 208 struct net_device *brdev;
209#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
209 int igmp; 210 int igmp;
210 int mrouters_only; 211 int mrouters_only;
212#endif
211}; 213};
212 214
213#define BR_INPUT_SKB_CB(__skb) ((struct br_input_skb_cb *)(__skb)->cb) 215#define BR_INPUT_SKB_CB(__skb) ((struct br_input_skb_cb *)(__skb)->cb)
214 216
217#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
218# define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (BR_INPUT_SKB_CB(__skb)->mrouters_only)
219#else
220# define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (0)
221#endif
222
215extern struct notifier_block br_device_notifier; 223extern struct notifier_block br_device_notifier;
216extern const u8 br_group_address[ETH_ALEN]; 224extern const u8 br_group_address[ETH_ALEN];
217 225
@@ -252,7 +260,7 @@ extern void br_deliver(const struct net_bridge_port *to,
252 struct sk_buff *skb); 260 struct sk_buff *skb);
253extern int br_dev_queue_push_xmit(struct sk_buff *skb); 261extern int br_dev_queue_push_xmit(struct sk_buff *skb);
254extern void br_forward(const struct net_bridge_port *to, 262extern void br_forward(const struct net_bridge_port *to,
255 struct sk_buff *skb); 263 struct sk_buff *skb, struct sk_buff *skb0);
256extern int br_forward_finish(struct sk_buff *skb); 264extern int br_forward_finish(struct sk_buff *skb);
257extern void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb); 265extern void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb);
258extern void br_flood_forward(struct net_bridge *br, struct sk_buff *skb, 266extern void br_flood_forward(struct net_bridge *br, struct sk_buff *skb,
@@ -423,7 +431,7 @@ extern void br_ifinfo_notify(int event, struct net_bridge_port *port);
423 431
424#ifdef CONFIG_SYSFS 432#ifdef CONFIG_SYSFS
425/* br_sysfs_if.c */ 433/* br_sysfs_if.c */
426extern struct sysfs_ops brport_sysfs_ops; 434extern const struct sysfs_ops brport_sysfs_ops;
427extern int br_sysfs_addif(struct net_bridge_port *p); 435extern int br_sysfs_addif(struct net_bridge_port *p);
428 436
429/* br_sysfs_br.c */ 437/* br_sysfs_br.c */
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 696596cd338..0b9916489d6 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -238,7 +238,7 @@ static ssize_t brport_store(struct kobject * kobj,
238 return ret; 238 return ret;
239} 239}
240 240
241struct sysfs_ops brport_sysfs_ops = { 241const struct sysfs_ops brport_sysfs_ops = {
242 .show = brport_show, 242 .show = brport_show,
243 .store = brport_store, 243 .store = brport_store,
244}; 244};
diff --git a/net/core/dev.c b/net/core/dev.c
index bcc490cc945..59d4394d2ce 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2483,6 +2483,7 @@ int netif_receive_skb(struct sk_buff *skb)
2483{ 2483{
2484 struct packet_type *ptype, *pt_prev; 2484 struct packet_type *ptype, *pt_prev;
2485 struct net_device *orig_dev; 2485 struct net_device *orig_dev;
2486 struct net_device *master;
2486 struct net_device *null_or_orig; 2487 struct net_device *null_or_orig;
2487 struct net_device *null_or_bond; 2488 struct net_device *null_or_bond;
2488 int ret = NET_RX_DROP; 2489 int ret = NET_RX_DROP;
@@ -2503,11 +2504,12 @@ int netif_receive_skb(struct sk_buff *skb)
2503 2504
2504 null_or_orig = NULL; 2505 null_or_orig = NULL;
2505 orig_dev = skb->dev; 2506 orig_dev = skb->dev;
2506 if (orig_dev->master) { 2507 master = ACCESS_ONCE(orig_dev->master);
2507 if (skb_bond_should_drop(skb)) 2508 if (master) {
2509 if (skb_bond_should_drop(skb, master))
2508 null_or_orig = orig_dev; /* deliver only exact match */ 2510 null_or_orig = orig_dev; /* deliver only exact match */
2509 else 2511 else
2510 skb->dev = orig_dev->master; 2512 skb->dev = master;
2511 } 2513 }
2512 2514
2513 __get_cpu_var(netdev_rx_stat).total++; 2515 __get_cpu_var(netdev_rx_stat).total++;
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c
index fd91569e239..3dc295beb48 100644
--- a/net/core/dev_mcast.c
+++ b/net/core/dev_mcast.c
@@ -97,8 +97,9 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
97 97
98 netif_addr_lock_bh(dev); 98 netif_addr_lock_bh(dev);
99 if (alen != dev->addr_len) 99 if (alen != dev->addr_len)
100 return -EINVAL; 100 err = -EINVAL;
101 err = __dev_addr_add(&dev->mc_list, &dev->mc_count, addr, alen, glbl); 101 else
102 err = __dev_addr_add(&dev->mc_list, &dev->mc_count, addr, alen, glbl);
102 if (!err) 103 if (!err)
103 __dev_set_rx_mode(dev); 104 __dev_set_rx_mode(dev);
104 netif_addr_unlock_bh(dev); 105 netif_addr_unlock_bh(dev);
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 0f2f82185ec..f4cb6b6299d 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -17,6 +17,7 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/ethtool.h> 18#include <linux/ethtool.h>
19#include <linux/netdevice.h> 19#include <linux/netdevice.h>
20#include <linux/bitops.h>
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
21 22
22/* 23/*
@@ -199,10 +200,7 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
199 return dev->ethtool_ops->set_settings(dev, &cmd); 200 return dev->ethtool_ops->set_settings(dev, &cmd);
200} 201}
201 202
202/* 203static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
203 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
204 */
205static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
206{ 204{
207 struct ethtool_drvinfo info; 205 struct ethtool_drvinfo info;
208 const struct ethtool_ops *ops = dev->ethtool_ops; 206 const struct ethtool_ops *ops = dev->ethtool_ops;
@@ -214,6 +212,10 @@ static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use
214 info.cmd = ETHTOOL_GDRVINFO; 212 info.cmd = ETHTOOL_GDRVINFO;
215 ops->get_drvinfo(dev, &info); 213 ops->get_drvinfo(dev, &info);
216 214
215 /*
216 * this method of obtaining string set info is deprecated;
217 * Use ETHTOOL_GSSET_INFO instead.
218 */
217 if (ops->get_sset_count) { 219 if (ops->get_sset_count) {
218 int rc; 220 int rc;
219 221
@@ -237,10 +239,67 @@ static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use
237 return 0; 239 return 0;
238} 240}
239 241
240/* 242static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
241 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool() 243 void __user *useraddr)
242 */ 244{
243static noinline int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr) 245 struct ethtool_sset_info info;
246 const struct ethtool_ops *ops = dev->ethtool_ops;
247 u64 sset_mask;
248 int i, idx = 0, n_bits = 0, ret, rc;
249 u32 *info_buf = NULL;
250
251 if (!ops->get_sset_count)
252 return -EOPNOTSUPP;
253
254 if (copy_from_user(&info, useraddr, sizeof(info)))
255 return -EFAULT;
256
257 /* store copy of mask, because we zero struct later on */
258 sset_mask = info.sset_mask;
259 if (!sset_mask)
260 return 0;
261
262 /* calculate size of return buffer */
263 n_bits = hweight64(sset_mask);
264
265 memset(&info, 0, sizeof(info));
266 info.cmd = ETHTOOL_GSSET_INFO;
267
268 info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER);
269 if (!info_buf)
270 return -ENOMEM;
271
272 /*
273 * fill return buffer based on input bitmask and successful
274 * get_sset_count return
275 */
276 for (i = 0; i < 64; i++) {
277 if (!(sset_mask & (1ULL << i)))
278 continue;
279
280 rc = ops->get_sset_count(dev, i);
281 if (rc >= 0) {
282 info.sset_mask |= (1ULL << i);
283 info_buf[idx++] = rc;
284 }
285 }
286
287 ret = -EFAULT;
288 if (copy_to_user(useraddr, &info, sizeof(info)))
289 goto out;
290
291 useraddr += offsetof(struct ethtool_sset_info, data);
292 if (copy_to_user(useraddr, info_buf, idx * sizeof(u32)))
293 goto out;
294
295 ret = 0;
296
297out:
298 kfree(info_buf);
299 return ret;
300}
301
302static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr)
244{ 303{
245 struct ethtool_rxnfc cmd; 304 struct ethtool_rxnfc cmd;
246 305
@@ -253,10 +312,7 @@ static noinline int ethtool_set_rxnfc(struct net_device *dev, void __user *usera
253 return dev->ethtool_ops->set_rxnfc(dev, &cmd); 312 return dev->ethtool_ops->set_rxnfc(dev, &cmd);
254} 313}
255 314
256/* 315static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr)
257 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
258 */
259static noinline int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr)
260{ 316{
261 struct ethtool_rxnfc info; 317 struct ethtool_rxnfc info;
262 const struct ethtool_ops *ops = dev->ethtool_ops; 318 const struct ethtool_ops *ops = dev->ethtool_ops;
@@ -328,10 +384,7 @@ static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list,
328 list->count++; 384 list->count++;
329} 385}
330 386
331/* 387static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev, void __user *useraddr)
332 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
333 */
334static noinline int ethtool_set_rx_ntuple(struct net_device *dev, void __user *useraddr)
335{ 388{
336 struct ethtool_rx_ntuple cmd; 389 struct ethtool_rx_ntuple cmd;
337 const struct ethtool_ops *ops = dev->ethtool_ops; 390 const struct ethtool_ops *ops = dev->ethtool_ops;
@@ -799,10 +852,7 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
799 return ret; 852 return ret;
800} 853}
801 854
802/* 855static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
803 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
804 */
805static noinline int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
806{ 856{
807 struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE }; 857 struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
808 858
@@ -816,10 +866,7 @@ static noinline int ethtool_get_coalesce(struct net_device *dev, void __user *us
816 return 0; 866 return 0;
817} 867}
818 868
819/* 869static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
820 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
821 */
822static noinline int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
823{ 870{
824 struct ethtool_coalesce coalesce; 871 struct ethtool_coalesce coalesce;
825 872
@@ -1229,10 +1276,7 @@ static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
1229 return actor(dev, edata.data); 1276 return actor(dev, edata.data);
1230} 1277}
1231 1278
1232/* 1279static noinline_for_stack int ethtool_flash_device(struct net_device *dev, char __user *useraddr)
1233 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
1234 */
1235static noinline int ethtool_flash_device(struct net_device *dev, char __user *useraddr)
1236{ 1280{
1237 struct ethtool_flash efl; 1281 struct ethtool_flash efl;
1238 1282
@@ -1471,6 +1515,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1471 case ETHTOOL_GRXNTUPLE: 1515 case ETHTOOL_GRXNTUPLE:
1472 rc = ethtool_get_rx_ntuple(dev, useraddr); 1516 rc = ethtool_get_rx_ntuple(dev, useraddr);
1473 break; 1517 break;
1518 case ETHTOOL_GSSET_INFO:
1519 rc = ethtool_get_sset_info(dev, useraddr);
1520 break;
1474 default: 1521 default:
1475 rc = -EOPNOTSUPP; 1522 rc = -EOPNOTSUPP;
1476 } 1523 }
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index d102f6d9abd..6cee6434da6 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -771,6 +771,8 @@ static __inline__ int neigh_max_probes(struct neighbour *n)
771} 771}
772 772
773static void neigh_invalidate(struct neighbour *neigh) 773static void neigh_invalidate(struct neighbour *neigh)
774 __releases(neigh->lock)
775 __acquires(neigh->lock)
774{ 776{
775 struct sk_buff *skb; 777 struct sk_buff *skb;
776 778
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 7aa69725376..6f9206b36dc 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -614,7 +614,7 @@ void netpoll_print_options(struct netpoll *np)
614 np->name, np->local_port); 614 np->name, np->local_port);
615 printk(KERN_INFO "%s: local IP %pI4\n", 615 printk(KERN_INFO "%s: local IP %pI4\n",
616 np->name, &np->local_ip); 616 np->name, &np->local_ip);
617 printk(KERN_INFO "%s: interface %s\n", 617 printk(KERN_INFO "%s: interface '%s'\n",
618 np->name, np->dev_name); 618 np->name, np->dev_name);
619 printk(KERN_INFO "%s: remote port %d\n", 619 printk(KERN_INFO "%s: remote port %d\n",
620 np->name, np->remote_port); 620 np->name, np->remote_port);
@@ -661,6 +661,9 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
661 if ((delim = strchr(cur, '@')) == NULL) 661 if ((delim = strchr(cur, '@')) == NULL)
662 goto parse_failed; 662 goto parse_failed;
663 *delim = 0; 663 *delim = 0;
664 if (*cur == ' ' || *cur == '\t')
665 printk(KERN_INFO "%s: warning: whitespace"
666 "is not allowed\n", np->name);
664 np->remote_port = simple_strtol(cur, NULL, 10); 667 np->remote_port = simple_strtol(cur, NULL, 10);
665 cur = delim; 668 cur = delim;
666 } 669 }
@@ -708,7 +711,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
708 return 0; 711 return 0;
709 712
710 parse_failed: 713 parse_failed:
711 printk(KERN_INFO "%s: couldn't parse config at %s!\n", 714 printk(KERN_INFO "%s: couldn't parse config at '%s'!\n",
712 np->name, cur); 715 np->name, cur);
713 return -1; 716 return -1;
714} 717}
@@ -735,7 +738,7 @@ int netpoll_setup(struct netpoll *np)
735 npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL); 738 npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
736 if (!npinfo) { 739 if (!npinfo) {
737 err = -ENOMEM; 740 err = -ENOMEM;
738 goto release; 741 goto put;
739 } 742 }
740 743
741 npinfo->rx_flags = 0; 744 npinfo->rx_flags = 0;
@@ -845,7 +848,7 @@ int netpoll_setup(struct netpoll *np)
845 848
846 kfree(npinfo); 849 kfree(npinfo);
847 } 850 }
848 851put:
849 dev_put(ndev); 852 dev_put(ndev);
850 return err; 853 return err;
851} 854}
diff --git a/net/core/sock.c b/net/core/sock.c
index fcd397a762f..c5812bbc2cc 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -340,8 +340,12 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
340 rc = sk_backlog_rcv(sk, skb); 340 rc = sk_backlog_rcv(sk, skb);
341 341
342 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_); 342 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
343 } else 343 } else if (sk_add_backlog(sk, skb)) {
344 sk_add_backlog(sk, skb); 344 bh_unlock_sock(sk);
345 atomic_inc(&sk->sk_drops);
346 goto discard_and_relse;
347 }
348
345 bh_unlock_sock(sk); 349 bh_unlock_sock(sk);
346out: 350out:
347 sock_put(sk); 351 sock_put(sk);
@@ -1139,6 +1143,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
1139 sock_lock_init(newsk); 1143 sock_lock_init(newsk);
1140 bh_lock_sock(newsk); 1144 bh_lock_sock(newsk);
1141 newsk->sk_backlog.head = newsk->sk_backlog.tail = NULL; 1145 newsk->sk_backlog.head = newsk->sk_backlog.tail = NULL;
1146 newsk->sk_backlog.len = 0;
1142 1147
1143 atomic_set(&newsk->sk_rmem_alloc, 0); 1148 atomic_set(&newsk->sk_rmem_alloc, 0);
1144 /* 1149 /*
@@ -1542,6 +1547,12 @@ static void __release_sock(struct sock *sk)
1542 1547
1543 bh_lock_sock(sk); 1548 bh_lock_sock(sk);
1544 } while ((skb = sk->sk_backlog.head) != NULL); 1549 } while ((skb = sk->sk_backlog.head) != NULL);
1550
1551 /*
1552 * Doing the zeroing here guarantee we can not loop forever
1553 * while a wild producer attempts to flood us.
1554 */
1555 sk->sk_backlog.len = 0;
1545} 1556}
1546 1557
1547/** 1558/**
@@ -1874,6 +1885,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
1874 sk->sk_allocation = GFP_KERNEL; 1885 sk->sk_allocation = GFP_KERNEL;
1875 sk->sk_rcvbuf = sysctl_rmem_default; 1886 sk->sk_rcvbuf = sysctl_rmem_default;
1876 sk->sk_sndbuf = sysctl_wmem_default; 1887 sk->sk_sndbuf = sysctl_wmem_default;
1888 sk->sk_backlog.limit = sk->sk_rcvbuf << 1;
1877 sk->sk_state = TCP_CLOSE; 1889 sk->sk_state = TCP_CLOSE;
1878 sk_set_socket(sk, sock); 1890 sk_set_socket(sk, sock);
1879 1891
@@ -2276,7 +2288,8 @@ out_free_request_sock_slab:
2276 prot->rsk_prot->slab = NULL; 2288 prot->rsk_prot->slab = NULL;
2277 } 2289 }
2278out_free_request_sock_slab_name: 2290out_free_request_sock_slab_name:
2279 kfree(prot->rsk_prot->slab_name); 2291 if (prot->rsk_prot)
2292 kfree(prot->rsk_prot->slab_name);
2280out_free_sock_slab: 2293out_free_sock_slab:
2281 kmem_cache_destroy(prot->slab); 2294 kmem_cache_destroy(prot->slab);
2282 prot->slab = NULL; 2295 prot->slab = NULL;
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index b195c4feaa0..4071eaf2b36 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -998,11 +998,11 @@ static struct inet_protosw dccp_v4_protosw = {
998 998
999static int __net_init dccp_v4_init_net(struct net *net) 999static int __net_init dccp_v4_init_net(struct net *net)
1000{ 1000{
1001 int err; 1001 if (dccp_hashinfo.bhash == NULL)
1002 return -ESOCKTNOSUPPORT;
1002 1003
1003 err = inet_ctl_sock_create(&net->dccp.v4_ctl_sk, PF_INET, 1004 return inet_ctl_sock_create(&net->dccp.v4_ctl_sk, PF_INET,
1004 SOCK_DCCP, IPPROTO_DCCP, net); 1005 SOCK_DCCP, IPPROTO_DCCP, net);
1005 return err;
1006} 1006}
1007 1007
1008static void __net_exit dccp_v4_exit_net(struct net *net) 1008static void __net_exit dccp_v4_exit_net(struct net *net)
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 1aec6349e85..af3394df63b 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1191,11 +1191,11 @@ static struct inet_protosw dccp_v6_protosw = {
1191 1191
1192static int __net_init dccp_v6_init_net(struct net *net) 1192static int __net_init dccp_v6_init_net(struct net *net)
1193{ 1193{
1194 int err; 1194 if (dccp_hashinfo.bhash == NULL)
1195 return -ESOCKTNOSUPPORT;
1195 1196
1196 err = inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6, 1197 return inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6,
1197 SOCK_DCCP, IPPROTO_DCCP, net); 1198 SOCK_DCCP, IPPROTO_DCCP, net);
1198 return err;
1199} 1199}
1200 1200
1201static void __net_exit dccp_v6_exit_net(struct net *net) 1201static void __net_exit dccp_v6_exit_net(struct net *net)
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index af226a06314..0d508c359fa 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -254,7 +254,7 @@ int dccp_child_process(struct sock *parent, struct sock *child,
254 * in main socket hash table and lock on listening 254 * in main socket hash table and lock on listening
255 * socket does not protect us more. 255 * socket does not protect us more.
256 */ 256 */
257 sk_add_backlog(child, skb); 257 __sk_add_backlog(child, skb);
258 } 258 }
259 259
260 bh_unlock_sock(child); 260 bh_unlock_sock(child);
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 0ef7061920c..aa4cef374fd 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -1036,7 +1036,7 @@ static int __init dccp_init(void)
1036 FIELD_SIZEOF(struct sk_buff, cb)); 1036 FIELD_SIZEOF(struct sk_buff, cb));
1037 rc = percpu_counter_init(&dccp_orphan_count, 0); 1037 rc = percpu_counter_init(&dccp_orphan_count, 0);
1038 if (rc) 1038 if (rc)
1039 goto out; 1039 goto out_fail;
1040 rc = -ENOBUFS; 1040 rc = -ENOBUFS;
1041 inet_hashinfo_init(&dccp_hashinfo); 1041 inet_hashinfo_init(&dccp_hashinfo);
1042 dccp_hashinfo.bind_bucket_cachep = 1042 dccp_hashinfo.bind_bucket_cachep =
@@ -1125,8 +1125,9 @@ static int __init dccp_init(void)
1125 goto out_sysctl_exit; 1125 goto out_sysctl_exit;
1126 1126
1127 dccp_timestamping_init(); 1127 dccp_timestamping_init();
1128out: 1128
1129 return rc; 1129 return 0;
1130
1130out_sysctl_exit: 1131out_sysctl_exit:
1131 dccp_sysctl_exit(); 1132 dccp_sysctl_exit();
1132out_ackvec_exit: 1133out_ackvec_exit:
@@ -1135,18 +1136,19 @@ out_free_dccp_mib:
1135 dccp_mib_exit(); 1136 dccp_mib_exit();
1136out_free_dccp_bhash: 1137out_free_dccp_bhash:
1137 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order); 1138 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
1138 dccp_hashinfo.bhash = NULL;
1139out_free_dccp_locks: 1139out_free_dccp_locks:
1140 inet_ehash_locks_free(&dccp_hashinfo); 1140 inet_ehash_locks_free(&dccp_hashinfo);
1141out_free_dccp_ehash: 1141out_free_dccp_ehash:
1142 free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order); 1142 free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order);
1143 dccp_hashinfo.ehash = NULL;
1144out_free_bind_bucket_cachep: 1143out_free_bind_bucket_cachep:
1145 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); 1144 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
1146 dccp_hashinfo.bind_bucket_cachep = NULL;
1147out_free_percpu: 1145out_free_percpu:
1148 percpu_counter_destroy(&dccp_orphan_count); 1146 percpu_counter_destroy(&dccp_orphan_count);
1149 goto out; 1147out_fail:
1148 dccp_hashinfo.bhash = NULL;
1149 dccp_hashinfo.ehash = NULL;
1150 dccp_hashinfo.bind_bucket_cachep = NULL;
1151 return rc;
1150} 1152}
1151 1153
1152static void __exit dccp_fini(void) 1154static void __exit dccp_fini(void)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 51ca946e339..3feb2b39030 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1194,7 +1194,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
1194 hlist_for_each_entry_rcu(dev, node, head, index_hlist) { 1194 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
1195 if (idx < s_idx) 1195 if (idx < s_idx)
1196 goto cont; 1196 goto cont;
1197 if (idx > s_idx) 1197 if (h > s_h || idx > s_idx)
1198 s_ip_idx = 0; 1198 s_ip_idx = 0;
1199 in_dev = __in_dev_get_rcu(dev); 1199 in_dev = __in_dev_get_rcu(dev);
1200 if (!in_dev) 1200 if (!in_dev)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index af5d8979286..01ef8ba9025 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -961,7 +961,9 @@ fib_find_node(struct trie *t, u32 key)
961 struct node *n; 961 struct node *n;
962 962
963 pos = 0; 963 pos = 0;
964 n = rcu_dereference(t->trie); 964 n = rcu_dereference_check(t->trie,
965 rcu_read_lock_held() ||
966 lockdep_rtnl_is_held());
965 967
966 while (n != NULL && NODE_TYPE(n) == T_TNODE) { 968 while (n != NULL && NODE_TYPE(n) == T_TNODE) {
967 tn = (struct tnode *) n; 969 tn = (struct tnode *) n;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index c0c5274d027..f78402d097b 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -810,11 +810,13 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
810 tunnel->err_count = 0; 810 tunnel->err_count = 0;
811 } 811 }
812 812
813 max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen; 813 max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen + rt->u.dst.header_len;
814 814
815 if (skb_headroom(skb) < max_headroom || skb_shared(skb)|| 815 if (skb_headroom(skb) < max_headroom || skb_shared(skb)||
816 (skb_cloned(skb) && !skb_clone_writable(skb, 0))) { 816 (skb_cloned(skb) && !skb_clone_writable(skb, 0))) {
817 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); 817 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
818 if (max_headroom > dev->needed_headroom)
819 dev->needed_headroom = max_headroom;
818 if (!new_skb) { 820 if (!new_skb) {
819 ip_rt_put(rt); 821 ip_rt_put(rt);
820 txq->tx_dropped++; 822 txq->tx_dropped++;
@@ -1144,12 +1146,9 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
1144 1146
1145 if (saddr) 1147 if (saddr)
1146 memcpy(&iph->saddr, saddr, 4); 1148 memcpy(&iph->saddr, saddr, 4);
1147 1149 if (daddr)
1148 if (daddr) {
1149 memcpy(&iph->daddr, daddr, 4); 1150 memcpy(&iph->daddr, daddr, 4);
1150 return t->hlen; 1151 if (iph->daddr)
1151 }
1152 if (iph->daddr && !ipv4_is_multicast(iph->daddr))
1153 return t->hlen; 1152 return t->hlen;
1154 1153
1155 return -t->hlen; 1154 return -t->hlen;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 10a6a604bf3..67890928164 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -187,6 +187,16 @@ struct ic_device {
187static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */ 187static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */
188static struct net_device *ic_dev __initdata = NULL; /* Selected device */ 188static struct net_device *ic_dev __initdata = NULL; /* Selected device */
189 189
190static bool __init ic_device_match(struct net_device *dev)
191{
192 if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
193 (!(dev->flags & IFF_LOOPBACK) &&
194 (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
195 strncmp(dev->name, "dummy", 5)))
196 return true;
197 return false;
198}
199
190static int __init ic_open_devs(void) 200static int __init ic_open_devs(void)
191{ 201{
192 struct ic_device *d, **last; 202 struct ic_device *d, **last;
@@ -207,10 +217,7 @@ static int __init ic_open_devs(void)
207 for_each_netdev(&init_net, dev) { 217 for_each_netdev(&init_net, dev) {
208 if (dev->flags & IFF_LOOPBACK) 218 if (dev->flags & IFF_LOOPBACK)
209 continue; 219 continue;
210 if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : 220 if (ic_device_match(dev)) {
211 (!(dev->flags & IFF_LOOPBACK) &&
212 (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
213 strncmp(dev->name, "dummy", 5))) {
214 int able = 0; 221 int able = 0;
215 if (dev->mtu >= 364) 222 if (dev->mtu >= 364)
216 able |= IC_BOOTP; 223 able |= IC_BOOTP;
@@ -228,7 +235,7 @@ static int __init ic_open_devs(void)
228 } 235 }
229 if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) { 236 if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
230 rtnl_unlock(); 237 rtnl_unlock();
231 return -1; 238 return -ENOMEM;
232 } 239 }
233 d->dev = dev; 240 d->dev = dev;
234 *last = d; 241 *last = d;
@@ -253,7 +260,7 @@ static int __init ic_open_devs(void)
253 printk(KERN_ERR "IP-Config: Device `%s' not found.\n", user_dev_name); 260 printk(KERN_ERR "IP-Config: Device `%s' not found.\n", user_dev_name);
254 else 261 else
255 printk(KERN_ERR "IP-Config: No network devices available.\n"); 262 printk(KERN_ERR "IP-Config: No network devices available.\n");
256 return -1; 263 return -ENODEV;
257 } 264 }
258 return 0; 265 return 0;
259} 266}
@@ -1303,6 +1310,32 @@ __be32 __init root_nfs_parse_addr(char *name)
1303 return addr; 1310 return addr;
1304} 1311}
1305 1312
1313#define DEVICE_WAIT_MAX 12 /* 12 seconds */
1314
1315static int __init wait_for_devices(void)
1316{
1317 int i;
1318
1319 msleep(CONF_PRE_OPEN);
1320 for (i = 0; i < DEVICE_WAIT_MAX; i++) {
1321 struct net_device *dev;
1322 int found = 0;
1323
1324 rtnl_lock();
1325 for_each_netdev(&init_net, dev) {
1326 if (ic_device_match(dev)) {
1327 found = 1;
1328 break;
1329 }
1330 }
1331 rtnl_unlock();
1332 if (found)
1333 return 0;
1334 ssleep(1);
1335 }
1336 return -ENODEV;
1337}
1338
1306/* 1339/*
1307 * IP Autoconfig dispatcher. 1340 * IP Autoconfig dispatcher.
1308 */ 1341 */
@@ -1313,6 +1346,7 @@ static int __init ip_auto_config(void)
1313#ifdef IPCONFIG_DYNAMIC 1346#ifdef IPCONFIG_DYNAMIC
1314 int retries = CONF_OPEN_RETRIES; 1347 int retries = CONF_OPEN_RETRIES;
1315#endif 1348#endif
1349 int err;
1316 1350
1317#ifdef CONFIG_PROC_FS 1351#ifdef CONFIG_PROC_FS
1318 proc_net_fops_create(&init_net, "pnp", S_IRUGO, &pnp_seq_fops); 1352 proc_net_fops_create(&init_net, "pnp", S_IRUGO, &pnp_seq_fops);
@@ -1325,12 +1359,15 @@ static int __init ip_auto_config(void)
1325#ifdef IPCONFIG_DYNAMIC 1359#ifdef IPCONFIG_DYNAMIC
1326 try_try_again: 1360 try_try_again:
1327#endif 1361#endif
1328 /* Give hardware a chance to settle */ 1362 /* Wait for devices to appear */
1329 msleep(CONF_PRE_OPEN); 1363 err = wait_for_devices();
1364 if (err)
1365 return err;
1330 1366
1331 /* Setup all network devices */ 1367 /* Setup all network devices */
1332 if (ic_open_devs() < 0) 1368 err = ic_open_devs();
1333 return -1; 1369 if (err)
1370 return err;
1334 1371
1335 /* Give drivers a chance to settle */ 1372 /* Give drivers a chance to settle */
1336 ssleep(CONF_POST_OPEN); 1373 ssleep(CONF_POST_OPEN);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 8582e12e4a6..d0a6092a67b 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -802,6 +802,9 @@ static int ipmr_mfc_add(struct net *net, struct mfcctl *mfc, int mrtsock)
802 int line; 802 int line;
803 struct mfc_cache *uc, *c, **cp; 803 struct mfc_cache *uc, *c, **cp;
804 804
805 if (mfc->mfcc_parent >= MAXVIFS)
806 return -ENFILE;
807
805 line = MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr); 808 line = MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr);
806 809
807 for (cp = &net->ipv4.mfc_cache_array[line]; 810 for (cp = &net->ipv4.mfc_cache_array[line];
@@ -1613,17 +1616,20 @@ ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm)
1613 int ct; 1616 int ct;
1614 struct rtnexthop *nhp; 1617 struct rtnexthop *nhp;
1615 struct net *net = mfc_net(c); 1618 struct net *net = mfc_net(c);
1616 struct net_device *dev = net->ipv4.vif_table[c->mfc_parent].dev;
1617 u8 *b = skb_tail_pointer(skb); 1619 u8 *b = skb_tail_pointer(skb);
1618 struct rtattr *mp_head; 1620 struct rtattr *mp_head;
1619 1621
1620 if (dev) 1622 /* If cache is unresolved, don't try to parse IIF and OIF */
1621 RTA_PUT(skb, RTA_IIF, 4, &dev->ifindex); 1623 if (c->mfc_parent > MAXVIFS)
1624 return -ENOENT;
1625
1626 if (VIF_EXISTS(net, c->mfc_parent))
1627 RTA_PUT(skb, RTA_IIF, 4, &net->ipv4.vif_table[c->mfc_parent].dev->ifindex);
1622 1628
1623 mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0)); 1629 mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0));
1624 1630
1625 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) { 1631 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
1626 if (c->mfc_un.res.ttls[ct] < 255) { 1632 if (VIF_EXISTS(net, ct) && c->mfc_un.res.ttls[ct] < 255) {
1627 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4)) 1633 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
1628 goto rtattr_failure; 1634 goto rtattr_failure;
1629 nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp))); 1635 nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 242ed230737..4f1f337f433 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -249,6 +249,8 @@ static const struct snmp_mib snmp4_net_list[] = {
249 SNMP_MIB_ITEM("TCPSackShifted", LINUX_MIB_SACKSHIFTED), 249 SNMP_MIB_ITEM("TCPSackShifted", LINUX_MIB_SACKSHIFTED),
250 SNMP_MIB_ITEM("TCPSackMerged", LINUX_MIB_SACKMERGED), 250 SNMP_MIB_ITEM("TCPSackMerged", LINUX_MIB_SACKMERGED),
251 SNMP_MIB_ITEM("TCPSackShiftFallback", LINUX_MIB_SACKSHIFTFALLBACK), 251 SNMP_MIB_ITEM("TCPSackShiftFallback", LINUX_MIB_SACKSHIFTFALLBACK),
252 SNMP_MIB_ITEM("TCPBacklogDrop", LINUX_MIB_TCPBACKLOGDROP),
253 SNMP_MIB_ITEM("TCPMinTTLDrop", LINUX_MIB_TCPMINTTLDROP),
252 SNMP_MIB_SENTINEL 254 SNMP_MIB_SENTINEL
253}; 255};
254 256
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index b2ba5581d2a..d413b57be9b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -146,7 +146,6 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst);
146static void ipv4_link_failure(struct sk_buff *skb); 146static void ipv4_link_failure(struct sk_buff *skb);
147static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu); 147static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu);
148static int rt_garbage_collect(struct dst_ops *ops); 148static int rt_garbage_collect(struct dst_ops *ops);
149static void rt_emergency_hash_rebuild(struct net *net);
150 149
151 150
152static struct dst_ops ipv4_dst_ops = { 151static struct dst_ops ipv4_dst_ops = {
@@ -780,11 +779,30 @@ static void rt_do_flush(int process_context)
780#define FRACT_BITS 3 779#define FRACT_BITS 3
781#define ONE (1UL << FRACT_BITS) 780#define ONE (1UL << FRACT_BITS)
782 781
782/*
783 * Given a hash chain and an item in this hash chain,
784 * find if a previous entry has the same hash_inputs
785 * (but differs on tos, mark or oif)
786 * Returns 0 if an alias is found.
787 * Returns ONE if rth has no alias before itself.
788 */
789static int has_noalias(const struct rtable *head, const struct rtable *rth)
790{
791 const struct rtable *aux = head;
792
793 while (aux != rth) {
794 if (compare_hash_inputs(&aux->fl, &rth->fl))
795 return 0;
796 aux = aux->u.dst.rt_next;
797 }
798 return ONE;
799}
800
783static void rt_check_expire(void) 801static void rt_check_expire(void)
784{ 802{
785 static unsigned int rover; 803 static unsigned int rover;
786 unsigned int i = rover, goal; 804 unsigned int i = rover, goal;
787 struct rtable *rth, *aux, **rthp; 805 struct rtable *rth, **rthp;
788 unsigned long samples = 0; 806 unsigned long samples = 0;
789 unsigned long sum = 0, sum2 = 0; 807 unsigned long sum = 0, sum2 = 0;
790 unsigned long delta; 808 unsigned long delta;
@@ -835,15 +853,7 @@ nofree:
835 * attributes don't unfairly skew 853 * attributes don't unfairly skew
836 * the length computation 854 * the length computation
837 */ 855 */
838 for (aux = rt_hash_table[i].chain;;) { 856 length += has_noalias(rt_hash_table[i].chain, rth);
839 if (aux == rth) {
840 length += ONE;
841 break;
842 }
843 if (compare_hash_inputs(&aux->fl, &rth->fl))
844 break;
845 aux = aux->u.dst.rt_next;
846 }
847 continue; 857 continue;
848 } 858 }
849 } else if (!rt_may_expire(rth, tmo, ip_rt_gc_timeout)) 859 } else if (!rt_may_expire(rth, tmo, ip_rt_gc_timeout))
@@ -922,10 +932,8 @@ static void rt_secret_rebuild_oneshot(struct net *net)
922{ 932{
923 del_timer_sync(&net->ipv4.rt_secret_timer); 933 del_timer_sync(&net->ipv4.rt_secret_timer);
924 rt_cache_invalidate(net); 934 rt_cache_invalidate(net);
925 if (ip_rt_secret_interval) { 935 if (ip_rt_secret_interval)
926 net->ipv4.rt_secret_timer.expires += ip_rt_secret_interval; 936 mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval);
927 add_timer(&net->ipv4.rt_secret_timer);
928 }
929} 937}
930 938
931static void rt_emergency_hash_rebuild(struct net *net) 939static void rt_emergency_hash_rebuild(struct net *net)
@@ -1073,8 +1081,23 @@ work_done:
1073out: return 0; 1081out: return 0;
1074} 1082}
1075 1083
1084/*
1085 * Returns number of entries in a hash chain that have different hash_inputs
1086 */
1087static int slow_chain_length(const struct rtable *head)
1088{
1089 int length = 0;
1090 const struct rtable *rth = head;
1091
1092 while (rth) {
1093 length += has_noalias(head, rth);
1094 rth = rth->u.dst.rt_next;
1095 }
1096 return length >> FRACT_BITS;
1097}
1098
1076static int rt_intern_hash(unsigned hash, struct rtable *rt, 1099static int rt_intern_hash(unsigned hash, struct rtable *rt,
1077 struct rtable **rp, struct sk_buff *skb) 1100 struct rtable **rp, struct sk_buff *skb, int ifindex)
1078{ 1101{
1079 struct rtable *rth, **rthp; 1102 struct rtable *rth, **rthp;
1080 unsigned long now; 1103 unsigned long now;
@@ -1185,14 +1208,20 @@ restart:
1185 rt_free(cand); 1208 rt_free(cand);
1186 } 1209 }
1187 } else { 1210 } else {
1188 if (chain_length > rt_chain_length_max) { 1211 if (chain_length > rt_chain_length_max &&
1212 slow_chain_length(rt_hash_table[hash].chain) > rt_chain_length_max) {
1189 struct net *net = dev_net(rt->u.dst.dev); 1213 struct net *net = dev_net(rt->u.dst.dev);
1190 int num = ++net->ipv4.current_rt_cache_rebuild_count; 1214 int num = ++net->ipv4.current_rt_cache_rebuild_count;
1191 if (!rt_caching(dev_net(rt->u.dst.dev))) { 1215 if (!rt_caching(net)) {
1192 printk(KERN_WARNING "%s: %d rebuilds is over limit, route caching disabled\n", 1216 printk(KERN_WARNING "%s: %d rebuilds is over limit, route caching disabled\n",
1193 rt->u.dst.dev->name, num); 1217 rt->u.dst.dev->name, num);
1194 } 1218 }
1195 rt_emergency_hash_rebuild(dev_net(rt->u.dst.dev)); 1219 rt_emergency_hash_rebuild(net);
1220 spin_unlock_bh(rt_hash_lock_addr(hash));
1221
1222 hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
1223 ifindex, rt_genid(net));
1224 goto restart;
1196 } 1225 }
1197 } 1226 }
1198 1227
@@ -1417,7 +1446,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1417 dev_hold(rt->u.dst.dev); 1446 dev_hold(rt->u.dst.dev);
1418 if (rt->idev) 1447 if (rt->idev)
1419 in_dev_hold(rt->idev); 1448 in_dev_hold(rt->idev);
1420 rt->u.dst.obsolete = 0; 1449 rt->u.dst.obsolete = -1;
1421 rt->u.dst.lastuse = jiffies; 1450 rt->u.dst.lastuse = jiffies;
1422 rt->u.dst.path = &rt->u.dst; 1451 rt->u.dst.path = &rt->u.dst;
1423 rt->u.dst.neighbour = NULL; 1452 rt->u.dst.neighbour = NULL;
@@ -1453,7 +1482,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1453 &netevent); 1482 &netevent);
1454 1483
1455 rt_del(hash, rth); 1484 rt_del(hash, rth);
1456 if (!rt_intern_hash(hash, rt, &rt, NULL)) 1485 if (!rt_intern_hash(hash, rt, &rt, NULL, rt->fl.oif))
1457 ip_rt_put(rt); 1486 ip_rt_put(rt);
1458 goto do_next; 1487 goto do_next;
1459 } 1488 }
@@ -1482,11 +1511,12 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1482 struct dst_entry *ret = dst; 1511 struct dst_entry *ret = dst;
1483 1512
1484 if (rt) { 1513 if (rt) {
1485 if (dst->obsolete) { 1514 if (dst->obsolete > 0) {
1486 ip_rt_put(rt); 1515 ip_rt_put(rt);
1487 ret = NULL; 1516 ret = NULL;
1488 } else if ((rt->rt_flags & RTCF_REDIRECTED) || 1517 } else if ((rt->rt_flags & RTCF_REDIRECTED) ||
1489 rt->u.dst.expires) { 1518 (rt->u.dst.expires &&
1519 time_after_eq(jiffies, rt->u.dst.expires))) {
1490 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src, 1520 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
1491 rt->fl.oif, 1521 rt->fl.oif,
1492 rt_genid(dev_net(dst->dev))); 1522 rt_genid(dev_net(dst->dev)));
@@ -1702,7 +1732,9 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
1702 1732
1703static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie) 1733static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie)
1704{ 1734{
1705 return NULL; 1735 if (rt_is_expired((struct rtable *)dst))
1736 return NULL;
1737 return dst;
1706} 1738}
1707 1739
1708static void ipv4_dst_destroy(struct dst_entry *dst) 1740static void ipv4_dst_destroy(struct dst_entry *dst)
@@ -1864,7 +1896,8 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1864 if (!rth) 1896 if (!rth)
1865 goto e_nobufs; 1897 goto e_nobufs;
1866 1898
1867 rth->u.dst.output= ip_rt_bug; 1899 rth->u.dst.output = ip_rt_bug;
1900 rth->u.dst.obsolete = -1;
1868 1901
1869 atomic_set(&rth->u.dst.__refcnt, 1); 1902 atomic_set(&rth->u.dst.__refcnt, 1);
1870 rth->u.dst.flags= DST_HOST; 1903 rth->u.dst.flags= DST_HOST;
@@ -1903,7 +1936,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1903 1936
1904 in_dev_put(in_dev); 1937 in_dev_put(in_dev);
1905 hash = rt_hash(daddr, saddr, dev->ifindex, rt_genid(dev_net(dev))); 1938 hash = rt_hash(daddr, saddr, dev->ifindex, rt_genid(dev_net(dev)));
1906 return rt_intern_hash(hash, rth, NULL, skb); 1939 return rt_intern_hash(hash, rth, NULL, skb, dev->ifindex);
1907 1940
1908e_nobufs: 1941e_nobufs:
1909 in_dev_put(in_dev); 1942 in_dev_put(in_dev);
@@ -2030,6 +2063,7 @@ static int __mkroute_input(struct sk_buff *skb,
2030 rth->fl.oif = 0; 2063 rth->fl.oif = 0;
2031 rth->rt_spec_dst= spec_dst; 2064 rth->rt_spec_dst= spec_dst;
2032 2065
2066 rth->u.dst.obsolete = -1;
2033 rth->u.dst.input = ip_forward; 2067 rth->u.dst.input = ip_forward;
2034 rth->u.dst.output = ip_output; 2068 rth->u.dst.output = ip_output;
2035 rth->rt_genid = rt_genid(dev_net(rth->u.dst.dev)); 2069 rth->rt_genid = rt_genid(dev_net(rth->u.dst.dev));
@@ -2069,7 +2103,7 @@ static int ip_mkroute_input(struct sk_buff *skb,
2069 /* put it into the cache */ 2103 /* put it into the cache */
2070 hash = rt_hash(daddr, saddr, fl->iif, 2104 hash = rt_hash(daddr, saddr, fl->iif,
2071 rt_genid(dev_net(rth->u.dst.dev))); 2105 rt_genid(dev_net(rth->u.dst.dev)));
2072 return rt_intern_hash(hash, rth, NULL, skb); 2106 return rt_intern_hash(hash, rth, NULL, skb, fl->iif);
2073} 2107}
2074 2108
2075/* 2109/*
@@ -2194,6 +2228,7 @@ local_input:
2194 goto e_nobufs; 2228 goto e_nobufs;
2195 2229
2196 rth->u.dst.output= ip_rt_bug; 2230 rth->u.dst.output= ip_rt_bug;
2231 rth->u.dst.obsolete = -1;
2197 rth->rt_genid = rt_genid(net); 2232 rth->rt_genid = rt_genid(net);
2198 2233
2199 atomic_set(&rth->u.dst.__refcnt, 1); 2234 atomic_set(&rth->u.dst.__refcnt, 1);
@@ -2225,7 +2260,7 @@ local_input:
2225 } 2260 }
2226 rth->rt_type = res.type; 2261 rth->rt_type = res.type;
2227 hash = rt_hash(daddr, saddr, fl.iif, rt_genid(net)); 2262 hash = rt_hash(daddr, saddr, fl.iif, rt_genid(net));
2228 err = rt_intern_hash(hash, rth, NULL, skb); 2263 err = rt_intern_hash(hash, rth, NULL, skb, fl.iif);
2229 goto done; 2264 goto done;
2230 2265
2231no_route: 2266no_route:
@@ -2420,6 +2455,7 @@ static int __mkroute_output(struct rtable **result,
2420 rth->rt_spec_dst= fl->fl4_src; 2455 rth->rt_spec_dst= fl->fl4_src;
2421 2456
2422 rth->u.dst.output=ip_output; 2457 rth->u.dst.output=ip_output;
2458 rth->u.dst.obsolete = -1;
2423 rth->rt_genid = rt_genid(dev_net(dev_out)); 2459 rth->rt_genid = rt_genid(dev_net(dev_out));
2424 2460
2425 RT_CACHE_STAT_INC(out_slow_tot); 2461 RT_CACHE_STAT_INC(out_slow_tot);
@@ -2471,7 +2507,7 @@ static int ip_mkroute_output(struct rtable **rp,
2471 if (err == 0) { 2507 if (err == 0) {
2472 hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif, 2508 hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif,
2473 rt_genid(dev_net(dev_out))); 2509 rt_genid(dev_net(dev_out)));
2474 err = rt_intern_hash(hash, rth, rp, NULL); 2510 err = rt_intern_hash(hash, rth, rp, NULL, oldflp->oif);
2475 } 2511 }
2476 2512
2477 return err; 2513 return err;
@@ -3077,22 +3113,20 @@ static void rt_secret_reschedule(int old)
3077 rtnl_lock(); 3113 rtnl_lock();
3078 for_each_net(net) { 3114 for_each_net(net) {
3079 int deleted = del_timer_sync(&net->ipv4.rt_secret_timer); 3115 int deleted = del_timer_sync(&net->ipv4.rt_secret_timer);
3116 long time;
3080 3117
3081 if (!new) 3118 if (!new)
3082 continue; 3119 continue;
3083 3120
3084 if (deleted) { 3121 if (deleted) {
3085 long time = net->ipv4.rt_secret_timer.expires - jiffies; 3122 time = net->ipv4.rt_secret_timer.expires - jiffies;
3086 3123
3087 if (time <= 0 || (time += diff) <= 0) 3124 if (time <= 0 || (time += diff) <= 0)
3088 time = 0; 3125 time = 0;
3089
3090 net->ipv4.rt_secret_timer.expires = time;
3091 } else 3126 } else
3092 net->ipv4.rt_secret_timer.expires = new; 3127 time = new;
3093 3128
3094 net->ipv4.rt_secret_timer.expires += jiffies; 3129 mod_timer(&net->ipv4.rt_secret_timer, jiffies + time);
3095 add_timer(&net->ipv4.rt_secret_timer);
3096 } 3130 }
3097 rtnl_unlock(); 3131 rtnl_unlock();
3098} 3132}
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 5901010fad5..6afb6d8662b 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -429,7 +429,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
429 if (tp->urg_seq == tp->copied_seq && 429 if (tp->urg_seq == tp->copied_seq &&
430 !sock_flag(sk, SOCK_URGINLINE) && 430 !sock_flag(sk, SOCK_URGINLINE) &&
431 tp->urg_data) 431 tp->urg_data)
432 target--; 432 target++;
433 433
434 /* Potential race condition. If read of tp below will 434 /* Potential race condition. If read of tp below will
435 * escape above sk->sk_state, we can be illegally awaken 435 * escape above sk->sk_state, we can be illegally awaken
@@ -1254,6 +1254,39 @@ static void tcp_prequeue_process(struct sock *sk)
1254 tp->ucopy.memory = 0; 1254 tp->ucopy.memory = 0;
1255} 1255}
1256 1256
1257#ifdef CONFIG_NET_DMA
1258static void tcp_service_net_dma(struct sock *sk, bool wait)
1259{
1260 dma_cookie_t done, used;
1261 dma_cookie_t last_issued;
1262 struct tcp_sock *tp = tcp_sk(sk);
1263
1264 if (!tp->ucopy.dma_chan)
1265 return;
1266
1267 last_issued = tp->ucopy.dma_cookie;
1268 dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
1269
1270 do {
1271 if (dma_async_memcpy_complete(tp->ucopy.dma_chan,
1272 last_issued, &done,
1273 &used) == DMA_SUCCESS) {
1274 /* Safe to free early-copied skbs now */
1275 __skb_queue_purge(&sk->sk_async_wait_queue);
1276 break;
1277 } else {
1278 struct sk_buff *skb;
1279 while ((skb = skb_peek(&sk->sk_async_wait_queue)) &&
1280 (dma_async_is_complete(skb->dma_cookie, done,
1281 used) == DMA_SUCCESS)) {
1282 __skb_dequeue(&sk->sk_async_wait_queue);
1283 kfree_skb(skb);
1284 }
1285 }
1286 } while (wait);
1287}
1288#endif
1289
1257static inline struct sk_buff *tcp_recv_skb(struct sock *sk, u32 seq, u32 *off) 1290static inline struct sk_buff *tcp_recv_skb(struct sock *sk, u32 seq, u32 *off)
1258{ 1291{
1259 struct sk_buff *skb; 1292 struct sk_buff *skb;
@@ -1546,6 +1579,10 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1546 /* __ Set realtime policy in scheduler __ */ 1579 /* __ Set realtime policy in scheduler __ */
1547 } 1580 }
1548 1581
1582#ifdef CONFIG_NET_DMA
1583 if (tp->ucopy.dma_chan)
1584 dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
1585#endif
1549 if (copied >= target) { 1586 if (copied >= target) {
1550 /* Do not sleep, just process backlog. */ 1587 /* Do not sleep, just process backlog. */
1551 release_sock(sk); 1588 release_sock(sk);
@@ -1554,6 +1591,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1554 sk_wait_data(sk, &timeo); 1591 sk_wait_data(sk, &timeo);
1555 1592
1556#ifdef CONFIG_NET_DMA 1593#ifdef CONFIG_NET_DMA
1594 tcp_service_net_dma(sk, false); /* Don't block */
1557 tp->ucopy.wakeup = 0; 1595 tp->ucopy.wakeup = 0;
1558#endif 1596#endif
1559 1597
@@ -1633,6 +1671,9 @@ do_prequeue:
1633 copied = -EFAULT; 1671 copied = -EFAULT;
1634 break; 1672 break;
1635 } 1673 }
1674
1675 dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
1676
1636 if ((offset + used) == skb->len) 1677 if ((offset + used) == skb->len)
1637 copied_early = 1; 1678 copied_early = 1;
1638 1679
@@ -1702,27 +1743,9 @@ skip_copy:
1702 } 1743 }
1703 1744
1704#ifdef CONFIG_NET_DMA 1745#ifdef CONFIG_NET_DMA
1705 if (tp->ucopy.dma_chan) { 1746 tcp_service_net_dma(sk, true); /* Wait for queue to drain */
1706 dma_cookie_t done, used; 1747 tp->ucopy.dma_chan = NULL;
1707
1708 dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
1709
1710 while (dma_async_memcpy_complete(tp->ucopy.dma_chan,
1711 tp->ucopy.dma_cookie, &done,
1712 &used) == DMA_IN_PROGRESS) {
1713 /* do partial cleanup of sk_async_wait_queue */
1714 while ((skb = skb_peek(&sk->sk_async_wait_queue)) &&
1715 (dma_async_is_complete(skb->dma_cookie, done,
1716 used) == DMA_SUCCESS)) {
1717 __skb_dequeue(&sk->sk_async_wait_queue);
1718 kfree_skb(skb);
1719 }
1720 }
1721 1748
1722 /* Safe to free early-copied skbs now */
1723 __skb_queue_purge(&sk->sk_async_wait_queue);
1724 tp->ucopy.dma_chan = NULL;
1725 }
1726 if (tp->ucopy.pinned_list) { 1749 if (tp->ucopy.pinned_list) {
1727 dma_unpin_iovec_pages(tp->ucopy.pinned_list); 1750 dma_unpin_iovec_pages(tp->ucopy.pinned_list);
1728 tp->ucopy.pinned_list = NULL; 1751 tp->ucopy.pinned_list = NULL;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 788851ca8c5..c096a4218b8 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2511,6 +2511,9 @@ static void tcp_mark_head_lost(struct sock *sk, int packets)
2511 int err; 2511 int err;
2512 unsigned int mss; 2512 unsigned int mss;
2513 2513
2514 if (packets == 0)
2515 return;
2516
2514 WARN_ON(packets > tp->packets_out); 2517 WARN_ON(packets > tp->packets_out);
2515 if (tp->lost_skb_hint) { 2518 if (tp->lost_skb_hint) {
2516 skb = tp->lost_skb_hint; 2519 skb = tp->lost_skb_hint;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index c3588b4fd97..f4df5f931f3 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -370,6 +370,11 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
370 if (sk->sk_state == TCP_CLOSE) 370 if (sk->sk_state == TCP_CLOSE)
371 goto out; 371 goto out;
372 372
373 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
374 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
375 goto out;
376 }
377
373 icsk = inet_csk(sk); 378 icsk = inet_csk(sk);
374 tp = tcp_sk(sk); 379 tp = tcp_sk(sk);
375 seq = ntohl(th->seq); 380 seq = ntohl(th->seq);
@@ -1651,13 +1656,15 @@ int tcp_v4_rcv(struct sk_buff *skb)
1651 if (!sk) 1656 if (!sk)
1652 goto no_tcp_socket; 1657 goto no_tcp_socket;
1653 1658
1654 if (iph->ttl < inet_sk(sk)->min_ttl)
1655 goto discard_and_relse;
1656
1657process: 1659process:
1658 if (sk->sk_state == TCP_TIME_WAIT) 1660 if (sk->sk_state == TCP_TIME_WAIT)
1659 goto do_time_wait; 1661 goto do_time_wait;
1660 1662
1663 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
1664 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
1665 goto discard_and_relse;
1666 }
1667
1661 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) 1668 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
1662 goto discard_and_relse; 1669 goto discard_and_relse;
1663 nf_reset(skb); 1670 nf_reset(skb);
@@ -1682,8 +1689,11 @@ process:
1682 if (!tcp_prequeue(sk, skb)) 1689 if (!tcp_prequeue(sk, skb))
1683 ret = tcp_v4_do_rcv(sk, skb); 1690 ret = tcp_v4_do_rcv(sk, skb);
1684 } 1691 }
1685 } else 1692 } else if (unlikely(sk_add_backlog(sk, skb))) {
1686 sk_add_backlog(sk, skb); 1693 bh_unlock_sock(sk);
1694 NET_INC_STATS_BH(net, LINUX_MIB_TCPBACKLOGDROP);
1695 goto discard_and_relse;
1696 }
1687 bh_unlock_sock(sk); 1697 bh_unlock_sock(sk);
1688 1698
1689 sock_put(sk); 1699 sock_put(sk);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index f206ee5dda8..4199bc6915c 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -728,7 +728,7 @@ int tcp_child_process(struct sock *parent, struct sock *child,
728 * in main socket hash table and lock on listening 728 * in main socket hash table and lock on listening
729 * socket does not protect us more. 729 * socket does not protect us more.
730 */ 730 */
731 sk_add_backlog(child, skb); 731 __sk_add_backlog(child, skb);
732 } 732 }
733 733
734 bh_unlock_sock(child); 734 bh_unlock_sock(child);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4a1605d3f90..f181b78f238 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2395,13 +2395,17 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2395 struct tcp_extend_values *xvp = tcp_xv(rvp); 2395 struct tcp_extend_values *xvp = tcp_xv(rvp);
2396 struct inet_request_sock *ireq = inet_rsk(req); 2396 struct inet_request_sock *ireq = inet_rsk(req);
2397 struct tcp_sock *tp = tcp_sk(sk); 2397 struct tcp_sock *tp = tcp_sk(sk);
2398 const struct tcp_cookie_values *cvp = tp->cookie_values;
2398 struct tcphdr *th; 2399 struct tcphdr *th;
2399 struct sk_buff *skb; 2400 struct sk_buff *skb;
2400 struct tcp_md5sig_key *md5; 2401 struct tcp_md5sig_key *md5;
2401 int tcp_header_size; 2402 int tcp_header_size;
2402 int mss; 2403 int mss;
2404 int s_data_desired = 0;
2403 2405
2404 skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC); 2406 if (cvp != NULL && cvp->s_data_constant && cvp->s_data_desired)
2407 s_data_desired = cvp->s_data_desired;
2408 skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15 + s_data_desired, 1, GFP_ATOMIC);
2405 if (skb == NULL) 2409 if (skb == NULL)
2406 return NULL; 2410 return NULL;
2407 2411
@@ -2457,16 +2461,12 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2457 TCPCB_FLAG_SYN | TCPCB_FLAG_ACK); 2461 TCPCB_FLAG_SYN | TCPCB_FLAG_ACK);
2458 2462
2459 if (OPTION_COOKIE_EXTENSION & opts.options) { 2463 if (OPTION_COOKIE_EXTENSION & opts.options) {
2460 const struct tcp_cookie_values *cvp = tp->cookie_values; 2464 if (s_data_desired) {
2461 2465 u8 *buf = skb_put(skb, s_data_desired);
2462 if (cvp != NULL &&
2463 cvp->s_data_constant &&
2464 cvp->s_data_desired > 0) {
2465 u8 *buf = skb_put(skb, cvp->s_data_desired);
2466 2466
2467 /* copy data directly from the listening socket. */ 2467 /* copy data directly from the listening socket. */
2468 memcpy(buf, cvp->s_data_payload, cvp->s_data_desired); 2468 memcpy(buf, cvp->s_data_payload, s_data_desired);
2469 TCP_SKB_CB(skb)->end_seq += cvp->s_data_desired; 2469 TCP_SKB_CB(skb)->end_seq += s_data_desired;
2470 } 2470 }
2471 2471
2472 if (opts.hash_size > 0) { 2472 if (opts.hash_size > 0) {
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index a17629b8912..b2e6bbccaee 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -134,7 +134,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
134} 134}
135 135
136/* This function calculates a "timeout" which is equivalent to the timeout of a 136/* This function calculates a "timeout" which is equivalent to the timeout of a
137 * TCP connection after "boundary" unsucessful, exponentially backed-off 137 * TCP connection after "boundary" unsuccessful, exponentially backed-off
138 * retransmissions with an initial RTO of TCP_RTO_MIN. 138 * retransmissions with an initial RTO of TCP_RTO_MIN.
139 */ 139 */
140static bool retransmits_timed_out(struct sock *sk, 140static bool retransmits_timed_out(struct sock *sk,
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 608a5446d05..7af756d0f93 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1371,8 +1371,10 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1371 bh_lock_sock(sk); 1371 bh_lock_sock(sk);
1372 if (!sock_owned_by_user(sk)) 1372 if (!sock_owned_by_user(sk))
1373 rc = __udp_queue_rcv_skb(sk, skb); 1373 rc = __udp_queue_rcv_skb(sk, skb);
1374 else 1374 else if (sk_add_backlog(sk, skb)) {
1375 sk_add_backlog(sk, skb); 1375 bh_unlock_sock(sk);
1376 goto drop;
1377 }
1376 bh_unlock_sock(sk); 1378 bh_unlock_sock(sk);
1377 1379
1378 return rc; 1380 return rc;
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 67107d63c1c..e4a1483fba7 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -91,11 +91,12 @@ static int xfrm4_init_path(struct xfrm_dst *path, struct dst_entry *dst,
91 return 0; 91 return 0;
92} 92}
93 93
94static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev) 94static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
95 struct flowi *fl)
95{ 96{
96 struct rtable *rt = (struct rtable *)xdst->route; 97 struct rtable *rt = (struct rtable *)xdst->route;
97 98
98 xdst->u.rt.fl = rt->fl; 99 xdst->u.rt.fl = *fl;
99 100
100 xdst->u.dst.dev = dev; 101 xdst->u.dst.dev = dev;
101 dev_hold(dev); 102 dev_hold(dev);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 88fd8c5877e..7e567ae5eaa 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1380,6 +1380,8 @@ static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed)
1380 if (dad_failed) 1380 if (dad_failed)
1381 ifp->flags |= IFA_F_DADFAILED; 1381 ifp->flags |= IFA_F_DADFAILED;
1382 spin_unlock_bh(&ifp->lock); 1382 spin_unlock_bh(&ifp->lock);
1383 if (dad_failed)
1384 ipv6_ifa_notify(0, ifp);
1383 in6_ifa_put(ifp); 1385 in6_ifa_put(ifp);
1384#ifdef CONFIG_IPV6_PRIVACY 1386#ifdef CONFIG_IPV6_PRIVACY
1385 } else if (ifp->flags&IFA_F_TEMPORARY) { 1387 } else if (ifp->flags&IFA_F_TEMPORARY) {
@@ -2615,7 +2617,7 @@ static void addrconf_bonding_change(struct net_device *dev, unsigned long event)
2615static int addrconf_ifdown(struct net_device *dev, int how) 2617static int addrconf_ifdown(struct net_device *dev, int how)
2616{ 2618{
2617 struct inet6_dev *idev; 2619 struct inet6_dev *idev;
2618 struct inet6_ifaddr *ifa, **bifa; 2620 struct inet6_ifaddr *ifa, *keep_list, **bifa;
2619 struct net *net = dev_net(dev); 2621 struct net *net = dev_net(dev);
2620 int i; 2622 int i;
2621 2623
@@ -2649,11 +2651,11 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2649 write_lock_bh(&addrconf_hash_lock); 2651 write_lock_bh(&addrconf_hash_lock);
2650 while ((ifa = *bifa) != NULL) { 2652 while ((ifa = *bifa) != NULL) {
2651 if (ifa->idev == idev && 2653 if (ifa->idev == idev &&
2652 (how || !(ifa->flags&IFA_F_PERMANENT))) { 2654 (how || !(ifa->flags&IFA_F_PERMANENT) ||
2655 ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) {
2653 *bifa = ifa->lst_next; 2656 *bifa = ifa->lst_next;
2654 ifa->lst_next = NULL; 2657 ifa->lst_next = NULL;
2655 addrconf_del_timer(ifa); 2658 __in6_ifa_put(ifa);
2656 in6_ifa_put(ifa);
2657 continue; 2659 continue;
2658 } 2660 }
2659 bifa = &ifa->lst_next; 2661 bifa = &ifa->lst_next;
@@ -2689,31 +2691,51 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2689 write_lock_bh(&idev->lock); 2691 write_lock_bh(&idev->lock);
2690 } 2692 }
2691#endif 2693#endif
2692 bifa = &idev->addr_list; 2694 keep_list = NULL;
2693 while ((ifa = *bifa) != NULL) { 2695 bifa = &keep_list;
2694 if (how == 0 && (ifa->flags&IFA_F_PERMANENT)) { 2696 while ((ifa = idev->addr_list) != NULL) {
2695 /* Retain permanent address on admin down */ 2697 idev->addr_list = ifa->if_next;
2698 ifa->if_next = NULL;
2699
2700 addrconf_del_timer(ifa);
2701
2702 /* If just doing link down, and address is permanent
2703 and not link-local, then retain it. */
2704 if (how == 0 &&
2705 (ifa->flags&IFA_F_PERMANENT) &&
2706 !(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) {
2707
2708 /* Move to holding list */
2709 *bifa = ifa;
2696 bifa = &ifa->if_next; 2710 bifa = &ifa->if_next;
2697 2711
2698 /* Restart DAD if needed when link comes back up */ 2712 /* If not doing DAD on this address, just keep it. */
2699 if ( !((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) || 2713 if ((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) ||
2700 idev->cnf.accept_dad <= 0 || 2714 idev->cnf.accept_dad <= 0 ||
2701 (ifa->flags & IFA_F_NODAD))) 2715 (ifa->flags & IFA_F_NODAD))
2702 ifa->flags |= IFA_F_TENTATIVE; 2716 continue;
2703 } else {
2704 *bifa = ifa->if_next;
2705 ifa->if_next = NULL;
2706 2717
2718 /* If it was tentative already, no need to notify */
2719 if (ifa->flags & IFA_F_TENTATIVE)
2720 continue;
2721
2722 /* Flag it for later restoration when link comes up */
2723 ifa->flags |= IFA_F_TENTATIVE;
2724 in6_ifa_hold(ifa);
2725 } else {
2707 ifa->dead = 1; 2726 ifa->dead = 1;
2708 write_unlock_bh(&idev->lock); 2727 }
2728 write_unlock_bh(&idev->lock);
2709 2729
2710 __ipv6_ifa_notify(RTM_DELADDR, ifa); 2730 __ipv6_ifa_notify(RTM_DELADDR, ifa);
2711 atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa); 2731 atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
2712 in6_ifa_put(ifa); 2732 in6_ifa_put(ifa);
2713 2733
2714 write_lock_bh(&idev->lock); 2734 write_lock_bh(&idev->lock);
2715 }
2716 } 2735 }
2736
2737 idev->addr_list = keep_list;
2738
2717 write_unlock_bh(&idev->lock); 2739 write_unlock_bh(&idev->lock);
2718 2740
2719 /* Step 5: Discard multicast list */ 2741 /* Step 5: Discard multicast list */
@@ -2739,28 +2761,29 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2739static void addrconf_rs_timer(unsigned long data) 2761static void addrconf_rs_timer(unsigned long data)
2740{ 2762{
2741 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *) data; 2763 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *) data;
2764 struct inet6_dev *idev = ifp->idev;
2742 2765
2743 if (ifp->idev->cnf.forwarding) 2766 read_lock(&idev->lock);
2767 if (idev->dead || !(idev->if_flags & IF_READY))
2744 goto out; 2768 goto out;
2745 2769
2746 if (ifp->idev->if_flags & IF_RA_RCVD) { 2770 if (idev->cnf.forwarding)
2747 /* 2771 goto out;
2748 * Announcement received after solicitation 2772
2749 * was sent 2773 /* Announcement received after solicitation was sent */
2750 */ 2774 if (idev->if_flags & IF_RA_RCVD)
2751 goto out; 2775 goto out;
2752 }
2753 2776
2754 spin_lock(&ifp->lock); 2777 spin_lock(&ifp->lock);
2755 if (ifp->probes++ < ifp->idev->cnf.rtr_solicits) { 2778 if (ifp->probes++ < idev->cnf.rtr_solicits) {
2756 /* The wait after the last probe can be shorter */ 2779 /* The wait after the last probe can be shorter */
2757 addrconf_mod_timer(ifp, AC_RS, 2780 addrconf_mod_timer(ifp, AC_RS,
2758 (ifp->probes == ifp->idev->cnf.rtr_solicits) ? 2781 (ifp->probes == idev->cnf.rtr_solicits) ?
2759 ifp->idev->cnf.rtr_solicit_delay : 2782 idev->cnf.rtr_solicit_delay :
2760 ifp->idev->cnf.rtr_solicit_interval); 2783 idev->cnf.rtr_solicit_interval);
2761 spin_unlock(&ifp->lock); 2784 spin_unlock(&ifp->lock);
2762 2785
2763 ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters); 2786 ndisc_send_rs(idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
2764 } else { 2787 } else {
2765 spin_unlock(&ifp->lock); 2788 spin_unlock(&ifp->lock);
2766 /* 2789 /*
@@ -2768,10 +2791,11 @@ static void addrconf_rs_timer(unsigned long data)
2768 * assumption any longer. 2791 * assumption any longer.
2769 */ 2792 */
2770 printk(KERN_DEBUG "%s: no IPv6 routers present\n", 2793 printk(KERN_DEBUG "%s: no IPv6 routers present\n",
2771 ifp->idev->dev->name); 2794 idev->dev->name);
2772 } 2795 }
2773 2796
2774out: 2797out:
2798 read_unlock(&idev->lock);
2775 in6_ifa_put(ifp); 2799 in6_ifa_put(ifp);
2776} 2800}
2777 2801
@@ -2850,9 +2874,9 @@ static void addrconf_dad_timer(unsigned long data)
2850 struct inet6_dev *idev = ifp->idev; 2874 struct inet6_dev *idev = ifp->idev;
2851 struct in6_addr mcaddr; 2875 struct in6_addr mcaddr;
2852 2876
2853 read_lock_bh(&idev->lock); 2877 read_lock(&idev->lock);
2854 if (idev->dead) { 2878 if (idev->dead || !(idev->if_flags & IF_READY)) {
2855 read_unlock_bh(&idev->lock); 2879 read_unlock(&idev->lock);
2856 goto out; 2880 goto out;
2857 } 2881 }
2858 2882
@@ -2864,7 +2888,7 @@ static void addrconf_dad_timer(unsigned long data)
2864 2888
2865 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); 2889 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
2866 spin_unlock(&ifp->lock); 2890 spin_unlock(&ifp->lock);
2867 read_unlock_bh(&idev->lock); 2891 read_unlock(&idev->lock);
2868 2892
2869 addrconf_dad_completed(ifp); 2893 addrconf_dad_completed(ifp);
2870 2894
@@ -2874,7 +2898,7 @@ static void addrconf_dad_timer(unsigned long data)
2874 ifp->probes--; 2898 ifp->probes--;
2875 addrconf_mod_timer(ifp, AC_DAD, ifp->idev->nd_parms->retrans_time); 2899 addrconf_mod_timer(ifp, AC_DAD, ifp->idev->nd_parms->retrans_time);
2876 spin_unlock(&ifp->lock); 2900 spin_unlock(&ifp->lock);
2877 read_unlock_bh(&idev->lock); 2901 read_unlock(&idev->lock);
2878 2902
2879 /* send a neighbour solicitation for our addr */ 2903 /* send a neighbour solicitation for our addr */
2880 addrconf_addr_solict_mult(&ifp->addr, &mcaddr); 2904 addrconf_addr_solict_mult(&ifp->addr, &mcaddr);
@@ -3586,7 +3610,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
3586 hlist_for_each_entry_rcu(dev, node, head, index_hlist) { 3610 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
3587 if (idx < s_idx) 3611 if (idx < s_idx)
3588 goto cont; 3612 goto cont;
3589 if (idx > s_idx) 3613 if (h > s_h || idx > s_idx)
3590 s_ip_idx = 0; 3614 s_ip_idx = 0;
3591 ip_idx = 0; 3615 ip_idx = 0;
3592 if ((idev = __in6_dev_get(dev)) == NULL) 3616 if ((idev = __in6_dev_get(dev)) == NULL)
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 551882b9dfd..5e463c43fcc 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -84,18 +84,11 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
84 if ((rule->flags & FIB_RULE_FIND_SADDR) && 84 if ((rule->flags & FIB_RULE_FIND_SADDR) &&
85 r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) { 85 r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) {
86 struct in6_addr saddr; 86 struct in6_addr saddr;
87 unsigned int srcprefs = 0;
88
89 if (flags & RT6_LOOKUP_F_SRCPREF_TMP)
90 srcprefs |= IPV6_PREFER_SRC_TMP;
91 if (flags & RT6_LOOKUP_F_SRCPREF_PUBLIC)
92 srcprefs |= IPV6_PREFER_SRC_PUBLIC;
93 if (flags & RT6_LOOKUP_F_SRCPREF_COA)
94 srcprefs |= IPV6_PREFER_SRC_COA;
95 87
96 if (ipv6_dev_get_saddr(net, 88 if (ipv6_dev_get_saddr(net,
97 ip6_dst_idev(&rt->u.dst)->dev, 89 ip6_dst_idev(&rt->u.dst)->dev,
98 &flp->fl6_dst, srcprefs, 90 &flp->fl6_dst,
91 rt6_flags2srcprefs(flags),
99 &saddr)) 92 &saddr))
100 goto again; 93 goto again;
101 if (!ipv6_prefix_equal(&saddr, &r->src.addr, 94 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 52e0f74fdfe..27acfb58650 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1113,6 +1113,9 @@ static int ip6mr_mfc_add(struct net *net, struct mf6cctl *mfc, int mrtsock)
1113 unsigned char ttls[MAXMIFS]; 1113 unsigned char ttls[MAXMIFS];
1114 int i; 1114 int i;
1115 1115
1116 if (mfc->mf6cc_parent >= MAXMIFS)
1117 return -ENFILE;
1118
1116 memset(ttls, 255, MAXMIFS); 1119 memset(ttls, 255, MAXMIFS);
1117 for (i = 0; i < MAXMIFS; i++) { 1120 for (i = 0; i < MAXMIFS; i++) {
1118 if (IF_ISSET(i, &mfc->mf6cc_ifset)) 1121 if (IF_ISSET(i, &mfc->mf6cc_ifset))
@@ -1692,17 +1695,20 @@ ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm)
1692 int ct; 1695 int ct;
1693 struct rtnexthop *nhp; 1696 struct rtnexthop *nhp;
1694 struct net *net = mfc6_net(c); 1697 struct net *net = mfc6_net(c);
1695 struct net_device *dev = net->ipv6.vif6_table[c->mf6c_parent].dev;
1696 u8 *b = skb_tail_pointer(skb); 1698 u8 *b = skb_tail_pointer(skb);
1697 struct rtattr *mp_head; 1699 struct rtattr *mp_head;
1698 1700
1699 if (dev) 1701 /* If cache is unresolved, don't try to parse IIF and OIF */
1700 RTA_PUT(skb, RTA_IIF, 4, &dev->ifindex); 1702 if (c->mf6c_parent > MAXMIFS)
1703 return -ENOENT;
1704
1705 if (MIF_EXISTS(net, c->mf6c_parent))
1706 RTA_PUT(skb, RTA_IIF, 4, &net->ipv6.vif6_table[c->mf6c_parent].dev->ifindex);
1701 1707
1702 mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0)); 1708 mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0));
1703 1709
1704 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) { 1710 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
1705 if (c->mfc_un.res.ttls[ct] < 255) { 1711 if (MIF_EXISTS(net, ct) && c->mfc_un.res.ttls[ct] < 255) {
1706 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4)) 1712 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
1707 goto rtattr_failure; 1713 goto rtattr_failure;
1708 nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp))); 1714 nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index aef31a29de9..b9cf7cd6192 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -13,7 +13,7 @@ static const struct xt_table packet_raw = {
13 .valid_hooks = RAW_VALID_HOOKS, 13 .valid_hooks = RAW_VALID_HOOKS,
14 .me = THIS_MODULE, 14 .me = THIS_MODULE,
15 .af = NFPROTO_IPV6, 15 .af = NFPROTO_IPV6,
16 .priority = NF_IP6_PRI_FIRST, 16 .priority = NF_IP6_PRI_RAW,
17}; 17};
18 18
19/* The work comes in here from netfilter.c. */ 19/* The work comes in here from netfilter.c. */
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b08879e97f2..0d7713c5c20 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -819,15 +819,8 @@ struct dst_entry * ip6_route_output(struct net *net, struct sock *sk,
819 819
820 if (!ipv6_addr_any(&fl->fl6_src)) 820 if (!ipv6_addr_any(&fl->fl6_src))
821 flags |= RT6_LOOKUP_F_HAS_SADDR; 821 flags |= RT6_LOOKUP_F_HAS_SADDR;
822 else if (sk) { 822 else if (sk)
823 unsigned int prefs = inet6_sk(sk)->srcprefs; 823 flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs);
824 if (prefs & IPV6_PREFER_SRC_TMP)
825 flags |= RT6_LOOKUP_F_SRCPREF_TMP;
826 if (prefs & IPV6_PREFER_SRC_PUBLIC)
827 flags |= RT6_LOOKUP_F_SRCPREF_PUBLIC;
828 if (prefs & IPV6_PREFER_SRC_COA)
829 flags |= RT6_LOOKUP_F_SRCPREF_COA;
830 }
831 824
832 return fib6_rule_lookup(net, fl, flags, ip6_pol_route_output); 825 return fib6_rule_lookup(net, fl, flags, ip6_pol_route_output);
833} 826}
@@ -886,7 +879,7 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie)
886 879
887 rt = (struct rt6_info *) dst; 880 rt = (struct rt6_info *) dst;
888 881
889 if (rt && rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) 882 if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie))
890 return dst; 883 return dst;
891 884
892 return NULL; 885 return NULL;
@@ -897,12 +890,17 @@ static struct dst_entry *ip6_negative_advice(struct dst_entry *dst)
897 struct rt6_info *rt = (struct rt6_info *) dst; 890 struct rt6_info *rt = (struct rt6_info *) dst;
898 891
899 if (rt) { 892 if (rt) {
900 if (rt->rt6i_flags & RTF_CACHE) 893 if (rt->rt6i_flags & RTF_CACHE) {
901 ip6_del_rt(rt); 894 if (rt6_check_expired(rt)) {
902 else 895 ip6_del_rt(rt);
896 dst = NULL;
897 }
898 } else {
903 dst_release(dst); 899 dst_release(dst);
900 dst = NULL;
901 }
904 } 902 }
905 return NULL; 903 return dst;
906} 904}
907 905
908static void ip6_link_failure(struct sk_buff *skb) 906static void ip6_link_failure(struct sk_buff *skb)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 6963a6b6763..9b6dbba80d3 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1740,8 +1740,11 @@ process:
1740 if (!tcp_prequeue(sk, skb)) 1740 if (!tcp_prequeue(sk, skb))
1741 ret = tcp_v6_do_rcv(sk, skb); 1741 ret = tcp_v6_do_rcv(sk, skb);
1742 } 1742 }
1743 } else 1743 } else if (unlikely(sk_add_backlog(sk, skb))) {
1744 sk_add_backlog(sk, skb); 1744 bh_unlock_sock(sk);
1745 NET_INC_STATS_BH(net, LINUX_MIB_TCPBACKLOGDROP);
1746 goto discard_and_relse;
1747 }
1745 bh_unlock_sock(sk); 1748 bh_unlock_sock(sk);
1746 1749
1747 sock_put(sk); 1750 sock_put(sk);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 52b8347ae3b..3c0c9c755c9 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -583,16 +583,20 @@ static void flush_stack(struct sock **stack, unsigned int count,
583 bh_lock_sock(sk); 583 bh_lock_sock(sk);
584 if (!sock_owned_by_user(sk)) 584 if (!sock_owned_by_user(sk))
585 udpv6_queue_rcv_skb(sk, skb1); 585 udpv6_queue_rcv_skb(sk, skb1);
586 else 586 else if (sk_add_backlog(sk, skb1)) {
587 sk_add_backlog(sk, skb1); 587 kfree_skb(skb1);
588 bh_unlock_sock(sk);
589 goto drop;
590 }
588 bh_unlock_sock(sk); 591 bh_unlock_sock(sk);
589 } else { 592 continue;
590 atomic_inc(&sk->sk_drops);
591 UDP6_INC_STATS_BH(sock_net(sk),
592 UDP_MIB_RCVBUFERRORS, IS_UDPLITE(sk));
593 UDP6_INC_STATS_BH(sock_net(sk),
594 UDP_MIB_INERRORS, IS_UDPLITE(sk));
595 } 593 }
594drop:
595 atomic_inc(&sk->sk_drops);
596 UDP6_INC_STATS_BH(sock_net(sk),
597 UDP_MIB_RCVBUFERRORS, IS_UDPLITE(sk));
598 UDP6_INC_STATS_BH(sock_net(sk),
599 UDP_MIB_INERRORS, IS_UDPLITE(sk));
596 } 600 }
597} 601}
598/* 602/*
@@ -754,8 +758,12 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
754 bh_lock_sock(sk); 758 bh_lock_sock(sk);
755 if (!sock_owned_by_user(sk)) 759 if (!sock_owned_by_user(sk))
756 udpv6_queue_rcv_skb(sk, skb); 760 udpv6_queue_rcv_skb(sk, skb);
757 else 761 else if (sk_add_backlog(sk, skb)) {
758 sk_add_backlog(sk, skb); 762 atomic_inc(&sk->sk_drops);
763 bh_unlock_sock(sk);
764 sock_put(sk);
765 goto discard;
766 }
759 bh_unlock_sock(sk); 767 bh_unlock_sock(sk);
760 sock_put(sk); 768 sock_put(sk);
761 return 0; 769 return 0;
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index dbdc696f5fc..ae181651c75 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -116,7 +116,8 @@ static int xfrm6_init_path(struct xfrm_dst *path, struct dst_entry *dst,
116 return 0; 116 return 0;
117} 117}
118 118
119static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev) 119static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
120 struct flowi *fl)
120{ 121{
121 struct rt6_info *rt = (struct rt6_info*)xdst->route; 122 struct rt6_info *rt = (struct rt6_info*)xdst->route;
122 123
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 36870788264..344145f23c3 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2129,10 +2129,9 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c
2129 int err; 2129 int err;
2130 2130
2131 out_skb = pfkey_xfrm_policy2msg_prep(xp); 2131 out_skb = pfkey_xfrm_policy2msg_prep(xp);
2132 if (IS_ERR(out_skb)) { 2132 if (IS_ERR(out_skb))
2133 err = PTR_ERR(out_skb); 2133 return PTR_ERR(out_skb);
2134 goto out; 2134
2135 }
2136 err = pfkey_xfrm_policy2msg(out_skb, xp, dir); 2135 err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
2137 if (err < 0) 2136 if (err < 0)
2138 return err; 2137 return err;
@@ -2148,7 +2147,6 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c
2148 out_hdr->sadb_msg_seq = c->seq; 2147 out_hdr->sadb_msg_seq = c->seq;
2149 out_hdr->sadb_msg_pid = c->pid; 2148 out_hdr->sadb_msg_pid = c->pid;
2150 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp)); 2149 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp));
2151out:
2152 return 0; 2150 return 0;
2153 2151
2154} 2152}
diff --git a/net/llc/llc_c_ac.c b/net/llc/llc_c_ac.c
index 019c780512e..86d6985b9d4 100644
--- a/net/llc/llc_c_ac.c
+++ b/net/llc/llc_c_ac.c
@@ -1437,7 +1437,7 @@ static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb)
1437 llc_conn_state_process(sk, skb); 1437 llc_conn_state_process(sk, skb);
1438 else { 1438 else {
1439 llc_set_backlog_type(skb, LLC_EVENT); 1439 llc_set_backlog_type(skb, LLC_EVENT);
1440 sk_add_backlog(sk, skb); 1440 __sk_add_backlog(sk, skb);
1441 } 1441 }
1442 } 1442 }
1443} 1443}
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
index a8dde9b010d..a12144da797 100644
--- a/net/llc/llc_conn.c
+++ b/net/llc/llc_conn.c
@@ -827,7 +827,8 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
827 else { 827 else {
828 dprintk("%s: adding to backlog...\n", __func__); 828 dprintk("%s: adding to backlog...\n", __func__);
829 llc_set_backlog_type(skb, LLC_PACKET); 829 llc_set_backlog_type(skb, LLC_PACKET);
830 sk_add_backlog(sk, skb); 830 if (sk_add_backlog(sk, skb))
831 goto drop_unlock;
831 } 832 }
832out: 833out:
833 bh_unlock_sock(sk); 834 bh_unlock_sock(sk);
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 9affe2cd185..b4ddb2f8391 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -48,20 +48,24 @@ static ssize_t ieee80211_if_write(
48 ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int)) 48 ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int))
49{ 49{
50 u8 *buf; 50 u8 *buf;
51 ssize_t ret = -ENODEV; 51 ssize_t ret;
52 52
53 buf = kzalloc(count, GFP_KERNEL); 53 buf = kmalloc(count, GFP_KERNEL);
54 if (!buf) 54 if (!buf)
55 return -ENOMEM; 55 return -ENOMEM;
56 56
57 ret = -EFAULT;
57 if (copy_from_user(buf, userbuf, count)) 58 if (copy_from_user(buf, userbuf, count))
58 return -EFAULT; 59 goto freebuf;
59 60
61 ret = -ENODEV;
60 rtnl_lock(); 62 rtnl_lock();
61 if (sdata->dev->reg_state == NETREG_REGISTERED) 63 if (sdata->dev->reg_state == NETREG_REGISTERED)
62 ret = (*write)(sdata, buf, count); 64 ret = (*write)(sdata, buf, count);
63 rtnl_unlock(); 65 rtnl_unlock();
64 66
67freebuf:
68 kfree(buf);
65 return ret; 69 return ret;
66} 70}
67 71
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index bc4e20e57ff..1a29c4a8139 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -744,7 +744,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
744 break; 744 break;
745 default: 745 default:
746 /* should not get here, PLINK_BLOCKED is dealt with at the 746 /* should not get here, PLINK_BLOCKED is dealt with at the
747 * beggining of the function 747 * beginning of the function
748 */ 748 */
749 spin_unlock_bh(&sta->lock); 749 spin_unlock_bh(&sta->lock);
750 break; 750 break;
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 41812a15eea..be5f723d643 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -177,7 +177,8 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
177 sta = sta_info_get(sdata, bssid); 177 sta = sta_info_get(sdata, bssid);
178 if (sta) 178 if (sta)
179 rate_control_rate_update(local, sband, sta, 179 rate_control_rate_update(local, sband, sta,
180 IEEE80211_RC_HT_CHANGED); 180 IEEE80211_RC_HT_CHANGED,
181 local->oper_channel_type);
181 rcu_read_unlock(); 182 rcu_read_unlock();
182 } 183 }
183 184
@@ -435,10 +436,12 @@ static void ieee80211_enable_ps(struct ieee80211_local *local,
435 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) 436 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
436 ieee80211_send_nullfunc(local, sdata, 1); 437 ieee80211_send_nullfunc(local, sdata, 1);
437 438
438 if (!(local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)) { 439 if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) &&
439 conf->flags |= IEEE80211_CONF_PS; 440 (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS))
440 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 441 return;
441 } 442
443 conf->flags |= IEEE80211_CONF_PS;
444 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
442 } 445 }
443} 446}
444 447
@@ -557,7 +560,8 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
557 (!(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED))) 560 (!(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)))
558 ieee80211_send_nullfunc(local, sdata, 1); 561 ieee80211_send_nullfunc(local, sdata, 1);
559 562
560 if (!(local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) || 563 if (!((local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) &&
564 (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) ||
561 (ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { 565 (ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) {
562 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; 566 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED;
563 local->hw.conf.flags |= IEEE80211_CONF_PS; 567 local->hw.conf.flags |= IEEE80211_CONF_PS;
@@ -1893,8 +1897,20 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
1893 1897
1894 mutex_lock(&ifmgd->mtx); 1898 mutex_lock(&ifmgd->mtx);
1895 if (ifmgd->associated) { 1899 if (ifmgd->associated) {
1896 mutex_unlock(&ifmgd->mtx); 1900 if (!req->prev_bssid ||
1897 return -EALREADY; 1901 memcmp(req->prev_bssid, ifmgd->associated->bssid,
1902 ETH_ALEN)) {
1903 /*
1904 * We are already associated and the request was not a
1905 * reassociation request from the current BSS, so
1906 * reject it.
1907 */
1908 mutex_unlock(&ifmgd->mtx);
1909 return -EALREADY;
1910 }
1911
1912 /* Trying to reassociate - clear previous association state */
1913 ieee80211_set_disassoc(sdata);
1898 } 1914 }
1899 mutex_unlock(&ifmgd->mtx); 1915 mutex_unlock(&ifmgd->mtx);
1900 1916
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h
index b6108bca96d..065a96190e3 100644
--- a/net/mac80211/rate.h
+++ b/net/mac80211/rate.h
@@ -66,7 +66,8 @@ static inline void rate_control_rate_init(struct sta_info *sta)
66 66
67static inline void rate_control_rate_update(struct ieee80211_local *local, 67static inline void rate_control_rate_update(struct ieee80211_local *local,
68 struct ieee80211_supported_band *sband, 68 struct ieee80211_supported_band *sband,
69 struct sta_info *sta, u32 changed) 69 struct sta_info *sta, u32 changed,
70 enum nl80211_channel_type oper_chan_type)
70{ 71{
71 struct rate_control_ref *ref = local->rate_ctrl; 72 struct rate_control_ref *ref = local->rate_ctrl;
72 struct ieee80211_sta *ista = &sta->sta; 73 struct ieee80211_sta *ista = &sta->sta;
@@ -74,7 +75,7 @@ static inline void rate_control_rate_update(struct ieee80211_local *local,
74 75
75 if (ref && ref->ops->rate_update) 76 if (ref && ref->ops->rate_update)
76 ref->ops->rate_update(ref->priv, sband, ista, 77 ref->ops->rate_update(ref->priv, sband, ista,
77 priv_sta, changed); 78 priv_sta, changed, oper_chan_type);
78} 79}
79 80
80static inline void *rate_control_alloc_sta(struct rate_control_ref *ref, 81static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 211c475f73c..56422d89435 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -434,6 +434,7 @@ int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU)
434 /* check if STA exists already */ 434 /* check if STA exists already */
435 if (sta_info_get_bss(sdata, sta->sta.addr)) { 435 if (sta_info_get_bss(sdata, sta->sta.addr)) {
436 spin_unlock_irqrestore(&local->sta_lock, flags); 436 spin_unlock_irqrestore(&local->sta_lock, flags);
437 mutex_unlock(&local->sta_mtx);
437 rcu_read_lock(); 438 rcu_read_lock();
438 err = -EEXIST; 439 err = -EEXIST;
439 goto out_free; 440 goto out_free;
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 2b2af631d2b..569410a8595 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -582,7 +582,9 @@ nla_put_failure:
582nlmsg_failure: 582nlmsg_failure:
583 kfree_skb(skb); 583 kfree_skb(skb);
584errout: 584errout:
585 nfnetlink_set_err(net, 0, group, -ENOBUFS); 585 if (nfnetlink_set_err(net, 0, group, -ENOBUFS) > 0)
586 return -ENOBUFS;
587
586 return 0; 588 return 0;
587} 589}
588#endif /* CONFIG_NF_CONNTRACK_EVENTS */ 590#endif /* CONFIG_NF_CONNTRACK_EVENTS */
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 8dd75d90efc..c6cd1b84edd 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -284,7 +284,7 @@ EXPORT_SYMBOL_GPL(ct_sip_parse_request);
284 * tabs, spaces and continuation lines, which are treated as a single whitespace 284 * tabs, spaces and continuation lines, which are treated as a single whitespace
285 * character. 285 * character.
286 * 286 *
287 * Some headers may appear multiple times. A comma seperated list of values is 287 * Some headers may appear multiple times. A comma separated list of values is
288 * equivalent to multiple headers. 288 * equivalent to multiple headers.
289 */ 289 */
290static const struct sip_header ct_sip_hdrs[] = { 290static const struct sip_header ct_sip_hdrs[] = {
@@ -421,7 +421,7 @@ int ct_sip_get_header(const struct nf_conn *ct, const char *dptr,
421} 421}
422EXPORT_SYMBOL_GPL(ct_sip_get_header); 422EXPORT_SYMBOL_GPL(ct_sip_get_header);
423 423
424/* Get next header field in a list of comma seperated values */ 424/* Get next header field in a list of comma separated values */
425static int ct_sip_next_header(const struct nf_conn *ct, const char *dptr, 425static int ct_sip_next_header(const struct nf_conn *ct, const char *dptr,
426 unsigned int dataoff, unsigned int datalen, 426 unsigned int dataoff, unsigned int datalen,
427 enum sip_header_types type, 427 enum sip_header_types type,
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 8eb0cc23ada..6afa3d52ea5 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -113,9 +113,9 @@ int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid,
113} 113}
114EXPORT_SYMBOL_GPL(nfnetlink_send); 114EXPORT_SYMBOL_GPL(nfnetlink_send);
115 115
116void nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error) 116int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error)
117{ 117{
118 netlink_set_err(net->nfnl, pid, group, error); 118 return netlink_set_err(net->nfnl, pid, group, error);
119} 119}
120EXPORT_SYMBOL_GPL(nfnetlink_set_err); 120EXPORT_SYMBOL_GPL(nfnetlink_set_err);
121 121
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index d952806b646..215a64835de 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * xt_hashlimit - Netfilter module to limit the number of packets per time 2 * xt_hashlimit - Netfilter module to limit the number of packets per time
3 * seperately for each hashbucket (sourceip/sourceport/dstip/dstport) 3 * separately for each hashbucket (sourceip/sourceport/dstip/dstport)
4 * 4 *
5 * (C) 2003-2004 by Harald Welte <laforge@netfilter.org> 5 * (C) 2003-2004 by Harald Welte <laforge@netfilter.org>
6 * Copyright © CC Computer Consultants GmbH, 2007 - 2008 6 * Copyright © CC Computer Consultants GmbH, 2007 - 2008
@@ -493,6 +493,7 @@ static void hashlimit_ipv6_mask(__be32 *i, unsigned int p)
493 case 64 ... 95: 493 case 64 ... 95:
494 i[2] = maskl(i[2], p - 64); 494 i[2] = maskl(i[2], p - 64);
495 i[3] = 0; 495 i[3] = 0;
496 break;
496 case 96 ... 127: 497 case 96 ... 127:
497 i[3] = maskl(i[3], p - 96); 498 i[3] = maskl(i[3], p - 96);
498 break; 499 break;
@@ -879,7 +880,8 @@ static void dl_seq_stop(struct seq_file *s, void *v)
879 struct xt_hashlimit_htable *htable = s->private; 880 struct xt_hashlimit_htable *htable = s->private;
880 unsigned int *bucket = (unsigned int *)v; 881 unsigned int *bucket = (unsigned int *)v;
881 882
882 kfree(bucket); 883 if (!IS_ERR(bucket))
884 kfree(bucket);
883 spin_unlock_bh(&htable->lock); 885 spin_unlock_bh(&htable->lock);
884} 886}
885 887
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 7073dbb8100..971d172afec 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -267,7 +267,7 @@ recent_mt(const struct sk_buff *skb, const struct xt_match_param *par)
267 for (i = 0; i < e->nstamps; i++) { 267 for (i = 0; i < e->nstamps; i++) {
268 if (info->seconds && time_after(time, e->stamps[i])) 268 if (info->seconds && time_after(time, e->stamps[i]))
269 continue; 269 continue;
270 if (info->hit_count && ++hits >= info->hit_count) { 270 if (!info->hit_count || ++hits >= info->hit_count) {
271 ret = !ret; 271 ret = !ret;
272 break; 272 break;
273 } 273 }
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 320d0423a24..acbbae1e89b 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1093,6 +1093,7 @@ static inline int do_one_set_err(struct sock *sk,
1093 struct netlink_set_err_data *p) 1093 struct netlink_set_err_data *p)
1094{ 1094{
1095 struct netlink_sock *nlk = nlk_sk(sk); 1095 struct netlink_sock *nlk = nlk_sk(sk);
1096 int ret = 0;
1096 1097
1097 if (sk == p->exclude_sk) 1098 if (sk == p->exclude_sk)
1098 goto out; 1099 goto out;
@@ -1104,10 +1105,15 @@ static inline int do_one_set_err(struct sock *sk,
1104 !test_bit(p->group - 1, nlk->groups)) 1105 !test_bit(p->group - 1, nlk->groups))
1105 goto out; 1106 goto out;
1106 1107
1108 if (p->code == ENOBUFS && nlk->flags & NETLINK_RECV_NO_ENOBUFS) {
1109 ret = 1;
1110 goto out;
1111 }
1112
1107 sk->sk_err = p->code; 1113 sk->sk_err = p->code;
1108 sk->sk_error_report(sk); 1114 sk->sk_error_report(sk);
1109out: 1115out:
1110 return 0; 1116 return ret;
1111} 1117}
1112 1118
1113/** 1119/**
@@ -1116,12 +1122,16 @@ out:
1116 * @pid: the PID of a process that we want to skip (if any) 1122 * @pid: the PID of a process that we want to skip (if any)
1117 * @groups: the broadcast group that will notice the error 1123 * @groups: the broadcast group that will notice the error
1118 * @code: error code, must be negative (as usual in kernelspace) 1124 * @code: error code, must be negative (as usual in kernelspace)
1125 *
1126 * This function returns the number of broadcast listeners that have set the
1127 * NETLINK_RECV_NO_ENOBUFS socket option.
1119 */ 1128 */
1120void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code) 1129int netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
1121{ 1130{
1122 struct netlink_set_err_data info; 1131 struct netlink_set_err_data info;
1123 struct hlist_node *node; 1132 struct hlist_node *node;
1124 struct sock *sk; 1133 struct sock *sk;
1134 int ret = 0;
1125 1135
1126 info.exclude_sk = ssk; 1136 info.exclude_sk = ssk;
1127 info.pid = pid; 1137 info.pid = pid;
@@ -1132,9 +1142,10 @@ void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
1132 read_lock(&nl_table_lock); 1142 read_lock(&nl_table_lock);
1133 1143
1134 sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list) 1144 sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
1135 do_one_set_err(sk, &info); 1145 ret += do_one_set_err(sk, &info);
1136 1146
1137 read_unlock(&nl_table_lock); 1147 read_unlock(&nl_table_lock);
1148 return ret;
1138} 1149}
1139EXPORT_SYMBOL(netlink_set_err); 1150EXPORT_SYMBOL(netlink_set_err);
1140 1151
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 031a5e6fb4a..1612d417d10 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1688,6 +1688,8 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,
1688{ 1688{
1689 switch (i->type) { 1689 switch (i->type) {
1690 case PACKET_MR_MULTICAST: 1690 case PACKET_MR_MULTICAST:
1691 if (i->alen != dev->addr_len)
1692 return -EINVAL;
1691 if (what > 0) 1693 if (what > 0)
1692 return dev_mc_add(dev, i->addr, i->alen, 0); 1694 return dev_mc_add(dev, i->addr, i->alen, 0);
1693 else 1695 else
@@ -1700,6 +1702,8 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,
1700 return dev_set_allmulti(dev, what); 1702 return dev_set_allmulti(dev, what);
1701 break; 1703 break;
1702 case PACKET_MR_UNICAST: 1704 case PACKET_MR_UNICAST:
1705 if (i->alen != dev->addr_len)
1706 return -EINVAL;
1703 if (what > 0) 1707 if (what > 0)
1704 return dev_unicast_add(dev, i->addr); 1708 return dev_unicast_add(dev, i->addr);
1705 else 1709 else
@@ -1734,7 +1738,7 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq_max *mreq)
1734 goto done; 1738 goto done;
1735 1739
1736 err = -EINVAL; 1740 err = -EINVAL;
1737 if (mreq->mr_alen != dev->addr_len) 1741 if (mreq->mr_alen > dev->addr_len)
1738 goto done; 1742 goto done;
1739 1743
1740 err = -ENOBUFS; 1744 err = -ENOBUFS;
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index c597cc53a6f..5c6ae0c701c 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -107,8 +107,7 @@ static void phonet_device_destroy(struct net_device *dev)
107 if (pnd) { 107 if (pnd) {
108 u8 addr; 108 u8 addr;
109 109
110 for (addr = find_first_bit(pnd->addrs, 64); addr < 64; 110 for_each_set_bit(addr, pnd->addrs, 64)
111 addr = find_next_bit(pnd->addrs, 64, 1+addr))
112 phonet_address_notify(RTM_DELADDR, dev, addr); 111 phonet_address_notify(RTM_DELADDR, dev, addr);
113 kfree(pnd); 112 kfree(pnd);
114 } 113 }
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c
index 2e6c7eb8e76..fe2e7088ee0 100644
--- a/net/phonet/pn_netlink.c
+++ b/net/phonet/pn_netlink.c
@@ -141,8 +141,7 @@ static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
141 continue; 141 continue;
142 142
143 addr_idx = 0; 143 addr_idx = 0;
144 for (addr = find_first_bit(pnd->addrs, 64); addr < 64; 144 for_each_set_bit(addr, pnd->addrs, 64) {
145 addr = find_next_bit(pnd->addrs, 64, 1+addr)) {
146 if (addr_idx++ < addr_start_idx) 145 if (addr_idx++ < addr_start_idx)
147 continue; 146 continue;
148 147
diff --git a/net/rfkill/input.c b/net/rfkill/input.c
index a7295ad5f9c..3713d7ecab9 100644
--- a/net/rfkill/input.c
+++ b/net/rfkill/input.c
@@ -212,6 +212,9 @@ static void rfkill_event(struct input_handle *handle, unsigned int type,
212 case KEY_WIMAX: 212 case KEY_WIMAX:
213 rfkill_schedule_toggle(RFKILL_TYPE_WIMAX); 213 rfkill_schedule_toggle(RFKILL_TYPE_WIMAX);
214 break; 214 break;
215 case KEY_RFKILL:
216 rfkill_schedule_toggle(RFKILL_TYPE_ALL);
217 break;
215 } 218 }
216 } else if (type == EV_SW && code == SW_RFKILL_ALL) 219 } else if (type == EV_SW && code == SW_RFKILL_ALL)
217 rfkill_schedule_evsw_rfkillall(data); 220 rfkill_schedule_evsw_rfkillall(data);
@@ -295,6 +298,11 @@ static const struct input_device_id rfkill_ids[] = {
295 .keybit = { [BIT_WORD(KEY_WIMAX)] = BIT_MASK(KEY_WIMAX) }, 298 .keybit = { [BIT_WORD(KEY_WIMAX)] = BIT_MASK(KEY_WIMAX) },
296 }, 299 },
297 { 300 {
301 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
302 .evbit = { BIT_MASK(EV_KEY) },
303 .keybit = { [BIT_WORD(KEY_RFKILL)] = BIT_MASK(KEY_RFKILL) },
304 },
305 {
298 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_SWBIT, 306 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_SWBIT,
299 .evbit = { BIT(EV_SW) }, 307 .evbit = { BIT(EV_SW) },
300 .swbit = { [BIT_WORD(SW_RFKILL_ALL)] = BIT_MASK(SW_RFKILL_ALL) }, 308 .swbit = { [BIT_WORD(SW_RFKILL_ALL)] = BIT_MASK(SW_RFKILL_ALL) },
diff --git a/net/rxrpc/ar-accept.c b/net/rxrpc/ar-accept.c
index 77228f28fa3..2d744f22a9a 100644
--- a/net/rxrpc/ar-accept.c
+++ b/net/rxrpc/ar-accept.c
@@ -88,6 +88,11 @@ static int rxrpc_accept_incoming_call(struct rxrpc_local *local,
88 88
89 /* get a notification message to send to the server app */ 89 /* get a notification message to send to the server app */
90 notification = alloc_skb(0, GFP_NOFS); 90 notification = alloc_skb(0, GFP_NOFS);
91 if (!notification) {
92 _debug("no memory");
93 ret = -ENOMEM;
94 goto error_nofree;
95 }
91 rxrpc_new_skb(notification); 96 rxrpc_new_skb(notification);
92 notification->mark = RXRPC_SKB_MARK_NEW_CALL; 97 notification->mark = RXRPC_SKB_MARK_NEW_CALL;
93 98
@@ -189,6 +194,7 @@ invalid_service:
189 ret = -ECONNREFUSED; 194 ret = -ECONNREFUSED;
190error: 195error:
191 rxrpc_free_skb(notification); 196 rxrpc_free_skb(notification);
197error_nofree:
192 _leave(" = %d", ret); 198 _leave(" = %d", ret);
193 return ret; 199 return ret;
194} 200}
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 21f9c7678aa..2f691fb180d 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -328,13 +328,16 @@ config NET_CLS_FLOW
328 module will be called cls_flow. 328 module will be called cls_flow.
329 329
330config NET_CLS_CGROUP 330config NET_CLS_CGROUP
331 bool "Control Group Classifier" 331 tristate "Control Group Classifier"
332 select NET_CLS 332 select NET_CLS
333 depends on CGROUPS 333 depends on CGROUPS
334 ---help--- 334 ---help---
335 Say Y here if you want to classify packets based on the control 335 Say Y here if you want to classify packets based on the control
336 cgroup of their process. 336 cgroup of their process.
337 337
338 To compile this code as a module, choose M here: the
339 module will be called cls_cgroup.
340
338config NET_EMATCH 341config NET_EMATCH
339 bool "Extended Matches" 342 bool "Extended Matches"
340 select NET_CLS 343 select NET_CLS
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index e4877ca6727..7f27d2c15e0 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -24,6 +24,25 @@ struct cgroup_cls_state
24 u32 classid; 24 u32 classid;
25}; 25};
26 26
27static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss,
28 struct cgroup *cgrp);
29static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp);
30static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp);
31
32struct cgroup_subsys net_cls_subsys = {
33 .name = "net_cls",
34 .create = cgrp_create,
35 .destroy = cgrp_destroy,
36 .populate = cgrp_populate,
37#ifdef CONFIG_NET_CLS_CGROUP
38 .subsys_id = net_cls_subsys_id,
39#else
40#define net_cls_subsys_id net_cls_subsys.subsys_id
41#endif
42 .module = THIS_MODULE,
43};
44
45
27static inline struct cgroup_cls_state *cgrp_cls_state(struct cgroup *cgrp) 46static inline struct cgroup_cls_state *cgrp_cls_state(struct cgroup *cgrp)
28{ 47{
29 return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id), 48 return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id),
@@ -79,14 +98,6 @@ static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
79 return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files)); 98 return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files));
80} 99}
81 100
82struct cgroup_subsys net_cls_subsys = {
83 .name = "net_cls",
84 .create = cgrp_create,
85 .destroy = cgrp_destroy,
86 .populate = cgrp_populate,
87 .subsys_id = net_cls_subsys_id,
88};
89
90struct cls_cgroup_head 101struct cls_cgroup_head
91{ 102{
92 u32 handle; 103 u32 handle;
@@ -277,12 +288,19 @@ static struct tcf_proto_ops cls_cgroup_ops __read_mostly = {
277 288
278static int __init init_cgroup_cls(void) 289static int __init init_cgroup_cls(void)
279{ 290{
280 return register_tcf_proto_ops(&cls_cgroup_ops); 291 int ret = register_tcf_proto_ops(&cls_cgroup_ops);
292 if (ret)
293 return ret;
294 ret = cgroup_load_subsys(&net_cls_subsys);
295 if (ret)
296 unregister_tcf_proto_ops(&cls_cgroup_ops);
297 return ret;
281} 298}
282 299
283static void __exit exit_cgroup_cls(void) 300static void __exit exit_cgroup_cls(void)
284{ 301{
285 unregister_tcf_proto_ops(&cls_cgroup_ops); 302 unregister_tcf_proto_ops(&cls_cgroup_ops);
303 cgroup_unload_subsys(&net_cls_subsys);
286} 304}
287 305
288module_init(init_cgroup_cls); 306module_init(init_cgroup_cls);
diff --git a/net/sctp/input.c b/net/sctp/input.c
index c0c973e67ad..3d74b264ea2 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -75,7 +75,7 @@ static struct sctp_association *__sctp_lookup_association(
75 const union sctp_addr *peer, 75 const union sctp_addr *peer,
76 struct sctp_transport **pt); 76 struct sctp_transport **pt);
77 77
78static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb); 78static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb);
79 79
80 80
81/* Calculate the SCTP checksum of an SCTP packet. */ 81/* Calculate the SCTP checksum of an SCTP packet. */
@@ -265,8 +265,13 @@ int sctp_rcv(struct sk_buff *skb)
265 } 265 }
266 266
267 if (sock_owned_by_user(sk)) { 267 if (sock_owned_by_user(sk)) {
268 if (sctp_add_backlog(sk, skb)) {
269 sctp_bh_unlock_sock(sk);
270 sctp_chunk_free(chunk);
271 skb = NULL; /* sctp_chunk_free already freed the skb */
272 goto discard_release;
273 }
268 SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_BACKLOG); 274 SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_BACKLOG);
269 sctp_add_backlog(sk, skb);
270 } else { 275 } else {
271 SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_SOFTIRQ); 276 SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_SOFTIRQ);
272 sctp_inq_push(&chunk->rcvr->inqueue, chunk); 277 sctp_inq_push(&chunk->rcvr->inqueue, chunk);
@@ -336,8 +341,10 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
336 sctp_bh_lock_sock(sk); 341 sctp_bh_lock_sock(sk);
337 342
338 if (sock_owned_by_user(sk)) { 343 if (sock_owned_by_user(sk)) {
339 sk_add_backlog(sk, skb); 344 if (sk_add_backlog(sk, skb))
340 backloged = 1; 345 sctp_chunk_free(chunk);
346 else
347 backloged = 1;
341 } else 348 } else
342 sctp_inq_push(inqueue, chunk); 349 sctp_inq_push(inqueue, chunk);
343 350
@@ -362,22 +369,27 @@ done:
362 return 0; 369 return 0;
363} 370}
364 371
365static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb) 372static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb)
366{ 373{
367 struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk; 374 struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
368 struct sctp_ep_common *rcvr = chunk->rcvr; 375 struct sctp_ep_common *rcvr = chunk->rcvr;
376 int ret;
369 377
370 /* Hold the assoc/ep while hanging on the backlog queue. 378 ret = sk_add_backlog(sk, skb);
371 * This way, we know structures we need will not disappear from us 379 if (!ret) {
372 */ 380 /* Hold the assoc/ep while hanging on the backlog queue.
373 if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type) 381 * This way, we know structures we need will not disappear
374 sctp_association_hold(sctp_assoc(rcvr)); 382 * from us
375 else if (SCTP_EP_TYPE_SOCKET == rcvr->type) 383 */
376 sctp_endpoint_hold(sctp_ep(rcvr)); 384 if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
377 else 385 sctp_association_hold(sctp_assoc(rcvr));
378 BUG(); 386 else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
387 sctp_endpoint_hold(sctp_ep(rcvr));
388 else
389 BUG();
390 }
391 return ret;
379 392
380 sk_add_backlog(sk, skb);
381} 393}
382 394
383/* Handle icmp frag needed error. */ 395/* Handle icmp frag needed error. */
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 4e4ca65cd32..500886bda9b 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -475,7 +475,7 @@ static void sctp_do_8_2_transport_strike(struct sctp_association *asoc,
475 * used to provide an upper bound to this doubling operation. 475 * used to provide an upper bound to this doubling operation.
476 * 476 *
477 * Special Case: the first HB doesn't trigger exponential backoff. 477 * Special Case: the first HB doesn't trigger exponential backoff.
478 * The first unacknowleged HB triggers it. We do this with a flag 478 * The first unacknowledged HB triggers it. We do this with a flag
479 * that indicates that we have an outstanding HB. 479 * that indicates that we have an outstanding HB.
480 */ 480 */
481 if (!is_hb || transport->hb_sent) { 481 if (!is_hb || transport->hb_sent) {
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index f6d1e59c415..dfc5c127efd 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3720,6 +3720,9 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3720 SCTP_DBG_OBJCNT_INC(sock); 3720 SCTP_DBG_OBJCNT_INC(sock);
3721 percpu_counter_inc(&sctp_sockets_allocated); 3721 percpu_counter_inc(&sctp_sockets_allocated);
3722 3722
3723 /* Set socket backlog limit. */
3724 sk->sk_backlog.limit = sysctl_sctp_rmem[1];
3725
3723 local_bh_disable(); 3726 local_bh_disable();
3724 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 3727 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
3725 local_bh_enable(); 3728 local_bh_enable();
diff --git a/net/socket.c b/net/socket.c
index 769c386bd42..f55ffe9f8c8 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2135,6 +2135,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
2135 break; 2135 break;
2136 ++datagrams; 2136 ++datagrams;
2137 2137
2138 /* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */
2139 if (flags & MSG_WAITFORONE)
2140 flags |= MSG_DONTWAIT;
2141
2138 if (timeout) { 2142 if (timeout) {
2139 ktime_get_ts(timeout); 2143 ktime_get_ts(timeout);
2140 *timeout = timespec_sub(end_time, *timeout); 2144 *timeout = timespec_sub(end_time, *timeout);
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c
index 6dcdd251781..f845d9d72f7 100644
--- a/net/sunrpc/addr.c
+++ b/net/sunrpc/addr.c
@@ -71,8 +71,9 @@ static size_t rpc_ntop6(const struct sockaddr *sap,
71 if (unlikely(len == 0)) 71 if (unlikely(len == 0))
72 return len; 72 return len;
73 73
74 if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) && 74 if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL))
75 !(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_SITELOCAL)) 75 return len;
76 if (sin6->sin6_scope_id == 0)
76 return len; 77 return len;
77 78
78 rc = snprintf(scopebuf, sizeof(scopebuf), "%c%u", 79 rc = snprintf(scopebuf, sizeof(scopebuf), "%c%u",
@@ -165,8 +166,7 @@ static int rpc_parse_scope_id(const char *buf, const size_t buflen,
165 if (*delim != IPV6_SCOPE_DELIMITER) 166 if (*delim != IPV6_SCOPE_DELIMITER)
166 return 0; 167 return 0;
167 168
168 if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) && 169 if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL))
169 !(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_SITELOCAL))
170 return 0; 170 return 0;
171 171
172 len = (buf + buflen) - delim - 1; 172 len = (buf + buflen) - delim - 1;
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index f7a7f8380e3..c389ccf6437 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -206,8 +206,14 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct
206 ctx->gc_win = window_size; 206 ctx->gc_win = window_size;
207 /* gssd signals an error by passing ctx->gc_win = 0: */ 207 /* gssd signals an error by passing ctx->gc_win = 0: */
208 if (ctx->gc_win == 0) { 208 if (ctx->gc_win == 0) {
209 /* in which case, p points to an error code which we ignore */ 209 /*
210 p = ERR_PTR(-EACCES); 210 * in which case, p points to an error code. Anything other
211 * than -EKEYEXPIRED gets converted to -EACCES.
212 */
213 p = simple_get_bytes(p, end, &ret, sizeof(ret));
214 if (!IS_ERR(p))
215 p = (ret == -EKEYEXPIRED) ? ERR_PTR(-EKEYEXPIRED) :
216 ERR_PTR(-EACCES);
211 goto err; 217 goto err;
212 } 218 }
213 /* copy the opaque wire context */ 219 /* copy the opaque wire context */
@@ -646,6 +652,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
646 err = PTR_ERR(p); 652 err = PTR_ERR(p);
647 switch (err) { 653 switch (err) {
648 case -EACCES: 654 case -EACCES:
655 case -EKEYEXPIRED:
649 gss_msg->msg.errno = err; 656 gss_msg->msg.errno = err;
650 err = mlen; 657 err = mlen;
651 break; 658 break;
@@ -1273,9 +1280,8 @@ alloc_enc_pages(struct rpc_rqst *rqstp)
1273 rqstp->rq_release_snd_buf = priv_release_snd_buf; 1280 rqstp->rq_release_snd_buf = priv_release_snd_buf;
1274 return 0; 1281 return 0;
1275out_free: 1282out_free:
1276 for (i--; i >= 0; i--) { 1283 rqstp->rq_enc_pages_num = i;
1277 __free_page(rqstp->rq_enc_pages[i]); 1284 priv_release_snd_buf(rqstp);
1278 }
1279out: 1285out:
1280 return -EAGAIN; 1286 return -EAGAIN;
1281} 1287}
diff --git a/net/sunrpc/bc_svc.c b/net/sunrpc/bc_svc.c
index 13f214f5312..f0c05d3311c 100644
--- a/net/sunrpc/bc_svc.c
+++ b/net/sunrpc/bc_svc.c
@@ -37,21 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 37
38#define RPCDBG_FACILITY RPCDBG_SVCDSP 38#define RPCDBG_FACILITY RPCDBG_SVCDSP
39 39
40void bc_release_request(struct rpc_task *task)
41{
42 struct rpc_rqst *req = task->tk_rqstp;
43
44 dprintk("RPC: bc_release_request: task= %p\n", task);
45
46 /*
47 * Release this request only if it's a backchannel
48 * preallocated request
49 */
50 if (!bc_prealloc(req))
51 return;
52 xprt_free_bc_request(req);
53}
54
55/* Empty callback ops */ 40/* Empty callback ops */
56static const struct rpc_call_ops nfs41_callback_ops = { 41static const struct rpc_call_ops nfs41_callback_ops = {
57}; 42};
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 154034b675b..19c9983d536 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -659,6 +659,7 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req,
659 task = rpc_new_task(&task_setup_data); 659 task = rpc_new_task(&task_setup_data);
660 if (!task) { 660 if (!task) {
661 xprt_free_bc_request(req); 661 xprt_free_bc_request(req);
662 task = ERR_PTR(-ENOMEM);
662 goto out; 663 goto out;
663 } 664 }
664 task->tk_rqstp = req; 665 task->tk_rqstp = req;
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 9ea45383480..20e30c6f835 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -587,6 +587,8 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,
587 struct dentry *dentry; 587 struct dentry *dentry;
588 588
589 dentry = __rpc_lookup_create(parent, name); 589 dentry = __rpc_lookup_create(parent, name);
590 if (IS_ERR(dentry))
591 return dentry;
590 if (dentry->d_inode == NULL) 592 if (dentry->d_inode == NULL)
591 return dentry; 593 return dentry;
592 dput(dentry); 594 dput(dentry);
@@ -999,19 +1001,14 @@ rpc_fill_super(struct super_block *sb, void *data, int silent)
999 inode = rpc_get_inode(sb, S_IFDIR | 0755); 1001 inode = rpc_get_inode(sb, S_IFDIR | 0755);
1000 if (!inode) 1002 if (!inode)
1001 return -ENOMEM; 1003 return -ENOMEM;
1002 root = d_alloc_root(inode); 1004 sb->s_root = root = d_alloc_root(inode);
1003 if (!root) { 1005 if (!root) {
1004 iput(inode); 1006 iput(inode);
1005 return -ENOMEM; 1007 return -ENOMEM;
1006 } 1008 }
1007 if (rpc_populate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF, NULL)) 1009 if (rpc_populate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF, NULL))
1008 goto out; 1010 return -ENOMEM;
1009 sb->s_root = root;
1010 return 0; 1011 return 0;
1011out:
1012 d_genocide(root);
1013 dput(root);
1014 return -ENOMEM;
1015} 1012}
1016 1013
1017static int 1014static int
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 538ca433a56..8420a4205b7 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -133,7 +133,7 @@ svc_pool_map_choose_mode(void)
133 return SVC_POOL_PERNODE; 133 return SVC_POOL_PERNODE;
134 } 134 }
135 135
136 node = any_online_node(node_online_map); 136 node = first_online_node;
137 if (nr_cpus_node(node) > 2) { 137 if (nr_cpus_node(node) > 2) {
138 /* 138 /*
139 * Non-trivial SMP, or CONFIG_NUMA on 139 * Non-trivial SMP, or CONFIG_NUMA on
@@ -506,6 +506,10 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size)
506{ 506{
507 unsigned int pages, arghi; 507 unsigned int pages, arghi;
508 508
509 /* bc_xprt uses fore channel allocated buffers */
510 if (svc_is_backchannel(rqstp))
511 return 1;
512
509 pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply. 513 pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply.
510 * We assume one is at most one page 514 * We assume one is at most one page
511 */ 515 */
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 7d1f9e928f6..8f0f1fb3dc5 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -173,11 +173,13 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl,
173 .sin_addr.s_addr = htonl(INADDR_ANY), 173 .sin_addr.s_addr = htonl(INADDR_ANY),
174 .sin_port = htons(port), 174 .sin_port = htons(port),
175 }; 175 };
176#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
176 struct sockaddr_in6 sin6 = { 177 struct sockaddr_in6 sin6 = {
177 .sin6_family = AF_INET6, 178 .sin6_family = AF_INET6,
178 .sin6_addr = IN6ADDR_ANY_INIT, 179 .sin6_addr = IN6ADDR_ANY_INIT,
179 .sin6_port = htons(port), 180 .sin6_port = htons(port),
180 }; 181 };
182#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
181 struct sockaddr *sap; 183 struct sockaddr *sap;
182 size_t len; 184 size_t len;
183 185
@@ -186,10 +188,12 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl,
186 sap = (struct sockaddr *)&sin; 188 sap = (struct sockaddr *)&sin;
187 len = sizeof(sin); 189 len = sizeof(sin);
188 break; 190 break;
191#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
189 case PF_INET6: 192 case PF_INET6:
190 sap = (struct sockaddr *)&sin6; 193 sap = (struct sockaddr *)&sin6;
191 len = sizeof(sin6); 194 len = sizeof(sin6);
192 break; 195 break;
196#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
193 default: 197 default:
194 return ERR_PTR(-EAFNOSUPPORT); 198 return ERR_PTR(-EAFNOSUPPORT);
195 } 199 }
@@ -231,7 +235,10 @@ int svc_create_xprt(struct svc_serv *serv, const char *xprt_name,
231 err: 235 err:
232 spin_unlock(&svc_xprt_class_lock); 236 spin_unlock(&svc_xprt_class_lock);
233 dprintk("svc: transport %s not found\n", xprt_name); 237 dprintk("svc: transport %s not found\n", xprt_name);
234 return -ENOENT; 238
239 /* This errno is exposed to user space. Provide a reasonable
240 * perror msg for a bad transport. */
241 return -EPROTONOSUPPORT;
235} 242}
236EXPORT_SYMBOL_GPL(svc_create_xprt); 243EXPORT_SYMBOL_GPL(svc_create_xprt);
237 244
@@ -699,8 +706,10 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
699 spin_unlock_bh(&pool->sp_lock); 706 spin_unlock_bh(&pool->sp_lock);
700 707
701 len = 0; 708 len = 0;
702 if (test_bit(XPT_LISTENER, &xprt->xpt_flags) && 709 if (test_bit(XPT_CLOSE, &xprt->xpt_flags)) {
703 !test_bit(XPT_CLOSE, &xprt->xpt_flags)) { 710 dprintk("svc_recv: found XPT_CLOSE\n");
711 svc_delete_xprt(xprt);
712 } else if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) {
704 struct svc_xprt *newxpt; 713 struct svc_xprt *newxpt;
705 newxpt = xprt->xpt_ops->xpo_accept(xprt); 714 newxpt = xprt->xpt_ops->xpo_accept(xprt);
706 if (newxpt) { 715 if (newxpt) {
@@ -726,7 +735,7 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
726 svc_xprt_received(newxpt); 735 svc_xprt_received(newxpt);
727 } 736 }
728 svc_xprt_received(xprt); 737 svc_xprt_received(xprt);
729 } else if (!test_bit(XPT_CLOSE, &xprt->xpt_flags)) { 738 } else {
730 dprintk("svc: server %p, pool %u, transport %p, inuse=%d\n", 739 dprintk("svc: server %p, pool %u, transport %p, inuse=%d\n",
731 rqstp, pool->sp_id, xprt, 740 rqstp, pool->sp_id, xprt,
732 atomic_read(&xprt->xpt_ref.refcount)); 741 atomic_read(&xprt->xpt_ref.refcount));
@@ -739,11 +748,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
739 dprintk("svc: got len=%d\n", len); 748 dprintk("svc: got len=%d\n", len);
740 } 749 }
741 750
742 if (test_bit(XPT_CLOSE, &xprt->xpt_flags)) {
743 dprintk("svc_recv: found XPT_CLOSE\n");
744 svc_delete_xprt(xprt);
745 }
746
747 /* No data, incomplete (TCP) read, or accept() */ 751 /* No data, incomplete (TCP) read, or accept() */
748 if (len == 0 || len == -EAGAIN) { 752 if (len == 0 || len == -EAGAIN) {
749 rqstp->rq_res.len = 0; 753 rqstp->rq_res.len = 0;
@@ -889,11 +893,8 @@ void svc_delete_xprt(struct svc_xprt *xprt)
889 if (test_bit(XPT_TEMP, &xprt->xpt_flags)) 893 if (test_bit(XPT_TEMP, &xprt->xpt_flags))
890 serv->sv_tmpcnt--; 894 serv->sv_tmpcnt--;
891 895
892 for (dr = svc_deferred_dequeue(xprt); dr; 896 while ((dr = svc_deferred_dequeue(xprt)) != NULL)
893 dr = svc_deferred_dequeue(xprt)) {
894 svc_xprt_put(xprt);
895 kfree(dr); 897 kfree(dr);
896 }
897 898
898 svc_xprt_put(xprt); 899 svc_xprt_put(xprt);
899 spin_unlock_bh(&serv->sv_lock); 900 spin_unlock_bh(&serv->sv_lock);
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index d8c04111449..afdcb0459a8 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#define RPCDBG_FACILITY RPCDBG_AUTH 16#define RPCDBG_FACILITY RPCDBG_AUTH
17 17
18#include <linux/sunrpc/clnt.h>
18 19
19/* 20/*
20 * AUTHUNIX and AUTHNULL credentials are both handled here. 21 * AUTHUNIX and AUTHNULL credentials are both handled here.
@@ -187,10 +188,13 @@ static int ip_map_parse(struct cache_detail *cd,
187 * for scratch: */ 188 * for scratch: */
188 char *buf = mesg; 189 char *buf = mesg;
189 int len; 190 int len;
190 int b1, b2, b3, b4, b5, b6, b7, b8;
191 char c;
192 char class[8]; 191 char class[8];
193 struct in6_addr addr; 192 union {
193 struct sockaddr sa;
194 struct sockaddr_in s4;
195 struct sockaddr_in6 s6;
196 } address;
197 struct sockaddr_in6 sin6;
194 int err; 198 int err;
195 199
196 struct ip_map *ipmp; 200 struct ip_map *ipmp;
@@ -209,24 +213,24 @@ static int ip_map_parse(struct cache_detail *cd,
209 len = qword_get(&mesg, buf, mlen); 213 len = qword_get(&mesg, buf, mlen);
210 if (len <= 0) return -EINVAL; 214 if (len <= 0) return -EINVAL;
211 215
212 if (sscanf(buf, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) == 4) { 216 if (rpc_pton(buf, len, &address.sa, sizeof(address)) == 0)
213 addr.s6_addr32[0] = 0;
214 addr.s6_addr32[1] = 0;
215 addr.s6_addr32[2] = htonl(0xffff);
216 addr.s6_addr32[3] =
217 htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4);
218 } else if (sscanf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x%c",
219 &b1, &b2, &b3, &b4, &b5, &b6, &b7, &b8, &c) == 8) {
220 addr.s6_addr16[0] = htons(b1);
221 addr.s6_addr16[1] = htons(b2);
222 addr.s6_addr16[2] = htons(b3);
223 addr.s6_addr16[3] = htons(b4);
224 addr.s6_addr16[4] = htons(b5);
225 addr.s6_addr16[5] = htons(b6);
226 addr.s6_addr16[6] = htons(b7);
227 addr.s6_addr16[7] = htons(b8);
228 } else
229 return -EINVAL; 217 return -EINVAL;
218 switch (address.sa.sa_family) {
219 case AF_INET:
220 /* Form a mapped IPv4 address in sin6 */
221 memset(&sin6, 0, sizeof(sin6));
222 sin6.sin6_family = AF_INET6;
223 sin6.sin6_addr.s6_addr32[2] = htonl(0xffff);
224 sin6.sin6_addr.s6_addr32[3] = address.s4.sin_addr.s_addr;
225 break;
226#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
227 case AF_INET6:
228 memcpy(&sin6, &address.s6, sizeof(sin6));
229 break;
230#endif
231 default:
232 return -EINVAL;
233 }
230 234
231 expiry = get_expiry(&mesg); 235 expiry = get_expiry(&mesg);
232 if (expiry ==0) 236 if (expiry ==0)
@@ -243,7 +247,8 @@ static int ip_map_parse(struct cache_detail *cd,
243 } else 247 } else
244 dom = NULL; 248 dom = NULL;
245 249
246 ipmp = ip_map_lookup(class, &addr); 250 /* IPv6 scope IDs are ignored for now */
251 ipmp = ip_map_lookup(class, &sin6.sin6_addr);
247 if (ipmp) { 252 if (ipmp) {
248 err = ip_map_update(ipmp, 253 err = ip_map_update(ipmp,
249 container_of(dom, struct unix_domain, h), 254 container_of(dom, struct unix_domain, h),
@@ -619,7 +624,7 @@ static int unix_gid_show(struct seq_file *m,
619 else 624 else
620 glen = 0; 625 glen = 0;
621 626
622 seq_printf(m, "%d %d:", ug->uid, glen); 627 seq_printf(m, "%u %d:", ug->uid, glen);
623 for (i = 0; i < glen; i++) 628 for (i = 0; i < glen; i++)
624 seq_printf(m, " %d", GROUP_AT(ug->gi, i)); 629 seq_printf(m, " %d", GROUP_AT(ug->gi, i));
625 seq_printf(m, "\n"); 630 seq_printf(m, "\n");
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 870929e08e5..a29f259204e 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -968,6 +968,7 @@ static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp)
968 return len; 968 return len;
969 err_delete: 969 err_delete:
970 set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags); 970 set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags);
971 svc_xprt_received(&svsk->sk_xprt);
971 err_again: 972 err_again:
972 return -EAGAIN; 973 return -EAGAIN;
973} 974}
@@ -1357,7 +1358,7 @@ int svc_addsock(struct svc_serv *serv, const int fd, char *name_return,
1357 1358
1358 if (!so) 1359 if (!so)
1359 return err; 1360 return err;
1360 if (so->sk->sk_family != AF_INET) 1361 if ((so->sk->sk_family != PF_INET) && (so->sk->sk_family != PF_INET6))
1361 err = -EAFNOSUPPORT; 1362 err = -EAFNOSUPPORT;
1362 else if (so->sk->sk_protocol != IPPROTO_TCP && 1363 else if (so->sk->sk_protocol != IPPROTO_TCP &&
1363 so->sk->sk_protocol != IPPROTO_UDP) 1364 so->sk->sk_protocol != IPPROTO_UDP)
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 469de292c23..42f09ade004 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -46,6 +46,7 @@
46 46
47#include <linux/sunrpc/clnt.h> 47#include <linux/sunrpc/clnt.h>
48#include <linux/sunrpc/metrics.h> 48#include <linux/sunrpc/metrics.h>
49#include <linux/sunrpc/bc_xprt.h>
49 50
50#include "sunrpc.h" 51#include "sunrpc.h"
51 52
@@ -1032,21 +1033,16 @@ void xprt_release(struct rpc_task *task)
1032 if (req->rq_release_snd_buf) 1033 if (req->rq_release_snd_buf)
1033 req->rq_release_snd_buf(req); 1034 req->rq_release_snd_buf(req);
1034 1035
1035 /*
1036 * Early exit if this is a backchannel preallocated request.
1037 * There is no need to have it added to the RPC slot list.
1038 */
1039 if (is_bc_request)
1040 return;
1041
1042 memset(req, 0, sizeof(*req)); /* mark unused */
1043
1044 dprintk("RPC: %5u release request %p\n", task->tk_pid, req); 1036 dprintk("RPC: %5u release request %p\n", task->tk_pid, req);
1037 if (likely(!is_bc_request)) {
1038 memset(req, 0, sizeof(*req)); /* mark unused */
1045 1039
1046 spin_lock(&xprt->reserve_lock); 1040 spin_lock(&xprt->reserve_lock);
1047 list_add(&req->rq_list, &xprt->free); 1041 list_add(&req->rq_list, &xprt->free);
1048 rpc_wake_up_next(&xprt->backlog); 1042 rpc_wake_up_next(&xprt->backlog);
1049 spin_unlock(&xprt->reserve_lock); 1043 spin_unlock(&xprt->reserve_lock);
1044 } else
1045 xprt_free_bc_request(req);
1050} 1046}
1051 1047
1052/** 1048/**
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 7018eef1dcd..f96c2fe6137 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -160,16 +160,15 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt)
160 (void)rpc_ntop(sap, buf, sizeof(buf)); 160 (void)rpc_ntop(sap, buf, sizeof(buf));
161 xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL); 161 xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL);
162 162
163 (void)snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap)); 163 snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap));
164 xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL); 164 xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL);
165 165
166 xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma"; 166 xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma";
167 167
168 (void)snprintf(buf, sizeof(buf), "%02x%02x%02x%02x", 168 snprintf(buf, sizeof(buf), "%08x", ntohl(sin->sin_addr.s_addr));
169 NIPQUAD(sin->sin_addr.s_addr));
170 xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL); 169 xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL);
171 170
172 (void)snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap)); 171 snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap));
173 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL); 172 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL);
174 173
175 /* netid */ 174 /* netid */
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 3d739e5d15d..9847c30b500 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -297,12 +297,11 @@ static void xs_format_common_peer_addresses(struct rpc_xprt *xprt)
297 switch (sap->sa_family) { 297 switch (sap->sa_family) {
298 case AF_INET: 298 case AF_INET:
299 sin = xs_addr_in(xprt); 299 sin = xs_addr_in(xprt);
300 (void)snprintf(buf, sizeof(buf), "%02x%02x%02x%02x", 300 snprintf(buf, sizeof(buf), "%08x", ntohl(sin->sin_addr.s_addr));
301 NIPQUAD(sin->sin_addr.s_addr));
302 break; 301 break;
303 case AF_INET6: 302 case AF_INET6:
304 sin6 = xs_addr_in6(xprt); 303 sin6 = xs_addr_in6(xprt);
305 (void)snprintf(buf, sizeof(buf), "%pi6", &sin6->sin6_addr); 304 snprintf(buf, sizeof(buf), "%pi6", &sin6->sin6_addr);
306 break; 305 break;
307 default: 306 default:
308 BUG(); 307 BUG();
@@ -315,10 +314,10 @@ static void xs_format_common_peer_ports(struct rpc_xprt *xprt)
315 struct sockaddr *sap = xs_addr(xprt); 314 struct sockaddr *sap = xs_addr(xprt);
316 char buf[128]; 315 char buf[128];
317 316
318 (void)snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap)); 317 snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap));
319 xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL); 318 xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL);
320 319
321 (void)snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap)); 320 snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap));
322 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL); 321 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL);
323} 322}
324 323
@@ -549,8 +548,6 @@ static int xs_udp_send_request(struct rpc_task *task)
549 /* Still some bytes left; set up for a retry later. */ 548 /* Still some bytes left; set up for a retry later. */
550 status = -EAGAIN; 549 status = -EAGAIN;
551 } 550 }
552 if (!transport->sock)
553 goto out;
554 551
555 switch (status) { 552 switch (status) {
556 case -ENOTSOCK: 553 case -ENOTSOCK:
@@ -570,7 +567,7 @@ static int xs_udp_send_request(struct rpc_task *task)
570 * prompts ECONNREFUSED. */ 567 * prompts ECONNREFUSED. */
571 clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); 568 clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags);
572 } 569 }
573out: 570
574 return status; 571 return status;
575} 572}
576 573
@@ -652,8 +649,6 @@ static int xs_tcp_send_request(struct rpc_task *task)
652 status = -EAGAIN; 649 status = -EAGAIN;
653 break; 650 break;
654 } 651 }
655 if (!transport->sock)
656 goto out;
657 652
658 switch (status) { 653 switch (status) {
659 case -ENOTSOCK: 654 case -ENOTSOCK:
@@ -673,7 +668,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
673 case -ENOTCONN: 668 case -ENOTCONN:
674 clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); 669 clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags);
675 } 670 }
676out: 671
677 return status; 672 return status;
678} 673}
679 674
@@ -1912,6 +1907,11 @@ static void xs_tcp_setup_socket(struct rpc_xprt *xprt,
1912 case -EALREADY: 1907 case -EALREADY:
1913 xprt_clear_connecting(xprt); 1908 xprt_clear_connecting(xprt);
1914 return; 1909 return;
1910 case -EINVAL:
1911 /* Happens, for instance, if the user specified a link
1912 * local IPv6 address without a scope-id.
1913 */
1914 goto out;
1915 } 1915 }
1916out_eagain: 1916out_eagain:
1917 status = -EAGAIN; 1917 status = -EAGAIN;
@@ -2100,7 +2100,7 @@ static void xs_tcp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq)
2100 * we allocate pages instead doing a kmalloc like rpc_malloc is because we want 2100 * we allocate pages instead doing a kmalloc like rpc_malloc is because we want
2101 * to use the server side send routines. 2101 * to use the server side send routines.
2102 */ 2102 */
2103void *bc_malloc(struct rpc_task *task, size_t size) 2103static void *bc_malloc(struct rpc_task *task, size_t size)
2104{ 2104{
2105 struct page *page; 2105 struct page *page;
2106 struct rpc_buffer *buf; 2106 struct rpc_buffer *buf;
@@ -2120,7 +2120,7 @@ void *bc_malloc(struct rpc_task *task, size_t size)
2120/* 2120/*
2121 * Free the space allocated in the bc_alloc routine 2121 * Free the space allocated in the bc_alloc routine
2122 */ 2122 */
2123void bc_free(void *buffer) 2123static void bc_free(void *buffer)
2124{ 2124{
2125 struct rpc_buffer *buf; 2125 struct rpc_buffer *buf;
2126 2126
@@ -2251,9 +2251,6 @@ static struct rpc_xprt_ops xs_tcp_ops = {
2251 .buf_free = rpc_free, 2251 .buf_free = rpc_free,
2252 .send_request = xs_tcp_send_request, 2252 .send_request = xs_tcp_send_request,
2253 .set_retrans_timeout = xprt_set_retrans_timeout_def, 2253 .set_retrans_timeout = xprt_set_retrans_timeout_def,
2254#if defined(CONFIG_NFS_V4_1)
2255 .release_request = bc_release_request,
2256#endif /* CONFIG_NFS_V4_1 */
2257 .close = xs_tcp_close, 2254 .close = xs_tcp_close,
2258 .destroy = xs_destroy, 2255 .destroy = xs_destroy,
2259 .print_stats = xs_tcp_print_stats, 2256 .print_stats = xs_tcp_print_stats,
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 327011fcc40..78091375ca1 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -45,10 +45,10 @@
45 45
46#define MAX_ADDR_STR 32 46#define MAX_ADDR_STR 32
47 47
48static struct media *media_list = NULL; 48static struct media media_list[MAX_MEDIA];
49static u32 media_count = 0; 49static u32 media_count = 0;
50 50
51struct bearer *tipc_bearers = NULL; 51struct bearer tipc_bearers[MAX_BEARERS];
52 52
53/** 53/**
54 * media_name_valid - validate media name 54 * media_name_valid - validate media name
@@ -108,9 +108,11 @@ int tipc_register_media(u32 media_type,
108 int res = -EINVAL; 108 int res = -EINVAL;
109 109
110 write_lock_bh(&tipc_net_lock); 110 write_lock_bh(&tipc_net_lock);
111 if (!media_list)
112 goto exit;
113 111
112 if (tipc_mode != TIPC_NET_MODE) {
113 warn("Media <%s> rejected, not in networked mode yet\n", name);
114 goto exit;
115 }
114 if (!media_name_valid(name)) { 116 if (!media_name_valid(name)) {
115 warn("Media <%s> rejected, illegal name\n", name); 117 warn("Media <%s> rejected, illegal name\n", name);
116 goto exit; 118 goto exit;
@@ -660,33 +662,10 @@ int tipc_disable_bearer(const char *name)
660 662
661 663
662 664
663int tipc_bearer_init(void)
664{
665 int res;
666
667 write_lock_bh(&tipc_net_lock);
668 tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC);
669 media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC);
670 if (tipc_bearers && media_list) {
671 res = 0;
672 } else {
673 kfree(tipc_bearers);
674 kfree(media_list);
675 tipc_bearers = NULL;
676 media_list = NULL;
677 res = -ENOMEM;
678 }
679 write_unlock_bh(&tipc_net_lock);
680 return res;
681}
682
683void tipc_bearer_stop(void) 665void tipc_bearer_stop(void)
684{ 666{
685 u32 i; 667 u32 i;
686 668
687 if (!tipc_bearers)
688 return;
689
690 for (i = 0; i < MAX_BEARERS; i++) { 669 for (i = 0; i < MAX_BEARERS; i++) {
691 if (tipc_bearers[i].active) 670 if (tipc_bearers[i].active)
692 tipc_bearers[i].publ.blocked = 1; 671 tipc_bearers[i].publ.blocked = 1;
@@ -695,10 +674,6 @@ void tipc_bearer_stop(void)
695 if (tipc_bearers[i].active) 674 if (tipc_bearers[i].active)
696 bearer_disable(tipc_bearers[i].publ.name); 675 bearer_disable(tipc_bearers[i].publ.name);
697 } 676 }
698 kfree(tipc_bearers);
699 kfree(media_list);
700 tipc_bearers = NULL;
701 media_list = NULL;
702 media_count = 0; 677 media_count = 0;
703} 678}
704 679
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index ca573489271..000228e93f9 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -114,7 +114,7 @@ struct bearer_name {
114 114
115struct link; 115struct link;
116 116
117extern struct bearer *tipc_bearers; 117extern struct bearer tipc_bearers[];
118 118
119void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); 119void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a);
120struct sk_buff *tipc_media_get_names(void); 120struct sk_buff *tipc_media_get_names(void);
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 6f50f6423f6..1a7e4665af8 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1882,6 +1882,15 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
1882 (msg_destnode(msg) != tipc_own_addr))) 1882 (msg_destnode(msg) != tipc_own_addr)))
1883 goto cont; 1883 goto cont;
1884 1884
1885 /* Discard non-routeable messages destined for another node */
1886
1887 if (unlikely(!msg_isdata(msg) &&
1888 (msg_destnode(msg) != tipc_own_addr))) {
1889 if ((msg_user(msg) != CONN_MANAGER) &&
1890 (msg_user(msg) != MSG_FRAGMENTER))
1891 goto cont;
1892 }
1893
1885 /* Locate unicast link endpoint that should handle message */ 1894 /* Locate unicast link endpoint that should handle message */
1886 1895
1887 n_ptr = tipc_node_find(msg_prevnode(msg)); 1896 n_ptr = tipc_node_find(msg_prevnode(msg));
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 7906608bf51..f25b1cdb64e 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -116,7 +116,8 @@
116*/ 116*/
117 117
118DEFINE_RWLOCK(tipc_net_lock); 118DEFINE_RWLOCK(tipc_net_lock);
119struct network tipc_net = { NULL }; 119struct _zone *tipc_zones[256] = { NULL, };
120struct network tipc_net = { tipc_zones };
120 121
121struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) 122struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref)
122{ 123{
@@ -158,28 +159,12 @@ void tipc_net_send_external_routes(u32 dest)
158 } 159 }
159} 160}
160 161
161static int net_init(void)
162{
163 memset(&tipc_net, 0, sizeof(tipc_net));
164 tipc_net.zones = kcalloc(tipc_max_zones + 1, sizeof(struct _zone *), GFP_ATOMIC);
165 if (!tipc_net.zones) {
166 return -ENOMEM;
167 }
168 return 0;
169}
170
171static void net_stop(void) 162static void net_stop(void)
172{ 163{
173 u32 z_num; 164 u32 z_num;
174 165
175 if (!tipc_net.zones) 166 for (z_num = 1; z_num <= tipc_max_zones; z_num++)
176 return;
177
178 for (z_num = 1; z_num <= tipc_max_zones; z_num++) {
179 tipc_zone_delete(tipc_net.zones[z_num]); 167 tipc_zone_delete(tipc_net.zones[z_num]);
180 }
181 kfree(tipc_net.zones);
182 tipc_net.zones = NULL;
183} 168}
184 169
185static void net_route_named_msg(struct sk_buff *buf) 170static void net_route_named_msg(struct sk_buff *buf)
@@ -282,9 +267,7 @@ int tipc_net_start(u32 addr)
282 tipc_named_reinit(); 267 tipc_named_reinit();
283 tipc_port_reinit(); 268 tipc_port_reinit();
284 269
285 if ((res = tipc_bearer_init()) || 270 if ((res = tipc_cltr_init()) ||
286 (res = net_init()) ||
287 (res = tipc_cltr_init()) ||
288 (res = tipc_bclink_init())) { 271 (res = tipc_bclink_init())) {
289 return res; 272 return res;
290 } 273 }
diff --git a/net/tipc/ref.c b/net/tipc/ref.c
index 414fc34b8be..8dea66500cf 100644
--- a/net/tipc/ref.c
+++ b/net/tipc/ref.c
@@ -153,11 +153,11 @@ void tipc_ref_table_stop(void)
153 153
154u32 tipc_ref_acquire(void *object, spinlock_t **lock) 154u32 tipc_ref_acquire(void *object, spinlock_t **lock)
155{ 155{
156 struct reference *entry;
157 u32 index; 156 u32 index;
158 u32 index_mask; 157 u32 index_mask;
159 u32 next_plus_upper; 158 u32 next_plus_upper;
160 u32 ref; 159 u32 ref;
160 struct reference *entry = NULL;
161 161
162 if (!object) { 162 if (!object) {
163 err("Attempt to acquire reference to non-existent object\n"); 163 err("Attempt to acquire reference to non-existent object\n");
@@ -175,30 +175,36 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
175 index = tipc_ref_table.first_free; 175 index = tipc_ref_table.first_free;
176 entry = &(tipc_ref_table.entries[index]); 176 entry = &(tipc_ref_table.entries[index]);
177 index_mask = tipc_ref_table.index_mask; 177 index_mask = tipc_ref_table.index_mask;
178 /* take lock in case a previous user of entry still holds it */
179 spin_lock_bh(&entry->lock);
180 next_plus_upper = entry->ref; 178 next_plus_upper = entry->ref;
181 tipc_ref_table.first_free = next_plus_upper & index_mask; 179 tipc_ref_table.first_free = next_plus_upper & index_mask;
182 ref = (next_plus_upper & ~index_mask) + index; 180 ref = (next_plus_upper & ~index_mask) + index;
183 entry->ref = ref;
184 entry->object = object;
185 *lock = &entry->lock;
186 } 181 }
187 else if (tipc_ref_table.init_point < tipc_ref_table.capacity) { 182 else if (tipc_ref_table.init_point < tipc_ref_table.capacity) {
188 index = tipc_ref_table.init_point++; 183 index = tipc_ref_table.init_point++;
189 entry = &(tipc_ref_table.entries[index]); 184 entry = &(tipc_ref_table.entries[index]);
190 spin_lock_init(&entry->lock); 185 spin_lock_init(&entry->lock);
191 spin_lock_bh(&entry->lock);
192 ref = tipc_ref_table.start_mask + index; 186 ref = tipc_ref_table.start_mask + index;
193 entry->ref = ref;
194 entry->object = object;
195 *lock = &entry->lock;
196 } 187 }
197 else { 188 else {
198 ref = 0; 189 ref = 0;
199 } 190 }
200 write_unlock_bh(&ref_table_lock); 191 write_unlock_bh(&ref_table_lock);
201 192
193 /*
194 * Grab the lock so no one else can modify this entry
195 * While we assign its ref value & object pointer
196 */
197 if (entry) {
198 spin_lock_bh(&entry->lock);
199 entry->ref = ref;
200 entry->object = object;
201 *lock = &entry->lock;
202 /*
203 * keep it locked, the caller is responsible
204 * for unlocking this when they're done with it
205 */
206 }
207
202 return ref; 208 return ref;
203} 209}
204 210
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 1ea64f09cc4..4b235fc1c70 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1322,8 +1322,10 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
1322 if (!sock_owned_by_user(sk)) { 1322 if (!sock_owned_by_user(sk)) {
1323 res = filter_rcv(sk, buf); 1323 res = filter_rcv(sk, buf);
1324 } else { 1324 } else {
1325 sk_add_backlog(sk, buf); 1325 if (sk_add_backlog(sk, buf))
1326 res = TIPC_OK; 1326 res = TIPC_ERR_OVERLOAD;
1327 else
1328 res = TIPC_OK;
1327 } 1329 }
1328 bh_unlock_sock(sk); 1330 bh_unlock_sock(sk);
1329 1331
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index ac91f0dfa14..ff123e56114 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -76,19 +76,6 @@ struct top_srv {
76static struct top_srv topsrv = { 0 }; 76static struct top_srv topsrv = { 0 };
77 77
78/** 78/**
79 * htohl - convert value to endianness used by destination
80 * @in: value to convert
81 * @swap: non-zero if endianness must be reversed
82 *
83 * Returns converted value
84 */
85
86static u32 htohl(u32 in, int swap)
87{
88 return swap ? swab32(in) : in;
89}
90
91/**
92 * subscr_send_event - send a message containing a tipc_event to the subscriber 79 * subscr_send_event - send a message containing a tipc_event to the subscriber
93 * 80 *
94 * Note: Must not hold subscriber's server port lock, since tipc_send() will 81 * Note: Must not hold subscriber's server port lock, since tipc_send() will
@@ -107,11 +94,11 @@ static void subscr_send_event(struct subscription *sub,
107 msg_sect.iov_base = (void *)&sub->evt; 94 msg_sect.iov_base = (void *)&sub->evt;
108 msg_sect.iov_len = sizeof(struct tipc_event); 95 msg_sect.iov_len = sizeof(struct tipc_event);
109 96
110 sub->evt.event = htohl(event, sub->swap); 97 sub->evt.event = htonl(event);
111 sub->evt.found_lower = htohl(found_lower, sub->swap); 98 sub->evt.found_lower = htonl(found_lower);
112 sub->evt.found_upper = htohl(found_upper, sub->swap); 99 sub->evt.found_upper = htonl(found_upper);
113 sub->evt.port.ref = htohl(port_ref, sub->swap); 100 sub->evt.port.ref = htonl(port_ref);
114 sub->evt.port.node = htohl(node, sub->swap); 101 sub->evt.port.node = htonl(node);
115 tipc_send(sub->server_ref, 1, &msg_sect); 102 tipc_send(sub->server_ref, 1, &msg_sect);
116} 103}
117 104
@@ -287,16 +274,23 @@ static void subscr_cancel(struct tipc_subscr *s,
287{ 274{
288 struct subscription *sub; 275 struct subscription *sub;
289 struct subscription *sub_temp; 276 struct subscription *sub_temp;
277 __u32 type, lower, upper;
290 int found = 0; 278 int found = 0;
291 279
292 /* Find first matching subscription, exit if not found */ 280 /* Find first matching subscription, exit if not found */
293 281
282 type = ntohl(s->seq.type);
283 lower = ntohl(s->seq.lower);
284 upper = ntohl(s->seq.upper);
285
294 list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, 286 list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list,
295 subscription_list) { 287 subscription_list) {
296 if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { 288 if ((type == sub->seq.type) &&
297 found = 1; 289 (lower == sub->seq.lower) &&
298 break; 290 (upper == sub->seq.upper)) {
299 } 291 found = 1;
292 break;
293 }
300 } 294 }
301 if (!found) 295 if (!found)
302 return; 296 return;
@@ -325,16 +319,10 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s,
325 struct subscriber *subscriber) 319 struct subscriber *subscriber)
326{ 320{
327 struct subscription *sub; 321 struct subscription *sub;
328 int swap;
329
330 /* Determine subscriber's endianness */
331
332 swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE));
333 322
334 /* Detect & process a subscription cancellation request */ 323 /* Detect & process a subscription cancellation request */
335 324
336 if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) { 325 if (ntohl(s->filter) & TIPC_SUB_CANCEL) {
337 s->filter &= ~htohl(TIPC_SUB_CANCEL, swap);
338 subscr_cancel(s, subscriber); 326 subscr_cancel(s, subscriber);
339 return NULL; 327 return NULL;
340 } 328 }
@@ -359,11 +347,11 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s,
359 347
360 /* Initialize subscription object */ 348 /* Initialize subscription object */
361 349
362 sub->seq.type = htohl(s->seq.type, swap); 350 sub->seq.type = ntohl(s->seq.type);
363 sub->seq.lower = htohl(s->seq.lower, swap); 351 sub->seq.lower = ntohl(s->seq.lower);
364 sub->seq.upper = htohl(s->seq.upper, swap); 352 sub->seq.upper = ntohl(s->seq.upper);
365 sub->timeout = htohl(s->timeout, swap); 353 sub->timeout = ntohl(s->timeout);
366 sub->filter = htohl(s->filter, swap); 354 sub->filter = ntohl(s->filter);
367 if ((!(sub->filter & TIPC_SUB_PORTS) == 355 if ((!(sub->filter & TIPC_SUB_PORTS) ==
368 !(sub->filter & TIPC_SUB_SERVICE)) || 356 !(sub->filter & TIPC_SUB_SERVICE)) ||
369 (sub->seq.lower > sub->seq.upper)) { 357 (sub->seq.lower > sub->seq.upper)) {
@@ -376,7 +364,6 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s,
376 INIT_LIST_HEAD(&sub->nameseq_list); 364 INIT_LIST_HEAD(&sub->nameseq_list);
377 list_add(&sub->subscription_list, &subscriber->subscription_list); 365 list_add(&sub->subscription_list, &subscriber->subscription_list);
378 sub->server_ref = subscriber->port_ref; 366 sub->server_ref = subscriber->port_ref;
379 sub->swap = swap;
380 memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr)); 367 memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr));
381 atomic_inc(&topsrv.subscription_count); 368 atomic_inc(&topsrv.subscription_count);
382 if (sub->timeout != TIPC_WAIT_FOREVER) { 369 if (sub->timeout != TIPC_WAIT_FOREVER) {
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h
index 45d89bf4d20..c20f496d95b 100644
--- a/net/tipc/subscr.h
+++ b/net/tipc/subscr.h
@@ -53,7 +53,6 @@ typedef void (*tipc_subscr_event) (struct subscription *sub,
53 * @nameseq_list: adjacent subscriptions in name sequence's subscription list 53 * @nameseq_list: adjacent subscriptions in name sequence's subscription list
54 * @subscription_list: adjacent subscriptions in subscriber's subscription list 54 * @subscription_list: adjacent subscriptions in subscriber's subscription list
55 * @server_ref: object reference of server port associated with subscription 55 * @server_ref: object reference of server port associated with subscription
56 * @swap: indicates if subscriber uses opposite endianness in its messages
57 * @evt: template for events generated by subscription 56 * @evt: template for events generated by subscription
58 */ 57 */
59 58
@@ -66,7 +65,6 @@ struct subscription {
66 struct list_head nameseq_list; 65 struct list_head nameseq_list;
67 struct list_head subscription_list; 66 struct list_head subscription_list;
68 u32 server_ref; 67 u32 server_ref;
69 int swap;
70 struct tipc_event evt; 68 struct tipc_event evt;
71}; 69};
72 70
diff --git a/net/x25/x25_dev.c b/net/x25/x25_dev.c
index 3e1efe53464..52e30421224 100644
--- a/net/x25/x25_dev.c
+++ b/net/x25/x25_dev.c
@@ -53,7 +53,7 @@ static int x25_receive_data(struct sk_buff *skb, struct x25_neigh *nb)
53 if (!sock_owned_by_user(sk)) { 53 if (!sock_owned_by_user(sk)) {
54 queued = x25_process_rx_frame(sk, skb); 54 queued = x25_process_rx_frame(sk, skb);
55 } else { 55 } else {
56 sk_add_backlog(sk, skb); 56 queued = !sk_add_backlog(sk, skb);
57 } 57 }
58 bh_unlock_sock(sk); 58 bh_unlock_sock(sk);
59 sock_put(sk); 59 sock_put(sk);
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 34a5ef8316e..843e066649c 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1372,7 +1372,8 @@ static inline int xfrm_init_path(struct xfrm_dst *path, struct dst_entry *dst,
1372 return err; 1372 return err;
1373} 1373}
1374 1374
1375static inline int xfrm_fill_dst(struct xfrm_dst *xdst, struct net_device *dev) 1375static inline int xfrm_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
1376 struct flowi *fl)
1376{ 1377{
1377 struct xfrm_policy_afinfo *afinfo = 1378 struct xfrm_policy_afinfo *afinfo =
1378 xfrm_policy_get_afinfo(xdst->u.dst.ops->family); 1379 xfrm_policy_get_afinfo(xdst->u.dst.ops->family);
@@ -1381,7 +1382,7 @@ static inline int xfrm_fill_dst(struct xfrm_dst *xdst, struct net_device *dev)
1381 if (!afinfo) 1382 if (!afinfo)
1382 return -EINVAL; 1383 return -EINVAL;
1383 1384
1384 err = afinfo->fill_dst(xdst, dev); 1385 err = afinfo->fill_dst(xdst, dev, fl);
1385 1386
1386 xfrm_policy_put_afinfo(afinfo); 1387 xfrm_policy_put_afinfo(afinfo);
1387 1388
@@ -1486,7 +1487,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
1486 for (dst_prev = dst0; dst_prev != dst; dst_prev = dst_prev->child) { 1487 for (dst_prev = dst0; dst_prev != dst; dst_prev = dst_prev->child) {
1487 struct xfrm_dst *xdst = (struct xfrm_dst *)dst_prev; 1488 struct xfrm_dst *xdst = (struct xfrm_dst *)dst_prev;
1488 1489
1489 err = xfrm_fill_dst(xdst, dev); 1490 err = xfrm_fill_dst(xdst, dev, fl);
1490 if (err) 1491 if (err)
1491 goto free_dst; 1492 goto free_dst;
1492 1493