aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/802/tr.c2
-rw-r--r--net/8021q/vlan.c11
-rw-r--r--net/8021q/vlan_dev.c3
-rw-r--r--net/atm/mpc.c7
-rw-r--r--net/ax25/af_ax25.c51
-rw-r--r--net/ax25/ax25_in.c2
-rw-r--r--net/ax25/ax25_subr.c2
-rw-r--r--net/bluetooth/hci_conn.c10
-rw-r--r--net/bluetooth/hci_sysfs.c18
-rw-r--r--net/bluetooth/rfcomm/tty.c25
-rw-r--r--net/bridge/br.c4
-rw-r--r--net/bridge/br_device.c3
-rw-r--r--net/bridge/br_fdb.c2
-rw-r--r--net/bridge/br_if.c12
-rw-r--r--net/bridge/br_input.c7
-rw-r--r--net/bridge/br_netfilter.c45
-rw-r--r--net/bridge/br_private.h2
-rw-r--r--net/bridge/br_sysfs_br.c14
-rw-r--r--net/bridge/br_sysfs_if.c2
-rw-r--r--net/bridge/netfilter/ebt_among.c2
-rw-r--r--net/bridge/netfilter/ebtable_broute.c4
-rw-r--r--net/compat.c2
-rw-r--r--net/core/dev.c16
-rw-r--r--net/core/net_namespace.c2
-rw-r--r--net/core/pktgen.c2
-rw-r--r--net/core/rtnetlink.c5
-rw-r--r--net/core/scm.c2
-rw-r--r--net/core/skbuff.c42
-rw-r--r--net/dccp/ackvec.h2
-rw-r--r--net/dccp/ccids/ccid3.c2
-rw-r--r--net/dccp/ccids/lib/loss_interval.c2
-rw-r--r--net/decnet/dn_dev.c4
-rw-r--r--net/decnet/dn_route.c6
-rw-r--r--net/ieee80211/ieee80211_crypt_ccmp.c2
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c4
-rw-r--r--net/ieee80211/ieee80211_tx.c3
-rw-r--r--net/ipv4/arp.c25
-rw-r--r--net/ipv4/devinet.c5
-rw-r--r--net/ipv4/esp4.c5
-rw-r--r--net/ipv4/fib_frontend.c9
-rw-r--r--net/ipv4/fib_hash.c23
-rw-r--r--net/ipv4/fib_trie.c3
-rw-r--r--net/ipv4/icmp.c1
-rw-r--r--net/ipv4/inet_diag.c69
-rw-r--r--net/ipv4/inet_lro.c19
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/ipconfig.c47
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_ctl.c24
-rw-r--r--net/ipv4/ipvs/ip_vs_lblc.c9
-rw-r--r--net/ipv4/ipvs/ip_vs_lblcr.c9
-rw-r--r--net/ipv4/ipvs/ip_vs_proto.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_sched.c27
-rw-r--r--net/ipv4/netfilter/ip_tables.c57
-rw-r--r--net/ipv4/netfilter/iptable_raw.c2
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c3
-rw-r--r--net/ipv4/netfilter/nf_nat_core.c5
-rw-r--r--net/ipv4/netfilter/nf_nat_sip.c2
-rw-r--r--net/ipv4/raw.c4
-rw-r--r--net/ipv4/route.c27
-rw-r--r--net/ipv4/sysctl_net_ipv4.c2
-rw-r--r--net/ipv4/tcp_illinois.c2
-rw-r--r--net/ipv4/tcp_input.c38
-rw-r--r--net/ipv4/tcp_ipv4.c11
-rw-r--r--net/ipv4/tcp_output.c24
-rw-r--r--net/ipv6/addrconf.c13
-rw-r--r--net/ipv6/datagram.c6
-rw-r--r--net/ipv6/esp6.c6
-rw-r--r--net/ipv6/icmp.c2
-rw-r--r--net/ipv6/inet6_hashtables.c2
-rw-r--r--net/ipv6/ip6_output.c6
-rw-r--r--net/ipv6/ipv6_sockglue.c12
-rw-r--r--net/ipv6/ndisc.c2
-rw-r--r--net/ipv6/netfilter/ip6t_eui64.c2
-rw-r--r--net/ipv6/proc.c4
-rw-r--r--net/ipv6/route.c11
-rw-r--r--net/ipv6/tcp_ipv6.c11
-rw-r--r--net/ipv6/xfrm6_policy.c2
-rw-r--r--net/irda/af_irda.c32
-rw-r--r--net/irda/ircomm/ircomm_param.c2
-rw-r--r--net/irda/ircomm/ircomm_tty.c2
-rw-r--r--net/irda/iriap.c2
-rw-r--r--net/irda/irlan/irlan_eth.c4
-rw-r--r--net/irda/irlap_frame.c2
-rw-r--r--net/irda/irlmp.c1
-rw-r--r--net/irda/parameters.c18
-rw-r--r--net/irda/wrapper.c2
-rw-r--r--net/iucv/iucv.c107
-rw-r--r--net/key/af_key.c34
-rw-r--r--net/mac80211/ieee80211.c38
-rw-r--r--net/mac80211/ieee80211_ioctl.c6
-rw-r--r--net/mac80211/ieee80211_rate.c3
-rw-r--r--net/mac80211/ieee80211_sta.c10
-rw-r--r--net/mac80211/rx.c2
-rw-r--r--net/mac80211/sta_info.c7
-rw-r--r--net/mac80211/wep.c3
-rw-r--r--net/netfilter/nf_conntrack_core.c5
-rw-r--r--net/netfilter/nf_conntrack_netlink.c4
-rw-r--r--net/netfilter/nf_conntrack_sip.c4
-rw-r--r--net/netfilter/x_tables.c8
-rw-r--r--net/netfilter/xt_CONNMARK.c10
-rw-r--r--net/netfilter/xt_CONNSECMARK.c10
-rw-r--r--net/netfilter/xt_TCPMSS.c4
-rw-r--r--net/netfilter/xt_hashlimit.c2
-rw-r--r--net/netfilter/xt_helper.c4
-rw-r--r--net/netlabel/netlabel_mgmt.c2
-rw-r--r--net/netrom/nr_dev.c2
-rw-r--r--net/rfkill/rfkill.c19
-rw-r--r--net/rose/rose_dev.c2
-rw-r--r--net/rxrpc/Kconfig1
-rw-r--r--net/rxrpc/rxkad.c1
-rw-r--r--net/sched/sch_hfsc.c2
-rw-r--r--net/sctp/Kconfig6
-rw-r--r--net/sctp/auth.c4
-rw-r--r--net/sctp/bind_addr.c26
-rw-r--r--net/sctp/sm_make_chunk.c33
-rw-r--r--net/sctp/sm_statefuns.c26
-rw-r--r--net/sctp/socket.c18
-rw-r--r--net/sctp/ulpevent.c2
-rw-r--r--net/sctp/ulpqueue.c33
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c6
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_mech.c8
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_seal.c1
-rw-r--r--net/sunrpc/rpc_pipe.c2
-rw-r--r--net/sunrpc/xprt.c2
-rw-r--r--net/sunrpc/xprtrdma/rpc_rdma.c9
-rw-r--r--net/sunrpc/xprtrdma/transport.c10
-rw-r--r--net/sunrpc/xprtsock.c4
-rw-r--r--net/tipc/socket.c2
-rw-r--r--net/unix/af_unix.c9
-rw-r--r--net/wireless/wext.c2
-rw-r--r--net/x25/x25_forward.c5
-rw-r--r--net/xfrm/xfrm_policy.c14
-rw-r--r--net/xfrm/xfrm_state.c18
-rw-r--r--net/xfrm/xfrm_user.c19
136 files changed, 827 insertions, 654 deletions
diff --git a/net/802/tr.c b/net/802/tr.c
index a2bd0f2e3af8..1e115e5beab6 100644
--- a/net/802/tr.c
+++ b/net/802/tr.c
@@ -642,7 +642,7 @@ struct net_device *alloc_trdev(int sizeof_priv)
642static int __init rif_init(void) 642static int __init rif_init(void)
643{ 643{
644 init_timer(&rif_timer); 644 init_timer(&rif_timer);
645 rif_timer.expires = sysctl_tr_rif_timeout; 645 rif_timer.expires = jiffies + sysctl_tr_rif_timeout;
646 rif_timer.data = 0L; 646 rif_timer.data = 0L;
647 rif_timer.function = rif_check_expire; 647 rif_timer.function = rif_check_expire;
648 add_timer(&rif_timer); 648 add_timer(&rif_timer);
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 6567213959cb..032bf44eca5e 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -124,8 +124,8 @@ static void __exit vlan_cleanup_module(void)
124{ 124{
125 int i; 125 int i;
126 126
127 vlan_netlink_fini();
128 vlan_ioctl_set(NULL); 127 vlan_ioctl_set(NULL);
128 vlan_netlink_fini();
129 129
130 /* Un-register us from receiving netdevice events */ 130 /* Un-register us from receiving netdevice events */
131 unregister_netdevice_notifier(&vlan_notifier_block); 131 unregister_netdevice_notifier(&vlan_notifier_block);
@@ -323,6 +323,7 @@ static const struct header_ops vlan_header_ops = {
323static int vlan_dev_init(struct net_device *dev) 323static int vlan_dev_init(struct net_device *dev)
324{ 324{
325 struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev; 325 struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
326 int subclass = 0;
326 327
327 /* IFF_BROADCAST|IFF_MULTICAST; ??? */ 328 /* IFF_BROADCAST|IFF_MULTICAST; ??? */
328 dev->flags = real_dev->flags & ~IFF_UP; 329 dev->flags = real_dev->flags & ~IFF_UP;
@@ -349,7 +350,11 @@ static int vlan_dev_init(struct net_device *dev)
349 dev->hard_start_xmit = vlan_dev_hard_start_xmit; 350 dev->hard_start_xmit = vlan_dev_hard_start_xmit;
350 } 351 }
351 352
352 lockdep_set_class(&dev->_xmit_lock, &vlan_netdev_xmit_lock_key); 353 if (real_dev->priv_flags & IFF_802_1Q_VLAN)
354 subclass = 1;
355
356 lockdep_set_class_and_subclass(&dev->_xmit_lock,
357 &vlan_netdev_xmit_lock_key, subclass);
353 return 0; 358 return 0;
354} 359}
355 360
@@ -776,7 +781,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
776 case SET_VLAN_NAME_TYPE_CMD: 781 case SET_VLAN_NAME_TYPE_CMD:
777 err = -EPERM; 782 err = -EPERM;
778 if (!capable(CAP_NET_ADMIN)) 783 if (!capable(CAP_NET_ADMIN))
779 return -EPERM; 784 break;
780 if ((args.u.name_type >= 0) && 785 if ((args.u.name_type >= 0) &&
781 (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) { 786 (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
782 vlan_name_type = args.u.name_type; 787 vlan_name_type = args.u.name_type;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 7a36878241da..4f99bb86af5c 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -462,7 +462,8 @@ int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
462 * OTHER THINGS LIKE FDDI/TokenRing/802.3 SNAPs... 462 * OTHER THINGS LIKE FDDI/TokenRing/802.3 SNAPs...
463 */ 463 */
464 464
465 if (veth->h_vlan_proto != htons(ETH_P_8021Q)) { 465 if (veth->h_vlan_proto != htons(ETH_P_8021Q) ||
466 VLAN_DEV_INFO(dev)->flags & VLAN_FLAG_REORDER_HDR) {
466 int orig_headroom = skb_headroom(skb); 467 int orig_headroom = skb_headroom(skb);
467 unsigned short veth_TCI; 468 unsigned short veth_TCI;
468 469
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 2086396de177..9c7f712fc7e9 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -542,6 +542,13 @@ static int mpc_send_packet(struct sk_buff *skb, struct net_device *dev)
542 if (eth->h_proto != htons(ETH_P_IP)) 542 if (eth->h_proto != htons(ETH_P_IP))
543 goto non_ip; /* Multi-Protocol Over ATM :-) */ 543 goto non_ip; /* Multi-Protocol Over ATM :-) */
544 544
545 /* Weed out funny packets (e.g., AF_PACKET or raw). */
546 if (skb->len < ETH_HLEN + sizeof(struct iphdr))
547 goto non_ip;
548 skb_set_network_header(skb, ETH_HLEN);
549 if (skb->len < ETH_HLEN + ip_hdr(skb)->ihl * 4 || ip_hdr(skb)->ihl < 5)
550 goto non_ip;
551
545 while (i < mpc->number_of_mps_macs) { 552 while (i < mpc->number_of_mps_macs) {
546 if (!compare_ether_addr(eth->h_dest, (mpc->mps_macs + i*ETH_ALEN))) 553 if (!compare_ether_addr(eth->h_dest, (mpc->mps_macs + i*ETH_ALEN)))
547 if ( send_via_shortcut(skb, mpc) == 0 ) /* try shortcut */ 554 if ( send_via_shortcut(skb, mpc) == 0 ) /* try shortcut */
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 8378afd54b30..b4725ff317c0 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -87,10 +87,22 @@ static void ax25_kill_by_device(struct net_device *dev)
87 return; 87 return;
88 88
89 spin_lock_bh(&ax25_list_lock); 89 spin_lock_bh(&ax25_list_lock);
90again:
90 ax25_for_each(s, node, &ax25_list) { 91 ax25_for_each(s, node, &ax25_list) {
91 if (s->ax25_dev == ax25_dev) { 92 if (s->ax25_dev == ax25_dev) {
92 s->ax25_dev = NULL; 93 s->ax25_dev = NULL;
94 spin_unlock_bh(&ax25_list_lock);
93 ax25_disconnect(s, ENETUNREACH); 95 ax25_disconnect(s, ENETUNREACH);
96 spin_lock_bh(&ax25_list_lock);
97
98 /* The entry could have been deleted from the
99 * list meanwhile and thus the next pointer is
100 * no longer valid. Play it safe and restart
101 * the scan. Forward progress is ensured
102 * because we set s->ax25_dev to NULL and we
103 * are never passed a NULL 'dev' argument.
104 */
105 goto again;
94 } 106 }
95 } 107 }
96 spin_unlock_bh(&ax25_list_lock); 108 spin_unlock_bh(&ax25_list_lock);
@@ -1109,21 +1121,19 @@ static int __must_check ax25_connect(struct socket *sock,
1109 * some sanity checks. code further down depends on this 1121 * some sanity checks. code further down depends on this
1110 */ 1122 */
1111 1123
1112 if (addr_len == sizeof(struct sockaddr_ax25)) { 1124 if (addr_len == sizeof(struct sockaddr_ax25))
1113 /* support for this will go away in early 2.5.x */ 1125 /* support for this will go away in early 2.5.x
1114 printk(KERN_WARNING "ax25_connect(): %s uses obsolete socket structure\n", 1126 * ax25_connect(): uses obsolete socket structure
1115 current->comm); 1127 */
1116 } 1128 ;
1117 else if (addr_len != sizeof(struct full_sockaddr_ax25)) { 1129 else if (addr_len != sizeof(struct full_sockaddr_ax25))
1118 /* support for old structure may go away some time */ 1130 /* support for old structure may go away some time
1131 * ax25_connect(): uses old (6 digipeater) socket structure.
1132 */
1119 if ((addr_len < sizeof(struct sockaddr_ax25) + sizeof(ax25_address) * 6) || 1133 if ((addr_len < sizeof(struct sockaddr_ax25) + sizeof(ax25_address) * 6) ||
1120 (addr_len > sizeof(struct full_sockaddr_ax25))) { 1134 (addr_len > sizeof(struct full_sockaddr_ax25)))
1121 return -EINVAL; 1135 return -EINVAL;
1122 }
1123 1136
1124 printk(KERN_WARNING "ax25_connect(): %s uses old (6 digipeater) socket structure.\n",
1125 current->comm);
1126 }
1127 1137
1128 if (fsa->fsa_ax25.sax25_family != AF_AX25) 1138 if (fsa->fsa_ax25.sax25_family != AF_AX25)
1129 return -EINVAL; 1139 return -EINVAL;
@@ -1467,21 +1477,20 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
1467 goto out; 1477 goto out;
1468 } 1478 }
1469 1479
1470 if (addr_len == sizeof(struct sockaddr_ax25)) { 1480 if (addr_len == sizeof(struct sockaddr_ax25))
1471 printk(KERN_WARNING "ax25_sendmsg(): %s uses obsolete socket structure\n", 1481 /* ax25_sendmsg(): uses obsolete socket structure */
1472 current->comm); 1482 ;
1473 } 1483 else if (addr_len != sizeof(struct full_sockaddr_ax25))
1474 else if (addr_len != sizeof(struct full_sockaddr_ax25)) { 1484 /* support for old structure may go away some time
1475 /* support for old structure may go away some time */ 1485 * ax25_sendmsg(): uses old (6 digipeater)
1486 * socket structure.
1487 */
1476 if ((addr_len < sizeof(struct sockaddr_ax25) + sizeof(ax25_address) * 6) || 1488 if ((addr_len < sizeof(struct sockaddr_ax25) + sizeof(ax25_address) * 6) ||
1477 (addr_len > sizeof(struct full_sockaddr_ax25))) { 1489 (addr_len > sizeof(struct full_sockaddr_ax25))) {
1478 err = -EINVAL; 1490 err = -EINVAL;
1479 goto out; 1491 goto out;
1480 } 1492 }
1481 1493
1482 printk(KERN_WARNING "ax25_sendmsg(): %s uses old (6 digipeater) socket structure.\n",
1483 current->comm);
1484 }
1485 1494
1486 if (addr_len > sizeof(struct sockaddr_ax25) && usax->sax25_ndigis != 0) { 1495 if (addr_len > sizeof(struct sockaddr_ax25) && usax->sax25_ndigis != 0) {
1487 int ct = 0; 1496 int ct = 0;
diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c
index 3b7d1720c2ee..d1be080dcb25 100644
--- a/net/ax25/ax25_in.c
+++ b/net/ax25/ax25_in.c
@@ -124,7 +124,7 @@ int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb)
124 } 124 }
125 125
126 skb_pull(skb, 1); /* Remove PID */ 126 skb_pull(skb, 1); /* Remove PID */
127 skb_reset_mac_header(skb); 127 skb->mac_header = skb->network_header;
128 skb_reset_network_header(skb); 128 skb_reset_network_header(skb);
129 skb->dev = ax25->ax25_dev->dev; 129 skb->dev = ax25->ax25_dev->dev;
130 skb->pkt_type = PACKET_HOST; 130 skb->pkt_type = PACKET_HOST;
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 5fe9b2a6697d..d8f215733175 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -279,6 +279,7 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
279 ax25_link_failed(ax25, reason); 279 ax25_link_failed(ax25, reason);
280 280
281 if (ax25->sk != NULL) { 281 if (ax25->sk != NULL) {
282 local_bh_disable();
282 bh_lock_sock(ax25->sk); 283 bh_lock_sock(ax25->sk);
283 ax25->sk->sk_state = TCP_CLOSE; 284 ax25->sk->sk_state = TCP_CLOSE;
284 ax25->sk->sk_err = reason; 285 ax25->sk->sk_err = reason;
@@ -288,5 +289,6 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
288 sock_set_flag(ax25->sk, SOCK_DEAD); 289 sock_set_flag(ax25->sk, SOCK_DEAD);
289 } 290 }
290 bh_unlock_sock(ax25->sk); 291 bh_unlock_sock(ax25->sk);
292 local_bh_enable();
291 } 293 }
292} 294}
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 9483320f6dad..34d1a3c822bf 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -259,22 +259,14 @@ int hci_conn_del(struct hci_conn *conn)
259 } 259 }
260 260
261 tasklet_disable(&hdev->tx_task); 261 tasklet_disable(&hdev->tx_task);
262
263 hci_conn_del_sysfs(conn);
264
265 hci_conn_hash_del(hdev, conn); 262 hci_conn_hash_del(hdev, conn);
266 if (hdev->notify) 263 if (hdev->notify)
267 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); 264 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
268
269 tasklet_enable(&hdev->tx_task); 265 tasklet_enable(&hdev->tx_task);
270
271 skb_queue_purge(&conn->data_q); 266 skb_queue_purge(&conn->data_q);
272 267 hci_conn_del_sysfs(conn);
273 hci_dev_put(hdev); 268 hci_dev_put(hdev);
274 269
275 /* will free via device release */
276 put_device(&conn->dev);
277
278 return 0; 270 return 0;
279} 271}
280 272
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index cef1e3e1881c..17f7fb720553 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -316,10 +316,28 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
316 schedule_work(&conn->work); 316 schedule_work(&conn->work);
317} 317}
318 318
319static int __match_tty(struct device *dev, void *data)
320{
321 /* The rfcomm tty device will possibly retain even when conn
322 * is down, and sysfs doesn't support move zombie device,
323 * so we should move the device before conn device is destroyed.
324 * Due to the only child device of hci_conn dev is rfcomm
325 * tty_dev, here just return 1
326 */
327 return 1;
328}
329
319static void del_conn(struct work_struct *work) 330static void del_conn(struct work_struct *work)
320{ 331{
332 struct device *dev;
321 struct hci_conn *conn = container_of(work, struct hci_conn, work); 333 struct hci_conn *conn = container_of(work, struct hci_conn, work);
334
335 while (dev = device_find_child(&conn->dev, NULL, __match_tty)) {
336 device_move(dev, NULL);
337 put_device(dev);
338 }
322 device_del(&conn->dev); 339 device_del(&conn->dev);
340 put_device(&conn->dev);
323} 341}
324 342
325void hci_conn_del_sysfs(struct hci_conn *conn) 343void hci_conn_del_sysfs(struct hci_conn *conn)
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index e447651a2dbe..788c70321858 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -95,9 +95,10 @@ static void rfcomm_dev_destruct(struct rfcomm_dev *dev)
95 95
96 BT_DBG("dev %p dlc %p", dev, dlc); 96 BT_DBG("dev %p dlc %p", dev, dlc);
97 97
98 write_lock_bh(&rfcomm_dev_lock); 98 /* Refcount should only hit zero when called from rfcomm_dev_del()
99 list_del_init(&dev->list); 99 which will have taken us off the list. Everything else are
100 write_unlock_bh(&rfcomm_dev_lock); 100 refcounting bugs. */
101 BUG_ON(!list_empty(&dev->list));
101 102
102 rfcomm_dlc_lock(dlc); 103 rfcomm_dlc_lock(dlc);
103 /* Detach DLC if it's owned by this dev */ 104 /* Detach DLC if it's owned by this dev */
@@ -109,11 +110,6 @@ static void rfcomm_dev_destruct(struct rfcomm_dev *dev)
109 110
110 tty_unregister_device(rfcomm_tty_driver, dev->id); 111 tty_unregister_device(rfcomm_tty_driver, dev->id);
111 112
112 /* Refcount should only hit zero when called from rfcomm_dev_del()
113 which will have taken us off the list. Everything else are
114 refcounting bugs. */
115 BUG_ON(!list_empty(&dev->list));
116
117 kfree(dev); 113 kfree(dev);
118 114
119 /* It's safe to call module_put() here because socket still 115 /* It's safe to call module_put() here because socket still
@@ -313,7 +309,15 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
313{ 309{
314 BT_DBG("dev %p", dev); 310 BT_DBG("dev %p", dev);
315 311
316 set_bit(RFCOMM_TTY_RELEASED, &dev->flags); 312 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags))
313 BUG_ON(1);
314 else
315 set_bit(RFCOMM_TTY_RELEASED, &dev->flags);
316
317 write_lock_bh(&rfcomm_dev_lock);
318 list_del_init(&dev->list);
319 write_unlock_bh(&rfcomm_dev_lock);
320
317 rfcomm_dev_put(dev); 321 rfcomm_dev_put(dev);
318} 322}
319 323
@@ -692,7 +696,8 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
692 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, dev->opened); 696 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, dev->opened);
693 697
694 if (--dev->opened == 0) { 698 if (--dev->opened == 0) {
695 device_move(dev->tty_dev, NULL); 699 if (dev->tty_dev->parent)
700 device_move(dev->tty_dev, NULL);
696 701
697 /* Close DLC and dettach TTY */ 702 /* Close DLC and dettach TTY */
698 rfcomm_dlc_close(dev->dlc, 0); 703 rfcomm_dlc_close(dev->dlc, 0);
diff --git a/net/bridge/br.c b/net/bridge/br.c
index 93867bb6cc97..a90182873120 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -39,7 +39,7 @@ static int __init br_init(void)
39 39
40 err = br_fdb_init(); 40 err = br_fdb_init();
41 if (err) 41 if (err)
42 goto err_out1; 42 goto err_out;
43 43
44 err = br_netfilter_init(); 44 err = br_netfilter_init();
45 if (err) 45 if (err)
@@ -65,6 +65,8 @@ err_out3:
65err_out2: 65err_out2:
66 br_netfilter_fini(); 66 br_netfilter_fini();
67err_out1: 67err_out1:
68 br_fdb_fini();
69err_out:
68 llc_sap_put(br_stp_sap); 70 llc_sap_put(br_stp_sap);
69 return err; 71 return err;
70} 72}
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index c07bac5e3e10..bf7787395fe0 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -157,8 +157,7 @@ static struct ethtool_ops br_ethtool_ops = {
157 157
158void br_dev_setup(struct net_device *dev) 158void br_dev_setup(struct net_device *dev)
159{ 159{
160 memset(dev->dev_addr, 0, ETH_ALEN); 160 random_ether_addr(dev->dev_addr);
161
162 ether_setup(dev); 161 ether_setup(dev);
163 162
164 dev->do_ioctl = br_dev_ioctl; 163 dev->do_ioctl = br_dev_ioctl;
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index eb57502bb264..bc40377136a2 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -44,7 +44,7 @@ int __init br_fdb_init(void)
44 return 0; 44 return 0;
45} 45}
46 46
47void __exit br_fdb_fini(void) 47void br_fdb_fini(void)
48{ 48{
49 kmem_cache_destroy(br_fdb_cache); 49 kmem_cache_destroy(br_fdb_cache);
50} 50}
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 935784f736b3..298e0f463c56 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -133,7 +133,7 @@ static void del_nbp(struct net_bridge_port *p)
133 struct net_bridge *br = p->br; 133 struct net_bridge *br = p->br;
134 struct net_device *dev = p->dev; 134 struct net_device *dev = p->dev;
135 135
136 sysfs_remove_link(&br->ifobj, dev->name); 136 sysfs_remove_link(br->ifobj, dev->name);
137 137
138 dev_set_promiscuity(dev, -1); 138 dev_set_promiscuity(dev, -1);
139 139
@@ -258,12 +258,6 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
258 p->state = BR_STATE_DISABLED; 258 p->state = BR_STATE_DISABLED;
259 br_stp_port_timer_init(p); 259 br_stp_port_timer_init(p);
260 260
261 kobject_init(&p->kobj);
262 kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR);
263 p->kobj.ktype = &brport_ktype;
264 p->kobj.parent = &(dev->dev.kobj);
265 p->kobj.kset = NULL;
266
267 return p; 261 return p;
268} 262}
269 263
@@ -379,7 +373,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
379 if (IS_ERR(p)) 373 if (IS_ERR(p))
380 return PTR_ERR(p); 374 return PTR_ERR(p);
381 375
382 err = kobject_add(&p->kobj); 376 err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj),
377 SYSFS_BRIDGE_PORT_ATTR);
383 if (err) 378 if (err)
384 goto err0; 379 goto err0;
385 380
@@ -416,6 +411,7 @@ err2:
416 br_fdb_delete_by_port(br, p, 1); 411 br_fdb_delete_by_port(br, p, 1);
417err1: 412err1:
418 kobject_del(&p->kobj); 413 kobject_del(&p->kobj);
414 return err;
419err0: 415err0:
420 kobject_put(&p->kobj); 416 kobject_put(&p->kobj);
421 return err; 417 return err;
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 3cedd4eeeed6..0ee79a726d91 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -122,6 +122,7 @@ static inline int is_link_local(const unsigned char *dest)
122struct sk_buff *br_handle_frame(struct net_bridge_port *p, struct sk_buff *skb) 122struct sk_buff *br_handle_frame(struct net_bridge_port *p, struct sk_buff *skb)
123{ 123{
124 const unsigned char *dest = eth_hdr(skb)->h_dest; 124 const unsigned char *dest = eth_hdr(skb)->h_dest;
125 int (*rhook)(struct sk_buff *skb);
125 126
126 if (!is_valid_ether_addr(eth_hdr(skb)->h_source)) 127 if (!is_valid_ether_addr(eth_hdr(skb)->h_source))
127 goto drop; 128 goto drop;
@@ -147,9 +148,9 @@ struct sk_buff *br_handle_frame(struct net_bridge_port *p, struct sk_buff *skb)
147 148
148 switch (p->state) { 149 switch (p->state) {
149 case BR_STATE_FORWARDING: 150 case BR_STATE_FORWARDING:
150 151 rhook = rcu_dereference(br_should_route_hook);
151 if (br_should_route_hook) { 152 if (rhook != NULL) {
152 if (br_should_route_hook(skb)) 153 if (rhook(skb))
153 return skb; 154 return skb;
154 dest = eth_hdr(skb)->h_dest; 155 dest = eth_hdr(skb)->h_dest;
155 } 156 }
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index c1757c79dfbb..9f78a69d6b8b 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -142,6 +142,23 @@ static inline struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
142 return skb->nf_bridge; 142 return skb->nf_bridge;
143} 143}
144 144
145static inline struct nf_bridge_info *nf_bridge_unshare(struct sk_buff *skb)
146{
147 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
148
149 if (atomic_read(&nf_bridge->use) > 1) {
150 struct nf_bridge_info *tmp = nf_bridge_alloc(skb);
151
152 if (tmp) {
153 memcpy(tmp, nf_bridge, sizeof(struct nf_bridge_info));
154 atomic_set(&tmp->use, 1);
155 nf_bridge_put(nf_bridge);
156 }
157 nf_bridge = tmp;
158 }
159 return nf_bridge;
160}
161
145static inline void nf_bridge_push_encap_header(struct sk_buff *skb) 162static inline void nf_bridge_push_encap_header(struct sk_buff *skb)
146{ 163{
147 unsigned int len = nf_bridge_encap_header_len(skb); 164 unsigned int len = nf_bridge_encap_header_len(skb);
@@ -247,8 +264,9 @@ static void __br_dnat_complain(void)
247 * Let us first consider the case that ip_route_input() succeeds: 264 * Let us first consider the case that ip_route_input() succeeds:
248 * 265 *
249 * If skb->dst->dev equals the logical bridge device the packet 266 * If skb->dst->dev equals the logical bridge device the packet
250 * came in on, we can consider this bridging. We then call 267 * came in on, we can consider this bridging. The packet is passed
251 * skb->dst->output() which will make the packet enter br_nf_local_out() 268 * through the neighbour output function to build a new destination
269 * MAC address, which will make the packet enter br_nf_local_out()
252 * not much later. In that function it is assured that the iptables 270 * not much later. In that function it is assured that the iptables
253 * FORWARD chain is traversed for the packet. 271 * FORWARD chain is traversed for the packet.
254 * 272 *
@@ -285,12 +303,17 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
285 skb->nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; 303 skb->nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
286 304
287 skb->dev = bridge_parent(skb->dev); 305 skb->dev = bridge_parent(skb->dev);
288 if (!skb->dev) 306 if (skb->dev) {
289 kfree_skb(skb); 307 struct dst_entry *dst = skb->dst;
290 else { 308
291 nf_bridge_pull_encap_header(skb); 309 nf_bridge_pull_encap_header(skb);
292 skb->dst->output(skb); 310
311 if (dst->hh)
312 return neigh_hh_output(dst->hh, skb);
313 else if (dst->neighbour)
314 return dst->neighbour->output(skb);
293 } 315 }
316 kfree_skb(skb);
294 return 0; 317 return 0;
295} 318}
296 319
@@ -631,6 +654,11 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb,
631 if (!skb->nf_bridge) 654 if (!skb->nf_bridge)
632 return NF_ACCEPT; 655 return NF_ACCEPT;
633 656
657 /* Need exclusive nf_bridge_info since we might have multiple
658 * different physoutdevs. */
659 if (!nf_bridge_unshare(skb))
660 return NF_DROP;
661
634 parent = bridge_parent(out); 662 parent = bridge_parent(out);
635 if (!parent) 663 if (!parent)
636 return NF_DROP; 664 return NF_DROP;
@@ -712,6 +740,11 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff *skb,
712 if (!skb->nf_bridge) 740 if (!skb->nf_bridge)
713 return NF_ACCEPT; 741 return NF_ACCEPT;
714 742
743 /* Need exclusive nf_bridge_info since we might have multiple
744 * different physoutdevs. */
745 if (!nf_bridge_unshare(skb))
746 return NF_DROP;
747
715 nf_bridge = skb->nf_bridge; 748 nf_bridge = skb->nf_bridge;
716 if (!(nf_bridge->mask & BRNF_BRIDGED_DNAT)) 749 if (!(nf_bridge->mask & BRNF_BRIDGED_DNAT))
717 return NF_ACCEPT; 750 return NF_ACCEPT;
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index f666f7b28ff5..c11b554fd109 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -124,7 +124,7 @@ struct net_bridge
124 struct timer_list tcn_timer; 124 struct timer_list tcn_timer;
125 struct timer_list topology_change_timer; 125 struct timer_list topology_change_timer;
126 struct timer_list gc_timer; 126 struct timer_list gc_timer;
127 struct kobject ifobj; 127 struct kobject *ifobj;
128}; 128};
129 129
130extern struct notifier_block br_device_notifier; 130extern struct notifier_block br_device_notifier;
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 3312e8f2abe4..9cf0538d1717 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -426,16 +426,10 @@ int br_sysfs_addbr(struct net_device *dev)
426 goto out2; 426 goto out2;
427 } 427 }
428 428
429 429 br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj);
430 kobject_set_name(&br->ifobj, SYSFS_BRIDGE_PORT_SUBDIR); 430 if (!br->ifobj) {
431 br->ifobj.ktype = NULL;
432 br->ifobj.kset = NULL;
433 br->ifobj.parent = brobj;
434
435 err = kobject_register(&br->ifobj);
436 if (err) {
437 pr_info("%s: can't add kobject (directory) %s/%s\n", 431 pr_info("%s: can't add kobject (directory) %s/%s\n",
438 __FUNCTION__, dev->name, kobject_name(&br->ifobj)); 432 __FUNCTION__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR);
439 goto out3; 433 goto out3;
440 } 434 }
441 return 0; 435 return 0;
@@ -453,7 +447,7 @@ void br_sysfs_delbr(struct net_device *dev)
453 struct kobject *kobj = &dev->dev.kobj; 447 struct kobject *kobj = &dev->dev.kobj;
454 struct net_bridge *br = netdev_priv(dev); 448 struct net_bridge *br = netdev_priv(dev);
455 449
456 kobject_unregister(&br->ifobj); 450 kobject_put(br->ifobj);
457 sysfs_remove_bin_file(kobj, &bridge_forward); 451 sysfs_remove_bin_file(kobj, &bridge_forward);
458 sysfs_remove_group(kobj, &bridge_group); 452 sysfs_remove_group(kobj, &bridge_group);
459} 453}
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 79db51fcb476..02b2d50cce4d 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -229,7 +229,7 @@ int br_sysfs_addif(struct net_bridge_port *p)
229 goto out2; 229 goto out2;
230 } 230 }
231 231
232 err= sysfs_create_link(&br->ifobj, &p->kobj, p->dev->name); 232 err = sysfs_create_link(br->ifobj, &p->kobj, p->dev->name);
233out2: 233out2:
234 return err; 234 return err;
235} 235}
diff --git a/net/bridge/netfilter/ebt_among.c b/net/bridge/netfilter/ebt_among.c
index 392d877040d3..6436d30a550e 100644
--- a/net/bridge/netfilter/ebt_among.c
+++ b/net/bridge/netfilter/ebt_among.c
@@ -187,7 +187,7 @@ static int ebt_among_check(const char *tablename, unsigned int hookmask,
187 187
188 if (datalen != EBT_ALIGN(expected_length)) { 188 if (datalen != EBT_ALIGN(expected_length)) {
189 printk(KERN_WARNING 189 printk(KERN_WARNING
190 "ebtables: among: wrong size: %d" 190 "ebtables: among: wrong size: %d "
191 "against expected %d, rounded to %Zd\n", 191 "against expected %d, rounded to %Zd\n",
192 datalen, expected_length, 192 datalen, expected_length,
193 EBT_ALIGN(expected_length)); 193 EBT_ALIGN(expected_length));
diff --git a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c
index e44519ebf1d2..be6f18681053 100644
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -70,13 +70,13 @@ static int __init ebtable_broute_init(void)
70 if (ret < 0) 70 if (ret < 0)
71 return ret; 71 return ret;
72 /* see br_input.c */ 72 /* see br_input.c */
73 br_should_route_hook = ebt_broute; 73 rcu_assign_pointer(br_should_route_hook, ebt_broute);
74 return ret; 74 return ret;
75} 75}
76 76
77static void __exit ebtable_broute_fini(void) 77static void __exit ebtable_broute_fini(void)
78{ 78{
79 br_should_route_hook = NULL; 79 rcu_assign_pointer(br_should_route_hook, NULL);
80 synchronize_net(); 80 synchronize_net();
81 ebt_unregister_table(&broute_table); 81 ebt_unregister_table(&broute_table);
82} 82}
diff --git a/net/compat.c b/net/compat.c
index d74d82155d78..377e560ab5c9 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -254,6 +254,8 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
254 if (copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr))) 254 if (copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr)))
255 return -EFAULT; 255 return -EFAULT;
256 cmlen = CMSG_COMPAT_SPACE(len); 256 cmlen = CMSG_COMPAT_SPACE(len);
257 if (kmsg->msg_controllen < cmlen)
258 cmlen = kmsg->msg_controllen;
257 kmsg->msg_control += cmlen; 259 kmsg->msg_control += cmlen;
258 kmsg->msg_controllen -= cmlen; 260 kmsg->msg_controllen -= cmlen;
259 return 0; 261 return 0;
diff --git a/net/core/dev.c b/net/core/dev.c
index 86d62611f2fc..0879f52115eb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2207,8 +2207,12 @@ static void net_rx_action(struct softirq_action *h)
2207 * still "owns" the NAPI instance and therefore can 2207 * still "owns" the NAPI instance and therefore can
2208 * move the instance around on the list at-will. 2208 * move the instance around on the list at-will.
2209 */ 2209 */
2210 if (unlikely(work == weight)) 2210 if (unlikely(work == weight)) {
2211 list_move_tail(&n->poll_list, list); 2211 if (unlikely(napi_disable_pending(n)))
2212 __napi_complete(n);
2213 else
2214 list_move_tail(&n->poll_list, list);
2215 }
2212 2216
2213 netpoll_poll_unlock(have); 2217 netpoll_poll_unlock(have);
2214 } 2218 }
@@ -2819,7 +2823,7 @@ void dev_set_allmulti(struct net_device *dev, int inc)
2819/* 2823/*
2820 * Upload unicast and multicast address lists to device and 2824 * Upload unicast and multicast address lists to device and
2821 * configure RX filtering. When the device doesn't support unicast 2825 * configure RX filtering. When the device doesn't support unicast
2822 * filtering it is put in promiscous mode while unicast addresses 2826 * filtering it is put in promiscuous mode while unicast addresses
2823 * are present. 2827 * are present.
2824 */ 2828 */
2825void __dev_set_rx_mode(struct net_device *dev) 2829void __dev_set_rx_mode(struct net_device *dev)
@@ -3972,8 +3976,7 @@ void synchronize_net(void)
3972 * @dev: device 3976 * @dev: device
3973 * 3977 *
3974 * This function shuts down a device interface and removes it 3978 * This function shuts down a device interface and removes it
3975 * from the kernel tables. On success 0 is returned, on a failure 3979 * from the kernel tables.
3976 * a negative errno code is returned.
3977 * 3980 *
3978 * Callers must hold the rtnl semaphore. You may want 3981 * Callers must hold the rtnl semaphore. You may want
3979 * unregister_netdev() instead of this. 3982 * unregister_netdev() instead of this.
@@ -3991,8 +3994,7 @@ void unregister_netdevice(struct net_device *dev)
3991 * @dev: device 3994 * @dev: device
3992 * 3995 *
3993 * This function shuts down a device interface and removes it 3996 * This function shuts down a device interface and removes it
3994 * from the kernel tables. On success 0 is returned, on a failure 3997 * from the kernel tables.
3995 * a negative errno code is returned.
3996 * 3998 *
3997 * This is just a wrapper for unregister_netdevice that takes 3999 * This is just a wrapper for unregister_netdevice that takes
3998 * the rtnl semaphore. In general you want to use this and not 4000 * the rtnl semaphore. In general you want to use this and not
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 383252b50411..ec936ae92458 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -18,7 +18,7 @@ static DEFINE_MUTEX(net_mutex);
18LIST_HEAD(net_namespace_list); 18LIST_HEAD(net_namespace_list);
19 19
20struct net init_net; 20struct net init_net;
21EXPORT_SYMBOL_GPL(init_net); 21EXPORT_SYMBOL(init_net);
22 22
23/* 23/*
24 * setup_net runs the initializers for the network namespace object. 24 * setup_net runs the initializers for the network namespace object.
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index de33f36947e9..285ec3ed9b37 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2463,8 +2463,6 @@ static int pktgen_output_ipsec(struct sk_buff *skb, struct pktgen_dev *pkt_dev)
2463 2463
2464 x->curlft.bytes +=skb->len; 2464 x->curlft.bytes +=skb->len;
2465 x->curlft.packets++; 2465 x->curlft.packets++;
2466 spin_unlock(&x->lock);
2467
2468error: 2466error:
2469 spin_unlock(&x->lock); 2467 spin_unlock(&x->lock);
2470 return err; 2468 return err;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e1ba26fb4bf2..fed95a323b28 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -308,9 +308,12 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
308 struct net *net; 308 struct net *net;
309 309
310 for_each_net(net) { 310 for_each_net(net) {
311restart:
311 for_each_netdev_safe(net, dev, n) { 312 for_each_netdev_safe(net, dev, n) {
312 if (dev->rtnl_link_ops == ops) 313 if (dev->rtnl_link_ops == ops) {
313 ops->dellink(dev); 314 ops->dellink(dev);
315 goto restart;
316 }
314 } 317 }
315 } 318 }
316 list_del(&ops->list); 319 list_del(&ops->list);
diff --git a/net/core/scm.c b/net/core/scm.c
index 100ba6d9d478..10f5c65f6a47 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -196,6 +196,8 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
196 if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr))) 196 if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
197 goto out; 197 goto out;
198 cmlen = CMSG_SPACE(len); 198 cmlen = CMSG_SPACE(len);
199 if (msg->msg_controllen < cmlen)
200 cmlen = msg->msg_controllen;
199 msg->msg_control += cmlen; 201 msg->msg_control += cmlen;
200 msg->msg_controllen -= cmlen; 202 msg->msg_controllen -= cmlen;
201 err = 0; 203 err = 0;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 32d5826b7177..b6283779e93d 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -275,12 +275,11 @@ static void skb_release_data(struct sk_buff *skb)
275/* 275/*
276 * Free an skbuff by memory without cleaning the state. 276 * Free an skbuff by memory without cleaning the state.
277 */ 277 */
278void kfree_skbmem(struct sk_buff *skb) 278static void kfree_skbmem(struct sk_buff *skb)
279{ 279{
280 struct sk_buff *other; 280 struct sk_buff *other;
281 atomic_t *fclone_ref; 281 atomic_t *fclone_ref;
282 282
283 skb_release_data(skb);
284 switch (skb->fclone) { 283 switch (skb->fclone) {
285 case SKB_FCLONE_UNAVAILABLE: 284 case SKB_FCLONE_UNAVAILABLE:
286 kmem_cache_free(skbuff_head_cache, skb); 285 kmem_cache_free(skbuff_head_cache, skb);
@@ -307,16 +306,8 @@ void kfree_skbmem(struct sk_buff *skb)
307 } 306 }
308} 307}
309 308
310/** 309/* Free everything but the sk_buff shell. */
311 * __kfree_skb - private function 310static void skb_release_all(struct sk_buff *skb)
312 * @skb: buffer
313 *
314 * Free an sk_buff. Release anything attached to the buffer.
315 * Clean the state. This is an internal helper function. Users should
316 * always call kfree_skb
317 */
318
319void __kfree_skb(struct sk_buff *skb)
320{ 311{
321 dst_release(skb->dst); 312 dst_release(skb->dst);
322#ifdef CONFIG_XFRM 313#ifdef CONFIG_XFRM
@@ -340,7 +331,21 @@ void __kfree_skb(struct sk_buff *skb)
340 skb->tc_verd = 0; 331 skb->tc_verd = 0;
341#endif 332#endif
342#endif 333#endif
334 skb_release_data(skb);
335}
336
337/**
338 * __kfree_skb - private function
339 * @skb: buffer
340 *
341 * Free an sk_buff. Release anything attached to the buffer.
342 * Clean the state. This is an internal helper function. Users should
343 * always call kfree_skb
344 */
343 345
346void __kfree_skb(struct sk_buff *skb)
347{
348 skb_release_all(skb);
344 kfree_skbmem(skb); 349 kfree_skbmem(skb);
345} 350}
346 351
@@ -411,16 +416,17 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
411 C(len); 416 C(len);
412 C(data_len); 417 C(data_len);
413 C(mac_len); 418 C(mac_len);
414 n->cloned = 1;
415 n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len; 419 n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len;
420 n->cloned = 1;
416 n->nohdr = 0; 421 n->nohdr = 0;
417 n->destructor = NULL; 422 n->destructor = NULL;
418 C(truesize); 423 C(iif);
419 atomic_set(&n->users, 1);
420 C(head);
421 C(data);
422 C(tail); 424 C(tail);
423 C(end); 425 C(end);
426 C(head);
427 C(data);
428 C(truesize);
429 atomic_set(&n->users, 1);
424 430
425 atomic_inc(&(skb_shinfo(skb)->dataref)); 431 atomic_inc(&(skb_shinfo(skb)->dataref));
426 skb->cloned = 1; 432 skb->cloned = 1;
@@ -441,7 +447,7 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
441 */ 447 */
442struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src) 448struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src)
443{ 449{
444 skb_release_data(dst); 450 skb_release_all(dst);
445 return __skb_clone(dst, src); 451 return __skb_clone(dst, src);
446} 452}
447EXPORT_SYMBOL_GPL(skb_morph); 453EXPORT_SYMBOL_GPL(skb_morph);
diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h
index 9ef0737043ee..9671ecd17e00 100644
--- a/net/dccp/ackvec.h
+++ b/net/dccp/ackvec.h
@@ -71,7 +71,7 @@ struct dccp_ackvec {
71 * @dccpavr_ack_ackno - sequence number being acknowledged 71 * @dccpavr_ack_ackno - sequence number being acknowledged
72 * @dccpavr_ack_ptr - pointer into dccpav_buf where this record starts 72 * @dccpavr_ack_ptr - pointer into dccpav_buf where this record starts
73 * @dccpavr_ack_nonce - dccpav_ack_nonce at the time this record was sent 73 * @dccpavr_ack_nonce - dccpav_ack_nonce at the time this record was sent
74 * @dccpavr_sent_len - lenght of the record in dccpav_buf 74 * @dccpavr_sent_len - length of the record in dccpav_buf
75 */ 75 */
76struct dccp_ackvec_record { 76struct dccp_ackvec_record {
77 struct list_head dccpavr_node; 77 struct list_head dccpavr_node;
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 19b33586333d..d133416d3970 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -239,7 +239,7 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
239 ccid3_tx_state_name(hctx->ccid3hctx_state), 239 ccid3_tx_state_name(hctx->ccid3hctx_state),
240 (unsigned)(hctx->ccid3hctx_x >> 6)); 240 (unsigned)(hctx->ccid3hctx_x >> 6));
241 /* The value of R is still undefined and so we can not recompute 241 /* The value of R is still undefined and so we can not recompute
242 * the timout value. Keep initial value as per [RFC 4342, 5]. */ 242 * the timeout value. Keep initial value as per [RFC 4342, 5]. */
243 t_nfb = TFRC_INITIAL_TIMEOUT; 243 t_nfb = TFRC_INITIAL_TIMEOUT;
244 ccid3_update_send_interval(hctx); 244 ccid3_update_send_interval(hctx);
245 break; 245 break;
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c
index 40ad428a27f5..d26b88dbbb45 100644
--- a/net/dccp/ccids/lib/loss_interval.c
+++ b/net/dccp/ccids/lib/loss_interval.c
@@ -166,7 +166,7 @@ static u32 dccp_li_calc_first_li(struct sock *sk,
166 } 166 }
167 167
168 if (unlikely(interval == 0)) { 168 if (unlikely(interval == 0)) {
169 DCCP_WARN("%s(%p), Could not find a win_count interval > 0." 169 DCCP_WARN("%s(%p), Could not find a win_count interval > 0. "
170 "Defaulting to 1\n", dccp_role(sk), sk); 170 "Defaulting to 1\n", dccp_role(sk), sk);
171 interval = 1; 171 interval = 1;
172 } 172 }
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 66e266fb5908..3bc82dc83b38 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -651,16 +651,18 @@ static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
651 struct dn_dev *dn_db; 651 struct dn_dev *dn_db;
652 struct ifaddrmsg *ifm; 652 struct ifaddrmsg *ifm;
653 struct dn_ifaddr *ifa, **ifap; 653 struct dn_ifaddr *ifa, **ifap;
654 int err = -EADDRNOTAVAIL; 654 int err;
655 655
656 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy); 656 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
657 if (err < 0) 657 if (err < 0)
658 goto errout; 658 goto errout;
659 659
660 err = -ENODEV;
660 ifm = nlmsg_data(nlh); 661 ifm = nlmsg_data(nlh);
661 if ((dn_db = dn_dev_by_index(ifm->ifa_index)) == NULL) 662 if ((dn_db = dn_dev_by_index(ifm->ifa_index)) == NULL)
662 goto errout; 663 goto errout;
663 664
665 err = -EADDRNOTAVAIL;
664 for (ifap = &dn_db->ifa_list; (ifa = *ifap); ifap = &ifa->ifa_next) { 666 for (ifap = &dn_db->ifa_list; (ifa = *ifap); ifap = &ifa->ifa_next) {
665 if (tb[IFA_LOCAL] && 667 if (tb[IFA_LOCAL] &&
666 nla_memcmp(tb[IFA_LOCAL], &ifa->ifa_local, 2)) 668 nla_memcmp(tb[IFA_LOCAL], &ifa->ifa_local, 2))
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 66663e5d7acd..0e10ff21e292 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1665,12 +1665,12 @@ static struct dn_route *dn_rt_cache_get_first(struct seq_file *seq)
1665 break; 1665 break;
1666 rcu_read_unlock_bh(); 1666 rcu_read_unlock_bh();
1667 } 1667 }
1668 return rt; 1668 return rcu_dereference(rt);
1669} 1669}
1670 1670
1671static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt) 1671static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt)
1672{ 1672{
1673 struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private); 1673 struct dn_rt_cache_iter_state *s = seq->private;
1674 1674
1675 rt = rt->u.dst.dn_next; 1675 rt = rt->u.dst.dn_next;
1676 while(!rt) { 1676 while(!rt) {
@@ -1680,7 +1680,7 @@ static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_rou
1680 rcu_read_lock_bh(); 1680 rcu_read_lock_bh();
1681 rt = dn_rt_hash_table[s->bucket].chain; 1681 rt = dn_rt_hash_table[s->bucket].chain;
1682 } 1682 }
1683 return rt; 1683 return rcu_dereference(rt);
1684} 1684}
1685 1685
1686static void *dn_rt_cache_seq_start(struct seq_file *seq, loff_t *pos) 1686static void *dn_rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c
index c6d760d9fbbe..208bf35b5546 100644
--- a/net/ieee80211/ieee80211_crypt_ccmp.c
+++ b/net/ieee80211/ieee80211_crypt_ccmp.c
@@ -338,7 +338,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
338 pos += 8; 338 pos += 8;
339 339
340 if (ccmp_replay_check(pn, key->rx_pn)) { 340 if (ccmp_replay_check(pn, key->rx_pn)) {
341 if (net_ratelimit()) { 341 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) {
342 IEEE80211_DEBUG_DROP("CCMP: replay detected: STA=%s " 342 IEEE80211_DEBUG_DROP("CCMP: replay detected: STA=%s "
343 "previous PN %02x%02x%02x%02x%02x%02x " 343 "previous PN %02x%02x%02x%02x%02x%02x "
344 "received PN %02x%02x%02x%02x%02x%02x\n", 344 "received PN %02x%02x%02x%02x%02x%02x\n",
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 58b22619ab15..8e146949fc6f 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -464,7 +464,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
464 pos += 8; 464 pos += 8;
465 465
466 if (tkip_replay_check(iv32, iv16, tkey->rx_iv32, tkey->rx_iv16)) { 466 if (tkip_replay_check(iv32, iv16, tkey->rx_iv32, tkey->rx_iv16)) {
467 if (net_ratelimit()) { 467 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) {
468 IEEE80211_DEBUG_DROP("TKIP: replay detected: STA=%s" 468 IEEE80211_DEBUG_DROP("TKIP: replay detected: STA=%s"
469 " previous TSC %08x%04x received TSC " 469 " previous TSC %08x%04x received TSC "
470 "%08x%04x\n", print_mac(mac, hdr->addr2), 470 "%08x%04x\n", print_mac(mac, hdr->addr2),
@@ -504,7 +504,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
504 * it needs to be recalculated for the next packet. */ 504 * it needs to be recalculated for the next packet. */
505 tkey->rx_phase1_done = 0; 505 tkey->rx_phase1_done = 0;
506 } 506 }
507 if (net_ratelimit()) { 507 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) {
508 IEEE80211_DEBUG_DROP("TKIP: ICV error detected: STA=" 508 IEEE80211_DEBUG_DROP("TKIP: ICV error detected: STA="
509 "%s\n", print_mac(mac, hdr->addr2)); 509 "%s\n", print_mac(mac, hdr->addr2));
510 } 510 }
diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c
index a4c3c51140a3..6d06f1385e28 100644
--- a/net/ieee80211/ieee80211_tx.c
+++ b/net/ieee80211/ieee80211_tx.c
@@ -144,7 +144,8 @@ static int ieee80211_copy_snap(u8 * data, u16 h_proto)
144 snap->oui[1] = oui[1]; 144 snap->oui[1] = oui[1];
145 snap->oui[2] = oui[2]; 145 snap->oui[2] = oui[2];
146 146
147 *(u16 *) (data + SNAP_SIZE) = htons(h_proto); 147 h_proto = htons(h_proto);
148 memcpy(data + SNAP_SIZE, &h_proto, sizeof(u16));
148 149
149 return SNAP_SIZE + sizeof(u16); 150 return SNAP_SIZE + sizeof(u16);
150} 151}
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 36d6798947b5..08174a2aa878 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -111,12 +111,8 @@
111#include <net/tcp.h> 111#include <net/tcp.h>
112#include <net/sock.h> 112#include <net/sock.h>
113#include <net/arp.h> 113#include <net/arp.h>
114#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
115#include <net/ax25.h> 114#include <net/ax25.h>
116#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
117#include <net/netrom.h> 115#include <net/netrom.h>
118#endif
119#endif
120#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) 116#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
121#include <net/atmclip.h> 117#include <net/atmclip.h>
122struct neigh_table *clip_tbl_hook; 118struct neigh_table *clip_tbl_hook;
@@ -710,7 +706,7 @@ static int arp_process(struct sk_buff *skb)
710 struct arphdr *arp; 706 struct arphdr *arp;
711 unsigned char *arp_ptr; 707 unsigned char *arp_ptr;
712 struct rtable *rt; 708 struct rtable *rt;
713 unsigned char *sha, *tha; 709 unsigned char *sha;
714 __be32 sip, tip; 710 __be32 sip, tip;
715 u16 dev_type = dev->type; 711 u16 dev_type = dev->type;
716 int addr_type; 712 int addr_type;
@@ -731,20 +727,10 @@ static int arp_process(struct sk_buff *skb)
731 htons(dev_type) != arp->ar_hrd) 727 htons(dev_type) != arp->ar_hrd)
732 goto out; 728 goto out;
733 break; 729 break;
734#ifdef CONFIG_NET_ETHERNET
735 case ARPHRD_ETHER: 730 case ARPHRD_ETHER:
736#endif
737#ifdef CONFIG_TR
738 case ARPHRD_IEEE802_TR: 731 case ARPHRD_IEEE802_TR:
739#endif
740#ifdef CONFIG_FDDI
741 case ARPHRD_FDDI: 732 case ARPHRD_FDDI:
742#endif
743#ifdef CONFIG_NET_FC
744 case ARPHRD_IEEE802: 733 case ARPHRD_IEEE802:
745#endif
746#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_TR) || \
747 defined(CONFIG_FDDI) || defined(CONFIG_NET_FC)
748 /* 734 /*
749 * ETHERNET, Token Ring and Fibre Channel (which are IEEE 802 735 * ETHERNET, Token Ring and Fibre Channel (which are IEEE 802
750 * devices, according to RFC 2625) devices will accept ARP 736 * devices, according to RFC 2625) devices will accept ARP
@@ -759,21 +745,16 @@ static int arp_process(struct sk_buff *skb)
759 arp->ar_pro != htons(ETH_P_IP)) 745 arp->ar_pro != htons(ETH_P_IP))
760 goto out; 746 goto out;
761 break; 747 break;
762#endif
763#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
764 case ARPHRD_AX25: 748 case ARPHRD_AX25:
765 if (arp->ar_pro != htons(AX25_P_IP) || 749 if (arp->ar_pro != htons(AX25_P_IP) ||
766 arp->ar_hrd != htons(ARPHRD_AX25)) 750 arp->ar_hrd != htons(ARPHRD_AX25))
767 goto out; 751 goto out;
768 break; 752 break;
769#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
770 case ARPHRD_NETROM: 753 case ARPHRD_NETROM:
771 if (arp->ar_pro != htons(AX25_P_IP) || 754 if (arp->ar_pro != htons(AX25_P_IP) ||
772 arp->ar_hrd != htons(ARPHRD_NETROM)) 755 arp->ar_hrd != htons(ARPHRD_NETROM))
773 goto out; 756 goto out;
774 break; 757 break;
775#endif
776#endif
777 } 758 }
778 759
779 /* Understand only these message types */ 760 /* Understand only these message types */
@@ -790,7 +771,6 @@ static int arp_process(struct sk_buff *skb)
790 arp_ptr += dev->addr_len; 771 arp_ptr += dev->addr_len;
791 memcpy(&sip, arp_ptr, 4); 772 memcpy(&sip, arp_ptr, 4);
792 arp_ptr += 4; 773 arp_ptr += 4;
793 tha = arp_ptr;
794 arp_ptr += dev->addr_len; 774 arp_ptr += dev->addr_len;
795 memcpy(&tip, arp_ptr, 4); 775 memcpy(&tip, arp_ptr, 4);
796/* 776/*
@@ -828,7 +808,8 @@ static int arp_process(struct sk_buff *skb)
828 if (arp->ar_op == htons(ARPOP_REQUEST) && 808 if (arp->ar_op == htons(ARPOP_REQUEST) &&
829 inet_addr_type(tip) == RTN_LOCAL && 809 inet_addr_type(tip) == RTN_LOCAL &&
830 !arp_ignore(in_dev,dev,sip,tip)) 810 !arp_ignore(in_dev,dev,sip,tip))
831 arp_send(ARPOP_REPLY,ETH_P_ARP,tip,dev,tip,sha,dev->dev_addr,dev->dev_addr); 811 arp_send(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha,
812 dev->dev_addr, sha);
832 goto out; 813 goto out;
833 } 814 }
834 815
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 55d199e4ae21..b42f74617bac 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -516,8 +516,6 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
516 goto errout; 516 goto errout;
517 } 517 }
518 518
519 ipv4_devconf_setall(in_dev);
520
521 ifa = inet_alloc_ifa(); 519 ifa = inet_alloc_ifa();
522 if (ifa == NULL) { 520 if (ifa == NULL) {
523 /* 521 /*
@@ -528,6 +526,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
528 goto errout; 526 goto errout;
529 } 527 }
530 528
529 ipv4_devconf_setall(in_dev);
531 in_dev_hold(in_dev); 530 in_dev_hold(in_dev);
532 531
533 if (tb[IFA_ADDRESS] == NULL) 532 if (tb[IFA_ADDRESS] == NULL)
@@ -1028,7 +1027,7 @@ static void inetdev_changename(struct net_device *dev, struct in_device *in_dev)
1028 memcpy(ifa->ifa_label, dev->name, IFNAMSIZ); 1027 memcpy(ifa->ifa_label, dev->name, IFNAMSIZ);
1029 if (named++ == 0) 1028 if (named++ == 0)
1030 continue; 1029 continue;
1031 dot = strchr(ifa->ifa_label, ':'); 1030 dot = strchr(old, ':');
1032 if (dot == NULL) { 1031 if (dot == NULL) {
1033 sprintf(old, ":%d", named); 1032 sprintf(old, ":%d", named);
1034 dot = old; 1033 dot = old;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index c31bccb9b526..1738113268bc 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -9,6 +9,7 @@
9#include <linux/pfkeyv2.h> 9#include <linux/pfkeyv2.h>
10#include <linux/random.h> 10#include <linux/random.h>
11#include <linux/spinlock.h> 11#include <linux/spinlock.h>
12#include <linux/in6.h>
12#include <net/icmp.h> 13#include <net/icmp.h>
13#include <net/protocol.h> 14#include <net/protocol.h>
14#include <net/udp.h> 15#include <net/udp.h>
@@ -224,6 +225,10 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
224 225
225 /* ... check padding bits here. Silly. :-) */ 226 /* ... check padding bits here. Silly. :-) */
226 227
228 /* RFC4303: Drop dummy packets without any error */
229 if (nexthdr[1] == IPPROTO_NONE)
230 goto out;
231
227 iph = ip_hdr(skb); 232 iph = ip_hdr(skb);
228 ihl = iph->ihl * 4; 233 ihl = iph->ihl * 4;
229 234
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 732d8f088b13..97abf934d185 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -804,10 +804,13 @@ static void nl_fib_input(struct sk_buff *skb)
804 804
805 nlh = nlmsg_hdr(skb); 805 nlh = nlmsg_hdr(skb);
806 if (skb->len < NLMSG_SPACE(0) || skb->len < nlh->nlmsg_len || 806 if (skb->len < NLMSG_SPACE(0) || skb->len < nlh->nlmsg_len ||
807 nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*frn))) { 807 nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*frn)))
808 kfree_skb(skb);
809 return; 808 return;
810 } 809
810 skb = skb_clone(skb, GFP_KERNEL);
811 if (skb == NULL)
812 return;
813 nlh = nlmsg_hdr(skb);
811 814
812 frn = (struct fib_result_nl *) NLMSG_DATA(nlh); 815 frn = (struct fib_result_nl *) NLMSG_DATA(nlh);
813 tb = fib_get_table(frn->tb_id_in); 816 tb = fib_get_table(frn->tb_id_in);
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 527a6e0af5b6..0dfee27cfbcd 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -444,6 +444,9 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
444 struct fib_info *fi_drop; 444 struct fib_info *fi_drop;
445 u8 state; 445 u8 state;
446 446
447 if (fi->fib_treeref > 1)
448 goto out;
449
447 write_lock_bh(&fib_hash_lock); 450 write_lock_bh(&fib_hash_lock);
448 fi_drop = fa->fa_info; 451 fi_drop = fa->fa_info;
449 fa->fa_info = fi; 452 fa->fa_info = fi;
@@ -718,19 +721,18 @@ fn_hash_dump_zone(struct sk_buff *skb, struct netlink_callback *cb,
718{ 721{
719 int h, s_h; 722 int h, s_h;
720 723
724 if (fz->fz_hash == NULL)
725 return skb->len;
721 s_h = cb->args[3]; 726 s_h = cb->args[3];
722 for (h=0; h < fz->fz_divisor; h++) { 727 for (h = s_h; h < fz->fz_divisor; h++) {
723 if (h < s_h) continue; 728 if (hlist_empty(&fz->fz_hash[h]))
724 if (h > s_h)
725 memset(&cb->args[4], 0,
726 sizeof(cb->args) - 4*sizeof(cb->args[0]));
727 if (fz->fz_hash == NULL ||
728 hlist_empty(&fz->fz_hash[h]))
729 continue; 729 continue;
730 if (fn_hash_dump_bucket(skb, cb, tb, fz, &fz->fz_hash[h])<0) { 730 if (fn_hash_dump_bucket(skb, cb, tb, fz, &fz->fz_hash[h]) < 0) {
731 cb->args[3] = h; 731 cb->args[3] = h;
732 return -1; 732 return -1;
733 } 733 }
734 memset(&cb->args[4], 0,
735 sizeof(cb->args) - 4*sizeof(cb->args[0]));
734 } 736 }
735 cb->args[3] = h; 737 cb->args[3] = h;
736 return skb->len; 738 return skb->len;
@@ -746,14 +748,13 @@ static int fn_hash_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin
746 read_lock(&fib_hash_lock); 748 read_lock(&fib_hash_lock);
747 for (fz = table->fn_zone_list, m=0; fz; fz = fz->fz_next, m++) { 749 for (fz = table->fn_zone_list, m=0; fz; fz = fz->fz_next, m++) {
748 if (m < s_m) continue; 750 if (m < s_m) continue;
749 if (m > s_m)
750 memset(&cb->args[3], 0,
751 sizeof(cb->args) - 3*sizeof(cb->args[0]));
752 if (fn_hash_dump_zone(skb, cb, tb, fz) < 0) { 751 if (fn_hash_dump_zone(skb, cb, tb, fz) < 0) {
753 cb->args[2] = m; 752 cb->args[2] = m;
754 read_unlock(&fib_hash_lock); 753 read_unlock(&fib_hash_lock);
755 return -1; 754 return -1;
756 } 755 }
756 memset(&cb->args[3], 0,
757 sizeof(cb->args) - 3*sizeof(cb->args[0]));
757 } 758 }
758 read_unlock(&fib_hash_lock); 759 read_unlock(&fib_hash_lock);
759 cb->args[2] = m; 760 cb->args[2] = m;
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 8d8c2915e064..1010b469d7d3 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1214,6 +1214,9 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1214 struct fib_info *fi_drop; 1214 struct fib_info *fi_drop;
1215 u8 state; 1215 u8 state;
1216 1216
1217 if (fi->fib_treeref > 1)
1218 goto out;
1219
1217 err = -ENOBUFS; 1220 err = -ENOBUFS;
1218 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL); 1221 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
1219 if (new_fa == NULL) 1222 if (new_fa == NULL)
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 233de0634298..82baea026484 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -540,7 +540,6 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
540 icmp_param.data.icmph.checksum = 0; 540 icmp_param.data.icmph.checksum = 0;
541 icmp_param.skb = skb_in; 541 icmp_param.skb = skb_in;
542 icmp_param.offset = skb_network_offset(skb_in); 542 icmp_param.offset = skb_network_offset(skb_in);
543 icmp_out_count(icmp_param.data.icmph.type);
544 inet_sk(icmp_socket->sk)->tos = tos; 543 inet_sk(icmp_socket->sk)->tos = tos;
545 ipc.addr = iph->saddr; 544 ipc.addr = iph->saddr;
546 ipc.opt = &icmp_param.replyopts; 545 ipc.opt = &icmp_param.replyopts;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index b0170732b5e9..e468e7a7aac4 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -51,6 +51,29 @@ static struct sock *idiagnl;
51#define INET_DIAG_PUT(skb, attrtype, attrlen) \ 51#define INET_DIAG_PUT(skb, attrtype, attrlen) \
52 RTA_DATA(__RTA_PUT(skb, attrtype, attrlen)) 52 RTA_DATA(__RTA_PUT(skb, attrtype, attrlen))
53 53
54static DEFINE_MUTEX(inet_diag_table_mutex);
55
56static const struct inet_diag_handler *inet_diag_lock_handler(int type)
57{
58#ifdef CONFIG_KMOD
59 if (!inet_diag_table[type])
60 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
61 NETLINK_INET_DIAG, type);
62#endif
63
64 mutex_lock(&inet_diag_table_mutex);
65 if (!inet_diag_table[type])
66 return ERR_PTR(-ENOENT);
67
68 return inet_diag_table[type];
69}
70
71static inline void inet_diag_unlock_handler(
72 const struct inet_diag_handler *handler)
73{
74 mutex_unlock(&inet_diag_table_mutex);
75}
76
54static int inet_csk_diag_fill(struct sock *sk, 77static int inet_csk_diag_fill(struct sock *sk,
55 struct sk_buff *skb, 78 struct sk_buff *skb,
56 int ext, u32 pid, u32 seq, u16 nlmsg_flags, 79 int ext, u32 pid, u32 seq, u16 nlmsg_flags,
@@ -235,9 +258,12 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
235 struct inet_hashinfo *hashinfo; 258 struct inet_hashinfo *hashinfo;
236 const struct inet_diag_handler *handler; 259 const struct inet_diag_handler *handler;
237 260
238 handler = inet_diag_table[nlh->nlmsg_type]; 261 handler = inet_diag_lock_handler(nlh->nlmsg_type);
239 BUG_ON(handler == NULL); 262 if (!handler)
263 return -ENOENT;
264
240 hashinfo = handler->idiag_hashinfo; 265 hashinfo = handler->idiag_hashinfo;
266 err = -EINVAL;
241 267
242 if (req->idiag_family == AF_INET) { 268 if (req->idiag_family == AF_INET) {
243 sk = inet_lookup(hashinfo, req->id.idiag_dst[0], 269 sk = inet_lookup(hashinfo, req->id.idiag_dst[0],
@@ -255,11 +281,12 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
255 } 281 }
256#endif 282#endif
257 else { 283 else {
258 return -EINVAL; 284 goto unlock;
259 } 285 }
260 286
287 err = -ENOENT;
261 if (sk == NULL) 288 if (sk == NULL)
262 return -ENOENT; 289 goto unlock;
263 290
264 err = -ESTALE; 291 err = -ESTALE;
265 if ((req->id.idiag_cookie[0] != INET_DIAG_NOCOOKIE || 292 if ((req->id.idiag_cookie[0] != INET_DIAG_NOCOOKIE ||
@@ -296,6 +323,8 @@ out:
296 else 323 else
297 sock_put(sk); 324 sock_put(sk);
298 } 325 }
326unlock:
327 inet_diag_unlock_handler(handler);
299 return err; 328 return err;
300} 329}
301 330
@@ -678,8 +707,10 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
678 const struct inet_diag_handler *handler; 707 const struct inet_diag_handler *handler;
679 struct inet_hashinfo *hashinfo; 708 struct inet_hashinfo *hashinfo;
680 709
681 handler = inet_diag_table[cb->nlh->nlmsg_type]; 710 handler = inet_diag_lock_handler(cb->nlh->nlmsg_type);
682 BUG_ON(handler == NULL); 711 if (!handler)
712 goto no_handler;
713
683 hashinfo = handler->idiag_hashinfo; 714 hashinfo = handler->idiag_hashinfo;
684 715
685 s_i = cb->args[1]; 716 s_i = cb->args[1];
@@ -743,7 +774,7 @@ skip_listen_ht:
743 } 774 }
744 775
745 if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV))) 776 if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV)))
746 return skb->len; 777 goto unlock;
747 778
748 for (i = s_i; i < hashinfo->ehash_size; i++) { 779 for (i = s_i; i < hashinfo->ehash_size; i++) {
749 struct inet_ehash_bucket *head = &hashinfo->ehash[i]; 780 struct inet_ehash_bucket *head = &hashinfo->ehash[i];
@@ -805,6 +836,9 @@ next_dying:
805done: 836done:
806 cb->args[1] = i; 837 cb->args[1] = i;
807 cb->args[2] = num; 838 cb->args[2] = num;
839unlock:
840 inet_diag_unlock_handler(handler);
841no_handler:
808 return skb->len; 842 return skb->len;
809} 843}
810 844
@@ -816,15 +850,6 @@ static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
816 nlmsg_len(nlh) < hdrlen) 850 nlmsg_len(nlh) < hdrlen)
817 return -EINVAL; 851 return -EINVAL;
818 852
819#ifdef CONFIG_KMOD
820 if (inet_diag_table[nlh->nlmsg_type] == NULL)
821 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
822 NETLINK_INET_DIAG, nlh->nlmsg_type);
823#endif
824
825 if (inet_diag_table[nlh->nlmsg_type] == NULL)
826 return -ENOENT;
827
828 if (nlh->nlmsg_flags & NLM_F_DUMP) { 853 if (nlh->nlmsg_flags & NLM_F_DUMP) {
829 if (nlmsg_attrlen(nlh, hdrlen)) { 854 if (nlmsg_attrlen(nlh, hdrlen)) {
830 struct nlattr *attr; 855 struct nlattr *attr;
@@ -853,8 +878,6 @@ static void inet_diag_rcv(struct sk_buff *skb)
853 mutex_unlock(&inet_diag_mutex); 878 mutex_unlock(&inet_diag_mutex);
854} 879}
855 880
856static DEFINE_SPINLOCK(inet_diag_register_lock);
857
858int inet_diag_register(const struct inet_diag_handler *h) 881int inet_diag_register(const struct inet_diag_handler *h)
859{ 882{
860 const __u16 type = h->idiag_type; 883 const __u16 type = h->idiag_type;
@@ -863,13 +886,13 @@ int inet_diag_register(const struct inet_diag_handler *h)
863 if (type >= INET_DIAG_GETSOCK_MAX) 886 if (type >= INET_DIAG_GETSOCK_MAX)
864 goto out; 887 goto out;
865 888
866 spin_lock(&inet_diag_register_lock); 889 mutex_lock(&inet_diag_table_mutex);
867 err = -EEXIST; 890 err = -EEXIST;
868 if (inet_diag_table[type] == NULL) { 891 if (inet_diag_table[type] == NULL) {
869 inet_diag_table[type] = h; 892 inet_diag_table[type] = h;
870 err = 0; 893 err = 0;
871 } 894 }
872 spin_unlock(&inet_diag_register_lock); 895 mutex_unlock(&inet_diag_table_mutex);
873out: 896out:
874 return err; 897 return err;
875} 898}
@@ -882,11 +905,9 @@ void inet_diag_unregister(const struct inet_diag_handler *h)
882 if (type >= INET_DIAG_GETSOCK_MAX) 905 if (type >= INET_DIAG_GETSOCK_MAX)
883 return; 906 return;
884 907
885 spin_lock(&inet_diag_register_lock); 908 mutex_lock(&inet_diag_table_mutex);
886 inet_diag_table[type] = NULL; 909 inet_diag_table[type] = NULL;
887 spin_unlock(&inet_diag_register_lock); 910 mutex_unlock(&inet_diag_table_mutex);
888
889 synchronize_rcu();
890} 911}
891EXPORT_SYMBOL_GPL(inet_diag_unregister); 912EXPORT_SYMBOL_GPL(inet_diag_unregister);
892 913
diff --git a/net/ipv4/inet_lro.c b/net/ipv4/inet_lro.c
index ac3b1d3dba2e..4a4d49fca1f2 100644
--- a/net/ipv4/inet_lro.c
+++ b/net/ipv4/inet_lro.c
@@ -310,7 +310,7 @@ static void lro_flush(struct net_lro_mgr *lro_mgr,
310 skb_shinfo(lro_desc->parent)->gso_size = lro_desc->mss; 310 skb_shinfo(lro_desc->parent)->gso_size = lro_desc->mss;
311 311
312 if (lro_desc->vgrp) { 312 if (lro_desc->vgrp) {
313 if (test_bit(LRO_F_NAPI, &lro_mgr->features)) 313 if (lro_mgr->features & LRO_F_NAPI)
314 vlan_hwaccel_receive_skb(lro_desc->parent, 314 vlan_hwaccel_receive_skb(lro_desc->parent,
315 lro_desc->vgrp, 315 lro_desc->vgrp,
316 lro_desc->vlan_tag); 316 lro_desc->vlan_tag);
@@ -320,7 +320,7 @@ static void lro_flush(struct net_lro_mgr *lro_mgr,
320 lro_desc->vlan_tag); 320 lro_desc->vlan_tag);
321 321
322 } else { 322 } else {
323 if (test_bit(LRO_F_NAPI, &lro_mgr->features)) 323 if (lro_mgr->features & LRO_F_NAPI)
324 netif_receive_skb(lro_desc->parent); 324 netif_receive_skb(lro_desc->parent);
325 else 325 else
326 netif_rx(lro_desc->parent); 326 netif_rx(lro_desc->parent);
@@ -352,7 +352,7 @@ static int __lro_proc_skb(struct net_lro_mgr *lro_mgr, struct sk_buff *skb,
352 goto out; 352 goto out;
353 353
354 if ((skb->protocol == htons(ETH_P_8021Q)) 354 if ((skb->protocol == htons(ETH_P_8021Q))
355 && !test_bit(LRO_F_EXTRACT_VLAN_ID, &lro_mgr->features)) 355 && !(lro_mgr->features & LRO_F_EXTRACT_VLAN_ID))
356 vlan_hdr_len = VLAN_HLEN; 356 vlan_hdr_len = VLAN_HLEN;
357 357
358 if (!lro_desc->active) { /* start new lro session */ 358 if (!lro_desc->active) { /* start new lro session */
@@ -401,10 +401,11 @@ static struct sk_buff *lro_gen_skb(struct net_lro_mgr *lro_mgr,
401 int data_len = len; 401 int data_len = len;
402 int hdr_len = min(len, hlen); 402 int hdr_len = min(len, hlen);
403 403
404 skb = netdev_alloc_skb(lro_mgr->dev, hlen); 404 skb = netdev_alloc_skb(lro_mgr->dev, hlen + lro_mgr->frag_align_pad);
405 if (!skb) 405 if (!skb)
406 return NULL; 406 return NULL;
407 407
408 skb_reserve(skb, lro_mgr->frag_align_pad);
408 skb->len = len; 409 skb->len = len;
409 skb->data_len = len - hdr_len; 410 skb->data_len = len - hdr_len;
410 skb->truesize += true_size; 411 skb->truesize += true_size;
@@ -473,7 +474,7 @@ static struct sk_buff *__lro_proc_segment(struct net_lro_mgr *lro_mgr,
473 goto out; 474 goto out;
474 475
475 if ((skb->protocol == htons(ETH_P_8021Q)) 476 if ((skb->protocol == htons(ETH_P_8021Q))
476 && !test_bit(LRO_F_EXTRACT_VLAN_ID, &lro_mgr->features)) 477 && !(lro_mgr->features & LRO_F_EXTRACT_VLAN_ID))
477 vlan_hdr_len = VLAN_HLEN; 478 vlan_hdr_len = VLAN_HLEN;
478 479
479 iph = (void *)(skb->data + vlan_hdr_len); 480 iph = (void *)(skb->data + vlan_hdr_len);
@@ -515,7 +516,7 @@ void lro_receive_skb(struct net_lro_mgr *lro_mgr,
515 void *priv) 516 void *priv)
516{ 517{
517 if (__lro_proc_skb(lro_mgr, skb, NULL, 0, priv)) { 518 if (__lro_proc_skb(lro_mgr, skb, NULL, 0, priv)) {
518 if (test_bit(LRO_F_NAPI, &lro_mgr->features)) 519 if (lro_mgr->features & LRO_F_NAPI)
519 netif_receive_skb(skb); 520 netif_receive_skb(skb);
520 else 521 else
521 netif_rx(skb); 522 netif_rx(skb);
@@ -530,7 +531,7 @@ void lro_vlan_hwaccel_receive_skb(struct net_lro_mgr *lro_mgr,
530 void *priv) 531 void *priv)
531{ 532{
532 if (__lro_proc_skb(lro_mgr, skb, vgrp, vlan_tag, priv)) { 533 if (__lro_proc_skb(lro_mgr, skb, vgrp, vlan_tag, priv)) {
533 if (test_bit(LRO_F_NAPI, &lro_mgr->features)) 534 if (lro_mgr->features & LRO_F_NAPI)
534 vlan_hwaccel_receive_skb(skb, vgrp, vlan_tag); 535 vlan_hwaccel_receive_skb(skb, vgrp, vlan_tag);
535 else 536 else
536 vlan_hwaccel_rx(skb, vgrp, vlan_tag); 537 vlan_hwaccel_rx(skb, vgrp, vlan_tag);
@@ -549,7 +550,7 @@ void lro_receive_frags(struct net_lro_mgr *lro_mgr,
549 if (!skb) 550 if (!skb)
550 return; 551 return;
551 552
552 if (test_bit(LRO_F_NAPI, &lro_mgr->features)) 553 if (lro_mgr->features & LRO_F_NAPI)
553 netif_receive_skb(skb); 554 netif_receive_skb(skb);
554 else 555 else
555 netif_rx(skb); 556 netif_rx(skb);
@@ -569,7 +570,7 @@ void lro_vlan_hwaccel_receive_frags(struct net_lro_mgr *lro_mgr,
569 if (!skb) 570 if (!skb)
570 return; 571 return;
571 572
572 if (test_bit(LRO_F_NAPI, &lro_mgr->features)) 573 if (lro_mgr->features & LRO_F_NAPI)
573 vlan_hwaccel_receive_skb(skb, vgrp, vlan_tag); 574 vlan_hwaccel_receive_skb(skb, vgrp, vlan_tag);
574 else 575 else
575 vlan_hwaccel_rx(skb, vgrp, vlan_tag); 576 vlan_hwaccel_rx(skb, vgrp, vlan_tag);
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 02b02a8d681c..4b93f32de10d 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -613,7 +613,7 @@ static int ipgre_rcv(struct sk_buff *skb)
613 offset += 4; 613 offset += 4;
614 } 614 }
615 615
616 skb_reset_mac_header(skb); 616 skb->mac_header = skb->network_header;
617 __pskb_pull(skb, offset); 617 __pskb_pull(skb, offset);
618 skb_reset_network_header(skb); 618 skb_reset_network_header(skb);
619 skb_postpull_rcsum(skb, skb_transport_header(skb), offset); 619 skb_postpull_rcsum(skb, skb_transport_header(skb), offset);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index fd99fbd685ea..bc9e57550e86 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1016,8 +1016,6 @@ alloc_new_skb:
1016 1016
1017 skb_fill_page_desc(skb, i, page, 0, 0); 1017 skb_fill_page_desc(skb, i, page, 0, 0);
1018 frag = &skb_shinfo(skb)->frags[i]; 1018 frag = &skb_shinfo(skb)->frags[i];
1019 skb->truesize += PAGE_SIZE;
1020 atomic_add(PAGE_SIZE, &sk->sk_wmem_alloc);
1021 } else { 1019 } else {
1022 err = -EMSGSIZE; 1020 err = -EMSGSIZE;
1023 goto error; 1021 goto error;
@@ -1030,6 +1028,8 @@ alloc_new_skb:
1030 frag->size += copy; 1028 frag->size += copy;
1031 skb->len += copy; 1029 skb->len += copy;
1032 skb->data_len += copy; 1030 skb->data_len += copy;
1031 skb->truesize += copy;
1032 atomic_add(copy, &sk->sk_wmem_alloc);
1033 } 1033 }
1034 offset += copy; 1034 offset += copy;
1035 length -= copy; 1035 length -= copy;
@@ -1172,6 +1172,8 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
1172 1172
1173 skb->len += len; 1173 skb->len += len;
1174 skb->data_len += len; 1174 skb->data_len += len;
1175 skb->truesize += len;
1176 atomic_add(len, &sk->sk_wmem_alloc);
1175 offset += len; 1177 offset += len;
1176 size -= len; 1178 size -= len;
1177 } 1179 }
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index c5c107a01823..b8f7763b2261 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -1396,31 +1396,16 @@ late_initcall(ip_auto_config);
1396 1396
1397/* 1397/*
1398 * Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel 1398 * Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel
1399 * command line parameter. It consists of option fields separated by colons in 1399 * command line parameter. See Documentation/nfsroot.txt.
1400 * the following order:
1401 *
1402 * <client-ip>:<server-ip>:<gw-ip>:<netmask>:<host name>:<device>:<PROTO>
1403 *
1404 * Any of the fields can be empty which means to use a default value:
1405 * <client-ip> - address given by BOOTP or RARP
1406 * <server-ip> - address of host returning BOOTP or RARP packet
1407 * <gw-ip> - none, or the address returned by BOOTP
1408 * <netmask> - automatically determined from <client-ip>, or the
1409 * one returned by BOOTP
1410 * <host name> - <client-ip> in ASCII notation, or the name returned
1411 * by BOOTP
1412 * <device> - use all available devices
1413 * <PROTO>:
1414 * off|none - don't do autoconfig at all (DEFAULT)
1415 * on|any - use any configured protocol
1416 * dhcp|bootp|rarp - use only the specified protocol
1417 * both - use both BOOTP and RARP (not DHCP)
1418 */ 1400 */
1419static int __init ic_proto_name(char *name) 1401static int __init ic_proto_name(char *name)
1420{ 1402{
1421 if (!strcmp(name, "on") || !strcmp(name, "any")) { 1403 if (!strcmp(name, "on") || !strcmp(name, "any")) {
1422 return 1; 1404 return 1;
1423 } 1405 }
1406 if (!strcmp(name, "off") || !strcmp(name, "none")) {
1407 return 0;
1408 }
1424#ifdef CONFIG_IP_PNP_DHCP 1409#ifdef CONFIG_IP_PNP_DHCP
1425 else if (!strcmp(name, "dhcp")) { 1410 else if (!strcmp(name, "dhcp")) {
1426 ic_proto_enabled &= ~IC_RARP; 1411 ic_proto_enabled &= ~IC_RARP;
@@ -1454,17 +1439,24 @@ static int __init ip_auto_config_setup(char *addrs)
1454 int num = 0; 1439 int num = 0;
1455 1440
1456 ic_set_manually = 1; 1441 ic_set_manually = 1;
1442 ic_enable = 1;
1457 1443
1458 ic_enable = (*addrs && 1444 /*
1459 (strcmp(addrs, "off") != 0) && 1445 * If any dhcp, bootp etc options are set, leave autoconfig on
1460 (strcmp(addrs, "none") != 0)); 1446 * and skip the below static IP processing.
1461 if (!ic_enable) 1447 */
1448 if (ic_proto_name(addrs))
1462 return 1; 1449 return 1;
1463 1450
1464 if (ic_proto_name(addrs)) 1451 /* If no static IP is given, turn off autoconfig and bail. */
1452 if (*addrs == 0 ||
1453 strcmp(addrs, "off") == 0 ||
1454 strcmp(addrs, "none") == 0) {
1455 ic_enable = 0;
1465 return 1; 1456 return 1;
1457 }
1466 1458
1467 /* Parse the whole string */ 1459 /* Parse string for static IP assignment. */
1468 ip = addrs; 1460 ip = addrs;
1469 while (ip && *ip) { 1461 while (ip && *ip) {
1470 if ((cp = strchr(ip, ':'))) 1462 if ((cp = strchr(ip, ':')))
@@ -1502,7 +1494,10 @@ static int __init ip_auto_config_setup(char *addrs)
1502 strlcpy(user_dev_name, ip, sizeof(user_dev_name)); 1494 strlcpy(user_dev_name, ip, sizeof(user_dev_name));
1503 break; 1495 break;
1504 case 6: 1496 case 6:
1505 ic_proto_name(ip); 1497 if (ic_proto_name(ip) == 0 &&
1498 ic_myaddr == NONE) {
1499 ic_enable = 0;
1500 }
1506 break; 1501 break;
1507 } 1502 }
1508 } 1503 }
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c
index 20c884a57721..8fba20256f52 100644
--- a/net/ipv4/ipvs/ip_vs_core.c
+++ b/net/ipv4/ipvs/ip_vs_core.c
@@ -637,7 +637,7 @@ static int ip_vs_out_icmp(struct sk_buff *skb, int *related)
637 verdict = NF_DROP; 637 verdict = NF_DROP;
638 638
639 if (IP_VS_FWD_METHOD(cp) != 0) { 639 if (IP_VS_FWD_METHOD(cp) != 0) {
640 IP_VS_ERR("shouldn't reach here, because the box is on the" 640 IP_VS_ERR("shouldn't reach here, because the box is on the "
641 "half connection in the tun/dr module.\n"); 641 "half connection in the tun/dr module.\n");
642 } 642 }
643 643
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index b64cf45a9ead..693d92490c11 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -1424,7 +1424,6 @@ proc_do_sync_threshold(ctl_table *table, int write, struct file *filp,
1424 1424
1425static struct ctl_table vs_vars[] = { 1425static struct ctl_table vs_vars[] = {
1426 { 1426 {
1427 .ctl_name = NET_IPV4_VS_AMEMTHRESH,
1428 .procname = "amemthresh", 1427 .procname = "amemthresh",
1429 .data = &sysctl_ip_vs_amemthresh, 1428 .data = &sysctl_ip_vs_amemthresh,
1430 .maxlen = sizeof(int), 1429 .maxlen = sizeof(int),
@@ -1433,7 +1432,6 @@ static struct ctl_table vs_vars[] = {
1433 }, 1432 },
1434#ifdef CONFIG_IP_VS_DEBUG 1433#ifdef CONFIG_IP_VS_DEBUG
1435 { 1434 {
1436 .ctl_name = NET_IPV4_VS_DEBUG_LEVEL,
1437 .procname = "debug_level", 1435 .procname = "debug_level",
1438 .data = &sysctl_ip_vs_debug_level, 1436 .data = &sysctl_ip_vs_debug_level,
1439 .maxlen = sizeof(int), 1437 .maxlen = sizeof(int),
@@ -1442,7 +1440,6 @@ static struct ctl_table vs_vars[] = {
1442 }, 1440 },
1443#endif 1441#endif
1444 { 1442 {
1445 .ctl_name = NET_IPV4_VS_AMDROPRATE,
1446 .procname = "am_droprate", 1443 .procname = "am_droprate",
1447 .data = &sysctl_ip_vs_am_droprate, 1444 .data = &sysctl_ip_vs_am_droprate,
1448 .maxlen = sizeof(int), 1445 .maxlen = sizeof(int),
@@ -1450,7 +1447,6 @@ static struct ctl_table vs_vars[] = {
1450 .proc_handler = &proc_dointvec, 1447 .proc_handler = &proc_dointvec,
1451 }, 1448 },
1452 { 1449 {
1453 .ctl_name = NET_IPV4_VS_DROP_ENTRY,
1454 .procname = "drop_entry", 1450 .procname = "drop_entry",
1455 .data = &sysctl_ip_vs_drop_entry, 1451 .data = &sysctl_ip_vs_drop_entry,
1456 .maxlen = sizeof(int), 1452 .maxlen = sizeof(int),
@@ -1458,7 +1454,6 @@ static struct ctl_table vs_vars[] = {
1458 .proc_handler = &proc_do_defense_mode, 1454 .proc_handler = &proc_do_defense_mode,
1459 }, 1455 },
1460 { 1456 {
1461 .ctl_name = NET_IPV4_VS_DROP_PACKET,
1462 .procname = "drop_packet", 1457 .procname = "drop_packet",
1463 .data = &sysctl_ip_vs_drop_packet, 1458 .data = &sysctl_ip_vs_drop_packet,
1464 .maxlen = sizeof(int), 1459 .maxlen = sizeof(int),
@@ -1466,7 +1461,6 @@ static struct ctl_table vs_vars[] = {
1466 .proc_handler = &proc_do_defense_mode, 1461 .proc_handler = &proc_do_defense_mode,
1467 }, 1462 },
1468 { 1463 {
1469 .ctl_name = NET_IPV4_VS_SECURE_TCP,
1470 .procname = "secure_tcp", 1464 .procname = "secure_tcp",
1471 .data = &sysctl_ip_vs_secure_tcp, 1465 .data = &sysctl_ip_vs_secure_tcp,
1472 .maxlen = sizeof(int), 1466 .maxlen = sizeof(int),
@@ -1475,7 +1469,6 @@ static struct ctl_table vs_vars[] = {
1475 }, 1469 },
1476#if 0 1470#if 0
1477 { 1471 {
1478 .ctl_name = NET_IPV4_VS_TO_ES,
1479 .procname = "timeout_established", 1472 .procname = "timeout_established",
1480 .data = &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED], 1473 .data = &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED],
1481 .maxlen = sizeof(int), 1474 .maxlen = sizeof(int),
@@ -1483,7 +1476,6 @@ static struct ctl_table vs_vars[] = {
1483 .proc_handler = &proc_dointvec_jiffies, 1476 .proc_handler = &proc_dointvec_jiffies,
1484 }, 1477 },
1485 { 1478 {
1486 .ctl_name = NET_IPV4_VS_TO_SS,
1487 .procname = "timeout_synsent", 1479 .procname = "timeout_synsent",
1488 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_SENT], 1480 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_SENT],
1489 .maxlen = sizeof(int), 1481 .maxlen = sizeof(int),
@@ -1491,7 +1483,6 @@ static struct ctl_table vs_vars[] = {
1491 .proc_handler = &proc_dointvec_jiffies, 1483 .proc_handler = &proc_dointvec_jiffies,
1492 }, 1484 },
1493 { 1485 {
1494 .ctl_name = NET_IPV4_VS_TO_SR,
1495 .procname = "timeout_synrecv", 1486 .procname = "timeout_synrecv",
1496 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_RECV], 1487 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_RECV],
1497 .maxlen = sizeof(int), 1488 .maxlen = sizeof(int),
@@ -1499,7 +1490,6 @@ static struct ctl_table vs_vars[] = {
1499 .proc_handler = &proc_dointvec_jiffies, 1490 .proc_handler = &proc_dointvec_jiffies,
1500 }, 1491 },
1501 { 1492 {
1502 .ctl_name = NET_IPV4_VS_TO_FW,
1503 .procname = "timeout_finwait", 1493 .procname = "timeout_finwait",
1504 .data = &vs_timeout_table_dos.timeout[IP_VS_S_FIN_WAIT], 1494 .data = &vs_timeout_table_dos.timeout[IP_VS_S_FIN_WAIT],
1505 .maxlen = sizeof(int), 1495 .maxlen = sizeof(int),
@@ -1507,7 +1497,6 @@ static struct ctl_table vs_vars[] = {
1507 .proc_handler = &proc_dointvec_jiffies, 1497 .proc_handler = &proc_dointvec_jiffies,
1508 }, 1498 },
1509 { 1499 {
1510 .ctl_name = NET_IPV4_VS_TO_TW,
1511 .procname = "timeout_timewait", 1500 .procname = "timeout_timewait",
1512 .data = &vs_timeout_table_dos.timeout[IP_VS_S_TIME_WAIT], 1501 .data = &vs_timeout_table_dos.timeout[IP_VS_S_TIME_WAIT],
1513 .maxlen = sizeof(int), 1502 .maxlen = sizeof(int),
@@ -1515,7 +1504,6 @@ static struct ctl_table vs_vars[] = {
1515 .proc_handler = &proc_dointvec_jiffies, 1504 .proc_handler = &proc_dointvec_jiffies,
1516 }, 1505 },
1517 { 1506 {
1518 .ctl_name = NET_IPV4_VS_TO_CL,
1519 .procname = "timeout_close", 1507 .procname = "timeout_close",
1520 .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE], 1508 .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE],
1521 .maxlen = sizeof(int), 1509 .maxlen = sizeof(int),
@@ -1523,7 +1511,6 @@ static struct ctl_table vs_vars[] = {
1523 .proc_handler = &proc_dointvec_jiffies, 1511 .proc_handler = &proc_dointvec_jiffies,
1524 }, 1512 },
1525 { 1513 {
1526 .ctl_name = NET_IPV4_VS_TO_CW,
1527 .procname = "timeout_closewait", 1514 .procname = "timeout_closewait",
1528 .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE_WAIT], 1515 .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE_WAIT],
1529 .maxlen = sizeof(int), 1516 .maxlen = sizeof(int),
@@ -1531,7 +1518,6 @@ static struct ctl_table vs_vars[] = {
1531 .proc_handler = &proc_dointvec_jiffies, 1518 .proc_handler = &proc_dointvec_jiffies,
1532 }, 1519 },
1533 { 1520 {
1534 .ctl_name = NET_IPV4_VS_TO_LA,
1535 .procname = "timeout_lastack", 1521 .procname = "timeout_lastack",
1536 .data = &vs_timeout_table_dos.timeout[IP_VS_S_LAST_ACK], 1522 .data = &vs_timeout_table_dos.timeout[IP_VS_S_LAST_ACK],
1537 .maxlen = sizeof(int), 1523 .maxlen = sizeof(int),
@@ -1539,7 +1525,6 @@ static struct ctl_table vs_vars[] = {
1539 .proc_handler = &proc_dointvec_jiffies, 1525 .proc_handler = &proc_dointvec_jiffies,
1540 }, 1526 },
1541 { 1527 {
1542 .ctl_name = NET_IPV4_VS_TO_LI,
1543 .procname = "timeout_listen", 1528 .procname = "timeout_listen",
1544 .data = &vs_timeout_table_dos.timeout[IP_VS_S_LISTEN], 1529 .data = &vs_timeout_table_dos.timeout[IP_VS_S_LISTEN],
1545 .maxlen = sizeof(int), 1530 .maxlen = sizeof(int),
@@ -1547,7 +1532,6 @@ static struct ctl_table vs_vars[] = {
1547 .proc_handler = &proc_dointvec_jiffies, 1532 .proc_handler = &proc_dointvec_jiffies,
1548 }, 1533 },
1549 { 1534 {
1550 .ctl_name = NET_IPV4_VS_TO_SA,
1551 .procname = "timeout_synack", 1535 .procname = "timeout_synack",
1552 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYNACK], 1536 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYNACK],
1553 .maxlen = sizeof(int), 1537 .maxlen = sizeof(int),
@@ -1555,7 +1539,6 @@ static struct ctl_table vs_vars[] = {
1555 .proc_handler = &proc_dointvec_jiffies, 1539 .proc_handler = &proc_dointvec_jiffies,
1556 }, 1540 },
1557 { 1541 {
1558 .ctl_name = NET_IPV4_VS_TO_UDP,
1559 .procname = "timeout_udp", 1542 .procname = "timeout_udp",
1560 .data = &vs_timeout_table_dos.timeout[IP_VS_S_UDP], 1543 .data = &vs_timeout_table_dos.timeout[IP_VS_S_UDP],
1561 .maxlen = sizeof(int), 1544 .maxlen = sizeof(int),
@@ -1563,7 +1546,6 @@ static struct ctl_table vs_vars[] = {
1563 .proc_handler = &proc_dointvec_jiffies, 1546 .proc_handler = &proc_dointvec_jiffies,
1564 }, 1547 },
1565 { 1548 {
1566 .ctl_name = NET_IPV4_VS_TO_ICMP,
1567 .procname = "timeout_icmp", 1549 .procname = "timeout_icmp",
1568 .data = &vs_timeout_table_dos.timeout[IP_VS_S_ICMP], 1550 .data = &vs_timeout_table_dos.timeout[IP_VS_S_ICMP],
1569 .maxlen = sizeof(int), 1551 .maxlen = sizeof(int),
@@ -1572,7 +1554,6 @@ static struct ctl_table vs_vars[] = {
1572 }, 1554 },
1573#endif 1555#endif
1574 { 1556 {
1575 .ctl_name = NET_IPV4_VS_CACHE_BYPASS,
1576 .procname = "cache_bypass", 1557 .procname = "cache_bypass",
1577 .data = &sysctl_ip_vs_cache_bypass, 1558 .data = &sysctl_ip_vs_cache_bypass,
1578 .maxlen = sizeof(int), 1559 .maxlen = sizeof(int),
@@ -1580,7 +1561,6 @@ static struct ctl_table vs_vars[] = {
1580 .proc_handler = &proc_dointvec, 1561 .proc_handler = &proc_dointvec,
1581 }, 1562 },
1582 { 1563 {
1583 .ctl_name = NET_IPV4_VS_EXPIRE_NODEST_CONN,
1584 .procname = "expire_nodest_conn", 1564 .procname = "expire_nodest_conn",
1585 .data = &sysctl_ip_vs_expire_nodest_conn, 1565 .data = &sysctl_ip_vs_expire_nodest_conn,
1586 .maxlen = sizeof(int), 1566 .maxlen = sizeof(int),
@@ -1588,7 +1568,6 @@ static struct ctl_table vs_vars[] = {
1588 .proc_handler = &proc_dointvec, 1568 .proc_handler = &proc_dointvec,
1589 }, 1569 },
1590 { 1570 {
1591 .ctl_name = NET_IPV4_VS_EXPIRE_QUIESCENT_TEMPLATE,
1592 .procname = "expire_quiescent_template", 1571 .procname = "expire_quiescent_template",
1593 .data = &sysctl_ip_vs_expire_quiescent_template, 1572 .data = &sysctl_ip_vs_expire_quiescent_template,
1594 .maxlen = sizeof(int), 1573 .maxlen = sizeof(int),
@@ -1596,7 +1575,6 @@ static struct ctl_table vs_vars[] = {
1596 .proc_handler = &proc_dointvec, 1575 .proc_handler = &proc_dointvec,
1597 }, 1576 },
1598 { 1577 {
1599 .ctl_name = NET_IPV4_VS_SYNC_THRESHOLD,
1600 .procname = "sync_threshold", 1578 .procname = "sync_threshold",
1601 .data = &sysctl_ip_vs_sync_threshold, 1579 .data = &sysctl_ip_vs_sync_threshold,
1602 .maxlen = sizeof(sysctl_ip_vs_sync_threshold), 1580 .maxlen = sizeof(sysctl_ip_vs_sync_threshold),
@@ -1604,7 +1582,6 @@ static struct ctl_table vs_vars[] = {
1604 .proc_handler = &proc_do_sync_threshold, 1582 .proc_handler = &proc_do_sync_threshold,
1605 }, 1583 },
1606 { 1584 {
1607 .ctl_name = NET_IPV4_VS_NAT_ICMP_SEND,
1608 .procname = "nat_icmp_send", 1585 .procname = "nat_icmp_send",
1609 .data = &sysctl_ip_vs_nat_icmp_send, 1586 .data = &sysctl_ip_vs_nat_icmp_send,
1610 .maxlen = sizeof(int), 1587 .maxlen = sizeof(int),
@@ -1616,7 +1593,6 @@ static struct ctl_table vs_vars[] = {
1616 1593
1617static ctl_table vs_table[] = { 1594static ctl_table vs_table[] = {
1618 { 1595 {
1619 .ctl_name = NET_IPV4_VS,
1620 .procname = "vs", 1596 .procname = "vs",
1621 .mode = 0555, 1597 .mode = 0555,
1622 .child = vs_vars 1598 .child = vs_vars
diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
index 052f4ed59174..ad89644ef5d2 100644
--- a/net/ipv4/ipvs/ip_vs_lblc.c
+++ b/net/ipv4/ipvs/ip_vs_lblc.c
@@ -114,7 +114,6 @@ struct ip_vs_lblc_table {
114 114
115static ctl_table vs_vars_table[] = { 115static ctl_table vs_vars_table[] = {
116 { 116 {
117 .ctl_name = NET_IPV4_VS_LBLC_EXPIRE,
118 .procname = "lblc_expiration", 117 .procname = "lblc_expiration",
119 .data = &sysctl_ip_vs_lblc_expiration, 118 .data = &sysctl_ip_vs_lblc_expiration,
120 .maxlen = sizeof(int), 119 .maxlen = sizeof(int),
@@ -126,7 +125,6 @@ static ctl_table vs_vars_table[] = {
126 125
127static ctl_table vs_table[] = { 126static ctl_table vs_table[] = {
128 { 127 {
129 .ctl_name = NET_IPV4_VS,
130 .procname = "vs", 128 .procname = "vs",
131 .mode = 0555, 129 .mode = 0555,
132 .child = vs_vars_table 130 .child = vs_vars_table
@@ -582,9 +580,14 @@ static struct ip_vs_scheduler ip_vs_lblc_scheduler =
582 580
583static int __init ip_vs_lblc_init(void) 581static int __init ip_vs_lblc_init(void)
584{ 582{
583 int ret;
584
585 INIT_LIST_HEAD(&ip_vs_lblc_scheduler.n_list); 585 INIT_LIST_HEAD(&ip_vs_lblc_scheduler.n_list);
586 sysctl_header = register_sysctl_table(lblc_root_table); 586 sysctl_header = register_sysctl_table(lblc_root_table);
587 return register_ip_vs_scheduler(&ip_vs_lblc_scheduler); 587 ret = register_ip_vs_scheduler(&ip_vs_lblc_scheduler);
588 if (ret)
589 unregister_sysctl_table(sysctl_header);
590 return ret;
588} 591}
589 592
590 593
diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
index 427b593c1069..2a5ed85a3352 100644
--- a/net/ipv4/ipvs/ip_vs_lblcr.c
+++ b/net/ipv4/ipvs/ip_vs_lblcr.c
@@ -302,7 +302,6 @@ struct ip_vs_lblcr_table {
302 302
303static ctl_table vs_vars_table[] = { 303static ctl_table vs_vars_table[] = {
304 { 304 {
305 .ctl_name = NET_IPV4_VS_LBLCR_EXPIRE,
306 .procname = "lblcr_expiration", 305 .procname = "lblcr_expiration",
307 .data = &sysctl_ip_vs_lblcr_expiration, 306 .data = &sysctl_ip_vs_lblcr_expiration,
308 .maxlen = sizeof(int), 307 .maxlen = sizeof(int),
@@ -314,7 +313,6 @@ static ctl_table vs_vars_table[] = {
314 313
315static ctl_table vs_table[] = { 314static ctl_table vs_table[] = {
316 { 315 {
317 .ctl_name = NET_IPV4_VS,
318 .procname = "vs", 316 .procname = "vs",
319 .mode = 0555, 317 .mode = 0555,
320 .child = vs_vars_table 318 .child = vs_vars_table
@@ -771,9 +769,14 @@ static struct ip_vs_scheduler ip_vs_lblcr_scheduler =
771 769
772static int __init ip_vs_lblcr_init(void) 770static int __init ip_vs_lblcr_init(void)
773{ 771{
772 int ret;
773
774 INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list); 774 INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list);
775 sysctl_header = register_sysctl_table(lblcr_root_table); 775 sysctl_header = register_sysctl_table(lblcr_root_table);
776 return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler); 776 ret = register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
777 if (ret)
778 unregister_sysctl_table(sysctl_header);
779 return ret;
777} 780}
778 781
779 782
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c
index e844ddb82b9a..c0e11ec8f0f9 100644
--- a/net/ipv4/ipvs/ip_vs_proto.c
+++ b/net/ipv4/ipvs/ip_vs_proto.c
@@ -45,7 +45,7 @@ static struct ip_vs_protocol *ip_vs_proto_table[IP_VS_PROTO_TAB_SIZE];
45/* 45/*
46 * register an ipvs protocol 46 * register an ipvs protocol
47 */ 47 */
48static int register_ip_vs_protocol(struct ip_vs_protocol *pp) 48static int __used register_ip_vs_protocol(struct ip_vs_protocol *pp)
49{ 49{
50 unsigned hash = IP_VS_PROTO_HASH(pp->protocol); 50 unsigned hash = IP_VS_PROTO_HASH(pp->protocol);
51 51
diff --git a/net/ipv4/ipvs/ip_vs_sched.c b/net/ipv4/ipvs/ip_vs_sched.c
index 1602304abbf9..432235861908 100644
--- a/net/ipv4/ipvs/ip_vs_sched.c
+++ b/net/ipv4/ipvs/ip_vs_sched.c
@@ -183,19 +183,6 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
183 /* increase the module use count */ 183 /* increase the module use count */
184 ip_vs_use_count_inc(); 184 ip_vs_use_count_inc();
185 185
186 /*
187 * Make sure that the scheduler with this name doesn't exist
188 * in the scheduler list.
189 */
190 sched = ip_vs_sched_getbyname(scheduler->name);
191 if (sched) {
192 ip_vs_scheduler_put(sched);
193 ip_vs_use_count_dec();
194 IP_VS_ERR("register_ip_vs_scheduler(): [%s] scheduler "
195 "already existed in the system\n", scheduler->name);
196 return -EINVAL;
197 }
198
199 write_lock_bh(&__ip_vs_sched_lock); 186 write_lock_bh(&__ip_vs_sched_lock);
200 187
201 if (scheduler->n_list.next != &scheduler->n_list) { 188 if (scheduler->n_list.next != &scheduler->n_list) {
@@ -207,6 +194,20 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
207 } 194 }
208 195
209 /* 196 /*
197 * Make sure that the scheduler with this name doesn't exist
198 * in the scheduler list.
199 */
200 list_for_each_entry(sched, &ip_vs_schedulers, n_list) {
201 if (strcmp(scheduler->name, sched->name) == 0) {
202 write_unlock_bh(&__ip_vs_sched_lock);
203 ip_vs_use_count_dec();
204 IP_VS_ERR("register_ip_vs_scheduler(): [%s] scheduler "
205 "already existed in the system\n",
206 scheduler->name);
207 return -EINVAL;
208 }
209 }
210 /*
210 * Add it into the d-linked scheduler list 211 * Add it into the d-linked scheduler list
211 */ 212 */
212 list_add(&scheduler->n_list, &ip_vs_schedulers); 213 list_add(&scheduler->n_list, &ip_vs_schedulers);
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 4b10b98640ac..b9b189c26208 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -1492,8 +1492,10 @@ static inline int compat_copy_match_to_user(struct ipt_entry_match *m,
1492 return xt_compat_match_to_user(m, dstptr, size); 1492 return xt_compat_match_to_user(m, dstptr, size);
1493} 1493}
1494 1494
1495static int compat_copy_entry_to_user(struct ipt_entry *e, 1495static int
1496 void __user **dstptr, compat_uint_t *size) 1496compat_copy_entry_to_user(struct ipt_entry *e, void __user **dstptr,
1497 compat_uint_t *size, struct xt_counters *counters,
1498 unsigned int *i)
1497{ 1499{
1498 struct ipt_entry_target *t; 1500 struct ipt_entry_target *t;
1499 struct compat_ipt_entry __user *ce; 1501 struct compat_ipt_entry __user *ce;
@@ -1507,6 +1509,9 @@ static int compat_copy_entry_to_user(struct ipt_entry *e,
1507 if (copy_to_user(ce, e, sizeof(struct ipt_entry))) 1509 if (copy_to_user(ce, e, sizeof(struct ipt_entry)))
1508 goto out; 1510 goto out;
1509 1511
1512 if (copy_to_user(&ce->counters, &counters[*i], sizeof(counters[*i])))
1513 goto out;
1514
1510 *dstptr += sizeof(struct compat_ipt_entry); 1515 *dstptr += sizeof(struct compat_ipt_entry);
1511 ret = IPT_MATCH_ITERATE(e, compat_copy_match_to_user, dstptr, size); 1516 ret = IPT_MATCH_ITERATE(e, compat_copy_match_to_user, dstptr, size);
1512 target_offset = e->target_offset - (origsize - *size); 1517 target_offset = e->target_offset - (origsize - *size);
@@ -1522,6 +1527,8 @@ static int compat_copy_entry_to_user(struct ipt_entry *e,
1522 goto out; 1527 goto out;
1523 if (put_user(next_offset, &ce->next_offset)) 1528 if (put_user(next_offset, &ce->next_offset))
1524 goto out; 1529 goto out;
1530
1531 (*i)++;
1525 return 0; 1532 return 0;
1526out: 1533out:
1527 return ret; 1534 return ret;
@@ -1937,14 +1944,13 @@ struct compat_ipt_get_entries
1937static int compat_copy_entries_to_user(unsigned int total_size, 1944static int compat_copy_entries_to_user(unsigned int total_size,
1938 struct xt_table *table, void __user *userptr) 1945 struct xt_table *table, void __user *userptr)
1939{ 1946{
1940 unsigned int off, num;
1941 struct compat_ipt_entry e;
1942 struct xt_counters *counters; 1947 struct xt_counters *counters;
1943 struct xt_table_info *private = table->private; 1948 struct xt_table_info *private = table->private;
1944 void __user *pos; 1949 void __user *pos;
1945 unsigned int size; 1950 unsigned int size;
1946 int ret = 0; 1951 int ret = 0;
1947 void *loc_cpu_entry; 1952 void *loc_cpu_entry;
1953 unsigned int i = 0;
1948 1954
1949 counters = alloc_counters(table); 1955 counters = alloc_counters(table);
1950 if (IS_ERR(counters)) 1956 if (IS_ERR(counters))
@@ -1958,48 +1964,9 @@ static int compat_copy_entries_to_user(unsigned int total_size,
1958 pos = userptr; 1964 pos = userptr;
1959 size = total_size; 1965 size = total_size;
1960 ret = IPT_ENTRY_ITERATE(loc_cpu_entry, total_size, 1966 ret = IPT_ENTRY_ITERATE(loc_cpu_entry, total_size,
1961 compat_copy_entry_to_user, &pos, &size); 1967 compat_copy_entry_to_user,
1962 if (ret) 1968 &pos, &size, counters, &i);
1963 goto free_counters;
1964
1965 /* ... then go back and fix counters and names */
1966 for (off = 0, num = 0; off < size; off += e.next_offset, num++) {
1967 unsigned int i;
1968 struct ipt_entry_match m;
1969 struct ipt_entry_target t;
1970 1969
1971 ret = -EFAULT;
1972 if (copy_from_user(&e, userptr + off,
1973 sizeof(struct compat_ipt_entry)))
1974 goto free_counters;
1975 if (copy_to_user(userptr + off +
1976 offsetof(struct compat_ipt_entry, counters),
1977 &counters[num], sizeof(counters[num])))
1978 goto free_counters;
1979
1980 for (i = sizeof(struct compat_ipt_entry);
1981 i < e.target_offset; i += m.u.match_size) {
1982 if (copy_from_user(&m, userptr + off + i,
1983 sizeof(struct ipt_entry_match)))
1984 goto free_counters;
1985 if (copy_to_user(userptr + off + i +
1986 offsetof(struct ipt_entry_match, u.user.name),
1987 m.u.kernel.match->name,
1988 strlen(m.u.kernel.match->name) + 1))
1989 goto free_counters;
1990 }
1991
1992 if (copy_from_user(&t, userptr + off + e.target_offset,
1993 sizeof(struct ipt_entry_target)))
1994 goto free_counters;
1995 if (copy_to_user(userptr + off + e.target_offset +
1996 offsetof(struct ipt_entry_target, u.user.name),
1997 t.u.kernel.target->name,
1998 strlen(t.u.kernel.target->name) + 1))
1999 goto free_counters;
2000 }
2001 ret = 0;
2002free_counters:
2003 vfree(counters); 1970 vfree(counters);
2004 return ret; 1971 return ret;
2005} 1972}
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index 5de6e57ac55c..f8678651250f 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -66,7 +66,7 @@ ipt_local_hook(unsigned int hook,
66 if (skb->len < sizeof(struct iphdr) || 66 if (skb->len < sizeof(struct iphdr) ||
67 ip_hdrlen(skb) < sizeof(struct iphdr)) { 67 ip_hdrlen(skb) < sizeof(struct iphdr)) {
68 if (net_ratelimit()) 68 if (net_ratelimit())
69 printk("iptable_raw: ignoring short SOCK_RAW" 69 printk("iptable_raw: ignoring short SOCK_RAW "
70 "packet.\n"); 70 "packet.\n");
71 return NF_ACCEPT; 71 return NF_ACCEPT;
72 } 72 }
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 831e9b29806d..910dae732a0f 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -419,6 +419,9 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 __read_mostly = {
419 .me = THIS_MODULE, 419 .me = THIS_MODULE,
420}; 420};
421 421
422module_param_call(hashsize, nf_conntrack_set_hashsize, param_get_uint,
423 &nf_conntrack_htable_size, 0600);
424
422MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET)); 425MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
423MODULE_ALIAS("ip_conntrack"); 426MODULE_ALIAS("ip_conntrack");
424MODULE_LICENSE("GPL"); 427MODULE_LICENSE("GPL");
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index 70e7997ea284..86b465b176ba 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -607,13 +607,10 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old)
607 struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT); 607 struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT);
608 struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old; 608 struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old;
609 struct nf_conn *ct = old_nat->ct; 609 struct nf_conn *ct = old_nat->ct;
610 unsigned int srchash;
611 610
612 if (!(ct->status & IPS_NAT_DONE_MASK)) 611 if (!ct || !(ct->status & IPS_NAT_DONE_MASK))
613 return; 612 return;
614 613
615 srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
616
617 write_lock_bh(&nf_nat_lock); 614 write_lock_bh(&nf_nat_lock);
618 hlist_replace_rcu(&old_nat->bysource, &new_nat->bysource); 615 hlist_replace_rcu(&old_nat->bysource, &new_nat->bysource);
619 new_nat->ct = ct; 616 new_nat->ct = ct;
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c
index 3ca98971a1e9..8996ccb757db 100644
--- a/net/ipv4/netfilter/nf_nat_sip.c
+++ b/net/ipv4/netfilter/nf_nat_sip.c
@@ -165,7 +165,7 @@ static int mangle_content_len(struct sk_buff *skb,
165 165
166 dataoff = ip_hdrlen(skb) + sizeof(struct udphdr); 166 dataoff = ip_hdrlen(skb) + sizeof(struct udphdr);
167 167
168 /* Get actual SDP lenght */ 168 /* Get actual SDP length */
169 if (ct_sip_get_info(ct, dptr, skb->len - dataoff, &matchoff, 169 if (ct_sip_get_info(ct, dptr, skb->len - dataoff, &matchoff,
170 &matchlen, POS_SDP_HEADER) > 0) { 170 &matchlen, POS_SDP_HEADER) > 0) {
171 171
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 66b42f547bf9..e7050f8eabeb 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -271,6 +271,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
271 int hh_len; 271 int hh_len;
272 struct iphdr *iph; 272 struct iphdr *iph;
273 struct sk_buff *skb; 273 struct sk_buff *skb;
274 unsigned int iphlen;
274 int err; 275 int err;
275 276
276 if (length > rt->u.dst.dev->mtu) { 277 if (length > rt->u.dst.dev->mtu) {
@@ -304,7 +305,8 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
304 goto error_fault; 305 goto error_fault;
305 306
306 /* We don't modify invalid header */ 307 /* We don't modify invalid header */
307 if (length >= sizeof(*iph) && iph->ihl * 4U <= length) { 308 iphlen = iph->ihl * 4;
309 if (iphlen >= sizeof(*iph) && iphlen <= length) {
308 if (!iph->saddr) 310 if (!iph->saddr)
309 iph->saddr = rt->rt_src; 311 iph->saddr = rt->rt_src;
310 iph->check = 0; 312 iph->check = 0;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 1bff9ed349ff..28484f396b04 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -283,12 +283,12 @@ static struct rtable *rt_cache_get_first(struct seq_file *seq)
283 break; 283 break;
284 rcu_read_unlock_bh(); 284 rcu_read_unlock_bh();
285 } 285 }
286 return r; 286 return rcu_dereference(r);
287} 287}
288 288
289static struct rtable *rt_cache_get_next(struct seq_file *seq, struct rtable *r) 289static struct rtable *rt_cache_get_next(struct seq_file *seq, struct rtable *r)
290{ 290{
291 struct rt_cache_iter_state *st = rcu_dereference(seq->private); 291 struct rt_cache_iter_state *st = seq->private;
292 292
293 r = r->u.dst.rt_next; 293 r = r->u.dst.rt_next;
294 while (!r) { 294 while (!r) {
@@ -298,7 +298,7 @@ static struct rtable *rt_cache_get_next(struct seq_file *seq, struct rtable *r)
298 rcu_read_lock_bh(); 298 rcu_read_lock_bh();
299 r = rt_hash_table[st->bucket].chain; 299 r = rt_hash_table[st->bucket].chain;
300 } 300 }
301 return r; 301 return rcu_dereference(r);
302} 302}
303 303
304static struct rtable *rt_cache_get_idx(struct seq_file *seq, loff_t pos) 304static struct rtable *rt_cache_get_idx(struct seq_file *seq, loff_t pos)
@@ -1161,7 +1161,7 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1161 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src, 1161 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
1162 rt->fl.oif); 1162 rt->fl.oif);
1163#if RT_CACHE_DEBUG >= 1 1163#if RT_CACHE_DEBUG >= 1
1164 printk(KERN_DEBUG "ip_rt_advice: redirect to " 1164 printk(KERN_DEBUG "ipv4_negative_advice: redirect to "
1165 "%u.%u.%u.%u/%02x dropped\n", 1165 "%u.%u.%u.%u/%02x dropped\n",
1166 NIPQUAD(rt->rt_dst), rt->fl.fl4_tos); 1166 NIPQUAD(rt->rt_dst), rt->fl.fl4_tos);
1167#endif 1167#endif
@@ -1252,6 +1252,7 @@ static int ip_error(struct sk_buff *skb)
1252 break; 1252 break;
1253 case ENETUNREACH: 1253 case ENETUNREACH:
1254 code = ICMP_NET_UNREACH; 1254 code = ICMP_NET_UNREACH;
1255 IP_INC_STATS_BH(IPSTATS_MIB_INNOROUTES);
1255 break; 1256 break;
1256 case EACCES: 1257 case EACCES:
1257 code = ICMP_PKT_FILTERED; 1258 code = ICMP_PKT_FILTERED;
@@ -1881,6 +1882,8 @@ no_route:
1881 RT_CACHE_STAT_INC(in_no_route); 1882 RT_CACHE_STAT_INC(in_no_route);
1882 spec_dst = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE); 1883 spec_dst = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
1883 res.type = RTN_UNREACHABLE; 1884 res.type = RTN_UNREACHABLE;
1885 if (err == -ESRCH)
1886 err = -ENETUNREACH;
1884 goto local_input; 1887 goto local_input;
1885 1888
1886 /* 1889 /*
@@ -2623,11 +2626,10 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb)
2623 int idx, s_idx; 2626 int idx, s_idx;
2624 2627
2625 s_h = cb->args[0]; 2628 s_h = cb->args[0];
2629 if (s_h < 0)
2630 s_h = 0;
2626 s_idx = idx = cb->args[1]; 2631 s_idx = idx = cb->args[1];
2627 for (h = 0; h <= rt_hash_mask; h++) { 2632 for (h = s_h; h <= rt_hash_mask; h++) {
2628 if (h < s_h) continue;
2629 if (h > s_h)
2630 s_idx = 0;
2631 rcu_read_lock_bh(); 2633 rcu_read_lock_bh();
2632 for (rt = rcu_dereference(rt_hash_table[h].chain), idx = 0; rt; 2634 for (rt = rcu_dereference(rt_hash_table[h].chain), idx = 0; rt;
2633 rt = rcu_dereference(rt->u.dst.rt_next), idx++) { 2635 rt = rcu_dereference(rt->u.dst.rt_next), idx++) {
@@ -2644,6 +2646,7 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb)
2644 dst_release(xchg(&skb->dst, NULL)); 2646 dst_release(xchg(&skb->dst, NULL));
2645 } 2647 }
2646 rcu_read_unlock_bh(); 2648 rcu_read_unlock_bh();
2649 s_idx = 0;
2647 } 2650 }
2648 2651
2649done: 2652done:
@@ -2888,18 +2891,14 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
2888 offset /= sizeof(u32); 2891 offset /= sizeof(u32);
2889 2892
2890 if (length > 0) { 2893 if (length > 0) {
2891 u32 *src = ((u32 *) IP_RT_ACCT_CPU(0)) + offset;
2892 u32 *dst = (u32 *) buffer; 2894 u32 *dst = (u32 *) buffer;
2893 2895
2894 /* Copy first cpu. */
2895 *start = buffer; 2896 *start = buffer;
2896 memcpy(dst, src, length); 2897 memset(dst, 0, length);
2897 2898
2898 /* Add the other cpus in, one int at a time */
2899 for_each_possible_cpu(i) { 2899 for_each_possible_cpu(i) {
2900 unsigned int j; 2900 unsigned int j;
2901 2901 u32 *src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
2902 src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
2903 2902
2904 for (j = 0; j < length/4; j++) 2903 for (j = 0; j < length/4; j++)
2905 dst[j] += src[j]; 2904 dst[j] += src[j];
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index ffddd2b45352..bec6fe880657 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -191,7 +191,7 @@ static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
191 191
192 tcp_get_default_congestion_control(val); 192 tcp_get_default_congestion_control(val);
193 ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen); 193 ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen);
194 if (ret == 0 && newval && newlen) 194 if (ret == 1 && newval && newlen)
195 ret = tcp_set_default_congestion_control(val); 195 ret = tcp_set_default_congestion_control(val);
196 return ret; 196 return ret;
197} 197}
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 64f1cbaf96e8..5aa5f5496d6d 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -298,7 +298,7 @@ static u32 tcp_illinois_ssthresh(struct sock *sk)
298 struct illinois *ca = inet_csk_ca(sk); 298 struct illinois *ca = inet_csk_ca(sk);
299 299
300 /* Multiplicative decrease */ 300 /* Multiplicative decrease */
301 return max((tp->snd_cwnd * ca->beta) >> BETA_SHIFT, 2U); 301 return max(tp->snd_cwnd - ((tp->snd_cwnd * ca->beta) >> BETA_SHIFT), 2U);
302} 302}
303 303
304 304
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0f0c1c9829a1..b39f0d86e44c 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -923,7 +923,7 @@ static void tcp_init_metrics(struct sock *sk)
923 } 923 }
924 if (dst_metric(dst, RTAX_RTTVAR) > tp->mdev) { 924 if (dst_metric(dst, RTAX_RTTVAR) > tp->mdev) {
925 tp->mdev = dst_metric(dst, RTAX_RTTVAR); 925 tp->mdev = dst_metric(dst, RTAX_RTTVAR);
926 tp->mdev_max = tp->rttvar = max(tp->mdev, TCP_RTO_MIN); 926 tp->mdev_max = tp->rttvar = max(tp->mdev, tcp_rto_min(sk));
927 } 927 }
928 tcp_set_rto(sk); 928 tcp_set_rto(sk);
929 tcp_bound_rto(sk); 929 tcp_bound_rto(sk);
@@ -2651,6 +2651,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p,
2651 u32 cnt = 0; 2651 u32 cnt = 0;
2652 u32 reord = tp->packets_out; 2652 u32 reord = tp->packets_out;
2653 s32 seq_rtt = -1; 2653 s32 seq_rtt = -1;
2654 s32 ca_seq_rtt = -1;
2654 ktime_t last_ackt = net_invalid_timestamp(); 2655 ktime_t last_ackt = net_invalid_timestamp();
2655 2656
2656 while ((skb = tcp_write_queue_head(sk)) && skb != tcp_send_head(sk)) { 2657 while ((skb = tcp_write_queue_head(sk)) && skb != tcp_send_head(sk)) {
@@ -2659,6 +2660,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p,
2659 u32 packets_acked; 2660 u32 packets_acked;
2660 u8 sacked = scb->sacked; 2661 u8 sacked = scb->sacked;
2661 2662
2663 /* Determine how many packets and what bytes were acked, tso and else */
2662 if (after(scb->end_seq, tp->snd_una)) { 2664 if (after(scb->end_seq, tp->snd_una)) {
2663 if (tcp_skb_pcount(skb) == 1 || 2665 if (tcp_skb_pcount(skb) == 1 ||
2664 !after(tp->snd_una, scb->seq)) 2666 !after(tp->snd_una, scb->seq))
@@ -2686,15 +2688,16 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p,
2686 if (sacked & TCPCB_SACKED_RETRANS) 2688 if (sacked & TCPCB_SACKED_RETRANS)
2687 tp->retrans_out -= packets_acked; 2689 tp->retrans_out -= packets_acked;
2688 flag |= FLAG_RETRANS_DATA_ACKED; 2690 flag |= FLAG_RETRANS_DATA_ACKED;
2691 ca_seq_rtt = -1;
2689 seq_rtt = -1; 2692 seq_rtt = -1;
2690 if ((flag & FLAG_DATA_ACKED) || 2693 if ((flag & FLAG_DATA_ACKED) ||
2691 (packets_acked > 1)) 2694 (packets_acked > 1))
2692 flag |= FLAG_NONHEAD_RETRANS_ACKED; 2695 flag |= FLAG_NONHEAD_RETRANS_ACKED;
2693 } else { 2696 } else {
2697 ca_seq_rtt = now - scb->when;
2698 last_ackt = skb->tstamp;
2694 if (seq_rtt < 0) { 2699 if (seq_rtt < 0) {
2695 seq_rtt = now - scb->when; 2700 seq_rtt = ca_seq_rtt;
2696 if (fully_acked)
2697 last_ackt = skb->tstamp;
2698 } 2701 }
2699 if (!(sacked & TCPCB_SACKED_ACKED)) 2702 if (!(sacked & TCPCB_SACKED_ACKED))
2700 reord = min(cnt, reord); 2703 reord = min(cnt, reord);
@@ -2709,10 +2712,10 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p,
2709 !before(end_seq, tp->snd_up)) 2712 !before(end_seq, tp->snd_up))
2710 tp->urg_mode = 0; 2713 tp->urg_mode = 0;
2711 } else { 2714 } else {
2715 ca_seq_rtt = now - scb->when;
2716 last_ackt = skb->tstamp;
2712 if (seq_rtt < 0) { 2717 if (seq_rtt < 0) {
2713 seq_rtt = now - scb->when; 2718 seq_rtt = ca_seq_rtt;
2714 if (fully_acked)
2715 last_ackt = skb->tstamp;
2716 } 2719 }
2717 reord = min(cnt, reord); 2720 reord = min(cnt, reord);
2718 } 2721 }
@@ -2772,8 +2775,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p,
2772 net_invalid_timestamp())) 2775 net_invalid_timestamp()))
2773 rtt_us = ktime_us_delta(ktime_get_real(), 2776 rtt_us = ktime_us_delta(ktime_get_real(),
2774 last_ackt); 2777 last_ackt);
2775 else if (seq_rtt > 0) 2778 else if (ca_seq_rtt > 0)
2776 rtt_us = jiffies_to_usecs(seq_rtt); 2779 rtt_us = jiffies_to_usecs(ca_seq_rtt);
2777 } 2780 }
2778 2781
2779 ca_ops->pkts_acked(sk, pkts_acked, rtt_us); 2782 ca_ops->pkts_acked(sk, pkts_acked, rtt_us);
@@ -3003,17 +3006,13 @@ static int tcp_process_frto(struct sock *sk, int flag)
3003 } 3006 }
3004 3007
3005 if (tp->frto_counter == 1) { 3008 if (tp->frto_counter == 1) {
3006 /* Sending of the next skb must be allowed or no F-RTO */ 3009 /* tcp_may_send_now needs to see updated state */
3007 if (!tcp_send_head(sk) ||
3008 after(TCP_SKB_CB(tcp_send_head(sk))->end_seq,
3009 tp->snd_una + tp->snd_wnd)) {
3010 tcp_enter_frto_loss(sk, (tp->frto_counter == 1 ? 2 : 3),
3011 flag);
3012 return 1;
3013 }
3014
3015 tp->snd_cwnd = tcp_packets_in_flight(tp) + 2; 3010 tp->snd_cwnd = tcp_packets_in_flight(tp) + 2;
3016 tp->frto_counter = 2; 3011 tp->frto_counter = 2;
3012
3013 if (!tcp_may_send_now(sk))
3014 tcp_enter_frto_loss(sk, 2, flag);
3015
3017 return 1; 3016 return 1;
3018 } else { 3017 } else {
3019 switch (sysctl_tcp_frto_response) { 3018 switch (sysctl_tcp_frto_response) {
@@ -3069,6 +3068,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
3069 } 3068 }
3070 3069
3071 prior_fackets = tp->fackets_out; 3070 prior_fackets = tp->fackets_out;
3071 prior_in_flight = tcp_packets_in_flight(tp);
3072 3072
3073 if (!(flag&FLAG_SLOWPATH) && after(ack, prior_snd_una)) { 3073 if (!(flag&FLAG_SLOWPATH) && after(ack, prior_snd_una)) {
3074 /* Window is constant, pure forward advance. 3074 /* Window is constant, pure forward advance.
@@ -3108,8 +3108,6 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
3108 if (!prior_packets) 3108 if (!prior_packets)
3109 goto no_queue; 3109 goto no_queue;
3110 3110
3111 prior_in_flight = tcp_packets_in_flight(tp);
3112
3113 /* See if we can take anything off of the retransmit queue. */ 3111 /* See if we can take anything off of the retransmit queue. */
3114 flag |= tcp_clean_rtx_queue(sk, &seq_rtt, prior_fackets); 3112 flag |= tcp_clean_rtx_queue(sk, &seq_rtt, prior_fackets);
3115 3113
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index e566f3c67677..652c32368ccc 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -900,8 +900,7 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr,
900 sizeof(*keys) * md5sig->entries4); 900 sizeof(*keys) * md5sig->entries4);
901 901
902 /* Free old key list, and reference new one */ 902 /* Free old key list, and reference new one */
903 if (md5sig->keys4) 903 kfree(md5sig->keys4);
904 kfree(md5sig->keys4);
905 md5sig->keys4 = keys; 904 md5sig->keys4 = keys;
906 md5sig->alloced4++; 905 md5sig->alloced4++;
907 } 906 }
@@ -939,10 +938,10 @@ int tcp_v4_md5_do_del(struct sock *sk, __be32 addr)
939 tp->md5sig_info->alloced4 = 0; 938 tp->md5sig_info->alloced4 = 0;
940 } else if (tp->md5sig_info->entries4 != i) { 939 } else if (tp->md5sig_info->entries4 != i) {
941 /* Need to do some manipulation */ 940 /* Need to do some manipulation */
942 memcpy(&tp->md5sig_info->keys4[i], 941 memmove(&tp->md5sig_info->keys4[i],
943 &tp->md5sig_info->keys4[i+1], 942 &tp->md5sig_info->keys4[i+1],
944 (tp->md5sig_info->entries4 - i) * 943 (tp->md5sig_info->entries4 - i) *
945 sizeof(struct tcp4_md5sig_key)); 944 sizeof(struct tcp4_md5sig_key));
946 } 945 }
947 tcp_free_md5sig_pool(); 946 tcp_free_md5sig_pool();
948 return 0; 947 return 0;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 324b4207254a..f4c1eef89af0 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1162,8 +1162,7 @@ int tcp_may_send_now(struct sock *sk)
1162 return (skb && 1162 return (skb &&
1163 tcp_snd_test(sk, skb, tcp_current_mss(sk, 1), 1163 tcp_snd_test(sk, skb, tcp_current_mss(sk, 1),
1164 (tcp_skb_is_last(sk, skb) ? 1164 (tcp_skb_is_last(sk, skb) ?
1165 TCP_NAGLE_PUSH : 1165 tp->nonagle : TCP_NAGLE_PUSH)));
1166 tp->nonagle)));
1167} 1166}
1168 1167
1169/* Trim TSO SKB to LEN bytes, put the remaining data into a new packet 1168/* Trim TSO SKB to LEN bytes, put the remaining data into a new packet
@@ -1295,6 +1294,7 @@ static int tcp_mtu_probe(struct sock *sk)
1295 struct sk_buff *skb, *nskb, *next; 1294 struct sk_buff *skb, *nskb, *next;
1296 int len; 1295 int len;
1297 int probe_size; 1296 int probe_size;
1297 int size_needed;
1298 unsigned int pif; 1298 unsigned int pif;
1299 int copy; 1299 int copy;
1300 int mss_now; 1300 int mss_now;
@@ -1313,27 +1313,20 @@ static int tcp_mtu_probe(struct sock *sk)
1313 /* Very simple search strategy: just double the MSS. */ 1313 /* Very simple search strategy: just double the MSS. */
1314 mss_now = tcp_current_mss(sk, 0); 1314 mss_now = tcp_current_mss(sk, 0);
1315 probe_size = 2*tp->mss_cache; 1315 probe_size = 2*tp->mss_cache;
1316 size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache;
1316 if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) { 1317 if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) {
1317 /* TODO: set timer for probe_converge_event */ 1318 /* TODO: set timer for probe_converge_event */
1318 return -1; 1319 return -1;
1319 } 1320 }
1320 1321
1321 /* Have enough data in the send queue to probe? */ 1322 /* Have enough data in the send queue to probe? */
1322 len = 0; 1323 if (tp->write_seq - tp->snd_nxt < size_needed)
1323 if ((skb = tcp_send_head(sk)) == NULL)
1324 return -1;
1325 while ((len += skb->len) < probe_size && !tcp_skb_is_last(sk, skb))
1326 skb = tcp_write_queue_next(sk, skb);
1327 if (len < probe_size)
1328 return -1; 1324 return -1;
1329 1325
1330 /* Receive window check. */ 1326 if (tp->snd_wnd < size_needed)
1331 if (after(TCP_SKB_CB(skb)->seq + probe_size, tp->snd_una + tp->snd_wnd)) { 1327 return -1;
1332 if (tp->snd_wnd < probe_size) 1328 if (after(tp->snd_nxt + size_needed, tp->snd_una + tp->snd_wnd))
1333 return -1; 1329 return 0;
1334 else
1335 return 0;
1336 }
1337 1330
1338 /* Do we need to wait to drain cwnd? */ 1331 /* Do we need to wait to drain cwnd? */
1339 pif = tcp_packets_in_flight(tp); 1332 pif = tcp_packets_in_flight(tp);
@@ -1352,7 +1345,6 @@ static int tcp_mtu_probe(struct sock *sk)
1352 1345
1353 skb = tcp_send_head(sk); 1346 skb = tcp_send_head(sk);
1354 tcp_insert_write_queue_before(nskb, skb, sk); 1347 tcp_insert_write_queue_before(nskb, skb, sk);
1355 tcp_advance_send_head(sk, skb);
1356 1348
1357 TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq; 1349 TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq;
1358 TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size; 1350 TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 1bd8d818f8e9..e8c347579da9 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -967,7 +967,7 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
967 if (unlikely(score.addr_type == IPV6_ADDR_ANY || 967 if (unlikely(score.addr_type == IPV6_ADDR_ANY ||
968 score.addr_type & IPV6_ADDR_MULTICAST)) { 968 score.addr_type & IPV6_ADDR_MULTICAST)) {
969 LIMIT_NETDEBUG(KERN_DEBUG 969 LIMIT_NETDEBUG(KERN_DEBUG
970 "ADDRCONF: unspecified / multicast address" 970 "ADDRCONF: unspecified / multicast address "
971 "assigned as unicast address on %s", 971 "assigned as unicast address on %s",
972 dev->name); 972 dev->name);
973 continue; 973 continue;
@@ -2293,6 +2293,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2293 break; 2293 break;
2294 } 2294 }
2295 2295
2296 if (!idev && dev->mtu >= IPV6_MIN_MTU)
2297 idev = ipv6_add_dev(dev);
2298
2296 if (idev) 2299 if (idev)
2297 idev->if_flags |= IF_READY; 2300 idev->if_flags |= IF_READY;
2298 } else { 2301 } else {
@@ -2357,12 +2360,18 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2357 break; 2360 break;
2358 2361
2359 case NETDEV_CHANGEMTU: 2362 case NETDEV_CHANGEMTU:
2360 if ( idev && dev->mtu >= IPV6_MIN_MTU) { 2363 if (idev && dev->mtu >= IPV6_MIN_MTU) {
2361 rt6_mtu_change(dev, dev->mtu); 2364 rt6_mtu_change(dev, dev->mtu);
2362 idev->cnf.mtu6 = dev->mtu; 2365 idev->cnf.mtu6 = dev->mtu;
2363 break; 2366 break;
2364 } 2367 }
2365 2368
2369 if (!idev && dev->mtu >= IPV6_MIN_MTU) {
2370 idev = ipv6_add_dev(dev);
2371 if (idev)
2372 break;
2373 }
2374
2366 /* MTU falled under IPV6_MIN_MTU. Stop IPv6 on this interface. */ 2375 /* MTU falled under IPV6_MIN_MTU. Stop IPv6 on this interface. */
2367 2376
2368 case NETDEV_DOWN: 2377 case NETDEV_DOWN:
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 2ed689ac449e..5d4245ab4183 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -123,11 +123,11 @@ ipv4_connected:
123 goto out; 123 goto out;
124 } 124 }
125 sk->sk_bound_dev_if = usin->sin6_scope_id; 125 sk->sk_bound_dev_if = usin->sin6_scope_id;
126 if (!sk->sk_bound_dev_if &&
127 (addr_type & IPV6_ADDR_MULTICAST))
128 fl.oif = np->mcast_oif;
129 } 126 }
130 127
128 if (!sk->sk_bound_dev_if && (addr_type & IPV6_ADDR_MULTICAST))
129 sk->sk_bound_dev_if = np->mcast_oif;
130
131 /* Connect to link-local address requires an interface */ 131 /* Connect to link-local address requires an interface */
132 if (!sk->sk_bound_dev_if) { 132 if (!sk->sk_bound_dev_if) {
133 err = -EINVAL; 133 err = -EINVAL;
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 7db66f10e00d..444053254676 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -230,6 +230,12 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
230 } 230 }
231 /* ... check padding bits here. Silly. :-) */ 231 /* ... check padding bits here. Silly. :-) */
232 232
233 /* RFC4303: Drop dummy packets without any error */
234 if (nexthdr[1] == IPPROTO_NONE) {
235 ret = -EINVAL;
236 goto out;
237 }
238
233 pskb_trim(skb, skb->len - alen - padlen - 2); 239 pskb_trim(skb, skb->len - alen - padlen - 2);
234 ret = nexthdr[1]; 240 ret = nexthdr[1];
235 } 241 }
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 9bb031fa1c2f..f1240688dc58 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -458,8 +458,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
458 } 458 }
459 err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, len + sizeof(struct icmp6hdr)); 459 err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, len + sizeof(struct icmp6hdr));
460 460
461 ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);
462
463out_put: 461out_put:
464 if (likely(idev != NULL)) 462 if (likely(idev != NULL))
465 in6_dev_put(idev); 463 in6_dev_put(idev);
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index adc73adadfae..0765d8bd380f 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -193,7 +193,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
193 sk2->sk_family == PF_INET6 && 193 sk2->sk_family == PF_INET6 &&
194 ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && 194 ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) &&
195 ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && 195 ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) &&
196 sk2->sk_bound_dev_if == sk->sk_bound_dev_if) { 196 (!sk2->sk_bound_dev_if || sk2->sk_bound_dev_if == dif)) {
197 if (twsk_unique(sk, sk2, twp)) 197 if (twsk_unique(sk, sk2, twp))
198 goto unique; 198 goto unique;
199 else 199 else
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 86e1835ce4e4..3bef30e4a23d 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -933,6 +933,8 @@ static int ip6_dst_lookup_tail(struct sock *sk,
933 return 0; 933 return 0;
934 934
935out_err_release: 935out_err_release:
936 if (err == -ENETUNREACH)
937 IP6_INC_STATS_BH(NULL, IPSTATS_MIB_OUTNOROUTES);
936 dst_release(*dst); 938 dst_release(*dst);
937 *dst = NULL; 939 *dst = NULL;
938 return err; 940 return err;
@@ -1314,8 +1316,6 @@ alloc_new_skb:
1314 1316
1315 skb_fill_page_desc(skb, i, page, 0, 0); 1317 skb_fill_page_desc(skb, i, page, 0, 0);
1316 frag = &skb_shinfo(skb)->frags[i]; 1318 frag = &skb_shinfo(skb)->frags[i];
1317 skb->truesize += PAGE_SIZE;
1318 atomic_add(PAGE_SIZE, &sk->sk_wmem_alloc);
1319 } else { 1319 } else {
1320 err = -EMSGSIZE; 1320 err = -EMSGSIZE;
1321 goto error; 1321 goto error;
@@ -1328,6 +1328,8 @@ alloc_new_skb:
1328 frag->size += copy; 1328 frag->size += copy;
1329 skb->len += copy; 1329 skb->len += copy;
1330 skb->data_len += copy; 1330 skb->data_len += copy;
1331 skb->truesize += copy;
1332 atomic_add(copy, &sk->sk_wmem_alloc);
1331 } 1333 }
1332 offset += copy; 1334 offset += copy;
1333 length -= copy; 1335 length -= copy;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 1334fc174bcf..8c5f80fd03ad 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -1046,7 +1046,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
1046 break; 1046 break;
1047 1047
1048 default: 1048 default:
1049 return -EINVAL; 1049 return -ENOPROTOOPT;
1050 } 1050 }
1051 len = min_t(unsigned int, sizeof(int), len); 1051 len = min_t(unsigned int, sizeof(int), len);
1052 if(put_user(len, optlen)) 1052 if(put_user(len, optlen))
@@ -1069,9 +1069,8 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
1069 1069
1070 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen); 1070 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
1071#ifdef CONFIG_NETFILTER 1071#ifdef CONFIG_NETFILTER
1072 /* we need to exclude all possible EINVALs except default case */ 1072 /* we need to exclude all possible ENOPROTOOPTs except default case */
1073 if (err == -EINVAL && optname != IPV6_ADDRFORM && 1073 if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
1074 optname != MCAST_MSFILTER) {
1075 int len; 1074 int len;
1076 1075
1077 if (get_user(len, optlen)) 1076 if (get_user(len, optlen))
@@ -1108,9 +1107,8 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
1108 1107
1109 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen); 1108 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
1110#ifdef CONFIG_NETFILTER 1109#ifdef CONFIG_NETFILTER
1111 /* we need to exclude all possible EINVALs except default case */ 1110 /* we need to exclude all possible ENOPROTOOPTs except default case */
1112 if (err == -EINVAL && optname != IPV6_ADDRFORM && 1111 if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
1113 optname != MCAST_MSFILTER) {
1114 int len; 1112 int len;
1115 1113
1116 if (get_user(len, optlen)) 1114 if (get_user(len, optlen))
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 67997a74ddce..777ed733b2d7 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -612,7 +612,7 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
612 * optimistic addresses, but we may send the solicitation 612 * optimistic addresses, but we may send the solicitation
613 * if we don't include the sllao. So here we check 613 * if we don't include the sllao. So here we check
614 * if our address is optimistic, and if so, we 614 * if our address is optimistic, and if so, we
615 * supress the inclusion of the sllao. 615 * suppress the inclusion of the sllao.
616 */ 616 */
617 if (send_sllao) { 617 if (send_sllao) {
618 struct inet6_ifaddr *ifp = ipv6_get_ifaddr(saddr, dev, 1); 618 struct inet6_ifaddr *ifp = ipv6_get_ifaddr(saddr, dev, 1);
diff --git a/net/ipv6/netfilter/ip6t_eui64.c b/net/ipv6/netfilter/ip6t_eui64.c
index 34ba150bfe5d..41df9a578c7a 100644
--- a/net/ipv6/netfilter/ip6t_eui64.c
+++ b/net/ipv6/netfilter/ip6t_eui64.c
@@ -47,7 +47,7 @@ match(const struct sk_buff *skb,
47 memcpy(eui64 + 5, eth_hdr(skb)->h_source + 3, 3); 47 memcpy(eui64 + 5, eth_hdr(skb)->h_source + 3, 3);
48 eui64[3] = 0xff; 48 eui64[3] = 0xff;
49 eui64[4] = 0xfe; 49 eui64[4] = 0xfe;
50 eui64[0] |= 0x02; 50 eui64[0] ^= 0x02;
51 51
52 i = 0; 52 i = 0;
53 while (ipv6_hdr(skb)->saddr.s6_addr[8 + i] == eui64[i] 53 while (ipv6_hdr(skb)->saddr.s6_addr[8 + i] == eui64[i]
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 8631ed7fe8a9..44937616057e 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -88,7 +88,7 @@ static char *icmp6type2name[256] = {
88 [ICMPV6_PKT_TOOBIG] = "PktTooBigs", 88 [ICMPV6_PKT_TOOBIG] = "PktTooBigs",
89 [ICMPV6_TIME_EXCEED] = "TimeExcds", 89 [ICMPV6_TIME_EXCEED] = "TimeExcds",
90 [ICMPV6_PARAMPROB] = "ParmProblems", 90 [ICMPV6_PARAMPROB] = "ParmProblems",
91 [ICMPV6_ECHO_REQUEST] = "EchoRequest", 91 [ICMPV6_ECHO_REQUEST] = "Echos",
92 [ICMPV6_ECHO_REPLY] = "EchoReplies", 92 [ICMPV6_ECHO_REPLY] = "EchoReplies",
93 [ICMPV6_MGM_QUERY] = "GroupMembQueries", 93 [ICMPV6_MGM_QUERY] = "GroupMembQueries",
94 [ICMPV6_MGM_REPORT] = "GroupMembResponses", 94 [ICMPV6_MGM_REPORT] = "GroupMembResponses",
@@ -98,7 +98,7 @@ static char *icmp6type2name[256] = {
98 [NDISC_ROUTER_SOLICITATION] = "RouterSolicits", 98 [NDISC_ROUTER_SOLICITATION] = "RouterSolicits",
99 [NDISC_NEIGHBOUR_ADVERTISEMENT] = "NeighborAdvertisements", 99 [NDISC_NEIGHBOUR_ADVERTISEMENT] = "NeighborAdvertisements",
100 [NDISC_NEIGHBOUR_SOLICITATION] = "NeighborSolicits", 100 [NDISC_NEIGHBOUR_SOLICITATION] = "NeighborSolicits",
101 [NDISC_REDIRECT] = "NeighborRedirects", 101 [NDISC_REDIRECT] = "Redirects",
102}; 102};
103 103
104 104
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6ecb5e6fae2e..20083e0d3995 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -329,7 +329,7 @@ static inline int rt6_check_dev(struct rt6_info *rt, int oif)
329static inline int rt6_check_neigh(struct rt6_info *rt) 329static inline int rt6_check_neigh(struct rt6_info *rt)
330{ 330{
331 struct neighbour *neigh = rt->rt6i_nexthop; 331 struct neighbour *neigh = rt->rt6i_nexthop;
332 int m = 0; 332 int m;
333 if (rt->rt6i_flags & RTF_NONEXTHOP || 333 if (rt->rt6i_flags & RTF_NONEXTHOP ||
334 !(rt->rt6i_flags & RTF_GATEWAY)) 334 !(rt->rt6i_flags & RTF_GATEWAY))
335 m = 1; 335 m = 1;
@@ -337,10 +337,15 @@ static inline int rt6_check_neigh(struct rt6_info *rt)
337 read_lock_bh(&neigh->lock); 337 read_lock_bh(&neigh->lock);
338 if (neigh->nud_state & NUD_VALID) 338 if (neigh->nud_state & NUD_VALID)
339 m = 2; 339 m = 2;
340 else if (!(neigh->nud_state & NUD_FAILED)) 340#ifdef CONFIG_IPV6_ROUTER_PREF
341 else if (neigh->nud_state & NUD_FAILED)
342 m = 0;
343#endif
344 else
341 m = 1; 345 m = 1;
342 read_unlock_bh(&neigh->lock); 346 read_unlock_bh(&neigh->lock);
343 } 347 } else
348 m = 0;
344 return m; 349 return m;
345} 350}
346 351
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 3aad861975a0..93980c3b83e6 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -581,7 +581,10 @@ static int tcp_v6_md5_do_add(struct sock *sk, struct in6_addr *peer,
581 } 581 }
582 sk->sk_route_caps &= ~NETIF_F_GSO_MASK; 582 sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
583 } 583 }
584 tcp_alloc_md5sig_pool(); 584 if (tcp_alloc_md5sig_pool() == NULL) {
585 kfree(newkey);
586 return -ENOMEM;
587 }
585 if (tp->md5sig_info->alloced6 == tp->md5sig_info->entries6) { 588 if (tp->md5sig_info->alloced6 == tp->md5sig_info->entries6) {
586 keys = kmalloc((sizeof (tp->md5sig_info->keys6[0]) * 589 keys = kmalloc((sizeof (tp->md5sig_info->keys6[0]) *
587 (tp->md5sig_info->entries6 + 1)), GFP_ATOMIC); 590 (tp->md5sig_info->entries6 + 1)), GFP_ATOMIC);
@@ -634,10 +637,6 @@ static int tcp_v6_md5_do_del(struct sock *sk, struct in6_addr *peer)
634 kfree(tp->md5sig_info->keys6); 637 kfree(tp->md5sig_info->keys6);
635 tp->md5sig_info->keys6 = NULL; 638 tp->md5sig_info->keys6 = NULL;
636 tp->md5sig_info->alloced6 = 0; 639 tp->md5sig_info->alloced6 = 0;
637
638 tcp_free_md5sig_pool();
639
640 return 0;
641 } else { 640 } else {
642 /* shrink the database */ 641 /* shrink the database */
643 if (tp->md5sig_info->entries6 != i) 642 if (tp->md5sig_info->entries6 != i)
@@ -646,6 +645,8 @@ static int tcp_v6_md5_do_del(struct sock *sk, struct in6_addr *peer)
646 (tp->md5sig_info->entries6 - i) 645 (tp->md5sig_info->entries6 - i)
647 * sizeof (tp->md5sig_info->keys6[0])); 646 * sizeof (tp->md5sig_info->keys6[0]));
648 } 647 }
648 tcp_free_md5sig_pool();
649 return 0;
649 } 650 }
650 } 651 }
651 return -ENOENT; 652 return -ENOENT;
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 82e27b80d07d..b8e9eb445d74 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -233,7 +233,7 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
233 dst_prev->output = dst_prev->xfrm->outer_mode->afinfo->output; 233 dst_prev->output = dst_prev->xfrm->outer_mode->afinfo->output;
234 /* Sheit... I remember I did this right. Apparently, 234 /* Sheit... I remember I did this right. Apparently,
235 * it was magically lost, so this code needs audit */ 235 * it was magically lost, so this code needs audit */
236 x->u.rt6.rt6i_flags = rt0->rt6i_flags&(RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL); 236 x->u.rt6.rt6i_flags = rt0->rt6i_flags&(RTF_ANYCAST|RTF_LOCAL);
237 x->u.rt6.rt6i_metric = rt0->rt6i_metric; 237 x->u.rt6.rt6i_metric = rt0->rt6i_metric;
238 x->u.rt6.rt6i_node = rt0->rt6i_node; 238 x->u.rt6.rt6i_node = rt0->rt6i_node;
239 x->u.rt6.rt6i_gateway = rt0->rt6i_gateway; 239 x->u.rt6.rt6i_gateway = rt0->rt6i_gateway;
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 48ce59a6e026..07dfa7fdd2a0 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -802,12 +802,18 @@ static int irda_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
802 } 802 }
803#endif /* CONFIG_IRDA_ULTRA */ 803#endif /* CONFIG_IRDA_ULTRA */
804 804
805 self->ias_obj = irias_new_object(addr->sir_name, jiffies);
806 if (self->ias_obj == NULL)
807 return -ENOMEM;
808
805 err = irda_open_tsap(self, addr->sir_lsap_sel, addr->sir_name); 809 err = irda_open_tsap(self, addr->sir_lsap_sel, addr->sir_name);
806 if (err < 0) 810 if (err < 0) {
811 kfree(self->ias_obj->name);
812 kfree(self->ias_obj);
807 return err; 813 return err;
814 }
808 815
809 /* Register with LM-IAS */ 816 /* Register with LM-IAS */
810 self->ias_obj = irias_new_object(addr->sir_name, jiffies);
811 irias_add_integer_attrib(self->ias_obj, "IrDA:TinyTP:LsapSel", 817 irias_add_integer_attrib(self->ias_obj, "IrDA:TinyTP:LsapSel",
812 self->stsap_sel, IAS_KERNEL_ATTR); 818 self->stsap_sel, IAS_KERNEL_ATTR);
813 irias_insert_object(self->ias_obj); 819 irias_insert_object(self->ias_obj);
@@ -1118,8 +1124,6 @@ static int irda_create(struct net *net, struct socket *sock, int protocol)
1118 self->max_sdu_size_rx = TTP_SAR_UNBOUND; 1124 self->max_sdu_size_rx = TTP_SAR_UNBOUND;
1119 break; 1125 break;
1120 default: 1126 default:
1121 IRDA_ERROR("%s: protocol not supported!\n",
1122 __FUNCTION__);
1123 return -ESOCKTNOSUPPORT; 1127 return -ESOCKTNOSUPPORT;
1124 } 1128 }
1125 break; 1129 break;
@@ -1827,7 +1831,7 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
1827 struct irda_ias_set *ias_opt; 1831 struct irda_ias_set *ias_opt;
1828 struct ias_object *ias_obj; 1832 struct ias_object *ias_obj;
1829 struct ias_attrib * ias_attr; /* Attribute in IAS object */ 1833 struct ias_attrib * ias_attr; /* Attribute in IAS object */
1830 int opt; 1834 int opt, free_ias = 0;
1831 1835
1832 IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self); 1836 IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self);
1833 1837
@@ -1883,11 +1887,20 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
1883 /* Create a new object */ 1887 /* Create a new object */
1884 ias_obj = irias_new_object(ias_opt->irda_class_name, 1888 ias_obj = irias_new_object(ias_opt->irda_class_name,
1885 jiffies); 1889 jiffies);
1890 if (ias_obj == NULL) {
1891 kfree(ias_opt);
1892 return -ENOMEM;
1893 }
1894 free_ias = 1;
1886 } 1895 }
1887 1896
1888 /* Do we have the attribute already ? */ 1897 /* Do we have the attribute already ? */
1889 if(irias_find_attrib(ias_obj, ias_opt->irda_attrib_name)) { 1898 if(irias_find_attrib(ias_obj, ias_opt->irda_attrib_name)) {
1890 kfree(ias_opt); 1899 kfree(ias_opt);
1900 if (free_ias) {
1901 kfree(ias_obj->name);
1902 kfree(ias_obj);
1903 }
1891 return -EINVAL; 1904 return -EINVAL;
1892 } 1905 }
1893 1906
@@ -1906,6 +1919,11 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
1906 if(ias_opt->attribute.irda_attrib_octet_seq.len > 1919 if(ias_opt->attribute.irda_attrib_octet_seq.len >
1907 IAS_MAX_OCTET_STRING) { 1920 IAS_MAX_OCTET_STRING) {
1908 kfree(ias_opt); 1921 kfree(ias_opt);
1922 if (free_ias) {
1923 kfree(ias_obj->name);
1924 kfree(ias_obj);
1925 }
1926
1909 return -EINVAL; 1927 return -EINVAL;
1910 } 1928 }
1911 /* Add an octet sequence attribute */ 1929 /* Add an octet sequence attribute */
@@ -1934,6 +1952,10 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
1934 break; 1952 break;
1935 default : 1953 default :
1936 kfree(ias_opt); 1954 kfree(ias_opt);
1955 if (free_ias) {
1956 kfree(ias_obj->name);
1957 kfree(ias_obj);
1958 }
1937 return -EINVAL; 1959 return -EINVAL;
1938 } 1960 }
1939 irias_insert_object(ias_obj); 1961 irias_insert_object(ias_obj);
diff --git a/net/irda/ircomm/ircomm_param.c b/net/irda/ircomm/ircomm_param.c
index e5e4792a0314..598dcbe4a501 100644
--- a/net/irda/ircomm/ircomm_param.c
+++ b/net/irda/ircomm/ircomm_param.c
@@ -496,7 +496,7 @@ static int ircomm_param_poll(void *instance, irda_param_t *param, int get)
496 IRDA_ASSERT(self != NULL, return -1;); 496 IRDA_ASSERT(self != NULL, return -1;);
497 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); 497 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
498 498
499 /* Poll parameters are always of lenght 0 (just a signal) */ 499 /* Poll parameters are always of length 0 (just a signal) */
500 if (!get) { 500 if (!get) {
501 /* Respond with DTE line settings */ 501 /* Respond with DTE line settings */
502 ircomm_param_request(self, IRCOMM_DTE, TRUE); 502 ircomm_param_request(self, IRCOMM_DTE, TRUE);
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 1120b150e211..be627e1f04d8 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -1245,6 +1245,7 @@ static void ircomm_tty_flow_indication(void *instance, void *sap,
1245 self->flow = cmd; 1245 self->flow = cmd;
1246} 1246}
1247 1247
1248#ifdef CONFIG_PROC_FS
1248static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf) 1249static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
1249{ 1250{
1250 int ret=0; 1251 int ret=0;
@@ -1354,7 +1355,6 @@ static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
1354 * 1355 *
1355 * 1356 *
1356 */ 1357 */
1357#ifdef CONFIG_PROC_FS
1358static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len, 1358static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len,
1359 int *eof, void *unused) 1359 int *eof, void *unused)
1360{ 1360{
diff --git a/net/irda/iriap.c b/net/irda/iriap.c
index dc5e34a01620..a86a5d83786b 100644
--- a/net/irda/iriap.c
+++ b/net/irda/iriap.c
@@ -928,7 +928,7 @@ void iriap_call_indication(struct iriap_cb *self, struct sk_buff *skb)
928 928
929 opcode = fp[0]; 929 opcode = fp[0];
930 if (~opcode & 0x80) { 930 if (~opcode & 0x80) {
931 IRDA_WARNING("%s: IrIAS multiframe commands or results" 931 IRDA_WARNING("%s: IrIAS multiframe commands or results "
932 "is not implemented yet!\n", __FUNCTION__); 932 "is not implemented yet!\n", __FUNCTION__);
933 return; 933 return;
934 } 934 }
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index 7f9c8542e5fc..1ab91f787cc1 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -296,6 +296,7 @@ void irlan_eth_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
296 */ 296 */
297void irlan_eth_send_gratuitous_arp(struct net_device *dev) 297void irlan_eth_send_gratuitous_arp(struct net_device *dev)
298{ 298{
299#ifdef CONFIG_INET
299 struct in_device *in_dev; 300 struct in_device *in_dev;
300 301
301 /* 302 /*
@@ -303,7 +304,6 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
303 * is useful if we have changed access points on the same 304 * is useful if we have changed access points on the same
304 * subnet. 305 * subnet.
305 */ 306 */
306#ifdef CONFIG_INET
307 IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n"); 307 IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n");
308 rcu_read_lock(); 308 rcu_read_lock();
309 in_dev = __in_dev_get_rcu(dev); 309 in_dev = __in_dev_get_rcu(dev);
@@ -342,7 +342,7 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
342 342
343 if (dev->flags & IFF_PROMISC) { 343 if (dev->flags & IFF_PROMISC) {
344 /* Enable promiscuous mode */ 344 /* Enable promiscuous mode */
345 IRDA_WARNING("Promiscous mode not implemented by IrLAN!\n"); 345 IRDA_WARNING("Promiscuous mode not implemented by IrLAN!\n");
346 } 346 }
347 else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) { 347 else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) {
348 /* Disable promiscuous mode, use normal mode. */ 348 /* Disable promiscuous mode, use normal mode. */
diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c
index 4f3764546b2f..7c132d6342af 100644
--- a/net/irda/irlap_frame.c
+++ b/net/irda/irlap_frame.c
@@ -144,7 +144,7 @@ void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos)
144 frame->control = SNRM_CMD | PF_BIT; 144 frame->control = SNRM_CMD | PF_BIT;
145 145
146 /* 146 /*
147 * If we are establishing a connection then insert QoS paramerters 147 * If we are establishing a connection then insert QoS parameters
148 */ 148 */
149 if (qos) { 149 if (qos) {
150 skb_put(tx_skb, 9); /* 25 left */ 150 skb_put(tx_skb, 9); /* 25 left */
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index cedff8068fbc..f24cb755908e 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -353,6 +353,7 @@ void irlmp_unregister_link(__u32 saddr)
353 /* Final cleanup */ 353 /* Final cleanup */
354 del_timer(&link->idle_timer); 354 del_timer(&link->idle_timer);
355 link->magic = 0; 355 link->magic = 0;
356 hashbin_delete(link->lsaps, (FREE_FUNC) __irlmp_close_lsap);
356 kfree(link); 357 kfree(link);
357 } 358 }
358} 359}
diff --git a/net/irda/parameters.c b/net/irda/parameters.c
index 2627dad7cd87..722bbe044d9c 100644
--- a/net/irda/parameters.c
+++ b/net/irda/parameters.c
@@ -133,7 +133,7 @@ static int irda_insert_integer(void *self, __u8 *buf, int len, __u8 pi,
133 int err; 133 int err;
134 134
135 p.pi = pi; /* In case handler needs to know */ 135 p.pi = pi; /* In case handler needs to know */
136 p.pl = type & PV_MASK; /* The integer type codes the lenght as well */ 136 p.pl = type & PV_MASK; /* The integer type codes the length as well */
137 p.pv.i = 0; /* Clear value */ 137 p.pv.i = 0; /* Clear value */
138 138
139 /* Call handler for this parameter */ 139 /* Call handler for this parameter */
@@ -142,7 +142,7 @@ static int irda_insert_integer(void *self, __u8 *buf, int len, __u8 pi,
142 return err; 142 return err;
143 143
144 /* 144 /*
145 * If parameter lenght is still 0, then (1) this is an any length 145 * If parameter length is still 0, then (1) this is an any length
146 * integer, and (2) the handler function does not care which length 146 * integer, and (2) the handler function does not care which length
147 * we choose to use, so we pick the one the gives the fewest bytes. 147 * we choose to use, so we pick the one the gives the fewest bytes.
148 */ 148 */
@@ -206,11 +206,11 @@ static int irda_extract_integer(void *self, __u8 *buf, int len, __u8 pi,
206{ 206{
207 irda_param_t p; 207 irda_param_t p;
208 int n = 0; 208 int n = 0;
209 int extract_len; /* Real lenght we extract */ 209 int extract_len; /* Real length we extract */
210 int err; 210 int err;
211 211
212 p.pi = pi; /* In case handler needs to know */ 212 p.pi = pi; /* In case handler needs to know */
213 p.pl = buf[1]; /* Extract lenght of value */ 213 p.pl = buf[1]; /* Extract length of value */
214 p.pv.i = 0; /* Clear value */ 214 p.pv.i = 0; /* Clear value */
215 extract_len = p.pl; /* Default : extract all */ 215 extract_len = p.pl; /* Default : extract all */
216 216
@@ -297,7 +297,7 @@ static int irda_extract_string(void *self, __u8 *buf, int len, __u8 pi,
297 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 297 IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
298 298
299 p.pi = pi; /* In case handler needs to know */ 299 p.pi = pi; /* In case handler needs to know */
300 p.pl = buf[1]; /* Extract lenght of value */ 300 p.pl = buf[1]; /* Extract length of value */
301 301
302 IRDA_DEBUG(2, "%s(), pi=%#x, pl=%d\n", __FUNCTION__, 302 IRDA_DEBUG(2, "%s(), pi=%#x, pl=%d\n", __FUNCTION__,
303 p.pi, p.pl); 303 p.pi, p.pl);
@@ -339,7 +339,7 @@ static int irda_extract_octseq(void *self, __u8 *buf, int len, __u8 pi,
339 irda_param_t p; 339 irda_param_t p;
340 340
341 p.pi = pi; /* In case handler needs to know */ 341 p.pi = pi; /* In case handler needs to know */
342 p.pl = buf[1]; /* Extract lenght of value */ 342 p.pl = buf[1]; /* Extract length of value */
343 343
344 /* Check if buffer is long enough for parsing */ 344 /* Check if buffer is long enough for parsing */
345 if (len < (2+p.pl)) { 345 if (len < (2+p.pl)) {
@@ -463,7 +463,7 @@ int irda_param_insert(void *self, __u8 pi, __u8 *buf, int len,
463 int n = 0; 463 int n = 0;
464 464
465 IRDA_ASSERT(buf != NULL, return ret;); 465 IRDA_ASSERT(buf != NULL, return ret;);
466 IRDA_ASSERT(info != 0, return ret;); 466 IRDA_ASSERT(info != NULL, return ret;);
467 467
468 pi_minor = pi & info->pi_mask; 468 pi_minor = pi & info->pi_mask;
469 pi_major = pi >> info->pi_major_offset; 469 pi_major = pi >> info->pi_major_offset;
@@ -517,7 +517,7 @@ static int irda_param_extract(void *self, __u8 *buf, int len,
517 int n = 0; 517 int n = 0;
518 518
519 IRDA_ASSERT(buf != NULL, return ret;); 519 IRDA_ASSERT(buf != NULL, return ret;);
520 IRDA_ASSERT(info != 0, return ret;); 520 IRDA_ASSERT(info != NULL, return ret;);
521 521
522 pi_minor = buf[n] & info->pi_mask; 522 pi_minor = buf[n] & info->pi_mask;
523 pi_major = buf[n] >> info->pi_major_offset; 523 pi_major = buf[n] >> info->pi_major_offset;
@@ -570,7 +570,7 @@ int irda_param_extract_all(void *self, __u8 *buf, int len,
570 int n = 0; 570 int n = 0;
571 571
572 IRDA_ASSERT(buf != NULL, return ret;); 572 IRDA_ASSERT(buf != NULL, return ret;);
573 IRDA_ASSERT(info != 0, return ret;); 573 IRDA_ASSERT(info != NULL, return ret;);
574 574
575 /* 575 /*
576 * Parse all parameters. Each parameter must be at least two bytes 576 * Parse all parameters. Each parameter must be at least two bytes
diff --git a/net/irda/wrapper.c b/net/irda/wrapper.c
index e71286768a48..c246983308b8 100644
--- a/net/irda/wrapper.c
+++ b/net/irda/wrapper.c
@@ -238,7 +238,7 @@ async_bump(struct net_device *dev,
238 skb_reserve(newskb, 1); 238 skb_reserve(newskb, 1);
239 239
240 if(docopy) { 240 if(docopy) {
241 /* Copy data without CRC (lenght already checked) */ 241 /* Copy data without CRC (length already checked) */
242 skb_copy_to_linear_data(newskb, rx_buff->data, 242 skb_copy_to_linear_data(newskb, rx_buff->data,
243 rx_buff->len - 2); 243 rx_buff->len - 2);
244 /* Deliver this skb */ 244 /* Deliver this skb */
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index a2f5a6ea3895..7698f6c459d6 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -97,7 +97,7 @@ struct iucv_irq_list {
97 struct iucv_irq_data data; 97 struct iucv_irq_data data;
98}; 98};
99 99
100static struct iucv_irq_data *iucv_irq_data; 100static struct iucv_irq_data *iucv_irq_data[NR_CPUS];
101static cpumask_t iucv_buffer_cpumask = CPU_MASK_NONE; 101static cpumask_t iucv_buffer_cpumask = CPU_MASK_NONE;
102static cpumask_t iucv_irq_cpumask = CPU_MASK_NONE; 102static cpumask_t iucv_irq_cpumask = CPU_MASK_NONE;
103 103
@@ -277,7 +277,7 @@ union iucv_param {
277/* 277/*
278 * Anchor for per-cpu IUCV command parameter block. 278 * Anchor for per-cpu IUCV command parameter block.
279 */ 279 */
280static union iucv_param *iucv_param; 280static union iucv_param *iucv_param[NR_CPUS];
281 281
282/** 282/**
283 * iucv_call_b2f0 283 * iucv_call_b2f0
@@ -356,7 +356,7 @@ static void iucv_allow_cpu(void *data)
356 * 0x10 - Flag to allow priority message completion interrupts 356 * 0x10 - Flag to allow priority message completion interrupts
357 * 0x08 - Flag to allow IUCV control interrupts 357 * 0x08 - Flag to allow IUCV control interrupts
358 */ 358 */
359 parm = percpu_ptr(iucv_param, smp_processor_id()); 359 parm = iucv_param[cpu];
360 memset(parm, 0, sizeof(union iucv_param)); 360 memset(parm, 0, sizeof(union iucv_param));
361 parm->set_mask.ipmask = 0xf8; 361 parm->set_mask.ipmask = 0xf8;
362 iucv_call_b2f0(IUCV_SETMASK, parm); 362 iucv_call_b2f0(IUCV_SETMASK, parm);
@@ -377,7 +377,7 @@ static void iucv_block_cpu(void *data)
377 union iucv_param *parm; 377 union iucv_param *parm;
378 378
379 /* Disable all iucv interrupts. */ 379 /* Disable all iucv interrupts. */
380 parm = percpu_ptr(iucv_param, smp_processor_id()); 380 parm = iucv_param[cpu];
381 memset(parm, 0, sizeof(union iucv_param)); 381 memset(parm, 0, sizeof(union iucv_param));
382 iucv_call_b2f0(IUCV_SETMASK, parm); 382 iucv_call_b2f0(IUCV_SETMASK, parm);
383 383
@@ -401,9 +401,9 @@ static void iucv_declare_cpu(void *data)
401 return; 401 return;
402 402
403 /* Declare interrupt buffer. */ 403 /* Declare interrupt buffer. */
404 parm = percpu_ptr(iucv_param, cpu); 404 parm = iucv_param[cpu];
405 memset(parm, 0, sizeof(union iucv_param)); 405 memset(parm, 0, sizeof(union iucv_param));
406 parm->db.ipbfadr1 = virt_to_phys(percpu_ptr(iucv_irq_data, cpu)); 406 parm->db.ipbfadr1 = virt_to_phys(iucv_irq_data[cpu]);
407 rc = iucv_call_b2f0(IUCV_DECLARE_BUFFER, parm); 407 rc = iucv_call_b2f0(IUCV_DECLARE_BUFFER, parm);
408 if (rc) { 408 if (rc) {
409 char *err = "Unknown"; 409 char *err = "Unknown";
@@ -458,7 +458,7 @@ static void iucv_retrieve_cpu(void *data)
458 iucv_block_cpu(NULL); 458 iucv_block_cpu(NULL);
459 459
460 /* Retrieve interrupt buffer. */ 460 /* Retrieve interrupt buffer. */
461 parm = percpu_ptr(iucv_param, cpu); 461 parm = iucv_param[cpu];
462 iucv_call_b2f0(IUCV_RETRIEVE_BUFFER, parm); 462 iucv_call_b2f0(IUCV_RETRIEVE_BUFFER, parm);
463 463
464 /* Clear indication that an iucv buffer exists for this cpu. */ 464 /* Clear indication that an iucv buffer exists for this cpu. */
@@ -558,22 +558,23 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
558 switch (action) { 558 switch (action) {
559 case CPU_UP_PREPARE: 559 case CPU_UP_PREPARE:
560 case CPU_UP_PREPARE_FROZEN: 560 case CPU_UP_PREPARE_FROZEN:
561 if (!percpu_populate(iucv_irq_data, 561 iucv_irq_data[cpu] = kmalloc_node(sizeof(struct iucv_irq_data),
562 sizeof(struct iucv_irq_data), 562 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
563 GFP_KERNEL|GFP_DMA, cpu)) 563 if (!iucv_irq_data[cpu])
564 return NOTIFY_BAD; 564 return NOTIFY_BAD;
565 if (!percpu_populate(iucv_param, sizeof(union iucv_param), 565 iucv_param[cpu] = kmalloc_node(sizeof(union iucv_param),
566 GFP_KERNEL|GFP_DMA, cpu)) { 566 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
567 percpu_depopulate(iucv_irq_data, cpu); 567 if (!iucv_param[cpu])
568 return NOTIFY_BAD; 568 return NOTIFY_BAD;
569 }
570 break; 569 break;
571 case CPU_UP_CANCELED: 570 case CPU_UP_CANCELED:
572 case CPU_UP_CANCELED_FROZEN: 571 case CPU_UP_CANCELED_FROZEN:
573 case CPU_DEAD: 572 case CPU_DEAD:
574 case CPU_DEAD_FROZEN: 573 case CPU_DEAD_FROZEN:
575 percpu_depopulate(iucv_param, cpu); 574 kfree(iucv_param[cpu]);
576 percpu_depopulate(iucv_irq_data, cpu); 575 iucv_param[cpu] = NULL;
576 kfree(iucv_irq_data[cpu]);
577 iucv_irq_data[cpu] = NULL;
577 break; 578 break;
578 case CPU_ONLINE: 579 case CPU_ONLINE:
579 case CPU_ONLINE_FROZEN: 580 case CPU_ONLINE_FROZEN:
@@ -612,7 +613,7 @@ static int iucv_sever_pathid(u16 pathid, u8 userdata[16])
612{ 613{
613 union iucv_param *parm; 614 union iucv_param *parm;
614 615
615 parm = percpu_ptr(iucv_param, smp_processor_id()); 616 parm = iucv_param[smp_processor_id()];
616 memset(parm, 0, sizeof(union iucv_param)); 617 memset(parm, 0, sizeof(union iucv_param));
617 if (userdata) 618 if (userdata)
618 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser)); 619 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
@@ -755,7 +756,7 @@ int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
755 756
756 local_bh_disable(); 757 local_bh_disable();
757 /* Prepare parameter block. */ 758 /* Prepare parameter block. */
758 parm = percpu_ptr(iucv_param, smp_processor_id()); 759 parm = iucv_param[smp_processor_id()];
759 memset(parm, 0, sizeof(union iucv_param)); 760 memset(parm, 0, sizeof(union iucv_param));
760 parm->ctrl.ippathid = path->pathid; 761 parm->ctrl.ippathid = path->pathid;
761 parm->ctrl.ipmsglim = path->msglim; 762 parm->ctrl.ipmsglim = path->msglim;
@@ -799,7 +800,7 @@ int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
799 BUG_ON(in_atomic()); 800 BUG_ON(in_atomic());
800 spin_lock_bh(&iucv_table_lock); 801 spin_lock_bh(&iucv_table_lock);
801 iucv_cleanup_queue(); 802 iucv_cleanup_queue();
802 parm = percpu_ptr(iucv_param, smp_processor_id()); 803 parm = iucv_param[smp_processor_id()];
803 memset(parm, 0, sizeof(union iucv_param)); 804 memset(parm, 0, sizeof(union iucv_param));
804 parm->ctrl.ipmsglim = path->msglim; 805 parm->ctrl.ipmsglim = path->msglim;
805 parm->ctrl.ipflags1 = path->flags; 806 parm->ctrl.ipflags1 = path->flags;
@@ -854,7 +855,7 @@ int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16])
854 int rc; 855 int rc;
855 856
856 local_bh_disable(); 857 local_bh_disable();
857 parm = percpu_ptr(iucv_param, smp_processor_id()); 858 parm = iucv_param[smp_processor_id()];
858 memset(parm, 0, sizeof(union iucv_param)); 859 memset(parm, 0, sizeof(union iucv_param));
859 if (userdata) 860 if (userdata)
860 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser)); 861 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
@@ -881,7 +882,7 @@ int iucv_path_resume(struct iucv_path *path, u8 userdata[16])
881 int rc; 882 int rc;
882 883
883 local_bh_disable(); 884 local_bh_disable();
884 parm = percpu_ptr(iucv_param, smp_processor_id()); 885 parm = iucv_param[smp_processor_id()];
885 memset(parm, 0, sizeof(union iucv_param)); 886 memset(parm, 0, sizeof(union iucv_param));
886 if (userdata) 887 if (userdata)
887 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser)); 888 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
@@ -936,7 +937,7 @@ int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
936 int rc; 937 int rc;
937 938
938 local_bh_disable(); 939 local_bh_disable();
939 parm = percpu_ptr(iucv_param, smp_processor_id()); 940 parm = iucv_param[smp_processor_id()];
940 memset(parm, 0, sizeof(union iucv_param)); 941 memset(parm, 0, sizeof(union iucv_param));
941 parm->purge.ippathid = path->pathid; 942 parm->purge.ippathid = path->pathid;
942 parm->purge.ipmsgid = msg->id; 943 parm->purge.ipmsgid = msg->id;
@@ -1003,7 +1004,7 @@ int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
1003 } 1004 }
1004 1005
1005 local_bh_disable(); 1006 local_bh_disable();
1006 parm = percpu_ptr(iucv_param, smp_processor_id()); 1007 parm = iucv_param[smp_processor_id()];
1007 memset(parm, 0, sizeof(union iucv_param)); 1008 memset(parm, 0, sizeof(union iucv_param));
1008 parm->db.ipbfadr1 = (u32)(addr_t) buffer; 1009 parm->db.ipbfadr1 = (u32)(addr_t) buffer;
1009 parm->db.ipbfln1f = (u32) size; 1010 parm->db.ipbfln1f = (u32) size;
@@ -1040,7 +1041,7 @@ int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg)
1040 int rc; 1041 int rc;
1041 1042
1042 local_bh_disable(); 1043 local_bh_disable();
1043 parm = percpu_ptr(iucv_param, smp_processor_id()); 1044 parm = iucv_param[smp_processor_id()];
1044 memset(parm, 0, sizeof(union iucv_param)); 1045 memset(parm, 0, sizeof(union iucv_param));
1045 parm->db.ippathid = path->pathid; 1046 parm->db.ippathid = path->pathid;
1046 parm->db.ipmsgid = msg->id; 1047 parm->db.ipmsgid = msg->id;
@@ -1074,7 +1075,7 @@ int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
1074 int rc; 1075 int rc;
1075 1076
1076 local_bh_disable(); 1077 local_bh_disable();
1077 parm = percpu_ptr(iucv_param, smp_processor_id()); 1078 parm = iucv_param[smp_processor_id()];
1078 memset(parm, 0, sizeof(union iucv_param)); 1079 memset(parm, 0, sizeof(union iucv_param));
1079 if (flags & IUCV_IPRMDATA) { 1080 if (flags & IUCV_IPRMDATA) {
1080 parm->dpl.ippathid = path->pathid; 1081 parm->dpl.ippathid = path->pathid;
@@ -1118,7 +1119,7 @@ int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
1118 int rc; 1119 int rc;
1119 1120
1120 local_bh_disable(); 1121 local_bh_disable();
1121 parm = percpu_ptr(iucv_param, smp_processor_id()); 1122 parm = iucv_param[smp_processor_id()];
1122 memset(parm, 0, sizeof(union iucv_param)); 1123 memset(parm, 0, sizeof(union iucv_param));
1123 if (flags & IUCV_IPRMDATA) { 1124 if (flags & IUCV_IPRMDATA) {
1124 /* Message of 8 bytes can be placed into the parameter list. */ 1125 /* Message of 8 bytes can be placed into the parameter list. */
@@ -1172,7 +1173,7 @@ int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
1172 int rc; 1173 int rc;
1173 1174
1174 local_bh_disable(); 1175 local_bh_disable();
1175 parm = percpu_ptr(iucv_param, smp_processor_id()); 1176 parm = iucv_param[smp_processor_id()];
1176 memset(parm, 0, sizeof(union iucv_param)); 1177 memset(parm, 0, sizeof(union iucv_param));
1177 if (flags & IUCV_IPRMDATA) { 1178 if (flags & IUCV_IPRMDATA) {
1178 parm->dpl.ippathid = path->pathid; 1179 parm->dpl.ippathid = path->pathid;
@@ -1559,7 +1560,7 @@ static void iucv_external_interrupt(u16 code)
1559 struct iucv_irq_data *p; 1560 struct iucv_irq_data *p;
1560 struct iucv_irq_list *work; 1561 struct iucv_irq_list *work;
1561 1562
1562 p = percpu_ptr(iucv_irq_data, smp_processor_id()); 1563 p = iucv_irq_data[smp_processor_id()];
1563 if (p->ippathid >= iucv_max_pathid) { 1564 if (p->ippathid >= iucv_max_pathid) {
1564 printk(KERN_WARNING "iucv_do_int: Got interrupt with " 1565 printk(KERN_WARNING "iucv_do_int: Got interrupt with "
1565 "pathid %d > max_connections (%ld)\n", 1566 "pathid %d > max_connections (%ld)\n",
@@ -1598,6 +1599,7 @@ static void iucv_external_interrupt(u16 code)
1598static int __init iucv_init(void) 1599static int __init iucv_init(void)
1599{ 1600{
1600 int rc; 1601 int rc;
1602 int cpu;
1601 1603
1602 if (!MACHINE_IS_VM) { 1604 if (!MACHINE_IS_VM) {
1603 rc = -EPROTONOSUPPORT; 1605 rc = -EPROTONOSUPPORT;
@@ -1617,19 +1619,23 @@ static int __init iucv_init(void)
1617 rc = PTR_ERR(iucv_root); 1619 rc = PTR_ERR(iucv_root);
1618 goto out_bus; 1620 goto out_bus;
1619 } 1621 }
1620 /* Note: GFP_DMA used to get memory below 2G */ 1622
1621 iucv_irq_data = percpu_alloc(sizeof(struct iucv_irq_data), 1623 for_each_online_cpu(cpu) {
1622 GFP_KERNEL|GFP_DMA); 1624 /* Note: GFP_DMA used to get memory below 2G */
1623 if (!iucv_irq_data) { 1625 iucv_irq_data[cpu] = kmalloc_node(sizeof(struct iucv_irq_data),
1624 rc = -ENOMEM; 1626 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
1625 goto out_root; 1627 if (!iucv_irq_data[cpu]) {
1626 } 1628 rc = -ENOMEM;
1627 /* Allocate parameter blocks. */ 1629 goto out_free;
1628 iucv_param = percpu_alloc(sizeof(union iucv_param), 1630 }
1629 GFP_KERNEL|GFP_DMA); 1631
1630 if (!iucv_param) { 1632 /* Allocate parameter blocks. */
1631 rc = -ENOMEM; 1633 iucv_param[cpu] = kmalloc_node(sizeof(union iucv_param),
1632 goto out_extint; 1634 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
1635 if (!iucv_param[cpu]) {
1636 rc = -ENOMEM;
1637 goto out_free;
1638 }
1633 } 1639 }
1634 register_hotcpu_notifier(&iucv_cpu_notifier); 1640 register_hotcpu_notifier(&iucv_cpu_notifier);
1635 ASCEBC(iucv_error_no_listener, 16); 1641 ASCEBC(iucv_error_no_listener, 16);
@@ -1638,9 +1644,13 @@ static int __init iucv_init(void)
1638 iucv_available = 1; 1644 iucv_available = 1;
1639 return 0; 1645 return 0;
1640 1646
1641out_extint: 1647out_free:
1642 percpu_free(iucv_irq_data); 1648 for_each_possible_cpu(cpu) {
1643out_root: 1649 kfree(iucv_param[cpu]);
1650 iucv_param[cpu] = NULL;
1651 kfree(iucv_irq_data[cpu]);
1652 iucv_irq_data[cpu] = NULL;
1653 }
1644 s390_root_dev_unregister(iucv_root); 1654 s390_root_dev_unregister(iucv_root);
1645out_bus: 1655out_bus:
1646 bus_unregister(&iucv_bus); 1656 bus_unregister(&iucv_bus);
@@ -1658,6 +1668,7 @@ out:
1658static void __exit iucv_exit(void) 1668static void __exit iucv_exit(void)
1659{ 1669{
1660 struct iucv_irq_list *p, *n; 1670 struct iucv_irq_list *p, *n;
1671 int cpu;
1661 1672
1662 spin_lock_irq(&iucv_queue_lock); 1673 spin_lock_irq(&iucv_queue_lock);
1663 list_for_each_entry_safe(p, n, &iucv_task_queue, list) 1674 list_for_each_entry_safe(p, n, &iucv_task_queue, list)
@@ -1666,8 +1677,12 @@ static void __exit iucv_exit(void)
1666 kfree(p); 1677 kfree(p);
1667 spin_unlock_irq(&iucv_queue_lock); 1678 spin_unlock_irq(&iucv_queue_lock);
1668 unregister_hotcpu_notifier(&iucv_cpu_notifier); 1679 unregister_hotcpu_notifier(&iucv_cpu_notifier);
1669 percpu_free(iucv_param); 1680 for_each_possible_cpu(cpu) {
1670 percpu_free(iucv_irq_data); 1681 kfree(iucv_param[cpu]);
1682 iucv_param[cpu] = NULL;
1683 kfree(iucv_irq_data[cpu]);
1684 iucv_irq_data[cpu] = NULL;
1685 }
1671 s390_root_dev_unregister(iucv_root); 1686 s390_root_dev_unregister(iucv_root);
1672 bus_unregister(&iucv_bus); 1687 bus_unregister(&iucv_bus);
1673 unregister_external_interrupt(0x4000, iucv_external_interrupt); 1688 unregister_external_interrupt(0x4000, iucv_external_interrupt);
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 10c89d47f685..76dcd882f87b 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1015,9 +1015,7 @@ static inline struct sk_buff *pfkey_xfrm_state2msg(struct xfrm_state *x)
1015{ 1015{
1016 struct sk_buff *skb; 1016 struct sk_buff *skb;
1017 1017
1018 spin_lock_bh(&x->lock);
1019 skb = __pfkey_xfrm_state2msg(x, 1, 3); 1018 skb = __pfkey_xfrm_state2msg(x, 1, 3);
1020 spin_unlock_bh(&x->lock);
1021 1019
1022 return skb; 1020 return skb;
1023} 1021}
@@ -1552,7 +1550,7 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
1552 1550
1553 out_hdr = (struct sadb_msg *) out_skb->data; 1551 out_hdr = (struct sadb_msg *) out_skb->data;
1554 out_hdr->sadb_msg_version = hdr->sadb_msg_version; 1552 out_hdr->sadb_msg_version = hdr->sadb_msg_version;
1555 out_hdr->sadb_msg_type = SADB_DUMP; 1553 out_hdr->sadb_msg_type = SADB_GET;
1556 out_hdr->sadb_msg_satype = pfkey_proto2satype(proto); 1554 out_hdr->sadb_msg_satype = pfkey_proto2satype(proto);
1557 out_hdr->sadb_msg_errno = 0; 1555 out_hdr->sadb_msg_errno = 0;
1558 out_hdr->sadb_msg_reserved = 0; 1556 out_hdr->sadb_msg_reserved = 0;
@@ -2786,12 +2784,22 @@ static struct sadb_msg *pfkey_get_base_msg(struct sk_buff *skb, int *errp)
2786 2784
2787static inline int aalg_tmpl_set(struct xfrm_tmpl *t, struct xfrm_algo_desc *d) 2785static inline int aalg_tmpl_set(struct xfrm_tmpl *t, struct xfrm_algo_desc *d)
2788{ 2786{
2789 return t->aalgos & (1 << d->desc.sadb_alg_id); 2787 unsigned int id = d->desc.sadb_alg_id;
2788
2789 if (id >= sizeof(t->aalgos) * 8)
2790 return 0;
2791
2792 return (t->aalgos >> id) & 1;
2790} 2793}
2791 2794
2792static inline int ealg_tmpl_set(struct xfrm_tmpl *t, struct xfrm_algo_desc *d) 2795static inline int ealg_tmpl_set(struct xfrm_tmpl *t, struct xfrm_algo_desc *d)
2793{ 2796{
2794 return t->ealgos & (1 << d->desc.sadb_alg_id); 2797 unsigned int id = d->desc.sadb_alg_id;
2798
2799 if (id >= sizeof(t->ealgos) * 8)
2800 return 0;
2801
2802 return (t->ealgos >> id) & 1;
2795} 2803}
2796 2804
2797static int count_ah_combs(struct xfrm_tmpl *t) 2805static int count_ah_combs(struct xfrm_tmpl *t)
@@ -3585,27 +3593,29 @@ static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
3585 /* old ipsecrequest */ 3593 /* old ipsecrequest */
3586 int mode = pfkey_mode_from_xfrm(mp->mode); 3594 int mode = pfkey_mode_from_xfrm(mp->mode);
3587 if (mode < 0) 3595 if (mode < 0)
3588 return -EINVAL; 3596 goto err;
3589 if (set_ipsecrequest(skb, mp->proto, mode, 3597 if (set_ipsecrequest(skb, mp->proto, mode,
3590 (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE), 3598 (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
3591 mp->reqid, mp->old_family, 3599 mp->reqid, mp->old_family,
3592 &mp->old_saddr, &mp->old_daddr) < 0) { 3600 &mp->old_saddr, &mp->old_daddr) < 0)
3593 return -EINVAL; 3601 goto err;
3594 }
3595 3602
3596 /* new ipsecrequest */ 3603 /* new ipsecrequest */
3597 if (set_ipsecrequest(skb, mp->proto, mode, 3604 if (set_ipsecrequest(skb, mp->proto, mode,
3598 (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE), 3605 (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
3599 mp->reqid, mp->new_family, 3606 mp->reqid, mp->new_family,
3600 &mp->new_saddr, &mp->new_daddr) < 0) { 3607 &mp->new_saddr, &mp->new_daddr) < 0)
3601 return -EINVAL; 3608 goto err;
3602 }
3603 } 3609 }
3604 3610
3605 /* broadcast migrate message to sockets */ 3611 /* broadcast migrate message to sockets */
3606 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL); 3612 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL);
3607 3613
3608 return 0; 3614 return 0;
3615
3616err:
3617 kfree_skb(skb);
3618 return -EINVAL;
3609} 3619}
3610#else 3620#else
3611static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 3621static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c
index e0ee65a969bc..6378850d8580 100644
--- a/net/mac80211/ieee80211.c
+++ b/net/mac80211/ieee80211.c
@@ -216,6 +216,7 @@ static int ieee80211_open(struct net_device *dev)
216 res = local->ops->start(local_to_hw(local)); 216 res = local->ops->start(local_to_hw(local));
217 if (res) 217 if (res)
218 return res; 218 return res;
219 ieee80211_hw_config(local);
219 } 220 }
220 221
221 switch (sdata->type) { 222 switch (sdata->type) {
@@ -232,7 +233,6 @@ static int ieee80211_open(struct net_device *dev)
232 netif_tx_unlock_bh(local->mdev); 233 netif_tx_unlock_bh(local->mdev);
233 234
234 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; 235 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
235 ieee80211_hw_config(local);
236 } 236 }
237 break; 237 break;
238 case IEEE80211_IF_TYPE_STA: 238 case IEEE80211_IF_TYPE_STA:
@@ -267,6 +267,17 @@ static int ieee80211_open(struct net_device *dev)
267 tasklet_enable(&local->tasklet); 267 tasklet_enable(&local->tasklet);
268 } 268 }
269 269
270 /*
271 * set_multicast_list will be invoked by the networking core
272 * which will check whether any increments here were done in
273 * error and sync them down to the hardware as filter flags.
274 */
275 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
276 atomic_inc(&local->iff_allmultis);
277
278 if (sdata->flags & IEEE80211_SDATA_PROMISC)
279 atomic_inc(&local->iff_promiscs);
280
270 local->open_count++; 281 local->open_count++;
271 282
272 netif_start_queue(dev); 283 netif_start_queue(dev);
@@ -284,6 +295,18 @@ static int ieee80211_stop(struct net_device *dev)
284 295
285 netif_stop_queue(dev); 296 netif_stop_queue(dev);
286 297
298 /*
299 * Don't count this interface for promisc/allmulti while it
300 * is down. dev_mc_unsync() will invoke set_multicast_list
301 * on the master interface which will sync these down to the
302 * hardware as filter flags.
303 */
304 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
305 atomic_dec(&local->iff_allmultis);
306
307 if (sdata->flags & IEEE80211_SDATA_PROMISC)
308 atomic_dec(&local->iff_promiscs);
309
287 dev_mc_unsync(local->mdev, dev); 310 dev_mc_unsync(local->mdev, dev);
288 311
289 /* down all dependent devices, that is VLANs */ 312 /* down all dependent devices, that is VLANs */
@@ -311,8 +334,7 @@ static int ieee80211_stop(struct net_device *dev)
311 ieee80211_configure_filter(local); 334 ieee80211_configure_filter(local);
312 netif_tx_unlock_bh(local->mdev); 335 netif_tx_unlock_bh(local->mdev);
313 336
314 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; 337 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
315 ieee80211_hw_config(local);
316 } 338 }
317 break; 339 break;
318 case IEEE80211_IF_TYPE_STA: 340 case IEEE80211_IF_TYPE_STA:
@@ -334,6 +356,11 @@ static int ieee80211_stop(struct net_device *dev)
334 cancel_delayed_work(&local->scan_work); 356 cancel_delayed_work(&local->scan_work);
335 } 357 }
336 flush_workqueue(local->hw.workqueue); 358 flush_workqueue(local->hw.workqueue);
359
360 sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
361 kfree(sdata->u.sta.extra_ie);
362 sdata->u.sta.extra_ie = NULL;
363 sdata->u.sta.extra_ie_len = 0;
337 /* fall through */ 364 /* fall through */
338 default: 365 default:
339 conf.if_id = dev->ifindex; 366 conf.if_id = dev->ifindex;
@@ -366,8 +393,8 @@ static void ieee80211_set_multicast_list(struct net_device *dev)
366 393
367 allmulti = !!(dev->flags & IFF_ALLMULTI); 394 allmulti = !!(dev->flags & IFF_ALLMULTI);
368 promisc = !!(dev->flags & IFF_PROMISC); 395 promisc = !!(dev->flags & IFF_PROMISC);
369 sdata_allmulti = sdata->flags & IEEE80211_SDATA_ALLMULTI; 396 sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
370 sdata_promisc = sdata->flags & IEEE80211_SDATA_PROMISC; 397 sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC);
371 398
372 if (allmulti != sdata_allmulti) { 399 if (allmulti != sdata_allmulti) {
373 if (dev->flags & IFF_ALLMULTI) 400 if (dev->flags & IFF_ALLMULTI)
@@ -400,7 +427,6 @@ static const struct header_ops ieee80211_header_ops = {
400void ieee80211_if_setup(struct net_device *dev) 427void ieee80211_if_setup(struct net_device *dev)
401{ 428{
402 ether_setup(dev); 429 ether_setup(dev);
403 dev->header_ops = &ieee80211_header_ops;
404 dev->hard_start_xmit = ieee80211_subif_start_xmit; 430 dev->hard_start_xmit = ieee80211_subif_start_xmit;
405 dev->wireless_handlers = &ieee80211_iw_handler_def; 431 dev->wireless_handlers = &ieee80211_iw_handler_def;
406 dev->set_multicast_list = ieee80211_set_multicast_list; 432 dev->set_multicast_list = ieee80211_set_multicast_list;
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c
index 7027eed4d4ae..308bbe4a1333 100644
--- a/net/mac80211/ieee80211_ioctl.c
+++ b/net/mac80211/ieee80211_ioctl.c
@@ -591,7 +591,7 @@ static int ieee80211_ioctl_siwrate(struct net_device *dev,
591 sdata->bss->force_unicast_rateidx = -1; 591 sdata->bss->force_unicast_rateidx = -1;
592 if (rate->value < 0) 592 if (rate->value < 0)
593 return 0; 593 return 0;
594 for (i=0; i< mode->num_rates; i++) { 594 for (i=0; i < mode->num_rates; i++) {
595 struct ieee80211_rate *rates = &mode->rates[i]; 595 struct ieee80211_rate *rates = &mode->rates[i];
596 int this_rate = rates->rate; 596 int this_rate = rates->rate;
597 597
@@ -599,10 +599,10 @@ static int ieee80211_ioctl_siwrate(struct net_device *dev,
599 sdata->bss->max_ratectrl_rateidx = i; 599 sdata->bss->max_ratectrl_rateidx = i;
600 if (rate->fixed) 600 if (rate->fixed)
601 sdata->bss->force_unicast_rateidx = i; 601 sdata->bss->force_unicast_rateidx = i;
602 break; 602 return 0;
603 } 603 }
604 } 604 }
605 return 0; 605 return -EINVAL;
606} 606}
607 607
608static int ieee80211_ioctl_giwrate(struct net_device *dev, 608static int ieee80211_ioctl_giwrate(struct net_device *dev,
diff --git a/net/mac80211/ieee80211_rate.c b/net/mac80211/ieee80211_rate.c
index 7254bd609839..c3f278393741 100644
--- a/net/mac80211/ieee80211_rate.c
+++ b/net/mac80211/ieee80211_rate.c
@@ -33,6 +33,7 @@ int ieee80211_rate_control_register(struct rate_control_ops *ops)
33 if (!strcmp(alg->ops->name, ops->name)) { 33 if (!strcmp(alg->ops->name, ops->name)) {
34 /* don't register an algorithm twice */ 34 /* don't register an algorithm twice */
35 WARN_ON(1); 35 WARN_ON(1);
36 mutex_unlock(&rate_ctrl_mutex);
36 return -EALREADY; 37 return -EALREADY;
37 } 38 }
38 } 39 }
@@ -59,11 +60,11 @@ void ieee80211_rate_control_unregister(struct rate_control_ops *ops)
59 list_for_each_entry(alg, &rate_ctrl_algs, list) { 60 list_for_each_entry(alg, &rate_ctrl_algs, list) {
60 if (alg->ops == ops) { 61 if (alg->ops == ops) {
61 list_del(&alg->list); 62 list_del(&alg->list);
63 kfree(alg);
62 break; 64 break;
63 } 65 }
64 } 66 }
65 mutex_unlock(&rate_ctrl_mutex); 67 mutex_unlock(&rate_ctrl_mutex);
66 kfree(alg);
67} 68}
68EXPORT_SYMBOL(ieee80211_rate_control_unregister); 69EXPORT_SYMBOL(ieee80211_rate_control_unregister);
69 70
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index 015b3f879aa9..bee8080f2249 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -808,12 +808,8 @@ static void ieee80211_associated(struct net_device *dev,
808 sta_info_put(sta); 808 sta_info_put(sta);
809 } 809 }
810 if (disassoc) { 810 if (disassoc) {
811 union iwreq_data wrqu; 811 ifsta->state = IEEE80211_DISABLED;
812 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); 812 ieee80211_set_associated(dev, ifsta, 0);
813 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
814 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
815 mod_timer(&ifsta->timer, jiffies +
816 IEEE80211_MONITORING_INTERVAL + 30 * HZ);
817 } else { 813 } else {
818 mod_timer(&ifsta->timer, jiffies + 814 mod_timer(&ifsta->timer, jiffies +
819 IEEE80211_MONITORING_INTERVAL); 815 IEEE80211_MONITORING_INTERVAL);
@@ -2647,7 +2643,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)
2647 local->sta_scanning = 0; 2643 local->sta_scanning = 0;
2648 2644
2649 if (ieee80211_hw_config(local)) 2645 if (ieee80211_hw_config(local))
2650 printk(KERN_DEBUG "%s: failed to restore operational" 2646 printk(KERN_DEBUG "%s: failed to restore operational "
2651 "channel after scan\n", dev->name); 2647 "channel after scan\n", dev->name);
2652 2648
2653 2649
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 428a9fcf57d6..00f908d9275e 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -997,7 +997,7 @@ ieee80211_rx_h_drop_unencrypted(struct ieee80211_txrx_data *rx)
997 if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) && 997 if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) &&
998 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && 998 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
999 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC && 999 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
1000 rx->sdata->drop_unencrypted && 1000 (rx->key || rx->sdata->drop_unencrypted) &&
1001 (rx->sdata->eapol == 0 || !ieee80211_is_eapol(rx->skb)))) { 1001 (rx->sdata->eapol == 0 || !ieee80211_is_eapol(rx->skb)))) {
1002 if (net_ratelimit()) 1002 if (net_ratelimit())
1003 printk(KERN_DEBUG "%s: RX non-WEP frame, but expected " 1003 printk(KERN_DEBUG "%s: RX non-WEP frame, but expected "
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index e8491554a5dc..cfd8ee9adad0 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -14,6 +14,7 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/skbuff.h> 15#include <linux/skbuff.h>
16#include <linux/if_arp.h> 16#include <linux/if_arp.h>
17#include <linux/timer.h>
17 18
18#include <net/mac80211.h> 19#include <net/mac80211.h>
19#include "ieee80211_i.h" 20#include "ieee80211_i.h"
@@ -306,7 +307,8 @@ static void sta_info_cleanup(unsigned long data)
306 } 307 }
307 read_unlock_bh(&local->sta_lock); 308 read_unlock_bh(&local->sta_lock);
308 309
309 local->sta_cleanup.expires = jiffies + STA_INFO_CLEANUP_INTERVAL; 310 local->sta_cleanup.expires =
311 round_jiffies(jiffies + STA_INFO_CLEANUP_INTERVAL);
310 add_timer(&local->sta_cleanup); 312 add_timer(&local->sta_cleanup);
311} 313}
312 314
@@ -345,7 +347,8 @@ void sta_info_init(struct ieee80211_local *local)
345 INIT_LIST_HEAD(&local->sta_list); 347 INIT_LIST_HEAD(&local->sta_list);
346 348
347 init_timer(&local->sta_cleanup); 349 init_timer(&local->sta_cleanup);
348 local->sta_cleanup.expires = jiffies + STA_INFO_CLEANUP_INTERVAL; 350 local->sta_cleanup.expires =
351 round_jiffies(jiffies + STA_INFO_CLEANUP_INTERVAL);
349 local->sta_cleanup.data = (unsigned long) local; 352 local->sta_cleanup.data = (unsigned long) local;
350 local->sta_cleanup.function = sta_info_cleanup; 353 local->sta_cleanup.function = sta_info_cleanup;
351 354
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index 9bf0e1cc530a..b5f3413403bd 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -265,7 +265,8 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
265 if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen, 265 if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen,
266 skb->data + hdrlen + WEP_IV_LEN, 266 skb->data + hdrlen + WEP_IV_LEN,
267 len)) { 267 len)) {
268 printk(KERN_DEBUG "WEP decrypt failed (ICV)\n"); 268 if (net_ratelimit())
269 printk(KERN_DEBUG "WEP decrypt failed (ICV)\n");
269 ret = -1; 270 ret = -1;
270 } 271 }
271 272
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 000c2fb462d0..a4d5cdeb0110 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1016,7 +1016,7 @@ struct hlist_head *nf_ct_alloc_hashtable(int *sizep, int *vmalloced)
1016} 1016}
1017EXPORT_SYMBOL_GPL(nf_ct_alloc_hashtable); 1017EXPORT_SYMBOL_GPL(nf_ct_alloc_hashtable);
1018 1018
1019int set_hashsize(const char *val, struct kernel_param *kp) 1019int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp)
1020{ 1020{
1021 int i, bucket, hashsize, vmalloced; 1021 int i, bucket, hashsize, vmalloced;
1022 int old_vmalloced, old_size; 1022 int old_vmalloced, old_size;
@@ -1063,8 +1063,9 @@ int set_hashsize(const char *val, struct kernel_param *kp)
1063 nf_ct_free_hashtable(old_hash, old_vmalloced, old_size); 1063 nf_ct_free_hashtable(old_hash, old_vmalloced, old_size);
1064 return 0; 1064 return 0;
1065} 1065}
1066EXPORT_SYMBOL_GPL(nf_conntrack_set_hashsize);
1066 1067
1067module_param_call(hashsize, set_hashsize, param_get_uint, 1068module_param_call(hashsize, nf_conntrack_set_hashsize, param_get_uint,
1068 &nf_conntrack_htable_size, 0600); 1069 &nf_conntrack_htable_size, 0600);
1069 1070
1070int __init nf_conntrack_init(void) 1071int __init nf_conntrack_init(void)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 9be1826e6cdd..7d231243754a 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1024,8 +1024,10 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
1024 } 1024 }
1025 1025
1026 /* setup master conntrack: this is a confirmed expectation */ 1026 /* setup master conntrack: this is a confirmed expectation */
1027 if (master_ct) 1027 if (master_ct) {
1028 __set_bit(IPS_EXPECTED_BIT, &ct->status);
1028 ct->master = master_ct; 1029 ct->master = master_ct;
1030 }
1029 1031
1030 add_timer(&ct->timeout); 1032 add_timer(&ct->timeout);
1031 nf_conntrack_hash_insert(ct); 1033 nf_conntrack_hash_insert(ct);
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 8f8b5a48df38..515abffc4a09 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -187,7 +187,7 @@ static const struct sip_header_nfo ct_sip_hdrs[] = {
187 } 187 }
188}; 188};
189 189
190/* get line lenght until first CR or LF seen. */ 190/* get line length until first CR or LF seen. */
191int ct_sip_lnlen(const char *line, const char *limit) 191int ct_sip_lnlen(const char *line, const char *limit)
192{ 192{
193 const char *k = line; 193 const char *k = line;
@@ -236,7 +236,7 @@ static int digits_len(struct nf_conn *ct, const char *dptr,
236 return len; 236 return len;
237} 237}
238 238
239/* get digits lenght, skiping blank spaces. */ 239/* get digits length, skipping blank spaces. */
240static int skp_digits_len(struct nf_conn *ct, const char *dptr, 240static int skp_digits_len(struct nf_conn *ct, const char *dptr,
241 const char *limit, int *shift) 241 const char *limit, int *shift)
242{ 242{
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index d9a3bded0d00..b6160e41eb1c 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -377,7 +377,9 @@ int xt_compat_match_to_user(struct xt_entry_match *m, void __user **dstptr,
377 u_int16_t msize = m->u.user.match_size - off; 377 u_int16_t msize = m->u.user.match_size - off;
378 378
379 if (copy_to_user(cm, m, sizeof(*cm)) || 379 if (copy_to_user(cm, m, sizeof(*cm)) ||
380 put_user(msize, &cm->u.user.match_size)) 380 put_user(msize, &cm->u.user.match_size) ||
381 copy_to_user(cm->u.user.name, m->u.kernel.match->name,
382 strlen(m->u.kernel.match->name) + 1))
381 return -EFAULT; 383 return -EFAULT;
382 384
383 if (match->compat_to_user) { 385 if (match->compat_to_user) {
@@ -468,7 +470,9 @@ int xt_compat_target_to_user(struct xt_entry_target *t, void __user **dstptr,
468 u_int16_t tsize = t->u.user.target_size - off; 470 u_int16_t tsize = t->u.user.target_size - off;
469 471
470 if (copy_to_user(ct, t, sizeof(*ct)) || 472 if (copy_to_user(ct, t, sizeof(*ct)) ||
471 put_user(tsize, &ct->u.user.target_size)) 473 put_user(tsize, &ct->u.user.target_size) ||
474 copy_to_user(ct->u.user.name, t->u.kernel.target->name,
475 strlen(t->u.kernel.target->name) + 1))
472 return -EFAULT; 476 return -EFAULT;
473 477
474 if (target->compat_to_user) { 478 if (target->compat_to_user) {
diff --git a/net/netfilter/xt_CONNMARK.c b/net/netfilter/xt_CONNMARK.c
index 856793e8db7a..0621ca7de3b0 100644
--- a/net/netfilter/xt_CONNMARK.c
+++ b/net/netfilter/xt_CONNMARK.c
@@ -86,11 +86,6 @@ checkentry(const char *tablename,
86{ 86{
87 const struct xt_connmark_target_info *matchinfo = targinfo; 87 const struct xt_connmark_target_info *matchinfo = targinfo;
88 88
89 if (nf_ct_l3proto_try_module_get(target->family) < 0) {
90 printk(KERN_WARNING "can't load conntrack support for "
91 "proto=%d\n", target->family);
92 return false;
93 }
94 if (matchinfo->mode == XT_CONNMARK_RESTORE) { 89 if (matchinfo->mode == XT_CONNMARK_RESTORE) {
95 if (strcmp(tablename, "mangle") != 0) { 90 if (strcmp(tablename, "mangle") != 0) {
96 printk(KERN_WARNING "CONNMARK: restore can only be " 91 printk(KERN_WARNING "CONNMARK: restore can only be "
@@ -103,6 +98,11 @@ checkentry(const char *tablename,
103 printk(KERN_WARNING "CONNMARK: Only supports 32bit mark\n"); 98 printk(KERN_WARNING "CONNMARK: Only supports 32bit mark\n");
104 return false; 99 return false;
105 } 100 }
101 if (nf_ct_l3proto_try_module_get(target->family) < 0) {
102 printk(KERN_WARNING "can't load conntrack support for "
103 "proto=%d\n", target->family);
104 return false;
105 }
106 return true; 106 return true;
107} 107}
108 108
diff --git a/net/netfilter/xt_CONNSECMARK.c b/net/netfilter/xt_CONNSECMARK.c
index 021b5c8d20e2..d8feba9bdb48 100644
--- a/net/netfilter/xt_CONNSECMARK.c
+++ b/net/netfilter/xt_CONNSECMARK.c
@@ -90,11 +90,6 @@ static bool checkentry(const char *tablename, const void *entry,
90{ 90{
91 const struct xt_connsecmark_target_info *info = targinfo; 91 const struct xt_connsecmark_target_info *info = targinfo;
92 92
93 if (nf_ct_l3proto_try_module_get(target->family) < 0) {
94 printk(KERN_WARNING "can't load conntrack support for "
95 "proto=%d\n", target->family);
96 return false;
97 }
98 switch (info->mode) { 93 switch (info->mode) {
99 case CONNSECMARK_SAVE: 94 case CONNSECMARK_SAVE:
100 case CONNSECMARK_RESTORE: 95 case CONNSECMARK_RESTORE:
@@ -105,6 +100,11 @@ static bool checkentry(const char *tablename, const void *entry,
105 return false; 100 return false;
106 } 101 }
107 102
103 if (nf_ct_l3proto_try_module_get(target->family) < 0) {
104 printk(KERN_WARNING "can't load conntrack support for "
105 "proto=%d\n", target->family);
106 return false;
107 }
108 return true; 108 return true;
109} 109}
110 110
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index 07435a602b11..8e76d1f52fbe 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -174,10 +174,8 @@ xt_tcpmss_target6(struct sk_buff *skb,
174 174
175 nexthdr = ipv6h->nexthdr; 175 nexthdr = ipv6h->nexthdr;
176 tcphoff = ipv6_skip_exthdr(skb, sizeof(*ipv6h), &nexthdr); 176 tcphoff = ipv6_skip_exthdr(skb, sizeof(*ipv6h), &nexthdr);
177 if (tcphoff < 0) { 177 if (tcphoff < 0)
178 WARN_ON(1);
179 return NF_DROP; 178 return NF_DROP;
180 }
181 ret = tcpmss_mangle_packet(skb, targinfo, tcphoff, 179 ret = tcpmss_mangle_packet(skb, targinfo, tcphoff,
182 sizeof(*ipv6h) + sizeof(struct tcphdr)); 180 sizeof(*ipv6h) + sizeof(struct tcphdr));
183 if (ret < 0) 181 if (ret < 0)
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 19103678bf20..2ef44d8560c1 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -240,7 +240,7 @@ static bool select_all(const struct xt_hashlimit_htable *ht,
240static bool select_gc(const struct xt_hashlimit_htable *ht, 240static bool select_gc(const struct xt_hashlimit_htable *ht,
241 const struct dsthash_ent *he) 241 const struct dsthash_ent *he)
242{ 242{
243 return jiffies >= he->expires; 243 return time_after_eq(jiffies, he->expires);
244} 244}
245 245
246static void htable_selective_cleanup(struct xt_hashlimit_htable *ht, 246static void htable_selective_cleanup(struct xt_hashlimit_htable *ht,
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c
index 0a1f4c6bcdef..d842c4a6d63f 100644
--- a/net/netfilter/xt_helper.c
+++ b/net/netfilter/xt_helper.c
@@ -56,8 +56,8 @@ match(const struct sk_buff *skb,
56 if (info->name[0] == '\0') 56 if (info->name[0] == '\0')
57 ret = !ret; 57 ret = !ret;
58 else 58 else
59 ret ^= !strncmp(master_help->helper->name, info->name, 59 ret ^= !strncmp(helper->name, info->name,
60 strlen(master_help->helper->name)); 60 strlen(helper->name));
61 return ret; 61 return ret;
62} 62}
63 63
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 56483377997a..9c41464d58d1 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -71,7 +71,7 @@ static const struct nla_policy netlbl_mgmt_genl_policy[NLBL_MGMT_A_MAX + 1] = {
71}; 71};
72 72
73/* 73/*
74 * NetLabel Misc Managment Functions 74 * NetLabel Misc Management Functions
75 */ 75 */
76 76
77/** 77/**
diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c
index 8c68da5ef0a1..6caf459665f2 100644
--- a/net/netrom/nr_dev.c
+++ b/net/netrom/nr_dev.c
@@ -56,7 +56,7 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev)
56 56
57 /* Spoof incoming device */ 57 /* Spoof incoming device */
58 skb->dev = dev; 58 skb->dev = dev;
59 skb_reset_mac_header(skb); 59 skb->mac_header = skb->network_header;
60 skb_reset_network_header(skb); 60 skb_reset_network_header(skb);
61 skb->pkt_type = PACKET_HOST; 61 skb->pkt_type = PACKET_HOST;
62 62
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 73d60a307129..d06d338812e9 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -60,11 +60,7 @@ static void rfkill_led_trigger(struct rfkill *rfkill,
60static int rfkill_toggle_radio(struct rfkill *rfkill, 60static int rfkill_toggle_radio(struct rfkill *rfkill,
61 enum rfkill_state state) 61 enum rfkill_state state)
62{ 62{
63 int retval; 63 int retval = 0;
64
65 retval = mutex_lock_interruptible(&rfkill->mutex);
66 if (retval)
67 return retval;
68 64
69 if (state != rfkill->state) { 65 if (state != rfkill->state) {
70 retval = rfkill->toggle_radio(rfkill->data, state); 66 retval = rfkill->toggle_radio(rfkill->data, state);
@@ -74,7 +70,6 @@ static int rfkill_toggle_radio(struct rfkill *rfkill,
74 } 70 }
75 } 71 }
76 72
77 mutex_unlock(&rfkill->mutex);
78 return retval; 73 return retval;
79} 74}
80 75
@@ -158,12 +153,13 @@ static ssize_t rfkill_state_store(struct device *dev,
158 if (!capable(CAP_NET_ADMIN)) 153 if (!capable(CAP_NET_ADMIN))
159 return -EPERM; 154 return -EPERM;
160 155
156 if (mutex_lock_interruptible(&rfkill->mutex))
157 return -ERESTARTSYS;
161 error = rfkill_toggle_radio(rfkill, 158 error = rfkill_toggle_radio(rfkill,
162 state ? RFKILL_STATE_ON : RFKILL_STATE_OFF); 159 state ? RFKILL_STATE_ON : RFKILL_STATE_OFF);
163 if (error) 160 mutex_unlock(&rfkill->mutex);
164 return error;
165 161
166 return count; 162 return error ? error : count;
167} 163}
168 164
169static ssize_t rfkill_claim_show(struct device *dev, 165static ssize_t rfkill_claim_show(struct device *dev,
@@ -396,11 +392,14 @@ int rfkill_register(struct rfkill *rfkill)
396 rfkill_led_trigger_register(rfkill); 392 rfkill_led_trigger_register(rfkill);
397 393
398 error = rfkill_add_switch(rfkill); 394 error = rfkill_add_switch(rfkill);
399 if (error) 395 if (error) {
396 rfkill_led_trigger_unregister(rfkill);
400 return error; 397 return error;
398 }
401 399
402 error = device_add(dev); 400 error = device_add(dev);
403 if (error) { 401 if (error) {
402 rfkill_led_trigger_unregister(rfkill);
404 rfkill_remove_switch(rfkill); 403 rfkill_remove_switch(rfkill);
405 return error; 404 return error;
406 } 405 }
diff --git a/net/rose/rose_dev.c b/net/rose/rose_dev.c
index 1b6741f1d746..12cfcf09556b 100644
--- a/net/rose/rose_dev.c
+++ b/net/rose/rose_dev.c
@@ -55,13 +55,13 @@ static int rose_header(struct sk_buff *skb, struct net_device *dev,
55 55
56static int rose_rebuild_header(struct sk_buff *skb) 56static int rose_rebuild_header(struct sk_buff *skb)
57{ 57{
58#ifdef CONFIG_INET
58 struct net_device *dev = skb->dev; 59 struct net_device *dev = skb->dev;
59 struct net_device_stats *stats = netdev_priv(dev); 60 struct net_device_stats *stats = netdev_priv(dev);
60 unsigned char *bp = (unsigned char *)skb->data; 61 unsigned char *bp = (unsigned char *)skb->data;
61 struct sk_buff *skbn; 62 struct sk_buff *skbn;
62 unsigned int len; 63 unsigned int len;
63 64
64#ifdef CONFIG_INET
65 if (arp_find(bp + 7, skb)) { 65 if (arp_find(bp + 7, skb)) {
66 return 1; 66 return 1;
67 } 67 }
diff --git a/net/rxrpc/Kconfig b/net/rxrpc/Kconfig
index e662f1d07664..0d3103c4f11c 100644
--- a/net/rxrpc/Kconfig
+++ b/net/rxrpc/Kconfig
@@ -5,6 +5,7 @@
5config AF_RXRPC 5config AF_RXRPC
6 tristate "RxRPC session sockets" 6 tristate "RxRPC session sockets"
7 depends on INET && EXPERIMENTAL 7 depends on INET && EXPERIMENTAL
8 select CRYPTO
8 select KEYS 9 select KEYS
9 help 10 help
10 Say Y or M here to include support for RxRPC session sockets (just 11 Say Y or M here to include support for RxRPC session sockets (just
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index e09a95aa68ff..8e69d6993833 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -1021,6 +1021,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn,
1021 1021
1022 abort_code = RXKADINCONSISTENCY; 1022 abort_code = RXKADINCONSISTENCY;
1023 if (version != RXKAD_VERSION) 1023 if (version != RXKAD_VERSION)
1024 goto protocol_error;
1024 1025
1025 abort_code = RXKADTICKETLEN; 1026 abort_code = RXKADTICKETLEN;
1026 if (ticket_len < 4 || ticket_len > MAXKRB5TICKETLEN) 1027 if (ticket_len < 4 || ticket_len > MAXKRB5TICKETLEN)
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 55e7e4530f43..a6ad491e434b 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -160,7 +160,7 @@ struct hfsc_class
160 u64 cl_vtoff; /* inter-period cumulative vt offset */ 160 u64 cl_vtoff; /* inter-period cumulative vt offset */
161 u64 cl_cvtmax; /* max child's vt in the last period */ 161 u64 cl_cvtmax; /* max child's vt in the last period */
162 u64 cl_cvtoff; /* cumulative cvtmax of all periods */ 162 u64 cl_cvtoff; /* cumulative cvtmax of all periods */
163 u64 cl_pcvtoff; /* parent's cvtoff at initalization 163 u64 cl_pcvtoff; /* parent's cvtoff at initialization
164 time */ 164 time */
165 165
166 struct internal_sc cl_rsc; /* internal real-time service curve */ 166 struct internal_sc cl_rsc; /* internal real-time service curve */
diff --git a/net/sctp/Kconfig b/net/sctp/Kconfig
index 8210f549c492..5390bc792159 100644
--- a/net/sctp/Kconfig
+++ b/net/sctp/Kconfig
@@ -6,9 +6,9 @@ menuconfig IP_SCTP
6 tristate "The SCTP Protocol (EXPERIMENTAL)" 6 tristate "The SCTP Protocol (EXPERIMENTAL)"
7 depends on INET && EXPERIMENTAL 7 depends on INET && EXPERIMENTAL
8 depends on IPV6 || IPV6=n 8 depends on IPV6 || IPV6=n
9 select CRYPTO if SCTP_HMAC_SHA1 || SCTP_HMAC_MD5 9 select CRYPTO
10 select CRYPTO_HMAC if SCTP_HMAC_SHA1 || SCTP_HMAC_MD5 10 select CRYPTO_HMAC
11 select CRYPTO_SHA1 if SCTP_HMAC_SHA1 11 select CRYPTO_SHA1
12 select CRYPTO_MD5 if SCTP_HMAC_MD5 12 select CRYPTO_MD5 if SCTP_HMAC_MD5
13 ---help--- 13 ---help---
14 Stream Control Transmission Protocol 14 Stream Control Transmission Protocol
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index 6d5fa6bb371b..97e6ebd14500 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -54,11 +54,13 @@ static struct sctp_hmac sctp_hmac_list[SCTP_AUTH_NUM_HMACS] = {
54 /* id 2 is reserved as well */ 54 /* id 2 is reserved as well */
55 .hmac_id = SCTP_AUTH_HMAC_ID_RESERVED_2, 55 .hmac_id = SCTP_AUTH_HMAC_ID_RESERVED_2,
56 }, 56 },
57#if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE)
57 { 58 {
58 .hmac_id = SCTP_AUTH_HMAC_ID_SHA256, 59 .hmac_id = SCTP_AUTH_HMAC_ID_SHA256,
59 .hmac_name="hmac(sha256)", 60 .hmac_name="hmac(sha256)",
60 .hmac_len = SCTP_SHA256_SIG_SIZE, 61 .hmac_len = SCTP_SHA256_SIG_SIZE,
61 } 62 }
63#endif
62}; 64};
63 65
64 66
@@ -631,7 +633,7 @@ static int __sctp_auth_cid(sctp_cid_t chunk, struct sctp_chunks_param *param)
631 int found = 0; 633 int found = 0;
632 int i; 634 int i;
633 635
634 if (!param) 636 if (!param || param->param_hdr.length == 0)
635 return 0; 637 return 0;
636 638
637 len = ntohs(param->param_hdr.length) - sizeof(sctp_paramhdr_t); 639 len = ntohs(param->param_hdr.length) - sizeof(sctp_paramhdr_t);
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index cae95af9a8cc..6a7d01091f0c 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -105,6 +105,32 @@ out:
105 return error; 105 return error;
106} 106}
107 107
108/* Exactly duplicate the address lists. This is necessary when doing
109 * peer-offs and accepts. We don't want to put all the current system
110 * addresses into the endpoint. That's useless. But we do want duplicat
111 * the list of bound addresses that the older endpoint used.
112 */
113int sctp_bind_addr_dup(struct sctp_bind_addr *dest,
114 const struct sctp_bind_addr *src,
115 gfp_t gfp)
116{
117 struct sctp_sockaddr_entry *addr;
118 struct list_head *pos;
119 int error = 0;
120
121 /* All addresses share the same port. */
122 dest->port = src->port;
123
124 list_for_each(pos, &src->address_list) {
125 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
126 error = sctp_add_bind_addr(dest, &addr->a, 1, gfp);
127 if (error < 0)
128 break;
129 }
130
131 return error;
132}
133
108/* Initialize the SCTP_bind_addr structure for either an endpoint or 134/* Initialize the SCTP_bind_addr structure for either an endpoint or
109 * an association. 135 * an association.
110 */ 136 */
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 5a9783c38de1..3cc629d3c9ff 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -77,6 +77,8 @@ static int sctp_process_param(struct sctp_association *asoc,
77 union sctp_params param, 77 union sctp_params param,
78 const union sctp_addr *peer_addr, 78 const union sctp_addr *peer_addr,
79 gfp_t gfp); 79 gfp_t gfp);
80static void *sctp_addto_param(struct sctp_chunk *chunk, int len,
81 const void *data);
80 82
81/* What was the inbound interface for this chunk? */ 83/* What was the inbound interface for this chunk? */
82int sctp_chunk_iif(const struct sctp_chunk *chunk) 84int sctp_chunk_iif(const struct sctp_chunk *chunk)
@@ -207,11 +209,10 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
207 209
208 chunksize = sizeof(init) + addrs_len + SCTP_SAT_LEN(num_types); 210 chunksize = sizeof(init) + addrs_len + SCTP_SAT_LEN(num_types);
209 chunksize += sizeof(ecap_param); 211 chunksize += sizeof(ecap_param);
210 if (sctp_prsctp_enable) { 212
213 if (sctp_prsctp_enable)
211 chunksize += sizeof(prsctp_param); 214 chunksize += sizeof(prsctp_param);
212 extensions[num_ext] = SCTP_CID_FWD_TSN; 215
213 num_ext += 1;
214 }
215 /* ADDIP: Section 4.2.7: 216 /* ADDIP: Section 4.2.7:
216 * An implementation supporting this extension [ADDIP] MUST list 217 * An implementation supporting this extension [ADDIP] MUST list
217 * the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and 218 * the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and
@@ -243,7 +244,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
243 if (auth_chunks->length) 244 if (auth_chunks->length)
244 chunksize += ntohs(auth_chunks->length); 245 chunksize += ntohs(auth_chunks->length);
245 else 246 else
246 auth_hmacs = NULL; 247 auth_chunks = NULL;
247 248
248 extensions[num_ext] = SCTP_CID_AUTH; 249 extensions[num_ext] = SCTP_CID_AUTH;
249 num_ext += 1; 250 num_ext += 1;
@@ -288,7 +289,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
288 289
289 sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param); 290 sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param);
290 291
291 /* Add the supported extensions paramter. Be nice and add this 292 /* Add the supported extensions parameter. Be nice and add this
292 * fist before addiding the parameters for the extensions themselves 293 * fist before addiding the parameters for the extensions themselves
293 */ 294 */
294 if (num_ext) { 295 if (num_ext) {
@@ -297,7 +298,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
297 htons(sizeof(sctp_supported_ext_param_t) + num_ext); 298 htons(sizeof(sctp_supported_ext_param_t) + num_ext);
298 sctp_addto_chunk(retval, sizeof(sctp_supported_ext_param_t), 299 sctp_addto_chunk(retval, sizeof(sctp_supported_ext_param_t),
299 &ext_param); 300 &ext_param);
300 sctp_addto_chunk(retval, num_ext, extensions); 301 sctp_addto_param(retval, num_ext, extensions);
301 } 302 }
302 303
303 if (sctp_prsctp_enable) 304 if (sctp_prsctp_enable)
@@ -371,12 +372,8 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
371 if (asoc->peer.ecn_capable) 372 if (asoc->peer.ecn_capable)
372 chunksize += sizeof(ecap_param); 373 chunksize += sizeof(ecap_param);
373 374
374 /* Tell peer that we'll do PR-SCTP only if peer advertised. */ 375 if (sctp_prsctp_enable)
375 if (asoc->peer.prsctp_capable) {
376 chunksize += sizeof(prsctp_param); 376 chunksize += sizeof(prsctp_param);
377 extensions[num_ext] = SCTP_CID_FWD_TSN;
378 num_ext += 1;
379 }
380 377
381 if (sctp_addip_enable) { 378 if (sctp_addip_enable) {
382 extensions[num_ext] = SCTP_CID_ASCONF; 379 extensions[num_ext] = SCTP_CID_ASCONF;
@@ -384,7 +381,6 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
384 num_ext += 2; 381 num_ext += 2;
385 } 382 }
386 383
387 chunksize += sizeof(ext_param) + num_ext;
388 chunksize += sizeof(aiparam); 384 chunksize += sizeof(aiparam);
389 385
390 if (asoc->peer.auth_capable) { 386 if (asoc->peer.auth_capable) {
@@ -407,6 +403,9 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
407 num_ext += 1; 403 num_ext += 1;
408 } 404 }
409 405
406 if (num_ext)
407 chunksize += sizeof(sctp_supported_ext_param_t) + num_ext;
408
410 /* Now allocate and fill out the chunk. */ 409 /* Now allocate and fill out the chunk. */
411 retval = sctp_make_chunk(asoc, SCTP_CID_INIT_ACK, 0, chunksize); 410 retval = sctp_make_chunk(asoc, SCTP_CID_INIT_ACK, 0, chunksize);
412 if (!retval) 411 if (!retval)
@@ -428,7 +427,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
428 htons(sizeof(sctp_supported_ext_param_t) + num_ext); 427 htons(sizeof(sctp_supported_ext_param_t) + num_ext);
429 sctp_addto_chunk(retval, sizeof(sctp_supported_ext_param_t), 428 sctp_addto_chunk(retval, sizeof(sctp_supported_ext_param_t),
430 &ext_param); 429 &ext_param);
431 sctp_addto_chunk(retval, num_ext, extensions); 430 sctp_addto_param(retval, num_ext, extensions);
432 } 431 }
433 if (asoc->peer.prsctp_capable) 432 if (asoc->peer.prsctp_capable)
434 sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); 433 sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param);
@@ -2866,7 +2865,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
2866 chunk_len -= length; 2865 chunk_len -= length;
2867 2866
2868 /* Skip the address parameter and store a pointer to the first 2867 /* Skip the address parameter and store a pointer to the first
2869 * asconf paramter. 2868 * asconf parameter.
2870 */ 2869 */
2871 length = ntohs(addr_param->v4.param_hdr.length); 2870 length = ntohs(addr_param->v4.param_hdr.length);
2872 asconf_param = (sctp_addip_param_t *)((void *)addr_param + length); 2871 asconf_param = (sctp_addip_param_t *)((void *)addr_param + length);
@@ -2875,7 +2874,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
2875 /* create an ASCONF_ACK chunk. 2874 /* create an ASCONF_ACK chunk.
2876 * Based on the definitions of parameters, we know that the size of 2875 * Based on the definitions of parameters, we know that the size of
2877 * ASCONF_ACK parameters are less than or equal to the twice of ASCONF 2876 * ASCONF_ACK parameters are less than or equal to the twice of ASCONF
2878 * paramters. 2877 * parameters.
2879 */ 2878 */
2880 asconf_ack = sctp_make_asconf_ack(asoc, serial, chunk_len * 2); 2879 asconf_ack = sctp_make_asconf_ack(asoc, serial, chunk_len * 2);
2881 if (!asconf_ack) 2880 if (!asconf_ack)
@@ -3069,7 +3068,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
3069 asconf_len -= length; 3068 asconf_len -= length;
3070 3069
3071 /* Skip the address parameter in the last asconf sent and store a 3070 /* Skip the address parameter in the last asconf sent and store a
3072 * pointer to the first asconf paramter. 3071 * pointer to the first asconf parameter.
3073 */ 3072 */
3074 length = ntohs(addr_param->v4.param_hdr.length); 3073 length = ntohs(addr_param->v4.param_hdr.length);
3075 asconf_param = (sctp_addip_param_t *)((void *)addr_param + length); 3074 asconf_param = (sctp_addip_param_t *)((void *)addr_param + length);
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 5ebbe808d801..d247ed4ee423 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -959,7 +959,7 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep,
959{ 959{
960 struct sctp_transport *transport = (struct sctp_transport *) arg; 960 struct sctp_transport *transport = (struct sctp_transport *) arg;
961 961
962 if (asoc->overall_error_count >= asoc->max_retrans) { 962 if (asoc->overall_error_count > asoc->max_retrans) {
963 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 963 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
964 SCTP_ERROR(ETIMEDOUT)); 964 SCTP_ERROR(ETIMEDOUT));
965 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 965 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
@@ -1146,7 +1146,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep,
1146 /* Check if the timestamp looks valid. */ 1146 /* Check if the timestamp looks valid. */
1147 if (time_after(hbinfo->sent_at, jiffies) || 1147 if (time_after(hbinfo->sent_at, jiffies) ||
1148 time_after(jiffies, hbinfo->sent_at + max_interval)) { 1148 time_after(jiffies, hbinfo->sent_at + max_interval)) {
1149 SCTP_DEBUG_PRINTK("%s: HEARTBEAT ACK with invalid timestamp" 1149 SCTP_DEBUG_PRINTK("%s: HEARTBEAT ACK with invalid timestamp "
1150 "received for transport: %p\n", 1150 "received for transport: %p\n",
1151 __FUNCTION__, link); 1151 __FUNCTION__, link);
1152 return SCTP_DISPOSITION_DISCARD; 1152 return SCTP_DISPOSITION_DISCARD;
@@ -1309,26 +1309,6 @@ static void sctp_tietags_populate(struct sctp_association *new_asoc,
1309 new_asoc->c.initial_tsn = asoc->c.initial_tsn; 1309 new_asoc->c.initial_tsn = asoc->c.initial_tsn;
1310} 1310}
1311 1311
1312static void sctp_auth_params_populate(struct sctp_association *new_asoc,
1313 const struct sctp_association *asoc)
1314{
1315 /* Only perform this if AUTH extension is enabled */
1316 if (!sctp_auth_enable)
1317 return;
1318
1319 /* We need to provide the same parameter information as
1320 * was in the original INIT. This means that we need to copy
1321 * the HMACS, CHUNKS, and RANDOM parameter from the original
1322 * assocaition.
1323 */
1324 memcpy(new_asoc->c.auth_random, asoc->c.auth_random,
1325 sizeof(asoc->c.auth_random));
1326 memcpy(new_asoc->c.auth_hmacs, asoc->c.auth_hmacs,
1327 sizeof(asoc->c.auth_hmacs));
1328 memcpy(new_asoc->c.auth_chunks, asoc->c.auth_chunks,
1329 sizeof(asoc->c.auth_chunks));
1330}
1331
1332/* 1312/*
1333 * Compare vtag/tietag values to determine unexpected COOKIE-ECHO 1313 * Compare vtag/tietag values to determine unexpected COOKIE-ECHO
1334 * handling action. 1314 * handling action.
@@ -1486,8 +1466,6 @@ static sctp_disposition_t sctp_sf_do_unexpected_init(
1486 1466
1487 sctp_tietags_populate(new_asoc, asoc); 1467 sctp_tietags_populate(new_asoc, asoc);
1488 1468
1489 sctp_auth_params_populate(new_asoc, asoc);
1490
1491 /* B) "Z" shall respond immediately with an INIT ACK chunk. */ 1469 /* B) "Z" shall respond immediately with an INIT ACK chunk. */
1492 1470
1493 /* If there are errors need to be reported for unknown parameters, 1471 /* If there are errors need to be reported for unknown parameters,
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index ff8bc95670ed..ea9649ca0b2a 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -6325,7 +6325,7 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
6325 struct sctp_endpoint *newep = newsp->ep; 6325 struct sctp_endpoint *newep = newsp->ep;
6326 struct sk_buff *skb, *tmp; 6326 struct sk_buff *skb, *tmp;
6327 struct sctp_ulpevent *event; 6327 struct sctp_ulpevent *event;
6328 int flags = 0; 6328 struct sctp_bind_hashbucket *head;
6329 6329
6330 /* Migrate socket buffer sizes and all the socket level options to the 6330 /* Migrate socket buffer sizes and all the socket level options to the
6331 * new socket. 6331 * new socket.
@@ -6342,23 +6342,21 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
6342 newsp->hmac = NULL; 6342 newsp->hmac = NULL;
6343 6343
6344 /* Hook this new socket in to the bind_hash list. */ 6344 /* Hook this new socket in to the bind_hash list. */
6345 head = &sctp_port_hashtable[sctp_phashfn(inet_sk(oldsk)->num)];
6346 sctp_local_bh_disable();
6347 sctp_spin_lock(&head->lock);
6345 pp = sctp_sk(oldsk)->bind_hash; 6348 pp = sctp_sk(oldsk)->bind_hash;
6346 sk_add_bind_node(newsk, &pp->owner); 6349 sk_add_bind_node(newsk, &pp->owner);
6347 sctp_sk(newsk)->bind_hash = pp; 6350 sctp_sk(newsk)->bind_hash = pp;
6348 inet_sk(newsk)->num = inet_sk(oldsk)->num; 6351 inet_sk(newsk)->num = inet_sk(oldsk)->num;
6352 sctp_spin_unlock(&head->lock);
6353 sctp_local_bh_enable();
6349 6354
6350 /* Copy the bind_addr list from the original endpoint to the new 6355 /* Copy the bind_addr list from the original endpoint to the new
6351 * endpoint so that we can handle restarts properly 6356 * endpoint so that we can handle restarts properly
6352 */ 6357 */
6353 if (PF_INET6 == assoc->base.sk->sk_family) 6358 sctp_bind_addr_dup(&newsp->ep->base.bind_addr,
6354 flags = SCTP_ADDR6_ALLOWED; 6359 &oldsp->ep->base.bind_addr, GFP_KERNEL);
6355 if (assoc->peer.ipv4_address)
6356 flags |= SCTP_ADDR4_PEERSUPP;
6357 if (assoc->peer.ipv6_address)
6358 flags |= SCTP_ADDR6_PEERSUPP;
6359 sctp_bind_addr_copy(&newsp->ep->base.bind_addr,
6360 &oldsp->ep->base.bind_addr,
6361 SCTP_SCOPE_GLOBAL, GFP_KERNEL, flags);
6362 6360
6363 /* Move any messages in the old socket's receive queue that are for the 6361 /* Move any messages in the old socket's receive queue that are for the
6364 * peeled off association to the new socket's receive queue. 6362 * peeled off association to the new socket's receive queue.
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index 2c17c7efad46..307314356e16 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -830,7 +830,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_authkey(
830 ak = (struct sctp_authkey_event *) 830 ak = (struct sctp_authkey_event *)
831 skb_put(skb, sizeof(struct sctp_authkey_event)); 831 skb_put(skb, sizeof(struct sctp_authkey_event));
832 832
833 ak->auth_type = SCTP_AUTHENTICATION_EVENT; 833 ak->auth_type = SCTP_AUTHENTICATION_INDICATION;
834 ak->auth_flags = 0; 834 ak->auth_flags = 0;
835 ak->auth_length = sizeof(struct sctp_authkey_event); 835 ak->auth_length = sizeof(struct sctp_authkey_event);
836 836
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 4908041ffb31..1733fa29a501 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -53,6 +53,7 @@ static struct sctp_ulpevent * sctp_ulpq_reasm(struct sctp_ulpq *ulpq,
53 struct sctp_ulpevent *); 53 struct sctp_ulpevent *);
54static struct sctp_ulpevent * sctp_ulpq_order(struct sctp_ulpq *, 54static struct sctp_ulpevent * sctp_ulpq_order(struct sctp_ulpq *,
55 struct sctp_ulpevent *); 55 struct sctp_ulpevent *);
56static void sctp_ulpq_reasm_drain(struct sctp_ulpq *ulpq);
56 57
57/* 1st Level Abstractions */ 58/* 1st Level Abstractions */
58 59
@@ -190,6 +191,7 @@ static void sctp_ulpq_set_pd(struct sctp_ulpq *ulpq)
190static int sctp_ulpq_clear_pd(struct sctp_ulpq *ulpq) 191static int sctp_ulpq_clear_pd(struct sctp_ulpq *ulpq)
191{ 192{
192 ulpq->pd_mode = 0; 193 ulpq->pd_mode = 0;
194 sctp_ulpq_reasm_drain(ulpq);
193 return sctp_clear_pd(ulpq->asoc->base.sk, ulpq->asoc); 195 return sctp_clear_pd(ulpq->asoc->base.sk, ulpq->asoc);
194} 196}
195 197
@@ -699,6 +701,37 @@ void sctp_ulpq_reasm_flushtsn(struct sctp_ulpq *ulpq, __u32 fwd_tsn)
699 } 701 }
700} 702}
701 703
704/*
705 * Drain the reassembly queue. If we just cleared parted delivery, it
706 * is possible that the reassembly queue will contain already reassembled
707 * messages. Retrieve any such messages and give them to the user.
708 */
709static void sctp_ulpq_reasm_drain(struct sctp_ulpq *ulpq)
710{
711 struct sctp_ulpevent *event = NULL;
712 struct sk_buff_head temp;
713
714 if (skb_queue_empty(&ulpq->reasm))
715 return;
716
717 while ((event = sctp_ulpq_retrieve_reassembled(ulpq)) != NULL) {
718 /* Do ordering if needed. */
719 if ((event) && (event->msg_flags & MSG_EOR)){
720 skb_queue_head_init(&temp);
721 __skb_queue_tail(&temp, sctp_event2skb(event));
722
723 event = sctp_ulpq_order(ulpq, event);
724 }
725
726 /* Send event to the ULP. 'event' is the
727 * sctp_ulpevent for very first SKB on the temp' list.
728 */
729 if (event)
730 sctp_ulpq_tail_event(ulpq, event);
731 }
732}
733
734
702/* Helper function to gather skbs that have possibly become 735/* Helper function to gather skbs that have possibly become
703 * ordered by an an incoming chunk. 736 * ordered by an an incoming chunk.
704 */ 737 */
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 53995af9ca4b..1f2d85e869c0 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -540,7 +540,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
540 p = gss_fill_context(p, end, ctx, gss_msg->auth->mech); 540 p = gss_fill_context(p, end, ctx, gss_msg->auth->mech);
541 if (IS_ERR(p)) { 541 if (IS_ERR(p)) {
542 err = PTR_ERR(p); 542 err = PTR_ERR(p);
543 gss_msg->msg.errno = (err == -EACCES) ? -EACCES : -EAGAIN; 543 gss_msg->msg.errno = (err == -EAGAIN) ? -EAGAIN : -EACCES;
544 goto err_release_msg; 544 goto err_release_msg;
545 } 545 }
546 gss_msg->ctx = gss_get_ctx(ctx); 546 gss_msg->ctx = gss_get_ctx(ctx);
@@ -625,7 +625,7 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
625 err = -EINVAL; 625 err = -EINVAL;
626 gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor); 626 gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor);
627 if (!gss_auth->mech) { 627 if (!gss_auth->mech) {
628 printk(KERN_WARNING "%s: Pseudoflavor %d not found!", 628 printk(KERN_WARNING "%s: Pseudoflavor %d not found!\n",
629 __FUNCTION__, flavor); 629 __FUNCTION__, flavor);
630 goto err_free; 630 goto err_free;
631 } 631 }
@@ -967,7 +967,7 @@ gss_validate(struct rpc_task *task, __be32 *p)
967 if (maj_stat == GSS_S_CONTEXT_EXPIRED) 967 if (maj_stat == GSS_S_CONTEXT_EXPIRED)
968 clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); 968 clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags);
969 if (maj_stat) { 969 if (maj_stat) {
970 dprintk("RPC: %5u gss_validate: gss_verify_mic returned" 970 dprintk("RPC: %5u gss_validate: gss_verify_mic returned "
971 "error 0x%08x\n", task->tk_pid, maj_stat); 971 "error 0x%08x\n", task->tk_pid, maj_stat);
972 goto out_bad; 972 goto out_bad;
973 } 973 }
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c
index 9843eacef11d..60c3dba545d7 100644
--- a/net/sunrpc/auth_gss/gss_krb5_mech.c
+++ b/net/sunrpc/auth_gss/gss_krb5_mech.c
@@ -147,13 +147,17 @@ gss_import_sec_context_kerberos(const void *p,
147 p = simple_get_bytes(p, end, &tmp, sizeof(tmp)); 147 p = simple_get_bytes(p, end, &tmp, sizeof(tmp));
148 if (IS_ERR(p)) 148 if (IS_ERR(p))
149 goto out_err_free_ctx; 149 goto out_err_free_ctx;
150 if (tmp != SGN_ALG_DES_MAC_MD5) 150 if (tmp != SGN_ALG_DES_MAC_MD5) {
151 p = ERR_PTR(-ENOSYS);
151 goto out_err_free_ctx; 152 goto out_err_free_ctx;
153 }
152 p = simple_get_bytes(p, end, &tmp, sizeof(tmp)); 154 p = simple_get_bytes(p, end, &tmp, sizeof(tmp));
153 if (IS_ERR(p)) 155 if (IS_ERR(p))
154 goto out_err_free_ctx; 156 goto out_err_free_ctx;
155 if (tmp != SEAL_ALG_DES) 157 if (tmp != SEAL_ALG_DES) {
158 p = ERR_PTR(-ENOSYS);
156 goto out_err_free_ctx; 159 goto out_err_free_ctx;
160 }
157 p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); 161 p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime));
158 if (IS_ERR(p)) 162 if (IS_ERR(p))
159 goto out_err_free_ctx; 163 goto out_err_free_ctx;
diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c
index 1c6eda5077c1..dedcbd6108f4 100644
--- a/net/sunrpc/auth_gss/gss_krb5_seal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
@@ -83,6 +83,7 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
83 u32 seq_send; 83 u32 seq_send;
84 84
85 dprintk("RPC: gss_krb5_seal\n"); 85 dprintk("RPC: gss_krb5_seal\n");
86 BUG_ON(ctx == NULL);
86 87
87 now = get_seconds(); 88 now = get_seconds();
88 89
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 18f0a8dcc095..c59f3ca2b41b 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -280,7 +280,7 @@ rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
280 mask = POLLOUT | POLLWRNORM; 280 mask = POLLOUT | POLLWRNORM;
281 if (rpci->ops == NULL) 281 if (rpci->ops == NULL)
282 mask |= POLLERR | POLLHUP; 282 mask |= POLLERR | POLLHUP;
283 if (!list_empty(&rpci->pipe)) 283 if (filp->private_data || !list_empty(&rpci->pipe))
284 mask |= POLLIN | POLLRDNORM; 284 mask |= POLLIN | POLLRDNORM;
285 return mask; 285 return mask;
286} 286}
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 282a9a2ec90c..cd641c8634f0 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -62,7 +62,7 @@ static inline void do_xprt_reserve(struct rpc_task *);
62static void xprt_connect_status(struct rpc_task *task); 62static void xprt_connect_status(struct rpc_task *task);
63static int __xprt_get_cong(struct rpc_xprt *, struct rpc_task *); 63static int __xprt_get_cong(struct rpc_xprt *, struct rpc_task *);
64 64
65static spinlock_t xprt_list_lock = SPIN_LOCK_UNLOCKED; 65static DEFINE_SPINLOCK(xprt_list_lock);
66static LIST_HEAD(xprt_list); 66static LIST_HEAD(xprt_list);
67 67
68/* 68/*
diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
index 9e11ce715958..ee8de7af2a5b 100644
--- a/net/sunrpc/xprtrdma/rpc_rdma.c
+++ b/net/sunrpc/xprtrdma/rpc_rdma.c
@@ -92,7 +92,6 @@ rpcrdma_convert_iovs(struct xdr_buf *xdrbuf, int pos,
92 seg[n].mr_page = NULL; 92 seg[n].mr_page = NULL;
93 seg[n].mr_offset = xdrbuf->head[0].iov_base; 93 seg[n].mr_offset = xdrbuf->head[0].iov_base;
94 seg[n].mr_len = xdrbuf->head[0].iov_len; 94 seg[n].mr_len = xdrbuf->head[0].iov_len;
95 pos += xdrbuf->head[0].iov_len;
96 ++n; 95 ++n;
97 } 96 }
98 97
@@ -104,7 +103,6 @@ rpcrdma_convert_iovs(struct xdr_buf *xdrbuf, int pos,
104 seg[n].mr_len = min_t(u32, 103 seg[n].mr_len = min_t(u32,
105 PAGE_SIZE - xdrbuf->page_base, xdrbuf->page_len); 104 PAGE_SIZE - xdrbuf->page_base, xdrbuf->page_len);
106 len = xdrbuf->page_len - seg[n].mr_len; 105 len = xdrbuf->page_len - seg[n].mr_len;
107 pos += len;
108 ++n; 106 ++n;
109 p = 1; 107 p = 1;
110 while (len > 0) { 108 while (len > 0) {
@@ -119,20 +117,15 @@ rpcrdma_convert_iovs(struct xdr_buf *xdrbuf, int pos,
119 } 117 }
120 } 118 }
121 119
122 if (pos < xdrbuf->len && xdrbuf->tail[0].iov_len) { 120 if (xdrbuf->tail[0].iov_len) {
123 if (n == nsegs) 121 if (n == nsegs)
124 return 0; 122 return 0;
125 seg[n].mr_page = NULL; 123 seg[n].mr_page = NULL;
126 seg[n].mr_offset = xdrbuf->tail[0].iov_base; 124 seg[n].mr_offset = xdrbuf->tail[0].iov_base;
127 seg[n].mr_len = xdrbuf->tail[0].iov_len; 125 seg[n].mr_len = xdrbuf->tail[0].iov_len;
128 pos += xdrbuf->tail[0].iov_len;
129 ++n; 126 ++n;
130 } 127 }
131 128
132 if (pos < xdrbuf->len)
133 dprintk("RPC: %s: marshaled only %d of %d\n",
134 __func__, pos, xdrbuf->len);
135
136 return n; 129 return n;
137} 130}
138 131
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 1afeb3eb8e4c..6f2112dd9f78 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -89,7 +89,7 @@ static struct ctl_table_header *sunrpc_table_header;
89 89
90static ctl_table xr_tunables_table[] = { 90static ctl_table xr_tunables_table[] = {
91 { 91 {
92 .ctl_name = CTL_SLOTTABLE_RDMA, 92 .ctl_name = CTL_UNNUMBERED,
93 .procname = "rdma_slot_table_entries", 93 .procname = "rdma_slot_table_entries",
94 .data = &xprt_rdma_slot_table_entries, 94 .data = &xprt_rdma_slot_table_entries,
95 .maxlen = sizeof(unsigned int), 95 .maxlen = sizeof(unsigned int),
@@ -100,7 +100,7 @@ static ctl_table xr_tunables_table[] = {
100 .extra2 = &max_slot_table_size 100 .extra2 = &max_slot_table_size
101 }, 101 },
102 { 102 {
103 .ctl_name = CTL_RDMA_MAXINLINEREAD, 103 .ctl_name = CTL_UNNUMBERED,
104 .procname = "rdma_max_inline_read", 104 .procname = "rdma_max_inline_read",
105 .data = &xprt_rdma_max_inline_read, 105 .data = &xprt_rdma_max_inline_read,
106 .maxlen = sizeof(unsigned int), 106 .maxlen = sizeof(unsigned int),
@@ -109,7 +109,7 @@ static ctl_table xr_tunables_table[] = {
109 .strategy = &sysctl_intvec, 109 .strategy = &sysctl_intvec,
110 }, 110 },
111 { 111 {
112 .ctl_name = CTL_RDMA_MAXINLINEWRITE, 112 .ctl_name = CTL_UNNUMBERED,
113 .procname = "rdma_max_inline_write", 113 .procname = "rdma_max_inline_write",
114 .data = &xprt_rdma_max_inline_write, 114 .data = &xprt_rdma_max_inline_write,
115 .maxlen = sizeof(unsigned int), 115 .maxlen = sizeof(unsigned int),
@@ -118,7 +118,7 @@ static ctl_table xr_tunables_table[] = {
118 .strategy = &sysctl_intvec, 118 .strategy = &sysctl_intvec,
119 }, 119 },
120 { 120 {
121 .ctl_name = CTL_RDMA_WRITEPADDING, 121 .ctl_name = CTL_UNNUMBERED,
122 .procname = "rdma_inline_write_padding", 122 .procname = "rdma_inline_write_padding",
123 .data = &xprt_rdma_inline_write_padding, 123 .data = &xprt_rdma_inline_write_padding,
124 .maxlen = sizeof(unsigned int), 124 .maxlen = sizeof(unsigned int),
@@ -129,7 +129,7 @@ static ctl_table xr_tunables_table[] = {
129 .extra2 = &max_padding, 129 .extra2 = &max_padding,
130 }, 130 },
131 { 131 {
132 .ctl_name = CTL_RDMA_MEMREG, 132 .ctl_name = CTL_UNNUMBERED,
133 .procname = "rdma_memreg_strategy", 133 .procname = "rdma_memreg_strategy",
134 .data = &xprt_rdma_memreg_strategy, 134 .data = &xprt_rdma_memreg_strategy,
135 .maxlen = sizeof(unsigned int), 135 .maxlen = sizeof(unsigned int),
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 02298f529dad..2f630a512ab7 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1828,7 +1828,7 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args,
1828 * @args: rpc transport creation arguments 1828 * @args: rpc transport creation arguments
1829 * 1829 *
1830 */ 1830 */
1831struct rpc_xprt *xs_setup_udp(struct xprt_create *args) 1831static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
1832{ 1832{
1833 struct sockaddr *addr = args->dstaddr; 1833 struct sockaddr *addr = args->dstaddr;
1834 struct rpc_xprt *xprt; 1834 struct rpc_xprt *xprt;
@@ -1894,7 +1894,7 @@ struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
1894 * @args: rpc transport creation arguments 1894 * @args: rpc transport creation arguments
1895 * 1895 *
1896 */ 1896 */
1897struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) 1897static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
1898{ 1898{
1899 struct sockaddr *addr = args->dstaddr; 1899 struct sockaddr *addr = args->dstaddr;
1900 struct rpc_xprt *xprt; 1900 struct rpc_xprt *xprt;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 6b792265dc06..24ddfd2ca38b 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -253,7 +253,7 @@ static int release(struct socket *sock)
253 dbg("sock_delete: %x\n",tsock); 253 dbg("sock_delete: %x\n",tsock);
254 if (!tsock) 254 if (!tsock)
255 return 0; 255 return 0;
256 down_interruptible(&tsock->sem); 256 down(&tsock->sem);
257 if (!sock->sk) { 257 if (!sock->sk) {
258 up(&tsock->sem); 258 up(&tsock->sem);
259 return 0; 259 return 0;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e835da8fc091..060bba4567d2 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1637,8 +1637,15 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
1637 mutex_lock(&u->readlock); 1637 mutex_lock(&u->readlock);
1638 1638
1639 skb = skb_recv_datagram(sk, flags, noblock, &err); 1639 skb = skb_recv_datagram(sk, flags, noblock, &err);
1640 if (!skb) 1640 if (!skb) {
1641 unix_state_lock(sk);
1642 /* Signal EOF on disconnected non-blocking SEQPACKET socket. */
1643 if (sk->sk_type == SOCK_SEQPACKET && err == -EAGAIN &&
1644 (sk->sk_shutdown & RCV_SHUTDOWN))
1645 err = 0;
1646 unix_state_unlock(sk);
1641 goto out_unlock; 1647 goto out_unlock;
1648 }
1642 1649
1643 wake_up_interruptible_sync(&u->peer_wait); 1650 wake_up_interruptible_sync(&u->peer_wait);
1644 1651
diff --git a/net/wireless/wext.c b/net/wireless/wext.c
index 85e5f9dd0d8e..47e80cc2077c 100644
--- a/net/wireless/wext.c
+++ b/net/wireless/wext.c
@@ -1094,7 +1094,7 @@ int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
1094 rtnl_lock(); 1094 rtnl_lock();
1095 ret = wireless_process_ioctl(net, ifr, cmd); 1095 ret = wireless_process_ioctl(net, ifr, cmd);
1096 rtnl_unlock(); 1096 rtnl_unlock();
1097 if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq))) 1097 if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct iwreq)))
1098 return -EFAULT; 1098 return -EFAULT;
1099 return ret; 1099 return ret;
1100} 1100}
diff --git a/net/x25/x25_forward.c b/net/x25/x25_forward.c
index 8738ec7ce693..34478035e05e 100644
--- a/net/x25/x25_forward.c
+++ b/net/x25/x25_forward.c
@@ -118,13 +118,14 @@ int x25_forward_data(int lci, struct x25_neigh *from, struct sk_buff *skb) {
118 goto out; 118 goto out;
119 119
120 if ( (skbn = pskb_copy(skb, GFP_ATOMIC)) == NULL){ 120 if ( (skbn = pskb_copy(skb, GFP_ATOMIC)) == NULL){
121 goto out; 121 goto output;
122 122
123 } 123 }
124 x25_transmit_link(skbn, nb); 124 x25_transmit_link(skbn, nb);
125 125
126 x25_neigh_put(nb);
127 rc = 1; 126 rc = 1;
127output:
128 x25_neigh_put(nb);
128out: 129out:
129 return rc; 130 return rc;
130} 131}
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index b702bd8a3893..26b846e11bfb 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1318,8 +1318,9 @@ restart:
1318 1318
1319 if (sk && sk->sk_policy[XFRM_POLICY_OUT]) { 1319 if (sk && sk->sk_policy[XFRM_POLICY_OUT]) {
1320 policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl); 1320 policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl);
1321 err = PTR_ERR(policy);
1321 if (IS_ERR(policy)) 1322 if (IS_ERR(policy))
1322 return PTR_ERR(policy); 1323 goto dropdst;
1323 } 1324 }
1324 1325
1325 if (!policy) { 1326 if (!policy) {
@@ -1330,8 +1331,9 @@ restart:
1330 1331
1331 policy = flow_cache_lookup(fl, dst_orig->ops->family, 1332 policy = flow_cache_lookup(fl, dst_orig->ops->family,
1332 dir, xfrm_policy_lookup); 1333 dir, xfrm_policy_lookup);
1334 err = PTR_ERR(policy);
1333 if (IS_ERR(policy)) 1335 if (IS_ERR(policy))
1334 return PTR_ERR(policy); 1336 goto dropdst;
1335 } 1337 }
1336 1338
1337 if (!policy) 1339 if (!policy)
@@ -1344,6 +1346,7 @@ restart:
1344 xfrm_nr += pols[0]->xfrm_nr; 1346 xfrm_nr += pols[0]->xfrm_nr;
1345 1347
1346 switch (policy->action) { 1348 switch (policy->action) {
1349 default:
1347 case XFRM_POLICY_BLOCK: 1350 case XFRM_POLICY_BLOCK:
1348 /* Prohibit the flow */ 1351 /* Prohibit the flow */
1349 err = -EPERM; 1352 err = -EPERM;
@@ -1500,8 +1503,9 @@ restart:
1500 return 0; 1503 return 0;
1501 1504
1502error: 1505error:
1503 dst_release(dst_orig);
1504 xfrm_pols_put(pols, npols); 1506 xfrm_pols_put(pols, npols);
1507dropdst:
1508 dst_release(dst_orig);
1505 *dst_p = NULL; 1509 *dst_p = NULL;
1506 return err; 1510 return err;
1507} 1511}
@@ -2158,7 +2162,7 @@ xfrm_audit_policy_add(struct xfrm_policy *xp, int result, u32 auid, u32 sid)
2158 2162
2159 if (audit_enabled == 0) 2163 if (audit_enabled == 0)
2160 return; 2164 return;
2161 audit_buf = xfrm_audit_start(sid, auid); 2165 audit_buf = xfrm_audit_start(auid, sid);
2162 if (audit_buf == NULL) 2166 if (audit_buf == NULL)
2163 return; 2167 return;
2164 audit_log_format(audit_buf, " op=SPD-add res=%u", result); 2168 audit_log_format(audit_buf, " op=SPD-add res=%u", result);
@@ -2175,7 +2179,7 @@ xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, u32 auid, u32 sid)
2175 2179
2176 if (audit_enabled == 0) 2180 if (audit_enabled == 0)
2177 return; 2181 return;
2178 audit_buf = xfrm_audit_start(sid, auid); 2182 audit_buf = xfrm_audit_start(auid, sid);
2179 if (audit_buf == NULL) 2183 if (audit_buf == NULL)
2180 return; 2184 return;
2181 audit_log_format(audit_buf, " op=SPD-delete res=%u", result); 2185 audit_log_format(audit_buf, " op=SPD-delete res=%u", result);
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 224b44e31a07..f26aaaca1fae 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -552,7 +552,7 @@ int __xfrm_state_delete(struct xfrm_state *x)
552 * The xfrm_state_alloc call gives a reference, and that 552 * The xfrm_state_alloc call gives a reference, and that
553 * is what we are dropping here. 553 * is what we are dropping here.
554 */ 554 */
555 __xfrm_state_put(x); 555 xfrm_state_put(x);
556 err = 0; 556 err = 0;
557 } 557 }
558 558
@@ -1749,6 +1749,7 @@ void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 pid)
1749} 1749}
1750EXPORT_SYMBOL(km_policy_expired); 1750EXPORT_SYMBOL(km_policy_expired);
1751 1751
1752#ifdef CONFIG_XFRM_MIGRATE
1752int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1753int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
1753 struct xfrm_migrate *m, int num_migrate) 1754 struct xfrm_migrate *m, int num_migrate)
1754{ 1755{
@@ -1768,6 +1769,7 @@ int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
1768 return err; 1769 return err;
1769} 1770}
1770EXPORT_SYMBOL(km_migrate); 1771EXPORT_SYMBOL(km_migrate);
1772#endif
1771 1773
1772int km_report(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr) 1774int km_report(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr)
1773{ 1775{
@@ -2028,17 +2030,18 @@ void
2028xfrm_audit_state_add(struct xfrm_state *x, int result, u32 auid, u32 sid) 2030xfrm_audit_state_add(struct xfrm_state *x, int result, u32 auid, u32 sid)
2029{ 2031{
2030 struct audit_buffer *audit_buf; 2032 struct audit_buffer *audit_buf;
2033 u32 spi;
2031 extern int audit_enabled; 2034 extern int audit_enabled;
2032 2035
2033 if (audit_enabled == 0) 2036 if (audit_enabled == 0)
2034 return; 2037 return;
2035 audit_buf = xfrm_audit_start(sid, auid); 2038 audit_buf = xfrm_audit_start(auid, sid);
2036 if (audit_buf == NULL) 2039 if (audit_buf == NULL)
2037 return; 2040 return;
2038 audit_log_format(audit_buf, " op=SAD-add res=%u",result); 2041 audit_log_format(audit_buf, " op=SAD-add res=%u",result);
2039 xfrm_audit_common_stateinfo(x, audit_buf); 2042 xfrm_audit_common_stateinfo(x, audit_buf);
2040 audit_log_format(audit_buf, " spi=%lu(0x%lx)", 2043 spi = ntohl(x->id.spi);
2041 (unsigned long)x->id.spi, (unsigned long)x->id.spi); 2044 audit_log_format(audit_buf, " spi=%u(0x%x)", spi, spi);
2042 audit_log_end(audit_buf); 2045 audit_log_end(audit_buf);
2043} 2046}
2044EXPORT_SYMBOL_GPL(xfrm_audit_state_add); 2047EXPORT_SYMBOL_GPL(xfrm_audit_state_add);
@@ -2047,17 +2050,18 @@ void
2047xfrm_audit_state_delete(struct xfrm_state *x, int result, u32 auid, u32 sid) 2050xfrm_audit_state_delete(struct xfrm_state *x, int result, u32 auid, u32 sid)
2048{ 2051{
2049 struct audit_buffer *audit_buf; 2052 struct audit_buffer *audit_buf;
2053 u32 spi;
2050 extern int audit_enabled; 2054 extern int audit_enabled;
2051 2055
2052 if (audit_enabled == 0) 2056 if (audit_enabled == 0)
2053 return; 2057 return;
2054 audit_buf = xfrm_audit_start(sid, auid); 2058 audit_buf = xfrm_audit_start(auid, sid);
2055 if (audit_buf == NULL) 2059 if (audit_buf == NULL)
2056 return; 2060 return;
2057 audit_log_format(audit_buf, " op=SAD-delete res=%u",result); 2061 audit_log_format(audit_buf, " op=SAD-delete res=%u",result);
2058 xfrm_audit_common_stateinfo(x, audit_buf); 2062 xfrm_audit_common_stateinfo(x, audit_buf);
2059 audit_log_format(audit_buf, " spi=%lu(0x%lx)", 2063 spi = ntohl(x->id.spi);
2060 (unsigned long)x->id.spi, (unsigned long)x->id.spi); 2064 audit_log_format(audit_buf, " spi=%u(0x%x)", spi, spi);
2061 audit_log_end(audit_buf); 2065 audit_log_end(audit_buf);
2062} 2066}
2063EXPORT_SYMBOL_GPL(xfrm_audit_state_delete); 2067EXPORT_SYMBOL_GPL(xfrm_audit_state_delete);
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index d41588d101d0..c4f6419b1769 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -31,11 +31,6 @@
31#include <linux/in6.h> 31#include <linux/in6.h>
32#endif 32#endif
33 33
34static inline int alg_len(struct xfrm_algo *alg)
35{
36 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
37}
38
39static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type) 34static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)
40{ 35{
41 struct nlattr *rt = attrs[type]; 36 struct nlattr *rt = attrs[type];
@@ -45,7 +40,7 @@ static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)
45 return 0; 40 return 0;
46 41
47 algp = nla_data(rt); 42 algp = nla_data(rt);
48 if (nla_len(rt) < alg_len(algp)) 43 if (nla_len(rt) < xfrm_alg_len(algp))
49 return -EINVAL; 44 return -EINVAL;
50 45
51 switch (type) { 46 switch (type) {
@@ -204,7 +199,7 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 *props,
204 return -ENOSYS; 199 return -ENOSYS;
205 *props = algo->desc.sadb_alg_id; 200 *props = algo->desc.sadb_alg_id;
206 201
207 p = kmemdup(ualg, alg_len(ualg), GFP_KERNEL); 202 p = kmemdup(ualg, xfrm_alg_len(ualg), GFP_KERNEL);
208 if (!p) 203 if (!p)
209 return -ENOMEM; 204 return -ENOMEM;
210 205
@@ -507,7 +502,6 @@ static int copy_to_user_state_extra(struct xfrm_state *x,
507 struct xfrm_usersa_info *p, 502 struct xfrm_usersa_info *p,
508 struct sk_buff *skb) 503 struct sk_buff *skb)
509{ 504{
510 spin_lock_bh(&x->lock);
511 copy_to_user_state(x, p); 505 copy_to_user_state(x, p);
512 506
513 if (x->coaddr) 507 if (x->coaddr)
@@ -515,12 +509,11 @@ static int copy_to_user_state_extra(struct xfrm_state *x,
515 509
516 if (x->lastused) 510 if (x->lastused)
517 NLA_PUT_U64(skb, XFRMA_LASTUSED, x->lastused); 511 NLA_PUT_U64(skb, XFRMA_LASTUSED, x->lastused);
518 spin_unlock_bh(&x->lock);
519 512
520 if (x->aalg) 513 if (x->aalg)
521 NLA_PUT(skb, XFRMA_ALG_AUTH, alg_len(x->aalg), x->aalg); 514 NLA_PUT(skb, XFRMA_ALG_AUTH, xfrm_alg_len(x->aalg), x->aalg);
522 if (x->ealg) 515 if (x->ealg)
523 NLA_PUT(skb, XFRMA_ALG_CRYPT, alg_len(x->ealg), x->ealg); 516 NLA_PUT(skb, XFRMA_ALG_CRYPT, xfrm_alg_len(x->ealg), x->ealg);
524 if (x->calg) 517 if (x->calg)
525 NLA_PUT(skb, XFRMA_ALG_COMP, sizeof(*(x->calg)), x->calg); 518 NLA_PUT(skb, XFRMA_ALG_COMP, sizeof(*(x->calg)), x->calg);
526 519
@@ -1980,9 +1973,9 @@ static inline size_t xfrm_sa_len(struct xfrm_state *x)
1980{ 1973{
1981 size_t l = 0; 1974 size_t l = 0;
1982 if (x->aalg) 1975 if (x->aalg)
1983 l += nla_total_size(alg_len(x->aalg)); 1976 l += nla_total_size(xfrm_alg_len(x->aalg));
1984 if (x->ealg) 1977 if (x->ealg)
1985 l += nla_total_size(alg_len(x->ealg)); 1978 l += nla_total_size(xfrm_alg_len(x->ealg));
1986 if (x->calg) 1979 if (x->calg)
1987 l += nla_total_size(sizeof(*x->calg)); 1980 l += nla_total_size(sizeof(*x->calg));
1988 if (x->encap) 1981 if (x->encap)