aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/802/tr.c24
-rw-r--r--net/8021q/vlan.c26
-rw-r--r--net/8021q/vlan.h6
-rw-r--r--net/8021q/vlan_core.c2
-rw-r--r--net/8021q/vlan_dev.c54
-rw-r--r--net/Kconfig5
-rw-r--r--net/appletalk/aarp.c3
-rw-r--r--net/appletalk/ddp.c2
-rw-r--r--net/appletalk/sysctl_net_atalk.c14
-rw-r--r--net/atm/atm_sysfs.c2
-rw-r--r--net/atm/br2684.c7
-rw-r--r--net/atm/clip.c4
-rw-r--r--net/atm/lec.c60
-rw-r--r--net/atm/mpc.c36
-rw-r--r--net/atm/mpoa_caches.c18
-rw-r--r--net/ax25/sysctl_net_ax25.c56
-rw-r--r--net/bluetooth/bnep/core.c3
-rw-r--r--net/bluetooth/bnep/netdev.c6
-rw-r--r--net/bluetooth/hci_sysfs.c7
-rw-r--r--net/bridge/br_device.c18
-rw-r--r--net/bridge/br_if.c2
-rw-r--r--net/bridge/br_netfilter.c10
-rw-r--r--net/bridge/br_sysfs_br.c2
-rw-r--r--net/bridge/netfilter/ebt_log.c18
-rw-r--r--net/core/datagram.c5
-rw-r--r--net/core/dev.c232
-rw-r--r--net/core/dst.c6
-rw-r--r--net/core/fib_rules.c7
-rw-r--r--net/core/filter.c19
-rw-r--r--net/core/flow.c2
-rw-r--r--net/core/neighbour.c67
-rw-r--r--net/core/net-sysfs.c12
-rw-r--r--net/core/net_namespace.c2
-rw-r--r--net/core/netpoll.c14
-rw-r--r--net/core/pktgen.c31
-rw-r--r--net/core/rtnetlink.c15
-rw-r--r--net/core/skbuff.c3
-rw-r--r--net/core/sock.c36
-rw-r--r--net/core/sysctl_net_core.c34
-rw-r--r--net/dccp/ccid.c48
-rw-r--r--net/dccp/ccid.h5
-rw-r--r--net/dccp/ccids/ccid2.c6
-rw-r--r--net/dccp/dccp.h8
-rw-r--r--net/dccp/diag.c2
-rw-r--r--net/dccp/feat.c626
-rw-r--r--net/dccp/feat.h92
-rw-r--r--net/dccp/input.c2
-rw-r--r--net/dccp/ipv4.c13
-rw-r--r--net/dccp/ipv6.c5
-rw-r--r--net/dccp/minisocks.c8
-rw-r--r--net/dccp/options.c19
-rw-r--r--net/dccp/output.c17
-rw-r--r--net/dccp/probe.c12
-rw-r--r--net/dccp/proto.c125
-rw-r--r--net/dccp/sysctl.c7
-rw-r--r--net/dccp/timer.c12
-rw-r--r--net/decnet/dn_route.c1
-rw-r--r--net/decnet/sysctl_net_decnet.c44
-rw-r--r--net/dsa/slave.c2
-rw-r--r--net/dsa/tag_dsa.c1
-rw-r--r--net/dsa/tag_edsa.c1
-rw-r--r--net/dsa/tag_trailer.c1
-rw-r--r--net/ethernet/eth.c13
-rw-r--r--net/ieee80211/Kconfig57
-rw-r--r--net/ieee80211/ieee80211_crypt_ccmp.c13
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c29
-rw-r--r--net/ieee80211/ieee80211_module.c26
-rw-r--r--net/ieee80211/ieee80211_rx.c116
-rw-r--r--net/ieee80211/ieee80211_wx.c30
-rw-r--r--net/ipv4/af_inet.c7
-rw-r--r--net/ipv4/ah4.c4
-rw-r--r--net/ipv4/arp.c36
-rw-r--r--net/ipv4/cipso_ipv4.c1
-rw-r--r--net/ipv4/devinet.c19
-rw-r--r--net/ipv4/esp4.c4
-rw-r--r--net/ipv4/fib_frontend.c10
-rw-r--r--net/ipv4/fib_hash.c12
-rw-r--r--net/ipv4/fib_semantics.c8
-rw-r--r--net/ipv4/fib_trie.c6
-rw-r--r--net/ipv4/icmp.c27
-rw-r--r--net/ipv4/igmp.c46
-rw-r--r--net/ipv4/inet_connection_sock.c6
-rw-r--r--net/ipv4/inet_diag.c19
-rw-r--r--net/ipv4/inet_hashtables.c170
-rw-r--r--net/ipv4/inet_lro.c4
-rw-r--r--net/ipv4/inet_timewait_sock.c26
-rw-r--r--net/ipv4/inetpeer.c2
-rw-r--r--net/ipv4/ip_forward.c2
-rw-r--r--net/ipv4/ip_fragment.c21
-rw-r--r--net/ipv4/ip_gre.c14
-rw-r--r--net/ipv4/ip_input.c10
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/ip_sockglue.c72
-rw-r--r--net/ipv4/ipcomp.c4
-rw-r--r--net/ipv4/ipconfig.c40
-rw-r--r--net/ipv4/ipip.c2
-rw-r--r--net/ipv4/ipmr.c155
-rw-r--r--net/ipv4/netfilter/arp_tables.c16
-rw-r--r--net/ipv4/netfilter/ip_tables.c12
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c9
-rw-r--r--net/ipv4/netfilter/ipt_LOG.c7
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c27
-rw-r--r--net/ipv4/netfilter/nf_conntrack_proto_icmp.c4
-rw-r--r--net/ipv4/netfilter/nf_nat_h323.c58
-rw-r--r--net/ipv4/netfilter/nf_nat_irc.c4
-rw-r--r--net/ipv4/netfilter/nf_nat_rule.c6
-rw-r--r--net/ipv4/netfilter/nf_nat_sip.c18
-rw-r--r--net/ipv4/netfilter/nf_nat_snmp_basic.c9
-rw-r--r--net/ipv4/raw.c8
-rw-r--r--net/ipv4/route.c225
-rw-r--r--net/ipv4/sysctl_net_ipv4.c188
-rw-r--r--net/ipv4/tcp.c10
-rw-r--r--net/ipv4/tcp_cubic.c120
-rw-r--r--net/ipv4/tcp_diag.c2
-rw-r--r--net/ipv4/tcp_input.c8
-rw-r--r--net/ipv4/tcp_ipv4.c82
-rw-r--r--net/ipv4/tcp_minisocks.c2
-rw-r--r--net/ipv4/tcp_output.c8
-rw-r--r--net/ipv4/tcp_probe.c7
-rw-r--r--net/ipv4/tcp_timer.c12
-rw-r--r--net/ipv4/tcp_yeah.c4
-rw-r--r--net/ipv4/udp.c267
-rw-r--r--net/ipv4/udp_impl.h4
-rw-r--r--net/ipv4/udplite.c14
-rw-r--r--net/ipv4/xfrm4_policy.c3
-rw-r--r--net/ipv6/addrconf.c80
-rw-r--r--net/ipv6/addrlabel.c34
-rw-r--r--net/ipv6/ah6.c4
-rw-r--r--net/ipv6/anycast.c6
-rw-r--r--net/ipv6/esp6.c4
-rw-r--r--net/ipv6/exthdrs.c2
-rw-r--r--net/ipv6/icmp.c15
-rw-r--r--net/ipv6/inet6_hashtables.c89
-rw-r--r--net/ipv6/ip6_flowlabel.c4
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/ip6mr.c5
-rw-r--r--net/ipv6/ipcomp6.c4
-rw-r--r--net/ipv6/mcast.c12
-rw-r--r--net/ipv6/ndisc.c103
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c7
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c5
-rw-r--r--net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c6
-rw-r--r--net/ipv6/reassembly.c12
-rw-r--r--net/ipv6/route.c45
-rw-r--r--net/ipv6/sysctl_net_ipv6.c4
-rw-r--r--net/ipv6/tcp_ipv6.c15
-rw-r--r--net/ipv6/udp.c145
-rw-r--r--net/ipv6/udp_impl.h4
-rw-r--r--net/ipv6/udplite.c9
-rw-r--r--net/ipv6/xfrm6_policy.c10
-rw-r--r--net/ipx/sysctl_net_ipx.c2
-rw-r--r--net/irda/irlan/irlan_client.c4
-rw-r--r--net/irda/irlan/irlan_common.c2
-rw-r--r--net/irda/irsysctl.c50
-rw-r--r--net/llc/llc_proc.c3
-rw-r--r--net/llc/sysctl_net_llc.c20
-rw-r--r--net/mac80211/cfg.c141
-rw-r--r--net/mac80211/debugfs.c12
-rw-r--r--net/mac80211/debugfs_key.c4
-rw-r--r--net/mac80211/debugfs_netdev.c117
-rw-r--r--net/mac80211/debugfs_sta.c84
-rw-r--r--net/mac80211/event.c5
-rw-r--r--net/mac80211/ht.c252
-rw-r--r--net/mac80211/ieee80211_i.h62
-rw-r--r--net/mac80211/iface.c27
-rw-r--r--net/mac80211/key.c10
-rw-r--r--net/mac80211/main.c224
-rw-r--r--net/mac80211/mesh.c4
-rw-r--r--net/mac80211/mesh.h5
-rw-r--r--net/mac80211/mesh_hwmp.c6
-rw-r--r--net/mac80211/mesh_plink.c49
-rw-r--r--net/mac80211/mlme.c502
-rw-r--r--net/mac80211/rate.c52
-rw-r--r--net/mac80211/rate.h11
-rw-r--r--net/mac80211/rc80211_minstrel.c109
-rw-r--r--net/mac80211/rc80211_minstrel.h2
-rw-r--r--net/mac80211/rc80211_pid.h3
-rw-r--r--net/mac80211/rc80211_pid_algo.c32
-rw-r--r--net/mac80211/rc80211_pid_debugfs.c5
-rw-r--r--net/mac80211/rx.c77
-rw-r--r--net/mac80211/scan.c24
-rw-r--r--net/mac80211/sta_info.c37
-rw-r--r--net/mac80211/sta_info.h42
-rw-r--r--net/mac80211/tkip.c10
-rw-r--r--net/mac80211/tx.c437
-rw-r--r--net/mac80211/util.c20
-rw-r--r--net/mac80211/wep.c26
-rw-r--r--net/mac80211/wep.h2
-rw-r--r--net/mac80211/wext.c88
-rw-r--r--net/mac80211/wme.c32
-rw-r--r--net/mac80211/wpa.c32
-rw-r--r--net/netfilter/ipvs/ip_vs_conn.c20
-rw-r--r--net/netfilter/ipvs/ip_vs_core.c20
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c82
-rw-r--r--net/netfilter/ipvs/ip_vs_dh.c34
-rw-r--r--net/netfilter/ipvs/ip_vs_ftp.c13
-rw-r--r--net/netfilter/ipvs/ip_vs_lblc.c69
-rw-r--r--net/netfilter/ipvs/ip_vs_lblcr.c96
-rw-r--r--net/netfilter/ipvs/ip_vs_lc.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_nq.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_proto.c38
-rw-r--r--net/netfilter/ipvs/ip_vs_proto_ah_esp.c10
-rw-r--r--net/netfilter/ipvs/ip_vs_proto_tcp.c8
-rw-r--r--net/netfilter/ipvs/ip_vs_proto_udp.c8
-rw-r--r--net/netfilter/ipvs/ip_vs_rr.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_sed.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_sh.c34
-rw-r--r--net/netfilter/ipvs/ip_vs_sync.c4
-rw-r--r--net/netfilter/ipvs/ip_vs_wlc.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_wrr.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_xmit.c34
-rw-r--r--net/netfilter/nf_conntrack_acct.c2
-rw-r--r--net/netfilter/nf_conntrack_ftp.c15
-rw-r--r--net/netfilter/nf_conntrack_h323_main.c12
-rw-r--r--net/netfilter/nf_conntrack_irc.c13
-rw-r--r--net/netfilter/nf_conntrack_proto_generic.c4
-rw-r--r--net/netfilter/nf_conntrack_proto_sctp.c28
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c50
-rw-r--r--net/netfilter/nf_conntrack_proto_udp.c8
-rw-r--r--net/netfilter/nf_conntrack_proto_udplite.c4
-rw-r--r--net/netfilter/nf_conntrack_standalone.c16
-rw-r--r--net/netfilter/xt_hashlimit.c14
-rw-r--r--net/netfilter/xt_iprange.c36
-rw-r--r--net/netfilter/xt_recent.c10
-rw-r--r--net/netlabel/netlabel_addrlist.c4
-rw-r--r--net/netlink/attr.c2
-rw-r--r--net/netrom/sysctl_net_netrom.c48
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/phonet/pep-gprs.c41
-rw-r--r--net/phonet/sysctl.c2
-rw-r--r--net/rfkill/rfkill-input.c337
-rw-r--r--net/rfkill/rfkill-input.h3
-rw-r--r--net/rfkill/rfkill.c85
-rw-r--r--net/rose/sysctl_net_rose.c40
-rw-r--r--net/rxrpc/af_rxrpc.c4
-rw-r--r--net/rxrpc/ar-error.c3
-rw-r--r--net/rxrpc/ar-local.c16
-rw-r--r--net/rxrpc/ar-peer.c8
-rw-r--r--net/rxrpc/ar-proc.c16
-rw-r--r--net/rxrpc/ar-transport.c12
-rw-r--r--net/rxrpc/rxkad.c2
-rw-r--r--net/sched/Kconfig22
-rw-r--r--net/sched/Makefile2
-rw-r--r--net/sched/cls_api.c3
-rw-r--r--net/sched/cls_basic.c2
-rw-r--r--net/sched/cls_cgroup.c288
-rw-r--r--net/sched/cls_fw.c2
-rw-r--r--net/sched/cls_route.c2
-rw-r--r--net/sched/cls_tcindex.c6
-rw-r--r--net/sched/cls_u32.c11
-rw-r--r--net/sched/ematch.c18
-rw-r--r--net/sched/sch_api.c15
-rw-r--r--net/sched/sch_atm.c36
-rw-r--r--net/sched/sch_blackhole.c1
-rw-r--r--net/sched/sch_cbq.c43
-rw-r--r--net/sched/sch_drr.c506
-rw-r--r--net/sched/sch_dsmark.c22
-rw-r--r--net/sched/sch_fifo.c4
-rw-r--r--net/sched/sch_generic.c40
-rw-r--r--net/sched/sch_gred.c22
-rw-r--r--net/sched/sch_hfsc.c37
-rw-r--r--net/sched/sch_htb.c49
-rw-r--r--net/sched/sch_multiq.c82
-rw-r--r--net/sched/sch_netem.c159
-rw-r--r--net/sched/sch_prio.c50
-rw-r--r--net/sched/sch_red.c33
-rw-r--r--net/sched/sch_sfq.c69
-rw-r--r--net/sched/sch_tbf.c44
-rw-r--r--net/sched/sch_teql.c19
-rw-r--r--net/sctp/ipv6.c35
-rw-r--r--net/sctp/protocol.c18
-rw-r--r--net/sctp/sm_statefuns.c10
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/sctp/sysctl.c82
-rw-r--r--net/socket.c1
-rw-r--r--net/sunrpc/clnt.c8
-rw-r--r--net/sunrpc/rpcb_clnt.c17
-rw-r--r--net/sunrpc/svcauth_unix.c24
-rw-r--r--net/sunrpc/svcsock.c6
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_transport.c12
-rw-r--r--net/sunrpc/xprtrdma/transport.c14
-rw-r--r--net/sunrpc/xprtrdma/verbs.c14
-rw-r--r--net/sunrpc/xprtsock.c41
-rw-r--r--net/tipc/eth_media.c3
-rw-r--r--net/tipc/name_table.c2
-rw-r--r--net/unix/af_unix.c197
-rw-r--r--net/unix/garbage.c12
-rw-r--r--net/unix/sysctl_net_unix.c3
-rw-r--r--net/wanrouter/wanmain.c36
-rw-r--r--net/wireless/Kconfig10
-rw-r--r--net/wireless/Makefile1
-rw-r--r--net/wireless/core.c9
-rw-r--r--net/wireless/lib80211.c65
-rw-r--r--net/wireless/nl80211.c288
-rw-r--r--net/wireless/reg.c462
-rw-r--r--net/wireless/reg.h20
-rw-r--r--net/wireless/util.c19
-rw-r--r--net/x25/sysctl_net_x25.c22
-rw-r--r--net/xfrm/xfrm_policy.c22
-rw-r--r--net/xfrm/xfrm_state.c24
-rw-r--r--net/xfrm/xfrm_user.c52
302 files changed, 6880 insertions, 4895 deletions
diff --git a/net/802/tr.c b/net/802/tr.c
index 18c66475d8c3..158150fee462 100644
--- a/net/802/tr.c
+++ b/net/802/tr.c
@@ -285,10 +285,7 @@ void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,
285 if(entry) 285 if(entry)
286 { 286 {
287#if TR_SR_DEBUG 287#if TR_SR_DEBUG
288{ 288printk("source routing for %pM\n", trh->daddr);
289DECLARE_MAC_BUF(mac);
290printk("source routing for %s\n",print_mac(mac, trh->daddr));
291}
292#endif 289#endif
293 if(!entry->local_ring && (ntohs(entry->rcf) & TR_RCF_LEN_MASK) >> 8) 290 if(!entry->local_ring && (ntohs(entry->rcf) & TR_RCF_LEN_MASK) >> 8)
294 { 291 {
@@ -370,9 +367,8 @@ static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev)
370 if(entry==NULL) 367 if(entry==NULL)
371 { 368 {
372#if TR_SR_DEBUG 369#if TR_SR_DEBUG
373 DECLARE_MAC_BUF(mac); 370 printk("adding rif_entry: addr:%pM rcf:%04X\n",
374 printk("adding rif_entry: addr:%s rcf:%04X\n", 371 trh->saddr, ntohs(trh->rcf));
375 print_mac(mac, trh->saddr), ntohs(trh->rcf));
376#endif 372#endif
377 /* 373 /*
378 * Allocate our new entry. A failure to allocate loses 374 * Allocate our new entry. A failure to allocate loses
@@ -417,11 +413,8 @@ static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev)
417 !(trh->rcf & htons(TR_RCF_BROADCAST_MASK))) 413 !(trh->rcf & htons(TR_RCF_BROADCAST_MASK)))
418 { 414 {
419#if TR_SR_DEBUG 415#if TR_SR_DEBUG
420{ 416printk("updating rif_entry: addr:%pM rcf:%04X\n",
421DECLARE_MAC_BUF(mac); 417 trh->saddr, ntohs(trh->rcf));
422printk("updating rif_entry: addr:%s rcf:%04X\n",
423 print_mac(mac, trh->saddr), ntohs(trh->rcf));
424}
425#endif 418#endif
426 entry->rcf = trh->rcf & htons((unsigned short)~TR_RCF_BROADCAST_MASK); 419 entry->rcf = trh->rcf & htons((unsigned short)~TR_RCF_BROADCAST_MASK);
427 memcpy(&(entry->rseg[0]),&(trh->rseg[0]),8*sizeof(unsigned short)); 420 memcpy(&(entry->rseg[0]),&(trh->rseg[0]),8*sizeof(unsigned short));
@@ -532,7 +525,6 @@ static int rif_seq_show(struct seq_file *seq, void *v)
532{ 525{
533 int j, rcf_len, segment, brdgnmb; 526 int j, rcf_len, segment, brdgnmb;
534 struct rif_cache *entry = v; 527 struct rif_cache *entry = v;
535 DECLARE_MAC_BUF(mac);
536 528
537 if (v == SEQ_START_TOKEN) 529 if (v == SEQ_START_TOKEN)
538 seq_puts(seq, 530 seq_puts(seq,
@@ -542,9 +534,9 @@ static int rif_seq_show(struct seq_file *seq, void *v)
542 long ttl = (long) (entry->last_used + sysctl_tr_rif_timeout) 534 long ttl = (long) (entry->last_used + sysctl_tr_rif_timeout)
543 - (long) jiffies; 535 - (long) jiffies;
544 536
545 seq_printf(seq, "%s %s %7li ", 537 seq_printf(seq, "%s %pM %7li ",
546 dev?dev->name:"?", 538 dev?dev->name:"?",
547 print_mac(mac, entry->addr), 539 entry->addr,
548 ttl/HZ); 540 ttl/HZ);
549 541
550 if (entry->local_ring) 542 if (entry->local_ring)
@@ -643,7 +635,7 @@ static struct ctl_table tr_table[] = {
643 .data = &sysctl_tr_rif_timeout, 635 .data = &sysctl_tr_rif_timeout,
644 .maxlen = sizeof(int), 636 .maxlen = sizeof(int),
645 .mode = 0644, 637 .mode = 0644,
646 .proc_handler = &proc_dointvec 638 .proc_handler = proc_dointvec
647 }, 639 },
648 { 0 }, 640 { 0 },
649}; 641};
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index f0e335aa20df..41e8f65bd3f0 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -46,10 +46,10 @@ int vlan_net_id;
46/* Our listing of VLAN group(s) */ 46/* Our listing of VLAN group(s) */
47static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE]; 47static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
48 48
49static char vlan_fullname[] = "802.1Q VLAN Support"; 49const char vlan_fullname[] = "802.1Q VLAN Support";
50static char vlan_version[] = DRV_VERSION; 50const char vlan_version[] = DRV_VERSION;
51static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>"; 51static const char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
52static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; 52static const char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
53 53
54static struct packet_type vlan_packet_type = { 54static struct packet_type vlan_packet_type = {
55 .type = __constant_htons(ETH_P_8021Q), 55 .type = __constant_htons(ETH_P_8021Q),
@@ -144,6 +144,7 @@ void unregister_vlan_dev(struct net_device *dev)
144{ 144{
145 struct vlan_dev_info *vlan = vlan_dev_info(dev); 145 struct vlan_dev_info *vlan = vlan_dev_info(dev);
146 struct net_device *real_dev = vlan->real_dev; 146 struct net_device *real_dev = vlan->real_dev;
147 const struct net_device_ops *ops = real_dev->netdev_ops;
147 struct vlan_group *grp; 148 struct vlan_group *grp;
148 u16 vlan_id = vlan->vlan_id; 149 u16 vlan_id = vlan->vlan_id;
149 150
@@ -156,7 +157,7 @@ void unregister_vlan_dev(struct net_device *dev)
156 * HW accelerating devices or SW vlan input packet processing. 157 * HW accelerating devices or SW vlan input packet processing.
157 */ 158 */
158 if (real_dev->features & NETIF_F_HW_VLAN_FILTER) 159 if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
159 real_dev->vlan_rx_kill_vid(real_dev, vlan_id); 160 ops->ndo_vlan_rx_kill_vid(real_dev, vlan_id);
160 161
161 vlan_group_set_device(grp, vlan_id, NULL); 162 vlan_group_set_device(grp, vlan_id, NULL);
162 grp->nr_vlans--; 163 grp->nr_vlans--;
@@ -170,7 +171,7 @@ void unregister_vlan_dev(struct net_device *dev)
170 vlan_gvrp_uninit_applicant(real_dev); 171 vlan_gvrp_uninit_applicant(real_dev);
171 172
172 if (real_dev->features & NETIF_F_HW_VLAN_RX) 173 if (real_dev->features & NETIF_F_HW_VLAN_RX)
173 real_dev->vlan_rx_register(real_dev, NULL); 174 ops->ndo_vlan_rx_register(real_dev, NULL);
174 175
175 hlist_del_rcu(&grp->hlist); 176 hlist_del_rcu(&grp->hlist);
176 177
@@ -205,21 +206,21 @@ static void vlan_transfer_operstate(const struct net_device *dev,
205 206
206int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id) 207int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id)
207{ 208{
208 char *name = real_dev->name; 209 const char *name = real_dev->name;
210 const struct net_device_ops *ops = real_dev->netdev_ops;
209 211
210 if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { 212 if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
211 pr_info("8021q: VLANs not supported on %s\n", name); 213 pr_info("8021q: VLANs not supported on %s\n", name);
212 return -EOPNOTSUPP; 214 return -EOPNOTSUPP;
213 } 215 }
214 216
215 if ((real_dev->features & NETIF_F_HW_VLAN_RX) && 217 if ((real_dev->features & NETIF_F_HW_VLAN_RX) && !ops->ndo_vlan_rx_register) {
216 !real_dev->vlan_rx_register) {
217 pr_info("8021q: device %s has buggy VLAN hw accel\n", name); 218 pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
218 return -EOPNOTSUPP; 219 return -EOPNOTSUPP;
219 } 220 }
220 221
221 if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) && 222 if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
222 (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) { 223 (!ops->ndo_vlan_rx_add_vid || !ops->ndo_vlan_rx_kill_vid)) {
223 pr_info("8021q: Device %s has buggy VLAN hw accel\n", name); 224 pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
224 return -EOPNOTSUPP; 225 return -EOPNOTSUPP;
225 } 226 }
@@ -240,6 +241,7 @@ int register_vlan_dev(struct net_device *dev)
240{ 241{
241 struct vlan_dev_info *vlan = vlan_dev_info(dev); 242 struct vlan_dev_info *vlan = vlan_dev_info(dev);
242 struct net_device *real_dev = vlan->real_dev; 243 struct net_device *real_dev = vlan->real_dev;
244 const struct net_device_ops *ops = real_dev->netdev_ops;
243 u16 vlan_id = vlan->vlan_id; 245 u16 vlan_id = vlan->vlan_id;
244 struct vlan_group *grp, *ngrp = NULL; 246 struct vlan_group *grp, *ngrp = NULL;
245 int err; 247 int err;
@@ -275,9 +277,9 @@ int register_vlan_dev(struct net_device *dev)
275 grp->nr_vlans++; 277 grp->nr_vlans++;
276 278
277 if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX) 279 if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX)
278 real_dev->vlan_rx_register(real_dev, ngrp); 280 ops->ndo_vlan_rx_register(real_dev, ngrp);
279 if (real_dev->features & NETIF_F_HW_VLAN_FILTER) 281 if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
280 real_dev->vlan_rx_add_vid(real_dev, vlan_id); 282 ops->ndo_vlan_rx_add_vid(real_dev, vlan_id);
281 283
282 return 0; 284 return 0;
283 285
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index a6603a4d917f..82570bc2a180 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -108,8 +108,10 @@ static inline int vlan_gvrp_init(void) { return 0; }
108static inline void vlan_gvrp_uninit(void) {} 108static inline void vlan_gvrp_uninit(void) {}
109#endif 109#endif
110 110
111int vlan_netlink_init(void); 111extern const char vlan_fullname[];
112void vlan_netlink_fini(void); 112extern const char vlan_version[];
113extern int vlan_netlink_init(void);
114extern void vlan_netlink_fini(void);
113 115
114extern struct rtnl_link_ops vlan_link_ops; 116extern struct rtnl_link_ops vlan_link_ops;
115 117
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 68ced4bf158c..dd86a1dc4cd0 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -47,8 +47,6 @@ int vlan_hwaccel_do_receive(struct sk_buff *skb)
47 skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci); 47 skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci);
48 skb->vlan_tci = 0; 48 skb->vlan_tci = 0;
49 49
50 dev->last_rx = jiffies;
51
52 stats = &dev->stats; 50 stats = &dev->stats;
53 stats->rx_packets++; 51 stats->rx_packets++;
54 stats->rx_bytes += skb->len; 52 stats->rx_bytes += skb->len;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 8883e9c8a223..71193a6b10e6 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -163,8 +163,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
163 goto err_unlock; 163 goto err_unlock;
164 } 164 }
165 165
166 skb->dev->last_rx = jiffies;
167
168 stats = &skb->dev->stats; 166 stats = &skb->dev->stats;
169 stats->rx_packets++; 167 stats->rx_packets++;
170 stats->rx_bytes += skb->len; 168 stats->rx_bytes += skb->len;
@@ -526,6 +524,7 @@ out:
526static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 524static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
527{ 525{
528 struct net_device *real_dev = vlan_dev_info(dev)->real_dev; 526 struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
527 const struct net_device_ops *ops = real_dev->netdev_ops;
529 struct ifreq ifrr; 528 struct ifreq ifrr;
530 int err = -EOPNOTSUPP; 529 int err = -EOPNOTSUPP;
531 530
@@ -536,8 +535,8 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
536 case SIOCGMIIPHY: 535 case SIOCGMIIPHY:
537 case SIOCGMIIREG: 536 case SIOCGMIIREG:
538 case SIOCSMIIREG: 537 case SIOCSMIIREG:
539 if (real_dev->do_ioctl && netif_device_present(real_dev)) 538 if (netif_device_present(real_dev) && ops->ndo_do_ioctl)
540 err = real_dev->do_ioctl(real_dev, &ifrr, cmd); 539 err = ops->ndo_do_ioctl(real_dev, &ifrr, cmd);
541 break; 540 break;
542 } 541 }
543 542
@@ -648,6 +647,26 @@ static void vlan_dev_uninit(struct net_device *dev)
648 } 647 }
649} 648}
650 649
650static int vlan_ethtool_get_settings(struct net_device *dev,
651 struct ethtool_cmd *cmd)
652{
653 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
654 struct net_device *real_dev = vlan->real_dev;
655
656 if (!real_dev->ethtool_ops->get_settings)
657 return -EOPNOTSUPP;
658
659 return real_dev->ethtool_ops->get_settings(real_dev, cmd);
660}
661
662static void vlan_ethtool_get_drvinfo(struct net_device *dev,
663 struct ethtool_drvinfo *info)
664{
665 strcpy(info->driver, vlan_fullname);
666 strcpy(info->version, vlan_version);
667 strcpy(info->fw_version, "N/A");
668}
669
651static u32 vlan_ethtool_get_rx_csum(struct net_device *dev) 670static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
652{ 671{
653 const struct vlan_dev_info *vlan = vlan_dev_info(dev); 672 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
@@ -672,11 +691,27 @@ static u32 vlan_ethtool_get_flags(struct net_device *dev)
672} 691}
673 692
674static const struct ethtool_ops vlan_ethtool_ops = { 693static const struct ethtool_ops vlan_ethtool_ops = {
694 .get_settings = vlan_ethtool_get_settings,
695 .get_drvinfo = vlan_ethtool_get_drvinfo,
675 .get_link = ethtool_op_get_link, 696 .get_link = ethtool_op_get_link,
676 .get_rx_csum = vlan_ethtool_get_rx_csum, 697 .get_rx_csum = vlan_ethtool_get_rx_csum,
677 .get_flags = vlan_ethtool_get_flags, 698 .get_flags = vlan_ethtool_get_flags,
678}; 699};
679 700
701static const struct net_device_ops vlan_netdev_ops = {
702 .ndo_change_mtu = vlan_dev_change_mtu,
703 .ndo_init = vlan_dev_init,
704 .ndo_uninit = vlan_dev_uninit,
705 .ndo_open = vlan_dev_open,
706 .ndo_stop = vlan_dev_stop,
707 .ndo_validate_addr = eth_validate_addr,
708 .ndo_set_mac_address = vlan_dev_set_mac_address,
709 .ndo_set_rx_mode = vlan_dev_set_rx_mode,
710 .ndo_set_multicast_list = vlan_dev_set_rx_mode,
711 .ndo_change_rx_flags = vlan_dev_change_rx_flags,
712 .ndo_do_ioctl = vlan_dev_ioctl,
713};
714
680void vlan_setup(struct net_device *dev) 715void vlan_setup(struct net_device *dev)
681{ 716{
682 ether_setup(dev); 717 ether_setup(dev);
@@ -684,16 +719,7 @@ void vlan_setup(struct net_device *dev)
684 dev->priv_flags |= IFF_802_1Q_VLAN; 719 dev->priv_flags |= IFF_802_1Q_VLAN;
685 dev->tx_queue_len = 0; 720 dev->tx_queue_len = 0;
686 721
687 dev->change_mtu = vlan_dev_change_mtu; 722 dev->netdev_ops = &vlan_netdev_ops;
688 dev->init = vlan_dev_init;
689 dev->uninit = vlan_dev_uninit;
690 dev->open = vlan_dev_open;
691 dev->stop = vlan_dev_stop;
692 dev->set_mac_address = vlan_dev_set_mac_address;
693 dev->set_rx_mode = vlan_dev_set_rx_mode;
694 dev->set_multicast_list = vlan_dev_set_rx_mode;
695 dev->change_rx_flags = vlan_dev_change_rx_flags;
696 dev->do_ioctl = vlan_dev_ioctl;
697 dev->destructor = free_netdev; 723 dev->destructor = free_netdev;
698 dev->ethtool_ops = &vlan_ethtool_ops; 724 dev->ethtool_ops = &vlan_ethtool_ops;
699 725
diff --git a/net/Kconfig b/net/Kconfig
index d789d79551ae..4e2e40ba8ba6 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -27,11 +27,14 @@ menu "Networking options"
27config NET_NS 27config NET_NS
28 bool "Network namespace support" 28 bool "Network namespace support"
29 default n 29 default n
30 depends on EXPERIMENTAL && !SYSFS && NAMESPACES 30 depends on EXPERIMENTAL && NAMESPACES
31 help 31 help
32 Allow user space to create what appear to be multiple instances 32 Allow user space to create what appear to be multiple instances
33 of the network stack. 33 of the network stack.
34 34
35config COMPAT_NET_DEV_OPS
36 def_bool y
37
35source "net/packet/Kconfig" 38source "net/packet/Kconfig"
36source "net/unix/Kconfig" 39source "net/unix/Kconfig"
37source "net/xfrm/Kconfig" 40source "net/xfrm/Kconfig"
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index b25c1e909d14..b03ff58e9308 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -995,7 +995,6 @@ static int aarp_seq_show(struct seq_file *seq, void *v)
995 struct aarp_iter_state *iter = seq->private; 995 struct aarp_iter_state *iter = seq->private;
996 struct aarp_entry *entry = v; 996 struct aarp_entry *entry = v;
997 unsigned long now = jiffies; 997 unsigned long now = jiffies;
998 DECLARE_MAC_BUF(mac);
999 998
1000 if (v == SEQ_START_TOKEN) 999 if (v == SEQ_START_TOKEN)
1001 seq_puts(seq, 1000 seq_puts(seq,
@@ -1006,7 +1005,7 @@ static int aarp_seq_show(struct seq_file *seq, void *v)
1006 ntohs(entry->target_addr.s_net), 1005 ntohs(entry->target_addr.s_net),
1007 (unsigned int) entry->target_addr.s_node, 1006 (unsigned int) entry->target_addr.s_node,
1008 entry->dev ? entry->dev->name : "????"); 1007 entry->dev ? entry->dev->name : "????");
1009 seq_printf(seq, "%s", print_mac(mac, entry->hwaddr)); 1008 seq_printf(seq, "%pM", entry->hwaddr);
1010 seq_printf(seq, " %8s", 1009 seq_printf(seq, " %8s",
1011 dt2str((long)entry->expires_at - (long)now)); 1010 dt2str((long)entry->expires_at - (long)now));
1012 if (iter->table == unresolved) 1011 if (iter->table == unresolved)
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index d3134e7e6ee8..c3f002717378 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1284,7 +1284,7 @@ static int handle_ip_over_ddp(struct sk_buff *skb)
1284 skb->dev = dev; 1284 skb->dev = dev;
1285 skb_reset_transport_header(skb); 1285 skb_reset_transport_header(skb);
1286 1286
1287 stats = dev->priv; 1287 stats = netdev_priv(dev);
1288 stats->rx_packets++; 1288 stats->rx_packets++;
1289 stats->rx_bytes += skb->len + 13; 1289 stats->rx_bytes += skb->len + 13;
1290 netif_rx(skb); /* Send the SKB up to a higher place. */ 1290 netif_rx(skb); /* Send the SKB up to a higher place. */
diff --git a/net/appletalk/sysctl_net_atalk.c b/net/appletalk/sysctl_net_atalk.c
index 621805dfa2f4..8d237b15183b 100644
--- a/net/appletalk/sysctl_net_atalk.c
+++ b/net/appletalk/sysctl_net_atalk.c
@@ -17,8 +17,8 @@ static struct ctl_table atalk_table[] = {
17 .data = &sysctl_aarp_expiry_time, 17 .data = &sysctl_aarp_expiry_time,
18 .maxlen = sizeof(int), 18 .maxlen = sizeof(int),
19 .mode = 0644, 19 .mode = 0644,
20 .proc_handler = &proc_dointvec_jiffies, 20 .proc_handler = proc_dointvec_jiffies,
21 .strategy = &sysctl_jiffies, 21 .strategy = sysctl_jiffies,
22 }, 22 },
23 { 23 {
24 .ctl_name = NET_ATALK_AARP_TICK_TIME, 24 .ctl_name = NET_ATALK_AARP_TICK_TIME,
@@ -26,8 +26,8 @@ static struct ctl_table atalk_table[] = {
26 .data = &sysctl_aarp_tick_time, 26 .data = &sysctl_aarp_tick_time,
27 .maxlen = sizeof(int), 27 .maxlen = sizeof(int),
28 .mode = 0644, 28 .mode = 0644,
29 .proc_handler = &proc_dointvec_jiffies, 29 .proc_handler = proc_dointvec_jiffies,
30 .strategy = &sysctl_jiffies, 30 .strategy = sysctl_jiffies,
31 }, 31 },
32 { 32 {
33 .ctl_name = NET_ATALK_AARP_RETRANSMIT_LIMIT, 33 .ctl_name = NET_ATALK_AARP_RETRANSMIT_LIMIT,
@@ -35,7 +35,7 @@ static struct ctl_table atalk_table[] = {
35 .data = &sysctl_aarp_retransmit_limit, 35 .data = &sysctl_aarp_retransmit_limit,
36 .maxlen = sizeof(int), 36 .maxlen = sizeof(int),
37 .mode = 0644, 37 .mode = 0644,
38 .proc_handler = &proc_dointvec, 38 .proc_handler = proc_dointvec,
39 }, 39 },
40 { 40 {
41 .ctl_name = NET_ATALK_AARP_RESOLVE_TIME, 41 .ctl_name = NET_ATALK_AARP_RESOLVE_TIME,
@@ -43,8 +43,8 @@ static struct ctl_table atalk_table[] = {
43 .data = &sysctl_aarp_resolve_time, 43 .data = &sysctl_aarp_resolve_time,
44 .maxlen = sizeof(int), 44 .maxlen = sizeof(int),
45 .mode = 0644, 45 .mode = 0644,
46 .proc_handler = &proc_dointvec_jiffies, 46 .proc_handler = proc_dointvec_jiffies,
47 .strategy = &sysctl_jiffies, 47 .strategy = sysctl_jiffies,
48 }, 48 },
49 { 0 }, 49 { 0 },
50}; 50};
diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
index 1b88311f2130..b5674dc2083d 100644
--- a/net/atm/atm_sysfs.c
+++ b/net/atm/atm_sysfs.c
@@ -149,7 +149,7 @@ int atm_register_sysfs(struct atm_dev *adev)
149 cdev->class = &atm_class; 149 cdev->class = &atm_class;
150 dev_set_drvdata(cdev, adev); 150 dev_set_drvdata(cdev, adev);
151 151
152 snprintf(cdev->bus_id, BUS_ID_SIZE, "%s%d", adev->type, adev->number); 152 dev_set_name(cdev, "%s%d", adev->type, adev->number);
153 err = device_register(cdev); 153 err = device_register(cdev);
154 if (err < 0) 154 if (err < 0)
155 return err; 155 return err;
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 280de481edc7..ea9438fc6855 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -101,7 +101,7 @@ static LIST_HEAD(br2684_devs);
101 101
102static inline struct br2684_dev *BRPRIV(const struct net_device *net_dev) 102static inline struct br2684_dev *BRPRIV(const struct net_device *net_dev)
103{ 103{
104 return (struct br2684_dev *)net_dev->priv; 104 return (struct br2684_dev *)netdev_priv(net_dev);
105} 105}
106 106
107static inline struct net_device *list_entry_brdev(const struct list_head *le) 107static inline struct net_device *list_entry_brdev(const struct list_head *le)
@@ -698,12 +698,11 @@ static int br2684_seq_show(struct seq_file *seq, void *v)
698 br2684_devs); 698 br2684_devs);
699 const struct net_device *net_dev = brdev->net_dev; 699 const struct net_device *net_dev = brdev->net_dev;
700 const struct br2684_vcc *brvcc; 700 const struct br2684_vcc *brvcc;
701 DECLARE_MAC_BUF(mac);
702 701
703 seq_printf(seq, "dev %.16s: num=%d, mac=%s (%s)\n", 702 seq_printf(seq, "dev %.16s: num=%d, mac=%pM (%s)\n",
704 net_dev->name, 703 net_dev->name,
705 brdev->number, 704 brdev->number,
706 print_mac(mac, net_dev->dev_addr), 705 net_dev->dev_addr,
707 brdev->mac_was_set ? "set" : "auto"); 706 brdev->mac_was_set ? "set" : "auto");
708 707
709 list_for_each_entry(brvcc, &brdev->brvccs, brvccs) { 708 list_for_each_entry(brvcc, &brdev->brvccs, brvccs) {
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 5b5b96344ce6..2d33a83be799 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -822,8 +822,8 @@ static void atmarp_info(struct seq_file *seq, struct net_device *dev,
822 seq_printf(seq, "%-6s%-4s%-4s%5ld ", 822 seq_printf(seq, "%-6s%-4s%-4s%5ld ",
823 dev->name, svc ? "SVC" : "PVC", llc ? "LLC" : "NULL", exp); 823 dev->name, svc ? "SVC" : "PVC", llc ? "LLC" : "NULL", exp);
824 824
825 off = scnprintf(buf, sizeof(buf) - 1, "%d.%d.%d.%d", 825 off = scnprintf(buf, sizeof(buf) - 1, "%pI4",
826 NIPQUAD(entry->ip)); 826 &entry->ip);
827 while (off < 16) 827 while (off < 16)
828 buf[off++] = ' '; 828 buf[off++] = ' ';
829 buf[off] = '\0'; 829 buf[off] = '\0';
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 8f701cde5945..e5e301550e8a 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -152,7 +152,7 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
152 buff += 4; 152 buff += 4;
153 mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */ 153 mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */
154 154
155 priv = (struct lec_priv *)dev->priv; 155 priv = netdev_priv(dev);
156 atm_force_charge(priv->lecd, skb2->truesize); 156 atm_force_charge(priv->lecd, skb2->truesize);
157 sk = sk_atm(priv->lecd); 157 sk = sk_atm(priv->lecd);
158 skb_queue_tail(&sk->sk_receive_queue, skb2); 158 skb_queue_tail(&sk->sk_receive_queue, skb2);
@@ -218,7 +218,7 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
218 218
219static int lec_open(struct net_device *dev) 219static int lec_open(struct net_device *dev)
220{ 220{
221 struct lec_priv *priv = (struct lec_priv *)dev->priv; 221 struct lec_priv *priv = netdev_priv(dev);
222 222
223 netif_start_queue(dev); 223 netif_start_queue(dev);
224 memset(&priv->stats, 0, sizeof(struct net_device_stats)); 224 memset(&priv->stats, 0, sizeof(struct net_device_stats));
@@ -252,7 +252,7 @@ static void lec_tx_timeout(struct net_device *dev)
252static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev) 252static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
253{ 253{
254 struct sk_buff *skb2; 254 struct sk_buff *skb2;
255 struct lec_priv *priv = (struct lec_priv *)dev->priv; 255 struct lec_priv *priv = netdev_priv(dev);
256 struct lecdatahdr_8023 *lec_h; 256 struct lecdatahdr_8023 *lec_h;
257 struct atm_vcc *vcc; 257 struct atm_vcc *vcc;
258 struct lec_arp_table *entry; 258 struct lec_arp_table *entry;
@@ -373,19 +373,13 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
373 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { 373 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) {
374 pr_debug("%s:lec_start_xmit: queuing packet, ", 374 pr_debug("%s:lec_start_xmit: queuing packet, ",
375 dev->name); 375 dev->name);
376 pr_debug("MAC address " MAC_FMT "\n", 376 pr_debug("MAC address %pM\n", lec_h->h_dest);
377 lec_h->h_dest[0], lec_h->h_dest[1],
378 lec_h->h_dest[2], lec_h->h_dest[3],
379 lec_h->h_dest[4], lec_h->h_dest[5]);
380 skb_queue_tail(&entry->tx_wait, skb); 377 skb_queue_tail(&entry->tx_wait, skb);
381 } else { 378 } else {
382 pr_debug 379 pr_debug
383 ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", 380 ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ",
384 dev->name); 381 dev->name);
385 pr_debug("MAC address " MAC_FMT "\n", 382 pr_debug("MAC address %pM\n", lec_h->h_dest);
386 lec_h->h_dest[0], lec_h->h_dest[1],
387 lec_h->h_dest[2], lec_h->h_dest[3],
388 lec_h->h_dest[4], lec_h->h_dest[5]);
389 priv->stats.tx_dropped++; 383 priv->stats.tx_dropped++;
390 dev_kfree_skb(skb); 384 dev_kfree_skb(skb);
391 } 385 }
@@ -397,10 +391,7 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
397 391
398 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { 392 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) {
399 pr_debug("lec.c: emptying tx queue, "); 393 pr_debug("lec.c: emptying tx queue, ");
400 pr_debug("MAC address " MAC_FMT "\n", 394 pr_debug("MAC address %pM\n", lec_h->h_dest);
401 lec_h->h_dest[0], lec_h->h_dest[1],
402 lec_h->h_dest[2], lec_h->h_dest[3],
403 lec_h->h_dest[4], lec_h->h_dest[5]);
404 lec_send(vcc, skb2, priv); 395 lec_send(vcc, skb2, priv);
405 } 396 }
406 397
@@ -442,14 +433,14 @@ static int lec_close(struct net_device *dev)
442 */ 433 */
443static struct net_device_stats *lec_get_stats(struct net_device *dev) 434static struct net_device_stats *lec_get_stats(struct net_device *dev)
444{ 435{
445 return &((struct lec_priv *)dev->priv)->stats; 436 return &((struct lec_priv *)netdev_priv(dev))->stats;
446} 437}
447 438
448static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) 439static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
449{ 440{
450 unsigned long flags; 441 unsigned long flags;
451 struct net_device *dev = (struct net_device *)vcc->proto_data; 442 struct net_device *dev = (struct net_device *)vcc->proto_data;
452 struct lec_priv *priv = (struct lec_priv *)dev->priv; 443 struct lec_priv *priv = netdev_priv(dev);
453 struct atmlec_msg *mesg; 444 struct atmlec_msg *mesg;
454 struct lec_arp_table *entry; 445 struct lec_arp_table *entry;
455 int i; 446 int i;
@@ -539,15 +530,8 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
539 { 530 {
540 struct net_bridge_fdb_entry *f; 531 struct net_bridge_fdb_entry *f;
541 532
542 pr_debug 533 pr_debug("%s: bridge zeppelin asks about %pM\n",
543 ("%s: bridge zeppelin asks about " MAC_FMT "\n", 534 dev->name, mesg->content.proxy.mac_addr);
544 dev->name,
545 mesg->content.proxy.mac_addr[0],
546 mesg->content.proxy.mac_addr[1],
547 mesg->content.proxy.mac_addr[2],
548 mesg->content.proxy.mac_addr[3],
549 mesg->content.proxy.mac_addr[4],
550 mesg->content.proxy.mac_addr[5]);
551 535
552 if (br_fdb_get_hook == NULL || dev->br_port == NULL) 536 if (br_fdb_get_hook == NULL || dev->br_port == NULL)
553 break; 537 break;
@@ -596,7 +580,7 @@ static void lec_atm_close(struct atm_vcc *vcc)
596{ 580{
597 struct sk_buff *skb; 581 struct sk_buff *skb;
598 struct net_device *dev = (struct net_device *)vcc->proto_data; 582 struct net_device *dev = (struct net_device *)vcc->proto_data;
599 struct lec_priv *priv = (struct lec_priv *)dev->priv; 583 struct lec_priv *priv = netdev_priv(dev);
600 584
601 priv->lecd = NULL; 585 priv->lecd = NULL;
602 /* Do something needful? */ 586 /* Do something needful? */
@@ -727,7 +711,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
727{ 711{
728 unsigned long flags; 712 unsigned long flags;
729 struct net_device *dev = (struct net_device *)vcc->proto_data; 713 struct net_device *dev = (struct net_device *)vcc->proto_data;
730 struct lec_priv *priv = (struct lec_priv *)dev->priv; 714 struct lec_priv *priv = netdev_priv(dev);
731 715
732#if DUMP_PACKETS >0 716#if DUMP_PACKETS >0
733 int i = 0; 717 int i = 0;
@@ -874,7 +858,7 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
874 vpriv->old_pop = vcc->pop; 858 vpriv->old_pop = vcc->pop;
875 vcc->user_back = vpriv; 859 vcc->user_back = vpriv;
876 vcc->pop = lec_pop; 860 vcc->pop = lec_pop;
877 lec_vcc_added(dev_lec[ioc_data.dev_num]->priv, 861 lec_vcc_added(netdev_priv(dev_lec[ioc_data.dev_num]),
878 &ioc_data, vcc, vcc->push); 862 &ioc_data, vcc, vcc->push);
879 vcc->proto_data = dev_lec[ioc_data.dev_num]; 863 vcc->proto_data = dev_lec[ioc_data.dev_num];
880 vcc->push = lec_push; 864 vcc->push = lec_push;
@@ -886,7 +870,8 @@ static int lec_mcast_attach(struct atm_vcc *vcc, int arg)
886 if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) 870 if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg])
887 return -EINVAL; 871 return -EINVAL;
888 vcc->proto_data = dev_lec[arg]; 872 vcc->proto_data = dev_lec[arg];
889 return (lec_mcast_make((struct lec_priv *)dev_lec[arg]->priv, vcc)); 873 return lec_mcast_make((struct lec_priv *)netdev_priv(dev_lec[arg]),
874 vcc);
890} 875}
891 876
892/* Initialize device. */ 877/* Initialize device. */
@@ -928,11 +913,11 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
928 return -EINVAL; 913 return -EINVAL;
929 } 914 }
930 915
931 priv = dev_lec[i]->priv; 916 priv = netdev_priv(dev_lec[i]);
932 priv->is_trdev = is_trdev; 917 priv->is_trdev = is_trdev;
933 lec_init(dev_lec[i]); 918 lec_init(dev_lec[i]);
934 } else { 919 } else {
935 priv = dev_lec[i]->priv; 920 priv = netdev_priv(dev_lec[i]);
936 if (priv->lecd) 921 if (priv->lecd)
937 return -EADDRINUSE; 922 return -EADDRINUSE;
938 } 923 }
@@ -1093,7 +1078,8 @@ static void *lec_itf_walk(struct lec_state *state, loff_t *l)
1093 void *v; 1078 void *v;
1094 1079
1095 dev = state->dev ? state->dev : dev_lec[state->itf]; 1080 dev = state->dev ? state->dev : dev_lec[state->itf];
1096 v = (dev && dev->priv) ? lec_priv_walk(state, l, dev->priv) : NULL; 1081 v = (dev && netdev_priv(dev)) ?
1082 lec_priv_walk(state, l, netdev_priv(dev)) : NULL;
1097 if (!v && dev) { 1083 if (!v && dev) {
1098 dev_put(dev); 1084 dev_put(dev);
1099 /* Partial state reset for the next time we get called */ 1085 /* Partial state reset for the next time we get called */
@@ -1255,7 +1241,7 @@ static void __exit lane_module_cleanup(void)
1255 1241
1256 for (i = 0; i < MAX_LEC_ITF; i++) { 1242 for (i = 0; i < MAX_LEC_ITF; i++) {
1257 if (dev_lec[i] != NULL) { 1243 if (dev_lec[i] != NULL) {
1258 priv = (struct lec_priv *)dev_lec[i]->priv; 1244 priv = netdev_priv(dev_lec[i]);
1259 unregister_netdev(dev_lec[i]); 1245 unregister_netdev(dev_lec[i]);
1260 free_netdev(dev_lec[i]); 1246 free_netdev(dev_lec[i]);
1261 dev_lec[i] = NULL; 1247 dev_lec[i] = NULL;
@@ -1279,7 +1265,7 @@ static int lane2_resolve(struct net_device *dev, const u8 *dst_mac, int force,
1279 u8 **tlvs, u32 *sizeoftlvs) 1265 u8 **tlvs, u32 *sizeoftlvs)
1280{ 1266{
1281 unsigned long flags; 1267 unsigned long flags;
1282 struct lec_priv *priv = (struct lec_priv *)dev->priv; 1268 struct lec_priv *priv = netdev_priv(dev);
1283 struct lec_arp_table *table; 1269 struct lec_arp_table *table;
1284 struct sk_buff *skb; 1270 struct sk_buff *skb;
1285 int retval; 1271 int retval;
@@ -1326,7 +1312,7 @@ static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
1326{ 1312{
1327 int retval; 1313 int retval;
1328 struct sk_buff *skb; 1314 struct sk_buff *skb;
1329 struct lec_priv *priv = (struct lec_priv *)dev->priv; 1315 struct lec_priv *priv = netdev_priv(dev);
1330 1316
1331 if (compare_ether_addr(lan_dst, dev->dev_addr)) 1317 if (compare_ether_addr(lan_dst, dev->dev_addr))
1332 return (0); /* not our mac address */ 1318 return (0); /* not our mac address */
@@ -1363,7 +1349,7 @@ static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr,
1363#if 0 1349#if 0
1364 int i = 0; 1350 int i = 0;
1365#endif 1351#endif
1366 struct lec_priv *priv = (struct lec_priv *)dev->priv; 1352 struct lec_priv *priv = netdev_priv(dev);
1367#if 0 /* 1353#if 0 /*
1368 * Why have the TLVs in LE_ARP entries 1354 * Why have the TLVs in LE_ARP entries
1369 * since we do not use them? When you 1355 * since we do not use them? When you
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 11b16d16661c..12e9ea371db1 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -232,8 +232,8 @@ void atm_mpoa_disp_qos(struct seq_file *m)
232 seq_printf(m, "IP address\n TX:max_pcr pcr min_pcr max_cdv max_sdu\n RX:max_pcr pcr min_pcr max_cdv max_sdu\n"); 232 seq_printf(m, "IP address\n TX:max_pcr pcr min_pcr max_cdv max_sdu\n RX:max_pcr pcr min_pcr max_cdv max_sdu\n");
233 233
234 while (qos != NULL) { 234 while (qos != NULL) {
235 seq_printf(m, "%u.%u.%u.%u\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n", 235 seq_printf(m, "%pI4\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n",
236 NIPQUAD(qos->ipaddr), 236 &qos->ipaddr,
237 qos->qos.txtp.max_pcr, qos->qos.txtp.pcr, qos->qos.txtp.min_pcr, qos->qos.txtp.max_cdv, qos->qos.txtp.max_sdu, 237 qos->qos.txtp.max_pcr, qos->qos.txtp.pcr, qos->qos.txtp.min_pcr, qos->qos.txtp.max_cdv, qos->qos.txtp.max_sdu,
238 qos->qos.rxtp.max_pcr, qos->qos.rxtp.pcr, qos->qos.rxtp.min_pcr, qos->qos.rxtp.max_cdv, qos->qos.rxtp.max_sdu); 238 qos->qos.rxtp.max_pcr, qos->qos.rxtp.pcr, qos->qos.rxtp.min_pcr, qos->qos.rxtp.max_cdv, qos->qos.rxtp.max_sdu);
239 qos = qos->next; 239 qos = qos->next;
@@ -595,8 +595,8 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg)
595 if (in_entry != NULL) mpc->in_ops->put(in_entry); 595 if (in_entry != NULL) mpc->in_ops->put(in_entry);
596 return -EINVAL; 596 return -EINVAL;
597 } 597 }
598 printk("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %u.%u.%u.%u\n", 598 printk("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %pI4\n",
599 mpc->dev->name, NIPQUAD(in_entry->ctrl_info.in_dst_ip)); 599 mpc->dev->name, &in_entry->ctrl_info.in_dst_ip);
600 in_entry->shortcut = vcc; 600 in_entry->shortcut = vcc;
601 mpc->in_ops->put(in_entry); 601 mpc->in_ops->put(in_entry);
602 } else { 602 } else {
@@ -627,8 +627,8 @@ static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev)
627 dprintk("mpoa: (%s) mpc_vcc_close:\n", dev->name); 627 dprintk("mpoa: (%s) mpc_vcc_close:\n", dev->name);
628 in_entry = mpc->in_ops->get_by_vcc(vcc, mpc); 628 in_entry = mpc->in_ops->get_by_vcc(vcc, mpc);
629 if (in_entry) { 629 if (in_entry) {
630 dprintk("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %u.%u.%u.%u\n", 630 dprintk("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %pI4\n",
631 mpc->dev->name, NIPQUAD(in_entry->ctrl_info.in_dst_ip)); 631 mpc->dev->name, &in_entry->ctrl_info.in_dst_ip);
632 in_entry->shortcut = NULL; 632 in_entry->shortcut = NULL;
633 mpc->in_ops->put(in_entry); 633 mpc->in_ops->put(in_entry);
634 } 634 }
@@ -785,7 +785,7 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)
785 } 785 }
786 786
787 if (mpc->dev) { /* check if the lec is LANE2 capable */ 787 if (mpc->dev) { /* check if the lec is LANE2 capable */
788 priv = (struct lec_priv *)mpc->dev->priv; 788 priv = netdev_priv(mpc->dev);
789 if (priv->lane_version < 2) { 789 if (priv->lane_version < 2) {
790 dev_put(mpc->dev); 790 dev_put(mpc->dev);
791 mpc->dev = NULL; 791 mpc->dev = NULL;
@@ -845,7 +845,7 @@ static void mpoad_close(struct atm_vcc *vcc)
845 845
846 mpc->mpoad_vcc = NULL; 846 mpc->mpoad_vcc = NULL;
847 if (mpc->dev) { 847 if (mpc->dev) {
848 struct lec_priv *priv = (struct lec_priv *)mpc->dev->priv; 848 struct lec_priv *priv = netdev_priv(mpc->dev);
849 priv->lane2_ops->associate_indicator = NULL; 849 priv->lane2_ops->associate_indicator = NULL;
850 stop_mpc(mpc); 850 stop_mpc(mpc);
851 dev_put(mpc->dev); 851 dev_put(mpc->dev);
@@ -976,7 +976,7 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo
976 976
977 switch (event) { 977 switch (event) {
978 case NETDEV_REGISTER: /* a new lec device was allocated */ 978 case NETDEV_REGISTER: /* a new lec device was allocated */
979 priv = (struct lec_priv *)dev->priv; 979 priv = netdev_priv(dev);
980 if (priv->lane_version < 2) 980 if (priv->lane_version < 2)
981 break; 981 break;
982 priv->lane2_ops->associate_indicator = lane2_assoc_ind; 982 priv->lane2_ops->associate_indicator = lane2_assoc_ind;
@@ -1098,7 +1098,8 @@ static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_clien
1098 entry->shortcut = eg_entry->shortcut; 1098 entry->shortcut = eg_entry->shortcut;
1099 } 1099 }
1100 if(entry->shortcut){ 1100 if(entry->shortcut){
1101 dprintk("mpoa: (%s) using egress SVC to reach %u.%u.%u.%u\n",client->dev->name, NIPQUAD(dst_ip)); 1101 dprintk("mpoa: (%s) using egress SVC to reach %pI4\n",
1102 client->dev->name, &dst_ip);
1102 client->eg_ops->put(eg_entry); 1103 client->eg_ops->put(eg_entry);
1103 return; 1104 return;
1104 } 1105 }
@@ -1123,7 +1124,8 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1123 __be32 dst_ip = msg->content.in_info.in_dst_ip; 1124 __be32 dst_ip = msg->content.in_info.in_dst_ip;
1124 in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc); 1125 in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc);
1125 1126
1126 dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %u.%u.%u.%u\n", mpc->dev->name, NIPQUAD(dst_ip)); 1127 dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %pI4\n",
1128 mpc->dev->name, &dst_ip);
1127 ddprintk("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p", mpc->dev->name, entry); 1129 ddprintk("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p", mpc->dev->name, entry);
1128 if(entry == NULL){ 1130 if(entry == NULL){
1129 printk("\nmpoa: (%s) ARGH, received res. reply for an entry that doesn't exist.\n", mpc->dev->name); 1131 printk("\nmpoa: (%s) ARGH, received res. reply for an entry that doesn't exist.\n", mpc->dev->name);
@@ -1171,14 +1173,14 @@ static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1171 in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); 1173 in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask);
1172 1174
1173 if(entry == NULL){ 1175 if(entry == NULL){
1174 printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ", mpc->dev->name); 1176 printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ip = %pI4\n",
1175 printk("ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip)); 1177 mpc->dev->name, &dst_ip);
1176 return; 1178 return;
1177 } 1179 }
1178 1180
1179 do { 1181 do {
1180 dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %u.%u.%u.%u\n" , 1182 dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %pI4\n",
1181 mpc->dev->name, NIPQUAD(dst_ip)); 1183 mpc->dev->name, &dst_ip);
1182 write_lock_bh(&mpc->ingress_lock); 1184 write_lock_bh(&mpc->ingress_lock);
1183 mpc->in_ops->remove_entry(entry, mpc); 1185 mpc->in_ops->remove_entry(entry, mpc);
1184 write_unlock_bh(&mpc->ingress_lock); 1186 write_unlock_bh(&mpc->ingress_lock);
@@ -1322,7 +1324,7 @@ static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *m
1322 dprintk("\n"); 1324 dprintk("\n");
1323 1325
1324 if (mpc->dev) { 1326 if (mpc->dev) {
1325 priv = (struct lec_priv *)mpc->dev->priv; 1327 priv = netdev_priv(mpc->dev);
1326 retval = priv->lane2_ops->associate_req(mpc->dev, mpc->dev->dev_addr, tlv, sizeof(tlv)); 1328 retval = priv->lane2_ops->associate_req(mpc->dev, mpc->dev->dev_addr, tlv, sizeof(tlv));
1327 if (retval == 0) 1329 if (retval == 0)
1328 printk("mpoa: (%s) MPOA device type TLV association failed\n", mpc->dev->name); 1330 printk("mpoa: (%s) MPOA device type TLV association failed\n", mpc->dev->name);
@@ -1472,7 +1474,7 @@ static void __exit atm_mpoa_cleanup(void)
1472 tmp = mpc->next; 1474 tmp = mpc->next;
1473 if (mpc->dev != NULL) { 1475 if (mpc->dev != NULL) {
1474 stop_mpc(mpc); 1476 stop_mpc(mpc);
1475 priv = (struct lec_priv *)mpc->dev->priv; 1477 priv = netdev_priv(mpc->dev);
1476 if (priv->lane2_ops != NULL) 1478 if (priv->lane2_ops != NULL)
1477 priv->lane2_ops->associate_indicator = NULL; 1479 priv->lane2_ops->associate_indicator = NULL;
1478 } 1480 }
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
index 24799e3e78f7..4504a4b339bb 100644
--- a/net/atm/mpoa_caches.c
+++ b/net/atm/mpoa_caches.c
@@ -94,7 +94,7 @@ static in_cache_entry *in_cache_add_entry(__be32 dst_ip,
94 return NULL; 94 return NULL;
95 } 95 }
96 96
97 dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip)); 97 dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %pI4\n", &dst_ip);
98 98
99 atomic_set(&entry->use, 1); 99 atomic_set(&entry->use, 1);
100 dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n"); 100 dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n");
@@ -150,7 +150,8 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc)
150 150
151 if( entry->count > mpc->parameters.mpc_p1 && 151 if( entry->count > mpc->parameters.mpc_p1 &&
152 entry->entry_state == INGRESS_INVALID){ 152 entry->entry_state == INGRESS_INVALID){
153 dprintk("mpoa: (%s) mpoa_caches.c: threshold exceeded for ip %u.%u.%u.%u, sending MPOA res req\n", mpc->dev->name, NIPQUAD(entry->ctrl_info.in_dst_ip)); 153 dprintk("mpoa: (%s) mpoa_caches.c: threshold exceeded for ip %pI4, sending MPOA res req\n",
154 mpc->dev->name, &entry->ctrl_info.in_dst_ip);
154 entry->entry_state = INGRESS_RESOLVING; 155 entry->entry_state = INGRESS_RESOLVING;
155 msg.type = SND_MPOA_RES_RQST; 156 msg.type = SND_MPOA_RES_RQST;
156 memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN ); 157 memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN );
@@ -184,7 +185,8 @@ static void in_cache_remove_entry(in_cache_entry *entry,
184 struct k_message msg; 185 struct k_message msg;
185 186
186 vcc = entry->shortcut; 187 vcc = entry->shortcut;
187 dprintk("mpoa: mpoa_caches.c: removing an ingress entry, ip = %u.%u.%u.%u\n",NIPQUAD(entry->ctrl_info.in_dst_ip)); 188 dprintk("mpoa: mpoa_caches.c: removing an ingress entry, ip = %pI4\n",
189 &entry->ctrl_info.in_dst_ip);
188 190
189 if (entry->prev != NULL) 191 if (entry->prev != NULL)
190 entry->prev->next = entry->next; 192 entry->prev->next = entry->next;
@@ -228,7 +230,8 @@ static void clear_count_and_expired(struct mpoa_client *client)
228 next_entry = entry->next; 230 next_entry = entry->next;
229 if((now.tv_sec - entry->tv.tv_sec) 231 if((now.tv_sec - entry->tv.tv_sec)
230 > entry->ctrl_info.holding_time){ 232 > entry->ctrl_info.holding_time){
231 dprintk("mpoa: mpoa_caches.c: holding time expired, ip = %u.%u.%u.%u\n", NIPQUAD(entry->ctrl_info.in_dst_ip)); 233 dprintk("mpoa: mpoa_caches.c: holding time expired, ip = %pI4\n",
234 &entry->ctrl_info.in_dst_ip);
232 client->in_ops->remove_entry(entry, client); 235 client->in_ops->remove_entry(entry, client);
233 } 236 }
234 entry = next_entry; 237 entry = next_entry;
@@ -453,7 +456,8 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_cli
453 return NULL; 456 return NULL;
454 } 457 }
455 458
456 dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %u.%u.%u.%u, this should be our IP\n", NIPQUAD(msg->content.eg_info.eg_dst_ip)); 459 dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %pI4, this should be our IP\n",
460 &msg->content.eg_info.eg_dst_ip);
457 461
458 atomic_set(&entry->use, 1); 462 atomic_set(&entry->use, 1);
459 dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n"); 463 dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n");
@@ -469,8 +473,8 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_cli
469 do_gettimeofday(&(entry->tv)); 473 do_gettimeofday(&(entry->tv));
470 entry->entry_state = EGRESS_RESOLVED; 474 entry->entry_state = EGRESS_RESOLVED;
471 dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry cache_id %lu\n", ntohl(entry->ctrl_info.cache_id)); 475 dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry cache_id %lu\n", ntohl(entry->ctrl_info.cache_id));
472 dprintk("mpoa: mpoa_caches.c: mps_ip = %u.%u.%u.%u\n", 476 dprintk("mpoa: mpoa_caches.c: mps_ip = %pI4\n",
473 NIPQUAD(entry->ctrl_info.mps_ip)); 477 &entry->ctrl_info.mps_ip);
474 atomic_inc(&entry->use); 478 atomic_inc(&entry->use);
475 479
476 write_unlock_irq(&client->egress_lock); 480 write_unlock_irq(&client->egress_lock);
diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
index f288fc4aef9b..c1d877bb5dff 100644
--- a/net/ax25/sysctl_net_ax25.c
+++ b/net/ax25/sysctl_net_ax25.c
@@ -43,8 +43,8 @@ static const ctl_table ax25_param_table[] = {
43 .procname = "ip_default_mode", 43 .procname = "ip_default_mode",
44 .maxlen = sizeof(int), 44 .maxlen = sizeof(int),
45 .mode = 0644, 45 .mode = 0644,
46 .proc_handler = &proc_dointvec_minmax, 46 .proc_handler = proc_dointvec_minmax,
47 .strategy = &sysctl_intvec, 47 .strategy = sysctl_intvec,
48 .extra1 = &min_ipdefmode, 48 .extra1 = &min_ipdefmode,
49 .extra2 = &max_ipdefmode 49 .extra2 = &max_ipdefmode
50 }, 50 },
@@ -53,8 +53,8 @@ static const ctl_table ax25_param_table[] = {
53 .procname = "ax25_default_mode", 53 .procname = "ax25_default_mode",
54 .maxlen = sizeof(int), 54 .maxlen = sizeof(int),
55 .mode = 0644, 55 .mode = 0644,
56 .proc_handler = &proc_dointvec_minmax, 56 .proc_handler = proc_dointvec_minmax,
57 .strategy = &sysctl_intvec, 57 .strategy = sysctl_intvec,
58 .extra1 = &min_axdefmode, 58 .extra1 = &min_axdefmode,
59 .extra2 = &max_axdefmode 59 .extra2 = &max_axdefmode
60 }, 60 },
@@ -63,8 +63,8 @@ static const ctl_table ax25_param_table[] = {
63 .procname = "backoff_type", 63 .procname = "backoff_type",
64 .maxlen = sizeof(int), 64 .maxlen = sizeof(int),
65 .mode = 0644, 65 .mode = 0644,
66 .proc_handler = &proc_dointvec_minmax, 66 .proc_handler = proc_dointvec_minmax,
67 .strategy = &sysctl_intvec, 67 .strategy = sysctl_intvec,
68 .extra1 = &min_backoff, 68 .extra1 = &min_backoff,
69 .extra2 = &max_backoff 69 .extra2 = &max_backoff
70 }, 70 },
@@ -73,8 +73,8 @@ static const ctl_table ax25_param_table[] = {
73 .procname = "connect_mode", 73 .procname = "connect_mode",
74 .maxlen = sizeof(int), 74 .maxlen = sizeof(int),
75 .mode = 0644, 75 .mode = 0644,
76 .proc_handler = &proc_dointvec_minmax, 76 .proc_handler = proc_dointvec_minmax,
77 .strategy = &sysctl_intvec, 77 .strategy = sysctl_intvec,
78 .extra1 = &min_conmode, 78 .extra1 = &min_conmode,
79 .extra2 = &max_conmode 79 .extra2 = &max_conmode
80 }, 80 },
@@ -83,8 +83,8 @@ static const ctl_table ax25_param_table[] = {
83 .procname = "standard_window_size", 83 .procname = "standard_window_size",
84 .maxlen = sizeof(int), 84 .maxlen = sizeof(int),
85 .mode = 0644, 85 .mode = 0644,
86 .proc_handler = &proc_dointvec_minmax, 86 .proc_handler = proc_dointvec_minmax,
87 .strategy = &sysctl_intvec, 87 .strategy = sysctl_intvec,
88 .extra1 = &min_window, 88 .extra1 = &min_window,
89 .extra2 = &max_window 89 .extra2 = &max_window
90 }, 90 },
@@ -93,8 +93,8 @@ static const ctl_table ax25_param_table[] = {
93 .procname = "extended_window_size", 93 .procname = "extended_window_size",
94 .maxlen = sizeof(int), 94 .maxlen = sizeof(int),
95 .mode = 0644, 95 .mode = 0644,
96 .proc_handler = &proc_dointvec_minmax, 96 .proc_handler = proc_dointvec_minmax,
97 .strategy = &sysctl_intvec, 97 .strategy = sysctl_intvec,
98 .extra1 = &min_ewindow, 98 .extra1 = &min_ewindow,
99 .extra2 = &max_ewindow 99 .extra2 = &max_ewindow
100 }, 100 },
@@ -103,8 +103,8 @@ static const ctl_table ax25_param_table[] = {
103 .procname = "t1_timeout", 103 .procname = "t1_timeout",
104 .maxlen = sizeof(int), 104 .maxlen = sizeof(int),
105 .mode = 0644, 105 .mode = 0644,
106 .proc_handler = &proc_dointvec_minmax, 106 .proc_handler = proc_dointvec_minmax,
107 .strategy = &sysctl_intvec, 107 .strategy = sysctl_intvec,
108 .extra1 = &min_t1, 108 .extra1 = &min_t1,
109 .extra2 = &max_t1 109 .extra2 = &max_t1
110 }, 110 },
@@ -113,8 +113,8 @@ static const ctl_table ax25_param_table[] = {
113 .procname = "t2_timeout", 113 .procname = "t2_timeout",
114 .maxlen = sizeof(int), 114 .maxlen = sizeof(int),
115 .mode = 0644, 115 .mode = 0644,
116 .proc_handler = &proc_dointvec_minmax, 116 .proc_handler = proc_dointvec_minmax,
117 .strategy = &sysctl_intvec, 117 .strategy = sysctl_intvec,
118 .extra1 = &min_t2, 118 .extra1 = &min_t2,
119 .extra2 = &max_t2 119 .extra2 = &max_t2
120 }, 120 },
@@ -123,8 +123,8 @@ static const ctl_table ax25_param_table[] = {
123 .procname = "t3_timeout", 123 .procname = "t3_timeout",
124 .maxlen = sizeof(int), 124 .maxlen = sizeof(int),
125 .mode = 0644, 125 .mode = 0644,
126 .proc_handler = &proc_dointvec_minmax, 126 .proc_handler = proc_dointvec_minmax,
127 .strategy = &sysctl_intvec, 127 .strategy = sysctl_intvec,
128 .extra1 = &min_t3, 128 .extra1 = &min_t3,
129 .extra2 = &max_t3 129 .extra2 = &max_t3
130 }, 130 },
@@ -133,8 +133,8 @@ static const ctl_table ax25_param_table[] = {
133 .procname = "idle_timeout", 133 .procname = "idle_timeout",
134 .maxlen = sizeof(int), 134 .maxlen = sizeof(int),
135 .mode = 0644, 135 .mode = 0644,
136 .proc_handler = &proc_dointvec_minmax, 136 .proc_handler = proc_dointvec_minmax,
137 .strategy = &sysctl_intvec, 137 .strategy = sysctl_intvec,
138 .extra1 = &min_idle, 138 .extra1 = &min_idle,
139 .extra2 = &max_idle 139 .extra2 = &max_idle
140 }, 140 },
@@ -143,8 +143,8 @@ static const ctl_table ax25_param_table[] = {
143 .procname = "maximum_retry_count", 143 .procname = "maximum_retry_count",
144 .maxlen = sizeof(int), 144 .maxlen = sizeof(int),
145 .mode = 0644, 145 .mode = 0644,
146 .proc_handler = &proc_dointvec_minmax, 146 .proc_handler = proc_dointvec_minmax,
147 .strategy = &sysctl_intvec, 147 .strategy = sysctl_intvec,
148 .extra1 = &min_n2, 148 .extra1 = &min_n2,
149 .extra2 = &max_n2 149 .extra2 = &max_n2
150 }, 150 },
@@ -153,8 +153,8 @@ static const ctl_table ax25_param_table[] = {
153 .procname = "maximum_packet_length", 153 .procname = "maximum_packet_length",
154 .maxlen = sizeof(int), 154 .maxlen = sizeof(int),
155 .mode = 0644, 155 .mode = 0644,
156 .proc_handler = &proc_dointvec_minmax, 156 .proc_handler = proc_dointvec_minmax,
157 .strategy = &sysctl_intvec, 157 .strategy = sysctl_intvec,
158 .extra1 = &min_paclen, 158 .extra1 = &min_paclen,
159 .extra2 = &max_paclen 159 .extra2 = &max_paclen
160 }, 160 },
@@ -163,8 +163,8 @@ static const ctl_table ax25_param_table[] = {
163 .procname = "protocol", 163 .procname = "protocol",
164 .maxlen = sizeof(int), 164 .maxlen = sizeof(int),
165 .mode = 0644, 165 .mode = 0644,
166 .proc_handler = &proc_dointvec_minmax, 166 .proc_handler = proc_dointvec_minmax,
167 .strategy = &sysctl_intvec, 167 .strategy = sysctl_intvec,
168 .extra1 = &min_proto, 168 .extra1 = &min_proto,
169 .extra2 = &max_proto 169 .extra2 = &max_proto
170 }, 170 },
@@ -174,8 +174,8 @@ static const ctl_table ax25_param_table[] = {
174 .procname = "dama_slave_timeout", 174 .procname = "dama_slave_timeout",
175 .maxlen = sizeof(int), 175 .maxlen = sizeof(int),
176 .mode = 0644, 176 .mode = 0644,
177 .proc_handler = &proc_dointvec_minmax, 177 .proc_handler = proc_dointvec_minmax,
178 .strategy = &sysctl_intvec, 178 .strategy = sysctl_intvec,
179 .extra1 = &min_ds_timeout, 179 .extra1 = &min_ds_timeout,
180 .extra2 = &max_ds_timeout 180 .extra2 = &max_ds_timeout
181 }, 181 },
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 80ba30cf4b68..f8efaf35293c 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -311,7 +311,6 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
311 struct sk_buff *nskb; 311 struct sk_buff *nskb;
312 u8 type; 312 u8 type;
313 313
314 dev->last_rx = jiffies;
315 s->stats.rx_bytes += skb->len; 314 s->stats.rx_bytes += skb->len;
316 315
317 type = *(u8 *) skb->data; skb_pull(skb, 1); 316 type = *(u8 *) skb->data; skb_pull(skb, 1);
@@ -566,7 +565,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
566 goto failed; 565 goto failed;
567 } 566 }
568 567
569 s = dev->priv; 568 s = netdev_priv(dev);
570 569
571 /* This is rx header therefore addresses are swapped. 570 /* This is rx header therefore addresses are swapped.
572 * ie eh.h_dest is our local address. */ 571 * ie eh.h_dest is our local address. */
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c
index d9fa0ab2c87f..47e179f62e82 100644
--- a/net/bluetooth/bnep/netdev.c
+++ b/net/bluetooth/bnep/netdev.c
@@ -62,14 +62,14 @@ static int bnep_net_close(struct net_device *dev)
62 62
63static struct net_device_stats *bnep_net_get_stats(struct net_device *dev) 63static struct net_device_stats *bnep_net_get_stats(struct net_device *dev)
64{ 64{
65 struct bnep_session *s = dev->priv; 65 struct bnep_session *s = netdev_priv(dev);
66 return &s->stats; 66 return &s->stats;
67} 67}
68 68
69static void bnep_net_set_mc_list(struct net_device *dev) 69static void bnep_net_set_mc_list(struct net_device *dev)
70{ 70{
71#ifdef CONFIG_BT_BNEP_MC_FILTER 71#ifdef CONFIG_BT_BNEP_MC_FILTER
72 struct bnep_session *s = dev->priv; 72 struct bnep_session *s = netdev_priv(dev);
73 struct sock *sk = s->sock->sk; 73 struct sock *sk = s->sock->sk;
74 struct bnep_set_filter_req *r; 74 struct bnep_set_filter_req *r;
75 struct sk_buff *skb; 75 struct sk_buff *skb;
@@ -183,7 +183,7 @@ static inline int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session
183 183
184static int bnep_net_xmit(struct sk_buff *skb, struct net_device *dev) 184static int bnep_net_xmit(struct sk_buff *skb, struct net_device *dev)
185{ 185{
186 struct bnep_session *s = dev->priv; 186 struct bnep_session *s = netdev_priv(dev);
187 struct sock *sk = s->sock->sk; 187 struct sock *sk = s->sock->sk;
188 188
189 BT_DBG("skb %p, dev %p", skb, dev); 189 BT_DBG("skb %p, dev %p", skb, dev);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index f4f6615cad9f..f2bbb2f65434 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -113,8 +113,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
113 conn->dev.class = bt_class; 113 conn->dev.class = bt_class;
114 conn->dev.parent = &hdev->dev; 114 conn->dev.parent = &hdev->dev;
115 115
116 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d", 116 dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
117 hdev->name, conn->handle);
118 117
119 dev_set_drvdata(&conn->dev, conn); 118 dev_set_drvdata(&conn->dev, conn);
120 119
@@ -132,7 +131,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
132 */ 131 */
133static int __match_tty(struct device *dev, void *data) 132static int __match_tty(struct device *dev, void *data)
134{ 133{
135 return !strncmp(dev->bus_id, "rfcomm", 6); 134 return !strncmp(dev_name(dev), "rfcomm", 6);
136} 135}
137 136
138static void del_conn(struct work_struct *work) 137static void del_conn(struct work_struct *work)
@@ -421,7 +420,7 @@ int hci_register_sysfs(struct hci_dev *hdev)
421 dev->class = bt_class; 420 dev->class = bt_class;
422 dev->parent = hdev->parent; 421 dev->parent = hdev->parent;
423 422
424 strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); 423 dev_set_name(dev, hdev->name);
425 424
426 dev_set_drvdata(dev, hdev); 425 dev_set_drvdata(dev, hdev);
427 426
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 6c023f0f8252..920ce3348398 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -147,7 +147,7 @@ static int br_set_tx_csum(struct net_device *dev, u32 data)
147 return 0; 147 return 0;
148} 148}
149 149
150static struct ethtool_ops br_ethtool_ops = { 150static const struct ethtool_ops br_ethtool_ops = {
151 .get_drvinfo = br_getinfo, 151 .get_drvinfo = br_getinfo,
152 .get_link = ethtool_op_get_link, 152 .get_link = ethtool_op_get_link,
153 .get_tx_csum = ethtool_op_get_tx_csum, 153 .get_tx_csum = ethtool_op_get_tx_csum,
@@ -160,21 +160,25 @@ static struct ethtool_ops br_ethtool_ops = {
160 .get_flags = ethtool_op_get_flags, 160 .get_flags = ethtool_op_get_flags,
161}; 161};
162 162
163static const struct net_device_ops br_netdev_ops = {
164 .ndo_open = br_dev_open,
165 .ndo_stop = br_dev_stop,
166 .ndo_set_mac_address = br_set_mac_address,
167 .ndo_set_multicast_list = br_dev_set_multicast_list,
168 .ndo_change_mtu = br_change_mtu,
169 .ndo_do_ioctl = br_dev_ioctl,
170};
171
163void br_dev_setup(struct net_device *dev) 172void br_dev_setup(struct net_device *dev)
164{ 173{
165 random_ether_addr(dev->dev_addr); 174 random_ether_addr(dev->dev_addr);
166 ether_setup(dev); 175 ether_setup(dev);
167 176
168 dev->do_ioctl = br_dev_ioctl; 177 dev->netdev_ops = &br_netdev_ops;
169 dev->hard_start_xmit = br_dev_xmit; 178 dev->hard_start_xmit = br_dev_xmit;
170 dev->open = br_dev_open;
171 dev->set_multicast_list = br_dev_set_multicast_list;
172 dev->change_mtu = br_change_mtu;
173 dev->destructor = free_netdev; 179 dev->destructor = free_netdev;
174 SET_ETHTOOL_OPS(dev, &br_ethtool_ops); 180 SET_ETHTOOL_OPS(dev, &br_ethtool_ops);
175 dev->stop = br_dev_stop;
176 dev->tx_queue_len = 0; 181 dev->tx_queue_len = 0;
177 dev->set_mac_address = br_set_mac_address;
178 dev->priv_flags = IFF_EBRIDGE; 182 dev->priv_flags = IFF_EBRIDGE;
179 183
180 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | 184 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 0a09ccf68c1c..ee3a8dd13f55 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -460,7 +460,7 @@ void br_net_exit(struct net *net)
460restart: 460restart:
461 for_each_netdev(net, dev) { 461 for_each_netdev(net, dev) {
462 if (dev->priv_flags & IFF_EBRIDGE) { 462 if (dev->priv_flags & IFF_EBRIDGE) {
463 del_br(dev->priv); 463 del_br(netdev_priv(dev));
464 goto restart; 464 goto restart;
465 } 465 }
466 } 466 }
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index fa5cda4e552a..db6176d96e71 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -938,35 +938,35 @@ static ctl_table brnf_table[] = {
938 .data = &brnf_call_arptables, 938 .data = &brnf_call_arptables,
939 .maxlen = sizeof(int), 939 .maxlen = sizeof(int),
940 .mode = 0644, 940 .mode = 0644,
941 .proc_handler = &brnf_sysctl_call_tables, 941 .proc_handler = brnf_sysctl_call_tables,
942 }, 942 },
943 { 943 {
944 .procname = "bridge-nf-call-iptables", 944 .procname = "bridge-nf-call-iptables",
945 .data = &brnf_call_iptables, 945 .data = &brnf_call_iptables,
946 .maxlen = sizeof(int), 946 .maxlen = sizeof(int),
947 .mode = 0644, 947 .mode = 0644,
948 .proc_handler = &brnf_sysctl_call_tables, 948 .proc_handler = brnf_sysctl_call_tables,
949 }, 949 },
950 { 950 {
951 .procname = "bridge-nf-call-ip6tables", 951 .procname = "bridge-nf-call-ip6tables",
952 .data = &brnf_call_ip6tables, 952 .data = &brnf_call_ip6tables,
953 .maxlen = sizeof(int), 953 .maxlen = sizeof(int),
954 .mode = 0644, 954 .mode = 0644,
955 .proc_handler = &brnf_sysctl_call_tables, 955 .proc_handler = brnf_sysctl_call_tables,
956 }, 956 },
957 { 957 {
958 .procname = "bridge-nf-filter-vlan-tagged", 958 .procname = "bridge-nf-filter-vlan-tagged",
959 .data = &brnf_filter_vlan_tagged, 959 .data = &brnf_filter_vlan_tagged,
960 .maxlen = sizeof(int), 960 .maxlen = sizeof(int),
961 .mode = 0644, 961 .mode = 0644,
962 .proc_handler = &brnf_sysctl_call_tables, 962 .proc_handler = brnf_sysctl_call_tables,
963 }, 963 },
964 { 964 {
965 .procname = "bridge-nf-filter-pppoe-tagged", 965 .procname = "bridge-nf-filter-pppoe-tagged",
966 .data = &brnf_filter_pppoe_tagged, 966 .data = &brnf_filter_pppoe_tagged,
967 .maxlen = sizeof(int), 967 .maxlen = sizeof(int),
968 .mode = 0644, 968 .mode = 0644,
969 .proc_handler = &brnf_sysctl_call_tables, 969 .proc_handler = brnf_sysctl_call_tables,
970 }, 970 },
971 { .ctl_name = 0 } 971 { .ctl_name = 0 }
972}; 972};
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 158dee8b4965..603d89248e71 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -22,7 +22,7 @@
22#include "br_private.h" 22#include "br_private.h"
23 23
24#define to_dev(obj) container_of(obj, struct device, kobj) 24#define to_dev(obj) container_of(obj, struct device, kobj)
25#define to_bridge(cd) ((struct net_bridge *)(to_net_dev(cd)->priv)) 25#define to_bridge(cd) ((struct net_bridge *)netdev_priv(to_net_dev(cd)))
26 26
27/* 27/*
28 * Common code for storing bridge parameters. 28 * Common code for storing bridge parameters.
diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c
index 3d33c608906a..d44cbf8c374a 100644
--- a/net/bridge/netfilter/ebt_log.c
+++ b/net/bridge/netfilter/ebt_log.c
@@ -79,7 +79,6 @@ print_ports(const struct sk_buff *skb, uint8_t protocol, int offset)
79 } 79 }
80} 80}
81 81
82#define myNIPQUAD(a) a[0], a[1], a[2], a[3]
83static void 82static void
84ebt_log_packet(u_int8_t pf, unsigned int hooknum, 83ebt_log_packet(u_int8_t pf, unsigned int hooknum,
85 const struct sk_buff *skb, const struct net_device *in, 84 const struct sk_buff *skb, const struct net_device *in,
@@ -113,9 +112,8 @@ ebt_log_packet(u_int8_t pf, unsigned int hooknum,
113 printk(" INCOMPLETE IP header"); 112 printk(" INCOMPLETE IP header");
114 goto out; 113 goto out;
115 } 114 }
116 printk(" IP SRC=%u.%u.%u.%u IP DST=%u.%u.%u.%u, IP " 115 printk(" IP SRC=%pI4 IP DST=%pI4, IP tos=0x%02X, IP proto=%d",
117 "tos=0x%02X, IP proto=%d", NIPQUAD(ih->saddr), 116 &ih->saddr, &ih->daddr, ih->tos, ih->protocol);
118 NIPQUAD(ih->daddr), ih->tos, ih->protocol);
119 print_ports(skb, ih->protocol, ih->ihl*4); 117 print_ports(skb, ih->protocol, ih->ihl*4);
120 goto out; 118 goto out;
121 } 119 }
@@ -133,10 +131,8 @@ ebt_log_packet(u_int8_t pf, unsigned int hooknum,
133 printk(" INCOMPLETE IPv6 header"); 131 printk(" INCOMPLETE IPv6 header");
134 goto out; 132 goto out;
135 } 133 }
136 printk(" IPv6 SRC=%x:%x:%x:%x:%x:%x:%x:%x " 134 printk(" IPv6 SRC=%pI6 IPv6 DST=%pI6, IPv6 priority=0x%01X, Next Header=%d",
137 "IPv6 DST=%x:%x:%x:%x:%x:%x:%x:%x, IPv6 " 135 &ih->saddr, &ih->daddr, ih->priority, ih->nexthdr);
138 "priority=0x%01X, Next Header=%d", NIP6(ih->saddr),
139 NIP6(ih->daddr), ih->priority, ih->nexthdr);
140 nexthdr = ih->nexthdr; 136 nexthdr = ih->nexthdr;
141 offset_ph = ipv6_skip_exthdr(skb, sizeof(_iph), &nexthdr); 137 offset_ph = ipv6_skip_exthdr(skb, sizeof(_iph), &nexthdr);
142 if (offset_ph == -1) 138 if (offset_ph == -1)
@@ -177,12 +173,10 @@ ebt_log_packet(u_int8_t pf, unsigned int hooknum,
177 } 173 }
178 printk(" ARP MAC SRC="); 174 printk(" ARP MAC SRC=");
179 print_MAC(ap->mac_src); 175 print_MAC(ap->mac_src);
180 printk(" ARP IP SRC=%u.%u.%u.%u", 176 printk(" ARP IP SRC=%pI4", ap->ip_src);
181 myNIPQUAD(ap->ip_src));
182 printk(" ARP MAC DST="); 177 printk(" ARP MAC DST=");
183 print_MAC(ap->mac_dst); 178 print_MAC(ap->mac_dst);
184 printk(" ARP IP DST=%u.%u.%u.%u", 179 printk(" ARP IP DST=%pI4", ap->ip_dst);
185 myNIPQUAD(ap->ip_dst));
186 } 180 }
187 } 181 }
188out: 182out:
diff --git a/net/core/datagram.c b/net/core/datagram.c
index ee631843c2f5..5e2ac0c4b07c 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -209,7 +209,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
209void skb_free_datagram(struct sock *sk, struct sk_buff *skb) 209void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
210{ 210{
211 kfree_skb(skb); 211 kfree_skb(skb);
212 sk_mem_reclaim(sk); 212 sk_mem_reclaim_partial(sk);
213} 213}
214 214
215/** 215/**
@@ -248,8 +248,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
248 spin_unlock_bh(&sk->sk_receive_queue.lock); 248 spin_unlock_bh(&sk->sk_receive_queue.lock);
249 } 249 }
250 250
251 kfree_skb(skb); 251 skb_free_datagram(sk, skb);
252 sk_mem_reclaim(sk);
253 return err; 252 return err;
254} 253}
255 254
diff --git a/net/core/dev.c b/net/core/dev.c
index 9174c77d3112..8843f4e3f5e1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -108,7 +108,6 @@
108#include <linux/init.h> 108#include <linux/init.h>
109#include <linux/kmod.h> 109#include <linux/kmod.h>
110#include <linux/module.h> 110#include <linux/module.h>
111#include <linux/kallsyms.h>
112#include <linux/netpoll.h> 111#include <linux/netpoll.h>
113#include <linux/rcupdate.h> 112#include <linux/rcupdate.h>
114#include <linux/delay.h> 113#include <linux/delay.h>
@@ -924,10 +923,15 @@ int dev_change_name(struct net_device *dev, const char *newname)
924 strlcpy(dev->name, newname, IFNAMSIZ); 923 strlcpy(dev->name, newname, IFNAMSIZ);
925 924
926rollback: 925rollback:
927 ret = device_rename(&dev->dev, dev->name); 926 /* For now only devices in the initial network namespace
928 if (ret) { 927 * are in sysfs.
929 memcpy(dev->name, oldname, IFNAMSIZ); 928 */
930 return ret; 929 if (net == &init_net) {
930 ret = device_rename(&dev->dev, dev->name);
931 if (ret) {
932 memcpy(dev->name, oldname, IFNAMSIZ);
933 return ret;
934 }
931 } 935 }
932 936
933 write_lock_bh(&dev_base_lock); 937 write_lock_bh(&dev_base_lock);
@@ -1055,6 +1059,7 @@ void dev_load(struct net *net, const char *name)
1055 */ 1059 */
1056int dev_open(struct net_device *dev) 1060int dev_open(struct net_device *dev)
1057{ 1061{
1062 const struct net_device_ops *ops = dev->netdev_ops;
1058 int ret = 0; 1063 int ret = 0;
1059 1064
1060 ASSERT_RTNL(); 1065 ASSERT_RTNL();
@@ -1077,11 +1082,11 @@ int dev_open(struct net_device *dev)
1077 */ 1082 */
1078 set_bit(__LINK_STATE_START, &dev->state); 1083 set_bit(__LINK_STATE_START, &dev->state);
1079 1084
1080 if (dev->validate_addr) 1085 if (ops->ndo_validate_addr)
1081 ret = dev->validate_addr(dev); 1086 ret = ops->ndo_validate_addr(dev);
1082 1087
1083 if (!ret && dev->open) 1088 if (!ret && ops->ndo_open)
1084 ret = dev->open(dev); 1089 ret = ops->ndo_open(dev);
1085 1090
1086 /* 1091 /*
1087 * If it went open OK then: 1092 * If it went open OK then:
@@ -1125,6 +1130,7 @@ int dev_open(struct net_device *dev)
1125 */ 1130 */
1126int dev_close(struct net_device *dev) 1131int dev_close(struct net_device *dev)
1127{ 1132{
1133 const struct net_device_ops *ops = dev->netdev_ops;
1128 ASSERT_RTNL(); 1134 ASSERT_RTNL();
1129 1135
1130 might_sleep(); 1136 might_sleep();
@@ -1157,8 +1163,8 @@ int dev_close(struct net_device *dev)
1157 * We allow it to be called even after a DETACH hot-plug 1163 * We allow it to be called even after a DETACH hot-plug
1158 * event. 1164 * event.
1159 */ 1165 */
1160 if (dev->stop) 1166 if (ops->ndo_stop)
1161 dev->stop(dev); 1167 ops->ndo_stop(dev);
1162 1168
1163 /* 1169 /*
1164 * Device is now down. 1170 * Device is now down.
@@ -2251,8 +2257,10 @@ int netif_receive_skb(struct sk_buff *skb)
2251 rcu_read_lock(); 2257 rcu_read_lock();
2252 2258
2253 /* Don't receive packets in an exiting network namespace */ 2259 /* Don't receive packets in an exiting network namespace */
2254 if (!net_alive(dev_net(skb->dev))) 2260 if (!net_alive(dev_net(skb->dev))) {
2261 kfree_skb(skb);
2255 goto out; 2262 goto out;
2263 }
2256 2264
2257#ifdef CONFIG_NET_CLS_ACT 2265#ifdef CONFIG_NET_CLS_ACT
2258 if (skb->tc_verd & TC_NCLS) { 2266 if (skb->tc_verd & TC_NCLS) {
@@ -2371,7 +2379,7 @@ EXPORT_SYMBOL(__napi_schedule);
2371static void net_rx_action(struct softirq_action *h) 2379static void net_rx_action(struct softirq_action *h)
2372{ 2380{
2373 struct list_head *list = &__get_cpu_var(softnet_data).poll_list; 2381 struct list_head *list = &__get_cpu_var(softnet_data).poll_list;
2374 unsigned long start_time = jiffies; 2382 unsigned long time_limit = jiffies + 2;
2375 int budget = netdev_budget; 2383 int budget = netdev_budget;
2376 void *have; 2384 void *have;
2377 2385
@@ -2382,13 +2390,10 @@ static void net_rx_action(struct softirq_action *h)
2382 int work, weight; 2390 int work, weight;
2383 2391
2384 /* If softirq window is exhuasted then punt. 2392 /* If softirq window is exhuasted then punt.
2385 * 2393 * Allow this to run for 2 jiffies since which will allow
2386 * Note that this is a slight policy change from the 2394 * an average latency of 1.5/HZ.
2387 * previous NAPI code, which would allow up to 2
2388 * jiffies to pass before breaking out. The test
2389 * used to be "jiffies - start_time > 1".
2390 */ 2395 */
2391 if (unlikely(budget <= 0 || jiffies != start_time)) 2396 if (unlikely(budget <= 0 || time_after(jiffies, time_limit)))
2392 goto softnet_break; 2397 goto softnet_break;
2393 2398
2394 local_irq_enable(); 2399 local_irq_enable();
@@ -2615,7 +2620,7 @@ void dev_seq_stop(struct seq_file *seq, void *v)
2615 2620
2616static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev) 2621static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
2617{ 2622{
2618 struct net_device_stats *stats = dev->get_stats(dev); 2623 const struct net_device_stats *stats = dev_get_stats(dev);
2619 2624
2620 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu " 2625 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
2621 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n", 2626 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
@@ -2797,31 +2802,6 @@ static void ptype_seq_stop(struct seq_file *seq, void *v)
2797 rcu_read_unlock(); 2802 rcu_read_unlock();
2798} 2803}
2799 2804
2800static void ptype_seq_decode(struct seq_file *seq, void *sym)
2801{
2802#ifdef CONFIG_KALLSYMS
2803 unsigned long offset = 0, symsize;
2804 const char *symname;
2805 char *modname;
2806 char namebuf[128];
2807
2808 symname = kallsyms_lookup((unsigned long)sym, &symsize, &offset,
2809 &modname, namebuf);
2810
2811 if (symname) {
2812 char *delim = ":";
2813
2814 if (!modname)
2815 modname = delim = "";
2816 seq_printf(seq, "%s%s%s%s+0x%lx", delim, modname, delim,
2817 symname, offset);
2818 return;
2819 }
2820#endif
2821
2822 seq_printf(seq, "[%p]", sym);
2823}
2824
2825static int ptype_seq_show(struct seq_file *seq, void *v) 2805static int ptype_seq_show(struct seq_file *seq, void *v)
2826{ 2806{
2827 struct packet_type *pt = v; 2807 struct packet_type *pt = v;
@@ -2834,10 +2814,8 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
2834 else 2814 else
2835 seq_printf(seq, "%04x", ntohs(pt->type)); 2815 seq_printf(seq, "%04x", ntohs(pt->type));
2836 2816
2837 seq_printf(seq, " %-8s ", 2817 seq_printf(seq, " %-8s %pF\n",
2838 pt->dev ? pt->dev->name : ""); 2818 pt->dev ? pt->dev->name : "", pt->func);
2839 ptype_seq_decode(seq, pt->func);
2840 seq_putc(seq, '\n');
2841 } 2819 }
2842 2820
2843 return 0; 2821 return 0;
@@ -2954,8 +2932,10 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
2954 2932
2955static void dev_change_rx_flags(struct net_device *dev, int flags) 2933static void dev_change_rx_flags(struct net_device *dev, int flags)
2956{ 2934{
2957 if (dev->flags & IFF_UP && dev->change_rx_flags) 2935 const struct net_device_ops *ops = dev->netdev_ops;
2958 dev->change_rx_flags(dev, flags); 2936
2937 if ((dev->flags & IFF_UP) && ops->ndo_change_rx_flags)
2938 ops->ndo_change_rx_flags(dev, flags);
2959} 2939}
2960 2940
2961static int __dev_set_promiscuity(struct net_device *dev, int inc) 2941static int __dev_set_promiscuity(struct net_device *dev, int inc)
@@ -3075,6 +3055,8 @@ int dev_set_allmulti(struct net_device *dev, int inc)
3075 */ 3055 */
3076void __dev_set_rx_mode(struct net_device *dev) 3056void __dev_set_rx_mode(struct net_device *dev)
3077{ 3057{
3058 const struct net_device_ops *ops = dev->netdev_ops;
3059
3078 /* dev_open will call this function so the list will stay sane. */ 3060 /* dev_open will call this function so the list will stay sane. */
3079 if (!(dev->flags&IFF_UP)) 3061 if (!(dev->flags&IFF_UP))
3080 return; 3062 return;
@@ -3082,8 +3064,8 @@ void __dev_set_rx_mode(struct net_device *dev)
3082 if (!netif_device_present(dev)) 3064 if (!netif_device_present(dev))
3083 return; 3065 return;
3084 3066
3085 if (dev->set_rx_mode) 3067 if (ops->ndo_set_rx_mode)
3086 dev->set_rx_mode(dev); 3068 ops->ndo_set_rx_mode(dev);
3087 else { 3069 else {
3088 /* Unicast addresses changes may only happen under the rtnl, 3070 /* Unicast addresses changes may only happen under the rtnl,
3089 * therefore calling __dev_set_promiscuity here is safe. 3071 * therefore calling __dev_set_promiscuity here is safe.
@@ -3096,8 +3078,8 @@ void __dev_set_rx_mode(struct net_device *dev)
3096 dev->uc_promisc = 0; 3078 dev->uc_promisc = 0;
3097 } 3079 }
3098 3080
3099 if (dev->set_multicast_list) 3081 if (ops->ndo_set_multicast_list)
3100 dev->set_multicast_list(dev); 3082 ops->ndo_set_multicast_list(dev);
3101 } 3083 }
3102} 3084}
3103 3085
@@ -3456,6 +3438,7 @@ int dev_change_flags(struct net_device *dev, unsigned flags)
3456 */ 3438 */
3457int dev_set_mtu(struct net_device *dev, int new_mtu) 3439int dev_set_mtu(struct net_device *dev, int new_mtu)
3458{ 3440{
3441 const struct net_device_ops *ops = dev->netdev_ops;
3459 int err; 3442 int err;
3460 3443
3461 if (new_mtu == dev->mtu) 3444 if (new_mtu == dev->mtu)
@@ -3469,10 +3452,11 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
3469 return -ENODEV; 3452 return -ENODEV;
3470 3453
3471 err = 0; 3454 err = 0;
3472 if (dev->change_mtu) 3455 if (ops->ndo_change_mtu)
3473 err = dev->change_mtu(dev, new_mtu); 3456 err = ops->ndo_change_mtu(dev, new_mtu);
3474 else 3457 else
3475 dev->mtu = new_mtu; 3458 dev->mtu = new_mtu;
3459
3476 if (!err && dev->flags & IFF_UP) 3460 if (!err && dev->flags & IFF_UP)
3477 call_netdevice_notifiers(NETDEV_CHANGEMTU, dev); 3461 call_netdevice_notifiers(NETDEV_CHANGEMTU, dev);
3478 return err; 3462 return err;
@@ -3487,15 +3471,16 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
3487 */ 3471 */
3488int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) 3472int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
3489{ 3473{
3474 const struct net_device_ops *ops = dev->netdev_ops;
3490 int err; 3475 int err;
3491 3476
3492 if (!dev->set_mac_address) 3477 if (!ops->ndo_set_mac_address)
3493 return -EOPNOTSUPP; 3478 return -EOPNOTSUPP;
3494 if (sa->sa_family != dev->type) 3479 if (sa->sa_family != dev->type)
3495 return -EINVAL; 3480 return -EINVAL;
3496 if (!netif_device_present(dev)) 3481 if (!netif_device_present(dev))
3497 return -ENODEV; 3482 return -ENODEV;
3498 err = dev->set_mac_address(dev, sa); 3483 err = ops->ndo_set_mac_address(dev, sa);
3499 if (!err) 3484 if (!err)
3500 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); 3485 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
3501 return err; 3486 return err;
@@ -3575,6 +3560,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
3575{ 3560{
3576 int err; 3561 int err;
3577 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name); 3562 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
3563 const struct net_device_ops *ops = dev->netdev_ops;
3578 3564
3579 if (!dev) 3565 if (!dev)
3580 return -ENODEV; 3566 return -ENODEV;
@@ -3602,15 +3588,15 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
3602 return 0; 3588 return 0;
3603 3589
3604 case SIOCSIFMAP: 3590 case SIOCSIFMAP:
3605 if (dev->set_config) { 3591 if (ops->ndo_set_config) {
3606 if (!netif_device_present(dev)) 3592 if (!netif_device_present(dev))
3607 return -ENODEV; 3593 return -ENODEV;
3608 return dev->set_config(dev, &ifr->ifr_map); 3594 return ops->ndo_set_config(dev, &ifr->ifr_map);
3609 } 3595 }
3610 return -EOPNOTSUPP; 3596 return -EOPNOTSUPP;
3611 3597
3612 case SIOCADDMULTI: 3598 case SIOCADDMULTI:
3613 if ((!dev->set_multicast_list && !dev->set_rx_mode) || 3599 if ((!ops->ndo_set_multicast_list && !ops->ndo_set_rx_mode) ||
3614 ifr->ifr_hwaddr.sa_family != AF_UNSPEC) 3600 ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
3615 return -EINVAL; 3601 return -EINVAL;
3616 if (!netif_device_present(dev)) 3602 if (!netif_device_present(dev))
@@ -3619,7 +3605,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
3619 dev->addr_len, 1); 3605 dev->addr_len, 1);
3620 3606
3621 case SIOCDELMULTI: 3607 case SIOCDELMULTI:
3622 if ((!dev->set_multicast_list && !dev->set_rx_mode) || 3608 if ((!ops->ndo_set_multicast_list && !ops->ndo_set_rx_mode) ||
3623 ifr->ifr_hwaddr.sa_family != AF_UNSPEC) 3609 ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
3624 return -EINVAL; 3610 return -EINVAL;
3625 if (!netif_device_present(dev)) 3611 if (!netif_device_present(dev))
@@ -3657,10 +3643,9 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
3657 cmd == SIOCBRDELIF || 3643 cmd == SIOCBRDELIF ||
3658 cmd == SIOCWANDEV) { 3644 cmd == SIOCWANDEV) {
3659 err = -EOPNOTSUPP; 3645 err = -EOPNOTSUPP;
3660 if (dev->do_ioctl) { 3646 if (ops->ndo_do_ioctl) {
3661 if (netif_device_present(dev)) 3647 if (netif_device_present(dev))
3662 err = dev->do_ioctl(dev, ifr, 3648 err = ops->ndo_do_ioctl(dev, ifr, cmd);
3663 cmd);
3664 else 3649 else
3665 err = -ENODEV; 3650 err = -ENODEV;
3666 } 3651 }
@@ -3921,8 +3906,8 @@ static void rollback_registered(struct net_device *dev)
3921 */ 3906 */
3922 dev_addr_discard(dev); 3907 dev_addr_discard(dev);
3923 3908
3924 if (dev->uninit) 3909 if (dev->netdev_ops->ndo_uninit)
3925 dev->uninit(dev); 3910 dev->netdev_ops->ndo_uninit(dev);
3926 3911
3927 /* Notifier chain MUST detach us from master device. */ 3912 /* Notifier chain MUST detach us from master device. */
3928 WARN_ON(dev->master); 3913 WARN_ON(dev->master);
@@ -4012,7 +3997,7 @@ int register_netdevice(struct net_device *dev)
4012 struct hlist_head *head; 3997 struct hlist_head *head;
4013 struct hlist_node *p; 3998 struct hlist_node *p;
4014 int ret; 3999 int ret;
4015 struct net *net; 4000 struct net *net = dev_net(dev);
4016 4001
4017 BUG_ON(dev_boot_phase); 4002 BUG_ON(dev_boot_phase);
4018 ASSERT_RTNL(); 4003 ASSERT_RTNL();
@@ -4021,8 +4006,7 @@ int register_netdevice(struct net_device *dev)
4021 4006
4022 /* When net_device's are persistent, this will be fatal. */ 4007 /* When net_device's are persistent, this will be fatal. */
4023 BUG_ON(dev->reg_state != NETREG_UNINITIALIZED); 4008 BUG_ON(dev->reg_state != NETREG_UNINITIALIZED);
4024 BUG_ON(!dev_net(dev)); 4009 BUG_ON(!net);
4025 net = dev_net(dev);
4026 4010
4027 spin_lock_init(&dev->addr_list_lock); 4011 spin_lock_init(&dev->addr_list_lock);
4028 netdev_set_addr_lockdep_class(dev); 4012 netdev_set_addr_lockdep_class(dev);
@@ -4030,9 +4014,46 @@ int register_netdevice(struct net_device *dev)
4030 4014
4031 dev->iflink = -1; 4015 dev->iflink = -1;
4032 4016
4017#ifdef CONFIG_COMPAT_NET_DEV_OPS
4018 /* Netdevice_ops API compatiability support.
4019 * This is temporary until all network devices are converted.
4020 */
4021 if (dev->netdev_ops) {
4022 const struct net_device_ops *ops = dev->netdev_ops;
4023
4024 dev->init = ops->ndo_init;
4025 dev->uninit = ops->ndo_uninit;
4026 dev->open = ops->ndo_open;
4027 dev->change_rx_flags = ops->ndo_change_rx_flags;
4028 dev->set_rx_mode = ops->ndo_set_rx_mode;
4029 dev->set_multicast_list = ops->ndo_set_multicast_list;
4030 dev->set_mac_address = ops->ndo_set_mac_address;
4031 dev->validate_addr = ops->ndo_validate_addr;
4032 dev->do_ioctl = ops->ndo_do_ioctl;
4033 dev->set_config = ops->ndo_set_config;
4034 dev->change_mtu = ops->ndo_change_mtu;
4035 dev->tx_timeout = ops->ndo_tx_timeout;
4036 dev->get_stats = ops->ndo_get_stats;
4037 dev->vlan_rx_register = ops->ndo_vlan_rx_register;
4038 dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid;
4039 dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid;
4040#ifdef CONFIG_NET_POLL_CONTROLLER
4041 dev->poll_controller = ops->ndo_poll_controller;
4042#endif
4043 } else {
4044 char drivername[64];
4045 pr_info("%s (%s): not using net_device_ops yet\n",
4046 dev->name, netdev_drivername(dev, drivername, 64));
4047
4048 /* This works only because net_device_ops and the
4049 compatiablity structure are the same. */
4050 dev->netdev_ops = (void *) &(dev->init);
4051 }
4052#endif
4053
4033 /* Init, if this function is available */ 4054 /* Init, if this function is available */
4034 if (dev->init) { 4055 if (dev->netdev_ops->ndo_init) {
4035 ret = dev->init(dev); 4056 ret = dev->netdev_ops->ndo_init(dev);
4036 if (ret) { 4057 if (ret) {
4037 if (ret > 0) 4058 if (ret > 0)
4038 ret = -EIO; 4059 ret = -EIO;
@@ -4110,8 +4131,8 @@ out:
4110 return ret; 4131 return ret;
4111 4132
4112err_uninit: 4133err_uninit:
4113 if (dev->uninit) 4134 if (dev->netdev_ops->ndo_uninit)
4114 dev->uninit(dev); 4135 dev->netdev_ops->ndo_uninit(dev);
4115 goto out; 4136 goto out;
4116} 4137}
4117 4138
@@ -4267,10 +4288,24 @@ void netdev_run_todo(void)
4267 } 4288 }
4268} 4289}
4269 4290
4270static struct net_device_stats *internal_stats(struct net_device *dev) 4291/**
4271{ 4292 * dev_get_stats - get network device statistics
4272 return &dev->stats; 4293 * @dev: device to get statistics from
4294 *
4295 * Get network statistics from device. The device driver may provide
4296 * its own method by setting dev->netdev_ops->get_stats; otherwise
4297 * the internal statistics structure is used.
4298 */
4299const struct net_device_stats *dev_get_stats(struct net_device *dev)
4300 {
4301 const struct net_device_ops *ops = dev->netdev_ops;
4302
4303 if (ops->ndo_get_stats)
4304 return ops->ndo_get_stats(dev);
4305 else
4306 return &dev->stats;
4273} 4307}
4308EXPORT_SYMBOL(dev_get_stats);
4274 4309
4275static void netdev_init_one_queue(struct net_device *dev, 4310static void netdev_init_one_queue(struct net_device *dev,
4276 struct netdev_queue *queue, 4311 struct netdev_queue *queue,
@@ -4349,7 +4384,6 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
4349 4384
4350 netdev_init_queues(dev); 4385 netdev_init_queues(dev);
4351 4386
4352 dev->get_stats = internal_stats;
4353 netpoll_netdev_init(dev); 4387 netpoll_netdev_init(dev);
4354 setup(dev); 4388 setup(dev);
4355 strcpy(dev->name, name); 4389 strcpy(dev->name, name);
@@ -4463,6 +4497,15 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
4463 if (dev->features & NETIF_F_NETNS_LOCAL) 4497 if (dev->features & NETIF_F_NETNS_LOCAL)
4464 goto out; 4498 goto out;
4465 4499
4500#ifdef CONFIG_SYSFS
4501 /* Don't allow real devices to be moved when sysfs
4502 * is enabled.
4503 */
4504 err = -EINVAL;
4505 if (dev->dev.parent)
4506 goto out;
4507#endif
4508
4466 /* Ensure the device has been registrered */ 4509 /* Ensure the device has been registrered */
4467 err = -EINVAL; 4510 err = -EINVAL;
4468 if (dev->reg_state != NETREG_REGISTERED) 4511 if (dev->reg_state != NETREG_REGISTERED)
@@ -4520,6 +4563,8 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
4520 */ 4563 */
4521 dev_addr_discard(dev); 4564 dev_addr_discard(dev);
4522 4565
4566 netdev_unregister_kobject(dev);
4567
4523 /* Actually switch the network namespace */ 4568 /* Actually switch the network namespace */
4524 dev_net_set(dev, net); 4569 dev_net_set(dev, net);
4525 4570
@@ -4536,7 +4581,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
4536 } 4581 }
4537 4582
4538 /* Fixup kobjects */ 4583 /* Fixup kobjects */
4539 netdev_unregister_kobject(dev);
4540 err = netdev_register_kobject(dev); 4584 err = netdev_register_kobject(dev);
4541 WARN_ON(err); 4585 WARN_ON(err);
4542 4586
@@ -4843,6 +4887,12 @@ static void __net_exit default_device_exit(struct net *net)
4843 if (dev->features & NETIF_F_NETNS_LOCAL) 4887 if (dev->features & NETIF_F_NETNS_LOCAL)
4844 continue; 4888 continue;
4845 4889
4890 /* Delete virtual devices */
4891 if (dev->rtnl_link_ops && dev->rtnl_link_ops->dellink) {
4892 dev->rtnl_link_ops->dellink(dev);
4893 continue;
4894 }
4895
4846 /* Push remaing network devices to init_net */ 4896 /* Push remaing network devices to init_net */
4847 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); 4897 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
4848 err = dev_change_net_namespace(dev, &init_net, fb_name); 4898 err = dev_change_net_namespace(dev, &init_net, fb_name);
@@ -4889,9 +4939,6 @@ static int __init net_dev_init(void)
4889 if (register_pernet_subsys(&netdev_net_ops)) 4939 if (register_pernet_subsys(&netdev_net_ops))
4890 goto out; 4940 goto out;
4891 4941
4892 if (register_pernet_device(&default_device_ops))
4893 goto out;
4894
4895 /* 4942 /*
4896 * Initialise the packet receive queues. 4943 * Initialise the packet receive queues.
4897 */ 4944 */
@@ -4908,10 +4955,25 @@ static int __init net_dev_init(void)
4908 queue->backlog.weight = weight_p; 4955 queue->backlog.weight = weight_p;
4909 } 4956 }
4910 4957
4911 netdev_dma_register();
4912
4913 dev_boot_phase = 0; 4958 dev_boot_phase = 0;
4914 4959
4960 /* The loopback device is special if any other network devices
4961 * is present in a network namespace the loopback device must
4962 * be present. Since we now dynamically allocate and free the
4963 * loopback device ensure this invariant is maintained by
4964 * keeping the loopback device as the first device on the
4965 * list of network devices. Ensuring the loopback devices
4966 * is the first device that appears and the last network device
4967 * that disappears.
4968 */
4969 if (register_pernet_device(&loopback_net_ops))
4970 goto out;
4971
4972 if (register_pernet_device(&default_device_ops))
4973 goto out;
4974
4975 netdev_dma_register();
4976
4915 open_softirq(NET_TX_SOFTIRQ, net_tx_action); 4977 open_softirq(NET_TX_SOFTIRQ, net_tx_action);
4916 open_softirq(NET_RX_SOFTIRQ, net_rx_action); 4978 open_softirq(NET_RX_SOFTIRQ, net_rx_action);
4917 4979
diff --git a/net/core/dst.c b/net/core/dst.c
index 09c1530f4681..57bc4d5b8d08 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -263,9 +263,11 @@ again:
263void dst_release(struct dst_entry *dst) 263void dst_release(struct dst_entry *dst)
264{ 264{
265 if (dst) { 265 if (dst) {
266 WARN_ON(atomic_read(&dst->__refcnt) < 1); 266 int newrefcnt;
267
267 smp_mb__before_atomic_dec(); 268 smp_mb__before_atomic_dec();
268 atomic_dec(&dst->__refcnt); 269 newrefcnt = atomic_dec_return(&dst->__refcnt);
270 WARN_ON(newrefcnt < 0);
269 } 271 }
270} 272}
271EXPORT_SYMBOL(dst_release); 273EXPORT_SYMBOL(dst_release);
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 79de3b14a8d1..32b3a0152d7a 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -664,17 +664,18 @@ static int __init fib_rules_init(void)
664 rtnl_register(PF_UNSPEC, RTM_DELRULE, fib_nl_delrule, NULL); 664 rtnl_register(PF_UNSPEC, RTM_DELRULE, fib_nl_delrule, NULL);
665 rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, fib_nl_dumprule); 665 rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, fib_nl_dumprule);
666 666
667 err = register_netdevice_notifier(&fib_rules_notifier); 667 err = register_pernet_subsys(&fib_rules_net_ops);
668 if (err < 0) 668 if (err < 0)
669 goto fail; 669 goto fail;
670 670
671 err = register_pernet_subsys(&fib_rules_net_ops); 671 err = register_netdevice_notifier(&fib_rules_notifier);
672 if (err < 0) 672 if (err < 0)
673 goto fail_unregister; 673 goto fail_unregister;
674
674 return 0; 675 return 0;
675 676
676fail_unregister: 677fail_unregister:
677 unregister_netdevice_notifier(&fib_rules_notifier); 678 unregister_pernet_subsys(&fib_rules_net_ops);
678fail: 679fail:
679 rtnl_unregister(PF_UNSPEC, RTM_NEWRULE); 680 rtnl_unregister(PF_UNSPEC, RTM_NEWRULE);
680 rtnl_unregister(PF_UNSPEC, RTM_DELRULE); 681 rtnl_unregister(PF_UNSPEC, RTM_DELRULE);
diff --git a/net/core/filter.c b/net/core/filter.c
index df3744355839..d1d779ca096d 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -319,6 +319,25 @@ load_b:
319 A = 0; 319 A = 0;
320 continue; 320 continue;
321 } 321 }
322 case SKF_AD_NLATTR_NEST: {
323 struct nlattr *nla;
324
325 if (skb_is_nonlinear(skb))
326 return 0;
327 if (A > skb->len - sizeof(struct nlattr))
328 return 0;
329
330 nla = (struct nlattr *)&skb->data[A];
331 if (nla->nla_len > A - skb->len)
332 return 0;
333
334 nla = nla_find_nested(nla, X);
335 if (nla)
336 A = (void *)nla - (void *)skb->data;
337 else
338 A = 0;
339 continue;
340 }
322 default: 341 default:
323 return 0; 342 return 0;
324 } 343 }
diff --git a/net/core/flow.c b/net/core/flow.c
index 5cf81052d044..d323388dd1ba 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -307,7 +307,7 @@ void flow_cache_flush(void)
307 put_online_cpus(); 307 put_online_cpus();
308} 308}
309 309
310static void __devinit flow_cache_cpu_prepare(int cpu) 310static void __init flow_cache_cpu_prepare(int cpu)
311{ 311{
312 struct tasklet_struct *tasklet; 312 struct tasklet_struct *tasklet;
313 unsigned long order; 313 unsigned long order;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 1dc728b38589..cca6a55909eb 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -531,9 +531,7 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
531 if (!n) 531 if (!n)
532 goto out; 532 goto out;
533 533
534#ifdef CONFIG_NET_NS 534 write_pnet(&n->net, hold_net(net));
535 n->net = hold_net(net);
536#endif
537 memcpy(n->key, pkey, key_len); 535 memcpy(n->key, pkey, key_len);
538 n->dev = dev; 536 n->dev = dev;
539 if (dev) 537 if (dev)
@@ -1340,7 +1338,6 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
1340 if (p) { 1338 if (p) {
1341 p->tbl = tbl; 1339 p->tbl = tbl;
1342 atomic_set(&p->refcnt, 1); 1340 atomic_set(&p->refcnt, 1);
1343 INIT_RCU_HEAD(&p->rcu_head);
1344 p->reachable_time = 1341 p->reachable_time =
1345 neigh_rand_reach_time(p->base_reachable_time); 1342 neigh_rand_reach_time(p->base_reachable_time);
1346 1343
@@ -1351,9 +1348,7 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
1351 1348
1352 dev_hold(dev); 1349 dev_hold(dev);
1353 p->dev = dev; 1350 p->dev = dev;
1354#ifdef CONFIG_NET_NS 1351 write_pnet(&p->net, hold_net(net));
1355 p->net = hold_net(net);
1356#endif
1357 p->sysctl_table = NULL; 1352 p->sysctl_table = NULL;
1358 write_lock_bh(&tbl->lock); 1353 write_lock_bh(&tbl->lock);
1359 p->next = tbl->parms.next; 1354 p->next = tbl->parms.next;
@@ -1408,11 +1403,8 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
1408 unsigned long now = jiffies; 1403 unsigned long now = jiffies;
1409 unsigned long phsize; 1404 unsigned long phsize;
1410 1405
1411#ifdef CONFIG_NET_NS 1406 write_pnet(&tbl->parms.net, &init_net);
1412 tbl->parms.net = &init_net;
1413#endif
1414 atomic_set(&tbl->parms.refcnt, 1); 1407 atomic_set(&tbl->parms.refcnt, 1);
1415 INIT_RCU_HEAD(&tbl->parms.rcu_head);
1416 tbl->parms.reachable_time = 1408 tbl->parms.reachable_time =
1417 neigh_rand_reach_time(tbl->parms.base_reachable_time); 1409 neigh_rand_reach_time(tbl->parms.base_reachable_time);
1418 1410
@@ -1426,9 +1418,8 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
1426 panic("cannot create neighbour cache statistics"); 1418 panic("cannot create neighbour cache statistics");
1427 1419
1428#ifdef CONFIG_PROC_FS 1420#ifdef CONFIG_PROC_FS
1429 tbl->pde = proc_create_data(tbl->id, 0, init_net.proc_net_stat, 1421 if (!proc_create_data(tbl->id, 0, init_net.proc_net_stat,
1430 &neigh_stat_seq_fops, tbl); 1422 &neigh_stat_seq_fops, tbl))
1431 if (!tbl->pde)
1432 panic("cannot create neighbour proc dir entry"); 1423 panic("cannot create neighbour proc dir entry");
1433#endif 1424#endif
1434 1425
@@ -2568,128 +2559,128 @@ static struct neigh_sysctl_table {
2568 .procname = "mcast_solicit", 2559 .procname = "mcast_solicit",
2569 .maxlen = sizeof(int), 2560 .maxlen = sizeof(int),
2570 .mode = 0644, 2561 .mode = 0644,
2571 .proc_handler = &proc_dointvec, 2562 .proc_handler = proc_dointvec,
2572 }, 2563 },
2573 { 2564 {
2574 .ctl_name = NET_NEIGH_UCAST_SOLICIT, 2565 .ctl_name = NET_NEIGH_UCAST_SOLICIT,
2575 .procname = "ucast_solicit", 2566 .procname = "ucast_solicit",
2576 .maxlen = sizeof(int), 2567 .maxlen = sizeof(int),
2577 .mode = 0644, 2568 .mode = 0644,
2578 .proc_handler = &proc_dointvec, 2569 .proc_handler = proc_dointvec,
2579 }, 2570 },
2580 { 2571 {
2581 .ctl_name = NET_NEIGH_APP_SOLICIT, 2572 .ctl_name = NET_NEIGH_APP_SOLICIT,
2582 .procname = "app_solicit", 2573 .procname = "app_solicit",
2583 .maxlen = sizeof(int), 2574 .maxlen = sizeof(int),
2584 .mode = 0644, 2575 .mode = 0644,
2585 .proc_handler = &proc_dointvec, 2576 .proc_handler = proc_dointvec,
2586 }, 2577 },
2587 { 2578 {
2588 .procname = "retrans_time", 2579 .procname = "retrans_time",
2589 .maxlen = sizeof(int), 2580 .maxlen = sizeof(int),
2590 .mode = 0644, 2581 .mode = 0644,
2591 .proc_handler = &proc_dointvec_userhz_jiffies, 2582 .proc_handler = proc_dointvec_userhz_jiffies,
2592 }, 2583 },
2593 { 2584 {
2594 .ctl_name = NET_NEIGH_REACHABLE_TIME, 2585 .ctl_name = NET_NEIGH_REACHABLE_TIME,
2595 .procname = "base_reachable_time", 2586 .procname = "base_reachable_time",
2596 .maxlen = sizeof(int), 2587 .maxlen = sizeof(int),
2597 .mode = 0644, 2588 .mode = 0644,
2598 .proc_handler = &proc_dointvec_jiffies, 2589 .proc_handler = proc_dointvec_jiffies,
2599 .strategy = &sysctl_jiffies, 2590 .strategy = sysctl_jiffies,
2600 }, 2591 },
2601 { 2592 {
2602 .ctl_name = NET_NEIGH_DELAY_PROBE_TIME, 2593 .ctl_name = NET_NEIGH_DELAY_PROBE_TIME,
2603 .procname = "delay_first_probe_time", 2594 .procname = "delay_first_probe_time",
2604 .maxlen = sizeof(int), 2595 .maxlen = sizeof(int),
2605 .mode = 0644, 2596 .mode = 0644,
2606 .proc_handler = &proc_dointvec_jiffies, 2597 .proc_handler = proc_dointvec_jiffies,
2607 .strategy = &sysctl_jiffies, 2598 .strategy = sysctl_jiffies,
2608 }, 2599 },
2609 { 2600 {
2610 .ctl_name = NET_NEIGH_GC_STALE_TIME, 2601 .ctl_name = NET_NEIGH_GC_STALE_TIME,
2611 .procname = "gc_stale_time", 2602 .procname = "gc_stale_time",
2612 .maxlen = sizeof(int), 2603 .maxlen = sizeof(int),
2613 .mode = 0644, 2604 .mode = 0644,
2614 .proc_handler = &proc_dointvec_jiffies, 2605 .proc_handler = proc_dointvec_jiffies,
2615 .strategy = &sysctl_jiffies, 2606 .strategy = sysctl_jiffies,
2616 }, 2607 },
2617 { 2608 {
2618 .ctl_name = NET_NEIGH_UNRES_QLEN, 2609 .ctl_name = NET_NEIGH_UNRES_QLEN,
2619 .procname = "unres_qlen", 2610 .procname = "unres_qlen",
2620 .maxlen = sizeof(int), 2611 .maxlen = sizeof(int),
2621 .mode = 0644, 2612 .mode = 0644,
2622 .proc_handler = &proc_dointvec, 2613 .proc_handler = proc_dointvec,
2623 }, 2614 },
2624 { 2615 {
2625 .ctl_name = NET_NEIGH_PROXY_QLEN, 2616 .ctl_name = NET_NEIGH_PROXY_QLEN,
2626 .procname = "proxy_qlen", 2617 .procname = "proxy_qlen",
2627 .maxlen = sizeof(int), 2618 .maxlen = sizeof(int),
2628 .mode = 0644, 2619 .mode = 0644,
2629 .proc_handler = &proc_dointvec, 2620 .proc_handler = proc_dointvec,
2630 }, 2621 },
2631 { 2622 {
2632 .procname = "anycast_delay", 2623 .procname = "anycast_delay",
2633 .maxlen = sizeof(int), 2624 .maxlen = sizeof(int),
2634 .mode = 0644, 2625 .mode = 0644,
2635 .proc_handler = &proc_dointvec_userhz_jiffies, 2626 .proc_handler = proc_dointvec_userhz_jiffies,
2636 }, 2627 },
2637 { 2628 {
2638 .procname = "proxy_delay", 2629 .procname = "proxy_delay",
2639 .maxlen = sizeof(int), 2630 .maxlen = sizeof(int),
2640 .mode = 0644, 2631 .mode = 0644,
2641 .proc_handler = &proc_dointvec_userhz_jiffies, 2632 .proc_handler = proc_dointvec_userhz_jiffies,
2642 }, 2633 },
2643 { 2634 {
2644 .procname = "locktime", 2635 .procname = "locktime",
2645 .maxlen = sizeof(int), 2636 .maxlen = sizeof(int),
2646 .mode = 0644, 2637 .mode = 0644,
2647 .proc_handler = &proc_dointvec_userhz_jiffies, 2638 .proc_handler = proc_dointvec_userhz_jiffies,
2648 }, 2639 },
2649 { 2640 {
2650 .ctl_name = NET_NEIGH_RETRANS_TIME_MS, 2641 .ctl_name = NET_NEIGH_RETRANS_TIME_MS,
2651 .procname = "retrans_time_ms", 2642 .procname = "retrans_time_ms",
2652 .maxlen = sizeof(int), 2643 .maxlen = sizeof(int),
2653 .mode = 0644, 2644 .mode = 0644,
2654 .proc_handler = &proc_dointvec_ms_jiffies, 2645 .proc_handler = proc_dointvec_ms_jiffies,
2655 .strategy = &sysctl_ms_jiffies, 2646 .strategy = sysctl_ms_jiffies,
2656 }, 2647 },
2657 { 2648 {
2658 .ctl_name = NET_NEIGH_REACHABLE_TIME_MS, 2649 .ctl_name = NET_NEIGH_REACHABLE_TIME_MS,
2659 .procname = "base_reachable_time_ms", 2650 .procname = "base_reachable_time_ms",
2660 .maxlen = sizeof(int), 2651 .maxlen = sizeof(int),
2661 .mode = 0644, 2652 .mode = 0644,
2662 .proc_handler = &proc_dointvec_ms_jiffies, 2653 .proc_handler = proc_dointvec_ms_jiffies,
2663 .strategy = &sysctl_ms_jiffies, 2654 .strategy = sysctl_ms_jiffies,
2664 }, 2655 },
2665 { 2656 {
2666 .ctl_name = NET_NEIGH_GC_INTERVAL, 2657 .ctl_name = NET_NEIGH_GC_INTERVAL,
2667 .procname = "gc_interval", 2658 .procname = "gc_interval",
2668 .maxlen = sizeof(int), 2659 .maxlen = sizeof(int),
2669 .mode = 0644, 2660 .mode = 0644,
2670 .proc_handler = &proc_dointvec_jiffies, 2661 .proc_handler = proc_dointvec_jiffies,
2671 .strategy = &sysctl_jiffies, 2662 .strategy = sysctl_jiffies,
2672 }, 2663 },
2673 { 2664 {
2674 .ctl_name = NET_NEIGH_GC_THRESH1, 2665 .ctl_name = NET_NEIGH_GC_THRESH1,
2675 .procname = "gc_thresh1", 2666 .procname = "gc_thresh1",
2676 .maxlen = sizeof(int), 2667 .maxlen = sizeof(int),
2677 .mode = 0644, 2668 .mode = 0644,
2678 .proc_handler = &proc_dointvec, 2669 .proc_handler = proc_dointvec,
2679 }, 2670 },
2680 { 2671 {
2681 .ctl_name = NET_NEIGH_GC_THRESH2, 2672 .ctl_name = NET_NEIGH_GC_THRESH2,
2682 .procname = "gc_thresh2", 2673 .procname = "gc_thresh2",
2683 .maxlen = sizeof(int), 2674 .maxlen = sizeof(int),
2684 .mode = 0644, 2675 .mode = 0644,
2685 .proc_handler = &proc_dointvec, 2676 .proc_handler = proc_dointvec,
2686 }, 2677 },
2687 { 2678 {
2688 .ctl_name = NET_NEIGH_GC_THRESH3, 2679 .ctl_name = NET_NEIGH_GC_THRESH3,
2689 .procname = "gc_thresh3", 2680 .procname = "gc_thresh3",
2690 .maxlen = sizeof(int), 2681 .maxlen = sizeof(int),
2691 .mode = 0644, 2682 .mode = 0644,
2692 .proc_handler = &proc_dointvec, 2683 .proc_handler = proc_dointvec,
2693 }, 2684 },
2694 {}, 2685 {},
2695 }, 2686 },
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 92d6b9467314..afd42d717320 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -270,7 +270,6 @@ static ssize_t netstat_show(const struct device *d,
270 unsigned long offset) 270 unsigned long offset)
271{ 271{
272 struct net_device *dev = to_net_dev(d); 272 struct net_device *dev = to_net_dev(d);
273 struct net_device_stats *stats;
274 ssize_t ret = -EINVAL; 273 ssize_t ret = -EINVAL;
275 274
276 WARN_ON(offset > sizeof(struct net_device_stats) || 275 WARN_ON(offset > sizeof(struct net_device_stats) ||
@@ -278,7 +277,7 @@ static ssize_t netstat_show(const struct device *d,
278 277
279 read_lock(&dev_base_lock); 278 read_lock(&dev_base_lock);
280 if (dev_isalive(dev)) { 279 if (dev_isalive(dev)) {
281 stats = dev->get_stats(dev); 280 const struct net_device_stats *stats = dev_get_stats(dev);
282 ret = sprintf(buf, fmt_ulong, 281 ret = sprintf(buf, fmt_ulong,
283 *(unsigned long *)(((u8 *) stats) + offset)); 282 *(unsigned long *)(((u8 *) stats) + offset));
284 } 283 }
@@ -476,6 +475,10 @@ void netdev_unregister_kobject(struct net_device * net)
476 struct device *dev = &(net->dev); 475 struct device *dev = &(net->dev);
477 476
478 kobject_get(&dev->kobj); 477 kobject_get(&dev->kobj);
478
479 if (dev_net(net) != &init_net)
480 return;
481
479 device_del(dev); 482 device_del(dev);
480} 483}
481 484
@@ -490,7 +493,7 @@ int netdev_register_kobject(struct net_device *net)
490 dev->groups = groups; 493 dev->groups = groups;
491 494
492 BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ); 495 BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ);
493 strlcpy(dev->bus_id, net->name, BUS_ID_SIZE); 496 dev_set_name(dev, net->name);
494 497
495#ifdef CONFIG_SYSFS 498#ifdef CONFIG_SYSFS
496 *groups++ = &netstat_group; 499 *groups++ = &netstat_group;
@@ -501,6 +504,9 @@ int netdev_register_kobject(struct net_device *net)
501#endif 504#endif
502#endif /* CONFIG_SYSFS */ 505#endif /* CONFIG_SYSFS */
503 506
507 if (dev_net(net) != &init_net)
508 return 0;
509
504 return device_add(dev); 510 return device_add(dev);
505} 511}
506 512
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 1895a4ca9c4f..55cffad2f328 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -47,7 +47,6 @@ static __net_init int setup_net(struct net *net)
47 goto out; 47 goto out;
48 48
49 ng->len = INITIAL_NET_GEN_PTRS; 49 ng->len = INITIAL_NET_GEN_PTRS;
50 INIT_RCU_HEAD(&ng->rcu);
51 rcu_assign_pointer(net->gen, ng); 50 rcu_assign_pointer(net->gen, ng);
52 51
53 error = 0; 52 error = 0;
@@ -478,7 +477,6 @@ int net_assign_generic(struct net *net, int id, void *data)
478 */ 477 */
479 478
480 ng->len = id; 479 ng->len = id;
481 INIT_RCU_HEAD(&ng->rcu);
482 memcpy(&ng->ptr, &old_ng->ptr, old_ng->len); 480 memcpy(&ng->ptr, &old_ng->ptr, old_ng->len);
483 481
484 rcu_assign_pointer(net->gen, ng); 482 rcu_assign_pointer(net->gen, ng);
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 6c7af390be0a..630df6034444 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -172,12 +172,13 @@ static void service_arp_queue(struct netpoll_info *npi)
172void netpoll_poll(struct netpoll *np) 172void netpoll_poll(struct netpoll *np)
173{ 173{
174 struct net_device *dev = np->dev; 174 struct net_device *dev = np->dev;
175 const struct net_device_ops *ops = dev->netdev_ops;
175 176
176 if (!dev || !netif_running(dev) || !dev->poll_controller) 177 if (!dev || !netif_running(dev) || !ops->ndo_poll_controller)
177 return; 178 return;
178 179
179 /* Process pending work on NIC */ 180 /* Process pending work on NIC */
180 dev->poll_controller(dev); 181 ops->ndo_poll_controller(dev);
181 182
182 poll_napi(dev); 183 poll_napi(dev);
183 184
@@ -343,7 +344,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
343 udph->check = csum_tcpudp_magic(htonl(np->local_ip), 344 udph->check = csum_tcpudp_magic(htonl(np->local_ip),
344 htonl(np->remote_ip), 345 htonl(np->remote_ip),
345 udp_len, IPPROTO_UDP, 346 udp_len, IPPROTO_UDP,
346 csum_partial((unsigned char *)udph, udp_len, 0)); 347 csum_partial(udph, udp_len, 0));
347 if (udph->check == 0) 348 if (udph->check == 0)
348 udph->check = CSUM_MANGLED_0; 349 udph->check = CSUM_MANGLED_0;
349 350
@@ -553,7 +554,6 @@ out:
553 554
554void netpoll_print_options(struct netpoll *np) 555void netpoll_print_options(struct netpoll *np)
555{ 556{
556 DECLARE_MAC_BUF(mac);
557 printk(KERN_INFO "%s: local port %d\n", 557 printk(KERN_INFO "%s: local port %d\n",
558 np->name, np->local_port); 558 np->name, np->local_port);
559 printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n", 559 printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n",
@@ -564,8 +564,8 @@ void netpoll_print_options(struct netpoll *np)
564 np->name, np->remote_port); 564 np->name, np->remote_port);
565 printk(KERN_INFO "%s: remote IP %d.%d.%d.%d\n", 565 printk(KERN_INFO "%s: remote IP %d.%d.%d.%d\n",
566 np->name, HIPQUAD(np->remote_ip)); 566 np->name, HIPQUAD(np->remote_ip));
567 printk(KERN_INFO "%s: remote ethernet address %s\n", 567 printk(KERN_INFO "%s: remote ethernet address %pM\n",
568 np->name, print_mac(mac, np->remote_mac)); 568 np->name, np->remote_mac);
569} 569}
570 570
571int netpoll_parse_options(struct netpoll *np, char *opt) 571int netpoll_parse_options(struct netpoll *np, char *opt)
@@ -695,7 +695,7 @@ int netpoll_setup(struct netpoll *np)
695 atomic_inc(&npinfo->refcnt); 695 atomic_inc(&npinfo->refcnt);
696 } 696 }
697 697
698 if (!ndev->poll_controller) { 698 if (!ndev->netdev_ops->ndo_poll_controller) {
699 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", 699 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
700 np->name, np->dev_name); 700 np->name, np->dev_name);
701 err = -ENOTSUPP; 701 err = -ENOTSUPP;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8997e912aaaf..4e77914c4d42 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -422,6 +422,7 @@ static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t,
422 const char *ifname); 422 const char *ifname);
423static int pktgen_device_event(struct notifier_block *, unsigned long, void *); 423static int pktgen_device_event(struct notifier_block *, unsigned long, void *);
424static void pktgen_run_all_threads(void); 424static void pktgen_run_all_threads(void);
425static void pktgen_reset_all_threads(void);
425static void pktgen_stop_all_threads_ifs(void); 426static void pktgen_stop_all_threads_ifs(void);
426static int pktgen_stop_device(struct pktgen_dev *pkt_dev); 427static int pktgen_stop_device(struct pktgen_dev *pkt_dev);
427static void pktgen_stop(struct pktgen_thread *t); 428static void pktgen_stop(struct pktgen_thread *t);
@@ -480,6 +481,9 @@ static ssize_t pgctrl_write(struct file *file, const char __user * buf,
480 else if (!strcmp(data, "start")) 481 else if (!strcmp(data, "start"))
481 pktgen_run_all_threads(); 482 pktgen_run_all_threads();
482 483
484 else if (!strcmp(data, "reset"))
485 pktgen_reset_all_threads();
486
483 else 487 else
484 printk(KERN_WARNING "pktgen: Unknown command: %s\n", data); 488 printk(KERN_WARNING "pktgen: Unknown command: %s\n", data);
485 489
@@ -509,7 +513,6 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
509 __u64 sa; 513 __u64 sa;
510 __u64 stopped; 514 __u64 stopped;
511 __u64 now = getCurUs(); 515 __u64 now = getCurUs();
512 DECLARE_MAC_BUF(mac);
513 516
514 seq_printf(seq, 517 seq_printf(seq,
515 "Params: count %llu min_pkt_size: %u max_pkt_size: %u\n", 518 "Params: count %llu min_pkt_size: %u max_pkt_size: %u\n",
@@ -554,12 +557,12 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
554 557
555 seq_puts(seq, " src_mac: "); 558 seq_puts(seq, " src_mac: ");
556 559
557 seq_printf(seq, "%s ", 560 seq_printf(seq, "%pM ",
558 print_mac(mac, is_zero_ether_addr(pkt_dev->src_mac) ? 561 is_zero_ether_addr(pkt_dev->src_mac) ?
559 pkt_dev->odev->dev_addr : pkt_dev->src_mac)); 562 pkt_dev->odev->dev_addr : pkt_dev->src_mac);
560 563
561 seq_printf(seq, "dst_mac: "); 564 seq_printf(seq, "dst_mac: ");
562 seq_printf(seq, "%s\n", print_mac(mac, pkt_dev->dst_mac)); 565 seq_printf(seq, "%pM\n", pkt_dev->dst_mac);
563 566
564 seq_printf(seq, 567 seq_printf(seq,
565 " udp_src_min: %d udp_src_max: %d udp_dst_min: %d udp_dst_max: %d\n", 568 " udp_src_min: %d udp_src_max: %d udp_dst_min: %d udp_dst_max: %d\n",
@@ -3169,6 +3172,24 @@ static void pktgen_run_all_threads(void)
3169 pktgen_wait_all_threads_run(); 3172 pktgen_wait_all_threads_run();
3170} 3173}
3171 3174
3175static void pktgen_reset_all_threads(void)
3176{
3177 struct pktgen_thread *t;
3178
3179 pr_debug("pktgen: entering pktgen_reset_all_threads.\n");
3180
3181 mutex_lock(&pktgen_thread_lock);
3182
3183 list_for_each_entry(t, &pktgen_threads, th_list)
3184 t->control |= (T_REMDEVALL);
3185
3186 mutex_unlock(&pktgen_thread_lock);
3187
3188 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */
3189
3190 pktgen_wait_all_threads_run();
3191}
3192
3172static void show_results(struct pktgen_dev *pkt_dev, int nr_frags) 3193static void show_results(struct pktgen_dev *pkt_dev, int nr_frags)
3173{ 3194{
3174 __u64 total_us, bps, mbps, pps, idle; 3195 __u64 total_us, bps, mbps, pps, idle;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 4dfb6b4d4559..790dd205bb5d 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -551,7 +551,7 @@ static void set_operstate(struct net_device *dev, unsigned char transition)
551} 551}
552 552
553static void copy_rtnl_link_stats(struct rtnl_link_stats *a, 553static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
554 struct net_device_stats *b) 554 const struct net_device_stats *b)
555{ 555{
556 a->rx_packets = b->rx_packets; 556 a->rx_packets = b->rx_packets;
557 a->tx_packets = b->tx_packets; 557 a->tx_packets = b->tx_packets;
@@ -609,7 +609,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
609 struct netdev_queue *txq; 609 struct netdev_queue *txq;
610 struct ifinfomsg *ifm; 610 struct ifinfomsg *ifm;
611 struct nlmsghdr *nlh; 611 struct nlmsghdr *nlh;
612 struct net_device_stats *stats; 612 const struct net_device_stats *stats;
613 struct nlattr *attr; 613 struct nlattr *attr;
614 614
615 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags); 615 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);
@@ -666,7 +666,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
666 if (attr == NULL) 666 if (attr == NULL)
667 goto nla_put_failure; 667 goto nla_put_failure;
668 668
669 stats = dev->get_stats(dev); 669 stats = dev_get_stats(dev);
670 copy_rtnl_link_stats(nla_data(attr), stats); 670 copy_rtnl_link_stats(nla_data(attr), stats);
671 671
672 if (dev->rtnl_link_ops) { 672 if (dev->rtnl_link_ops) {
@@ -762,6 +762,7 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[])
762static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, 762static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
763 struct nlattr **tb, char *ifname, int modified) 763 struct nlattr **tb, char *ifname, int modified)
764{ 764{
765 const struct net_device_ops *ops = dev->netdev_ops;
765 int send_addr_notify = 0; 766 int send_addr_notify = 0;
766 int err; 767 int err;
767 768
@@ -783,7 +784,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
783 struct rtnl_link_ifmap *u_map; 784 struct rtnl_link_ifmap *u_map;
784 struct ifmap k_map; 785 struct ifmap k_map;
785 786
786 if (!dev->set_config) { 787 if (!ops->ndo_set_config) {
787 err = -EOPNOTSUPP; 788 err = -EOPNOTSUPP;
788 goto errout; 789 goto errout;
789 } 790 }
@@ -801,7 +802,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
801 k_map.dma = (unsigned char) u_map->dma; 802 k_map.dma = (unsigned char) u_map->dma;
802 k_map.port = (unsigned char) u_map->port; 803 k_map.port = (unsigned char) u_map->port;
803 804
804 err = dev->set_config(dev, &k_map); 805 err = ops->ndo_set_config(dev, &k_map);
805 if (err < 0) 806 if (err < 0)
806 goto errout; 807 goto errout;
807 808
@@ -812,7 +813,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
812 struct sockaddr *sa; 813 struct sockaddr *sa;
813 int len; 814 int len;
814 815
815 if (!dev->set_mac_address) { 816 if (!ops->ndo_set_mac_address) {
816 err = -EOPNOTSUPP; 817 err = -EOPNOTSUPP;
817 goto errout; 818 goto errout;
818 } 819 }
@@ -831,7 +832,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
831 sa->sa_family = dev->type; 832 sa->sa_family = dev->type;
832 memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]), 833 memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]),
833 dev->addr_len); 834 dev->addr_len);
834 err = dev->set_mac_address(dev, sa); 835 err = ops->ndo_set_mac_address(dev, sa);
835 kfree(sa); 836 kfree(sa);
836 if (err) 837 if (err)
837 goto errout; 838 goto errout;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index d49ef8301b5b..267185a848f6 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -501,7 +501,7 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
501 new->network_header = old->network_header; 501 new->network_header = old->network_header;
502 new->mac_header = old->mac_header; 502 new->mac_header = old->mac_header;
503 new->dst = dst_clone(old->dst); 503 new->dst = dst_clone(old->dst);
504#ifdef CONFIG_INET 504#ifdef CONFIG_XFRM
505 new->sp = secpath_get(old->sp); 505 new->sp = secpath_get(old->sp);
506#endif 506#endif
507 memcpy(new->cb, old->cb, sizeof(old->cb)); 507 memcpy(new->cb, old->cb, sizeof(old->cb));
@@ -556,6 +556,7 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
556 C(truesize); 556 C(truesize);
557#if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE) 557#if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE)
558 C(do_not_encrypt); 558 C(do_not_encrypt);
559 C(requeue);
559#endif 560#endif
560 atomic_set(&n->users, 1); 561 atomic_set(&n->users, 1);
561 562
diff --git a/net/core/sock.c b/net/core/sock.c
index 341e39456952..a4e840e5a053 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2040,7 +2040,8 @@ int proto_register(struct proto *prot, int alloc_slab)
2040 2040
2041 if (alloc_slab) { 2041 if (alloc_slab) {
2042 prot->slab = kmem_cache_create(prot->name, prot->obj_size, 0, 2042 prot->slab = kmem_cache_create(prot->name, prot->obj_size, 0,
2043 SLAB_HWCACHE_ALIGN, NULL); 2043 SLAB_HWCACHE_ALIGN | prot->slab_flags,
2044 NULL);
2044 2045
2045 if (prot->slab == NULL) { 2046 if (prot->slab == NULL) {
2046 printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n", 2047 printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n",
@@ -2079,7 +2080,9 @@ int proto_register(struct proto *prot, int alloc_slab)
2079 prot->twsk_prot->twsk_slab = 2080 prot->twsk_prot->twsk_slab =
2080 kmem_cache_create(timewait_sock_slab_name, 2081 kmem_cache_create(timewait_sock_slab_name,
2081 prot->twsk_prot->twsk_obj_size, 2082 prot->twsk_prot->twsk_obj_size,
2082 0, SLAB_HWCACHE_ALIGN, 2083 0,
2084 SLAB_HWCACHE_ALIGN |
2085 prot->slab_flags,
2083 NULL); 2086 NULL);
2084 if (prot->twsk_prot->twsk_slab == NULL) 2087 if (prot->twsk_prot->twsk_slab == NULL)
2085 goto out_free_timewait_sock_slab_name; 2088 goto out_free_timewait_sock_slab_name;
@@ -2171,7 +2174,7 @@ static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
2171 "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n", 2174 "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n",
2172 proto->name, 2175 proto->name,
2173 proto->obj_size, 2176 proto->obj_size,
2174 proto->sockets_allocated != NULL ? atomic_read(proto->sockets_allocated) : -1, 2177 sock_prot_inuse_get(seq_file_net(seq), proto),
2175 proto->memory_allocated != NULL ? atomic_read(proto->memory_allocated) : -1, 2178 proto->memory_allocated != NULL ? atomic_read(proto->memory_allocated) : -1,
2176 proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI", 2179 proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI",
2177 proto->max_header, 2180 proto->max_header,
@@ -2225,7 +2228,8 @@ static const struct seq_operations proto_seq_ops = {
2225 2228
2226static int proto_seq_open(struct inode *inode, struct file *file) 2229static int proto_seq_open(struct inode *inode, struct file *file)
2227{ 2230{
2228 return seq_open(file, &proto_seq_ops); 2231 return seq_open_net(inode, file, &proto_seq_ops,
2232 sizeof(struct seq_net_private));
2229} 2233}
2230 2234
2231static const struct file_operations proto_seq_fops = { 2235static const struct file_operations proto_seq_fops = {
@@ -2233,13 +2237,31 @@ static const struct file_operations proto_seq_fops = {
2233 .open = proto_seq_open, 2237 .open = proto_seq_open,
2234 .read = seq_read, 2238 .read = seq_read,
2235 .llseek = seq_lseek, 2239 .llseek = seq_lseek,
2236 .release = seq_release, 2240 .release = seq_release_net,
2241};
2242
2243static __net_init int proto_init_net(struct net *net)
2244{
2245 if (!proc_net_fops_create(net, "protocols", S_IRUGO, &proto_seq_fops))
2246 return -ENOMEM;
2247
2248 return 0;
2249}
2250
2251static __net_exit void proto_exit_net(struct net *net)
2252{
2253 proc_net_remove(net, "protocols");
2254}
2255
2256
2257static __net_initdata struct pernet_operations proto_net_ops = {
2258 .init = proto_init_net,
2259 .exit = proto_exit_net,
2237}; 2260};
2238 2261
2239static int __init proto_init(void) 2262static int __init proto_init(void)
2240{ 2263{
2241 /* register /proc/net/protocols */ 2264 return register_pernet_subsys(&proto_net_ops);
2242 return proc_net_fops_create(&init_net, "protocols", S_IRUGO, &proto_seq_fops) == NULL ? -ENOBUFS : 0;
2243} 2265}
2244 2266
2245subsys_initcall(proto_init); 2267subsys_initcall(proto_init);
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index f686467ff12b..2bc0384b0448 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -22,7 +22,7 @@ static struct ctl_table net_core_table[] = {
22 .data = &sysctl_wmem_max, 22 .data = &sysctl_wmem_max,
23 .maxlen = sizeof(int), 23 .maxlen = sizeof(int),
24 .mode = 0644, 24 .mode = 0644,
25 .proc_handler = &proc_dointvec 25 .proc_handler = proc_dointvec
26 }, 26 },
27 { 27 {
28 .ctl_name = NET_CORE_RMEM_MAX, 28 .ctl_name = NET_CORE_RMEM_MAX,
@@ -30,7 +30,7 @@ static struct ctl_table net_core_table[] = {
30 .data = &sysctl_rmem_max, 30 .data = &sysctl_rmem_max,
31 .maxlen = sizeof(int), 31 .maxlen = sizeof(int),
32 .mode = 0644, 32 .mode = 0644,
33 .proc_handler = &proc_dointvec 33 .proc_handler = proc_dointvec
34 }, 34 },
35 { 35 {
36 .ctl_name = NET_CORE_WMEM_DEFAULT, 36 .ctl_name = NET_CORE_WMEM_DEFAULT,
@@ -38,7 +38,7 @@ static struct ctl_table net_core_table[] = {
38 .data = &sysctl_wmem_default, 38 .data = &sysctl_wmem_default,
39 .maxlen = sizeof(int), 39 .maxlen = sizeof(int),
40 .mode = 0644, 40 .mode = 0644,
41 .proc_handler = &proc_dointvec 41 .proc_handler = proc_dointvec
42 }, 42 },
43 { 43 {
44 .ctl_name = NET_CORE_RMEM_DEFAULT, 44 .ctl_name = NET_CORE_RMEM_DEFAULT,
@@ -46,7 +46,7 @@ static struct ctl_table net_core_table[] = {
46 .data = &sysctl_rmem_default, 46 .data = &sysctl_rmem_default,
47 .maxlen = sizeof(int), 47 .maxlen = sizeof(int),
48 .mode = 0644, 48 .mode = 0644,
49 .proc_handler = &proc_dointvec 49 .proc_handler = proc_dointvec
50 }, 50 },
51 { 51 {
52 .ctl_name = NET_CORE_DEV_WEIGHT, 52 .ctl_name = NET_CORE_DEV_WEIGHT,
@@ -54,7 +54,7 @@ static struct ctl_table net_core_table[] = {
54 .data = &weight_p, 54 .data = &weight_p,
55 .maxlen = sizeof(int), 55 .maxlen = sizeof(int),
56 .mode = 0644, 56 .mode = 0644,
57 .proc_handler = &proc_dointvec 57 .proc_handler = proc_dointvec
58 }, 58 },
59 { 59 {
60 .ctl_name = NET_CORE_MAX_BACKLOG, 60 .ctl_name = NET_CORE_MAX_BACKLOG,
@@ -62,7 +62,7 @@ static struct ctl_table net_core_table[] = {
62 .data = &netdev_max_backlog, 62 .data = &netdev_max_backlog,
63 .maxlen = sizeof(int), 63 .maxlen = sizeof(int),
64 .mode = 0644, 64 .mode = 0644,
65 .proc_handler = &proc_dointvec 65 .proc_handler = proc_dointvec
66 }, 66 },
67 { 67 {
68 .ctl_name = NET_CORE_MSG_COST, 68 .ctl_name = NET_CORE_MSG_COST,
@@ -70,8 +70,8 @@ static struct ctl_table net_core_table[] = {
70 .data = &net_ratelimit_state.interval, 70 .data = &net_ratelimit_state.interval,
71 .maxlen = sizeof(int), 71 .maxlen = sizeof(int),
72 .mode = 0644, 72 .mode = 0644,
73 .proc_handler = &proc_dointvec_jiffies, 73 .proc_handler = proc_dointvec_jiffies,
74 .strategy = &sysctl_jiffies, 74 .strategy = sysctl_jiffies,
75 }, 75 },
76 { 76 {
77 .ctl_name = NET_CORE_MSG_BURST, 77 .ctl_name = NET_CORE_MSG_BURST,
@@ -79,7 +79,7 @@ static struct ctl_table net_core_table[] = {
79 .data = &net_ratelimit_state.burst, 79 .data = &net_ratelimit_state.burst,
80 .maxlen = sizeof(int), 80 .maxlen = sizeof(int),
81 .mode = 0644, 81 .mode = 0644,
82 .proc_handler = &proc_dointvec, 82 .proc_handler = proc_dointvec,
83 }, 83 },
84 { 84 {
85 .ctl_name = NET_CORE_OPTMEM_MAX, 85 .ctl_name = NET_CORE_OPTMEM_MAX,
@@ -87,7 +87,7 @@ static struct ctl_table net_core_table[] = {
87 .data = &sysctl_optmem_max, 87 .data = &sysctl_optmem_max,
88 .maxlen = sizeof(int), 88 .maxlen = sizeof(int),
89 .mode = 0644, 89 .mode = 0644,
90 .proc_handler = &proc_dointvec 90 .proc_handler = proc_dointvec
91 }, 91 },
92#ifdef CONFIG_XFRM 92#ifdef CONFIG_XFRM
93 { 93 {
@@ -96,7 +96,7 @@ static struct ctl_table net_core_table[] = {
96 .data = &sysctl_xfrm_aevent_etime, 96 .data = &sysctl_xfrm_aevent_etime,
97 .maxlen = sizeof(u32), 97 .maxlen = sizeof(u32),
98 .mode = 0644, 98 .mode = 0644,
99 .proc_handler = &proc_dointvec 99 .proc_handler = proc_dointvec
100 }, 100 },
101 { 101 {
102 .ctl_name = NET_CORE_AEVENT_RSEQTH, 102 .ctl_name = NET_CORE_AEVENT_RSEQTH,
@@ -104,7 +104,7 @@ static struct ctl_table net_core_table[] = {
104 .data = &sysctl_xfrm_aevent_rseqth, 104 .data = &sysctl_xfrm_aevent_rseqth,
105 .maxlen = sizeof(u32), 105 .maxlen = sizeof(u32),
106 .mode = 0644, 106 .mode = 0644,
107 .proc_handler = &proc_dointvec 107 .proc_handler = proc_dointvec
108 }, 108 },
109 { 109 {
110 .ctl_name = CTL_UNNUMBERED, 110 .ctl_name = CTL_UNNUMBERED,
@@ -112,7 +112,7 @@ static struct ctl_table net_core_table[] = {
112 .data = &sysctl_xfrm_larval_drop, 112 .data = &sysctl_xfrm_larval_drop,
113 .maxlen = sizeof(int), 113 .maxlen = sizeof(int),
114 .mode = 0644, 114 .mode = 0644,
115 .proc_handler = &proc_dointvec 115 .proc_handler = proc_dointvec
116 }, 116 },
117 { 117 {
118 .ctl_name = CTL_UNNUMBERED, 118 .ctl_name = CTL_UNNUMBERED,
@@ -120,7 +120,7 @@ static struct ctl_table net_core_table[] = {
120 .data = &sysctl_xfrm_acq_expires, 120 .data = &sysctl_xfrm_acq_expires,
121 .maxlen = sizeof(int), 121 .maxlen = sizeof(int),
122 .mode = 0644, 122 .mode = 0644,
123 .proc_handler = &proc_dointvec 123 .proc_handler = proc_dointvec
124 }, 124 },
125#endif /* CONFIG_XFRM */ 125#endif /* CONFIG_XFRM */
126#endif /* CONFIG_NET */ 126#endif /* CONFIG_NET */
@@ -130,7 +130,7 @@ static struct ctl_table net_core_table[] = {
130 .data = &netdev_budget, 130 .data = &netdev_budget,
131 .maxlen = sizeof(int), 131 .maxlen = sizeof(int),
132 .mode = 0644, 132 .mode = 0644,
133 .proc_handler = &proc_dointvec 133 .proc_handler = proc_dointvec
134 }, 134 },
135 { 135 {
136 .ctl_name = NET_CORE_WARNINGS, 136 .ctl_name = NET_CORE_WARNINGS,
@@ -138,7 +138,7 @@ static struct ctl_table net_core_table[] = {
138 .data = &net_msg_warn, 138 .data = &net_msg_warn,
139 .maxlen = sizeof(int), 139 .maxlen = sizeof(int),
140 .mode = 0644, 140 .mode = 0644,
141 .proc_handler = &proc_dointvec 141 .proc_handler = proc_dointvec
142 }, 142 },
143 { .ctl_name = 0 } 143 { .ctl_name = 0 }
144}; 144};
@@ -150,7 +150,7 @@ static struct ctl_table netns_core_table[] = {
150 .data = &init_net.core.sysctl_somaxconn, 150 .data = &init_net.core.sysctl_somaxconn,
151 .maxlen = sizeof(int), 151 .maxlen = sizeof(int),
152 .mode = 0644, 152 .mode = 0644,
153 .proc_handler = &proc_dointvec 153 .proc_handler = proc_dointvec
154 }, 154 },
155 { .ctl_name = 0 } 155 { .ctl_name = 0 }
156}; 156};
diff --git a/net/dccp/ccid.c b/net/dccp/ccid.c
index 8fe931a3d7a1..647cb0614f84 100644
--- a/net/dccp/ccid.c
+++ b/net/dccp/ccid.c
@@ -13,6 +13,13 @@
13 13
14#include "ccid.h" 14#include "ccid.h"
15 15
16static u8 builtin_ccids[] = {
17 DCCPC_CCID2, /* CCID2 is supported by default */
18#if defined(CONFIG_IP_DCCP_CCID3) || defined(CONFIG_IP_DCCP_CCID3_MODULE)
19 DCCPC_CCID3,
20#endif
21};
22
16static struct ccid_operations *ccids[CCID_MAX]; 23static struct ccid_operations *ccids[CCID_MAX];
17#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) 24#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
18static atomic_t ccids_lockct = ATOMIC_INIT(0); 25static atomic_t ccids_lockct = ATOMIC_INIT(0);
@@ -86,6 +93,47 @@ static void ccid_kmem_cache_destroy(struct kmem_cache *slab)
86 } 93 }
87} 94}
88 95
96/* check that up to @array_len members in @ccid_array are supported */
97bool ccid_support_check(u8 const *ccid_array, u8 array_len)
98{
99 u8 i, j, found;
100
101 for (i = 0, found = 0; i < array_len; i++, found = 0) {
102 for (j = 0; !found && j < ARRAY_SIZE(builtin_ccids); j++)
103 found = (ccid_array[i] == builtin_ccids[j]);
104 if (!found)
105 return false;
106 }
107 return true;
108}
109
110/**
111 * ccid_get_builtin_ccids - Provide copy of `builtin' CCID array
112 * @ccid_array: pointer to copy into
113 * @array_len: value to return length into
114 * This function allocates memory - caller must see that it is freed after use.
115 */
116int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len)
117{
118 *ccid_array = kmemdup(builtin_ccids, sizeof(builtin_ccids), gfp_any());
119 if (*ccid_array == NULL)
120 return -ENOBUFS;
121 *array_len = ARRAY_SIZE(builtin_ccids);
122 return 0;
123}
124
125int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
126 char __user *optval, int __user *optlen)
127{
128 if (len < sizeof(builtin_ccids))
129 return -EINVAL;
130
131 if (put_user(sizeof(builtin_ccids), optlen) ||
132 copy_to_user(optval, builtin_ccids, sizeof(builtin_ccids)))
133 return -EFAULT;
134 return 0;
135}
136
89int ccid_register(struct ccid_operations *ccid_ops) 137int ccid_register(struct ccid_operations *ccid_ops)
90{ 138{
91 int err = -ENOBUFS; 139 int err = -ENOBUFS;
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index fdeae7b57319..259f5469d7d0 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -103,6 +103,11 @@ static inline void *ccid_priv(const struct ccid *ccid)
103 return (void *)ccid->ccid_priv; 103 return (void *)ccid->ccid_priv;
104} 104}
105 105
106extern bool ccid_support_check(u8 const *ccid_array, u8 array_len);
107extern int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len);
108extern int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
109 char __user *, int __user *);
110
106extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, 111extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx,
107 gfp_t gfp); 112 gfp_t gfp);
108 113
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index 9a430734530c..c9ea19a4d85e 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -25,7 +25,7 @@
25/* 25/*
26 * This implementation should follow RFC 4341 26 * This implementation should follow RFC 4341
27 */ 27 */
28 28#include "../feat.h"
29#include "../ccid.h" 29#include "../ccid.h"
30#include "../dccp.h" 30#include "../dccp.h"
31#include "ccid2.h" 31#include "ccid2.h"
@@ -147,8 +147,8 @@ static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val)
147 DCCP_WARN("Limiting Ack Ratio (%u) to %u\n", val, max_ratio); 147 DCCP_WARN("Limiting Ack Ratio (%u) to %u\n", val, max_ratio);
148 val = max_ratio; 148 val = max_ratio;
149 } 149 }
150 if (val > 0xFFFF) /* RFC 4340, 11.3 */ 150 if (val > DCCPF_ACK_RATIO_MAX)
151 val = 0xFFFF; 151 val = DCCPF_ACK_RATIO_MAX;
152 152
153 if (val == dp->dccps_l_ack_ratio) 153 if (val == dp->dccps_l_ack_ratio)
154 return; 154 return;
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index b4bc6e095a0e..031ce350d3c1 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -98,7 +98,6 @@ extern int sysctl_dccp_retries2;
98extern int sysctl_dccp_feat_sequence_window; 98extern int sysctl_dccp_feat_sequence_window;
99extern int sysctl_dccp_feat_rx_ccid; 99extern int sysctl_dccp_feat_rx_ccid;
100extern int sysctl_dccp_feat_tx_ccid; 100extern int sysctl_dccp_feat_tx_ccid;
101extern int sysctl_dccp_feat_ack_ratio;
102extern int sysctl_dccp_feat_send_ack_vector; 101extern int sysctl_dccp_feat_send_ack_vector;
103extern int sysctl_dccp_feat_send_ndp_count; 102extern int sysctl_dccp_feat_send_ndp_count;
104extern int sysctl_dccp_tx_qlen; 103extern int sysctl_dccp_tx_qlen;
@@ -252,7 +251,8 @@ extern const char *dccp_state_name(const int state);
252extern void dccp_set_state(struct sock *sk, const int state); 251extern void dccp_set_state(struct sock *sk, const int state);
253extern void dccp_done(struct sock *sk); 252extern void dccp_done(struct sock *sk);
254 253
255extern void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb); 254extern int dccp_reqsk_init(struct request_sock *rq, struct dccp_sock const *dp,
255 struct sk_buff const *skb);
256 256
257extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb); 257extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
258 258
@@ -441,6 +441,10 @@ static inline int dccp_ack_pending(const struct sock *sk)
441 inet_csk_ack_scheduled(sk); 441 inet_csk_ack_scheduled(sk);
442} 442}
443 443
444extern int dccp_feat_finalise_settings(struct dccp_sock *dp);
445extern int dccp_feat_server_ccid_dependencies(struct dccp_request_sock *dreq);
446extern void dccp_feat_list_purge(struct list_head *fn_list);
447
444extern int dccp_insert_options(struct sock *sk, struct sk_buff *skb); 448extern int dccp_insert_options(struct sock *sk, struct sk_buff *skb);
445extern int dccp_insert_options_rsk(struct dccp_request_sock*, struct sk_buff*); 449extern int dccp_insert_options_rsk(struct dccp_request_sock*, struct sk_buff*);
446extern int dccp_insert_option_elapsed_time(struct sock *sk, 450extern int dccp_insert_option_elapsed_time(struct sock *sk,
diff --git a/net/dccp/diag.c b/net/dccp/diag.c
index d8a3509b26f6..d1e100395efb 100644
--- a/net/dccp/diag.c
+++ b/net/dccp/diag.c
@@ -45,7 +45,7 @@ static void dccp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
45 dccp_get_info(sk, _info); 45 dccp_get_info(sk, _info);
46} 46}
47 47
48static struct inet_diag_handler dccp_diag_handler = { 48static const struct inet_diag_handler dccp_diag_handler = {
49 .idiag_hashinfo = &dccp_hashinfo, 49 .idiag_hashinfo = &dccp_hashinfo,
50 .idiag_get_info = dccp_diag_get_info, 50 .idiag_get_info = dccp_diag_get_info,
51 .idiag_type = DCCPDIAG_GETSOCK, 51 .idiag_type = DCCPDIAG_GETSOCK,
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index 933a0ecf8d46..2c2216f64b1b 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -6,6 +6,8 @@
6 * 6 *
7 * ASSUMPTIONS 7 * ASSUMPTIONS
8 * ----------- 8 * -----------
9 * o Feature negotiation is coordinated with connection setup (as in TCP), wild
10 * changes of parameters of an established connection are not supported.
9 * o All currently known SP features have 1-byte quantities. If in the future 11 * o All currently known SP features have 1-byte quantities. If in the future
10 * extensions of RFCs 4340..42 define features with item lengths larger than 12 * extensions of RFCs 4340..42 define features with item lengths larger than
11 * one byte, a feature-specific extension of the code will be required. 13 * one byte, a feature-specific extension of the code will be required.
@@ -23,53 +25,560 @@
23 25
24#define DCCP_FEAT_SP_NOAGREE (-123) 26#define DCCP_FEAT_SP_NOAGREE (-123)
25 27
26int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, 28static const struct {
27 u8 *val, u8 len, gfp_t gfp) 29 u8 feat_num; /* DCCPF_xxx */
30 enum dccp_feat_type rxtx; /* RX or TX */
31 enum dccp_feat_type reconciliation; /* SP or NN */
32 u8 default_value; /* as in 6.4 */
33/*
34 * Lookup table for location and type of features (from RFC 4340/4342)
35 * +--------------------------+----+-----+----+----+---------+-----------+
36 * | Feature | Location | Reconc. | Initial | Section |
37 * | | RX | TX | SP | NN | Value | Reference |
38 * +--------------------------+----+-----+----+----+---------+-----------+
39 * | DCCPF_CCID | | X | X | | 2 | 10 |
40 * | DCCPF_SHORT_SEQNOS | | X | X | | 0 | 7.6.1 |
41 * | DCCPF_SEQUENCE_WINDOW | | X | | X | 100 | 7.5.2 |
42 * | DCCPF_ECN_INCAPABLE | X | | X | | 0 | 12.1 |
43 * | DCCPF_ACK_RATIO | | X | | X | 2 | 11.3 |
44 * | DCCPF_SEND_ACK_VECTOR | X | | X | | 0 | 11.5 |
45 * | DCCPF_SEND_NDP_COUNT | | X | X | | 0 | 7.7.2 |
46 * | DCCPF_MIN_CSUM_COVER | X | | X | | 0 | 9.2.1 |
47 * | DCCPF_DATA_CHECKSUM | X | | X | | 0 | 9.3.1 |
48 * | DCCPF_SEND_LEV_RATE | X | | X | | 0 | 4342/8.4 |
49 * +--------------------------+----+-----+----+----+---------+-----------+
50 */
51} dccp_feat_table[] = {
52 { DCCPF_CCID, FEAT_AT_TX, FEAT_SP, 2 },
53 { DCCPF_SHORT_SEQNOS, FEAT_AT_TX, FEAT_SP, 0 },
54 { DCCPF_SEQUENCE_WINDOW, FEAT_AT_TX, FEAT_NN, 100 },
55 { DCCPF_ECN_INCAPABLE, FEAT_AT_RX, FEAT_SP, 0 },
56 { DCCPF_ACK_RATIO, FEAT_AT_TX, FEAT_NN, 2 },
57 { DCCPF_SEND_ACK_VECTOR, FEAT_AT_RX, FEAT_SP, 0 },
58 { DCCPF_SEND_NDP_COUNT, FEAT_AT_TX, FEAT_SP, 0 },
59 { DCCPF_MIN_CSUM_COVER, FEAT_AT_RX, FEAT_SP, 0 },
60 { DCCPF_DATA_CHECKSUM, FEAT_AT_RX, FEAT_SP, 0 },
61 { DCCPF_SEND_LEV_RATE, FEAT_AT_RX, FEAT_SP, 0 },
62};
63#define DCCP_FEAT_SUPPORTED_MAX ARRAY_SIZE(dccp_feat_table)
64
65/**
66 * dccp_feat_index - Hash function to map feature number into array position
67 * Returns consecutive array index or -1 if the feature is not understood.
68 */
69static int dccp_feat_index(u8 feat_num)
28{ 70{
29 struct dccp_opt_pend *opt; 71 /* The first 9 entries are occupied by the types from RFC 4340, 6.4 */
72 if (feat_num > DCCPF_RESERVED && feat_num <= DCCPF_DATA_CHECKSUM)
73 return feat_num - 1;
30 74
31 dccp_feat_debug(type, feature, *val); 75 /*
76 * Other features: add cases for new feature types here after adding
77 * them to the above table.
78 */
79 switch (feat_num) {
80 case DCCPF_SEND_LEV_RATE:
81 return DCCP_FEAT_SUPPORTED_MAX - 1;
82 }
83 return -1;
84}
32 85
33 if (len > 3) { 86static u8 dccp_feat_type(u8 feat_num)
34 DCCP_WARN("invalid length %d\n", len); 87{
35 return -EINVAL; 88 int idx = dccp_feat_index(feat_num);
89
90 if (idx < 0)
91 return FEAT_UNKNOWN;
92 return dccp_feat_table[idx].reconciliation;
93}
94
95static int dccp_feat_default_value(u8 feat_num)
96{
97 int idx = dccp_feat_index(feat_num);
98 /*
99 * There are no default values for unknown features, so encountering a
100 * negative index here indicates a serious problem somewhere else.
101 */
102 DCCP_BUG_ON(idx < 0);
103
104 return idx < 0 ? 0 : dccp_feat_table[idx].default_value;
105}
106
107/* copy constructor, fval must not already contain allocated memory */
108static int dccp_feat_clone_sp_val(dccp_feat_val *fval, u8 const *val, u8 len)
109{
110 fval->sp.len = len;
111 if (fval->sp.len > 0) {
112 fval->sp.vec = kmemdup(val, len, gfp_any());
113 if (fval->sp.vec == NULL) {
114 fval->sp.len = 0;
115 return -ENOBUFS;
116 }
36 } 117 }
37 /* XXX add further sanity checks */ 118 return 0;
119}
38 120
39 /* check if that feature is already being negotiated */ 121static void dccp_feat_val_destructor(u8 feat_num, dccp_feat_val *val)
40 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) { 122{
41 /* ok we found a negotiation for this option already */ 123 if (unlikely(val == NULL))
42 if (opt->dccpop_feat == feature && opt->dccpop_type == type) { 124 return;
43 dccp_pr_debug("Replacing old\n"); 125 if (dccp_feat_type(feat_num) == FEAT_SP)
44 /* replace */ 126 kfree(val->sp.vec);
45 BUG_ON(opt->dccpop_val == NULL); 127 memset(val, 0, sizeof(*val));
46 kfree(opt->dccpop_val); 128}
47 opt->dccpop_val = val; 129
48 opt->dccpop_len = len; 130static struct dccp_feat_entry *
49 opt->dccpop_conf = 0; 131 dccp_feat_clone_entry(struct dccp_feat_entry const *original)
50 return 0; 132{
133 struct dccp_feat_entry *new;
134 u8 type = dccp_feat_type(original->feat_num);
135
136 if (type == FEAT_UNKNOWN)
137 return NULL;
138
139 new = kmemdup(original, sizeof(struct dccp_feat_entry), gfp_any());
140 if (new == NULL)
141 return NULL;
142
143 if (type == FEAT_SP && dccp_feat_clone_sp_val(&new->val,
144 original->val.sp.vec,
145 original->val.sp.len)) {
146 kfree(new);
147 return NULL;
148 }
149 return new;
150}
151
152static void dccp_feat_entry_destructor(struct dccp_feat_entry *entry)
153{
154 if (entry != NULL) {
155 dccp_feat_val_destructor(entry->feat_num, &entry->val);
156 kfree(entry);
157 }
158}
159
160/*
161 * List management functions
162 *
163 * Feature negotiation lists rely on and maintain the following invariants:
164 * - each feat_num in the list is known, i.e. we know its type and default value
165 * - each feat_num/is_local combination is unique (old entries are overwritten)
166 * - SP values are always freshly allocated
167 * - list is sorted in increasing order of feature number (faster lookup)
168 */
169static struct dccp_feat_entry *dccp_feat_list_lookup(struct list_head *fn_list,
170 u8 feat_num, bool is_local)
171{
172 struct dccp_feat_entry *entry;
173
174 list_for_each_entry(entry, fn_list, node) {
175 if (entry->feat_num == feat_num && entry->is_local == is_local)
176 return entry;
177 else if (entry->feat_num > feat_num)
178 break;
179 }
180 return NULL;
181}
182
183/**
184 * dccp_feat_entry_new - Central list update routine (called by all others)
185 * @head: list to add to
186 * @feat: feature number
187 * @local: whether the local (1) or remote feature with number @feat is meant
188 * This is the only constructor and serves to ensure the above invariants.
189 */
190static struct dccp_feat_entry *
191 dccp_feat_entry_new(struct list_head *head, u8 feat, bool local)
192{
193 struct dccp_feat_entry *entry;
194
195 list_for_each_entry(entry, head, node)
196 if (entry->feat_num == feat && entry->is_local == local) {
197 dccp_feat_val_destructor(entry->feat_num, &entry->val);
198 return entry;
199 } else if (entry->feat_num > feat) {
200 head = &entry->node;
201 break;
51 } 202 }
203
204 entry = kmalloc(sizeof(*entry), gfp_any());
205 if (entry != NULL) {
206 entry->feat_num = feat;
207 entry->is_local = local;
208 list_add_tail(&entry->node, head);
52 } 209 }
210 return entry;
211}
53 212
54 /* negotiation for a new feature */ 213/**
55 opt = kmalloc(sizeof(*opt), gfp); 214 * dccp_feat_push_change - Add/overwrite a Change option in the list
56 if (opt == NULL) 215 * @fn_list: feature-negotiation list to update
216 * @feat: one of %dccp_feature_numbers
217 * @local: whether local (1) or remote (0) @feat_num is meant
218 * @needs_mandatory: whether to use Mandatory feature negotiation options
219 * @fval: pointer to NN/SP value to be inserted (will be copied)
220 */
221static int dccp_feat_push_change(struct list_head *fn_list, u8 feat, u8 local,
222 u8 mandatory, dccp_feat_val *fval)
223{
224 struct dccp_feat_entry *new = dccp_feat_entry_new(fn_list, feat, local);
225
226 if (new == NULL)
57 return -ENOMEM; 227 return -ENOMEM;
58 228
59 opt->dccpop_type = type; 229 new->feat_num = feat;
60 opt->dccpop_feat = feature; 230 new->is_local = local;
61 opt->dccpop_len = len; 231 new->state = FEAT_INITIALISING;
62 opt->dccpop_val = val; 232 new->needs_confirm = 0;
63 opt->dccpop_conf = 0; 233 new->empty_confirm = 0;
64 opt->dccpop_sc = NULL; 234 new->val = *fval;
235 new->needs_mandatory = mandatory;
236
237 return 0;
238}
239
240static inline void dccp_feat_list_pop(struct dccp_feat_entry *entry)
241{
242 list_del(&entry->node);
243 dccp_feat_entry_destructor(entry);
244}
245
246void dccp_feat_list_purge(struct list_head *fn_list)
247{
248 struct dccp_feat_entry *entry, *next;
249
250 list_for_each_entry_safe(entry, next, fn_list, node)
251 dccp_feat_entry_destructor(entry);
252 INIT_LIST_HEAD(fn_list);
253}
254EXPORT_SYMBOL_GPL(dccp_feat_list_purge);
255
256/* generate @to as full clone of @from - @to must not contain any nodes */
257int dccp_feat_clone_list(struct list_head const *from, struct list_head *to)
258{
259 struct dccp_feat_entry *entry, *new;
260
261 INIT_LIST_HEAD(to);
262 list_for_each_entry(entry, from, node) {
263 new = dccp_feat_clone_entry(entry);
264 if (new == NULL)
265 goto cloning_failed;
266 list_add_tail(&new->node, to);
267 }
268 return 0;
269
270cloning_failed:
271 dccp_feat_list_purge(to);
272 return -ENOMEM;
273}
274
275static u8 dccp_feat_is_valid_nn_val(u8 feat_num, u64 val)
276{
277 switch (feat_num) {
278 case DCCPF_ACK_RATIO:
279 return val <= DCCPF_ACK_RATIO_MAX;
280 case DCCPF_SEQUENCE_WINDOW:
281 return val >= DCCPF_SEQ_WMIN && val <= DCCPF_SEQ_WMAX;
282 }
283 return 0; /* feature unknown - so we can't tell */
284}
285
286/* check that SP values are within the ranges defined in RFC 4340 */
287static u8 dccp_feat_is_valid_sp_val(u8 feat_num, u8 val)
288{
289 switch (feat_num) {
290 case DCCPF_CCID:
291 return val == DCCPC_CCID2 || val == DCCPC_CCID3;
292 /* Type-check Boolean feature values: */
293 case DCCPF_SHORT_SEQNOS:
294 case DCCPF_ECN_INCAPABLE:
295 case DCCPF_SEND_ACK_VECTOR:
296 case DCCPF_SEND_NDP_COUNT:
297 case DCCPF_DATA_CHECKSUM:
298 case DCCPF_SEND_LEV_RATE:
299 return val < 2;
300 case DCCPF_MIN_CSUM_COVER:
301 return val < 16;
302 }
303 return 0; /* feature unknown */
304}
305
306static u8 dccp_feat_sp_list_ok(u8 feat_num, u8 const *sp_list, u8 sp_len)
307{
308 if (sp_list == NULL || sp_len < 1)
309 return 0;
310 while (sp_len--)
311 if (!dccp_feat_is_valid_sp_val(feat_num, *sp_list++))
312 return 0;
313 return 1;
314}
315
316/**
317 * __feat_register_nn - Register new NN value on socket
318 * @fn: feature-negotiation list to register with
319 * @feat: an NN feature from %dccp_feature_numbers
320 * @mandatory: use Mandatory option if 1
321 * @nn_val: value to register (restricted to 4 bytes)
322 * Note that NN features are local by definition (RFC 4340, 6.3.2).
323 */
324static int __feat_register_nn(struct list_head *fn, u8 feat,
325 u8 mandatory, u64 nn_val)
326{
327 dccp_feat_val fval = { .nn = nn_val };
328
329 if (dccp_feat_type(feat) != FEAT_NN ||
330 !dccp_feat_is_valid_nn_val(feat, nn_val))
331 return -EINVAL;
332
333 /* Don't bother with default values, they will be activated anyway. */
334 if (nn_val - (u64)dccp_feat_default_value(feat) == 0)
335 return 0;
336
337 return dccp_feat_push_change(fn, feat, 1, mandatory, &fval);
338}
339
340/**
341 * __feat_register_sp - Register new SP value/list on socket
342 * @fn: feature-negotiation list to register with
343 * @feat: an SP feature from %dccp_feature_numbers
344 * @is_local: whether the local (1) or the remote (0) @feat is meant
345 * @mandatory: use Mandatory option if 1
346 * @sp_val: SP value followed by optional preference list
347 * @sp_len: length of @sp_val in bytes
348 */
349static int __feat_register_sp(struct list_head *fn, u8 feat, u8 is_local,
350 u8 mandatory, u8 const *sp_val, u8 sp_len)
351{
352 dccp_feat_val fval;
353
354 if (dccp_feat_type(feat) != FEAT_SP ||
355 !dccp_feat_sp_list_ok(feat, sp_val, sp_len))
356 return -EINVAL;
357
358 /* Avoid negotiating alien CCIDs by only advertising supported ones */
359 if (feat == DCCPF_CCID && !ccid_support_check(sp_val, sp_len))
360 return -EOPNOTSUPP;
65 361
66 BUG_ON(opt->dccpop_val == NULL); 362 if (dccp_feat_clone_sp_val(&fval, sp_val, sp_len))
363 return -ENOMEM;
67 364
68 list_add_tail(&opt->dccpop_node, &dmsk->dccpms_pending); 365 return dccp_feat_push_change(fn, feat, is_local, mandatory, &fval);
366}
367
368/**
369 * dccp_feat_register_sp - Register requests to change SP feature values
370 * @sk: client or listening socket
371 * @feat: one of %dccp_feature_numbers
372 * @is_local: whether the local (1) or remote (0) @feat is meant
373 * @list: array of preferred values, in descending order of preference
374 * @len: length of @list in bytes
375 */
376int dccp_feat_register_sp(struct sock *sk, u8 feat, u8 is_local,
377 u8 const *list, u8 len)
378{ /* any changes must be registered before establishing the connection */
379 if (sk->sk_state != DCCP_CLOSED)
380 return -EISCONN;
381 if (dccp_feat_type(feat) != FEAT_SP)
382 return -EINVAL;
383 return __feat_register_sp(&dccp_sk(sk)->dccps_featneg, feat, is_local,
384 0, list, len);
385}
386
387/* Analogous to dccp_feat_register_sp(), but for non-negotiable values */
388int dccp_feat_register_nn(struct sock *sk, u8 feat, u64 val)
389{
390 /* any changes must be registered before establishing the connection */
391 if (sk->sk_state != DCCP_CLOSED)
392 return -EISCONN;
393 if (dccp_feat_type(feat) != FEAT_NN)
394 return -EINVAL;
395 return __feat_register_nn(&dccp_sk(sk)->dccps_featneg, feat, 0, val);
396}
397
398/*
399 * Tracking features whose value depend on the choice of CCID
400 *
401 * This is designed with an extension in mind so that a list walk could be done
402 * before activating any features. However, the existing framework was found to
403 * work satisfactorily up until now, the automatic verification is left open.
404 * When adding new CCIDs, add a corresponding dependency table here.
405 */
406static const struct ccid_dependency *dccp_feat_ccid_deps(u8 ccid, bool is_local)
407{
408 static const struct ccid_dependency ccid2_dependencies[2][2] = {
409 /*
410 * CCID2 mandates Ack Vectors (RFC 4341, 4.): as CCID is a TX
411 * feature and Send Ack Vector is an RX feature, `is_local'
412 * needs to be reversed.
413 */
414 { /* Dependencies of the receiver-side (remote) CCID2 */
415 {
416 .dependent_feat = DCCPF_SEND_ACK_VECTOR,
417 .is_local = true,
418 .is_mandatory = true,
419 .val = 1
420 },
421 { 0, 0, 0, 0 }
422 },
423 { /* Dependencies of the sender-side (local) CCID2 */
424 {
425 .dependent_feat = DCCPF_SEND_ACK_VECTOR,
426 .is_local = false,
427 .is_mandatory = true,
428 .val = 1
429 },
430 { 0, 0, 0, 0 }
431 }
432 };
433 static const struct ccid_dependency ccid3_dependencies[2][5] = {
434 { /*
435 * Dependencies of the receiver-side CCID3
436 */
437 { /* locally disable Ack Vectors */
438 .dependent_feat = DCCPF_SEND_ACK_VECTOR,
439 .is_local = true,
440 .is_mandatory = false,
441 .val = 0
442 },
443 { /* see below why Send Loss Event Rate is on */
444 .dependent_feat = DCCPF_SEND_LEV_RATE,
445 .is_local = true,
446 .is_mandatory = true,
447 .val = 1
448 },
449 { /* NDP Count is needed as per RFC 4342, 6.1.1 */
450 .dependent_feat = DCCPF_SEND_NDP_COUNT,
451 .is_local = false,
452 .is_mandatory = true,
453 .val = 1
454 },
455 { 0, 0, 0, 0 },
456 },
457 { /*
458 * CCID3 at the TX side: we request that the HC-receiver
459 * will not send Ack Vectors (they will be ignored, so
460 * Mandatory is not set); we enable Send Loss Event Rate
461 * (Mandatory since the implementation does not support
462 * the Loss Intervals option of RFC 4342, 8.6).
463 * The last two options are for peer's information only.
464 */
465 {
466 .dependent_feat = DCCPF_SEND_ACK_VECTOR,
467 .is_local = false,
468 .is_mandatory = false,
469 .val = 0
470 },
471 {
472 .dependent_feat = DCCPF_SEND_LEV_RATE,
473 .is_local = false,
474 .is_mandatory = true,
475 .val = 1
476 },
477 { /* this CCID does not support Ack Ratio */
478 .dependent_feat = DCCPF_ACK_RATIO,
479 .is_local = true,
480 .is_mandatory = false,
481 .val = 0
482 },
483 { /* tell receiver we are sending NDP counts */
484 .dependent_feat = DCCPF_SEND_NDP_COUNT,
485 .is_local = true,
486 .is_mandatory = false,
487 .val = 1
488 },
489 { 0, 0, 0, 0 }
490 }
491 };
492 switch (ccid) {
493 case DCCPC_CCID2:
494 return ccid2_dependencies[is_local];
495 case DCCPC_CCID3:
496 return ccid3_dependencies[is_local];
497 default:
498 return NULL;
499 }
500}
501
502/**
503 * dccp_feat_propagate_ccid - Resolve dependencies of features on choice of CCID
504 * @fn: feature-negotiation list to update
505 * @id: CCID number to track
506 * @is_local: whether TX CCID (1) or RX CCID (0) is meant
507 * This function needs to be called after registering all other features.
508 */
509static int dccp_feat_propagate_ccid(struct list_head *fn, u8 id, bool is_local)
510{
511 const struct ccid_dependency *table = dccp_feat_ccid_deps(id, is_local);
512 int i, rc = (table == NULL);
513
514 for (i = 0; rc == 0 && table[i].dependent_feat != DCCPF_RESERVED; i++)
515 if (dccp_feat_type(table[i].dependent_feat) == FEAT_SP)
516 rc = __feat_register_sp(fn, table[i].dependent_feat,
517 table[i].is_local,
518 table[i].is_mandatory,
519 &table[i].val, 1);
520 else
521 rc = __feat_register_nn(fn, table[i].dependent_feat,
522 table[i].is_mandatory,
523 table[i].val);
524 return rc;
525}
526
527/**
528 * dccp_feat_finalise_settings - Finalise settings before starting negotiation
529 * @dp: client or listening socket (settings will be inherited)
530 * This is called after all registrations (socket initialisation, sysctls, and
531 * sockopt calls), and before sending the first packet containing Change options
532 * (ie. client-Request or server-Response), to ensure internal consistency.
533 */
534int dccp_feat_finalise_settings(struct dccp_sock *dp)
535{
536 struct list_head *fn = &dp->dccps_featneg;
537 struct dccp_feat_entry *entry;
538 int i = 2, ccids[2] = { -1, -1 };
539
540 /*
541 * Propagating CCIDs:
542 * 1) not useful to propagate CCID settings if this host advertises more
543 * than one CCID: the choice of CCID may still change - if this is
544 * the client, or if this is the server and the client sends
545 * singleton CCID values.
546 * 2) since is that propagate_ccid changes the list, we defer changing
547 * the sorted list until after the traversal.
548 */
549 list_for_each_entry(entry, fn, node)
550 if (entry->feat_num == DCCPF_CCID && entry->val.sp.len == 1)
551 ccids[entry->is_local] = entry->val.sp.vec[0];
552 while (i--)
553 if (ccids[i] > 0 && dccp_feat_propagate_ccid(fn, ccids[i], i))
554 return -1;
69 return 0; 555 return 0;
70} 556}
71 557
72EXPORT_SYMBOL_GPL(dccp_feat_change); 558/**
559 * dccp_feat_server_ccid_dependencies - Resolve CCID-dependent features
560 * It is the server which resolves the dependencies once the CCID has been
561 * fully negotiated. If no CCID has been negotiated, it uses the default CCID.
562 */
563int dccp_feat_server_ccid_dependencies(struct dccp_request_sock *dreq)
564{
565 struct list_head *fn = &dreq->dreq_featneg;
566 struct dccp_feat_entry *entry;
567 u8 is_local, ccid;
568
569 for (is_local = 0; is_local <= 1; is_local++) {
570 entry = dccp_feat_list_lookup(fn, DCCPF_CCID, is_local);
571
572 if (entry != NULL && !entry->empty_confirm)
573 ccid = entry->val.sp.vec[0];
574 else
575 ccid = dccp_feat_default_value(DCCPF_CCID);
576
577 if (dccp_feat_propagate_ccid(fn, ccid, is_local))
578 return -1;
579 }
580 return 0;
581}
73 582
74static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr) 583static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr)
75{ 584{
@@ -377,6 +886,9 @@ int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
377{ 886{
378 int rc; 887 int rc;
379 888
889 /* Ignore Change requests other than during connection setup */
890 if (sk->sk_state != DCCP_LISTEN && sk->sk_state != DCCP_REQUESTING)
891 return 0;
380 dccp_feat_debug(type, feature, *val); 892 dccp_feat_debug(type, feature, *val);
381 893
382 /* figure out if it's SP or NN feature */ 894 /* figure out if it's SP or NN feature */
@@ -426,6 +938,9 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
426 int found = 0; 938 int found = 0;
427 int all_confirmed = 1; 939 int all_confirmed = 1;
428 940
941 /* Ignore Confirm options other than during connection setup */
942 if (sk->sk_state != DCCP_LISTEN && sk->sk_state != DCCP_REQUESTING)
943 return 0;
429 dccp_feat_debug(type, feature, *val); 944 dccp_feat_debug(type, feature, *val);
430 945
431 /* locate our change request */ 946 /* locate our change request */
@@ -460,17 +975,6 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
460 all_confirmed = 0; 975 all_confirmed = 0;
461 } 976 }
462 977
463 /* fix re-transmit timer */
464 /* XXX gotta make sure that no option negotiation occurs during
465 * connection shutdown. Consider that the CLOSEREQ is sent and timer is
466 * on. if all options are confirmed it might kill timer which should
467 * remain alive until close is received.
468 */
469 if (all_confirmed) {
470 dccp_pr_debug("clear feat negotiation timer %p\n", sk);
471 inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS);
472 }
473
474 if (!found) 978 if (!found)
475 dccp_pr_debug("%s(%d, ...) never requested\n", 979 dccp_pr_debug("%s(%d, ...) never requested\n",
476 dccp_feat_typename(type), feature); 980 dccp_feat_typename(type), feature);
@@ -564,42 +1068,30 @@ out_clean:
564 1068
565EXPORT_SYMBOL_GPL(dccp_feat_clone); 1069EXPORT_SYMBOL_GPL(dccp_feat_clone);
566 1070
567static int __dccp_feat_init(struct dccp_minisock *dmsk, u8 type, u8 feat, 1071int dccp_feat_init(struct sock *sk)
568 u8 *val, u8 len)
569{
570 int rc = -ENOMEM;
571 u8 *copy = kmemdup(val, len, GFP_KERNEL);
572
573 if (copy != NULL) {
574 rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL);
575 if (rc)
576 kfree(copy);
577 }
578 return rc;
579}
580
581int dccp_feat_init(struct dccp_minisock *dmsk)
582{ 1072{
1073 struct dccp_sock *dp = dccp_sk(sk);
1074 struct dccp_minisock *dmsk = dccp_msk(sk);
583 int rc; 1075 int rc;
584 1076
585 INIT_LIST_HEAD(&dmsk->dccpms_pending); 1077 INIT_LIST_HEAD(&dmsk->dccpms_pending); /* XXX no longer used */
586 INIT_LIST_HEAD(&dmsk->dccpms_conf); 1078 INIT_LIST_HEAD(&dmsk->dccpms_conf); /* XXX no longer used */
587 1079
588 /* CCID L */ 1080 /* CCID L */
589 rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_L, DCCPF_CCID, 1081 rc = __feat_register_sp(&dp->dccps_featneg, DCCPF_CCID, 1, 0,
590 &dmsk->dccpms_tx_ccid, 1); 1082 &dmsk->dccpms_tx_ccid, 1);
591 if (rc) 1083 if (rc)
592 goto out; 1084 goto out;
593 1085
594 /* CCID R */ 1086 /* CCID R */
595 rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_R, DCCPF_CCID, 1087 rc = __feat_register_sp(&dp->dccps_featneg, DCCPF_CCID, 0, 0,
596 &dmsk->dccpms_rx_ccid, 1); 1088 &dmsk->dccpms_rx_ccid, 1);
597 if (rc) 1089 if (rc)
598 goto out; 1090 goto out;
599 1091
600 /* Ack ratio */ 1092 /* Ack ratio */
601 rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_L, DCCPF_ACK_RATIO, 1093 rc = __feat_register_nn(&dp->dccps_featneg, DCCPF_ACK_RATIO, 0,
602 &dmsk->dccpms_ack_ratio, 1); 1094 dp->dccps_l_ack_ratio);
603out: 1095out:
604 return rc; 1096 return rc;
605} 1097}
@@ -639,6 +1131,8 @@ const char *dccp_feat_name(const u8 feat)
639 if (feat > DCCPF_DATA_CHECKSUM && feat < DCCPF_MIN_CCID_SPECIFIC) 1131 if (feat > DCCPF_DATA_CHECKSUM && feat < DCCPF_MIN_CCID_SPECIFIC)
640 return feature_names[DCCPF_RESERVED]; 1132 return feature_names[DCCPF_RESERVED];
641 1133
1134 if (feat == DCCPF_SEND_LEV_RATE)
1135 return "Send Loss Event Rate";
642 if (feat >= DCCPF_MIN_CCID_SPECIFIC) 1136 if (feat >= DCCPF_MIN_CCID_SPECIFIC)
643 return "CCID-specific"; 1137 return "CCID-specific";
644 1138
diff --git a/net/dccp/feat.h b/net/dccp/feat.h
index e272222c7ace..4d172822df17 100644
--- a/net/dccp/feat.h
+++ b/net/dccp/feat.h
@@ -14,6 +14,90 @@
14#include <linux/types.h> 14#include <linux/types.h>
15#include "dccp.h" 15#include "dccp.h"
16 16
17/*
18 * Known limit values
19 */
20/* Ack Ratio takes 2-byte integer values (11.3) */
21#define DCCPF_ACK_RATIO_MAX 0xFFFF
22/* Wmin=32 and Wmax=2^46-1 from 7.5.2 */
23#define DCCPF_SEQ_WMIN 32
24#define DCCPF_SEQ_WMAX 0x3FFFFFFFFFFFull
25
26enum dccp_feat_type {
27 FEAT_AT_RX = 1, /* located at RX side of half-connection */
28 FEAT_AT_TX = 2, /* located at TX side of half-connection */
29 FEAT_SP = 4, /* server-priority reconciliation (6.3.1) */
30 FEAT_NN = 8, /* non-negotiable reconciliation (6.3.2) */
31 FEAT_UNKNOWN = 0xFF /* not understood or invalid feature */
32};
33
34enum dccp_feat_state {
35 FEAT_DEFAULT = 0, /* using default values from 6.4 */
36 FEAT_INITIALISING, /* feature is being initialised */
37 FEAT_CHANGING, /* Change sent but not confirmed yet */
38 FEAT_UNSTABLE, /* local modification in state CHANGING */
39 FEAT_STABLE /* both ends (think they) agree */
40};
41
42/**
43 * dccp_feat_val - Container for SP or NN feature values
44 * @nn: single NN value
45 * @sp.vec: single SP value plus optional preference list
46 * @sp.len: length of @sp.vec in bytes
47 */
48typedef union {
49 u64 nn;
50 struct {
51 u8 *vec;
52 u8 len;
53 } sp;
54} dccp_feat_val;
55
56/**
57 * struct feat_entry - Data structure to perform feature negotiation
58 * @val: feature's current value (SP features may have preference list)
59 * @state: feature's current state
60 * @feat_num: one of %dccp_feature_numbers
61 * @needs_mandatory: whether Mandatory options should be sent
62 * @needs_confirm: whether to send a Confirm instead of a Change
63 * @empty_confirm: whether to send an empty Confirm (depends on @needs_confirm)
64 * @is_local: feature location (1) or feature-remote (0)
65 * @node: list pointers, entries arranged in FIFO order
66 */
67struct dccp_feat_entry {
68 dccp_feat_val val;
69 enum dccp_feat_state state:8;
70 u8 feat_num;
71
72 bool needs_mandatory,
73 needs_confirm,
74 empty_confirm,
75 is_local;
76
77 struct list_head node;
78};
79
80static inline u8 dccp_feat_genopt(struct dccp_feat_entry *entry)
81{
82 if (entry->needs_confirm)
83 return entry->is_local ? DCCPO_CONFIRM_L : DCCPO_CONFIRM_R;
84 return entry->is_local ? DCCPO_CHANGE_L : DCCPO_CHANGE_R;
85}
86
87/**
88 * struct ccid_dependency - Track changes resulting from choosing a CCID
89 * @dependent_feat: one of %dccp_feature_numbers
90 * @is_local: local (1) or remote (0) @dependent_feat
91 * @is_mandatory: whether presence of @dependent_feat is mission-critical or not
92 * @val: corresponding default value for @dependent_feat (u8 is sufficient here)
93 */
94struct ccid_dependency {
95 u8 dependent_feat;
96 bool is_local:1,
97 is_mandatory:1;
98 u8 val;
99};
100
17#ifdef CONFIG_IP_DCCP_DEBUG 101#ifdef CONFIG_IP_DCCP_DEBUG
18extern const char *dccp_feat_typename(const u8 type); 102extern const char *dccp_feat_typename(const u8 type);
19extern const char *dccp_feat_name(const u8 feat); 103extern const char *dccp_feat_name(const u8 feat);
@@ -27,14 +111,16 @@ static inline void dccp_feat_debug(const u8 type, const u8 feat, const u8 val)
27#define dccp_feat_debug(type, feat, val) 111#define dccp_feat_debug(type, feat, val)
28#endif /* CONFIG_IP_DCCP_DEBUG */ 112#endif /* CONFIG_IP_DCCP_DEBUG */
29 113
30extern int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, 114extern int dccp_feat_register_sp(struct sock *sk, u8 feat, u8 is_local,
31 u8 *val, u8 len, gfp_t gfp); 115 u8 const *list, u8 len);
116extern int dccp_feat_register_nn(struct sock *sk, u8 feat, u64 val);
32extern int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, 117extern int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature,
33 u8 *val, u8 len); 118 u8 *val, u8 len);
34extern int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature, 119extern int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
35 u8 *val, u8 len); 120 u8 *val, u8 len);
36extern void dccp_feat_clean(struct dccp_minisock *dmsk); 121extern void dccp_feat_clean(struct dccp_minisock *dmsk);
37extern int dccp_feat_clone(struct sock *oldsk, struct sock *newsk); 122extern int dccp_feat_clone(struct sock *oldsk, struct sock *newsk);
38extern int dccp_feat_init(struct dccp_minisock *dmsk); 123extern int dccp_feat_clone_list(struct list_head const *, struct list_head *);
124extern int dccp_feat_init(struct sock *sk);
39 125
40#endif /* _DCCP_FEAT_H */ 126#endif /* _DCCP_FEAT_H */
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 779d0ed9ae94..3070015edc75 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -590,8 +590,6 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
590 if (inet_csk(sk)->icsk_af_ops->conn_request(sk, 590 if (inet_csk(sk)->icsk_af_ops->conn_request(sk,
591 skb) < 0) 591 skb) < 0)
592 return 1; 592 return 1;
593
594 /* FIXME: do congestion control initialization */
595 goto discard; 593 goto discard;
596 } 594 }
597 if (dh->dccph_type == DCCP_PKT_RESET) 595 if (dh->dccph_type == DCCP_PKT_RESET)
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index e3dfddab21cc..d1dd95289b89 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -545,6 +545,7 @@ out:
545 545
546static void dccp_v4_reqsk_destructor(struct request_sock *req) 546static void dccp_v4_reqsk_destructor(struct request_sock *req)
547{ 547{
548 dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);
548 kfree(inet_rsk(req)->opt); 549 kfree(inet_rsk(req)->opt);
549} 550}
550 551
@@ -595,7 +596,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
595 if (req == NULL) 596 if (req == NULL)
596 goto drop; 597 goto drop;
597 598
598 dccp_reqsk_init(req, skb); 599 if (dccp_reqsk_init(req, dccp_sk(sk), skb))
600 goto drop_and_free;
599 601
600 dreq = dccp_rsk(req); 602 dreq = dccp_rsk(req);
601 if (dccp_parse_options(sk, dreq, skb)) 603 if (dccp_parse_options(sk, dreq, skb))
@@ -792,12 +794,10 @@ static int dccp_v4_rcv(struct sk_buff *skb)
792 DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh); 794 DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);
793 DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type; 795 DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
794 796
795 dccp_pr_debug("%8.8s " 797 dccp_pr_debug("%8.8s src=%pI4@%-5d dst=%pI4@%-5d seq=%llu",
796 "src=%u.%u.%u.%u@%-5d "
797 "dst=%u.%u.%u.%u@%-5d seq=%llu",
798 dccp_packet_name(dh->dccph_type), 798 dccp_packet_name(dh->dccph_type),
799 NIPQUAD(iph->saddr), ntohs(dh->dccph_sport), 799 &iph->saddr, ntohs(dh->dccph_sport),
800 NIPQUAD(iph->daddr), ntohs(dh->dccph_dport), 800 &iph->daddr, ntohs(dh->dccph_dport),
801 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq); 801 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
802 802
803 if (dccp_packet_without_ack(skb)) { 803 if (dccp_packet_without_ack(skb)) {
@@ -938,6 +938,7 @@ static struct proto dccp_v4_prot = {
938 .orphan_count = &dccp_orphan_count, 938 .orphan_count = &dccp_orphan_count,
939 .max_header = MAX_DCCP_HEADER, 939 .max_header = MAX_DCCP_HEADER,
940 .obj_size = sizeof(struct dccp_sock), 940 .obj_size = sizeof(struct dccp_sock),
941 .slab_flags = SLAB_DESTROY_BY_RCU,
941 .rsk_prot = &dccp_request_sock_ops, 942 .rsk_prot = &dccp_request_sock_ops,
942 .twsk_prot = &dccp_timewait_sock_ops, 943 .twsk_prot = &dccp_timewait_sock_ops,
943 .h.hashinfo = &dccp_hashinfo, 944 .h.hashinfo = &dccp_hashinfo,
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index d4ce1224e008..f033e845bb07 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -304,6 +304,7 @@ done:
304 304
305static void dccp_v6_reqsk_destructor(struct request_sock *req) 305static void dccp_v6_reqsk_destructor(struct request_sock *req)
306{ 306{
307 dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);
307 if (inet6_rsk(req)->pktopts != NULL) 308 if (inet6_rsk(req)->pktopts != NULL)
308 kfree_skb(inet6_rsk(req)->pktopts); 309 kfree_skb(inet6_rsk(req)->pktopts);
309} 310}
@@ -426,7 +427,8 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
426 if (req == NULL) 427 if (req == NULL)
427 goto drop; 428 goto drop;
428 429
429 dccp_reqsk_init(req, skb); 430 if (dccp_reqsk_init(req, dccp_sk(sk), skb))
431 goto drop_and_free;
430 432
431 dreq = dccp_rsk(req); 433 dreq = dccp_rsk(req);
432 if (dccp_parse_options(sk, dreq, skb)) 434 if (dccp_parse_options(sk, dreq, skb))
@@ -1138,6 +1140,7 @@ static struct proto dccp_v6_prot = {
1138 .orphan_count = &dccp_orphan_count, 1140 .orphan_count = &dccp_orphan_count,
1139 .max_header = MAX_DCCP_HEADER, 1141 .max_header = MAX_DCCP_HEADER,
1140 .obj_size = sizeof(struct dccp6_sock), 1142 .obj_size = sizeof(struct dccp6_sock),
1143 .slab_flags = SLAB_DESTROY_BY_RCU,
1141 .rsk_prot = &dccp6_request_sock_ops, 1144 .rsk_prot = &dccp6_request_sock_ops,
1142 .twsk_prot = &dccp6_timewait_sock_ops, 1145 .twsk_prot = &dccp6_timewait_sock_ops,
1143 .h.hashinfo = &dccp_hashinfo, 1146 .h.hashinfo = &dccp_hashinfo,
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index e6bf99e3e41a..ed61bc58e41e 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -47,7 +47,6 @@ void dccp_minisock_init(struct dccp_minisock *dmsk)
47 dmsk->dccpms_sequence_window = sysctl_dccp_feat_sequence_window; 47 dmsk->dccpms_sequence_window = sysctl_dccp_feat_sequence_window;
48 dmsk->dccpms_rx_ccid = sysctl_dccp_feat_rx_ccid; 48 dmsk->dccpms_rx_ccid = sysctl_dccp_feat_rx_ccid;
49 dmsk->dccpms_tx_ccid = sysctl_dccp_feat_tx_ccid; 49 dmsk->dccpms_tx_ccid = sysctl_dccp_feat_tx_ccid;
50 dmsk->dccpms_ack_ratio = sysctl_dccp_feat_ack_ratio;
51 dmsk->dccpms_send_ack_vector = sysctl_dccp_feat_send_ack_vector; 50 dmsk->dccpms_send_ack_vector = sysctl_dccp_feat_send_ack_vector;
52 dmsk->dccpms_send_ndp_count = sysctl_dccp_feat_send_ndp_count; 51 dmsk->dccpms_send_ndp_count = sysctl_dccp_feat_send_ndp_count;
53} 52}
@@ -125,6 +124,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
125 newdp->dccps_timestamp_time = dreq->dreq_timestamp_time; 124 newdp->dccps_timestamp_time = dreq->dreq_timestamp_time;
126 newicsk->icsk_rto = DCCP_TIMEOUT_INIT; 125 newicsk->icsk_rto = DCCP_TIMEOUT_INIT;
127 126
127 INIT_LIST_HEAD(&newdp->dccps_featneg);
128 if (dccp_feat_clone(sk, newsk)) 128 if (dccp_feat_clone(sk, newsk))
129 goto out_free; 129 goto out_free;
130 130
@@ -304,7 +304,8 @@ void dccp_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
304 304
305EXPORT_SYMBOL_GPL(dccp_reqsk_send_ack); 305EXPORT_SYMBOL_GPL(dccp_reqsk_send_ack);
306 306
307void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb) 307int dccp_reqsk_init(struct request_sock *req,
308 struct dccp_sock const *dp, struct sk_buff const *skb)
308{ 309{
309 struct dccp_request_sock *dreq = dccp_rsk(req); 310 struct dccp_request_sock *dreq = dccp_rsk(req);
310 311
@@ -313,6 +314,9 @@ void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb)
313 inet_rsk(req)->acked = 0; 314 inet_rsk(req)->acked = 0;
314 req->rcv_wnd = sysctl_dccp_feat_sequence_window; 315 req->rcv_wnd = sysctl_dccp_feat_sequence_window;
315 dreq->dreq_timestamp_echo = 0; 316 dreq->dreq_timestamp_echo = 0;
317
318 /* inherit feature negotiation options from listening socket */
319 return dccp_feat_clone_list(&dp->dccps_featneg, &dreq->dreq_featneg);
316} 320}
317 321
318EXPORT_SYMBOL_GPL(dccp_reqsk_init); 322EXPORT_SYMBOL_GPL(dccp_reqsk_init);
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 0809b63cb055..515ad45013ad 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -26,7 +26,6 @@
26int sysctl_dccp_feat_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW; 26int sysctl_dccp_feat_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW;
27int sysctl_dccp_feat_rx_ccid = DCCPF_INITIAL_CCID; 27int sysctl_dccp_feat_rx_ccid = DCCPF_INITIAL_CCID;
28int sysctl_dccp_feat_tx_ccid = DCCPF_INITIAL_CCID; 28int sysctl_dccp_feat_tx_ccid = DCCPF_INITIAL_CCID;
29int sysctl_dccp_feat_ack_ratio = DCCPF_INITIAL_ACK_RATIO;
30int sysctl_dccp_feat_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR; 29int sysctl_dccp_feat_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR;
31int sysctl_dccp_feat_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT; 30int sysctl_dccp_feat_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT;
32 31
@@ -489,7 +488,6 @@ static int dccp_insert_feat_opt(struct sk_buff *skb, u8 type, u8 feat,
489 488
490static int dccp_insert_options_feat(struct sock *sk, struct sk_buff *skb) 489static int dccp_insert_options_feat(struct sock *sk, struct sk_buff *skb)
491{ 490{
492 struct dccp_sock *dp = dccp_sk(sk);
493 struct dccp_minisock *dmsk = dccp_msk(sk); 491 struct dccp_minisock *dmsk = dccp_msk(sk);
494 struct dccp_opt_pend *opt, *next; 492 struct dccp_opt_pend *opt, *next;
495 int change = 0; 493 int change = 0;
@@ -530,23 +528,6 @@ static int dccp_insert_options_feat(struct sock *sk, struct sk_buff *skb)
530 } 528 }
531 } 529 }
532 530
533 /* Retransmit timer.
534 * If this is the master listening sock, we don't set a timer on it. It
535 * should be fine because if the dude doesn't receive our RESPONSE
536 * [which will contain the CHANGE] he will send another REQUEST which
537 * will "retrnasmit" the change.
538 */
539 if (change && dp->dccps_role != DCCP_ROLE_LISTEN) {
540 dccp_pr_debug("reset feat negotiation timer %p\n", sk);
541
542 /* XXX don't reset the timer on re-transmissions. I.e. reset it
543 * only when sending new stuff i guess. Currently the timer
544 * never backs off because on re-transmission it just resets it!
545 */
546 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
547 inet_csk(sk)->icsk_rto, DCCP_RTO_MAX);
548 }
549
550 return 0; 531 return 0;
551} 532}
552 533
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 809d803d5006..fea30cdc0bee 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -339,10 +339,12 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
339 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE; 339 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE;
340 DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss; 340 DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss;
341 341
342 if (dccp_insert_options_rsk(dreq, skb)) { 342 /* Resolve feature dependencies resulting from choice of CCID */
343 kfree_skb(skb); 343 if (dccp_feat_server_ccid_dependencies(dreq))
344 return NULL; 344 goto response_failed;
345 } 345
346 if (dccp_insert_options_rsk(dreq, skb))
347 goto response_failed;
346 348
347 /* Build and checksum header */ 349 /* Build and checksum header */
348 dh = dccp_zeroed_hdr(skb, dccp_header_size); 350 dh = dccp_zeroed_hdr(skb, dccp_header_size);
@@ -363,6 +365,9 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
363 inet_rsk(req)->acked = 1; 365 inet_rsk(req)->acked = 1;
364 DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 366 DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
365 return skb; 367 return skb;
368response_failed:
369 kfree_skb(skb);
370 return NULL;
366} 371}
367 372
368EXPORT_SYMBOL_GPL(dccp_make_response); 373EXPORT_SYMBOL_GPL(dccp_make_response);
@@ -469,6 +474,10 @@ int dccp_connect(struct sock *sk)
469 struct sk_buff *skb; 474 struct sk_buff *skb;
470 struct inet_connection_sock *icsk = inet_csk(sk); 475 struct inet_connection_sock *icsk = inet_csk(sk);
471 476
477 /* do not connect if feature negotiation setup fails */
478 if (dccp_feat_finalise_settings(dccp_sk(sk)))
479 return -EPROTO;
480
472 dccp_connect_init(sk); 481 dccp_connect_init(sk);
473 482
474 skb = alloc_skb(sk->sk_prot->max_header, sk->sk_allocation); 483 skb = alloc_skb(sk->sk_prot->max_header, sk->sk_allocation);
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 81368a7f5379..49ba8d5ec4b5 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -86,18 +86,18 @@ static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk,
86 if (port == 0 || ntohs(inet->dport) == port || 86 if (port == 0 || ntohs(inet->dport) == port ||
87 ntohs(inet->sport) == port) { 87 ntohs(inet->sport) == port) {
88 if (hctx) 88 if (hctx)
89 printl("%d.%d.%d.%d:%u %d.%d.%d.%d:%u %d %d %d %d %u " 89 printl("%pI4:%u %pI4:%u %d %d %d %d %u "
90 "%llu %llu %d\n", 90 "%llu %llu %d\n",
91 NIPQUAD(inet->saddr), ntohs(inet->sport), 91 &inet->saddr, ntohs(inet->sport),
92 NIPQUAD(inet->daddr), ntohs(inet->dport), size, 92 &inet->daddr, ntohs(inet->dport), size,
93 hctx->ccid3hctx_s, hctx->ccid3hctx_rtt, 93 hctx->ccid3hctx_s, hctx->ccid3hctx_rtt,
94 hctx->ccid3hctx_p, hctx->ccid3hctx_x_calc, 94 hctx->ccid3hctx_p, hctx->ccid3hctx_x_calc,
95 hctx->ccid3hctx_x_recv >> 6, 95 hctx->ccid3hctx_x_recv >> 6,
96 hctx->ccid3hctx_x >> 6, hctx->ccid3hctx_t_ipi); 96 hctx->ccid3hctx_x >> 6, hctx->ccid3hctx_t_ipi);
97 else 97 else
98 printl("%d.%d.%d.%d:%u %d.%d.%d.%d:%u %d\n", 98 printl("%pI4:%u %pI4:%u %d\n",
99 NIPQUAD(inet->saddr), ntohs(inet->sport), 99 &inet->saddr, ntohs(inet->sport),
100 NIPQUAD(inet->daddr), ntohs(inet->dport), size); 100 &inet->daddr, ntohs(inet->dport), size);
101 } 101 }
102 102
103 jprobe_return(); 103 jprobe_return();
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index d0bd34819761..8b63394ec24c 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -44,12 +44,7 @@ atomic_t dccp_orphan_count = ATOMIC_INIT(0);
44 44
45EXPORT_SYMBOL_GPL(dccp_orphan_count); 45EXPORT_SYMBOL_GPL(dccp_orphan_count);
46 46
47struct inet_hashinfo __cacheline_aligned dccp_hashinfo = { 47struct inet_hashinfo dccp_hashinfo;
48 .lhash_lock = RW_LOCK_UNLOCKED,
49 .lhash_users = ATOMIC_INIT(0),
50 .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(dccp_hashinfo.lhash_wait),
51};
52
53EXPORT_SYMBOL_GPL(dccp_hashinfo); 48EXPORT_SYMBOL_GPL(dccp_hashinfo);
54 49
55/* the maximum queue length for tx in packets. 0 is no limit */ 50/* the maximum queue length for tx in packets. 0 is no limit */
@@ -193,6 +188,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
193 188
194 dccp_init_xmit_timers(sk); 189 dccp_init_xmit_timers(sk);
195 190
191 INIT_LIST_HEAD(&dp->dccps_featneg);
196 /* 192 /*
197 * FIXME: We're hardcoding the CCID, and doing this at this point makes 193 * FIXME: We're hardcoding the CCID, and doing this at this point makes
198 * the listening (master) sock get CCID control blocks, which is not 194 * the listening (master) sock get CCID control blocks, which is not
@@ -201,7 +197,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
201 * setsockopt(CCIDs-I-want/accept). -acme 197 * setsockopt(CCIDs-I-want/accept). -acme
202 */ 198 */
203 if (likely(ctl_sock_initialized)) { 199 if (likely(ctl_sock_initialized)) {
204 int rc = dccp_feat_init(dmsk); 200 int rc = dccp_feat_init(sk);
205 201
206 if (rc) 202 if (rc)
207 return rc; 203 return rc;
@@ -267,7 +263,7 @@ void dccp_destroy_sock(struct sock *sk)
267 dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; 263 dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
268 264
269 /* clean up feature negotiation state */ 265 /* clean up feature negotiation state */
270 dccp_feat_clean(dmsk); 266 dccp_feat_list_purge(&dp->dccps_featneg);
271} 267}
272 268
273EXPORT_SYMBOL_GPL(dccp_destroy_sock); 269EXPORT_SYMBOL_GPL(dccp_destroy_sock);
@@ -277,6 +273,9 @@ static inline int dccp_listen_start(struct sock *sk, int backlog)
277 struct dccp_sock *dp = dccp_sk(sk); 273 struct dccp_sock *dp = dccp_sk(sk);
278 274
279 dp->dccps_role = DCCP_ROLE_LISTEN; 275 dp->dccps_role = DCCP_ROLE_LISTEN;
276 /* do not start to listen if feature negotiation setup fails */
277 if (dccp_feat_finalise_settings(dp))
278 return -EPROTO;
280 return inet_csk_listen_start(sk, backlog); 279 return inet_csk_listen_start(sk, backlog);
281} 280}
282 281
@@ -466,42 +465,40 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service,
466 return 0; 465 return 0;
467} 466}
468 467
469/* byte 1 is feature. the rest is the preference list */ 468static int dccp_setsockopt_cscov(struct sock *sk, int cscov, bool rx)
470static int dccp_setsockopt_change(struct sock *sk, int type,
471 struct dccp_so_feat __user *optval)
472{ 469{
473 struct dccp_so_feat opt; 470 u8 *list, len;
474 u8 *val; 471 int i, rc;
475 int rc;
476 472
477 if (copy_from_user(&opt, optval, sizeof(opt))) 473 if (cscov < 0 || cscov > 15)
478 return -EFAULT; 474 return -EINVAL;
479 /* 475 /*
480 * rfc4340: 6.1. Change Options 476 * Populate a list of permissible values, in the range cscov...15. This
477 * is necessary since feature negotiation of single values only works if
478 * both sides incidentally choose the same value. Since the list starts
479 * lowest-value first, negotiation will pick the smallest shared value.
481 */ 480 */
482 if (opt.dccpsf_len < 1) 481 if (cscov == 0)
483 return -EINVAL; 482 return 0;
483 len = 16 - cscov;
484 484
485 val = kmalloc(opt.dccpsf_len, GFP_KERNEL); 485 list = kmalloc(len, GFP_KERNEL);
486 if (!val) 486 if (list == NULL)
487 return -ENOMEM; 487 return -ENOBUFS;
488 488
489 if (copy_from_user(val, opt.dccpsf_val, opt.dccpsf_len)) { 489 for (i = 0; i < len; i++)
490 rc = -EFAULT; 490 list[i] = cscov++;
491 goto out_free_val;
492 }
493 491
494 rc = dccp_feat_change(dccp_msk(sk), type, opt.dccpsf_feat, 492 rc = dccp_feat_register_sp(sk, DCCPF_MIN_CSUM_COVER, rx, list, len);
495 val, opt.dccpsf_len, GFP_KERNEL);
496 if (rc)
497 goto out_free_val;
498 493
499out: 494 if (rc == 0) {
495 if (rx)
496 dccp_sk(sk)->dccps_pcrlen = cscov;
497 else
498 dccp_sk(sk)->dccps_pcslen = cscov;
499 }
500 kfree(list);
500 return rc; 501 return rc;
501
502out_free_val:
503 kfree(val);
504 goto out;
505} 502}
506 503
507static int do_dccp_setsockopt(struct sock *sk, int level, int optname, 504static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
@@ -510,7 +507,17 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
510 struct dccp_sock *dp = dccp_sk(sk); 507 struct dccp_sock *dp = dccp_sk(sk);
511 int val, err = 0; 508 int val, err = 0;
512 509
513 if (optlen < sizeof(int)) 510 switch (optname) {
511 case DCCP_SOCKOPT_PACKET_SIZE:
512 DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
513 return 0;
514 case DCCP_SOCKOPT_CHANGE_L:
515 case DCCP_SOCKOPT_CHANGE_R:
516 DCCP_WARN("sockopt(CHANGE_L/R) is deprecated: fix your app\n");
517 return 0;
518 }
519
520 if (optlen < (int)sizeof(int))
514 return -EINVAL; 521 return -EINVAL;
515 522
516 if (get_user(val, (int __user *)optval)) 523 if (get_user(val, (int __user *)optval))
@@ -521,53 +528,24 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
521 528
522 lock_sock(sk); 529 lock_sock(sk);
523 switch (optname) { 530 switch (optname) {
524 case DCCP_SOCKOPT_PACKET_SIZE:
525 DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
526 err = 0;
527 break;
528 case DCCP_SOCKOPT_CHANGE_L:
529 if (optlen != sizeof(struct dccp_so_feat))
530 err = -EINVAL;
531 else
532 err = dccp_setsockopt_change(sk, DCCPO_CHANGE_L,
533 (struct dccp_so_feat __user *)
534 optval);
535 break;
536 case DCCP_SOCKOPT_CHANGE_R:
537 if (optlen != sizeof(struct dccp_so_feat))
538 err = -EINVAL;
539 else
540 err = dccp_setsockopt_change(sk, DCCPO_CHANGE_R,
541 (struct dccp_so_feat __user *)
542 optval);
543 break;
544 case DCCP_SOCKOPT_SERVER_TIMEWAIT: 531 case DCCP_SOCKOPT_SERVER_TIMEWAIT:
545 if (dp->dccps_role != DCCP_ROLE_SERVER) 532 if (dp->dccps_role != DCCP_ROLE_SERVER)
546 err = -EOPNOTSUPP; 533 err = -EOPNOTSUPP;
547 else 534 else
548 dp->dccps_server_timewait = (val != 0); 535 dp->dccps_server_timewait = (val != 0);
549 break; 536 break;
550 case DCCP_SOCKOPT_SEND_CSCOV: /* sender side, RFC 4340, sec. 9.2 */ 537 case DCCP_SOCKOPT_SEND_CSCOV:
551 if (val < 0 || val > 15) 538 err = dccp_setsockopt_cscov(sk, val, false);
552 err = -EINVAL;
553 else
554 dp->dccps_pcslen = val;
555 break; 539 break;
556 case DCCP_SOCKOPT_RECV_CSCOV: /* receiver side, RFC 4340 sec. 9.2.1 */ 540 case DCCP_SOCKOPT_RECV_CSCOV:
557 if (val < 0 || val > 15) 541 err = dccp_setsockopt_cscov(sk, val, true);
558 err = -EINVAL;
559 else {
560 dp->dccps_pcrlen = val;
561 /* FIXME: add feature negotiation,
562 * ChangeL(MinimumChecksumCoverage, val) */
563 }
564 break; 542 break;
565 default: 543 default:
566 err = -ENOPROTOOPT; 544 err = -ENOPROTOOPT;
567 break; 545 break;
568 } 546 }
569
570 release_sock(sk); 547 release_sock(sk);
548
571 return err; 549 return err;
572} 550}
573 551
@@ -648,6 +626,8 @@ static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
648 case DCCP_SOCKOPT_GET_CUR_MPS: 626 case DCCP_SOCKOPT_GET_CUR_MPS:
649 val = dp->dccps_mss_cache; 627 val = dp->dccps_mss_cache;
650 break; 628 break;
629 case DCCP_SOCKOPT_AVAILABLE_CCIDS:
630 return ccid_getsockopt_builtin_ccids(sk, len, optval, optlen);
651 case DCCP_SOCKOPT_SERVER_TIMEWAIT: 631 case DCCP_SOCKOPT_SERVER_TIMEWAIT:
652 val = dp->dccps_server_timewait; 632 val = dp->dccps_server_timewait;
653 break; 633 break;
@@ -1045,6 +1025,7 @@ static int __init dccp_init(void)
1045 BUILD_BUG_ON(sizeof(struct dccp_skb_cb) > 1025 BUILD_BUG_ON(sizeof(struct dccp_skb_cb) >
1046 FIELD_SIZEOF(struct sk_buff, cb)); 1026 FIELD_SIZEOF(struct sk_buff, cb));
1047 1027
1028 inet_hashinfo_init(&dccp_hashinfo);
1048 dccp_hashinfo.bind_bucket_cachep = 1029 dccp_hashinfo.bind_bucket_cachep =
1049 kmem_cache_create("dccp_bind_bucket", 1030 kmem_cache_create("dccp_bind_bucket",
1050 sizeof(struct inet_bind_bucket), 0, 1031 sizeof(struct inet_bind_bucket), 0,
@@ -1084,8 +1065,8 @@ static int __init dccp_init(void)
1084 } 1065 }
1085 1066
1086 for (i = 0; i < dccp_hashinfo.ehash_size; i++) { 1067 for (i = 0; i < dccp_hashinfo.ehash_size; i++) {
1087 INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].chain); 1068 INIT_HLIST_NULLS_HEAD(&dccp_hashinfo.ehash[i].chain, i);
1088 INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].twchain); 1069 INIT_HLIST_NULLS_HEAD(&dccp_hashinfo.ehash[i].twchain, i);
1089 } 1070 }
1090 1071
1091 if (inet_ehash_locks_alloc(&dccp_hashinfo)) 1072 if (inet_ehash_locks_alloc(&dccp_hashinfo))
diff --git a/net/dccp/sysctl.c b/net/dccp/sysctl.c
index 21295993fdb8..f6e54f433e29 100644
--- a/net/dccp/sysctl.c
+++ b/net/dccp/sysctl.c
@@ -41,13 +41,6 @@ static struct ctl_table dccp_default_table[] = {
41 .proc_handler = proc_dointvec, 41 .proc_handler = proc_dointvec,
42 }, 42 },
43 { 43 {
44 .procname = "ack_ratio",
45 .data = &sysctl_dccp_feat_ack_ratio,
46 .maxlen = sizeof(sysctl_dccp_feat_ack_ratio),
47 .mode = 0644,
48 .proc_handler = proc_dointvec,
49 },
50 {
51 .procname = "send_ackvec", 44 .procname = "send_ackvec",
52 .data = &sysctl_dccp_feat_send_ack_vector, 45 .data = &sysctl_dccp_feat_send_ack_vector,
53 .maxlen = sizeof(sysctl_dccp_feat_send_ack_vector), 46 .maxlen = sizeof(sysctl_dccp_feat_send_ack_vector),
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 54b3c7e9e016..162d1e683c39 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -87,17 +87,6 @@ static void dccp_retransmit_timer(struct sock *sk)
87{ 87{
88 struct inet_connection_sock *icsk = inet_csk(sk); 88 struct inet_connection_sock *icsk = inet_csk(sk);
89 89
90 /* retransmit timer is used for feature negotiation throughout
91 * connection. In this case, no packet is re-transmitted, but rather an
92 * ack is generated and pending changes are placed into its options.
93 */
94 if (sk->sk_send_head == NULL) {
95 dccp_pr_debug("feat negotiation retransmit timeout %p\n", sk);
96 if (sk->sk_state == DCCP_OPEN)
97 dccp_send_ack(sk);
98 goto backoff;
99 }
100
101 /* 90 /*
102 * More than than 4MSL (8 minutes) has passed, a RESET(aborted) was 91 * More than than 4MSL (8 minutes) has passed, a RESET(aborted) was
103 * sent, no need to retransmit, this sock is dead. 92 * sent, no need to retransmit, this sock is dead.
@@ -126,7 +115,6 @@ static void dccp_retransmit_timer(struct sock *sk)
126 return; 115 return;
127 } 116 }
128 117
129backoff:
130 icsk->icsk_backoff++; 118 icsk->icsk_backoff++;
131 119
132 icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX); 120 icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX);
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 821bd1cdec04..768df000523b 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -131,7 +131,6 @@ static struct dst_ops dn_dst_ops = {
131 .negative_advice = dn_dst_negative_advice, 131 .negative_advice = dn_dst_negative_advice,
132 .link_failure = dn_dst_link_failure, 132 .link_failure = dn_dst_link_failure,
133 .update_pmtu = dn_dst_update_pmtu, 133 .update_pmtu = dn_dst_update_pmtu,
134 .entry_size = sizeof(struct dn_route),
135 .entries = ATOMIC_INIT(0), 134 .entries = ATOMIC_INIT(0),
136}; 135};
137 136
diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
index 36400b266896..2f360a1e5e49 100644
--- a/net/decnet/sysctl_net_decnet.c
+++ b/net/decnet/sysctl_net_decnet.c
@@ -354,8 +354,8 @@ static ctl_table dn_table[] = {
354 .data = node_name, 354 .data = node_name,
355 .maxlen = 7, 355 .maxlen = 7,
356 .mode = 0644, 356 .mode = 0644,
357 .proc_handler = &proc_dostring, 357 .proc_handler = proc_dostring,
358 .strategy = &sysctl_string, 358 .strategy = sysctl_string,
359 }, 359 },
360 { 360 {
361 .ctl_name = NET_DECNET_DEFAULT_DEVICE, 361 .ctl_name = NET_DECNET_DEFAULT_DEVICE,
@@ -371,8 +371,8 @@ static ctl_table dn_table[] = {
371 .data = &decnet_time_wait, 371 .data = &decnet_time_wait,
372 .maxlen = sizeof(int), 372 .maxlen = sizeof(int),
373 .mode = 0644, 373 .mode = 0644,
374 .proc_handler = &proc_dointvec_minmax, 374 .proc_handler = proc_dointvec_minmax,
375 .strategy = &sysctl_intvec, 375 .strategy = sysctl_intvec,
376 .extra1 = &min_decnet_time_wait, 376 .extra1 = &min_decnet_time_wait,
377 .extra2 = &max_decnet_time_wait 377 .extra2 = &max_decnet_time_wait
378 }, 378 },
@@ -382,8 +382,8 @@ static ctl_table dn_table[] = {
382 .data = &decnet_dn_count, 382 .data = &decnet_dn_count,
383 .maxlen = sizeof(int), 383 .maxlen = sizeof(int),
384 .mode = 0644, 384 .mode = 0644,
385 .proc_handler = &proc_dointvec_minmax, 385 .proc_handler = proc_dointvec_minmax,
386 .strategy = &sysctl_intvec, 386 .strategy = sysctl_intvec,
387 .extra1 = &min_state_count, 387 .extra1 = &min_state_count,
388 .extra2 = &max_state_count 388 .extra2 = &max_state_count
389 }, 389 },
@@ -393,8 +393,8 @@ static ctl_table dn_table[] = {
393 .data = &decnet_di_count, 393 .data = &decnet_di_count,
394 .maxlen = sizeof(int), 394 .maxlen = sizeof(int),
395 .mode = 0644, 395 .mode = 0644,
396 .proc_handler = &proc_dointvec_minmax, 396 .proc_handler = proc_dointvec_minmax,
397 .strategy = &sysctl_intvec, 397 .strategy = sysctl_intvec,
398 .extra1 = &min_state_count, 398 .extra1 = &min_state_count,
399 .extra2 = &max_state_count 399 .extra2 = &max_state_count
400 }, 400 },
@@ -404,8 +404,8 @@ static ctl_table dn_table[] = {
404 .data = &decnet_dr_count, 404 .data = &decnet_dr_count,
405 .maxlen = sizeof(int), 405 .maxlen = sizeof(int),
406 .mode = 0644, 406 .mode = 0644,
407 .proc_handler = &proc_dointvec_minmax, 407 .proc_handler = proc_dointvec_minmax,
408 .strategy = &sysctl_intvec, 408 .strategy = sysctl_intvec,
409 .extra1 = &min_state_count, 409 .extra1 = &min_state_count,
410 .extra2 = &max_state_count 410 .extra2 = &max_state_count
411 }, 411 },
@@ -415,8 +415,8 @@ static ctl_table dn_table[] = {
415 .data = &decnet_dst_gc_interval, 415 .data = &decnet_dst_gc_interval,
416 .maxlen = sizeof(int), 416 .maxlen = sizeof(int),
417 .mode = 0644, 417 .mode = 0644,
418 .proc_handler = &proc_dointvec_minmax, 418 .proc_handler = proc_dointvec_minmax,
419 .strategy = &sysctl_intvec, 419 .strategy = sysctl_intvec,
420 .extra1 = &min_decnet_dst_gc_interval, 420 .extra1 = &min_decnet_dst_gc_interval,
421 .extra2 = &max_decnet_dst_gc_interval 421 .extra2 = &max_decnet_dst_gc_interval
422 }, 422 },
@@ -426,8 +426,8 @@ static ctl_table dn_table[] = {
426 .data = &decnet_no_fc_max_cwnd, 426 .data = &decnet_no_fc_max_cwnd,
427 .maxlen = sizeof(int), 427 .maxlen = sizeof(int),
428 .mode = 0644, 428 .mode = 0644,
429 .proc_handler = &proc_dointvec_minmax, 429 .proc_handler = proc_dointvec_minmax,
430 .strategy = &sysctl_intvec, 430 .strategy = sysctl_intvec,
431 .extra1 = &min_decnet_no_fc_max_cwnd, 431 .extra1 = &min_decnet_no_fc_max_cwnd,
432 .extra2 = &max_decnet_no_fc_max_cwnd 432 .extra2 = &max_decnet_no_fc_max_cwnd
433 }, 433 },
@@ -437,8 +437,8 @@ static ctl_table dn_table[] = {
437 .data = &sysctl_decnet_mem, 437 .data = &sysctl_decnet_mem,
438 .maxlen = sizeof(sysctl_decnet_mem), 438 .maxlen = sizeof(sysctl_decnet_mem),
439 .mode = 0644, 439 .mode = 0644,
440 .proc_handler = &proc_dointvec, 440 .proc_handler = proc_dointvec,
441 .strategy = &sysctl_intvec, 441 .strategy = sysctl_intvec,
442 }, 442 },
443 { 443 {
444 .ctl_name = NET_DECNET_RMEM, 444 .ctl_name = NET_DECNET_RMEM,
@@ -446,8 +446,8 @@ static ctl_table dn_table[] = {
446 .data = &sysctl_decnet_rmem, 446 .data = &sysctl_decnet_rmem,
447 .maxlen = sizeof(sysctl_decnet_rmem), 447 .maxlen = sizeof(sysctl_decnet_rmem),
448 .mode = 0644, 448 .mode = 0644,
449 .proc_handler = &proc_dointvec, 449 .proc_handler = proc_dointvec,
450 .strategy = &sysctl_intvec, 450 .strategy = sysctl_intvec,
451 }, 451 },
452 { 452 {
453 .ctl_name = NET_DECNET_WMEM, 453 .ctl_name = NET_DECNET_WMEM,
@@ -455,8 +455,8 @@ static ctl_table dn_table[] = {
455 .data = &sysctl_decnet_wmem, 455 .data = &sysctl_decnet_wmem,
456 .maxlen = sizeof(sysctl_decnet_wmem), 456 .maxlen = sizeof(sysctl_decnet_wmem),
457 .mode = 0644, 457 .mode = 0644,
458 .proc_handler = &proc_dointvec, 458 .proc_handler = proc_dointvec,
459 .strategy = &sysctl_intvec, 459 .strategy = sysctl_intvec,
460 }, 460 },
461 { 461 {
462 .ctl_name = NET_DECNET_DEBUG_LEVEL, 462 .ctl_name = NET_DECNET_DEBUG_LEVEL,
@@ -464,8 +464,8 @@ static ctl_table dn_table[] = {
464 .data = &decnet_debug_level, 464 .data = &decnet_debug_level,
465 .maxlen = sizeof(int), 465 .maxlen = sizeof(int),
466 .mode = 0644, 466 .mode = 0644,
467 .proc_handler = &proc_dointvec, 467 .proc_handler = proc_dointvec,
468 .strategy = &sysctl_intvec, 468 .strategy = sysctl_intvec,
469 }, 469 },
470 {0} 470 {0}
471}; 471};
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 1af5a79309e9..a3a410d20da0 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -352,7 +352,7 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
352 netif_carrier_off(slave_dev); 352 netif_carrier_off(slave_dev);
353 353
354 if (p->phy != NULL) { 354 if (p->phy != NULL) {
355 phy_attach(slave_dev, p->phy->dev.bus_id, 355 phy_attach(slave_dev, dev_name(&p->phy->dev),
356 0, PHY_INTERFACE_MODE_GMII); 356 0, PHY_INTERFACE_MODE_GMII);
357 357
358 p->phy->autoneg = AUTONEG_ENABLE; 358 p->phy->autoneg = AUTONEG_ENABLE;
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c
index 31866543332e..f99a019b939e 100644
--- a/net/dsa/tag_dsa.c
+++ b/net/dsa/tag_dsa.c
@@ -162,7 +162,6 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev,
162 skb->pkt_type = PACKET_HOST; 162 skb->pkt_type = PACKET_HOST;
163 skb->protocol = eth_type_trans(skb, skb->dev); 163 skb->protocol = eth_type_trans(skb, skb->dev);
164 164
165 skb->dev->last_rx = jiffies;
166 skb->dev->stats.rx_packets++; 165 skb->dev->stats.rx_packets++;
167 skb->dev->stats.rx_bytes += skb->len; 166 skb->dev->stats.rx_bytes += skb->len;
168 167
diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c
index 9f4ce55eae59..328ec957f786 100644
--- a/net/dsa/tag_edsa.c
+++ b/net/dsa/tag_edsa.c
@@ -181,7 +181,6 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev,
181 skb->pkt_type = PACKET_HOST; 181 skb->pkt_type = PACKET_HOST;
182 skb->protocol = eth_type_trans(skb, skb->dev); 182 skb->protocol = eth_type_trans(skb, skb->dev);
183 183
184 skb->dev->last_rx = jiffies;
185 skb->dev->stats.rx_packets++; 184 skb->dev->stats.rx_packets++;
186 skb->dev->stats.rx_bytes += skb->len; 185 skb->dev->stats.rx_bytes += skb->len;
187 186
diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c
index efd26697e716..b59132878ad1 100644
--- a/net/dsa/tag_trailer.c
+++ b/net/dsa/tag_trailer.c
@@ -98,7 +98,6 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev,
98 skb->pkt_type = PACKET_HOST; 98 skb->pkt_type = PACKET_HOST;
99 skb->protocol = eth_type_trans(skb, skb->dev); 99 skb->protocol = eth_type_trans(skb, skb->dev);
100 100
101 skb->dev->last_rx = jiffies;
102 skb->dev->stats.rx_packets++; 101 skb->dev->stats.rx_packets++;
103 skb->dev->stats.rx_bytes += skb->len; 102 skb->dev->stats.rx_bytes += skb->len;
104 103
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index b9d85af2dd31..a87a171d9914 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -282,7 +282,7 @@ EXPORT_SYMBOL(eth_header_cache_update);
282 * This doesn't change hardware matching, so needs to be overridden 282 * This doesn't change hardware matching, so needs to be overridden
283 * for most real devices. 283 * for most real devices.
284 */ 284 */
285static int eth_mac_addr(struct net_device *dev, void *p) 285int eth_mac_addr(struct net_device *dev, void *p)
286{ 286{
287 struct sockaddr *addr = p; 287 struct sockaddr *addr = p;
288 288
@@ -293,6 +293,7 @@ static int eth_mac_addr(struct net_device *dev, void *p)
293 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 293 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
294 return 0; 294 return 0;
295} 295}
296EXPORT_SYMBOL(eth_mac_addr);
296 297
297/** 298/**
298 * eth_change_mtu - set new MTU size 299 * eth_change_mtu - set new MTU size
@@ -302,21 +303,23 @@ static int eth_mac_addr(struct net_device *dev, void *p)
302 * Allow changing MTU size. Needs to be overridden for devices 303 * Allow changing MTU size. Needs to be overridden for devices
303 * supporting jumbo frames. 304 * supporting jumbo frames.
304 */ 305 */
305static int eth_change_mtu(struct net_device *dev, int new_mtu) 306int eth_change_mtu(struct net_device *dev, int new_mtu)
306{ 307{
307 if (new_mtu < 68 || new_mtu > ETH_DATA_LEN) 308 if (new_mtu < 68 || new_mtu > ETH_DATA_LEN)
308 return -EINVAL; 309 return -EINVAL;
309 dev->mtu = new_mtu; 310 dev->mtu = new_mtu;
310 return 0; 311 return 0;
311} 312}
313EXPORT_SYMBOL(eth_change_mtu);
312 314
313static int eth_validate_addr(struct net_device *dev) 315int eth_validate_addr(struct net_device *dev)
314{ 316{
315 if (!is_valid_ether_addr(dev->dev_addr)) 317 if (!is_valid_ether_addr(dev->dev_addr))
316 return -EADDRNOTAVAIL; 318 return -EADDRNOTAVAIL;
317 319
318 return 0; 320 return 0;
319} 321}
322EXPORT_SYMBOL(eth_validate_addr);
320 323
321const struct header_ops eth_header_ops ____cacheline_aligned = { 324const struct header_ops eth_header_ops ____cacheline_aligned = {
322 .create = eth_header, 325 .create = eth_header,
@@ -334,11 +337,11 @@ const struct header_ops eth_header_ops ____cacheline_aligned = {
334void ether_setup(struct net_device *dev) 337void ether_setup(struct net_device *dev)
335{ 338{
336 dev->header_ops = &eth_header_ops; 339 dev->header_ops = &eth_header_ops;
337 340#ifdef CONFIG_COMPAT_NET_DEV_OPS
338 dev->change_mtu = eth_change_mtu; 341 dev->change_mtu = eth_change_mtu;
339 dev->set_mac_address = eth_mac_addr; 342 dev->set_mac_address = eth_mac_addr;
340 dev->validate_addr = eth_validate_addr; 343 dev->validate_addr = eth_validate_addr;
341 344#endif
342 dev->type = ARPHRD_ETHER; 345 dev->type = ARPHRD_ETHER;
343 dev->hard_header_len = ETH_HLEN; 346 dev->hard_header_len = ETH_HLEN;
344 dev->mtu = ETH_DATA_LEN; 347 dev->mtu = ETH_DATA_LEN;
diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig
index 94ed7d3cd9da..d2282bb2e4f1 100644
--- a/net/ieee80211/Kconfig
+++ b/net/ieee80211/Kconfig
@@ -1,12 +1,24 @@
1config IEEE80211 1config IEEE80211
2 tristate "Generic IEEE 802.11 Networking Stack (DEPRECATED)" 2 tristate
3 select WIRELESS_EXT
4 select CRYPTO
5 select CRYPTO_ARC4
6 select CRYPTO_ECB
7 select CRYPTO_AES
8 select CRYPTO_MICHAEL_MIC
9 select CRYPTO_ECB
10 select CRC32
11 select IEEE80211_CRYPT_WEP
12 select IEEE80211_CRYPT_TKIP
13 select IEEE80211_CRYPT_CCMP
14 select LIB80211
3 ---help--- 15 ---help---
4 This option enables the hardware independent IEEE 802.11 16 This option enables the hardware independent IEEE 802.11
5 networking stack. This component is deprecated in favor of the 17 networking stack. This component is deprecated in favor of the
6 mac80211 component. 18 mac80211 component.
7 19
8config IEEE80211_DEBUG 20config IEEE80211_DEBUG
9 bool "Enable full debugging output" 21 bool "Full debugging output for the old IEEE80211 stack"
10 depends on IEEE80211 22 depends on IEEE80211
11 ---help--- 23 ---help---
12 This option will enable debug tracing output for the 24 This option will enable debug tracing output for the
@@ -29,45 +41,10 @@ config IEEE80211_DEBUG
29 subsystem, you most likely want to say N here. 41 subsystem, you most likely want to say N here.
30 42
31config IEEE80211_CRYPT_WEP 43config IEEE80211_CRYPT_WEP
32 tristate "IEEE 802.11 WEP encryption (802.1x)" 44 tristate
33 depends on IEEE80211
34 select CRYPTO
35 select CRYPTO_ARC4
36 select CRYPTO_ECB
37 select CRC32
38 ---help---
39 Include software based cipher suites in support of IEEE
40 802.11's WEP. This is needed for WEP as well as 802.1x.
41
42 This can be compiled as a module and it will be called
43 "ieee80211_crypt_wep".
44 45
45config IEEE80211_CRYPT_CCMP 46config IEEE80211_CRYPT_CCMP
46 tristate "IEEE 802.11i CCMP support" 47 tristate
47 depends on IEEE80211
48 select CRYPTO
49 select CRYPTO_AES
50 ---help---
51 Include software based cipher suites in support of IEEE 802.11i
52 (aka TGi, WPA, WPA2, WPA-PSK, etc.) for use with CCMP enabled
53 networks.
54
55 This can be compiled as a module and it will be called
56 "ieee80211_crypt_ccmp".
57 48
58config IEEE80211_CRYPT_TKIP 49config IEEE80211_CRYPT_TKIP
59 tristate "IEEE 802.11i TKIP encryption" 50 tristate
60 depends on IEEE80211
61 select WIRELESS_EXT
62 select CRYPTO
63 select CRYPTO_MICHAEL_MIC
64 select CRYPTO_ECB
65 select CRC32
66 ---help---
67 Include software based cipher suites in support of IEEE 802.11i
68 (aka TGi, WPA, WPA2, WPA-PSK, etc.) for use with TKIP enabled
69 networks.
70
71 This can be compiled as a module and it will be called
72 "ieee80211_crypt_tkip".
73
diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c
index 208bf35b5546..bea04af0b482 100644
--- a/net/ieee80211/ieee80211_crypt_ccmp.c
+++ b/net/ieee80211/ieee80211_crypt_ccmp.c
@@ -296,7 +296,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
296 int i, blocks, last, len; 296 int i, blocks, last, len;
297 size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN; 297 size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN;
298 u8 *mic = skb->data + skb->len - CCMP_MIC_LEN; 298 u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
299 DECLARE_MAC_BUF(mac);
300 299
301 if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) { 300 if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
302 key->dot11RSNAStatsCCMPFormatErrors++; 301 key->dot11RSNAStatsCCMPFormatErrors++;
@@ -309,7 +308,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
309 if (!(keyidx & (1 << 5))) { 308 if (!(keyidx & (1 << 5))) {
310 if (net_ratelimit()) { 309 if (net_ratelimit()) {
311 printk(KERN_DEBUG "CCMP: received packet without ExtIV" 310 printk(KERN_DEBUG "CCMP: received packet without ExtIV"
312 " flag from %s\n", print_mac(mac, hdr->addr2)); 311 " flag from %pM\n", hdr->addr2);
313 } 312 }
314 key->dot11RSNAStatsCCMPFormatErrors++; 313 key->dot11RSNAStatsCCMPFormatErrors++;
315 return -2; 314 return -2;
@@ -322,9 +321,9 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
322 } 321 }
323 if (!key->key_set) { 322 if (!key->key_set) {
324 if (net_ratelimit()) { 323 if (net_ratelimit()) {
325 printk(KERN_DEBUG "CCMP: received packet from %s" 324 printk(KERN_DEBUG "CCMP: received packet from %pM"
326 " with keyid=%d that does not have a configured" 325 " with keyid=%d that does not have a configured"
327 " key\n", print_mac(mac, hdr->addr2), keyidx); 326 " key\n", hdr->addr2, keyidx);
328 } 327 }
329 return -3; 328 return -3;
330 } 329 }
@@ -339,10 +338,10 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
339 338
340 if (ccmp_replay_check(pn, key->rx_pn)) { 339 if (ccmp_replay_check(pn, key->rx_pn)) {
341 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) { 340 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) {
342 IEEE80211_DEBUG_DROP("CCMP: replay detected: STA=%s " 341 IEEE80211_DEBUG_DROP("CCMP: replay detected: STA=%pM "
343 "previous PN %02x%02x%02x%02x%02x%02x " 342 "previous PN %02x%02x%02x%02x%02x%02x "
344 "received PN %02x%02x%02x%02x%02x%02x\n", 343 "received PN %02x%02x%02x%02x%02x%02x\n",
345 print_mac(mac, hdr->addr2), 344 hdr->addr2,
346 key->rx_pn[0], key->rx_pn[1], key->rx_pn[2], 345 key->rx_pn[0], key->rx_pn[1], key->rx_pn[2],
347 key->rx_pn[3], key->rx_pn[4], key->rx_pn[5], 346 key->rx_pn[3], key->rx_pn[4], key->rx_pn[5],
348 pn[0], pn[1], pn[2], pn[3], pn[4], pn[5]); 347 pn[0], pn[1], pn[2], pn[3], pn[4], pn[5]);
@@ -373,7 +372,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
373 if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { 372 if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
374 if (net_ratelimit()) { 373 if (net_ratelimit()) {
375 printk(KERN_DEBUG "CCMP: decrypt failed: STA=" 374 printk(KERN_DEBUG "CCMP: decrypt failed: STA="
376 "%s\n", print_mac(mac, hdr->addr2)); 375 "%pM\n", hdr->addr2);
377 } 376 }
378 key->dot11RSNAStatsCCMPDecryptErrors++; 377 key->dot11RSNAStatsCCMPDecryptErrors++;
379 return -5; 378 return -5;
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index bba0152e2d71..d12da1da6328 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -359,15 +359,13 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
359 u8 rc4key[16], *pos, *icv; 359 u8 rc4key[16], *pos, *icv;
360 u32 crc; 360 u32 crc;
361 struct scatterlist sg; 361 struct scatterlist sg;
362 DECLARE_MAC_BUF(mac);
363 362
364 if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) { 363 if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) {
365 if (net_ratelimit()) { 364 if (net_ratelimit()) {
366 struct ieee80211_hdr_4addr *hdr = 365 struct ieee80211_hdr_4addr *hdr =
367 (struct ieee80211_hdr_4addr *)skb->data; 366 (struct ieee80211_hdr_4addr *)skb->data;
368 printk(KERN_DEBUG ": TKIP countermeasures: dropped " 367 printk(KERN_DEBUG ": TKIP countermeasures: dropped "
369 "TX packet to %s\n", 368 "TX packet to %pM\n", hdr->addr1);
370 print_mac(mac, hdr->addr1));
371 } 369 }
372 return -1; 370 return -1;
373 } 371 }
@@ -420,15 +418,13 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
420 u32 crc; 418 u32 crc;
421 struct scatterlist sg; 419 struct scatterlist sg;
422 int plen; 420 int plen;
423 DECLARE_MAC_BUF(mac);
424 421
425 hdr = (struct ieee80211_hdr_4addr *)skb->data; 422 hdr = (struct ieee80211_hdr_4addr *)skb->data;
426 423
427 if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) { 424 if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) {
428 if (net_ratelimit()) { 425 if (net_ratelimit()) {
429 printk(KERN_DEBUG ": TKIP countermeasures: dropped " 426 printk(KERN_DEBUG ": TKIP countermeasures: dropped "
430 "received packet from %s\n", 427 "received packet from %pM\n", hdr->addr2);
431 print_mac(mac, hdr->addr2));
432 } 428 }
433 return -1; 429 return -1;
434 } 430 }
@@ -441,7 +437,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
441 if (!(keyidx & (1 << 5))) { 437 if (!(keyidx & (1 << 5))) {
442 if (net_ratelimit()) { 438 if (net_ratelimit()) {
443 printk(KERN_DEBUG "TKIP: received packet without ExtIV" 439 printk(KERN_DEBUG "TKIP: received packet without ExtIV"
444 " flag from %s\n", print_mac(mac, hdr->addr2)); 440 " flag from %pM\n", hdr->addr2);
445 } 441 }
446 return -2; 442 return -2;
447 } 443 }
@@ -453,9 +449,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
453 } 449 }
454 if (!tkey->key_set) { 450 if (!tkey->key_set) {
455 if (net_ratelimit()) { 451 if (net_ratelimit()) {
456 printk(KERN_DEBUG "TKIP: received packet from %s" 452 printk(KERN_DEBUG "TKIP: received packet from %pM"
457 " with keyid=%d that does not have a configured" 453 " with keyid=%d that does not have a configured"
458 " key\n", print_mac(mac, hdr->addr2), keyidx); 454 " key\n", hdr->addr2, keyidx);
459 } 455 }
460 return -3; 456 return -3;
461 } 457 }
@@ -465,9 +461,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
465 461
466 if (tkip_replay_check(iv32, iv16, tkey->rx_iv32, tkey->rx_iv16)) { 462 if (tkip_replay_check(iv32, iv16, tkey->rx_iv32, tkey->rx_iv16)) {
467 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) { 463 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) {
468 IEEE80211_DEBUG_DROP("TKIP: replay detected: STA=%s" 464 IEEE80211_DEBUG_DROP("TKIP: replay detected: STA=%pM"
469 " previous TSC %08x%04x received TSC " 465 " previous TSC %08x%04x received TSC "
470 "%08x%04x\n", print_mac(mac, hdr->addr2), 466 "%08x%04x\n", hdr->addr2,
471 tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); 467 tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
472 } 468 }
473 tkey->dot11RSNAStatsTKIPReplays++; 469 tkey->dot11RSNAStatsTKIPReplays++;
@@ -487,8 +483,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
487 if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { 483 if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
488 if (net_ratelimit()) { 484 if (net_ratelimit()) {
489 printk(KERN_DEBUG ": TKIP: failed to decrypt " 485 printk(KERN_DEBUG ": TKIP: failed to decrypt "
490 "received packet from %s\n", 486 "received packet from %pM\n",
491 print_mac(mac, hdr->addr2)); 487 hdr->addr2);
492 } 488 }
493 return -7; 489 return -7;
494 } 490 }
@@ -506,7 +502,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
506 } 502 }
507 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) { 503 if (ieee80211_ratelimit_debug(IEEE80211_DL_DROP)) {
508 IEEE80211_DEBUG_DROP("TKIP: ICV error detected: STA=" 504 IEEE80211_DEBUG_DROP("TKIP: ICV error detected: STA="
509 "%s\n", print_mac(mac, hdr->addr2)); 505 "%pM\n", hdr->addr2);
510 } 506 }
511 tkey->dot11RSNAStatsTKIPICVErrors++; 507 tkey->dot11RSNAStatsTKIPICVErrors++;
512 return -5; 508 return -5;
@@ -633,7 +629,6 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
633{ 629{
634 struct ieee80211_tkip_data *tkey = priv; 630 struct ieee80211_tkip_data *tkey = priv;
635 u8 mic[8]; 631 u8 mic[8];
636 DECLARE_MAC_BUF(mac);
637 632
638 if (!tkey->key_set) 633 if (!tkey->key_set)
639 return -1; 634 return -1;
@@ -646,8 +641,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
646 struct ieee80211_hdr_4addr *hdr; 641 struct ieee80211_hdr_4addr *hdr;
647 hdr = (struct ieee80211_hdr_4addr *)skb->data; 642 hdr = (struct ieee80211_hdr_4addr *)skb->data;
648 printk(KERN_DEBUG "%s: Michael MIC verification failed for " 643 printk(KERN_DEBUG "%s: Michael MIC verification failed for "
649 "MSDU from %s keyidx=%d\n", 644 "MSDU from %pM keyidx=%d\n",
650 skb->dev ? skb->dev->name : "N/A", print_mac(mac, hdr->addr2), 645 skb->dev ? skb->dev->name : "N/A", hdr->addr2,
651 keyidx); 646 keyidx);
652 if (skb->dev) 647 if (skb->dev)
653 ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); 648 ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
index 949772a5a7dc..d34d4e79b6f7 100644
--- a/net/ieee80211/ieee80211_module.c
+++ b/net/ieee80211/ieee80211_module.c
@@ -308,31 +308,5 @@ MODULE_PARM_DESC(debug, "debug output mask");
308module_exit(ieee80211_exit); 308module_exit(ieee80211_exit);
309module_init(ieee80211_init); 309module_init(ieee80211_init);
310 310
311const char *escape_essid(const char *essid, u8 essid_len)
312{
313 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
314 const char *s = essid;
315 char *d = escaped;
316
317 if (ieee80211_is_empty_essid(essid, essid_len)) {
318 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
319 return escaped;
320 }
321
322 essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
323 while (essid_len--) {
324 if (*s == '\0') {
325 *d++ = '\\';
326 *d++ = '0';
327 s++;
328 } else {
329 *d++ = *s++;
330 }
331 }
332 *d = '\0';
333 return escaped;
334}
335
336EXPORT_SYMBOL(alloc_ieee80211); 311EXPORT_SYMBOL(alloc_ieee80211);
337EXPORT_SYMBOL(free_ieee80211); 312EXPORT_SYMBOL(free_ieee80211);
338EXPORT_SYMBOL(escape_essid);
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index 69dbc342a464..3dd58b594f6a 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -32,6 +32,7 @@
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <linux/ctype.h> 33#include <linux/ctype.h>
34 34
35#include <net/lib80211.h>
35#include <net/ieee80211.h> 36#include <net/ieee80211.h>
36 37
37static void ieee80211_monitor_rx(struct ieee80211_device *ieee, 38static void ieee80211_monitor_rx(struct ieee80211_device *ieee,
@@ -39,7 +40,7 @@ static void ieee80211_monitor_rx(struct ieee80211_device *ieee,
39 struct ieee80211_rx_stats *rx_stats) 40 struct ieee80211_rx_stats *rx_stats)
40{ 41{
41 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 42 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
42 u16 fc = le16_to_cpu(hdr->frame_ctl); 43 u16 fc = le16_to_cpu(hdr->frame_control);
43 44
44 skb->dev = ieee->dev; 45 skb->dev = ieee->dev;
45 skb_reset_mac_header(skb); 46 skb_reset_mac_header(skb);
@@ -282,12 +283,8 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
282 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); 283 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
283 atomic_dec(&crypt->refcnt); 284 atomic_dec(&crypt->refcnt);
284 if (res < 0) { 285 if (res < 0) {
285 IEEE80211_DEBUG_DROP("decryption failed (SA=" MAC_FMT 286 IEEE80211_DEBUG_DROP("decryption failed (SA=%pM) res=%d\n",
286 ") res=%d\n", 287 hdr->addr2, res);
287 hdr->addr2[0], hdr->addr2[1],
288 hdr->addr2[2], hdr->addr2[3],
289 hdr->addr2[4], hdr->addr2[5],
290 res);
291 if (res == -2) 288 if (res == -2)
292 IEEE80211_DEBUG_DROP("Decryption failed ICV " 289 IEEE80211_DEBUG_DROP("Decryption failed ICV "
293 "mismatch (key %d)\n", 290 "mismatch (key %d)\n",
@@ -319,11 +316,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee,
319 atomic_dec(&crypt->refcnt); 316 atomic_dec(&crypt->refcnt);
320 if (res < 0) { 317 if (res < 0) {
321 printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" 318 printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
322 " (SA=" MAC_FMT " keyidx=%d)\n", 319 " (SA=%pM keyidx=%d)\n", ieee->dev->name, hdr->addr2,
323 ieee->dev->name,
324 hdr->addr2[0], hdr->addr2[1],
325 hdr->addr2[2], hdr->addr2[3],
326 hdr->addr2[4], hdr->addr2[5],
327 keyidx); 320 keyidx);
328 return -1; 321 return -1;
329 } 322 }
@@ -358,7 +351,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
358 struct ieee80211_crypt_data *crypt = NULL; 351 struct ieee80211_crypt_data *crypt = NULL;
359 int keyidx = 0; 352 int keyidx = 0;
360 int can_be_decrypted = 0; 353 int can_be_decrypted = 0;
361 DECLARE_MAC_BUF(mac);
362 354
363 hdr = (struct ieee80211_hdr_4addr *)skb->data; 355 hdr = (struct ieee80211_hdr_4addr *)skb->data;
364 stats = &ieee->stats; 356 stats = &ieee->stats;
@@ -468,10 +460,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
468 * frames silently instead of filling system log with 460 * frames silently instead of filling system log with
469 * these reports. */ 461 * these reports. */
470 IEEE80211_DEBUG_DROP("Decryption failed (not set)" 462 IEEE80211_DEBUG_DROP("Decryption failed (not set)"
471 " (SA=" MAC_FMT ")\n", 463 " (SA=%pM)\n", hdr->addr2);
472 hdr->addr2[0], hdr->addr2[1],
473 hdr->addr2[2], hdr->addr2[3],
474 hdr->addr2[4], hdr->addr2[5]);
475 ieee->ieee_stats.rx_discards_undecryptable++; 464 ieee->ieee_stats.rx_discards_undecryptable++;
476 goto rx_dropped; 465 goto rx_dropped;
477 } 466 }
@@ -482,10 +471,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
482 fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt && 471 fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt &&
483 (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0) { 472 (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0) {
484 printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth " 473 printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
485 "from " MAC_FMT "\n", dev->name, 474 "from %pM\n", dev->name, hdr->addr2);
486 hdr->addr2[0], hdr->addr2[1],
487 hdr->addr2[2], hdr->addr2[3],
488 hdr->addr2[4], hdr->addr2[5]);
489 /* TODO: could inform hostapd about this so that it 475 /* TODO: could inform hostapd about this so that it
490 * could send auth failure report */ 476 * could send auth failure report */
491 goto rx_dropped; 477 goto rx_dropped;
@@ -547,8 +533,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
547 } 533 }
548#endif 534#endif
549 535
550 dev->last_rx = jiffies;
551
552#ifdef NOT_YET 536#ifdef NOT_YET
553 if ((ieee->iw_mode == IW_MODE_MASTER || 537 if ((ieee->iw_mode == IW_MODE_MASTER ||
554 ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { 538 ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) {
@@ -663,11 +647,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
663 * configured */ 647 * configured */
664 } else { 648 } else {
665 IEEE80211_DEBUG_DROP("encryption configured, but RX " 649 IEEE80211_DEBUG_DROP("encryption configured, but RX "
666 "frame not encrypted (SA=" 650 "frame not encrypted (SA=%pM)\n",
667 MAC_FMT ")\n", 651 hdr->addr2);
668 hdr->addr2[0], hdr->addr2[1],
669 hdr->addr2[2], hdr->addr2[3],
670 hdr->addr2[4], hdr->addr2[5]);
671 goto rx_dropped; 652 goto rx_dropped;
672 } 653 }
673 } 654 }
@@ -675,11 +656,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
675 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep && 656 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep &&
676 !ieee80211_is_eapol_frame(ieee, skb)) { 657 !ieee80211_is_eapol_frame(ieee, skb)) {
677 IEEE80211_DEBUG_DROP("dropped unencrypted RX data " 658 IEEE80211_DEBUG_DROP("dropped unencrypted RX data "
678 "frame from " MAC_FMT 659 "frame from %pM (drop_unencrypted=1)\n",
679 " (drop_unencrypted=1)\n", 660 hdr->addr2);
680 hdr->addr2[0], hdr->addr2[1],
681 hdr->addr2[2], hdr->addr2[3],
682 hdr->addr2[4], hdr->addr2[5]);
683 goto rx_dropped; 661 goto rx_dropped;
684 } 662 }
685 663
@@ -1144,6 +1122,7 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1144 *info_element, u16 length, 1122 *info_element, u16 length,
1145 struct ieee80211_network *network) 1123 struct ieee80211_network *network)
1146{ 1124{
1125 DECLARE_SSID_BUF(ssid);
1147 u8 i; 1126 u8 i;
1148#ifdef CONFIG_IEEE80211_DEBUG 1127#ifdef CONFIG_IEEE80211_DEBUG
1149 char rates_str[64]; 1128 char rates_str[64];
@@ -1166,12 +1145,6 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1166 1145
1167 switch (info_element->id) { 1146 switch (info_element->id) {
1168 case MFIE_TYPE_SSID: 1147 case MFIE_TYPE_SSID:
1169 if (ieee80211_is_empty_essid(info_element->data,
1170 info_element->len)) {
1171 network->flags |= NETWORK_EMPTY_ESSID;
1172 break;
1173 }
1174
1175 network->ssid_len = min(info_element->len, 1148 network->ssid_len = min(info_element->len,
1176 (u8) IW_ESSID_MAX_SIZE); 1149 (u8) IW_ESSID_MAX_SIZE);
1177 memcpy(network->ssid, info_element->data, 1150 memcpy(network->ssid, info_element->data,
@@ -1181,7 +1154,9 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1181 IW_ESSID_MAX_SIZE - network->ssid_len); 1154 IW_ESSID_MAX_SIZE - network->ssid_len);
1182 1155
1183 IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n", 1156 IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
1184 network->ssid, network->ssid_len); 1157 print_ssid(ssid, network->ssid,
1158 network->ssid_len),
1159 network->ssid_len);
1185 break; 1160 break;
1186 1161
1187 case MFIE_TYPE_RATES: 1162 case MFIE_TYPE_RATES:
@@ -1411,9 +1386,6 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
1411 network->mode |= IEEE_B; 1386 network->mode |= IEEE_B;
1412 } 1387 }
1413 1388
1414 if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
1415 network->flags |= NETWORK_EMPTY_ESSID;
1416
1417 memcpy(&network->stats, stats, sizeof(network->stats)); 1389 memcpy(&network->stats, stats, sizeof(network->stats));
1418 1390
1419 if (ieee->handle_assoc_response != NULL) 1391 if (ieee->handle_assoc_response != NULL)
@@ -1429,7 +1401,7 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
1429 struct ieee80211_network *network, 1401 struct ieee80211_network *network,
1430 struct ieee80211_rx_stats *stats) 1402 struct ieee80211_rx_stats *stats)
1431{ 1403{
1432 DECLARE_MAC_BUF(mac); 1404 DECLARE_SSID_BUF(ssid);
1433 1405
1434 network->qos_data.active = 0; 1406 network->qos_data.active = 0;
1435 network->qos_data.supported = 0; 1407 network->qos_data.supported = 0;
@@ -1477,17 +1449,14 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
1477 } 1449 }
1478 1450
1479 if (network->mode == 0) { 1451 if (network->mode == 0) {
1480 IEEE80211_DEBUG_SCAN("Filtered out '%s (%s)' " 1452 IEEE80211_DEBUG_SCAN("Filtered out '%s (%pM)' "
1481 "network.\n", 1453 "network.\n",
1482 escape_essid(network->ssid, 1454 print_ssid(ssid, network->ssid,
1483 network->ssid_len), 1455 network->ssid_len),
1484 print_mac(mac, network->bssid)); 1456 network->bssid);
1485 return 1; 1457 return 1;
1486 } 1458 }
1487 1459
1488 if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
1489 network->flags |= NETWORK_EMPTY_ESSID;
1490
1491 memcpy(&network->stats, stats, sizeof(network->stats)); 1460 memcpy(&network->stats, stats, sizeof(network->stats));
1492 1461
1493 return 0; 1462 return 0;
@@ -1510,7 +1479,6 @@ static void update_network(struct ieee80211_network *dst,
1510{ 1479{
1511 int qos_active; 1480 int qos_active;
1512 u8 old_param; 1481 u8 old_param;
1513 DECLARE_MAC_BUF(mac);
1514 1482
1515 ieee80211_network_reset(dst); 1483 ieee80211_network_reset(dst);
1516 dst->ibss_dfs = src->ibss_dfs; 1484 dst->ibss_dfs = src->ibss_dfs;
@@ -1524,8 +1492,8 @@ static void update_network(struct ieee80211_network *dst,
1524 memcpy(&dst->stats, &src->stats, 1492 memcpy(&dst->stats, &src->stats,
1525 sizeof(struct ieee80211_rx_stats)); 1493 sizeof(struct ieee80211_rx_stats));
1526 else 1494 else
1527 IEEE80211_DEBUG_SCAN("Network %s info received " 1495 IEEE80211_DEBUG_SCAN("Network %pM info received "
1528 "off channel (%d vs. %d)\n", print_mac(mac, src->bssid), 1496 "off channel (%d vs. %d)\n", src->bssid,
1529 dst->channel, src->stats.received_channel); 1497 dst->channel, src->stats.received_channel);
1530 1498
1531 dst->capability = src->capability; 1499 dst->capability = src->capability;
@@ -1597,12 +1565,12 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1597 struct ieee80211_info_element *info_element = beacon->info_element; 1565 struct ieee80211_info_element *info_element = beacon->info_element;
1598#endif 1566#endif
1599 unsigned long flags; 1567 unsigned long flags;
1600 DECLARE_MAC_BUF(mac); 1568 DECLARE_SSID_BUF(ssid);
1601 1569
1602 IEEE80211_DEBUG_SCAN("'%s' (%s" 1570 IEEE80211_DEBUG_SCAN("'%s' (%pM"
1603 "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", 1571 "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
1604 escape_essid(info_element->data, info_element->len), 1572 print_ssid(ssid, info_element->data, info_element->len),
1605 print_mac(mac, beacon->header.addr3), 1573 beacon->header.addr3,
1606 (beacon->capability & cpu_to_le16(1 << 0xf)) ? '1' : '0', 1574 (beacon->capability & cpu_to_le16(1 << 0xf)) ? '1' : '0',
1607 (beacon->capability & cpu_to_le16(1 << 0xe)) ? '1' : '0', 1575 (beacon->capability & cpu_to_le16(1 << 0xe)) ? '1' : '0',
1608 (beacon->capability & cpu_to_le16(1 << 0xd)) ? '1' : '0', 1576 (beacon->capability & cpu_to_le16(1 << 0xd)) ? '1' : '0',
@@ -1621,10 +1589,10 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1621 (beacon->capability & cpu_to_le16(1 << 0x0)) ? '1' : '0'); 1589 (beacon->capability & cpu_to_le16(1 << 0x0)) ? '1' : '0');
1622 1590
1623 if (ieee80211_network_init(ieee, beacon, &network, stats)) { 1591 if (ieee80211_network_init(ieee, beacon, &network, stats)) {
1624 IEEE80211_DEBUG_SCAN("Dropped '%s' (%s) via %s.\n", 1592 IEEE80211_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n",
1625 escape_essid(info_element->data, 1593 print_ssid(ssid, info_element->data,
1626 info_element->len), 1594 info_element->len),
1627 print_mac(mac, beacon->header.addr3), 1595 beacon->header.addr3,
1628 is_beacon(beacon->header.frame_ctl) ? 1596 is_beacon(beacon->header.frame_ctl) ?
1629 "BEACON" : "PROBE RESPONSE"); 1597 "BEACON" : "PROBE RESPONSE");
1630 return; 1598 return;
@@ -1658,11 +1626,11 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1658 /* If there are no more slots, expire the oldest */ 1626 /* If there are no more slots, expire the oldest */
1659 list_del(&oldest->list); 1627 list_del(&oldest->list);
1660 target = oldest; 1628 target = oldest;
1661 IEEE80211_DEBUG_SCAN("Expired '%s' (%s) from " 1629 IEEE80211_DEBUG_SCAN("Expired '%s' (%pM) from "
1662 "network list.\n", 1630 "network list.\n",
1663 escape_essid(target->ssid, 1631 print_ssid(ssid, target->ssid,
1664 target->ssid_len), 1632 target->ssid_len),
1665 print_mac(mac, target->bssid)); 1633 target->bssid);
1666 ieee80211_network_reset(target); 1634 ieee80211_network_reset(target);
1667 } else { 1635 } else {
1668 /* Otherwise just pull from the free list */ 1636 /* Otherwise just pull from the free list */
@@ -1672,10 +1640,10 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1672 } 1640 }
1673 1641
1674#ifdef CONFIG_IEEE80211_DEBUG 1642#ifdef CONFIG_IEEE80211_DEBUG
1675 IEEE80211_DEBUG_SCAN("Adding '%s' (%s) via %s.\n", 1643 IEEE80211_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n",
1676 escape_essid(network.ssid, 1644 print_ssid(ssid, network.ssid,
1677 network.ssid_len), 1645 network.ssid_len),
1678 print_mac(mac, network.bssid), 1646 network.bssid,
1679 is_beacon(beacon->header.frame_ctl) ? 1647 is_beacon(beacon->header.frame_ctl) ?
1680 "BEACON" : "PROBE RESPONSE"); 1648 "BEACON" : "PROBE RESPONSE");
1681#endif 1649#endif
@@ -1683,10 +1651,10 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1683 network.ibss_dfs = NULL; 1651 network.ibss_dfs = NULL;
1684 list_add_tail(&target->list, &ieee->network_list); 1652 list_add_tail(&target->list, &ieee->network_list);
1685 } else { 1653 } else {
1686 IEEE80211_DEBUG_SCAN("Updating '%s' (%s) via %s.\n", 1654 IEEE80211_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n",
1687 escape_essid(target->ssid, 1655 print_ssid(ssid, target->ssid,
1688 target->ssid_len), 1656 target->ssid_len),
1689 print_mac(mac, target->bssid), 1657 target->bssid,
1690 is_beacon(beacon->header.frame_ctl) ? 1658 is_beacon(beacon->header.frame_ctl) ?
1691 "BEACON" : "PROBE RESPONSE"); 1659 "BEACON" : "PROBE RESPONSE");
1692 update_network(target, &network); 1660 update_network(target, &network);
diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c
index 973832dd7faf..7cc4e5ee3660 100644
--- a/net/ieee80211/ieee80211_wx.c
+++ b/net/ieee80211/ieee80211_wx.c
@@ -34,6 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/jiffies.h> 35#include <linux/jiffies.h>
36 36
37#include <net/lib80211.h>
37#include <net/ieee80211.h> 38#include <net/ieee80211.h>
38#include <linux/wireless.h> 39#include <linux/wireless.h>
39 40
@@ -65,15 +66,9 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
65 /* Add the ESSID */ 66 /* Add the ESSID */
66 iwe.cmd = SIOCGIWESSID; 67 iwe.cmd = SIOCGIWESSID;
67 iwe.u.data.flags = 1; 68 iwe.u.data.flags = 1;
68 if (network->flags & NETWORK_EMPTY_ESSID) { 69 iwe.u.data.length = min(network->ssid_len, (u8) 32);
69 iwe.u.data.length = sizeof("<hidden>"); 70 start = iwe_stream_add_point(info, start, stop,
70 start = iwe_stream_add_point(info, start, stop, 71 &iwe, network->ssid);
71 &iwe, "<hidden>");
72 } else {
73 iwe.u.data.length = min(network->ssid_len, (u8) 32);
74 start = iwe_stream_add_point(info, start, stop,
75 &iwe, network->ssid);
76 }
77 72
78 /* Add the protocol name */ 73 /* Add the protocol name */
79 iwe.cmd = SIOCGIWNAME; 74 iwe.cmd = SIOCGIWNAME;
@@ -264,7 +259,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
264 char *ev = extra; 259 char *ev = extra;
265 char *stop = ev + wrqu->data.length; 260 char *stop = ev + wrqu->data.length;
266 int i = 0; 261 int i = 0;
267 DECLARE_MAC_BUF(mac); 262 DECLARE_SSID_BUF(ssid);
268 263
269 IEEE80211_DEBUG_WX("Getting scan\n"); 264 IEEE80211_DEBUG_WX("Getting scan\n");
270 265
@@ -283,10 +278,10 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
283 info); 278 info);
284 else 279 else
285 IEEE80211_DEBUG_SCAN("Not showing network '%s (" 280 IEEE80211_DEBUG_SCAN("Not showing network '%s ("
286 "%s)' due to age (%dms).\n", 281 "%pM)' due to age (%dms).\n",
287 escape_essid(network->ssid, 282 print_ssid(ssid, network->ssid,
288 network->ssid_len), 283 network->ssid_len),
289 print_mac(mac, network->bssid), 284 network->bssid,
290 jiffies_to_msecs(jiffies - 285 jiffies_to_msecs(jiffies -
291 network-> 286 network->
292 last_scanned)); 287 last_scanned));
@@ -314,6 +309,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
314 int i, key, key_provided, len; 309 int i, key, key_provided, len;
315 struct ieee80211_crypt_data **crypt; 310 struct ieee80211_crypt_data **crypt;
316 int host_crypto = ieee->host_encrypt || ieee->host_decrypt || ieee->host_build_iv; 311 int host_crypto = ieee->host_encrypt || ieee->host_decrypt || ieee->host_build_iv;
312 DECLARE_SSID_BUF(ssid);
317 313
318 IEEE80211_DEBUG_WX("SET_ENCODE\n"); 314 IEEE80211_DEBUG_WX("SET_ENCODE\n");
319 315
@@ -403,13 +399,17 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
403 399
404 /* If a new key was provided, set it up */ 400 /* If a new key was provided, set it up */
405 if (erq->length > 0) { 401 if (erq->length > 0) {
402#ifdef CONFIG_IEEE80211_DEBUG
403 DECLARE_SSID_BUF(ssid);
404#endif
405
406 len = erq->length <= 5 ? 5 : 13; 406 len = erq->length <= 5 ? 5 : 13;
407 memcpy(sec.keys[key], keybuf, erq->length); 407 memcpy(sec.keys[key], keybuf, erq->length);
408 if (len > erq->length) 408 if (len > erq->length)
409 memset(sec.keys[key] + erq->length, 0, 409 memset(sec.keys[key] + erq->length, 0,
410 len - erq->length); 410 len - erq->length);
411 IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n", 411 IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
412 key, escape_essid(sec.keys[key], len), 412 key, print_ssid(ssid, sec.keys[key], len),
413 erq->length, len); 413 erq->length, len);
414 sec.key_sizes[key] = len; 414 sec.key_sizes[key] = len;
415 if (*crypt) 415 if (*crypt)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1aa2dc9e380e..b1462e8c64cf 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1070,11 +1070,8 @@ static int inet_sk_reselect_saddr(struct sock *sk)
1070 return 0; 1070 return 0;
1071 1071
1072 if (sysctl_ip_dynaddr > 1) { 1072 if (sysctl_ip_dynaddr > 1) {
1073 printk(KERN_INFO "%s(): shifting inet->" 1073 printk(KERN_INFO "%s(): shifting inet->saddr from %pI4 to %pI4\n",
1074 "saddr from " NIPQUAD_FMT " to " NIPQUAD_FMT "\n", 1074 __func__, &old_saddr, &new_saddr);
1075 __func__,
1076 NIPQUAD(old_saddr),
1077 NIPQUAD(new_saddr));
1078 } 1075 }
1079 1076
1080 inet->saddr = inet->rcv_saddr = new_saddr; 1077 inet->saddr = inet->rcv_saddr = new_saddr;
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 8219b7e0968d..3f205181712d 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -201,8 +201,8 @@ out:
201 201
202static void ah4_err(struct sk_buff *skb, u32 info) 202static void ah4_err(struct sk_buff *skb, u32 info)
203{ 203{
204 struct iphdr *iph = (struct iphdr*)skb->data; 204 struct iphdr *iph = (struct iphdr *)skb->data;
205 struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+(iph->ihl<<2)); 205 struct ip_auth_hdr *ah = (struct ip_auth_hdr *)(skb->data+(iph->ihl<<2));
206 struct xfrm_state *x; 206 struct xfrm_state *x;
207 207
208 if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH || 208 if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 1a9dd66511fc..29a74c01d8de 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -506,7 +506,7 @@ int arp_bind_neighbour(struct dst_entry *dst)
506 if (dev == NULL) 506 if (dev == NULL)
507 return -EINVAL; 507 return -EINVAL;
508 if (n == NULL) { 508 if (n == NULL) {
509 __be32 nexthop = ((struct rtable*)dst)->rt_gateway; 509 __be32 nexthop = ((struct rtable *)dst)->rt_gateway;
510 if (dev->flags&(IFF_LOOPBACK|IFF_POINTOPOINT)) 510 if (dev->flags&(IFF_LOOPBACK|IFF_POINTOPOINT))
511 nexthop = 0; 511 nexthop = 0;
512 n = __neigh_lookup_errno( 512 n = __neigh_lookup_errno(
@@ -640,14 +640,14 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
640 arp_ptr=(unsigned char *)(arp+1); 640 arp_ptr=(unsigned char *)(arp+1);
641 641
642 memcpy(arp_ptr, src_hw, dev->addr_len); 642 memcpy(arp_ptr, src_hw, dev->addr_len);
643 arp_ptr+=dev->addr_len; 643 arp_ptr += dev->addr_len;
644 memcpy(arp_ptr, &src_ip,4); 644 memcpy(arp_ptr, &src_ip, 4);
645 arp_ptr+=4; 645 arp_ptr += 4;
646 if (target_hw != NULL) 646 if (target_hw != NULL)
647 memcpy(arp_ptr, target_hw, dev->addr_len); 647 memcpy(arp_ptr, target_hw, dev->addr_len);
648 else 648 else
649 memset(arp_ptr, 0, dev->addr_len); 649 memset(arp_ptr, 0, dev->addr_len);
650 arp_ptr+=dev->addr_len; 650 arp_ptr += dev->addr_len;
651 memcpy(arp_ptr, &dest_ip, 4); 651 memcpy(arp_ptr, &dest_ip, 4);
652 652
653 return skb; 653 return skb;
@@ -818,18 +818,18 @@ static int arp_process(struct sk_buff *skb)
818 addr_type = rt->rt_type; 818 addr_type = rt->rt_type;
819 819
820 if (addr_type == RTN_LOCAL) { 820 if (addr_type == RTN_LOCAL) {
821 n = neigh_event_ns(&arp_tbl, sha, &sip, dev); 821 int dont_send = 0;
822 if (n) {
823 int dont_send = 0;
824
825 if (!dont_send)
826 dont_send |= arp_ignore(in_dev,sip,tip);
827 if (!dont_send && IN_DEV_ARPFILTER(in_dev))
828 dont_send |= arp_filter(sip,tip,dev);
829 if (!dont_send)
830 arp_send(ARPOP_REPLY,ETH_P_ARP,sip,dev,tip,sha,dev->dev_addr,sha);
831 822
832 neigh_release(n); 823 if (!dont_send)
824 dont_send |= arp_ignore(in_dev,sip,tip);
825 if (!dont_send && IN_DEV_ARPFILTER(in_dev))
826 dont_send |= arp_filter(sip,tip,dev);
827 if (!dont_send) {
828 n = neigh_event_ns(&arp_tbl, sha, &sip, dev);
829 if (n) {
830 arp_send(ARPOP_REPLY,ETH_P_ARP,sip,dev,tip,sha,dev->dev_addr,sha);
831 neigh_release(n);
832 }
833 } 833 }
834 goto out; 834 goto out;
835 } else if (IN_DEV_FORWARD(in_dev)) { 835 } else if (IN_DEV_FORWARD(in_dev)) {
@@ -1308,7 +1308,7 @@ static void arp_format_neigh_entry(struct seq_file *seq,
1308#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 1308#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
1309 } 1309 }
1310#endif 1310#endif
1311 sprintf(tbuf, NIPQUAD_FMT, NIPQUAD(*(u32*)n->primary_key)); 1311 sprintf(tbuf, "%pI4", n->primary_key);
1312 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n", 1312 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
1313 tbuf, hatype, arp_state_to_flags(n), hbuffer, dev->name); 1313 tbuf, hatype, arp_state_to_flags(n), hbuffer, dev->name);
1314 read_unlock(&n->lock); 1314 read_unlock(&n->lock);
@@ -1321,7 +1321,7 @@ static void arp_format_pneigh_entry(struct seq_file *seq,
1321 int hatype = dev ? dev->type : 0; 1321 int hatype = dev ? dev->type : 0;
1322 char tbuf[16]; 1322 char tbuf[16];
1323 1323
1324 sprintf(tbuf, NIPQUAD_FMT, NIPQUAD(*(u32*)n->key)); 1324 sprintf(tbuf, "%pI4", n->key);
1325 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n", 1325 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
1326 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00", 1326 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
1327 dev ? dev->name : "*"); 1327 dev ? dev->name : "*");
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 2e78f6bd9775..e52799047a5f 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -490,7 +490,6 @@ int cipso_v4_doi_add(struct cipso_v4_doi *doi_def)
490 } 490 }
491 491
492 atomic_set(&doi_def->refcount, 1); 492 atomic_set(&doi_def->refcount, 1);
493 INIT_RCU_HEAD(&doi_def->rcu);
494 493
495 spin_lock(&cipso_v4_doi_list_lock); 494 spin_lock(&cipso_v4_doi_list_lock);
496 if (cipso_v4_doi_search(doi_def->doi) != NULL) 495 if (cipso_v4_doi_search(doi_def->doi) != NULL)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 56fce3ab6c55..309997edc8a5 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -112,13 +112,7 @@ static inline void devinet_sysctl_unregister(struct in_device *idev)
112 112
113static struct in_ifaddr *inet_alloc_ifa(void) 113static struct in_ifaddr *inet_alloc_ifa(void)
114{ 114{
115 struct in_ifaddr *ifa = kzalloc(sizeof(*ifa), GFP_KERNEL); 115 return kzalloc(sizeof(struct in_ifaddr), GFP_KERNEL);
116
117 if (ifa) {
118 INIT_RCU_HEAD(&ifa->rcu_head);
119 }
120
121 return ifa;
122} 116}
123 117
124static void inet_rcu_free_ifa(struct rcu_head *head) 118static void inet_rcu_free_ifa(struct rcu_head *head)
@@ -161,7 +155,6 @@ static struct in_device *inetdev_init(struct net_device *dev)
161 in_dev = kzalloc(sizeof(*in_dev), GFP_KERNEL); 155 in_dev = kzalloc(sizeof(*in_dev), GFP_KERNEL);
162 if (!in_dev) 156 if (!in_dev)
163 goto out; 157 goto out;
164 INIT_RCU_HEAD(&in_dev->rcu_head);
165 memcpy(&in_dev->cnf, dev_net(dev)->ipv4.devconf_dflt, 158 memcpy(&in_dev->cnf, dev_net(dev)->ipv4.devconf_dflt,
166 sizeof(in_dev->cnf)); 159 sizeof(in_dev->cnf));
167 in_dev->cnf.sysctl = NULL; 160 in_dev->cnf.sysctl = NULL;
@@ -1108,7 +1101,7 @@ out:
1108} 1101}
1109 1102
1110static struct notifier_block ip_netdev_notifier = { 1103static struct notifier_block ip_netdev_notifier = {
1111 .notifier_call =inetdev_event, 1104 .notifier_call = inetdev_event,
1112}; 1105};
1113 1106
1114static inline size_t inet_nlmsg_size(void) 1107static inline size_t inet_nlmsg_size(void)
@@ -1195,7 +1188,7 @@ done:
1195 return skb->len; 1188 return skb->len;
1196} 1189}
1197 1190
1198static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh, 1191static void rtmsg_ifa(int event, struct in_ifaddr *ifa, struct nlmsghdr *nlh,
1199 u32 pid) 1192 u32 pid)
1200{ 1193{
1201 struct sk_buff *skb; 1194 struct sk_buff *skb;
@@ -1262,7 +1255,7 @@ static void inet_forward_change(struct net *net)
1262} 1255}
1263 1256
1264static int devinet_conf_proc(ctl_table *ctl, int write, 1257static int devinet_conf_proc(ctl_table *ctl, int write,
1265 struct file* filp, void __user *buffer, 1258 struct file *filp, void __user *buffer,
1266 size_t *lenp, loff_t *ppos) 1259 size_t *lenp, loff_t *ppos)
1267{ 1260{
1268 int ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos); 1261 int ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
@@ -1334,7 +1327,7 @@ static int devinet_conf_sysctl(ctl_table *table,
1334} 1327}
1335 1328
1336static int devinet_sysctl_forward(ctl_table *ctl, int write, 1329static int devinet_sysctl_forward(ctl_table *ctl, int write,
1337 struct file* filp, void __user *buffer, 1330 struct file *filp, void __user *buffer,
1338 size_t *lenp, loff_t *ppos) 1331 size_t *lenp, loff_t *ppos)
1339{ 1332{
1340 int *valp = ctl->data; 1333 int *valp = ctl->data;
@@ -1363,7 +1356,7 @@ static int devinet_sysctl_forward(ctl_table *ctl, int write,
1363} 1356}
1364 1357
1365int ipv4_doint_and_flush(ctl_table *ctl, int write, 1358int ipv4_doint_and_flush(ctl_table *ctl, int write,
1366 struct file* filp, void __user *buffer, 1359 struct file *filp, void __user *buffer,
1367 size_t *lenp, loff_t *ppos) 1360 size_t *lenp, loff_t *ppos)
1368{ 1361{
1369 int *valp = ctl->data; 1362 int *valp = ctl->data;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 21515d4c49eb..95a9c65003f8 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -413,8 +413,8 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
413 413
414static void esp4_err(struct sk_buff *skb, u32 info) 414static void esp4_err(struct sk_buff *skb, u32 info)
415{ 415{
416 struct iphdr *iph = (struct iphdr*)skb->data; 416 struct iphdr *iph = (struct iphdr *)skb->data;
417 struct ip_esp_hdr *esph = (struct ip_esp_hdr*)(skb->data+(iph->ihl<<2)); 417 struct ip_esp_hdr *esph = (struct ip_esp_hdr *)(skb->data+(iph->ihl<<2));
418 struct xfrm_state *x; 418 struct xfrm_state *x;
419 419
420 if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH || 420 if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 65c1503f8cc8..741e4fa3e474 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -578,7 +578,7 @@ errout:
578 return err; 578 return err;
579} 579}
580 580
581static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 581static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
582{ 582{
583 struct net *net = sock_net(skb->sk); 583 struct net *net = sock_net(skb->sk);
584 struct fib_config cfg; 584 struct fib_config cfg;
@@ -600,7 +600,7 @@ errout:
600 return err; 600 return err;
601} 601}
602 602
603static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 603static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
604{ 604{
605 struct net *net = sock_net(skb->sk); 605 struct net *net = sock_net(skb->sk);
606 struct fib_config cfg; 606 struct fib_config cfg;
@@ -903,7 +903,7 @@ static void fib_disable_ip(struct net_device *dev, int force)
903 903
904static int fib_inetaddr_event(struct notifier_block *this, unsigned long event, void *ptr) 904static int fib_inetaddr_event(struct notifier_block *this, unsigned long event, void *ptr)
905{ 905{
906 struct in_ifaddr *ifa = (struct in_ifaddr*)ptr; 906 struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
907 struct net_device *dev = ifa->ifa_dev->dev; 907 struct net_device *dev = ifa->ifa_dev->dev;
908 908
909 switch (event) { 909 switch (event) {
@@ -964,11 +964,11 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
964} 964}
965 965
966static struct notifier_block fib_inetaddr_notifier = { 966static struct notifier_block fib_inetaddr_notifier = {
967 .notifier_call =fib_inetaddr_event, 967 .notifier_call = fib_inetaddr_event,
968}; 968};
969 969
970static struct notifier_block fib_netdev_notifier = { 970static struct notifier_block fib_netdev_notifier = {
971 .notifier_call =fib_netdev_event, 971 .notifier_call = fib_netdev_event,
972}; 972};
973 973
974static int __net_init ip_fib_net_init(struct net *net) 974static int __net_init ip_fib_net_init(struct net *net)
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index c8cac6c7f881..ded8c44fb848 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -247,7 +247,7 @@ fn_hash_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
247{ 247{
248 int err; 248 int err;
249 struct fn_zone *fz; 249 struct fn_zone *fz;
250 struct fn_hash *t = (struct fn_hash*)tb->tb_data; 250 struct fn_hash *t = (struct fn_hash *)tb->tb_data;
251 251
252 read_lock(&fib_hash_lock); 252 read_lock(&fib_hash_lock);
253 for (fz = t->fn_zone_list; fz; fz = fz->fz_next) { 253 for (fz = t->fn_zone_list; fz; fz = fz->fz_next) {
@@ -283,7 +283,7 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
283 struct fib_node *f; 283 struct fib_node *f;
284 struct fib_info *fi = NULL; 284 struct fib_info *fi = NULL;
285 struct fib_info *last_resort; 285 struct fib_info *last_resort;
286 struct fn_hash *t = (struct fn_hash*)tb->tb_data; 286 struct fn_hash *t = (struct fn_hash *)tb->tb_data;
287 struct fn_zone *fz = t->fn_zones[0]; 287 struct fn_zone *fz = t->fn_zones[0];
288 288
289 if (fz == NULL) 289 if (fz == NULL)
@@ -548,7 +548,7 @@ out:
548 548
549static int fn_hash_delete(struct fib_table *tb, struct fib_config *cfg) 549static int fn_hash_delete(struct fib_table *tb, struct fib_config *cfg)
550{ 550{
551 struct fn_hash *table = (struct fn_hash*)tb->tb_data; 551 struct fn_hash *table = (struct fn_hash *)tb->tb_data;
552 struct fib_node *f; 552 struct fib_node *f;
553 struct fib_alias *fa, *fa_to_delete; 553 struct fib_alias *fa, *fa_to_delete;
554 struct fn_zone *fz; 554 struct fn_zone *fz;
@@ -748,7 +748,7 @@ static int fn_hash_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin
748{ 748{
749 int m, s_m; 749 int m, s_m;
750 struct fn_zone *fz; 750 struct fn_zone *fz;
751 struct fn_hash *table = (struct fn_hash*)tb->tb_data; 751 struct fn_hash *table = (struct fn_hash *)tb->tb_data;
752 752
753 s_m = cb->args[2]; 753 s_m = cb->args[2];
754 read_lock(&fib_hash_lock); 754 read_lock(&fib_hash_lock);
@@ -845,10 +845,10 @@ static struct fib_alias *fib_get_first(struct seq_file *seq)
845 struct hlist_node *node; 845 struct hlist_node *node;
846 struct fib_node *fn; 846 struct fib_node *fn;
847 847
848 hlist_for_each_entry(fn,node,iter->hash_head,fn_hash) { 848 hlist_for_each_entry(fn, node, iter->hash_head, fn_hash) {
849 struct fib_alias *fa; 849 struct fib_alias *fa;
850 850
851 list_for_each_entry(fa,&fn->fn_alias,fa_list) { 851 list_for_each_entry(fa, &fn->fn_alias, fa_list) {
852 iter->fn = fn; 852 iter->fn = fn;
853 iter->fa = fa; 853 iter->fa = fa;
854 goto out; 854 goto out;
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index ded2ae34eab1..4817dea3bc73 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -63,16 +63,16 @@ static DEFINE_SPINLOCK(fib_multipath_lock);
63for (nhsel=0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++) 63for (nhsel=0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++)
64 64
65#define change_nexthops(fi) { int nhsel; struct fib_nh * nh; \ 65#define change_nexthops(fi) { int nhsel; struct fib_nh * nh; \
66for (nhsel=0, nh = (struct fib_nh*)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++, nhsel++) 66for (nhsel=0, nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++, nhsel++)
67 67
68#else /* CONFIG_IP_ROUTE_MULTIPATH */ 68#else /* CONFIG_IP_ROUTE_MULTIPATH */
69 69
70/* Hope, that gcc will optimize it to get rid of dummy loop */ 70/* Hope, that gcc will optimize it to get rid of dummy loop */
71 71
72#define for_nexthops(fi) { int nhsel=0; const struct fib_nh * nh = (fi)->fib_nh; \ 72#define for_nexthops(fi) { int nhsel = 0; const struct fib_nh * nh = (fi)->fib_nh; \
73for (nhsel=0; nhsel < 1; nhsel++) 73for (nhsel=0; nhsel < 1; nhsel++)
74 74
75#define change_nexthops(fi) { int nhsel=0; struct fib_nh * nh = (struct fib_nh*)((fi)->fib_nh); \ 75#define change_nexthops(fi) { int nhsel = 0; struct fib_nh * nh = (struct fib_nh *)((fi)->fib_nh); \
76for (nhsel=0; nhsel < 1; nhsel++) 76for (nhsel=0; nhsel < 1; nhsel++)
77 77
78#endif /* CONFIG_IP_ROUTE_MULTIPATH */ 78#endif /* CONFIG_IP_ROUTE_MULTIPATH */
@@ -358,7 +358,7 @@ int fib_detect_death(struct fib_info *fi, int order,
358 state = n->nud_state; 358 state = n->nud_state;
359 neigh_release(n); 359 neigh_release(n);
360 } 360 }
361 if (state==NUD_REACHABLE) 361 if (state == NUD_REACHABLE)
362 return 0; 362 return 0;
363 if ((state&NUD_VALID) && order != dflt) 363 if ((state&NUD_VALID) && order != dflt)
364 return 0; 364 return 0;
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 5cb72786a8af..ec0ae490f0b6 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2399,8 +2399,8 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2399 __be32 prf = htonl(mask_pfx(tn->key, tn->pos)); 2399 __be32 prf = htonl(mask_pfx(tn->key, tn->pos));
2400 2400
2401 seq_indent(seq, iter->depth-1); 2401 seq_indent(seq, iter->depth-1);
2402 seq_printf(seq, " +-- " NIPQUAD_FMT "/%d %d %d %d\n", 2402 seq_printf(seq, " +-- %pI4/%d %d %d %d\n",
2403 NIPQUAD(prf), tn->pos, tn->bits, tn->full_children, 2403 &prf, tn->pos, tn->bits, tn->full_children,
2404 tn->empty_children); 2404 tn->empty_children);
2405 2405
2406 } else { 2406 } else {
@@ -2410,7 +2410,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2410 __be32 val = htonl(l->key); 2410 __be32 val = htonl(l->key);
2411 2411
2412 seq_indent(seq, iter->depth); 2412 seq_indent(seq, iter->depth);
2413 seq_printf(seq, " |-- " NIPQUAD_FMT "\n", NIPQUAD(val)); 2413 seq_printf(seq, " |-- %pI4\n", &val);
2414 2414
2415 hlist_for_each_entry_rcu(li, node, &l->list, hlist) { 2415 hlist_for_each_entry_rcu(li, node, &l->list, hlist) {
2416 struct fib_alias *fa; 2416 struct fib_alias *fa;
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 72b2de76f1cd..21e497efbd7f 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -683,10 +683,8 @@ static void icmp_unreach(struct sk_buff *skb)
683 break; 683 break;
684 case ICMP_FRAG_NEEDED: 684 case ICMP_FRAG_NEEDED:
685 if (ipv4_config.no_pmtu_disc) { 685 if (ipv4_config.no_pmtu_disc) {
686 LIMIT_NETDEBUG(KERN_INFO "ICMP: " NIPQUAD_FMT ": " 686 LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: fragmentation needed and DF set.\n",
687 "fragmentation needed " 687 &iph->daddr);
688 "and DF set.\n",
689 NIPQUAD(iph->daddr));
690 } else { 688 } else {
691 info = ip_rt_frag_needed(net, iph, 689 info = ip_rt_frag_needed(net, iph,
692 ntohs(icmph->un.frag.mtu), 690 ntohs(icmph->un.frag.mtu),
@@ -696,9 +694,8 @@ static void icmp_unreach(struct sk_buff *skb)
696 } 694 }
697 break; 695 break;
698 case ICMP_SR_FAILED: 696 case ICMP_SR_FAILED:
699 LIMIT_NETDEBUG(KERN_INFO "ICMP: " NIPQUAD_FMT ": Source " 697 LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: Source Route Failed.\n",
700 "Route Failed.\n", 698 &iph->daddr);
701 NIPQUAD(iph->daddr));
702 break; 699 break;
703 default: 700 default:
704 break; 701 break;
@@ -729,12 +726,12 @@ static void icmp_unreach(struct sk_buff *skb)
729 if (!net->ipv4.sysctl_icmp_ignore_bogus_error_responses && 726 if (!net->ipv4.sysctl_icmp_ignore_bogus_error_responses &&
730 inet_addr_type(net, iph->daddr) == RTN_BROADCAST) { 727 inet_addr_type(net, iph->daddr) == RTN_BROADCAST) {
731 if (net_ratelimit()) 728 if (net_ratelimit())
732 printk(KERN_WARNING NIPQUAD_FMT " sent an invalid ICMP " 729 printk(KERN_WARNING "%pI4 sent an invalid ICMP "
733 "type %u, code %u " 730 "type %u, code %u "
734 "error to a broadcast: " NIPQUAD_FMT " on %s\n", 731 "error to a broadcast: %pI4 on %s\n",
735 NIPQUAD(ip_hdr(skb)->saddr), 732 &ip_hdr(skb)->saddr,
736 icmph->type, icmph->code, 733 icmph->type, icmph->code,
737 NIPQUAD(iph->daddr), 734 &iph->daddr,
738 skb->dev->name); 735 skb->dev->name);
739 goto out; 736 goto out;
740 } 737 }
@@ -952,9 +949,8 @@ static void icmp_address_reply(struct sk_buff *skb)
952 break; 949 break;
953 } 950 }
954 if (!ifa && net_ratelimit()) { 951 if (!ifa && net_ratelimit()) {
955 printk(KERN_INFO "Wrong address mask " NIPQUAD_FMT " from " 952 printk(KERN_INFO "Wrong address mask %pI4 from %s/%pI4\n",
956 "%s/" NIPQUAD_FMT "\n", 953 mp, dev->name, &rt->rt_src);
957 NIPQUAD(*mp), dev->name, NIPQUAD(rt->rt_src));
958 } 954 }
959 } 955 }
960 rcu_read_unlock(); 956 rcu_read_unlock();
@@ -976,9 +972,10 @@ int icmp_rcv(struct sk_buff *skb)
976 struct net *net = dev_net(rt->u.dst.dev); 972 struct net *net = dev_net(rt->u.dst.dev);
977 973
978 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { 974 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
975 struct sec_path *sp = skb_sec_path(skb);
979 int nh; 976 int nh;
980 977
981 if (!(skb->sp && skb->sp->xvec[skb->sp->len - 1]->props.flags & 978 if (!(sp && sp->xvec[sp->len - 1]->props.flags &
982 XFRM_STATE_ICMP)) 979 XFRM_STATE_ICMP))
983 goto drop; 980 goto drop;
984 981
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index a0d86455c53e..f92733e15c9f 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -167,7 +167,7 @@ static __inline__ void igmp_stop_timer(struct ip_mc_list *im)
167 spin_lock_bh(&im->lock); 167 spin_lock_bh(&im->lock);
168 if (del_timer(&im->timer)) 168 if (del_timer(&im->timer))
169 atomic_dec(&im->refcnt); 169 atomic_dec(&im->refcnt);
170 im->tm_running=0; 170 im->tm_running = 0;
171 im->reporter = 0; 171 im->reporter = 0;
172 im->unsolicit_count = 0; 172 im->unsolicit_count = 0;
173 spin_unlock_bh(&im->lock); 173 spin_unlock_bh(&im->lock);
@@ -176,9 +176,9 @@ static __inline__ void igmp_stop_timer(struct ip_mc_list *im)
176/* It must be called with locked im->lock */ 176/* It must be called with locked im->lock */
177static void igmp_start_timer(struct ip_mc_list *im, int max_delay) 177static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
178{ 178{
179 int tv=net_random() % max_delay; 179 int tv = net_random() % max_delay;
180 180
181 im->tm_running=1; 181 im->tm_running = 1;
182 if (!mod_timer(&im->timer, jiffies+tv+2)) 182 if (!mod_timer(&im->timer, jiffies+tv+2))
183 atomic_inc(&im->refcnt); 183 atomic_inc(&im->refcnt);
184} 184}
@@ -207,7 +207,7 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)
207 if (del_timer(&im->timer)) { 207 if (del_timer(&im->timer)) {
208 if ((long)(im->timer.expires-jiffies) < max_delay) { 208 if ((long)(im->timer.expires-jiffies) < max_delay) {
209 add_timer(&im->timer); 209 add_timer(&im->timer);
210 im->tm_running=1; 210 im->tm_running = 1;
211 spin_unlock_bh(&im->lock); 211 spin_unlock_bh(&im->lock);
212 return; 212 return;
213 } 213 }
@@ -358,7 +358,7 @@ static int igmpv3_sendpack(struct sk_buff *skb)
358 358
359static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel) 359static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel)
360{ 360{
361 return sizeof(struct igmpv3_grec) + 4*igmp_scount(pmc,type,gdel,sdel); 361 return sizeof(struct igmpv3_grec) + 4*igmp_scount(pmc, type, gdel, sdel);
362} 362}
363 363
364static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc, 364static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc,
@@ -653,7 +653,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
653 return -1; 653 return -1;
654 } 654 }
655 655
656 skb=alloc_skb(IGMP_SIZE+LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); 656 skb = alloc_skb(IGMP_SIZE+LL_ALLOCATED_SPACE(dev), GFP_ATOMIC);
657 if (skb == NULL) { 657 if (skb == NULL) {
658 ip_rt_put(rt); 658 ip_rt_put(rt);
659 return -1; 659 return -1;
@@ -682,11 +682,11 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
682 ((u8*)&iph[1])[3] = 0; 682 ((u8*)&iph[1])[3] = 0;
683 683
684 ih = (struct igmphdr *)skb_put(skb, sizeof(struct igmphdr)); 684 ih = (struct igmphdr *)skb_put(skb, sizeof(struct igmphdr));
685 ih->type=type; 685 ih->type = type;
686 ih->code=0; 686 ih->code = 0;
687 ih->csum=0; 687 ih->csum = 0;
688 ih->group=group; 688 ih->group = group;
689 ih->csum=ip_compute_csum((void *)ih, sizeof(struct igmphdr)); 689 ih->csum = ip_compute_csum((void *)ih, sizeof(struct igmphdr));
690 690
691 return ip_local_out(skb); 691 return ip_local_out(skb);
692} 692}
@@ -728,7 +728,7 @@ static void igmp_timer_expire(unsigned long data)
728 struct in_device *in_dev = im->interface; 728 struct in_device *in_dev = im->interface;
729 729
730 spin_lock(&im->lock); 730 spin_lock(&im->lock);
731 im->tm_running=0; 731 im->tm_running = 0;
732 732
733 if (im->unsolicit_count) { 733 if (im->unsolicit_count) {
734 im->unsolicit_count--; 734 im->unsolicit_count--;
@@ -997,7 +997,7 @@ static void ip_mc_filter_add(struct in_device *in_dev, __be32 addr)
997 --ANK 997 --ANK
998 */ 998 */
999 if (arp_mc_map(addr, buf, dev, 0) == 0) 999 if (arp_mc_map(addr, buf, dev, 0) == 0)
1000 dev_mc_add(dev,buf,dev->addr_len,0); 1000 dev_mc_add(dev, buf, dev->addr_len, 0);
1001} 1001}
1002 1002
1003/* 1003/*
@@ -1010,7 +1010,7 @@ static void ip_mc_filter_del(struct in_device *in_dev, __be32 addr)
1010 struct net_device *dev = in_dev->dev; 1010 struct net_device *dev = in_dev->dev;
1011 1011
1012 if (arp_mc_map(addr, buf, dev, 0) == 0) 1012 if (arp_mc_map(addr, buf, dev, 0) == 0)
1013 dev_mc_delete(dev,buf,dev->addr_len,0); 1013 dev_mc_delete(dev, buf, dev->addr_len, 0);
1014} 1014}
1015 1015
1016#ifdef CONFIG_IP_MULTICAST 1016#ifdef CONFIG_IP_MULTICAST
@@ -1210,10 +1210,10 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1210 if (!im) 1210 if (!im)
1211 goto out; 1211 goto out;
1212 1212
1213 im->users=1; 1213 im->users = 1;
1214 im->interface=in_dev; 1214 im->interface = in_dev;
1215 in_dev_hold(in_dev); 1215 in_dev_hold(in_dev);
1216 im->multiaddr=addr; 1216 im->multiaddr = addr;
1217 /* initial mode is (EX, empty) */ 1217 /* initial mode is (EX, empty) */
1218 im->sfmode = MCAST_EXCLUDE; 1218 im->sfmode = MCAST_EXCLUDE;
1219 im->sfcount[MCAST_INCLUDE] = 0; 1219 im->sfcount[MCAST_INCLUDE] = 0;
@@ -1224,7 +1224,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1224 atomic_set(&im->refcnt, 1); 1224 atomic_set(&im->refcnt, 1);
1225 spin_lock_init(&im->lock); 1225 spin_lock_init(&im->lock);
1226#ifdef CONFIG_IP_MULTICAST 1226#ifdef CONFIG_IP_MULTICAST
1227 im->tm_running=0; 1227 im->tm_running = 0;
1228 setup_timer(&im->timer, &igmp_timer_expire, (unsigned long)im); 1228 setup_timer(&im->timer, &igmp_timer_expire, (unsigned long)im);
1229 im->unsolicit_count = IGMP_Unsolicited_Report_Count; 1229 im->unsolicit_count = IGMP_Unsolicited_Report_Count;
1230 im->reporter = 0; 1230 im->reporter = 0;
@@ -1232,8 +1232,8 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1232#endif 1232#endif
1233 im->loaded = 0; 1233 im->loaded = 0;
1234 write_lock_bh(&in_dev->mc_list_lock); 1234 write_lock_bh(&in_dev->mc_list_lock);
1235 im->next=in_dev->mc_list; 1235 im->next = in_dev->mc_list;
1236 in_dev->mc_list=im; 1236 in_dev->mc_list = im;
1237 in_dev->mc_count++; 1237 in_dev->mc_count++;
1238 write_unlock_bh(&in_dev->mc_list_lock); 1238 write_unlock_bh(&in_dev->mc_list_lock);
1239#ifdef CONFIG_IP_MULTICAST 1239#ifdef CONFIG_IP_MULTICAST
@@ -1279,7 +1279,7 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
1279 ASSERT_RTNL(); 1279 ASSERT_RTNL();
1280 1280
1281 for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) { 1281 for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) {
1282 if (i->multiaddr==addr) { 1282 if (i->multiaddr == addr) {
1283 if (--i->users == 0) { 1283 if (--i->users == 0) {
1284 write_lock_bh(&in_dev->mc_list_lock); 1284 write_lock_bh(&in_dev->mc_list_lock);
1285 *ip = i->next; 1285 *ip = i->next;
@@ -1738,7 +1738,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
1738{ 1738{
1739 int err; 1739 int err;
1740 __be32 addr = imr->imr_multiaddr.s_addr; 1740 __be32 addr = imr->imr_multiaddr.s_addr;
1741 struct ip_mc_socklist *iml=NULL, *i; 1741 struct ip_mc_socklist *iml = NULL, *i;
1742 struct in_device *in_dev; 1742 struct in_device *in_dev;
1743 struct inet_sock *inet = inet_sk(sk); 1743 struct inet_sock *inet = inet_sk(sk);
1744 struct net *net = sock_net(sk); 1744 struct net *net = sock_net(sk);
@@ -1769,7 +1769,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
1769 err = -ENOBUFS; 1769 err = -ENOBUFS;
1770 if (count >= sysctl_igmp_max_memberships) 1770 if (count >= sysctl_igmp_max_memberships)
1771 goto done; 1771 goto done;
1772 iml = sock_kmalloc(sk,sizeof(*iml),GFP_KERNEL); 1772 iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL);
1773 if (iml == NULL) 1773 if (iml == NULL)
1774 goto done; 1774 goto done;
1775 1775
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index bd1278a2d828..05af807ca9b9 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -109,7 +109,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
109 hashinfo->bhash_size)]; 109 hashinfo->bhash_size)];
110 spin_lock(&head->lock); 110 spin_lock(&head->lock);
111 inet_bind_bucket_for_each(tb, node, &head->chain) 111 inet_bind_bucket_for_each(tb, node, &head->chain)
112 if (tb->ib_net == net && tb->port == rover) 112 if (ib_net(tb) == net && tb->port == rover)
113 goto next; 113 goto next;
114 break; 114 break;
115 next: 115 next:
@@ -137,7 +137,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
137 hashinfo->bhash_size)]; 137 hashinfo->bhash_size)];
138 spin_lock(&head->lock); 138 spin_lock(&head->lock);
139 inet_bind_bucket_for_each(tb, node, &head->chain) 139 inet_bind_bucket_for_each(tb, node, &head->chain)
140 if (tb->ib_net == net && tb->port == snum) 140 if (ib_net(tb) == net && tb->port == snum)
141 goto tb_found; 141 goto tb_found;
142 } 142 }
143 tb = NULL; 143 tb = NULL;
@@ -323,7 +323,7 @@ void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long len)
323 323
324EXPORT_SYMBOL(inet_csk_reset_keepalive_timer); 324EXPORT_SYMBOL(inet_csk_reset_keepalive_timer);
325 325
326struct dst_entry* inet_csk_route_req(struct sock *sk, 326struct dst_entry *inet_csk_route_req(struct sock *sk,
327 const struct request_sock *req) 327 const struct request_sock *req)
328{ 328{
329 struct rtable *rt; 329 struct rtable *rt;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 564230dabcb8..1cb154ed75ad 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -718,13 +718,15 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
718 if (!(r->idiag_states & (TCPF_LISTEN | TCPF_SYN_RECV))) 718 if (!(r->idiag_states & (TCPF_LISTEN | TCPF_SYN_RECV)))
719 goto skip_listen_ht; 719 goto skip_listen_ht;
720 720
721 inet_listen_lock(hashinfo);
722 for (i = s_i; i < INET_LHTABLE_SIZE; i++) { 721 for (i = s_i; i < INET_LHTABLE_SIZE; i++) {
723 struct sock *sk; 722 struct sock *sk;
724 struct hlist_node *node; 723 struct hlist_node *node;
724 struct inet_listen_hashbucket *ilb;
725 725
726 num = 0; 726 num = 0;
727 sk_for_each(sk, node, &hashinfo->listening_hash[i]) { 727 ilb = &hashinfo->listening_hash[i];
728 spin_lock_bh(&ilb->lock);
729 sk_for_each(sk, node, &ilb->head) {
728 struct inet_sock *inet = inet_sk(sk); 730 struct inet_sock *inet = inet_sk(sk);
729 731
730 if (num < s_num) { 732 if (num < s_num) {
@@ -742,7 +744,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
742 goto syn_recv; 744 goto syn_recv;
743 745
744 if (inet_csk_diag_dump(sk, skb, cb) < 0) { 746 if (inet_csk_diag_dump(sk, skb, cb) < 0) {
745 inet_listen_unlock(hashinfo); 747 spin_unlock_bh(&ilb->lock);
746 goto done; 748 goto done;
747 } 749 }
748 750
@@ -751,7 +753,7 @@ syn_recv:
751 goto next_listen; 753 goto next_listen;
752 754
753 if (inet_diag_dump_reqs(skb, sk, cb) < 0) { 755 if (inet_diag_dump_reqs(skb, sk, cb) < 0) {
754 inet_listen_unlock(hashinfo); 756 spin_unlock_bh(&ilb->lock);
755 goto done; 757 goto done;
756 } 758 }
757 759
@@ -760,12 +762,12 @@ next_listen:
760 cb->args[4] = 0; 762 cb->args[4] = 0;
761 ++num; 763 ++num;
762 } 764 }
765 spin_unlock_bh(&ilb->lock);
763 766
764 s_num = 0; 767 s_num = 0;
765 cb->args[3] = 0; 768 cb->args[3] = 0;
766 cb->args[4] = 0; 769 cb->args[4] = 0;
767 } 770 }
768 inet_listen_unlock(hashinfo);
769skip_listen_ht: 771skip_listen_ht:
770 cb->args[0] = 1; 772 cb->args[0] = 1;
771 s_i = num = s_num = 0; 773 s_i = num = s_num = 0;
@@ -778,18 +780,19 @@ skip_listen_ht:
778 struct inet_ehash_bucket *head = &hashinfo->ehash[i]; 780 struct inet_ehash_bucket *head = &hashinfo->ehash[i];
779 rwlock_t *lock = inet_ehash_lockp(hashinfo, i); 781 rwlock_t *lock = inet_ehash_lockp(hashinfo, i);
780 struct sock *sk; 782 struct sock *sk;
781 struct hlist_node *node; 783 struct hlist_nulls_node *node;
782 784
783 num = 0; 785 num = 0;
784 786
785 if (hlist_empty(&head->chain) && hlist_empty(&head->twchain)) 787 if (hlist_nulls_empty(&head->chain) &&
788 hlist_nulls_empty(&head->twchain))
786 continue; 789 continue;
787 790
788 if (i > s_i) 791 if (i > s_i)
789 s_num = 0; 792 s_num = 0;
790 793
791 read_lock_bh(lock); 794 read_lock_bh(lock);
792 sk_for_each(sk, node, &head->chain) { 795 sk_nulls_for_each(sk, node, &head->chain) {
793 struct inet_sock *inet = inet_sk(sk); 796 struct inet_sock *inet = inet_sk(sk);
794 797
795 if (num < s_num) 798 if (num < s_num)
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 44981906fb91..377d004e5723 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -35,7 +35,7 @@ struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep,
35 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC); 35 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC);
36 36
37 if (tb != NULL) { 37 if (tb != NULL) {
38 tb->ib_net = hold_net(net); 38 write_pnet(&tb->ib_net, hold_net(net));
39 tb->port = snum; 39 tb->port = snum;
40 tb->fastreuse = 0; 40 tb->fastreuse = 0;
41 INIT_HLIST_HEAD(&tb->owners); 41 INIT_HLIST_HEAD(&tb->owners);
@@ -51,7 +51,7 @@ void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket
51{ 51{
52 if (hlist_empty(&tb->owners)) { 52 if (hlist_empty(&tb->owners)) {
53 __hlist_del(&tb->node); 53 __hlist_del(&tb->node);
54 release_net(tb->ib_net); 54 release_net(ib_net(tb));
55 kmem_cache_free(cachep, tb); 55 kmem_cache_free(cachep, tb);
56 } 56 }
57} 57}
@@ -111,35 +111,6 @@ void __inet_inherit_port(struct sock *sk, struct sock *child)
111EXPORT_SYMBOL_GPL(__inet_inherit_port); 111EXPORT_SYMBOL_GPL(__inet_inherit_port);
112 112
113/* 113/*
114 * This lock without WQ_FLAG_EXCLUSIVE is good on UP and it can be very bad on SMP.
115 * Look, when several writers sleep and reader wakes them up, all but one
116 * immediately hit write lock and grab all the cpus. Exclusive sleep solves
117 * this, _but_ remember, it adds useless work on UP machines (wake up each
118 * exclusive lock release). It should be ifdefed really.
119 */
120void inet_listen_wlock(struct inet_hashinfo *hashinfo)
121 __acquires(hashinfo->lhash_lock)
122{
123 write_lock(&hashinfo->lhash_lock);
124
125 if (atomic_read(&hashinfo->lhash_users)) {
126 DEFINE_WAIT(wait);
127
128 for (;;) {
129 prepare_to_wait_exclusive(&hashinfo->lhash_wait,
130 &wait, TASK_UNINTERRUPTIBLE);
131 if (!atomic_read(&hashinfo->lhash_users))
132 break;
133 write_unlock_bh(&hashinfo->lhash_lock);
134 schedule();
135 write_lock_bh(&hashinfo->lhash_lock);
136 }
137
138 finish_wait(&hashinfo->lhash_wait, &wait);
139 }
140}
141
142/*
143 * Don't inline this cruft. Here are some nice properties to exploit here. The 114 * Don't inline this cruft. Here are some nice properties to exploit here. The
144 * BSD API does not allow a listening sock to specify the remote port nor the 115 * BSD API does not allow a listening sock to specify the remote port nor the
145 * remote address for the connection. So always assume those are both 116 * remote address for the connection. So always assume those are both
@@ -191,25 +162,25 @@ struct sock *__inet_lookup_listener(struct net *net,
191 const int dif) 162 const int dif)
192{ 163{
193 struct sock *sk = NULL; 164 struct sock *sk = NULL;
194 const struct hlist_head *head; 165 struct inet_listen_hashbucket *ilb;
195 166
196 read_lock(&hashinfo->lhash_lock); 167 ilb = &hashinfo->listening_hash[inet_lhashfn(net, hnum)];
197 head = &hashinfo->listening_hash[inet_lhashfn(net, hnum)]; 168 spin_lock(&ilb->lock);
198 if (!hlist_empty(head)) { 169 if (!hlist_empty(&ilb->head)) {
199 const struct inet_sock *inet = inet_sk((sk = __sk_head(head))); 170 const struct inet_sock *inet = inet_sk((sk = __sk_head(&ilb->head)));
200 171
201 if (inet->num == hnum && !sk->sk_node.next && 172 if (inet->num == hnum && !sk->sk_node.next &&
202 (!inet->rcv_saddr || inet->rcv_saddr == daddr) && 173 (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
203 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) && 174 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
204 !sk->sk_bound_dev_if && net_eq(sock_net(sk), net)) 175 !sk->sk_bound_dev_if && net_eq(sock_net(sk), net))
205 goto sherry_cache; 176 goto sherry_cache;
206 sk = inet_lookup_listener_slow(net, head, daddr, hnum, dif); 177 sk = inet_lookup_listener_slow(net, &ilb->head, daddr, hnum, dif);
207 } 178 }
208 if (sk) { 179 if (sk) {
209sherry_cache: 180sherry_cache:
210 sock_hold(sk); 181 sock_hold(sk);
211 } 182 }
212 read_unlock(&hashinfo->lhash_lock); 183 spin_unlock(&ilb->lock);
213 return sk; 184 return sk;
214} 185}
215EXPORT_SYMBOL_GPL(__inet_lookup_listener); 186EXPORT_SYMBOL_GPL(__inet_lookup_listener);
@@ -223,35 +194,65 @@ struct sock * __inet_lookup_established(struct net *net,
223 INET_ADDR_COOKIE(acookie, saddr, daddr) 194 INET_ADDR_COOKIE(acookie, saddr, daddr)
224 const __portpair ports = INET_COMBINED_PORTS(sport, hnum); 195 const __portpair ports = INET_COMBINED_PORTS(sport, hnum);
225 struct sock *sk; 196 struct sock *sk;
226 const struct hlist_node *node; 197 const struct hlist_nulls_node *node;
227 /* Optimize here for direct hit, only listening connections can 198 /* Optimize here for direct hit, only listening connections can
228 * have wildcards anyways. 199 * have wildcards anyways.
229 */ 200 */
230 unsigned int hash = inet_ehashfn(net, daddr, hnum, saddr, sport); 201 unsigned int hash = inet_ehashfn(net, daddr, hnum, saddr, sport);
231 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); 202 unsigned int slot = hash & (hashinfo->ehash_size - 1);
232 rwlock_t *lock = inet_ehash_lockp(hashinfo, hash); 203 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
233 204
234 prefetch(head->chain.first); 205 rcu_read_lock();
235 read_lock(lock); 206begin:
236 sk_for_each(sk, node, &head->chain) { 207 sk_nulls_for_each_rcu(sk, node, &head->chain) {
237 if (INET_MATCH(sk, net, hash, acookie, 208 if (INET_MATCH(sk, net, hash, acookie,
238 saddr, daddr, ports, dif)) 209 saddr, daddr, ports, dif)) {
239 goto hit; /* You sunk my battleship! */ 210 if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt)))
211 goto begintw;
212 if (unlikely(!INET_MATCH(sk, net, hash, acookie,
213 saddr, daddr, ports, dif))) {
214 sock_put(sk);
215 goto begin;
216 }
217 goto out;
218 }
240 } 219 }
220 /*
221 * if the nulls value we got at the end of this lookup is
222 * not the expected one, we must restart lookup.
223 * We probably met an item that was moved to another chain.
224 */
225 if (get_nulls_value(node) != slot)
226 goto begin;
241 227
228begintw:
242 /* Must check for a TIME_WAIT'er before going to listener hash. */ 229 /* Must check for a TIME_WAIT'er before going to listener hash. */
243 sk_for_each(sk, node, &head->twchain) { 230 sk_nulls_for_each_rcu(sk, node, &head->twchain) {
244 if (INET_TW_MATCH(sk, net, hash, acookie, 231 if (INET_TW_MATCH(sk, net, hash, acookie,
245 saddr, daddr, ports, dif)) 232 saddr, daddr, ports, dif)) {
246 goto hit; 233 if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt))) {
234 sk = NULL;
235 goto out;
236 }
237 if (unlikely(!INET_TW_MATCH(sk, net, hash, acookie,
238 saddr, daddr, ports, dif))) {
239 sock_put(sk);
240 goto begintw;
241 }
242 goto out;
243 }
247 } 244 }
245 /*
246 * if the nulls value we got at the end of this lookup is
247 * not the expected one, we must restart lookup.
248 * We probably met an item that was moved to another chain.
249 */
250 if (get_nulls_value(node) != slot)
251 goto begintw;
248 sk = NULL; 252 sk = NULL;
249out: 253out:
250 read_unlock(lock); 254 rcu_read_unlock();
251 return sk; 255 return sk;
252hit:
253 sock_hold(sk);
254 goto out;
255} 256}
256EXPORT_SYMBOL_GPL(__inet_lookup_established); 257EXPORT_SYMBOL_GPL(__inet_lookup_established);
257 258
@@ -272,14 +273,14 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
272 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); 273 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
273 rwlock_t *lock = inet_ehash_lockp(hinfo, hash); 274 rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
274 struct sock *sk2; 275 struct sock *sk2;
275 const struct hlist_node *node; 276 const struct hlist_nulls_node *node;
276 struct inet_timewait_sock *tw; 277 struct inet_timewait_sock *tw;
277 278
278 prefetch(head->chain.first); 279 prefetch(head->chain.first);
279 write_lock(lock); 280 write_lock(lock);
280 281
281 /* Check TIME-WAIT sockets first. */ 282 /* Check TIME-WAIT sockets first. */
282 sk_for_each(sk2, node, &head->twchain) { 283 sk_nulls_for_each(sk2, node, &head->twchain) {
283 tw = inet_twsk(sk2); 284 tw = inet_twsk(sk2);
284 285
285 if (INET_TW_MATCH(sk2, net, hash, acookie, 286 if (INET_TW_MATCH(sk2, net, hash, acookie,
@@ -293,7 +294,7 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
293 tw = NULL; 294 tw = NULL;
294 295
295 /* And established part... */ 296 /* And established part... */
296 sk_for_each(sk2, node, &head->chain) { 297 sk_nulls_for_each(sk2, node, &head->chain) {
297 if (INET_MATCH(sk2, net, hash, acookie, 298 if (INET_MATCH(sk2, net, hash, acookie,
298 saddr, daddr, ports, dif)) 299 saddr, daddr, ports, dif))
299 goto not_unique; 300 goto not_unique;
@@ -306,7 +307,7 @@ unique:
306 inet->sport = htons(lport); 307 inet->sport = htons(lport);
307 sk->sk_hash = hash; 308 sk->sk_hash = hash;
308 WARN_ON(!sk_unhashed(sk)); 309 WARN_ON(!sk_unhashed(sk));
309 __sk_add_node(sk, &head->chain); 310 __sk_nulls_add_node_rcu(sk, &head->chain);
310 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 311 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
311 write_unlock(lock); 312 write_unlock(lock);
312 313
@@ -338,7 +339,7 @@ static inline u32 inet_sk_port_offset(const struct sock *sk)
338void __inet_hash_nolisten(struct sock *sk) 339void __inet_hash_nolisten(struct sock *sk)
339{ 340{
340 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; 341 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
341 struct hlist_head *list; 342 struct hlist_nulls_head *list;
342 rwlock_t *lock; 343 rwlock_t *lock;
343 struct inet_ehash_bucket *head; 344 struct inet_ehash_bucket *head;
344 345
@@ -350,7 +351,7 @@ void __inet_hash_nolisten(struct sock *sk)
350 lock = inet_ehash_lockp(hashinfo, sk->sk_hash); 351 lock = inet_ehash_lockp(hashinfo, sk->sk_hash);
351 352
352 write_lock(lock); 353 write_lock(lock);
353 __sk_add_node(sk, list); 354 __sk_nulls_add_node_rcu(sk, list);
354 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 355 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
355 write_unlock(lock); 356 write_unlock(lock);
356} 357}
@@ -359,8 +360,7 @@ EXPORT_SYMBOL_GPL(__inet_hash_nolisten);
359static void __inet_hash(struct sock *sk) 360static void __inet_hash(struct sock *sk)
360{ 361{
361 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; 362 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
362 struct hlist_head *list; 363 struct inet_listen_hashbucket *ilb;
363 rwlock_t *lock;
364 364
365 if (sk->sk_state != TCP_LISTEN) { 365 if (sk->sk_state != TCP_LISTEN) {
366 __inet_hash_nolisten(sk); 366 __inet_hash_nolisten(sk);
@@ -368,14 +368,12 @@ static void __inet_hash(struct sock *sk)
368 } 368 }
369 369
370 WARN_ON(!sk_unhashed(sk)); 370 WARN_ON(!sk_unhashed(sk));
371 list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; 371 ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
372 lock = &hashinfo->lhash_lock;
373 372
374 inet_listen_wlock(hashinfo); 373 spin_lock(&ilb->lock);
375 __sk_add_node(sk, list); 374 __sk_add_node(sk, &ilb->head);
376 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 375 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
377 write_unlock(lock); 376 spin_unlock(&ilb->lock);
378 wake_up(&hashinfo->lhash_wait);
379} 377}
380 378
381void inet_hash(struct sock *sk) 379void inet_hash(struct sock *sk)
@@ -390,27 +388,27 @@ EXPORT_SYMBOL_GPL(inet_hash);
390 388
391void inet_unhash(struct sock *sk) 389void inet_unhash(struct sock *sk)
392{ 390{
393 rwlock_t *lock;
394 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; 391 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
395 392
396 if (sk_unhashed(sk)) 393 if (sk_unhashed(sk))
397 goto out; 394 return;
398 395
399 if (sk->sk_state == TCP_LISTEN) { 396 if (sk->sk_state == TCP_LISTEN) {
400 local_bh_disable(); 397 struct inet_listen_hashbucket *ilb;
401 inet_listen_wlock(hashinfo); 398
402 lock = &hashinfo->lhash_lock; 399 ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
400 spin_lock_bh(&ilb->lock);
401 if (__sk_del_node_init(sk))
402 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
403 spin_unlock_bh(&ilb->lock);
403 } else { 404 } else {
404 lock = inet_ehash_lockp(hashinfo, sk->sk_hash); 405 rwlock_t *lock = inet_ehash_lockp(hashinfo, sk->sk_hash);
406
405 write_lock_bh(lock); 407 write_lock_bh(lock);
408 if (__sk_nulls_del_node_init_rcu(sk))
409 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
410 write_unlock_bh(lock);
406 } 411 }
407
408 if (__sk_del_node_init(sk))
409 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
410 write_unlock_bh(lock);
411out:
412 if (sk->sk_state == TCP_LISTEN)
413 wake_up(&hashinfo->lhash_wait);
414} 412}
415EXPORT_SYMBOL_GPL(inet_unhash); 413EXPORT_SYMBOL_GPL(inet_unhash);
416 414
@@ -449,7 +447,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
449 * unique enough. 447 * unique enough.
450 */ 448 */
451 inet_bind_bucket_for_each(tb, node, &head->chain) { 449 inet_bind_bucket_for_each(tb, node, &head->chain) {
452 if (tb->ib_net == net && tb->port == port) { 450 if (ib_net(tb) == net && tb->port == port) {
453 WARN_ON(hlist_empty(&tb->owners)); 451 WARN_ON(hlist_empty(&tb->owners));
454 if (tb->fastreuse >= 0) 452 if (tb->fastreuse >= 0)
455 goto next_port; 453 goto next_port;
@@ -524,3 +522,13 @@ int inet_hash_connect(struct inet_timewait_death_row *death_row,
524} 522}
525 523
526EXPORT_SYMBOL_GPL(inet_hash_connect); 524EXPORT_SYMBOL_GPL(inet_hash_connect);
525
526void inet_hashinfo_init(struct inet_hashinfo *h)
527{
528 int i;
529
530 for (i = 0; i < INET_LHTABLE_SIZE; i++)
531 spin_lock_init(&h->listening_hash[i].lock);
532}
533
534EXPORT_SYMBOL_GPL(inet_hashinfo_init);
diff --git a/net/ipv4/inet_lro.c b/net/ipv4/inet_lro.c
index cfd034a2b96e..6a667dae315e 100644
--- a/net/ipv4/inet_lro.c
+++ b/net/ipv4/inet_lro.c
@@ -120,7 +120,7 @@ static void lro_update_tcp_ip_header(struct net_lro_desc *lro_desc)
120 iph->check = ip_fast_csum((u8 *)lro_desc->iph, iph->ihl); 120 iph->check = ip_fast_csum((u8 *)lro_desc->iph, iph->ihl);
121 121
122 tcph->check = 0; 122 tcph->check = 0;
123 tcp_hdr_csum = csum_partial((u8 *)tcph, TCP_HDR_LEN(tcph), 0); 123 tcp_hdr_csum = csum_partial(tcph, TCP_HDR_LEN(tcph), 0);
124 lro_desc->data_csum = csum_add(lro_desc->data_csum, tcp_hdr_csum); 124 lro_desc->data_csum = csum_add(lro_desc->data_csum, tcp_hdr_csum);
125 tcph->check = csum_tcpudp_magic(iph->saddr, iph->daddr, 125 tcph->check = csum_tcpudp_magic(iph->saddr, iph->daddr,
126 lro_desc->ip_tot_len - 126 lro_desc->ip_tot_len -
@@ -135,7 +135,7 @@ static __wsum lro_tcp_data_csum(struct iphdr *iph, struct tcphdr *tcph, int len)
135 __wsum tcp_ps_hdr_csum; 135 __wsum tcp_ps_hdr_csum;
136 136
137 tcp_csum = ~csum_unfold(tcph->check); 137 tcp_csum = ~csum_unfold(tcph->check);
138 tcp_hdr_csum = csum_partial((u8 *)tcph, TCP_HDR_LEN(tcph), tcp_csum); 138 tcp_hdr_csum = csum_partial(tcph, TCP_HDR_LEN(tcph), tcp_csum);
139 139
140 tcp_ps_hdr_csum = csum_tcpudp_nofold(iph->saddr, iph->daddr, 140 tcp_ps_hdr_csum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
141 len + TCP_HDR_LEN(tcph), 141 len + TCP_HDR_LEN(tcph),
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 1c5fd38f8824..60689951ecdb 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -23,12 +23,12 @@ static void __inet_twsk_kill(struct inet_timewait_sock *tw,
23 rwlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash); 23 rwlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash);
24 24
25 write_lock(lock); 25 write_lock(lock);
26 if (hlist_unhashed(&tw->tw_node)) { 26 if (hlist_nulls_unhashed(&tw->tw_node)) {
27 write_unlock(lock); 27 write_unlock(lock);
28 return; 28 return;
29 } 29 }
30 __hlist_del(&tw->tw_node); 30 hlist_nulls_del_rcu(&tw->tw_node);
31 sk_node_init(&tw->tw_node); 31 sk_nulls_node_init(&tw->tw_node);
32 write_unlock(lock); 32 write_unlock(lock);
33 33
34 /* Disassociate with bind bucket. */ 34 /* Disassociate with bind bucket. */
@@ -92,13 +92,17 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
92 92
93 write_lock(lock); 93 write_lock(lock);
94 94
95 /* Step 2: Remove SK from established hash. */ 95 /*
96 if (__sk_del_node_init(sk)) 96 * Step 2: Hash TW into TIMEWAIT chain.
97 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); 97 * Should be done before removing sk from established chain
98 98 * because readers are lockless and search established first.
99 /* Step 3: Hash TW into TIMEWAIT chain. */ 99 */
100 inet_twsk_add_node(tw, &ehead->twchain);
101 atomic_inc(&tw->tw_refcnt); 100 atomic_inc(&tw->tw_refcnt);
101 inet_twsk_add_node_rcu(tw, &ehead->twchain);
102
103 /* Step 3: Remove SK from established hash. */
104 if (__sk_nulls_del_node_init_rcu(sk))
105 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
102 106
103 write_unlock(lock); 107 write_unlock(lock);
104} 108}
@@ -416,7 +420,7 @@ void inet_twsk_purge(struct net *net, struct inet_hashinfo *hashinfo,
416{ 420{
417 struct inet_timewait_sock *tw; 421 struct inet_timewait_sock *tw;
418 struct sock *sk; 422 struct sock *sk;
419 struct hlist_node *node; 423 struct hlist_nulls_node *node;
420 int h; 424 int h;
421 425
422 local_bh_disable(); 426 local_bh_disable();
@@ -426,7 +430,7 @@ void inet_twsk_purge(struct net *net, struct inet_hashinfo *hashinfo,
426 rwlock_t *lock = inet_ehash_lockp(hashinfo, h); 430 rwlock_t *lock = inet_ehash_lockp(hashinfo, h);
427restart: 431restart:
428 write_lock(lock); 432 write_lock(lock);
429 sk_for_each(sk, node, &head->twchain) { 433 sk_nulls_for_each(sk, node, &head->twchain) {
430 434
431 tw = inet_twsk(sk); 435 tw = inet_twsk(sk);
432 if (!net_eq(twsk_net(tw), net) || 436 if (!net_eq(twsk_net(tw), net) ||
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index a456ceeac3f2..b1fbe18feb5a 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -144,7 +144,7 @@ static void unlink_from_unused(struct inet_peer *p)
144 * _stack is known to be NULL or not at compile time, 144 * _stack is known to be NULL or not at compile time,
145 * so compiler will optimize the if (_stack) tests. 145 * so compiler will optimize the if (_stack) tests.
146 */ 146 */
147#define lookup(_daddr,_stack) \ 147#define lookup(_daddr, _stack) \
148({ \ 148({ \
149 struct inet_peer *u, **v; \ 149 struct inet_peer *u, **v; \
150 if (_stack != NULL) { \ 150 if (_stack != NULL) { \
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index 450016b89a18..df3fe50bbf0d 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -106,7 +106,7 @@ int ip_forward(struct sk_buff *skb)
106 * We now generate an ICMP HOST REDIRECT giving the route 106 * We now generate an ICMP HOST REDIRECT giving the route
107 * we calculated. 107 * we calculated.
108 */ 108 */
109 if (rt->rt_flags&RTCF_DOREDIRECT && !opt->srr && !skb->sp) 109 if (rt->rt_flags&RTCF_DOREDIRECT && !opt->srr && !skb_sec_path(skb))
110 ip_rt_send_redirect(skb); 110 ip_rt_send_redirect(skb);
111 111
112 skb->priority = rt_tos2priority(iph->tos); 112 skb->priority = rt_tos2priority(iph->tos);
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index e4f81f54befe..6659ac000eeb 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -56,7 +56,7 @@ struct ipfrag_skb_cb
56 int offset; 56 int offset;
57}; 57};
58 58
59#define FRAG_CB(skb) ((struct ipfrag_skb_cb*)((skb)->cb)) 59#define FRAG_CB(skb) ((struct ipfrag_skb_cb *)((skb)->cb))
60 60
61/* Describe an entry in the "incomplete datagrams" queue. */ 61/* Describe an entry in the "incomplete datagrams" queue. */
62struct ipq { 62struct ipq {
@@ -559,9 +559,8 @@ out_nomem:
559 goto out_fail; 559 goto out_fail;
560out_oversize: 560out_oversize:
561 if (net_ratelimit()) 561 if (net_ratelimit())
562 printk(KERN_INFO 562 printk(KERN_INFO "Oversized IP packet from %pI4.\n",
563 "Oversized IP packet from " NIPQUAD_FMT ".\n", 563 &qp->saddr);
564 NIPQUAD(qp->saddr));
565out_fail: 564out_fail:
566 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_REASMFAILS); 565 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_REASMFAILS);
567 return err; 566 return err;
@@ -608,7 +607,7 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = {
608 .data = &init_net.ipv4.frags.high_thresh, 607 .data = &init_net.ipv4.frags.high_thresh,
609 .maxlen = sizeof(int), 608 .maxlen = sizeof(int),
610 .mode = 0644, 609 .mode = 0644,
611 .proc_handler = &proc_dointvec 610 .proc_handler = proc_dointvec
612 }, 611 },
613 { 612 {
614 .ctl_name = NET_IPV4_IPFRAG_LOW_THRESH, 613 .ctl_name = NET_IPV4_IPFRAG_LOW_THRESH,
@@ -616,7 +615,7 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = {
616 .data = &init_net.ipv4.frags.low_thresh, 615 .data = &init_net.ipv4.frags.low_thresh,
617 .maxlen = sizeof(int), 616 .maxlen = sizeof(int),
618 .mode = 0644, 617 .mode = 0644,
619 .proc_handler = &proc_dointvec 618 .proc_handler = proc_dointvec
620 }, 619 },
621 { 620 {
622 .ctl_name = NET_IPV4_IPFRAG_TIME, 621 .ctl_name = NET_IPV4_IPFRAG_TIME,
@@ -624,8 +623,8 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = {
624 .data = &init_net.ipv4.frags.timeout, 623 .data = &init_net.ipv4.frags.timeout,
625 .maxlen = sizeof(int), 624 .maxlen = sizeof(int),
626 .mode = 0644, 625 .mode = 0644,
627 .proc_handler = &proc_dointvec_jiffies, 626 .proc_handler = proc_dointvec_jiffies,
628 .strategy = &sysctl_jiffies 627 .strategy = sysctl_jiffies
629 }, 628 },
630 { } 629 { }
631}; 630};
@@ -637,15 +636,15 @@ static struct ctl_table ip4_frags_ctl_table[] = {
637 .data = &ip4_frags.secret_interval, 636 .data = &ip4_frags.secret_interval,
638 .maxlen = sizeof(int), 637 .maxlen = sizeof(int),
639 .mode = 0644, 638 .mode = 0644,
640 .proc_handler = &proc_dointvec_jiffies, 639 .proc_handler = proc_dointvec_jiffies,
641 .strategy = &sysctl_jiffies 640 .strategy = sysctl_jiffies
642 }, 641 },
643 { 642 {
644 .procname = "ipfrag_max_dist", 643 .procname = "ipfrag_max_dist",
645 .data = &sysctl_ipfrag_max_dist, 644 .data = &sysctl_ipfrag_max_dist,
646 .maxlen = sizeof(int), 645 .maxlen = sizeof(int),
647 .mode = 0644, 646 .mode = 0644,
648 .proc_handler = &proc_dointvec_minmax, 647 .proc_handler = proc_dointvec_minmax,
649 .extra1 = &zero 648 .extra1 = &zero
650 }, 649 },
651 { } 650 { }
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 85c487b8572b..191ef7588134 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -371,7 +371,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
371 by themself??? 371 by themself???
372 */ 372 */
373 373
374 struct iphdr *iph = (struct iphdr*)skb->data; 374 struct iphdr *iph = (struct iphdr *)skb->data;
375 __be16 *p = (__be16*)(skb->data+(iph->ihl<<2)); 375 __be16 *p = (__be16*)(skb->data+(iph->ihl<<2));
376 int grehlen = (iph->ihl<<2) + 4; 376 int grehlen = (iph->ihl<<2) + 4;
377 const int type = icmp_hdr(skb)->type; 377 const int type = icmp_hdr(skb)->type;
@@ -632,7 +632,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
632 632
633 if (dev->header_ops && dev->type == ARPHRD_IPGRE) { 633 if (dev->header_ops && dev->type == ARPHRD_IPGRE) {
634 gre_hlen = 0; 634 gre_hlen = 0;
635 tiph = (struct iphdr*)skb->data; 635 tiph = (struct iphdr *)skb->data;
636 } else { 636 } else {
637 gre_hlen = tunnel->hlen; 637 gre_hlen = tunnel->hlen;
638 tiph = &tunnel->parms.iph; 638 tiph = &tunnel->parms.iph;
@@ -660,7 +660,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
660 if (neigh == NULL) 660 if (neigh == NULL)
661 goto tx_error; 661 goto tx_error;
662 662
663 addr6 = (struct in6_addr*)&neigh->primary_key; 663 addr6 = (struct in6_addr *)&neigh->primary_key;
664 addr_type = ipv6_addr_type(addr6); 664 addr_type = ipv6_addr_type(addr6);
665 665
666 if (addr_type == IPV6_ADDR_ANY) { 666 if (addr_type == IPV6_ADDR_ANY) {
@@ -726,7 +726,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
726 } 726 }
727#ifdef CONFIG_IPV6 727#ifdef CONFIG_IPV6
728 else if (skb->protocol == htons(ETH_P_IPV6)) { 728 else if (skb->protocol == htons(ETH_P_IPV6)) {
729 struct rt6_info *rt6 = (struct rt6_info*)skb->dst; 729 struct rt6_info *rt6 = (struct rt6_info *)skb->dst;
730 730
731 if (rt6 && mtu < dst_mtu(skb->dst) && mtu >= IPV6_MIN_MTU) { 731 if (rt6 && mtu < dst_mtu(skb->dst) && mtu >= IPV6_MIN_MTU) {
732 if ((tunnel->parms.iph.daddr && 732 if ((tunnel->parms.iph.daddr &&
@@ -800,7 +800,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
800 iph->ttl = old_iph->ttl; 800 iph->ttl = old_iph->ttl;
801#ifdef CONFIG_IPV6 801#ifdef CONFIG_IPV6
802 else if (skb->protocol == htons(ETH_P_IPV6)) 802 else if (skb->protocol == htons(ETH_P_IPV6))
803 iph->ttl = ((struct ipv6hdr*)old_iph)->hop_limit; 803 iph->ttl = ((struct ipv6hdr *)old_iph)->hop_limit;
804#endif 804#endif
805 else 805 else
806 iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT); 806 iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT);
@@ -962,7 +962,7 @@ ipgre_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
962 break; 962 break;
963 } 963 }
964 } else { 964 } else {
965 unsigned nflags=0; 965 unsigned nflags = 0;
966 966
967 t = netdev_priv(dev); 967 t = netdev_priv(dev);
968 968
@@ -1104,7 +1104,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
1104 1104
1105static int ipgre_header_parse(const struct sk_buff *skb, unsigned char *haddr) 1105static int ipgre_header_parse(const struct sk_buff *skb, unsigned char *haddr)
1106{ 1106{
1107 struct iphdr *iph = (struct iphdr*) skb_mac_header(skb); 1107 struct iphdr *iph = (struct iphdr *) skb_mac_header(skb);
1108 memcpy(haddr, &iph->saddr, 4); 1108 memcpy(haddr, &iph->saddr, 4);
1109 return 4; 1109 return 4;
1110} 1110}
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index cfb38ac9d698..1a58a6fa1dc0 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -302,10 +302,8 @@ static inline int ip_rcv_options(struct sk_buff *skb)
302 if (!IN_DEV_SOURCE_ROUTE(in_dev)) { 302 if (!IN_DEV_SOURCE_ROUTE(in_dev)) {
303 if (IN_DEV_LOG_MARTIANS(in_dev) && 303 if (IN_DEV_LOG_MARTIANS(in_dev) &&
304 net_ratelimit()) 304 net_ratelimit())
305 printk(KERN_INFO "source route option " 305 printk(KERN_INFO "source route option %pI4 -> %pI4\n",
306 NIPQUAD_FMT " -> " NIPQUAD_FMT "\n", 306 &iph->saddr, &iph->daddr);
307 NIPQUAD(iph->saddr),
308 NIPQUAD(iph->daddr));
309 in_dev_put(in_dev); 307 in_dev_put(in_dev);
310 goto drop; 308 goto drop;
311 } 309 }
@@ -350,9 +348,9 @@ static int ip_rcv_finish(struct sk_buff *skb)
350 struct ip_rt_acct *st = per_cpu_ptr(ip_rt_acct, smp_processor_id()); 348 struct ip_rt_acct *st = per_cpu_ptr(ip_rt_acct, smp_processor_id());
351 u32 idx = skb->dst->tclassid; 349 u32 idx = skb->dst->tclassid;
352 st[idx&0xFF].o_packets++; 350 st[idx&0xFF].o_packets++;
353 st[idx&0xFF].o_bytes+=skb->len; 351 st[idx&0xFF].o_bytes += skb->len;
354 st[(idx>>16)&0xFF].i_packets++; 352 st[(idx>>16)&0xFF].i_packets++;
355 st[(idx>>16)&0xFF].i_bytes+=skb->len; 353 st[(idx>>16)&0xFF].i_bytes += skb->len;
356 } 354 }
357#endif 355#endif
358 356
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index d2a8f8bb78a6..46d7be233eac 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -430,7 +430,7 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
430 * single device frame, and queue such a frame for sending. 430 * single device frame, and queue such a frame for sending.
431 */ 431 */
432 432
433int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) 433int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
434{ 434{
435 struct iphdr *iph; 435 struct iphdr *iph;
436 int raw = 0; 436 int raw = 0;
@@ -720,7 +720,7 @@ static inline int ip_ufo_append_data(struct sock *sk,
720 int getfrag(void *from, char *to, int offset, int len, 720 int getfrag(void *from, char *to, int offset, int len,
721 int odd, struct sk_buff *skb), 721 int odd, struct sk_buff *skb),
722 void *from, int length, int hh_len, int fragheaderlen, 722 void *from, int length, int hh_len, int fragheaderlen,
723 int transhdrlen, int mtu,unsigned int flags) 723 int transhdrlen, int mtu, unsigned int flags)
724{ 724{
725 struct sk_buff *skb; 725 struct sk_buff *skb;
726 int err; 726 int err;
@@ -741,7 +741,7 @@ static inline int ip_ufo_append_data(struct sock *sk,
741 skb_reserve(skb, hh_len); 741 skb_reserve(skb, hh_len);
742 742
743 /* create space for UDP/IP header */ 743 /* create space for UDP/IP header */
744 skb_put(skb,fragheaderlen + transhdrlen); 744 skb_put(skb, fragheaderlen + transhdrlen);
745 745
746 /* initialize network header pointer */ 746 /* initialize network header pointer */
747 skb_reset_network_header(skb); 747 skb_reset_network_header(skb);
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 465abf0a9869..43c05854d752 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -48,6 +48,7 @@
48#define IP_CMSG_RECVOPTS 8 48#define IP_CMSG_RECVOPTS 8
49#define IP_CMSG_RETOPTS 16 49#define IP_CMSG_RETOPTS 16
50#define IP_CMSG_PASSSEC 32 50#define IP_CMSG_PASSSEC 32
51#define IP_CMSG_ORIGDSTADDR 64
51 52
52/* 53/*
53 * SOL_IP control messages. 54 * SOL_IP control messages.
@@ -94,7 +95,7 @@ static void ip_cmsg_recv_opts(struct msghdr *msg, struct sk_buff *skb)
94static void ip_cmsg_recv_retopts(struct msghdr *msg, struct sk_buff *skb) 95static void ip_cmsg_recv_retopts(struct msghdr *msg, struct sk_buff *skb)
95{ 96{
96 unsigned char optbuf[sizeof(struct ip_options) + 40]; 97 unsigned char optbuf[sizeof(struct ip_options) + 40];
97 struct ip_options * opt = (struct ip_options*)optbuf; 98 struct ip_options * opt = (struct ip_options *)optbuf;
98 99
99 if (IPCB(skb)->opt.optlen == 0) 100 if (IPCB(skb)->opt.optlen == 0)
100 return; 101 return;
@@ -126,6 +127,27 @@ static void ip_cmsg_recv_security(struct msghdr *msg, struct sk_buff *skb)
126 security_release_secctx(secdata, seclen); 127 security_release_secctx(secdata, seclen);
127} 128}
128 129
130static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb)
131{
132 struct sockaddr_in sin;
133 struct iphdr *iph = ip_hdr(skb);
134 __be16 *ports = (__be16 *)skb_transport_header(skb);
135
136 if (skb_transport_offset(skb) + 4 > skb->len)
137 return;
138
139 /* All current transport protocols have the port numbers in the
140 * first four bytes of the transport header and this function is
141 * written with this assumption in mind.
142 */
143
144 sin.sin_family = AF_INET;
145 sin.sin_addr.s_addr = iph->daddr;
146 sin.sin_port = ports[1];
147 memset(sin.sin_zero, 0, sizeof(sin.sin_zero));
148
149 put_cmsg(msg, SOL_IP, IP_ORIGDSTADDR, sizeof(sin), &sin);
150}
129 151
130void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb) 152void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb)
131{ 153{
@@ -160,6 +182,12 @@ void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb)
160 182
161 if (flags & 1) 183 if (flags & 1)
162 ip_cmsg_recv_security(msg, skb); 184 ip_cmsg_recv_security(msg, skb);
185
186 if ((flags>>=1) == 0)
187 return;
188 if (flags & 1)
189 ip_cmsg_recv_dstaddr(msg, skb);
190
163} 191}
164 192
165int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc) 193int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc)
@@ -411,7 +439,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
411 int optname, char __user *optval, int optlen) 439 int optname, char __user *optval, int optlen)
412{ 440{
413 struct inet_sock *inet = inet_sk(sk); 441 struct inet_sock *inet = inet_sk(sk);
414 int val=0,err; 442 int val = 0, err;
415 443
416 if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) | 444 if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) |
417 (1<<IP_RECVOPTS) | (1<<IP_RECVTOS) | 445 (1<<IP_RECVOPTS) | (1<<IP_RECVTOS) |
@@ -421,7 +449,8 @@ static int do_ip_setsockopt(struct sock *sk, int level,
421 (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | 449 (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) |
422 (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT))) || 450 (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT))) ||
423 optname == IP_MULTICAST_TTL || 451 optname == IP_MULTICAST_TTL ||
424 optname == IP_MULTICAST_LOOP) { 452 optname == IP_MULTICAST_LOOP ||
453 optname == IP_RECVORIGDSTADDR) {
425 if (optlen >= sizeof(int)) { 454 if (optlen >= sizeof(int)) {
426 if (get_user(val, (int __user *) optval)) 455 if (get_user(val, (int __user *) optval))
427 return -EFAULT; 456 return -EFAULT;
@@ -437,7 +466,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
437 /* If optlen==0, it is equivalent to val == 0 */ 466 /* If optlen==0, it is equivalent to val == 0 */
438 467
439 if (ip_mroute_opt(optname)) 468 if (ip_mroute_opt(optname))
440 return ip_mroute_setsockopt(sk,optname,optval,optlen); 469 return ip_mroute_setsockopt(sk, optname, optval, optlen);
441 470
442 err = 0; 471 err = 0;
443 lock_sock(sk); 472 lock_sock(sk);
@@ -509,6 +538,12 @@ static int do_ip_setsockopt(struct sock *sk, int level,
509 else 538 else
510 inet->cmsg_flags &= ~IP_CMSG_PASSSEC; 539 inet->cmsg_flags &= ~IP_CMSG_PASSSEC;
511 break; 540 break;
541 case IP_RECVORIGDSTADDR:
542 if (val)
543 inet->cmsg_flags |= IP_CMSG_ORIGDSTADDR;
544 else
545 inet->cmsg_flags &= ~IP_CMSG_ORIGDSTADDR;
546 break;
512 case IP_TOS: /* This sets both TOS and Precedence */ 547 case IP_TOS: /* This sets both TOS and Precedence */
513 if (sk->sk_type == SOCK_STREAM) { 548 if (sk->sk_type == SOCK_STREAM) {
514 val &= ~3; 549 val &= ~3;
@@ -549,7 +584,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
549 goto e_inval; 584 goto e_inval;
550 if (optlen<1) 585 if (optlen<1)
551 goto e_inval; 586 goto e_inval;
552 if (val==-1) 587 if (val == -1)
553 val = 1; 588 val = 1;
554 if (val < 0 || val > 255) 589 if (val < 0 || val > 255)
555 goto e_inval; 590 goto e_inval;
@@ -573,12 +608,12 @@ static int do_ip_setsockopt(struct sock *sk, int level,
573 608
574 err = -EFAULT; 609 err = -EFAULT;
575 if (optlen >= sizeof(struct ip_mreqn)) { 610 if (optlen >= sizeof(struct ip_mreqn)) {
576 if (copy_from_user(&mreq,optval,sizeof(mreq))) 611 if (copy_from_user(&mreq, optval, sizeof(mreq)))
577 break; 612 break;
578 } else { 613 } else {
579 memset(&mreq, 0, sizeof(mreq)); 614 memset(&mreq, 0, sizeof(mreq));
580 if (optlen >= sizeof(struct in_addr) && 615 if (optlen >= sizeof(struct in_addr) &&
581 copy_from_user(&mreq.imr_address,optval,sizeof(struct in_addr))) 616 copy_from_user(&mreq.imr_address, optval, sizeof(struct in_addr)))
582 break; 617 break;
583 } 618 }
584 619
@@ -626,11 +661,11 @@ static int do_ip_setsockopt(struct sock *sk, int level,
626 goto e_inval; 661 goto e_inval;
627 err = -EFAULT; 662 err = -EFAULT;
628 if (optlen >= sizeof(struct ip_mreqn)) { 663 if (optlen >= sizeof(struct ip_mreqn)) {
629 if (copy_from_user(&mreq,optval,sizeof(mreq))) 664 if (copy_from_user(&mreq, optval, sizeof(mreq)))
630 break; 665 break;
631 } else { 666 } else {
632 memset(&mreq, 0, sizeof(mreq)); 667 memset(&mreq, 0, sizeof(mreq));
633 if (copy_from_user(&mreq,optval,sizeof(struct ip_mreq))) 668 if (copy_from_user(&mreq, optval, sizeof(struct ip_mreq)))
634 break; 669 break;
635 } 670 }
636 671
@@ -808,7 +843,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
808 err = -ENOBUFS; 843 err = -ENOBUFS;
809 break; 844 break;
810 } 845 }
811 gsf = kmalloc(optlen,GFP_KERNEL); 846 gsf = kmalloc(optlen, GFP_KERNEL);
812 if (!gsf) { 847 if (!gsf) {
813 err = -ENOBUFS; 848 err = -ENOBUFS;
814 break; 849 break;
@@ -828,7 +863,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
828 goto mc_msf_out; 863 goto mc_msf_out;
829 } 864 }
830 msize = IP_MSFILTER_SIZE(gsf->gf_numsrc); 865 msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
831 msf = kmalloc(msize,GFP_KERNEL); 866 msf = kmalloc(msize, GFP_KERNEL);
832 if (!msf) { 867 if (!msf) {
833 err = -ENOBUFS; 868 err = -ENOBUFS;
834 goto mc_msf_out; 869 goto mc_msf_out;
@@ -971,9 +1006,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
971 return -EOPNOTSUPP; 1006 return -EOPNOTSUPP;
972 1007
973 if (ip_mroute_opt(optname)) 1008 if (ip_mroute_opt(optname))
974 return ip_mroute_getsockopt(sk,optname,optval,optlen); 1009 return ip_mroute_getsockopt(sk, optname, optval, optlen);
975 1010
976 if (get_user(len,optlen)) 1011 if (get_user(len, optlen))
977 return -EFAULT; 1012 return -EFAULT;
978 if (len < 0) 1013 if (len < 0)
979 return -EINVAL; 1014 return -EINVAL;
@@ -984,7 +1019,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
984 case IP_OPTIONS: 1019 case IP_OPTIONS:
985 { 1020 {
986 unsigned char optbuf[sizeof(struct ip_options)+40]; 1021 unsigned char optbuf[sizeof(struct ip_options)+40];
987 struct ip_options * opt = (struct ip_options*)optbuf; 1022 struct ip_options * opt = (struct ip_options *)optbuf;
988 opt->optlen = 0; 1023 opt->optlen = 0;
989 if (inet->opt) 1024 if (inet->opt)
990 memcpy(optbuf, inet->opt, 1025 memcpy(optbuf, inet->opt,
@@ -1022,6 +1057,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
1022 case IP_PASSSEC: 1057 case IP_PASSSEC:
1023 val = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0; 1058 val = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0;
1024 break; 1059 break;
1060 case IP_RECVORIGDSTADDR:
1061 val = (inet->cmsg_flags & IP_CMSG_ORIGDSTADDR) != 0;
1062 break;
1025 case IP_TOS: 1063 case IP_TOS:
1026 val = inet->tos; 1064 val = inet->tos;
1027 break; 1065 break;
@@ -1154,13 +1192,13 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
1154 len = 1; 1192 len = 1;
1155 if (put_user(len, optlen)) 1193 if (put_user(len, optlen))
1156 return -EFAULT; 1194 return -EFAULT;
1157 if (copy_to_user(optval,&ucval,1)) 1195 if (copy_to_user(optval, &ucval, 1))
1158 return -EFAULT; 1196 return -EFAULT;
1159 } else { 1197 } else {
1160 len = min_t(unsigned int, sizeof(int), len); 1198 len = min_t(unsigned int, sizeof(int), len);
1161 if (put_user(len, optlen)) 1199 if (put_user(len, optlen))
1162 return -EFAULT; 1200 return -EFAULT;
1163 if (copy_to_user(optval,&val,len)) 1201 if (copy_to_user(optval, &val, len))
1164 return -EFAULT; 1202 return -EFAULT;
1165 } 1203 }
1166 return 0; 1204 return 0;
@@ -1178,7 +1216,7 @@ int ip_getsockopt(struct sock *sk, int level,
1178 !ip_mroute_opt(optname)) { 1216 !ip_mroute_opt(optname)) {
1179 int len; 1217 int len;
1180 1218
1181 if (get_user(len,optlen)) 1219 if (get_user(len, optlen))
1182 return -EFAULT; 1220 return -EFAULT;
1183 1221
1184 lock_sock(sk); 1222 lock_sock(sk);
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 38ccb6dfb02e..ec8264ae45c2 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -39,8 +39,8 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
39 spi, IPPROTO_COMP, AF_INET); 39 spi, IPPROTO_COMP, AF_INET);
40 if (!x) 40 if (!x)
41 return; 41 return;
42 NETDEBUG(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/" NIPQUAD_FMT "\n", 42 NETDEBUG(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%pI4\n",
43 spi, NIPQUAD(iph->daddr)); 43 spi, &iph->daddr);
44 xfrm_state_put(x); 44 xfrm_state_put(x);
45} 45}
46 46
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 42065fff46c4..42a0f3dd3fd6 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -374,7 +374,7 @@ static int __init ic_defaults(void)
374 */ 374 */
375 375
376 if (!ic_host_name_set) 376 if (!ic_host_name_set)
377 sprintf(init_utsname()->nodename, NIPQUAD_FMT, NIPQUAD(ic_myaddr)); 377 sprintf(init_utsname()->nodename, "%pI4", &ic_myaddr);
378 378
379 if (root_server_addr == NONE) 379 if (root_server_addr == NONE)
380 root_server_addr = ic_servaddr; 380 root_server_addr = ic_servaddr;
@@ -387,11 +387,11 @@ static int __init ic_defaults(void)
387 else if (IN_CLASSC(ntohl(ic_myaddr))) 387 else if (IN_CLASSC(ntohl(ic_myaddr)))
388 ic_netmask = htonl(IN_CLASSC_NET); 388 ic_netmask = htonl(IN_CLASSC_NET);
389 else { 389 else {
390 printk(KERN_ERR "IP-Config: Unable to guess netmask for address " NIPQUAD_FMT "\n", 390 printk(KERN_ERR "IP-Config: Unable to guess netmask for address %pI4\n",
391 NIPQUAD(ic_myaddr)); 391 &ic_myaddr);
392 return -1; 392 return -1;
393 } 393 }
394 printk("IP-Config: Guessing netmask " NIPQUAD_FMT "\n", NIPQUAD(ic_netmask)); 394 printk("IP-Config: Guessing netmask %pI4\n", &ic_netmask);
395 } 395 }
396 396
397 return 0; 397 return 0;
@@ -979,10 +979,8 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
979 ic_myaddr = b->your_ip; 979 ic_myaddr = b->your_ip;
980 ic_servaddr = server_id; 980 ic_servaddr = server_id;
981#ifdef IPCONFIG_DEBUG 981#ifdef IPCONFIG_DEBUG
982 printk("DHCP: Offered address " NIPQUAD_FMT, 982 printk("DHCP: Offered address %pI4 by server %pI4\n",
983 NIPQUAD(ic_myaddr)); 983 &ic_myaddr, &ic_servaddr);
984 printk(" by server " NIPQUAD_FMT "\n",
985 NIPQUAD(ic_servaddr));
986#endif 984#endif
987 /* The DHCP indicated server address takes 985 /* The DHCP indicated server address takes
988 * precedence over the bootp header one if 986 * precedence over the bootp header one if
@@ -1177,11 +1175,11 @@ static int __init ic_dynamic(void)
1177 return -1; 1175 return -1;
1178 } 1176 }
1179 1177
1180 printk("IP-Config: Got %s answer from " NIPQUAD_FMT ", ", 1178 printk("IP-Config: Got %s answer from %pI4, ",
1181 ((ic_got_reply & IC_RARP) ? "RARP" 1179 ((ic_got_reply & IC_RARP) ? "RARP"
1182 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"), 1180 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
1183 NIPQUAD(ic_servaddr)); 1181 &ic_servaddr);
1184 printk("my address is " NIPQUAD_FMT "\n", NIPQUAD(ic_myaddr)); 1182 printk("my address is %pI4\n", &ic_myaddr);
1185 1183
1186 return 0; 1184 return 0;
1187} 1185}
@@ -1206,14 +1204,12 @@ static int pnp_seq_show(struct seq_file *seq, void *v)
1206 "domain %s\n", ic_domain); 1204 "domain %s\n", ic_domain);
1207 for (i = 0; i < CONF_NAMESERVERS_MAX; i++) { 1205 for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
1208 if (ic_nameservers[i] != NONE) 1206 if (ic_nameservers[i] != NONE)
1209 seq_printf(seq, 1207 seq_printf(seq, "nameserver %pI4\n",
1210 "nameserver " NIPQUAD_FMT "\n", 1208 &ic_nameservers[i]);
1211 NIPQUAD(ic_nameservers[i]));
1212 } 1209 }
1213 if (ic_servaddr != NONE) 1210 if (ic_servaddr != NONE)
1214 seq_printf(seq, 1211 seq_printf(seq, "bootserver %pI4\n",
1215 "bootserver " NIPQUAD_FMT "\n", 1212 &ic_servaddr);
1216 NIPQUAD(ic_servaddr));
1217 return 0; 1213 return 0;
1218} 1214}
1219 1215
@@ -1387,13 +1383,13 @@ static int __init ip_auto_config(void)
1387 */ 1383 */
1388 printk("IP-Config: Complete:"); 1384 printk("IP-Config: Complete:");
1389 printk("\n device=%s", ic_dev->name); 1385 printk("\n device=%s", ic_dev->name);
1390 printk(", addr=" NIPQUAD_FMT, NIPQUAD(ic_myaddr)); 1386 printk(", addr=%pI4", &ic_myaddr);
1391 printk(", mask=" NIPQUAD_FMT, NIPQUAD(ic_netmask)); 1387 printk(", mask=%pI4", &ic_netmask);
1392 printk(", gw=" NIPQUAD_FMT, NIPQUAD(ic_gateway)); 1388 printk(", gw=%pI4", &ic_gateway);
1393 printk(",\n host=%s, domain=%s, nis-domain=%s", 1389 printk(",\n host=%s, domain=%s, nis-domain=%s",
1394 utsname()->nodename, ic_domain, utsname()->domainname); 1390 utsname()->nodename, ic_domain, utsname()->domainname);
1395 printk(",\n bootserver=" NIPQUAD_FMT, NIPQUAD(ic_servaddr)); 1391 printk(",\n bootserver=%pI4", &ic_servaddr);
1396 printk(", rootserver=" NIPQUAD_FMT, NIPQUAD(root_server_addr)); 1392 printk(", rootserver=%pI4", &root_server_addr);
1397 printk(", rootpath=%s", root_server_path); 1393 printk(", rootpath=%s", root_server_path);
1398 printk("\n"); 1394 printk("\n");
1399#endif /* !SILENT */ 1395#endif /* !SILENT */
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 29609d29df76..b3c3d7b0d116 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -281,7 +281,7 @@ static int ipip_err(struct sk_buff *skb, u32 info)
281 8 bytes of packet payload. It means, that precise relaying of 281 8 bytes of packet payload. It means, that precise relaying of
282 ICMP in the real Internet is absolutely infeasible. 282 ICMP in the real Internet is absolutely infeasible.
283 */ 283 */
284 struct iphdr *iph = (struct iphdr*)skb->data; 284 struct iphdr *iph = (struct iphdr *)skb->data;
285 const int type = icmp_hdr(skb)->type; 285 const int type = icmp_hdr(skb)->type;
286 const int code = icmp_hdr(skb)->code; 286 const int code = icmp_hdr(skb)->code;
287 struct ip_tunnel *t; 287 struct ip_tunnel *t;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 25924b1eb2ef..ee58bcbc99a5 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -124,8 +124,8 @@ static void ipmr_del_tunnel(struct net_device *dev, struct vifctl *v)
124 124
125 dev = __dev_get_by_name(&init_net, "tunl0"); 125 dev = __dev_get_by_name(&init_net, "tunl0");
126 if (dev) { 126 if (dev) {
127 const struct net_device_ops *ops = dev->netdev_ops;
127 struct ifreq ifr; 128 struct ifreq ifr;
128 mm_segment_t oldfs;
129 struct ip_tunnel_parm p; 129 struct ip_tunnel_parm p;
130 130
131 memset(&p, 0, sizeof(p)); 131 memset(&p, 0, sizeof(p));
@@ -137,9 +137,13 @@ static void ipmr_del_tunnel(struct net_device *dev, struct vifctl *v)
137 sprintf(p.name, "dvmrp%d", v->vifc_vifi); 137 sprintf(p.name, "dvmrp%d", v->vifc_vifi);
138 ifr.ifr_ifru.ifru_data = (__force void __user *)&p; 138 ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
139 139
140 oldfs = get_fs(); set_fs(KERNEL_DS); 140 if (ops->ndo_do_ioctl) {
141 dev->do_ioctl(dev, &ifr, SIOCDELTUNNEL); 141 mm_segment_t oldfs = get_fs();
142 set_fs(oldfs); 142
143 set_fs(KERNEL_DS);
144 ops->ndo_do_ioctl(dev, &ifr, SIOCDELTUNNEL);
145 set_fs(oldfs);
146 }
143 } 147 }
144} 148}
145 149
@@ -151,9 +155,9 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
151 dev = __dev_get_by_name(&init_net, "tunl0"); 155 dev = __dev_get_by_name(&init_net, "tunl0");
152 156
153 if (dev) { 157 if (dev) {
158 const struct net_device_ops *ops = dev->netdev_ops;
154 int err; 159 int err;
155 struct ifreq ifr; 160 struct ifreq ifr;
156 mm_segment_t oldfs;
157 struct ip_tunnel_parm p; 161 struct ip_tunnel_parm p;
158 struct in_device *in_dev; 162 struct in_device *in_dev;
159 163
@@ -166,9 +170,14 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
166 sprintf(p.name, "dvmrp%d", v->vifc_vifi); 170 sprintf(p.name, "dvmrp%d", v->vifc_vifi);
167 ifr.ifr_ifru.ifru_data = (__force void __user *)&p; 171 ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
168 172
169 oldfs = get_fs(); set_fs(KERNEL_DS); 173 if (ops->ndo_do_ioctl) {
170 err = dev->do_ioctl(dev, &ifr, SIOCADDTUNNEL); 174 mm_segment_t oldfs = get_fs();
171 set_fs(oldfs); 175
176 set_fs(KERNEL_DS);
177 err = ops->ndo_do_ioctl(dev, &ifr, SIOCADDTUNNEL);
178 set_fs(oldfs);
179 } else
180 err = -EOPNOTSUPP;
172 181
173 dev = NULL; 182 dev = NULL;
174 183
@@ -331,7 +340,7 @@ static void ipmr_destroy_unres(struct mfc_cache *c)
331 340
332 atomic_dec(&cache_resolve_queue_len); 341 atomic_dec(&cache_resolve_queue_len);
333 342
334 while ((skb=skb_dequeue(&c->mfc_un.unres.unresolved))) { 343 while ((skb = skb_dequeue(&c->mfc_un.unres.unresolved))) {
335 if (ip_hdr(skb)->version == 0) { 344 if (ip_hdr(skb)->version == 0) {
336 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr)); 345 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
337 nlh->nlmsg_type = NLMSG_ERROR; 346 nlh->nlmsg_type = NLMSG_ERROR;
@@ -477,13 +486,13 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
477 /* 486 /*
478 * Fill in the VIF structures 487 * Fill in the VIF structures
479 */ 488 */
480 v->rate_limit=vifc->vifc_rate_limit; 489 v->rate_limit = vifc->vifc_rate_limit;
481 v->local=vifc->vifc_lcl_addr.s_addr; 490 v->local = vifc->vifc_lcl_addr.s_addr;
482 v->remote=vifc->vifc_rmt_addr.s_addr; 491 v->remote = vifc->vifc_rmt_addr.s_addr;
483 v->flags=vifc->vifc_flags; 492 v->flags = vifc->vifc_flags;
484 if (!mrtsock) 493 if (!mrtsock)
485 v->flags |= VIFF_STATIC; 494 v->flags |= VIFF_STATIC;
486 v->threshold=vifc->vifc_threshold; 495 v->threshold = vifc->vifc_threshold;
487 v->bytes_in = 0; 496 v->bytes_in = 0;
488 v->bytes_out = 0; 497 v->bytes_out = 0;
489 v->pkt_in = 0; 498 v->pkt_in = 0;
@@ -494,7 +503,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
494 503
495 /* And finish update writing critical data */ 504 /* And finish update writing critical data */
496 write_lock_bh(&mrt_lock); 505 write_lock_bh(&mrt_lock);
497 v->dev=dev; 506 v->dev = dev;
498#ifdef CONFIG_IP_PIMSM 507#ifdef CONFIG_IP_PIMSM
499 if (v->flags&VIFF_REGISTER) 508 if (v->flags&VIFF_REGISTER)
500 reg_vif_num = vifi; 509 reg_vif_num = vifi;
@@ -507,7 +516,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
507 516
508static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp) 517static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp)
509{ 518{
510 int line=MFC_HASH(mcastgrp,origin); 519 int line = MFC_HASH(mcastgrp, origin);
511 struct mfc_cache *c; 520 struct mfc_cache *c;
512 521
513 for (c=mfc_cache_array[line]; c; c = c->next) { 522 for (c=mfc_cache_array[line]; c; c = c->next) {
@@ -522,8 +531,8 @@ static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp)
522 */ 531 */
523static struct mfc_cache *ipmr_cache_alloc(void) 532static struct mfc_cache *ipmr_cache_alloc(void)
524{ 533{
525 struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_KERNEL); 534 struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_KERNEL);
526 if (c==NULL) 535 if (c == NULL)
527 return NULL; 536 return NULL;
528 c->mfc_un.res.minvif = MAXVIFS; 537 c->mfc_un.res.minvif = MAXVIFS;
529 return c; 538 return c;
@@ -531,8 +540,8 @@ static struct mfc_cache *ipmr_cache_alloc(void)
531 540
532static struct mfc_cache *ipmr_cache_alloc_unres(void) 541static struct mfc_cache *ipmr_cache_alloc_unres(void)
533{ 542{
534 struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC); 543 struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC);
535 if (c==NULL) 544 if (c == NULL)
536 return NULL; 545 return NULL;
537 skb_queue_head_init(&c->mfc_un.unres.unresolved); 546 skb_queue_head_init(&c->mfc_un.unres.unresolved);
538 c->mfc_un.unres.expires = jiffies + 10*HZ; 547 c->mfc_un.unres.expires = jiffies + 10*HZ;
@@ -552,7 +561,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
552 * Play the pending entries through our router 561 * Play the pending entries through our router
553 */ 562 */
554 563
555 while ((skb=__skb_dequeue(&uc->mfc_un.unres.unresolved))) { 564 while ((skb = __skb_dequeue(&uc->mfc_un.unres.unresolved))) {
556 if (ip_hdr(skb)->version == 0) { 565 if (ip_hdr(skb)->version == 0) {
557 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr)); 566 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
558 567
@@ -637,7 +646,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
637 * Add our header 646 * Add our header
638 */ 647 */
639 648
640 igmp=(struct igmphdr *)skb_put(skb,sizeof(struct igmphdr)); 649 igmp=(struct igmphdr *)skb_put(skb, sizeof(struct igmphdr));
641 igmp->type = 650 igmp->type =
642 msg->im_msgtype = assert; 651 msg->im_msgtype = assert;
643 igmp->code = 0; 652 igmp->code = 0;
@@ -653,7 +662,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
653 /* 662 /*
654 * Deliver to mrouted 663 * Deliver to mrouted
655 */ 664 */
656 if ((ret=sock_queue_rcv_skb(mroute_socket,skb))<0) { 665 if ((ret = sock_queue_rcv_skb(mroute_socket, skb))<0) {
657 if (net_ratelimit()) 666 if (net_ratelimit())
658 printk(KERN_WARNING "mroute: pending queue full, dropping entries.\n"); 667 printk(KERN_WARNING "mroute: pending queue full, dropping entries.\n");
659 kfree_skb(skb); 668 kfree_skb(skb);
@@ -685,7 +694,7 @@ ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
685 * Create a new entry if allowable 694 * Create a new entry if allowable
686 */ 695 */
687 696
688 if (atomic_read(&cache_resolve_queue_len)>=10 || 697 if (atomic_read(&cache_resolve_queue_len) >= 10 ||
689 (c=ipmr_cache_alloc_unres())==NULL) { 698 (c=ipmr_cache_alloc_unres())==NULL) {
690 spin_unlock_bh(&mfc_unres_lock); 699 spin_unlock_bh(&mfc_unres_lock);
691 700
@@ -728,7 +737,7 @@ ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
728 kfree_skb(skb); 737 kfree_skb(skb);
729 err = -ENOBUFS; 738 err = -ENOBUFS;
730 } else { 739 } else {
731 skb_queue_tail(&c->mfc_un.unres.unresolved,skb); 740 skb_queue_tail(&c->mfc_un.unres.unresolved, skb);
732 err = 0; 741 err = 0;
733 } 742 }
734 743
@@ -745,7 +754,7 @@ static int ipmr_mfc_delete(struct mfcctl *mfc)
745 int line; 754 int line;
746 struct mfc_cache *c, **cp; 755 struct mfc_cache *c, **cp;
747 756
748 line=MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr); 757 line = MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr);
749 758
750 for (cp=&mfc_cache_array[line]; (c=*cp) != NULL; cp = &c->next) { 759 for (cp=&mfc_cache_array[line]; (c=*cp) != NULL; cp = &c->next) {
751 if (c->mfc_origin == mfc->mfcc_origin.s_addr && 760 if (c->mfc_origin == mfc->mfcc_origin.s_addr &&
@@ -766,7 +775,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
766 int line; 775 int line;
767 struct mfc_cache *uc, *c, **cp; 776 struct mfc_cache *uc, *c, **cp;
768 777
769 line=MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr); 778 line = MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr);
770 779
771 for (cp=&mfc_cache_array[line]; (c=*cp) != NULL; cp = &c->next) { 780 for (cp=&mfc_cache_array[line]; (c=*cp) != NULL; cp = &c->next) {
772 if (c->mfc_origin == mfc->mfcc_origin.s_addr && 781 if (c->mfc_origin == mfc->mfcc_origin.s_addr &&
@@ -787,13 +796,13 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
787 if (!ipv4_is_multicast(mfc->mfcc_mcastgrp.s_addr)) 796 if (!ipv4_is_multicast(mfc->mfcc_mcastgrp.s_addr))
788 return -EINVAL; 797 return -EINVAL;
789 798
790 c=ipmr_cache_alloc(); 799 c = ipmr_cache_alloc();
791 if (c==NULL) 800 if (c == NULL)
792 return -ENOMEM; 801 return -ENOMEM;
793 802
794 c->mfc_origin=mfc->mfcc_origin.s_addr; 803 c->mfc_origin = mfc->mfcc_origin.s_addr;
795 c->mfc_mcastgrp=mfc->mfcc_mcastgrp.s_addr; 804 c->mfc_mcastgrp = mfc->mfcc_mcastgrp.s_addr;
796 c->mfc_parent=mfc->mfcc_parent; 805 c->mfc_parent = mfc->mfcc_parent;
797 ipmr_update_thresholds(c, mfc->mfcc_ttls); 806 ipmr_update_thresholds(c, mfc->mfcc_ttls);
798 if (!mrtsock) 807 if (!mrtsock)
799 c->mfc_flags |= MFC_STATIC; 808 c->mfc_flags |= MFC_STATIC;
@@ -846,7 +855,7 @@ static void mroute_clean_tables(struct sock *sk)
846 /* 855 /*
847 * Wipe the cache 856 * Wipe the cache
848 */ 857 */
849 for (i=0;i<MFC_LINES;i++) { 858 for (i=0; i<MFC_LINES; i++) {
850 struct mfc_cache *c, **cp; 859 struct mfc_cache *c, **cp;
851 860
852 cp = &mfc_cache_array[i]; 861 cp = &mfc_cache_array[i];
@@ -887,7 +896,7 @@ static void mrtsock_destruct(struct sock *sk)
887 IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)--; 896 IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)--;
888 897
889 write_lock_bh(&mrt_lock); 898 write_lock_bh(&mrt_lock);
890 mroute_socket=NULL; 899 mroute_socket = NULL;
891 write_unlock_bh(&mrt_lock); 900 write_unlock_bh(&mrt_lock);
892 901
893 mroute_clean_tables(sk); 902 mroute_clean_tables(sk);
@@ -902,7 +911,7 @@ static void mrtsock_destruct(struct sock *sk)
902 * MOSPF/PIM router set up we can clean this up. 911 * MOSPF/PIM router set up we can clean this up.
903 */ 912 */
904 913
905int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int optlen) 914int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int optlen)
906{ 915{
907 int ret; 916 int ret;
908 struct vifctl vif; 917 struct vifctl vif;
@@ -918,7 +927,7 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt
918 if (sk->sk_type != SOCK_RAW || 927 if (sk->sk_type != SOCK_RAW ||
919 inet_sk(sk)->num != IPPROTO_IGMP) 928 inet_sk(sk)->num != IPPROTO_IGMP)
920 return -EOPNOTSUPP; 929 return -EOPNOTSUPP;
921 if (optlen!=sizeof(int)) 930 if (optlen != sizeof(int))
922 return -ENOPROTOOPT; 931 return -ENOPROTOOPT;
923 932
924 rtnl_lock(); 933 rtnl_lock();
@@ -930,7 +939,7 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt
930 ret = ip_ra_control(sk, 1, mrtsock_destruct); 939 ret = ip_ra_control(sk, 1, mrtsock_destruct);
931 if (ret == 0) { 940 if (ret == 0) {
932 write_lock_bh(&mrt_lock); 941 write_lock_bh(&mrt_lock);
933 mroute_socket=sk; 942 mroute_socket = sk;
934 write_unlock_bh(&mrt_lock); 943 write_unlock_bh(&mrt_lock);
935 944
936 IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)++; 945 IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)++;
@@ -938,19 +947,19 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt
938 rtnl_unlock(); 947 rtnl_unlock();
939 return ret; 948 return ret;
940 case MRT_DONE: 949 case MRT_DONE:
941 if (sk!=mroute_socket) 950 if (sk != mroute_socket)
942 return -EACCES; 951 return -EACCES;
943 return ip_ra_control(sk, 0, NULL); 952 return ip_ra_control(sk, 0, NULL);
944 case MRT_ADD_VIF: 953 case MRT_ADD_VIF:
945 case MRT_DEL_VIF: 954 case MRT_DEL_VIF:
946 if (optlen!=sizeof(vif)) 955 if (optlen != sizeof(vif))
947 return -EINVAL; 956 return -EINVAL;
948 if (copy_from_user(&vif,optval,sizeof(vif))) 957 if (copy_from_user(&vif, optval, sizeof(vif)))
949 return -EFAULT; 958 return -EFAULT;
950 if (vif.vifc_vifi >= MAXVIFS) 959 if (vif.vifc_vifi >= MAXVIFS)
951 return -ENFILE; 960 return -ENFILE;
952 rtnl_lock(); 961 rtnl_lock();
953 if (optname==MRT_ADD_VIF) { 962 if (optname == MRT_ADD_VIF) {
954 ret = vif_add(&vif, sk==mroute_socket); 963 ret = vif_add(&vif, sk==mroute_socket);
955 } else { 964 } else {
956 ret = vif_delete(vif.vifc_vifi, 0); 965 ret = vif_delete(vif.vifc_vifi, 0);
@@ -964,12 +973,12 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt
964 */ 973 */
965 case MRT_ADD_MFC: 974 case MRT_ADD_MFC:
966 case MRT_DEL_MFC: 975 case MRT_DEL_MFC:
967 if (optlen!=sizeof(mfc)) 976 if (optlen != sizeof(mfc))
968 return -EINVAL; 977 return -EINVAL;
969 if (copy_from_user(&mfc,optval, sizeof(mfc))) 978 if (copy_from_user(&mfc, optval, sizeof(mfc)))
970 return -EFAULT; 979 return -EFAULT;
971 rtnl_lock(); 980 rtnl_lock();
972 if (optname==MRT_DEL_MFC) 981 if (optname == MRT_DEL_MFC)
973 ret = ipmr_mfc_delete(&mfc); 982 ret = ipmr_mfc_delete(&mfc);
974 else 983 else
975 ret = ipmr_mfc_add(&mfc, sk==mroute_socket); 984 ret = ipmr_mfc_add(&mfc, sk==mroute_socket);
@@ -1028,12 +1037,12 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt
1028 * Getsock opt support for the multicast routing system. 1037 * Getsock opt support for the multicast routing system.
1029 */ 1038 */
1030 1039
1031int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __user *optlen) 1040int ip_mroute_getsockopt(struct sock *sk, int optname, char __user *optval, int __user *optlen)
1032{ 1041{
1033 int olr; 1042 int olr;
1034 int val; 1043 int val;
1035 1044
1036 if (optname!=MRT_VERSION && 1045 if (optname != MRT_VERSION &&
1037#ifdef CONFIG_IP_PIMSM 1046#ifdef CONFIG_IP_PIMSM
1038 optname!=MRT_PIM && 1047 optname!=MRT_PIM &&
1039#endif 1048#endif
@@ -1047,17 +1056,17 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u
1047 if (olr < 0) 1056 if (olr < 0)
1048 return -EINVAL; 1057 return -EINVAL;
1049 1058
1050 if (put_user(olr,optlen)) 1059 if (put_user(olr, optlen))
1051 return -EFAULT; 1060 return -EFAULT;
1052 if (optname==MRT_VERSION) 1061 if (optname == MRT_VERSION)
1053 val=0x0305; 1062 val = 0x0305;
1054#ifdef CONFIG_IP_PIMSM 1063#ifdef CONFIG_IP_PIMSM
1055 else if (optname==MRT_PIM) 1064 else if (optname == MRT_PIM)
1056 val=mroute_do_pim; 1065 val = mroute_do_pim;
1057#endif 1066#endif
1058 else 1067 else
1059 val=mroute_do_assert; 1068 val = mroute_do_assert;
1060 if (copy_to_user(optval,&val,olr)) 1069 if (copy_to_user(optval, &val, olr))
1061 return -EFAULT; 1070 return -EFAULT;
1062 return 0; 1071 return 0;
1063} 1072}
@@ -1075,27 +1084,27 @@ int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
1075 1084
1076 switch (cmd) { 1085 switch (cmd) {
1077 case SIOCGETVIFCNT: 1086 case SIOCGETVIFCNT:
1078 if (copy_from_user(&vr,arg,sizeof(vr))) 1087 if (copy_from_user(&vr, arg, sizeof(vr)))
1079 return -EFAULT; 1088 return -EFAULT;
1080 if (vr.vifi>=maxvif) 1089 if (vr.vifi >= maxvif)
1081 return -EINVAL; 1090 return -EINVAL;
1082 read_lock(&mrt_lock); 1091 read_lock(&mrt_lock);
1083 vif=&vif_table[vr.vifi]; 1092 vif=&vif_table[vr.vifi];
1084 if (VIF_EXISTS(vr.vifi)) { 1093 if (VIF_EXISTS(vr.vifi)) {
1085 vr.icount=vif->pkt_in; 1094 vr.icount = vif->pkt_in;
1086 vr.ocount=vif->pkt_out; 1095 vr.ocount = vif->pkt_out;
1087 vr.ibytes=vif->bytes_in; 1096 vr.ibytes = vif->bytes_in;
1088 vr.obytes=vif->bytes_out; 1097 vr.obytes = vif->bytes_out;
1089 read_unlock(&mrt_lock); 1098 read_unlock(&mrt_lock);
1090 1099
1091 if (copy_to_user(arg,&vr,sizeof(vr))) 1100 if (copy_to_user(arg, &vr, sizeof(vr)))
1092 return -EFAULT; 1101 return -EFAULT;
1093 return 0; 1102 return 0;
1094 } 1103 }
1095 read_unlock(&mrt_lock); 1104 read_unlock(&mrt_lock);
1096 return -EADDRNOTAVAIL; 1105 return -EADDRNOTAVAIL;
1097 case SIOCGETSGCNT: 1106 case SIOCGETSGCNT:
1098 if (copy_from_user(&sr,arg,sizeof(sr))) 1107 if (copy_from_user(&sr, arg, sizeof(sr)))
1099 return -EFAULT; 1108 return -EFAULT;
1100 1109
1101 read_lock(&mrt_lock); 1110 read_lock(&mrt_lock);
@@ -1106,7 +1115,7 @@ int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
1106 sr.wrong_if = c->mfc_un.res.wrong_if; 1115 sr.wrong_if = c->mfc_un.res.wrong_if;
1107 read_unlock(&mrt_lock); 1116 read_unlock(&mrt_lock);
1108 1117
1109 if (copy_to_user(arg,&sr,sizeof(sr))) 1118 if (copy_to_user(arg, &sr, sizeof(sr)))
1110 return -EFAULT; 1119 return -EFAULT;
1111 return 0; 1120 return 0;
1112 } 1121 }
@@ -1130,15 +1139,15 @@ static int ipmr_device_event(struct notifier_block *this, unsigned long event, v
1130 if (event != NETDEV_UNREGISTER) 1139 if (event != NETDEV_UNREGISTER)
1131 return NOTIFY_DONE; 1140 return NOTIFY_DONE;
1132 v=&vif_table[0]; 1141 v=&vif_table[0];
1133 for (ct=0;ct<maxvif;ct++,v++) { 1142 for (ct=0; ct<maxvif; ct++,v++) {
1134 if (v->dev==dev) 1143 if (v->dev == dev)
1135 vif_delete(ct, 1); 1144 vif_delete(ct, 1);
1136 } 1145 }
1137 return NOTIFY_DONE; 1146 return NOTIFY_DONE;
1138} 1147}
1139 1148
1140 1149
1141static struct notifier_block ip_mr_notifier={ 1150static struct notifier_block ip_mr_notifier = {
1142 .notifier_call = ipmr_device_event, 1151 .notifier_call = ipmr_device_event,
1143}; 1152};
1144 1153
@@ -1204,7 +1213,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
1204#ifdef CONFIG_IP_PIMSM 1213#ifdef CONFIG_IP_PIMSM
1205 if (vif->flags & VIFF_REGISTER) { 1214 if (vif->flags & VIFF_REGISTER) {
1206 vif->pkt_out++; 1215 vif->pkt_out++;
1207 vif->bytes_out+=skb->len; 1216 vif->bytes_out += skb->len;
1208 vif->dev->stats.tx_bytes += skb->len; 1217 vif->dev->stats.tx_bytes += skb->len;
1209 vif->dev->stats.tx_packets++; 1218 vif->dev->stats.tx_packets++;
1210 ipmr_cache_report(skb, vifi, IGMPMSG_WHOLEPKT); 1219 ipmr_cache_report(skb, vifi, IGMPMSG_WHOLEPKT);
@@ -1254,7 +1263,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
1254 } 1263 }
1255 1264
1256 vif->pkt_out++; 1265 vif->pkt_out++;
1257 vif->bytes_out+=skb->len; 1266 vif->bytes_out += skb->len;
1258 1267
1259 dst_release(skb->dst); 1268 dst_release(skb->dst);
1260 skb->dst = &rt->u.dst; 1269 skb->dst = &rt->u.dst;
@@ -1352,7 +1361,7 @@ static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local
1352 } 1361 }
1353 1362
1354 vif_table[vif].pkt_in++; 1363 vif_table[vif].pkt_in++;
1355 vif_table[vif].bytes_in+=skb->len; 1364 vif_table[vif].bytes_in += skb->len;
1356 1365
1357 /* 1366 /*
1358 * Forward the frame 1367 * Forward the frame
@@ -1364,7 +1373,7 @@ static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local
1364 if (skb2) 1373 if (skb2)
1365 ipmr_queue_xmit(skb2, cache, psend); 1374 ipmr_queue_xmit(skb2, cache, psend);
1366 } 1375 }
1367 psend=ct; 1376 psend = ct;
1368 } 1377 }
1369 } 1378 }
1370 if (psend != -1) { 1379 if (psend != -1) {
@@ -1428,7 +1437,7 @@ int ip_mr_input(struct sk_buff *skb)
1428 /* 1437 /*
1429 * No usable cache entry 1438 * No usable cache entry
1430 */ 1439 */
1431 if (cache==NULL) { 1440 if (cache == NULL) {
1432 int vif; 1441 int vif;
1433 1442
1434 if (local) { 1443 if (local) {
@@ -1602,13 +1611,13 @@ ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm)
1602 if (dev) 1611 if (dev)
1603 RTA_PUT(skb, RTA_IIF, 4, &dev->ifindex); 1612 RTA_PUT(skb, RTA_IIF, 4, &dev->ifindex);
1604 1613
1605 mp_head = (struct rtattr*)skb_put(skb, RTA_LENGTH(0)); 1614 mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0));
1606 1615
1607 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) { 1616 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
1608 if (c->mfc_un.res.ttls[ct] < 255) { 1617 if (c->mfc_un.res.ttls[ct] < 255) {
1609 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4)) 1618 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
1610 goto rtattr_failure; 1619 goto rtattr_failure;
1611 nhp = (struct rtnexthop*)skb_put(skb, RTA_ALIGN(sizeof(*nhp))); 1620 nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
1612 nhp->rtnh_flags = 0; 1621 nhp->rtnh_flags = 0;
1613 nhp->rtnh_hops = c->mfc_un.res.ttls[ct]; 1622 nhp->rtnh_hops = c->mfc_un.res.ttls[ct];
1614 nhp->rtnh_ifindex = vif_table[ct].dev->ifindex; 1623 nhp->rtnh_ifindex = vif_table[ct].dev->ifindex;
@@ -1634,7 +1643,7 @@ int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait)
1634 read_lock(&mrt_lock); 1643 read_lock(&mrt_lock);
1635 cache = ipmr_cache_find(rt->rt_src, rt->rt_dst); 1644 cache = ipmr_cache_find(rt->rt_src, rt->rt_dst);
1636 1645
1637 if (cache==NULL) { 1646 if (cache == NULL) {
1638 struct sk_buff *skb2; 1647 struct sk_buff *skb2;
1639 struct iphdr *iph; 1648 struct iphdr *iph;
1640 struct net_device *dev; 1649 struct net_device *dev;
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 8d70d29f1ccf..7ea88b61cb0d 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -142,15 +142,15 @@ static inline int arp_packet_match(const struct arphdr *arphdr,
142 ARPT_INV_TGTIP)) { 142 ARPT_INV_TGTIP)) {
143 dprintf("Source or target IP address mismatch.\n"); 143 dprintf("Source or target IP address mismatch.\n");
144 144
145 dprintf("SRC: %u.%u.%u.%u. Mask: %u.%u.%u.%u. Target: %u.%u.%u.%u.%s\n", 145 dprintf("SRC: %pI4. Mask: %pI4. Target: %pI4.%s\n",
146 NIPQUAD(src_ipaddr), 146 &src_ipaddr,
147 NIPQUAD(arpinfo->smsk.s_addr), 147 &arpinfo->smsk.s_addr,
148 NIPQUAD(arpinfo->src.s_addr), 148 &arpinfo->src.s_addr,
149 arpinfo->invflags & ARPT_INV_SRCIP ? " (INV)" : ""); 149 arpinfo->invflags & ARPT_INV_SRCIP ? " (INV)" : "");
150 dprintf("TGT: %u.%u.%u.%u Mask: %u.%u.%u.%u Target: %u.%u.%u.%u.%s\n", 150 dprintf("TGT: %pI4 Mask: %pI4 Target: %pI4.%s\n",
151 NIPQUAD(tgt_ipaddr), 151 &tgt_ipaddr,
152 NIPQUAD(arpinfo->tmsk.s_addr), 152 &arpinfo->tmsk.s_addr,
153 NIPQUAD(arpinfo->tgt.s_addr), 153 &arpinfo->tgt.s_addr,
154 arpinfo->invflags & ARPT_INV_TGTIP ? " (INV)" : ""); 154 arpinfo->invflags & ARPT_INV_TGTIP ? " (INV)" : "");
155 return 0; 155 return 0;
156 } 156 }
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 213fb27debc1..ef8b6ca068b2 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -94,15 +94,11 @@ ip_packet_match(const struct iphdr *ip,
94 IPT_INV_DSTIP)) { 94 IPT_INV_DSTIP)) {
95 dprintf("Source or dest mismatch.\n"); 95 dprintf("Source or dest mismatch.\n");
96 96
97 dprintf("SRC: %u.%u.%u.%u. Mask: %u.%u.%u.%u. Target: %u.%u.%u.%u.%s\n", 97 dprintf("SRC: %pI4. Mask: %pI4. Target: %pI4.%s\n",
98 NIPQUAD(ip->saddr), 98 &ip->saddr, &ipinfo->smsk.s_addr, &ipinfo->src.s_addr,
99 NIPQUAD(ipinfo->smsk.s_addr),
100 NIPQUAD(ipinfo->src.s_addr),
101 ipinfo->invflags & IPT_INV_SRCIP ? " (INV)" : ""); 99 ipinfo->invflags & IPT_INV_SRCIP ? " (INV)" : "");
102 dprintf("DST: %u.%u.%u.%u Mask: %u.%u.%u.%u Target: %u.%u.%u.%u.%s\n", 100 dprintf("DST: %pI4 Mask: %pI4 Target: %pI4.%s\n",
103 NIPQUAD(ip->daddr), 101 &ip->daddr, &ipinfo->dmsk.s_addr, &ipinfo->dst.s_addr,
104 NIPQUAD(ipinfo->dmsk.s_addr),
105 NIPQUAD(ipinfo->dst.s_addr),
106 ipinfo->invflags & IPT_INV_DSTIP ? " (INV)" : ""); 102 ipinfo->invflags & IPT_INV_DSTIP ? " (INV)" : "");
107 return false; 103 return false;
108 } 104 }
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 7ac1677419a9..2e4f98b85524 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -168,7 +168,7 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
168 char buffer[16]; 168 char buffer[16];
169 169
170 /* create proc dir entry */ 170 /* create proc dir entry */
171 sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip)); 171 sprintf(buffer, "%pI4", &ip);
172 c->pde = proc_create_data(buffer, S_IWUSR|S_IRUSR, 172 c->pde = proc_create_data(buffer, S_IWUSR|S_IRUSR,
173 clusterip_procdir, 173 clusterip_procdir,
174 &clusterip_proc_fops, c); 174 &clusterip_proc_fops, c);
@@ -373,7 +373,7 @@ static bool clusterip_tg_check(const struct xt_tgchk_param *par)
373 config = clusterip_config_find_get(e->ip.dst.s_addr, 1); 373 config = clusterip_config_find_get(e->ip.dst.s_addr, 1);
374 if (!config) { 374 if (!config) {
375 if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) { 375 if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) {
376 printk(KERN_WARNING "CLUSTERIP: no config found for %u.%u.%u.%u, need 'new'\n", NIPQUAD(e->ip.dst.s_addr)); 376 printk(KERN_WARNING "CLUSTERIP: no config found for %pI4, need 'new'\n", &e->ip.dst.s_addr);
377 return false; 377 return false;
378 } else { 378 } else {
379 struct net_device *dev; 379 struct net_device *dev;
@@ -478,9 +478,8 @@ static void arp_print(struct arp_payload *payload)
478 } 478 }
479 hbuffer[--k]='\0'; 479 hbuffer[--k]='\0';
480 480
481 printk("src %u.%u.%u.%u@%s, dst %u.%u.%u.%u\n", 481 printk("src %pI4@%s, dst %pI4\n",
482 NIPQUAD(payload->src_ip), hbuffer, 482 &payload->src_ip, hbuffer, &payload->dst_ip);
483 NIPQUAD(payload->dst_ip));
484} 483}
485#endif 484#endif
486 485
diff --git a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
index fc6ce04a3e35..4614a696f1b0 100644
--- a/net/ipv4/netfilter/ipt_LOG.c
+++ b/net/ipv4/netfilter/ipt_LOG.c
@@ -54,8 +54,8 @@ static void dump_packet(const struct nf_loginfo *info,
54 /* Important fields: 54 /* Important fields:
55 * TOS, len, DF/MF, fragment offset, TTL, src, dst, options. */ 55 * TOS, len, DF/MF, fragment offset, TTL, src, dst, options. */
56 /* Max length: 40 "SRC=255.255.255.255 DST=255.255.255.255 " */ 56 /* Max length: 40 "SRC=255.255.255.255 DST=255.255.255.255 " */
57 printk("SRC=%u.%u.%u.%u DST=%u.%u.%u.%u ", 57 printk("SRC=%pI4 DST=%pI4 ",
58 NIPQUAD(ih->saddr), NIPQUAD(ih->daddr)); 58 &ih->saddr, &ih->daddr);
59 59
60 /* Max length: 46 "LEN=65535 TOS=0xFF PREC=0xFF TTL=255 ID=65535 " */ 60 /* Max length: 46 "LEN=65535 TOS=0xFF PREC=0xFF TTL=255 ID=65535 " */
61 printk("LEN=%u TOS=0x%02X PREC=0x%02X TTL=%u ID=%u ", 61 printk("LEN=%u TOS=0x%02X PREC=0x%02X TTL=%u ID=%u ",
@@ -262,8 +262,7 @@ static void dump_packet(const struct nf_loginfo *info,
262 break; 262 break;
263 case ICMP_REDIRECT: 263 case ICMP_REDIRECT:
264 /* Max length: 24 "GATEWAY=255.255.255.255 " */ 264 /* Max length: 24 "GATEWAY=255.255.255.255 " */
265 printk("GATEWAY=%u.%u.%u.%u ", 265 printk("GATEWAY=%pI4 ", &ich->un.gateway);
266 NIPQUAD(ich->un.gateway));
267 /* Fall through */ 266 /* Fall through */
268 case ICMP_DEST_UNREACH: 267 case ICMP_DEST_UNREACH:
269 case ICMP_SOURCE_QUENCH: 268 case ICMP_SOURCE_QUENCH:
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 4a7c35275396..b2141e11575e 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -60,9 +60,8 @@ static bool ipv4_invert_tuple(struct nf_conntrack_tuple *tuple,
60static int ipv4_print_tuple(struct seq_file *s, 60static int ipv4_print_tuple(struct seq_file *s,
61 const struct nf_conntrack_tuple *tuple) 61 const struct nf_conntrack_tuple *tuple)
62{ 62{
63 return seq_printf(s, "src=%u.%u.%u.%u dst=%u.%u.%u.%u ", 63 return seq_printf(s, "src=%pI4 dst=%pI4 ",
64 NIPQUAD(tuple->src.u3.ip), 64 &tuple->src.u3.ip, &tuple->dst.u3.ip);
65 NIPQUAD(tuple->dst.u3.ip));
66} 65}
67 66
68static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff, 67static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
@@ -198,7 +197,7 @@ static ctl_table ip_ct_sysctl_table[] = {
198 .data = &nf_conntrack_max, 197 .data = &nf_conntrack_max,
199 .maxlen = sizeof(int), 198 .maxlen = sizeof(int),
200 .mode = 0644, 199 .mode = 0644,
201 .proc_handler = &proc_dointvec, 200 .proc_handler = proc_dointvec,
202 }, 201 },
203 { 202 {
204 .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT, 203 .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT,
@@ -206,7 +205,7 @@ static ctl_table ip_ct_sysctl_table[] = {
206 .data = &init_net.ct.count, 205 .data = &init_net.ct.count,
207 .maxlen = sizeof(int), 206 .maxlen = sizeof(int),
208 .mode = 0444, 207 .mode = 0444,
209 .proc_handler = &proc_dointvec, 208 .proc_handler = proc_dointvec,
210 }, 209 },
211 { 210 {
212 .ctl_name = NET_IPV4_NF_CONNTRACK_BUCKETS, 211 .ctl_name = NET_IPV4_NF_CONNTRACK_BUCKETS,
@@ -214,7 +213,7 @@ static ctl_table ip_ct_sysctl_table[] = {
214 .data = &nf_conntrack_htable_size, 213 .data = &nf_conntrack_htable_size,
215 .maxlen = sizeof(unsigned int), 214 .maxlen = sizeof(unsigned int),
216 .mode = 0444, 215 .mode = 0444,
217 .proc_handler = &proc_dointvec, 216 .proc_handler = proc_dointvec,
218 }, 217 },
219 { 218 {
220 .ctl_name = NET_IPV4_NF_CONNTRACK_CHECKSUM, 219 .ctl_name = NET_IPV4_NF_CONNTRACK_CHECKSUM,
@@ -222,7 +221,7 @@ static ctl_table ip_ct_sysctl_table[] = {
222 .data = &init_net.ct.sysctl_checksum, 221 .data = &init_net.ct.sysctl_checksum,
223 .maxlen = sizeof(int), 222 .maxlen = sizeof(int),
224 .mode = 0644, 223 .mode = 0644,
225 .proc_handler = &proc_dointvec, 224 .proc_handler = proc_dointvec,
226 }, 225 },
227 { 226 {
228 .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID, 227 .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID,
@@ -230,8 +229,8 @@ static ctl_table ip_ct_sysctl_table[] = {
230 .data = &init_net.ct.sysctl_log_invalid, 229 .data = &init_net.ct.sysctl_log_invalid,
231 .maxlen = sizeof(unsigned int), 230 .maxlen = sizeof(unsigned int),
232 .mode = 0644, 231 .mode = 0644,
233 .proc_handler = &proc_dointvec_minmax, 232 .proc_handler = proc_dointvec_minmax,
234 .strategy = &sysctl_intvec, 233 .strategy = sysctl_intvec,
235 .extra1 = &log_invalid_proto_min, 234 .extra1 = &log_invalid_proto_min,
236 .extra2 = &log_invalid_proto_max, 235 .extra2 = &log_invalid_proto_max,
237 }, 236 },
@@ -284,17 +283,17 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
284 .tuple.dst.u3.ip; 283 .tuple.dst.u3.ip;
285 memset(sin.sin_zero, 0, sizeof(sin.sin_zero)); 284 memset(sin.sin_zero, 0, sizeof(sin.sin_zero));
286 285
287 pr_debug("SO_ORIGINAL_DST: %u.%u.%u.%u %u\n", 286 pr_debug("SO_ORIGINAL_DST: %pI4 %u\n",
288 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port)); 287 &sin.sin_addr.s_addr, ntohs(sin.sin_port));
289 nf_ct_put(ct); 288 nf_ct_put(ct);
290 if (copy_to_user(user, &sin, sizeof(sin)) != 0) 289 if (copy_to_user(user, &sin, sizeof(sin)) != 0)
291 return -EFAULT; 290 return -EFAULT;
292 else 291 else
293 return 0; 292 return 0;
294 } 293 }
295 pr_debug("SO_ORIGINAL_DST: Can't find %u.%u.%u.%u/%u-%u.%u.%u.%u/%u.\n", 294 pr_debug("SO_ORIGINAL_DST: Can't find %pI4/%u-%pI4/%u.\n",
296 NIPQUAD(tuple.src.u3.ip), ntohs(tuple.src.u.tcp.port), 295 &tuple.src.u3.ip, ntohs(tuple.src.u.tcp.port),
297 NIPQUAD(tuple.dst.u3.ip), ntohs(tuple.dst.u.tcp.port)); 296 &tuple.dst.u3.ip, ntohs(tuple.dst.u.tcp.port));
298 return -ENOENT; 297 return -ENOENT;
299} 298}
300 299
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index 4e8879220222..1fd3ef7718b6 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -272,7 +272,7 @@ static struct ctl_table icmp_sysctl_table[] = {
272 .data = &nf_ct_icmp_timeout, 272 .data = &nf_ct_icmp_timeout,
273 .maxlen = sizeof(unsigned int), 273 .maxlen = sizeof(unsigned int),
274 .mode = 0644, 274 .mode = 0644,
275 .proc_handler = &proc_dointvec_jiffies, 275 .proc_handler = proc_dointvec_jiffies,
276 }, 276 },
277 { 277 {
278 .ctl_name = 0 278 .ctl_name = 0
@@ -285,7 +285,7 @@ static struct ctl_table icmp_compat_sysctl_table[] = {
285 .data = &nf_ct_icmp_timeout, 285 .data = &nf_ct_icmp_timeout,
286 .maxlen = sizeof(unsigned int), 286 .maxlen = sizeof(unsigned int),
287 .mode = 0644, 287 .mode = 0644,
288 .proc_handler = &proc_dointvec_jiffies, 288 .proc_handler = proc_dointvec_jiffies,
289 }, 289 },
290 { 290 {
291 .ctl_name = 0 291 .ctl_name = 0
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c
index ee47bf28c825..7e8e6fc75413 100644
--- a/net/ipv4/netfilter/nf_nat_h323.c
+++ b/net/ipv4/netfilter/nf_nat_h323.c
@@ -119,10 +119,9 @@ static int set_sig_addr(struct sk_buff *skb, struct nf_conn *ct,
119 (ntohl(addr.ip) & 0xff000000) == 0x7f000000) 119 (ntohl(addr.ip) & 0xff000000) == 0x7f000000)
120 i = 0; 120 i = 0;
121 121
122 pr_debug("nf_nat_ras: set signal address " 122 pr_debug("nf_nat_ras: set signal address %pI4:%hu->%pI4:%hu\n",
123 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 123 &addr.ip, port,
124 NIPQUAD(addr.ip), port, 124 &ct->tuplehash[!dir].tuple.dst.u3.ip,
125 NIPQUAD(ct->tuplehash[!dir].tuple.dst.u3.ip),
126 info->sig_port[!dir]); 125 info->sig_port[!dir]);
127 return set_h225_addr(skb, data, 0, &taddr[i], 126 return set_h225_addr(skb, data, 0, &taddr[i],
128 &ct->tuplehash[!dir]. 127 &ct->tuplehash[!dir].
@@ -131,10 +130,9 @@ static int set_sig_addr(struct sk_buff *skb, struct nf_conn *ct,
131 } else if (addr.ip == ct->tuplehash[dir].tuple.dst.u3.ip && 130 } else if (addr.ip == ct->tuplehash[dir].tuple.dst.u3.ip &&
132 port == info->sig_port[dir]) { 131 port == info->sig_port[dir]) {
133 /* GK->GW */ 132 /* GK->GW */
134 pr_debug("nf_nat_ras: set signal address " 133 pr_debug("nf_nat_ras: set signal address %pI4:%hu->%pI4:%hu\n",
135 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 134 &addr.ip, port,
136 NIPQUAD(addr.ip), port, 135 &ct->tuplehash[!dir].tuple.src.u3.ip,
137 NIPQUAD(ct->tuplehash[!dir].tuple.src.u3.ip),
138 info->sig_port[!dir]); 136 info->sig_port[!dir]);
139 return set_h225_addr(skb, data, 0, &taddr[i], 137 return set_h225_addr(skb, data, 0, &taddr[i],
140 &ct->tuplehash[!dir]. 138 &ct->tuplehash[!dir].
@@ -162,10 +160,9 @@ static int set_ras_addr(struct sk_buff *skb, struct nf_conn *ct,
162 if (get_h225_addr(ct, *data, &taddr[i], &addr, &port) && 160 if (get_h225_addr(ct, *data, &taddr[i], &addr, &port) &&
163 addr.ip == ct->tuplehash[dir].tuple.src.u3.ip && 161 addr.ip == ct->tuplehash[dir].tuple.src.u3.ip &&
164 port == ct->tuplehash[dir].tuple.src.u.udp.port) { 162 port == ct->tuplehash[dir].tuple.src.u.udp.port) {
165 pr_debug("nf_nat_ras: set rasAddress " 163 pr_debug("nf_nat_ras: set rasAddress %pI4:%hu->%pI4:%hu\n",
166 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 164 &addr.ip, ntohs(port),
167 NIPQUAD(addr.ip), ntohs(port), 165 &ct->tuplehash[!dir].tuple.dst.u3.ip,
168 NIPQUAD(ct->tuplehash[!dir].tuple.dst.u3.ip),
169 ntohs(ct->tuplehash[!dir].tuple.dst.u.udp.port)); 166 ntohs(ct->tuplehash[!dir].tuple.dst.u.udp.port));
170 return set_h225_addr(skb, data, 0, &taddr[i], 167 return set_h225_addr(skb, data, 0, &taddr[i],
171 &ct->tuplehash[!dir].tuple.dst.u3, 168 &ct->tuplehash[!dir].tuple.dst.u3,
@@ -257,15 +254,15 @@ static int nat_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,
257 } 254 }
258 255
259 /* Success */ 256 /* Success */
260 pr_debug("nf_nat_h323: expect RTP %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 257 pr_debug("nf_nat_h323: expect RTP %pI4:%hu->%pI4:%hu\n",
261 NIPQUAD(rtp_exp->tuple.src.u3.ip), 258 &rtp_exp->tuple.src.u3.ip,
262 ntohs(rtp_exp->tuple.src.u.udp.port), 259 ntohs(rtp_exp->tuple.src.u.udp.port),
263 NIPQUAD(rtp_exp->tuple.dst.u3.ip), 260 &rtp_exp->tuple.dst.u3.ip,
264 ntohs(rtp_exp->tuple.dst.u.udp.port)); 261 ntohs(rtp_exp->tuple.dst.u.udp.port));
265 pr_debug("nf_nat_h323: expect RTCP %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 262 pr_debug("nf_nat_h323: expect RTCP %pI4:%hu->%pI4:%hu\n",
266 NIPQUAD(rtcp_exp->tuple.src.u3.ip), 263 &rtcp_exp->tuple.src.u3.ip,
267 ntohs(rtcp_exp->tuple.src.u.udp.port), 264 ntohs(rtcp_exp->tuple.src.u.udp.port),
268 NIPQUAD(rtcp_exp->tuple.dst.u3.ip), 265 &rtcp_exp->tuple.dst.u3.ip,
269 ntohs(rtcp_exp->tuple.dst.u.udp.port)); 266 ntohs(rtcp_exp->tuple.dst.u.udp.port));
270 267
271 return 0; 268 return 0;
@@ -307,10 +304,10 @@ static int nat_t120(struct sk_buff *skb, struct nf_conn *ct,
307 return -1; 304 return -1;
308 } 305 }
309 306
310 pr_debug("nf_nat_h323: expect T.120 %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 307 pr_debug("nf_nat_h323: expect T.120 %pI4:%hu->%pI4:%hu\n",
311 NIPQUAD(exp->tuple.src.u3.ip), 308 &exp->tuple.src.u3.ip,
312 ntohs(exp->tuple.src.u.tcp.port), 309 ntohs(exp->tuple.src.u.tcp.port),
313 NIPQUAD(exp->tuple.dst.u3.ip), 310 &exp->tuple.dst.u3.ip,
314 ntohs(exp->tuple.dst.u.tcp.port)); 311 ntohs(exp->tuple.dst.u.tcp.port));
315 312
316 return 0; 313 return 0;
@@ -361,10 +358,10 @@ static int nat_h245(struct sk_buff *skb, struct nf_conn *ct,
361 return -1; 358 return -1;
362 } 359 }
363 360
364 pr_debug("nf_nat_q931: expect H.245 %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 361 pr_debug("nf_nat_q931: expect H.245 %pI4:%hu->%pI4:%hu\n",
365 NIPQUAD(exp->tuple.src.u3.ip), 362 &exp->tuple.src.u3.ip,
366 ntohs(exp->tuple.src.u.tcp.port), 363 ntohs(exp->tuple.src.u.tcp.port),
367 NIPQUAD(exp->tuple.dst.u3.ip), 364 &exp->tuple.dst.u3.ip,
368 ntohs(exp->tuple.dst.u.tcp.port)); 365 ntohs(exp->tuple.dst.u.tcp.port));
369 366
370 return 0; 367 return 0;
@@ -455,10 +452,10 @@ static int nat_q931(struct sk_buff *skb, struct nf_conn *ct,
455 } 452 }
456 453
457 /* Success */ 454 /* Success */
458 pr_debug("nf_nat_ras: expect Q.931 %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 455 pr_debug("nf_nat_ras: expect Q.931 %pI4:%hu->%pI4:%hu\n",
459 NIPQUAD(exp->tuple.src.u3.ip), 456 &exp->tuple.src.u3.ip,
460 ntohs(exp->tuple.src.u.tcp.port), 457 ntohs(exp->tuple.src.u.tcp.port),
461 NIPQUAD(exp->tuple.dst.u3.ip), 458 &exp->tuple.dst.u3.ip,
462 ntohs(exp->tuple.dst.u.tcp.port)); 459 ntohs(exp->tuple.dst.u.tcp.port));
463 460
464 return 0; 461 return 0;
@@ -524,11 +521,10 @@ static int nat_callforwarding(struct sk_buff *skb, struct nf_conn *ct,
524 } 521 }
525 522
526 /* Success */ 523 /* Success */
527 pr_debug("nf_nat_q931: expect Call Forwarding " 524 pr_debug("nf_nat_q931: expect Call Forwarding %pI4:%hu->%pI4:%hu\n",
528 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n", 525 &exp->tuple.src.u3.ip,
529 NIPQUAD(exp->tuple.src.u3.ip),
530 ntohs(exp->tuple.src.u.tcp.port), 526 ntohs(exp->tuple.src.u.tcp.port),
531 NIPQUAD(exp->tuple.dst.u3.ip), 527 &exp->tuple.dst.u3.ip,
532 ntohs(exp->tuple.dst.u.tcp.port)); 528 ntohs(exp->tuple.dst.u.tcp.port));
533 529
534 return 0; 530 return 0;
diff --git a/net/ipv4/netfilter/nf_nat_irc.c b/net/ipv4/netfilter/nf_nat_irc.c
index fe6f9cef6c85..ea83a886b03e 100644
--- a/net/ipv4/netfilter/nf_nat_irc.c
+++ b/net/ipv4/netfilter/nf_nat_irc.c
@@ -55,8 +55,8 @@ static unsigned int help(struct sk_buff *skb,
55 55
56 ip = ntohl(exp->master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip); 56 ip = ntohl(exp->master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip);
57 sprintf(buffer, "%u %u", ip, port); 57 sprintf(buffer, "%u %u", ip, port);
58 pr_debug("nf_nat_irc: inserting '%s' == %u.%u.%u.%u, port %u\n", 58 pr_debug("nf_nat_irc: inserting '%s' == %pI4, port %u\n",
59 buffer, NIPQUAD(ip), port); 59 buffer, &ip, port);
60 60
61 ret = nf_nat_mangle_tcp_packet(skb, exp->master, ctinfo, 61 ret = nf_nat_mangle_tcp_packet(skb, exp->master, ctinfo,
62 matchoff, matchlen, buffer, 62 matchoff, matchlen, buffer,
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c
index bea54a685109..a4f1c3479e23 100644
--- a/net/ipv4/netfilter/nf_nat_rule.c
+++ b/net/ipv4/netfilter/nf_nat_rule.c
@@ -98,8 +98,7 @@ static void warn_if_extra_mangle(struct net *net, __be32 dstip, __be32 srcip)
98 98
99 if (rt->rt_src != srcip && !warned) { 99 if (rt->rt_src != srcip && !warned) {
100 printk("NAT: no longer support implicit source local NAT\n"); 100 printk("NAT: no longer support implicit source local NAT\n");
101 printk("NAT: packet src %u.%u.%u.%u -> dst %u.%u.%u.%u\n", 101 printk("NAT: packet src %pI4 -> dst %pI4\n", &srcip, &dstip);
102 NIPQUAD(srcip), NIPQUAD(dstip));
103 warned = 1; 102 warned = 1;
104 } 103 }
105 ip_rt_put(rt); 104 ip_rt_put(rt);
@@ -166,8 +165,7 @@ alloc_null_binding(struct nf_conn *ct, unsigned int hooknum)
166 struct nf_nat_range range 165 struct nf_nat_range range
167 = { IP_NAT_RANGE_MAP_IPS, ip, ip, { 0 }, { 0 } }; 166 = { IP_NAT_RANGE_MAP_IPS, ip, ip, { 0 }, { 0 } };
168 167
169 pr_debug("Allocating NULL binding for %p (%u.%u.%u.%u)\n", 168 pr_debug("Allocating NULL binding for %p (%pI4)\n", ct, &ip);
170 ct, NIPQUAD(ip));
171 return nf_nat_setup_info(ct, &range, HOOK2MANIP(hooknum)); 169 return nf_nat_setup_info(ct, &range, HOOK2MANIP(hooknum));
172} 170}
173 171
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c
index 14544320c545..07d61a57613c 100644
--- a/net/ipv4/netfilter/nf_nat_sip.c
+++ b/net/ipv4/netfilter/nf_nat_sip.c
@@ -74,8 +74,7 @@ static int map_addr(struct sk_buff *skb,
74 if (newaddr == addr->ip && newport == port) 74 if (newaddr == addr->ip && newport == port)
75 return 1; 75 return 1;
76 76
77 buflen = sprintf(buffer, "%u.%u.%u.%u:%u", 77 buflen = sprintf(buffer, "%pI4:%u", &newaddr, ntohs(newport));
78 NIPQUAD(newaddr), ntohs(newport));
79 78
80 return mangle_packet(skb, dptr, datalen, matchoff, matchlen, 79 return mangle_packet(skb, dptr, datalen, matchoff, matchlen,
81 buffer, buflen); 80 buffer, buflen);
@@ -152,8 +151,8 @@ static unsigned int ip_nat_sip(struct sk_buff *skb,
152 &addr) > 0 && 151 &addr) > 0 &&
153 addr.ip == ct->tuplehash[dir].tuple.src.u3.ip && 152 addr.ip == ct->tuplehash[dir].tuple.src.u3.ip &&
154 addr.ip != ct->tuplehash[!dir].tuple.dst.u3.ip) { 153 addr.ip != ct->tuplehash[!dir].tuple.dst.u3.ip) {
155 __be32 ip = ct->tuplehash[!dir].tuple.dst.u3.ip; 154 buflen = sprintf(buffer, "%pI4",
156 buflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip)); 155 &ct->tuplehash[!dir].tuple.dst.u3.ip);
157 if (!mangle_packet(skb, dptr, datalen, poff, plen, 156 if (!mangle_packet(skb, dptr, datalen, poff, plen,
158 buffer, buflen)) 157 buffer, buflen))
159 return NF_DROP; 158 return NF_DROP;
@@ -166,8 +165,8 @@ static unsigned int ip_nat_sip(struct sk_buff *skb,
166 &addr) > 0 && 165 &addr) > 0 &&
167 addr.ip == ct->tuplehash[dir].tuple.dst.u3.ip && 166 addr.ip == ct->tuplehash[dir].tuple.dst.u3.ip &&
168 addr.ip != ct->tuplehash[!dir].tuple.src.u3.ip) { 167 addr.ip != ct->tuplehash[!dir].tuple.src.u3.ip) {
169 __be32 ip = ct->tuplehash[!dir].tuple.src.u3.ip; 168 buflen = sprintf(buffer, "%pI4",
170 buflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip)); 169 &ct->tuplehash[!dir].tuple.src.u3.ip);
171 if (!mangle_packet(skb, dptr, datalen, poff, plen, 170 if (!mangle_packet(skb, dptr, datalen, poff, plen,
172 buffer, buflen)) 171 buffer, buflen))
173 return NF_DROP; 172 return NF_DROP;
@@ -279,8 +278,7 @@ static unsigned int ip_nat_sip_expect(struct sk_buff *skb,
279 278
280 if (exp->tuple.dst.u3.ip != exp->saved_ip || 279 if (exp->tuple.dst.u3.ip != exp->saved_ip ||
281 exp->tuple.dst.u.udp.port != exp->saved_proto.udp.port) { 280 exp->tuple.dst.u.udp.port != exp->saved_proto.udp.port) {
282 buflen = sprintf(buffer, "%u.%u.%u.%u:%u", 281 buflen = sprintf(buffer, "%pI4:%u", &newip, port);
283 NIPQUAD(newip), port);
284 if (!mangle_packet(skb, dptr, datalen, matchoff, matchlen, 282 if (!mangle_packet(skb, dptr, datalen, matchoff, matchlen,
285 buffer, buflen)) 283 buffer, buflen))
286 goto err; 284 goto err;
@@ -345,7 +343,7 @@ static unsigned int ip_nat_sdp_addr(struct sk_buff *skb, const char **dptr,
345 char buffer[sizeof("nnn.nnn.nnn.nnn")]; 343 char buffer[sizeof("nnn.nnn.nnn.nnn")];
346 unsigned int buflen; 344 unsigned int buflen;
347 345
348 buflen = sprintf(buffer, NIPQUAD_FMT, NIPQUAD(addr->ip)); 346 buflen = sprintf(buffer, "%pI4", &addr->ip);
349 if (mangle_sdp_packet(skb, dptr, dataoff, datalen, type, term, 347 if (mangle_sdp_packet(skb, dptr, dataoff, datalen, type, term,
350 buffer, buflen)) 348 buffer, buflen))
351 return 0; 349 return 0;
@@ -380,7 +378,7 @@ static unsigned int ip_nat_sdp_session(struct sk_buff *skb, const char **dptr,
380 unsigned int buflen; 378 unsigned int buflen;
381 379
382 /* Mangle session description owner and contact addresses */ 380 /* Mangle session description owner and contact addresses */
383 buflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(addr->ip)); 381 buflen = sprintf(buffer, "%pI4", &addr->ip);
384 if (mangle_sdp_packet(skb, dptr, dataoff, datalen, 382 if (mangle_sdp_packet(skb, dptr, dataoff, datalen,
385 SDP_HDR_OWNER_IP4, SDP_HDR_MEDIA, 383 SDP_HDR_OWNER_IP4, SDP_HDR_MEDIA,
386 buffer, buflen)) 384 buffer, buflen))
diff --git a/net/ipv4/netfilter/nf_nat_snmp_basic.c b/net/ipv4/netfilter/nf_nat_snmp_basic.c
index 8303e4b406c0..182f845de92f 100644
--- a/net/ipv4/netfilter/nf_nat_snmp_basic.c
+++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c
@@ -930,8 +930,8 @@ static inline void mangle_address(unsigned char *begin,
930 } 930 }
931 931
932 if (debug) 932 if (debug)
933 printk(KERN_DEBUG "bsalg: mapped %u.%u.%u.%u to " 933 printk(KERN_DEBUG "bsalg: mapped %pI4 to %pI4\n",
934 "%u.%u.%u.%u\n", NIPQUAD(old), NIPQUAD(*addr)); 934 &old, addr);
935 } 935 }
936} 936}
937 937
@@ -1267,9 +1267,8 @@ static int help(struct sk_buff *skb, unsigned int protoff,
1267 */ 1267 */
1268 if (ntohs(udph->len) != skb->len - (iph->ihl << 2)) { 1268 if (ntohs(udph->len) != skb->len - (iph->ihl << 2)) {
1269 if (net_ratelimit()) 1269 if (net_ratelimit())
1270 printk(KERN_WARNING "SNMP: dropping malformed packet " 1270 printk(KERN_WARNING "SNMP: dropping malformed packet src=%pI4 dst=%pI4\n",
1271 "src=%u.%u.%u.%u dst=%u.%u.%u.%u\n", 1271 &iph->saddr, &iph->daddr);
1272 NIPQUAD(iph->saddr), NIPQUAD(iph->daddr));
1273 return NF_DROP; 1272 return NF_DROP;
1274 } 1273 }
1275 1274
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index cd975743bcd2..998fcffc9e15 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -247,7 +247,7 @@ static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
247 } 247 }
248 248
249 if (inet->recverr) { 249 if (inet->recverr) {
250 struct iphdr *iph = (struct iphdr*)skb->data; 250 struct iphdr *iph = (struct iphdr *)skb->data;
251 u8 *payload = skb->data + (iph->ihl << 2); 251 u8 *payload = skb->data + (iph->ihl << 2);
252 252
253 if (inet->hdrincl) 253 if (inet->hdrincl)
@@ -465,7 +465,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
465 */ 465 */
466 466
467 if (msg->msg_namelen) { 467 if (msg->msg_namelen) {
468 struct sockaddr_in *usin = (struct sockaddr_in*)msg->msg_name; 468 struct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name;
469 err = -EINVAL; 469 err = -EINVAL;
470 if (msg->msg_namelen < sizeof(*usin)) 470 if (msg->msg_namelen < sizeof(*usin))
471 goto out; 471 goto out;
@@ -851,7 +851,7 @@ struct proto raw_prot = {
851static struct sock *raw_get_first(struct seq_file *seq) 851static struct sock *raw_get_first(struct seq_file *seq)
852{ 852{
853 struct sock *sk; 853 struct sock *sk;
854 struct raw_iter_state* state = raw_seq_private(seq); 854 struct raw_iter_state *state = raw_seq_private(seq);
855 855
856 for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE; 856 for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE;
857 ++state->bucket) { 857 ++state->bucket) {
@@ -868,7 +868,7 @@ found:
868 868
869static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk) 869static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk)
870{ 870{
871 struct raw_iter_state* state = raw_seq_private(seq); 871 struct raw_iter_state *state = raw_seq_private(seq);
872 872
873 do { 873 do {
874 sk = sk_next(sk); 874 sk = sk_next(sk);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 2ea6dcc3e2cc..4e6959c29819 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -129,6 +129,7 @@ static int ip_rt_mtu_expires __read_mostly = 10 * 60 * HZ;
129static int ip_rt_min_pmtu __read_mostly = 512 + 20 + 20; 129static int ip_rt_min_pmtu __read_mostly = 512 + 20 + 20;
130static int ip_rt_min_advmss __read_mostly = 256; 130static int ip_rt_min_advmss __read_mostly = 256;
131static int ip_rt_secret_interval __read_mostly = 10 * 60 * HZ; 131static int ip_rt_secret_interval __read_mostly = 10 * 60 * HZ;
132static int rt_chain_length_max __read_mostly = 20;
132 133
133static void rt_worker_func(struct work_struct *work); 134static void rt_worker_func(struct work_struct *work);
134static DECLARE_DELAYED_WORK(expires_work, rt_worker_func); 135static DECLARE_DELAYED_WORK(expires_work, rt_worker_func);
@@ -145,6 +146,7 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst);
145static void ipv4_link_failure(struct sk_buff *skb); 146static void ipv4_link_failure(struct sk_buff *skb);
146static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu); 147static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu);
147static int rt_garbage_collect(struct dst_ops *ops); 148static int rt_garbage_collect(struct dst_ops *ops);
149static void rt_emergency_hash_rebuild(struct net *net);
148 150
149 151
150static struct dst_ops ipv4_dst_ops = { 152static struct dst_ops ipv4_dst_ops = {
@@ -158,7 +160,6 @@ static struct dst_ops ipv4_dst_ops = {
158 .link_failure = ipv4_link_failure, 160 .link_failure = ipv4_link_failure,
159 .update_pmtu = ip_rt_update_pmtu, 161 .update_pmtu = ip_rt_update_pmtu,
160 .local_out = __ip_local_out, 162 .local_out = __ip_local_out,
161 .entry_size = sizeof(struct rtable),
162 .entries = ATOMIC_INIT(0), 163 .entries = ATOMIC_INIT(0),
163}; 164};
164 165
@@ -201,6 +202,7 @@ const __u8 ip_tos2prio[16] = {
201struct rt_hash_bucket { 202struct rt_hash_bucket {
202 struct rtable *chain; 203 struct rtable *chain;
203}; 204};
205
204#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) || \ 206#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) || \
205 defined(CONFIG_PROVE_LOCKING) 207 defined(CONFIG_PROVE_LOCKING)
206/* 208/*
@@ -674,6 +676,20 @@ static inline u32 rt_score(struct rtable *rt)
674 return score; 676 return score;
675} 677}
676 678
679static inline bool rt_caching(const struct net *net)
680{
681 return net->ipv4.current_rt_cache_rebuild_count <=
682 net->ipv4.sysctl_rt_cache_rebuild_count;
683}
684
685static inline bool compare_hash_inputs(const struct flowi *fl1,
686 const struct flowi *fl2)
687{
688 return (__force u32)(((fl1->nl_u.ip4_u.daddr ^ fl2->nl_u.ip4_u.daddr) |
689 (fl1->nl_u.ip4_u.saddr ^ fl2->nl_u.ip4_u.saddr) |
690 (fl1->iif ^ fl2->iif)) == 0);
691}
692
677static inline int compare_keys(struct flowi *fl1, struct flowi *fl2) 693static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
678{ 694{
679 return ((__force u32)((fl1->nl_u.ip4_u.daddr ^ fl2->nl_u.ip4_u.daddr) | 695 return ((__force u32)((fl1->nl_u.ip4_u.daddr ^ fl2->nl_u.ip4_u.daddr) |
@@ -753,11 +769,24 @@ static void rt_do_flush(int process_context)
753 } 769 }
754} 770}
755 771
772/*
773 * While freeing expired entries, we compute average chain length
774 * and standard deviation, using fixed-point arithmetic.
775 * This to have an estimation of rt_chain_length_max
776 * rt_chain_length_max = max(elasticity, AVG + 4*SD)
777 * We use 3 bits for frational part, and 29 (or 61) for magnitude.
778 */
779
780#define FRACT_BITS 3
781#define ONE (1UL << FRACT_BITS)
782
756static void rt_check_expire(void) 783static void rt_check_expire(void)
757{ 784{
758 static unsigned int rover; 785 static unsigned int rover;
759 unsigned int i = rover, goal; 786 unsigned int i = rover, goal;
760 struct rtable *rth, **rthp; 787 struct rtable *rth, **rthp;
788 unsigned long length = 0, samples = 0;
789 unsigned long sum = 0, sum2 = 0;
761 u64 mult; 790 u64 mult;
762 791
763 mult = ((u64)ip_rt_gc_interval) << rt_hash_log; 792 mult = ((u64)ip_rt_gc_interval) << rt_hash_log;
@@ -766,6 +795,7 @@ static void rt_check_expire(void)
766 goal = (unsigned int)mult; 795 goal = (unsigned int)mult;
767 if (goal > rt_hash_mask) 796 if (goal > rt_hash_mask)
768 goal = rt_hash_mask + 1; 797 goal = rt_hash_mask + 1;
798 length = 0;
769 for (; goal > 0; goal--) { 799 for (; goal > 0; goal--) {
770 unsigned long tmo = ip_rt_gc_timeout; 800 unsigned long tmo = ip_rt_gc_timeout;
771 801
@@ -775,6 +805,8 @@ static void rt_check_expire(void)
775 if (need_resched()) 805 if (need_resched())
776 cond_resched(); 806 cond_resched();
777 807
808 samples++;
809
778 if (*rthp == NULL) 810 if (*rthp == NULL)
779 continue; 811 continue;
780 spin_lock_bh(rt_hash_lock_addr(i)); 812 spin_lock_bh(rt_hash_lock_addr(i));
@@ -789,11 +821,29 @@ static void rt_check_expire(void)
789 if (time_before_eq(jiffies, rth->u.dst.expires)) { 821 if (time_before_eq(jiffies, rth->u.dst.expires)) {
790 tmo >>= 1; 822 tmo >>= 1;
791 rthp = &rth->u.dst.rt_next; 823 rthp = &rth->u.dst.rt_next;
824 /*
825 * Only bump our length if the hash
826 * inputs on entries n and n+1 are not
827 * the same, we only count entries on
828 * a chain with equal hash inputs once
829 * so that entries for different QOS
830 * levels, and other non-hash input
831 * attributes don't unfairly skew
832 * the length computation
833 */
834 if ((*rthp == NULL) ||
835 !compare_hash_inputs(&(*rthp)->fl,
836 &rth->fl))
837 length += ONE;
792 continue; 838 continue;
793 } 839 }
794 } else if (!rt_may_expire(rth, tmo, ip_rt_gc_timeout)) { 840 } else if (!rt_may_expire(rth, tmo, ip_rt_gc_timeout)) {
795 tmo >>= 1; 841 tmo >>= 1;
796 rthp = &rth->u.dst.rt_next; 842 rthp = &rth->u.dst.rt_next;
843 if ((*rthp == NULL) ||
844 !compare_hash_inputs(&(*rthp)->fl,
845 &rth->fl))
846 length += ONE;
797 continue; 847 continue;
798 } 848 }
799 849
@@ -802,6 +852,15 @@ static void rt_check_expire(void)
802 rt_free(rth); 852 rt_free(rth);
803 } 853 }
804 spin_unlock_bh(rt_hash_lock_addr(i)); 854 spin_unlock_bh(rt_hash_lock_addr(i));
855 sum += length;
856 sum2 += length*length;
857 }
858 if (samples) {
859 unsigned long avg = sum / samples;
860 unsigned long sd = int_sqrt(sum2 / samples - avg*avg);
861 rt_chain_length_max = max_t(unsigned long,
862 ip_rt_gc_elasticity,
863 (avg + 4*sd) >> FRACT_BITS);
805 } 864 }
806 rover = i; 865 rover = i;
807} 866}
@@ -851,6 +910,26 @@ static void rt_secret_rebuild(unsigned long __net)
851 mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval); 910 mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval);
852} 911}
853 912
913static void rt_secret_rebuild_oneshot(struct net *net)
914{
915 del_timer_sync(&net->ipv4.rt_secret_timer);
916 rt_cache_invalidate(net);
917 if (ip_rt_secret_interval) {
918 net->ipv4.rt_secret_timer.expires += ip_rt_secret_interval;
919 add_timer(&net->ipv4.rt_secret_timer);
920 }
921}
922
923static void rt_emergency_hash_rebuild(struct net *net)
924{
925 if (net_ratelimit()) {
926 printk(KERN_WARNING "Route hash chain too long!\n");
927 printk(KERN_WARNING "Adjust your secret_interval!\n");
928 }
929
930 rt_secret_rebuild_oneshot(net);
931}
932
854/* 933/*
855 Short description of GC goals. 934 Short description of GC goals.
856 935
@@ -989,6 +1068,7 @@ out: return 0;
989static int rt_intern_hash(unsigned hash, struct rtable *rt, struct rtable **rp) 1068static int rt_intern_hash(unsigned hash, struct rtable *rt, struct rtable **rp)
990{ 1069{
991 struct rtable *rth, **rthp; 1070 struct rtable *rth, **rthp;
1071 struct rtable *rthi;
992 unsigned long now; 1072 unsigned long now;
993 struct rtable *cand, **candp; 1073 struct rtable *cand, **candp;
994 u32 min_score; 1074 u32 min_score;
@@ -1002,7 +1082,13 @@ restart:
1002 candp = NULL; 1082 candp = NULL;
1003 now = jiffies; 1083 now = jiffies;
1004 1084
1085 if (!rt_caching(dev_net(rt->u.dst.dev))) {
1086 rt_drop(rt);
1087 return 0;
1088 }
1089
1005 rthp = &rt_hash_table[hash].chain; 1090 rthp = &rt_hash_table[hash].chain;
1091 rthi = NULL;
1006 1092
1007 spin_lock_bh(rt_hash_lock_addr(hash)); 1093 spin_lock_bh(rt_hash_lock_addr(hash));
1008 while ((rth = *rthp) != NULL) { 1094 while ((rth = *rthp) != NULL) {
@@ -1048,6 +1134,17 @@ restart:
1048 chain_length++; 1134 chain_length++;
1049 1135
1050 rthp = &rth->u.dst.rt_next; 1136 rthp = &rth->u.dst.rt_next;
1137
1138 /*
1139 * check to see if the next entry in the chain
1140 * contains the same hash input values as rt. If it does
1141 * This is where we will insert into the list, instead of
1142 * at the head. This groups entries that differ by aspects not
1143 * relvant to the hash function together, which we use to adjust
1144 * our chain length
1145 */
1146 if (*rthp && compare_hash_inputs(&(*rthp)->fl, &rt->fl))
1147 rthi = rth;
1051 } 1148 }
1052 1149
1053 if (cand) { 1150 if (cand) {
@@ -1061,6 +1158,16 @@ restart:
1061 *candp = cand->u.dst.rt_next; 1158 *candp = cand->u.dst.rt_next;
1062 rt_free(cand); 1159 rt_free(cand);
1063 } 1160 }
1161 } else {
1162 if (chain_length > rt_chain_length_max) {
1163 struct net *net = dev_net(rt->u.dst.dev);
1164 int num = ++net->ipv4.current_rt_cache_rebuild_count;
1165 if (!rt_caching(dev_net(rt->u.dst.dev))) {
1166 printk(KERN_WARNING "%s: %d rebuilds is over limit, route caching disabled\n",
1167 rt->u.dst.dev->name, num);
1168 }
1169 rt_emergency_hash_rebuild(dev_net(rt->u.dst.dev));
1170 }
1064 } 1171 }
1065 1172
1066 /* Try to bind route to arp only if it is output 1173 /* Try to bind route to arp only if it is output
@@ -1098,14 +1205,17 @@ restart:
1098 } 1205 }
1099 } 1206 }
1100 1207
1101 rt->u.dst.rt_next = rt_hash_table[hash].chain; 1208 if (rthi)
1209 rt->u.dst.rt_next = rthi->u.dst.rt_next;
1210 else
1211 rt->u.dst.rt_next = rt_hash_table[hash].chain;
1212
1102#if RT_CACHE_DEBUG >= 2 1213#if RT_CACHE_DEBUG >= 2
1103 if (rt->u.dst.rt_next) { 1214 if (rt->u.dst.rt_next) {
1104 struct rtable *trt; 1215 struct rtable *trt;
1105 printk(KERN_DEBUG "rt_cache @%02x: " NIPQUAD_FMT, hash, 1216 printk(KERN_DEBUG "rt_cache @%02x: %pI4", hash, &rt->rt_dst);
1106 NIPQUAD(rt->rt_dst));
1107 for (trt = rt->u.dst.rt_next; trt; trt = trt->u.dst.rt_next) 1217 for (trt = rt->u.dst.rt_next; trt; trt = trt->u.dst.rt_next)
1108 printk(" . " NIPQUAD_FMT, NIPQUAD(trt->rt_dst)); 1218 printk(" . %pI4", &trt->rt_dst);
1109 printk("\n"); 1219 printk("\n");
1110 } 1220 }
1111#endif 1221#endif
@@ -1114,7 +1224,11 @@ restart:
1114 * previous writes to rt are comitted to memory 1224 * previous writes to rt are comitted to memory
1115 * before making rt visible to other CPUS. 1225 * before making rt visible to other CPUS.
1116 */ 1226 */
1117 rcu_assign_pointer(rt_hash_table[hash].chain, rt); 1227 if (rthi)
1228 rcu_assign_pointer(rthi->u.dst.rt_next, rt);
1229 else
1230 rcu_assign_pointer(rt_hash_table[hash].chain, rt);
1231
1118 spin_unlock_bh(rt_hash_lock_addr(hash)); 1232 spin_unlock_bh(rt_hash_lock_addr(hash));
1119 *rp = rt; 1233 *rp = rt;
1120 return 0; 1234 return 0;
@@ -1217,6 +1331,9 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1217 || ipv4_is_zeronet(new_gw)) 1331 || ipv4_is_zeronet(new_gw))
1218 goto reject_redirect; 1332 goto reject_redirect;
1219 1333
1334 if (!rt_caching(net))
1335 goto reject_redirect;
1336
1220 if (!IN_DEV_SHARED_MEDIA(in_dev)) { 1337 if (!IN_DEV_SHARED_MEDIA(in_dev)) {
1221 if (!inet_addr_onlink(in_dev, new_gw, old_gw)) 1338 if (!inet_addr_onlink(in_dev, new_gw, old_gw))
1222 goto reject_redirect; 1339 goto reject_redirect;
@@ -1267,7 +1384,6 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1267 1384
1268 /* Copy all the information. */ 1385 /* Copy all the information. */
1269 *rt = *rth; 1386 *rt = *rth;
1270 INIT_RCU_HEAD(&rt->u.dst.rcu_head);
1271 rt->u.dst.__use = 1; 1387 rt->u.dst.__use = 1;
1272 atomic_set(&rt->u.dst.__refcnt, 1); 1388 atomic_set(&rt->u.dst.__refcnt, 1);
1273 rt->u.dst.child = NULL; 1389 rt->u.dst.child = NULL;
@@ -1280,7 +1396,9 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1280 rt->u.dst.path = &rt->u.dst; 1396 rt->u.dst.path = &rt->u.dst;
1281 rt->u.dst.neighbour = NULL; 1397 rt->u.dst.neighbour = NULL;
1282 rt->u.dst.hh = NULL; 1398 rt->u.dst.hh = NULL;
1399#ifdef CONFIG_XFRM
1283 rt->u.dst.xfrm = NULL; 1400 rt->u.dst.xfrm = NULL;
1401#endif
1284 rt->rt_genid = rt_genid(net); 1402 rt->rt_genid = rt_genid(net);
1285 rt->rt_flags |= RTCF_REDIRECTED; 1403 rt->rt_flags |= RTCF_REDIRECTED;
1286 1404
@@ -1324,11 +1442,10 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1324reject_redirect: 1442reject_redirect:
1325#ifdef CONFIG_IP_ROUTE_VERBOSE 1443#ifdef CONFIG_IP_ROUTE_VERBOSE
1326 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) 1444 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
1327 printk(KERN_INFO "Redirect from " NIPQUAD_FMT " on %s about " 1445 printk(KERN_INFO "Redirect from %pI4 on %s about %pI4 ignored.\n"
1328 NIPQUAD_FMT " ignored.\n" 1446 " Advised path = %pI4 -> %pI4\n",
1329 " Advised path = " NIPQUAD_FMT " -> " NIPQUAD_FMT "\n", 1447 &old_gw, dev->name, &new_gw,
1330 NIPQUAD(old_gw), dev->name, NIPQUAD(new_gw), 1448 &saddr, &daddr);
1331 NIPQUAD(saddr), NIPQUAD(daddr));
1332#endif 1449#endif
1333 in_dev_put(in_dev); 1450 in_dev_put(in_dev);
1334} 1451}
@@ -1348,9 +1465,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1348 rt->fl.oif, 1465 rt->fl.oif,
1349 rt_genid(dev_net(dst->dev))); 1466 rt_genid(dev_net(dst->dev)));
1350#if RT_CACHE_DEBUG >= 1 1467#if RT_CACHE_DEBUG >= 1
1351 printk(KERN_DEBUG "ipv4_negative_advice: redirect to " 1468 printk(KERN_DEBUG "ipv4_negative_advice: redirect to %pI4/%02x dropped\n",
1352 NIPQUAD_FMT "/%02x dropped\n", 1469 &rt->rt_dst, rt->fl.fl4_tos);
1353 NIPQUAD(rt->rt_dst), rt->fl.fl4_tos);
1354#endif 1470#endif
1355 rt_del(hash, rt); 1471 rt_del(hash, rt);
1356 ret = NULL; 1472 ret = NULL;
@@ -1414,10 +1530,9 @@ void ip_rt_send_redirect(struct sk_buff *skb)
1414 if (IN_DEV_LOG_MARTIANS(in_dev) && 1530 if (IN_DEV_LOG_MARTIANS(in_dev) &&
1415 rt->u.dst.rate_tokens == ip_rt_redirect_number && 1531 rt->u.dst.rate_tokens == ip_rt_redirect_number &&
1416 net_ratelimit()) 1532 net_ratelimit())
1417 printk(KERN_WARNING "host " NIPQUAD_FMT "/if%d ignores " 1533 printk(KERN_WARNING "host %pI4/if%d ignores redirects for %pI4 to %pI4.\n",
1418 "redirects for " NIPQUAD_FMT " to " NIPQUAD_FMT ".\n", 1534 &rt->rt_src, rt->rt_iif,
1419 NIPQUAD(rt->rt_src), rt->rt_iif, 1535 &rt->rt_dst, &rt->rt_gateway);
1420 NIPQUAD(rt->rt_dst), NIPQUAD(rt->rt_gateway));
1421#endif 1536#endif
1422 } 1537 }
1423out: 1538out:
@@ -1610,8 +1725,8 @@ static void ipv4_link_failure(struct sk_buff *skb)
1610 1725
1611static int ip_rt_bug(struct sk_buff *skb) 1726static int ip_rt_bug(struct sk_buff *skb)
1612{ 1727{
1613 printk(KERN_DEBUG "ip_rt_bug: " NIPQUAD_FMT " -> " NIPQUAD_FMT ", %s\n", 1728 printk(KERN_DEBUG "ip_rt_bug: %pI4 -> %pI4, %s\n",
1614 NIPQUAD(ip_hdr(skb)->saddr), NIPQUAD(ip_hdr(skb)->daddr), 1729 &ip_hdr(skb)->saddr, &ip_hdr(skb)->daddr,
1615 skb->dev ? skb->dev->name : "?"); 1730 skb->dev ? skb->dev->name : "?");
1616 kfree_skb(skb); 1731 kfree_skb(skb);
1617 return 0; 1732 return 0;
@@ -1788,9 +1903,8 @@ static void ip_handle_martian_source(struct net_device *dev,
1788 * RFC1812 recommendation, if source is martian, 1903 * RFC1812 recommendation, if source is martian,
1789 * the only hint is MAC header. 1904 * the only hint is MAC header.
1790 */ 1905 */
1791 printk(KERN_WARNING "martian source " NIPQUAD_FMT " from " 1906 printk(KERN_WARNING "martian source %pI4 from %pI4, on dev %s\n",
1792 NIPQUAD_FMT", on dev %s\n", 1907 &daddr, &saddr, dev->name);
1793 NIPQUAD(daddr), NIPQUAD(saddr), dev->name);
1794 if (dev->hard_header_len && skb_mac_header_was_set(skb)) { 1908 if (dev->hard_header_len && skb_mac_header_was_set(skb)) {
1795 int i; 1909 int i;
1796 const unsigned char *p = skb_mac_header(skb); 1910 const unsigned char *p = skb_mac_header(skb);
@@ -2099,9 +2213,8 @@ martian_destination:
2099 RT_CACHE_STAT_INC(in_martian_dst); 2213 RT_CACHE_STAT_INC(in_martian_dst);
2100#ifdef CONFIG_IP_ROUTE_VERBOSE 2214#ifdef CONFIG_IP_ROUTE_VERBOSE
2101 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) 2215 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
2102 printk(KERN_WARNING "martian destination " NIPQUAD_FMT " from " 2216 printk(KERN_WARNING "martian destination %pI4 from %pI4, dev %s\n",
2103 NIPQUAD_FMT ", dev %s\n", 2217 &daddr, &saddr, dev->name);
2104 NIPQUAD(daddr), NIPQUAD(saddr), dev->name);
2105#endif 2218#endif
2106 2219
2107e_hostunreach: 2220e_hostunreach:
@@ -2130,6 +2243,10 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2130 struct net *net; 2243 struct net *net;
2131 2244
2132 net = dev_net(dev); 2245 net = dev_net(dev);
2246
2247 if (!rt_caching(net))
2248 goto skip_cache;
2249
2133 tos &= IPTOS_RT_MASK; 2250 tos &= IPTOS_RT_MASK;
2134 hash = rt_hash(daddr, saddr, iif, rt_genid(net)); 2251 hash = rt_hash(daddr, saddr, iif, rt_genid(net));
2135 2252
@@ -2154,6 +2271,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2154 } 2271 }
2155 rcu_read_unlock(); 2272 rcu_read_unlock();
2156 2273
2274skip_cache:
2157 /* Multicast recognition logic is moved from route cache to here. 2275 /* Multicast recognition logic is moved from route cache to here.
2158 The problem was that too many Ethernet cards have broken/missing 2276 The problem was that too many Ethernet cards have broken/missing
2159 hardware multicast filters :-( As result the host on multicasting 2277 hardware multicast filters :-( As result the host on multicasting
@@ -2539,6 +2657,9 @@ int __ip_route_output_key(struct net *net, struct rtable **rp,
2539 unsigned hash; 2657 unsigned hash;
2540 struct rtable *rth; 2658 struct rtable *rth;
2541 2659
2660 if (!rt_caching(net))
2661 goto slow_output;
2662
2542 hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif, rt_genid(net)); 2663 hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif, rt_genid(net));
2543 2664
2544 rcu_read_lock_bh(); 2665 rcu_read_lock_bh();
@@ -2563,6 +2684,7 @@ int __ip_route_output_key(struct net *net, struct rtable **rp,
2563 } 2684 }
2564 rcu_read_unlock_bh(); 2685 rcu_read_unlock_bh();
2565 2686
2687slow_output:
2566 return ip_route_output_slow(net, rp, flp); 2688 return ip_route_output_slow(net, rp, flp);
2567} 2689}
2568 2690
@@ -2578,7 +2700,6 @@ static struct dst_ops ipv4_dst_blackhole_ops = {
2578 .destroy = ipv4_dst_destroy, 2700 .destroy = ipv4_dst_destroy,
2579 .check = ipv4_dst_check, 2701 .check = ipv4_dst_check,
2580 .update_pmtu = ipv4_rt_blackhole_update_pmtu, 2702 .update_pmtu = ipv4_rt_blackhole_update_pmtu,
2581 .entry_size = sizeof(struct rtable),
2582 .entries = ATOMIC_INIT(0), 2703 .entries = ATOMIC_INIT(0),
2583}; 2704};
2584 2705
@@ -2995,7 +3116,7 @@ static ctl_table ipv4_route_table[] = {
2995 .data = &ipv4_dst_ops.gc_thresh, 3116 .data = &ipv4_dst_ops.gc_thresh,
2996 .maxlen = sizeof(int), 3117 .maxlen = sizeof(int),
2997 .mode = 0644, 3118 .mode = 0644,
2998 .proc_handler = &proc_dointvec, 3119 .proc_handler = proc_dointvec,
2999 }, 3120 },
3000 { 3121 {
3001 .ctl_name = NET_IPV4_ROUTE_MAX_SIZE, 3122 .ctl_name = NET_IPV4_ROUTE_MAX_SIZE,
@@ -3003,7 +3124,7 @@ static ctl_table ipv4_route_table[] = {
3003 .data = &ip_rt_max_size, 3124 .data = &ip_rt_max_size,
3004 .maxlen = sizeof(int), 3125 .maxlen = sizeof(int),
3005 .mode = 0644, 3126 .mode = 0644,
3006 .proc_handler = &proc_dointvec, 3127 .proc_handler = proc_dointvec,
3007 }, 3128 },
3008 { 3129 {
3009 /* Deprecated. Use gc_min_interval_ms */ 3130 /* Deprecated. Use gc_min_interval_ms */
@@ -3013,8 +3134,8 @@ static ctl_table ipv4_route_table[] = {
3013 .data = &ip_rt_gc_min_interval, 3134 .data = &ip_rt_gc_min_interval,
3014 .maxlen = sizeof(int), 3135 .maxlen = sizeof(int),
3015 .mode = 0644, 3136 .mode = 0644,
3016 .proc_handler = &proc_dointvec_jiffies, 3137 .proc_handler = proc_dointvec_jiffies,
3017 .strategy = &sysctl_jiffies, 3138 .strategy = sysctl_jiffies,
3018 }, 3139 },
3019 { 3140 {
3020 .ctl_name = NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS, 3141 .ctl_name = NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS,
@@ -3022,8 +3143,8 @@ static ctl_table ipv4_route_table[] = {
3022 .data = &ip_rt_gc_min_interval, 3143 .data = &ip_rt_gc_min_interval,
3023 .maxlen = sizeof(int), 3144 .maxlen = sizeof(int),
3024 .mode = 0644, 3145 .mode = 0644,
3025 .proc_handler = &proc_dointvec_ms_jiffies, 3146 .proc_handler = proc_dointvec_ms_jiffies,
3026 .strategy = &sysctl_ms_jiffies, 3147 .strategy = sysctl_ms_jiffies,
3027 }, 3148 },
3028 { 3149 {
3029 .ctl_name = NET_IPV4_ROUTE_GC_TIMEOUT, 3150 .ctl_name = NET_IPV4_ROUTE_GC_TIMEOUT,
@@ -3031,8 +3152,8 @@ static ctl_table ipv4_route_table[] = {
3031 .data = &ip_rt_gc_timeout, 3152 .data = &ip_rt_gc_timeout,
3032 .maxlen = sizeof(int), 3153 .maxlen = sizeof(int),
3033 .mode = 0644, 3154 .mode = 0644,
3034 .proc_handler = &proc_dointvec_jiffies, 3155 .proc_handler = proc_dointvec_jiffies,
3035 .strategy = &sysctl_jiffies, 3156 .strategy = sysctl_jiffies,
3036 }, 3157 },
3037 { 3158 {
3038 .ctl_name = NET_IPV4_ROUTE_GC_INTERVAL, 3159 .ctl_name = NET_IPV4_ROUTE_GC_INTERVAL,
@@ -3040,8 +3161,8 @@ static ctl_table ipv4_route_table[] = {
3040 .data = &ip_rt_gc_interval, 3161 .data = &ip_rt_gc_interval,
3041 .maxlen = sizeof(int), 3162 .maxlen = sizeof(int),
3042 .mode = 0644, 3163 .mode = 0644,
3043 .proc_handler = &proc_dointvec_jiffies, 3164 .proc_handler = proc_dointvec_jiffies,
3044 .strategy = &sysctl_jiffies, 3165 .strategy = sysctl_jiffies,
3045 }, 3166 },
3046 { 3167 {
3047 .ctl_name = NET_IPV4_ROUTE_REDIRECT_LOAD, 3168 .ctl_name = NET_IPV4_ROUTE_REDIRECT_LOAD,
@@ -3049,7 +3170,7 @@ static ctl_table ipv4_route_table[] = {
3049 .data = &ip_rt_redirect_load, 3170 .data = &ip_rt_redirect_load,
3050 .maxlen = sizeof(int), 3171 .maxlen = sizeof(int),
3051 .mode = 0644, 3172 .mode = 0644,
3052 .proc_handler = &proc_dointvec, 3173 .proc_handler = proc_dointvec,
3053 }, 3174 },
3054 { 3175 {
3055 .ctl_name = NET_IPV4_ROUTE_REDIRECT_NUMBER, 3176 .ctl_name = NET_IPV4_ROUTE_REDIRECT_NUMBER,
@@ -3057,7 +3178,7 @@ static ctl_table ipv4_route_table[] = {
3057 .data = &ip_rt_redirect_number, 3178 .data = &ip_rt_redirect_number,
3058 .maxlen = sizeof(int), 3179 .maxlen = sizeof(int),
3059 .mode = 0644, 3180 .mode = 0644,
3060 .proc_handler = &proc_dointvec, 3181 .proc_handler = proc_dointvec,
3061 }, 3182 },
3062 { 3183 {
3063 .ctl_name = NET_IPV4_ROUTE_REDIRECT_SILENCE, 3184 .ctl_name = NET_IPV4_ROUTE_REDIRECT_SILENCE,
@@ -3065,7 +3186,7 @@ static ctl_table ipv4_route_table[] = {
3065 .data = &ip_rt_redirect_silence, 3186 .data = &ip_rt_redirect_silence,
3066 .maxlen = sizeof(int), 3187 .maxlen = sizeof(int),
3067 .mode = 0644, 3188 .mode = 0644,
3068 .proc_handler = &proc_dointvec, 3189 .proc_handler = proc_dointvec,
3069 }, 3190 },
3070 { 3191 {
3071 .ctl_name = NET_IPV4_ROUTE_ERROR_COST, 3192 .ctl_name = NET_IPV4_ROUTE_ERROR_COST,
@@ -3073,7 +3194,7 @@ static ctl_table ipv4_route_table[] = {
3073 .data = &ip_rt_error_cost, 3194 .data = &ip_rt_error_cost,
3074 .maxlen = sizeof(int), 3195 .maxlen = sizeof(int),
3075 .mode = 0644, 3196 .mode = 0644,
3076 .proc_handler = &proc_dointvec, 3197 .proc_handler = proc_dointvec,
3077 }, 3198 },
3078 { 3199 {
3079 .ctl_name = NET_IPV4_ROUTE_ERROR_BURST, 3200 .ctl_name = NET_IPV4_ROUTE_ERROR_BURST,
@@ -3081,7 +3202,7 @@ static ctl_table ipv4_route_table[] = {
3081 .data = &ip_rt_error_burst, 3202 .data = &ip_rt_error_burst,
3082 .maxlen = sizeof(int), 3203 .maxlen = sizeof(int),
3083 .mode = 0644, 3204 .mode = 0644,
3084 .proc_handler = &proc_dointvec, 3205 .proc_handler = proc_dointvec,
3085 }, 3206 },
3086 { 3207 {
3087 .ctl_name = NET_IPV4_ROUTE_GC_ELASTICITY, 3208 .ctl_name = NET_IPV4_ROUTE_GC_ELASTICITY,
@@ -3089,7 +3210,7 @@ static ctl_table ipv4_route_table[] = {
3089 .data = &ip_rt_gc_elasticity, 3210 .data = &ip_rt_gc_elasticity,
3090 .maxlen = sizeof(int), 3211 .maxlen = sizeof(int),
3091 .mode = 0644, 3212 .mode = 0644,
3092 .proc_handler = &proc_dointvec, 3213 .proc_handler = proc_dointvec,
3093 }, 3214 },
3094 { 3215 {
3095 .ctl_name = NET_IPV4_ROUTE_MTU_EXPIRES, 3216 .ctl_name = NET_IPV4_ROUTE_MTU_EXPIRES,
@@ -3097,8 +3218,8 @@ static ctl_table ipv4_route_table[] = {
3097 .data = &ip_rt_mtu_expires, 3218 .data = &ip_rt_mtu_expires,
3098 .maxlen = sizeof(int), 3219 .maxlen = sizeof(int),
3099 .mode = 0644, 3220 .mode = 0644,
3100 .proc_handler = &proc_dointvec_jiffies, 3221 .proc_handler = proc_dointvec_jiffies,
3101 .strategy = &sysctl_jiffies, 3222 .strategy = sysctl_jiffies,
3102 }, 3223 },
3103 { 3224 {
3104 .ctl_name = NET_IPV4_ROUTE_MIN_PMTU, 3225 .ctl_name = NET_IPV4_ROUTE_MIN_PMTU,
@@ -3106,7 +3227,7 @@ static ctl_table ipv4_route_table[] = {
3106 .data = &ip_rt_min_pmtu, 3227 .data = &ip_rt_min_pmtu,
3107 .maxlen = sizeof(int), 3228 .maxlen = sizeof(int),
3108 .mode = 0644, 3229 .mode = 0644,
3109 .proc_handler = &proc_dointvec, 3230 .proc_handler = proc_dointvec,
3110 }, 3231 },
3111 { 3232 {
3112 .ctl_name = NET_IPV4_ROUTE_MIN_ADVMSS, 3233 .ctl_name = NET_IPV4_ROUTE_MIN_ADVMSS,
@@ -3114,7 +3235,7 @@ static ctl_table ipv4_route_table[] = {
3114 .data = &ip_rt_min_advmss, 3235 .data = &ip_rt_min_advmss,
3115 .maxlen = sizeof(int), 3236 .maxlen = sizeof(int),
3116 .mode = 0644, 3237 .mode = 0644,
3117 .proc_handler = &proc_dointvec, 3238 .proc_handler = proc_dointvec,
3118 }, 3239 },
3119 { 3240 {
3120 .ctl_name = NET_IPV4_ROUTE_SECRET_INTERVAL, 3241 .ctl_name = NET_IPV4_ROUTE_SECRET_INTERVAL,
@@ -3122,8 +3243,8 @@ static ctl_table ipv4_route_table[] = {
3122 .data = &ip_rt_secret_interval, 3243 .data = &ip_rt_secret_interval,
3123 .maxlen = sizeof(int), 3244 .maxlen = sizeof(int),
3124 .mode = 0644, 3245 .mode = 0644,
3125 .proc_handler = &ipv4_sysctl_rt_secret_interval, 3246 .proc_handler = ipv4_sysctl_rt_secret_interval,
3126 .strategy = &ipv4_sysctl_rt_secret_interval_strategy, 3247 .strategy = ipv4_sysctl_rt_secret_interval_strategy,
3127 }, 3248 },
3128 { .ctl_name = 0 } 3249 { .ctl_name = 0 }
3129}; 3250};
@@ -3151,8 +3272,8 @@ static struct ctl_table ipv4_route_flush_table[] = {
3151 .procname = "flush", 3272 .procname = "flush",
3152 .maxlen = sizeof(int), 3273 .maxlen = sizeof(int),
3153 .mode = 0200, 3274 .mode = 0200,
3154 .proc_handler = &ipv4_sysctl_rtcache_flush, 3275 .proc_handler = ipv4_sysctl_rtcache_flush,
3155 .strategy = &ipv4_sysctl_rtcache_flush_strategy, 3276 .strategy = ipv4_sysctl_rtcache_flush_strategy,
3156 }, 3277 },
3157 { .ctl_name = 0 }, 3278 { .ctl_name = 0 },
3158}; 3279};
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 1bb10df8ce7d..4710d219f06a 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -195,7 +195,7 @@ static struct ctl_table ipv4_table[] = {
195 .data = &sysctl_tcp_timestamps, 195 .data = &sysctl_tcp_timestamps,
196 .maxlen = sizeof(int), 196 .maxlen = sizeof(int),
197 .mode = 0644, 197 .mode = 0644,
198 .proc_handler = &proc_dointvec 198 .proc_handler = proc_dointvec
199 }, 199 },
200 { 200 {
201 .ctl_name = NET_IPV4_TCP_WINDOW_SCALING, 201 .ctl_name = NET_IPV4_TCP_WINDOW_SCALING,
@@ -203,7 +203,7 @@ static struct ctl_table ipv4_table[] = {
203 .data = &sysctl_tcp_window_scaling, 203 .data = &sysctl_tcp_window_scaling,
204 .maxlen = sizeof(int), 204 .maxlen = sizeof(int),
205 .mode = 0644, 205 .mode = 0644,
206 .proc_handler = &proc_dointvec 206 .proc_handler = proc_dointvec
207 }, 207 },
208 { 208 {
209 .ctl_name = NET_IPV4_TCP_SACK, 209 .ctl_name = NET_IPV4_TCP_SACK,
@@ -211,7 +211,7 @@ static struct ctl_table ipv4_table[] = {
211 .data = &sysctl_tcp_sack, 211 .data = &sysctl_tcp_sack,
212 .maxlen = sizeof(int), 212 .maxlen = sizeof(int),
213 .mode = 0644, 213 .mode = 0644,
214 .proc_handler = &proc_dointvec 214 .proc_handler = proc_dointvec
215 }, 215 },
216 { 216 {
217 .ctl_name = NET_IPV4_TCP_RETRANS_COLLAPSE, 217 .ctl_name = NET_IPV4_TCP_RETRANS_COLLAPSE,
@@ -219,7 +219,7 @@ static struct ctl_table ipv4_table[] = {
219 .data = &sysctl_tcp_retrans_collapse, 219 .data = &sysctl_tcp_retrans_collapse,
220 .maxlen = sizeof(int), 220 .maxlen = sizeof(int),
221 .mode = 0644, 221 .mode = 0644,
222 .proc_handler = &proc_dointvec 222 .proc_handler = proc_dointvec
223 }, 223 },
224 { 224 {
225 .ctl_name = NET_IPV4_DEFAULT_TTL, 225 .ctl_name = NET_IPV4_DEFAULT_TTL,
@@ -227,8 +227,8 @@ static struct ctl_table ipv4_table[] = {
227 .data = &sysctl_ip_default_ttl, 227 .data = &sysctl_ip_default_ttl,
228 .maxlen = sizeof(int), 228 .maxlen = sizeof(int),
229 .mode = 0644, 229 .mode = 0644,
230 .proc_handler = &ipv4_doint_and_flush, 230 .proc_handler = ipv4_doint_and_flush,
231 .strategy = &ipv4_doint_and_flush_strategy, 231 .strategy = ipv4_doint_and_flush_strategy,
232 .extra2 = &init_net, 232 .extra2 = &init_net,
233 }, 233 },
234 { 234 {
@@ -237,7 +237,7 @@ static struct ctl_table ipv4_table[] = {
237 .data = &ipv4_config.no_pmtu_disc, 237 .data = &ipv4_config.no_pmtu_disc,
238 .maxlen = sizeof(int), 238 .maxlen = sizeof(int),
239 .mode = 0644, 239 .mode = 0644,
240 .proc_handler = &proc_dointvec 240 .proc_handler = proc_dointvec
241 }, 241 },
242 { 242 {
243 .ctl_name = NET_IPV4_NONLOCAL_BIND, 243 .ctl_name = NET_IPV4_NONLOCAL_BIND,
@@ -245,7 +245,7 @@ static struct ctl_table ipv4_table[] = {
245 .data = &sysctl_ip_nonlocal_bind, 245 .data = &sysctl_ip_nonlocal_bind,
246 .maxlen = sizeof(int), 246 .maxlen = sizeof(int),
247 .mode = 0644, 247 .mode = 0644,
248 .proc_handler = &proc_dointvec 248 .proc_handler = proc_dointvec
249 }, 249 },
250 { 250 {
251 .ctl_name = NET_IPV4_TCP_SYN_RETRIES, 251 .ctl_name = NET_IPV4_TCP_SYN_RETRIES,
@@ -253,7 +253,7 @@ static struct ctl_table ipv4_table[] = {
253 .data = &sysctl_tcp_syn_retries, 253 .data = &sysctl_tcp_syn_retries,
254 .maxlen = sizeof(int), 254 .maxlen = sizeof(int),
255 .mode = 0644, 255 .mode = 0644,
256 .proc_handler = &proc_dointvec 256 .proc_handler = proc_dointvec
257 }, 257 },
258 { 258 {
259 .ctl_name = NET_TCP_SYNACK_RETRIES, 259 .ctl_name = NET_TCP_SYNACK_RETRIES,
@@ -261,7 +261,7 @@ static struct ctl_table ipv4_table[] = {
261 .data = &sysctl_tcp_synack_retries, 261 .data = &sysctl_tcp_synack_retries,
262 .maxlen = sizeof(int), 262 .maxlen = sizeof(int),
263 .mode = 0644, 263 .mode = 0644,
264 .proc_handler = &proc_dointvec 264 .proc_handler = proc_dointvec
265 }, 265 },
266 { 266 {
267 .ctl_name = NET_TCP_MAX_ORPHANS, 267 .ctl_name = NET_TCP_MAX_ORPHANS,
@@ -269,7 +269,7 @@ static struct ctl_table ipv4_table[] = {
269 .data = &sysctl_tcp_max_orphans, 269 .data = &sysctl_tcp_max_orphans,
270 .maxlen = sizeof(int), 270 .maxlen = sizeof(int),
271 .mode = 0644, 271 .mode = 0644,
272 .proc_handler = &proc_dointvec 272 .proc_handler = proc_dointvec
273 }, 273 },
274 { 274 {
275 .ctl_name = NET_TCP_MAX_TW_BUCKETS, 275 .ctl_name = NET_TCP_MAX_TW_BUCKETS,
@@ -277,7 +277,7 @@ static struct ctl_table ipv4_table[] = {
277 .data = &tcp_death_row.sysctl_max_tw_buckets, 277 .data = &tcp_death_row.sysctl_max_tw_buckets,
278 .maxlen = sizeof(int), 278 .maxlen = sizeof(int),
279 .mode = 0644, 279 .mode = 0644,
280 .proc_handler = &proc_dointvec 280 .proc_handler = proc_dointvec
281 }, 281 },
282 { 282 {
283 .ctl_name = NET_IPV4_DYNADDR, 283 .ctl_name = NET_IPV4_DYNADDR,
@@ -285,7 +285,7 @@ static struct ctl_table ipv4_table[] = {
285 .data = &sysctl_ip_dynaddr, 285 .data = &sysctl_ip_dynaddr,
286 .maxlen = sizeof(int), 286 .maxlen = sizeof(int),
287 .mode = 0644, 287 .mode = 0644,
288 .proc_handler = &proc_dointvec 288 .proc_handler = proc_dointvec
289 }, 289 },
290 { 290 {
291 .ctl_name = NET_IPV4_TCP_KEEPALIVE_TIME, 291 .ctl_name = NET_IPV4_TCP_KEEPALIVE_TIME,
@@ -293,8 +293,8 @@ static struct ctl_table ipv4_table[] = {
293 .data = &sysctl_tcp_keepalive_time, 293 .data = &sysctl_tcp_keepalive_time,
294 .maxlen = sizeof(int), 294 .maxlen = sizeof(int),
295 .mode = 0644, 295 .mode = 0644,
296 .proc_handler = &proc_dointvec_jiffies, 296 .proc_handler = proc_dointvec_jiffies,
297 .strategy = &sysctl_jiffies 297 .strategy = sysctl_jiffies
298 }, 298 },
299 { 299 {
300 .ctl_name = NET_IPV4_TCP_KEEPALIVE_PROBES, 300 .ctl_name = NET_IPV4_TCP_KEEPALIVE_PROBES,
@@ -302,7 +302,7 @@ static struct ctl_table ipv4_table[] = {
302 .data = &sysctl_tcp_keepalive_probes, 302 .data = &sysctl_tcp_keepalive_probes,
303 .maxlen = sizeof(int), 303 .maxlen = sizeof(int),
304 .mode = 0644, 304 .mode = 0644,
305 .proc_handler = &proc_dointvec 305 .proc_handler = proc_dointvec
306 }, 306 },
307 { 307 {
308 .ctl_name = NET_IPV4_TCP_KEEPALIVE_INTVL, 308 .ctl_name = NET_IPV4_TCP_KEEPALIVE_INTVL,
@@ -310,8 +310,8 @@ static struct ctl_table ipv4_table[] = {
310 .data = &sysctl_tcp_keepalive_intvl, 310 .data = &sysctl_tcp_keepalive_intvl,
311 .maxlen = sizeof(int), 311 .maxlen = sizeof(int),
312 .mode = 0644, 312 .mode = 0644,
313 .proc_handler = &proc_dointvec_jiffies, 313 .proc_handler = proc_dointvec_jiffies,
314 .strategy = &sysctl_jiffies 314 .strategy = sysctl_jiffies
315 }, 315 },
316 { 316 {
317 .ctl_name = NET_IPV4_TCP_RETRIES1, 317 .ctl_name = NET_IPV4_TCP_RETRIES1,
@@ -319,8 +319,8 @@ static struct ctl_table ipv4_table[] = {
319 .data = &sysctl_tcp_retries1, 319 .data = &sysctl_tcp_retries1,
320 .maxlen = sizeof(int), 320 .maxlen = sizeof(int),
321 .mode = 0644, 321 .mode = 0644,
322 .proc_handler = &proc_dointvec_minmax, 322 .proc_handler = proc_dointvec_minmax,
323 .strategy = &sysctl_intvec, 323 .strategy = sysctl_intvec,
324 .extra2 = &tcp_retr1_max 324 .extra2 = &tcp_retr1_max
325 }, 325 },
326 { 326 {
@@ -329,7 +329,7 @@ static struct ctl_table ipv4_table[] = {
329 .data = &sysctl_tcp_retries2, 329 .data = &sysctl_tcp_retries2,
330 .maxlen = sizeof(int), 330 .maxlen = sizeof(int),
331 .mode = 0644, 331 .mode = 0644,
332 .proc_handler = &proc_dointvec 332 .proc_handler = proc_dointvec
333 }, 333 },
334 { 334 {
335 .ctl_name = NET_IPV4_TCP_FIN_TIMEOUT, 335 .ctl_name = NET_IPV4_TCP_FIN_TIMEOUT,
@@ -337,8 +337,8 @@ static struct ctl_table ipv4_table[] = {
337 .data = &sysctl_tcp_fin_timeout, 337 .data = &sysctl_tcp_fin_timeout,
338 .maxlen = sizeof(int), 338 .maxlen = sizeof(int),
339 .mode = 0644, 339 .mode = 0644,
340 .proc_handler = &proc_dointvec_jiffies, 340 .proc_handler = proc_dointvec_jiffies,
341 .strategy = &sysctl_jiffies 341 .strategy = sysctl_jiffies
342 }, 342 },
343#ifdef CONFIG_SYN_COOKIES 343#ifdef CONFIG_SYN_COOKIES
344 { 344 {
@@ -347,7 +347,7 @@ static struct ctl_table ipv4_table[] = {
347 .data = &sysctl_tcp_syncookies, 347 .data = &sysctl_tcp_syncookies,
348 .maxlen = sizeof(int), 348 .maxlen = sizeof(int),
349 .mode = 0644, 349 .mode = 0644,
350 .proc_handler = &proc_dointvec 350 .proc_handler = proc_dointvec
351 }, 351 },
352#endif 352#endif
353 { 353 {
@@ -356,7 +356,7 @@ static struct ctl_table ipv4_table[] = {
356 .data = &tcp_death_row.sysctl_tw_recycle, 356 .data = &tcp_death_row.sysctl_tw_recycle,
357 .maxlen = sizeof(int), 357 .maxlen = sizeof(int),
358 .mode = 0644, 358 .mode = 0644,
359 .proc_handler = &proc_dointvec 359 .proc_handler = proc_dointvec
360 }, 360 },
361 { 361 {
362 .ctl_name = NET_TCP_ABORT_ON_OVERFLOW, 362 .ctl_name = NET_TCP_ABORT_ON_OVERFLOW,
@@ -364,7 +364,7 @@ static struct ctl_table ipv4_table[] = {
364 .data = &sysctl_tcp_abort_on_overflow, 364 .data = &sysctl_tcp_abort_on_overflow,
365 .maxlen = sizeof(int), 365 .maxlen = sizeof(int),
366 .mode = 0644, 366 .mode = 0644,
367 .proc_handler = &proc_dointvec 367 .proc_handler = proc_dointvec
368 }, 368 },
369 { 369 {
370 .ctl_name = NET_TCP_STDURG, 370 .ctl_name = NET_TCP_STDURG,
@@ -372,7 +372,7 @@ static struct ctl_table ipv4_table[] = {
372 .data = &sysctl_tcp_stdurg, 372 .data = &sysctl_tcp_stdurg,
373 .maxlen = sizeof(int), 373 .maxlen = sizeof(int),
374 .mode = 0644, 374 .mode = 0644,
375 .proc_handler = &proc_dointvec 375 .proc_handler = proc_dointvec
376 }, 376 },
377 { 377 {
378 .ctl_name = NET_TCP_RFC1337, 378 .ctl_name = NET_TCP_RFC1337,
@@ -380,7 +380,7 @@ static struct ctl_table ipv4_table[] = {
380 .data = &sysctl_tcp_rfc1337, 380 .data = &sysctl_tcp_rfc1337,
381 .maxlen = sizeof(int), 381 .maxlen = sizeof(int),
382 .mode = 0644, 382 .mode = 0644,
383 .proc_handler = &proc_dointvec 383 .proc_handler = proc_dointvec
384 }, 384 },
385 { 385 {
386 .ctl_name = NET_TCP_MAX_SYN_BACKLOG, 386 .ctl_name = NET_TCP_MAX_SYN_BACKLOG,
@@ -388,7 +388,7 @@ static struct ctl_table ipv4_table[] = {
388 .data = &sysctl_max_syn_backlog, 388 .data = &sysctl_max_syn_backlog,
389 .maxlen = sizeof(int), 389 .maxlen = sizeof(int),
390 .mode = 0644, 390 .mode = 0644,
391 .proc_handler = &proc_dointvec 391 .proc_handler = proc_dointvec
392 }, 392 },
393 { 393 {
394 .ctl_name = NET_IPV4_LOCAL_PORT_RANGE, 394 .ctl_name = NET_IPV4_LOCAL_PORT_RANGE,
@@ -396,8 +396,8 @@ static struct ctl_table ipv4_table[] = {
396 .data = &sysctl_local_ports.range, 396 .data = &sysctl_local_ports.range,
397 .maxlen = sizeof(sysctl_local_ports.range), 397 .maxlen = sizeof(sysctl_local_ports.range),
398 .mode = 0644, 398 .mode = 0644,
399 .proc_handler = &ipv4_local_port_range, 399 .proc_handler = ipv4_local_port_range,
400 .strategy = &ipv4_sysctl_local_port_range, 400 .strategy = ipv4_sysctl_local_port_range,
401 }, 401 },
402#ifdef CONFIG_IP_MULTICAST 402#ifdef CONFIG_IP_MULTICAST
403 { 403 {
@@ -406,7 +406,7 @@ static struct ctl_table ipv4_table[] = {
406 .data = &sysctl_igmp_max_memberships, 406 .data = &sysctl_igmp_max_memberships,
407 .maxlen = sizeof(int), 407 .maxlen = sizeof(int),
408 .mode = 0644, 408 .mode = 0644,
409 .proc_handler = &proc_dointvec 409 .proc_handler = proc_dointvec
410 }, 410 },
411 411
412#endif 412#endif
@@ -416,7 +416,7 @@ static struct ctl_table ipv4_table[] = {
416 .data = &sysctl_igmp_max_msf, 416 .data = &sysctl_igmp_max_msf,
417 .maxlen = sizeof(int), 417 .maxlen = sizeof(int),
418 .mode = 0644, 418 .mode = 0644,
419 .proc_handler = &proc_dointvec 419 .proc_handler = proc_dointvec
420 }, 420 },
421 { 421 {
422 .ctl_name = NET_IPV4_INET_PEER_THRESHOLD, 422 .ctl_name = NET_IPV4_INET_PEER_THRESHOLD,
@@ -424,7 +424,7 @@ static struct ctl_table ipv4_table[] = {
424 .data = &inet_peer_threshold, 424 .data = &inet_peer_threshold,
425 .maxlen = sizeof(int), 425 .maxlen = sizeof(int),
426 .mode = 0644, 426 .mode = 0644,
427 .proc_handler = &proc_dointvec 427 .proc_handler = proc_dointvec
428 }, 428 },
429 { 429 {
430 .ctl_name = NET_IPV4_INET_PEER_MINTTL, 430 .ctl_name = NET_IPV4_INET_PEER_MINTTL,
@@ -432,8 +432,8 @@ static struct ctl_table ipv4_table[] = {
432 .data = &inet_peer_minttl, 432 .data = &inet_peer_minttl,
433 .maxlen = sizeof(int), 433 .maxlen = sizeof(int),
434 .mode = 0644, 434 .mode = 0644,
435 .proc_handler = &proc_dointvec_jiffies, 435 .proc_handler = proc_dointvec_jiffies,
436 .strategy = &sysctl_jiffies 436 .strategy = sysctl_jiffies
437 }, 437 },
438 { 438 {
439 .ctl_name = NET_IPV4_INET_PEER_MAXTTL, 439 .ctl_name = NET_IPV4_INET_PEER_MAXTTL,
@@ -441,8 +441,8 @@ static struct ctl_table ipv4_table[] = {
441 .data = &inet_peer_maxttl, 441 .data = &inet_peer_maxttl,
442 .maxlen = sizeof(int), 442 .maxlen = sizeof(int),
443 .mode = 0644, 443 .mode = 0644,
444 .proc_handler = &proc_dointvec_jiffies, 444 .proc_handler = proc_dointvec_jiffies,
445 .strategy = &sysctl_jiffies 445 .strategy = sysctl_jiffies
446 }, 446 },
447 { 447 {
448 .ctl_name = NET_IPV4_INET_PEER_GC_MINTIME, 448 .ctl_name = NET_IPV4_INET_PEER_GC_MINTIME,
@@ -450,8 +450,8 @@ static struct ctl_table ipv4_table[] = {
450 .data = &inet_peer_gc_mintime, 450 .data = &inet_peer_gc_mintime,
451 .maxlen = sizeof(int), 451 .maxlen = sizeof(int),
452 .mode = 0644, 452 .mode = 0644,
453 .proc_handler = &proc_dointvec_jiffies, 453 .proc_handler = proc_dointvec_jiffies,
454 .strategy = &sysctl_jiffies 454 .strategy = sysctl_jiffies
455 }, 455 },
456 { 456 {
457 .ctl_name = NET_IPV4_INET_PEER_GC_MAXTIME, 457 .ctl_name = NET_IPV4_INET_PEER_GC_MAXTIME,
@@ -459,8 +459,8 @@ static struct ctl_table ipv4_table[] = {
459 .data = &inet_peer_gc_maxtime, 459 .data = &inet_peer_gc_maxtime,
460 .maxlen = sizeof(int), 460 .maxlen = sizeof(int),
461 .mode = 0644, 461 .mode = 0644,
462 .proc_handler = &proc_dointvec_jiffies, 462 .proc_handler = proc_dointvec_jiffies,
463 .strategy = &sysctl_jiffies 463 .strategy = sysctl_jiffies
464 }, 464 },
465 { 465 {
466 .ctl_name = NET_TCP_ORPHAN_RETRIES, 466 .ctl_name = NET_TCP_ORPHAN_RETRIES,
@@ -468,7 +468,7 @@ static struct ctl_table ipv4_table[] = {
468 .data = &sysctl_tcp_orphan_retries, 468 .data = &sysctl_tcp_orphan_retries,
469 .maxlen = sizeof(int), 469 .maxlen = sizeof(int),
470 .mode = 0644, 470 .mode = 0644,
471 .proc_handler = &proc_dointvec 471 .proc_handler = proc_dointvec
472 }, 472 },
473 { 473 {
474 .ctl_name = NET_TCP_FACK, 474 .ctl_name = NET_TCP_FACK,
@@ -476,7 +476,7 @@ static struct ctl_table ipv4_table[] = {
476 .data = &sysctl_tcp_fack, 476 .data = &sysctl_tcp_fack,
477 .maxlen = sizeof(int), 477 .maxlen = sizeof(int),
478 .mode = 0644, 478 .mode = 0644,
479 .proc_handler = &proc_dointvec 479 .proc_handler = proc_dointvec
480 }, 480 },
481 { 481 {
482 .ctl_name = NET_TCP_REORDERING, 482 .ctl_name = NET_TCP_REORDERING,
@@ -484,7 +484,7 @@ static struct ctl_table ipv4_table[] = {
484 .data = &sysctl_tcp_reordering, 484 .data = &sysctl_tcp_reordering,
485 .maxlen = sizeof(int), 485 .maxlen = sizeof(int),
486 .mode = 0644, 486 .mode = 0644,
487 .proc_handler = &proc_dointvec 487 .proc_handler = proc_dointvec
488 }, 488 },
489 { 489 {
490 .ctl_name = NET_TCP_ECN, 490 .ctl_name = NET_TCP_ECN,
@@ -492,7 +492,7 @@ static struct ctl_table ipv4_table[] = {
492 .data = &sysctl_tcp_ecn, 492 .data = &sysctl_tcp_ecn,
493 .maxlen = sizeof(int), 493 .maxlen = sizeof(int),
494 .mode = 0644, 494 .mode = 0644,
495 .proc_handler = &proc_dointvec 495 .proc_handler = proc_dointvec
496 }, 496 },
497 { 497 {
498 .ctl_name = NET_TCP_DSACK, 498 .ctl_name = NET_TCP_DSACK,
@@ -500,7 +500,7 @@ static struct ctl_table ipv4_table[] = {
500 .data = &sysctl_tcp_dsack, 500 .data = &sysctl_tcp_dsack,
501 .maxlen = sizeof(int), 501 .maxlen = sizeof(int),
502 .mode = 0644, 502 .mode = 0644,
503 .proc_handler = &proc_dointvec 503 .proc_handler = proc_dointvec
504 }, 504 },
505 { 505 {
506 .ctl_name = NET_TCP_MEM, 506 .ctl_name = NET_TCP_MEM,
@@ -508,7 +508,7 @@ static struct ctl_table ipv4_table[] = {
508 .data = &sysctl_tcp_mem, 508 .data = &sysctl_tcp_mem,
509 .maxlen = sizeof(sysctl_tcp_mem), 509 .maxlen = sizeof(sysctl_tcp_mem),
510 .mode = 0644, 510 .mode = 0644,
511 .proc_handler = &proc_dointvec 511 .proc_handler = proc_dointvec
512 }, 512 },
513 { 513 {
514 .ctl_name = NET_TCP_WMEM, 514 .ctl_name = NET_TCP_WMEM,
@@ -516,7 +516,7 @@ static struct ctl_table ipv4_table[] = {
516 .data = &sysctl_tcp_wmem, 516 .data = &sysctl_tcp_wmem,
517 .maxlen = sizeof(sysctl_tcp_wmem), 517 .maxlen = sizeof(sysctl_tcp_wmem),
518 .mode = 0644, 518 .mode = 0644,
519 .proc_handler = &proc_dointvec 519 .proc_handler = proc_dointvec
520 }, 520 },
521 { 521 {
522 .ctl_name = NET_TCP_RMEM, 522 .ctl_name = NET_TCP_RMEM,
@@ -524,7 +524,7 @@ static struct ctl_table ipv4_table[] = {
524 .data = &sysctl_tcp_rmem, 524 .data = &sysctl_tcp_rmem,
525 .maxlen = sizeof(sysctl_tcp_rmem), 525 .maxlen = sizeof(sysctl_tcp_rmem),
526 .mode = 0644, 526 .mode = 0644,
527 .proc_handler = &proc_dointvec 527 .proc_handler = proc_dointvec
528 }, 528 },
529 { 529 {
530 .ctl_name = NET_TCP_APP_WIN, 530 .ctl_name = NET_TCP_APP_WIN,
@@ -532,7 +532,7 @@ static struct ctl_table ipv4_table[] = {
532 .data = &sysctl_tcp_app_win, 532 .data = &sysctl_tcp_app_win,
533 .maxlen = sizeof(int), 533 .maxlen = sizeof(int),
534 .mode = 0644, 534 .mode = 0644,
535 .proc_handler = &proc_dointvec 535 .proc_handler = proc_dointvec
536 }, 536 },
537 { 537 {
538 .ctl_name = NET_TCP_ADV_WIN_SCALE, 538 .ctl_name = NET_TCP_ADV_WIN_SCALE,
@@ -540,7 +540,7 @@ static struct ctl_table ipv4_table[] = {
540 .data = &sysctl_tcp_adv_win_scale, 540 .data = &sysctl_tcp_adv_win_scale,
541 .maxlen = sizeof(int), 541 .maxlen = sizeof(int),
542 .mode = 0644, 542 .mode = 0644,
543 .proc_handler = &proc_dointvec 543 .proc_handler = proc_dointvec
544 }, 544 },
545 { 545 {
546 .ctl_name = NET_TCP_TW_REUSE, 546 .ctl_name = NET_TCP_TW_REUSE,
@@ -548,7 +548,7 @@ static struct ctl_table ipv4_table[] = {
548 .data = &sysctl_tcp_tw_reuse, 548 .data = &sysctl_tcp_tw_reuse,
549 .maxlen = sizeof(int), 549 .maxlen = sizeof(int),
550 .mode = 0644, 550 .mode = 0644,
551 .proc_handler = &proc_dointvec 551 .proc_handler = proc_dointvec
552 }, 552 },
553 { 553 {
554 .ctl_name = NET_TCP_FRTO, 554 .ctl_name = NET_TCP_FRTO,
@@ -556,7 +556,7 @@ static struct ctl_table ipv4_table[] = {
556 .data = &sysctl_tcp_frto, 556 .data = &sysctl_tcp_frto,
557 .maxlen = sizeof(int), 557 .maxlen = sizeof(int),
558 .mode = 0644, 558 .mode = 0644,
559 .proc_handler = &proc_dointvec 559 .proc_handler = proc_dointvec
560 }, 560 },
561 { 561 {
562 .ctl_name = NET_TCP_FRTO_RESPONSE, 562 .ctl_name = NET_TCP_FRTO_RESPONSE,
@@ -564,7 +564,7 @@ static struct ctl_table ipv4_table[] = {
564 .data = &sysctl_tcp_frto_response, 564 .data = &sysctl_tcp_frto_response,
565 .maxlen = sizeof(int), 565 .maxlen = sizeof(int),
566 .mode = 0644, 566 .mode = 0644,
567 .proc_handler = &proc_dointvec 567 .proc_handler = proc_dointvec
568 }, 568 },
569 { 569 {
570 .ctl_name = NET_TCP_LOW_LATENCY, 570 .ctl_name = NET_TCP_LOW_LATENCY,
@@ -572,7 +572,7 @@ static struct ctl_table ipv4_table[] = {
572 .data = &sysctl_tcp_low_latency, 572 .data = &sysctl_tcp_low_latency,
573 .maxlen = sizeof(int), 573 .maxlen = sizeof(int),
574 .mode = 0644, 574 .mode = 0644,
575 .proc_handler = &proc_dointvec 575 .proc_handler = proc_dointvec
576 }, 576 },
577 { 577 {
578 .ctl_name = NET_TCP_NO_METRICS_SAVE, 578 .ctl_name = NET_TCP_NO_METRICS_SAVE,
@@ -580,7 +580,7 @@ static struct ctl_table ipv4_table[] = {
580 .data = &sysctl_tcp_nometrics_save, 580 .data = &sysctl_tcp_nometrics_save,
581 .maxlen = sizeof(int), 581 .maxlen = sizeof(int),
582 .mode = 0644, 582 .mode = 0644,
583 .proc_handler = &proc_dointvec, 583 .proc_handler = proc_dointvec,
584 }, 584 },
585 { 585 {
586 .ctl_name = NET_TCP_MODERATE_RCVBUF, 586 .ctl_name = NET_TCP_MODERATE_RCVBUF,
@@ -588,7 +588,7 @@ static struct ctl_table ipv4_table[] = {
588 .data = &sysctl_tcp_moderate_rcvbuf, 588 .data = &sysctl_tcp_moderate_rcvbuf,
589 .maxlen = sizeof(int), 589 .maxlen = sizeof(int),
590 .mode = 0644, 590 .mode = 0644,
591 .proc_handler = &proc_dointvec, 591 .proc_handler = proc_dointvec,
592 }, 592 },
593 { 593 {
594 .ctl_name = NET_TCP_TSO_WIN_DIVISOR, 594 .ctl_name = NET_TCP_TSO_WIN_DIVISOR,
@@ -596,15 +596,15 @@ static struct ctl_table ipv4_table[] = {
596 .data = &sysctl_tcp_tso_win_divisor, 596 .data = &sysctl_tcp_tso_win_divisor,
597 .maxlen = sizeof(int), 597 .maxlen = sizeof(int),
598 .mode = 0644, 598 .mode = 0644,
599 .proc_handler = &proc_dointvec, 599 .proc_handler = proc_dointvec,
600 }, 600 },
601 { 601 {
602 .ctl_name = NET_TCP_CONG_CONTROL, 602 .ctl_name = NET_TCP_CONG_CONTROL,
603 .procname = "tcp_congestion_control", 603 .procname = "tcp_congestion_control",
604 .mode = 0644, 604 .mode = 0644,
605 .maxlen = TCP_CA_NAME_MAX, 605 .maxlen = TCP_CA_NAME_MAX,
606 .proc_handler = &proc_tcp_congestion_control, 606 .proc_handler = proc_tcp_congestion_control,
607 .strategy = &sysctl_tcp_congestion_control, 607 .strategy = sysctl_tcp_congestion_control,
608 }, 608 },
609 { 609 {
610 .ctl_name = NET_TCP_ABC, 610 .ctl_name = NET_TCP_ABC,
@@ -612,7 +612,7 @@ static struct ctl_table ipv4_table[] = {
612 .data = &sysctl_tcp_abc, 612 .data = &sysctl_tcp_abc,
613 .maxlen = sizeof(int), 613 .maxlen = sizeof(int),
614 .mode = 0644, 614 .mode = 0644,
615 .proc_handler = &proc_dointvec, 615 .proc_handler = proc_dointvec,
616 }, 616 },
617 { 617 {
618 .ctl_name = NET_TCP_MTU_PROBING, 618 .ctl_name = NET_TCP_MTU_PROBING,
@@ -620,7 +620,7 @@ static struct ctl_table ipv4_table[] = {
620 .data = &sysctl_tcp_mtu_probing, 620 .data = &sysctl_tcp_mtu_probing,
621 .maxlen = sizeof(int), 621 .maxlen = sizeof(int),
622 .mode = 0644, 622 .mode = 0644,
623 .proc_handler = &proc_dointvec, 623 .proc_handler = proc_dointvec,
624 }, 624 },
625 { 625 {
626 .ctl_name = NET_TCP_BASE_MSS, 626 .ctl_name = NET_TCP_BASE_MSS,
@@ -628,7 +628,7 @@ static struct ctl_table ipv4_table[] = {
628 .data = &sysctl_tcp_base_mss, 628 .data = &sysctl_tcp_base_mss,
629 .maxlen = sizeof(int), 629 .maxlen = sizeof(int),
630 .mode = 0644, 630 .mode = 0644,
631 .proc_handler = &proc_dointvec, 631 .proc_handler = proc_dointvec,
632 }, 632 },
633 { 633 {
634 .ctl_name = NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS, 634 .ctl_name = NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS,
@@ -636,7 +636,7 @@ static struct ctl_table ipv4_table[] = {
636 .data = &sysctl_tcp_workaround_signed_windows, 636 .data = &sysctl_tcp_workaround_signed_windows,
637 .maxlen = sizeof(int), 637 .maxlen = sizeof(int),
638 .mode = 0644, 638 .mode = 0644,
639 .proc_handler = &proc_dointvec 639 .proc_handler = proc_dointvec
640 }, 640 },
641#ifdef CONFIG_NET_DMA 641#ifdef CONFIG_NET_DMA
642 { 642 {
@@ -645,7 +645,7 @@ static struct ctl_table ipv4_table[] = {
645 .data = &sysctl_tcp_dma_copybreak, 645 .data = &sysctl_tcp_dma_copybreak,
646 .maxlen = sizeof(int), 646 .maxlen = sizeof(int),
647 .mode = 0644, 647 .mode = 0644,
648 .proc_handler = &proc_dointvec 648 .proc_handler = proc_dointvec
649 }, 649 },
650#endif 650#endif
651 { 651 {
@@ -654,7 +654,7 @@ static struct ctl_table ipv4_table[] = {
654 .data = &sysctl_tcp_slow_start_after_idle, 654 .data = &sysctl_tcp_slow_start_after_idle,
655 .maxlen = sizeof(int), 655 .maxlen = sizeof(int),
656 .mode = 0644, 656 .mode = 0644,
657 .proc_handler = &proc_dointvec 657 .proc_handler = proc_dointvec
658 }, 658 },
659#ifdef CONFIG_NETLABEL 659#ifdef CONFIG_NETLABEL
660 { 660 {
@@ -663,7 +663,7 @@ static struct ctl_table ipv4_table[] = {
663 .data = &cipso_v4_cache_enabled, 663 .data = &cipso_v4_cache_enabled,
664 .maxlen = sizeof(int), 664 .maxlen = sizeof(int),
665 .mode = 0644, 665 .mode = 0644,
666 .proc_handler = &proc_dointvec, 666 .proc_handler = proc_dointvec,
667 }, 667 },
668 { 668 {
669 .ctl_name = NET_CIPSOV4_CACHE_BUCKET_SIZE, 669 .ctl_name = NET_CIPSOV4_CACHE_BUCKET_SIZE,
@@ -671,7 +671,7 @@ static struct ctl_table ipv4_table[] = {
671 .data = &cipso_v4_cache_bucketsize, 671 .data = &cipso_v4_cache_bucketsize,
672 .maxlen = sizeof(int), 672 .maxlen = sizeof(int),
673 .mode = 0644, 673 .mode = 0644,
674 .proc_handler = &proc_dointvec, 674 .proc_handler = proc_dointvec,
675 }, 675 },
676 { 676 {
677 .ctl_name = NET_CIPSOV4_RBM_OPTFMT, 677 .ctl_name = NET_CIPSOV4_RBM_OPTFMT,
@@ -679,7 +679,7 @@ static struct ctl_table ipv4_table[] = {
679 .data = &cipso_v4_rbm_optfmt, 679 .data = &cipso_v4_rbm_optfmt,
680 .maxlen = sizeof(int), 680 .maxlen = sizeof(int),
681 .mode = 0644, 681 .mode = 0644,
682 .proc_handler = &proc_dointvec, 682 .proc_handler = proc_dointvec,
683 }, 683 },
684 { 684 {
685 .ctl_name = NET_CIPSOV4_RBM_STRICTVALID, 685 .ctl_name = NET_CIPSOV4_RBM_STRICTVALID,
@@ -687,22 +687,22 @@ static struct ctl_table ipv4_table[] = {
687 .data = &cipso_v4_rbm_strictvalid, 687 .data = &cipso_v4_rbm_strictvalid,
688 .maxlen = sizeof(int), 688 .maxlen = sizeof(int),
689 .mode = 0644, 689 .mode = 0644,
690 .proc_handler = &proc_dointvec, 690 .proc_handler = proc_dointvec,
691 }, 691 },
692#endif /* CONFIG_NETLABEL */ 692#endif /* CONFIG_NETLABEL */
693 { 693 {
694 .procname = "tcp_available_congestion_control", 694 .procname = "tcp_available_congestion_control",
695 .maxlen = TCP_CA_BUF_MAX, 695 .maxlen = TCP_CA_BUF_MAX,
696 .mode = 0444, 696 .mode = 0444,
697 .proc_handler = &proc_tcp_available_congestion_control, 697 .proc_handler = proc_tcp_available_congestion_control,
698 }, 698 },
699 { 699 {
700 .ctl_name = NET_TCP_ALLOWED_CONG_CONTROL, 700 .ctl_name = NET_TCP_ALLOWED_CONG_CONTROL,
701 .procname = "tcp_allowed_congestion_control", 701 .procname = "tcp_allowed_congestion_control",
702 .maxlen = TCP_CA_BUF_MAX, 702 .maxlen = TCP_CA_BUF_MAX,
703 .mode = 0644, 703 .mode = 0644,
704 .proc_handler = &proc_allowed_congestion_control, 704 .proc_handler = proc_allowed_congestion_control,
705 .strategy = &strategy_allowed_congestion_control, 705 .strategy = strategy_allowed_congestion_control,
706 }, 706 },
707 { 707 {
708 .ctl_name = NET_TCP_MAX_SSTHRESH, 708 .ctl_name = NET_TCP_MAX_SSTHRESH,
@@ -710,7 +710,7 @@ static struct ctl_table ipv4_table[] = {
710 .data = &sysctl_tcp_max_ssthresh, 710 .data = &sysctl_tcp_max_ssthresh,
711 .maxlen = sizeof(int), 711 .maxlen = sizeof(int),
712 .mode = 0644, 712 .mode = 0644,
713 .proc_handler = &proc_dointvec, 713 .proc_handler = proc_dointvec,
714 }, 714 },
715 { 715 {
716 .ctl_name = CTL_UNNUMBERED, 716 .ctl_name = CTL_UNNUMBERED,
@@ -718,8 +718,8 @@ static struct ctl_table ipv4_table[] = {
718 .data = &sysctl_udp_mem, 718 .data = &sysctl_udp_mem,
719 .maxlen = sizeof(sysctl_udp_mem), 719 .maxlen = sizeof(sysctl_udp_mem),
720 .mode = 0644, 720 .mode = 0644,
721 .proc_handler = &proc_dointvec_minmax, 721 .proc_handler = proc_dointvec_minmax,
722 .strategy = &sysctl_intvec, 722 .strategy = sysctl_intvec,
723 .extra1 = &zero 723 .extra1 = &zero
724 }, 724 },
725 { 725 {
@@ -728,8 +728,8 @@ static struct ctl_table ipv4_table[] = {
728 .data = &sysctl_udp_rmem_min, 728 .data = &sysctl_udp_rmem_min,
729 .maxlen = sizeof(sysctl_udp_rmem_min), 729 .maxlen = sizeof(sysctl_udp_rmem_min),
730 .mode = 0644, 730 .mode = 0644,
731 .proc_handler = &proc_dointvec_minmax, 731 .proc_handler = proc_dointvec_minmax,
732 .strategy = &sysctl_intvec, 732 .strategy = sysctl_intvec,
733 .extra1 = &zero 733 .extra1 = &zero
734 }, 734 },
735 { 735 {
@@ -738,8 +738,8 @@ static struct ctl_table ipv4_table[] = {
738 .data = &sysctl_udp_wmem_min, 738 .data = &sysctl_udp_wmem_min,
739 .maxlen = sizeof(sysctl_udp_wmem_min), 739 .maxlen = sizeof(sysctl_udp_wmem_min),
740 .mode = 0644, 740 .mode = 0644,
741 .proc_handler = &proc_dointvec_minmax, 741 .proc_handler = proc_dointvec_minmax,
742 .strategy = &sysctl_intvec, 742 .strategy = sysctl_intvec,
743 .extra1 = &zero 743 .extra1 = &zero
744 }, 744 },
745 { .ctl_name = 0 } 745 { .ctl_name = 0 }
@@ -752,7 +752,7 @@ static struct ctl_table ipv4_net_table[] = {
752 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, 752 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
753 .maxlen = sizeof(int), 753 .maxlen = sizeof(int),
754 .mode = 0644, 754 .mode = 0644,
755 .proc_handler = &proc_dointvec 755 .proc_handler = proc_dointvec
756 }, 756 },
757 { 757 {
758 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, 758 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,
@@ -760,7 +760,7 @@ static struct ctl_table ipv4_net_table[] = {
760 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, 760 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
761 .maxlen = sizeof(int), 761 .maxlen = sizeof(int),
762 .mode = 0644, 762 .mode = 0644,
763 .proc_handler = &proc_dointvec 763 .proc_handler = proc_dointvec
764 }, 764 },
765 { 765 {
766 .ctl_name = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, 766 .ctl_name = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES,
@@ -768,7 +768,7 @@ static struct ctl_table ipv4_net_table[] = {
768 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, 768 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
769 .maxlen = sizeof(int), 769 .maxlen = sizeof(int),
770 .mode = 0644, 770 .mode = 0644,
771 .proc_handler = &proc_dointvec 771 .proc_handler = proc_dointvec
772 }, 772 },
773 { 773 {
774 .ctl_name = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR, 774 .ctl_name = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,
@@ -776,7 +776,7 @@ static struct ctl_table ipv4_net_table[] = {
776 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, 776 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
777 .maxlen = sizeof(int), 777 .maxlen = sizeof(int),
778 .mode = 0644, 778 .mode = 0644,
779 .proc_handler = &proc_dointvec 779 .proc_handler = proc_dointvec
780 }, 780 },
781 { 781 {
782 .ctl_name = NET_IPV4_ICMP_RATELIMIT, 782 .ctl_name = NET_IPV4_ICMP_RATELIMIT,
@@ -784,8 +784,8 @@ static struct ctl_table ipv4_net_table[] = {
784 .data = &init_net.ipv4.sysctl_icmp_ratelimit, 784 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
785 .maxlen = sizeof(int), 785 .maxlen = sizeof(int),
786 .mode = 0644, 786 .mode = 0644,
787 .proc_handler = &proc_dointvec_ms_jiffies, 787 .proc_handler = proc_dointvec_ms_jiffies,
788 .strategy = &sysctl_ms_jiffies 788 .strategy = sysctl_ms_jiffies
789 }, 789 },
790 { 790 {
791 .ctl_name = NET_IPV4_ICMP_RATEMASK, 791 .ctl_name = NET_IPV4_ICMP_RATEMASK,
@@ -793,7 +793,15 @@ static struct ctl_table ipv4_net_table[] = {
793 .data = &init_net.ipv4.sysctl_icmp_ratemask, 793 .data = &init_net.ipv4.sysctl_icmp_ratemask,
794 .maxlen = sizeof(int), 794 .maxlen = sizeof(int),
795 .mode = 0644, 795 .mode = 0644,
796 .proc_handler = &proc_dointvec 796 .proc_handler = proc_dointvec
797 },
798 {
799 .ctl_name = CTL_UNNUMBERED,
800 .procname = "rt_cache_rebuild_count",
801 .data = &init_net.ipv4.sysctl_rt_cache_rebuild_count,
802 .maxlen = sizeof(int),
803 .mode = 0644,
804 .proc_handler = proc_dointvec
797 }, 805 },
798 { } 806 { }
799}; 807};
@@ -827,8 +835,12 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
827 &net->ipv4.sysctl_icmp_ratelimit; 835 &net->ipv4.sysctl_icmp_ratelimit;
828 table[5].data = 836 table[5].data =
829 &net->ipv4.sysctl_icmp_ratemask; 837 &net->ipv4.sysctl_icmp_ratemask;
838 table[6].data =
839 &net->ipv4.sysctl_rt_cache_rebuild_count;
830 } 840 }
831 841
842 net->ipv4.sysctl_rt_cache_rebuild_count = 4;
843
832 net->ipv4.ipv4_hdr = register_net_sysctl_table(net, 844 net->ipv4.ipv4_hdr = register_net_sysctl_table(net,
833 net_ipv4_ctl_path, table); 845 net_ipv4_ctl_path, table);
834 if (net->ipv4.ipv4_hdr == NULL) 846 if (net->ipv4.ipv4_hdr == NULL)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c5aca0bb116a..044224a341eb 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1680,7 +1680,7 @@ void tcp_set_state(struct sock *sk, int state)
1680 inet_put_port(sk); 1680 inet_put_port(sk);
1681 /* fall through */ 1681 /* fall through */
1682 default: 1682 default:
1683 if (oldstate==TCP_ESTABLISHED) 1683 if (oldstate == TCP_ESTABLISHED)
1684 TCP_DEC_STATS(sock_net(sk), TCP_MIB_CURRESTAB); 1684 TCP_DEC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);
1685 } 1685 }
1686 1686
@@ -1690,7 +1690,7 @@ void tcp_set_state(struct sock *sk, int state)
1690 sk->sk_state = state; 1690 sk->sk_state = state;
1691 1691
1692#ifdef STATE_TRACE 1692#ifdef STATE_TRACE
1693 SOCK_DEBUG(sk, "TCP sk=%p, State %s -> %s\n",sk, statename[oldstate],statename[state]); 1693 SOCK_DEBUG(sk, "TCP sk=%p, State %s -> %s\n", sk, statename[oldstate], statename[state]);
1694#endif 1694#endif
1695} 1695}
1696EXPORT_SYMBOL_GPL(tcp_set_state); 1696EXPORT_SYMBOL_GPL(tcp_set_state);
@@ -2650,7 +2650,7 @@ EXPORT_SYMBOL(tcp_md5_hash_key);
2650 2650
2651void tcp_done(struct sock *sk) 2651void tcp_done(struct sock *sk)
2652{ 2652{
2653 if(sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV) 2653 if (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)
2654 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_ATTEMPTFAILS); 2654 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
2655 2655
2656 tcp_set_state(sk, TCP_CLOSE); 2656 tcp_set_state(sk, TCP_CLOSE);
@@ -2707,8 +2707,8 @@ void __init tcp_init(void)
2707 thash_entries ? 0 : 512 * 1024); 2707 thash_entries ? 0 : 512 * 1024);
2708 tcp_hashinfo.ehash_size = 1 << tcp_hashinfo.ehash_size; 2708 tcp_hashinfo.ehash_size = 1 << tcp_hashinfo.ehash_size;
2709 for (i = 0; i < tcp_hashinfo.ehash_size; i++) { 2709 for (i = 0; i < tcp_hashinfo.ehash_size; i++) {
2710 INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].chain); 2710 INIT_HLIST_NULLS_HEAD(&tcp_hashinfo.ehash[i].chain, i);
2711 INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].twchain); 2711 INIT_HLIST_NULLS_HEAD(&tcp_hashinfo.ehash[i].twchain, i);
2712 } 2712 }
2713 if (inet_ehash_locks_alloc(&tcp_hashinfo)) 2713 if (inet_ehash_locks_alloc(&tcp_hashinfo))
2714 panic("TCP: failed to alloc ehash_locks"); 2714 panic("TCP: failed to alloc ehash_locks");
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 4a1221e5e8ee..ee467ec40c4f 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -1,13 +1,23 @@
1/* 1/*
2 * TCP CUBIC: Binary Increase Congestion control for TCP v2.2 2 * TCP CUBIC: Binary Increase Congestion control for TCP v2.3
3 * Home page: 3 * Home page:
4 * http://netsrv.csc.ncsu.edu/twiki/bin/view/Main/BIC 4 * http://netsrv.csc.ncsu.edu/twiki/bin/view/Main/BIC
5 * This is from the implementation of CUBIC TCP in 5 * This is from the implementation of CUBIC TCP in
6 * Injong Rhee, Lisong Xu. 6 * Sangtae Ha, Injong Rhee and Lisong Xu,
7 * "CUBIC: A New TCP-Friendly High-Speed TCP Variant 7 * "CUBIC: A New TCP-Friendly High-Speed TCP Variant"
8 * in PFLDnet 2005 8 * in ACM SIGOPS Operating System Review, July 2008.
9 * Available from: 9 * Available from:
10 * http://netsrv.csc.ncsu.edu/export/cubic-paper.pdf 10 * http://netsrv.csc.ncsu.edu/export/cubic_a_new_tcp_2008.pdf
11 *
12 * CUBIC integrates a new slow start algorithm, called HyStart.
13 * The details of HyStart are presented in
14 * Sangtae Ha and Injong Rhee,
15 * "Taming the Elephants: New TCP Slow Start", NCSU TechReport 2008.
16 * Available from:
17 * http://netsrv.csc.ncsu.edu/export/hystart_techreport_2008.pdf
18 *
19 * All testing results are available from:
20 * http://netsrv.csc.ncsu.edu/wiki/index.php/TCP_Testing
11 * 21 *
12 * Unless CUBIC is enabled and congestion window is large 22 * Unless CUBIC is enabled and congestion window is large
13 * this behaves the same as the original Reno. 23 * this behaves the same as the original Reno.
@@ -23,12 +33,26 @@
23 */ 33 */
24#define BICTCP_HZ 10 /* BIC HZ 2^10 = 1024 */ 34#define BICTCP_HZ 10 /* BIC HZ 2^10 = 1024 */
25 35
36/* Two methods of hybrid slow start */
37#define HYSTART_ACK_TRAIN 0x1
38#define HYSTART_DELAY 0x2
39
40/* Number of delay samples for detecting the increase of delay */
41#define HYSTART_MIN_SAMPLES 8
42#define HYSTART_DELAY_MIN (2U<<3)
43#define HYSTART_DELAY_MAX (16U<<3)
44#define HYSTART_DELAY_THRESH(x) clamp(x, HYSTART_DELAY_MIN, HYSTART_DELAY_MAX)
45
26static int fast_convergence __read_mostly = 1; 46static int fast_convergence __read_mostly = 1;
27static int beta __read_mostly = 717; /* = 717/1024 (BICTCP_BETA_SCALE) */ 47static int beta __read_mostly = 717; /* = 717/1024 (BICTCP_BETA_SCALE) */
28static int initial_ssthresh __read_mostly; 48static int initial_ssthresh __read_mostly;
29static int bic_scale __read_mostly = 41; 49static int bic_scale __read_mostly = 41;
30static int tcp_friendliness __read_mostly = 1; 50static int tcp_friendliness __read_mostly = 1;
31 51
52static int hystart __read_mostly = 1;
53static int hystart_detect __read_mostly = HYSTART_ACK_TRAIN | HYSTART_DELAY;
54static int hystart_low_window __read_mostly = 16;
55
32static u32 cube_rtt_scale __read_mostly; 56static u32 cube_rtt_scale __read_mostly;
33static u32 beta_scale __read_mostly; 57static u32 beta_scale __read_mostly;
34static u64 cube_factor __read_mostly; 58static u64 cube_factor __read_mostly;
@@ -44,6 +68,13 @@ module_param(bic_scale, int, 0444);
44MODULE_PARM_DESC(bic_scale, "scale (scaled by 1024) value for bic function (bic_scale/1024)"); 68MODULE_PARM_DESC(bic_scale, "scale (scaled by 1024) value for bic function (bic_scale/1024)");
45module_param(tcp_friendliness, int, 0644); 69module_param(tcp_friendliness, int, 0644);
46MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness"); 70MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness");
71module_param(hystart, int, 0644);
72MODULE_PARM_DESC(hystart, "turn on/off hybrid slow start algorithm");
73module_param(hystart_detect, int, 0644);
74MODULE_PARM_DESC(hystart_detect, "hyrbrid slow start detection mechanisms"
75 " 1: packet-train 2: delay 3: both packet-train and delay");
76module_param(hystart_low_window, int, 0644);
77MODULE_PARM_DESC(hystart_low_window, "lower bound cwnd for hybrid slow start");
47 78
48/* BIC TCP Parameters */ 79/* BIC TCP Parameters */
49struct bictcp { 80struct bictcp {
@@ -59,7 +90,13 @@ struct bictcp {
59 u32 ack_cnt; /* number of acks */ 90 u32 ack_cnt; /* number of acks */
60 u32 tcp_cwnd; /* estimated tcp cwnd */ 91 u32 tcp_cwnd; /* estimated tcp cwnd */
61#define ACK_RATIO_SHIFT 4 92#define ACK_RATIO_SHIFT 4
62 u32 delayed_ack; /* estimate the ratio of Packets/ACKs << 4 */ 93 u16 delayed_ack; /* estimate the ratio of Packets/ACKs << 4 */
94 u8 sample_cnt; /* number of samples to decide curr_rtt */
95 u8 found; /* the exit point is found? */
96 u32 round_start; /* beginning of each round */
97 u32 end_seq; /* end_seq of the round */
98 u32 last_jiffies; /* last time when the ACK spacing is close */
99 u32 curr_rtt; /* the minimum rtt of current round */
63}; 100};
64 101
65static inline void bictcp_reset(struct bictcp *ca) 102static inline void bictcp_reset(struct bictcp *ca)
@@ -76,12 +113,28 @@ static inline void bictcp_reset(struct bictcp *ca)
76 ca->delayed_ack = 2 << ACK_RATIO_SHIFT; 113 ca->delayed_ack = 2 << ACK_RATIO_SHIFT;
77 ca->ack_cnt = 0; 114 ca->ack_cnt = 0;
78 ca->tcp_cwnd = 0; 115 ca->tcp_cwnd = 0;
116 ca->found = 0;
117}
118
119static inline void bictcp_hystart_reset(struct sock *sk)
120{
121 struct tcp_sock *tp = tcp_sk(sk);
122 struct bictcp *ca = inet_csk_ca(sk);
123
124 ca->round_start = ca->last_jiffies = jiffies;
125 ca->end_seq = tp->snd_nxt;
126 ca->curr_rtt = 0;
127 ca->sample_cnt = 0;
79} 128}
80 129
81static void bictcp_init(struct sock *sk) 130static void bictcp_init(struct sock *sk)
82{ 131{
83 bictcp_reset(inet_csk_ca(sk)); 132 bictcp_reset(inet_csk_ca(sk));
84 if (initial_ssthresh) 133
134 if (hystart)
135 bictcp_hystart_reset(sk);
136
137 if (!hystart && initial_ssthresh)
85 tcp_sk(sk)->snd_ssthresh = initial_ssthresh; 138 tcp_sk(sk)->snd_ssthresh = initial_ssthresh;
86} 139}
87 140
@@ -235,9 +288,11 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
235 if (!tcp_is_cwnd_limited(sk, in_flight)) 288 if (!tcp_is_cwnd_limited(sk, in_flight))
236 return; 289 return;
237 290
238 if (tp->snd_cwnd <= tp->snd_ssthresh) 291 if (tp->snd_cwnd <= tp->snd_ssthresh) {
292 if (hystart && after(ack, ca->end_seq))
293 bictcp_hystart_reset(sk);
239 tcp_slow_start(tp); 294 tcp_slow_start(tp);
240 else { 295 } else {
241 bictcp_update(ca, tp->snd_cwnd); 296 bictcp_update(ca, tp->snd_cwnd);
242 297
243 /* In dangerous area, increase slowly. 298 /* In dangerous area, increase slowly.
@@ -281,8 +336,45 @@ static u32 bictcp_undo_cwnd(struct sock *sk)
281 336
282static void bictcp_state(struct sock *sk, u8 new_state) 337static void bictcp_state(struct sock *sk, u8 new_state)
283{ 338{
284 if (new_state == TCP_CA_Loss) 339 if (new_state == TCP_CA_Loss) {
285 bictcp_reset(inet_csk_ca(sk)); 340 bictcp_reset(inet_csk_ca(sk));
341 bictcp_hystart_reset(sk);
342 }
343}
344
345static void hystart_update(struct sock *sk, u32 delay)
346{
347 struct tcp_sock *tp = tcp_sk(sk);
348 struct bictcp *ca = inet_csk_ca(sk);
349
350 if (!(ca->found & hystart_detect)) {
351 u32 curr_jiffies = jiffies;
352
353 /* first detection parameter - ack-train detection */
354 if (curr_jiffies - ca->last_jiffies <= msecs_to_jiffies(2)) {
355 ca->last_jiffies = curr_jiffies;
356 if (curr_jiffies - ca->round_start >= ca->delay_min>>4)
357 ca->found |= HYSTART_ACK_TRAIN;
358 }
359
360 /* obtain the minimum delay of more than sampling packets */
361 if (ca->sample_cnt < HYSTART_MIN_SAMPLES) {
362 if (ca->curr_rtt == 0 || ca->curr_rtt > delay)
363 ca->curr_rtt = delay;
364
365 ca->sample_cnt++;
366 } else {
367 if (ca->curr_rtt > ca->delay_min +
368 HYSTART_DELAY_THRESH(ca->delay_min>>4))
369 ca->found |= HYSTART_DELAY;
370 }
371 /*
372 * Either one of two conditions are met,
373 * we exit from slow start immediately.
374 */
375 if (ca->found & hystart_detect)
376 tp->snd_ssthresh = tp->snd_cwnd;
377 }
286} 378}
287 379
288/* Track delayed acknowledgment ratio using sliding window 380/* Track delayed acknowledgment ratio using sliding window
@@ -291,6 +383,7 @@ static void bictcp_state(struct sock *sk, u8 new_state)
291static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us) 383static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
292{ 384{
293 const struct inet_connection_sock *icsk = inet_csk(sk); 385 const struct inet_connection_sock *icsk = inet_csk(sk);
386 const struct tcp_sock *tp = tcp_sk(sk);
294 struct bictcp *ca = inet_csk_ca(sk); 387 struct bictcp *ca = inet_csk_ca(sk);
295 u32 delay; 388 u32 delay;
296 389
@@ -314,6 +407,11 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
314 /* first time call or link delay decreases */ 407 /* first time call or link delay decreases */
315 if (ca->delay_min == 0 || ca->delay_min > delay) 408 if (ca->delay_min == 0 || ca->delay_min > delay)
316 ca->delay_min = delay; 409 ca->delay_min = delay;
410
411 /* hystart triggers when cwnd is larger than some threshold */
412 if (hystart && tp->snd_cwnd <= tp->snd_ssthresh &&
413 tp->snd_cwnd >= hystart_low_window)
414 hystart_update(sk, delay);
317} 415}
318 416
319static struct tcp_congestion_ops cubictcp = { 417static struct tcp_congestion_ops cubictcp = {
@@ -372,4 +470,4 @@ module_exit(cubictcp_unregister);
372MODULE_AUTHOR("Sangtae Ha, Stephen Hemminger"); 470MODULE_AUTHOR("Sangtae Ha, Stephen Hemminger");
373MODULE_LICENSE("GPL"); 471MODULE_LICENSE("GPL");
374MODULE_DESCRIPTION("CUBIC TCP"); 472MODULE_DESCRIPTION("CUBIC TCP");
375MODULE_VERSION("2.2"); 473MODULE_VERSION("2.3");
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index 838d491dfda7..fcbcd4ff6c5f 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -34,7 +34,7 @@ static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
34 tcp_get_info(sk, info); 34 tcp_get_info(sk, info);
35} 35}
36 36
37static struct inet_diag_handler tcp_diag_handler = { 37static const struct inet_diag_handler tcp_diag_handler = {
38 .idiag_hashinfo = &tcp_hashinfo, 38 .idiag_hashinfo = &tcp_hashinfo,
39 .idiag_get_info = tcp_diag_get_info, 39 .idiag_get_info = tcp_diag_get_info,
40 .idiag_type = TCPDIAG_GETSOCK, 40 .idiag_type = TCPDIAG_GETSOCK,
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index d77c0d29e239..097294b7da3e 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2336,9 +2336,9 @@ static void DBGUNDO(struct sock *sk, const char *msg)
2336 struct inet_sock *inet = inet_sk(sk); 2336 struct inet_sock *inet = inet_sk(sk);
2337 2337
2338 if (sk->sk_family == AF_INET) { 2338 if (sk->sk_family == AF_INET) {
2339 printk(KERN_DEBUG "Undo %s " NIPQUAD_FMT "/%u c%u l%u ss%u/%u p%u\n", 2339 printk(KERN_DEBUG "Undo %s %pI4/%u c%u l%u ss%u/%u p%u\n",
2340 msg, 2340 msg,
2341 NIPQUAD(inet->daddr), ntohs(inet->dport), 2341 &inet->daddr, ntohs(inet->dport),
2342 tp->snd_cwnd, tcp_left_out(tp), 2342 tp->snd_cwnd, tcp_left_out(tp),
2343 tp->snd_ssthresh, tp->prior_ssthresh, 2343 tp->snd_ssthresh, tp->prior_ssthresh,
2344 tp->packets_out); 2344 tp->packets_out);
@@ -2346,9 +2346,9 @@ static void DBGUNDO(struct sock *sk, const char *msg)
2346#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 2346#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
2347 else if (sk->sk_family == AF_INET6) { 2347 else if (sk->sk_family == AF_INET6) {
2348 struct ipv6_pinfo *np = inet6_sk(sk); 2348 struct ipv6_pinfo *np = inet6_sk(sk);
2349 printk(KERN_DEBUG "Undo %s " NIP6_FMT "/%u c%u l%u ss%u/%u p%u\n", 2349 printk(KERN_DEBUG "Undo %s %pI6/%u c%u l%u ss%u/%u p%u\n",
2350 msg, 2350 msg,
2351 NIP6(np->daddr), ntohs(inet->dport), 2351 &np->daddr, ntohs(inet->dport),
2352 tp->snd_cwnd, tcp_left_out(tp), 2352 tp->snd_cwnd, tcp_left_out(tp),
2353 tp->snd_ssthresh, tp->prior_ssthresh, 2353 tp->snd_ssthresh, tp->prior_ssthresh,
2354 tp->packets_out); 2354 tp->packets_out);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 5c8fa7f1e327..330b08a12274 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -97,11 +97,7 @@ struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr)
97} 97}
98#endif 98#endif
99 99
100struct inet_hashinfo __cacheline_aligned tcp_hashinfo = { 100struct inet_hashinfo tcp_hashinfo;
101 .lhash_lock = __RW_LOCK_UNLOCKED(tcp_hashinfo.lhash_lock),
102 .lhash_users = ATOMIC_INIT(0),
103 .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.lhash_wait),
104};
105 101
106static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb) 102static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb)
107{ 103{
@@ -492,7 +488,7 @@ void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb)
492 skb->csum_offset = offsetof(struct tcphdr, check); 488 skb->csum_offset = offsetof(struct tcphdr, check);
493 } else { 489 } else {
494 th->check = tcp_v4_check(len, inet->saddr, inet->daddr, 490 th->check = tcp_v4_check(len, inet->saddr, inet->daddr,
495 csum_partial((char *)th, 491 csum_partial(th,
496 th->doff << 2, 492 th->doff << 2,
497 skb->csum)); 493 skb->csum));
498 } 494 }
@@ -726,7 +722,7 @@ static int __tcp_v4_send_synack(struct sock *sk, struct request_sock *req,
726 th->check = tcp_v4_check(skb->len, 722 th->check = tcp_v4_check(skb->len,
727 ireq->loc_addr, 723 ireq->loc_addr,
728 ireq->rmt_addr, 724 ireq->rmt_addr,
729 csum_partial((char *)th, skb->len, 725 csum_partial(th, skb->len,
730 skb->csum)); 726 skb->csum));
731 727
732 err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr, 728 err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr,
@@ -1139,10 +1135,9 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb)
1139 1135
1140 if (genhash || memcmp(hash_location, newhash, 16) != 0) { 1136 if (genhash || memcmp(hash_location, newhash, 16) != 0) {
1141 if (net_ratelimit()) { 1137 if (net_ratelimit()) {
1142 printk(KERN_INFO "MD5 Hash failed for " 1138 printk(KERN_INFO "MD5 Hash failed for (%pI4, %d)->(%pI4, %d)%s\n",
1143 "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)%s\n", 1139 &iph->saddr, ntohs(th->source),
1144 NIPQUAD(iph->saddr), ntohs(th->source), 1140 &iph->daddr, ntohs(th->dest),
1145 NIPQUAD(iph->daddr), ntohs(th->dest),
1146 genhash ? " tcp_v4_calc_md5_hash failed" : ""); 1141 genhash ? " tcp_v4_calc_md5_hash failed" : "");
1147 } 1142 }
1148 return 1; 1143 return 1;
@@ -1297,10 +1292,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1297 * to destinations, already remembered 1292 * to destinations, already remembered
1298 * to the moment of synflood. 1293 * to the moment of synflood.
1299 */ 1294 */
1300 LIMIT_NETDEBUG(KERN_DEBUG "TCP: drop open " 1295 LIMIT_NETDEBUG(KERN_DEBUG "TCP: drop open request from %pI4/%u\n",
1301 "request from " NIPQUAD_FMT "/%u\n", 1296 &saddr, ntohs(tcp_hdr(skb)->source));
1302 NIPQUAD(saddr),
1303 ntohs(tcp_hdr(skb)->source));
1304 goto drop_and_release; 1297 goto drop_and_release;
1305 } 1298 }
1306 1299
@@ -1860,16 +1853,16 @@ EXPORT_SYMBOL(tcp_v4_destroy_sock);
1860#ifdef CONFIG_PROC_FS 1853#ifdef CONFIG_PROC_FS
1861/* Proc filesystem TCP sock list dumping. */ 1854/* Proc filesystem TCP sock list dumping. */
1862 1855
1863static inline struct inet_timewait_sock *tw_head(struct hlist_head *head) 1856static inline struct inet_timewait_sock *tw_head(struct hlist_nulls_head *head)
1864{ 1857{
1865 return hlist_empty(head) ? NULL : 1858 return hlist_nulls_empty(head) ? NULL :
1866 list_entry(head->first, struct inet_timewait_sock, tw_node); 1859 list_entry(head->first, struct inet_timewait_sock, tw_node);
1867} 1860}
1868 1861
1869static inline struct inet_timewait_sock *tw_next(struct inet_timewait_sock *tw) 1862static inline struct inet_timewait_sock *tw_next(struct inet_timewait_sock *tw)
1870{ 1863{
1871 return tw->tw_node.next ? 1864 return !is_a_nulls(tw->tw_node.next) ?
1872 hlist_entry(tw->tw_node.next, typeof(*tw), tw_node) : NULL; 1865 hlist_nulls_entry(tw->tw_node.next, typeof(*tw), tw_node) : NULL;
1873} 1866}
1874 1867
1875static void *listening_get_next(struct seq_file *seq, void *cur) 1868static void *listening_get_next(struct seq_file *seq, void *cur)
@@ -1877,15 +1870,18 @@ static void *listening_get_next(struct seq_file *seq, void *cur)
1877 struct inet_connection_sock *icsk; 1870 struct inet_connection_sock *icsk;
1878 struct hlist_node *node; 1871 struct hlist_node *node;
1879 struct sock *sk = cur; 1872 struct sock *sk = cur;
1880 struct tcp_iter_state* st = seq->private; 1873 struct inet_listen_hashbucket *ilb;
1874 struct tcp_iter_state *st = seq->private;
1881 struct net *net = seq_file_net(seq); 1875 struct net *net = seq_file_net(seq);
1882 1876
1883 if (!sk) { 1877 if (!sk) {
1884 st->bucket = 0; 1878 st->bucket = 0;
1885 sk = sk_head(&tcp_hashinfo.listening_hash[0]); 1879 ilb = &tcp_hashinfo.listening_hash[0];
1880 spin_lock_bh(&ilb->lock);
1881 sk = sk_head(&ilb->head);
1886 goto get_sk; 1882 goto get_sk;
1887 } 1883 }
1888 1884 ilb = &tcp_hashinfo.listening_hash[st->bucket];
1889 ++st->num; 1885 ++st->num;
1890 1886
1891 if (st->state == TCP_SEQ_STATE_OPENREQ) { 1887 if (st->state == TCP_SEQ_STATE_OPENREQ) {
@@ -1935,8 +1931,11 @@ start_req:
1935 } 1931 }
1936 read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock); 1932 read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock);
1937 } 1933 }
1934 spin_unlock_bh(&ilb->lock);
1938 if (++st->bucket < INET_LHTABLE_SIZE) { 1935 if (++st->bucket < INET_LHTABLE_SIZE) {
1939 sk = sk_head(&tcp_hashinfo.listening_hash[st->bucket]); 1936 ilb = &tcp_hashinfo.listening_hash[st->bucket];
1937 spin_lock_bh(&ilb->lock);
1938 sk = sk_head(&ilb->head);
1940 goto get_sk; 1939 goto get_sk;
1941 } 1940 }
1942 cur = NULL; 1941 cur = NULL;
@@ -1957,19 +1956,19 @@ static void *listening_get_idx(struct seq_file *seq, loff_t *pos)
1957 1956
1958static inline int empty_bucket(struct tcp_iter_state *st) 1957static inline int empty_bucket(struct tcp_iter_state *st)
1959{ 1958{
1960 return hlist_empty(&tcp_hashinfo.ehash[st->bucket].chain) && 1959 return hlist_nulls_empty(&tcp_hashinfo.ehash[st->bucket].chain) &&
1961 hlist_empty(&tcp_hashinfo.ehash[st->bucket].twchain); 1960 hlist_nulls_empty(&tcp_hashinfo.ehash[st->bucket].twchain);
1962} 1961}
1963 1962
1964static void *established_get_first(struct seq_file *seq) 1963static void *established_get_first(struct seq_file *seq)
1965{ 1964{
1966 struct tcp_iter_state* st = seq->private; 1965 struct tcp_iter_state *st = seq->private;
1967 struct net *net = seq_file_net(seq); 1966 struct net *net = seq_file_net(seq);
1968 void *rc = NULL; 1967 void *rc = NULL;
1969 1968
1970 for (st->bucket = 0; st->bucket < tcp_hashinfo.ehash_size; ++st->bucket) { 1969 for (st->bucket = 0; st->bucket < tcp_hashinfo.ehash_size; ++st->bucket) {
1971 struct sock *sk; 1970 struct sock *sk;
1972 struct hlist_node *node; 1971 struct hlist_nulls_node *node;
1973 struct inet_timewait_sock *tw; 1972 struct inet_timewait_sock *tw;
1974 rwlock_t *lock = inet_ehash_lockp(&tcp_hashinfo, st->bucket); 1973 rwlock_t *lock = inet_ehash_lockp(&tcp_hashinfo, st->bucket);
1975 1974
@@ -1978,7 +1977,7 @@ static void *established_get_first(struct seq_file *seq)
1978 continue; 1977 continue;
1979 1978
1980 read_lock_bh(lock); 1979 read_lock_bh(lock);
1981 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) { 1980 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
1982 if (sk->sk_family != st->family || 1981 if (sk->sk_family != st->family ||
1983 !net_eq(sock_net(sk), net)) { 1982 !net_eq(sock_net(sk), net)) {
1984 continue; 1983 continue;
@@ -2007,8 +2006,8 @@ static void *established_get_next(struct seq_file *seq, void *cur)
2007{ 2006{
2008 struct sock *sk = cur; 2007 struct sock *sk = cur;
2009 struct inet_timewait_sock *tw; 2008 struct inet_timewait_sock *tw;
2010 struct hlist_node *node; 2009 struct hlist_nulls_node *node;
2011 struct tcp_iter_state* st = seq->private; 2010 struct tcp_iter_state *st = seq->private;
2012 struct net *net = seq_file_net(seq); 2011 struct net *net = seq_file_net(seq);
2013 2012
2014 ++st->num; 2013 ++st->num;
@@ -2035,11 +2034,11 @@ get_tw:
2035 return NULL; 2034 return NULL;
2036 2035
2037 read_lock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket)); 2036 read_lock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
2038 sk = sk_head(&tcp_hashinfo.ehash[st->bucket].chain); 2037 sk = sk_nulls_head(&tcp_hashinfo.ehash[st->bucket].chain);
2039 } else 2038 } else
2040 sk = sk_next(sk); 2039 sk = sk_nulls_next(sk);
2041 2040
2042 sk_for_each_from(sk, node) { 2041 sk_nulls_for_each_from(sk, node) {
2043 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) 2042 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
2044 goto found; 2043 goto found;
2045 } 2044 }
@@ -2067,14 +2066,12 @@ static void *established_get_idx(struct seq_file *seq, loff_t pos)
2067static void *tcp_get_idx(struct seq_file *seq, loff_t pos) 2066static void *tcp_get_idx(struct seq_file *seq, loff_t pos)
2068{ 2067{
2069 void *rc; 2068 void *rc;
2070 struct tcp_iter_state* st = seq->private; 2069 struct tcp_iter_state *st = seq->private;
2071 2070
2072 inet_listen_lock(&tcp_hashinfo);
2073 st->state = TCP_SEQ_STATE_LISTENING; 2071 st->state = TCP_SEQ_STATE_LISTENING;
2074 rc = listening_get_idx(seq, &pos); 2072 rc = listening_get_idx(seq, &pos);
2075 2073
2076 if (!rc) { 2074 if (!rc) {
2077 inet_listen_unlock(&tcp_hashinfo);
2078 st->state = TCP_SEQ_STATE_ESTABLISHED; 2075 st->state = TCP_SEQ_STATE_ESTABLISHED;
2079 rc = established_get_idx(seq, pos); 2076 rc = established_get_idx(seq, pos);
2080 } 2077 }
@@ -2084,7 +2081,7 @@ static void *tcp_get_idx(struct seq_file *seq, loff_t pos)
2084 2081
2085static void *tcp_seq_start(struct seq_file *seq, loff_t *pos) 2082static void *tcp_seq_start(struct seq_file *seq, loff_t *pos)
2086{ 2083{
2087 struct tcp_iter_state* st = seq->private; 2084 struct tcp_iter_state *st = seq->private;
2088 st->state = TCP_SEQ_STATE_LISTENING; 2085 st->state = TCP_SEQ_STATE_LISTENING;
2089 st->num = 0; 2086 st->num = 0;
2090 return *pos ? tcp_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; 2087 return *pos ? tcp_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
@@ -2093,7 +2090,7 @@ static void *tcp_seq_start(struct seq_file *seq, loff_t *pos)
2093static void *tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos) 2090static void *tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2094{ 2091{
2095 void *rc = NULL; 2092 void *rc = NULL;
2096 struct tcp_iter_state* st; 2093 struct tcp_iter_state *st;
2097 2094
2098 if (v == SEQ_START_TOKEN) { 2095 if (v == SEQ_START_TOKEN) {
2099 rc = tcp_get_idx(seq, 0); 2096 rc = tcp_get_idx(seq, 0);
@@ -2106,7 +2103,6 @@ static void *tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2106 case TCP_SEQ_STATE_LISTENING: 2103 case TCP_SEQ_STATE_LISTENING:
2107 rc = listening_get_next(seq, v); 2104 rc = listening_get_next(seq, v);
2108 if (!rc) { 2105 if (!rc) {
2109 inet_listen_unlock(&tcp_hashinfo);
2110 st->state = TCP_SEQ_STATE_ESTABLISHED; 2106 st->state = TCP_SEQ_STATE_ESTABLISHED;
2111 rc = established_get_first(seq); 2107 rc = established_get_first(seq);
2112 } 2108 }
@@ -2123,7 +2119,7 @@ out:
2123 2119
2124static void tcp_seq_stop(struct seq_file *seq, void *v) 2120static void tcp_seq_stop(struct seq_file *seq, void *v)
2125{ 2121{
2126 struct tcp_iter_state* st = seq->private; 2122 struct tcp_iter_state *st = seq->private;
2127 2123
2128 switch (st->state) { 2124 switch (st->state) {
2129 case TCP_SEQ_STATE_OPENREQ: 2125 case TCP_SEQ_STATE_OPENREQ:
@@ -2133,7 +2129,7 @@ static void tcp_seq_stop(struct seq_file *seq, void *v)
2133 } 2129 }
2134 case TCP_SEQ_STATE_LISTENING: 2130 case TCP_SEQ_STATE_LISTENING:
2135 if (v != SEQ_START_TOKEN) 2131 if (v != SEQ_START_TOKEN)
2136 inet_listen_unlock(&tcp_hashinfo); 2132 spin_unlock_bh(&tcp_hashinfo.listening_hash[st->bucket].lock);
2137 break; 2133 break;
2138 case TCP_SEQ_STATE_TIME_WAIT: 2134 case TCP_SEQ_STATE_TIME_WAIT:
2139 case TCP_SEQ_STATE_ESTABLISHED: 2135 case TCP_SEQ_STATE_ESTABLISHED:
@@ -2284,7 +2280,7 @@ static void get_timewait4_sock(struct inet_timewait_sock *tw,
2284 2280
2285static int tcp4_seq_show(struct seq_file *seq, void *v) 2281static int tcp4_seq_show(struct seq_file *seq, void *v)
2286{ 2282{
2287 struct tcp_iter_state* st; 2283 struct tcp_iter_state *st;
2288 int len; 2284 int len;
2289 2285
2290 if (v == SEQ_START_TOKEN) { 2286 if (v == SEQ_START_TOKEN) {
@@ -2378,6 +2374,7 @@ struct proto tcp_prot = {
2378 .sysctl_rmem = sysctl_tcp_rmem, 2374 .sysctl_rmem = sysctl_tcp_rmem,
2379 .max_header = MAX_TCP_HEADER, 2375 .max_header = MAX_TCP_HEADER,
2380 .obj_size = sizeof(struct tcp_sock), 2376 .obj_size = sizeof(struct tcp_sock),
2377 .slab_flags = SLAB_DESTROY_BY_RCU,
2381 .twsk_prot = &tcp_timewait_sock_ops, 2378 .twsk_prot = &tcp_timewait_sock_ops,
2382 .rsk_prot = &tcp_request_sock_ops, 2379 .rsk_prot = &tcp_request_sock_ops,
2383 .h.hashinfo = &tcp_hashinfo, 2380 .h.hashinfo = &tcp_hashinfo,
@@ -2407,6 +2404,7 @@ static struct pernet_operations __net_initdata tcp_sk_ops = {
2407 2404
2408void __init tcp_v4_init(void) 2405void __init tcp_v4_init(void)
2409{ 2406{
2407 inet_hashinfo_init(&tcp_hashinfo);
2410 if (register_pernet_device(&tcp_sk_ops)) 2408 if (register_pernet_device(&tcp_sk_ops))
2411 panic("Failed to create the TCP control socket.\n"); 2409 panic("Failed to create the TCP control socket.\n");
2412} 2410}
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 779f2e9d0689..f67effbb102b 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -491,7 +491,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
491 * as a request_sock. 491 * as a request_sock.
492 */ 492 */
493 493
494struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, 494struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
495 struct request_sock *req, 495 struct request_sock *req,
496 struct request_sock **prev) 496 struct request_sock **prev)
497{ 497{
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index ba85d8831893..a524627923ae 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -42,7 +42,7 @@
42/* People can turn this off for buggy TCP's found in printers etc. */ 42/* People can turn this off for buggy TCP's found in printers etc. */
43int sysctl_tcp_retrans_collapse __read_mostly = 1; 43int sysctl_tcp_retrans_collapse __read_mostly = 1;
44 44
45/* People can turn this on to work with those rare, broken TCPs that 45/* People can turn this on to work with those rare, broken TCPs that
46 * interpret the window field as a signed quantity. 46 * interpret the window field as a signed quantity.
47 */ 47 */
48int sysctl_tcp_workaround_signed_windows __read_mostly = 0; 48int sysctl_tcp_workaround_signed_windows __read_mostly = 0;
@@ -484,7 +484,7 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
484 } 484 }
485 if (likely(sysctl_tcp_window_scaling)) { 485 if (likely(sysctl_tcp_window_scaling)) {
486 opts->ws = tp->rx_opt.rcv_wscale; 486 opts->ws = tp->rx_opt.rcv_wscale;
487 if(likely(opts->ws)) 487 if (likely(opts->ws))
488 size += TCPOLEN_WSCALE_ALIGNED; 488 size += TCPOLEN_WSCALE_ALIGNED;
489 } 489 }
490 if (likely(sysctl_tcp_sack)) { 490 if (likely(sysctl_tcp_sack)) {
@@ -526,7 +526,7 @@ static unsigned tcp_synack_options(struct sock *sk,
526 526
527 if (likely(ireq->wscale_ok)) { 527 if (likely(ireq->wscale_ok)) {
528 opts->ws = ireq->rcv_wscale; 528 opts->ws = ireq->rcv_wscale;
529 if(likely(opts->ws)) 529 if (likely(opts->ws))
530 size += TCPOLEN_WSCALE_ALIGNED; 530 size += TCPOLEN_WSCALE_ALIGNED;
531 } 531 }
532 if (likely(doing_ts)) { 532 if (likely(doing_ts)) {
@@ -1172,7 +1172,7 @@ static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb,
1172 1172
1173static inline int tcp_minshall_check(const struct tcp_sock *tp) 1173static inline int tcp_minshall_check(const struct tcp_sock *tp)
1174{ 1174{
1175 return after(tp->snd_sml,tp->snd_una) && 1175 return after(tp->snd_sml, tp->snd_una) &&
1176 !after(tp->snd_sml, tp->snd_nxt); 1176 !after(tp->snd_sml, tp->snd_nxt);
1177} 1177}
1178 1178
diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
index 7ddc30f0744f..25524d4e372a 100644
--- a/net/ipv4/tcp_probe.c
+++ b/net/ipv4/tcp_probe.c
@@ -153,12 +153,11 @@ static int tcpprobe_sprint(char *tbuf, int n)
153 = ktime_to_timespec(ktime_sub(p->tstamp, tcp_probe.start)); 153 = ktime_to_timespec(ktime_sub(p->tstamp, tcp_probe.start));
154 154
155 return snprintf(tbuf, n, 155 return snprintf(tbuf, n,
156 "%lu.%09lu " NIPQUAD_FMT ":%u " NIPQUAD_FMT ":%u" 156 "%lu.%09lu %pI4:%u %pI4:%u %d %#x %#x %u %u %u %u\n",
157 " %d %#x %#x %u %u %u %u\n",
158 (unsigned long) tv.tv_sec, 157 (unsigned long) tv.tv_sec,
159 (unsigned long) tv.tv_nsec, 158 (unsigned long) tv.tv_nsec,
160 NIPQUAD(p->saddr), ntohs(p->sport), 159 &p->saddr, ntohs(p->sport),
161 NIPQUAD(p->daddr), ntohs(p->dport), 160 &p->daddr, ntohs(p->dport),
162 p->length, p->snd_nxt, p->snd_una, 161 p->length, p->snd_nxt, p->snd_una,
163 p->snd_cwnd, p->ssthresh, p->snd_wnd, p->srtt); 162 p->snd_cwnd, p->ssthresh, p->snd_wnd, p->srtt);
164} 163}
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 6b6dff1164b9..3df339e3e363 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -171,7 +171,7 @@ static int tcp_write_timeout(struct sock *sk)
171 171
172static void tcp_delack_timer(unsigned long data) 172static void tcp_delack_timer(unsigned long data)
173{ 173{
174 struct sock *sk = (struct sock*)data; 174 struct sock *sk = (struct sock *)data;
175 struct tcp_sock *tp = tcp_sk(sk); 175 struct tcp_sock *tp = tcp_sk(sk);
176 struct inet_connection_sock *icsk = inet_csk(sk); 176 struct inet_connection_sock *icsk = inet_csk(sk);
177 177
@@ -299,15 +299,15 @@ static void tcp_retransmit_timer(struct sock *sk)
299#ifdef TCP_DEBUG 299#ifdef TCP_DEBUG
300 struct inet_sock *inet = inet_sk(sk); 300 struct inet_sock *inet = inet_sk(sk);
301 if (sk->sk_family == AF_INET) { 301 if (sk->sk_family == AF_INET) {
302 LIMIT_NETDEBUG(KERN_DEBUG "TCP: Treason uncloaked! Peer " NIPQUAD_FMT ":%u/%u shrinks window %u:%u. Repaired.\n", 302 LIMIT_NETDEBUG(KERN_DEBUG "TCP: Treason uncloaked! Peer %pI4:%u/%u shrinks window %u:%u. Repaired.\n",
303 NIPQUAD(inet->daddr), ntohs(inet->dport), 303 &inet->daddr, ntohs(inet->dport),
304 inet->num, tp->snd_una, tp->snd_nxt); 304 inet->num, tp->snd_una, tp->snd_nxt);
305 } 305 }
306#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 306#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
307 else if (sk->sk_family == AF_INET6) { 307 else if (sk->sk_family == AF_INET6) {
308 struct ipv6_pinfo *np = inet6_sk(sk); 308 struct ipv6_pinfo *np = inet6_sk(sk);
309 LIMIT_NETDEBUG(KERN_DEBUG "TCP: Treason uncloaked! Peer " NIP6_FMT ":%u/%u shrinks window %u:%u. Repaired.\n", 309 LIMIT_NETDEBUG(KERN_DEBUG "TCP: Treason uncloaked! Peer %pI6:%u/%u shrinks window %u:%u. Repaired.\n",
310 NIP6(np->daddr), ntohs(inet->dport), 310 &np->daddr, ntohs(inet->dport),
311 inet->num, tp->snd_una, tp->snd_nxt); 311 inet->num, tp->snd_una, tp->snd_nxt);
312 } 312 }
313#endif 313#endif
@@ -396,7 +396,7 @@ out:;
396 396
397static void tcp_write_timer(unsigned long data) 397static void tcp_write_timer(unsigned long data)
398{ 398{
399 struct sock *sk = (struct sock*)data; 399 struct sock *sk = (struct sock *)data;
400 struct inet_connection_sock *icsk = inet_csk(sk); 400 struct inet_connection_sock *icsk = inet_csk(sk);
401 int event; 401 int event;
402 402
diff --git a/net/ipv4/tcp_yeah.c b/net/ipv4/tcp_yeah.c
index e03b10183a8b..9ec843a9bbb2 100644
--- a/net/ipv4/tcp_yeah.c
+++ b/net/ipv4/tcp_yeah.c
@@ -83,7 +83,7 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
83 else if (!yeah->doing_reno_now) { 83 else if (!yeah->doing_reno_now) {
84 /* Scalable */ 84 /* Scalable */
85 85
86 tp->snd_cwnd_cnt+=yeah->pkts_acked; 86 tp->snd_cwnd_cnt += yeah->pkts_acked;
87 if (tp->snd_cwnd_cnt > min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT)){ 87 if (tp->snd_cwnd_cnt > min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT)){
88 if (tp->snd_cwnd < tp->snd_cwnd_clamp) 88 if (tp->snd_cwnd < tp->snd_cwnd_clamp)
89 tp->snd_cwnd++; 89 tp->snd_cwnd++;
@@ -224,7 +224,7 @@ static u32 tcp_yeah_ssthresh(struct sock *sk) {
224 224
225 reduction = max( reduction, tp->snd_cwnd >> TCP_YEAH_DELTA); 225 reduction = max( reduction, tp->snd_cwnd >> TCP_YEAH_DELTA);
226 } else 226 } else
227 reduction = max(tp->snd_cwnd>>1,2U); 227 reduction = max(tp->snd_cwnd>>1, 2U);
228 228
229 yeah->fast_count = 0; 229 yeah->fast_count = 0;
230 yeah->reno_count = max(yeah->reno_count>>1, 2U); 230 yeah->reno_count = max(yeah->reno_count>>1, 2U);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 98c1fd09be88..da869ce041d9 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -81,6 +81,8 @@
81#include <asm/uaccess.h> 81#include <asm/uaccess.h>
82#include <asm/ioctls.h> 82#include <asm/ioctls.h>
83#include <linux/bootmem.h> 83#include <linux/bootmem.h>
84#include <linux/highmem.h>
85#include <linux/swap.h>
84#include <linux/types.h> 86#include <linux/types.h>
85#include <linux/fcntl.h> 87#include <linux/fcntl.h>
86#include <linux/module.h> 88#include <linux/module.h>
@@ -104,12 +106,8 @@
104#include <net/xfrm.h> 106#include <net/xfrm.h>
105#include "udp_impl.h" 107#include "udp_impl.h"
106 108
107/* 109struct udp_table udp_table;
108 * Snmp MIB for the UDP layer 110EXPORT_SYMBOL(udp_table);
109 */
110
111struct hlist_head udp_hash[UDP_HTABLE_SIZE];
112DEFINE_RWLOCK(udp_hash_lock);
113 111
114int sysctl_udp_mem[3] __read_mostly; 112int sysctl_udp_mem[3] __read_mostly;
115int sysctl_udp_rmem_min __read_mostly; 113int sysctl_udp_rmem_min __read_mostly;
@@ -123,15 +121,15 @@ atomic_t udp_memory_allocated;
123EXPORT_SYMBOL(udp_memory_allocated); 121EXPORT_SYMBOL(udp_memory_allocated);
124 122
125static int udp_lib_lport_inuse(struct net *net, __u16 num, 123static int udp_lib_lport_inuse(struct net *net, __u16 num,
126 const struct hlist_head udptable[], 124 const struct udp_hslot *hslot,
127 struct sock *sk, 125 struct sock *sk,
128 int (*saddr_comp)(const struct sock *sk1, 126 int (*saddr_comp)(const struct sock *sk1,
129 const struct sock *sk2)) 127 const struct sock *sk2))
130{ 128{
131 struct sock *sk2; 129 struct sock *sk2;
132 struct hlist_node *node; 130 struct hlist_nulls_node *node;
133 131
134 sk_for_each(sk2, node, &udptable[udp_hashfn(net, num)]) 132 sk_nulls_for_each(sk2, node, &hslot->head)
135 if (net_eq(sock_net(sk2), net) && 133 if (net_eq(sock_net(sk2), net) &&
136 sk2 != sk && 134 sk2 != sk &&
137 sk2->sk_hash == num && 135 sk2->sk_hash == num &&
@@ -154,12 +152,11 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
154 int (*saddr_comp)(const struct sock *sk1, 152 int (*saddr_comp)(const struct sock *sk1,
155 const struct sock *sk2 ) ) 153 const struct sock *sk2 ) )
156{ 154{
157 struct hlist_head *udptable = sk->sk_prot->h.udp_hash; 155 struct udp_hslot *hslot;
156 struct udp_table *udptable = sk->sk_prot->h.udp_table;
158 int error = 1; 157 int error = 1;
159 struct net *net = sock_net(sk); 158 struct net *net = sock_net(sk);
160 159
161 write_lock_bh(&udp_hash_lock);
162
163 if (!snum) { 160 if (!snum) {
164 int low, high, remaining; 161 int low, high, remaining;
165 unsigned rand; 162 unsigned rand;
@@ -171,26 +168,34 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
171 rand = net_random(); 168 rand = net_random();
172 snum = first = rand % remaining + low; 169 snum = first = rand % remaining + low;
173 rand |= 1; 170 rand |= 1;
174 while (udp_lib_lport_inuse(net, snum, udptable, sk, 171 for (;;) {
175 saddr_comp)) { 172 hslot = &udptable->hash[udp_hashfn(net, snum)];
173 spin_lock_bh(&hslot->lock);
174 if (!udp_lib_lport_inuse(net, snum, hslot, sk, saddr_comp))
175 break;
176 spin_unlock_bh(&hslot->lock);
176 do { 177 do {
177 snum = snum + rand; 178 snum = snum + rand;
178 } while (snum < low || snum > high); 179 } while (snum < low || snum > high);
179 if (snum == first) 180 if (snum == first)
180 goto fail; 181 goto fail;
181 } 182 }
182 } else if (udp_lib_lport_inuse(net, snum, udptable, sk, saddr_comp)) 183 } else {
183 goto fail; 184 hslot = &udptable->hash[udp_hashfn(net, snum)];
184 185 spin_lock_bh(&hslot->lock);
186 if (udp_lib_lport_inuse(net, snum, hslot, sk, saddr_comp))
187 goto fail_unlock;
188 }
185 inet_sk(sk)->num = snum; 189 inet_sk(sk)->num = snum;
186 sk->sk_hash = snum; 190 sk->sk_hash = snum;
187 if (sk_unhashed(sk)) { 191 if (sk_unhashed(sk)) {
188 sk_add_node(sk, &udptable[udp_hashfn(net, snum)]); 192 sk_nulls_add_node_rcu(sk, &hslot->head);
189 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 193 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
190 } 194 }
191 error = 0; 195 error = 0;
196fail_unlock:
197 spin_unlock_bh(&hslot->lock);
192fail: 198fail:
193 write_unlock_bh(&udp_hash_lock);
194 return error; 199 return error;
195} 200}
196 201
@@ -208,63 +213,91 @@ int udp_v4_get_port(struct sock *sk, unsigned short snum)
208 return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal); 213 return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal);
209} 214}
210 215
216static inline int compute_score(struct sock *sk, struct net *net, __be32 saddr,
217 unsigned short hnum,
218 __be16 sport, __be32 daddr, __be16 dport, int dif)
219{
220 int score = -1;
221
222 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
223 !ipv6_only_sock(sk)) {
224 struct inet_sock *inet = inet_sk(sk);
225
226 score = (sk->sk_family == PF_INET ? 1 : 0);
227 if (inet->rcv_saddr) {
228 if (inet->rcv_saddr != daddr)
229 return -1;
230 score += 2;
231 }
232 if (inet->daddr) {
233 if (inet->daddr != saddr)
234 return -1;
235 score += 2;
236 }
237 if (inet->dport) {
238 if (inet->dport != sport)
239 return -1;
240 score += 2;
241 }
242 if (sk->sk_bound_dev_if) {
243 if (sk->sk_bound_dev_if != dif)
244 return -1;
245 score += 2;
246 }
247 }
248 return score;
249}
250
211/* UDP is nearly always wildcards out the wazoo, it makes no sense to try 251/* UDP is nearly always wildcards out the wazoo, it makes no sense to try
212 * harder than this. -DaveM 252 * harder than this. -DaveM
213 */ 253 */
214static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, 254static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
215 __be16 sport, __be32 daddr, __be16 dport, 255 __be16 sport, __be32 daddr, __be16 dport,
216 int dif, struct hlist_head udptable[]) 256 int dif, struct udp_table *udptable)
217{ 257{
218 struct sock *sk, *result = NULL; 258 struct sock *sk, *result;
219 struct hlist_node *node; 259 struct hlist_nulls_node *node;
220 unsigned short hnum = ntohs(dport); 260 unsigned short hnum = ntohs(dport);
221 int badness = -1; 261 unsigned int hash = udp_hashfn(net, hnum);
222 262 struct udp_hslot *hslot = &udptable->hash[hash];
223 read_lock(&udp_hash_lock); 263 int score, badness;
224 sk_for_each(sk, node, &udptable[udp_hashfn(net, hnum)]) { 264
225 struct inet_sock *inet = inet_sk(sk); 265 rcu_read_lock();
226 266begin:
227 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum && 267 result = NULL;
228 !ipv6_only_sock(sk)) { 268 badness = -1;
229 int score = (sk->sk_family == PF_INET ? 1 : 0); 269 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
230 if (inet->rcv_saddr) { 270 score = compute_score(sk, net, saddr, hnum, sport,
231 if (inet->rcv_saddr != daddr) 271 daddr, dport, dif);
232 continue; 272 if (score > badness) {
233 score+=2; 273 result = sk;
234 } 274 badness = score;
235 if (inet->daddr) {
236 if (inet->daddr != saddr)
237 continue;
238 score+=2;
239 }
240 if (inet->dport) {
241 if (inet->dport != sport)
242 continue;
243 score+=2;
244 }
245 if (sk->sk_bound_dev_if) {
246 if (sk->sk_bound_dev_if != dif)
247 continue;
248 score+=2;
249 }
250 if (score == 9) {
251 result = sk;
252 break;
253 } else if (score > badness) {
254 result = sk;
255 badness = score;
256 }
257 } 275 }
258 } 276 }
259 if (result) 277 /*
260 sock_hold(result); 278 * if the nulls value we got at the end of this lookup is
261 read_unlock(&udp_hash_lock); 279 * not the expected one, we must restart lookup.
280 * We probably met an item that was moved to another chain.
281 */
282 if (get_nulls_value(node) != hash)
283 goto begin;
284
285 if (result) {
286 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
287 result = NULL;
288 else if (unlikely(compute_score(result, net, saddr, hnum, sport,
289 daddr, dport, dif) < badness)) {
290 sock_put(result);
291 goto begin;
292 }
293 }
294 rcu_read_unlock();
262 return result; 295 return result;
263} 296}
264 297
265static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb, 298static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb,
266 __be16 sport, __be16 dport, 299 __be16 sport, __be16 dport,
267 struct hlist_head udptable[]) 300 struct udp_table *udptable)
268{ 301{
269 struct sock *sk; 302 struct sock *sk;
270 const struct iphdr *iph = ip_hdr(skb); 303 const struct iphdr *iph = ip_hdr(skb);
@@ -280,7 +313,7 @@ static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb,
280struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, 313struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
281 __be32 daddr, __be16 dport, int dif) 314 __be32 daddr, __be16 dport, int dif)
282{ 315{
283 return __udp4_lib_lookup(net, saddr, sport, daddr, dport, dif, udp_hash); 316 return __udp4_lib_lookup(net, saddr, sport, daddr, dport, dif, &udp_table);
284} 317}
285EXPORT_SYMBOL_GPL(udp4_lib_lookup); 318EXPORT_SYMBOL_GPL(udp4_lib_lookup);
286 319
@@ -289,11 +322,11 @@ static inline struct sock *udp_v4_mcast_next(struct net *net, struct sock *sk,
289 __be16 rmt_port, __be32 rmt_addr, 322 __be16 rmt_port, __be32 rmt_addr,
290 int dif) 323 int dif)
291{ 324{
292 struct hlist_node *node; 325 struct hlist_nulls_node *node;
293 struct sock *s = sk; 326 struct sock *s = sk;
294 unsigned short hnum = ntohs(loc_port); 327 unsigned short hnum = ntohs(loc_port);
295 328
296 sk_for_each_from(s, node) { 329 sk_nulls_for_each_from(s, node) {
297 struct inet_sock *inet = inet_sk(s); 330 struct inet_sock *inet = inet_sk(s);
298 331
299 if (!net_eq(sock_net(s), net) || 332 if (!net_eq(sock_net(s), net) ||
@@ -324,7 +357,7 @@ found:
324 * to find the appropriate port. 357 * to find the appropriate port.
325 */ 358 */
326 359
327void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[]) 360void __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable)
328{ 361{
329 struct inet_sock *inet; 362 struct inet_sock *inet;
330 struct iphdr *iph = (struct iphdr*)skb->data; 363 struct iphdr *iph = (struct iphdr*)skb->data;
@@ -393,7 +426,7 @@ out:
393 426
394void udp_err(struct sk_buff *skb, u32 info) 427void udp_err(struct sk_buff *skb, u32 info)
395{ 428{
396 __udp4_lib_err(skb, info, udp_hash); 429 __udp4_lib_err(skb, info, &udp_table);
397} 430}
398 431
399/* 432/*
@@ -935,6 +968,21 @@ int udp_disconnect(struct sock *sk, int flags)
935 return 0; 968 return 0;
936} 969}
937 970
971void udp_lib_unhash(struct sock *sk)
972{
973 struct udp_table *udptable = sk->sk_prot->h.udp_table;
974 unsigned int hash = udp_hashfn(sock_net(sk), sk->sk_hash);
975 struct udp_hslot *hslot = &udptable->hash[hash];
976
977 spin_lock_bh(&hslot->lock);
978 if (sk_nulls_del_node_init_rcu(sk)) {
979 inet_sk(sk)->num = 0;
980 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
981 }
982 spin_unlock_bh(&hslot->lock);
983}
984EXPORT_SYMBOL(udp_lib_unhash);
985
938static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 986static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
939{ 987{
940 int is_udplite = IS_UDPLITE(sk); 988 int is_udplite = IS_UDPLITE(sk);
@@ -1073,13 +1121,14 @@ drop:
1073static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb, 1121static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
1074 struct udphdr *uh, 1122 struct udphdr *uh,
1075 __be32 saddr, __be32 daddr, 1123 __be32 saddr, __be32 daddr,
1076 struct hlist_head udptable[]) 1124 struct udp_table *udptable)
1077{ 1125{
1078 struct sock *sk; 1126 struct sock *sk;
1127 struct udp_hslot *hslot = &udptable->hash[udp_hashfn(net, ntohs(uh->dest))];
1079 int dif; 1128 int dif;
1080 1129
1081 read_lock(&udp_hash_lock); 1130 spin_lock(&hslot->lock);
1082 sk = sk_head(&udptable[udp_hashfn(net, ntohs(uh->dest))]); 1131 sk = sk_nulls_head(&hslot->head);
1083 dif = skb->dev->ifindex; 1132 dif = skb->dev->ifindex;
1084 sk = udp_v4_mcast_next(net, sk, uh->dest, daddr, uh->source, saddr, dif); 1133 sk = udp_v4_mcast_next(net, sk, uh->dest, daddr, uh->source, saddr, dif);
1085 if (sk) { 1134 if (sk) {
@@ -1088,7 +1137,7 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
1088 do { 1137 do {
1089 struct sk_buff *skb1 = skb; 1138 struct sk_buff *skb1 = skb;
1090 1139
1091 sknext = udp_v4_mcast_next(net, sk_next(sk), uh->dest, 1140 sknext = udp_v4_mcast_next(net, sk_nulls_next(sk), uh->dest,
1092 daddr, uh->source, saddr, 1141 daddr, uh->source, saddr,
1093 dif); 1142 dif);
1094 if (sknext) 1143 if (sknext)
@@ -1105,7 +1154,7 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
1105 } while (sknext); 1154 } while (sknext);
1106 } else 1155 } else
1107 kfree_skb(skb); 1156 kfree_skb(skb);
1108 read_unlock(&udp_hash_lock); 1157 spin_unlock(&hslot->lock);
1109 return 0; 1158 return 0;
1110} 1159}
1111 1160
@@ -1151,7 +1200,7 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
1151 * All we need to do is get the socket, and then do a checksum. 1200 * All we need to do is get the socket, and then do a checksum.
1152 */ 1201 */
1153 1202
1154int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], 1203int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
1155 int proto) 1204 int proto)
1156{ 1205{
1157 struct sock *sk; 1206 struct sock *sk;
@@ -1219,13 +1268,13 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
1219 return 0; 1268 return 0;
1220 1269
1221short_packet: 1270short_packet:
1222 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From " NIPQUAD_FMT ":%u %d/%d to " NIPQUAD_FMT ":%u\n", 1271 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %pI4:%u %d/%d to %pI4:%u\n",
1223 proto == IPPROTO_UDPLITE ? "-Lite" : "", 1272 proto == IPPROTO_UDPLITE ? "-Lite" : "",
1224 NIPQUAD(saddr), 1273 &saddr,
1225 ntohs(uh->source), 1274 ntohs(uh->source),
1226 ulen, 1275 ulen,
1227 skb->len, 1276 skb->len,
1228 NIPQUAD(daddr), 1277 &daddr,
1229 ntohs(uh->dest)); 1278 ntohs(uh->dest));
1230 goto drop; 1279 goto drop;
1231 1280
@@ -1234,11 +1283,11 @@ csum_error:
1234 * RFC1122: OK. Discards the bad packet silently (as far as 1283 * RFC1122: OK. Discards the bad packet silently (as far as
1235 * the network is concerned, anyway) as per 4.1.3.4 (MUST). 1284 * the network is concerned, anyway) as per 4.1.3.4 (MUST).
1236 */ 1285 */
1237 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From " NIPQUAD_FMT ":%u to " NIPQUAD_FMT ":%u ulen %d\n", 1286 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %pI4:%u to %pI4:%u ulen %d\n",
1238 proto == IPPROTO_UDPLITE ? "-Lite" : "", 1287 proto == IPPROTO_UDPLITE ? "-Lite" : "",
1239 NIPQUAD(saddr), 1288 &saddr,
1240 ntohs(uh->source), 1289 ntohs(uh->source),
1241 NIPQUAD(daddr), 1290 &daddr,
1242 ntohs(uh->dest), 1291 ntohs(uh->dest),
1243 ulen); 1292 ulen);
1244drop: 1293drop:
@@ -1249,7 +1298,7 @@ drop:
1249 1298
1250int udp_rcv(struct sk_buff *skb) 1299int udp_rcv(struct sk_buff *skb)
1251{ 1300{
1252 return __udp4_lib_rcv(skb, udp_hash, IPPROTO_UDP); 1301 return __udp4_lib_rcv(skb, &udp_table, IPPROTO_UDP);
1253} 1302}
1254 1303
1255void udp_destroy_sock(struct sock *sk) 1304void udp_destroy_sock(struct sock *sk)
@@ -1491,7 +1540,8 @@ struct proto udp_prot = {
1491 .sysctl_wmem = &sysctl_udp_wmem_min, 1540 .sysctl_wmem = &sysctl_udp_wmem_min,
1492 .sysctl_rmem = &sysctl_udp_rmem_min, 1541 .sysctl_rmem = &sysctl_udp_rmem_min,
1493 .obj_size = sizeof(struct udp_sock), 1542 .obj_size = sizeof(struct udp_sock),
1494 .h.udp_hash = udp_hash, 1543 .slab_flags = SLAB_DESTROY_BY_RCU,
1544 .h.udp_table = &udp_table,
1495#ifdef CONFIG_COMPAT 1545#ifdef CONFIG_COMPAT
1496 .compat_setsockopt = compat_udp_setsockopt, 1546 .compat_setsockopt = compat_udp_setsockopt,
1497 .compat_getsockopt = compat_udp_getsockopt, 1547 .compat_getsockopt = compat_udp_getsockopt,
@@ -1501,20 +1551,23 @@ struct proto udp_prot = {
1501/* ------------------------------------------------------------------------ */ 1551/* ------------------------------------------------------------------------ */
1502#ifdef CONFIG_PROC_FS 1552#ifdef CONFIG_PROC_FS
1503 1553
1504static struct sock *udp_get_first(struct seq_file *seq) 1554static struct sock *udp_get_first(struct seq_file *seq, int start)
1505{ 1555{
1506 struct sock *sk; 1556 struct sock *sk;
1507 struct udp_iter_state *state = seq->private; 1557 struct udp_iter_state *state = seq->private;
1508 struct net *net = seq_file_net(seq); 1558 struct net *net = seq_file_net(seq);
1509 1559
1510 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) { 1560 for (state->bucket = start; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
1511 struct hlist_node *node; 1561 struct hlist_nulls_node *node;
1512 sk_for_each(sk, node, state->hashtable + state->bucket) { 1562 struct udp_hslot *hslot = &state->udp_table->hash[state->bucket];
1563 spin_lock_bh(&hslot->lock);
1564 sk_nulls_for_each(sk, node, &hslot->head) {
1513 if (!net_eq(sock_net(sk), net)) 1565 if (!net_eq(sock_net(sk), net))
1514 continue; 1566 continue;
1515 if (sk->sk_family == state->family) 1567 if (sk->sk_family == state->family)
1516 goto found; 1568 goto found;
1517 } 1569 }
1570 spin_unlock_bh(&hslot->lock);
1518 } 1571 }
1519 sk = NULL; 1572 sk = NULL;
1520found: 1573found:
@@ -1527,21 +1580,19 @@ static struct sock *udp_get_next(struct seq_file *seq, struct sock *sk)
1527 struct net *net = seq_file_net(seq); 1580 struct net *net = seq_file_net(seq);
1528 1581
1529 do { 1582 do {
1530 sk = sk_next(sk); 1583 sk = sk_nulls_next(sk);
1531try_again:
1532 ;
1533 } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family)); 1584 } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
1534 1585
1535 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) { 1586 if (!sk) {
1536 sk = sk_head(state->hashtable + state->bucket); 1587 spin_unlock_bh(&state->udp_table->hash[state->bucket].lock);
1537 goto try_again; 1588 return udp_get_first(seq, state->bucket + 1);
1538 } 1589 }
1539 return sk; 1590 return sk;
1540} 1591}
1541 1592
1542static struct sock *udp_get_idx(struct seq_file *seq, loff_t pos) 1593static struct sock *udp_get_idx(struct seq_file *seq, loff_t pos)
1543{ 1594{
1544 struct sock *sk = udp_get_first(seq); 1595 struct sock *sk = udp_get_first(seq, 0);
1545 1596
1546 if (sk) 1597 if (sk)
1547 while (pos && (sk = udp_get_next(seq, sk)) != NULL) 1598 while (pos && (sk = udp_get_next(seq, sk)) != NULL)
@@ -1550,9 +1601,7 @@ static struct sock *udp_get_idx(struct seq_file *seq, loff_t pos)
1550} 1601}
1551 1602
1552static void *udp_seq_start(struct seq_file *seq, loff_t *pos) 1603static void *udp_seq_start(struct seq_file *seq, loff_t *pos)
1553 __acquires(udp_hash_lock)
1554{ 1604{
1555 read_lock(&udp_hash_lock);
1556 return *pos ? udp_get_idx(seq, *pos-1) : SEQ_START_TOKEN; 1605 return *pos ? udp_get_idx(seq, *pos-1) : SEQ_START_TOKEN;
1557} 1606}
1558 1607
@@ -1570,9 +1619,11 @@ static void *udp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1570} 1619}
1571 1620
1572static void udp_seq_stop(struct seq_file *seq, void *v) 1621static void udp_seq_stop(struct seq_file *seq, void *v)
1573 __releases(udp_hash_lock)
1574{ 1622{
1575 read_unlock(&udp_hash_lock); 1623 struct udp_iter_state *state = seq->private;
1624
1625 if (state->bucket < UDP_HTABLE_SIZE)
1626 spin_unlock_bh(&state->udp_table->hash[state->bucket].lock);
1576} 1627}
1577 1628
1578static int udp_seq_open(struct inode *inode, struct file *file) 1629static int udp_seq_open(struct inode *inode, struct file *file)
@@ -1588,7 +1639,7 @@ static int udp_seq_open(struct inode *inode, struct file *file)
1588 1639
1589 s = ((struct seq_file *)file->private_data)->private; 1640 s = ((struct seq_file *)file->private_data)->private;
1590 s->family = afinfo->family; 1641 s->family = afinfo->family;
1591 s->hashtable = afinfo->hashtable; 1642 s->udp_table = afinfo->udp_table;
1592 return err; 1643 return err;
1593} 1644}
1594 1645
@@ -1660,7 +1711,7 @@ int udp4_seq_show(struct seq_file *seq, void *v)
1660static struct udp_seq_afinfo udp4_seq_afinfo = { 1711static struct udp_seq_afinfo udp4_seq_afinfo = {
1661 .name = "udp", 1712 .name = "udp",
1662 .family = AF_INET, 1713 .family = AF_INET,
1663 .hashtable = udp_hash, 1714 .udp_table = &udp_table,
1664 .seq_fops = { 1715 .seq_fops = {
1665 .owner = THIS_MODULE, 1716 .owner = THIS_MODULE,
1666 }, 1717 },
@@ -1695,16 +1746,28 @@ void udp4_proc_exit(void)
1695} 1746}
1696#endif /* CONFIG_PROC_FS */ 1747#endif /* CONFIG_PROC_FS */
1697 1748
1749void __init udp_table_init(struct udp_table *table)
1750{
1751 int i;
1752
1753 for (i = 0; i < UDP_HTABLE_SIZE; i++) {
1754 INIT_HLIST_NULLS_HEAD(&table->hash[i].head, i);
1755 spin_lock_init(&table->hash[i].lock);
1756 }
1757}
1758
1698void __init udp_init(void) 1759void __init udp_init(void)
1699{ 1760{
1700 unsigned long limit; 1761 unsigned long nr_pages, limit;
1701 1762
1763 udp_table_init(&udp_table);
1702 /* Set the pressure threshold up by the same strategy of TCP. It is a 1764 /* Set the pressure threshold up by the same strategy of TCP. It is a
1703 * fraction of global memory that is up to 1/2 at 256 MB, decreasing 1765 * fraction of global memory that is up to 1/2 at 256 MB, decreasing
1704 * toward zero with the amount of memory, with a floor of 128 pages. 1766 * toward zero with the amount of memory, with a floor of 128 pages.
1705 */ 1767 */
1706 limit = min(nr_all_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT); 1768 nr_pages = totalram_pages - totalhigh_pages;
1707 limit = (limit * (nr_all_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11); 1769 limit = min(nr_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT);
1770 limit = (limit * (nr_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11);
1708 limit = max(limit, 128UL); 1771 limit = max(limit, 128UL);
1709 sysctl_udp_mem[0] = limit / 4 * 3; 1772 sysctl_udp_mem[0] = limit / 4 * 3;
1710 sysctl_udp_mem[1] = limit; 1773 sysctl_udp_mem[1] = limit;
@@ -1715,8 +1778,6 @@ void __init udp_init(void)
1715} 1778}
1716 1779
1717EXPORT_SYMBOL(udp_disconnect); 1780EXPORT_SYMBOL(udp_disconnect);
1718EXPORT_SYMBOL(udp_hash);
1719EXPORT_SYMBOL(udp_hash_lock);
1720EXPORT_SYMBOL(udp_ioctl); 1781EXPORT_SYMBOL(udp_ioctl);
1721EXPORT_SYMBOL(udp_prot); 1782EXPORT_SYMBOL(udp_prot);
1722EXPORT_SYMBOL(udp_sendmsg); 1783EXPORT_SYMBOL(udp_sendmsg);
diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h
index 2e9bad2fa1bc..9f4a6165f722 100644
--- a/net/ipv4/udp_impl.h
+++ b/net/ipv4/udp_impl.h
@@ -5,8 +5,8 @@
5#include <net/protocol.h> 5#include <net/protocol.h>
6#include <net/inet_common.h> 6#include <net/inet_common.h>
7 7
8extern int __udp4_lib_rcv(struct sk_buff *, struct hlist_head [], int ); 8extern int __udp4_lib_rcv(struct sk_buff *, struct udp_table *, int );
9extern void __udp4_lib_err(struct sk_buff *, u32, struct hlist_head []); 9extern void __udp4_lib_err(struct sk_buff *, u32, struct udp_table *);
10 10
11extern int udp_v4_get_port(struct sock *sk, unsigned short snum); 11extern int udp_v4_get_port(struct sock *sk, unsigned short snum);
12 12
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index 3c807964da96..c784891cb7e5 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -12,16 +12,17 @@
12 */ 12 */
13#include "udp_impl.h" 13#include "udp_impl.h"
14 14
15struct hlist_head udplite_hash[UDP_HTABLE_SIZE]; 15struct udp_table udplite_table;
16EXPORT_SYMBOL(udplite_table);
16 17
17static int udplite_rcv(struct sk_buff *skb) 18static int udplite_rcv(struct sk_buff *skb)
18{ 19{
19 return __udp4_lib_rcv(skb, udplite_hash, IPPROTO_UDPLITE); 20 return __udp4_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE);
20} 21}
21 22
22static void udplite_err(struct sk_buff *skb, u32 info) 23static void udplite_err(struct sk_buff *skb, u32 info)
23{ 24{
24 __udp4_lib_err(skb, info, udplite_hash); 25 __udp4_lib_err(skb, info, &udplite_table);
25} 26}
26 27
27static struct net_protocol udplite_protocol = { 28static struct net_protocol udplite_protocol = {
@@ -50,7 +51,8 @@ struct proto udplite_prot = {
50 .unhash = udp_lib_unhash, 51 .unhash = udp_lib_unhash,
51 .get_port = udp_v4_get_port, 52 .get_port = udp_v4_get_port,
52 .obj_size = sizeof(struct udp_sock), 53 .obj_size = sizeof(struct udp_sock),
53 .h.udp_hash = udplite_hash, 54 .slab_flags = SLAB_DESTROY_BY_RCU,
55 .h.udp_table = &udplite_table,
54#ifdef CONFIG_COMPAT 56#ifdef CONFIG_COMPAT
55 .compat_setsockopt = compat_udp_setsockopt, 57 .compat_setsockopt = compat_udp_setsockopt,
56 .compat_getsockopt = compat_udp_getsockopt, 58 .compat_getsockopt = compat_udp_getsockopt,
@@ -71,7 +73,7 @@ static struct inet_protosw udplite4_protosw = {
71static struct udp_seq_afinfo udplite4_seq_afinfo = { 73static struct udp_seq_afinfo udplite4_seq_afinfo = {
72 .name = "udplite", 74 .name = "udplite",
73 .family = AF_INET, 75 .family = AF_INET,
74 .hashtable = udplite_hash, 76 .udp_table = &udplite_table,
75 .seq_fops = { 77 .seq_fops = {
76 .owner = THIS_MODULE, 78 .owner = THIS_MODULE,
77 }, 79 },
@@ -108,6 +110,7 @@ static inline int udplite4_proc_init(void)
108 110
109void __init udplite4_register(void) 111void __init udplite4_register(void)
110{ 112{
113 udp_table_init(&udplite_table);
111 if (proto_register(&udplite_prot, 1)) 114 if (proto_register(&udplite_prot, 1))
112 goto out_register_err; 115 goto out_register_err;
113 116
@@ -126,5 +129,4 @@ out_register_err:
126 printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __func__); 129 printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __func__);
127} 130}
128 131
129EXPORT_SYMBOL(udplite_hash);
130EXPORT_SYMBOL(udplite_prot); 132EXPORT_SYMBOL(udplite_prot);
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index c63de0a72aba..84dbb5a03cc2 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -65,7 +65,7 @@ __xfrm4_find_bundle(struct flowi *fl, struct xfrm_policy *policy)
65 65
66 read_lock_bh(&policy->lock); 66 read_lock_bh(&policy->lock);
67 for (dst = policy->bundles; dst; dst = dst->next) { 67 for (dst = policy->bundles; dst; dst = dst->next) {
68 struct xfrm_dst *xdst = (struct xfrm_dst*)dst; 68 struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
69 if (xdst->u.rt.fl.oif == fl->oif && /*XXX*/ 69 if (xdst->u.rt.fl.oif == fl->oif && /*XXX*/
70 xdst->u.rt.fl.fl4_dst == fl->fl4_dst && 70 xdst->u.rt.fl.fl4_dst == fl->fl4_dst &&
71 xdst->u.rt.fl.fl4_src == fl->fl4_src && 71 xdst->u.rt.fl.fl4_src == fl->fl4_src &&
@@ -246,7 +246,6 @@ static struct dst_ops xfrm4_dst_ops = {
246 .ifdown = xfrm4_dst_ifdown, 246 .ifdown = xfrm4_dst_ifdown,
247 .local_out = __ip_local_out, 247 .local_out = __ip_local_out,
248 .gc_thresh = 1024, 248 .gc_thresh = 1024,
249 .entry_size = sizeof(struct xfrm_dst),
250 .entries = ATOMIC_INIT(0), 249 .entries = ATOMIC_INIT(0),
251}; 250};
252 251
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d9da5eb9dcb2..e92ad8455c63 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2031,8 +2031,8 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
2031 2031
2032#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE) 2032#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
2033 if (dev->type == ARPHRD_SIT) { 2033 if (dev->type == ARPHRD_SIT) {
2034 const struct net_device_ops *ops = dev->netdev_ops;
2034 struct ifreq ifr; 2035 struct ifreq ifr;
2035 mm_segment_t oldfs;
2036 struct ip_tunnel_parm p; 2036 struct ip_tunnel_parm p;
2037 2037
2038 err = -EADDRNOTAVAIL; 2038 err = -EADDRNOTAVAIL;
@@ -2048,9 +2048,14 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
2048 p.iph.ttl = 64; 2048 p.iph.ttl = 64;
2049 ifr.ifr_ifru.ifru_data = (__force void __user *)&p; 2049 ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
2050 2050
2051 oldfs = get_fs(); set_fs(KERNEL_DS); 2051 if (ops->ndo_do_ioctl) {
2052 err = dev->do_ioctl(dev, &ifr, SIOCADDTUNNEL); 2052 mm_segment_t oldfs = get_fs();
2053 set_fs(oldfs); 2053
2054 set_fs(KERNEL_DS);
2055 err = ops->ndo_do_ioctl(dev, &ifr, SIOCADDTUNNEL);
2056 set_fs(oldfs);
2057 } else
2058 err = -EOPNOTSUPP;
2054 2059
2055 if (err == 0) { 2060 if (err == 0) {
2056 err = -ENOBUFS; 2061 err = -ENOBUFS;
@@ -2988,9 +2993,8 @@ static void if6_seq_stop(struct seq_file *seq, void *v)
2988static int if6_seq_show(struct seq_file *seq, void *v) 2993static int if6_seq_show(struct seq_file *seq, void *v)
2989{ 2994{
2990 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v; 2995 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
2991 seq_printf(seq, 2996 seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
2992 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n", 2997 &ifp->addr,
2993 NIP6(ifp->addr),
2994 ifp->idev->dev->ifindex, 2998 ifp->idev->dev->ifindex,
2995 ifp->prefix_len, 2999 ifp->prefix_len,
2996 ifp->scope, 3000 ifp->scope,
@@ -4033,8 +4037,8 @@ static struct addrconf_sysctl_table
4033 .data = &ipv6_devconf.forwarding, 4037 .data = &ipv6_devconf.forwarding,
4034 .maxlen = sizeof(int), 4038 .maxlen = sizeof(int),
4035 .mode = 0644, 4039 .mode = 0644,
4036 .proc_handler = &addrconf_sysctl_forward, 4040 .proc_handler = addrconf_sysctl_forward,
4037 .strategy = &addrconf_sysctl_forward_strategy, 4041 .strategy = addrconf_sysctl_forward_strategy,
4038 }, 4042 },
4039 { 4043 {
4040 .ctl_name = NET_IPV6_HOP_LIMIT, 4044 .ctl_name = NET_IPV6_HOP_LIMIT,
@@ -4050,7 +4054,7 @@ static struct addrconf_sysctl_table
4050 .data = &ipv6_devconf.mtu6, 4054 .data = &ipv6_devconf.mtu6,
4051 .maxlen = sizeof(int), 4055 .maxlen = sizeof(int),
4052 .mode = 0644, 4056 .mode = 0644,
4053 .proc_handler = &proc_dointvec, 4057 .proc_handler = proc_dointvec,
4054 }, 4058 },
4055 { 4059 {
4056 .ctl_name = NET_IPV6_ACCEPT_RA, 4060 .ctl_name = NET_IPV6_ACCEPT_RA,
@@ -4058,7 +4062,7 @@ static struct addrconf_sysctl_table
4058 .data = &ipv6_devconf.accept_ra, 4062 .data = &ipv6_devconf.accept_ra,
4059 .maxlen = sizeof(int), 4063 .maxlen = sizeof(int),
4060 .mode = 0644, 4064 .mode = 0644,
4061 .proc_handler = &proc_dointvec, 4065 .proc_handler = proc_dointvec,
4062 }, 4066 },
4063 { 4067 {
4064 .ctl_name = NET_IPV6_ACCEPT_REDIRECTS, 4068 .ctl_name = NET_IPV6_ACCEPT_REDIRECTS,
@@ -4066,7 +4070,7 @@ static struct addrconf_sysctl_table
4066 .data = &ipv6_devconf.accept_redirects, 4070 .data = &ipv6_devconf.accept_redirects,
4067 .maxlen = sizeof(int), 4071 .maxlen = sizeof(int),
4068 .mode = 0644, 4072 .mode = 0644,
4069 .proc_handler = &proc_dointvec, 4073 .proc_handler = proc_dointvec,
4070 }, 4074 },
4071 { 4075 {
4072 .ctl_name = NET_IPV6_AUTOCONF, 4076 .ctl_name = NET_IPV6_AUTOCONF,
@@ -4074,7 +4078,7 @@ static struct addrconf_sysctl_table
4074 .data = &ipv6_devconf.autoconf, 4078 .data = &ipv6_devconf.autoconf,
4075 .maxlen = sizeof(int), 4079 .maxlen = sizeof(int),
4076 .mode = 0644, 4080 .mode = 0644,
4077 .proc_handler = &proc_dointvec, 4081 .proc_handler = proc_dointvec,
4078 }, 4082 },
4079 { 4083 {
4080 .ctl_name = NET_IPV6_DAD_TRANSMITS, 4084 .ctl_name = NET_IPV6_DAD_TRANSMITS,
@@ -4082,7 +4086,7 @@ static struct addrconf_sysctl_table
4082 .data = &ipv6_devconf.dad_transmits, 4086 .data = &ipv6_devconf.dad_transmits,
4083 .maxlen = sizeof(int), 4087 .maxlen = sizeof(int),
4084 .mode = 0644, 4088 .mode = 0644,
4085 .proc_handler = &proc_dointvec, 4089 .proc_handler = proc_dointvec,
4086 }, 4090 },
4087 { 4091 {
4088 .ctl_name = NET_IPV6_RTR_SOLICITS, 4092 .ctl_name = NET_IPV6_RTR_SOLICITS,
@@ -4090,7 +4094,7 @@ static struct addrconf_sysctl_table
4090 .data = &ipv6_devconf.rtr_solicits, 4094 .data = &ipv6_devconf.rtr_solicits,
4091 .maxlen = sizeof(int), 4095 .maxlen = sizeof(int),
4092 .mode = 0644, 4096 .mode = 0644,
4093 .proc_handler = &proc_dointvec, 4097 .proc_handler = proc_dointvec,
4094 }, 4098 },
4095 { 4099 {
4096 .ctl_name = NET_IPV6_RTR_SOLICIT_INTERVAL, 4100 .ctl_name = NET_IPV6_RTR_SOLICIT_INTERVAL,
@@ -4098,8 +4102,8 @@ static struct addrconf_sysctl_table
4098 .data = &ipv6_devconf.rtr_solicit_interval, 4102 .data = &ipv6_devconf.rtr_solicit_interval,
4099 .maxlen = sizeof(int), 4103 .maxlen = sizeof(int),
4100 .mode = 0644, 4104 .mode = 0644,
4101 .proc_handler = &proc_dointvec_jiffies, 4105 .proc_handler = proc_dointvec_jiffies,
4102 .strategy = &sysctl_jiffies, 4106 .strategy = sysctl_jiffies,
4103 }, 4107 },
4104 { 4108 {
4105 .ctl_name = NET_IPV6_RTR_SOLICIT_DELAY, 4109 .ctl_name = NET_IPV6_RTR_SOLICIT_DELAY,
@@ -4107,8 +4111,8 @@ static struct addrconf_sysctl_table
4107 .data = &ipv6_devconf.rtr_solicit_delay, 4111 .data = &ipv6_devconf.rtr_solicit_delay,
4108 .maxlen = sizeof(int), 4112 .maxlen = sizeof(int),
4109 .mode = 0644, 4113 .mode = 0644,
4110 .proc_handler = &proc_dointvec_jiffies, 4114 .proc_handler = proc_dointvec_jiffies,
4111 .strategy = &sysctl_jiffies, 4115 .strategy = sysctl_jiffies,
4112 }, 4116 },
4113 { 4117 {
4114 .ctl_name = NET_IPV6_FORCE_MLD_VERSION, 4118 .ctl_name = NET_IPV6_FORCE_MLD_VERSION,
@@ -4116,7 +4120,7 @@ static struct addrconf_sysctl_table
4116 .data = &ipv6_devconf.force_mld_version, 4120 .data = &ipv6_devconf.force_mld_version,
4117 .maxlen = sizeof(int), 4121 .maxlen = sizeof(int),
4118 .mode = 0644, 4122 .mode = 0644,
4119 .proc_handler = &proc_dointvec, 4123 .proc_handler = proc_dointvec,
4120 }, 4124 },
4121#ifdef CONFIG_IPV6_PRIVACY 4125#ifdef CONFIG_IPV6_PRIVACY
4122 { 4126 {
@@ -4125,7 +4129,7 @@ static struct addrconf_sysctl_table
4125 .data = &ipv6_devconf.use_tempaddr, 4129 .data = &ipv6_devconf.use_tempaddr,
4126 .maxlen = sizeof(int), 4130 .maxlen = sizeof(int),
4127 .mode = 0644, 4131 .mode = 0644,
4128 .proc_handler = &proc_dointvec, 4132 .proc_handler = proc_dointvec,
4129 }, 4133 },
4130 { 4134 {
4131 .ctl_name = NET_IPV6_TEMP_VALID_LFT, 4135 .ctl_name = NET_IPV6_TEMP_VALID_LFT,
@@ -4133,7 +4137,7 @@ static struct addrconf_sysctl_table
4133 .data = &ipv6_devconf.temp_valid_lft, 4137 .data = &ipv6_devconf.temp_valid_lft,
4134 .maxlen = sizeof(int), 4138 .maxlen = sizeof(int),
4135 .mode = 0644, 4139 .mode = 0644,
4136 .proc_handler = &proc_dointvec, 4140 .proc_handler = proc_dointvec,
4137 }, 4141 },
4138 { 4142 {
4139 .ctl_name = NET_IPV6_TEMP_PREFERED_LFT, 4143 .ctl_name = NET_IPV6_TEMP_PREFERED_LFT,
@@ -4141,7 +4145,7 @@ static struct addrconf_sysctl_table
4141 .data = &ipv6_devconf.temp_prefered_lft, 4145 .data = &ipv6_devconf.temp_prefered_lft,
4142 .maxlen = sizeof(int), 4146 .maxlen = sizeof(int),
4143 .mode = 0644, 4147 .mode = 0644,
4144 .proc_handler = &proc_dointvec, 4148 .proc_handler = proc_dointvec,
4145 }, 4149 },
4146 { 4150 {
4147 .ctl_name = NET_IPV6_REGEN_MAX_RETRY, 4151 .ctl_name = NET_IPV6_REGEN_MAX_RETRY,
@@ -4149,7 +4153,7 @@ static struct addrconf_sysctl_table
4149 .data = &ipv6_devconf.regen_max_retry, 4153 .data = &ipv6_devconf.regen_max_retry,
4150 .maxlen = sizeof(int), 4154 .maxlen = sizeof(int),
4151 .mode = 0644, 4155 .mode = 0644,
4152 .proc_handler = &proc_dointvec, 4156 .proc_handler = proc_dointvec,
4153 }, 4157 },
4154 { 4158 {
4155 .ctl_name = NET_IPV6_MAX_DESYNC_FACTOR, 4159 .ctl_name = NET_IPV6_MAX_DESYNC_FACTOR,
@@ -4157,7 +4161,7 @@ static struct addrconf_sysctl_table
4157 .data = &ipv6_devconf.max_desync_factor, 4161 .data = &ipv6_devconf.max_desync_factor,
4158 .maxlen = sizeof(int), 4162 .maxlen = sizeof(int),
4159 .mode = 0644, 4163 .mode = 0644,
4160 .proc_handler = &proc_dointvec, 4164 .proc_handler = proc_dointvec,
4161 }, 4165 },
4162#endif 4166#endif
4163 { 4167 {
@@ -4166,7 +4170,7 @@ static struct addrconf_sysctl_table
4166 .data = &ipv6_devconf.max_addresses, 4170 .data = &ipv6_devconf.max_addresses,
4167 .maxlen = sizeof(int), 4171 .maxlen = sizeof(int),
4168 .mode = 0644, 4172 .mode = 0644,
4169 .proc_handler = &proc_dointvec, 4173 .proc_handler = proc_dointvec,
4170 }, 4174 },
4171 { 4175 {
4172 .ctl_name = NET_IPV6_ACCEPT_RA_DEFRTR, 4176 .ctl_name = NET_IPV6_ACCEPT_RA_DEFRTR,
@@ -4174,7 +4178,7 @@ static struct addrconf_sysctl_table
4174 .data = &ipv6_devconf.accept_ra_defrtr, 4178 .data = &ipv6_devconf.accept_ra_defrtr,
4175 .maxlen = sizeof(int), 4179 .maxlen = sizeof(int),
4176 .mode = 0644, 4180 .mode = 0644,
4177 .proc_handler = &proc_dointvec, 4181 .proc_handler = proc_dointvec,
4178 }, 4182 },
4179 { 4183 {
4180 .ctl_name = NET_IPV6_ACCEPT_RA_PINFO, 4184 .ctl_name = NET_IPV6_ACCEPT_RA_PINFO,
@@ -4182,7 +4186,7 @@ static struct addrconf_sysctl_table
4182 .data = &ipv6_devconf.accept_ra_pinfo, 4186 .data = &ipv6_devconf.accept_ra_pinfo,
4183 .maxlen = sizeof(int), 4187 .maxlen = sizeof(int),
4184 .mode = 0644, 4188 .mode = 0644,
4185 .proc_handler = &proc_dointvec, 4189 .proc_handler = proc_dointvec,
4186 }, 4190 },
4187#ifdef CONFIG_IPV6_ROUTER_PREF 4191#ifdef CONFIG_IPV6_ROUTER_PREF
4188 { 4192 {
@@ -4191,7 +4195,7 @@ static struct addrconf_sysctl_table
4191 .data = &ipv6_devconf.accept_ra_rtr_pref, 4195 .data = &ipv6_devconf.accept_ra_rtr_pref,
4192 .maxlen = sizeof(int), 4196 .maxlen = sizeof(int),
4193 .mode = 0644, 4197 .mode = 0644,
4194 .proc_handler = &proc_dointvec, 4198 .proc_handler = proc_dointvec,
4195 }, 4199 },
4196 { 4200 {
4197 .ctl_name = NET_IPV6_RTR_PROBE_INTERVAL, 4201 .ctl_name = NET_IPV6_RTR_PROBE_INTERVAL,
@@ -4199,8 +4203,8 @@ static struct addrconf_sysctl_table
4199 .data = &ipv6_devconf.rtr_probe_interval, 4203 .data = &ipv6_devconf.rtr_probe_interval,
4200 .maxlen = sizeof(int), 4204 .maxlen = sizeof(int),
4201 .mode = 0644, 4205 .mode = 0644,
4202 .proc_handler = &proc_dointvec_jiffies, 4206 .proc_handler = proc_dointvec_jiffies,
4203 .strategy = &sysctl_jiffies, 4207 .strategy = sysctl_jiffies,
4204 }, 4208 },
4205#ifdef CONFIG_IPV6_ROUTE_INFO 4209#ifdef CONFIG_IPV6_ROUTE_INFO
4206 { 4210 {
@@ -4209,7 +4213,7 @@ static struct addrconf_sysctl_table
4209 .data = &ipv6_devconf.accept_ra_rt_info_max_plen, 4213 .data = &ipv6_devconf.accept_ra_rt_info_max_plen,
4210 .maxlen = sizeof(int), 4214 .maxlen = sizeof(int),
4211 .mode = 0644, 4215 .mode = 0644,
4212 .proc_handler = &proc_dointvec, 4216 .proc_handler = proc_dointvec,
4213 }, 4217 },
4214#endif 4218#endif
4215#endif 4219#endif
@@ -4219,7 +4223,7 @@ static struct addrconf_sysctl_table
4219 .data = &ipv6_devconf.proxy_ndp, 4223 .data = &ipv6_devconf.proxy_ndp,
4220 .maxlen = sizeof(int), 4224 .maxlen = sizeof(int),
4221 .mode = 0644, 4225 .mode = 0644,
4222 .proc_handler = &proc_dointvec, 4226 .proc_handler = proc_dointvec,
4223 }, 4227 },
4224 { 4228 {
4225 .ctl_name = NET_IPV6_ACCEPT_SOURCE_ROUTE, 4229 .ctl_name = NET_IPV6_ACCEPT_SOURCE_ROUTE,
@@ -4227,7 +4231,7 @@ static struct addrconf_sysctl_table
4227 .data = &ipv6_devconf.accept_source_route, 4231 .data = &ipv6_devconf.accept_source_route,
4228 .maxlen = sizeof(int), 4232 .maxlen = sizeof(int),
4229 .mode = 0644, 4233 .mode = 0644,
4230 .proc_handler = &proc_dointvec, 4234 .proc_handler = proc_dointvec,
4231 }, 4235 },
4232#ifdef CONFIG_IPV6_OPTIMISTIC_DAD 4236#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
4233 { 4237 {
@@ -4236,7 +4240,7 @@ static struct addrconf_sysctl_table
4236 .data = &ipv6_devconf.optimistic_dad, 4240 .data = &ipv6_devconf.optimistic_dad,
4237 .maxlen = sizeof(int), 4241 .maxlen = sizeof(int),
4238 .mode = 0644, 4242 .mode = 0644,
4239 .proc_handler = &proc_dointvec, 4243 .proc_handler = proc_dointvec,
4240 4244
4241 }, 4245 },
4242#endif 4246#endif
@@ -4247,7 +4251,7 @@ static struct addrconf_sysctl_table
4247 .data = &ipv6_devconf.mc_forwarding, 4251 .data = &ipv6_devconf.mc_forwarding,
4248 .maxlen = sizeof(int), 4252 .maxlen = sizeof(int),
4249 .mode = 0644, 4253 .mode = 0644,
4250 .proc_handler = &proc_dointvec, 4254 .proc_handler = proc_dointvec,
4251 }, 4255 },
4252#endif 4256#endif
4253 { 4257 {
@@ -4256,7 +4260,7 @@ static struct addrconf_sysctl_table
4256 .data = &ipv6_devconf.disable_ipv6, 4260 .data = &ipv6_devconf.disable_ipv6,
4257 .maxlen = sizeof(int), 4261 .maxlen = sizeof(int),
4258 .mode = 0644, 4262 .mode = 0644,
4259 .proc_handler = &proc_dointvec, 4263 .proc_handler = proc_dointvec,
4260 }, 4264 },
4261 { 4265 {
4262 .ctl_name = CTL_UNNUMBERED, 4266 .ctl_name = CTL_UNNUMBERED,
@@ -4264,7 +4268,7 @@ static struct addrconf_sysctl_table
4264 .data = &ipv6_devconf.accept_dad, 4268 .data = &ipv6_devconf.accept_dad,
4265 .maxlen = sizeof(int), 4269 .maxlen = sizeof(int),
4266 .mode = 0644, 4270 .mode = 0644,
4267 .proc_handler = &proc_dointvec, 4271 .proc_handler = proc_dointvec,
4268 }, 4272 },
4269 { 4273 {
4270 .ctl_name = 0, /* sentinel */ 4274 .ctl_name = 0, /* sentinel */
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index 08909039d87b..6ff73c4c126a 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -186,10 +186,8 @@ u32 ipv6_addr_label(struct net *net,
186 label = p ? p->label : IPV6_ADDR_LABEL_DEFAULT; 186 label = p ? p->label : IPV6_ADDR_LABEL_DEFAULT;
187 rcu_read_unlock(); 187 rcu_read_unlock();
188 188
189 ADDRLABEL(KERN_DEBUG "%s(addr=" NIP6_FMT ", type=%d, ifindex=%d) => %08x\n", 189 ADDRLABEL(KERN_DEBUG "%s(addr=%pI6, type=%d, ifindex=%d) => %08x\n",
190 __func__, 190 __func__, addr, type, ifindex, label);
191 NIP6(*addr), type, ifindex,
192 label);
193 191
194 return label; 192 return label;
195} 193}
@@ -203,11 +201,8 @@ static struct ip6addrlbl_entry *ip6addrlbl_alloc(struct net *net,
203 struct ip6addrlbl_entry *newp; 201 struct ip6addrlbl_entry *newp;
204 int addrtype; 202 int addrtype;
205 203
206 ADDRLABEL(KERN_DEBUG "%s(prefix=" NIP6_FMT ", prefixlen=%d, ifindex=%d, label=%u)\n", 204 ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d, label=%u)\n",
207 __func__, 205 __func__, prefix, prefixlen, ifindex, (unsigned int)label);
208 NIP6(*prefix), prefixlen,
209 ifindex,
210 (unsigned int)label);
211 206
212 addrtype = ipv6_addr_type(prefix) & (IPV6_ADDR_MAPPED | IPV6_ADDR_COMPATv4 | IPV6_ADDR_LOOPBACK); 207 addrtype = ipv6_addr_type(prefix) & (IPV6_ADDR_MAPPED | IPV6_ADDR_COMPATv4 | IPV6_ADDR_LOOPBACK);
213 208
@@ -294,12 +289,9 @@ static int ip6addrlbl_add(struct net *net,
294 struct ip6addrlbl_entry *newp; 289 struct ip6addrlbl_entry *newp;
295 int ret = 0; 290 int ret = 0;
296 291
297 ADDRLABEL(KERN_DEBUG "%s(prefix=" NIP6_FMT ", prefixlen=%d, ifindex=%d, label=%u, replace=%d)\n", 292 ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d, label=%u, replace=%d)\n",
298 __func__, 293 __func__, prefix, prefixlen, ifindex, (unsigned int)label,
299 NIP6(*prefix), prefixlen, 294 replace);
300 ifindex,
301 (unsigned int)label,
302 replace);
303 295
304 newp = ip6addrlbl_alloc(net, prefix, prefixlen, ifindex, label); 296 newp = ip6addrlbl_alloc(net, prefix, prefixlen, ifindex, label);
305 if (IS_ERR(newp)) 297 if (IS_ERR(newp))
@@ -321,10 +313,8 @@ static int __ip6addrlbl_del(struct net *net,
321 struct hlist_node *pos, *n; 313 struct hlist_node *pos, *n;
322 int ret = -ESRCH; 314 int ret = -ESRCH;
323 315
324 ADDRLABEL(KERN_DEBUG "%s(prefix=" NIP6_FMT ", prefixlen=%d, ifindex=%d)\n", 316 ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d)\n",
325 __func__, 317 __func__, prefix, prefixlen, ifindex);
326 NIP6(*prefix), prefixlen,
327 ifindex);
328 318
329 hlist_for_each_entry_safe(p, pos, n, &ip6addrlbl_table.head, list) { 319 hlist_for_each_entry_safe(p, pos, n, &ip6addrlbl_table.head, list) {
330 if (p->prefixlen == prefixlen && 320 if (p->prefixlen == prefixlen &&
@@ -347,10 +337,8 @@ static int ip6addrlbl_del(struct net *net,
347 struct in6_addr prefix_buf; 337 struct in6_addr prefix_buf;
348 int ret; 338 int ret;
349 339
350 ADDRLABEL(KERN_DEBUG "%s(prefix=" NIP6_FMT ", prefixlen=%d, ifindex=%d)\n", 340 ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d)\n",
351 __func__, 341 __func__, prefix, prefixlen, ifindex);
352 NIP6(*prefix), prefixlen,
353 ifindex);
354 342
355 ipv6_addr_prefix(&prefix_buf, prefix, prefixlen); 343 ipv6_addr_prefix(&prefix_buf, prefix, prefixlen);
356 spin_lock(&ip6addrlbl_table.lock); 344 spin_lock(&ip6addrlbl_table.lock);
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 2ff0c8233e47..7a8a01369e5c 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -419,8 +419,8 @@ static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
419 if (!x) 419 if (!x)
420 return; 420 return;
421 421
422 NETDEBUG(KERN_DEBUG "pmtu discovery on SA AH/%08x/" NIP6_FMT "\n", 422 NETDEBUG(KERN_DEBUG "pmtu discovery on SA AH/%08x/%pI6\n",
423 ntohl(ah->spi), NIP6(iph->daddr)); 423 ntohl(ah->spi), &iph->daddr);
424 424
425 xfrm_state_put(x); 425 xfrm_state_put(x);
426} 426}
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index 8336cd81cb4f..1ae58bec1de0 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -512,11 +512,9 @@ static int ac6_seq_show(struct seq_file *seq, void *v)
512 struct ifacaddr6 *im = (struct ifacaddr6 *)v; 512 struct ifacaddr6 *im = (struct ifacaddr6 *)v;
513 struct ac6_iter_state *state = ac6_seq_private(seq); 513 struct ac6_iter_state *state = ac6_seq_private(seq);
514 514
515 seq_printf(seq, 515 seq_printf(seq, "%-4d %-15s %pi6 %5d\n",
516 "%-4d %-15s " NIP6_SEQFMT " %5d\n",
517 state->dev->ifindex, state->dev->name, 516 state->dev->ifindex, state->dev->name,
518 NIP6(im->aca_addr), 517 &im->aca_addr, im->aca_users);
519 im->aca_users);
520 return 0; 518 return 0;
521} 519}
522 520
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index b181b08fb761..c02a6308defe 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -367,8 +367,8 @@ static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
367 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET6); 367 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET6);
368 if (!x) 368 if (!x)
369 return; 369 return;
370 printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/" NIP6_FMT "\n", 370 printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/%pI6\n",
371 ntohl(esph->spi), NIP6(iph->daddr)); 371 ntohl(esph->spi), &iph->daddr);
372 xfrm_state_put(x); 372 xfrm_state_put(x);
373} 373}
374 374
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 6bfffec2371c..1c7f400a3cfe 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -219,7 +219,7 @@ static int ipv6_dest_hao(struct sk_buff *skb, int optoff)
219 219
220 if (!(ipv6_addr_type(&hao->addr) & IPV6_ADDR_UNICAST)) { 220 if (!(ipv6_addr_type(&hao->addr) & IPV6_ADDR_UNICAST)) {
221 LIMIT_NETDEBUG( 221 LIMIT_NETDEBUG(
222 KERN_DEBUG "hao is not an unicast addr: " NIP6_FMT "\n", NIP6(hao->addr)); 222 KERN_DEBUG "hao is not an unicast addr: %pI6\n", &hao->addr);
223 goto discard; 223 goto discard;
224 } 224 }
225 225
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 9b7d19ae5ced..a77b8d103804 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -233,7 +233,7 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
233 icmp6h->icmp6_cksum = 0; 233 icmp6h->icmp6_cksum = 0;
234 234
235 if (skb_queue_len(&sk->sk_write_queue) == 1) { 235 if (skb_queue_len(&sk->sk_write_queue) == 1) {
236 skb->csum = csum_partial((char *)icmp6h, 236 skb->csum = csum_partial(icmp6h,
237 sizeof(struct icmp6hdr), skb->csum); 237 sizeof(struct icmp6hdr), skb->csum);
238 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src, 238 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src,
239 &fl->fl6_dst, 239 &fl->fl6_dst,
@@ -246,7 +246,7 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
246 tmp_csum = csum_add(tmp_csum, skb->csum); 246 tmp_csum = csum_add(tmp_csum, skb->csum);
247 } 247 }
248 248
249 tmp_csum = csum_partial((char *)icmp6h, 249 tmp_csum = csum_partial(icmp6h,
250 sizeof(struct icmp6hdr), tmp_csum); 250 sizeof(struct icmp6hdr), tmp_csum);
251 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src, 251 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src,
252 &fl->fl6_dst, 252 &fl->fl6_dst,
@@ -646,9 +646,10 @@ static int icmpv6_rcv(struct sk_buff *skb)
646 int type; 646 int type;
647 647
648 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { 648 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
649 struct sec_path *sp = skb_sec_path(skb);
649 int nh; 650 int nh;
650 651
651 if (!(skb->sp && skb->sp->xvec[skb->sp->len - 1]->props.flags & 652 if (!(sp && sp->xvec[sp->len - 1]->props.flags &
652 XFRM_STATE_ICMP)) 653 XFRM_STATE_ICMP))
653 goto drop_no_count; 654 goto drop_no_count;
654 655
@@ -680,8 +681,8 @@ static int icmpv6_rcv(struct sk_buff *skb)
680 skb->csum = ~csum_unfold(csum_ipv6_magic(saddr, daddr, skb->len, 681 skb->csum = ~csum_unfold(csum_ipv6_magic(saddr, daddr, skb->len,
681 IPPROTO_ICMPV6, 0)); 682 IPPROTO_ICMPV6, 0));
682 if (__skb_checksum_complete(skb)) { 683 if (__skb_checksum_complete(skb)) {
683 LIMIT_NETDEBUG(KERN_DEBUG "ICMPv6 checksum failed [" NIP6_FMT " > " NIP6_FMT "]\n", 684 LIMIT_NETDEBUG(KERN_DEBUG "ICMPv6 checksum failed [%pI6 > %pI6]\n",
684 NIP6(*saddr), NIP6(*daddr)); 685 saddr, daddr);
685 goto discard_it; 686 goto discard_it;
686 } 687 }
687 } 688 }
@@ -955,8 +956,8 @@ ctl_table ipv6_icmp_table_template[] = {
955 .data = &init_net.ipv6.sysctl.icmpv6_time, 956 .data = &init_net.ipv6.sysctl.icmpv6_time,
956 .maxlen = sizeof(int), 957 .maxlen = sizeof(int),
957 .mode = 0644, 958 .mode = 0644,
958 .proc_handler = &proc_dointvec_ms_jiffies, 959 .proc_handler = proc_dointvec_ms_jiffies,
959 .strategy = &sysctl_ms_jiffies 960 .strategy = sysctl_ms_jiffies
960 }, 961 },
961 { .ctl_name = 0 }, 962 { .ctl_name = 0 },
962}; 963};
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 1646a5658255..21544b9be259 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -25,26 +25,30 @@
25void __inet6_hash(struct sock *sk) 25void __inet6_hash(struct sock *sk)
26{ 26{
27 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; 27 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
28 struct hlist_head *list;
29 rwlock_t *lock;
30 28
31 WARN_ON(!sk_unhashed(sk)); 29 WARN_ON(!sk_unhashed(sk));
32 30
33 if (sk->sk_state == TCP_LISTEN) { 31 if (sk->sk_state == TCP_LISTEN) {
34 list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; 32 struct inet_listen_hashbucket *ilb;
35 lock = &hashinfo->lhash_lock; 33
36 inet_listen_wlock(hashinfo); 34 ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
35 spin_lock(&ilb->lock);
36 __sk_add_node(sk, &ilb->head);
37 spin_unlock(&ilb->lock);
37 } else { 38 } else {
38 unsigned int hash; 39 unsigned int hash;
40 struct hlist_nulls_head *list;
41 rwlock_t *lock;
42
39 sk->sk_hash = hash = inet6_sk_ehashfn(sk); 43 sk->sk_hash = hash = inet6_sk_ehashfn(sk);
40 list = &inet_ehash_bucket(hashinfo, hash)->chain; 44 list = &inet_ehash_bucket(hashinfo, hash)->chain;
41 lock = inet_ehash_lockp(hashinfo, hash); 45 lock = inet_ehash_lockp(hashinfo, hash);
42 write_lock(lock); 46 write_lock(lock);
47 __sk_nulls_add_node_rcu(sk, list);
48 write_unlock(lock);
43 } 49 }
44 50
45 __sk_add_node(sk, list);
46 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 51 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
47 write_unlock(lock);
48} 52}
49EXPORT_SYMBOL(__inet6_hash); 53EXPORT_SYMBOL(__inet6_hash);
50 54
@@ -63,33 +67,53 @@ struct sock *__inet6_lookup_established(struct net *net,
63 const int dif) 67 const int dif)
64{ 68{
65 struct sock *sk; 69 struct sock *sk;
66 const struct hlist_node *node; 70 const struct hlist_nulls_node *node;
67 const __portpair ports = INET_COMBINED_PORTS(sport, hnum); 71 const __portpair ports = INET_COMBINED_PORTS(sport, hnum);
68 /* Optimize here for direct hit, only listening connections can 72 /* Optimize here for direct hit, only listening connections can
69 * have wildcards anyways. 73 * have wildcards anyways.
70 */ 74 */
71 unsigned int hash = inet6_ehashfn(net, daddr, hnum, saddr, sport); 75 unsigned int hash = inet6_ehashfn(net, daddr, hnum, saddr, sport);
72 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); 76 unsigned int slot = hash & (hashinfo->ehash_size - 1);
73 rwlock_t *lock = inet_ehash_lockp(hashinfo, hash); 77 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
74 78
75 prefetch(head->chain.first); 79
76 read_lock(lock); 80 rcu_read_lock();
77 sk_for_each(sk, node, &head->chain) { 81begin:
82 sk_nulls_for_each_rcu(sk, node, &head->chain) {
78 /* For IPV6 do the cheaper port and family tests first. */ 83 /* For IPV6 do the cheaper port and family tests first. */
79 if (INET6_MATCH(sk, net, hash, saddr, daddr, ports, dif)) 84 if (INET6_MATCH(sk, net, hash, saddr, daddr, ports, dif)) {
80 goto hit; /* You sunk my battleship! */ 85 if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt)))
86 goto begintw;
87 if (!INET6_MATCH(sk, net, hash, saddr, daddr, ports, dif)) {
88 sock_put(sk);
89 goto begin;
90 }
91 goto out;
92 }
81 } 93 }
94 if (get_nulls_value(node) != slot)
95 goto begin;
96
97begintw:
82 /* Must check for a TIME_WAIT'er before going to listener hash. */ 98 /* Must check for a TIME_WAIT'er before going to listener hash. */
83 sk_for_each(sk, node, &head->twchain) { 99 sk_nulls_for_each_rcu(sk, node, &head->twchain) {
84 if (INET6_TW_MATCH(sk, net, hash, saddr, daddr, ports, dif)) 100 if (INET6_TW_MATCH(sk, net, hash, saddr, daddr, ports, dif)) {
85 goto hit; 101 if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt))) {
102 sk = NULL;
103 goto out;
104 }
105 if (!INET6_TW_MATCH(sk, net, hash, saddr, daddr, ports, dif)) {
106 sock_put(sk);
107 goto begintw;
108 }
109 goto out;
110 }
86 } 111 }
87 read_unlock(lock); 112 if (get_nulls_value(node) != slot)
88 return NULL; 113 goto begintw;
89 114 sk = NULL;
90hit: 115out:
91 sock_hold(sk); 116 rcu_read_unlock();
92 read_unlock(lock);
93 return sk; 117 return sk;
94} 118}
95EXPORT_SYMBOL(__inet6_lookup_established); 119EXPORT_SYMBOL(__inet6_lookup_established);
@@ -102,10 +126,11 @@ struct sock *inet6_lookup_listener(struct net *net,
102 const struct hlist_node *node; 126 const struct hlist_node *node;
103 struct sock *result = NULL; 127 struct sock *result = NULL;
104 int score, hiscore = 0; 128 int score, hiscore = 0;
129 struct inet_listen_hashbucket *ilb;
105 130
106 read_lock(&hashinfo->lhash_lock); 131 ilb = &hashinfo->listening_hash[inet_lhashfn(net, hnum)];
107 sk_for_each(sk, node, 132 spin_lock(&ilb->lock);
108 &hashinfo->listening_hash[inet_lhashfn(net, hnum)]) { 133 sk_for_each(sk, node, &ilb->head) {
109 if (net_eq(sock_net(sk), net) && inet_sk(sk)->num == hnum && 134 if (net_eq(sock_net(sk), net) && inet_sk(sk)->num == hnum &&
110 sk->sk_family == PF_INET6) { 135 sk->sk_family == PF_INET6) {
111 const struct ipv6_pinfo *np = inet6_sk(sk); 136 const struct ipv6_pinfo *np = inet6_sk(sk);
@@ -133,7 +158,7 @@ struct sock *inet6_lookup_listener(struct net *net,
133 } 158 }
134 if (result) 159 if (result)
135 sock_hold(result); 160 sock_hold(result);
136 read_unlock(&hashinfo->lhash_lock); 161 spin_unlock(&ilb->lock);
137 return result; 162 return result;
138} 163}
139 164
@@ -172,14 +197,14 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
172 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); 197 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
173 rwlock_t *lock = inet_ehash_lockp(hinfo, hash); 198 rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
174 struct sock *sk2; 199 struct sock *sk2;
175 const struct hlist_node *node; 200 const struct hlist_nulls_node *node;
176 struct inet_timewait_sock *tw; 201 struct inet_timewait_sock *tw;
177 202
178 prefetch(head->chain.first); 203 prefetch(head->chain.first);
179 write_lock(lock); 204 write_lock(lock);
180 205
181 /* Check TIME-WAIT sockets first. */ 206 /* Check TIME-WAIT sockets first. */
182 sk_for_each(sk2, node, &head->twchain) { 207 sk_nulls_for_each(sk2, node, &head->twchain) {
183 tw = inet_twsk(sk2); 208 tw = inet_twsk(sk2);
184 209
185 if (INET6_TW_MATCH(sk2, net, hash, saddr, daddr, ports, dif)) { 210 if (INET6_TW_MATCH(sk2, net, hash, saddr, daddr, ports, dif)) {
@@ -192,7 +217,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
192 tw = NULL; 217 tw = NULL;
193 218
194 /* And established part... */ 219 /* And established part... */
195 sk_for_each(sk2, node, &head->chain) { 220 sk_nulls_for_each(sk2, node, &head->chain) {
196 if (INET6_MATCH(sk2, net, hash, saddr, daddr, ports, dif)) 221 if (INET6_MATCH(sk2, net, hash, saddr, daddr, ports, dif))
197 goto not_unique; 222 goto not_unique;
198 } 223 }
@@ -203,7 +228,7 @@ unique:
203 inet->num = lport; 228 inet->num = lport;
204 inet->sport = htons(lport); 229 inet->sport = htons(lport);
205 WARN_ON(!sk_unhashed(sk)); 230 WARN_ON(!sk_unhashed(sk));
206 __sk_add_node(sk, &head->chain); 231 __sk_nulls_add_node_rcu(sk, &head->chain);
207 sk->sk_hash = hash; 232 sk->sk_hash = hash;
208 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 233 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
209 write_unlock(lock); 234 write_unlock(lock);
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 37a4e777e347..7927a8498d17 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -696,14 +696,14 @@ static int ip6fl_seq_show(struct seq_file *seq, void *v)
696 else { 696 else {
697 struct ip6_flowlabel *fl = v; 697 struct ip6_flowlabel *fl = v;
698 seq_printf(seq, 698 seq_printf(seq,
699 "%05X %-1d %-6d %-6d %-6ld %-8ld " NIP6_SEQFMT " %-4d\n", 699 "%05X %-1d %-6d %-6d %-6ld %-8ld %pi6 %-4d\n",
700 (unsigned)ntohl(fl->label), 700 (unsigned)ntohl(fl->label),
701 fl->share, 701 fl->share,
702 (unsigned)fl->owner, 702 (unsigned)fl->owner,
703 atomic_read(&fl->users), 703 atomic_read(&fl->users),
704 fl->linger/HZ, 704 fl->linger/HZ,
705 (long)(fl->expires - jiffies)/HZ, 705 (long)(fl->expires - jiffies)/HZ,
706 NIP6(fl->dst), 706 &fl->dst,
707 fl->opt ? fl->opt->opt_nflen : 0); 707 fl->opt ? fl->opt->opt_nflen : 0);
708 } 708 }
709 return 0; 709 return 0;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index c77db0b95e26..7d92fd97cfb9 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -490,7 +490,7 @@ int ip6_forward(struct sk_buff *skb)
490 We don't send redirects to frames decapsulated from IPsec. 490 We don't send redirects to frames decapsulated from IPsec.
491 */ 491 */
492 if (skb->dev == dst->dev && dst->neighbour && opt->srcrt == 0 && 492 if (skb->dev == dst->dev && dst->neighbour && opt->srcrt == 0 &&
493 !skb->sp) { 493 !skb_sec_path(skb)) {
494 struct in6_addr *target = NULL; 494 struct in6_addr *target = NULL;
495 struct rt6_info *rt; 495 struct rt6_info *rt;
496 struct neighbour *n = dst->neighbour; 496 struct neighbour *n = dst->neighbour;
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 0524769632e7..363ae258ee1e 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -297,9 +297,8 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
297 const struct mfc6_cache *mfc = v; 297 const struct mfc6_cache *mfc = v;
298 const struct ipmr_mfc_iter *it = seq->private; 298 const struct ipmr_mfc_iter *it = seq->private;
299 299
300 seq_printf(seq, 300 seq_printf(seq, "%pI6 %pI6 %-3d %8ld %8ld %8ld",
301 NIP6_FMT " " NIP6_FMT " %-3d %8ld %8ld %8ld", 301 &mfc->mf6c_mcastgrp, &mfc->mf6c_origin,
302 NIP6(mfc->mf6c_mcastgrp), NIP6(mfc->mf6c_origin),
303 mfc->mf6c_parent, 302 mfc->mf6c_parent,
304 mfc->mfc_un.res.pkt, 303 mfc->mfc_un.res.pkt,
305 mfc->mfc_un.res.bytes, 304 mfc->mfc_un.res.bytes,
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 4545e4306862..d4576a9c154f 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -67,8 +67,8 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
67 if (!x) 67 if (!x)
68 return; 68 return;
69 69
70 printk(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/" NIP6_FMT "\n", 70 printk(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%pI6\n",
71 spi, NIP6(iph->daddr)); 71 spi, &iph->daddr);
72 xfrm_state_put(x); 72 xfrm_state_put(x);
73} 73}
74 74
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index d7b3c6d398ae..870a1d64605a 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1817,7 +1817,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1817 1817
1818 hdr->icmp6_cksum = csum_ipv6_magic(saddr, snd_addr, len, 1818 hdr->icmp6_cksum = csum_ipv6_magic(saddr, snd_addr, len,
1819 IPPROTO_ICMPV6, 1819 IPPROTO_ICMPV6,
1820 csum_partial((__u8 *) hdr, len, 0)); 1820 csum_partial(hdr, len, 0));
1821 1821
1822 idev = in6_dev_get(skb->dev); 1822 idev = in6_dev_get(skb->dev);
1823 1823
@@ -2430,9 +2430,9 @@ static int igmp6_mc_seq_show(struct seq_file *seq, void *v)
2430 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq); 2430 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
2431 2431
2432 seq_printf(seq, 2432 seq_printf(seq,
2433 "%-4d %-15s " NIP6_SEQFMT " %5d %08X %ld\n", 2433 "%-4d %-15s %pi6 %5d %08X %ld\n",
2434 state->dev->ifindex, state->dev->name, 2434 state->dev->ifindex, state->dev->name,
2435 NIP6(im->mca_addr), 2435 &im->mca_addr,
2436 im->mca_users, im->mca_flags, 2436 im->mca_users, im->mca_flags,
2437 (im->mca_flags&MAF_TIMER_RUNNING) ? 2437 (im->mca_flags&MAF_TIMER_RUNNING) ?
2438 jiffies_to_clock_t(im->mca_timer.expires-jiffies) : 0); 2438 jiffies_to_clock_t(im->mca_timer.expires-jiffies) : 0);
@@ -2591,10 +2591,10 @@ static int igmp6_mcf_seq_show(struct seq_file *seq, void *v)
2591 "Source Address", "INC", "EXC"); 2591 "Source Address", "INC", "EXC");
2592 } else { 2592 } else {
2593 seq_printf(seq, 2593 seq_printf(seq,
2594 "%3d %6.6s " NIP6_SEQFMT " " NIP6_SEQFMT " %6lu %6lu\n", 2594 "%3d %6.6s %pi6 %pi6 %6lu %6lu\n",
2595 state->dev->ifindex, state->dev->name, 2595 state->dev->ifindex, state->dev->name,
2596 NIP6(state->im->mca_addr), 2596 &state->im->mca_addr,
2597 NIP6(psf->sf_addr), 2597 &psf->sf_addr,
2598 psf->sf_count[MCAST_INCLUDE], 2598 psf->sf_count[MCAST_INCLUDE],
2599 psf->sf_count[MCAST_EXCLUDE]); 2599 psf->sf_count[MCAST_EXCLUDE]);
2600 } 2600 }
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 172438320eec..af6705f03b5c 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -437,38 +437,20 @@ static void pndisc_destructor(struct pneigh_entry *n)
437 ipv6_dev_mc_dec(dev, &maddr); 437 ipv6_dev_mc_dec(dev, &maddr);
438} 438}
439 439
440/* 440struct sk_buff *ndisc_build_skb(struct net_device *dev,
441 * Send a Neighbour Advertisement 441 const struct in6_addr *daddr,
442 */ 442 const struct in6_addr *saddr,
443static void __ndisc_send(struct net_device *dev, 443 struct icmp6hdr *icmp6h,
444 struct neighbour *neigh, 444 const struct in6_addr *target,
445 const struct in6_addr *daddr, 445 int llinfo)
446 const struct in6_addr *saddr,
447 struct icmp6hdr *icmp6h, const struct in6_addr *target,
448 int llinfo)
449{ 446{
450 struct flowi fl;
451 struct dst_entry *dst;
452 struct net *net = dev_net(dev); 447 struct net *net = dev_net(dev);
453 struct sock *sk = net->ipv6.ndisc_sk; 448 struct sock *sk = net->ipv6.ndisc_sk;
454 struct sk_buff *skb; 449 struct sk_buff *skb;
455 struct icmp6hdr *hdr; 450 struct icmp6hdr *hdr;
456 struct inet6_dev *idev;
457 int len; 451 int len;
458 int err; 452 int err;
459 u8 *opt, type; 453 u8 *opt;
460
461 type = icmp6h->icmp6_type;
462
463 icmpv6_flow_init(sk, &fl, type, saddr, daddr, dev->ifindex);
464
465 dst = icmp6_dst_alloc(dev, neigh, daddr);
466 if (!dst)
467 return;
468
469 err = xfrm_lookup(&dst, &fl, NULL, 0);
470 if (err < 0)
471 return;
472 454
473 if (!dev->addr_len) 455 if (!dev->addr_len)
474 llinfo = 0; 456 llinfo = 0;
@@ -485,8 +467,7 @@ static void __ndisc_send(struct net_device *dev,
485 ND_PRINTK0(KERN_ERR 467 ND_PRINTK0(KERN_ERR
486 "ICMPv6 ND: %s() failed to allocate an skb.\n", 468 "ICMPv6 ND: %s() failed to allocate an skb.\n",
487 __func__); 469 __func__);
488 dst_release(dst); 470 return NULL;
489 return;
490 } 471 }
491 472
492 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 473 skb_reserve(skb, LL_RESERVED_SPACE(dev));
@@ -510,9 +491,45 @@ static void __ndisc_send(struct net_device *dev,
510 491
511 hdr->icmp6_cksum = csum_ipv6_magic(saddr, daddr, len, 492 hdr->icmp6_cksum = csum_ipv6_magic(saddr, daddr, len,
512 IPPROTO_ICMPV6, 493 IPPROTO_ICMPV6,
513 csum_partial((__u8 *) hdr, 494 csum_partial(hdr,
514 len, 0)); 495 len, 0));
515 496
497 return skb;
498}
499
500EXPORT_SYMBOL(ndisc_build_skb);
501
502void ndisc_send_skb(struct sk_buff *skb,
503 struct net_device *dev,
504 struct neighbour *neigh,
505 const struct in6_addr *daddr,
506 const struct in6_addr *saddr,
507 struct icmp6hdr *icmp6h)
508{
509 struct flowi fl;
510 struct dst_entry *dst;
511 struct net *net = dev_net(dev);
512 struct sock *sk = net->ipv6.ndisc_sk;
513 struct inet6_dev *idev;
514 int err;
515 u8 type;
516
517 type = icmp6h->icmp6_type;
518
519 icmpv6_flow_init(sk, &fl, type, saddr, daddr, dev->ifindex);
520
521 dst = icmp6_dst_alloc(dev, neigh, daddr);
522 if (!dst) {
523 kfree_skb(skb);
524 return;
525 }
526
527 err = xfrm_lookup(&dst, &fl, NULL, 0);
528 if (err < 0) {
529 kfree_skb(skb);
530 return;
531 }
532
516 skb->dst = dst; 533 skb->dst = dst;
517 534
518 idev = in6_dev_get(dst->dev); 535 idev = in6_dev_get(dst->dev);
@@ -529,6 +546,27 @@ static void __ndisc_send(struct net_device *dev,
529 in6_dev_put(idev); 546 in6_dev_put(idev);
530} 547}
531 548
549EXPORT_SYMBOL(ndisc_send_skb);
550
551/*
552 * Send a Neighbour Discover packet
553 */
554static void __ndisc_send(struct net_device *dev,
555 struct neighbour *neigh,
556 const struct in6_addr *daddr,
557 const struct in6_addr *saddr,
558 struct icmp6hdr *icmp6h, const struct in6_addr *target,
559 int llinfo)
560{
561 struct sk_buff *skb;
562
563 skb = ndisc_build_skb(dev, daddr, saddr, icmp6h, target, llinfo);
564 if (!skb)
565 return;
566
567 ndisc_send_skb(skb, dev, neigh, daddr, saddr, icmp6h);
568}
569
532static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, 570static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
533 const struct in6_addr *daddr, 571 const struct in6_addr *daddr,
534 const struct in6_addr *solicited_addr, 572 const struct in6_addr *solicited_addr,
@@ -647,11 +685,8 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
647 685
648 if ((probes -= neigh->parms->ucast_probes) < 0) { 686 if ((probes -= neigh->parms->ucast_probes) < 0) {
649 if (!(neigh->nud_state & NUD_VALID)) { 687 if (!(neigh->nud_state & NUD_VALID)) {
650 ND_PRINTK1(KERN_DEBUG 688 ND_PRINTK1(KERN_DEBUG "%s(): trying to ucast probe in NUD_INVALID: %pI6\n",
651 "%s(): trying to ucast probe in NUD_INVALID: " 689 __func__, target);
652 NIP6_FMT "\n",
653 __func__,
654 NIP6(*target));
655 } 690 }
656 ndisc_send_ns(dev, neigh, target, target, saddr); 691 ndisc_send_ns(dev, neigh, target, target, saddr);
657 } else if ((probes -= neigh->parms->app_probes) < 0) { 692 } else if ((probes -= neigh->parms->app_probes) < 0) {
@@ -1577,7 +1612,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1577 1612
1578 icmph->icmp6_cksum = csum_ipv6_magic(&saddr_buf, &ipv6_hdr(skb)->saddr, 1613 icmph->icmp6_cksum = csum_ipv6_magic(&saddr_buf, &ipv6_hdr(skb)->saddr,
1579 len, IPPROTO_ICMPV6, 1614 len, IPPROTO_ICMPV6,
1580 csum_partial((u8 *) icmph, len, 0)); 1615 csum_partial(icmph, len, 0));
1581 1616
1582 buff->dst = dst; 1617 buff->dst = dst;
1583 idev = in6_dev_get(dst->dev); 1618 idev = in6_dev_get(dst->dev);
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index caa441d09567..7c668c63f708 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -61,7 +61,7 @@ static void dump_packet(const struct nf_loginfo *info,
61 } 61 }
62 62
63 /* Max length: 88 "SRC=0000.0000.0000.0000.0000.0000.0000.0000 DST=0000.0000.0000.0000.0000.0000.0000.0000 " */ 63 /* Max length: 88 "SRC=0000.0000.0000.0000.0000.0000.0000.0000 DST=0000.0000.0000.0000.0000.0000.0000.0000 " */
64 printk("SRC=" NIP6_FMT " DST=" NIP6_FMT " ", NIP6(ih->saddr), NIP6(ih->daddr)); 64 printk("SRC=%pI6 DST=%pI6 ", &ih->saddr, &ih->daddr);
65 65
66 /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */ 66 /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
67 printk("LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ", 67 printk("LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
@@ -424,9 +424,8 @@ ip6t_log_packet(u_int8_t pf,
424 if (skb->dev->type == ARPHRD_SIT) { 424 if (skb->dev->type == ARPHRD_SIT) {
425 const struct iphdr *iph = 425 const struct iphdr *iph =
426 (struct iphdr *)skb_mac_header(skb); 426 (struct iphdr *)skb_mac_header(skb);
427 printk("TUNNEL=%u.%u.%u.%u->%u.%u.%u.%u ", 427 printk("TUNNEL=%pI4->%pI4 ",
428 NIPQUAD(iph->saddr), 428 &iph->saddr, &iph->daddr);
429 NIPQUAD(iph->daddr));
430 } 429 }
431 } else 430 } else
432 printk(" "); 431 printk(" ");
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index e91db16611d9..727b9530448a 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -56,9 +56,8 @@ static bool ipv6_invert_tuple(struct nf_conntrack_tuple *tuple,
56static int ipv6_print_tuple(struct seq_file *s, 56static int ipv6_print_tuple(struct seq_file *s,
57 const struct nf_conntrack_tuple *tuple) 57 const struct nf_conntrack_tuple *tuple)
58{ 58{
59 return seq_printf(s, "src=" NIP6_FMT " dst=" NIP6_FMT " ", 59 return seq_printf(s, "src=%pI6 dst=%pI6 ",
60 NIP6(*((struct in6_addr *)tuple->src.u3.ip6)), 60 tuple->src.u3.ip6, tuple->dst.u3.ip6);
61 NIP6(*((struct in6_addr *)tuple->dst.u3.ip6)));
62} 61}
63 62
64/* 63/*
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 05726177903f..bd52151d31e9 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -253,7 +253,7 @@ static struct ctl_table icmpv6_sysctl_table[] = {
253 .data = &nf_ct_icmpv6_timeout, 253 .data = &nf_ct_icmpv6_timeout,
254 .maxlen = sizeof(unsigned int), 254 .maxlen = sizeof(unsigned int),
255 .mode = 0644, 255 .mode = 0644,
256 .proc_handler = &proc_dointvec_jiffies, 256 .proc_handler = proc_dointvec_jiffies,
257 }, 257 },
258 { 258 {
259 .ctl_name = 0 259 .ctl_name = 0
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 9967ac7a01a8..ed4d79a9e4a6 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -80,7 +80,7 @@ struct ctl_table nf_ct_ipv6_sysctl_table[] = {
80 .data = &nf_init_frags.timeout, 80 .data = &nf_init_frags.timeout,
81 .maxlen = sizeof(unsigned int), 81 .maxlen = sizeof(unsigned int),
82 .mode = 0644, 82 .mode = 0644,
83 .proc_handler = &proc_dointvec_jiffies, 83 .proc_handler = proc_dointvec_jiffies,
84 }, 84 },
85 { 85 {
86 .ctl_name = NET_NF_CONNTRACK_FRAG6_LOW_THRESH, 86 .ctl_name = NET_NF_CONNTRACK_FRAG6_LOW_THRESH,
@@ -88,7 +88,7 @@ struct ctl_table nf_ct_ipv6_sysctl_table[] = {
88 .data = &nf_init_frags.low_thresh, 88 .data = &nf_init_frags.low_thresh,
89 .maxlen = sizeof(unsigned int), 89 .maxlen = sizeof(unsigned int),
90 .mode = 0644, 90 .mode = 0644,
91 .proc_handler = &proc_dointvec, 91 .proc_handler = proc_dointvec,
92 }, 92 },
93 { 93 {
94 .ctl_name = NET_NF_CONNTRACK_FRAG6_HIGH_THRESH, 94 .ctl_name = NET_NF_CONNTRACK_FRAG6_HIGH_THRESH,
@@ -96,7 +96,7 @@ struct ctl_table nf_ct_ipv6_sysctl_table[] = {
96 .data = &nf_init_frags.high_thresh, 96 .data = &nf_init_frags.high_thresh,
97 .maxlen = sizeof(unsigned int), 97 .maxlen = sizeof(unsigned int),
98 .mode = 0644, 98 .mode = 0644,
99 .proc_handler = &proc_dointvec, 99 .proc_handler = proc_dointvec,
100 }, 100 },
101 { .ctl_name = 0 } 101 { .ctl_name = 0 }
102}; 102};
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index af12de071f4c..3c575118fca5 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -642,7 +642,7 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = {
642 .data = &init_net.ipv6.frags.high_thresh, 642 .data = &init_net.ipv6.frags.high_thresh,
643 .maxlen = sizeof(int), 643 .maxlen = sizeof(int),
644 .mode = 0644, 644 .mode = 0644,
645 .proc_handler = &proc_dointvec 645 .proc_handler = proc_dointvec
646 }, 646 },
647 { 647 {
648 .ctl_name = NET_IPV6_IP6FRAG_LOW_THRESH, 648 .ctl_name = NET_IPV6_IP6FRAG_LOW_THRESH,
@@ -650,7 +650,7 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = {
650 .data = &init_net.ipv6.frags.low_thresh, 650 .data = &init_net.ipv6.frags.low_thresh,
651 .maxlen = sizeof(int), 651 .maxlen = sizeof(int),
652 .mode = 0644, 652 .mode = 0644,
653 .proc_handler = &proc_dointvec 653 .proc_handler = proc_dointvec
654 }, 654 },
655 { 655 {
656 .ctl_name = NET_IPV6_IP6FRAG_TIME, 656 .ctl_name = NET_IPV6_IP6FRAG_TIME,
@@ -658,8 +658,8 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = {
658 .data = &init_net.ipv6.frags.timeout, 658 .data = &init_net.ipv6.frags.timeout,
659 .maxlen = sizeof(int), 659 .maxlen = sizeof(int),
660 .mode = 0644, 660 .mode = 0644,
661 .proc_handler = &proc_dointvec_jiffies, 661 .proc_handler = proc_dointvec_jiffies,
662 .strategy = &sysctl_jiffies, 662 .strategy = sysctl_jiffies,
663 }, 663 },
664 { } 664 { }
665}; 665};
@@ -671,8 +671,8 @@ static struct ctl_table ip6_frags_ctl_table[] = {
671 .data = &ip6_frags.secret_interval, 671 .data = &ip6_frags.secret_interval,
672 .maxlen = sizeof(int), 672 .maxlen = sizeof(int),
673 .mode = 0644, 673 .mode = 0644,
674 .proc_handler = &proc_dointvec_jiffies, 674 .proc_handler = proc_dointvec_jiffies,
675 .strategy = &sysctl_jiffies 675 .strategy = sysctl_jiffies
676 }, 676 },
677 { } 677 { }
678}; 678};
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 89dc69924340..9da1ece466a2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -108,7 +108,6 @@ static struct dst_ops ip6_dst_ops_template = {
108 .link_failure = ip6_link_failure, 108 .link_failure = ip6_link_failure,
109 .update_pmtu = ip6_rt_update_pmtu, 109 .update_pmtu = ip6_rt_update_pmtu,
110 .local_out = __ip6_local_out, 110 .local_out = __ip6_local_out,
111 .entry_size = sizeof(struct rt6_info),
112 .entries = ATOMIC_INIT(0), 111 .entries = ATOMIC_INIT(0),
113}; 112};
114 113
@@ -122,7 +121,6 @@ static struct dst_ops ip6_dst_blackhole_ops = {
122 .destroy = ip6_dst_destroy, 121 .destroy = ip6_dst_destroy,
123 .check = ip6_dst_check, 122 .check = ip6_dst_check,
124 .update_pmtu = ip6_rt_blackhole_update_pmtu, 123 .update_pmtu = ip6_rt_blackhole_update_pmtu,
125 .entry_size = sizeof(struct rt6_info),
126 .entries = ATOMIC_INIT(0), 124 .entries = ATOMIC_INIT(0),
127}; 125};
128 126
@@ -2408,19 +2406,16 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2408{ 2406{
2409 struct seq_file *m = p_arg; 2407 struct seq_file *m = p_arg;
2410 2408
2411 seq_printf(m, NIP6_SEQFMT " %02x ", NIP6(rt->rt6i_dst.addr), 2409 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
2412 rt->rt6i_dst.plen);
2413 2410
2414#ifdef CONFIG_IPV6_SUBTREES 2411#ifdef CONFIG_IPV6_SUBTREES
2415 seq_printf(m, NIP6_SEQFMT " %02x ", NIP6(rt->rt6i_src.addr), 2412 seq_printf(m, "%pi6 %02x ", &rt->rt6i_src.addr, rt->rt6i_src.plen);
2416 rt->rt6i_src.plen);
2417#else 2413#else
2418 seq_puts(m, "00000000000000000000000000000000 00 "); 2414 seq_puts(m, "00000000000000000000000000000000 00 ");
2419#endif 2415#endif
2420 2416
2421 if (rt->rt6i_nexthop) { 2417 if (rt->rt6i_nexthop) {
2422 seq_printf(m, NIP6_SEQFMT, 2418 seq_printf(m, "%pi6", rt->rt6i_nexthop->primary_key);
2423 NIP6(*((struct in6_addr *)rt->rt6i_nexthop->primary_key)));
2424 } else { 2419 } else {
2425 seq_puts(m, "00000000000000000000000000000000"); 2420 seq_puts(m, "00000000000000000000000000000000");
2426 } 2421 }
@@ -2502,7 +2497,7 @@ ctl_table ipv6_route_table_template[] = {
2502 .data = &init_net.ipv6.sysctl.flush_delay, 2497 .data = &init_net.ipv6.sysctl.flush_delay,
2503 .maxlen = sizeof(int), 2498 .maxlen = sizeof(int),
2504 .mode = 0200, 2499 .mode = 0200,
2505 .proc_handler = &ipv6_sysctl_rtcache_flush 2500 .proc_handler = ipv6_sysctl_rtcache_flush
2506 }, 2501 },
2507 { 2502 {
2508 .ctl_name = NET_IPV6_ROUTE_GC_THRESH, 2503 .ctl_name = NET_IPV6_ROUTE_GC_THRESH,
@@ -2510,7 +2505,7 @@ ctl_table ipv6_route_table_template[] = {
2510 .data = &ip6_dst_ops_template.gc_thresh, 2505 .data = &ip6_dst_ops_template.gc_thresh,
2511 .maxlen = sizeof(int), 2506 .maxlen = sizeof(int),
2512 .mode = 0644, 2507 .mode = 0644,
2513 .proc_handler = &proc_dointvec, 2508 .proc_handler = proc_dointvec,
2514 }, 2509 },
2515 { 2510 {
2516 .ctl_name = NET_IPV6_ROUTE_MAX_SIZE, 2511 .ctl_name = NET_IPV6_ROUTE_MAX_SIZE,
@@ -2518,7 +2513,7 @@ ctl_table ipv6_route_table_template[] = {
2518 .data = &init_net.ipv6.sysctl.ip6_rt_max_size, 2513 .data = &init_net.ipv6.sysctl.ip6_rt_max_size,
2519 .maxlen = sizeof(int), 2514 .maxlen = sizeof(int),
2520 .mode = 0644, 2515 .mode = 0644,
2521 .proc_handler = &proc_dointvec, 2516 .proc_handler = proc_dointvec,
2522 }, 2517 },
2523 { 2518 {
2524 .ctl_name = NET_IPV6_ROUTE_GC_MIN_INTERVAL, 2519 .ctl_name = NET_IPV6_ROUTE_GC_MIN_INTERVAL,
@@ -2526,8 +2521,8 @@ ctl_table ipv6_route_table_template[] = {
2526 .data = &init_net.ipv6.sysctl.ip6_rt_gc_min_interval, 2521 .data = &init_net.ipv6.sysctl.ip6_rt_gc_min_interval,
2527 .maxlen = sizeof(int), 2522 .maxlen = sizeof(int),
2528 .mode = 0644, 2523 .mode = 0644,
2529 .proc_handler = &proc_dointvec_jiffies, 2524 .proc_handler = proc_dointvec_jiffies,
2530 .strategy = &sysctl_jiffies, 2525 .strategy = sysctl_jiffies,
2531 }, 2526 },
2532 { 2527 {
2533 .ctl_name = NET_IPV6_ROUTE_GC_TIMEOUT, 2528 .ctl_name = NET_IPV6_ROUTE_GC_TIMEOUT,
@@ -2535,8 +2530,8 @@ ctl_table ipv6_route_table_template[] = {
2535 .data = &init_net.ipv6.sysctl.ip6_rt_gc_timeout, 2530 .data = &init_net.ipv6.sysctl.ip6_rt_gc_timeout,
2536 .maxlen = sizeof(int), 2531 .maxlen = sizeof(int),
2537 .mode = 0644, 2532 .mode = 0644,
2538 .proc_handler = &proc_dointvec_jiffies, 2533 .proc_handler = proc_dointvec_jiffies,
2539 .strategy = &sysctl_jiffies, 2534 .strategy = sysctl_jiffies,
2540 }, 2535 },
2541 { 2536 {
2542 .ctl_name = NET_IPV6_ROUTE_GC_INTERVAL, 2537 .ctl_name = NET_IPV6_ROUTE_GC_INTERVAL,
@@ -2544,8 +2539,8 @@ ctl_table ipv6_route_table_template[] = {
2544 .data = &init_net.ipv6.sysctl.ip6_rt_gc_interval, 2539 .data = &init_net.ipv6.sysctl.ip6_rt_gc_interval,
2545 .maxlen = sizeof(int), 2540 .maxlen = sizeof(int),
2546 .mode = 0644, 2541 .mode = 0644,
2547 .proc_handler = &proc_dointvec_jiffies, 2542 .proc_handler = proc_dointvec_jiffies,
2548 .strategy = &sysctl_jiffies, 2543 .strategy = sysctl_jiffies,
2549 }, 2544 },
2550 { 2545 {
2551 .ctl_name = NET_IPV6_ROUTE_GC_ELASTICITY, 2546 .ctl_name = NET_IPV6_ROUTE_GC_ELASTICITY,
@@ -2553,8 +2548,8 @@ ctl_table ipv6_route_table_template[] = {
2553 .data = &init_net.ipv6.sysctl.ip6_rt_gc_elasticity, 2548 .data = &init_net.ipv6.sysctl.ip6_rt_gc_elasticity,
2554 .maxlen = sizeof(int), 2549 .maxlen = sizeof(int),
2555 .mode = 0644, 2550 .mode = 0644,
2556 .proc_handler = &proc_dointvec_jiffies, 2551 .proc_handler = proc_dointvec_jiffies,
2557 .strategy = &sysctl_jiffies, 2552 .strategy = sysctl_jiffies,
2558 }, 2553 },
2559 { 2554 {
2560 .ctl_name = NET_IPV6_ROUTE_MTU_EXPIRES, 2555 .ctl_name = NET_IPV6_ROUTE_MTU_EXPIRES,
@@ -2562,8 +2557,8 @@ ctl_table ipv6_route_table_template[] = {
2562 .data = &init_net.ipv6.sysctl.ip6_rt_mtu_expires, 2557 .data = &init_net.ipv6.sysctl.ip6_rt_mtu_expires,
2563 .maxlen = sizeof(int), 2558 .maxlen = sizeof(int),
2564 .mode = 0644, 2559 .mode = 0644,
2565 .proc_handler = &proc_dointvec_jiffies, 2560 .proc_handler = proc_dointvec_jiffies,
2566 .strategy = &sysctl_jiffies, 2561 .strategy = sysctl_jiffies,
2567 }, 2562 },
2568 { 2563 {
2569 .ctl_name = NET_IPV6_ROUTE_MIN_ADVMSS, 2564 .ctl_name = NET_IPV6_ROUTE_MIN_ADVMSS,
@@ -2571,8 +2566,8 @@ ctl_table ipv6_route_table_template[] = {
2571 .data = &init_net.ipv6.sysctl.ip6_rt_min_advmss, 2566 .data = &init_net.ipv6.sysctl.ip6_rt_min_advmss,
2572 .maxlen = sizeof(int), 2567 .maxlen = sizeof(int),
2573 .mode = 0644, 2568 .mode = 0644,
2574 .proc_handler = &proc_dointvec_jiffies, 2569 .proc_handler = proc_dointvec_jiffies,
2575 .strategy = &sysctl_jiffies, 2570 .strategy = sysctl_jiffies,
2576 }, 2571 },
2577 { 2572 {
2578 .ctl_name = NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS, 2573 .ctl_name = NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS,
@@ -2580,8 +2575,8 @@ ctl_table ipv6_route_table_template[] = {
2580 .data = &init_net.ipv6.sysctl.ip6_rt_gc_min_interval, 2575 .data = &init_net.ipv6.sysctl.ip6_rt_gc_min_interval,
2581 .maxlen = sizeof(int), 2576 .maxlen = sizeof(int),
2582 .mode = 0644, 2577 .mode = 0644,
2583 .proc_handler = &proc_dointvec_ms_jiffies, 2578 .proc_handler = proc_dointvec_ms_jiffies,
2584 .strategy = &sysctl_ms_jiffies, 2579 .strategy = sysctl_ms_jiffies,
2585 }, 2580 },
2586 { .ctl_name = 0 } 2581 { .ctl_name = 0 }
2587}; 2582};
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 587f8f60c489..9048fe7e7ea7 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -35,7 +35,7 @@ static ctl_table ipv6_table_template[] = {
35 .data = &init_net.ipv6.sysctl.bindv6only, 35 .data = &init_net.ipv6.sysctl.bindv6only,
36 .maxlen = sizeof(int), 36 .maxlen = sizeof(int),
37 .mode = 0644, 37 .mode = 0644,
38 .proc_handler = &proc_dointvec 38 .proc_handler = proc_dointvec
39 }, 39 },
40 { .ctl_name = 0 } 40 { .ctl_name = 0 }
41}; 41};
@@ -47,7 +47,7 @@ static ctl_table ipv6_table[] = {
47 .data = &sysctl_mld_max_msf, 47 .data = &sysctl_mld_max_msf,
48 .maxlen = sizeof(int), 48 .maxlen = sizeof(int),
49 .mode = 0644, 49 .mode = 0644,
50 .proc_handler = &proc_dointvec 50 .proc_handler = proc_dointvec
51 }, 51 },
52 { .ctl_name = 0 } 52 { .ctl_name = 0 }
53}; 53};
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index b6b356b7912a..a5d750acd793 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -501,7 +501,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req)
501 501
502 th->check = tcp_v6_check(th, skb->len, 502 th->check = tcp_v6_check(th, skb->len,
503 &treq->loc_addr, &treq->rmt_addr, 503 &treq->loc_addr, &treq->rmt_addr,
504 csum_partial((char *)th, skb->len, skb->csum)); 504 csum_partial(th, skb->len, skb->csum));
505 505
506 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr); 506 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr);
507 err = ip6_xmit(sk, skb, &fl, opt, 0); 507 err = ip6_xmit(sk, skb, &fl, opt, 0);
@@ -872,12 +872,10 @@ static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb)
872 872
873 if (genhash || memcmp(hash_location, newhash, 16) != 0) { 873 if (genhash || memcmp(hash_location, newhash, 16) != 0) {
874 if (net_ratelimit()) { 874 if (net_ratelimit()) {
875 printk(KERN_INFO "MD5 Hash %s for " 875 printk(KERN_INFO "MD5 Hash %s for (%pI6, %u)->(%pI6, %u)\n",
876 "(" NIP6_FMT ", %u)->"
877 "(" NIP6_FMT ", %u)\n",
878 genhash ? "failed" : "mismatch", 876 genhash ? "failed" : "mismatch",
879 NIP6(ip6h->saddr), ntohs(th->source), 877 &ip6h->saddr, ntohs(th->source),
880 NIP6(ip6h->daddr), ntohs(th->dest)); 878 &ip6h->daddr, ntohs(th->dest));
881 } 879 }
882 return 1; 880 return 1;
883 } 881 }
@@ -917,7 +915,7 @@ static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
917 skb->csum_offset = offsetof(struct tcphdr, check); 915 skb->csum_offset = offsetof(struct tcphdr, check);
918 } else { 916 } else {
919 th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 917 th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP,
920 csum_partial((char *)th, th->doff<<2, 918 csum_partial(th, th->doff<<2,
921 skb->csum)); 919 skb->csum));
922 } 920 }
923} 921}
@@ -999,7 +997,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
999 } 997 }
1000#endif 998#endif
1001 999
1002 buff->csum = csum_partial((char *)t1, tot_len, 0); 1000 buff->csum = csum_partial(t1, tot_len, 0);
1003 1001
1004 memset(&fl, 0, sizeof(fl)); 1002 memset(&fl, 0, sizeof(fl));
1005 ipv6_addr_copy(&fl.fl6_dst, &ipv6_hdr(skb)->saddr); 1003 ipv6_addr_copy(&fl.fl6_dst, &ipv6_hdr(skb)->saddr);
@@ -2045,6 +2043,7 @@ struct proto tcpv6_prot = {
2045 .sysctl_rmem = sysctl_tcp_rmem, 2043 .sysctl_rmem = sysctl_tcp_rmem,
2046 .max_header = MAX_TCP_HEADER, 2044 .max_header = MAX_TCP_HEADER,
2047 .obj_size = sizeof(struct tcp6_sock), 2045 .obj_size = sizeof(struct tcp6_sock),
2046 .slab_flags = SLAB_DESTROY_BY_RCU,
2048 .twsk_prot = &tcp6_timewait_sock_ops, 2047 .twsk_prot = &tcp6_timewait_sock_ops,
2049 .rsk_prot = &tcp6_request_sock_ops, 2048 .rsk_prot = &tcp6_request_sock_ops,
2050 .h.hashinfo = &tcp_hashinfo, 2049 .h.hashinfo = &tcp_hashinfo,
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 8b48512ebf6a..fd2d9ad4a8a3 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -54,62 +54,91 @@ int udp_v6_get_port(struct sock *sk, unsigned short snum)
54 return udp_lib_get_port(sk, snum, ipv6_rcv_saddr_equal); 54 return udp_lib_get_port(sk, snum, ipv6_rcv_saddr_equal);
55} 55}
56 56
57static inline int compute_score(struct sock *sk, struct net *net,
58 unsigned short hnum,
59 struct in6_addr *saddr, __be16 sport,
60 struct in6_addr *daddr, __be16 dport,
61 int dif)
62{
63 int score = -1;
64
65 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
66 sk->sk_family == PF_INET6) {
67 struct ipv6_pinfo *np = inet6_sk(sk);
68 struct inet_sock *inet = inet_sk(sk);
69
70 score = 0;
71 if (inet->dport) {
72 if (inet->dport != sport)
73 return -1;
74 score++;
75 }
76 if (!ipv6_addr_any(&np->rcv_saddr)) {
77 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
78 return -1;
79 score++;
80 }
81 if (!ipv6_addr_any(&np->daddr)) {
82 if (!ipv6_addr_equal(&np->daddr, saddr))
83 return -1;
84 score++;
85 }
86 if (sk->sk_bound_dev_if) {
87 if (sk->sk_bound_dev_if != dif)
88 return -1;
89 score++;
90 }
91 }
92 return score;
93}
94
57static struct sock *__udp6_lib_lookup(struct net *net, 95static struct sock *__udp6_lib_lookup(struct net *net,
58 struct in6_addr *saddr, __be16 sport, 96 struct in6_addr *saddr, __be16 sport,
59 struct in6_addr *daddr, __be16 dport, 97 struct in6_addr *daddr, __be16 dport,
60 int dif, struct hlist_head udptable[]) 98 int dif, struct udp_table *udptable)
61{ 99{
62 struct sock *sk, *result = NULL; 100 struct sock *sk, *result;
63 struct hlist_node *node; 101 struct hlist_nulls_node *node;
64 unsigned short hnum = ntohs(dport); 102 unsigned short hnum = ntohs(dport);
65 int badness = -1; 103 unsigned int hash = udp_hashfn(net, hnum);
66 104 struct udp_hslot *hslot = &udptable->hash[hash];
67 read_lock(&udp_hash_lock); 105 int score, badness;
68 sk_for_each(sk, node, &udptable[udp_hashfn(net, hnum)]) { 106
69 struct inet_sock *inet = inet_sk(sk); 107 rcu_read_lock();
70 108begin:
71 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum && 109 result = NULL;
72 sk->sk_family == PF_INET6) { 110 badness = -1;
73 struct ipv6_pinfo *np = inet6_sk(sk); 111 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
74 int score = 0; 112 score = compute_score(sk, net, hnum, saddr, sport, daddr, dport, dif);
75 if (inet->dport) { 113 if (score > badness) {
76 if (inet->dport != sport) 114 result = sk;
77 continue; 115 badness = score;
78 score++; 116 }
79 } 117 }
80 if (!ipv6_addr_any(&np->rcv_saddr)) { 118 /*
81 if (!ipv6_addr_equal(&np->rcv_saddr, daddr)) 119 * if the nulls value we got at the end of this lookup is
82 continue; 120 * not the expected one, we must restart lookup.
83 score++; 121 * We probably met an item that was moved to another chain.
84 } 122 */
85 if (!ipv6_addr_any(&np->daddr)) { 123 if (get_nulls_value(node) != hash)
86 if (!ipv6_addr_equal(&np->daddr, saddr)) 124 goto begin;
87 continue; 125
88 score++; 126 if (result) {
89 } 127 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
90 if (sk->sk_bound_dev_if) { 128 result = NULL;
91 if (sk->sk_bound_dev_if != dif) 129 else if (unlikely(compute_score(result, net, hnum, saddr, sport,
92 continue; 130 daddr, dport, dif) < badness)) {
93 score++; 131 sock_put(result);
94 } 132 goto begin;
95 if (score == 4) {
96 result = sk;
97 break;
98 } else if (score > badness) {
99 result = sk;
100 badness = score;
101 }
102 } 133 }
103 } 134 }
104 if (result) 135 rcu_read_unlock();
105 sock_hold(result);
106 read_unlock(&udp_hash_lock);
107 return result; 136 return result;
108} 137}
109 138
110static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb, 139static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb,
111 __be16 sport, __be16 dport, 140 __be16 sport, __be16 dport,
112 struct hlist_head udptable[]) 141 struct udp_table *udptable)
113{ 142{
114 struct sock *sk; 143 struct sock *sk;
115 struct ipv6hdr *iph = ipv6_hdr(skb); 144 struct ipv6hdr *iph = ipv6_hdr(skb);
@@ -253,7 +282,7 @@ csum_copy_err:
253 282
254void __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 283void __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
255 int type, int code, int offset, __be32 info, 284 int type, int code, int offset, __be32 info,
256 struct hlist_head udptable[] ) 285 struct udp_table *udptable)
257{ 286{
258 struct ipv6_pinfo *np; 287 struct ipv6_pinfo *np;
259 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data; 288 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data;
@@ -289,7 +318,7 @@ static __inline__ void udpv6_err(struct sk_buff *skb,
289 struct inet6_skb_parm *opt, int type, 318 struct inet6_skb_parm *opt, int type,
290 int code, int offset, __be32 info ) 319 int code, int offset, __be32 info )
291{ 320{
292 __udp6_lib_err(skb, opt, type, code, offset, info, udp_hash); 321 __udp6_lib_err(skb, opt, type, code, offset, info, &udp_table);
293} 322}
294 323
295int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) 324int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
@@ -347,11 +376,11 @@ static struct sock *udp_v6_mcast_next(struct net *net, struct sock *sk,
347 __be16 rmt_port, struct in6_addr *rmt_addr, 376 __be16 rmt_port, struct in6_addr *rmt_addr,
348 int dif) 377 int dif)
349{ 378{
350 struct hlist_node *node; 379 struct hlist_nulls_node *node;
351 struct sock *s = sk; 380 struct sock *s = sk;
352 unsigned short num = ntohs(loc_port); 381 unsigned short num = ntohs(loc_port);
353 382
354 sk_for_each_from(s, node) { 383 sk_nulls_for_each_from(s, node) {
355 struct inet_sock *inet = inet_sk(s); 384 struct inet_sock *inet = inet_sk(s);
356 385
357 if (!net_eq(sock_net(s), net)) 386 if (!net_eq(sock_net(s), net))
@@ -388,14 +417,15 @@ static struct sock *udp_v6_mcast_next(struct net *net, struct sock *sk,
388 */ 417 */
389static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb, 418static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
390 struct in6_addr *saddr, struct in6_addr *daddr, 419 struct in6_addr *saddr, struct in6_addr *daddr,
391 struct hlist_head udptable[]) 420 struct udp_table *udptable)
392{ 421{
393 struct sock *sk, *sk2; 422 struct sock *sk, *sk2;
394 const struct udphdr *uh = udp_hdr(skb); 423 const struct udphdr *uh = udp_hdr(skb);
424 struct udp_hslot *hslot = &udptable->hash[udp_hashfn(net, ntohs(uh->dest))];
395 int dif; 425 int dif;
396 426
397 read_lock(&udp_hash_lock); 427 spin_lock(&hslot->lock);
398 sk = sk_head(&udptable[udp_hashfn(net, ntohs(uh->dest))]); 428 sk = sk_nulls_head(&hslot->head);
399 dif = inet6_iif(skb); 429 dif = inet6_iif(skb);
400 sk = udp_v6_mcast_next(net, sk, uh->dest, daddr, uh->source, saddr, dif); 430 sk = udp_v6_mcast_next(net, sk, uh->dest, daddr, uh->source, saddr, dif);
401 if (!sk) { 431 if (!sk) {
@@ -404,7 +434,7 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
404 } 434 }
405 435
406 sk2 = sk; 436 sk2 = sk;
407 while ((sk2 = udp_v6_mcast_next(net, sk_next(sk2), uh->dest, daddr, 437 while ((sk2 = udp_v6_mcast_next(net, sk_nulls_next(sk2), uh->dest, daddr,
408 uh->source, saddr, dif))) { 438 uh->source, saddr, dif))) {
409 struct sk_buff *buff = skb_clone(skb, GFP_ATOMIC); 439 struct sk_buff *buff = skb_clone(skb, GFP_ATOMIC);
410 if (buff) { 440 if (buff) {
@@ -423,7 +453,7 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
423 sk_add_backlog(sk, skb); 453 sk_add_backlog(sk, skb);
424 bh_unlock_sock(sk); 454 bh_unlock_sock(sk);
425out: 455out:
426 read_unlock(&udp_hash_lock); 456 spin_unlock(&hslot->lock);
427 return 0; 457 return 0;
428} 458}
429 459
@@ -461,7 +491,7 @@ static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh,
461 return 0; 491 return 0;
462} 492}
463 493
464int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], 494int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
465 int proto) 495 int proto)
466{ 496{
467 struct sock *sk; 497 struct sock *sk;
@@ -558,7 +588,7 @@ discard:
558 588
559static __inline__ int udpv6_rcv(struct sk_buff *skb) 589static __inline__ int udpv6_rcv(struct sk_buff *skb)
560{ 590{
561 return __udp6_lib_rcv(skb, udp_hash, IPPROTO_UDP); 591 return __udp6_lib_rcv(skb, &udp_table, IPPROTO_UDP);
562} 592}
563 593
564/* 594/*
@@ -1022,7 +1052,7 @@ int udp6_seq_show(struct seq_file *seq, void *v)
1022static struct udp_seq_afinfo udp6_seq_afinfo = { 1052static struct udp_seq_afinfo udp6_seq_afinfo = {
1023 .name = "udp6", 1053 .name = "udp6",
1024 .family = AF_INET6, 1054 .family = AF_INET6,
1025 .hashtable = udp_hash, 1055 .udp_table = &udp_table,
1026 .seq_fops = { 1056 .seq_fops = {
1027 .owner = THIS_MODULE, 1057 .owner = THIS_MODULE,
1028 }, 1058 },
@@ -1064,7 +1094,8 @@ struct proto udpv6_prot = {
1064 .sysctl_wmem = &sysctl_udp_wmem_min, 1094 .sysctl_wmem = &sysctl_udp_wmem_min,
1065 .sysctl_rmem = &sysctl_udp_rmem_min, 1095 .sysctl_rmem = &sysctl_udp_rmem_min,
1066 .obj_size = sizeof(struct udp6_sock), 1096 .obj_size = sizeof(struct udp6_sock),
1067 .h.udp_hash = udp_hash, 1097 .slab_flags = SLAB_DESTROY_BY_RCU,
1098 .h.udp_table = &udp_table,
1068#ifdef CONFIG_COMPAT 1099#ifdef CONFIG_COMPAT
1069 .compat_setsockopt = compat_udpv6_setsockopt, 1100 .compat_setsockopt = compat_udpv6_setsockopt,
1070 .compat_getsockopt = compat_udpv6_getsockopt, 1101 .compat_getsockopt = compat_udpv6_getsockopt,
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
index 92dd7da766d8..23779208c334 100644
--- a/net/ipv6/udp_impl.h
+++ b/net/ipv6/udp_impl.h
@@ -7,9 +7,9 @@
7#include <net/inet_common.h> 7#include <net/inet_common.h>
8#include <net/transp_v6.h> 8#include <net/transp_v6.h>
9 9
10extern int __udp6_lib_rcv(struct sk_buff *, struct hlist_head [], int ); 10extern int __udp6_lib_rcv(struct sk_buff *, struct udp_table *, int );
11extern void __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *, 11extern void __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *,
12 int , int , int , __be32 , struct hlist_head []); 12 int , int , int , __be32 , struct udp_table *);
13 13
14extern int udp_v6_get_port(struct sock *sk, unsigned short snum); 14extern int udp_v6_get_port(struct sock *sk, unsigned short snum);
15 15
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 3cd1a1ac3d6c..ba162a824585 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -15,14 +15,14 @@
15 15
16static int udplitev6_rcv(struct sk_buff *skb) 16static int udplitev6_rcv(struct sk_buff *skb)
17{ 17{
18 return __udp6_lib_rcv(skb, udplite_hash, IPPROTO_UDPLITE); 18 return __udp6_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE);
19} 19}
20 20
21static void udplitev6_err(struct sk_buff *skb, 21static void udplitev6_err(struct sk_buff *skb,
22 struct inet6_skb_parm *opt, 22 struct inet6_skb_parm *opt,
23 int type, int code, int offset, __be32 info) 23 int type, int code, int offset, __be32 info)
24{ 24{
25 __udp6_lib_err(skb, opt, type, code, offset, info, udplite_hash); 25 __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table);
26} 26}
27 27
28static struct inet6_protocol udplitev6_protocol = { 28static struct inet6_protocol udplitev6_protocol = {
@@ -49,7 +49,8 @@ struct proto udplitev6_prot = {
49 .unhash = udp_lib_unhash, 49 .unhash = udp_lib_unhash,
50 .get_port = udp_v6_get_port, 50 .get_port = udp_v6_get_port,
51 .obj_size = sizeof(struct udp6_sock), 51 .obj_size = sizeof(struct udp6_sock),
52 .h.udp_hash = udplite_hash, 52 .slab_flags = SLAB_DESTROY_BY_RCU,
53 .h.udp_table = &udplite_table,
53#ifdef CONFIG_COMPAT 54#ifdef CONFIG_COMPAT
54 .compat_setsockopt = compat_udpv6_setsockopt, 55 .compat_setsockopt = compat_udpv6_setsockopt,
55 .compat_getsockopt = compat_udpv6_getsockopt, 56 .compat_getsockopt = compat_udpv6_getsockopt,
@@ -95,7 +96,7 @@ void udplitev6_exit(void)
95static struct udp_seq_afinfo udplite6_seq_afinfo = { 96static struct udp_seq_afinfo udplite6_seq_afinfo = {
96 .name = "udplite6", 97 .name = "udplite6",
97 .family = AF_INET6, 98 .family = AF_INET6,
98 .hashtable = udplite_hash, 99 .udp_table = &udplite_table,
99 .seq_fops = { 100 .seq_fops = {
100 .owner = THIS_MODULE, 101 .owner = THIS_MODULE,
101 }, 102 },
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 08e4cbbe3f04..3b67ce7786ec 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -144,6 +144,7 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev)
144static inline void 144static inline void
145_decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse) 145_decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
146{ 146{
147 int onlyproto = 0;
147 u16 offset = skb_network_header_len(skb); 148 u16 offset = skb_network_header_len(skb);
148 struct ipv6hdr *hdr = ipv6_hdr(skb); 149 struct ipv6hdr *hdr = ipv6_hdr(skb);
149 struct ipv6_opt_hdr *exthdr; 150 struct ipv6_opt_hdr *exthdr;
@@ -159,6 +160,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
159 exthdr = (struct ipv6_opt_hdr *)(nh + offset); 160 exthdr = (struct ipv6_opt_hdr *)(nh + offset);
160 161
161 switch (nexthdr) { 162 switch (nexthdr) {
163 case NEXTHDR_FRAGMENT:
164 onlyproto = 1;
162 case NEXTHDR_ROUTING: 165 case NEXTHDR_ROUTING:
163 case NEXTHDR_HOP: 166 case NEXTHDR_HOP:
164 case NEXTHDR_DEST: 167 case NEXTHDR_DEST:
@@ -172,7 +175,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
172 case IPPROTO_TCP: 175 case IPPROTO_TCP:
173 case IPPROTO_SCTP: 176 case IPPROTO_SCTP:
174 case IPPROTO_DCCP: 177 case IPPROTO_DCCP:
175 if (pskb_may_pull(skb, nh + offset + 4 - skb->data)) { 178 if (!onlyproto && pskb_may_pull(skb, nh + offset + 4 - skb->data)) {
176 __be16 *ports = (__be16 *)exthdr; 179 __be16 *ports = (__be16 *)exthdr;
177 180
178 fl->fl_ip_sport = ports[!!reverse]; 181 fl->fl_ip_sport = ports[!!reverse];
@@ -182,7 +185,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
182 return; 185 return;
183 186
184 case IPPROTO_ICMPV6: 187 case IPPROTO_ICMPV6:
185 if (pskb_may_pull(skb, nh + offset + 2 - skb->data)) { 188 if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
186 u8 *icmp = (u8 *)exthdr; 189 u8 *icmp = (u8 *)exthdr;
187 190
188 fl->fl_icmp_type = icmp[0]; 191 fl->fl_icmp_type = icmp[0];
@@ -193,7 +196,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
193 196
194#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 197#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
195 case IPPROTO_MH: 198 case IPPROTO_MH:
196 if (pskb_may_pull(skb, nh + offset + 3 - skb->data)) { 199 if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
197 struct ip6_mh *mh; 200 struct ip6_mh *mh;
198 mh = (struct ip6_mh *)exthdr; 201 mh = (struct ip6_mh *)exthdr;
199 202
@@ -274,7 +277,6 @@ static struct dst_ops xfrm6_dst_ops = {
274 .ifdown = xfrm6_dst_ifdown, 277 .ifdown = xfrm6_dst_ifdown,
275 .local_out = __ip6_local_out, 278 .local_out = __ip6_local_out,
276 .gc_thresh = 1024, 279 .gc_thresh = 1024,
277 .entry_size = sizeof(struct xfrm_dst),
278 .entries = ATOMIC_INIT(0), 280 .entries = ATOMIC_INIT(0),
279}; 281};
280 282
diff --git a/net/ipx/sysctl_net_ipx.c b/net/ipx/sysctl_net_ipx.c
index 92fef864e852..633fcab35580 100644
--- a/net/ipx/sysctl_net_ipx.c
+++ b/net/ipx/sysctl_net_ipx.c
@@ -23,7 +23,7 @@ static struct ctl_table ipx_table[] = {
23 .data = &sysctl_ipx_pprop_broadcasting, 23 .data = &sysctl_ipx_pprop_broadcasting,
24 .maxlen = sizeof(int), 24 .maxlen = sizeof(int),
25 .mode = 0644, 25 .mode = 0644,
26 .proc_handler = &proc_dointvec, 26 .proc_handler = proc_dointvec,
27 }, 27 },
28 { 0 }, 28 { 0 },
29}; 29};
diff --git a/net/irda/irlan/irlan_client.c b/net/irda/irlan/irlan_client.c
index 6be1ec26b30c..42f7d960d055 100644
--- a/net/irda/irlan/irlan_client.c
+++ b/net/irda/irlan/irlan_client.c
@@ -436,7 +436,6 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
436 __u16 tmp_cpu; /* Temporary value in host order */ 436 __u16 tmp_cpu; /* Temporary value in host order */
437 __u8 *bytes; 437 __u8 *bytes;
438 int i; 438 int i;
439 DECLARE_MAC_BUF(mac);
440 439
441 IRDA_DEBUG(4, "%s(), parm=%s\n", __func__ , param); 440 IRDA_DEBUG(4, "%s(), parm=%s\n", __func__ , param);
442 441
@@ -521,8 +520,7 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
521 /* FILTER_ENTRY, have we got an ethernet address? */ 520 /* FILTER_ENTRY, have we got an ethernet address? */
522 if (strcmp(param, "FILTER_ENTRY") == 0) { 521 if (strcmp(param, "FILTER_ENTRY") == 0) {
523 bytes = value; 522 bytes = value;
524 IRDA_DEBUG(4, "Ethernet address = %s\n", 523 IRDA_DEBUG(4, "Ethernet address = %pM\n", bytes);
525 print_mac(mac, bytes));
526 for (i = 0; i < 6; i++) 524 for (i = 0; i < 6; i++)
527 self->dev->dev_addr[i] = bytes[i]; 525 self->dev->dev_addr[i] = bytes[i];
528 } 526 }
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
index 9a1cd87e7142..774d73a76852 100644
--- a/net/irda/irlan/irlan_common.c
+++ b/net/irda/irlan/irlan_common.c
@@ -207,7 +207,7 @@ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
207 if (!dev) 207 if (!dev)
208 return NULL; 208 return NULL;
209 209
210 self = dev->priv; 210 self = netdev_priv(dev);
211 self->dev = dev; 211 self->dev = dev;
212 212
213 /* 213 /*
diff --git a/net/irda/irsysctl.c b/net/irda/irsysctl.c
index 9ab3df15425d..57f8817c3979 100644
--- a/net/irda/irsysctl.c
+++ b/net/irda/irsysctl.c
@@ -118,8 +118,8 @@ static ctl_table irda_table[] = {
118 .data = &sysctl_discovery, 118 .data = &sysctl_discovery,
119 .maxlen = sizeof(int), 119 .maxlen = sizeof(int),
120 .mode = 0644, 120 .mode = 0644,
121 .proc_handler = &do_discovery, 121 .proc_handler = do_discovery,
122 .strategy = &sysctl_intvec 122 .strategy = sysctl_intvec
123 }, 123 },
124 { 124 {
125 .ctl_name = NET_IRDA_DEVNAME, 125 .ctl_name = NET_IRDA_DEVNAME,
@@ -127,8 +127,8 @@ static ctl_table irda_table[] = {
127 .data = sysctl_devname, 127 .data = sysctl_devname,
128 .maxlen = 65, 128 .maxlen = 65,
129 .mode = 0644, 129 .mode = 0644,
130 .proc_handler = &do_devname, 130 .proc_handler = do_devname,
131 .strategy = &sysctl_string 131 .strategy = sysctl_string
132 }, 132 },
133#ifdef CONFIG_IRDA_DEBUG 133#ifdef CONFIG_IRDA_DEBUG
134 { 134 {
@@ -137,7 +137,7 @@ static ctl_table irda_table[] = {
137 .data = &irda_debug, 137 .data = &irda_debug,
138 .maxlen = sizeof(int), 138 .maxlen = sizeof(int),
139 .mode = 0644, 139 .mode = 0644,
140 .proc_handler = &proc_dointvec 140 .proc_handler = proc_dointvec
141 }, 141 },
142#endif 142#endif
143#ifdef CONFIG_IRDA_FAST_RR 143#ifdef CONFIG_IRDA_FAST_RR
@@ -147,7 +147,7 @@ static ctl_table irda_table[] = {
147 .data = &sysctl_fast_poll_increase, 147 .data = &sysctl_fast_poll_increase,
148 .maxlen = sizeof(int), 148 .maxlen = sizeof(int),
149 .mode = 0644, 149 .mode = 0644,
150 .proc_handler = &proc_dointvec 150 .proc_handler = proc_dointvec
151 }, 151 },
152#endif 152#endif
153 { 153 {
@@ -156,8 +156,8 @@ static ctl_table irda_table[] = {
156 .data = &sysctl_discovery_slots, 156 .data = &sysctl_discovery_slots,
157 .maxlen = sizeof(int), 157 .maxlen = sizeof(int),
158 .mode = 0644, 158 .mode = 0644,
159 .proc_handler = &proc_dointvec_minmax, 159 .proc_handler = proc_dointvec_minmax,
160 .strategy = &sysctl_intvec, 160 .strategy = sysctl_intvec,
161 .extra1 = &min_discovery_slots, 161 .extra1 = &min_discovery_slots,
162 .extra2 = &max_discovery_slots 162 .extra2 = &max_discovery_slots
163 }, 163 },
@@ -167,7 +167,7 @@ static ctl_table irda_table[] = {
167 .data = &sysctl_discovery_timeout, 167 .data = &sysctl_discovery_timeout,
168 .maxlen = sizeof(int), 168 .maxlen = sizeof(int),
169 .mode = 0644, 169 .mode = 0644,
170 .proc_handler = &proc_dointvec 170 .proc_handler = proc_dointvec
171 }, 171 },
172 { 172 {
173 .ctl_name = NET_IRDA_SLOT_TIMEOUT, 173 .ctl_name = NET_IRDA_SLOT_TIMEOUT,
@@ -175,8 +175,8 @@ static ctl_table irda_table[] = {
175 .data = &sysctl_slot_timeout, 175 .data = &sysctl_slot_timeout,
176 .maxlen = sizeof(int), 176 .maxlen = sizeof(int),
177 .mode = 0644, 177 .mode = 0644,
178 .proc_handler = &proc_dointvec_minmax, 178 .proc_handler = proc_dointvec_minmax,
179 .strategy = &sysctl_intvec, 179 .strategy = sysctl_intvec,
180 .extra1 = &min_slot_timeout, 180 .extra1 = &min_slot_timeout,
181 .extra2 = &max_slot_timeout 181 .extra2 = &max_slot_timeout
182 }, 182 },
@@ -186,8 +186,8 @@ static ctl_table irda_table[] = {
186 .data = &sysctl_max_baud_rate, 186 .data = &sysctl_max_baud_rate,
187 .maxlen = sizeof(int), 187 .maxlen = sizeof(int),
188 .mode = 0644, 188 .mode = 0644,
189 .proc_handler = &proc_dointvec_minmax, 189 .proc_handler = proc_dointvec_minmax,
190 .strategy = &sysctl_intvec, 190 .strategy = sysctl_intvec,
191 .extra1 = &min_max_baud_rate, 191 .extra1 = &min_max_baud_rate,
192 .extra2 = &max_max_baud_rate 192 .extra2 = &max_max_baud_rate
193 }, 193 },
@@ -197,8 +197,8 @@ static ctl_table irda_table[] = {
197 .data = &sysctl_min_tx_turn_time, 197 .data = &sysctl_min_tx_turn_time,
198 .maxlen = sizeof(int), 198 .maxlen = sizeof(int),
199 .mode = 0644, 199 .mode = 0644,
200 .proc_handler = &proc_dointvec_minmax, 200 .proc_handler = proc_dointvec_minmax,
201 .strategy = &sysctl_intvec, 201 .strategy = sysctl_intvec,
202 .extra1 = &min_min_tx_turn_time, 202 .extra1 = &min_min_tx_turn_time,
203 .extra2 = &max_min_tx_turn_time 203 .extra2 = &max_min_tx_turn_time
204 }, 204 },
@@ -208,8 +208,8 @@ static ctl_table irda_table[] = {
208 .data = &sysctl_max_tx_data_size, 208 .data = &sysctl_max_tx_data_size,
209 .maxlen = sizeof(int), 209 .maxlen = sizeof(int),
210 .mode = 0644, 210 .mode = 0644,
211 .proc_handler = &proc_dointvec_minmax, 211 .proc_handler = proc_dointvec_minmax,
212 .strategy = &sysctl_intvec, 212 .strategy = sysctl_intvec,
213 .extra1 = &min_max_tx_data_size, 213 .extra1 = &min_max_tx_data_size,
214 .extra2 = &max_max_tx_data_size 214 .extra2 = &max_max_tx_data_size
215 }, 215 },
@@ -219,8 +219,8 @@ static ctl_table irda_table[] = {
219 .data = &sysctl_max_tx_window, 219 .data = &sysctl_max_tx_window,
220 .maxlen = sizeof(int), 220 .maxlen = sizeof(int),
221 .mode = 0644, 221 .mode = 0644,
222 .proc_handler = &proc_dointvec_minmax, 222 .proc_handler = proc_dointvec_minmax,
223 .strategy = &sysctl_intvec, 223 .strategy = sysctl_intvec,
224 .extra1 = &min_max_tx_window, 224 .extra1 = &min_max_tx_window,
225 .extra2 = &max_max_tx_window 225 .extra2 = &max_max_tx_window
226 }, 226 },
@@ -230,8 +230,8 @@ static ctl_table irda_table[] = {
230 .data = &sysctl_max_noreply_time, 230 .data = &sysctl_max_noreply_time,
231 .maxlen = sizeof(int), 231 .maxlen = sizeof(int),
232 .mode = 0644, 232 .mode = 0644,
233 .proc_handler = &proc_dointvec_minmax, 233 .proc_handler = proc_dointvec_minmax,
234 .strategy = &sysctl_intvec, 234 .strategy = sysctl_intvec,
235 .extra1 = &min_max_noreply_time, 235 .extra1 = &min_max_noreply_time,
236 .extra2 = &max_max_noreply_time 236 .extra2 = &max_max_noreply_time
237 }, 237 },
@@ -241,8 +241,8 @@ static ctl_table irda_table[] = {
241 .data = &sysctl_warn_noreply_time, 241 .data = &sysctl_warn_noreply_time,
242 .maxlen = sizeof(int), 242 .maxlen = sizeof(int),
243 .mode = 0644, 243 .mode = 0644,
244 .proc_handler = &proc_dointvec_minmax, 244 .proc_handler = proc_dointvec_minmax,
245 .strategy = &sysctl_intvec, 245 .strategy = sysctl_intvec,
246 .extra1 = &min_warn_noreply_time, 246 .extra1 = &min_warn_noreply_time,
247 .extra2 = &max_warn_noreply_time 247 .extra2 = &max_warn_noreply_time
248 }, 248 },
@@ -252,8 +252,8 @@ static ctl_table irda_table[] = {
252 .data = &sysctl_lap_keepalive_time, 252 .data = &sysctl_lap_keepalive_time,
253 .maxlen = sizeof(int), 253 .maxlen = sizeof(int),
254 .mode = 0644, 254 .mode = 0644,
255 .proc_handler = &proc_dointvec_minmax, 255 .proc_handler = proc_dointvec_minmax,
256 .strategy = &sysctl_intvec, 256 .strategy = sysctl_intvec,
257 .extra1 = &min_lap_keepalive_time, 257 .extra1 = &min_lap_keepalive_time,
258 .extra2 = &max_lap_keepalive_time 258 .extra2 = &max_lap_keepalive_time
259 }, 259 },
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
index 48212c0a961c..b58bd7c6cdf8 100644
--- a/net/llc/llc_proc.c
+++ b/net/llc/llc_proc.c
@@ -27,8 +27,7 @@
27 27
28static void llc_ui_format_mac(struct seq_file *seq, u8 *addr) 28static void llc_ui_format_mac(struct seq_file *seq, u8 *addr)
29{ 29{
30 DECLARE_MAC_BUF(mac); 30 seq_printf(seq, "%pM", addr);
31 seq_printf(seq, "%s", print_mac(mac, addr));
32} 31}
33 32
34static struct sock *llc_get_sk_idx(loff_t pos) 33static struct sock *llc_get_sk_idx(loff_t pos)
diff --git a/net/llc/sysctl_net_llc.c b/net/llc/sysctl_net_llc.c
index 5bef1dcf18e3..57b9304d444c 100644
--- a/net/llc/sysctl_net_llc.c
+++ b/net/llc/sysctl_net_llc.c
@@ -20,8 +20,8 @@ static struct ctl_table llc2_timeout_table[] = {
20 .data = &sysctl_llc2_ack_timeout, 20 .data = &sysctl_llc2_ack_timeout,
21 .maxlen = sizeof(long), 21 .maxlen = sizeof(long),
22 .mode = 0644, 22 .mode = 0644,
23 .proc_handler = &proc_dointvec_jiffies, 23 .proc_handler = proc_dointvec_jiffies,
24 .strategy = &sysctl_jiffies, 24 .strategy = sysctl_jiffies,
25 }, 25 },
26 { 26 {
27 .ctl_name = NET_LLC2_BUSY_TIMEOUT, 27 .ctl_name = NET_LLC2_BUSY_TIMEOUT,
@@ -29,8 +29,8 @@ static struct ctl_table llc2_timeout_table[] = {
29 .data = &sysctl_llc2_busy_timeout, 29 .data = &sysctl_llc2_busy_timeout,
30 .maxlen = sizeof(long), 30 .maxlen = sizeof(long),
31 .mode = 0644, 31 .mode = 0644,
32 .proc_handler = &proc_dointvec_jiffies, 32 .proc_handler = proc_dointvec_jiffies,
33 .strategy = &sysctl_jiffies, 33 .strategy = sysctl_jiffies,
34 }, 34 },
35 { 35 {
36 .ctl_name = NET_LLC2_P_TIMEOUT, 36 .ctl_name = NET_LLC2_P_TIMEOUT,
@@ -38,8 +38,8 @@ static struct ctl_table llc2_timeout_table[] = {
38 .data = &sysctl_llc2_p_timeout, 38 .data = &sysctl_llc2_p_timeout,
39 .maxlen = sizeof(long), 39 .maxlen = sizeof(long),
40 .mode = 0644, 40 .mode = 0644,
41 .proc_handler = &proc_dointvec_jiffies, 41 .proc_handler = proc_dointvec_jiffies,
42 .strategy = &sysctl_jiffies, 42 .strategy = sysctl_jiffies,
43 }, 43 },
44 { 44 {
45 .ctl_name = NET_LLC2_REJ_TIMEOUT, 45 .ctl_name = NET_LLC2_REJ_TIMEOUT,
@@ -47,8 +47,8 @@ static struct ctl_table llc2_timeout_table[] = {
47 .data = &sysctl_llc2_rej_timeout, 47 .data = &sysctl_llc2_rej_timeout,
48 .maxlen = sizeof(long), 48 .maxlen = sizeof(long),
49 .mode = 0644, 49 .mode = 0644,
50 .proc_handler = &proc_dointvec_jiffies, 50 .proc_handler = proc_dointvec_jiffies,
51 .strategy = &sysctl_jiffies, 51 .strategy = sysctl_jiffies,
52 }, 52 },
53 { 0 }, 53 { 0 },
54}; 54};
@@ -60,8 +60,8 @@ static struct ctl_table llc_station_table[] = {
60 .data = &sysctl_llc_station_ack_timeout, 60 .data = &sysctl_llc_station_ack_timeout,
61 .maxlen = sizeof(long), 61 .maxlen = sizeof(long),
62 .mode = 0644, 62 .mode = 0644,
63 .proc_handler = &proc_dointvec_jiffies, 63 .proc_handler = proc_dointvec_jiffies,
64 .strategy = &sysctl_jiffies, 64 .strategy = sysctl_jiffies,
65 }, 65 },
66 { 0 }, 66 { 0 },
67}; 67};
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 855126a3039d..16423f94801b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -17,13 +17,6 @@
17#include "rate.h" 17#include "rate.h"
18#include "mesh.h" 18#include "mesh.h"
19 19
20struct ieee80211_hw *wiphy_to_hw(struct wiphy *wiphy)
21{
22 struct ieee80211_local *local = wiphy_priv(wiphy);
23 return &local->hw;
24}
25EXPORT_SYMBOL(wiphy_to_hw);
26
27static bool nl80211_type_check(enum nl80211_iftype type) 20static bool nl80211_type_check(enum nl80211_iftype type)
28{ 21{
29 switch (type) { 22 switch (type) {
@@ -33,6 +26,8 @@ static bool nl80211_type_check(enum nl80211_iftype type)
33#ifdef CONFIG_MAC80211_MESH 26#ifdef CONFIG_MAC80211_MESH
34 case NL80211_IFTYPE_MESH_POINT: 27 case NL80211_IFTYPE_MESH_POINT:
35#endif 28#endif
29 case NL80211_IFTYPE_AP:
30 case NL80211_IFTYPE_AP_VLAN:
36 case NL80211_IFTYPE_WDS: 31 case NL80211_IFTYPE_WDS:
37 return true; 32 return true;
38 default: 33 default:
@@ -401,8 +396,8 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
401 */ 396 */
402 if (params->interval) { 397 if (params->interval) {
403 sdata->local->hw.conf.beacon_int = params->interval; 398 sdata->local->hw.conf.beacon_int = params->interval;
404 if (ieee80211_hw_config(sdata->local)) 399 ieee80211_hw_config(sdata->local,
405 return -EINVAL; 400 IEEE80211_CONF_CHANGE_BEACON_INTERVAL);
406 /* 401 /*
407 * We updated some parameter so if below bails out 402 * We updated some parameter so if below bails out
408 * it's not an error. 403 * it's not an error.
@@ -589,6 +584,8 @@ static void sta_apply_parameters(struct ieee80211_local *local,
589 struct ieee80211_supported_band *sband; 584 struct ieee80211_supported_band *sband;
590 struct ieee80211_sub_if_data *sdata = sta->sdata; 585 struct ieee80211_sub_if_data *sdata = sta->sdata;
591 586
587 sband = local->hw.wiphy->bands[local->oper_channel->band];
588
592 /* 589 /*
593 * FIXME: updating the flags is racy when this function is 590 * FIXME: updating the flags is racy when this function is
594 * called from ieee80211_change_station(), this will 591 * called from ieee80211_change_station(), this will
@@ -629,7 +626,6 @@ static void sta_apply_parameters(struct ieee80211_local *local,
629 626
630 if (params->supported_rates) { 627 if (params->supported_rates) {
631 rates = 0; 628 rates = 0;
632 sband = local->hw.wiphy->bands[local->oper_channel->band];
633 629
634 for (i = 0; i < params->supported_rates_len; i++) { 630 for (i = 0; i < params->supported_rates_len; i++) {
635 int rate = (params->supported_rates[i] & 0x7f) * 5; 631 int rate = (params->supported_rates[i] & 0x7f) * 5;
@@ -641,10 +637,10 @@ static void sta_apply_parameters(struct ieee80211_local *local,
641 sta->sta.supp_rates[local->oper_channel->band] = rates; 637 sta->sta.supp_rates[local->oper_channel->band] = rates;
642 } 638 }
643 639
644 if (params->ht_capa) { 640 if (params->ht_capa)
645 ieee80211_ht_cap_ie_to_ht_info(params->ht_capa, 641 ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
646 &sta->sta.ht_info); 642 params->ht_capa,
647 } 643 &sta->sta.ht_cap);
648 644
649 if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) { 645 if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
650 switch (params->plink_action) { 646 switch (params->plink_action) {
@@ -957,6 +953,72 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
957 rcu_read_unlock(); 953 rcu_read_unlock();
958 return 0; 954 return 0;
959} 955}
956
957static int ieee80211_get_mesh_params(struct wiphy *wiphy,
958 struct net_device *dev,
959 struct mesh_config *conf)
960{
961 struct ieee80211_sub_if_data *sdata;
962 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
963
964 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
965 return -ENOTSUPP;
966 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
967 return 0;
968}
969
970static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
971{
972 return (mask >> (parm-1)) & 0x1;
973}
974
975static int ieee80211_set_mesh_params(struct wiphy *wiphy,
976 struct net_device *dev,
977 const struct mesh_config *nconf, u32 mask)
978{
979 struct mesh_config *conf;
980 struct ieee80211_sub_if_data *sdata;
981 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
982
983 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
984 return -ENOTSUPP;
985
986 /* Set the config options which we are interested in setting */
987 conf = &(sdata->u.mesh.mshcfg);
988 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
989 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
990 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
991 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
992 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
993 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
994 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
995 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
996 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
997 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
998 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
999 conf->dot11MeshTTL = nconf->dot11MeshTTL;
1000 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
1001 conf->auto_open_plinks = nconf->auto_open_plinks;
1002 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1003 conf->dot11MeshHWMPmaxPREQretries =
1004 nconf->dot11MeshHWMPmaxPREQretries;
1005 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1006 conf->path_refresh_time = nconf->path_refresh_time;
1007 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1008 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1009 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1010 conf->dot11MeshHWMPactivePathTimeout =
1011 nconf->dot11MeshHWMPactivePathTimeout;
1012 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1013 conf->dot11MeshHWMPpreqMinInterval =
1014 nconf->dot11MeshHWMPpreqMinInterval;
1015 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1016 mask))
1017 conf->dot11MeshHWMPnetDiameterTraversalTime =
1018 nconf->dot11MeshHWMPnetDiameterTraversalTime;
1019 return 0;
1020}
1021
960#endif 1022#endif
961 1023
962static int ieee80211_change_bss(struct wiphy *wiphy, 1024static int ieee80211_change_bss(struct wiphy *wiphy,
@@ -972,25 +1034,67 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
972 return -EINVAL; 1034 return -EINVAL;
973 1035
974 if (params->use_cts_prot >= 0) { 1036 if (params->use_cts_prot >= 0) {
975 sdata->bss_conf.use_cts_prot = params->use_cts_prot; 1037 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
976 changed |= BSS_CHANGED_ERP_CTS_PROT; 1038 changed |= BSS_CHANGED_ERP_CTS_PROT;
977 } 1039 }
978 if (params->use_short_preamble >= 0) { 1040 if (params->use_short_preamble >= 0) {
979 sdata->bss_conf.use_short_preamble = 1041 sdata->vif.bss_conf.use_short_preamble =
980 params->use_short_preamble; 1042 params->use_short_preamble;
981 changed |= BSS_CHANGED_ERP_PREAMBLE; 1043 changed |= BSS_CHANGED_ERP_PREAMBLE;
982 } 1044 }
983 if (params->use_short_slot_time >= 0) { 1045 if (params->use_short_slot_time >= 0) {
984 sdata->bss_conf.use_short_slot = 1046 sdata->vif.bss_conf.use_short_slot =
985 params->use_short_slot_time; 1047 params->use_short_slot_time;
986 changed |= BSS_CHANGED_ERP_SLOT; 1048 changed |= BSS_CHANGED_ERP_SLOT;
987 } 1049 }
988 1050
1051 if (params->basic_rates) {
1052 int i, j;
1053 u32 rates = 0;
1054 struct ieee80211_local *local = wiphy_priv(wiphy);
1055 struct ieee80211_supported_band *sband =
1056 wiphy->bands[local->oper_channel->band];
1057
1058 for (i = 0; i < params->basic_rates_len; i++) {
1059 int rate = (params->basic_rates[i] & 0x7f) * 5;
1060 for (j = 0; j < sband->n_bitrates; j++) {
1061 if (sband->bitrates[j].bitrate == rate)
1062 rates |= BIT(j);
1063 }
1064 }
1065 sdata->vif.bss_conf.basic_rates = rates;
1066 changed |= BSS_CHANGED_BASIC_RATES;
1067 }
1068
989 ieee80211_bss_info_change_notify(sdata, changed); 1069 ieee80211_bss_info_change_notify(sdata, changed);
990 1070
991 return 0; 1071 return 0;
992} 1072}
993 1073
1074static int ieee80211_set_txq_params(struct wiphy *wiphy,
1075 struct ieee80211_txq_params *params)
1076{
1077 struct ieee80211_local *local = wiphy_priv(wiphy);
1078 struct ieee80211_tx_queue_params p;
1079
1080 if (!local->ops->conf_tx)
1081 return -EOPNOTSUPP;
1082
1083 memset(&p, 0, sizeof(p));
1084 p.aifs = params->aifs;
1085 p.cw_max = params->cwmax;
1086 p.cw_min = params->cwmin;
1087 p.txop = params->txop;
1088 if (local->ops->conf_tx(local_to_hw(local), params->queue, &p)) {
1089 printk(KERN_DEBUG "%s: failed to set TX queue "
1090 "parameters for queue %d\n", local->mdev->name,
1091 params->queue);
1092 return -EINVAL;
1093 }
1094
1095 return 0;
1096}
1097
994struct cfg80211_ops mac80211_config_ops = { 1098struct cfg80211_ops mac80211_config_ops = {
995 .add_virtual_intf = ieee80211_add_iface, 1099 .add_virtual_intf = ieee80211_add_iface,
996 .del_virtual_intf = ieee80211_del_iface, 1100 .del_virtual_intf = ieee80211_del_iface,
@@ -1013,6 +1117,9 @@ struct cfg80211_ops mac80211_config_ops = {
1013 .change_mpath = ieee80211_change_mpath, 1117 .change_mpath = ieee80211_change_mpath,
1014 .get_mpath = ieee80211_get_mpath, 1118 .get_mpath = ieee80211_get_mpath,
1015 .dump_mpath = ieee80211_dump_mpath, 1119 .dump_mpath = ieee80211_dump_mpath,
1120 .set_mesh_params = ieee80211_set_mesh_params,
1121 .get_mesh_params = ieee80211_get_mesh_params,
1016#endif 1122#endif
1017 .change_bss = ieee80211_change_bss, 1123 .change_bss = ieee80211_change_bss,
1124 .set_txq_params = ieee80211_set_txq_params,
1018}; 1125};
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 24ce54463310..2697a2fe608f 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -47,18 +47,14 @@ static const struct file_operations name## _ops = { \
47 47
48DEBUGFS_READONLY_FILE(frequency, 20, "%d", 48DEBUGFS_READONLY_FILE(frequency, 20, "%d",
49 local->hw.conf.channel->center_freq); 49 local->hw.conf.channel->center_freq);
50DEBUGFS_READONLY_FILE(antenna_sel_tx, 20, "%d",
51 local->hw.conf.antenna_sel_tx);
52DEBUGFS_READONLY_FILE(antenna_sel_rx, 20, "%d",
53 local->hw.conf.antenna_sel_rx);
54DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d", 50DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d",
55 local->rts_threshold); 51 local->rts_threshold);
56DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d", 52DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d",
57 local->fragmentation_threshold); 53 local->fragmentation_threshold);
58DEBUGFS_READONLY_FILE(short_retry_limit, 20, "%d", 54DEBUGFS_READONLY_FILE(short_retry_limit, 20, "%d",
59 local->short_retry_limit); 55 local->hw.conf.short_frame_max_tx_count);
60DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d", 56DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d",
61 local->long_retry_limit); 57 local->hw.conf.long_frame_max_tx_count);
62DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d", 58DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d",
63 local->total_ps_buffered); 59 local->total_ps_buffered);
64DEBUGFS_READONLY_FILE(wep_iv, 20, "%#06x", 60DEBUGFS_READONLY_FILE(wep_iv, 20, "%#06x",
@@ -202,8 +198,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
202 local->debugfs.keys = debugfs_create_dir("keys", phyd); 198 local->debugfs.keys = debugfs_create_dir("keys", phyd);
203 199
204 DEBUGFS_ADD(frequency); 200 DEBUGFS_ADD(frequency);
205 DEBUGFS_ADD(antenna_sel_tx);
206 DEBUGFS_ADD(antenna_sel_rx);
207 DEBUGFS_ADD(rts_threshold); 201 DEBUGFS_ADD(rts_threshold);
208 DEBUGFS_ADD(fragmentation_threshold); 202 DEBUGFS_ADD(fragmentation_threshold);
209 DEBUGFS_ADD(short_retry_limit); 203 DEBUGFS_ADD(short_retry_limit);
@@ -258,8 +252,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
258void debugfs_hw_del(struct ieee80211_local *local) 252void debugfs_hw_del(struct ieee80211_local *local)
259{ 253{
260 DEBUGFS_DEL(frequency); 254 DEBUGFS_DEL(frequency);
261 DEBUGFS_DEL(antenna_sel_tx);
262 DEBUGFS_DEL(antenna_sel_rx);
263 DEBUGFS_DEL(rts_threshold); 255 DEBUGFS_DEL(rts_threshold);
264 DEBUGFS_DEL(fragmentation_threshold); 256 DEBUGFS_DEL(fragmentation_threshold);
265 DEBUGFS_DEL(short_retry_limit); 257 DEBUGFS_DEL(short_retry_limit);
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index a3294d109322..6424ac565ae0 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -188,7 +188,6 @@ void ieee80211_debugfs_key_add(struct ieee80211_key *key)
188 { 188 {
189 static int keycount; 189 static int keycount;
190 char buf[50]; 190 char buf[50];
191 DECLARE_MAC_BUF(mac);
192 struct sta_info *sta; 191 struct sta_info *sta;
193 192
194 if (!key->local->debugfs.keys) 193 if (!key->local->debugfs.keys)
@@ -206,8 +205,7 @@ void ieee80211_debugfs_key_add(struct ieee80211_key *key)
206 rcu_read_lock(); 205 rcu_read_lock();
207 sta = rcu_dereference(key->sta); 206 sta = rcu_dereference(key->sta);
208 if (sta) 207 if (sta)
209 sprintf(buf, "../../stations/%s", 208 sprintf(buf, "../../stations/%pM", sta->sta.addr);
210 print_mac(mac, sta->sta.addr));
211 rcu_read_unlock(); 209 rcu_read_unlock();
212 210
213 /* using sta as a boolean is fine outside RCU lock */ 211 /* using sta as a boolean is fine outside RCU lock */
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 2ad504fc3414..c54219301724 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -41,29 +41,6 @@ static ssize_t ieee80211_if_read(
41 return ret; 41 return ret;
42} 42}
43 43
44#ifdef CONFIG_MAC80211_MESH
45static ssize_t ieee80211_if_write(
46 struct ieee80211_sub_if_data *sdata,
47 char const __user *userbuf,
48 size_t count, loff_t *ppos,
49 int (*format)(struct ieee80211_sub_if_data *, char *))
50{
51 char buf[10];
52 int buf_size;
53
54 memset(buf, 0x00, sizeof(buf));
55 buf_size = min(count, (sizeof(buf)-1));
56 if (copy_from_user(buf, userbuf, buf_size))
57 return count;
58 read_lock(&dev_base_lock);
59 if (sdata->dev->reg_state == NETREG_REGISTERED)
60 (*format)(sdata, buf);
61 read_unlock(&dev_base_lock);
62
63 return count;
64}
65#endif
66
67#define IEEE80211_IF_FMT(name, field, format_string) \ 44#define IEEE80211_IF_FMT(name, field, format_string) \
68static ssize_t ieee80211_if_fmt_##name( \ 45static ssize_t ieee80211_if_fmt_##name( \
69 const struct ieee80211_sub_if_data *sdata, char *buf, \ 46 const struct ieee80211_sub_if_data *sdata, char *buf, \
@@ -71,19 +48,6 @@ static ssize_t ieee80211_if_fmt_##name( \
71{ \ 48{ \
72 return scnprintf(buf, buflen, format_string, sdata->field); \ 49 return scnprintf(buf, buflen, format_string, sdata->field); \
73} 50}
74#define IEEE80211_IF_WFMT(name, field, type) \
75static int ieee80211_if_wfmt_##name( \
76 struct ieee80211_sub_if_data *sdata, char *buf) \
77{ \
78 unsigned long tmp; \
79 char *endp; \
80 \
81 tmp = simple_strtoul(buf, &endp, 0); \
82 if ((endp == buf) || ((type)tmp != tmp)) \
83 return -EINVAL; \
84 sdata->field = tmp; \
85 return 0; \
86}
87#define IEEE80211_IF_FMT_DEC(name, field) \ 51#define IEEE80211_IF_FMT_DEC(name, field) \
88 IEEE80211_IF_FMT(name, field, "%d\n") 52 IEEE80211_IF_FMT(name, field, "%d\n")
89#define IEEE80211_IF_FMT_HEX(name, field) \ 53#define IEEE80211_IF_FMT_HEX(name, field) \
@@ -104,8 +68,7 @@ static ssize_t ieee80211_if_fmt_##name( \
104 const struct ieee80211_sub_if_data *sdata, char *buf, \ 68 const struct ieee80211_sub_if_data *sdata, char *buf, \
105 int buflen) \ 69 int buflen) \
106{ \ 70{ \
107 DECLARE_MAC_BUF(mac); \ 71 return scnprintf(buf, buflen, "%pM\n", sdata->field); \
108 return scnprintf(buf, buflen, "%s\n", print_mac(mac, sdata->field));\
109} 72}
110 73
111#define __IEEE80211_IF_FILE(name) \ 74#define __IEEE80211_IF_FILE(name) \
@@ -126,34 +89,6 @@ static const struct file_operations name##_ops = { \
126 IEEE80211_IF_FMT_##format(name, field) \ 89 IEEE80211_IF_FMT_##format(name, field) \
127 __IEEE80211_IF_FILE(name) 90 __IEEE80211_IF_FILE(name)
128 91
129#define __IEEE80211_IF_WFILE(name) \
130static ssize_t ieee80211_if_read_##name(struct file *file, \
131 char __user *userbuf, \
132 size_t count, loff_t *ppos) \
133{ \
134 return ieee80211_if_read(file->private_data, \
135 userbuf, count, ppos, \
136 ieee80211_if_fmt_##name); \
137} \
138static ssize_t ieee80211_if_write_##name(struct file *file, \
139 const char __user *userbuf, \
140 size_t count, loff_t *ppos) \
141{ \
142 return ieee80211_if_write(file->private_data, \
143 userbuf, count, ppos, \
144 ieee80211_if_wfmt_##name); \
145} \
146static const struct file_operations name##_ops = { \
147 .read = ieee80211_if_read_##name, \
148 .write = ieee80211_if_write_##name, \
149 .open = mac80211_open_file_generic, \
150}
151
152#define IEEE80211_IF_WFILE(name, field, format, type) \
153 IEEE80211_IF_FMT_##format(name, field) \
154 IEEE80211_IF_WFMT(name, field, type) \
155 __IEEE80211_IF_WFILE(name)
156
157/* common attributes */ 92/* common attributes */
158IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); 93IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
159IEEE80211_IF_FILE(force_unicast_rateidx, force_unicast_rateidx, DEC); 94IEEE80211_IF_FILE(force_unicast_rateidx, force_unicast_rateidx, DEC);
@@ -184,7 +119,7 @@ static ssize_t ieee80211_if_fmt_flags(
184 sdata->u.sta.flags & IEEE80211_STA_AUTHENTICATED ? "AUTH\n" : "", 119 sdata->u.sta.flags & IEEE80211_STA_AUTHENTICATED ? "AUTH\n" : "",
185 sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED ? "ASSOC\n" : "", 120 sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED ? "ASSOC\n" : "",
186 sdata->u.sta.flags & IEEE80211_STA_PROBEREQ_POLL ? "PROBEREQ POLL\n" : "", 121 sdata->u.sta.flags & IEEE80211_STA_PROBEREQ_POLL ? "PROBEREQ POLL\n" : "",
187 sdata->bss_conf.use_cts_prot ? "CTS prot\n" : ""); 122 sdata->vif.bss_conf.use_cts_prot ? "CTS prot\n" : "");
188} 123}
189__IEEE80211_IF_FILE(flags); 124__IEEE80211_IF_FILE(flags);
190 125
@@ -212,30 +147,30 @@ IEEE80211_IF_FILE(dropped_frames_no_route,
212IEEE80211_IF_FILE(estab_plinks, u.mesh.mshstats.estab_plinks, ATOMIC); 147IEEE80211_IF_FILE(estab_plinks, u.mesh.mshstats.estab_plinks, ATOMIC);
213 148
214/* Mesh parameters */ 149/* Mesh parameters */
215IEEE80211_IF_WFILE(dot11MeshMaxRetries, 150IEEE80211_IF_FILE(dot11MeshMaxRetries,
216 u.mesh.mshcfg.dot11MeshMaxRetries, DEC, u8); 151 u.mesh.mshcfg.dot11MeshMaxRetries, DEC);
217IEEE80211_IF_WFILE(dot11MeshRetryTimeout, 152IEEE80211_IF_FILE(dot11MeshRetryTimeout,
218 u.mesh.mshcfg.dot11MeshRetryTimeout, DEC, u16); 153 u.mesh.mshcfg.dot11MeshRetryTimeout, DEC);
219IEEE80211_IF_WFILE(dot11MeshConfirmTimeout, 154IEEE80211_IF_FILE(dot11MeshConfirmTimeout,
220 u.mesh.mshcfg.dot11MeshConfirmTimeout, DEC, u16); 155 u.mesh.mshcfg.dot11MeshConfirmTimeout, DEC);
221IEEE80211_IF_WFILE(dot11MeshHoldingTimeout, 156IEEE80211_IF_FILE(dot11MeshHoldingTimeout,
222 u.mesh.mshcfg.dot11MeshHoldingTimeout, DEC, u16); 157 u.mesh.mshcfg.dot11MeshHoldingTimeout, DEC);
223IEEE80211_IF_WFILE(dot11MeshTTL, u.mesh.mshcfg.dot11MeshTTL, DEC, u8); 158IEEE80211_IF_FILE(dot11MeshTTL, u.mesh.mshcfg.dot11MeshTTL, DEC);
224IEEE80211_IF_WFILE(auto_open_plinks, u.mesh.mshcfg.auto_open_plinks, DEC, u8); 159IEEE80211_IF_FILE(auto_open_plinks, u.mesh.mshcfg.auto_open_plinks, DEC);
225IEEE80211_IF_WFILE(dot11MeshMaxPeerLinks, 160IEEE80211_IF_FILE(dot11MeshMaxPeerLinks,
226 u.mesh.mshcfg.dot11MeshMaxPeerLinks, DEC, u16); 161 u.mesh.mshcfg.dot11MeshMaxPeerLinks, DEC);
227IEEE80211_IF_WFILE(dot11MeshHWMPactivePathTimeout, 162IEEE80211_IF_FILE(dot11MeshHWMPactivePathTimeout,
228 u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout, DEC, u32); 163 u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout, DEC);
229IEEE80211_IF_WFILE(dot11MeshHWMPpreqMinInterval, 164IEEE80211_IF_FILE(dot11MeshHWMPpreqMinInterval,
230 u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval, DEC, u16); 165 u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval, DEC);
231IEEE80211_IF_WFILE(dot11MeshHWMPnetDiameterTraversalTime, 166IEEE80211_IF_FILE(dot11MeshHWMPnetDiameterTraversalTime,
232 u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime, DEC, u16); 167 u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime, DEC);
233IEEE80211_IF_WFILE(dot11MeshHWMPmaxPREQretries, 168IEEE80211_IF_FILE(dot11MeshHWMPmaxPREQretries,
234 u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries, DEC, u8); 169 u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries, DEC);
235IEEE80211_IF_WFILE(path_refresh_time, 170IEEE80211_IF_FILE(path_refresh_time,
236 u.mesh.mshcfg.path_refresh_time, DEC, u32); 171 u.mesh.mshcfg.path_refresh_time, DEC);
237IEEE80211_IF_WFILE(min_discovery_timeout, 172IEEE80211_IF_FILE(min_discovery_timeout,
238 u.mesh.mshcfg.min_discovery_timeout, DEC, u16); 173 u.mesh.mshcfg.min_discovery_timeout, DEC);
239#endif 174#endif
240 175
241 176
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index b85c4f27b361..a2fbe0131312 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -39,13 +39,6 @@ static const struct file_operations sta_ ##name## _ops = { \
39 .open = mac80211_open_file_generic, \ 39 .open = mac80211_open_file_generic, \
40} 40}
41 41
42#define STA_OPS_WR(name) \
43static const struct file_operations sta_ ##name## _ops = { \
44 .read = sta_##name##_read, \
45 .write = sta_##name##_write, \
46 .open = mac80211_open_file_generic, \
47}
48
49#define STA_FILE(name, field, format) \ 42#define STA_FILE(name, field, format) \
50 STA_READ_##format(name, field) \ 43 STA_READ_##format(name, field) \
51 STA_OPS(name) 44 STA_OPS(name)
@@ -144,7 +137,7 @@ static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
144 p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:"); 137 p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:");
145 for (i = 0; i < STA_TID_NUM; i++) 138 for (i = 0; i < STA_TID_NUM; i++)
146 p += scnprintf(p, sizeof(buf)+buf-p, "%5d", 139 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
147 sta->ampdu_mlme.tid_state_rx[i]? 140 sta->ampdu_mlme.tid_state_rx[i] ?
148 sta->ampdu_mlme.tid_rx[i]->dialog_token : 0); 141 sta->ampdu_mlme.tid_rx[i]->dialog_token : 0);
149 142
150 p += scnprintf(p, sizeof(buf)+buf-p, "\n TX :"); 143 p += scnprintf(p, sizeof(buf)+buf-p, "\n TX :");
@@ -155,84 +148,20 @@ static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
155 p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:"); 148 p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:");
156 for (i = 0; i < STA_TID_NUM; i++) 149 for (i = 0; i < STA_TID_NUM; i++)
157 p += scnprintf(p, sizeof(buf)+buf-p, "%5d", 150 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
158 sta->ampdu_mlme.tid_state_tx[i]? 151 sta->ampdu_mlme.tid_state_tx[i] ?
159 sta->ampdu_mlme.tid_tx[i]->dialog_token : 0); 152 sta->ampdu_mlme.tid_tx[i]->dialog_token : 0);
160 153
161 p += scnprintf(p, sizeof(buf)+buf-p, "\n SSN :"); 154 p += scnprintf(p, sizeof(buf)+buf-p, "\n SSN :");
162 for (i = 0; i < STA_TID_NUM; i++) 155 for (i = 0; i < STA_TID_NUM; i++)
163 p += scnprintf(p, sizeof(buf)+buf-p, "%5d", 156 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
164 sta->ampdu_mlme.tid_state_tx[i]? 157 sta->ampdu_mlme.tid_state_tx[i] ?
165 sta->ampdu_mlme.tid_tx[i]->ssn : 0); 158 sta->ampdu_mlme.tid_tx[i]->ssn : 0);
166 159
167 p += scnprintf(p, sizeof(buf)+buf-p, "\n"); 160 p += scnprintf(p, sizeof(buf)+buf-p, "\n");
168 161
169 return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); 162 return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
170} 163}
171 164STA_OPS(agg_status);
172static ssize_t sta_agg_status_write(struct file *file,
173 const char __user *user_buf, size_t count, loff_t *ppos)
174{
175 struct sta_info *sta = file->private_data;
176 struct ieee80211_local *local = sta->sdata->local;
177 struct ieee80211_hw *hw = &local->hw;
178 u8 *da = sta->sta.addr;
179 static int tid_static_tx[16] = {0, 0, 0, 0, 0, 0, 0, 0,
180 0, 0, 0, 0, 0, 0, 0, 0};
181 static int tid_static_rx[16] = {1, 1, 1, 1, 1, 1, 1, 1,
182 1, 1, 1, 1, 1, 1, 1, 1};
183 char *endp;
184 char buf[32];
185 int buf_size, rs;
186 unsigned int tid_num;
187 char state[4];
188
189 memset(buf, 0x00, sizeof(buf));
190 buf_size = min(count, (sizeof(buf)-1));
191 if (copy_from_user(buf, user_buf, buf_size))
192 return -EFAULT;
193
194 tid_num = simple_strtoul(buf, &endp, 0);
195 if (endp == buf)
196 return -EINVAL;
197
198 if ((tid_num >= 100) && (tid_num <= 115)) {
199 /* toggle Rx aggregation command */
200 tid_num = tid_num - 100;
201 if (tid_static_rx[tid_num] == 1) {
202 strcpy(state, "off");
203 ieee80211_sta_stop_rx_ba_session(sta->sdata, da, tid_num, 0,
204 WLAN_REASON_QSTA_REQUIRE_SETUP);
205 sta->ampdu_mlme.tid_state_rx[tid_num] |=
206 HT_AGG_STATE_DEBUGFS_CTL;
207 tid_static_rx[tid_num] = 0;
208 } else {
209 strcpy(state, "on ");
210 sta->ampdu_mlme.tid_state_rx[tid_num] &=
211 ~HT_AGG_STATE_DEBUGFS_CTL;
212 tid_static_rx[tid_num] = 1;
213 }
214 printk(KERN_DEBUG "debugfs - try switching tid %u %s\n",
215 tid_num, state);
216 } else if ((tid_num >= 0) && (tid_num <= 15)) {
217 /* toggle Tx aggregation command */
218 if (tid_static_tx[tid_num] == 0) {
219 strcpy(state, "on ");
220 rs = ieee80211_start_tx_ba_session(hw, da, tid_num);
221 if (rs == 0)
222 tid_static_tx[tid_num] = 1;
223 } else {
224 strcpy(state, "off");
225 rs = ieee80211_stop_tx_ba_session(hw, da, tid_num, 1);
226 if (rs == 0)
227 tid_static_tx[tid_num] = 0;
228 }
229 printk(KERN_DEBUG "debugfs - switching tid %u %s, return=%d\n",
230 tid_num, state, rs);
231 }
232
233 return count;
234}
235STA_OPS_WR(agg_status);
236 165
237#define DEBUGFS_ADD(name) \ 166#define DEBUGFS_ADD(name) \
238 sta->debugfs.name = debugfs_create_file(#name, 0400, \ 167 sta->debugfs.name = debugfs_create_file(#name, 0400, \
@@ -246,15 +175,14 @@ STA_OPS_WR(agg_status);
246void ieee80211_sta_debugfs_add(struct sta_info *sta) 175void ieee80211_sta_debugfs_add(struct sta_info *sta)
247{ 176{
248 struct dentry *stations_dir = sta->local->debugfs.stations; 177 struct dentry *stations_dir = sta->local->debugfs.stations;
249 DECLARE_MAC_BUF(mbuf); 178 u8 mac[3*ETH_ALEN];
250 u8 *mac;
251 179
252 sta->debugfs.add_has_run = true; 180 sta->debugfs.add_has_run = true;
253 181
254 if (!stations_dir) 182 if (!stations_dir)
255 return; 183 return;
256 184
257 mac = print_mac(mbuf, sta->sta.addr); 185 snprintf(mac, sizeof(mac), "%pM", sta->sta.addr);
258 186
259 /* 187 /*
260 * This might fail due to a race condition: 188 * This might fail due to a race condition:
diff --git a/net/mac80211/event.c b/net/mac80211/event.c
index 8de60de70bc9..0d95561c0ee0 100644
--- a/net/mac80211/event.c
+++ b/net/mac80211/event.c
@@ -21,14 +21,13 @@ void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int ke
21{ 21{
22 union iwreq_data wrqu; 22 union iwreq_data wrqu;
23 char *buf = kmalloc(128, GFP_ATOMIC); 23 char *buf = kmalloc(128, GFP_ATOMIC);
24 DECLARE_MAC_BUF(mac);
25 24
26 if (buf) { 25 if (buf) {
27 /* TODO: needed parameters: count, key type, TSC */ 26 /* TODO: needed parameters: count, key type, TSC */
28 sprintf(buf, "MLME-MICHAELMICFAILURE.indication(" 27 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
29 "keyid=%d %scast addr=%s)", 28 "keyid=%d %scast addr=%pM)",
30 keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni", 29 keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
31 print_mac(mac, hdr->addr2)); 30 hdr->addr2);
32 memset(&wrqu, 0, sizeof(wrqu)); 31 memset(&wrqu, 0, sizeof(wrqu));
33 wrqu.data.length = strlen(buf); 32 wrqu.data.length = strlen(buf);
34 wireless_send_event(sdata->dev, IWEVCUSTOM, &wrqu, buf); 33 wireless_send_event(sdata->dev, IWEVCUSTOM, &wrqu, buf);
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index dc7d9a3d70d5..3e231d756776 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -20,50 +20,125 @@
20#include "sta_info.h" 20#include "sta_info.h"
21#include "wme.h" 21#include "wme.h"
22 22
23int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie, 23void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband,
24 struct ieee80211_ht_info *ht_info) 24 struct ieee80211_ht_cap *ht_cap_ie,
25 struct ieee80211_sta_ht_cap *ht_cap)
25{ 26{
27 u8 ampdu_info, tx_mcs_set_cap;
28 int i, max_tx_streams;
26 29
27 if (ht_info == NULL) 30 BUG_ON(!ht_cap);
28 return -EINVAL; 31
32 memset(ht_cap, 0, sizeof(*ht_cap));
33
34 if (!ht_cap_ie)
35 return;
29 36
30 memset(ht_info, 0, sizeof(*ht_info)); 37 ht_cap->ht_supported = true;
31 38
32 if (ht_cap_ie) { 39 ht_cap->cap = ht_cap->cap & sband->ht_cap.cap;
33 u8 ampdu_info = ht_cap_ie->ampdu_params_info; 40 ht_cap->cap &= ~IEEE80211_HT_CAP_SM_PS;
41 ht_cap->cap |= sband->ht_cap.cap & IEEE80211_HT_CAP_SM_PS;
34 42
35 ht_info->ht_supported = 1; 43 ampdu_info = ht_cap_ie->ampdu_params_info;
36 ht_info->cap = le16_to_cpu(ht_cap_ie->cap_info); 44 ht_cap->ampdu_factor =
37 ht_info->ampdu_factor = 45 ampdu_info & IEEE80211_HT_AMPDU_PARM_FACTOR;
38 ampdu_info & IEEE80211_HT_CAP_AMPDU_FACTOR; 46 ht_cap->ampdu_density =
39 ht_info->ampdu_density = 47 (ampdu_info & IEEE80211_HT_AMPDU_PARM_DENSITY) >> 2;
40 (ampdu_info & IEEE80211_HT_CAP_AMPDU_DENSITY) >> 2;
41 memcpy(ht_info->supp_mcs_set, ht_cap_ie->supp_mcs_set, 16);
42 } else
43 ht_info->ht_supported = 0;
44 48
45 return 0; 49 /* own MCS TX capabilities */
50 tx_mcs_set_cap = sband->ht_cap.mcs.tx_params;
51
52 /* can we TX with MCS rates? */
53 if (!(tx_mcs_set_cap & IEEE80211_HT_MCS_TX_DEFINED))
54 return;
55
56 /* Counting from 0, therefore +1 */
57 if (tx_mcs_set_cap & IEEE80211_HT_MCS_TX_RX_DIFF)
58 max_tx_streams =
59 ((tx_mcs_set_cap & IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK)
60 >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT) + 1;
61 else
62 max_tx_streams = IEEE80211_HT_MCS_TX_MAX_STREAMS;
63
64 /*
65 * 802.11n D5.0 20.3.5 / 20.6 says:
66 * - indices 0 to 7 and 32 are single spatial stream
67 * - 8 to 31 are multiple spatial streams using equal modulation
68 * [8..15 for two streams, 16..23 for three and 24..31 for four]
69 * - remainder are multiple spatial streams using unequal modulation
70 */
71 for (i = 0; i < max_tx_streams; i++)
72 ht_cap->mcs.rx_mask[i] =
73 sband->ht_cap.mcs.rx_mask[i] & ht_cap_ie->mcs.rx_mask[i];
74
75 if (tx_mcs_set_cap & IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION)
76 for (i = IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE;
77 i < IEEE80211_HT_MCS_MASK_LEN; i++)
78 ht_cap->mcs.rx_mask[i] =
79 sband->ht_cap.mcs.rx_mask[i] &
80 ht_cap_ie->mcs.rx_mask[i];
81
82 /* handle MCS rate 32 too */
83 if (sband->ht_cap.mcs.rx_mask[32/8] & ht_cap_ie->mcs.rx_mask[32/8] & 1)
84 ht_cap->mcs.rx_mask[32/8] |= 1;
46} 85}
47 86
48int ieee80211_ht_addt_info_ie_to_ht_bss_info( 87/*
49 struct ieee80211_ht_addt_info *ht_add_info_ie, 88 * ieee80211_enable_ht should be called only after the operating band
50 struct ieee80211_ht_bss_info *bss_info) 89 * has been determined as ht configuration depends on the hw's
90 * HT abilities for a specific band.
91 */
92u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
93 struct ieee80211_ht_info *hti,
94 u16 ap_ht_cap_flags)
51{ 95{
52 if (bss_info == NULL) 96 struct ieee80211_local *local = sdata->local;
53 return -EINVAL; 97 struct ieee80211_supported_band *sband;
98 struct ieee80211_bss_ht_conf ht;
99 u32 changed = 0;
100 bool enable_ht = true, ht_changed;
101
102 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
54 103
55 memset(bss_info, 0, sizeof(*bss_info)); 104 memset(&ht, 0, sizeof(ht));
56 105
57 if (ht_add_info_ie) { 106 /* HT is not supported */
58 u16 op_mode; 107 if (!sband->ht_cap.ht_supported)
59 op_mode = le16_to_cpu(ht_add_info_ie->operation_mode); 108 enable_ht = false;
60 109
61 bss_info->primary_channel = ht_add_info_ie->control_chan; 110 /* check that channel matches the right operating channel */
62 bss_info->bss_cap = ht_add_info_ie->ht_param; 111 if (local->hw.conf.channel->center_freq !=
63 bss_info->bss_op_mode = (u8)(op_mode & 0xff); 112 ieee80211_channel_to_frequency(hti->control_chan))
113 enable_ht = false;
114
115 /*
116 * XXX: This is totally incorrect when there are multiple virtual
117 * interfaces, needs to be fixed later.
118 */
119 ht_changed = local->hw.conf.ht.enabled != enable_ht;
120 local->hw.conf.ht.enabled = enable_ht;
121 if (ht_changed)
122 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_HT);
123
124 /* disable HT */
125 if (!enable_ht)
126 return 0;
127 ht.secondary_channel_offset =
128 hti->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
129 ht.width_40_ok =
130 !(ap_ht_cap_flags & IEEE80211_HT_CAP_40MHZ_INTOLERANT) &&
131 (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) &&
132 (hti->ht_param & IEEE80211_HT_PARAM_CHAN_WIDTH_ANY);
133 ht.operation_mode = le16_to_cpu(hti->operation_mode);
134
135 /* if bss configuration changed store the new one */
136 if (memcmp(&sdata->vif.bss_conf.ht, &ht, sizeof(ht))) {
137 changed |= BSS_CHANGED_HT;
138 sdata->vif.bss_conf.ht = ht;
64 } 139 }
65 140
66 return 0; 141 return changed;
67} 142}
68 143
69static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, 144static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
@@ -241,7 +316,6 @@ void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *r
241 struct ieee80211_hw *hw = &local->hw; 316 struct ieee80211_hw *hw = &local->hw;
242 struct sta_info *sta; 317 struct sta_info *sta;
243 int ret, i; 318 int ret, i;
244 DECLARE_MAC_BUF(mac);
245 319
246 rcu_read_lock(); 320 rcu_read_lock();
247 321
@@ -269,8 +343,8 @@ void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *r
269 BUG_ON(!local->ops->ampdu_action); 343 BUG_ON(!local->ops->ampdu_action);
270 344
271#ifdef CONFIG_MAC80211_HT_DEBUG 345#ifdef CONFIG_MAC80211_HT_DEBUG
272 printk(KERN_DEBUG "Rx BA session stop requested for %s tid %u\n", 346 printk(KERN_DEBUG "Rx BA session stop requested for %pM tid %u\n",
273 print_mac(mac, ra), tid); 347 ra, tid);
274#endif /* CONFIG_MAC80211_HT_DEBUG */ 348#endif /* CONFIG_MAC80211_HT_DEBUG */
275 349
276 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_STOP, 350 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_STOP,
@@ -383,14 +457,13 @@ int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
383 u16 start_seq_num; 457 u16 start_seq_num;
384 u8 *state; 458 u8 *state;
385 int ret; 459 int ret;
386 DECLARE_MAC_BUF(mac);
387 460
388 if (tid >= STA_TID_NUM) 461 if ((tid >= STA_TID_NUM) || !(hw->flags & IEEE80211_HW_AMPDU_AGGREGATION))
389 return -EINVAL; 462 return -EINVAL;
390 463
391#ifdef CONFIG_MAC80211_HT_DEBUG 464#ifdef CONFIG_MAC80211_HT_DEBUG
392 printk(KERN_DEBUG "Open BA session requested for %s tid %u\n", 465 printk(KERN_DEBUG "Open BA session requested for %pM tid %u\n",
393 print_mac(mac, ra), tid); 466 ra, tid);
394#endif /* CONFIG_MAC80211_HT_DEBUG */ 467#endif /* CONFIG_MAC80211_HT_DEBUG */
395 468
396 rcu_read_lock(); 469 rcu_read_lock();
@@ -442,17 +515,19 @@ int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
442 (unsigned long)&sta->timer_to_tid[tid]; 515 (unsigned long)&sta->timer_to_tid[tid];
443 init_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); 516 init_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer);
444 517
445 /* create a new queue for this aggregation */ 518 if (hw->ampdu_queues) {
446 ret = ieee80211_ht_agg_queue_add(local, sta, tid); 519 /* create a new queue for this aggregation */
520 ret = ieee80211_ht_agg_queue_add(local, sta, tid);
447 521
448 /* case no queue is available to aggregation 522 /* case no queue is available to aggregation
449 * don't switch to aggregation */ 523 * don't switch to aggregation */
450 if (ret) { 524 if (ret) {
451#ifdef CONFIG_MAC80211_HT_DEBUG 525#ifdef CONFIG_MAC80211_HT_DEBUG
452 printk(KERN_DEBUG "BA request denied - queue unavailable for" 526 printk(KERN_DEBUG "BA request denied - "
453 " tid %d\n", tid); 527 "queue unavailable for tid %d\n", tid);
454#endif /* CONFIG_MAC80211_HT_DEBUG */ 528#endif /* CONFIG_MAC80211_HT_DEBUG */
455 goto err_unlock_queue; 529 goto err_unlock_queue;
530 }
456 } 531 }
457 sdata = sta->sdata; 532 sdata = sta->sdata;
458 533
@@ -471,7 +546,8 @@ int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
471 /* No need to requeue the packets in the agg queue, since we 546 /* No need to requeue the packets in the agg queue, since we
472 * held the tx lock: no packet could be enqueued to the newly 547 * held the tx lock: no packet could be enqueued to the newly
473 * allocated queue */ 548 * allocated queue */
474 ieee80211_ht_agg_queue_remove(local, sta, tid, 0); 549 if (hw->ampdu_queues)
550 ieee80211_ht_agg_queue_remove(local, sta, tid, 0);
475#ifdef CONFIG_MAC80211_HT_DEBUG 551#ifdef CONFIG_MAC80211_HT_DEBUG
476 printk(KERN_DEBUG "BA request denied - HW unavailable for" 552 printk(KERN_DEBUG "BA request denied - HW unavailable for"
477 " tid %d\n", tid); 553 " tid %d\n", tid);
@@ -481,7 +557,8 @@ int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
481 } 557 }
482 558
483 /* Will put all the packets in the new SW queue */ 559 /* Will put all the packets in the new SW queue */
484 ieee80211_requeue(local, ieee802_1d_to_ac[tid]); 560 if (hw->ampdu_queues)
561 ieee80211_requeue(local, ieee802_1d_to_ac[tid]);
485 spin_unlock_bh(&sta->lock); 562 spin_unlock_bh(&sta->lock);
486 563
487 /* send an addBA request */ 564 /* send an addBA request */
@@ -524,7 +601,6 @@ int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
524 struct sta_info *sta; 601 struct sta_info *sta;
525 u8 *state; 602 u8 *state;
526 int ret = 0; 603 int ret = 0;
527 DECLARE_MAC_BUF(mac);
528 604
529 if (tid >= STA_TID_NUM) 605 if (tid >= STA_TID_NUM)
530 return -EINVAL; 606 return -EINVAL;
@@ -546,11 +622,12 @@ int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
546 } 622 }
547 623
548#ifdef CONFIG_MAC80211_HT_DEBUG 624#ifdef CONFIG_MAC80211_HT_DEBUG
549 printk(KERN_DEBUG "Tx BA session stop requested for %s tid %u\n", 625 printk(KERN_DEBUG "Tx BA session stop requested for %pM tid %u\n",
550 print_mac(mac, ra), tid); 626 ra, tid);
551#endif /* CONFIG_MAC80211_HT_DEBUG */ 627#endif /* CONFIG_MAC80211_HT_DEBUG */
552 628
553 ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]); 629 if (hw->ampdu_queues)
630 ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]);
554 631
555 *state = HT_AGG_STATE_REQ_STOP_BA_MSK | 632 *state = HT_AGG_STATE_REQ_STOP_BA_MSK |
556 (initiator << HT_AGG_STATE_INITIATOR_SHIFT); 633 (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
@@ -563,7 +640,8 @@ int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
563 if (ret) { 640 if (ret) {
564 WARN_ON(ret != -EBUSY); 641 WARN_ON(ret != -EBUSY);
565 *state = HT_AGG_STATE_OPERATIONAL; 642 *state = HT_AGG_STATE_OPERATIONAL;
566 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); 643 if (hw->ampdu_queues)
644 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
567 goto stop_BA_exit; 645 goto stop_BA_exit;
568 } 646 }
569 647
@@ -579,7 +657,6 @@ void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
579 struct ieee80211_local *local = hw_to_local(hw); 657 struct ieee80211_local *local = hw_to_local(hw);
580 struct sta_info *sta; 658 struct sta_info *sta;
581 u8 *state; 659 u8 *state;
582 DECLARE_MAC_BUF(mac);
583 660
584 if (tid >= STA_TID_NUM) { 661 if (tid >= STA_TID_NUM) {
585#ifdef CONFIG_MAC80211_HT_DEBUG 662#ifdef CONFIG_MAC80211_HT_DEBUG
@@ -594,8 +671,7 @@ void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
594 if (!sta) { 671 if (!sta) {
595 rcu_read_unlock(); 672 rcu_read_unlock();
596#ifdef CONFIG_MAC80211_HT_DEBUG 673#ifdef CONFIG_MAC80211_HT_DEBUG
597 printk(KERN_DEBUG "Could not find station: %s\n", 674 printk(KERN_DEBUG "Could not find station: %pM\n", ra);
598 print_mac(mac, ra));
599#endif 675#endif
600 return; 676 return;
601 } 677 }
@@ -621,7 +697,8 @@ void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
621#ifdef CONFIG_MAC80211_HT_DEBUG 697#ifdef CONFIG_MAC80211_HT_DEBUG
622 printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid); 698 printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid);
623#endif 699#endif
624 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); 700 if (hw->ampdu_queues)
701 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
625 } 702 }
626 spin_unlock_bh(&sta->lock); 703 spin_unlock_bh(&sta->lock);
627 rcu_read_unlock(); 704 rcu_read_unlock();
@@ -634,7 +711,6 @@ void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
634 struct sta_info *sta; 711 struct sta_info *sta;
635 u8 *state; 712 u8 *state;
636 int agg_queue; 713 int agg_queue;
637 DECLARE_MAC_BUF(mac);
638 714
639 if (tid >= STA_TID_NUM) { 715 if (tid >= STA_TID_NUM) {
640#ifdef CONFIG_MAC80211_HT_DEBUG 716#ifdef CONFIG_MAC80211_HT_DEBUG
@@ -645,16 +721,15 @@ void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
645 } 721 }
646 722
647#ifdef CONFIG_MAC80211_HT_DEBUG 723#ifdef CONFIG_MAC80211_HT_DEBUG
648 printk(KERN_DEBUG "Stopping Tx BA session for %s tid %d\n", 724 printk(KERN_DEBUG "Stopping Tx BA session for %pM tid %d\n",
649 print_mac(mac, ra), tid); 725 ra, tid);
650#endif /* CONFIG_MAC80211_HT_DEBUG */ 726#endif /* CONFIG_MAC80211_HT_DEBUG */
651 727
652 rcu_read_lock(); 728 rcu_read_lock();
653 sta = sta_info_get(local, ra); 729 sta = sta_info_get(local, ra);
654 if (!sta) { 730 if (!sta) {
655#ifdef CONFIG_MAC80211_HT_DEBUG 731#ifdef CONFIG_MAC80211_HT_DEBUG
656 printk(KERN_DEBUG "Could not find station: %s\n", 732 printk(KERN_DEBUG "Could not find station: %pM\n", ra);
657 print_mac(mac, ra));
658#endif 733#endif
659 rcu_read_unlock(); 734 rcu_read_unlock();
660 return; 735 return;
@@ -677,16 +752,18 @@ void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
677 ieee80211_send_delba(sta->sdata, ra, tid, 752 ieee80211_send_delba(sta->sdata, ra, tid,
678 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE); 753 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);
679 754
680 agg_queue = sta->tid_to_tx_q[tid]; 755 if (hw->ampdu_queues) {
681 756 agg_queue = sta->tid_to_tx_q[tid];
682 ieee80211_ht_agg_queue_remove(local, sta, tid, 1); 757 ieee80211_ht_agg_queue_remove(local, sta, tid, 1);
683 758
684 /* We just requeued the all the frames that were in the 759 /* We just requeued the all the frames that were in the
685 * removed queue, and since we might miss a softirq we do 760 * removed queue, and since we might miss a softirq we do
686 * netif_schedule_queue. ieee80211_wake_queue is not used 761 * netif_schedule_queue. ieee80211_wake_queue is not used
687 * here as this queue is not necessarily stopped 762 * here as this queue is not necessarily stopped
688 */ 763 */
689 netif_schedule_queue(netdev_get_tx_queue(local->mdev, agg_queue)); 764 netif_schedule_queue(netdev_get_tx_queue(local->mdev,
765 agg_queue));
766 }
690 spin_lock_bh(&sta->lock); 767 spin_lock_bh(&sta->lock);
691 *state = HT_AGG_STATE_IDLE; 768 *state = HT_AGG_STATE_IDLE;
692 sta->ampdu_mlme.addba_req_num[tid] = 0; 769 sta->ampdu_mlme.addba_req_num[tid] = 0;
@@ -783,7 +860,6 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
783 u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num, status; 860 u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num, status;
784 u8 dialog_token; 861 u8 dialog_token;
785 int ret = -EOPNOTSUPP; 862 int ret = -EOPNOTSUPP;
786 DECLARE_MAC_BUF(mac);
787 863
788 /* extract session parameters from addba request frame */ 864 /* extract session parameters from addba request frame */
789 dialog_token = mgmt->u.action.u.addba_req.dialog_token; 865 dialog_token = mgmt->u.action.u.addba_req.dialog_token;
@@ -801,15 +877,16 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
801 /* sanity check for incoming parameters: 877 /* sanity check for incoming parameters:
802 * check if configuration can support the BA policy 878 * check if configuration can support the BA policy
803 * and if buffer size does not exceeds max value */ 879 * and if buffer size does not exceeds max value */
880 /* XXX: check own ht delayed BA capability?? */
804 if (((ba_policy != 1) 881 if (((ba_policy != 1)
805 && (!(conf->ht_conf.cap & IEEE80211_HT_CAP_DELAY_BA))) 882 && (!(sta->sta.ht_cap.cap & IEEE80211_HT_CAP_DELAY_BA)))
806 || (buf_size > IEEE80211_MAX_AMPDU_BUF)) { 883 || (buf_size > IEEE80211_MAX_AMPDU_BUF)) {
807 status = WLAN_STATUS_INVALID_QOS_PARAM; 884 status = WLAN_STATUS_INVALID_QOS_PARAM;
808#ifdef CONFIG_MAC80211_HT_DEBUG 885#ifdef CONFIG_MAC80211_HT_DEBUG
809 if (net_ratelimit()) 886 if (net_ratelimit())
810 printk(KERN_DEBUG "AddBA Req with bad params from " 887 printk(KERN_DEBUG "AddBA Req with bad params from "
811 "%s on tid %u. policy %d, buffer size %d\n", 888 "%pM on tid %u. policy %d, buffer size %d\n",
812 print_mac(mac, mgmt->sa), tid, ba_policy, 889 mgmt->sa, tid, ba_policy,
813 buf_size); 890 buf_size);
814#endif /* CONFIG_MAC80211_HT_DEBUG */ 891#endif /* CONFIG_MAC80211_HT_DEBUG */
815 goto end_no_lock; 892 goto end_no_lock;
@@ -820,7 +897,7 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
820 897
821 sband = local->hw.wiphy->bands[conf->channel->band]; 898 sband = local->hw.wiphy->bands[conf->channel->band];
822 buf_size = IEEE80211_MIN_AMPDU_BUF; 899 buf_size = IEEE80211_MIN_AMPDU_BUF;
823 buf_size = buf_size << sband->ht_info.ampdu_factor; 900 buf_size = buf_size << sband->ht_cap.ampdu_factor;
824 } 901 }
825 902
826 903
@@ -831,8 +908,8 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
831#ifdef CONFIG_MAC80211_HT_DEBUG 908#ifdef CONFIG_MAC80211_HT_DEBUG
832 if (net_ratelimit()) 909 if (net_ratelimit())
833 printk(KERN_DEBUG "unexpected AddBA Req from " 910 printk(KERN_DEBUG "unexpected AddBA Req from "
834 "%s on tid %u\n", 911 "%pM on tid %u\n",
835 print_mac(mac, mgmt->sa), tid); 912 mgmt->sa, tid);
836#endif /* CONFIG_MAC80211_HT_DEBUG */ 913#endif /* CONFIG_MAC80211_HT_DEBUG */
837 goto end; 914 goto end;
838 } 915 }
@@ -910,7 +987,7 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local,
910{ 987{
911 struct ieee80211_hw *hw = &local->hw; 988 struct ieee80211_hw *hw = &local->hw;
912 u16 capab; 989 u16 capab;
913 u16 tid; 990 u16 tid, start_seq_num;
914 u8 *state; 991 u8 *state;
915 992
916 capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab); 993 capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab);
@@ -943,9 +1020,18 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local,
943 *state |= HT_ADDBA_RECEIVED_MSK; 1020 *state |= HT_ADDBA_RECEIVED_MSK;
944 sta->ampdu_mlme.addba_req_num[tid] = 0; 1021 sta->ampdu_mlme.addba_req_num[tid] = 0;
945 1022
946 if (*state == HT_AGG_STATE_OPERATIONAL) 1023 if (*state == HT_AGG_STATE_OPERATIONAL &&
1024 local->hw.ampdu_queues)
947 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); 1025 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
948 1026
1027 if (local->ops->ampdu_action) {
1028 (void)local->ops->ampdu_action(hw,
1029 IEEE80211_AMPDU_TX_RESUME,
1030 &sta->sta, tid, &start_seq_num);
1031 }
1032#ifdef CONFIG_MAC80211_HT_DEBUG
1033 printk(KERN_DEBUG "Resuming TX aggregation for tid %d\n", tid);
1034#endif /* CONFIG_MAC80211_HT_DEBUG */
949 spin_unlock_bh(&sta->lock); 1035 spin_unlock_bh(&sta->lock);
950 } else { 1036 } else {
951 sta->ampdu_mlme.addba_req_num[tid]++; 1037 sta->ampdu_mlme.addba_req_num[tid]++;
@@ -964,7 +1050,6 @@ void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
964 struct ieee80211_local *local = sdata->local; 1050 struct ieee80211_local *local = sdata->local;
965 u16 tid, params; 1051 u16 tid, params;
966 u16 initiator; 1052 u16 initiator;
967 DECLARE_MAC_BUF(mac);
968 1053
969 params = le16_to_cpu(mgmt->u.action.u.delba.params); 1054 params = le16_to_cpu(mgmt->u.action.u.delba.params);
970 tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12; 1055 tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12;
@@ -972,9 +1057,8 @@ void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
972 1057
973#ifdef CONFIG_MAC80211_HT_DEBUG 1058#ifdef CONFIG_MAC80211_HT_DEBUG
974 if (net_ratelimit()) 1059 if (net_ratelimit())
975 printk(KERN_DEBUG "delba from %s (%s) tid %d reason code %d\n", 1060 printk(KERN_DEBUG "delba from %pM (%s) tid %d reason code %d\n",
976 print_mac(mac, mgmt->sa), 1061 mgmt->sa, initiator ? "initiator" : "recipient", tid,
977 initiator ? "initiator" : "recipient", tid,
978 mgmt->u.action.u.delba.reason_code); 1062 mgmt->u.action.u.delba.reason_code);
979#endif /* CONFIG_MAC80211_HT_DEBUG */ 1063#endif /* CONFIG_MAC80211_HT_DEBUG */
980 1064
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 156e42a003ae..155a20410017 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -23,6 +23,7 @@
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/etherdevice.h> 25#include <linux/etherdevice.h>
26#include <net/cfg80211.h>
26#include <net/wireless.h> 27#include <net/wireless.h>
27#include <net/iw_handler.h> 28#include <net/iw_handler.h>
28#include <net/mac80211.h> 29#include <net/mac80211.h>
@@ -142,7 +143,6 @@ typedef unsigned __bitwise__ ieee80211_tx_result;
142#define IEEE80211_TX_FRAGMENTED BIT(0) 143#define IEEE80211_TX_FRAGMENTED BIT(0)
143#define IEEE80211_TX_UNICAST BIT(1) 144#define IEEE80211_TX_UNICAST BIT(1)
144#define IEEE80211_TX_PS_BUFFERED BIT(2) 145#define IEEE80211_TX_PS_BUFFERED BIT(2)
145#define IEEE80211_TX_PROBE_LAST_FRAG BIT(3)
146 146
147struct ieee80211_tx_data { 147struct ieee80211_tx_data {
148 struct sk_buff *skb; 148 struct sk_buff *skb;
@@ -153,11 +153,6 @@ struct ieee80211_tx_data {
153 struct ieee80211_key *key; 153 struct ieee80211_key *key;
154 154
155 struct ieee80211_channel *channel; 155 struct ieee80211_channel *channel;
156 s8 rate_idx;
157 /* use this rate (if set) for last fragment; rate can
158 * be set to lower rate for the first fragments, e.g.,
159 * when using CTS protection with IEEE 802.11g. */
160 s8 last_frag_rate_idx;
161 156
162 /* Extra fragments (in addition to the first fragment 157 /* Extra fragments (in addition to the first fragment
163 * in skb) */ 158 * in skb) */
@@ -203,9 +198,7 @@ struct ieee80211_rx_data {
203struct ieee80211_tx_stored_packet { 198struct ieee80211_tx_stored_packet {
204 struct sk_buff *skb; 199 struct sk_buff *skb;
205 struct sk_buff **extra_frag; 200 struct sk_buff **extra_frag;
206 s8 last_frag_rate_idx;
207 int num_extra_frag; 201 int num_extra_frag;
208 bool last_frag_rate_ctrl_probe;
209}; 202};
210 203
211struct beacon_data { 204struct beacon_data {
@@ -219,9 +212,6 @@ struct ieee80211_if_ap {
219 212
220 struct list_head vlans; 213 struct list_head vlans;
221 214
222 u8 ssid[IEEE80211_MAX_SSID_LEN];
223 size_t ssid_len;
224
225 /* yes, this looks ugly, but guarantees that we can later use 215 /* yes, this looks ugly, but guarantees that we can later use
226 * bitmap_empty :) 216 * bitmap_empty :)
227 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */ 217 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
@@ -255,26 +245,6 @@ struct mesh_preq_queue {
255 u8 flags; 245 u8 flags;
256}; 246};
257 247
258struct mesh_config {
259 /* Timeouts in ms */
260 /* Mesh plink management parameters */
261 u16 dot11MeshRetryTimeout;
262 u16 dot11MeshConfirmTimeout;
263 u16 dot11MeshHoldingTimeout;
264 u16 dot11MeshMaxPeerLinks;
265 u8 dot11MeshMaxRetries;
266 u8 dot11MeshTTL;
267 bool auto_open_plinks;
268 /* HWMP parameters */
269 u8 dot11MeshHWMPmaxPREQretries;
270 u32 path_refresh_time;
271 u16 min_discovery_timeout;
272 u32 dot11MeshHWMPactivePathTimeout;
273 u16 dot11MeshHWMPpreqMinInterval;
274 u16 dot11MeshHWMPnetDiameterTraversalTime;
275};
276
277
278/* flags used in struct ieee80211_if_sta.flags */ 248/* flags used in struct ieee80211_if_sta.flags */
279#define IEEE80211_STA_SSID_SET BIT(0) 249#define IEEE80211_STA_SSID_SET BIT(0)
280#define IEEE80211_STA_BSSID_SET BIT(1) 250#define IEEE80211_STA_BSSID_SET BIT(1)
@@ -438,8 +408,7 @@ struct ieee80211_sub_if_data {
438 struct ieee80211_key *keys[NUM_DEFAULT_KEYS]; 408 struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
439 struct ieee80211_key *default_key; 409 struct ieee80211_key *default_key;
440 410
441 /* BSS configuration for this interface. */ 411 u16 sequence_number;
442 struct ieee80211_bss_conf bss_conf;
443 412
444 /* 413 /*
445 * AP this belongs to: self in AP mode and 414 * AP this belongs to: self in AP mode and
@@ -633,8 +602,6 @@ struct ieee80211_local {
633 602
634 int rts_threshold; 603 int rts_threshold;
635 int fragmentation_threshold; 604 int fragmentation_threshold;
636 int short_retry_limit; /* dot11ShortRetryLimit */
637 int long_retry_limit; /* dot11LongRetryLimit */
638 605
639 struct crypto_blkcipher *wep_tx_tfm; 606 struct crypto_blkcipher *wep_tx_tfm;
640 struct crypto_blkcipher *wep_rx_tfm; 607 struct crypto_blkcipher *wep_rx_tfm;
@@ -727,8 +694,6 @@ struct ieee80211_local {
727 struct dentry *rcdir; 694 struct dentry *rcdir;
728 struct dentry *rcname; 695 struct dentry *rcname;
729 struct dentry *frequency; 696 struct dentry *frequency;
730 struct dentry *antenna_sel_tx;
731 struct dentry *antenna_sel_rx;
732 struct dentry *rts_threshold; 697 struct dentry *rts_threshold;
733 struct dentry *fragmentation_threshold; 698 struct dentry *fragmentation_threshold;
734 struct dentry *short_retry_limit; 699 struct dentry *short_retry_limit;
@@ -817,7 +782,7 @@ struct ieee802_11_elems {
817 u8 *wmm_info; 782 u8 *wmm_info;
818 u8 *wmm_param; 783 u8 *wmm_param;
819 struct ieee80211_ht_cap *ht_cap_elem; 784 struct ieee80211_ht_cap *ht_cap_elem;
820 struct ieee80211_ht_addt_info *ht_info_elem; 785 struct ieee80211_ht_info *ht_info_elem;
821 u8 *mesh_config; 786 u8 *mesh_config;
822 u8 *mesh_id; 787 u8 *mesh_id;
823 u8 *peer_link; 788 u8 *peer_link;
@@ -869,11 +834,6 @@ static inline struct ieee80211_hw *local_to_hw(
869 return &local->hw; 834 return &local->hw;
870} 835}
871 836
872struct sta_attribute {
873 struct attribute attr;
874 ssize_t (*show)(const struct sta_info *, char *buf);
875 ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
876};
877 837
878static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) 838static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
879{ 839{
@@ -882,12 +842,9 @@ static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
882} 842}
883 843
884 844
885int ieee80211_hw_config(struct ieee80211_local *local); 845int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
886int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed); 846int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed);
887void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx); 847void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
888u32 ieee80211_handle_ht(struct ieee80211_local *local, int enable_ht,
889 struct ieee80211_ht_info *req_ht_cap,
890 struct ieee80211_ht_bss_info *req_bss_cap);
891void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, 848void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
892 u32 changed); 849 u32 changed);
893void ieee80211_configure_filter(struct ieee80211_local *local); 850void ieee80211_configure_filter(struct ieee80211_local *local);
@@ -968,11 +925,12 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
968int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); 925int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
969 926
970/* HT */ 927/* HT */
971int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie, 928void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband,
972 struct ieee80211_ht_info *ht_info); 929 struct ieee80211_ht_cap *ht_cap_ie,
973int ieee80211_ht_addt_info_ie_to_ht_bss_info( 930 struct ieee80211_sta_ht_cap *ht_cap);
974 struct ieee80211_ht_addt_info *ht_add_info_ie, 931u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
975 struct ieee80211_ht_bss_info *bss_info); 932 struct ieee80211_ht_info *hti,
933 u16 ap_ht_cap_flags);
976void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn); 934void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn);
977 935
978void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da, 936void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 8336fee68d3e..cde145221b61 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -65,7 +65,7 @@ static int ieee80211_open(struct net_device *dev)
65 struct ieee80211_if_init_conf conf; 65 struct ieee80211_if_init_conf conf;
66 u32 changed = 0; 66 u32 changed = 0;
67 int res; 67 int res;
68 bool need_hw_reconfig = 0; 68 u32 hw_reconf_flags = 0;
69 u8 null_addr[ETH_ALEN] = {0}; 69 u8 null_addr[ETH_ALEN] = {0};
70 70
71 /* fail early if user set an invalid address */ 71 /* fail early if user set an invalid address */
@@ -152,7 +152,8 @@ static int ieee80211_open(struct net_device *dev)
152 res = local->ops->start(local_to_hw(local)); 152 res = local->ops->start(local_to_hw(local));
153 if (res) 153 if (res)
154 goto err_del_bss; 154 goto err_del_bss;
155 need_hw_reconfig = 1; 155 /* we're brought up, everything changes */
156 hw_reconf_flags = ~0;
156 ieee80211_led_radio(local, local->hw.conf.radio_enabled); 157 ieee80211_led_radio(local, local->hw.conf.radio_enabled);
157 } 158 }
158 159
@@ -198,8 +199,10 @@ static int ieee80211_open(struct net_device *dev)
198 199
199 /* must be before the call to ieee80211_configure_filter */ 200 /* must be before the call to ieee80211_configure_filter */
200 local->monitors++; 201 local->monitors++;
201 if (local->monitors == 1) 202 if (local->monitors == 1) {
202 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; 203 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
204 hw_reconf_flags |= IEEE80211_CONF_CHANGE_RADIOTAP;
205 }
203 206
204 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL) 207 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
205 local->fif_fcsfail++; 208 local->fif_fcsfail++;
@@ -279,8 +282,8 @@ static int ieee80211_open(struct net_device *dev)
279 atomic_inc(&local->iff_promiscs); 282 atomic_inc(&local->iff_promiscs);
280 283
281 local->open_count++; 284 local->open_count++;
282 if (need_hw_reconfig) { 285 if (hw_reconf_flags) {
283 ieee80211_hw_config(local); 286 ieee80211_hw_config(local, hw_reconf_flags);
284 /* 287 /*
285 * set default queue parameters so drivers don't 288 * set default queue parameters so drivers don't
286 * need to initialise the hardware if the hardware 289 * need to initialise the hardware if the hardware
@@ -322,6 +325,7 @@ static int ieee80211_stop(struct net_device *dev)
322 struct ieee80211_local *local = sdata->local; 325 struct ieee80211_local *local = sdata->local;
323 struct ieee80211_if_init_conf conf; 326 struct ieee80211_if_init_conf conf;
324 struct sta_info *sta; 327 struct sta_info *sta;
328 u32 hw_reconf_flags = 0;
325 329
326 /* 330 /*
327 * Stop TX on this interface first. 331 * Stop TX on this interface first.
@@ -405,8 +409,10 @@ static int ieee80211_stop(struct net_device *dev)
405 } 409 }
406 410
407 local->monitors--; 411 local->monitors--;
408 if (local->monitors == 0) 412 if (local->monitors == 0) {
409 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; 413 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
414 hw_reconf_flags |= IEEE80211_CONF_CHANGE_RADIOTAP;
415 }
410 416
411 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL) 417 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
412 local->fif_fcsfail--; 418 local->fif_fcsfail--;
@@ -504,8 +510,15 @@ static int ieee80211_stop(struct net_device *dev)
504 510
505 tasklet_disable(&local->tx_pending_tasklet); 511 tasklet_disable(&local->tx_pending_tasklet);
506 tasklet_disable(&local->tasklet); 512 tasklet_disable(&local->tasklet);
513
514 /* no reconfiguring after stop! */
515 hw_reconf_flags = 0;
507 } 516 }
508 517
518 /* do after stop to avoid reconfiguring when we stop anyway */
519 if (hw_reconf_flags)
520 ieee80211_hw_config(local, hw_reconf_flags);
521
509 return 0; 522 return 0;
510} 523}
511 524
@@ -682,7 +695,7 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
682 ieee80211_setup_sdata(sdata, type); 695 ieee80211_setup_sdata(sdata, type);
683 696
684 /* reset some values that shouldn't be kept across type changes */ 697 /* reset some values that shouldn't be kept across type changes */
685 sdata->bss_conf.basic_rates = 698 sdata->vif.bss_conf.basic_rates =
686 ieee80211_mandatory_rates(sdata->local, 699 ieee80211_mandatory_rates(sdata->local,
687 sdata->local->hw.conf.channel->band); 700 sdata->local->hw.conf.channel->band);
688 sdata->drop_unencrypted = 0; 701 sdata->drop_unencrypted = 0;
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index a5b06fe71980..999f7aa42326 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -132,7 +132,6 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
132{ 132{
133 const u8 *addr; 133 const u8 *addr;
134 int ret; 134 int ret;
135 DECLARE_MAC_BUF(mac);
136 135
137 assert_key_lock(); 136 assert_key_lock();
138 might_sleep(); 137 might_sleep();
@@ -154,16 +153,15 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
154 153
155 if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP) 154 if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
156 printk(KERN_ERR "mac80211-%s: failed to set key " 155 printk(KERN_ERR "mac80211-%s: failed to set key "
157 "(%d, %s) to hardware (%d)\n", 156 "(%d, %pM) to hardware (%d)\n",
158 wiphy_name(key->local->hw.wiphy), 157 wiphy_name(key->local->hw.wiphy),
159 key->conf.keyidx, print_mac(mac, addr), ret); 158 key->conf.keyidx, addr, ret);
160} 159}
161 160
162static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) 161static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
163{ 162{
164 const u8 *addr; 163 const u8 *addr;
165 int ret; 164 int ret;
166 DECLARE_MAC_BUF(mac);
167 165
168 assert_key_lock(); 166 assert_key_lock();
169 might_sleep(); 167 might_sleep();
@@ -186,9 +184,9 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
186 184
187 if (ret) 185 if (ret)
188 printk(KERN_ERR "mac80211-%s: failed to remove key " 186 printk(KERN_ERR "mac80211-%s: failed to remove key "
189 "(%d, %s) from hardware (%d)\n", 187 "(%d, %pM) from hardware (%d)\n",
190 wiphy_name(key->local->hw.wiphy), 188 wiphy_name(key->local->hw.wiphy),
191 key->conf.keyidx, print_mac(mac, addr), ret); 189 key->conf.keyidx, addr, ret);
192 190
193 spin_lock(&todo_lock); 191 spin_lock(&todo_lock);
194 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 192 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index ae62ad40ad63..d631dc96c323 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -41,6 +41,8 @@
41 */ 41 */
42struct ieee80211_tx_status_rtap_hdr { 42struct ieee80211_tx_status_rtap_hdr {
43 struct ieee80211_radiotap_header hdr; 43 struct ieee80211_radiotap_header hdr;
44 u8 rate;
45 u8 padding_for_rate;
44 __le16 tx_flags; 46 __le16 tx_flags;
45 u8 data_retries; 47 u8 data_retries;
46} __attribute__ ((packed)); 48} __attribute__ ((packed));
@@ -169,19 +171,13 @@ int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed)
169 conf.changed = changed; 171 conf.changed = changed;
170 172
171 if (sdata->vif.type == NL80211_IFTYPE_STATION || 173 if (sdata->vif.type == NL80211_IFTYPE_STATION ||
172 sdata->vif.type == NL80211_IFTYPE_ADHOC) { 174 sdata->vif.type == NL80211_IFTYPE_ADHOC)
173 conf.bssid = sdata->u.sta.bssid; 175 conf.bssid = sdata->u.sta.bssid;
174 conf.ssid = sdata->u.sta.ssid; 176 else if (sdata->vif.type == NL80211_IFTYPE_AP)
175 conf.ssid_len = sdata->u.sta.ssid_len;
176 } else if (sdata->vif.type == NL80211_IFTYPE_AP) {
177 conf.bssid = sdata->dev->dev_addr; 177 conf.bssid = sdata->dev->dev_addr;
178 conf.ssid = sdata->u.ap.ssid; 178 else if (ieee80211_vif_is_mesh(&sdata->vif)) {
179 conf.ssid_len = sdata->u.ap.ssid_len;
180 } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
181 u8 zero[ETH_ALEN] = { 0 }; 179 u8 zero[ETH_ALEN] = { 0 };
182 conf.bssid = zero; 180 conf.bssid = zero;
183 conf.ssid = zero;
184 conf.ssid_len = 0;
185 } else { 181 } else {
186 WARN_ON(1); 182 WARN_ON(1);
187 return -EINVAL; 183 return -EINVAL;
@@ -190,136 +186,48 @@ int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed)
190 if (WARN_ON(!conf.bssid && (changed & IEEE80211_IFCC_BSSID))) 186 if (WARN_ON(!conf.bssid && (changed & IEEE80211_IFCC_BSSID)))
191 return -EINVAL; 187 return -EINVAL;
192 188
193 if (WARN_ON(!conf.ssid && (changed & IEEE80211_IFCC_SSID)))
194 return -EINVAL;
195
196 return local->ops->config_interface(local_to_hw(local), 189 return local->ops->config_interface(local_to_hw(local),
197 &sdata->vif, &conf); 190 &sdata->vif, &conf);
198} 191}
199 192
200int ieee80211_hw_config(struct ieee80211_local *local) 193int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
201{ 194{
202 struct ieee80211_channel *chan; 195 struct ieee80211_channel *chan;
203 int ret = 0; 196 int ret = 0;
197 int power;
198
199 might_sleep();
204 200
205 if (local->sw_scanning) 201 if (local->sw_scanning)
206 chan = local->scan_channel; 202 chan = local->scan_channel;
207 else 203 else
208 chan = local->oper_channel; 204 chan = local->oper_channel;
209 205
210 local->hw.conf.channel = chan; 206 if (chan != local->hw.conf.channel) {
207 local->hw.conf.channel = chan;
208 changed |= IEEE80211_CONF_CHANGE_CHANNEL;
209 }
210
211 211
212 if (!local->hw.conf.power_level) 212 if (!local->hw.conf.power_level)
213 local->hw.conf.power_level = chan->max_power; 213 power = chan->max_power;
214 else 214 else
215 local->hw.conf.power_level = min(chan->max_power, 215 power = min(chan->max_power, local->hw.conf.power_level);
216 local->hw.conf.power_level); 216 if (local->hw.conf.power_level != power) {
217 217 changed |= IEEE80211_CONF_CHANGE_POWER;
218 local->hw.conf.max_antenna_gain = chan->max_antenna_gain; 218 local->hw.conf.power_level = power;
219
220#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
221 printk(KERN_DEBUG "%s: HW CONFIG: freq=%d\n",
222 wiphy_name(local->hw.wiphy), chan->center_freq);
223#endif
224
225 if (local->open_count)
226 ret = local->ops->config(local_to_hw(local), &local->hw.conf);
227
228 return ret;
229}
230
231/**
232 * ieee80211_handle_ht should be used only after legacy configuration
233 * has been determined namely band, as ht configuration depends upon
234 * the hardware's HT abilities for a _specific_ band.
235 */
236u32 ieee80211_handle_ht(struct ieee80211_local *local, int enable_ht,
237 struct ieee80211_ht_info *req_ht_cap,
238 struct ieee80211_ht_bss_info *req_bss_cap)
239{
240 struct ieee80211_conf *conf = &local->hw.conf;
241 struct ieee80211_supported_band *sband;
242 struct ieee80211_ht_info ht_conf;
243 struct ieee80211_ht_bss_info ht_bss_conf;
244 u32 changed = 0;
245 int i;
246 u8 max_tx_streams = IEEE80211_HT_CAP_MAX_STREAMS;
247 u8 tx_mcs_set_cap;
248
249 sband = local->hw.wiphy->bands[conf->channel->band];
250
251 memset(&ht_conf, 0, sizeof(struct ieee80211_ht_info));
252 memset(&ht_bss_conf, 0, sizeof(struct ieee80211_ht_bss_info));
253
254 /* HT is not supported */
255 if (!sband->ht_info.ht_supported) {
256 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
257 goto out;
258 } 219 }
259 220
260 /* disable HT */ 221 if (changed && local->open_count) {
261 if (!enable_ht) { 222 ret = local->ops->config(local_to_hw(local), changed);
262 if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) 223 /*
263 changed |= BSS_CHANGED_HT; 224 * HW reconfiguration should never fail, the driver has told
264 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; 225 * us what it can support so it should live up to that promise.
265 conf->ht_conf.ht_supported = 0; 226 */
266 goto out; 227 WARN_ON(ret);
267 } 228 }
268 229
269 230 return ret;
270 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE))
271 changed |= BSS_CHANGED_HT;
272
273 conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE;
274 ht_conf.ht_supported = 1;
275
276 ht_conf.cap = req_ht_cap->cap & sband->ht_info.cap;
277 ht_conf.cap &= ~(IEEE80211_HT_CAP_SM_PS);
278 ht_conf.cap |= sband->ht_info.cap & IEEE80211_HT_CAP_SM_PS;
279 ht_bss_conf.primary_channel = req_bss_cap->primary_channel;
280 ht_bss_conf.bss_cap = req_bss_cap->bss_cap;
281 ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode;
282
283 ht_conf.ampdu_factor = req_ht_cap->ampdu_factor;
284 ht_conf.ampdu_density = req_ht_cap->ampdu_density;
285
286 /* Bits 96-100 */
287 tx_mcs_set_cap = sband->ht_info.supp_mcs_set[12];
288
289 /* configure suppoerted Tx MCS according to requested MCS
290 * (based in most cases on Rx capabilities of peer) and self
291 * Tx MCS capabilities (as defined by low level driver HW
292 * Tx capabilities) */
293 if (!(tx_mcs_set_cap & IEEE80211_HT_CAP_MCS_TX_DEFINED))
294 goto check_changed;
295
296 /* Counting from 0 therfore + 1 */
297 if (tx_mcs_set_cap & IEEE80211_HT_CAP_MCS_TX_RX_DIFF)
298 max_tx_streams = ((tx_mcs_set_cap &
299 IEEE80211_HT_CAP_MCS_TX_STREAMS) >> 2) + 1;
300
301 for (i = 0; i < max_tx_streams; i++)
302 ht_conf.supp_mcs_set[i] =
303 sband->ht_info.supp_mcs_set[i] &
304 req_ht_cap->supp_mcs_set[i];
305
306 if (tx_mcs_set_cap & IEEE80211_HT_CAP_MCS_TX_UEQM)
307 for (i = IEEE80211_SUPP_MCS_SET_UEQM;
308 i < IEEE80211_SUPP_MCS_SET_LEN; i++)
309 ht_conf.supp_mcs_set[i] =
310 sband->ht_info.supp_mcs_set[i] &
311 req_ht_cap->supp_mcs_set[i];
312
313check_changed:
314 /* if bss configuration changed store the new one */
315 if (memcmp(&conf->ht_conf, &ht_conf, sizeof(ht_conf)) ||
316 memcmp(&conf->ht_bss_conf, &ht_bss_conf, sizeof(ht_bss_conf))) {
317 changed |= BSS_CHANGED_HT;
318 memcpy(&conf->ht_conf, &ht_conf, sizeof(ht_conf));
319 memcpy(&conf->ht_bss_conf, &ht_bss_conf, sizeof(ht_bss_conf));
320 }
321out:
322 return changed;
323} 231}
324 232
325void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, 233void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
@@ -336,15 +244,18 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
336 if (local->ops->bss_info_changed) 244 if (local->ops->bss_info_changed)
337 local->ops->bss_info_changed(local_to_hw(local), 245 local->ops->bss_info_changed(local_to_hw(local),
338 &sdata->vif, 246 &sdata->vif,
339 &sdata->bss_conf, 247 &sdata->vif.bss_conf,
340 changed); 248 changed);
341} 249}
342 250
343u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata) 251u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata)
344{ 252{
345 sdata->bss_conf.use_cts_prot = 0; 253 sdata->vif.bss_conf.use_cts_prot = false;
346 sdata->bss_conf.use_short_preamble = 0; 254 sdata->vif.bss_conf.use_short_preamble = false;
347 return BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_ERP_PREAMBLE; 255 sdata->vif.bss_conf.use_short_slot = false;
256 return BSS_CHANGED_ERP_CTS_PROT |
257 BSS_CHANGED_ERP_PREAMBLE |
258 BSS_CHANGED_ERP_SLOT;
348} 259}
349 260
350void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, 261void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
@@ -466,8 +377,6 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
466 struct sta_info *sta, 377 struct sta_info *sta,
467 struct sk_buff *skb) 378 struct sk_buff *skb)
468{ 379{
469 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
470
471 sta->tx_filtered_count++; 380 sta->tx_filtered_count++;
472 381
473 /* 382 /*
@@ -514,10 +423,9 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
514 return; 423 return;
515 } 424 }
516 425
517 if (!test_sta_flags(sta, WLAN_STA_PS) && 426 if (!test_sta_flags(sta, WLAN_STA_PS) && !skb->requeue) {
518 !(info->flags & IEEE80211_TX_CTL_REQUEUE)) {
519 /* Software retry the packet once */ 427 /* Software retry the packet once */
520 info->flags |= IEEE80211_TX_CTL_REQUEUE; 428 skb->requeue = 1;
521 ieee80211_remove_tx_extra(local, sta->key, skb); 429 ieee80211_remove_tx_extra(local, sta->key, skb);
522 dev_queue_xmit(skb); 430 dev_queue_xmit(skb);
523 return; 431 return;
@@ -547,13 +455,28 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
547 struct ieee80211_sub_if_data *sdata; 455 struct ieee80211_sub_if_data *sdata;
548 struct net_device *prev_dev = NULL; 456 struct net_device *prev_dev = NULL;
549 struct sta_info *sta; 457 struct sta_info *sta;
458 int retry_count = -1, i;
459
460 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
461 /* the HW cannot have attempted that rate */
462 if (i >= hw->max_rates) {
463 info->status.rates[i].idx = -1;
464 info->status.rates[i].count = 0;
465 }
466
467 retry_count += info->status.rates[i].count;
468 }
469 if (retry_count < 0)
470 retry_count = 0;
550 471
551 rcu_read_lock(); 472 rcu_read_lock();
552 473
474 sband = local->hw.wiphy->bands[info->band];
475
553 sta = sta_info_get(local, hdr->addr1); 476 sta = sta_info_get(local, hdr->addr1);
554 477
555 if (sta) { 478 if (sta) {
556 if (info->status.excessive_retries && 479 if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
557 test_sta_flags(sta, WLAN_STA_PS)) { 480 test_sta_flags(sta, WLAN_STA_PS)) {
558 /* 481 /*
559 * The STA is in power save mode, so assume 482 * The STA is in power save mode, so assume
@@ -584,12 +507,11 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
584 rcu_read_unlock(); 507 rcu_read_unlock();
585 return; 508 return;
586 } else { 509 } else {
587 if (info->status.excessive_retries) 510 if (!(info->flags & IEEE80211_TX_STAT_ACK))
588 sta->tx_retry_failed++; 511 sta->tx_retry_failed++;
589 sta->tx_retry_count += info->status.retry_count; 512 sta->tx_retry_count += retry_count;
590 } 513 }
591 514
592 sband = local->hw.wiphy->bands[info->band];
593 rate_control_tx_status(local, sband, sta, skb); 515 rate_control_tx_status(local, sband, sta, skb);
594 } 516 }
595 517
@@ -610,9 +532,9 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
610 local->dot11TransmittedFrameCount++; 532 local->dot11TransmittedFrameCount++;
611 if (is_multicast_ether_addr(hdr->addr1)) 533 if (is_multicast_ether_addr(hdr->addr1))
612 local->dot11MulticastTransmittedFrameCount++; 534 local->dot11MulticastTransmittedFrameCount++;
613 if (info->status.retry_count > 0) 535 if (retry_count > 0)
614 local->dot11RetryCount++; 536 local->dot11RetryCount++;
615 if (info->status.retry_count > 1) 537 if (retry_count > 1)
616 local->dot11MultipleRetryCount++; 538 local->dot11MultipleRetryCount++;
617 } 539 }
618 540
@@ -656,19 +578,30 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
656 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr)); 578 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
657 rthdr->hdr.it_present = 579 rthdr->hdr.it_present =
658 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) | 580 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
659 (1 << IEEE80211_RADIOTAP_DATA_RETRIES)); 581 (1 << IEEE80211_RADIOTAP_DATA_RETRIES) |
582 (1 << IEEE80211_RADIOTAP_RATE));
660 583
661 if (!(info->flags & IEEE80211_TX_STAT_ACK) && 584 if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
662 !is_multicast_ether_addr(hdr->addr1)) 585 !is_multicast_ether_addr(hdr->addr1))
663 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL); 586 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
664 587
665 if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) && 588 /*
666 (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) 589 * XXX: Once radiotap gets the bitmap reset thing the vendor
590 * extensions proposal contains, we can actually report
591 * the whole set of tries we did.
592 */
593 if ((info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
594 (info->status.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
667 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS); 595 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS);
668 else if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) 596 else if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
669 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS); 597 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS);
598 if (info->status.rates[0].idx >= 0 &&
599 !(info->status.rates[0].flags & IEEE80211_TX_RC_MCS))
600 rthdr->rate = sband->bitrates[
601 info->status.rates[0].idx].bitrate / 5;
670 602
671 rthdr->data_retries = info->status.retry_count; 603 /* for now report the total retry_count */
604 rthdr->data_retries = retry_count;
672 605
673 /* XXX: is this sufficient for BPF? */ 606 /* XXX: is this sufficient for BPF? */
674 skb_set_mac_header(skb, 0); 607 skb_set_mac_header(skb, 0);
@@ -753,13 +686,14 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
753 BUG_ON(!ops->configure_filter); 686 BUG_ON(!ops->configure_filter);
754 local->ops = ops; 687 local->ops = ops;
755 688
756 local->hw.queues = 1; /* default */ 689 /* set up some defaults */
757 690 local->hw.queues = 1;
691 local->hw.max_rates = 1;
758 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; 692 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
759 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD; 693 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
760 local->short_retry_limit = 7; 694 local->hw.conf.long_frame_max_tx_count = 4;
761 local->long_retry_limit = 4; 695 local->hw.conf.short_frame_max_tx_count = 7;
762 local->hw.conf.radio_enabled = 1; 696 local->hw.conf.radio_enabled = true;
763 697
764 INIT_LIST_HEAD(&local->interfaces); 698 INIT_LIST_HEAD(&local->interfaces);
765 699
@@ -1013,7 +947,7 @@ static int __init ieee80211_init(void)
1013 947
1014 BUILD_BUG_ON(sizeof(struct ieee80211_tx_info) > sizeof(skb->cb)); 948 BUILD_BUG_ON(sizeof(struct ieee80211_tx_info) > sizeof(skb->cb));
1015 BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, driver_data) + 949 BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, driver_data) +
1016 IEEE80211_TX_INFO_DRIVER_DATA_SIZE > sizeof(skb->cb)); 950 IEEE80211_TX_INFO_DRIVER_DATA_SIZE > sizeof(skb->cb));
1017 951
1018 ret = rc80211_minstrel_init(); 952 ret = rc80211_minstrel_init();
1019 if (ret) 953 if (ret)
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 8013277924f2..82f568e94365 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -238,7 +238,7 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
238 238
239 pos = skb_put(skb, 21); 239 pos = skb_put(skb, 21);
240 *pos++ = WLAN_EID_MESH_CONFIG; 240 *pos++ = WLAN_EID_MESH_CONFIG;
241 *pos++ = MESH_CFG_LEN; 241 *pos++ = IEEE80211_MESH_CONFIG_LEN;
242 /* Version */ 242 /* Version */
243 *pos++ = 1; 243 *pos++ = 1;
244 244
@@ -473,7 +473,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
473 size_t len, 473 size_t len,
474 struct ieee80211_rx_status *rx_status) 474 struct ieee80211_rx_status *rx_status)
475{ 475{
476 struct ieee80211_local *local= sdata->local; 476 struct ieee80211_local *local = sdata->local;
477 struct ieee802_11_elems elems; 477 struct ieee802_11_elems elems;
478 struct ieee80211_channel *channel; 478 struct ieee80211_channel *channel;
479 u64 supp_rates = 0; 479 u64 supp_rates = 0;
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index e10471c6ba42..c197ab545e54 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -145,9 +145,6 @@ struct mesh_rmc {
145}; 145};
146 146
147 147
148/* Mesh IEs constants */
149#define MESH_CFG_LEN 19
150
151/* 148/*
152 * MESH_CFG_COMP_LEN Includes: 149 * MESH_CFG_COMP_LEN Includes:
153 * - Active path selection protocol ID. 150 * - Active path selection protocol ID.
@@ -157,7 +154,7 @@ struct mesh_rmc {
157 * Does not include mesh capabilities, which may vary across nodes in the same 154 * Does not include mesh capabilities, which may vary across nodes in the same
158 * mesh 155 * mesh
159 */ 156 */
160#define MESH_CFG_CMP_LEN 17 157#define MESH_CFG_CMP_LEN (IEEE80211_MESH_CONFIG_LEN - 2)
161 158
162/* Default values, timeouts in ms */ 159/* Default values, timeouts in ms */
163#define MESH_TTL 5 160#define MESH_TTL 5
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 501c7831adb4..e8d573d592e7 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -218,12 +218,16 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
218 218
219 if (sta->fail_avg >= 100) 219 if (sta->fail_avg >= 100)
220 return MAX_METRIC; 220 return MAX_METRIC;
221
222 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
223 return MAX_METRIC;
224
221 err = (sta->fail_avg << ARITH_SHIFT) / 100; 225 err = (sta->fail_avg << ARITH_SHIFT) / 100;
222 226
223 /* bitrate is in units of 100 Kbps, while we need rate in units of 227 /* bitrate is in units of 100 Kbps, while we need rate in units of
224 * 1Mbps. This will be corrected on tx_time computation. 228 * 1Mbps. This will be corrected on tx_time computation.
225 */ 229 */
226 rate = sband->bitrates[sta->last_txrate_idx].bitrate; 230 rate = sband->bitrates[sta->last_tx_rate.idx].bitrate;
227 tx_time = (device_constant + 10 * test_frame_len / rate); 231 tx_time = (device_constant + 10 * test_frame_len / rate);
228 estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err)); 232 estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err));
229 result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ; 233 result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ;
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index faac101c0f85..929ba542fd72 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -257,9 +257,6 @@ static void mesh_plink_timer(unsigned long data)
257 struct sta_info *sta; 257 struct sta_info *sta;
258 __le16 llid, plid, reason; 258 __le16 llid, plid, reason;
259 struct ieee80211_sub_if_data *sdata; 259 struct ieee80211_sub_if_data *sdata;
260#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
261 DECLARE_MAC_BUF(mac);
262#endif
263 260
264 /* 261 /*
265 * This STA is valid because sta_info_destroy() will 262 * This STA is valid because sta_info_destroy() will
@@ -274,8 +271,8 @@ static void mesh_plink_timer(unsigned long data)
274 spin_unlock_bh(&sta->lock); 271 spin_unlock_bh(&sta->lock);
275 return; 272 return;
276 } 273 }
277 mpl_dbg("Mesh plink timer for %s fired on state %d\n", 274 mpl_dbg("Mesh plink timer for %pM fired on state %d\n",
278 print_mac(mac, sta->sta.addr), sta->plink_state); 275 sta->sta.addr, sta->plink_state);
279 reason = 0; 276 reason = 0;
280 llid = sta->llid; 277 llid = sta->llid;
281 plid = sta->plid; 278 plid = sta->plid;
@@ -287,9 +284,9 @@ static void mesh_plink_timer(unsigned long data)
287 /* retry timer */ 284 /* retry timer */
288 if (sta->plink_retries < dot11MeshMaxRetries(sdata)) { 285 if (sta->plink_retries < dot11MeshMaxRetries(sdata)) {
289 u32 rand; 286 u32 rand;
290 mpl_dbg("Mesh plink for %s (retry, timeout): %d %d\n", 287 mpl_dbg("Mesh plink for %pM (retry, timeout): %d %d\n",
291 print_mac(mac, sta->sta.addr), 288 sta->sta.addr, sta->plink_retries,
292 sta->plink_retries, sta->plink_timeout); 289 sta->plink_timeout);
293 get_random_bytes(&rand, sizeof(u32)); 290 get_random_bytes(&rand, sizeof(u32));
294 sta->plink_timeout = sta->plink_timeout + 291 sta->plink_timeout = sta->plink_timeout +
295 rand % sta->plink_timeout; 292 rand % sta->plink_timeout;
@@ -337,9 +334,6 @@ int mesh_plink_open(struct sta_info *sta)
337{ 334{
338 __le16 llid; 335 __le16 llid;
339 struct ieee80211_sub_if_data *sdata = sta->sdata; 336 struct ieee80211_sub_if_data *sdata = sta->sdata;
340#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
341 DECLARE_MAC_BUF(mac);
342#endif
343 337
344 spin_lock_bh(&sta->lock); 338 spin_lock_bh(&sta->lock);
345 get_random_bytes(&llid, 2); 339 get_random_bytes(&llid, 2);
@@ -351,8 +345,8 @@ int mesh_plink_open(struct sta_info *sta)
351 sta->plink_state = PLINK_OPN_SNT; 345 sta->plink_state = PLINK_OPN_SNT;
352 mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata)); 346 mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
353 spin_unlock_bh(&sta->lock); 347 spin_unlock_bh(&sta->lock);
354 mpl_dbg("Mesh plink: starting establishment with %s\n", 348 mpl_dbg("Mesh plink: starting establishment with %pM\n",
355 print_mac(mac, sta->sta.addr)); 349 sta->sta.addr);
356 350
357 return mesh_plink_frame_tx(sdata, PLINK_OPEN, 351 return mesh_plink_frame_tx(sdata, PLINK_OPEN,
358 sta->sta.addr, llid, 0, 0); 352 sta->sta.addr, llid, 0, 0);
@@ -360,10 +354,6 @@ int mesh_plink_open(struct sta_info *sta)
360 354
361void mesh_plink_block(struct sta_info *sta) 355void mesh_plink_block(struct sta_info *sta)
362{ 356{
363#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
364 DECLARE_MAC_BUF(mac);
365#endif
366
367 spin_lock_bh(&sta->lock); 357 spin_lock_bh(&sta->lock);
368 __mesh_plink_deactivate(sta); 358 __mesh_plink_deactivate(sta);
369 sta->plink_state = PLINK_BLOCKED; 359 sta->plink_state = PLINK_BLOCKED;
@@ -374,12 +364,8 @@ int mesh_plink_close(struct sta_info *sta)
374{ 364{
375 struct ieee80211_sub_if_data *sdata = sta->sdata; 365 struct ieee80211_sub_if_data *sdata = sta->sdata;
376 __le16 llid, plid, reason; 366 __le16 llid, plid, reason;
377#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
378 DECLARE_MAC_BUF(mac);
379#endif
380 367
381 mpl_dbg("Mesh plink: closing link with %s\n", 368 mpl_dbg("Mesh plink: closing link with %pM\n", sta->sta.addr);
382 print_mac(mac, sta->sta.addr));
383 spin_lock_bh(&sta->lock); 369 spin_lock_bh(&sta->lock);
384 sta->reason = cpu_to_le16(MESH_LINK_CANCELLED); 370 sta->reason = cpu_to_le16(MESH_LINK_CANCELLED);
385 reason = sta->reason; 371 reason = sta->reason;
@@ -417,9 +403,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
417 u8 ie_len; 403 u8 ie_len;
418 u8 *baseaddr; 404 u8 *baseaddr;
419 __le16 plid, llid, reason; 405 __le16 plid, llid, reason;
420#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
421 DECLARE_MAC_BUF(mac);
422#endif
423 406
424 /* need action_code, aux */ 407 /* need action_code, aux */
425 if (len < IEEE80211_MIN_ACTION_SIZE + 3) 408 if (len < IEEE80211_MIN_ACTION_SIZE + 3)
@@ -557,10 +540,10 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
557 } 540 }
558 } 541 }
559 542
560 mpl_dbg("Mesh plink (peer, state, llid, plid, event): %s %d %d %d %d\n", 543 mpl_dbg("Mesh plink (peer, state, llid, plid, event): %pM %d %d %d %d\n",
561 print_mac(mac, mgmt->sa), sta->plink_state, 544 mgmt->sa, sta->plink_state,
562 le16_to_cpu(sta->llid), le16_to_cpu(sta->plid), 545 le16_to_cpu(sta->llid), le16_to_cpu(sta->plid),
563 event); 546 event);
564 reason = 0; 547 reason = 0;
565 switch (sta->plink_state) { 548 switch (sta->plink_state) {
566 /* spin_unlock as soon as state is updated at each case */ 549 /* spin_unlock as soon as state is updated at each case */
@@ -660,8 +643,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
660 sta->plink_state = PLINK_ESTAB; 643 sta->plink_state = PLINK_ESTAB;
661 mesh_plink_inc_estab_count(sdata); 644 mesh_plink_inc_estab_count(sdata);
662 spin_unlock_bh(&sta->lock); 645 spin_unlock_bh(&sta->lock);
663 mpl_dbg("Mesh plink with %s ESTABLISHED\n", 646 mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
664 print_mac(mac, sta->sta.addr)); 647 sta->sta.addr);
665 break; 648 break;
666 default: 649 default:
667 spin_unlock_bh(&sta->lock); 650 spin_unlock_bh(&sta->lock);
@@ -693,8 +676,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
693 sta->plink_state = PLINK_ESTAB; 676 sta->plink_state = PLINK_ESTAB;
694 mesh_plink_inc_estab_count(sdata); 677 mesh_plink_inc_estab_count(sdata);
695 spin_unlock_bh(&sta->lock); 678 spin_unlock_bh(&sta->lock);
696 mpl_dbg("Mesh plink with %s ESTABLISHED\n", 679 mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
697 print_mac(mac, sta->sta.addr)); 680 sta->sta.addr);
698 mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid, 681 mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
699 plid, 0); 682 plid, 0);
700 break; 683 break;
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 409bb7716236..4d76bf25bada 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -236,7 +236,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
236 struct ieee80211_local *local = sdata->local; 236 struct ieee80211_local *local = sdata->local;
237 struct sk_buff *skb; 237 struct sk_buff *skb;
238 struct ieee80211_mgmt *mgmt; 238 struct ieee80211_mgmt *mgmt;
239 u8 *pos, *ies, *ht_add_ie; 239 u8 *pos, *ies, *ht_ie;
240 int i, len, count, rates_len, supp_rates_len; 240 int i, len, count, rates_len, supp_rates_len;
241 u16 capab; 241 u16 capab;
242 struct ieee80211_bss *bss; 242 struct ieee80211_bss *bss;
@@ -393,24 +393,25 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
393 393
394 /* wmm support is a must to HT */ 394 /* wmm support is a must to HT */
395 if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED) && 395 if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED) &&
396 sband->ht_info.ht_supported && 396 sband->ht_cap.ht_supported &&
397 (ht_add_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_EXTRA_INFO))) { 397 (ht_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_INFORMATION)) &&
398 struct ieee80211_ht_addt_info *ht_add_info = 398 ht_ie[1] >= sizeof(struct ieee80211_ht_info)) {
399 (struct ieee80211_ht_addt_info *)ht_add_ie; 399 struct ieee80211_ht_info *ht_info =
400 u16 cap = sband->ht_info.cap; 400 (struct ieee80211_ht_info *)(ht_ie + 2);
401 u16 cap = sband->ht_cap.cap;
401 __le16 tmp; 402 __le16 tmp;
402 u32 flags = local->hw.conf.channel->flags; 403 u32 flags = local->hw.conf.channel->flags;
403 404
404 switch (ht_add_info->ht_param & IEEE80211_HT_IE_CHA_SEC_OFFSET) { 405 switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
405 case IEEE80211_HT_IE_CHA_SEC_ABOVE: 406 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
406 if (flags & IEEE80211_CHAN_NO_FAT_ABOVE) { 407 if (flags & IEEE80211_CHAN_NO_FAT_ABOVE) {
407 cap &= ~IEEE80211_HT_CAP_SUP_WIDTH; 408 cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
408 cap &= ~IEEE80211_HT_CAP_SGI_40; 409 cap &= ~IEEE80211_HT_CAP_SGI_40;
409 } 410 }
410 break; 411 break;
411 case IEEE80211_HT_IE_CHA_SEC_BELOW: 412 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
412 if (flags & IEEE80211_CHAN_NO_FAT_BELOW) { 413 if (flags & IEEE80211_CHAN_NO_FAT_BELOW) {
413 cap &= ~IEEE80211_HT_CAP_SUP_WIDTH; 414 cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
414 cap &= ~IEEE80211_HT_CAP_SGI_40; 415 cap &= ~IEEE80211_HT_CAP_SGI_40;
415 } 416 }
416 break; 417 break;
@@ -424,9 +425,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
424 memcpy(pos, &tmp, sizeof(u16)); 425 memcpy(pos, &tmp, sizeof(u16));
425 pos += sizeof(u16); 426 pos += sizeof(u16);
426 /* TODO: needs a define here for << 2 */ 427 /* TODO: needs a define here for << 2 */
427 *pos++ = sband->ht_info.ampdu_factor | 428 *pos++ = sband->ht_cap.ampdu_factor |
428 (sband->ht_info.ampdu_density << 2); 429 (sband->ht_cap.ampdu_density << 2);
429 memcpy(pos, sband->ht_info.supp_mcs_set, 16); 430 memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs));
430 } 431 }
431 432
432 kfree(ifsta->assocreq_ies); 433 kfree(ifsta->assocreq_ies);
@@ -568,25 +569,35 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
568 } 569 }
569} 570}
570 571
571static u32 ieee80211_handle_protect_preamb(struct ieee80211_sub_if_data *sdata, 572static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
572 bool use_protection, 573 u16 capab, bool erp_valid, u8 erp)
573 bool use_short_preamble)
574{ 574{
575 struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf; 575 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
576#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 576#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
577 struct ieee80211_if_sta *ifsta = &sdata->u.sta; 577 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
578 DECLARE_MAC_BUF(mac);
579#endif 578#endif
580 u32 changed = 0; 579 u32 changed = 0;
580 bool use_protection;
581 bool use_short_preamble;
582 bool use_short_slot;
583
584 if (erp_valid) {
585 use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0;
586 use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0;
587 } else {
588 use_protection = false;
589 use_short_preamble = !!(capab & WLAN_CAPABILITY_SHORT_PREAMBLE);
590 }
591
592 use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
581 593
582 if (use_protection != bss_conf->use_cts_prot) { 594 if (use_protection != bss_conf->use_cts_prot) {
583#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 595#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
584 if (net_ratelimit()) { 596 if (net_ratelimit()) {
585 printk(KERN_DEBUG "%s: CTS protection %s (BSSID=" 597 printk(KERN_DEBUG "%s: CTS protection %s (BSSID=%pM)\n",
586 "%s)\n",
587 sdata->dev->name, 598 sdata->dev->name,
588 use_protection ? "enabled" : "disabled", 599 use_protection ? "enabled" : "disabled",
589 print_mac(mac, ifsta->bssid)); 600 ifsta->bssid);
590 } 601 }
591#endif 602#endif
592 bss_conf->use_cts_prot = use_protection; 603 bss_conf->use_cts_prot = use_protection;
@@ -597,40 +608,28 @@ static u32 ieee80211_handle_protect_preamb(struct ieee80211_sub_if_data *sdata,
597#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 608#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
598 if (net_ratelimit()) { 609 if (net_ratelimit()) {
599 printk(KERN_DEBUG "%s: switched to %s barker preamble" 610 printk(KERN_DEBUG "%s: switched to %s barker preamble"
600 " (BSSID=%s)\n", 611 " (BSSID=%pM)\n",
601 sdata->dev->name, 612 sdata->dev->name,
602 use_short_preamble ? "short" : "long", 613 use_short_preamble ? "short" : "long",
603 print_mac(mac, ifsta->bssid)); 614 ifsta->bssid);
604 } 615 }
605#endif 616#endif
606 bss_conf->use_short_preamble = use_short_preamble; 617 bss_conf->use_short_preamble = use_short_preamble;
607 changed |= BSS_CHANGED_ERP_PREAMBLE; 618 changed |= BSS_CHANGED_ERP_PREAMBLE;
608 } 619 }
609 620
610 return changed; 621 if (use_short_slot != bss_conf->use_short_slot) {
611} 622#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
612 623 if (net_ratelimit()) {
613static u32 ieee80211_handle_erp_ie(struct ieee80211_sub_if_data *sdata, 624 printk(KERN_DEBUG "%s: switched to %s slot"
614 u8 erp_value) 625 " (BSSID=%s)\n",
615{ 626 sdata->dev->name,
616 bool use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0; 627 use_short_slot ? "short" : "long",
617 bool use_short_preamble = (erp_value & WLAN_ERP_BARKER_PREAMBLE) == 0; 628 ifsta->bssid);
618 629 }
619 return ieee80211_handle_protect_preamb(sdata, 630#endif
620 use_protection, use_short_preamble); 631 bss_conf->use_short_slot = use_short_slot;
621} 632 changed |= BSS_CHANGED_ERP_SLOT;
622
623static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
624 struct ieee80211_bss *bss)
625{
626 u32 changed = 0;
627
628 if (bss->has_erp_value)
629 changed |= ieee80211_handle_erp_ie(sdata, bss->erp_value);
630 else {
631 u16 capab = bss->capability;
632 changed |= ieee80211_handle_protect_preamb(sdata, false,
633 (capab & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0);
634 } 633 }
635 634
636 return changed; 635 return changed;
@@ -701,14 +700,15 @@ static void ieee80211_sta_send_associnfo(struct ieee80211_sub_if_data *sdata,
701 700
702 701
703static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, 702static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
704 struct ieee80211_if_sta *ifsta) 703 struct ieee80211_if_sta *ifsta,
704 u32 bss_info_changed)
705{ 705{
706 struct ieee80211_local *local = sdata->local; 706 struct ieee80211_local *local = sdata->local;
707 struct ieee80211_conf *conf = &local_to_hw(local)->conf; 707 struct ieee80211_conf *conf = &local_to_hw(local)->conf;
708 u32 changed = BSS_CHANGED_ASSOC;
709 708
710 struct ieee80211_bss *bss; 709 struct ieee80211_bss *bss;
711 710
711 bss_info_changed |= BSS_CHANGED_ASSOC;
712 ifsta->flags |= IEEE80211_STA_ASSOCIATED; 712 ifsta->flags |= IEEE80211_STA_ASSOCIATED;
713 713
714 if (sdata->vif.type != NL80211_IFTYPE_STATION) 714 if (sdata->vif.type != NL80211_IFTYPE_STATION)
@@ -719,22 +719,16 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
719 ifsta->ssid, ifsta->ssid_len); 719 ifsta->ssid, ifsta->ssid_len);
720 if (bss) { 720 if (bss) {
721 /* set timing information */ 721 /* set timing information */
722 sdata->bss_conf.beacon_int = bss->beacon_int; 722 sdata->vif.bss_conf.beacon_int = bss->beacon_int;
723 sdata->bss_conf.timestamp = bss->timestamp; 723 sdata->vif.bss_conf.timestamp = bss->timestamp;
724 sdata->bss_conf.dtim_period = bss->dtim_period; 724 sdata->vif.bss_conf.dtim_period = bss->dtim_period;
725 725
726 changed |= ieee80211_handle_bss_capability(sdata, bss); 726 bss_info_changed |= ieee80211_handle_bss_capability(sdata,
727 bss->capability, bss->has_erp_value, bss->erp_value);
727 728
728 ieee80211_rx_bss_put(local, bss); 729 ieee80211_rx_bss_put(local, bss);
729 } 730 }
730 731
731 if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
732 changed |= BSS_CHANGED_HT;
733 sdata->bss_conf.assoc_ht = 1;
734 sdata->bss_conf.ht_conf = &conf->ht_conf;
735 sdata->bss_conf.ht_bss_conf = &conf->ht_bss_conf;
736 }
737
738 ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET; 732 ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET;
739 memcpy(ifsta->prev_bssid, sdata->u.sta.bssid, ETH_ALEN); 733 memcpy(ifsta->prev_bssid, sdata->u.sta.bssid, ETH_ALEN);
740 ieee80211_sta_send_associnfo(sdata, ifsta); 734 ieee80211_sta_send_associnfo(sdata, ifsta);
@@ -742,14 +736,14 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
742 ifsta->last_probe = jiffies; 736 ifsta->last_probe = jiffies;
743 ieee80211_led_assoc(local, 1); 737 ieee80211_led_assoc(local, 1);
744 738
745 sdata->bss_conf.assoc = 1; 739 sdata->vif.bss_conf.assoc = 1;
746 /* 740 /*
747 * For now just always ask the driver to update the basic rateset 741 * For now just always ask the driver to update the basic rateset
748 * when we have associated, we aren't checking whether it actually 742 * when we have associated, we aren't checking whether it actually
749 * changed or not. 743 * changed or not.
750 */ 744 */
751 changed |= BSS_CHANGED_BASIC_RATES; 745 bss_info_changed |= BSS_CHANGED_BASIC_RATES;
752 ieee80211_bss_info_change_notify(sdata, changed); 746 ieee80211_bss_info_change_notify(sdata, bss_info_changed);
753 747
754 netif_tx_start_all_queues(sdata->dev); 748 netif_tx_start_all_queues(sdata->dev);
755 netif_carrier_on(sdata->dev); 749 netif_carrier_on(sdata->dev);
@@ -760,18 +754,17 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
760static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata, 754static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata,
761 struct ieee80211_if_sta *ifsta) 755 struct ieee80211_if_sta *ifsta)
762{ 756{
763 DECLARE_MAC_BUF(mac);
764
765 ifsta->direct_probe_tries++; 757 ifsta->direct_probe_tries++;
766 if (ifsta->direct_probe_tries > IEEE80211_AUTH_MAX_TRIES) { 758 if (ifsta->direct_probe_tries > IEEE80211_AUTH_MAX_TRIES) {
767 printk(KERN_DEBUG "%s: direct probe to AP %s timed out\n", 759 printk(KERN_DEBUG "%s: direct probe to AP %pM timed out\n",
768 sdata->dev->name, print_mac(mac, ifsta->bssid)); 760 sdata->dev->name, ifsta->bssid);
769 ifsta->state = IEEE80211_STA_MLME_DISABLED; 761 ifsta->state = IEEE80211_STA_MLME_DISABLED;
762 ieee80211_sta_send_apinfo(sdata, ifsta);
770 return; 763 return;
771 } 764 }
772 765
773 printk(KERN_DEBUG "%s: direct probe to AP %s try %d\n", 766 printk(KERN_DEBUG "%s: direct probe to AP %pM try %d\n",
774 sdata->dev->name, print_mac(mac, ifsta->bssid), 767 sdata->dev->name, ifsta->bssid,
775 ifsta->direct_probe_tries); 768 ifsta->direct_probe_tries);
776 769
777 ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE; 770 ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE;
@@ -791,20 +784,19 @@ static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata,
791static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata, 784static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata,
792 struct ieee80211_if_sta *ifsta) 785 struct ieee80211_if_sta *ifsta)
793{ 786{
794 DECLARE_MAC_BUF(mac);
795
796 ifsta->auth_tries++; 787 ifsta->auth_tries++;
797 if (ifsta->auth_tries > IEEE80211_AUTH_MAX_TRIES) { 788 if (ifsta->auth_tries > IEEE80211_AUTH_MAX_TRIES) {
798 printk(KERN_DEBUG "%s: authentication with AP %s" 789 printk(KERN_DEBUG "%s: authentication with AP %pM"
799 " timed out\n", 790 " timed out\n",
800 sdata->dev->name, print_mac(mac, ifsta->bssid)); 791 sdata->dev->name, ifsta->bssid);
801 ifsta->state = IEEE80211_STA_MLME_DISABLED; 792 ifsta->state = IEEE80211_STA_MLME_DISABLED;
793 ieee80211_sta_send_apinfo(sdata, ifsta);
802 return; 794 return;
803 } 795 }
804 796
805 ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; 797 ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE;
806 printk(KERN_DEBUG "%s: authenticate with AP %s\n", 798 printk(KERN_DEBUG "%s: authenticate with AP %pM\n",
807 sdata->dev->name, print_mac(mac, ifsta->bssid)); 799 sdata->dev->name, ifsta->bssid);
808 800
809 ieee80211_send_auth(sdata, ifsta, 1, NULL, 0, 0); 801 ieee80211_send_auth(sdata, ifsta, 1, NULL, 0, 0);
810 802
@@ -817,7 +809,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
817{ 809{
818 struct ieee80211_local *local = sdata->local; 810 struct ieee80211_local *local = sdata->local;
819 struct sta_info *sta; 811 struct sta_info *sta;
820 u32 changed = BSS_CHANGED_ASSOC; 812 u32 changed = 0;
821 813
822 rcu_read_lock(); 814 rcu_read_lock();
823 815
@@ -851,15 +843,9 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
851 ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; 843 ifsta->flags &= ~IEEE80211_STA_ASSOCIATED;
852 changed |= ieee80211_reset_erp_info(sdata); 844 changed |= ieee80211_reset_erp_info(sdata);
853 845
854 if (sdata->bss_conf.assoc_ht)
855 changed |= BSS_CHANGED_HT;
856
857 sdata->bss_conf.assoc_ht = 0;
858 sdata->bss_conf.ht_conf = NULL;
859 sdata->bss_conf.ht_bss_conf = NULL;
860
861 ieee80211_led_assoc(local, 0); 846 ieee80211_led_assoc(local, 0);
862 sdata->bss_conf.assoc = 0; 847 changed |= BSS_CHANGED_ASSOC;
848 sdata->vif.bss_conf.assoc = false;
863 849
864 ieee80211_sta_send_apinfo(sdata, ifsta); 850 ieee80211_sta_send_apinfo(sdata, ifsta);
865 851
@@ -871,6 +857,11 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
871 rcu_read_unlock(); 857 rcu_read_unlock();
872 858
873 sta_info_destroy(sta); 859 sta_info_destroy(sta);
860
861 local->hw.conf.ht.enabled = false;
862 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_HT);
863
864 ieee80211_bss_info_change_notify(sdata, changed);
874} 865}
875 866
876static int ieee80211_sta_wep_configured(struct ieee80211_sub_if_data *sdata) 867static int ieee80211_sta_wep_configured(struct ieee80211_sub_if_data *sdata)
@@ -914,20 +905,19 @@ static int ieee80211_privacy_mismatch(struct ieee80211_sub_if_data *sdata,
914static void ieee80211_associate(struct ieee80211_sub_if_data *sdata, 905static void ieee80211_associate(struct ieee80211_sub_if_data *sdata,
915 struct ieee80211_if_sta *ifsta) 906 struct ieee80211_if_sta *ifsta)
916{ 907{
917 DECLARE_MAC_BUF(mac);
918
919 ifsta->assoc_tries++; 908 ifsta->assoc_tries++;
920 if (ifsta->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) { 909 if (ifsta->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) {
921 printk(KERN_DEBUG "%s: association with AP %s" 910 printk(KERN_DEBUG "%s: association with AP %pM"
922 " timed out\n", 911 " timed out\n",
923 sdata->dev->name, print_mac(mac, ifsta->bssid)); 912 sdata->dev->name, ifsta->bssid);
924 ifsta->state = IEEE80211_STA_MLME_DISABLED; 913 ifsta->state = IEEE80211_STA_MLME_DISABLED;
914 ieee80211_sta_send_apinfo(sdata, ifsta);
925 return; 915 return;
926 } 916 }
927 917
928 ifsta->state = IEEE80211_STA_MLME_ASSOCIATE; 918 ifsta->state = IEEE80211_STA_MLME_ASSOCIATE;
929 printk(KERN_DEBUG "%s: associate with AP %s\n", 919 printk(KERN_DEBUG "%s: associate with AP %pM\n",
930 sdata->dev->name, print_mac(mac, ifsta->bssid)); 920 sdata->dev->name, ifsta->bssid);
931 if (ieee80211_privacy_mismatch(sdata, ifsta)) { 921 if (ieee80211_privacy_mismatch(sdata, ifsta)) {
932 printk(KERN_DEBUG "%s: mismatch in privacy configuration and " 922 printk(KERN_DEBUG "%s: mismatch in privacy configuration and "
933 "mixed-cell disabled - abort association\n", sdata->dev->name); 923 "mixed-cell disabled - abort association\n", sdata->dev->name);
@@ -947,7 +937,6 @@ static void ieee80211_associated(struct ieee80211_sub_if_data *sdata,
947 struct ieee80211_local *local = sdata->local; 937 struct ieee80211_local *local = sdata->local;
948 struct sta_info *sta; 938 struct sta_info *sta;
949 int disassoc; 939 int disassoc;
950 DECLARE_MAC_BUF(mac);
951 940
952 /* TODO: start monitoring current AP signal quality and number of 941 /* TODO: start monitoring current AP signal quality and number of
953 * missed beacons. Scan other channels every now and then and search 942 * missed beacons. Scan other channels every now and then and search
@@ -960,8 +949,8 @@ static void ieee80211_associated(struct ieee80211_sub_if_data *sdata,
960 949
961 sta = sta_info_get(local, ifsta->bssid); 950 sta = sta_info_get(local, ifsta->bssid);
962 if (!sta) { 951 if (!sta) {
963 printk(KERN_DEBUG "%s: No STA entry for own AP %s\n", 952 printk(KERN_DEBUG "%s: No STA entry for own AP %pM\n",
964 sdata->dev->name, print_mac(mac, ifsta->bssid)); 953 sdata->dev->name, ifsta->bssid);
965 disassoc = 1; 954 disassoc = 1;
966 } else { 955 } else {
967 disassoc = 0; 956 disassoc = 0;
@@ -969,9 +958,9 @@ static void ieee80211_associated(struct ieee80211_sub_if_data *sdata,
969 sta->last_rx + IEEE80211_MONITORING_INTERVAL)) { 958 sta->last_rx + IEEE80211_MONITORING_INTERVAL)) {
970 if (ifsta->flags & IEEE80211_STA_PROBEREQ_POLL) { 959 if (ifsta->flags & IEEE80211_STA_PROBEREQ_POLL) {
971 printk(KERN_DEBUG "%s: No ProbeResp from " 960 printk(KERN_DEBUG "%s: No ProbeResp from "
972 "current AP %s - assume out of " 961 "current AP %pM - assume out of "
973 "range\n", 962 "range\n",
974 sdata->dev->name, print_mac(mac, ifsta->bssid)); 963 sdata->dev->name, ifsta->bssid);
975 disassoc = 1; 964 disassoc = 1;
976 } else 965 } else
977 ieee80211_send_probe_req(sdata, ifsta->bssid, 966 ieee80211_send_probe_req(sdata, ifsta->bssid,
@@ -1032,7 +1021,6 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
1032 size_t len) 1021 size_t len)
1033{ 1022{
1034 u16 auth_alg, auth_transaction, status_code; 1023 u16 auth_alg, auth_transaction, status_code;
1035 DECLARE_MAC_BUF(mac);
1036 1024
1037 if (ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && 1025 if (ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE &&
1038 sdata->vif.type != NL80211_IFTYPE_ADHOC) 1026 sdata->vif.type != NL80211_IFTYPE_ADHOC)
@@ -1125,7 +1113,6 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
1125 size_t len) 1113 size_t len)
1126{ 1114{
1127 u16 reason_code; 1115 u16 reason_code;
1128 DECLARE_MAC_BUF(mac);
1129 1116
1130 if (len < 24 + 2) 1117 if (len < 24 + 2)
1131 return; 1118 return;
@@ -1136,7 +1123,8 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
1136 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); 1123 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
1137 1124
1138 if (ifsta->flags & IEEE80211_STA_AUTHENTICATED) 1125 if (ifsta->flags & IEEE80211_STA_AUTHENTICATED)
1139 printk(KERN_DEBUG "%s: deauthenticated\n", sdata->dev->name); 1126 printk(KERN_DEBUG "%s: deauthenticated (Reason: %u)\n",
1127 sdata->dev->name, reason_code);
1140 1128
1141 if (ifsta->state == IEEE80211_STA_MLME_AUTHENTICATE || 1129 if (ifsta->state == IEEE80211_STA_MLME_AUTHENTICATE ||
1142 ifsta->state == IEEE80211_STA_MLME_ASSOCIATE || 1130 ifsta->state == IEEE80211_STA_MLME_ASSOCIATE ||
@@ -1157,7 +1145,6 @@ static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
1157 size_t len) 1145 size_t len)
1158{ 1146{
1159 u16 reason_code; 1147 u16 reason_code;
1160 DECLARE_MAC_BUF(mac);
1161 1148
1162 if (len < 24 + 2) 1149 if (len < 24 + 2)
1163 return; 1150 return;
@@ -1168,7 +1155,8 @@ static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
1168 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); 1155 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
1169 1156
1170 if (ifsta->flags & IEEE80211_STA_ASSOCIATED) 1157 if (ifsta->flags & IEEE80211_STA_ASSOCIATED)
1171 printk(KERN_DEBUG "%s: disassociated\n", sdata->dev->name); 1158 printk(KERN_DEBUG "%s: disassociated (Reason: %u)\n",
1159 sdata->dev->name, reason_code);
1172 1160
1173 if (ifsta->state == IEEE80211_STA_MLME_ASSOCIATED) { 1161 if (ifsta->state == IEEE80211_STA_MLME_ASSOCIATED) {
1174 ifsta->state = IEEE80211_STA_MLME_ASSOCIATE; 1162 ifsta->state = IEEE80211_STA_MLME_ASSOCIATE;
@@ -1192,11 +1180,12 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1192 u64 rates, basic_rates; 1180 u64 rates, basic_rates;
1193 u16 capab_info, status_code, aid; 1181 u16 capab_info, status_code, aid;
1194 struct ieee802_11_elems elems; 1182 struct ieee802_11_elems elems;
1195 struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf; 1183 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
1196 u8 *pos; 1184 u8 *pos;
1185 u32 changed = 0;
1197 int i, j; 1186 int i, j;
1198 DECLARE_MAC_BUF(mac); 1187 bool have_higher_than_11mbit = false, newsta = false;
1199 bool have_higher_than_11mbit = false; 1188 u16 ap_ht_cap_flags;
1200 1189
1201 /* AssocResp and ReassocResp have identical structure, so process both 1190 /* AssocResp and ReassocResp have identical structure, so process both
1202 * of them in this function. */ 1191 * of them in this function. */
@@ -1214,9 +1203,9 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1214 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); 1203 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
1215 aid = le16_to_cpu(mgmt->u.assoc_resp.aid); 1204 aid = le16_to_cpu(mgmt->u.assoc_resp.aid);
1216 1205
1217 printk(KERN_DEBUG "%s: RX %sssocResp from %s (capab=0x%x " 1206 printk(KERN_DEBUG "%s: RX %sssocResp from %pM (capab=0x%x "
1218 "status=%d aid=%d)\n", 1207 "status=%d aid=%d)\n",
1219 sdata->dev->name, reassoc ? "Rea" : "A", print_mac(mac, mgmt->sa), 1208 sdata->dev->name, reassoc ? "Rea" : "A", mgmt->sa,
1220 capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); 1209 capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14))));
1221 1210
1222 if (status_code != WLAN_STATUS_SUCCESS) { 1211 if (status_code != WLAN_STATUS_SUCCESS) {
@@ -1259,7 +1248,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1259 sta = sta_info_get(local, ifsta->bssid); 1248 sta = sta_info_get(local, ifsta->bssid);
1260 if (!sta) { 1249 if (!sta) {
1261 struct ieee80211_bss *bss; 1250 struct ieee80211_bss *bss;
1262 int err; 1251
1252 newsta = true;
1263 1253
1264 sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC); 1254 sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC);
1265 if (!sta) { 1255 if (!sta) {
@@ -1278,13 +1268,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1278 ieee80211_rx_bss_put(local, bss); 1268 ieee80211_rx_bss_put(local, bss);
1279 } 1269 }
1280 1270
1281 err = sta_info_insert(sta);
1282 if (err) {
1283 printk(KERN_DEBUG "%s: failed to insert STA entry for"
1284 " the AP (error %d)\n", sdata->dev->name, err);
1285 rcu_read_unlock();
1286 return;
1287 }
1288 /* update new sta with its last rx activity */ 1271 /* update new sta with its last rx activity */
1289 sta->last_rx = jiffies; 1272 sta->last_rx = jiffies;
1290 } 1273 }
@@ -1308,34 +1291,40 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1308 1291
1309 for (i = 0; i < elems.supp_rates_len; i++) { 1292 for (i = 0; i < elems.supp_rates_len; i++) {
1310 int rate = (elems.supp_rates[i] & 0x7f) * 5; 1293 int rate = (elems.supp_rates[i] & 0x7f) * 5;
1294 bool is_basic = !!(elems.supp_rates[i] & 0x80);
1311 1295
1312 if (rate > 110) 1296 if (rate > 110)
1313 have_higher_than_11mbit = true; 1297 have_higher_than_11mbit = true;
1314 1298
1315 for (j = 0; j < sband->n_bitrates; j++) { 1299 for (j = 0; j < sband->n_bitrates; j++) {
1316 if (sband->bitrates[j].bitrate == rate) 1300 if (sband->bitrates[j].bitrate == rate) {
1317 rates |= BIT(j); 1301 rates |= BIT(j);
1318 if (elems.supp_rates[i] & 0x80) 1302 if (is_basic)
1319 basic_rates |= BIT(j); 1303 basic_rates |= BIT(j);
1304 break;
1305 }
1320 } 1306 }
1321 } 1307 }
1322 1308
1323 for (i = 0; i < elems.ext_supp_rates_len; i++) { 1309 for (i = 0; i < elems.ext_supp_rates_len; i++) {
1324 int rate = (elems.ext_supp_rates[i] & 0x7f) * 5; 1310 int rate = (elems.ext_supp_rates[i] & 0x7f) * 5;
1311 bool is_basic = !!(elems.supp_rates[i] & 0x80);
1325 1312
1326 if (rate > 110) 1313 if (rate > 110)
1327 have_higher_than_11mbit = true; 1314 have_higher_than_11mbit = true;
1328 1315
1329 for (j = 0; j < sband->n_bitrates; j++) { 1316 for (j = 0; j < sband->n_bitrates; j++) {
1330 if (sband->bitrates[j].bitrate == rate) 1317 if (sband->bitrates[j].bitrate == rate) {
1331 rates |= BIT(j); 1318 rates |= BIT(j);
1332 if (elems.ext_supp_rates[i] & 0x80) 1319 if (is_basic)
1333 basic_rates |= BIT(j); 1320 basic_rates |= BIT(j);
1321 break;
1322 }
1334 } 1323 }
1335 } 1324 }
1336 1325
1337 sta->sta.supp_rates[local->hw.conf.channel->band] = rates; 1326 sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
1338 sdata->bss_conf.basic_rates = basic_rates; 1327 sdata->vif.bss_conf.basic_rates = basic_rates;
1339 1328
1340 /* cf. IEEE 802.11 9.2.12 */ 1329 /* cf. IEEE 802.11 9.2.12 */
1341 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && 1330 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
@@ -1344,31 +1333,43 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1344 else 1333 else
1345 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; 1334 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
1346 1335
1347 if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && 1336 if (elems.ht_cap_elem)
1348 (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) { 1337 ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
1349 struct ieee80211_ht_bss_info bss_info; 1338 elems.ht_cap_elem, &sta->sta.ht_cap);
1350 ieee80211_ht_cap_ie_to_ht_info( 1339
1351 elems.ht_cap_elem, &sta->sta.ht_info); 1340 ap_ht_cap_flags = sta->sta.ht_cap.cap;
1352 ieee80211_ht_addt_info_ie_to_ht_bss_info(
1353 elems.ht_info_elem, &bss_info);
1354 ieee80211_handle_ht(local, 1, &sta->sta.ht_info, &bss_info);
1355 }
1356 1341
1357 rate_control_rate_init(sta); 1342 rate_control_rate_init(sta);
1358 1343
1359 if (elems.wmm_param) { 1344 if (elems.wmm_param)
1360 set_sta_flags(sta, WLAN_STA_WME); 1345 set_sta_flags(sta, WLAN_STA_WME);
1361 rcu_read_unlock(); 1346
1347 if (newsta) {
1348 int err = sta_info_insert(sta);
1349 if (err) {
1350 printk(KERN_DEBUG "%s: failed to insert STA entry for"
1351 " the AP (error %d)\n", sdata->dev->name, err);
1352 rcu_read_unlock();
1353 return;
1354 }
1355 }
1356
1357 rcu_read_unlock();
1358
1359 if (elems.wmm_param)
1362 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param, 1360 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param,
1363 elems.wmm_param_len); 1361 elems.wmm_param_len);
1364 } else 1362
1365 rcu_read_unlock(); 1363 if (elems.ht_info_elem && elems.wmm_param &&
1364 (ifsta->flags & IEEE80211_STA_WMM_ENABLED))
1365 changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
1366 ap_ht_cap_flags);
1366 1367
1367 /* set AID and assoc capability, 1368 /* set AID and assoc capability,
1368 * ieee80211_set_associated() will tell the driver */ 1369 * ieee80211_set_associated() will tell the driver */
1369 bss_conf->aid = aid; 1370 bss_conf->aid = aid;
1370 bss_conf->assoc_capability = capab_info; 1371 bss_conf->assoc_capability = capab_info;
1371 ieee80211_set_associated(sdata, ifsta); 1372 ieee80211_set_associated(sdata, ifsta, changed);
1372 1373
1373 ieee80211_associated(sdata, ifsta); 1374 ieee80211_associated(sdata, ifsta);
1374} 1375}
@@ -1386,6 +1387,13 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
1386 struct ieee80211_supported_band *sband; 1387 struct ieee80211_supported_band *sband;
1387 union iwreq_data wrqu; 1388 union iwreq_data wrqu;
1388 1389
1390 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
1391 if (!skb) {
1392 printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
1393 "response\n", sdata->dev->name);
1394 return -ENOMEM;
1395 }
1396
1389 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1397 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1390 1398
1391 /* Remove possible STA entries from other IBSS networks. */ 1399 /* Remove possible STA entries from other IBSS networks. */
@@ -1411,63 +1419,62 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
1411 return res; 1419 return res;
1412 1420
1413 /* Build IBSS probe response */ 1421 /* Build IBSS probe response */
1414 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
1415 if (skb) {
1416 skb_reserve(skb, local->hw.extra_tx_headroom);
1417 1422
1418 mgmt = (struct ieee80211_mgmt *) 1423 skb_reserve(skb, local->hw.extra_tx_headroom);
1419 skb_put(skb, 24 + sizeof(mgmt->u.beacon));
1420 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
1421 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1422 IEEE80211_STYPE_PROBE_RESP);
1423 memset(mgmt->da, 0xff, ETH_ALEN);
1424 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
1425 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
1426 mgmt->u.beacon.beacon_int =
1427 cpu_to_le16(local->hw.conf.beacon_int);
1428 mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp);
1429 mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability);
1430
1431 pos = skb_put(skb, 2 + ifsta->ssid_len);
1432 *pos++ = WLAN_EID_SSID;
1433 *pos++ = ifsta->ssid_len;
1434 memcpy(pos, ifsta->ssid, ifsta->ssid_len);
1435
1436 rates = bss->supp_rates_len;
1437 if (rates > 8)
1438 rates = 8;
1439 pos = skb_put(skb, 2 + rates);
1440 *pos++ = WLAN_EID_SUPP_RATES;
1441 *pos++ = rates;
1442 memcpy(pos, bss->supp_rates, rates);
1443 1424
1444 if (bss->band == IEEE80211_BAND_2GHZ) { 1425 mgmt = (struct ieee80211_mgmt *)
1445 pos = skb_put(skb, 2 + 1); 1426 skb_put(skb, 24 + sizeof(mgmt->u.beacon));
1446 *pos++ = WLAN_EID_DS_PARAMS; 1427 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
1447 *pos++ = 1; 1428 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1448 *pos++ = ieee80211_frequency_to_channel(bss->freq); 1429 IEEE80211_STYPE_PROBE_RESP);
1449 } 1430 memset(mgmt->da, 0xff, ETH_ALEN);
1431 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
1432 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
1433 mgmt->u.beacon.beacon_int =
1434 cpu_to_le16(local->hw.conf.beacon_int);
1435 mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp);
1436 mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability);
1450 1437
1451 pos = skb_put(skb, 2 + 2); 1438 pos = skb_put(skb, 2 + ifsta->ssid_len);
1452 *pos++ = WLAN_EID_IBSS_PARAMS; 1439 *pos++ = WLAN_EID_SSID;
1453 *pos++ = 2; 1440 *pos++ = ifsta->ssid_len;
1454 /* FIX: set ATIM window based on scan results */ 1441 memcpy(pos, ifsta->ssid, ifsta->ssid_len);
1455 *pos++ = 0;
1456 *pos++ = 0;
1457 1442
1458 if (bss->supp_rates_len > 8) { 1443 rates = bss->supp_rates_len;
1459 rates = bss->supp_rates_len - 8; 1444 if (rates > 8)
1460 pos = skb_put(skb, 2 + rates); 1445 rates = 8;
1461 *pos++ = WLAN_EID_EXT_SUPP_RATES; 1446 pos = skb_put(skb, 2 + rates);
1462 *pos++ = rates; 1447 *pos++ = WLAN_EID_SUPP_RATES;
1463 memcpy(pos, &bss->supp_rates[8], rates); 1448 *pos++ = rates;
1464 } 1449 memcpy(pos, bss->supp_rates, rates);
1450
1451 if (bss->band == IEEE80211_BAND_2GHZ) {
1452 pos = skb_put(skb, 2 + 1);
1453 *pos++ = WLAN_EID_DS_PARAMS;
1454 *pos++ = 1;
1455 *pos++ = ieee80211_frequency_to_channel(bss->freq);
1456 }
1465 1457
1466 ifsta->probe_resp = skb; 1458 pos = skb_put(skb, 2 + 2);
1459 *pos++ = WLAN_EID_IBSS_PARAMS;
1460 *pos++ = 2;
1461 /* FIX: set ATIM window based on scan results */
1462 *pos++ = 0;
1463 *pos++ = 0;
1467 1464
1468 ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); 1465 if (bss->supp_rates_len > 8) {
1466 rates = bss->supp_rates_len - 8;
1467 pos = skb_put(skb, 2 + rates);
1468 *pos++ = WLAN_EID_EXT_SUPP_RATES;
1469 *pos++ = rates;
1470 memcpy(pos, &bss->supp_rates[8], rates);
1469 } 1471 }
1470 1472
1473 ifsta->probe_resp = skb;
1474
1475 ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
1476
1477
1471 rates = 0; 1478 rates = 0;
1472 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1479 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1473 for (i = 0; i < bss->supp_rates_len; i++) { 1480 for (i = 0; i < bss->supp_rates_len; i++) {
@@ -1507,8 +1514,6 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1507 u64 beacon_timestamp, rx_timestamp; 1514 u64 beacon_timestamp, rx_timestamp;
1508 u64 supp_rates = 0; 1515 u64 supp_rates = 0;
1509 enum ieee80211_band band = rx_status->band; 1516 enum ieee80211_band band = rx_status->band;
1510 DECLARE_MAC_BUF(mac);
1511 DECLARE_MAC_BUF(mac2);
1512 1517
1513 if (elems->ds_params && elems->ds_params_len == 1) 1518 if (elems->ds_params && elems->ds_params_len == 1)
1514 freq = ieee80211_channel_to_frequency(elems->ds_params[0]); 1519 freq = ieee80211_channel_to_frequency(elems->ds_params[0]);
@@ -1538,10 +1543,10 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1538#ifdef CONFIG_MAC80211_IBSS_DEBUG 1543#ifdef CONFIG_MAC80211_IBSS_DEBUG
1539 if (sta->sta.supp_rates[band] != prev_rates) 1544 if (sta->sta.supp_rates[band] != prev_rates)
1540 printk(KERN_DEBUG "%s: updated supp_rates set " 1545 printk(KERN_DEBUG "%s: updated supp_rates set "
1541 "for %s based on beacon info (0x%llx | " 1546 "for %pM based on beacon info (0x%llx | "
1542 "0x%llx -> 0x%llx)\n", 1547 "0x%llx -> 0x%llx)\n",
1543 sdata->dev->name, 1548 sdata->dev->name,
1544 print_mac(mac, sta->sta.addr), 1549 sta->sta.addr,
1545 (unsigned long long) prev_rates, 1550 (unsigned long long) prev_rates,
1546 (unsigned long long) supp_rates, 1551 (unsigned long long) supp_rates,
1547 (unsigned long long) sta->sta.supp_rates[band]); 1552 (unsigned long long) sta->sta.supp_rates[band]);
@@ -1605,10 +1610,9 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1605 /* can't merge without knowing the TSF */ 1610 /* can't merge without knowing the TSF */
1606 rx_timestamp = -1LLU; 1611 rx_timestamp = -1LLU;
1607#ifdef CONFIG_MAC80211_IBSS_DEBUG 1612#ifdef CONFIG_MAC80211_IBSS_DEBUG
1608 printk(KERN_DEBUG "RX beacon SA=%s BSSID=" 1613 printk(KERN_DEBUG "RX beacon SA=%pM BSSID="
1609 "%s TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n", 1614 "%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n",
1610 print_mac(mac, mgmt->sa), 1615 mgmt->sa, mgmt->bssid,
1611 print_mac(mac2, mgmt->bssid),
1612 (unsigned long long)rx_timestamp, 1616 (unsigned long long)rx_timestamp,
1613 (unsigned long long)beacon_timestamp, 1617 (unsigned long long)beacon_timestamp,
1614 (unsigned long long)(rx_timestamp - beacon_timestamp), 1618 (unsigned long long)(rx_timestamp - beacon_timestamp),
@@ -1617,8 +1621,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1617 if (beacon_timestamp > rx_timestamp) { 1621 if (beacon_timestamp > rx_timestamp) {
1618#ifdef CONFIG_MAC80211_IBSS_DEBUG 1622#ifdef CONFIG_MAC80211_IBSS_DEBUG
1619 printk(KERN_DEBUG "%s: beacon TSF higher than " 1623 printk(KERN_DEBUG "%s: beacon TSF higher than "
1620 "local TSF - IBSS merge with BSSID %s\n", 1624 "local TSF - IBSS merge with BSSID %pM\n",
1621 sdata->dev->name, print_mac(mac, mgmt->bssid)); 1625 sdata->dev->name, mgmt->bssid);
1622#endif 1626#endif
1623 ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss); 1627 ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss);
1624 ieee80211_ibss_add_sta(sdata, NULL, 1628 ieee80211_ibss_add_sta(sdata, NULL,
@@ -1671,8 +1675,9 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1671 size_t baselen; 1675 size_t baselen;
1672 struct ieee802_11_elems elems; 1676 struct ieee802_11_elems elems;
1673 struct ieee80211_local *local = sdata->local; 1677 struct ieee80211_local *local = sdata->local;
1674 struct ieee80211_conf *conf = &local->hw.conf;
1675 u32 changed = 0; 1678 u32 changed = 0;
1679 bool erp_valid;
1680 u8 erp_value = 0;
1676 1681
1677 /* Process beacon from the current BSS */ 1682 /* Process beacon from the current BSS */
1678 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; 1683 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
@@ -1694,22 +1699,42 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1694 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param, 1699 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param,
1695 elems.wmm_param_len); 1700 elems.wmm_param_len);
1696 1701
1697 if (elems.erp_info && elems.erp_info_len >= 1) 1702
1698 changed |= ieee80211_handle_erp_ie(sdata, elems.erp_info[0]); 1703 if (elems.erp_info && elems.erp_info_len >= 1) {
1699 else { 1704 erp_valid = true;
1700 u16 capab = le16_to_cpu(mgmt->u.beacon.capab_info); 1705 erp_value = elems.erp_info[0];
1701 changed |= ieee80211_handle_protect_preamb(sdata, false, 1706 } else {
1702 (capab & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0); 1707 erp_valid = false;
1703 } 1708 }
1709 changed |= ieee80211_handle_bss_capability(sdata,
1710 le16_to_cpu(mgmt->u.beacon.capab_info),
1711 erp_valid, erp_value);
1712
1713
1714 if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param) {
1715 struct sta_info *sta;
1716 struct ieee80211_supported_band *sband;
1717 u16 ap_ht_cap_flags;
1718
1719 rcu_read_lock();
1720
1721 sta = sta_info_get(local, ifsta->bssid);
1722 if (!sta) {
1723 rcu_read_unlock();
1724 return;
1725 }
1726
1727 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1704 1728
1705 if (elems.ht_cap_elem && elems.ht_info_elem && 1729 ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
1706 elems.wmm_param && conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) { 1730 elems.ht_cap_elem, &sta->sta.ht_cap);
1707 struct ieee80211_ht_bss_info bss_info;
1708 1731
1709 ieee80211_ht_addt_info_ie_to_ht_bss_info( 1732 ap_ht_cap_flags = sta->sta.ht_cap.cap;
1710 elems.ht_info_elem, &bss_info); 1733
1711 changed |= ieee80211_handle_ht(local, 1, &conf->ht_conf, 1734 rcu_read_unlock();
1712 &bss_info); 1735
1736 changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
1737 ap_ht_cap_flags);
1713 } 1738 }
1714 1739
1715 ieee80211_bss_info_change_notify(sdata, changed); 1740 ieee80211_bss_info_change_notify(sdata, changed);
@@ -1727,11 +1752,6 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
1727 struct sk_buff *skb; 1752 struct sk_buff *skb;
1728 struct ieee80211_mgmt *resp; 1753 struct ieee80211_mgmt *resp;
1729 u8 *pos, *end; 1754 u8 *pos, *end;
1730 DECLARE_MAC_BUF(mac);
1731#ifdef CONFIG_MAC80211_IBSS_DEBUG
1732 DECLARE_MAC_BUF(mac2);
1733 DECLARE_MAC_BUF(mac3);
1734#endif
1735 1755
1736 if (sdata->vif.type != NL80211_IFTYPE_ADHOC || 1756 if (sdata->vif.type != NL80211_IFTYPE_ADHOC ||
1737 ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED || 1757 ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED ||
@@ -1744,10 +1764,10 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
1744 tx_last_beacon = 1; 1764 tx_last_beacon = 1;
1745 1765
1746#ifdef CONFIG_MAC80211_IBSS_DEBUG 1766#ifdef CONFIG_MAC80211_IBSS_DEBUG
1747 printk(KERN_DEBUG "%s: RX ProbeReq SA=%s DA=%s BSSID=" 1767 printk(KERN_DEBUG "%s: RX ProbeReq SA=%pM DA=%pM BSSID=%pM"
1748 "%s (tx_last_beacon=%d)\n", 1768 " (tx_last_beacon=%d)\n",
1749 sdata->dev->name, print_mac(mac, mgmt->sa), print_mac(mac2, mgmt->da), 1769 sdata->dev->name, mgmt->sa, mgmt->da,
1750 print_mac(mac3, mgmt->bssid), tx_last_beacon); 1770 mgmt->bssid, tx_last_beacon);
1751#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 1771#endif /* CONFIG_MAC80211_IBSS_DEBUG */
1752 1772
1753 if (!tx_last_beacon) 1773 if (!tx_last_beacon)
@@ -1763,8 +1783,8 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
1763 pos + 2 + pos[1] > end) { 1783 pos + 2 + pos[1] > end) {
1764#ifdef CONFIG_MAC80211_IBSS_DEBUG 1784#ifdef CONFIG_MAC80211_IBSS_DEBUG
1765 printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " 1785 printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq "
1766 "from %s\n", 1786 "from %pM\n",
1767 sdata->dev->name, print_mac(mac, mgmt->sa)); 1787 sdata->dev->name, mgmt->sa);
1768#endif 1788#endif
1769 return; 1789 return;
1770 } 1790 }
@@ -1783,8 +1803,8 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
1783 resp = (struct ieee80211_mgmt *) skb->data; 1803 resp = (struct ieee80211_mgmt *) skb->data;
1784 memcpy(resp->da, mgmt->sa, ETH_ALEN); 1804 memcpy(resp->da, mgmt->sa, ETH_ALEN);
1785#ifdef CONFIG_MAC80211_IBSS_DEBUG 1805#ifdef CONFIG_MAC80211_IBSS_DEBUG
1786 printk(KERN_DEBUG "%s: Sending ProbeResp to %s\n", 1806 printk(KERN_DEBUG "%s: Sending ProbeResp to %pM\n",
1787 sdata->dev->name, print_mac(mac, resp->da)); 1807 sdata->dev->name, resp->da);
1788#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 1808#endif /* CONFIG_MAC80211_IBSS_DEBUG */
1789 ieee80211_tx_skb(sdata, skb, 0); 1809 ieee80211_tx_skb(sdata, skb, 0);
1790} 1810}
@@ -1990,7 +2010,6 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata,
1990 u8 bssid[ETH_ALEN], *pos; 2010 u8 bssid[ETH_ALEN], *pos;
1991 int i; 2011 int i;
1992 int ret; 2012 int ret;
1993 DECLARE_MAC_BUF(mac);
1994 2013
1995#if 0 2014#if 0
1996 /* Easier testing, use fixed BSSID. */ 2015 /* Easier testing, use fixed BSSID. */
@@ -2006,8 +2025,8 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata,
2006 bssid[0] |= 0x02; 2025 bssid[0] |= 0x02;
2007#endif 2026#endif
2008 2027
2009 printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %s\n", 2028 printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n",
2010 sdata->dev->name, print_mac(mac, bssid)); 2029 sdata->dev->name, bssid);
2011 2030
2012 bss = ieee80211_rx_bss_add(local, bssid, 2031 bss = ieee80211_rx_bss_add(local, bssid,
2013 local->hw.conf.channel->center_freq, 2032 local->hw.conf.channel->center_freq,
@@ -2050,8 +2069,6 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata,
2050 int found = 0; 2069 int found = 0;
2051 u8 bssid[ETH_ALEN]; 2070 u8 bssid[ETH_ALEN];
2052 int active_ibss; 2071 int active_ibss;
2053 DECLARE_MAC_BUF(mac);
2054 DECLARE_MAC_BUF(mac2);
2055 2072
2056 if (ifsta->ssid_len == 0) 2073 if (ifsta->ssid_len == 0)
2057 return -EINVAL; 2074 return -EINVAL;
@@ -2068,8 +2085,7 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata,
2068 || !(bss->capability & WLAN_CAPABILITY_IBSS)) 2085 || !(bss->capability & WLAN_CAPABILITY_IBSS))
2069 continue; 2086 continue;
2070#ifdef CONFIG_MAC80211_IBSS_DEBUG 2087#ifdef CONFIG_MAC80211_IBSS_DEBUG
2071 printk(KERN_DEBUG " bssid=%s found\n", 2088 printk(KERN_DEBUG " bssid=%pM found\n", bss->bssid);
2072 print_mac(mac, bss->bssid));
2073#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 2089#endif /* CONFIG_MAC80211_IBSS_DEBUG */
2074 memcpy(bssid, bss->bssid, ETH_ALEN); 2090 memcpy(bssid, bss->bssid, ETH_ALEN);
2075 found = 1; 2091 found = 1;
@@ -2080,9 +2096,8 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata,
2080 2096
2081#ifdef CONFIG_MAC80211_IBSS_DEBUG 2097#ifdef CONFIG_MAC80211_IBSS_DEBUG
2082 if (found) 2098 if (found)
2083 printk(KERN_DEBUG " sta_find_ibss: selected %s current " 2099 printk(KERN_DEBUG " sta_find_ibss: selected %pM current "
2084 "%s\n", print_mac(mac, bssid), 2100 "%pM\n", bssid, ifsta->bssid);
2085 print_mac(mac2, ifsta->bssid));
2086#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 2101#endif /* CONFIG_MAC80211_IBSS_DEBUG */
2087 2102
2088 if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) { 2103 if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) {
@@ -2099,9 +2114,9 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata,
2099 if (!bss) 2114 if (!bss)
2100 goto dont_join; 2115 goto dont_join;
2101 2116
2102 printk(KERN_DEBUG "%s: Selected IBSS BSSID %s" 2117 printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM"
2103 " based on configured SSID\n", 2118 " based on configured SSID\n",
2104 sdata->dev->name, print_mac(mac, bssid)); 2119 sdata->dev->name, bssid);
2105 ret = ieee80211_sta_join_ibss(sdata, ifsta, bss); 2120 ret = ieee80211_sta_join_ibss(sdata, ifsta, bss);
2106 ieee80211_rx_bss_put(local, bss); 2121 ieee80211_rx_bss_put(local, bss);
2107 return ret; 2122 return ret;
@@ -2343,7 +2358,6 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
2343{ 2358{
2344 struct ieee80211_local *local = sdata->local; 2359 struct ieee80211_local *local = sdata->local;
2345 struct sta_info *sta; 2360 struct sta_info *sta;
2346 DECLARE_MAC_BUF(mac);
2347 int band = local->hw.conf.channel->band; 2361 int band = local->hw.conf.channel->band;
2348 2362
2349 /* TODO: Could consider removing the least recently used entry and 2363 /* TODO: Could consider removing the least recently used entry and
@@ -2351,7 +2365,7 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
2351 if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) { 2365 if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) {
2352 if (net_ratelimit()) { 2366 if (net_ratelimit()) {
2353 printk(KERN_DEBUG "%s: No room for a new IBSS STA " 2367 printk(KERN_DEBUG "%s: No room for a new IBSS STA "
2354 "entry %s\n", sdata->dev->name, print_mac(mac, addr)); 2368 "entry %pM\n", sdata->dev->name, addr);
2355 } 2369 }
2356 return NULL; 2370 return NULL;
2357 } 2371 }
@@ -2360,8 +2374,8 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
2360 return NULL; 2374 return NULL;
2361 2375
2362#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 2376#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
2363 printk(KERN_DEBUG "%s: Adding new IBSS station %s (dev=%s)\n", 2377 printk(KERN_DEBUG "%s: Adding new IBSS station %pM (dev=%s)\n",
2364 wiphy_name(local->hw.wiphy), print_mac(mac, addr), sdata->dev->name); 2378 wiphy_name(local->hw.wiphy), addr, sdata->dev->name);
2365#endif 2379#endif
2366 2380
2367 sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); 2381 sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
@@ -2408,7 +2422,6 @@ void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata,
2408int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len) 2422int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len)
2409{ 2423{
2410 struct ieee80211_if_sta *ifsta; 2424 struct ieee80211_if_sta *ifsta;
2411 int res;
2412 2425
2413 if (len > IEEE80211_MAX_SSID_LEN) 2426 if (len > IEEE80211_MAX_SSID_LEN)
2414 return -EINVAL; 2427 return -EINVAL;
@@ -2420,19 +2433,6 @@ int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size
2420 memcpy(ifsta->ssid, ssid, len); 2433 memcpy(ifsta->ssid, ssid, len);
2421 ifsta->ssid_len = len; 2434 ifsta->ssid_len = len;
2422 ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET; 2435 ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET;
2423
2424 res = 0;
2425 /*
2426 * Hack! MLME code needs to be cleaned up to have different
2427 * entry points for configuration and internal selection change
2428 */
2429 if (netif_running(sdata->dev))
2430 res = ieee80211_if_config(sdata, IEEE80211_IFCC_SSID);
2431 if (res) {
2432 printk(KERN_DEBUG "%s: Failed to config new SSID to "
2433 "the low-level driver\n", sdata->dev->name);
2434 return res;
2435 }
2436 } 2436 }
2437 2437
2438 if (len) 2438 if (len)
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 5d786720d935..3fa7ab285066 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -199,48 +199,44 @@ static void rate_control_release(struct kref *kref)
199} 199}
200 200
201void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, 201void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
202 struct ieee80211_supported_band *sband, 202 struct sta_info *sta,
203 struct sta_info *sta, struct sk_buff *skb, 203 struct ieee80211_tx_rate_control *txrc)
204 struct rate_selection *sel)
205{ 204{
206 struct rate_control_ref *ref = sdata->local->rate_ctrl; 205 struct rate_control_ref *ref = sdata->local->rate_ctrl;
207 void *priv_sta = NULL; 206 void *priv_sta = NULL;
208 struct ieee80211_sta *ista = NULL; 207 struct ieee80211_sta *ista = NULL;
208 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
209 int i; 209 int i;
210 210
211 sel->rate_idx = -1;
212 sel->nonerp_idx = -1;
213 sel->probe_idx = -1;
214 sel->max_rate_idx = sdata->max_ratectrl_rateidx;
215
216 if (sta) { 211 if (sta) {
217 ista = &sta->sta; 212 ista = &sta->sta;
218 priv_sta = sta->rate_ctrl_priv; 213 priv_sta = sta->rate_ctrl_priv;
219 } 214 }
220 215
216 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
217 info->control.rates[i].idx = -1;
218 info->control.rates[i].flags = 0;
219 info->control.rates[i].count = 1;
220 }
221
221 if (sta && sdata->force_unicast_rateidx > -1) 222 if (sta && sdata->force_unicast_rateidx > -1)
222 sel->rate_idx = sdata->force_unicast_rateidx; 223 info->control.rates[0].idx = sdata->force_unicast_rateidx;
223 else 224 else
224 ref->ops->get_rate(ref->priv, sband, ista, priv_sta, skb, sel); 225 ref->ops->get_rate(ref->priv, ista, priv_sta, txrc);
225 226
226 if (sdata->max_ratectrl_rateidx > -1 && 227 /*
227 sel->rate_idx > sdata->max_ratectrl_rateidx) 228 * try to enforce the maximum rate the user wanted
228 sel->rate_idx = sdata->max_ratectrl_rateidx; 229 */
229 230 if (sdata->max_ratectrl_rateidx > -1)
230 BUG_ON(sel->rate_idx < 0); 231 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
231 232 if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS)
232 /* Select a non-ERP backup rate. */ 233 continue;
233 if (sel->nonerp_idx < 0) { 234 info->control.rates[i].idx =
234 for (i = 0; i < sband->n_bitrates; i++) { 235 min_t(s8, info->control.rates[i].idx,
235 struct ieee80211_rate *rate = &sband->bitrates[i]; 236 sdata->max_ratectrl_rateidx);
236 if (sband->bitrates[sel->rate_idx].bitrate < rate->bitrate)
237 break;
238
239 if (rate_supported(ista, sband->band, i) &&
240 !(rate->flags & IEEE80211_RATE_ERP_G))
241 sel->nonerp_idx = i;
242 }
243 } 237 }
238
239 BUG_ON(info->control.rates[0].idx < 0);
244} 240}
245 241
246struct rate_control_ref *rate_control_get(struct rate_control_ref *ref) 242struct rate_control_ref *rate_control_get(struct rate_control_ref *ref)
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h
index d0092f847f82..928da625e281 100644
--- a/net/mac80211/rate.h
+++ b/net/mac80211/rate.h
@@ -31,9 +31,8 @@ struct rate_control_ref {
31struct rate_control_ref *rate_control_alloc(const char *name, 31struct rate_control_ref *rate_control_alloc(const char *name,
32 struct ieee80211_local *local); 32 struct ieee80211_local *local);
33void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, 33void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
34 struct ieee80211_supported_band *sband, 34 struct sta_info *sta,
35 struct sta_info *sta, struct sk_buff *skb, 35 struct ieee80211_tx_rate_control *txrc);
36 struct rate_selection *sel);
37struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); 36struct rate_control_ref *rate_control_get(struct rate_control_ref *ref);
38void rate_control_put(struct rate_control_ref *ref); 37void rate_control_put(struct rate_control_ref *ref);
39 38
@@ -64,12 +63,6 @@ static inline void rate_control_rate_init(struct sta_info *sta)
64} 63}
65 64
66 65
67static inline void rate_control_clear(struct ieee80211_local *local)
68{
69 struct rate_control_ref *ref = local->rate_ctrl;
70 ref->ops->clear(ref->priv);
71}
72
73static inline void *rate_control_alloc_sta(struct rate_control_ref *ref, 66static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
74 struct ieee80211_sta *sta, 67 struct ieee80211_sta *sta,
75 gfp_t gfp) 68 gfp_t gfp)
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index f6d69dab07a3..2b3b490a6073 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -126,7 +126,9 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
126 mr->adjusted_retry_count = mr->retry_count >> 1; 126 mr->adjusted_retry_count = mr->retry_count >> 1;
127 if (mr->adjusted_retry_count > 2) 127 if (mr->adjusted_retry_count > 2)
128 mr->adjusted_retry_count = 2; 128 mr->adjusted_retry_count = 2;
129 mr->sample_limit = 4;
129 } else { 130 } else {
131 mr->sample_limit = -1;
130 mr->adjusted_retry_count = mr->retry_count; 132 mr->adjusted_retry_count = mr->retry_count;
131 } 133 }
132 if (!mr->adjusted_retry_count) 134 if (!mr->adjusted_retry_count)
@@ -169,30 +171,20 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
169{ 171{
170 struct minstrel_sta_info *mi = priv_sta; 172 struct minstrel_sta_info *mi = priv_sta;
171 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 173 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
172 struct ieee80211_tx_altrate *ar = info->status.retries; 174 struct ieee80211_tx_rate *ar = info->status.rates;
173 struct minstrel_priv *mp = priv; 175 int i, ndx;
174 int i, ndx, tries; 176 int success;
175 int success = 0;
176
177 if (!info->status.excessive_retries)
178 success = 1;
179 177
180 if (!mp->has_mrr || (ar[0].rate_idx < 0)) { 178 success = !!(info->flags & IEEE80211_TX_STAT_ACK);
181 ndx = rix_to_ndx(mi, info->tx_rate_idx);
182 tries = info->status.retry_count + 1;
183 mi->r[ndx].success += success;
184 mi->r[ndx].attempts += tries;
185 return;
186 }
187 179
188 for (i = 0; i < 4; i++) { 180 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
189 if (ar[i].rate_idx < 0) 181 if (ar[i].idx < 0)
190 break; 182 break;
191 183
192 ndx = rix_to_ndx(mi, ar[i].rate_idx); 184 ndx = rix_to_ndx(mi, ar[i].idx);
193 mi->r[ndx].attempts += ar[i].limit + 1; 185 mi->r[ndx].attempts += ar[i].count;
194 186
195 if ((i != 3) && (ar[i + 1].rate_idx < 0)) 187 if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0))
196 mi->r[ndx].success += success; 188 mi->r[ndx].success += success;
197 } 189 }
198 190
@@ -210,9 +202,9 @@ minstrel_get_retry_count(struct minstrel_rate *mr,
210{ 202{
211 unsigned int retry = mr->adjusted_retry_count; 203 unsigned int retry = mr->adjusted_retry_count;
212 204
213 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) 205 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
214 retry = max(2U, min(mr->retry_count_rtscts, retry)); 206 retry = max(2U, min(mr->retry_count_rtscts, retry));
215 else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) 207 else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
216 retry = max(2U, min(mr->retry_count_cts, retry)); 208 retry = max(2U, min(mr->retry_count_cts, retry));
217 return retry; 209 return retry;
218} 210}
@@ -233,15 +225,16 @@ minstrel_get_next_sample(struct minstrel_sta_info *mi)
233 return sample_ndx; 225 return sample_ndx;
234} 226}
235 227
236void 228static void
237minstrel_get_rate(void *priv, struct ieee80211_supported_band *sband, 229minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
238 struct ieee80211_sta *sta, void *priv_sta, 230 void *priv_sta, struct ieee80211_tx_rate_control *txrc)
239 struct sk_buff *skb, struct rate_selection *sel)
240{ 231{
232 struct sk_buff *skb = txrc->skb;
233 struct ieee80211_supported_band *sband = txrc->sband;
241 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 234 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
242 struct minstrel_sta_info *mi = priv_sta; 235 struct minstrel_sta_info *mi = priv_sta;
243 struct minstrel_priv *mp = priv; 236 struct minstrel_priv *mp = priv;
244 struct ieee80211_tx_altrate *ar = info->control.retries; 237 struct ieee80211_tx_rate *ar = info->control.rates;
245 unsigned int ndx, sample_ndx = 0; 238 unsigned int ndx, sample_ndx = 0;
246 bool mrr; 239 bool mrr;
247 bool sample_slower = false; 240 bool sample_slower = false;
@@ -251,16 +244,12 @@ minstrel_get_rate(void *priv, struct ieee80211_supported_band *sband,
251 int sample_rate; 244 int sample_rate;
252 245
253 if (!sta || !mi || use_low_rate(skb)) { 246 if (!sta || !mi || use_low_rate(skb)) {
254 sel->rate_idx = rate_lowest_index(sband, sta); 247 ar[0].idx = rate_lowest_index(sband, sta);
248 ar[0].count = mp->max_retry;
255 return; 249 return;
256 } 250 }
257 251
258 mrr = mp->has_mrr; 252 mrr = mp->has_mrr && !txrc->rts && !txrc->bss_conf->use_cts_prot;
259
260 /* mac80211 does not allow mrr for RTS/CTS */
261 if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
262 (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT))
263 mrr = false;
264 253
265 if (time_after(jiffies, mi->stats_update + (mp->update_interval * 254 if (time_after(jiffies, mi->stats_update + (mp->update_interval *
266 HZ) / 1000)) 255 HZ) / 1000))
@@ -278,7 +267,8 @@ minstrel_get_rate(void *priv, struct ieee80211_supported_band *sband,
278 (mi->sample_count + mi->sample_deferred / 2); 267 (mi->sample_count + mi->sample_deferred / 2);
279 268
280 /* delta > 0: sampling required */ 269 /* delta > 0: sampling required */
281 if (delta > 0) { 270 if ((delta > 0) && (mrr || !mi->prev_sample)) {
271 struct minstrel_rate *msr;
282 if (mi->packet_count >= 10000) { 272 if (mi->packet_count >= 10000) {
283 mi->sample_deferred = 0; 273 mi->sample_deferred = 0;
284 mi->sample_count = 0; 274 mi->sample_count = 0;
@@ -297,13 +287,20 @@ minstrel_get_rate(void *priv, struct ieee80211_supported_band *sband,
297 } 287 }
298 288
299 sample_ndx = minstrel_get_next_sample(mi); 289 sample_ndx = minstrel_get_next_sample(mi);
290 msr = &mi->r[sample_ndx];
300 sample = true; 291 sample = true;
301 sample_slower = mrr && (mi->r[sample_ndx].perfect_tx_time > 292 sample_slower = mrr && (msr->perfect_tx_time >
302 mi->r[ndx].perfect_tx_time); 293 mi->r[ndx].perfect_tx_time);
303 294
304 if (!sample_slower) { 295 if (!sample_slower) {
305 ndx = sample_ndx; 296 if (msr->sample_limit != 0) {
306 mi->sample_count++; 297 ndx = sample_ndx;
298 mi->sample_count++;
299 if (msr->sample_limit > 0)
300 msr->sample_limit--;
301 } else {
302 sample = false;
303 }
307 } else { 304 } else {
308 /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark 305 /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark
309 * packets that have the sampling rate deferred to the 306 * packets that have the sampling rate deferred to the
@@ -315,13 +312,22 @@ minstrel_get_rate(void *priv, struct ieee80211_supported_band *sband,
315 mi->sample_deferred++; 312 mi->sample_deferred++;
316 } 313 }
317 } 314 }
318 sel->rate_idx = mi->r[ndx].rix; 315 mi->prev_sample = sample;
319 info->control.retry_limit = minstrel_get_retry_count(&mi->r[ndx], info); 316
317 /* If we're not using MRR and the sampling rate already
318 * has a probability of >95%, we shouldn't be attempting
319 * to use it, as this only wastes precious airtime */
320 if (!mrr && sample && (mi->r[ndx].probability > 17100))
321 ndx = mi->max_tp_rate;
322
323 ar[0].idx = mi->r[ndx].rix;
324 ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info);
320 325
321 if (!mrr) { 326 if (!mrr) {
322 ar[0].rate_idx = mi->lowest_rix; 327 if (!sample)
323 ar[0].limit = mp->max_retry; 328 ar[0].count = mp->max_retry;
324 ar[1].rate_idx = -1; 329 ar[1].idx = mi->lowest_rix;
330 ar[1].count = mp->max_retry;
325 return; 331 return;
326 } 332 }
327 333
@@ -336,9 +342,9 @@ minstrel_get_rate(void *priv, struct ieee80211_supported_band *sband,
336 } 342 }
337 mrr_ndx[1] = mi->max_prob_rate; 343 mrr_ndx[1] = mi->max_prob_rate;
338 mrr_ndx[2] = 0; 344 mrr_ndx[2] = 0;
339 for (i = 0; i < 3; i++) { 345 for (i = 1; i < 4; i++) {
340 ar[i].rate_idx = mi->r[mrr_ndx[i]].rix; 346 ar[i].idx = mi->r[mrr_ndx[i - 1]].rix;
341 ar[i].limit = mi->r[mrr_ndx[i]].adjusted_retry_count; 347 ar[i].count = mi->r[mrr_ndx[i - 1]].adjusted_retry_count;
342 } 348 }
343} 349}
344 350
@@ -415,6 +421,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
415 421
416 /* calculate maximum number of retransmissions before 422 /* calculate maximum number of retransmissions before
417 * fallback (based on maximum segment size) */ 423 * fallback (based on maximum segment size) */
424 mr->sample_limit = -1;
418 mr->retry_count = 1; 425 mr->retry_count = 1;
419 mr->retry_count_cts = 1; 426 mr->retry_count_cts = 1;
420 mr->retry_count_rtscts = 1; 427 mr->retry_count_rtscts = 1;
@@ -500,11 +507,6 @@ minstrel_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta)
500 kfree(mi); 507 kfree(mi);
501} 508}
502 509
503static void
504minstrel_clear(void *priv)
505{
506}
507
508static void * 510static void *
509minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) 511minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
510{ 512{
@@ -532,13 +534,13 @@ minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
532 /* maximum time that the hw is allowed to stay in one MRR segment */ 534 /* maximum time that the hw is allowed to stay in one MRR segment */
533 mp->segment_size = 6000; 535 mp->segment_size = 6000;
534 536
535 if (hw->max_altrate_tries > 0) 537 if (hw->max_rate_tries > 0)
536 mp->max_retry = hw->max_altrate_tries; 538 mp->max_retry = hw->max_rate_tries;
537 else 539 else
538 /* safe default, does not necessarily have to match hw properties */ 540 /* safe default, does not necessarily have to match hw properties */
539 mp->max_retry = 7; 541 mp->max_retry = 7;
540 542
541 if (hw->max_altrates >= 3) 543 if (hw->max_rates >= 4)
542 mp->has_mrr = true; 544 mp->has_mrr = true;
543 545
544 mp->hw = hw; 546 mp->hw = hw;
@@ -558,7 +560,6 @@ static struct rate_control_ops mac80211_minstrel = {
558 .tx_status = minstrel_tx_status, 560 .tx_status = minstrel_tx_status,
559 .get_rate = minstrel_get_rate, 561 .get_rate = minstrel_get_rate,
560 .rate_init = minstrel_rate_init, 562 .rate_init = minstrel_rate_init,
561 .clear = minstrel_clear,
562 .alloc = minstrel_alloc, 563 .alloc = minstrel_alloc,
563 .free = minstrel_free, 564 .free = minstrel_free,
564 .alloc_sta = minstrel_alloc_sta, 565 .alloc_sta = minstrel_alloc_sta,
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 9a90a6aee043..869fe0ef951d 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -16,6 +16,7 @@ struct minstrel_rate {
16 unsigned int perfect_tx_time; 16 unsigned int perfect_tx_time;
17 unsigned int ack_time; 17 unsigned int ack_time;
18 18
19 int sample_limit;
19 unsigned int retry_count; 20 unsigned int retry_count;
20 unsigned int retry_count_cts; 21 unsigned int retry_count_cts;
21 unsigned int retry_count_rtscts; 22 unsigned int retry_count_rtscts;
@@ -57,6 +58,7 @@ struct minstrel_sta_info {
57 58
58 int n_rates; 59 int n_rates;
59 struct minstrel_rate *r; 60 struct minstrel_rate *r;
61 bool prev_sample;
60 62
61 /* sampling table */ 63 /* sampling table */
62 u8 *sample_table; 64 u8 *sample_table;
diff --git a/net/mac80211/rc80211_pid.h b/net/mac80211/rc80211_pid.h
index 01d64d53f3b9..1a873f00691a 100644
--- a/net/mac80211/rc80211_pid.h
+++ b/net/mac80211/rc80211_pid.h
@@ -49,7 +49,7 @@
49 49
50/* Arithmetic right shift for positive and negative values for ISO C. */ 50/* Arithmetic right shift for positive and negative values for ISO C. */
51#define RC_PID_DO_ARITH_RIGHT_SHIFT(x, y) \ 51#define RC_PID_DO_ARITH_RIGHT_SHIFT(x, y) \
52 (x) < 0 ? -((-(x)) >> (y)) : (x) >> (y) 52 ((x) < 0 ? -((-(x)) >> (y)) : (x) >> (y))
53 53
54enum rc_pid_event_type { 54enum rc_pid_event_type {
55 RC_PID_EVENT_TYPE_TX_STATUS, 55 RC_PID_EVENT_TYPE_TX_STATUS,
@@ -61,6 +61,7 @@ enum rc_pid_event_type {
61union rc_pid_event_data { 61union rc_pid_event_data {
62 /* RC_PID_EVENT_TX_STATUS */ 62 /* RC_PID_EVENT_TX_STATUS */
63 struct { 63 struct {
64 u32 flags;
64 struct ieee80211_tx_info tx_status; 65 struct ieee80211_tx_info tx_status;
65 }; 66 };
66 /* RC_PID_EVENT_TYPE_RATE_CHANGE */ 67 /* RC_PID_EVENT_TYPE_RATE_CHANGE */
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c
index 86eb374e3b87..2328ba568039 100644
--- a/net/mac80211/rc80211_pid_algo.c
+++ b/net/mac80211/rc80211_pid_algo.c
@@ -241,7 +241,7 @@ static void rate_control_pid_tx_status(void *priv, struct ieee80211_supported_ba
241 241
242 /* Ignore all frames that were sent with a different rate than the rate 242 /* Ignore all frames that were sent with a different rate than the rate
243 * we currently advise mac80211 to use. */ 243 * we currently advise mac80211 to use. */
244 if (info->tx_rate_idx != spinfo->txrate_idx) 244 if (info->status.rates[0].idx != spinfo->txrate_idx)
245 return; 245 return;
246 246
247 spinfo->tx_num_xmit++; 247 spinfo->tx_num_xmit++;
@@ -253,10 +253,10 @@ static void rate_control_pid_tx_status(void *priv, struct ieee80211_supported_ba
253 /* We count frames that totally failed to be transmitted as two bad 253 /* We count frames that totally failed to be transmitted as two bad
254 * frames, those that made it out but had some retries as one good and 254 * frames, those that made it out but had some retries as one good and
255 * one bad frame. */ 255 * one bad frame. */
256 if (info->status.excessive_retries) { 256 if (!(info->flags & IEEE80211_TX_STAT_ACK)) {
257 spinfo->tx_num_failed += 2; 257 spinfo->tx_num_failed += 2;
258 spinfo->tx_num_xmit++; 258 spinfo->tx_num_xmit++;
259 } else if (info->status.retry_count) { 259 } else if (info->status.rates[0].count) {
260 spinfo->tx_num_failed++; 260 spinfo->tx_num_failed++;
261 spinfo->tx_num_xmit++; 261 spinfo->tx_num_xmit++;
262 } 262 }
@@ -270,23 +270,32 @@ static void rate_control_pid_tx_status(void *priv, struct ieee80211_supported_ba
270} 270}
271 271
272static void 272static void
273rate_control_pid_get_rate(void *priv, struct ieee80211_supported_band *sband, 273rate_control_pid_get_rate(void *priv, struct ieee80211_sta *sta,
274 struct ieee80211_sta *sta, void *priv_sta, 274 void *priv_sta,
275 struct sk_buff *skb, 275 struct ieee80211_tx_rate_control *txrc)
276 struct rate_selection *sel)
277{ 276{
277 struct sk_buff *skb = txrc->skb;
278 struct ieee80211_supported_band *sband = txrc->sband;
278 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 279 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
280 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
279 struct rc_pid_sta_info *spinfo = priv_sta; 281 struct rc_pid_sta_info *spinfo = priv_sta;
280 int rateidx; 282 int rateidx;
281 u16 fc; 283 u16 fc;
282 284
285 if (txrc->rts)
286 info->control.rates[0].count =
287 txrc->hw->conf.long_frame_max_tx_count;
288 else
289 info->control.rates[0].count =
290 txrc->hw->conf.short_frame_max_tx_count;
291
283 /* Send management frames and broadcast/multicast data using lowest 292 /* Send management frames and broadcast/multicast data using lowest
284 * rate. */ 293 * rate. */
285 fc = le16_to_cpu(hdr->frame_control); 294 fc = le16_to_cpu(hdr->frame_control);
286 if (!sta || !spinfo || 295 if (!sta || !spinfo ||
287 (fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || 296 (fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
288 is_multicast_ether_addr(hdr->addr1)) { 297 is_multicast_ether_addr(hdr->addr1)) {
289 sel->rate_idx = rate_lowest_index(sband, sta); 298 info->control.rates[0].idx = rate_lowest_index(sband, sta);
290 return; 299 return;
291 } 300 }
292 301
@@ -295,7 +304,7 @@ rate_control_pid_get_rate(void *priv, struct ieee80211_supported_band *sband,
295 if (rateidx >= sband->n_bitrates) 304 if (rateidx >= sband->n_bitrates)
296 rateidx = sband->n_bitrates - 1; 305 rateidx = sband->n_bitrates - 1;
297 306
298 sel->rate_idx = rateidx; 307 info->control.rates[0].idx = rateidx;
299 308
300#ifdef CONFIG_MAC80211_DEBUGFS 309#ifdef CONFIG_MAC80211_DEBUGFS
301 rate_control_pid_event_tx_rate(&spinfo->events, 310 rate_control_pid_event_tx_rate(&spinfo->events,
@@ -437,10 +446,6 @@ static void rate_control_pid_free(void *priv)
437 kfree(pinfo); 446 kfree(pinfo);
438} 447}
439 448
440static void rate_control_pid_clear(void *priv)
441{
442}
443
444static void *rate_control_pid_alloc_sta(void *priv, struct ieee80211_sta *sta, 449static void *rate_control_pid_alloc_sta(void *priv, struct ieee80211_sta *sta,
445 gfp_t gfp) 450 gfp_t gfp)
446{ 451{
@@ -471,7 +476,6 @@ static struct rate_control_ops mac80211_rcpid = {
471 .tx_status = rate_control_pid_tx_status, 476 .tx_status = rate_control_pid_tx_status,
472 .get_rate = rate_control_pid_get_rate, 477 .get_rate = rate_control_pid_get_rate,
473 .rate_init = rate_control_pid_rate_init, 478 .rate_init = rate_control_pid_rate_init,
474 .clear = rate_control_pid_clear,
475 .alloc = rate_control_pid_alloc, 479 .alloc = rate_control_pid_alloc,
476 .free = rate_control_pid_free, 480 .free = rate_control_pid_free,
477 .alloc_sta = rate_control_pid_alloc_sta, 481 .alloc_sta = rate_control_pid_alloc_sta,
diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
index 8121d3bc6835..a08a9b530347 100644
--- a/net/mac80211/rc80211_pid_debugfs.c
+++ b/net/mac80211/rc80211_pid_debugfs.c
@@ -43,6 +43,7 @@ void rate_control_pid_event_tx_status(struct rc_pid_event_buffer *buf,
43{ 43{
44 union rc_pid_event_data evd; 44 union rc_pid_event_data evd;
45 45
46 evd.flags = stat->flags;
46 memcpy(&evd.tx_status, stat, sizeof(struct ieee80211_tx_info)); 47 memcpy(&evd.tx_status, stat, sizeof(struct ieee80211_tx_info));
47 rate_control_pid_event(buf, RC_PID_EVENT_TYPE_TX_STATUS, &evd); 48 rate_control_pid_event(buf, RC_PID_EVENT_TYPE_TX_STATUS, &evd);
48} 49}
@@ -167,8 +168,8 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
167 switch (ev->type) { 168 switch (ev->type) {
168 case RC_PID_EVENT_TYPE_TX_STATUS: 169 case RC_PID_EVENT_TYPE_TX_STATUS:
169 p += snprintf(pb + p, length - p, "tx_status %u %u", 170 p += snprintf(pb + p, length - p, "tx_status %u %u",
170 ev->data.tx_status.status.excessive_retries, 171 !(ev->data.flags & IEEE80211_TX_STAT_ACK),
171 ev->data.tx_status.status.retry_count); 172 ev->data.tx_status.status.rates[0].idx);
172 break; 173 break;
173 case RC_PID_EVENT_TYPE_RATE_CHANGE: 174 case RC_PID_EVENT_TYPE_RATE_CHANGE:
174 p += snprintf(pb + p, length - p, "rate_change %d %d", 175 p += snprintf(pb + p, length - p, "rate_change %d %d",
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index cf6b121e1bbf..648a1d0e6c82 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -26,10 +26,11 @@
26#include "tkip.h" 26#include "tkip.h"
27#include "wme.h" 27#include "wme.h"
28 28
29u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, 29static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
30 struct tid_ampdu_rx *tid_agg_rx, 30 struct tid_ampdu_rx *tid_agg_rx,
31 struct sk_buff *skb, u16 mpdu_seq_num, 31 struct sk_buff *skb,
32 int bar_req); 32 u16 mpdu_seq_num,
33 int bar_req);
33/* 34/*
34 * monitor mode reception 35 * monitor mode reception
35 * 36 *
@@ -653,13 +654,12 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
653static void ap_sta_ps_start(struct sta_info *sta) 654static void ap_sta_ps_start(struct sta_info *sta)
654{ 655{
655 struct ieee80211_sub_if_data *sdata = sta->sdata; 656 struct ieee80211_sub_if_data *sdata = sta->sdata;
656 DECLARE_MAC_BUF(mac);
657 657
658 atomic_inc(&sdata->bss->num_sta_ps); 658 atomic_inc(&sdata->bss->num_sta_ps);
659 set_and_clear_sta_flags(sta, WLAN_STA_PS, WLAN_STA_PSPOLL); 659 set_and_clear_sta_flags(sta, WLAN_STA_PS, WLAN_STA_PSPOLL);
660#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 660#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
661 printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n", 661 printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n",
662 sdata->dev->name, print_mac(mac, sta->sta.addr), sta->sta.aid); 662 sdata->dev->name, sta->sta.addr, sta->sta.aid);
663#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 663#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
664} 664}
665 665
@@ -669,8 +669,6 @@ static int ap_sta_ps_end(struct sta_info *sta)
669 struct ieee80211_local *local = sdata->local; 669 struct ieee80211_local *local = sdata->local;
670 struct sk_buff *skb; 670 struct sk_buff *skb;
671 int sent = 0; 671 int sent = 0;
672 struct ieee80211_tx_info *info;
673 DECLARE_MAC_BUF(mac);
674 672
675 atomic_dec(&sdata->bss->num_sta_ps); 673 atomic_dec(&sdata->bss->num_sta_ps);
676 674
@@ -680,27 +678,25 @@ static int ap_sta_ps_end(struct sta_info *sta)
680 sta_info_clear_tim_bit(sta); 678 sta_info_clear_tim_bit(sta);
681 679
682#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 680#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
683 printk(KERN_DEBUG "%s: STA %s aid %d exits power save mode\n", 681 printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n",
684 sdata->dev->name, print_mac(mac, sta->sta.addr), sta->sta.aid); 682 sdata->dev->name, sta->sta.addr, sta->sta.aid);
685#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 683#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
686 684
687 /* Send all buffered frames to the station */ 685 /* Send all buffered frames to the station */
688 while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { 686 while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
689 info = IEEE80211_SKB_CB(skb);
690 sent++; 687 sent++;
691 info->flags |= IEEE80211_TX_CTL_REQUEUE; 688 skb->requeue = 1;
692 dev_queue_xmit(skb); 689 dev_queue_xmit(skb);
693 } 690 }
694 while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) { 691 while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
695 info = IEEE80211_SKB_CB(skb);
696 local->total_ps_buffered--; 692 local->total_ps_buffered--;
697 sent++; 693 sent++;
698#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 694#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
699 printk(KERN_DEBUG "%s: STA %s aid %d send PS frame " 695 printk(KERN_DEBUG "%s: STA %pM aid %d send PS frame "
700 "since STA not sleeping anymore\n", sdata->dev->name, 696 "since STA not sleeping anymore\n", sdata->dev->name,
701 print_mac(mac, sta->sta.addr), sta->sta.aid); 697 sta->sta.addr, sta->sta.aid);
702#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 698#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
703 info->flags |= IEEE80211_TX_CTL_REQUEUE; 699 skb->requeue = 1;
704 dev_queue_xmit(skb); 700 dev_queue_xmit(skb);
705 } 701 }
706 702
@@ -789,15 +785,12 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
789#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 785#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
790 struct ieee80211_hdr *hdr = 786 struct ieee80211_hdr *hdr =
791 (struct ieee80211_hdr *) entry->skb_list.next->data; 787 (struct ieee80211_hdr *) entry->skb_list.next->data;
792 DECLARE_MAC_BUF(mac);
793 DECLARE_MAC_BUF(mac2);
794 printk(KERN_DEBUG "%s: RX reassembly removed oldest " 788 printk(KERN_DEBUG "%s: RX reassembly removed oldest "
795 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d " 789 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d "
796 "addr1=%s addr2=%s\n", 790 "addr1=%pM addr2=%pM\n",
797 sdata->dev->name, idx, 791 sdata->dev->name, idx,
798 jiffies - entry->first_frag_time, entry->seq, 792 jiffies - entry->first_frag_time, entry->seq,
799 entry->last_frag, print_mac(mac, hdr->addr1), 793 entry->last_frag, hdr->addr1, hdr->addr2);
800 print_mac(mac2, hdr->addr2));
801#endif 794#endif
802 __skb_queue_purge(&entry->skb_list); 795 __skb_queue_purge(&entry->skb_list);
803 } 796 }
@@ -866,7 +859,6 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
866 unsigned int frag, seq; 859 unsigned int frag, seq;
867 struct ieee80211_fragment_entry *entry; 860 struct ieee80211_fragment_entry *entry;
868 struct sk_buff *skb; 861 struct sk_buff *skb;
869 DECLARE_MAC_BUF(mac);
870 862
871 hdr = (struct ieee80211_hdr *)rx->skb->data; 863 hdr = (struct ieee80211_hdr *)rx->skb->data;
872 fc = hdr->frame_control; 864 fc = hdr->frame_control;
@@ -970,7 +962,6 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
970 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); 962 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
971 struct sk_buff *skb; 963 struct sk_buff *skb;
972 int no_pending_pkts; 964 int no_pending_pkts;
973 DECLARE_MAC_BUF(mac);
974 __le16 fc = ((struct ieee80211_hdr *)rx->skb->data)->frame_control; 965 __le16 fc = ((struct ieee80211_hdr *)rx->skb->data)->frame_control;
975 966
976 if (likely(!rx->sta || !ieee80211_is_pspoll(fc) || 967 if (likely(!rx->sta || !ieee80211_is_pspoll(fc) ||
@@ -1001,8 +992,8 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
1001 set_sta_flags(rx->sta, WLAN_STA_PSPOLL); 992 set_sta_flags(rx->sta, WLAN_STA_PSPOLL);
1002 993
1003#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 994#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1004 printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n", 995 printk(KERN_DEBUG "STA %pM aid %d: PS Poll (entries after %d)\n",
1005 print_mac(mac, rx->sta->sta.addr), rx->sta->sta.aid, 996 rx->sta->sta.addr, rx->sta->sta.aid,
1006 skb_queue_len(&rx->sta->ps_tx_buf)); 997 skb_queue_len(&rx->sta->ps_tx_buf));
1007#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 998#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1008 999
@@ -1025,9 +1016,9 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
1025 * Should we send it a null-func frame indicating we 1016 * Should we send it a null-func frame indicating we
1026 * have nothing buffered for it? 1017 * have nothing buffered for it?
1027 */ 1018 */
1028 printk(KERN_DEBUG "%s: STA %s sent PS Poll even " 1019 printk(KERN_DEBUG "%s: STA %pM sent PS Poll even "
1029 "though there are no buffered frames for it\n", 1020 "though there are no buffered frames for it\n",
1030 rx->dev->name, print_mac(mac, rx->sta->sta.addr)); 1021 rx->dev->name, rx->sta->sta.addr);
1031#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 1022#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1032 } 1023 }
1033 1024
@@ -1097,10 +1088,6 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
1097 u8 src[ETH_ALEN] __aligned(2); 1088 u8 src[ETH_ALEN] __aligned(2);
1098 struct sk_buff *skb = rx->skb; 1089 struct sk_buff *skb = rx->skb;
1099 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1090 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1100 DECLARE_MAC_BUF(mac);
1101 DECLARE_MAC_BUF(mac2);
1102 DECLARE_MAC_BUF(mac3);
1103 DECLARE_MAC_BUF(mac4);
1104 1091
1105 if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) 1092 if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
1106 return -1; 1093 return -1;
@@ -1279,7 +1266,6 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
1279 int remaining, err; 1266 int remaining, err;
1280 u8 dst[ETH_ALEN]; 1267 u8 dst[ETH_ALEN];
1281 u8 src[ETH_ALEN]; 1268 u8 src[ETH_ALEN];
1282 DECLARE_MAC_BUF(mac);
1283 1269
1284 if (unlikely(!ieee80211_is_data(fc))) 1270 if (unlikely(!ieee80211_is_data(fc)))
1285 return RX_CONTINUE; 1271 return RX_CONTINUE;
@@ -1552,14 +1538,6 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
1552 if (len < IEEE80211_MIN_ACTION_SIZE + 1) 1538 if (len < IEEE80211_MIN_ACTION_SIZE + 1)
1553 return RX_DROP_MONITOR; 1539 return RX_DROP_MONITOR;
1554 1540
1555 /*
1556 * FIXME: revisit this, I'm sure we should handle most
1557 * of these frames in other modes as well!
1558 */
1559 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
1560 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1561 return RX_CONTINUE;
1562
1563 switch (mgmt->u.action.category) { 1541 switch (mgmt->u.action.category) {
1564 case WLAN_CATEGORY_BACK: 1542 case WLAN_CATEGORY_BACK:
1565 switch (mgmt->u.action.u.addba_req.action_code) { 1543 switch (mgmt->u.action.u.addba_req.action_code) {
@@ -1632,8 +1610,6 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev,
1632{ 1610{
1633 int keyidx; 1611 int keyidx;
1634 unsigned int hdrlen; 1612 unsigned int hdrlen;
1635 DECLARE_MAC_BUF(mac);
1636 DECLARE_MAC_BUF(mac2);
1637 1613
1638 hdrlen = ieee80211_hdrlen(hdr->frame_control); 1614 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1639 if (rx->skb->len >= hdrlen + 4) 1615 if (rx->skb->len >= hdrlen + 4)
@@ -2002,17 +1978,17 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2002 1978
2003static inline int seq_less(u16 sq1, u16 sq2) 1979static inline int seq_less(u16 sq1, u16 sq2)
2004{ 1980{
2005 return (((sq1 - sq2) & SEQ_MASK) > (SEQ_MODULO >> 1)); 1981 return ((sq1 - sq2) & SEQ_MASK) > (SEQ_MODULO >> 1);
2006} 1982}
2007 1983
2008static inline u16 seq_inc(u16 sq) 1984static inline u16 seq_inc(u16 sq)
2009{ 1985{
2010 return ((sq + 1) & SEQ_MASK); 1986 return (sq + 1) & SEQ_MASK;
2011} 1987}
2012 1988
2013static inline u16 seq_sub(u16 sq1, u16 sq2) 1989static inline u16 seq_sub(u16 sq1, u16 sq2)
2014{ 1990{
2015 return ((sq1 - sq2) & SEQ_MASK); 1991 return (sq1 - sq2) & SEQ_MASK;
2016} 1992}
2017 1993
2018 1994
@@ -2020,10 +1996,11 @@ static inline u16 seq_sub(u16 sq1, u16 sq2)
2020 * As it function blongs to Rx path it must be called with 1996 * As it function blongs to Rx path it must be called with
2021 * the proper rcu_read_lock protection for its flow. 1997 * the proper rcu_read_lock protection for its flow.
2022 */ 1998 */
2023u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, 1999static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
2024 struct tid_ampdu_rx *tid_agg_rx, 2000 struct tid_ampdu_rx *tid_agg_rx,
2025 struct sk_buff *skb, u16 mpdu_seq_num, 2001 struct sk_buff *skb,
2026 int bar_req) 2002 u16 mpdu_seq_num,
2003 int bar_req)
2027{ 2004{
2028 struct ieee80211_local *local = hw_to_local(hw); 2005 struct ieee80211_local *local = hw_to_local(hw);
2029 struct ieee80211_rx_status status; 2006 struct ieee80211_rx_status status;
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 416bb41099f3..f5c7c3371929 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -159,7 +159,7 @@ ieee80211_rx_mesh_bss_add(struct ieee80211_local *local, u8 *mesh_id, int mesh_i
159{ 159{
160 struct ieee80211_bss *bss; 160 struct ieee80211_bss *bss;
161 161
162 if (mesh_config_len != MESH_CFG_LEN) 162 if (mesh_config_len != IEEE80211_MESH_CONFIG_LEN)
163 return NULL; 163 return NULL;
164 164
165 bss = kzalloc(sizeof(*bss), GFP_ATOMIC); 165 bss = kzalloc(sizeof(*bss), GFP_ATOMIC);
@@ -448,18 +448,17 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)
448 448
449 if (local->hw_scanning) { 449 if (local->hw_scanning) {
450 local->hw_scanning = false; 450 local->hw_scanning = false;
451 if (ieee80211_hw_config(local)) 451 /*
452 printk(KERN_DEBUG "%s: failed to restore operational " 452 * Somebody might have requested channel change during scan
453 "channel after scan\n", wiphy_name(local->hw.wiphy)); 453 * that we won't have acted upon, try now. ieee80211_hw_config
454 454 * will set the flag based on actual changes.
455 */
456 ieee80211_hw_config(local, 0);
455 goto done; 457 goto done;
456 } 458 }
457 459
458 local->sw_scanning = false; 460 local->sw_scanning = false;
459 if (ieee80211_hw_config(local)) 461 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
460 printk(KERN_DEBUG "%s: failed to restore operational "
461 "channel after scan\n", wiphy_name(local->hw.wiphy));
462
463 462
464 netif_tx_lock_bh(local->mdev); 463 netif_tx_lock_bh(local->mdev);
465 netif_addr_lock(local->mdev); 464 netif_addr_lock(local->mdev);
@@ -546,12 +545,9 @@ void ieee80211_scan_work(struct work_struct *work)
546 545
547 if (!skip) { 546 if (!skip) {
548 local->scan_channel = chan; 547 local->scan_channel = chan;
549 if (ieee80211_hw_config(local)) { 548 if (ieee80211_hw_config(local,
550 printk(KERN_DEBUG "%s: failed to set freq to " 549 IEEE80211_CONF_CHANGE_CHANNEL))
551 "%d MHz for scan\n", wiphy_name(local->hw.wiphy),
552 chan->center_freq);
553 skip = 1; 550 skip = 1;
554 }
555 } 551 }
556 552
557 /* advance state machine to next channel/band */ 553 /* advance state machine to next channel/band */
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 7fef8ea1f5ec..b22110a4a75e 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -137,14 +137,12 @@ struct sta_info *sta_info_get_by_idx(struct ieee80211_local *local, int idx,
137static void __sta_info_free(struct ieee80211_local *local, 137static void __sta_info_free(struct ieee80211_local *local,
138 struct sta_info *sta) 138 struct sta_info *sta)
139{ 139{
140 DECLARE_MAC_BUF(mbuf);
141
142 rate_control_free_sta(sta); 140 rate_control_free_sta(sta);
143 rate_control_put(sta->rate_ctrl); 141 rate_control_put(sta->rate_ctrl);
144 142
145#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 143#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
146 printk(KERN_DEBUG "%s: Destroyed STA %s\n", 144 printk(KERN_DEBUG "%s: Destroyed STA %pM\n",
147 wiphy_name(local->hw.wiphy), print_mac(mbuf, sta->sta.addr)); 145 wiphy_name(local->hw.wiphy), sta->sta.addr);
148#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ 146#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
149 147
150 kfree(sta); 148 kfree(sta);
@@ -222,7 +220,6 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
222 struct ieee80211_local *local = sdata->local; 220 struct ieee80211_local *local = sdata->local;
223 struct sta_info *sta; 221 struct sta_info *sta;
224 int i; 222 int i;
225 DECLARE_MAC_BUF(mbuf);
226 223
227 sta = kzalloc(sizeof(*sta) + local->hw.sta_data_size, gfp); 224 sta = kzalloc(sizeof(*sta) + local->hw.sta_data_size, gfp);
228 if (!sta) 225 if (!sta)
@@ -263,8 +260,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
263 skb_queue_head_init(&sta->tx_filtered); 260 skb_queue_head_init(&sta->tx_filtered);
264 261
265#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 262#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
266 printk(KERN_DEBUG "%s: Allocated STA %s\n", 263 printk(KERN_DEBUG "%s: Allocated STA %pM\n",
267 wiphy_name(local->hw.wiphy), print_mac(mbuf, sta->sta.addr)); 264 wiphy_name(local->hw.wiphy), sta->sta.addr);
268#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ 265#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
269 266
270#ifdef CONFIG_MAC80211_MESH 267#ifdef CONFIG_MAC80211_MESH
@@ -281,7 +278,6 @@ int sta_info_insert(struct sta_info *sta)
281 struct ieee80211_sub_if_data *sdata = sta->sdata; 278 struct ieee80211_sub_if_data *sdata = sta->sdata;
282 unsigned long flags; 279 unsigned long flags;
283 int err = 0; 280 int err = 0;
284 DECLARE_MAC_BUF(mac);
285 281
286 /* 282 /*
287 * Can't be a WARN_ON because it can be triggered through a race: 283 * Can't be a WARN_ON because it can be triggered through a race:
@@ -294,7 +290,7 @@ int sta_info_insert(struct sta_info *sta)
294 } 290 }
295 291
296 if (WARN_ON(compare_ether_addr(sta->sta.addr, sdata->dev->dev_addr) == 0 || 292 if (WARN_ON(compare_ether_addr(sta->sta.addr, sdata->dev->dev_addr) == 0 ||
297 is_multicast_ether_addr(sta->sta.addr))) { 293 is_multicast_ether_addr(sta->sta.addr))) {
298 err = -EINVAL; 294 err = -EINVAL;
299 goto out_free; 295 goto out_free;
300 } 296 }
@@ -322,8 +318,8 @@ int sta_info_insert(struct sta_info *sta)
322 } 318 }
323 319
324#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 320#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
325 printk(KERN_DEBUG "%s: Inserted STA %s\n", 321 printk(KERN_DEBUG "%s: Inserted STA %pM\n",
326 wiphy_name(local->hw.wiphy), print_mac(mac, sta->sta.addr)); 322 wiphy_name(local->hw.wiphy), sta->sta.addr);
327#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ 323#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
328 324
329 spin_unlock_irqrestore(&local->sta_lock, flags); 325 spin_unlock_irqrestore(&local->sta_lock, flags);
@@ -423,9 +419,6 @@ static void __sta_info_unlink(struct sta_info **sta)
423{ 419{
424 struct ieee80211_local *local = (*sta)->local; 420 struct ieee80211_local *local = (*sta)->local;
425 struct ieee80211_sub_if_data *sdata = (*sta)->sdata; 421 struct ieee80211_sub_if_data *sdata = (*sta)->sdata;
426#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
427 DECLARE_MAC_BUF(mbuf);
428#endif
429 /* 422 /*
430 * pull caller's reference if we're already gone. 423 * pull caller's reference if we're already gone.
431 */ 424 */
@@ -468,8 +461,8 @@ static void __sta_info_unlink(struct sta_info **sta)
468 } 461 }
469 462
470#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 463#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
471 printk(KERN_DEBUG "%s: Removed STA %s\n", 464 printk(KERN_DEBUG "%s: Removed STA %pM\n",
472 wiphy_name(local->hw.wiphy), print_mac(mbuf, (*sta)->sta.addr)); 465 wiphy_name(local->hw.wiphy), (*sta)->sta.addr);
473#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ 466#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
474 467
475 /* 468 /*
@@ -544,7 +537,6 @@ static void sta_info_cleanup_expire_buffered(struct ieee80211_local *local,
544 unsigned long flags; 537 unsigned long flags;
545 struct sk_buff *skb; 538 struct sk_buff *skb;
546 struct ieee80211_sub_if_data *sdata; 539 struct ieee80211_sub_if_data *sdata;
547 DECLARE_MAC_BUF(mac);
548 540
549 if (skb_queue_empty(&sta->ps_tx_buf)) 541 if (skb_queue_empty(&sta->ps_tx_buf))
550 return; 542 return;
@@ -564,8 +556,8 @@ static void sta_info_cleanup_expire_buffered(struct ieee80211_local *local,
564 sdata = sta->sdata; 556 sdata = sta->sdata;
565 local->total_ps_buffered--; 557 local->total_ps_buffered--;
566#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 558#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
567 printk(KERN_DEBUG "Buffered frame expired (STA " 559 printk(KERN_DEBUG "Buffered frame expired (STA %pM)\n",
568 "%s)\n", print_mac(mac, sta->sta.addr)); 560 sta->sta.addr);
569#endif 561#endif
570 dev_kfree_skb(skb); 562 dev_kfree_skb(skb);
571 563
@@ -809,15 +801,14 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
809 struct ieee80211_local *local = sdata->local; 801 struct ieee80211_local *local = sdata->local;
810 struct sta_info *sta, *tmp; 802 struct sta_info *sta, *tmp;
811 LIST_HEAD(tmp_list); 803 LIST_HEAD(tmp_list);
812 DECLARE_MAC_BUF(mac);
813 unsigned long flags; 804 unsigned long flags;
814 805
815 spin_lock_irqsave(&local->sta_lock, flags); 806 spin_lock_irqsave(&local->sta_lock, flags);
816 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) 807 list_for_each_entry_safe(sta, tmp, &local->sta_list, list)
817 if (time_after(jiffies, sta->last_rx + exp_time)) { 808 if (time_after(jiffies, sta->last_rx + exp_time)) {
818#ifdef CONFIG_MAC80211_IBSS_DEBUG 809#ifdef CONFIG_MAC80211_IBSS_DEBUG
819 printk(KERN_DEBUG "%s: expiring inactive STA %s\n", 810 printk(KERN_DEBUG "%s: expiring inactive STA %pM\n",
820 sdata->dev->name, print_mac(mac, sta->sta.addr)); 811 sdata->dev->name, sta->sta.addr);
821#endif 812#endif
822 __sta_info_unlink(&sta); 813 __sta_info_unlink(&sta);
823 if (sta) 814 if (sta)
@@ -830,7 +821,7 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
830} 821}
831 822
832struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw, 823struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw,
833 const u8 *addr) 824 const u8 *addr)
834{ 825{
835 struct sta_info *sta = sta_info_get(hw_to_local(hw), addr); 826 struct sta_info *sta = sta_info_get(hw_to_local(hw), addr);
836 827
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 168a39a298bd..5ad9250b63ab 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -160,18 +160,20 @@ struct sta_ampdu_mlme {
160 * @list: global linked list entry 160 * @list: global linked list entry
161 * @hnext: hash table linked list pointer 161 * @hnext: hash table linked list pointer
162 * @local: pointer to the global information 162 * @local: pointer to the global information
163 * @sdata: TBD 163 * @sdata: virtual interface this station belongs to
164 * @key: TBD 164 * @key: peer key negotiated with this station, if any
165 * @rate_ctrl: TBD 165 * @rate_ctrl: rate control algorithm reference
166 * @rate_ctrl_priv: TBD 166 * @rate_ctrl_priv: rate control private per-STA pointer
167 * @last_tx_rate: rate used for last transmit, to report to userspace as
168 * "the" transmit rate
167 * @lock: used for locking all fields that require locking, see comments 169 * @lock: used for locking all fields that require locking, see comments
168 * in the header file. 170 * in the header file.
169 * @flaglock: spinlock for flags accesses 171 * @flaglock: spinlock for flags accesses
170 * @addr: MAC address of this STA 172 * @addr: MAC address of this STA
171 * @aid: STA's unique AID (1..2007, 0 = not assigned yet), 173 * @aid: STA's unique AID (1..2007, 0 = not assigned yet),
172 * only used in AP (and IBSS?) mode 174 * only used in AP (and IBSS?) mode
173 * @listen_interval: TBD 175 * @listen_interval: listen interval of this station, when we're acting as AP
174 * @pin_status: TBD 176 * @pin_status: used internally for pinning a STA struct into memory
175 * @flags: STA flags, see &enum ieee80211_sta_info_flags 177 * @flags: STA flags, see &enum ieee80211_sta_info_flags
176 * @ps_tx_buf: buffer of frames to transmit to this station 178 * @ps_tx_buf: buffer of frames to transmit to this station
177 * when it leaves power saving state 179 * when it leaves power saving state
@@ -180,8 +182,8 @@ struct sta_ampdu_mlme {
180 * power saving state 182 * power saving state
181 * @rx_packets: Number of MSDUs received from this STA 183 * @rx_packets: Number of MSDUs received from this STA
182 * @rx_bytes: Number of bytes received from this STA 184 * @rx_bytes: Number of bytes received from this STA
183 * @wep_weak_iv_count: TBD 185 * @wep_weak_iv_count: number of weak WEP IVs received from this station
184 * @last_rx: TBD 186 * @last_rx: time (in jiffies) when last frame was received from this STA
185 * @num_duplicates: number of duplicate frames received from this STA 187 * @num_duplicates: number of duplicate frames received from this STA
186 * @rx_fragments: number of received MPDUs 188 * @rx_fragments: number of received MPDUs
187 * @rx_dropped: number of dropped MPDUs from this STA 189 * @rx_dropped: number of dropped MPDUs from this STA
@@ -189,26 +191,26 @@ struct sta_ampdu_mlme {
189 * @last_qual: qual of last received frame from this STA 191 * @last_qual: qual of last received frame from this STA
190 * @last_noise: noise of last received frame from this STA 192 * @last_noise: noise of last received frame from this STA
191 * @last_seq_ctrl: last received seq/frag number from this STA (per RX queue) 193 * @last_seq_ctrl: last received seq/frag number from this STA (per RX queue)
192 * @tx_filtered_count: TBD 194 * @tx_filtered_count: number of frames the hardware filtered for this STA
193 * @tx_retry_failed: TBD 195 * @tx_retry_failed: number of frames that failed retry
194 * @tx_retry_count: TBD 196 * @tx_retry_count: total number of retries for frames to this STA
195 * @fail_avg: moving percentage of failed MSDUs 197 * @fail_avg: moving percentage of failed MSDUs
196 * @tx_packets: number of RX/TX MSDUs 198 * @tx_packets: number of RX/TX MSDUs
197 * @tx_bytes: TBD 199 * @tx_bytes: number of bytes transmitted to this STA
198 * @tx_fragments: number of transmitted MPDUs 200 * @tx_fragments: number of transmitted MPDUs
199 * @last_txrate_idx: Index of the last used transmit rate 201 * @last_txrate: description of the last used transmit rate
200 * @tid_seq: TBD 202 * @tid_seq: per-TID sequence numbers for sending to this STA
201 * @ampdu_mlme: TBD 203 * @ampdu_mlme: A-MPDU state machine state
202 * @timer_to_tid: identity mapping to ID timers 204 * @timer_to_tid: identity mapping to ID timers
203 * @tid_to_tx_q: map tid to tx queue 205 * @tid_to_tx_q: map tid to tx queue
204 * @llid: Local link ID 206 * @llid: Local link ID
205 * @plid: Peer link ID 207 * @plid: Peer link ID
206 * @reason: Cancel reason on PLINK_HOLDING state 208 * @reason: Cancel reason on PLINK_HOLDING state
207 * @plink_retries: Retries in establishment 209 * @plink_retries: Retries in establishment
208 * @ignore_plink_timer: TBD 210 * @ignore_plink_timer: ignore the peer-link timer (used internally)
209 * @plink_state plink_state: TBD 211 * @plink_state: peer link state
210 * @plink_timeout: TBD 212 * @plink_timeout: timeout of peer link
211 * @plink_timer: TBD 213 * @plink_timer: peer link watch timer
212 * @debugfs: debug filesystem info 214 * @debugfs: debug filesystem info
213 * @sta: station information we share with the driver 215 * @sta: station information we share with the driver
214 */ 216 */
@@ -267,7 +269,7 @@ struct sta_info {
267 unsigned long tx_packets; 269 unsigned long tx_packets;
268 unsigned long tx_bytes; 270 unsigned long tx_bytes;
269 unsigned long tx_fragments; 271 unsigned long tx_fragments;
270 unsigned int last_txrate_idx; 272 struct ieee80211_tx_rate last_tx_rate;
271 u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1]; 273 u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
272 274
273 /* 275 /*
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c
index 34b32bc8f609..38fa111d2dc6 100644
--- a/net/mac80211/tkip.c
+++ b/net/mac80211/tkip.c
@@ -263,10 +263,9 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
263 (iv32 == key->u.tkip.rx[queue].iv32 && 263 (iv32 == key->u.tkip.rx[queue].iv32 &&
264 iv16 <= key->u.tkip.rx[queue].iv16))) { 264 iv16 <= key->u.tkip.rx[queue].iv16))) {
265#ifdef CONFIG_MAC80211_TKIP_DEBUG 265#ifdef CONFIG_MAC80211_TKIP_DEBUG
266 DECLARE_MAC_BUF(mac);
267 printk(KERN_DEBUG "TKIP replay detected for RX frame from " 266 printk(KERN_DEBUG "TKIP replay detected for RX frame from "
268 "%s (RX IV (%04x,%02x) <= prev. IV (%04x,%02x)\n", 267 "%pM (RX IV (%04x,%02x) <= prev. IV (%04x,%02x)\n",
269 print_mac(mac, ta), 268 ta,
270 iv32, iv16, key->u.tkip.rx[queue].iv32, 269 iv32, iv16, key->u.tkip.rx[queue].iv32,
271 key->u.tkip.rx[queue].iv16); 270 key->u.tkip.rx[queue].iv16);
272#endif 271#endif
@@ -287,9 +286,8 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
287 { 286 {
288 int i; 287 int i;
289 u8 key_offset = NL80211_TKIP_DATA_OFFSET_ENCR_KEY; 288 u8 key_offset = NL80211_TKIP_DATA_OFFSET_ENCR_KEY;
290 DECLARE_MAC_BUF(mac); 289 printk(KERN_DEBUG "TKIP decrypt: Phase1 TA=%pM"
291 printk(KERN_DEBUG "TKIP decrypt: Phase1 TA=%s" 290 " TK=", ta);
292 " TK=", print_mac(mac, ta));
293 for (i = 0; i < 16; i++) 291 for (i = 0; i < 16; i++)
294 printk("%02x ", 292 printk("%02x ",
295 key->conf.key[key_offset + i]); 293 key->conf.key[key_offset + i]);
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 1460537faf33..0d81b2cfd1a6 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -46,13 +46,20 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
46 struct ieee80211_local *local = tx->local; 46 struct ieee80211_local *local = tx->local;
47 struct ieee80211_supported_band *sband; 47 struct ieee80211_supported_band *sband;
48 struct ieee80211_hdr *hdr; 48 struct ieee80211_hdr *hdr;
49 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
50
51 /* assume HW handles this */
52 if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
53 return 0;
54
55 /* uh huh? */
56 if (WARN_ON_ONCE(info->control.rates[0].idx < 0))
57 return 0;
49 58
50 sband = local->hw.wiphy->bands[tx->channel->band]; 59 sband = local->hw.wiphy->bands[tx->channel->band];
51 txrate = &sband->bitrates[tx->rate_idx]; 60 txrate = &sband->bitrates[info->control.rates[0].idx];
52 61
53 erp = 0; 62 erp = txrate->flags & IEEE80211_RATE_ERP_G;
54 if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)
55 erp = txrate->flags & IEEE80211_RATE_ERP_G;
56 63
57 /* 64 /*
58 * data and mgmt (except PS Poll): 65 * data and mgmt (except PS Poll):
@@ -116,7 +123,7 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
116 if (r->bitrate > txrate->bitrate) 123 if (r->bitrate > txrate->bitrate)
117 break; 124 break;
118 125
119 if (tx->sdata->bss_conf.basic_rates & BIT(i)) 126 if (tx->sdata->vif.bss_conf.basic_rates & BIT(i))
120 rate = r->bitrate; 127 rate = r->bitrate;
121 128
122 switch (sband->band) { 129 switch (sband->band) {
@@ -150,7 +157,7 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
150 * to closest integer */ 157 * to closest integer */
151 158
152 dur = ieee80211_frame_duration(local, 10, rate, erp, 159 dur = ieee80211_frame_duration(local, 10, rate, erp,
153 tx->sdata->bss_conf.use_short_preamble); 160 tx->sdata->vif.bss_conf.use_short_preamble);
154 161
155 if (next_frag_len) { 162 if (next_frag_len) {
156 /* Frame is fragmented: duration increases with time needed to 163 /* Frame is fragmented: duration increases with time needed to
@@ -159,7 +166,7 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
159 /* next fragment */ 166 /* next fragment */
160 dur += ieee80211_frame_duration(local, next_frag_len, 167 dur += ieee80211_frame_duration(local, next_frag_len,
161 txrate->bitrate, erp, 168 txrate->bitrate, erp,
162 tx->sdata->bss_conf.use_short_preamble); 169 tx->sdata->vif.bss_conf.use_short_preamble);
163 } 170 }
164 171
165 return cpu_to_le16(dur); 172 return cpu_to_le16(dur);
@@ -201,10 +208,9 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
201 tx->sdata->vif.type != NL80211_IFTYPE_ADHOC && 208 tx->sdata->vif.type != NL80211_IFTYPE_ADHOC &&
202 ieee80211_is_data(hdr->frame_control))) { 209 ieee80211_is_data(hdr->frame_control))) {
203#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 210#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
204 DECLARE_MAC_BUF(mac);
205 printk(KERN_DEBUG "%s: dropped data frame to not " 211 printk(KERN_DEBUG "%s: dropped data frame to not "
206 "associated station %s\n", 212 "associated station %pM\n",
207 tx->dev->name, print_mac(mac, hdr->addr1)); 213 tx->dev->name, hdr->addr1);
208#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ 214#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
209 I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); 215 I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc);
210 return TX_DROP; 216 return TX_DROP;
@@ -331,7 +337,6 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
331 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); 337 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
332 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; 338 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
333 u32 staflags; 339 u32 staflags;
334 DECLARE_MAC_BUF(mac);
335 340
336 if (unlikely(!sta || ieee80211_is_probe_resp(hdr->frame_control))) 341 if (unlikely(!sta || ieee80211_is_probe_resp(hdr->frame_control)))
337 return TX_CONTINUE; 342 return TX_CONTINUE;
@@ -341,9 +346,9 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
341 if (unlikely((staflags & WLAN_STA_PS) && 346 if (unlikely((staflags & WLAN_STA_PS) &&
342 !(staflags & WLAN_STA_PSPOLL))) { 347 !(staflags & WLAN_STA_PSPOLL))) {
343#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 348#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
344 printk(KERN_DEBUG "STA %s aid %d: PS buffer (entries " 349 printk(KERN_DEBUG "STA %pM aid %d: PS buffer (entries "
345 "before %d)\n", 350 "before %d)\n",
346 print_mac(mac, sta->sta.addr), sta->sta.aid, 351 sta->sta.addr, sta->sta.aid,
347 skb_queue_len(&sta->ps_tx_buf)); 352 skb_queue_len(&sta->ps_tx_buf));
348#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 353#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
349 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) 354 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
@@ -352,9 +357,9 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
352 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf); 357 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf);
353#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 358#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
354 if (net_ratelimit()) { 359 if (net_ratelimit()) {
355 printk(KERN_DEBUG "%s: STA %s TX " 360 printk(KERN_DEBUG "%s: STA %pM TX "
356 "buffer full - dropping oldest frame\n", 361 "buffer full - dropping oldest frame\n",
357 tx->dev->name, print_mac(mac, sta->sta.addr)); 362 tx->dev->name, sta->sta.addr);
358 } 363 }
359#endif 364#endif
360 dev_kfree_skb(old); 365 dev_kfree_skb(old);
@@ -371,9 +376,9 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
371 } 376 }
372#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 377#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
373 else if (unlikely(test_sta_flags(sta, WLAN_STA_PS))) { 378 else if (unlikely(test_sta_flags(sta, WLAN_STA_PS))) {
374 printk(KERN_DEBUG "%s: STA %s in PS mode, but pspoll " 379 printk(KERN_DEBUG "%s: STA %pM in PS mode, but pspoll "
375 "set -> send frame\n", tx->dev->name, 380 "set -> send frame\n", tx->dev->name,
376 print_mac(mac, sta->sta.addr)); 381 sta->sta.addr);
377 } 382 }
378#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 383#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
379 clear_sta_flags(sta, WLAN_STA_PSPOLL); 384 clear_sta_flags(sta, WLAN_STA_PSPOLL);
@@ -439,140 +444,154 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
439static ieee80211_tx_result debug_noinline 444static ieee80211_tx_result debug_noinline
440ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) 445ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
441{ 446{
442 struct rate_selection rsel;
443 struct ieee80211_supported_band *sband;
444 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); 447 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
448 struct ieee80211_hdr *hdr = (void *)tx->skb->data;
449 struct ieee80211_supported_band *sband;
450 struct ieee80211_rate *rate;
451 int i, len;
452 bool inval = false, rts = false, short_preamble = false;
453 struct ieee80211_tx_rate_control txrc;
445 454
446 sband = tx->local->hw.wiphy->bands[tx->channel->band]; 455 memset(&txrc, 0, sizeof(txrc));
447 456
448 if (likely(tx->rate_idx < 0)) { 457 sband = tx->local->hw.wiphy->bands[tx->channel->band];
449 rate_control_get_rate(tx->sdata, sband, tx->sta,
450 tx->skb, &rsel);
451 if (tx->sta)
452 tx->sta->last_txrate_idx = rsel.rate_idx;
453 tx->rate_idx = rsel.rate_idx;
454 if (unlikely(rsel.probe_idx >= 0)) {
455 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
456 tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG;
457 info->control.retries[0].rate_idx = tx->rate_idx;
458 info->control.retries[0].limit = tx->local->hw.max_altrate_tries;
459 tx->rate_idx = rsel.probe_idx;
460 } else if (info->control.retries[0].limit == 0)
461 info->control.retries[0].rate_idx = -1;
462
463 if (unlikely(tx->rate_idx < 0))
464 return TX_DROP;
465 } else
466 info->control.retries[0].rate_idx = -1;
467 458
468 if (tx->sdata->bss_conf.use_cts_prot && 459 len = min_t(int, tx->skb->len + FCS_LEN,
469 (tx->flags & IEEE80211_TX_FRAGMENTED) && (rsel.nonerp_idx >= 0)) { 460 tx->local->fragmentation_threshold);
470 tx->last_frag_rate_idx = tx->rate_idx; 461
471 if (rsel.probe_idx >= 0) 462 /* set up the tx rate control struct we give the RC algo */
472 tx->flags &= ~IEEE80211_TX_PROBE_LAST_FRAG; 463 txrc.hw = local_to_hw(tx->local);
473 else 464 txrc.sband = sband;
474 tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG; 465 txrc.bss_conf = &tx->sdata->vif.bss_conf;
475 tx->rate_idx = rsel.nonerp_idx; 466 txrc.skb = tx->skb;
476 info->tx_rate_idx = rsel.nonerp_idx; 467 txrc.reported_rate.idx = -1;
477 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; 468 txrc.max_rate_idx = tx->sdata->max_ratectrl_rateidx;
478 } else { 469
479 tx->last_frag_rate_idx = tx->rate_idx; 470 /* set up RTS protection if desired */
480 info->tx_rate_idx = tx->rate_idx; 471 if (tx->local->rts_threshold < IEEE80211_MAX_RTS_THRESHOLD &&
472 len > tx->local->rts_threshold) {
473 txrc.rts = rts = true;
481 } 474 }
482 info->tx_rate_idx = tx->rate_idx;
483 475
484 return TX_CONTINUE; 476 /*
485} 477 * Use short preamble if the BSS can handle it, but not for
478 * management frames unless we know the receiver can handle
479 * that -- the management frame might be to a station that
480 * just wants a probe response.
481 */
482 if (tx->sdata->vif.bss_conf.use_short_preamble &&
483 (ieee80211_is_data(hdr->frame_control) ||
484 (tx->sta && test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))))
485 txrc.short_preamble = short_preamble = true;
486 486
487static ieee80211_tx_result debug_noinline
488ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
489{
490 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
491 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
492 struct ieee80211_supported_band *sband;
493 487
494 sband = tx->local->hw.wiphy->bands[tx->channel->band]; 488 rate_control_get_rate(tx->sdata, tx->sta, &txrc);
489
490 if (unlikely(info->control.rates[0].idx < 0))
491 return TX_DROP;
492
493 if (txrc.reported_rate.idx < 0)
494 txrc.reported_rate = info->control.rates[0];
495 495
496 if (tx->sta) 496 if (tx->sta)
497 info->control.sta = &tx->sta->sta; 497 tx->sta->last_tx_rate = txrc.reported_rate;
498 498
499 if (!info->control.retry_limit) { 499 if (unlikely(!info->control.rates[0].count))
500 if (!is_multicast_ether_addr(hdr->addr1)) { 500 info->control.rates[0].count = 1;
501 int len = min_t(int, tx->skb->len + FCS_LEN,
502 tx->local->fragmentation_threshold);
503 if (len > tx->local->rts_threshold
504 && tx->local->rts_threshold <
505 IEEE80211_MAX_RTS_THRESHOLD) {
506 info->flags |= IEEE80211_TX_CTL_USE_RTS_CTS;
507 info->flags |=
508 IEEE80211_TX_CTL_LONG_RETRY_LIMIT;
509 info->control.retry_limit =
510 tx->local->long_retry_limit;
511 } else {
512 info->control.retry_limit =
513 tx->local->short_retry_limit;
514 }
515 } else {
516 info->control.retry_limit = 1;
517 }
518 }
519 501
520 if (tx->flags & IEEE80211_TX_FRAGMENTED) { 502 if (is_multicast_ether_addr(hdr->addr1)) {
521 /* Do not use multiple retry rates when sending fragmented 503 /*
522 * frames. 504 * XXX: verify the rate is in the basic rateset
523 * TODO: The last fragment could still use multiple retry 505 */
524 * rates. */ 506 return TX_CONTINUE;
525 info->control.retries[0].rate_idx = -1;
526 } 507 }
527 508
528 /* Use CTS protection for unicast frames sent using extended rates if 509 /*
529 * there are associated non-ERP stations and RTS/CTS is not configured 510 * set up the RTS/CTS rate as the fastest basic rate
530 * for the frame. */ 511 * that is not faster than the data rate
531 if ((tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) && 512 *
532 (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_ERP_G) && 513 * XXX: Should this check all retry rates?
533 (tx->flags & IEEE80211_TX_UNICAST) && 514 */
534 tx->sdata->bss_conf.use_cts_prot && 515 if (!(info->control.rates[0].flags & IEEE80211_TX_RC_MCS)) {
535 !(info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)) 516 s8 baserate = 0;
536 info->flags |= IEEE80211_TX_CTL_USE_CTS_PROTECT; 517
537 518 rate = &sband->bitrates[info->control.rates[0].idx];
538 /* Transmit data frames using short preambles if the driver supports 519
539 * short preambles at the selected rate and short preambles are 520 for (i = 0; i < sband->n_bitrates; i++) {
540 * available on the network at the current point in time. */ 521 /* must be a basic rate */
541 if (ieee80211_is_data(hdr->frame_control) && 522 if (!(tx->sdata->vif.bss_conf.basic_rates & BIT(i)))
542 (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) && 523 continue;
543 tx->sdata->bss_conf.use_short_preamble && 524 /* must not be faster than the data rate */
544 (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) { 525 if (sband->bitrates[i].bitrate > rate->bitrate)
545 info->flags |= IEEE80211_TX_CTL_SHORT_PREAMBLE; 526 continue;
527 /* maximum */
528 if (sband->bitrates[baserate].bitrate <
529 sband->bitrates[i].bitrate)
530 baserate = i;
531 }
532
533 info->control.rts_cts_rate_idx = baserate;
546 } 534 }
547 535
548 if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) || 536 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
549 (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) { 537 /*
550 struct ieee80211_rate *rate; 538 * make sure there's no valid rate following
551 s8 baserate = -1; 539 * an invalid one, just in case drivers don't
552 int idx; 540 * take the API seriously to stop at -1.
541 */
542 if (inval) {
543 info->control.rates[i].idx = -1;
544 continue;
545 }
546 if (info->control.rates[i].idx < 0) {
547 inval = true;
548 continue;
549 }
553 550
554 /* Do not use multiple retry rates when using RTS/CTS */ 551 /*
555 info->control.retries[0].rate_idx = -1; 552 * For now assume MCS is already set up correctly, this
553 * needs to be fixed.
554 */
555 if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) {
556 WARN_ON(info->control.rates[i].idx > 76);
557 continue;
558 }
556 559
557 /* Use min(data rate, max base rate) as CTS/RTS rate */ 560 /* set up RTS protection if desired */
558 rate = &sband->bitrates[tx->rate_idx]; 561 if (rts)
562 info->control.rates[i].flags |=
563 IEEE80211_TX_RC_USE_RTS_CTS;
559 564
560 for (idx = 0; idx < sband->n_bitrates; idx++) { 565 /* RC is busted */
561 if (sband->bitrates[idx].bitrate > rate->bitrate) 566 if (WARN_ON_ONCE(info->control.rates[i].idx >=
562 continue; 567 sband->n_bitrates)) {
563 if (tx->sdata->bss_conf.basic_rates & BIT(idx) && 568 info->control.rates[i].idx = -1;
564 (baserate < 0 || 569 continue;
565 (sband->bitrates[baserate].bitrate
566 < sband->bitrates[idx].bitrate)))
567 baserate = idx;
568 } 570 }
569 571
570 if (baserate >= 0) 572 rate = &sband->bitrates[info->control.rates[i].idx];
571 info->control.rts_cts_rate_idx = baserate; 573
572 else 574 /* set up short preamble */
573 info->control.rts_cts_rate_idx = 0; 575 if (short_preamble &&
576 rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
577 info->control.rates[i].flags |=
578 IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
579
580 /* set up G protection */
581 if (!rts && tx->sdata->vif.bss_conf.use_cts_prot &&
582 rate->flags & IEEE80211_RATE_ERP_G)
583 info->control.rates[i].flags |=
584 IEEE80211_TX_RC_USE_CTS_PROTECT;
574 } 585 }
575 586
587 return TX_CONTINUE;
588}
589
590static ieee80211_tx_result debug_noinline
591ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
592{
593 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
594
576 if (tx->sta) 595 if (tx->sta)
577 info->control.sta = &tx->sta->sta; 596 info->control.sta = &tx->sta->sta;
578 597
@@ -602,8 +621,18 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
602 if (ieee80211_hdrlen(hdr->frame_control) < 24) 621 if (ieee80211_hdrlen(hdr->frame_control) < 24)
603 return TX_CONTINUE; 622 return TX_CONTINUE;
604 623
624 /*
625 * Anything but QoS data that has a sequence number field
626 * (is long enough) gets a sequence number from the global
627 * counter.
628 */
605 if (!ieee80211_is_data_qos(hdr->frame_control)) { 629 if (!ieee80211_is_data_qos(hdr->frame_control)) {
630 /* driver should assign sequence number */
606 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; 631 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
632 /* for pure STA mode without beacons, we can do it */
633 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number);
634 tx->sdata->sequence_number += 0x10;
635 tx->sdata->sequence_number &= IEEE80211_SCTL_SEQ;
607 return TX_CONTINUE; 636 return TX_CONTINUE;
608 } 637 }
609 638
@@ -632,6 +661,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
632static ieee80211_tx_result debug_noinline 661static ieee80211_tx_result debug_noinline
633ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) 662ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
634{ 663{
664 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
635 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; 665 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
636 size_t hdrlen, per_fragm, num_fragm, payload_len, left; 666 size_t hdrlen, per_fragm, num_fragm, payload_len, left;
637 struct sk_buff **frags, *first, *frag; 667 struct sk_buff **frags, *first, *frag;
@@ -648,9 +678,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
648 * This scenario is handled in __ieee80211_tx_prepare but extra 678 * This scenario is handled in __ieee80211_tx_prepare but extra
649 * caution taken here as fragmented ampdu may cause Tx stop. 679 * caution taken here as fragmented ampdu may cause Tx stop.
650 */ 680 */
651 if (WARN_ON(tx->flags & IEEE80211_TX_CTL_AMPDU || 681 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
652 skb_get_queue_mapping(tx->skb) >=
653 ieee80211_num_regular_queues(&tx->local->hw)))
654 return TX_DROP; 682 return TX_DROP;
655 683
656 first = tx->skb; 684 first = tx->skb;
@@ -684,20 +712,45 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
684 IEEE80211_ENCRYPT_TAILROOM); 712 IEEE80211_ENCRYPT_TAILROOM);
685 if (!frag) 713 if (!frag)
686 goto fail; 714 goto fail;
715
687 /* Make sure that all fragments use the same priority so 716 /* Make sure that all fragments use the same priority so
688 * that they end up using the same TX queue */ 717 * that they end up using the same TX queue */
689 frag->priority = first->priority; 718 frag->priority = first->priority;
719
690 skb_reserve(frag, tx->local->tx_headroom + 720 skb_reserve(frag, tx->local->tx_headroom +
691 IEEE80211_ENCRYPT_HEADROOM); 721 IEEE80211_ENCRYPT_HEADROOM);
722
723 /* copy TX information */
724 info = IEEE80211_SKB_CB(frag);
725 memcpy(info, first->cb, sizeof(frag->cb));
726
727 /* copy/fill in 802.11 header */
692 fhdr = (struct ieee80211_hdr *) skb_put(frag, hdrlen); 728 fhdr = (struct ieee80211_hdr *) skb_put(frag, hdrlen);
693 memcpy(fhdr, first->data, hdrlen); 729 memcpy(fhdr, first->data, hdrlen);
694 if (i == num_fragm - 2)
695 fhdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREFRAGS);
696 fhdr->seq_ctrl = cpu_to_le16(seq | ((i + 1) & IEEE80211_SCTL_FRAG)); 730 fhdr->seq_ctrl = cpu_to_le16(seq | ((i + 1) & IEEE80211_SCTL_FRAG));
731
732 if (i == num_fragm - 2) {
733 /* clear MOREFRAGS bit for the last fragment */
734 fhdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREFRAGS);
735 } else {
736 /*
737 * No multi-rate retries for fragmented frames, that
738 * would completely throw off the NAV at other STAs.
739 */
740 info->control.rates[1].idx = -1;
741 info->control.rates[2].idx = -1;
742 info->control.rates[3].idx = -1;
743 info->control.rates[4].idx = -1;
744 BUILD_BUG_ON(IEEE80211_TX_MAX_RATES != 5);
745 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE;
746 }
747
748 /* copy data */
697 copylen = left > per_fragm ? per_fragm : left; 749 copylen = left > per_fragm ? per_fragm : left;
698 memcpy(skb_put(frag, copylen), pos, copylen); 750 memcpy(skb_put(frag, copylen), pos, copylen);
699 memcpy(frag->cb, first->cb, sizeof(frag->cb)); 751
700 skb_copy_queue_mapping(frag, first); 752 skb_copy_queue_mapping(frag, first);
753
701 frag->do_not_encrypt = first->do_not_encrypt; 754 frag->do_not_encrypt = first->do_not_encrypt;
702 755
703 pos += copylen; 756 pos += copylen;
@@ -757,12 +810,10 @@ ieee80211_tx_h_calculate_duration(struct ieee80211_tx_data *tx)
757 tx->extra_frag[0]->len); 810 tx->extra_frag[0]->len);
758 811
759 for (i = 0; i < tx->num_extra_frag; i++) { 812 for (i = 0; i < tx->num_extra_frag; i++) {
760 if (i + 1 < tx->num_extra_frag) { 813 if (i + 1 < tx->num_extra_frag)
761 next_len = tx->extra_frag[i + 1]->len; 814 next_len = tx->extra_frag[i + 1]->len;
762 } else { 815 else
763 next_len = 0; 816 next_len = 0;
764 tx->rate_idx = tx->last_frag_rate_idx;
765 }
766 817
767 hdr = (struct ieee80211_hdr *)tx->extra_frag[i]->data; 818 hdr = (struct ieee80211_hdr *)tx->extra_frag[i]->data;
768 hdr->duration_id = ieee80211_duration(tx, 0, next_len); 819 hdr->duration_id = ieee80211_duration(tx, 0, next_len);
@@ -815,7 +866,6 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
815 (struct ieee80211_radiotap_header *) skb->data; 866 (struct ieee80211_radiotap_header *) skb->data;
816 struct ieee80211_supported_band *sband; 867 struct ieee80211_supported_band *sband;
817 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); 868 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len);
818 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
819 869
820 sband = tx->local->hw.wiphy->bands[tx->channel->band]; 870 sband = tx->local->hw.wiphy->bands[tx->channel->band];
821 871
@@ -829,8 +879,6 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
829 */ 879 */
830 880
831 while (!ret) { 881 while (!ret) {
832 int i, target_rate;
833
834 ret = ieee80211_radiotap_iterator_next(&iterator); 882 ret = ieee80211_radiotap_iterator_next(&iterator);
835 883
836 if (ret) 884 if (ret)
@@ -844,38 +892,6 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
844 * get_unaligned((type *)iterator.this_arg) to dereference 892 * get_unaligned((type *)iterator.this_arg) to dereference
845 * iterator.this_arg for type "type" safely on all arches. 893 * iterator.this_arg for type "type" safely on all arches.
846 */ 894 */
847 case IEEE80211_RADIOTAP_RATE:
848 /*
849 * radiotap rate u8 is in 500kbps units eg, 0x02=1Mbps
850 * ieee80211 rate int is in 100kbps units eg, 0x0a=1Mbps
851 */
852 target_rate = (*iterator.this_arg) * 5;
853 for (i = 0; i < sband->n_bitrates; i++) {
854 struct ieee80211_rate *r;
855
856 r = &sband->bitrates[i];
857
858 if (r->bitrate == target_rate) {
859 tx->rate_idx = i;
860 break;
861 }
862 }
863 break;
864
865 case IEEE80211_RADIOTAP_ANTENNA:
866 /*
867 * radiotap uses 0 for 1st ant, mac80211 is 1 for
868 * 1st ant
869 */
870 info->antenna_sel_tx = (*iterator.this_arg) + 1;
871 break;
872
873#if 0
874 case IEEE80211_RADIOTAP_DBM_TX_POWER:
875 control->power_level = *iterator.this_arg;
876 break;
877#endif
878
879 case IEEE80211_RADIOTAP_FLAGS: 895 case IEEE80211_RADIOTAP_FLAGS:
880 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) { 896 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) {
881 /* 897 /*
@@ -933,7 +949,8 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
933 struct ieee80211_sub_if_data *sdata; 949 struct ieee80211_sub_if_data *sdata;
934 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 950 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
935 951
936 int hdrlen; 952 int hdrlen, tid;
953 u8 *qc, *state;
937 954
938 memset(tx, 0, sizeof(*tx)); 955 memset(tx, 0, sizeof(*tx));
939 tx->skb = skb; 956 tx->skb = skb;
@@ -941,8 +958,6 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
941 tx->local = local; 958 tx->local = local;
942 tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev); 959 tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev);
943 tx->channel = local->hw.conf.channel; 960 tx->channel = local->hw.conf.channel;
944 tx->rate_idx = -1;
945 tx->last_frag_rate_idx = -1;
946 /* 961 /*
947 * Set this flag (used below to indicate "automatic fragmentation"), 962 * Set this flag (used below to indicate "automatic fragmentation"),
948 * it will be cleared/left by radiotap as desired. 963 * it will be cleared/left by radiotap as desired.
@@ -966,6 +981,15 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
966 981
967 tx->sta = sta_info_get(local, hdr->addr1); 982 tx->sta = sta_info_get(local, hdr->addr1);
968 983
984 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control)) {
985 qc = ieee80211_get_qos_ctl(hdr);
986 tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
987
988 state = &tx->sta->ampdu_mlme.tid_state_tx[tid];
989 if (*state == HT_AGG_STATE_OPERATIONAL)
990 info->flags |= IEEE80211_TX_CTL_AMPDU;
991 }
992
969 if (is_multicast_ether_addr(hdr->addr1)) { 993 if (is_multicast_ether_addr(hdr->addr1)) {
970 tx->flags &= ~IEEE80211_TX_UNICAST; 994 tx->flags &= ~IEEE80211_TX_UNICAST;
971 info->flags |= IEEE80211_TX_CTL_NO_ACK; 995 info->flags |= IEEE80211_TX_CTL_NO_ACK;
@@ -1043,23 +1067,11 @@ static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb,
1043 if (!tx->extra_frag[i]) 1067 if (!tx->extra_frag[i])
1044 continue; 1068 continue;
1045 info = IEEE80211_SKB_CB(tx->extra_frag[i]); 1069 info = IEEE80211_SKB_CB(tx->extra_frag[i]);
1046 info->flags &= ~(IEEE80211_TX_CTL_USE_RTS_CTS | 1070 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT |
1047 IEEE80211_TX_CTL_USE_CTS_PROTECT |
1048 IEEE80211_TX_CTL_CLEAR_PS_FILT |
1049 IEEE80211_TX_CTL_FIRST_FRAGMENT); 1071 IEEE80211_TX_CTL_FIRST_FRAGMENT);
1050 if (netif_subqueue_stopped(local->mdev, 1072 if (netif_subqueue_stopped(local->mdev,
1051 tx->extra_frag[i])) 1073 tx->extra_frag[i]))
1052 return IEEE80211_TX_FRAG_AGAIN; 1074 return IEEE80211_TX_FRAG_AGAIN;
1053 if (i == tx->num_extra_frag) {
1054 info->tx_rate_idx = tx->last_frag_rate_idx;
1055
1056 if (tx->flags & IEEE80211_TX_PROBE_LAST_FRAG)
1057 info->flags |=
1058 IEEE80211_TX_CTL_RATE_CTRL_PROBE;
1059 else
1060 info->flags &=
1061 ~IEEE80211_TX_CTL_RATE_CTRL_PROBE;
1062 }
1063 1075
1064 ret = local->ops->tx(local_to_hw(local), 1076 ret = local->ops->tx(local_to_hw(local),
1065 tx->extra_frag[i]); 1077 tx->extra_frag[i]);
@@ -1168,7 +1180,7 @@ retry:
1168 * queues, there's no reason for a driver to reject 1180 * queues, there's no reason for a driver to reject
1169 * a frame there, warn and drop it. 1181 * a frame there, warn and drop it.
1170 */ 1182 */
1171 if (WARN_ON(queue >= ieee80211_num_regular_queues(&local->hw))) 1183 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
1172 goto drop; 1184 goto drop;
1173 1185
1174 store = &local->pending_packet[queue]; 1186 store = &local->pending_packet[queue];
@@ -1196,9 +1208,6 @@ retry:
1196 store->skb = skb; 1208 store->skb = skb;
1197 store->extra_frag = tx.extra_frag; 1209 store->extra_frag = tx.extra_frag;
1198 store->num_extra_frag = tx.num_extra_frag; 1210 store->num_extra_frag = tx.num_extra_frag;
1199 store->last_frag_rate_idx = tx.last_frag_rate_idx;
1200 store->last_frag_rate_ctrl_probe =
1201 !!(tx.flags & IEEE80211_TX_PROBE_LAST_FRAG);
1202 } 1211 }
1203 out: 1212 out:
1204 rcu_read_unlock(); 1213 rcu_read_unlock();
@@ -1593,12 +1602,10 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1593 compare_ether_addr(dev->dev_addr, 1602 compare_ether_addr(dev->dev_addr,
1594 skb->data + ETH_ALEN) == 0))) { 1603 skb->data + ETH_ALEN) == 0))) {
1595#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 1604#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1596 DECLARE_MAC_BUF(mac);
1597
1598 if (net_ratelimit()) 1605 if (net_ratelimit())
1599 printk(KERN_DEBUG "%s: dropped frame to %s" 1606 printk(KERN_DEBUG "%s: dropped frame to %pM"
1600 " (unauthorized port)\n", dev->name, 1607 " (unauthorized port)\n", dev->name,
1601 print_mac(mac, hdr.addr1)); 1608 hdr.addr1);
1602#endif 1609#endif
1603 1610
1604 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); 1611 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port);
@@ -1757,10 +1764,7 @@ void ieee80211_tx_pending(unsigned long data)
1757 store = &local->pending_packet[i]; 1764 store = &local->pending_packet[i];
1758 tx.extra_frag = store->extra_frag; 1765 tx.extra_frag = store->extra_frag;
1759 tx.num_extra_frag = store->num_extra_frag; 1766 tx.num_extra_frag = store->num_extra_frag;
1760 tx.last_frag_rate_idx = store->last_frag_rate_idx;
1761 tx.flags = 0; 1767 tx.flags = 0;
1762 if (store->last_frag_rate_ctrl_probe)
1763 tx.flags |= IEEE80211_TX_PROBE_LAST_FRAG;
1764 ret = __ieee80211_tx(local, store->skb, &tx); 1768 ret = __ieee80211_tx(local, store->skb, &tx);
1765 if (ret) { 1769 if (ret) {
1766 if (ret == IEEE80211_TX_FRAG_AGAIN) 1770 if (ret == IEEE80211_TX_FRAG_AGAIN)
@@ -1848,7 +1852,6 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1848 struct ieee80211_sub_if_data *sdata = NULL; 1852 struct ieee80211_sub_if_data *sdata = NULL;
1849 struct ieee80211_if_ap *ap = NULL; 1853 struct ieee80211_if_ap *ap = NULL;
1850 struct ieee80211_if_sta *ifsta = NULL; 1854 struct ieee80211_if_sta *ifsta = NULL;
1851 struct rate_selection rsel;
1852 struct beacon_data *beacon; 1855 struct beacon_data *beacon;
1853 struct ieee80211_supported_band *sband; 1856 struct ieee80211_supported_band *sband;
1854 enum ieee80211_band band = local->hw.conf.channel->band; 1857 enum ieee80211_band band = local->hw.conf.channel->band;
@@ -1952,33 +1955,23 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1952 skb->do_not_encrypt = 1; 1955 skb->do_not_encrypt = 1;
1953 1956
1954 info->band = band; 1957 info->band = band;
1955 rate_control_get_rate(sdata, sband, NULL, skb, &rsel); 1958 /*
1956 1959 * XXX: For now, always use the lowest rate
1957 if (unlikely(rsel.rate_idx < 0)) { 1960 */
1958 if (net_ratelimit()) { 1961 info->control.rates[0].idx = 0;
1959 printk(KERN_DEBUG "%s: ieee80211_beacon_get: " 1962 info->control.rates[0].count = 1;
1960 "no rate found\n", 1963 info->control.rates[1].idx = -1;
1961 wiphy_name(local->hw.wiphy)); 1964 info->control.rates[2].idx = -1;
1962 } 1965 info->control.rates[3].idx = -1;
1963 dev_kfree_skb_any(skb); 1966 info->control.rates[4].idx = -1;
1964 skb = NULL; 1967 BUILD_BUG_ON(IEEE80211_TX_MAX_RATES != 5);
1965 goto out;
1966 }
1967 1968
1968 info->control.vif = vif; 1969 info->control.vif = vif;
1969 info->tx_rate_idx = rsel.rate_idx;
1970 1970
1971 info->flags |= IEEE80211_TX_CTL_NO_ACK; 1971 info->flags |= IEEE80211_TX_CTL_NO_ACK;
1972 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; 1972 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
1973 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; 1973 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
1974 if (sdata->bss_conf.use_short_preamble && 1974 out:
1975 sband->bitrates[rsel.rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE)
1976 info->flags |= IEEE80211_TX_CTL_SHORT_PREAMBLE;
1977
1978 info->antenna_sel_tx = local->hw.conf.antenna_sel_tx;
1979 info->control.retry_limit = 1;
1980
1981out:
1982 rcu_read_unlock(); 1975 rcu_read_unlock();
1983 return skb; 1976 return skb;
1984} 1977}
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index cee4884b9d06..0f841317c7e9 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -239,7 +239,7 @@ __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
239 erp = 0; 239 erp = 0;
240 if (vif) { 240 if (vif) {
241 sdata = vif_to_sdata(vif); 241 sdata = vif_to_sdata(vif);
242 short_preamble = sdata->bss_conf.use_short_preamble; 242 short_preamble = sdata->vif.bss_conf.use_short_preamble;
243 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) 243 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)
244 erp = rate->flags & IEEE80211_RATE_ERP_G; 244 erp = rate->flags & IEEE80211_RATE_ERP_G;
245 } 245 }
@@ -272,7 +272,7 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
272 erp = 0; 272 erp = 0;
273 if (vif) { 273 if (vif) {
274 sdata = vif_to_sdata(vif); 274 sdata = vif_to_sdata(vif);
275 short_preamble = sdata->bss_conf.use_short_preamble; 275 short_preamble = sdata->vif.bss_conf.use_short_preamble;
276 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) 276 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)
277 erp = rate->flags & IEEE80211_RATE_ERP_G; 277 erp = rate->flags & IEEE80211_RATE_ERP_G;
278 } 278 }
@@ -312,7 +312,7 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
312 erp = 0; 312 erp = 0;
313 if (vif) { 313 if (vif) {
314 sdata = vif_to_sdata(vif); 314 sdata = vif_to_sdata(vif);
315 short_preamble = sdata->bss_conf.use_short_preamble; 315 short_preamble = sdata->vif.bss_conf.use_short_preamble;
316 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) 316 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)
317 erp = rate->flags & IEEE80211_RATE_ERP_G; 317 erp = rate->flags & IEEE80211_RATE_ERP_G;
318 } 318 }
@@ -532,8 +532,8 @@ void ieee802_11_parse_elems(u8 *start, size_t len,
532 if (elen >= sizeof(struct ieee80211_ht_cap)) 532 if (elen >= sizeof(struct ieee80211_ht_cap))
533 elems->ht_cap_elem = (void *)pos; 533 elems->ht_cap_elem = (void *)pos;
534 break; 534 break;
535 case WLAN_EID_HT_EXTRA_INFO: 535 case WLAN_EID_HT_INFORMATION:
536 if (elen >= sizeof(struct ieee80211_ht_addt_info)) 536 if (elen >= sizeof(struct ieee80211_ht_info))
537 elems->ht_info_elem = (void *)pos; 537 elems->ht_info_elem = (void *)pos;
538 break; 538 break;
539 case WLAN_EID_MESH_ID: 539 case WLAN_EID_MESH_ID:
@@ -638,19 +638,15 @@ int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freqMHz)
638 638
639 if (chan && !(chan->flags & IEEE80211_CHAN_DISABLED)) { 639 if (chan && !(chan->flags & IEEE80211_CHAN_DISABLED)) {
640 if (sdata->vif.type == NL80211_IFTYPE_ADHOC && 640 if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
641 chan->flags & IEEE80211_CHAN_NO_IBSS) { 641 chan->flags & IEEE80211_CHAN_NO_IBSS)
642 printk(KERN_DEBUG "%s: IBSS not allowed on frequency "
643 "%d MHz\n", sdata->dev->name, chan->center_freq);
644 return ret; 642 return ret;
645 }
646 local->oper_channel = chan; 643 local->oper_channel = chan;
647 644
648 if (local->sw_scanning || local->hw_scanning) 645 if (local->sw_scanning || local->hw_scanning)
649 ret = 0; 646 ret = 0;
650 else 647 else
651 ret = ieee80211_hw_config(local); 648 ret = ieee80211_hw_config(
652 649 local, IEEE80211_CONF_CHANGE_CHANNEL);
653 rate_control_clear(local);
654 } 650 }
655 651
656 return ret; 652 return ret;
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index f0e2d3ecb5c4..7bbb98e846a3 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -49,17 +49,19 @@ void ieee80211_wep_free(struct ieee80211_local *local)
49 crypto_free_blkcipher(local->wep_rx_tfm); 49 crypto_free_blkcipher(local->wep_rx_tfm);
50} 50}
51 51
52static inline int ieee80211_wep_weak_iv(u32 iv, int keylen) 52static inline bool ieee80211_wep_weak_iv(u32 iv, int keylen)
53{ 53{
54 /* Fluhrer, Mantin, and Shamir have reported weaknesses in the 54 /*
55 * Fluhrer, Mantin, and Shamir have reported weaknesses in the
55 * key scheduling algorithm of RC4. At least IVs (KeyByte + 3, 56 * key scheduling algorithm of RC4. At least IVs (KeyByte + 3,
56 * 0xff, N) can be used to speedup attacks, so avoid using them. */ 57 * 0xff, N) can be used to speedup attacks, so avoid using them.
58 */
57 if ((iv & 0xff00) == 0xff00) { 59 if ((iv & 0xff00) == 0xff00) {
58 u8 B = (iv >> 16) & 0xff; 60 u8 B = (iv >> 16) & 0xff;
59 if (B >= 3 && B < 3 + keylen) 61 if (B >= 3 && B < 3 + keylen)
60 return 1; 62 return true;
61 } 63 }
62 return 0; 64 return false;
63} 65}
64 66
65 67
@@ -268,7 +270,7 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
268} 270}
269 271
270 272
271u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key) 273bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
272{ 274{
273 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 275 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
274 unsigned int hdrlen; 276 unsigned int hdrlen;
@@ -276,16 +278,13 @@ u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
276 u32 iv; 278 u32 iv;
277 279
278 if (!ieee80211_has_protected(hdr->frame_control)) 280 if (!ieee80211_has_protected(hdr->frame_control))
279 return NULL; 281 return false;
280 282
281 hdrlen = ieee80211_hdrlen(hdr->frame_control); 283 hdrlen = ieee80211_hdrlen(hdr->frame_control);
282 ivpos = skb->data + hdrlen; 284 ivpos = skb->data + hdrlen;
283 iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; 285 iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];
284 286
285 if (ieee80211_wep_weak_iv(iv, key->conf.keylen)) 287 return ieee80211_wep_weak_iv(iv, key->conf.keylen);
286 return ivpos;
287
288 return NULL;
289} 288}
290 289
291ieee80211_rx_result 290ieee80211_rx_result
@@ -329,6 +328,8 @@ static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
329ieee80211_tx_result 328ieee80211_tx_result
330ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx) 329ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx)
331{ 330{
331 int i;
332
332 ieee80211_tx_set_protected(tx); 333 ieee80211_tx_set_protected(tx);
333 334
334 if (wep_encrypt_skb(tx, tx->skb) < 0) { 335 if (wep_encrypt_skb(tx, tx->skb) < 0) {
@@ -337,9 +338,8 @@ ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx)
337 } 338 }
338 339
339 if (tx->extra_frag) { 340 if (tx->extra_frag) {
340 int i;
341 for (i = 0; i < tx->num_extra_frag; i++) { 341 for (i = 0; i < tx->num_extra_frag; i++) {
342 if (wep_encrypt_skb(tx, tx->extra_frag[i]) < 0) { 342 if (wep_encrypt_skb(tx, tx->extra_frag[i])) {
343 I802_DEBUG_INC(tx->local-> 343 I802_DEBUG_INC(tx->local->
344 tx_handlers_drop_wep); 344 tx_handlers_drop_wep);
345 return TX_DROP; 345 return TX_DROP;
diff --git a/net/mac80211/wep.h b/net/mac80211/wep.h
index e587172115b8..d3f0db48314e 100644
--- a/net/mac80211/wep.h
+++ b/net/mac80211/wep.h
@@ -26,7 +26,7 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
26 struct ieee80211_key *key); 26 struct ieee80211_key *key);
27int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, 27int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
28 struct ieee80211_key *key); 28 struct ieee80211_key *key);
29u8 *ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); 29bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key);
30 30
31ieee80211_rx_result 31ieee80211_rx_result
32ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx); 32ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx);
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index 742f811ca416..63f36e9d1af8 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -147,7 +147,7 @@ static int ieee80211_ioctl_giwname(struct net_device *dev,
147 sband = local->hw.wiphy->bands[IEEE80211_BAND_5GHZ]; 147 sband = local->hw.wiphy->bands[IEEE80211_BAND_5GHZ];
148 if (sband) { 148 if (sband) {
149 is_a = 1; 149 is_a = 1;
150 is_ht |= sband->ht_info.ht_supported; 150 is_ht |= sband->ht_cap.ht_supported;
151 } 151 }
152 152
153 sband = local->hw.wiphy->bands[IEEE80211_BAND_2GHZ]; 153 sband = local->hw.wiphy->bands[IEEE80211_BAND_2GHZ];
@@ -160,7 +160,7 @@ static int ieee80211_ioctl_giwname(struct net_device *dev,
160 if (sband->bitrates[i].bitrate == 60) 160 if (sband->bitrates[i].bitrate == 60)
161 is_g = 1; 161 is_g = 1;
162 } 162 }
163 is_ht |= sband->ht_info.ht_supported; 163 is_ht |= sband->ht_cap.ht_supported;
164 } 164 }
165 165
166 strcpy(name, "IEEE 802.11"); 166 strcpy(name, "IEEE 802.11");
@@ -407,13 +407,6 @@ static int ieee80211_ioctl_siwessid(struct net_device *dev,
407 return 0; 407 return 0;
408 } 408 }
409 409
410 if (sdata->vif.type == NL80211_IFTYPE_AP) {
411 memcpy(sdata->u.ap.ssid, ssid, len);
412 memset(sdata->u.ap.ssid + len, 0,
413 IEEE80211_MAX_SSID_LEN - len);
414 sdata->u.ap.ssid_len = len;
415 return ieee80211_if_config(sdata, IEEE80211_IFCC_SSID);
416 }
417 return -EOPNOTSUPP; 410 return -EOPNOTSUPP;
418} 411}
419 412
@@ -437,15 +430,6 @@ static int ieee80211_ioctl_giwessid(struct net_device *dev,
437 return res; 430 return res;
438 } 431 }
439 432
440 if (sdata->vif.type == NL80211_IFTYPE_AP) {
441 len = sdata->u.ap.ssid_len;
442 if (len > IW_ESSID_MAX_SIZE)
443 len = IW_ESSID_MAX_SIZE;
444 memcpy(ssid, sdata->u.ap.ssid, len);
445 data->length = len;
446 data->flags = 1;
447 return 0;
448 }
449 return -EOPNOTSUPP; 433 return -EOPNOTSUPP;
450} 434}
451 435
@@ -636,8 +620,8 @@ static int ieee80211_ioctl_giwrate(struct net_device *dev,
636 620
637 sta = sta_info_get(local, sdata->u.sta.bssid); 621 sta = sta_info_get(local, sdata->u.sta.bssid);
638 622
639 if (sta && sta->last_txrate_idx < sband->n_bitrates) 623 if (sta && !(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS))
640 rate->value = sband->bitrates[sta->last_txrate_idx].bitrate; 624 rate->value = sband->bitrates[sta->last_tx_rate.idx].bitrate;
641 else 625 else
642 rate->value = 0; 626 rate->value = 0;
643 627
@@ -656,45 +640,35 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev,
656 union iwreq_data *data, char *extra) 640 union iwreq_data *data, char *extra)
657{ 641{
658 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 642 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
659 bool need_reconfig = 0; 643 struct ieee80211_channel* chan = local->hw.conf.channel;
644 u32 reconf_flags = 0;
660 int new_power_level; 645 int new_power_level;
661 646
662 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) 647 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
663 return -EINVAL; 648 return -EINVAL;
664 if (data->txpower.flags & IW_TXPOW_RANGE) 649 if (data->txpower.flags & IW_TXPOW_RANGE)
665 return -EINVAL; 650 return -EINVAL;
651 if (!chan)
652 return -EINVAL;
666 653
667 if (data->txpower.fixed) { 654 if (data->txpower.fixed)
668 new_power_level = data->txpower.value; 655 new_power_level = min(data->txpower.value, chan->max_power);
669 } else { 656 else /* Automatic power level setting */
670 /*
671 * Automatic power level. Use maximum power for the current
672 * channel. Should be part of rate control.
673 */
674 struct ieee80211_channel* chan = local->hw.conf.channel;
675 if (!chan)
676 return -EINVAL;
677
678 new_power_level = chan->max_power; 657 new_power_level = chan->max_power;
679 }
680 658
681 if (local->hw.conf.power_level != new_power_level) { 659 if (local->hw.conf.power_level != new_power_level) {
682 local->hw.conf.power_level = new_power_level; 660 local->hw.conf.power_level = new_power_level;
683 need_reconfig = 1; 661 reconf_flags |= IEEE80211_CONF_CHANGE_POWER;
684 } 662 }
685 663
686 if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) { 664 if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) {
687 local->hw.conf.radio_enabled = !(data->txpower.disabled); 665 local->hw.conf.radio_enabled = !(data->txpower.disabled);
688 need_reconfig = 1; 666 reconf_flags |= IEEE80211_CONF_CHANGE_RADIO_ENABLED;
689 ieee80211_led_radio(local, local->hw.conf.radio_enabled); 667 ieee80211_led_radio(local, local->hw.conf.radio_enabled);
690 } 668 }
691 669
692 if (need_reconfig) { 670 if (reconf_flags)
693 ieee80211_hw_config(local); 671 ieee80211_hw_config(local, reconf_flags);
694 /* The return value of hw_config is not of big interest here,
695 * as it doesn't say that it failed because of _this_ config
696 * change or something else. Ignore it. */
697 }
698 672
699 return 0; 673 return 0;
700} 674}
@@ -806,21 +780,16 @@ static int ieee80211_ioctl_siwretry(struct net_device *dev,
806 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) 780 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
807 return -EINVAL; 781 return -EINVAL;
808 782
809 if (retry->flags & IW_RETRY_MAX) 783 if (retry->flags & IW_RETRY_MAX) {
810 local->long_retry_limit = retry->value; 784 local->hw.conf.long_frame_max_tx_count = retry->value;
811 else if (retry->flags & IW_RETRY_MIN) 785 } else if (retry->flags & IW_RETRY_MIN) {
812 local->short_retry_limit = retry->value; 786 local->hw.conf.short_frame_max_tx_count = retry->value;
813 else { 787 } else {
814 local->long_retry_limit = retry->value; 788 local->hw.conf.long_frame_max_tx_count = retry->value;
815 local->short_retry_limit = retry->value; 789 local->hw.conf.short_frame_max_tx_count = retry->value;
816 } 790 }
817 791
818 if (local->ops->set_retry_limit) { 792 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
819 return local->ops->set_retry_limit(
820 local_to_hw(local),
821 local->short_retry_limit,
822 local->long_retry_limit);
823 }
824 793
825 return 0; 794 return 0;
826} 795}
@@ -837,14 +806,15 @@ static int ieee80211_ioctl_giwretry(struct net_device *dev,
837 /* first return min value, iwconfig will ask max value 806 /* first return min value, iwconfig will ask max value
838 * later if needed */ 807 * later if needed */
839 retry->flags |= IW_RETRY_LIMIT; 808 retry->flags |= IW_RETRY_LIMIT;
840 retry->value = local->short_retry_limit; 809 retry->value = local->hw.conf.short_frame_max_tx_count;
841 if (local->long_retry_limit != local->short_retry_limit) 810 if (local->hw.conf.long_frame_max_tx_count !=
811 local->hw.conf.short_frame_max_tx_count)
842 retry->flags |= IW_RETRY_MIN; 812 retry->flags |= IW_RETRY_MIN;
843 return 0; 813 return 0;
844 } 814 }
845 if (retry->flags & IW_RETRY_MAX) { 815 if (retry->flags & IW_RETRY_MAX) {
846 retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 816 retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
847 retry->value = local->long_retry_limit; 817 retry->value = local->hw.conf.long_frame_max_tx_count;
848 } 818 }
849 819
850 return 0; 820 return 0;
@@ -980,7 +950,7 @@ static int ieee80211_ioctl_siwpower(struct net_device *dev,
980 950
981 if (wrq->disabled) { 951 if (wrq->disabled) {
982 conf->flags &= ~IEEE80211_CONF_PS; 952 conf->flags &= ~IEEE80211_CONF_PS;
983 return ieee80211_hw_config(local); 953 return ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
984 } 954 }
985 955
986 switch (wrq->flags & IW_POWER_MODE) { 956 switch (wrq->flags & IW_POWER_MODE) {
@@ -993,7 +963,7 @@ static int ieee80211_ioctl_siwpower(struct net_device *dev,
993 return -EINVAL; 963 return -EINVAL;
994 } 964 }
995 965
996 return ieee80211_hw_config(local); 966 return ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
997} 967}
998 968
999static int ieee80211_ioctl_giwpower(struct net_device *dev, 969static int ieee80211_ioctl_giwpower(struct net_device *dev,
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 139b5f267b34..ac71b38f7cb5 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -114,8 +114,8 @@ u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb)
114{ 114{
115 struct ieee80211_master_priv *mpriv = netdev_priv(dev); 115 struct ieee80211_master_priv *mpriv = netdev_priv(dev);
116 struct ieee80211_local *local = mpriv->local; 116 struct ieee80211_local *local = mpriv->local;
117 struct ieee80211_hw *hw = &local->hw;
117 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 118 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
118 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
119 struct sta_info *sta; 119 struct sta_info *sta;
120 u16 queue; 120 u16 queue;
121 u8 tid; 121 u8 tid;
@@ -124,21 +124,19 @@ u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb)
124 if (unlikely(queue >= local->hw.queues)) 124 if (unlikely(queue >= local->hw.queues))
125 queue = local->hw.queues - 1; 125 queue = local->hw.queues - 1;
126 126
127 if (info->flags & IEEE80211_TX_CTL_REQUEUE) { 127 if (skb->requeue) {
128 if (!hw->ampdu_queues)
129 return queue;
130
128 rcu_read_lock(); 131 rcu_read_lock();
129 sta = sta_info_get(local, hdr->addr1); 132 sta = sta_info_get(local, hdr->addr1);
130 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; 133 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
131 if (sta) { 134 if (sta) {
132 struct ieee80211_hw *hw = &local->hw;
133 int ampdu_queue = sta->tid_to_tx_q[tid]; 135 int ampdu_queue = sta->tid_to_tx_q[tid];
134 136
135 if ((ampdu_queue < ieee80211_num_queues(hw)) && 137 if ((ampdu_queue < ieee80211_num_queues(hw)) &&
136 test_bit(ampdu_queue, local->queue_pool)) { 138 test_bit(ampdu_queue, local->queue_pool))
137 queue = ampdu_queue; 139 queue = ampdu_queue;
138 info->flags |= IEEE80211_TX_CTL_AMPDU;
139 } else {
140 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
141 }
142 } 140 }
143 rcu_read_unlock(); 141 rcu_read_unlock();
144 142
@@ -159,20 +157,18 @@ u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb)
159 *p++ = ack_policy | tid; 157 *p++ = ack_policy | tid;
160 *p = 0; 158 *p = 0;
161 159
160 if (!hw->ampdu_queues)
161 return queue;
162
162 rcu_read_lock(); 163 rcu_read_lock();
163 164
164 sta = sta_info_get(local, hdr->addr1); 165 sta = sta_info_get(local, hdr->addr1);
165 if (sta) { 166 if (sta) {
166 int ampdu_queue = sta->tid_to_tx_q[tid]; 167 int ampdu_queue = sta->tid_to_tx_q[tid];
167 struct ieee80211_hw *hw = &local->hw;
168 168
169 if ((ampdu_queue < ieee80211_num_queues(hw)) && 169 if ((ampdu_queue < ieee80211_num_queues(hw)) &&
170 test_bit(ampdu_queue, local->queue_pool)) { 170 test_bit(ampdu_queue, local->queue_pool))
171 queue = ampdu_queue; 171 queue = ampdu_queue;
172 info->flags |= IEEE80211_TX_CTL_AMPDU;
173 } else {
174 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
175 }
176 } 172 }
177 173
178 rcu_read_unlock(); 174 rcu_read_unlock();
@@ -206,13 +202,11 @@ int ieee80211_ht_agg_queue_add(struct ieee80211_local *local,
206 * on the previous queue 202 * on the previous queue
207 * since HT is strict in order */ 203 * since HT is strict in order */
208#ifdef CONFIG_MAC80211_HT_DEBUG 204#ifdef CONFIG_MAC80211_HT_DEBUG
209 if (net_ratelimit()) { 205 if (net_ratelimit())
210 DECLARE_MAC_BUF(mac);
211 printk(KERN_DEBUG "allocated aggregation queue" 206 printk(KERN_DEBUG "allocated aggregation queue"
212 " %d tid %d addr %s pool=0x%lX\n", 207 " %d tid %d addr %pM pool=0x%lX\n",
213 i, tid, print_mac(mac, sta->sta.addr), 208 i, tid, sta->sta.addr,
214 local->queue_pool[0]); 209 local->queue_pool[0]);
215 }
216#endif /* CONFIG_MAC80211_HT_DEBUG */ 210#endif /* CONFIG_MAC80211_HT_DEBUG */
217 return 0; 211 return 0;
218 } 212 }
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 6db649480e8f..7aa63caf8d50 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -49,8 +49,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
49 !(tx->flags & IEEE80211_TX_FRAGMENTED) && 49 !(tx->flags & IEEE80211_TX_FRAGMENTED) &&
50 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) && 50 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) &&
51 !wpa_test) { 51 !wpa_test) {
52 /* hwaccel - with no need for preallocated room for Michael MIC 52 /* hwaccel - with no need for preallocated room for MMIC */
53 */
54 return TX_CONTINUE; 53 return TX_CONTINUE;
55 } 54 }
56 55
@@ -67,8 +66,6 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
67#else 66#else
68 authenticator = 1; 67 authenticator = 1;
69#endif 68#endif
70 /* At this point we know we're using ALG_TKIP. To get the MIC key
71 * we now will rely on the offset from the ieee80211_key_conf::key */
72 key_offset = authenticator ? 69 key_offset = authenticator ?
73 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY : 70 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY :
74 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY; 71 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY;
@@ -90,11 +87,8 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
90 u8 mic[MICHAEL_MIC_LEN]; 87 u8 mic[MICHAEL_MIC_LEN];
91 struct sk_buff *skb = rx->skb; 88 struct sk_buff *skb = rx->skb;
92 int authenticator = 1, wpa_test = 0; 89 int authenticator = 1, wpa_test = 0;
93 DECLARE_MAC_BUF(mac);
94 90
95 /* 91 /* No way to verify the MIC if the hardware stripped it */
96 * No way to verify the MIC if the hardware stripped it
97 */
98 if (rx->status->flag & RX_FLAG_MMIC_STRIPPED) 92 if (rx->status->flag & RX_FLAG_MMIC_STRIPPED)
99 return RX_CONTINUE; 93 return RX_CONTINUE;
100 94
@@ -116,8 +110,6 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
116#else 110#else
117 authenticator = 1; 111 authenticator = 1;
118#endif 112#endif
119 /* At this point we know we're using ALG_TKIP. To get the MIC key
120 * we now will rely on the offset from the ieee80211_key_conf::key */
121 key_offset = authenticator ? 113 key_offset = authenticator ?
122 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY : 114 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY :
123 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY; 115 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY;
@@ -202,6 +194,7 @@ ieee80211_tx_result
202ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx) 194ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
203{ 195{
204 struct sk_buff *skb = tx->skb; 196 struct sk_buff *skb = tx->skb;
197 int i;
205 198
206 ieee80211_tx_set_protected(tx); 199 ieee80211_tx_set_protected(tx);
207 200
@@ -209,9 +202,8 @@ ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
209 return TX_DROP; 202 return TX_DROP;
210 203
211 if (tx->extra_frag) { 204 if (tx->extra_frag) {
212 int i;
213 for (i = 0; i < tx->num_extra_frag; i++) { 205 for (i = 0; i < tx->num_extra_frag; i++) {
214 if (tkip_encrypt_skb(tx, tx->extra_frag[i]) < 0) 206 if (tkip_encrypt_skb(tx, tx->extra_frag[i]))
215 return TX_DROP; 207 return TX_DROP;
216 } 208 }
217 } 209 }
@@ -227,7 +219,6 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
227 int hdrlen, res, hwaccel = 0, wpa_test = 0; 219 int hdrlen, res, hwaccel = 0, wpa_test = 0;
228 struct ieee80211_key *key = rx->key; 220 struct ieee80211_key *key = rx->key;
229 struct sk_buff *skb = rx->skb; 221 struct sk_buff *skb = rx->skb;
230 DECLARE_MAC_BUF(mac);
231 222
232 hdrlen = ieee80211_hdrlen(hdr->frame_control); 223 hdrlen = ieee80211_hdrlen(hdr->frame_control);
233 224
@@ -350,7 +341,7 @@ static inline void ccmp_pn2hdr(u8 *hdr, u8 *pn, int key_id)
350} 341}
351 342
352 343
353static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr) 344static inline void ccmp_hdr2pn(u8 *pn, u8 *hdr)
354{ 345{
355 pn[0] = hdr[7]; 346 pn[0] = hdr[7];
356 pn[1] = hdr[6]; 347 pn[1] = hdr[6];
@@ -358,7 +349,6 @@ static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr)
358 pn[3] = hdr[4]; 349 pn[3] = hdr[4];
359 pn[4] = hdr[1]; 350 pn[4] = hdr[1];
360 pn[5] = hdr[0]; 351 pn[5] = hdr[0];
361 return (hdr[3] >> 6) & 0x03;
362} 352}
363 353
364 354
@@ -373,7 +363,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
373 363
374 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && 364 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
375 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { 365 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
376 /* hwaccel - with no need for preallocated room for CCMP " 366 /* hwaccel - with no need for preallocated room for CCMP
377 * header or MIC fields */ 367 * header or MIC fields */
378 info->control.hw_key = &tx->key->conf; 368 info->control.hw_key = &tx->key->conf;
379 return 0; 369 return 0;
@@ -426,6 +416,7 @@ ieee80211_tx_result
426ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx) 416ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
427{ 417{
428 struct sk_buff *skb = tx->skb; 418 struct sk_buff *skb = tx->skb;
419 int i;
429 420
430 ieee80211_tx_set_protected(tx); 421 ieee80211_tx_set_protected(tx);
431 422
@@ -433,9 +424,8 @@ ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
433 return TX_DROP; 424 return TX_DROP;
434 425
435 if (tx->extra_frag) { 426 if (tx->extra_frag) {
436 int i;
437 for (i = 0; i < tx->num_extra_frag; i++) { 427 for (i = 0; i < tx->num_extra_frag; i++) {
438 if (ccmp_encrypt_skb(tx, tx->extra_frag[i]) < 0) 428 if (ccmp_encrypt_skb(tx, tx->extra_frag[i]))
439 return TX_DROP; 429 return TX_DROP;
440 } 430 }
441 } 431 }
@@ -453,7 +443,6 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
453 struct sk_buff *skb = rx->skb; 443 struct sk_buff *skb = rx->skb;
454 u8 pn[CCMP_PN_LEN]; 444 u8 pn[CCMP_PN_LEN];
455 int data_len; 445 int data_len;
456 DECLARE_MAC_BUF(mac);
457 446
458 hdrlen = ieee80211_hdrlen(hdr->frame_control); 447 hdrlen = ieee80211_hdrlen(hdr->frame_control);
459 448
@@ -468,7 +457,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
468 (rx->status->flag & RX_FLAG_IV_STRIPPED)) 457 (rx->status->flag & RX_FLAG_IV_STRIPPED))
469 return RX_CONTINUE; 458 return RX_CONTINUE;
470 459
471 (void) ccmp_hdr2pn(pn, skb->data + hdrlen); 460 ccmp_hdr2pn(pn, skb->data + hdrlen);
472 461
473 if (memcmp(pn, key->u.ccmp.rx_pn[rx->queue], CCMP_PN_LEN) <= 0) { 462 if (memcmp(pn, key->u.ccmp.rx_pn[rx->queue], CCMP_PN_LEN) <= 0) {
474 key->u.ccmp.replays++; 463 key->u.ccmp.replays++;
@@ -483,9 +472,8 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
483 key->u.ccmp.tfm, key->u.ccmp.rx_crypto_buf, 472 key->u.ccmp.tfm, key->u.ccmp.rx_crypto_buf,
484 skb->data + hdrlen + CCMP_HDR_LEN, data_len, 473 skb->data + hdrlen + CCMP_HDR_LEN, data_len,
485 skb->data + skb->len - CCMP_MIC_LEN, 474 skb->data + skb->len - CCMP_MIC_LEN,
486 skb->data + hdrlen + CCMP_HDR_LEN)) { 475 skb->data + hdrlen + CCMP_HDR_LEN))
487 return RX_DROP_UNUSABLE; 476 return RX_DROP_UNUSABLE;
488 }
489 } 477 }
490 478
491 memcpy(key->u.ccmp.rx_pn[rx->queue], pn, CCMP_PN_LEN); 479 memcpy(key->u.ccmp.rx_pn[rx->queue], pn, CCMP_PN_LEN);
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 9a24332fbed8..60aba45023ff 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -820,13 +820,11 @@ static int ip_vs_conn_seq_show(struct seq_file *seq, void *v)
820 820
821#ifdef CONFIG_IP_VS_IPV6 821#ifdef CONFIG_IP_VS_IPV6
822 if (cp->af == AF_INET6) 822 if (cp->af == AF_INET6)
823 seq_printf(seq, 823 seq_printf(seq, "%-3s %pI6 %04X %pI6 %04X %pI6 %04X %-11s %7lu\n",
824 "%-3s " NIP6_FMT " %04X " NIP6_FMT
825 " %04X " NIP6_FMT " %04X %-11s %7lu\n",
826 ip_vs_proto_name(cp->protocol), 824 ip_vs_proto_name(cp->protocol),
827 NIP6(cp->caddr.in6), ntohs(cp->cport), 825 &cp->caddr.in6, ntohs(cp->cport),
828 NIP6(cp->vaddr.in6), ntohs(cp->vport), 826 &cp->vaddr.in6, ntohs(cp->vport),
829 NIP6(cp->daddr.in6), ntohs(cp->dport), 827 &cp->daddr.in6, ntohs(cp->dport),
830 ip_vs_state_name(cp->protocol, cp->state), 828 ip_vs_state_name(cp->protocol, cp->state),
831 (cp->timer.expires-jiffies)/HZ); 829 (cp->timer.expires-jiffies)/HZ);
832 else 830 else
@@ -883,13 +881,11 @@ static int ip_vs_conn_sync_seq_show(struct seq_file *seq, void *v)
883 881
884#ifdef CONFIG_IP_VS_IPV6 882#ifdef CONFIG_IP_VS_IPV6
885 if (cp->af == AF_INET6) 883 if (cp->af == AF_INET6)
886 seq_printf(seq, 884 seq_printf(seq, "%-3s %pI6 %04X %pI6 %04X %pI6 %04X %-11s %-6s %7lu\n",
887 "%-3s " NIP6_FMT " %04X " NIP6_FMT
888 " %04X " NIP6_FMT " %04X %-11s %-6s %7lu\n",
889 ip_vs_proto_name(cp->protocol), 885 ip_vs_proto_name(cp->protocol),
890 NIP6(cp->caddr.in6), ntohs(cp->cport), 886 &cp->caddr.in6, ntohs(cp->cport),
891 NIP6(cp->vaddr.in6), ntohs(cp->vport), 887 &cp->vaddr.in6, ntohs(cp->vport),
892 NIP6(cp->daddr.in6), ntohs(cp->dport), 888 &cp->daddr.in6, ntohs(cp->dport),
893 ip_vs_state_name(cp->protocol, cp->state), 889 ip_vs_state_name(cp->protocol, cp->state),
894 ip_vs_origin_name(cp->flags), 890 ip_vs_origin_name(cp->flags),
895 (cp->timer.expires-jiffies)/HZ); 891 (cp->timer.expires-jiffies)/HZ);
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 958abf3e5f8c..cb3e031335eb 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -730,9 +730,9 @@ static int ip_vs_out_icmp(struct sk_buff *skb, int *related)
730 if (ic == NULL) 730 if (ic == NULL)
731 return NF_DROP; 731 return NF_DROP;
732 732
733 IP_VS_DBG(12, "Outgoing ICMP (%d,%d) %u.%u.%u.%u->%u.%u.%u.%u\n", 733 IP_VS_DBG(12, "Outgoing ICMP (%d,%d) %pI4->%pI4\n",
734 ic->type, ntohs(icmp_id(ic)), 734 ic->type, ntohs(icmp_id(ic)),
735 NIPQUAD(iph->saddr), NIPQUAD(iph->daddr)); 735 &iph->saddr, &iph->daddr);
736 736
737 /* 737 /*
738 * Work through seeing if this is for us. 738 * Work through seeing if this is for us.
@@ -805,9 +805,9 @@ static int ip_vs_out_icmp_v6(struct sk_buff *skb, int *related)
805 if (ic == NULL) 805 if (ic == NULL)
806 return NF_DROP; 806 return NF_DROP;
807 807
808 IP_VS_DBG(12, "Outgoing ICMPv6 (%d,%d) " NIP6_FMT "->" NIP6_FMT "\n", 808 IP_VS_DBG(12, "Outgoing ICMPv6 (%d,%d) %pI6->%pI6\n",
809 ic->icmp6_type, ntohs(icmpv6_id(ic)), 809 ic->icmp6_type, ntohs(icmpv6_id(ic)),
810 NIP6(iph->saddr), NIP6(iph->daddr)); 810 &iph->saddr, &iph->daddr);
811 811
812 /* 812 /*
813 * Work through seeing if this is for us. 813 * Work through seeing if this is for us.
@@ -1070,9 +1070,9 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
1070 if (ic == NULL) 1070 if (ic == NULL)
1071 return NF_DROP; 1071 return NF_DROP;
1072 1072
1073 IP_VS_DBG(12, "Incoming ICMP (%d,%d) %u.%u.%u.%u->%u.%u.%u.%u\n", 1073 IP_VS_DBG(12, "Incoming ICMP (%d,%d) %pI4->%pI4\n",
1074 ic->type, ntohs(icmp_id(ic)), 1074 ic->type, ntohs(icmp_id(ic)),
1075 NIPQUAD(iph->saddr), NIPQUAD(iph->daddr)); 1075 &iph->saddr, &iph->daddr);
1076 1076
1077 /* 1077 /*
1078 * Work through seeing if this is for us. 1078 * Work through seeing if this is for us.
@@ -1127,8 +1127,8 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
1127 /* Ensure the checksum is correct */ 1127 /* Ensure the checksum is correct */
1128 if (!skb_csum_unnecessary(skb) && ip_vs_checksum_complete(skb, ihl)) { 1128 if (!skb_csum_unnecessary(skb) && ip_vs_checksum_complete(skb, ihl)) {
1129 /* Failed checksum! */ 1129 /* Failed checksum! */
1130 IP_VS_DBG(1, "Incoming ICMP: failed checksum from %d.%d.%d.%d!\n", 1130 IP_VS_DBG(1, "Incoming ICMP: failed checksum from %pI4!\n",
1131 NIPQUAD(iph->saddr)); 1131 &iph->saddr);
1132 goto out; 1132 goto out;
1133 } 1133 }
1134 1134
@@ -1175,9 +1175,9 @@ ip_vs_in_icmp_v6(struct sk_buff *skb, int *related, unsigned int hooknum)
1175 if (ic == NULL) 1175 if (ic == NULL)
1176 return NF_DROP; 1176 return NF_DROP;
1177 1177
1178 IP_VS_DBG(12, "Incoming ICMPv6 (%d,%d) " NIP6_FMT "->" NIP6_FMT "\n", 1178 IP_VS_DBG(12, "Incoming ICMPv6 (%d,%d) %pI6->%pI6\n",
1179 ic->icmp6_type, ntohs(icmpv6_id(ic)), 1179 ic->icmp6_type, ntohs(icmpv6_id(ic)),
1180 NIP6(iph->saddr), NIP6(iph->daddr)); 1180 &iph->saddr, &iph->daddr);
1181 1181
1182 /* 1182 /*
1183 * Work through seeing if this is for us. 1183 * Work through seeing if this is for us.
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 0302cf3e5039..e01061f49cdc 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -1168,15 +1168,9 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u,
1168 } 1168 }
1169 1169
1170#ifdef CONFIG_IP_VS_IPV6 1170#ifdef CONFIG_IP_VS_IPV6
1171 if (u->af == AF_INET6) { 1171 if (u->af == AF_INET6 && (u->netmask < 1 || u->netmask > 128)) {
1172 if (!sched->supports_ipv6) { 1172 ret = -EINVAL;
1173 ret = -EAFNOSUPPORT; 1173 goto out_err;
1174 goto out_err;
1175 }
1176 if ((u->netmask < 1) || (u->netmask > 128)) {
1177 ret = -EINVAL;
1178 goto out_err;
1179 }
1180 } 1174 }
1181#endif 1175#endif
1182 1176
@@ -1272,15 +1266,9 @@ ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u)
1272 old_sched = sched; 1266 old_sched = sched;
1273 1267
1274#ifdef CONFIG_IP_VS_IPV6 1268#ifdef CONFIG_IP_VS_IPV6
1275 if (u->af == AF_INET6) { 1269 if (u->af == AF_INET6 && (u->netmask < 1 || u->netmask > 128)) {
1276 if (!sched->supports_ipv6) { 1270 ret = -EINVAL;
1277 ret = -EAFNOSUPPORT; 1271 goto out;
1278 goto out;
1279 }
1280 if ((u->netmask < 1) || (u->netmask > 128)) {
1281 ret = -EINVAL;
1282 goto out;
1283 }
1284 } 1272 }
1285#endif 1273#endif
1286 1274
@@ -1557,7 +1545,7 @@ static struct ctl_table vs_vars[] = {
1557 .data = &sysctl_ip_vs_amemthresh, 1545 .data = &sysctl_ip_vs_amemthresh,
1558 .maxlen = sizeof(int), 1546 .maxlen = sizeof(int),
1559 .mode = 0644, 1547 .mode = 0644,
1560 .proc_handler = &proc_dointvec, 1548 .proc_handler = proc_dointvec,
1561 }, 1549 },
1562#ifdef CONFIG_IP_VS_DEBUG 1550#ifdef CONFIG_IP_VS_DEBUG
1563 { 1551 {
@@ -1565,7 +1553,7 @@ static struct ctl_table vs_vars[] = {
1565 .data = &sysctl_ip_vs_debug_level, 1553 .data = &sysctl_ip_vs_debug_level,
1566 .maxlen = sizeof(int), 1554 .maxlen = sizeof(int),
1567 .mode = 0644, 1555 .mode = 0644,
1568 .proc_handler = &proc_dointvec, 1556 .proc_handler = proc_dointvec,
1569 }, 1557 },
1570#endif 1558#endif
1571 { 1559 {
@@ -1573,28 +1561,28 @@ static struct ctl_table vs_vars[] = {
1573 .data = &sysctl_ip_vs_am_droprate, 1561 .data = &sysctl_ip_vs_am_droprate,
1574 .maxlen = sizeof(int), 1562 .maxlen = sizeof(int),
1575 .mode = 0644, 1563 .mode = 0644,
1576 .proc_handler = &proc_dointvec, 1564 .proc_handler = proc_dointvec,
1577 }, 1565 },
1578 { 1566 {
1579 .procname = "drop_entry", 1567 .procname = "drop_entry",
1580 .data = &sysctl_ip_vs_drop_entry, 1568 .data = &sysctl_ip_vs_drop_entry,
1581 .maxlen = sizeof(int), 1569 .maxlen = sizeof(int),
1582 .mode = 0644, 1570 .mode = 0644,
1583 .proc_handler = &proc_do_defense_mode, 1571 .proc_handler = proc_do_defense_mode,
1584 }, 1572 },
1585 { 1573 {
1586 .procname = "drop_packet", 1574 .procname = "drop_packet",
1587 .data = &sysctl_ip_vs_drop_packet, 1575 .data = &sysctl_ip_vs_drop_packet,
1588 .maxlen = sizeof(int), 1576 .maxlen = sizeof(int),
1589 .mode = 0644, 1577 .mode = 0644,
1590 .proc_handler = &proc_do_defense_mode, 1578 .proc_handler = proc_do_defense_mode,
1591 }, 1579 },
1592 { 1580 {
1593 .procname = "secure_tcp", 1581 .procname = "secure_tcp",
1594 .data = &sysctl_ip_vs_secure_tcp, 1582 .data = &sysctl_ip_vs_secure_tcp,
1595 .maxlen = sizeof(int), 1583 .maxlen = sizeof(int),
1596 .mode = 0644, 1584 .mode = 0644,
1597 .proc_handler = &proc_do_defense_mode, 1585 .proc_handler = proc_do_defense_mode,
1598 }, 1586 },
1599#if 0 1587#if 0
1600 { 1588 {
@@ -1602,84 +1590,84 @@ static struct ctl_table vs_vars[] = {
1602 .data = &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED], 1590 .data = &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED],
1603 .maxlen = sizeof(int), 1591 .maxlen = sizeof(int),
1604 .mode = 0644, 1592 .mode = 0644,
1605 .proc_handler = &proc_dointvec_jiffies, 1593 .proc_handler = proc_dointvec_jiffies,
1606 }, 1594 },
1607 { 1595 {
1608 .procname = "timeout_synsent", 1596 .procname = "timeout_synsent",
1609 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_SENT], 1597 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_SENT],
1610 .maxlen = sizeof(int), 1598 .maxlen = sizeof(int),
1611 .mode = 0644, 1599 .mode = 0644,
1612 .proc_handler = &proc_dointvec_jiffies, 1600 .proc_handler = proc_dointvec_jiffies,
1613 }, 1601 },
1614 { 1602 {
1615 .procname = "timeout_synrecv", 1603 .procname = "timeout_synrecv",
1616 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_RECV], 1604 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_RECV],
1617 .maxlen = sizeof(int), 1605 .maxlen = sizeof(int),
1618 .mode = 0644, 1606 .mode = 0644,
1619 .proc_handler = &proc_dointvec_jiffies, 1607 .proc_handler = proc_dointvec_jiffies,
1620 }, 1608 },
1621 { 1609 {
1622 .procname = "timeout_finwait", 1610 .procname = "timeout_finwait",
1623 .data = &vs_timeout_table_dos.timeout[IP_VS_S_FIN_WAIT], 1611 .data = &vs_timeout_table_dos.timeout[IP_VS_S_FIN_WAIT],
1624 .maxlen = sizeof(int), 1612 .maxlen = sizeof(int),
1625 .mode = 0644, 1613 .mode = 0644,
1626 .proc_handler = &proc_dointvec_jiffies, 1614 .proc_handler = proc_dointvec_jiffies,
1627 }, 1615 },
1628 { 1616 {
1629 .procname = "timeout_timewait", 1617 .procname = "timeout_timewait",
1630 .data = &vs_timeout_table_dos.timeout[IP_VS_S_TIME_WAIT], 1618 .data = &vs_timeout_table_dos.timeout[IP_VS_S_TIME_WAIT],
1631 .maxlen = sizeof(int), 1619 .maxlen = sizeof(int),
1632 .mode = 0644, 1620 .mode = 0644,
1633 .proc_handler = &proc_dointvec_jiffies, 1621 .proc_handler = proc_dointvec_jiffies,
1634 }, 1622 },
1635 { 1623 {
1636 .procname = "timeout_close", 1624 .procname = "timeout_close",
1637 .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE], 1625 .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE],
1638 .maxlen = sizeof(int), 1626 .maxlen = sizeof(int),
1639 .mode = 0644, 1627 .mode = 0644,
1640 .proc_handler = &proc_dointvec_jiffies, 1628 .proc_handler = proc_dointvec_jiffies,
1641 }, 1629 },
1642 { 1630 {
1643 .procname = "timeout_closewait", 1631 .procname = "timeout_closewait",
1644 .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE_WAIT], 1632 .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE_WAIT],
1645 .maxlen = sizeof(int), 1633 .maxlen = sizeof(int),
1646 .mode = 0644, 1634 .mode = 0644,
1647 .proc_handler = &proc_dointvec_jiffies, 1635 .proc_handler = proc_dointvec_jiffies,
1648 }, 1636 },
1649 { 1637 {
1650 .procname = "timeout_lastack", 1638 .procname = "timeout_lastack",
1651 .data = &vs_timeout_table_dos.timeout[IP_VS_S_LAST_ACK], 1639 .data = &vs_timeout_table_dos.timeout[IP_VS_S_LAST_ACK],
1652 .maxlen = sizeof(int), 1640 .maxlen = sizeof(int),
1653 .mode = 0644, 1641 .mode = 0644,
1654 .proc_handler = &proc_dointvec_jiffies, 1642 .proc_handler = proc_dointvec_jiffies,
1655 }, 1643 },
1656 { 1644 {
1657 .procname = "timeout_listen", 1645 .procname = "timeout_listen",
1658 .data = &vs_timeout_table_dos.timeout[IP_VS_S_LISTEN], 1646 .data = &vs_timeout_table_dos.timeout[IP_VS_S_LISTEN],
1659 .maxlen = sizeof(int), 1647 .maxlen = sizeof(int),
1660 .mode = 0644, 1648 .mode = 0644,
1661 .proc_handler = &proc_dointvec_jiffies, 1649 .proc_handler = proc_dointvec_jiffies,
1662 }, 1650 },
1663 { 1651 {
1664 .procname = "timeout_synack", 1652 .procname = "timeout_synack",
1665 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYNACK], 1653 .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYNACK],
1666 .maxlen = sizeof(int), 1654 .maxlen = sizeof(int),
1667 .mode = 0644, 1655 .mode = 0644,
1668 .proc_handler = &proc_dointvec_jiffies, 1656 .proc_handler = proc_dointvec_jiffies,
1669 }, 1657 },
1670 { 1658 {
1671 .procname = "timeout_udp", 1659 .procname = "timeout_udp",
1672 .data = &vs_timeout_table_dos.timeout[IP_VS_S_UDP], 1660 .data = &vs_timeout_table_dos.timeout[IP_VS_S_UDP],
1673 .maxlen = sizeof(int), 1661 .maxlen = sizeof(int),
1674 .mode = 0644, 1662 .mode = 0644,
1675 .proc_handler = &proc_dointvec_jiffies, 1663 .proc_handler = proc_dointvec_jiffies,
1676 }, 1664 },
1677 { 1665 {
1678 .procname = "timeout_icmp", 1666 .procname = "timeout_icmp",
1679 .data = &vs_timeout_table_dos.timeout[IP_VS_S_ICMP], 1667 .data = &vs_timeout_table_dos.timeout[IP_VS_S_ICMP],
1680 .maxlen = sizeof(int), 1668 .maxlen = sizeof(int),
1681 .mode = 0644, 1669 .mode = 0644,
1682 .proc_handler = &proc_dointvec_jiffies, 1670 .proc_handler = proc_dointvec_jiffies,
1683 }, 1671 },
1684#endif 1672#endif
1685 { 1673 {
@@ -1687,35 +1675,35 @@ static struct ctl_table vs_vars[] = {
1687 .data = &sysctl_ip_vs_cache_bypass, 1675 .data = &sysctl_ip_vs_cache_bypass,
1688 .maxlen = sizeof(int), 1676 .maxlen = sizeof(int),
1689 .mode = 0644, 1677 .mode = 0644,
1690 .proc_handler = &proc_dointvec, 1678 .proc_handler = proc_dointvec,
1691 }, 1679 },
1692 { 1680 {
1693 .procname = "expire_nodest_conn", 1681 .procname = "expire_nodest_conn",
1694 .data = &sysctl_ip_vs_expire_nodest_conn, 1682 .data = &sysctl_ip_vs_expire_nodest_conn,
1695 .maxlen = sizeof(int), 1683 .maxlen = sizeof(int),
1696 .mode = 0644, 1684 .mode = 0644,
1697 .proc_handler = &proc_dointvec, 1685 .proc_handler = proc_dointvec,
1698 }, 1686 },
1699 { 1687 {
1700 .procname = "expire_quiescent_template", 1688 .procname = "expire_quiescent_template",
1701 .data = &sysctl_ip_vs_expire_quiescent_template, 1689 .data = &sysctl_ip_vs_expire_quiescent_template,
1702 .maxlen = sizeof(int), 1690 .maxlen = sizeof(int),
1703 .mode = 0644, 1691 .mode = 0644,
1704 .proc_handler = &proc_dointvec, 1692 .proc_handler = proc_dointvec,
1705 }, 1693 },
1706 { 1694 {
1707 .procname = "sync_threshold", 1695 .procname = "sync_threshold",
1708 .data = &sysctl_ip_vs_sync_threshold, 1696 .data = &sysctl_ip_vs_sync_threshold,
1709 .maxlen = sizeof(sysctl_ip_vs_sync_threshold), 1697 .maxlen = sizeof(sysctl_ip_vs_sync_threshold),
1710 .mode = 0644, 1698 .mode = 0644,
1711 .proc_handler = &proc_do_sync_threshold, 1699 .proc_handler = proc_do_sync_threshold,
1712 }, 1700 },
1713 { 1701 {
1714 .procname = "nat_icmp_send", 1702 .procname = "nat_icmp_send",
1715 .data = &sysctl_ip_vs_nat_icmp_send, 1703 .data = &sysctl_ip_vs_nat_icmp_send,
1716 .maxlen = sizeof(int), 1704 .maxlen = sizeof(int),
1717 .mode = 0644, 1705 .mode = 0644,
1718 .proc_handler = &proc_dointvec, 1706 .proc_handler = proc_dointvec,
1719 }, 1707 },
1720 { .ctl_name = 0 } 1708 { .ctl_name = 0 }
1721}; 1709};
@@ -1867,9 +1855,9 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
1867 if (iter->table == ip_vs_svc_table) { 1855 if (iter->table == ip_vs_svc_table) {
1868#ifdef CONFIG_IP_VS_IPV6 1856#ifdef CONFIG_IP_VS_IPV6
1869 if (svc->af == AF_INET6) 1857 if (svc->af == AF_INET6)
1870 seq_printf(seq, "%s [" NIP6_FMT "]:%04X %s ", 1858 seq_printf(seq, "%s [%pI6]:%04X %s ",
1871 ip_vs_proto_name(svc->protocol), 1859 ip_vs_proto_name(svc->protocol),
1872 NIP6(svc->addr.in6), 1860 &svc->addr.in6,
1873 ntohs(svc->port), 1861 ntohs(svc->port),
1874 svc->scheduler->name); 1862 svc->scheduler->name);
1875 else 1863 else
@@ -1895,9 +1883,9 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
1895#ifdef CONFIG_IP_VS_IPV6 1883#ifdef CONFIG_IP_VS_IPV6
1896 if (dest->af == AF_INET6) 1884 if (dest->af == AF_INET6)
1897 seq_printf(seq, 1885 seq_printf(seq,
1898 " -> [" NIP6_FMT "]:%04X" 1886 " -> [%pI6]:%04X"
1899 " %-7s %-6d %-10d %-10d\n", 1887 " %-7s %-6d %-10d %-10d\n",
1900 NIP6(dest->addr.in6), 1888 &dest->addr.in6,
1901 ntohs(dest->port), 1889 ntohs(dest->port),
1902 ip_vs_fwd_name(atomic_read(&dest->conn_flags)), 1890 ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
1903 atomic_read(&dest->weight), 1891 atomic_read(&dest->weight),
@@ -2141,8 +2129,8 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
2141 2129
2142 /* Check for valid protocol: TCP or UDP, even for fwmark!=0 */ 2130 /* Check for valid protocol: TCP or UDP, even for fwmark!=0 */
2143 if (usvc.protocol != IPPROTO_TCP && usvc.protocol != IPPROTO_UDP) { 2131 if (usvc.protocol != IPPROTO_TCP && usvc.protocol != IPPROTO_UDP) {
2144 IP_VS_ERR("set_ctl: invalid protocol: %d %d.%d.%d.%d:%d %s\n", 2132 IP_VS_ERR("set_ctl: invalid protocol: %d %pI4:%d %s\n",
2145 usvc.protocol, NIPQUAD(usvc.addr.ip), 2133 usvc.protocol, &usvc.addr.ip,
2146 ntohs(usvc.port), usvc.sched_name); 2134 ntohs(usvc.port), usvc.sched_name);
2147 ret = -EFAULT; 2135 ret = -EFAULT;
2148 goto out_unlock; 2136 goto out_unlock;
diff --git a/net/netfilter/ipvs/ip_vs_dh.c b/net/netfilter/ipvs/ip_vs_dh.c
index a16943fd72f1..a9dac74bb13f 100644
--- a/net/netfilter/ipvs/ip_vs_dh.c
+++ b/net/netfilter/ipvs/ip_vs_dh.c
@@ -64,9 +64,16 @@ struct ip_vs_dh_bucket {
64/* 64/*
65 * Returns hash value for IPVS DH entry 65 * Returns hash value for IPVS DH entry
66 */ 66 */
67static inline unsigned ip_vs_dh_hashkey(__be32 addr) 67static inline unsigned ip_vs_dh_hashkey(int af, const union nf_inet_addr *addr)
68{ 68{
69 return (ntohl(addr)*2654435761UL) & IP_VS_DH_TAB_MASK; 69 __be32 addr_fold = addr->ip;
70
71#ifdef CONFIG_IP_VS_IPV6
72 if (af == AF_INET6)
73 addr_fold = addr->ip6[0]^addr->ip6[1]^
74 addr->ip6[2]^addr->ip6[3];
75#endif
76 return (ntohl(addr_fold)*2654435761UL) & IP_VS_DH_TAB_MASK;
70} 77}
71 78
72 79
@@ -74,9 +81,10 @@ static inline unsigned ip_vs_dh_hashkey(__be32 addr)
74 * Get ip_vs_dest associated with supplied parameters. 81 * Get ip_vs_dest associated with supplied parameters.
75 */ 82 */
76static inline struct ip_vs_dest * 83static inline struct ip_vs_dest *
77ip_vs_dh_get(struct ip_vs_dh_bucket *tbl, __be32 addr) 84ip_vs_dh_get(int af, struct ip_vs_dh_bucket *tbl,
85 const union nf_inet_addr *addr)
78{ 86{
79 return (tbl[ip_vs_dh_hashkey(addr)]).dest; 87 return (tbl[ip_vs_dh_hashkey(af, addr)]).dest;
80} 88}
81 89
82 90
@@ -202,12 +210,14 @@ ip_vs_dh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
202{ 210{
203 struct ip_vs_dest *dest; 211 struct ip_vs_dest *dest;
204 struct ip_vs_dh_bucket *tbl; 212 struct ip_vs_dh_bucket *tbl;
205 struct iphdr *iph = ip_hdr(skb); 213 struct ip_vs_iphdr iph;
214
215 ip_vs_fill_iphdr(svc->af, skb_network_header(skb), &iph);
206 216
207 IP_VS_DBG(6, "ip_vs_dh_schedule(): Scheduling...\n"); 217 IP_VS_DBG(6, "ip_vs_dh_schedule(): Scheduling...\n");
208 218
209 tbl = (struct ip_vs_dh_bucket *)svc->sched_data; 219 tbl = (struct ip_vs_dh_bucket *)svc->sched_data;
210 dest = ip_vs_dh_get(tbl, iph->daddr); 220 dest = ip_vs_dh_get(svc->af, tbl, &iph.daddr);
211 if (!dest 221 if (!dest
212 || !(dest->flags & IP_VS_DEST_F_AVAILABLE) 222 || !(dest->flags & IP_VS_DEST_F_AVAILABLE)
213 || atomic_read(&dest->weight) <= 0 223 || atomic_read(&dest->weight) <= 0
@@ -215,11 +225,10 @@ ip_vs_dh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
215 return NULL; 225 return NULL;
216 } 226 }
217 227
218 IP_VS_DBG(6, "DH: destination IP address %u.%u.%u.%u " 228 IP_VS_DBG_BUF(6, "DH: destination IP address %s --> server %s:%d\n",
219 "--> server %u.%u.%u.%u:%d\n", 229 IP_VS_DBG_ADDR(svc->af, &iph.daddr),
220 NIPQUAD(iph->daddr), 230 IP_VS_DBG_ADDR(svc->af, &dest->addr),
221 NIPQUAD(dest->addr.ip), 231 ntohs(dest->port));
222 ntohs(dest->port));
223 232
224 return dest; 233 return dest;
225} 234}
@@ -234,9 +243,6 @@ static struct ip_vs_scheduler ip_vs_dh_scheduler =
234 .refcnt = ATOMIC_INIT(0), 243 .refcnt = ATOMIC_INIT(0),
235 .module = THIS_MODULE, 244 .module = THIS_MODULE,
236 .n_list = LIST_HEAD_INIT(ip_vs_dh_scheduler.n_list), 245 .n_list = LIST_HEAD_INIT(ip_vs_dh_scheduler.n_list),
237#ifdef CONFIG_IP_VS_IPV6
238 .supports_ipv6 = 0,
239#endif
240 .init_service = ip_vs_dh_init_svc, 246 .init_service = ip_vs_dh_init_svc,
241 .done_service = ip_vs_dh_done_svc, 247 .done_service = ip_vs_dh_done_svc,
242 .update_service = ip_vs_dh_update_svc, 248 .update_service = ip_vs_dh_update_svc,
diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index 2e7dbd8b73a4..428edbf481cc 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -178,10 +178,8 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
178 &start, &end) != 1) 178 &start, &end) != 1)
179 return 1; 179 return 1;
180 180
181 IP_VS_DBG(7, "PASV response (%u.%u.%u.%u:%d) -> " 181 IP_VS_DBG(7, "PASV response (%pI4:%d) -> %pI4:%d detected\n",
182 "%u.%u.%u.%u:%d detected\n", 182 &from.ip, ntohs(port), &cp->caddr.ip, 0);
183 NIPQUAD(from.ip), ntohs(port),
184 NIPQUAD(cp->caddr.ip), 0);
185 183
186 /* 184 /*
187 * Now update or create an connection entry for it 185 * Now update or create an connection entry for it
@@ -312,8 +310,7 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
312 &start, &end) != 1) 310 &start, &end) != 1)
313 return 1; 311 return 1;
314 312
315 IP_VS_DBG(7, "PORT %u.%u.%u.%u:%d detected\n", 313 IP_VS_DBG(7, "PORT %pI4:%d detected\n", &to.ip, ntohs(port));
316 NIPQUAD(to.ip), ntohs(port));
317 314
318 /* Passive mode off */ 315 /* Passive mode off */
319 cp->app_data = NULL; 316 cp->app_data = NULL;
@@ -321,9 +318,9 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
321 /* 318 /*
322 * Now update or create a connection entry for it 319 * Now update or create a connection entry for it
323 */ 320 */
324 IP_VS_DBG(7, "protocol %s %u.%u.%u.%u:%d %u.%u.%u.%u:%d\n", 321 IP_VS_DBG(7, "protocol %s %pI4:%d %pI4:%d\n",
325 ip_vs_proto_name(iph->protocol), 322 ip_vs_proto_name(iph->protocol),
326 NIPQUAD(to.ip), ntohs(port), NIPQUAD(cp->vaddr.ip), 0); 323 &to.ip, ntohs(port), &cp->vaddr.ip, 0);
327 324
328 n_cp = ip_vs_conn_in_get(AF_INET, iph->protocol, 325 n_cp = ip_vs_conn_in_get(AF_INET, iph->protocol,
329 &to, port, 326 &to, port,
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index 6ecef3518cac..9394f539966a 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -86,7 +86,8 @@ static int sysctl_ip_vs_lblc_expiration = 24*60*60*HZ;
86 */ 86 */
87struct ip_vs_lblc_entry { 87struct ip_vs_lblc_entry {
88 struct list_head list; 88 struct list_head list;
89 __be32 addr; /* destination IP address */ 89 int af; /* address family */
90 union nf_inet_addr addr; /* destination IP address */
90 struct ip_vs_dest *dest; /* real server (cache) */ 91 struct ip_vs_dest *dest; /* real server (cache) */
91 unsigned long lastuse; /* last used time */ 92 unsigned long lastuse; /* last used time */
92}; 93};
@@ -115,7 +116,7 @@ static ctl_table vs_vars_table[] = {
115 .data = &sysctl_ip_vs_lblc_expiration, 116 .data = &sysctl_ip_vs_lblc_expiration,
116 .maxlen = sizeof(int), 117 .maxlen = sizeof(int),
117 .mode = 0644, 118 .mode = 0644,
118 .proc_handler = &proc_dointvec_jiffies, 119 .proc_handler = proc_dointvec_jiffies,
119 }, 120 },
120 { .ctl_name = 0 } 121 { .ctl_name = 0 }
121}; 122};
@@ -137,9 +138,17 @@ static inline void ip_vs_lblc_free(struct ip_vs_lblc_entry *en)
137/* 138/*
138 * Returns hash value for IPVS LBLC entry 139 * Returns hash value for IPVS LBLC entry
139 */ 140 */
140static inline unsigned ip_vs_lblc_hashkey(__be32 addr) 141static inline unsigned
142ip_vs_lblc_hashkey(int af, const union nf_inet_addr *addr)
141{ 143{
142 return (ntohl(addr)*2654435761UL) & IP_VS_LBLC_TAB_MASK; 144 __be32 addr_fold = addr->ip;
145
146#ifdef CONFIG_IP_VS_IPV6
147 if (af == AF_INET6)
148 addr_fold = addr->ip6[0]^addr->ip6[1]^
149 addr->ip6[2]^addr->ip6[3];
150#endif
151 return (ntohl(addr_fold)*2654435761UL) & IP_VS_LBLC_TAB_MASK;
143} 152}
144 153
145 154
@@ -150,7 +159,7 @@ static inline unsigned ip_vs_lblc_hashkey(__be32 addr)
150static void 159static void
151ip_vs_lblc_hash(struct ip_vs_lblc_table *tbl, struct ip_vs_lblc_entry *en) 160ip_vs_lblc_hash(struct ip_vs_lblc_table *tbl, struct ip_vs_lblc_entry *en)
152{ 161{
153 unsigned hash = ip_vs_lblc_hashkey(en->addr); 162 unsigned hash = ip_vs_lblc_hashkey(en->af, &en->addr);
154 163
155 list_add(&en->list, &tbl->bucket[hash]); 164 list_add(&en->list, &tbl->bucket[hash]);
156 atomic_inc(&tbl->entries); 165 atomic_inc(&tbl->entries);
@@ -162,13 +171,14 @@ ip_vs_lblc_hash(struct ip_vs_lblc_table *tbl, struct ip_vs_lblc_entry *en)
162 * lock 171 * lock
163 */ 172 */
164static inline struct ip_vs_lblc_entry * 173static inline struct ip_vs_lblc_entry *
165ip_vs_lblc_get(struct ip_vs_lblc_table *tbl, __be32 addr) 174ip_vs_lblc_get(int af, struct ip_vs_lblc_table *tbl,
175 const union nf_inet_addr *addr)
166{ 176{
167 unsigned hash = ip_vs_lblc_hashkey(addr); 177 unsigned hash = ip_vs_lblc_hashkey(af, addr);
168 struct ip_vs_lblc_entry *en; 178 struct ip_vs_lblc_entry *en;
169 179
170 list_for_each_entry(en, &tbl->bucket[hash], list) 180 list_for_each_entry(en, &tbl->bucket[hash], list)
171 if (en->addr == addr) 181 if (ip_vs_addr_equal(af, &en->addr, addr))
172 return en; 182 return en;
173 183
174 return NULL; 184 return NULL;
@@ -180,12 +190,12 @@ ip_vs_lblc_get(struct ip_vs_lblc_table *tbl, __be32 addr)
180 * address to a server. Called under write lock. 190 * address to a server. Called under write lock.
181 */ 191 */
182static inline struct ip_vs_lblc_entry * 192static inline struct ip_vs_lblc_entry *
183ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, __be32 daddr, 193ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,
184 struct ip_vs_dest *dest) 194 struct ip_vs_dest *dest)
185{ 195{
186 struct ip_vs_lblc_entry *en; 196 struct ip_vs_lblc_entry *en;
187 197
188 en = ip_vs_lblc_get(tbl, daddr); 198 en = ip_vs_lblc_get(dest->af, tbl, daddr);
189 if (!en) { 199 if (!en) {
190 en = kmalloc(sizeof(*en), GFP_ATOMIC); 200 en = kmalloc(sizeof(*en), GFP_ATOMIC);
191 if (!en) { 201 if (!en) {
@@ -193,7 +203,8 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, __be32 daddr,
193 return NULL; 203 return NULL;
194 } 204 }
195 205
196 en->addr = daddr; 206 en->af = dest->af;
207 ip_vs_addr_copy(dest->af, &en->addr, daddr);
197 en->lastuse = jiffies; 208 en->lastuse = jiffies;
198 209
199 atomic_inc(&dest->refcnt); 210 atomic_inc(&dest->refcnt);
@@ -369,7 +380,7 @@ static int ip_vs_lblc_done_svc(struct ip_vs_service *svc)
369 380
370 381
371static inline struct ip_vs_dest * 382static inline struct ip_vs_dest *
372__ip_vs_lblc_schedule(struct ip_vs_service *svc, struct iphdr *iph) 383__ip_vs_lblc_schedule(struct ip_vs_service *svc)
373{ 384{
374 struct ip_vs_dest *dest, *least; 385 struct ip_vs_dest *dest, *least;
375 int loh, doh; 386 int loh, doh;
@@ -420,12 +431,13 @@ __ip_vs_lblc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
420 } 431 }
421 } 432 }
422 433
423 IP_VS_DBG(6, "LBLC: server %d.%d.%d.%d:%d " 434 IP_VS_DBG_BUF(6, "LBLC: server %s:%d "
424 "activeconns %d refcnt %d weight %d overhead %d\n", 435 "activeconns %d refcnt %d weight %d overhead %d\n",
425 NIPQUAD(least->addr.ip), ntohs(least->port), 436 IP_VS_DBG_ADDR(least->af, &least->addr),
426 atomic_read(&least->activeconns), 437 ntohs(least->port),
427 atomic_read(&least->refcnt), 438 atomic_read(&least->activeconns),
428 atomic_read(&least->weight), loh); 439 atomic_read(&least->refcnt),
440 atomic_read(&least->weight), loh);
429 441
430 return least; 442 return least;
431} 443}
@@ -459,15 +471,17 @@ static struct ip_vs_dest *
459ip_vs_lblc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb) 471ip_vs_lblc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
460{ 472{
461 struct ip_vs_lblc_table *tbl = svc->sched_data; 473 struct ip_vs_lblc_table *tbl = svc->sched_data;
462 struct iphdr *iph = ip_hdr(skb); 474 struct ip_vs_iphdr iph;
463 struct ip_vs_dest *dest = NULL; 475 struct ip_vs_dest *dest = NULL;
464 struct ip_vs_lblc_entry *en; 476 struct ip_vs_lblc_entry *en;
465 477
478 ip_vs_fill_iphdr(svc->af, skb_network_header(skb), &iph);
479
466 IP_VS_DBG(6, "ip_vs_lblc_schedule(): Scheduling...\n"); 480 IP_VS_DBG(6, "ip_vs_lblc_schedule(): Scheduling...\n");
467 481
468 /* First look in our cache */ 482 /* First look in our cache */
469 read_lock(&svc->sched_lock); 483 read_lock(&svc->sched_lock);
470 en = ip_vs_lblc_get(tbl, iph->daddr); 484 en = ip_vs_lblc_get(svc->af, tbl, &iph.daddr);
471 if (en) { 485 if (en) {
472 /* We only hold a read lock, but this is atomic */ 486 /* We only hold a read lock, but this is atomic */
473 en->lastuse = jiffies; 487 en->lastuse = jiffies;
@@ -491,7 +505,7 @@ ip_vs_lblc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
491 goto out; 505 goto out;
492 506
493 /* No cache entry or it is invalid, time to schedule */ 507 /* No cache entry or it is invalid, time to schedule */
494 dest = __ip_vs_lblc_schedule(svc, iph); 508 dest = __ip_vs_lblc_schedule(svc);
495 if (!dest) { 509 if (!dest) {
496 IP_VS_DBG(1, "no destination available\n"); 510 IP_VS_DBG(1, "no destination available\n");
497 return NULL; 511 return NULL;
@@ -499,15 +513,13 @@ ip_vs_lblc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
499 513
500 /* If we fail to create a cache entry, we'll just use the valid dest */ 514 /* If we fail to create a cache entry, we'll just use the valid dest */
501 write_lock(&svc->sched_lock); 515 write_lock(&svc->sched_lock);
502 ip_vs_lblc_new(tbl, iph->daddr, dest); 516 ip_vs_lblc_new(tbl, &iph.daddr, dest);
503 write_unlock(&svc->sched_lock); 517 write_unlock(&svc->sched_lock);
504 518
505out: 519out:
506 IP_VS_DBG(6, "LBLC: destination IP address %u.%u.%u.%u " 520 IP_VS_DBG_BUF(6, "LBLC: destination IP address %s --> server %s:%d\n",
507 "--> server %u.%u.%u.%u:%d\n", 521 IP_VS_DBG_ADDR(svc->af, &iph.daddr),
508 NIPQUAD(iph->daddr), 522 IP_VS_DBG_ADDR(svc->af, &dest->addr), ntohs(dest->port));
509 NIPQUAD(dest->addr.ip),
510 ntohs(dest->port));
511 523
512 return dest; 524 return dest;
513} 525}
@@ -522,9 +534,6 @@ static struct ip_vs_scheduler ip_vs_lblc_scheduler =
522 .refcnt = ATOMIC_INIT(0), 534 .refcnt = ATOMIC_INIT(0),
523 .module = THIS_MODULE, 535 .module = THIS_MODULE,
524 .n_list = LIST_HEAD_INIT(ip_vs_lblc_scheduler.n_list), 536 .n_list = LIST_HEAD_INIT(ip_vs_lblc_scheduler.n_list),
525#ifdef CONFIG_IP_VS_IPV6
526 .supports_ipv6 = 0,
527#endif
528 .init_service = ip_vs_lblc_init_svc, 537 .init_service = ip_vs_lblc_init_svc,
529 .done_service = ip_vs_lblc_done_svc, 538 .done_service = ip_vs_lblc_done_svc,
530 .schedule = ip_vs_lblc_schedule, 539 .schedule = ip_vs_lblc_schedule,
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index 1f75ea83bcf8..92dc76a6842c 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -202,12 +202,13 @@ static inline struct ip_vs_dest *ip_vs_dest_set_min(struct ip_vs_dest_set *set)
202 } 202 }
203 } 203 }
204 204
205 IP_VS_DBG(6, "ip_vs_dest_set_min: server %d.%d.%d.%d:%d " 205 IP_VS_DBG_BUF(6, "ip_vs_dest_set_min: server %s:%d "
206 "activeconns %d refcnt %d weight %d overhead %d\n", 206 "activeconns %d refcnt %d weight %d overhead %d\n",
207 NIPQUAD(least->addr.ip), ntohs(least->port), 207 IP_VS_DBG_ADDR(least->af, &least->addr),
208 atomic_read(&least->activeconns), 208 ntohs(least->port),
209 atomic_read(&least->refcnt), 209 atomic_read(&least->activeconns),
210 atomic_read(&least->weight), loh); 210 atomic_read(&least->refcnt),
211 atomic_read(&least->weight), loh);
211 return least; 212 return least;
212} 213}
213 214
@@ -248,12 +249,12 @@ static inline struct ip_vs_dest *ip_vs_dest_set_max(struct ip_vs_dest_set *set)
248 } 249 }
249 } 250 }
250 251
251 IP_VS_DBG(6, "ip_vs_dest_set_max: server %d.%d.%d.%d:%d " 252 IP_VS_DBG_BUF(6, "ip_vs_dest_set_max: server %s:%d "
252 "activeconns %d refcnt %d weight %d overhead %d\n", 253 "activeconns %d refcnt %d weight %d overhead %d\n",
253 NIPQUAD(most->addr.ip), ntohs(most->port), 254 IP_VS_DBG_ADDR(most->af, &most->addr), ntohs(most->port),
254 atomic_read(&most->activeconns), 255 atomic_read(&most->activeconns),
255 atomic_read(&most->refcnt), 256 atomic_read(&most->refcnt),
256 atomic_read(&most->weight), moh); 257 atomic_read(&most->weight), moh);
257 return most; 258 return most;
258} 259}
259 260
@@ -264,7 +265,8 @@ static inline struct ip_vs_dest *ip_vs_dest_set_max(struct ip_vs_dest_set *set)
264 */ 265 */
265struct ip_vs_lblcr_entry { 266struct ip_vs_lblcr_entry {
266 struct list_head list; 267 struct list_head list;
267 __be32 addr; /* destination IP address */ 268 int af; /* address family */
269 union nf_inet_addr addr; /* destination IP address */
268 struct ip_vs_dest_set set; /* destination server set */ 270 struct ip_vs_dest_set set; /* destination server set */
269 unsigned long lastuse; /* last used time */ 271 unsigned long lastuse; /* last used time */
270}; 272};
@@ -293,7 +295,7 @@ static ctl_table vs_vars_table[] = {
293 .data = &sysctl_ip_vs_lblcr_expiration, 295 .data = &sysctl_ip_vs_lblcr_expiration,
294 .maxlen = sizeof(int), 296 .maxlen = sizeof(int),
295 .mode = 0644, 297 .mode = 0644,
296 .proc_handler = &proc_dointvec_jiffies, 298 .proc_handler = proc_dointvec_jiffies,
297 }, 299 },
298 { .ctl_name = 0 } 300 { .ctl_name = 0 }
299}; 301};
@@ -311,9 +313,17 @@ static inline void ip_vs_lblcr_free(struct ip_vs_lblcr_entry *en)
311/* 313/*
312 * Returns hash value for IPVS LBLCR entry 314 * Returns hash value for IPVS LBLCR entry
313 */ 315 */
314static inline unsigned ip_vs_lblcr_hashkey(__be32 addr) 316static inline unsigned
317ip_vs_lblcr_hashkey(int af, const union nf_inet_addr *addr)
315{ 318{
316 return (ntohl(addr)*2654435761UL) & IP_VS_LBLCR_TAB_MASK; 319 __be32 addr_fold = addr->ip;
320
321#ifdef CONFIG_IP_VS_IPV6
322 if (af == AF_INET6)
323 addr_fold = addr->ip6[0]^addr->ip6[1]^
324 addr->ip6[2]^addr->ip6[3];
325#endif
326 return (ntohl(addr_fold)*2654435761UL) & IP_VS_LBLCR_TAB_MASK;
317} 327}
318 328
319 329
@@ -324,7 +334,7 @@ static inline unsigned ip_vs_lblcr_hashkey(__be32 addr)
324static void 334static void
325ip_vs_lblcr_hash(struct ip_vs_lblcr_table *tbl, struct ip_vs_lblcr_entry *en) 335ip_vs_lblcr_hash(struct ip_vs_lblcr_table *tbl, struct ip_vs_lblcr_entry *en)
326{ 336{
327 unsigned hash = ip_vs_lblcr_hashkey(en->addr); 337 unsigned hash = ip_vs_lblcr_hashkey(en->af, &en->addr);
328 338
329 list_add(&en->list, &tbl->bucket[hash]); 339 list_add(&en->list, &tbl->bucket[hash]);
330 atomic_inc(&tbl->entries); 340 atomic_inc(&tbl->entries);
@@ -336,13 +346,14 @@ ip_vs_lblcr_hash(struct ip_vs_lblcr_table *tbl, struct ip_vs_lblcr_entry *en)
336 * read lock. 346 * read lock.
337 */ 347 */
338static inline struct ip_vs_lblcr_entry * 348static inline struct ip_vs_lblcr_entry *
339ip_vs_lblcr_get(struct ip_vs_lblcr_table *tbl, __be32 addr) 349ip_vs_lblcr_get(int af, struct ip_vs_lblcr_table *tbl,
350 const union nf_inet_addr *addr)
340{ 351{
341 unsigned hash = ip_vs_lblcr_hashkey(addr); 352 unsigned hash = ip_vs_lblcr_hashkey(af, addr);
342 struct ip_vs_lblcr_entry *en; 353 struct ip_vs_lblcr_entry *en;
343 354
344 list_for_each_entry(en, &tbl->bucket[hash], list) 355 list_for_each_entry(en, &tbl->bucket[hash], list)
345 if (en->addr == addr) 356 if (ip_vs_addr_equal(af, &en->addr, addr))
346 return en; 357 return en;
347 358
348 return NULL; 359 return NULL;
@@ -354,12 +365,12 @@ ip_vs_lblcr_get(struct ip_vs_lblcr_table *tbl, __be32 addr)
354 * IP address to a server. Called under write lock. 365 * IP address to a server. Called under write lock.
355 */ 366 */
356static inline struct ip_vs_lblcr_entry * 367static inline struct ip_vs_lblcr_entry *
357ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, __be32 daddr, 368ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr,
358 struct ip_vs_dest *dest) 369 struct ip_vs_dest *dest)
359{ 370{
360 struct ip_vs_lblcr_entry *en; 371 struct ip_vs_lblcr_entry *en;
361 372
362 en = ip_vs_lblcr_get(tbl, daddr); 373 en = ip_vs_lblcr_get(dest->af, tbl, daddr);
363 if (!en) { 374 if (!en) {
364 en = kmalloc(sizeof(*en), GFP_ATOMIC); 375 en = kmalloc(sizeof(*en), GFP_ATOMIC);
365 if (!en) { 376 if (!en) {
@@ -367,7 +378,8 @@ ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, __be32 daddr,
367 return NULL; 378 return NULL;
368 } 379 }
369 380
370 en->addr = daddr; 381 en->af = dest->af;
382 ip_vs_addr_copy(dest->af, &en->addr, daddr);
371 en->lastuse = jiffies; 383 en->lastuse = jiffies;
372 384
373 /* initilize its dest set */ 385 /* initilize its dest set */
@@ -544,7 +556,7 @@ static int ip_vs_lblcr_done_svc(struct ip_vs_service *svc)
544 556
545 557
546static inline struct ip_vs_dest * 558static inline struct ip_vs_dest *
547__ip_vs_lblcr_schedule(struct ip_vs_service *svc, struct iphdr *iph) 559__ip_vs_lblcr_schedule(struct ip_vs_service *svc)
548{ 560{
549 struct ip_vs_dest *dest, *least; 561 struct ip_vs_dest *dest, *least;
550 int loh, doh; 562 int loh, doh;
@@ -596,12 +608,13 @@ __ip_vs_lblcr_schedule(struct ip_vs_service *svc, struct iphdr *iph)
596 } 608 }
597 } 609 }
598 610
599 IP_VS_DBG(6, "LBLCR: server %d.%d.%d.%d:%d " 611 IP_VS_DBG_BUF(6, "LBLCR: server %s:%d "
600 "activeconns %d refcnt %d weight %d overhead %d\n", 612 "activeconns %d refcnt %d weight %d overhead %d\n",
601 NIPQUAD(least->addr.ip), ntohs(least->port), 613 IP_VS_DBG_ADDR(least->af, &least->addr),
602 atomic_read(&least->activeconns), 614 ntohs(least->port),
603 atomic_read(&least->refcnt), 615 atomic_read(&least->activeconns),
604 atomic_read(&least->weight), loh); 616 atomic_read(&least->refcnt),
617 atomic_read(&least->weight), loh);
605 618
606 return least; 619 return least;
607} 620}
@@ -635,15 +648,17 @@ static struct ip_vs_dest *
635ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb) 648ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
636{ 649{
637 struct ip_vs_lblcr_table *tbl = svc->sched_data; 650 struct ip_vs_lblcr_table *tbl = svc->sched_data;
638 struct iphdr *iph = ip_hdr(skb); 651 struct ip_vs_iphdr iph;
639 struct ip_vs_dest *dest = NULL; 652 struct ip_vs_dest *dest = NULL;
640 struct ip_vs_lblcr_entry *en; 653 struct ip_vs_lblcr_entry *en;
641 654
655 ip_vs_fill_iphdr(svc->af, skb_network_header(skb), &iph);
656
642 IP_VS_DBG(6, "ip_vs_lblcr_schedule(): Scheduling...\n"); 657 IP_VS_DBG(6, "ip_vs_lblcr_schedule(): Scheduling...\n");
643 658
644 /* First look in our cache */ 659 /* First look in our cache */
645 read_lock(&svc->sched_lock); 660 read_lock(&svc->sched_lock);
646 en = ip_vs_lblcr_get(tbl, iph->daddr); 661 en = ip_vs_lblcr_get(svc->af, tbl, &iph.daddr);
647 if (en) { 662 if (en) {
648 /* We only hold a read lock, but this is atomic */ 663 /* We only hold a read lock, but this is atomic */
649 en->lastuse = jiffies; 664 en->lastuse = jiffies;
@@ -673,7 +688,7 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
673 } 688 }
674 689
675 /* The cache entry is invalid, time to schedule */ 690 /* The cache entry is invalid, time to schedule */
676 dest = __ip_vs_lblcr_schedule(svc, iph); 691 dest = __ip_vs_lblcr_schedule(svc);
677 if (!dest) { 692 if (!dest) {
678 IP_VS_DBG(1, "no destination available\n"); 693 IP_VS_DBG(1, "no destination available\n");
679 read_unlock(&svc->sched_lock); 694 read_unlock(&svc->sched_lock);
@@ -691,7 +706,7 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
691 goto out; 706 goto out;
692 707
693 /* No cache entry, time to schedule */ 708 /* No cache entry, time to schedule */
694 dest = __ip_vs_lblcr_schedule(svc, iph); 709 dest = __ip_vs_lblcr_schedule(svc);
695 if (!dest) { 710 if (!dest) {
696 IP_VS_DBG(1, "no destination available\n"); 711 IP_VS_DBG(1, "no destination available\n");
697 return NULL; 712 return NULL;
@@ -699,15 +714,13 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
699 714
700 /* If we fail to create a cache entry, we'll just use the valid dest */ 715 /* If we fail to create a cache entry, we'll just use the valid dest */
701 write_lock(&svc->sched_lock); 716 write_lock(&svc->sched_lock);
702 ip_vs_lblcr_new(tbl, iph->daddr, dest); 717 ip_vs_lblcr_new(tbl, &iph.daddr, dest);
703 write_unlock(&svc->sched_lock); 718 write_unlock(&svc->sched_lock);
704 719
705out: 720out:
706 IP_VS_DBG(6, "LBLCR: destination IP address %u.%u.%u.%u " 721 IP_VS_DBG_BUF(6, "LBLCR: destination IP address %s --> server %s:%d\n",
707 "--> server %u.%u.%u.%u:%d\n", 722 IP_VS_DBG_ADDR(svc->af, &iph.daddr),
708 NIPQUAD(iph->daddr), 723 IP_VS_DBG_ADDR(svc->af, &dest->addr), ntohs(dest->port));
709 NIPQUAD(dest->addr.ip),
710 ntohs(dest->port));
711 724
712 return dest; 725 return dest;
713} 726}
@@ -722,9 +735,6 @@ static struct ip_vs_scheduler ip_vs_lblcr_scheduler =
722 .refcnt = ATOMIC_INIT(0), 735 .refcnt = ATOMIC_INIT(0),
723 .module = THIS_MODULE, 736 .module = THIS_MODULE,
724 .n_list = LIST_HEAD_INIT(ip_vs_lblcr_scheduler.n_list), 737 .n_list = LIST_HEAD_INIT(ip_vs_lblcr_scheduler.n_list),
725#ifdef CONFIG_IP_VS_IPV6
726 .supports_ipv6 = 0,
727#endif
728 .init_service = ip_vs_lblcr_init_svc, 738 .init_service = ip_vs_lblcr_init_svc,
729 .done_service = ip_vs_lblcr_done_svc, 739 .done_service = ip_vs_lblcr_done_svc,
730 .schedule = ip_vs_lblcr_schedule, 740 .schedule = ip_vs_lblcr_schedule,
diff --git a/net/netfilter/ipvs/ip_vs_lc.c b/net/netfilter/ipvs/ip_vs_lc.c
index b69f808ac461..51912cab777b 100644
--- a/net/netfilter/ipvs/ip_vs_lc.c
+++ b/net/netfilter/ipvs/ip_vs_lc.c
@@ -81,9 +81,6 @@ static struct ip_vs_scheduler ip_vs_lc_scheduler = {
81 .refcnt = ATOMIC_INIT(0), 81 .refcnt = ATOMIC_INIT(0),
82 .module = THIS_MODULE, 82 .module = THIS_MODULE,
83 .n_list = LIST_HEAD_INIT(ip_vs_lc_scheduler.n_list), 83 .n_list = LIST_HEAD_INIT(ip_vs_lc_scheduler.n_list),
84#ifdef CONFIG_IP_VS_IPV6
85 .supports_ipv6 = 1,
86#endif
87 .schedule = ip_vs_lc_schedule, 84 .schedule = ip_vs_lc_schedule,
88}; 85};
89 86
diff --git a/net/netfilter/ipvs/ip_vs_nq.c b/net/netfilter/ipvs/ip_vs_nq.c
index 9a2d8033f08f..6758ad2ceaaf 100644
--- a/net/netfilter/ipvs/ip_vs_nq.c
+++ b/net/netfilter/ipvs/ip_vs_nq.c
@@ -116,9 +116,6 @@ static struct ip_vs_scheduler ip_vs_nq_scheduler =
116 .refcnt = ATOMIC_INIT(0), 116 .refcnt = ATOMIC_INIT(0),
117 .module = THIS_MODULE, 117 .module = THIS_MODULE,
118 .n_list = LIST_HEAD_INIT(ip_vs_nq_scheduler.n_list), 118 .n_list = LIST_HEAD_INIT(ip_vs_nq_scheduler.n_list),
119#ifdef CONFIG_IP_VS_IPV6
120 .supports_ipv6 = 1,
121#endif
122 .schedule = ip_vs_nq_schedule, 119 .schedule = ip_vs_nq_schedule,
123}; 120};
124 121
diff --git a/net/netfilter/ipvs/ip_vs_proto.c b/net/netfilter/ipvs/ip_vs_proto.c
index 0791f9e08feb..a01520e3d6b8 100644
--- a/net/netfilter/ipvs/ip_vs_proto.c
+++ b/net/netfilter/ipvs/ip_vs_proto.c
@@ -164,26 +164,21 @@ ip_vs_tcpudp_debug_packet_v4(struct ip_vs_protocol *pp,
164 if (ih == NULL) 164 if (ih == NULL)
165 sprintf(buf, "%s TRUNCATED", pp->name); 165 sprintf(buf, "%s TRUNCATED", pp->name);
166 else if (ih->frag_off & htons(IP_OFFSET)) 166 else if (ih->frag_off & htons(IP_OFFSET))
167 sprintf(buf, "%s %u.%u.%u.%u->%u.%u.%u.%u frag", 167 sprintf(buf, "%s %pI4->%pI4 frag",
168 pp->name, NIPQUAD(ih->saddr), 168 pp->name, &ih->saddr, &ih->daddr);
169 NIPQUAD(ih->daddr));
170 else { 169 else {
171 __be16 _ports[2], *pptr 170 __be16 _ports[2], *pptr
172; 171;
173 pptr = skb_header_pointer(skb, offset + ih->ihl*4, 172 pptr = skb_header_pointer(skb, offset + ih->ihl*4,
174 sizeof(_ports), _ports); 173 sizeof(_ports), _ports);
175 if (pptr == NULL) 174 if (pptr == NULL)
176 sprintf(buf, "%s TRUNCATED %u.%u.%u.%u->%u.%u.%u.%u", 175 sprintf(buf, "%s TRUNCATED %pI4->%pI4",
177 pp->name, 176 pp->name, &ih->saddr, &ih->daddr);
178 NIPQUAD(ih->saddr),
179 NIPQUAD(ih->daddr));
180 else 177 else
181 sprintf(buf, "%s %u.%u.%u.%u:%u->%u.%u.%u.%u:%u", 178 sprintf(buf, "%s %pI4:%u->%pI4:%u",
182 pp->name, 179 pp->name,
183 NIPQUAD(ih->saddr), 180 &ih->saddr, ntohs(pptr[0]),
184 ntohs(pptr[0]), 181 &ih->daddr, ntohs(pptr[1]));
185 NIPQUAD(ih->daddr),
186 ntohs(pptr[1]));
187 } 182 }
188 183
189 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf); 184 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
@@ -203,26 +198,21 @@ ip_vs_tcpudp_debug_packet_v6(struct ip_vs_protocol *pp,
203 if (ih == NULL) 198 if (ih == NULL)
204 sprintf(buf, "%s TRUNCATED", pp->name); 199 sprintf(buf, "%s TRUNCATED", pp->name);
205 else if (ih->nexthdr == IPPROTO_FRAGMENT) 200 else if (ih->nexthdr == IPPROTO_FRAGMENT)
206 sprintf(buf, "%s " NIP6_FMT "->" NIP6_FMT " frag", 201 sprintf(buf, "%s %pI6->%pI6 frag",
207 pp->name, NIP6(ih->saddr), 202 pp->name, &ih->saddr, &ih->daddr);
208 NIP6(ih->daddr));
209 else { 203 else {
210 __be16 _ports[2], *pptr; 204 __be16 _ports[2], *pptr;
211 205
212 pptr = skb_header_pointer(skb, offset + sizeof(struct ipv6hdr), 206 pptr = skb_header_pointer(skb, offset + sizeof(struct ipv6hdr),
213 sizeof(_ports), _ports); 207 sizeof(_ports), _ports);
214 if (pptr == NULL) 208 if (pptr == NULL)
215 sprintf(buf, "%s TRUNCATED " NIP6_FMT "->" NIP6_FMT, 209 sprintf(buf, "%s TRUNCATED %pI6->%pI6",
216 pp->name, 210 pp->name, &ih->saddr, &ih->daddr);
217 NIP6(ih->saddr),
218 NIP6(ih->daddr));
219 else 211 else
220 sprintf(buf, "%s " NIP6_FMT ":%u->" NIP6_FMT ":%u", 212 sprintf(buf, "%s %pI6:%u->%pI6:%u",
221 pp->name, 213 pp->name,
222 NIP6(ih->saddr), 214 &ih->saddr, ntohs(pptr[0]),
223 ntohs(pptr[0]), 215 &ih->daddr, ntohs(pptr[1]));
224 NIP6(ih->daddr),
225 ntohs(pptr[1]));
226 } 216 }
227 217
228 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf); 218 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
diff --git a/net/netfilter/ipvs/ip_vs_proto_ah_esp.c b/net/netfilter/ipvs/ip_vs_proto_ah_esp.c
index 80ab0c8e5b4a..79f56c1e7c19 100644
--- a/net/netfilter/ipvs/ip_vs_proto_ah_esp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_ah_esp.c
@@ -135,9 +135,8 @@ ah_esp_debug_packet_v4(struct ip_vs_protocol *pp, const struct sk_buff *skb,
135 if (ih == NULL) 135 if (ih == NULL)
136 sprintf(buf, "%s TRUNCATED", pp->name); 136 sprintf(buf, "%s TRUNCATED", pp->name);
137 else 137 else
138 sprintf(buf, "%s %u.%u.%u.%u->%u.%u.%u.%u", 138 sprintf(buf, "%s %pI4->%pI4",
139 pp->name, NIPQUAD(ih->saddr), 139 pp->name, &ih->saddr, &ih->daddr);
140 NIPQUAD(ih->daddr));
141 140
142 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf); 141 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
143} 142}
@@ -154,9 +153,8 @@ ah_esp_debug_packet_v6(struct ip_vs_protocol *pp, const struct sk_buff *skb,
154 if (ih == NULL) 153 if (ih == NULL)
155 sprintf(buf, "%s TRUNCATED", pp->name); 154 sprintf(buf, "%s TRUNCATED", pp->name);
156 else 155 else
157 sprintf(buf, "%s " NIP6_FMT "->" NIP6_FMT, 156 sprintf(buf, "%s %pI6->%pI6",
158 pp->name, NIP6(ih->saddr), 157 pp->name, &ih->saddr, &ih->daddr);
159 NIP6(ih->daddr));
160 158
161 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf); 159 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
162} 160}
diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c
index dd4566ea2bff..8cba41802850 100644
--- a/net/netfilter/ipvs/ip_vs_proto_tcp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c
@@ -192,8 +192,8 @@ tcp_snat_handler(struct sk_buff *skb,
192 /* Adjust TCP checksums */ 192 /* Adjust TCP checksums */
193 if (skb->ip_summed == CHECKSUM_PARTIAL) { 193 if (skb->ip_summed == CHECKSUM_PARTIAL) {
194 tcp_partial_csum_update(cp->af, tcph, &cp->daddr, &cp->vaddr, 194 tcp_partial_csum_update(cp->af, tcph, &cp->daddr, &cp->vaddr,
195 htonl(oldlen), 195 htons(oldlen),
196 htonl(skb->len - tcphoff)); 196 htons(skb->len - tcphoff));
197 } else if (!cp->app) { 197 } else if (!cp->app) {
198 /* Only port and addr are changed, do fast csum update */ 198 /* Only port and addr are changed, do fast csum update */
199 tcp_fast_csum_update(cp->af, tcph, &cp->daddr, &cp->vaddr, 199 tcp_fast_csum_update(cp->af, tcph, &cp->daddr, &cp->vaddr,
@@ -267,8 +267,8 @@ tcp_dnat_handler(struct sk_buff *skb,
267 */ 267 */
268 if (skb->ip_summed == CHECKSUM_PARTIAL) { 268 if (skb->ip_summed == CHECKSUM_PARTIAL) {
269 tcp_partial_csum_update(cp->af, tcph, &cp->daddr, &cp->vaddr, 269 tcp_partial_csum_update(cp->af, tcph, &cp->daddr, &cp->vaddr,
270 htonl(oldlen), 270 htons(oldlen),
271 htonl(skb->len - tcphoff)); 271 htons(skb->len - tcphoff));
272 } else if (!cp->app) { 272 } else if (!cp->app) {
273 /* Only port and addr are changed, do fast csum update */ 273 /* Only port and addr are changed, do fast csum update */
274 tcp_fast_csum_update(cp->af, tcph, &cp->vaddr, &cp->daddr, 274 tcp_fast_csum_update(cp->af, tcph, &cp->vaddr, &cp->daddr,
diff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c
index 6eb6039d6343..d2930a71084b 100644
--- a/net/netfilter/ipvs/ip_vs_proto_udp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_udp.c
@@ -203,8 +203,8 @@ udp_snat_handler(struct sk_buff *skb,
203 */ 203 */
204 if (skb->ip_summed == CHECKSUM_PARTIAL) { 204 if (skb->ip_summed == CHECKSUM_PARTIAL) {
205 udp_partial_csum_update(cp->af, udph, &cp->daddr, &cp->vaddr, 205 udp_partial_csum_update(cp->af, udph, &cp->daddr, &cp->vaddr,
206 htonl(oldlen), 206 htons(oldlen),
207 htonl(skb->len - udphoff)); 207 htons(skb->len - udphoff));
208 } else if (!cp->app && (udph->check != 0)) { 208 } else if (!cp->app && (udph->check != 0)) {
209 /* Only port and addr are changed, do fast csum update */ 209 /* Only port and addr are changed, do fast csum update */
210 udp_fast_csum_update(cp->af, udph, &cp->daddr, &cp->vaddr, 210 udp_fast_csum_update(cp->af, udph, &cp->daddr, &cp->vaddr,
@@ -279,8 +279,8 @@ udp_dnat_handler(struct sk_buff *skb,
279 */ 279 */
280 if (skb->ip_summed == CHECKSUM_PARTIAL) { 280 if (skb->ip_summed == CHECKSUM_PARTIAL) {
281 udp_partial_csum_update(cp->af, udph, &cp->daddr, &cp->vaddr, 281 udp_partial_csum_update(cp->af, udph, &cp->daddr, &cp->vaddr,
282 htonl(oldlen), 282 htons(oldlen),
283 htonl(skb->len - udphoff)); 283 htons(skb->len - udphoff));
284 } else if (!cp->app && (udph->check != 0)) { 284 } else if (!cp->app && (udph->check != 0)) {
285 /* Only port and addr are changed, do fast csum update */ 285 /* Only port and addr are changed, do fast csum update */
286 udp_fast_csum_update(cp->af, udph, &cp->vaddr, &cp->daddr, 286 udp_fast_csum_update(cp->af, udph, &cp->vaddr, &cp->daddr,
diff --git a/net/netfilter/ipvs/ip_vs_rr.c b/net/netfilter/ipvs/ip_vs_rr.c
index a22195f68ac4..8fb51c169eb8 100644
--- a/net/netfilter/ipvs/ip_vs_rr.c
+++ b/net/netfilter/ipvs/ip_vs_rr.c
@@ -89,9 +89,6 @@ static struct ip_vs_scheduler ip_vs_rr_scheduler = {
89 .refcnt = ATOMIC_INIT(0), 89 .refcnt = ATOMIC_INIT(0),
90 .module = THIS_MODULE, 90 .module = THIS_MODULE,
91 .n_list = LIST_HEAD_INIT(ip_vs_rr_scheduler.n_list), 91 .n_list = LIST_HEAD_INIT(ip_vs_rr_scheduler.n_list),
92#ifdef CONFIG_IP_VS_IPV6
93 .supports_ipv6 = 1,
94#endif
95 .init_service = ip_vs_rr_init_svc, 92 .init_service = ip_vs_rr_init_svc,
96 .update_service = ip_vs_rr_update_svc, 93 .update_service = ip_vs_rr_update_svc,
97 .schedule = ip_vs_rr_schedule, 94 .schedule = ip_vs_rr_schedule,
diff --git a/net/netfilter/ipvs/ip_vs_sed.c b/net/netfilter/ipvs/ip_vs_sed.c
index 7d2f22f04b83..691a6a0086e1 100644
--- a/net/netfilter/ipvs/ip_vs_sed.c
+++ b/net/netfilter/ipvs/ip_vs_sed.c
@@ -118,9 +118,6 @@ static struct ip_vs_scheduler ip_vs_sed_scheduler =
118 .refcnt = ATOMIC_INIT(0), 118 .refcnt = ATOMIC_INIT(0),
119 .module = THIS_MODULE, 119 .module = THIS_MODULE,
120 .n_list = LIST_HEAD_INIT(ip_vs_sed_scheduler.n_list), 120 .n_list = LIST_HEAD_INIT(ip_vs_sed_scheduler.n_list),
121#ifdef CONFIG_IP_VS_IPV6
122 .supports_ipv6 = 1,
123#endif
124 .schedule = ip_vs_sed_schedule, 121 .schedule = ip_vs_sed_schedule,
125}; 122};
126 123
diff --git a/net/netfilter/ipvs/ip_vs_sh.c b/net/netfilter/ipvs/ip_vs_sh.c
index 1d96de27fefd..0e53955ef139 100644
--- a/net/netfilter/ipvs/ip_vs_sh.c
+++ b/net/netfilter/ipvs/ip_vs_sh.c
@@ -61,9 +61,16 @@ struct ip_vs_sh_bucket {
61/* 61/*
62 * Returns hash value for IPVS SH entry 62 * Returns hash value for IPVS SH entry
63 */ 63 */
64static inline unsigned ip_vs_sh_hashkey(__be32 addr) 64static inline unsigned ip_vs_sh_hashkey(int af, const union nf_inet_addr *addr)
65{ 65{
66 return (ntohl(addr)*2654435761UL) & IP_VS_SH_TAB_MASK; 66 __be32 addr_fold = addr->ip;
67
68#ifdef CONFIG_IP_VS_IPV6
69 if (af == AF_INET6)
70 addr_fold = addr->ip6[0]^addr->ip6[1]^
71 addr->ip6[2]^addr->ip6[3];
72#endif
73 return (ntohl(addr_fold)*2654435761UL) & IP_VS_SH_TAB_MASK;
67} 74}
68 75
69 76
@@ -71,9 +78,10 @@ static inline unsigned ip_vs_sh_hashkey(__be32 addr)
71 * Get ip_vs_dest associated with supplied parameters. 78 * Get ip_vs_dest associated with supplied parameters.
72 */ 79 */
73static inline struct ip_vs_dest * 80static inline struct ip_vs_dest *
74ip_vs_sh_get(struct ip_vs_sh_bucket *tbl, __be32 addr) 81ip_vs_sh_get(int af, struct ip_vs_sh_bucket *tbl,
82 const union nf_inet_addr *addr)
75{ 83{
76 return (tbl[ip_vs_sh_hashkey(addr)]).dest; 84 return (tbl[ip_vs_sh_hashkey(af, addr)]).dest;
77} 85}
78 86
79 87
@@ -199,12 +207,14 @@ ip_vs_sh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
199{ 207{
200 struct ip_vs_dest *dest; 208 struct ip_vs_dest *dest;
201 struct ip_vs_sh_bucket *tbl; 209 struct ip_vs_sh_bucket *tbl;
202 struct iphdr *iph = ip_hdr(skb); 210 struct ip_vs_iphdr iph;
211
212 ip_vs_fill_iphdr(svc->af, skb_network_header(skb), &iph);
203 213
204 IP_VS_DBG(6, "ip_vs_sh_schedule(): Scheduling...\n"); 214 IP_VS_DBG(6, "ip_vs_sh_schedule(): Scheduling...\n");
205 215
206 tbl = (struct ip_vs_sh_bucket *)svc->sched_data; 216 tbl = (struct ip_vs_sh_bucket *)svc->sched_data;
207 dest = ip_vs_sh_get(tbl, iph->saddr); 217 dest = ip_vs_sh_get(svc->af, tbl, &iph.saddr);
208 if (!dest 218 if (!dest
209 || !(dest->flags & IP_VS_DEST_F_AVAILABLE) 219 || !(dest->flags & IP_VS_DEST_F_AVAILABLE)
210 || atomic_read(&dest->weight) <= 0 220 || atomic_read(&dest->weight) <= 0
@@ -212,11 +222,10 @@ ip_vs_sh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
212 return NULL; 222 return NULL;
213 } 223 }
214 224
215 IP_VS_DBG(6, "SH: source IP address %u.%u.%u.%u " 225 IP_VS_DBG_BUF(6, "SH: source IP address %s --> server %s:%d\n",
216 "--> server %u.%u.%u.%u:%d\n", 226 IP_VS_DBG_ADDR(svc->af, &iph.saddr),
217 NIPQUAD(iph->saddr), 227 IP_VS_DBG_ADDR(svc->af, &dest->addr),
218 NIPQUAD(dest->addr.ip), 228 ntohs(dest->port));
219 ntohs(dest->port));
220 229
221 return dest; 230 return dest;
222} 231}
@@ -231,9 +240,6 @@ static struct ip_vs_scheduler ip_vs_sh_scheduler =
231 .refcnt = ATOMIC_INIT(0), 240 .refcnt = ATOMIC_INIT(0),
232 .module = THIS_MODULE, 241 .module = THIS_MODULE,
233 .n_list = LIST_HEAD_INIT(ip_vs_sh_scheduler.n_list), 242 .n_list = LIST_HEAD_INIT(ip_vs_sh_scheduler.n_list),
234#ifdef CONFIG_IP_VS_IPV6
235 .supports_ipv6 = 0,
236#endif
237 .init_service = ip_vs_sh_init_svc, 243 .init_service = ip_vs_sh_init_svc,
238 .done_service = ip_vs_sh_done_svc, 244 .done_service = ip_vs_sh_done_svc,
239 .update_service = ip_vs_sh_update_svc, 245 .update_service = ip_vs_sh_update_svc,
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index de5e7e118eed..6be5d4efa51b 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -580,8 +580,8 @@ static int bind_mcastif_addr(struct socket *sock, char *ifname)
580 IP_VS_ERR("You probably need to specify IP address on " 580 IP_VS_ERR("You probably need to specify IP address on "
581 "multicast interface.\n"); 581 "multicast interface.\n");
582 582
583 IP_VS_DBG(7, "binding socket with (%s) %u.%u.%u.%u\n", 583 IP_VS_DBG(7, "binding socket with (%s) %pI4\n",
584 ifname, NIPQUAD(addr)); 584 ifname, &addr);
585 585
586 /* Now bind the socket with the address of multicast interface */ 586 /* Now bind the socket with the address of multicast interface */
587 sin.sin_family = AF_INET; 587 sin.sin_family = AF_INET;
diff --git a/net/netfilter/ipvs/ip_vs_wlc.c b/net/netfilter/ipvs/ip_vs_wlc.c
index 8c596e712599..57b452bbb4ea 100644
--- a/net/netfilter/ipvs/ip_vs_wlc.c
+++ b/net/netfilter/ipvs/ip_vs_wlc.c
@@ -106,9 +106,6 @@ static struct ip_vs_scheduler ip_vs_wlc_scheduler =
106 .refcnt = ATOMIC_INIT(0), 106 .refcnt = ATOMIC_INIT(0),
107 .module = THIS_MODULE, 107 .module = THIS_MODULE,
108 .n_list = LIST_HEAD_INIT(ip_vs_wlc_scheduler.n_list), 108 .n_list = LIST_HEAD_INIT(ip_vs_wlc_scheduler.n_list),
109#ifdef CONFIG_IP_VS_IPV6
110 .supports_ipv6 = 1,
111#endif
112 .schedule = ip_vs_wlc_schedule, 109 .schedule = ip_vs_wlc_schedule,
113}; 110};
114 111
diff --git a/net/netfilter/ipvs/ip_vs_wrr.c b/net/netfilter/ipvs/ip_vs_wrr.c
index 7ea92fed50bf..2f618dc29c5b 100644
--- a/net/netfilter/ipvs/ip_vs_wrr.c
+++ b/net/netfilter/ipvs/ip_vs_wrr.c
@@ -213,9 +213,6 @@ static struct ip_vs_scheduler ip_vs_wrr_scheduler = {
213 .refcnt = ATOMIC_INIT(0), 213 .refcnt = ATOMIC_INIT(0),
214 .module = THIS_MODULE, 214 .module = THIS_MODULE,
215 .n_list = LIST_HEAD_INIT(ip_vs_wrr_scheduler.n_list), 215 .n_list = LIST_HEAD_INIT(ip_vs_wrr_scheduler.n_list),
216#ifdef CONFIG_IP_VS_IPV6
217 .supports_ipv6 = 1,
218#endif
219 .init_service = ip_vs_wrr_init_svc, 216 .init_service = ip_vs_wrr_init_svc,
220 .done_service = ip_vs_wrr_done_svc, 217 .done_service = ip_vs_wrr_done_svc,
221 .update_service = ip_vs_wrr_update_svc, 218 .update_service = ip_vs_wrr_update_svc,
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index e90d52f199bc..425ab144f15d 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -82,14 +82,13 @@ __ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
82 82
83 if (ip_route_output_key(&init_net, &rt, &fl)) { 83 if (ip_route_output_key(&init_net, &rt, &fl)) {
84 spin_unlock(&dest->dst_lock); 84 spin_unlock(&dest->dst_lock);
85 IP_VS_DBG_RL("ip_route_output error, " 85 IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n",
86 "dest: %u.%u.%u.%u\n", 86 &dest->addr.ip);
87 NIPQUAD(dest->addr.ip));
88 return NULL; 87 return NULL;
89 } 88 }
90 __ip_vs_dst_set(dest, rtos, dst_clone(&rt->u.dst)); 89 __ip_vs_dst_set(dest, rtos, dst_clone(&rt->u.dst));
91 IP_VS_DBG(10, "new dst %u.%u.%u.%u, refcnt=%d, rtos=%X\n", 90 IP_VS_DBG(10, "new dst %pI4, refcnt=%d, rtos=%X\n",
92 NIPQUAD(dest->addr.ip), 91 &dest->addr.ip,
93 atomic_read(&rt->u.dst.__refcnt), rtos); 92 atomic_read(&rt->u.dst.__refcnt), rtos);
94 } 93 }
95 spin_unlock(&dest->dst_lock); 94 spin_unlock(&dest->dst_lock);
@@ -104,8 +103,8 @@ __ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
104 }; 103 };
105 104
106 if (ip_route_output_key(&init_net, &rt, &fl)) { 105 if (ip_route_output_key(&init_net, &rt, &fl)) {
107 IP_VS_DBG_RL("ip_route_output error, dest: " 106 IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n",
108 "%u.%u.%u.%u\n", NIPQUAD(cp->daddr.ip)); 107 &cp->daddr.ip);
109 return NULL; 108 return NULL;
110 } 109 }
111 } 110 }
@@ -141,14 +140,13 @@ __ip_vs_get_out_rt_v6(struct ip_vs_conn *cp)
141 NULL, &fl); 140 NULL, &fl);
142 if (!rt) { 141 if (!rt) {
143 spin_unlock(&dest->dst_lock); 142 spin_unlock(&dest->dst_lock);
144 IP_VS_DBG_RL("ip6_route_output error, " 143 IP_VS_DBG_RL("ip6_route_output error, dest: %pI6\n",
145 "dest: " NIP6_FMT "\n", 144 &dest->addr.in6);
146 NIP6(dest->addr.in6));
147 return NULL; 145 return NULL;
148 } 146 }
149 __ip_vs_dst_set(dest, 0, dst_clone(&rt->u.dst)); 147 __ip_vs_dst_set(dest, 0, dst_clone(&rt->u.dst));
150 IP_VS_DBG(10, "new dst " NIP6_FMT ", refcnt=%d\n", 148 IP_VS_DBG(10, "new dst %pI6, refcnt=%d\n",
151 NIP6(dest->addr.in6), 149 &dest->addr.in6,
152 atomic_read(&rt->u.dst.__refcnt)); 150 atomic_read(&rt->u.dst.__refcnt));
153 } 151 }
154 spin_unlock(&dest->dst_lock); 152 spin_unlock(&dest->dst_lock);
@@ -167,8 +165,8 @@ __ip_vs_get_out_rt_v6(struct ip_vs_conn *cp)
167 165
168 rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl); 166 rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl);
169 if (!rt) { 167 if (!rt) {
170 IP_VS_DBG_RL("ip6_route_output error, dest: " 168 IP_VS_DBG_RL("ip6_route_output error, dest: %pI6\n",
171 NIP6_FMT "\n", NIP6(cp->daddr.in6)); 169 &cp->daddr.in6);
172 return NULL; 170 return NULL;
173 } 171 }
174 } 172 }
@@ -237,8 +235,8 @@ ip_vs_bypass_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
237 EnterFunction(10); 235 EnterFunction(10);
238 236
239 if (ip_route_output_key(&init_net, &rt, &fl)) { 237 if (ip_route_output_key(&init_net, &rt, &fl)) {
240 IP_VS_DBG_RL("ip_vs_bypass_xmit(): ip_route_output error, " 238 IP_VS_DBG_RL("ip_vs_bypass_xmit(): ip_route_output error, dest: %pI4\n",
241 "dest: %u.%u.%u.%u\n", NIPQUAD(iph->daddr)); 239 &iph->daddr);
242 goto tx_error_icmp; 240 goto tx_error_icmp;
243 } 241 }
244 242
@@ -301,8 +299,8 @@ ip_vs_bypass_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
301 299
302 rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl); 300 rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl);
303 if (!rt) { 301 if (!rt) {
304 IP_VS_DBG_RL("ip_vs_bypass_xmit_v6(): ip6_route_output error, " 302 IP_VS_DBG_RL("ip_vs_bypass_xmit_v6(): ip6_route_output error, dest: %pI6\n",
305 "dest: " NIP6_FMT "\n", NIP6(iph->daddr)); 303 &iph->daddr);
306 goto tx_error_icmp; 304 goto tx_error_icmp;
307 } 305 }
308 306
diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
index b92df5c1dfcf..9fe8982bd7c9 100644
--- a/net/netfilter/nf_conntrack_acct.c
+++ b/net/netfilter/nf_conntrack_acct.c
@@ -35,7 +35,7 @@ static struct ctl_table acct_sysctl_table[] = {
35 .data = &init_net.ct.sysctl_acct, 35 .data = &init_net.ct.sysctl_acct,
36 .maxlen = sizeof(unsigned int), 36 .maxlen = sizeof(unsigned int),
37 .mode = 0644, 37 .mode = 0644,
38 .proc_handler = &proc_dointvec, 38 .proc_handler = proc_dointvec,
39 }, 39 },
40 {} 40 {}
41}; 41};
diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
index 4f7107107e99..629500901bd4 100644
--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -462,16 +462,13 @@ static int help(struct sk_buff *skb,
462 different IP address. Simply don't record it for 462 different IP address. Simply don't record it for
463 NAT. */ 463 NAT. */
464 if (cmd.l3num == PF_INET) { 464 if (cmd.l3num == PF_INET) {
465 pr_debug("conntrack_ftp: NOT RECORDING: " NIPQUAD_FMT 465 pr_debug("conntrack_ftp: NOT RECORDING: %pI4 != %pI4\n",
466 " != " NIPQUAD_FMT "\n", 466 &cmd.u3.ip,
467 NIPQUAD(cmd.u3.ip), 467 &ct->tuplehash[dir].tuple.src.u3.ip);
468 NIPQUAD(ct->tuplehash[dir].tuple.src.u3.ip));
469 } else { 468 } else {
470 pr_debug("conntrack_ftp: NOT RECORDING: " NIP6_FMT 469 pr_debug("conntrack_ftp: NOT RECORDING: %pI6 != %pI6\n",
471 " != " NIP6_FMT "\n", 470 cmd.u3.ip6,
472 NIP6(*((struct in6_addr *)cmd.u3.ip6)), 471 ct->tuplehash[dir].tuple.src.u3.ip6);
473 NIP6(*((struct in6_addr *)
474 ct->tuplehash[dir].tuple.src.u3.ip6)));
475 } 472 }
476 473
477 /* Thanks to Cristiano Lincoln Mattos 474 /* Thanks to Cristiano Lincoln Mattos
diff --git a/net/netfilter/nf_conntrack_h323_main.c b/net/netfilter/nf_conntrack_h323_main.c
index c1504f71cdff..99bc803d1dd1 100644
--- a/net/netfilter/nf_conntrack_h323_main.c
+++ b/net/netfilter/nf_conntrack_h323_main.c
@@ -850,10 +850,8 @@ static int process_setup(struct sk_buff *skb, struct nf_conn *ct,
850 get_h225_addr(ct, *data, &setup->destCallSignalAddress, 850 get_h225_addr(ct, *data, &setup->destCallSignalAddress,
851 &addr, &port) && 851 &addr, &port) &&
852 memcmp(&addr, &ct->tuplehash[!dir].tuple.src.u3, sizeof(addr))) { 852 memcmp(&addr, &ct->tuplehash[!dir].tuple.src.u3, sizeof(addr))) {
853 pr_debug("nf_ct_q931: set destCallSignalAddress " 853 pr_debug("nf_ct_q931: set destCallSignalAddress %pI6:%hu->%pI6:%hu\n",
854 NIP6_FMT ":%hu->" NIP6_FMT ":%hu\n", 854 &addr, ntohs(port), &ct->tuplehash[!dir].tuple.src.u3,
855 NIP6(*(struct in6_addr *)&addr), ntohs(port),
856 NIP6(*(struct in6_addr *)&ct->tuplehash[!dir].tuple.src.u3),
857 ntohs(ct->tuplehash[!dir].tuple.src.u.tcp.port)); 855 ntohs(ct->tuplehash[!dir].tuple.src.u.tcp.port));
858 ret = set_h225_addr(skb, data, dataoff, 856 ret = set_h225_addr(skb, data, dataoff,
859 &setup->destCallSignalAddress, 857 &setup->destCallSignalAddress,
@@ -868,10 +866,8 @@ static int process_setup(struct sk_buff *skb, struct nf_conn *ct,
868 get_h225_addr(ct, *data, &setup->sourceCallSignalAddress, 866 get_h225_addr(ct, *data, &setup->sourceCallSignalAddress,
869 &addr, &port) && 867 &addr, &port) &&
870 memcmp(&addr, &ct->tuplehash[!dir].tuple.dst.u3, sizeof(addr))) { 868 memcmp(&addr, &ct->tuplehash[!dir].tuple.dst.u3, sizeof(addr))) {
871 pr_debug("nf_ct_q931: set sourceCallSignalAddress " 869 pr_debug("nf_ct_q931: set sourceCallSignalAddress %pI6:%hu->%pI6:%hu\n",
872 NIP6_FMT ":%hu->" NIP6_FMT ":%hu\n", 870 &addr, ntohs(port), &ct->tuplehash[!dir].tuple.dst.u3,
873 NIP6(*(struct in6_addr *)&addr), ntohs(port),
874 NIP6(*(struct in6_addr *)&ct->tuplehash[!dir].tuple.dst.u3),
875 ntohs(ct->tuplehash[!dir].tuple.dst.u.tcp.port)); 871 ntohs(ct->tuplehash[!dir].tuple.dst.u.tcp.port));
876 ret = set_h225_addr(skb, data, dataoff, 872 ret = set_h225_addr(skb, data, dataoff,
877 &setup->sourceCallSignalAddress, 873 &setup->sourceCallSignalAddress,
diff --git a/net/netfilter/nf_conntrack_irc.c b/net/netfilter/nf_conntrack_irc.c
index 20633fdf7e6b..4d681a04447e 100644
--- a/net/netfilter/nf_conntrack_irc.c
+++ b/net/netfilter/nf_conntrack_irc.c
@@ -156,9 +156,9 @@ static int help(struct sk_buff *skb, unsigned int protoff,
156 /* we have at least (19+MINMATCHLEN)-5 bytes valid data left */ 156 /* we have at least (19+MINMATCHLEN)-5 bytes valid data left */
157 157
158 iph = ip_hdr(skb); 158 iph = ip_hdr(skb);
159 pr_debug("DCC found in master %u.%u.%u.%u:%u %u.%u.%u.%u:%u\n", 159 pr_debug("DCC found in master %pI4:%u %pI4:%u\n",
160 NIPQUAD(iph->saddr), ntohs(th->source), 160 &iph->saddr, ntohs(th->source),
161 NIPQUAD(iph->daddr), ntohs(th->dest)); 161 &iph->daddr, ntohs(th->dest));
162 162
163 for (i = 0; i < ARRAY_SIZE(dccprotos); i++) { 163 for (i = 0; i < ARRAY_SIZE(dccprotos); i++) {
164 if (memcmp(data, dccprotos[i], strlen(dccprotos[i]))) { 164 if (memcmp(data, dccprotos[i], strlen(dccprotos[i]))) {
@@ -185,10 +185,9 @@ static int help(struct sk_buff *skb, unsigned int protoff,
185 tuple->dst.u3.ip != htonl(dcc_ip)) { 185 tuple->dst.u3.ip != htonl(dcc_ip)) {
186 if (net_ratelimit()) 186 if (net_ratelimit())
187 printk(KERN_WARNING 187 printk(KERN_WARNING
188 "Forged DCC command from " 188 "Forged DCC command from %pI4: %pI4:%u\n",
189 "%u.%u.%u.%u: %u.%u.%u.%u:%u\n", 189 &tuple->src.u3.ip,
190 NIPQUAD(tuple->src.u3.ip), 190 &dcc_ip, dcc_port);
191 HIPQUAD(dcc_ip), dcc_port);
192 continue; 191 continue;
193 } 192 }
194 193
diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
index dbe680af85d2..4be80d7b8795 100644
--- a/net/netfilter/nf_conntrack_proto_generic.c
+++ b/net/netfilter/nf_conntrack_proto_generic.c
@@ -67,7 +67,7 @@ static struct ctl_table generic_sysctl_table[] = {
67 .data = &nf_ct_generic_timeout, 67 .data = &nf_ct_generic_timeout,
68 .maxlen = sizeof(unsigned int), 68 .maxlen = sizeof(unsigned int),
69 .mode = 0644, 69 .mode = 0644,
70 .proc_handler = &proc_dointvec_jiffies, 70 .proc_handler = proc_dointvec_jiffies,
71 }, 71 },
72 { 72 {
73 .ctl_name = 0 73 .ctl_name = 0
@@ -80,7 +80,7 @@ static struct ctl_table generic_compat_sysctl_table[] = {
80 .data = &nf_ct_generic_timeout, 80 .data = &nf_ct_generic_timeout,
81 .maxlen = sizeof(unsigned int), 81 .maxlen = sizeof(unsigned int),
82 .mode = 0644, 82 .mode = 0644,
83 .proc_handler = &proc_dointvec_jiffies, 83 .proc_handler = proc_dointvec_jiffies,
84 }, 84 },
85 { 85 {
86 .ctl_name = 0 86 .ctl_name = 0
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index ae8c2609e230..c2bd457bc2f2 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -548,49 +548,49 @@ static struct ctl_table sctp_sysctl_table[] = {
548 .data = &sctp_timeouts[SCTP_CONNTRACK_CLOSED], 548 .data = &sctp_timeouts[SCTP_CONNTRACK_CLOSED],
549 .maxlen = sizeof(unsigned int), 549 .maxlen = sizeof(unsigned int),
550 .mode = 0644, 550 .mode = 0644,
551 .proc_handler = &proc_dointvec_jiffies, 551 .proc_handler = proc_dointvec_jiffies,
552 }, 552 },
553 { 553 {
554 .procname = "nf_conntrack_sctp_timeout_cookie_wait", 554 .procname = "nf_conntrack_sctp_timeout_cookie_wait",
555 .data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_WAIT], 555 .data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_WAIT],
556 .maxlen = sizeof(unsigned int), 556 .maxlen = sizeof(unsigned int),
557 .mode = 0644, 557 .mode = 0644,
558 .proc_handler = &proc_dointvec_jiffies, 558 .proc_handler = proc_dointvec_jiffies,
559 }, 559 },
560 { 560 {
561 .procname = "nf_conntrack_sctp_timeout_cookie_echoed", 561 .procname = "nf_conntrack_sctp_timeout_cookie_echoed",
562 .data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_ECHOED], 562 .data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_ECHOED],
563 .maxlen = sizeof(unsigned int), 563 .maxlen = sizeof(unsigned int),
564 .mode = 0644, 564 .mode = 0644,
565 .proc_handler = &proc_dointvec_jiffies, 565 .proc_handler = proc_dointvec_jiffies,
566 }, 566 },
567 { 567 {
568 .procname = "nf_conntrack_sctp_timeout_established", 568 .procname = "nf_conntrack_sctp_timeout_established",
569 .data = &sctp_timeouts[SCTP_CONNTRACK_ESTABLISHED], 569 .data = &sctp_timeouts[SCTP_CONNTRACK_ESTABLISHED],
570 .maxlen = sizeof(unsigned int), 570 .maxlen = sizeof(unsigned int),
571 .mode = 0644, 571 .mode = 0644,
572 .proc_handler = &proc_dointvec_jiffies, 572 .proc_handler = proc_dointvec_jiffies,
573 }, 573 },
574 { 574 {
575 .procname = "nf_conntrack_sctp_timeout_shutdown_sent", 575 .procname = "nf_conntrack_sctp_timeout_shutdown_sent",
576 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_SENT], 576 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_SENT],
577 .maxlen = sizeof(unsigned int), 577 .maxlen = sizeof(unsigned int),
578 .mode = 0644, 578 .mode = 0644,
579 .proc_handler = &proc_dointvec_jiffies, 579 .proc_handler = proc_dointvec_jiffies,
580 }, 580 },
581 { 581 {
582 .procname = "nf_conntrack_sctp_timeout_shutdown_recd", 582 .procname = "nf_conntrack_sctp_timeout_shutdown_recd",
583 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_RECD], 583 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_RECD],
584 .maxlen = sizeof(unsigned int), 584 .maxlen = sizeof(unsigned int),
585 .mode = 0644, 585 .mode = 0644,
586 .proc_handler = &proc_dointvec_jiffies, 586 .proc_handler = proc_dointvec_jiffies,
587 }, 587 },
588 { 588 {
589 .procname = "nf_conntrack_sctp_timeout_shutdown_ack_sent", 589 .procname = "nf_conntrack_sctp_timeout_shutdown_ack_sent",
590 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_ACK_SENT], 590 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_ACK_SENT],
591 .maxlen = sizeof(unsigned int), 591 .maxlen = sizeof(unsigned int),
592 .mode = 0644, 592 .mode = 0644,
593 .proc_handler = &proc_dointvec_jiffies, 593 .proc_handler = proc_dointvec_jiffies,
594 }, 594 },
595 { 595 {
596 .ctl_name = 0 596 .ctl_name = 0
@@ -604,49 +604,49 @@ static struct ctl_table sctp_compat_sysctl_table[] = {
604 .data = &sctp_timeouts[SCTP_CONNTRACK_CLOSED], 604 .data = &sctp_timeouts[SCTP_CONNTRACK_CLOSED],
605 .maxlen = sizeof(unsigned int), 605 .maxlen = sizeof(unsigned int),
606 .mode = 0644, 606 .mode = 0644,
607 .proc_handler = &proc_dointvec_jiffies, 607 .proc_handler = proc_dointvec_jiffies,
608 }, 608 },
609 { 609 {
610 .procname = "ip_conntrack_sctp_timeout_cookie_wait", 610 .procname = "ip_conntrack_sctp_timeout_cookie_wait",
611 .data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_WAIT], 611 .data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_WAIT],
612 .maxlen = sizeof(unsigned int), 612 .maxlen = sizeof(unsigned int),
613 .mode = 0644, 613 .mode = 0644,
614 .proc_handler = &proc_dointvec_jiffies, 614 .proc_handler = proc_dointvec_jiffies,
615 }, 615 },
616 { 616 {
617 .procname = "ip_conntrack_sctp_timeout_cookie_echoed", 617 .procname = "ip_conntrack_sctp_timeout_cookie_echoed",
618 .data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_ECHOED], 618 .data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_ECHOED],
619 .maxlen = sizeof(unsigned int), 619 .maxlen = sizeof(unsigned int),
620 .mode = 0644, 620 .mode = 0644,
621 .proc_handler = &proc_dointvec_jiffies, 621 .proc_handler = proc_dointvec_jiffies,
622 }, 622 },
623 { 623 {
624 .procname = "ip_conntrack_sctp_timeout_established", 624 .procname = "ip_conntrack_sctp_timeout_established",
625 .data = &sctp_timeouts[SCTP_CONNTRACK_ESTABLISHED], 625 .data = &sctp_timeouts[SCTP_CONNTRACK_ESTABLISHED],
626 .maxlen = sizeof(unsigned int), 626 .maxlen = sizeof(unsigned int),
627 .mode = 0644, 627 .mode = 0644,
628 .proc_handler = &proc_dointvec_jiffies, 628 .proc_handler = proc_dointvec_jiffies,
629 }, 629 },
630 { 630 {
631 .procname = "ip_conntrack_sctp_timeout_shutdown_sent", 631 .procname = "ip_conntrack_sctp_timeout_shutdown_sent",
632 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_SENT], 632 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_SENT],
633 .maxlen = sizeof(unsigned int), 633 .maxlen = sizeof(unsigned int),
634 .mode = 0644, 634 .mode = 0644,
635 .proc_handler = &proc_dointvec_jiffies, 635 .proc_handler = proc_dointvec_jiffies,
636 }, 636 },
637 { 637 {
638 .procname = "ip_conntrack_sctp_timeout_shutdown_recd", 638 .procname = "ip_conntrack_sctp_timeout_shutdown_recd",
639 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_RECD], 639 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_RECD],
640 .maxlen = sizeof(unsigned int), 640 .maxlen = sizeof(unsigned int),
641 .mode = 0644, 641 .mode = 0644,
642 .proc_handler = &proc_dointvec_jiffies, 642 .proc_handler = proc_dointvec_jiffies,
643 }, 643 },
644 { 644 {
645 .procname = "ip_conntrack_sctp_timeout_shutdown_ack_sent", 645 .procname = "ip_conntrack_sctp_timeout_shutdown_ack_sent",
646 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_ACK_SENT], 646 .data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_ACK_SENT],
647 .maxlen = sizeof(unsigned int), 647 .maxlen = sizeof(unsigned int),
648 .mode = 0644, 648 .mode = 0644,
649 .proc_handler = &proc_dointvec_jiffies, 649 .proc_handler = proc_dointvec_jiffies,
650 }, 650 },
651 { 651 {
652 .ctl_name = 0 652 .ctl_name = 0
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index f947ec41e391..a1edb9c1adee 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -1192,70 +1192,70 @@ static struct ctl_table tcp_sysctl_table[] = {
1192 .data = &tcp_timeouts[TCP_CONNTRACK_SYN_SENT], 1192 .data = &tcp_timeouts[TCP_CONNTRACK_SYN_SENT],
1193 .maxlen = sizeof(unsigned int), 1193 .maxlen = sizeof(unsigned int),
1194 .mode = 0644, 1194 .mode = 0644,
1195 .proc_handler = &proc_dointvec_jiffies, 1195 .proc_handler = proc_dointvec_jiffies,
1196 }, 1196 },
1197 { 1197 {
1198 .procname = "nf_conntrack_tcp_timeout_syn_recv", 1198 .procname = "nf_conntrack_tcp_timeout_syn_recv",
1199 .data = &tcp_timeouts[TCP_CONNTRACK_SYN_RECV], 1199 .data = &tcp_timeouts[TCP_CONNTRACK_SYN_RECV],
1200 .maxlen = sizeof(unsigned int), 1200 .maxlen = sizeof(unsigned int),
1201 .mode = 0644, 1201 .mode = 0644,
1202 .proc_handler = &proc_dointvec_jiffies, 1202 .proc_handler = proc_dointvec_jiffies,
1203 }, 1203 },
1204 { 1204 {
1205 .procname = "nf_conntrack_tcp_timeout_established", 1205 .procname = "nf_conntrack_tcp_timeout_established",
1206 .data = &tcp_timeouts[TCP_CONNTRACK_ESTABLISHED], 1206 .data = &tcp_timeouts[TCP_CONNTRACK_ESTABLISHED],
1207 .maxlen = sizeof(unsigned int), 1207 .maxlen = sizeof(unsigned int),
1208 .mode = 0644, 1208 .mode = 0644,
1209 .proc_handler = &proc_dointvec_jiffies, 1209 .proc_handler = proc_dointvec_jiffies,
1210 }, 1210 },
1211 { 1211 {
1212 .procname = "nf_conntrack_tcp_timeout_fin_wait", 1212 .procname = "nf_conntrack_tcp_timeout_fin_wait",
1213 .data = &tcp_timeouts[TCP_CONNTRACK_FIN_WAIT], 1213 .data = &tcp_timeouts[TCP_CONNTRACK_FIN_WAIT],
1214 .maxlen = sizeof(unsigned int), 1214 .maxlen = sizeof(unsigned int),
1215 .mode = 0644, 1215 .mode = 0644,
1216 .proc_handler = &proc_dointvec_jiffies, 1216 .proc_handler = proc_dointvec_jiffies,
1217 }, 1217 },
1218 { 1218 {
1219 .procname = "nf_conntrack_tcp_timeout_close_wait", 1219 .procname = "nf_conntrack_tcp_timeout_close_wait",
1220 .data = &tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT], 1220 .data = &tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT],
1221 .maxlen = sizeof(unsigned int), 1221 .maxlen = sizeof(unsigned int),
1222 .mode = 0644, 1222 .mode = 0644,
1223 .proc_handler = &proc_dointvec_jiffies, 1223 .proc_handler = proc_dointvec_jiffies,
1224 }, 1224 },
1225 { 1225 {
1226 .procname = "nf_conntrack_tcp_timeout_last_ack", 1226 .procname = "nf_conntrack_tcp_timeout_last_ack",
1227 .data = &tcp_timeouts[TCP_CONNTRACK_LAST_ACK], 1227 .data = &tcp_timeouts[TCP_CONNTRACK_LAST_ACK],
1228 .maxlen = sizeof(unsigned int), 1228 .maxlen = sizeof(unsigned int),
1229 .mode = 0644, 1229 .mode = 0644,
1230 .proc_handler = &proc_dointvec_jiffies, 1230 .proc_handler = proc_dointvec_jiffies,
1231 }, 1231 },
1232 { 1232 {
1233 .procname = "nf_conntrack_tcp_timeout_time_wait", 1233 .procname = "nf_conntrack_tcp_timeout_time_wait",
1234 .data = &tcp_timeouts[TCP_CONNTRACK_TIME_WAIT], 1234 .data = &tcp_timeouts[TCP_CONNTRACK_TIME_WAIT],
1235 .maxlen = sizeof(unsigned int), 1235 .maxlen = sizeof(unsigned int),
1236 .mode = 0644, 1236 .mode = 0644,
1237 .proc_handler = &proc_dointvec_jiffies, 1237 .proc_handler = proc_dointvec_jiffies,
1238 }, 1238 },
1239 { 1239 {
1240 .procname = "nf_conntrack_tcp_timeout_close", 1240 .procname = "nf_conntrack_tcp_timeout_close",
1241 .data = &tcp_timeouts[TCP_CONNTRACK_CLOSE], 1241 .data = &tcp_timeouts[TCP_CONNTRACK_CLOSE],
1242 .maxlen = sizeof(unsigned int), 1242 .maxlen = sizeof(unsigned int),
1243 .mode = 0644, 1243 .mode = 0644,
1244 .proc_handler = &proc_dointvec_jiffies, 1244 .proc_handler = proc_dointvec_jiffies,
1245 }, 1245 },
1246 { 1246 {
1247 .procname = "nf_conntrack_tcp_timeout_max_retrans", 1247 .procname = "nf_conntrack_tcp_timeout_max_retrans",
1248 .data = &nf_ct_tcp_timeout_max_retrans, 1248 .data = &nf_ct_tcp_timeout_max_retrans,
1249 .maxlen = sizeof(unsigned int), 1249 .maxlen = sizeof(unsigned int),
1250 .mode = 0644, 1250 .mode = 0644,
1251 .proc_handler = &proc_dointvec_jiffies, 1251 .proc_handler = proc_dointvec_jiffies,
1252 }, 1252 },
1253 { 1253 {
1254 .procname = "nf_conntrack_tcp_timeout_unacknowledged", 1254 .procname = "nf_conntrack_tcp_timeout_unacknowledged",
1255 .data = &nf_ct_tcp_timeout_unacknowledged, 1255 .data = &nf_ct_tcp_timeout_unacknowledged,
1256 .maxlen = sizeof(unsigned int), 1256 .maxlen = sizeof(unsigned int),
1257 .mode = 0644, 1257 .mode = 0644,
1258 .proc_handler = &proc_dointvec_jiffies, 1258 .proc_handler = proc_dointvec_jiffies,
1259 }, 1259 },
1260 { 1260 {
1261 .ctl_name = NET_NF_CONNTRACK_TCP_LOOSE, 1261 .ctl_name = NET_NF_CONNTRACK_TCP_LOOSE,
@@ -1263,7 +1263,7 @@ static struct ctl_table tcp_sysctl_table[] = {
1263 .data = &nf_ct_tcp_loose, 1263 .data = &nf_ct_tcp_loose,
1264 .maxlen = sizeof(unsigned int), 1264 .maxlen = sizeof(unsigned int),
1265 .mode = 0644, 1265 .mode = 0644,
1266 .proc_handler = &proc_dointvec, 1266 .proc_handler = proc_dointvec,
1267 }, 1267 },
1268 { 1268 {
1269 .ctl_name = NET_NF_CONNTRACK_TCP_BE_LIBERAL, 1269 .ctl_name = NET_NF_CONNTRACK_TCP_BE_LIBERAL,
@@ -1271,7 +1271,7 @@ static struct ctl_table tcp_sysctl_table[] = {
1271 .data = &nf_ct_tcp_be_liberal, 1271 .data = &nf_ct_tcp_be_liberal,
1272 .maxlen = sizeof(unsigned int), 1272 .maxlen = sizeof(unsigned int),
1273 .mode = 0644, 1273 .mode = 0644,
1274 .proc_handler = &proc_dointvec, 1274 .proc_handler = proc_dointvec,
1275 }, 1275 },
1276 { 1276 {
1277 .ctl_name = NET_NF_CONNTRACK_TCP_MAX_RETRANS, 1277 .ctl_name = NET_NF_CONNTRACK_TCP_MAX_RETRANS,
@@ -1279,7 +1279,7 @@ static struct ctl_table tcp_sysctl_table[] = {
1279 .data = &nf_ct_tcp_max_retrans, 1279 .data = &nf_ct_tcp_max_retrans,
1280 .maxlen = sizeof(unsigned int), 1280 .maxlen = sizeof(unsigned int),
1281 .mode = 0644, 1281 .mode = 0644,
1282 .proc_handler = &proc_dointvec, 1282 .proc_handler = proc_dointvec,
1283 }, 1283 },
1284 { 1284 {
1285 .ctl_name = 0 1285 .ctl_name = 0
@@ -1293,63 +1293,63 @@ static struct ctl_table tcp_compat_sysctl_table[] = {
1293 .data = &tcp_timeouts[TCP_CONNTRACK_SYN_SENT], 1293 .data = &tcp_timeouts[TCP_CONNTRACK_SYN_SENT],
1294 .maxlen = sizeof(unsigned int), 1294 .maxlen = sizeof(unsigned int),
1295 .mode = 0644, 1295 .mode = 0644,
1296 .proc_handler = &proc_dointvec_jiffies, 1296 .proc_handler = proc_dointvec_jiffies,
1297 }, 1297 },
1298 { 1298 {
1299 .procname = "ip_conntrack_tcp_timeout_syn_recv", 1299 .procname = "ip_conntrack_tcp_timeout_syn_recv",
1300 .data = &tcp_timeouts[TCP_CONNTRACK_SYN_RECV], 1300 .data = &tcp_timeouts[TCP_CONNTRACK_SYN_RECV],
1301 .maxlen = sizeof(unsigned int), 1301 .maxlen = sizeof(unsigned int),
1302 .mode = 0644, 1302 .mode = 0644,
1303 .proc_handler = &proc_dointvec_jiffies, 1303 .proc_handler = proc_dointvec_jiffies,
1304 }, 1304 },
1305 { 1305 {
1306 .procname = "ip_conntrack_tcp_timeout_established", 1306 .procname = "ip_conntrack_tcp_timeout_established",
1307 .data = &tcp_timeouts[TCP_CONNTRACK_ESTABLISHED], 1307 .data = &tcp_timeouts[TCP_CONNTRACK_ESTABLISHED],
1308 .maxlen = sizeof(unsigned int), 1308 .maxlen = sizeof(unsigned int),
1309 .mode = 0644, 1309 .mode = 0644,
1310 .proc_handler = &proc_dointvec_jiffies, 1310 .proc_handler = proc_dointvec_jiffies,
1311 }, 1311 },
1312 { 1312 {
1313 .procname = "ip_conntrack_tcp_timeout_fin_wait", 1313 .procname = "ip_conntrack_tcp_timeout_fin_wait",
1314 .data = &tcp_timeouts[TCP_CONNTRACK_FIN_WAIT], 1314 .data = &tcp_timeouts[TCP_CONNTRACK_FIN_WAIT],
1315 .maxlen = sizeof(unsigned int), 1315 .maxlen = sizeof(unsigned int),
1316 .mode = 0644, 1316 .mode = 0644,
1317 .proc_handler = &proc_dointvec_jiffies, 1317 .proc_handler = proc_dointvec_jiffies,
1318 }, 1318 },
1319 { 1319 {
1320 .procname = "ip_conntrack_tcp_timeout_close_wait", 1320 .procname = "ip_conntrack_tcp_timeout_close_wait",
1321 .data = &tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT], 1321 .data = &tcp_timeouts[TCP_CONNTRACK_CLOSE_WAIT],
1322 .maxlen = sizeof(unsigned int), 1322 .maxlen = sizeof(unsigned int),
1323 .mode = 0644, 1323 .mode = 0644,
1324 .proc_handler = &proc_dointvec_jiffies, 1324 .proc_handler = proc_dointvec_jiffies,
1325 }, 1325 },
1326 { 1326 {
1327 .procname = "ip_conntrack_tcp_timeout_last_ack", 1327 .procname = "ip_conntrack_tcp_timeout_last_ack",
1328 .data = &tcp_timeouts[TCP_CONNTRACK_LAST_ACK], 1328 .data = &tcp_timeouts[TCP_CONNTRACK_LAST_ACK],
1329 .maxlen = sizeof(unsigned int), 1329 .maxlen = sizeof(unsigned int),
1330 .mode = 0644, 1330 .mode = 0644,
1331 .proc_handler = &proc_dointvec_jiffies, 1331 .proc_handler = proc_dointvec_jiffies,
1332 }, 1332 },
1333 { 1333 {
1334 .procname = "ip_conntrack_tcp_timeout_time_wait", 1334 .procname = "ip_conntrack_tcp_timeout_time_wait",
1335 .data = &tcp_timeouts[TCP_CONNTRACK_TIME_WAIT], 1335 .data = &tcp_timeouts[TCP_CONNTRACK_TIME_WAIT],
1336 .maxlen = sizeof(unsigned int), 1336 .maxlen = sizeof(unsigned int),
1337 .mode = 0644, 1337 .mode = 0644,
1338 .proc_handler = &proc_dointvec_jiffies, 1338 .proc_handler = proc_dointvec_jiffies,
1339 }, 1339 },
1340 { 1340 {
1341 .procname = "ip_conntrack_tcp_timeout_close", 1341 .procname = "ip_conntrack_tcp_timeout_close",
1342 .data = &tcp_timeouts[TCP_CONNTRACK_CLOSE], 1342 .data = &tcp_timeouts[TCP_CONNTRACK_CLOSE],
1343 .maxlen = sizeof(unsigned int), 1343 .maxlen = sizeof(unsigned int),
1344 .mode = 0644, 1344 .mode = 0644,
1345 .proc_handler = &proc_dointvec_jiffies, 1345 .proc_handler = proc_dointvec_jiffies,
1346 }, 1346 },
1347 { 1347 {
1348 .procname = "ip_conntrack_tcp_timeout_max_retrans", 1348 .procname = "ip_conntrack_tcp_timeout_max_retrans",
1349 .data = &nf_ct_tcp_timeout_max_retrans, 1349 .data = &nf_ct_tcp_timeout_max_retrans,
1350 .maxlen = sizeof(unsigned int), 1350 .maxlen = sizeof(unsigned int),
1351 .mode = 0644, 1351 .mode = 0644,
1352 .proc_handler = &proc_dointvec_jiffies, 1352 .proc_handler = proc_dointvec_jiffies,
1353 }, 1353 },
1354 { 1354 {
1355 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_LOOSE, 1355 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_LOOSE,
@@ -1357,7 +1357,7 @@ static struct ctl_table tcp_compat_sysctl_table[] = {
1357 .data = &nf_ct_tcp_loose, 1357 .data = &nf_ct_tcp_loose,
1358 .maxlen = sizeof(unsigned int), 1358 .maxlen = sizeof(unsigned int),
1359 .mode = 0644, 1359 .mode = 0644,
1360 .proc_handler = &proc_dointvec, 1360 .proc_handler = proc_dointvec,
1361 }, 1361 },
1362 { 1362 {
1363 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL, 1363 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL,
@@ -1365,7 +1365,7 @@ static struct ctl_table tcp_compat_sysctl_table[] = {
1365 .data = &nf_ct_tcp_be_liberal, 1365 .data = &nf_ct_tcp_be_liberal,
1366 .maxlen = sizeof(unsigned int), 1366 .maxlen = sizeof(unsigned int),
1367 .mode = 0644, 1367 .mode = 0644,
1368 .proc_handler = &proc_dointvec, 1368 .proc_handler = proc_dointvec,
1369 }, 1369 },
1370 { 1370 {
1371 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS, 1371 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS,
@@ -1373,7 +1373,7 @@ static struct ctl_table tcp_compat_sysctl_table[] = {
1373 .data = &nf_ct_tcp_max_retrans, 1373 .data = &nf_ct_tcp_max_retrans,
1374 .maxlen = sizeof(unsigned int), 1374 .maxlen = sizeof(unsigned int),
1375 .mode = 0644, 1375 .mode = 0644,
1376 .proc_handler = &proc_dointvec, 1376 .proc_handler = proc_dointvec,
1377 }, 1377 },
1378 { 1378 {
1379 .ctl_name = 0 1379 .ctl_name = 0
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index 7c2ca48698be..2b8b1f579f93 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -143,14 +143,14 @@ static struct ctl_table udp_sysctl_table[] = {
143 .data = &nf_ct_udp_timeout, 143 .data = &nf_ct_udp_timeout,
144 .maxlen = sizeof(unsigned int), 144 .maxlen = sizeof(unsigned int),
145 .mode = 0644, 145 .mode = 0644,
146 .proc_handler = &proc_dointvec_jiffies, 146 .proc_handler = proc_dointvec_jiffies,
147 }, 147 },
148 { 148 {
149 .procname = "nf_conntrack_udp_timeout_stream", 149 .procname = "nf_conntrack_udp_timeout_stream",
150 .data = &nf_ct_udp_timeout_stream, 150 .data = &nf_ct_udp_timeout_stream,
151 .maxlen = sizeof(unsigned int), 151 .maxlen = sizeof(unsigned int),
152 .mode = 0644, 152 .mode = 0644,
153 .proc_handler = &proc_dointvec_jiffies, 153 .proc_handler = proc_dointvec_jiffies,
154 }, 154 },
155 { 155 {
156 .ctl_name = 0 156 .ctl_name = 0
@@ -163,14 +163,14 @@ static struct ctl_table udp_compat_sysctl_table[] = {
163 .data = &nf_ct_udp_timeout, 163 .data = &nf_ct_udp_timeout,
164 .maxlen = sizeof(unsigned int), 164 .maxlen = sizeof(unsigned int),
165 .mode = 0644, 165 .mode = 0644,
166 .proc_handler = &proc_dointvec_jiffies, 166 .proc_handler = proc_dointvec_jiffies,
167 }, 167 },
168 { 168 {
169 .procname = "ip_conntrack_udp_timeout_stream", 169 .procname = "ip_conntrack_udp_timeout_stream",
170 .data = &nf_ct_udp_timeout_stream, 170 .data = &nf_ct_udp_timeout_stream,
171 .maxlen = sizeof(unsigned int), 171 .maxlen = sizeof(unsigned int),
172 .mode = 0644, 172 .mode = 0644,
173 .proc_handler = &proc_dointvec_jiffies, 173 .proc_handler = proc_dointvec_jiffies,
174 }, 174 },
175 { 175 {
176 .ctl_name = 0 176 .ctl_name = 0
diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c
index d22d839e4f94..4579d8de13b1 100644
--- a/net/netfilter/nf_conntrack_proto_udplite.c
+++ b/net/netfilter/nf_conntrack_proto_udplite.c
@@ -151,7 +151,7 @@ static struct ctl_table udplite_sysctl_table[] = {
151 .data = &nf_ct_udplite_timeout, 151 .data = &nf_ct_udplite_timeout,
152 .maxlen = sizeof(unsigned int), 152 .maxlen = sizeof(unsigned int),
153 .mode = 0644, 153 .mode = 0644,
154 .proc_handler = &proc_dointvec_jiffies, 154 .proc_handler = proc_dointvec_jiffies,
155 }, 155 },
156 { 156 {
157 .ctl_name = CTL_UNNUMBERED, 157 .ctl_name = CTL_UNNUMBERED,
@@ -159,7 +159,7 @@ static struct ctl_table udplite_sysctl_table[] = {
159 .data = &nf_ct_udplite_timeout_stream, 159 .data = &nf_ct_udplite_timeout_stream,
160 .maxlen = sizeof(unsigned int), 160 .maxlen = sizeof(unsigned int),
161 .mode = 0644, 161 .mode = 0644,
162 .proc_handler = &proc_dointvec_jiffies, 162 .proc_handler = proc_dointvec_jiffies,
163 }, 163 },
164 { 164 {
165 .ctl_name = 0 165 .ctl_name = 0
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 98106d4e89f0..f37b9b74c6a8 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -336,7 +336,7 @@ static ctl_table nf_ct_sysctl_table[] = {
336 .data = &nf_conntrack_max, 336 .data = &nf_conntrack_max,
337 .maxlen = sizeof(int), 337 .maxlen = sizeof(int),
338 .mode = 0644, 338 .mode = 0644,
339 .proc_handler = &proc_dointvec, 339 .proc_handler = proc_dointvec,
340 }, 340 },
341 { 341 {
342 .ctl_name = NET_NF_CONNTRACK_COUNT, 342 .ctl_name = NET_NF_CONNTRACK_COUNT,
@@ -344,7 +344,7 @@ static ctl_table nf_ct_sysctl_table[] = {
344 .data = &init_net.ct.count, 344 .data = &init_net.ct.count,
345 .maxlen = sizeof(int), 345 .maxlen = sizeof(int),
346 .mode = 0444, 346 .mode = 0444,
347 .proc_handler = &proc_dointvec, 347 .proc_handler = proc_dointvec,
348 }, 348 },
349 { 349 {
350 .ctl_name = NET_NF_CONNTRACK_BUCKETS, 350 .ctl_name = NET_NF_CONNTRACK_BUCKETS,
@@ -352,7 +352,7 @@ static ctl_table nf_ct_sysctl_table[] = {
352 .data = &nf_conntrack_htable_size, 352 .data = &nf_conntrack_htable_size,
353 .maxlen = sizeof(unsigned int), 353 .maxlen = sizeof(unsigned int),
354 .mode = 0444, 354 .mode = 0444,
355 .proc_handler = &proc_dointvec, 355 .proc_handler = proc_dointvec,
356 }, 356 },
357 { 357 {
358 .ctl_name = NET_NF_CONNTRACK_CHECKSUM, 358 .ctl_name = NET_NF_CONNTRACK_CHECKSUM,
@@ -360,7 +360,7 @@ static ctl_table nf_ct_sysctl_table[] = {
360 .data = &init_net.ct.sysctl_checksum, 360 .data = &init_net.ct.sysctl_checksum,
361 .maxlen = sizeof(unsigned int), 361 .maxlen = sizeof(unsigned int),
362 .mode = 0644, 362 .mode = 0644,
363 .proc_handler = &proc_dointvec, 363 .proc_handler = proc_dointvec,
364 }, 364 },
365 { 365 {
366 .ctl_name = NET_NF_CONNTRACK_LOG_INVALID, 366 .ctl_name = NET_NF_CONNTRACK_LOG_INVALID,
@@ -368,8 +368,8 @@ static ctl_table nf_ct_sysctl_table[] = {
368 .data = &init_net.ct.sysctl_log_invalid, 368 .data = &init_net.ct.sysctl_log_invalid,
369 .maxlen = sizeof(unsigned int), 369 .maxlen = sizeof(unsigned int),
370 .mode = 0644, 370 .mode = 0644,
371 .proc_handler = &proc_dointvec_minmax, 371 .proc_handler = proc_dointvec_minmax,
372 .strategy = &sysctl_intvec, 372 .strategy = sysctl_intvec,
373 .extra1 = &log_invalid_proto_min, 373 .extra1 = &log_invalid_proto_min,
374 .extra2 = &log_invalid_proto_max, 374 .extra2 = &log_invalid_proto_max,
375 }, 375 },
@@ -379,7 +379,7 @@ static ctl_table nf_ct_sysctl_table[] = {
379 .data = &nf_ct_expect_max, 379 .data = &nf_ct_expect_max,
380 .maxlen = sizeof(int), 380 .maxlen = sizeof(int),
381 .mode = 0644, 381 .mode = 0644,
382 .proc_handler = &proc_dointvec, 382 .proc_handler = proc_dointvec,
383 }, 383 },
384 { .ctl_name = 0 } 384 { .ctl_name = 0 }
385}; 385};
@@ -393,7 +393,7 @@ static ctl_table nf_ct_netfilter_table[] = {
393 .data = &nf_conntrack_max, 393 .data = &nf_conntrack_max,
394 .maxlen = sizeof(int), 394 .maxlen = sizeof(int),
395 .mode = 0644, 395 .mode = 0644,
396 .proc_handler = &proc_dointvec, 396 .proc_handler = proc_dointvec,
397 }, 397 },
398 { .ctl_name = 0 } 398 { .ctl_name = 0 }
399}; 399};
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 6fc4292d46e6..f97fded024c4 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -893,23 +893,21 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
893 893
894 switch (family) { 894 switch (family) {
895 case NFPROTO_IPV4: 895 case NFPROTO_IPV4:
896 return seq_printf(s, "%ld %u.%u.%u.%u:%u->" 896 return seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n",
897 "%u.%u.%u.%u:%u %u %u %u\n",
898 (long)(ent->expires - jiffies)/HZ, 897 (long)(ent->expires - jiffies)/HZ,
899 NIPQUAD(ent->dst.ip.src), 898 &ent->dst.ip.src,
900 ntohs(ent->dst.src_port), 899 ntohs(ent->dst.src_port),
901 NIPQUAD(ent->dst.ip.dst), 900 &ent->dst.ip.dst,
902 ntohs(ent->dst.dst_port), 901 ntohs(ent->dst.dst_port),
903 ent->rateinfo.credit, ent->rateinfo.credit_cap, 902 ent->rateinfo.credit, ent->rateinfo.credit_cap,
904 ent->rateinfo.cost); 903 ent->rateinfo.cost);
905#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE) 904#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
906 case NFPROTO_IPV6: 905 case NFPROTO_IPV6:
907 return seq_printf(s, "%ld " NIP6_FMT ":%u->" 906 return seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n",
908 NIP6_FMT ":%u %u %u %u\n",
909 (long)(ent->expires - jiffies)/HZ, 907 (long)(ent->expires - jiffies)/HZ,
910 NIP6(*(struct in6_addr *)&ent->dst.ip6.src), 908 &ent->dst.ip6.src,
911 ntohs(ent->dst.src_port), 909 ntohs(ent->dst.src_port),
912 NIP6(*(struct in6_addr *)&ent->dst.ip6.dst), 910 &ent->dst.ip6.dst,
913 ntohs(ent->dst.dst_port), 911 ntohs(ent->dst.dst_port),
914 ent->rateinfo.credit, ent->rateinfo.credit_cap, 912 ent->rateinfo.credit, ent->rateinfo.credit_cap,
915 ent->rateinfo.cost); 913 ent->rateinfo.cost);
diff --git a/net/netfilter/xt_iprange.c b/net/netfilter/xt_iprange.c
index 7ac54eab0b00..501f9b623188 100644
--- a/net/netfilter/xt_iprange.c
+++ b/net/netfilter/xt_iprange.c
@@ -26,12 +26,11 @@ iprange_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
26 if ((ntohl(iph->saddr) < ntohl(info->src.min_ip) 26 if ((ntohl(iph->saddr) < ntohl(info->src.min_ip)
27 || ntohl(iph->saddr) > ntohl(info->src.max_ip)) 27 || ntohl(iph->saddr) > ntohl(info->src.max_ip))
28 ^ !!(info->flags & IPRANGE_SRC_INV)) { 28 ^ !!(info->flags & IPRANGE_SRC_INV)) {
29 pr_debug("src IP %u.%u.%u.%u NOT in range %s" 29 pr_debug("src IP %pI4 NOT in range %s%pI4-%pI4\n",
30 "%u.%u.%u.%u-%u.%u.%u.%u\n", 30 &iph->saddr,
31 NIPQUAD(iph->saddr),
32 info->flags & IPRANGE_SRC_INV ? "(INV) " : "", 31 info->flags & IPRANGE_SRC_INV ? "(INV) " : "",
33 NIPQUAD(info->src.min_ip), 32 &info->src.min_ip,
34 NIPQUAD(info->src.max_ip)); 33 &info->src.max_ip);
35 return false; 34 return false;
36 } 35 }
37 } 36 }
@@ -39,12 +38,11 @@ iprange_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
39 if ((ntohl(iph->daddr) < ntohl(info->dst.min_ip) 38 if ((ntohl(iph->daddr) < ntohl(info->dst.min_ip)
40 || ntohl(iph->daddr) > ntohl(info->dst.max_ip)) 39 || ntohl(iph->daddr) > ntohl(info->dst.max_ip))
41 ^ !!(info->flags & IPRANGE_DST_INV)) { 40 ^ !!(info->flags & IPRANGE_DST_INV)) {
42 pr_debug("dst IP %u.%u.%u.%u NOT in range %s" 41 pr_debug("dst IP %pI4 NOT in range %s%pI4-%pI4\n",
43 "%u.%u.%u.%u-%u.%u.%u.%u\n", 42 &iph->daddr,
44 NIPQUAD(iph->daddr),
45 info->flags & IPRANGE_DST_INV ? "(INV) " : "", 43 info->flags & IPRANGE_DST_INV ? "(INV) " : "",
46 NIPQUAD(info->dst.min_ip), 44 &info->dst.min_ip,
47 NIPQUAD(info->dst.max_ip)); 45 &info->dst.max_ip);
48 return false; 46 return false;
49 } 47 }
50 } 48 }
@@ -63,12 +61,11 @@ iprange_mt4(const struct sk_buff *skb, const struct xt_match_param *par)
63 m |= ntohl(iph->saddr) > ntohl(info->src_max.ip); 61 m |= ntohl(iph->saddr) > ntohl(info->src_max.ip);
64 m ^= !!(info->flags & IPRANGE_SRC_INV); 62 m ^= !!(info->flags & IPRANGE_SRC_INV);
65 if (m) { 63 if (m) {
66 pr_debug("src IP " NIPQUAD_FMT " NOT in range %s" 64 pr_debug("src IP %pI4 NOT in range %s%pI4-%pI4\n",
67 NIPQUAD_FMT "-" NIPQUAD_FMT "\n", 65 &iph->saddr,
68 NIPQUAD(iph->saddr),
69 (info->flags & IPRANGE_SRC_INV) ? "(INV) " : "", 66 (info->flags & IPRANGE_SRC_INV) ? "(INV) " : "",
70 NIPQUAD(info->src_max.ip), 67 &info->src_max.ip,
71 NIPQUAD(info->src_max.ip)); 68 &info->src_max.ip);
72 return false; 69 return false;
73 } 70 }
74 } 71 }
@@ -77,12 +74,11 @@ iprange_mt4(const struct sk_buff *skb, const struct xt_match_param *par)
77 m |= ntohl(iph->daddr) > ntohl(info->dst_max.ip); 74 m |= ntohl(iph->daddr) > ntohl(info->dst_max.ip);
78 m ^= !!(info->flags & IPRANGE_DST_INV); 75 m ^= !!(info->flags & IPRANGE_DST_INV);
79 if (m) { 76 if (m) {
80 pr_debug("dst IP " NIPQUAD_FMT " NOT in range %s" 77 pr_debug("dst IP %pI4 NOT in range %s%pI4-%pI4\n",
81 NIPQUAD_FMT "-" NIPQUAD_FMT "\n", 78 &iph->daddr,
82 NIPQUAD(iph->daddr),
83 (info->flags & IPRANGE_DST_INV) ? "(INV) " : "", 79 (info->flags & IPRANGE_DST_INV) ? "(INV) " : "",
84 NIPQUAD(info->dst_min.ip), 80 &info->dst_min.ip,
85 NIPQUAD(info->dst_max.ip)); 81 &info->dst_max.ip);
86 return false; 82 return false;
87 } 83 }
88 } 84 }
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 280c471bcdf4..3c3dd22b1d06 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -422,13 +422,11 @@ static int recent_seq_show(struct seq_file *seq, void *v)
422 422
423 i = (e->index - 1) % ip_pkt_list_tot; 423 i = (e->index - 1) % ip_pkt_list_tot;
424 if (e->family == NFPROTO_IPV4) 424 if (e->family == NFPROTO_IPV4)
425 seq_printf(seq, "src=" NIPQUAD_FMT " ttl: %u last_seen: %lu " 425 seq_printf(seq, "src=%pI4 ttl: %u last_seen: %lu oldest_pkt: %u",
426 "oldest_pkt: %u", NIPQUAD(e->addr.ip), e->ttl, 426 &e->addr.ip, e->ttl, e->stamps[i], e->index);
427 e->stamps[i], e->index);
428 else 427 else
429 seq_printf(seq, "src=" NIP6_FMT " ttl: %u last_seen: %lu " 428 seq_printf(seq, "src=%pI6 ttl: %u last_seen: %lu oldest_pkt: %u",
430 "oldest_pkt: %u", NIP6(e->addr.in6), e->ttl, 429 &e->addr.in6, e->ttl, e->stamps[i], e->index);
431 e->stamps[i], e->index);
432 for (i = 0; i < e->nstamps; i++) 430 for (i = 0; i < e->nstamps; i++)
433 seq_printf(seq, "%s %lu", i ? "," : "", e->stamps[i]); 431 seq_printf(seq, "%s %lu", i ? "," : "", e->stamps[i]);
434 seq_printf(seq, "\n"); 432 seq_printf(seq, "\n");
diff --git a/net/netlabel/netlabel_addrlist.c b/net/netlabel/netlabel_addrlist.c
index 249f6b92f153..834c6eb7f484 100644
--- a/net/netlabel/netlabel_addrlist.c
+++ b/net/netlabel/netlabel_addrlist.c
@@ -337,7 +337,7 @@ void netlbl_af4list_audit_addr(struct audit_buffer *audit_buf,
337 337
338 if (dev != NULL) 338 if (dev != NULL)
339 audit_log_format(audit_buf, " netif=%s", dev); 339 audit_log_format(audit_buf, " netif=%s", dev);
340 audit_log_format(audit_buf, " %s=" NIPQUAD_FMT, dir, NIPQUAD(addr)); 340 audit_log_format(audit_buf, " %s=%pI4", dir, &addr);
341 if (mask_val != 0xffffffff) { 341 if (mask_val != 0xffffffff) {
342 u32 mask_len = 0; 342 u32 mask_len = 0;
343 while (mask_val > 0) { 343 while (mask_val > 0) {
@@ -371,7 +371,7 @@ void netlbl_af6list_audit_addr(struct audit_buffer *audit_buf,
371 371
372 if (dev != NULL) 372 if (dev != NULL)
373 audit_log_format(audit_buf, " netif=%s", dev); 373 audit_log_format(audit_buf, " netif=%s", dev);
374 audit_log_format(audit_buf, " %s=" NIP6_FMT, dir, NIP6(*addr)); 374 audit_log_format(audit_buf, " %s=%pI6", dir, addr);
375 if (ntohl(mask->s6_addr32[3]) != 0xffffffff) { 375 if (ntohl(mask->s6_addr32[3]) != 0xffffffff) {
376 u32 mask_len = 0; 376 u32 mask_len = 0;
377 u32 mask_val; 377 u32 mask_val;
diff --git a/net/netlink/attr.c b/net/netlink/attr.c
index 2d106cfe1d27..c83fea7da9a8 100644
--- a/net/netlink/attr.c
+++ b/net/netlink/attr.c
@@ -233,7 +233,7 @@ size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
233 * 233 *
234 * Returns the number of bytes copied. 234 * Returns the number of bytes copied.
235 */ 235 */
236int nla_memcpy(void *dest, struct nlattr *src, int count) 236int nla_memcpy(void *dest, const struct nlattr *src, int count)
237{ 237{
238 int minlen = min_t(int, count, nla_len(src)); 238 int minlen = min_t(int, count, nla_len(src));
239 239
diff --git a/net/netrom/sysctl_net_netrom.c b/net/netrom/sysctl_net_netrom.c
index 34c96c9674df..7b49591fe87c 100644
--- a/net/netrom/sysctl_net_netrom.c
+++ b/net/netrom/sysctl_net_netrom.c
@@ -41,8 +41,8 @@ static ctl_table nr_table[] = {
41 .data = &sysctl_netrom_default_path_quality, 41 .data = &sysctl_netrom_default_path_quality,
42 .maxlen = sizeof(int), 42 .maxlen = sizeof(int),
43 .mode = 0644, 43 .mode = 0644,
44 .proc_handler = &proc_dointvec_minmax, 44 .proc_handler = proc_dointvec_minmax,
45 .strategy = &sysctl_intvec, 45 .strategy = sysctl_intvec,
46 .extra1 = &min_quality, 46 .extra1 = &min_quality,
47 .extra2 = &max_quality 47 .extra2 = &max_quality
48 }, 48 },
@@ -52,8 +52,8 @@ static ctl_table nr_table[] = {
52 .data = &sysctl_netrom_obsolescence_count_initialiser, 52 .data = &sysctl_netrom_obsolescence_count_initialiser,
53 .maxlen = sizeof(int), 53 .maxlen = sizeof(int),
54 .mode = 0644, 54 .mode = 0644,
55 .proc_handler = &proc_dointvec_minmax, 55 .proc_handler = proc_dointvec_minmax,
56 .strategy = &sysctl_intvec, 56 .strategy = sysctl_intvec,
57 .extra1 = &min_obs, 57 .extra1 = &min_obs,
58 .extra2 = &max_obs 58 .extra2 = &max_obs
59 }, 59 },
@@ -63,8 +63,8 @@ static ctl_table nr_table[] = {
63 .data = &sysctl_netrom_network_ttl_initialiser, 63 .data = &sysctl_netrom_network_ttl_initialiser,
64 .maxlen = sizeof(int), 64 .maxlen = sizeof(int),
65 .mode = 0644, 65 .mode = 0644,
66 .proc_handler = &proc_dointvec_minmax, 66 .proc_handler = proc_dointvec_minmax,
67 .strategy = &sysctl_intvec, 67 .strategy = sysctl_intvec,
68 .extra1 = &min_ttl, 68 .extra1 = &min_ttl,
69 .extra2 = &max_ttl 69 .extra2 = &max_ttl
70 }, 70 },
@@ -74,8 +74,8 @@ static ctl_table nr_table[] = {
74 .data = &sysctl_netrom_transport_timeout, 74 .data = &sysctl_netrom_transport_timeout,
75 .maxlen = sizeof(int), 75 .maxlen = sizeof(int),
76 .mode = 0644, 76 .mode = 0644,
77 .proc_handler = &proc_dointvec_minmax, 77 .proc_handler = proc_dointvec_minmax,
78 .strategy = &sysctl_intvec, 78 .strategy = sysctl_intvec,
79 .extra1 = &min_t1, 79 .extra1 = &min_t1,
80 .extra2 = &max_t1 80 .extra2 = &max_t1
81 }, 81 },
@@ -85,8 +85,8 @@ static ctl_table nr_table[] = {
85 .data = &sysctl_netrom_transport_maximum_tries, 85 .data = &sysctl_netrom_transport_maximum_tries,
86 .maxlen = sizeof(int), 86 .maxlen = sizeof(int),
87 .mode = 0644, 87 .mode = 0644,
88 .proc_handler = &proc_dointvec_minmax, 88 .proc_handler = proc_dointvec_minmax,
89 .strategy = &sysctl_intvec, 89 .strategy = sysctl_intvec,
90 .extra1 = &min_n2, 90 .extra1 = &min_n2,
91 .extra2 = &max_n2 91 .extra2 = &max_n2
92 }, 92 },
@@ -96,8 +96,8 @@ static ctl_table nr_table[] = {
96 .data = &sysctl_netrom_transport_acknowledge_delay, 96 .data = &sysctl_netrom_transport_acknowledge_delay,
97 .maxlen = sizeof(int), 97 .maxlen = sizeof(int),
98 .mode = 0644, 98 .mode = 0644,
99 .proc_handler = &proc_dointvec_minmax, 99 .proc_handler = proc_dointvec_minmax,
100 .strategy = &sysctl_intvec, 100 .strategy = sysctl_intvec,
101 .extra1 = &min_t2, 101 .extra1 = &min_t2,
102 .extra2 = &max_t2 102 .extra2 = &max_t2
103 }, 103 },
@@ -107,8 +107,8 @@ static ctl_table nr_table[] = {
107 .data = &sysctl_netrom_transport_busy_delay, 107 .data = &sysctl_netrom_transport_busy_delay,
108 .maxlen = sizeof(int), 108 .maxlen = sizeof(int),
109 .mode = 0644, 109 .mode = 0644,
110 .proc_handler = &proc_dointvec_minmax, 110 .proc_handler = proc_dointvec_minmax,
111 .strategy = &sysctl_intvec, 111 .strategy = sysctl_intvec,
112 .extra1 = &min_t4, 112 .extra1 = &min_t4,
113 .extra2 = &max_t4 113 .extra2 = &max_t4
114 }, 114 },
@@ -118,8 +118,8 @@ static ctl_table nr_table[] = {
118 .data = &sysctl_netrom_transport_requested_window_size, 118 .data = &sysctl_netrom_transport_requested_window_size,
119 .maxlen = sizeof(int), 119 .maxlen = sizeof(int),
120 .mode = 0644, 120 .mode = 0644,
121 .proc_handler = &proc_dointvec_minmax, 121 .proc_handler = proc_dointvec_minmax,
122 .strategy = &sysctl_intvec, 122 .strategy = sysctl_intvec,
123 .extra1 = &min_window, 123 .extra1 = &min_window,
124 .extra2 = &max_window 124 .extra2 = &max_window
125 }, 125 },
@@ -129,8 +129,8 @@ static ctl_table nr_table[] = {
129 .data = &sysctl_netrom_transport_no_activity_timeout, 129 .data = &sysctl_netrom_transport_no_activity_timeout,
130 .maxlen = sizeof(int), 130 .maxlen = sizeof(int),
131 .mode = 0644, 131 .mode = 0644,
132 .proc_handler = &proc_dointvec_minmax, 132 .proc_handler = proc_dointvec_minmax,
133 .strategy = &sysctl_intvec, 133 .strategy = sysctl_intvec,
134 .extra1 = &min_idle, 134 .extra1 = &min_idle,
135 .extra2 = &max_idle 135 .extra2 = &max_idle
136 }, 136 },
@@ -140,8 +140,8 @@ static ctl_table nr_table[] = {
140 .data = &sysctl_netrom_routing_control, 140 .data = &sysctl_netrom_routing_control,
141 .maxlen = sizeof(int), 141 .maxlen = sizeof(int),
142 .mode = 0644, 142 .mode = 0644,
143 .proc_handler = &proc_dointvec_minmax, 143 .proc_handler = proc_dointvec_minmax,
144 .strategy = &sysctl_intvec, 144 .strategy = sysctl_intvec,
145 .extra1 = &min_route, 145 .extra1 = &min_route,
146 .extra2 = &max_route 146 .extra2 = &max_route
147 }, 147 },
@@ -151,8 +151,8 @@ static ctl_table nr_table[] = {
151 .data = &sysctl_netrom_link_fails_count, 151 .data = &sysctl_netrom_link_fails_count,
152 .maxlen = sizeof(int), 152 .maxlen = sizeof(int),
153 .mode = 0644, 153 .mode = 0644,
154 .proc_handler = &proc_dointvec_minmax, 154 .proc_handler = proc_dointvec_minmax,
155 .strategy = &sysctl_intvec, 155 .strategy = sysctl_intvec,
156 .extra1 = &min_fails, 156 .extra1 = &min_fails,
157 .extra2 = &max_fails 157 .extra2 = &max_fails
158 }, 158 },
@@ -162,8 +162,8 @@ static ctl_table nr_table[] = {
162 .data = &sysctl_netrom_reset_circuit, 162 .data = &sysctl_netrom_reset_circuit,
163 .maxlen = sizeof(int), 163 .maxlen = sizeof(int),
164 .mode = 0644, 164 .mode = 0644,
165 .proc_handler = &proc_dointvec_minmax, 165 .proc_handler = proc_dointvec_minmax,
166 .strategy = &sysctl_intvec, 166 .strategy = sysctl_intvec,
167 .extra1 = &min_reset, 167 .extra1 = &min_reset,
168 .extra2 = &max_reset 168 .extra2 = &max_reset
169 }, 169 },
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index c718e7e3f7de..b4870a34c435 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -910,6 +910,7 @@ static int packet_release(struct socket *sock)
910 skb_queue_purge(&sk->sk_receive_queue); 910 skb_queue_purge(&sk->sk_receive_queue);
911 sk_refcnt_debug_release(sk); 911 sk_refcnt_debug_release(sk);
912 912
913 sock_prot_inuse_add(net, sk->sk_prot, -1);
913 sock_put(sk); 914 sock_put(sk);
914 return 0; 915 return 0;
915} 916}
@@ -1085,6 +1086,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol)
1085 write_lock_bh(&net->packet.sklist_lock); 1086 write_lock_bh(&net->packet.sklist_lock);
1086 sk_add_node(sk, &net->packet.sklist); 1087 sk_add_node(sk, &net->packet.sklist);
1087 write_unlock_bh(&net->packet.sklist_lock); 1088 write_unlock_bh(&net->packet.sklist_lock);
1089 sock_prot_inuse_add(net, &packet_proto, 1);
1088 return(0); 1090 return(0);
1089out: 1091out:
1090 return err; 1092 return err;
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c
index 9978afbd9f2a..e6e8e44852e5 100644
--- a/net/phonet/pep-gprs.c
+++ b/net/phonet/pep-gprs.c
@@ -41,7 +41,6 @@ struct gprs_dev {
41 void (*old_write_space)(struct sock *); 41 void (*old_write_space)(struct sock *);
42 42
43 struct net_device *net; 43 struct net_device *net;
44 struct net_device_stats stats;
45 44
46 struct sk_buff_head tx_queue; 45 struct sk_buff_head tx_queue;
47 struct work_struct tx_work; 46 struct work_struct tx_work;
@@ -49,14 +48,14 @@ struct gprs_dev {
49 unsigned tx_max; 48 unsigned tx_max;
50}; 49};
51 50
52static int gprs_type_trans(struct sk_buff *skb) 51static __be16 gprs_type_trans(struct sk_buff *skb)
53{ 52{
54 const u8 *pvfc; 53 const u8 *pvfc;
55 u8 buf; 54 u8 buf;
56 55
57 pvfc = skb_header_pointer(skb, 0, 1, &buf); 56 pvfc = skb_header_pointer(skb, 0, 1, &buf);
58 if (!pvfc) 57 if (!pvfc)
59 return 0; 58 return htons(0);
60 /* Look at IP version field */ 59 /* Look at IP version field */
61 switch (*pvfc >> 4) { 60 switch (*pvfc >> 4) {
62 case 4: 61 case 4:
@@ -64,7 +63,7 @@ static int gprs_type_trans(struct sk_buff *skb)
64 case 6: 63 case 6:
65 return htons(ETH_P_IPV6); 64 return htons(ETH_P_IPV6);
66 } 65 }
67 return 0; 66 return htons(0);
68} 67}
69 68
70/* 69/*
@@ -83,8 +82,9 @@ static void gprs_state_change(struct sock *sk)
83 82
84static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb) 83static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb)
85{ 84{
85 struct net_device *net = dev->net;
86 int err = 0; 86 int err = 0;
87 u16 protocol = gprs_type_trans(skb); 87 __be16 protocol = gprs_type_trans(skb);
88 88
89 if (!protocol) { 89 if (!protocol) {
90 err = -EINVAL; 90 err = -EINVAL;
@@ -99,7 +99,7 @@ static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb)
99 * so wrap the IP packet as a single fragment of an head-less 99 * so wrap the IP packet as a single fragment of an head-less
100 * socket buffer. The network stack will pull what it needs, 100 * socket buffer. The network stack will pull what it needs,
101 * but at least, the whole IP payload is not memcpy'd. */ 101 * but at least, the whole IP payload is not memcpy'd. */
102 rskb = netdev_alloc_skb(dev->net, 0); 102 rskb = netdev_alloc_skb(net, 0);
103 if (!rskb) { 103 if (!rskb) {
104 err = -ENOBUFS; 104 err = -ENOBUFS;
105 goto drop; 105 goto drop;
@@ -123,11 +123,11 @@ static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb)
123 123
124 skb->protocol = protocol; 124 skb->protocol = protocol;
125 skb_reset_mac_header(skb); 125 skb_reset_mac_header(skb);
126 skb->dev = dev->net; 126 skb->dev = net;
127 127
128 if (likely(dev->net->flags & IFF_UP)) { 128 if (likely(net->flags & IFF_UP)) {
129 dev->stats.rx_packets++; 129 net->stats.rx_packets++;
130 dev->stats.rx_bytes += skb->len; 130 net->stats.rx_bytes += skb->len;
131 netif_rx(skb); 131 netif_rx(skb);
132 skb = NULL; 132 skb = NULL;
133 } else 133 } else
@@ -136,7 +136,7 @@ static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb)
136drop: 136drop:
137 if (skb) { 137 if (skb) {
138 dev_kfree_skb(skb); 138 dev_kfree_skb(skb);
139 dev->stats.rx_dropped++; 139 net->stats.rx_dropped++;
140 } 140 }
141 return err; 141 return err;
142} 142}
@@ -199,14 +199,15 @@ static int gprs_xmit(struct sk_buff *skb, struct net_device *net)
199static void gprs_tx(struct work_struct *work) 199static void gprs_tx(struct work_struct *work)
200{ 200{
201 struct gprs_dev *dev = container_of(work, struct gprs_dev, tx_work); 201 struct gprs_dev *dev = container_of(work, struct gprs_dev, tx_work);
202 struct net_device *net = dev->net;
202 struct sock *sk = dev->sk; 203 struct sock *sk = dev->sk;
203 struct sk_buff *skb; 204 struct sk_buff *skb;
204 205
205 while ((skb = skb_dequeue(&dev->tx_queue)) != NULL) { 206 while ((skb = skb_dequeue(&dev->tx_queue)) != NULL) {
206 int err; 207 int err;
207 208
208 dev->stats.tx_bytes += skb->len; 209 net->stats.tx_bytes += skb->len;
209 dev->stats.tx_packets++; 210 net->stats.tx_packets++;
210 211
211 skb_orphan(skb); 212 skb_orphan(skb);
212 skb_set_owner_w(skb, sk); 213 skb_set_owner_w(skb, sk);
@@ -215,9 +216,9 @@ static void gprs_tx(struct work_struct *work)
215 err = pep_write(sk, skb); 216 err = pep_write(sk, skb);
216 if (err) { 217 if (err) {
217 LIMIT_NETDEBUG(KERN_WARNING"%s: TX error (%d)\n", 218 LIMIT_NETDEBUG(KERN_WARNING"%s: TX error (%d)\n",
218 dev->net->name, err); 219 net->name, err);
219 dev->stats.tx_aborted_errors++; 220 net->stats.tx_aborted_errors++;
220 dev->stats.tx_errors++; 221 net->stats.tx_errors++;
221 } 222 }
222 release_sock(sk); 223 release_sock(sk);
223 } 224 }
@@ -236,13 +237,6 @@ static int gprs_set_mtu(struct net_device *net, int new_mtu)
236 return 0; 237 return 0;
237} 238}
238 239
239static struct net_device_stats *gprs_get_stats(struct net_device *net)
240{
241 struct gprs_dev *dev = netdev_priv(net);
242
243 return &dev->stats;
244}
245
246static void gprs_setup(struct net_device *net) 240static void gprs_setup(struct net_device *net)
247{ 241{
248 net->features = NETIF_F_FRAGLIST; 242 net->features = NETIF_F_FRAGLIST;
@@ -256,7 +250,6 @@ static void gprs_setup(struct net_device *net)
256 net->destructor = free_netdev; 250 net->destructor = free_netdev;
257 net->hard_start_xmit = gprs_xmit; /* mandatory */ 251 net->hard_start_xmit = gprs_xmit; /* mandatory */
258 net->change_mtu = gprs_set_mtu; 252 net->change_mtu = gprs_set_mtu;
259 net->get_stats = gprs_get_stats;
260} 253}
261 254
262/* 255/*
diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
index 600a4309b8c8..0e3347bbdb12 100644
--- a/net/phonet/sysctl.c
+++ b/net/phonet/sysctl.c
@@ -89,7 +89,7 @@ static struct ctl_table phonet_table[] = {
89 .data = &local_port_range, 89 .data = &local_port_range,
90 .maxlen = sizeof(local_port_range), 90 .maxlen = sizeof(local_port_range),
91 .mode = 0644, 91 .mode = 0644,
92 .proc_handler = &proc_local_port_range, 92 .proc_handler = proc_local_port_range,
93 .strategy = NULL, 93 .strategy = NULL,
94 }, 94 },
95 { .ctl_name = 0 } 95 { .ctl_name = 0 }
diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c
index bfdade72e066..84efde97c5a7 100644
--- a/net/rfkill/rfkill-input.c
+++ b/net/rfkill/rfkill-input.c
@@ -24,138 +24,318 @@ MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
24MODULE_DESCRIPTION("Input layer to RF switch connector"); 24MODULE_DESCRIPTION("Input layer to RF switch connector");
25MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
26 26
27enum rfkill_input_master_mode {
28 RFKILL_INPUT_MASTER_DONOTHING = 0,
29 RFKILL_INPUT_MASTER_RESTORE = 1,
30 RFKILL_INPUT_MASTER_UNBLOCKALL = 2,
31 RFKILL_INPUT_MASTER_MAX, /* marker */
32};
33
34/* Delay (in ms) between consecutive switch ops */
35#define RFKILL_OPS_DELAY 200
36
37static enum rfkill_input_master_mode rfkill_master_switch_mode =
38 RFKILL_INPUT_MASTER_UNBLOCKALL;
39module_param_named(master_switch_mode, rfkill_master_switch_mode, uint, 0);
40MODULE_PARM_DESC(master_switch_mode,
41 "SW_RFKILL_ALL ON should: 0=do nothing; 1=restore; 2=unblock all");
42
43enum rfkill_global_sched_op {
44 RFKILL_GLOBAL_OP_EPO = 0,
45 RFKILL_GLOBAL_OP_RESTORE,
46 RFKILL_GLOBAL_OP_UNLOCK,
47 RFKILL_GLOBAL_OP_UNBLOCK,
48};
49
50/*
51 * Currently, the code marked with RFKILL_NEED_SWSET is inactive.
52 * If handling of EV_SW SW_WLAN/WWAN/BLUETOOTH/etc is needed in the
53 * future, when such events are added, that code will be necessary.
54 */
55
27struct rfkill_task { 56struct rfkill_task {
28 struct work_struct work; 57 struct delayed_work dwork;
29 enum rfkill_type type; 58
30 struct mutex mutex; /* ensures that task is serialized */ 59 /* ensures that task is serialized */
31 spinlock_t lock; /* for accessing last and desired state */ 60 struct mutex mutex;
32 unsigned long last; /* last schedule */ 61
33 enum rfkill_state desired_state; /* on/off */ 62 /* protects everything below */
63 spinlock_t lock;
64
65 /* pending regular switch operations (1=pending) */
66 unsigned long sw_pending[BITS_TO_LONGS(RFKILL_TYPE_MAX)];
67
68#ifdef RFKILL_NEED_SWSET
69 /* set operation pending (1=pending) */
70 unsigned long sw_setpending[BITS_TO_LONGS(RFKILL_TYPE_MAX)];
71
72 /* desired state for pending set operation (1=unblock) */
73 unsigned long sw_newstate[BITS_TO_LONGS(RFKILL_TYPE_MAX)];
74#endif
75
76 /* should the state be complemented (1=yes) */
77 unsigned long sw_togglestate[BITS_TO_LONGS(RFKILL_TYPE_MAX)];
78
79 bool global_op_pending;
80 enum rfkill_global_sched_op op;
81
82 /* last time it was scheduled */
83 unsigned long last_scheduled;
34}; 84};
35 85
86static void __rfkill_handle_global_op(enum rfkill_global_sched_op op)
87{
88 unsigned int i;
89
90 switch (op) {
91 case RFKILL_GLOBAL_OP_EPO:
92 rfkill_epo();
93 break;
94 case RFKILL_GLOBAL_OP_RESTORE:
95 rfkill_restore_states();
96 break;
97 case RFKILL_GLOBAL_OP_UNLOCK:
98 rfkill_remove_epo_lock();
99 break;
100 case RFKILL_GLOBAL_OP_UNBLOCK:
101 rfkill_remove_epo_lock();
102 for (i = 0; i < RFKILL_TYPE_MAX; i++)
103 rfkill_switch_all(i, RFKILL_STATE_UNBLOCKED);
104 break;
105 default:
106 /* memory corruption or bug, fail safely */
107 rfkill_epo();
108 WARN(1, "Unknown requested operation %d! "
109 "rfkill Emergency Power Off activated\n",
110 op);
111 }
112}
113
114#ifdef RFKILL_NEED_SWSET
115static void __rfkill_handle_normal_op(const enum rfkill_type type,
116 const bool sp, const bool s, const bool c)
117{
118 enum rfkill_state state;
119
120 if (sp)
121 state = (s) ? RFKILL_STATE_UNBLOCKED :
122 RFKILL_STATE_SOFT_BLOCKED;
123 else
124 state = rfkill_get_global_state(type);
125
126 if (c)
127 state = rfkill_state_complement(state);
128
129 rfkill_switch_all(type, state);
130}
131#else
132static void __rfkill_handle_normal_op(const enum rfkill_type type,
133 const bool c)
134{
135 enum rfkill_state state;
136
137 state = rfkill_get_global_state(type);
138 if (c)
139 state = rfkill_state_complement(state);
140
141 rfkill_switch_all(type, state);
142}
143#endif
144
36static void rfkill_task_handler(struct work_struct *work) 145static void rfkill_task_handler(struct work_struct *work)
37{ 146{
38 struct rfkill_task *task = container_of(work, struct rfkill_task, work); 147 struct rfkill_task *task = container_of(work,
148 struct rfkill_task, dwork.work);
149 bool doit = true;
39 150
40 mutex_lock(&task->mutex); 151 mutex_lock(&task->mutex);
41 152
42 rfkill_switch_all(task->type, task->desired_state); 153 spin_lock_irq(&task->lock);
154 while (doit) {
155 if (task->global_op_pending) {
156 enum rfkill_global_sched_op op = task->op;
157 task->global_op_pending = false;
158 memset(task->sw_pending, 0, sizeof(task->sw_pending));
159 spin_unlock_irq(&task->lock);
160
161 __rfkill_handle_global_op(op);
162
163 /* make sure we do at least one pass with
164 * !task->global_op_pending */
165 spin_lock_irq(&task->lock);
166 continue;
167 } else if (!rfkill_is_epo_lock_active()) {
168 unsigned int i = 0;
169
170 while (!task->global_op_pending &&
171 i < RFKILL_TYPE_MAX) {
172 if (test_and_clear_bit(i, task->sw_pending)) {
173 bool c;
174#ifdef RFKILL_NEED_SWSET
175 bool sp, s;
176 sp = test_and_clear_bit(i,
177 task->sw_setpending);
178 s = test_bit(i, task->sw_newstate);
179#endif
180 c = test_and_clear_bit(i,
181 task->sw_togglestate);
182 spin_unlock_irq(&task->lock);
183
184#ifdef RFKILL_NEED_SWSET
185 __rfkill_handle_normal_op(i, sp, s, c);
186#else
187 __rfkill_handle_normal_op(i, c);
188#endif
189
190 spin_lock_irq(&task->lock);
191 }
192 i++;
193 }
194 }
195 doit = task->global_op_pending;
196 }
197 spin_unlock_irq(&task->lock);
43 198
44 mutex_unlock(&task->mutex); 199 mutex_unlock(&task->mutex);
45} 200}
46 201
47static void rfkill_task_epo_handler(struct work_struct *work) 202static struct rfkill_task rfkill_task = {
203 .dwork = __DELAYED_WORK_INITIALIZER(rfkill_task.dwork,
204 rfkill_task_handler),
205 .mutex = __MUTEX_INITIALIZER(rfkill_task.mutex),
206 .lock = __SPIN_LOCK_UNLOCKED(rfkill_task.lock),
207};
208
209static unsigned long rfkill_ratelimit(const unsigned long last)
48{ 210{
49 rfkill_epo(); 211 const unsigned long delay = msecs_to_jiffies(RFKILL_OPS_DELAY);
212 return (time_after(jiffies, last + delay)) ? 0 : delay;
50} 213}
51 214
52static DECLARE_WORK(epo_work, rfkill_task_epo_handler); 215static void rfkill_schedule_ratelimited(void)
216{
217 if (!delayed_work_pending(&rfkill_task.dwork)) {
218 schedule_delayed_work(&rfkill_task.dwork,
219 rfkill_ratelimit(rfkill_task.last_scheduled));
220 rfkill_task.last_scheduled = jiffies;
221 }
222}
53 223
54static void rfkill_schedule_epo(void) 224static void rfkill_schedule_global_op(enum rfkill_global_sched_op op)
55{ 225{
56 schedule_work(&epo_work); 226 unsigned long flags;
227
228 spin_lock_irqsave(&rfkill_task.lock, flags);
229 rfkill_task.op = op;
230 rfkill_task.global_op_pending = true;
231 if (op == RFKILL_GLOBAL_OP_EPO && !rfkill_is_epo_lock_active()) {
232 /* bypass the limiter for EPO */
233 cancel_delayed_work(&rfkill_task.dwork);
234 schedule_delayed_work(&rfkill_task.dwork, 0);
235 rfkill_task.last_scheduled = jiffies;
236 } else
237 rfkill_schedule_ratelimited();
238 spin_unlock_irqrestore(&rfkill_task.lock, flags);
57} 239}
58 240
59static void rfkill_schedule_set(struct rfkill_task *task, 241#ifdef RFKILL_NEED_SWSET
242/* Use this if you need to add EV_SW SW_WLAN/WWAN/BLUETOOTH/etc handling */
243
244static void rfkill_schedule_set(enum rfkill_type type,
60 enum rfkill_state desired_state) 245 enum rfkill_state desired_state)
61{ 246{
62 unsigned long flags; 247 unsigned long flags;
63 248
64 if (unlikely(work_pending(&epo_work))) 249 if (rfkill_is_epo_lock_active())
65 return; 250 return;
66 251
67 spin_lock_irqsave(&task->lock, flags); 252 spin_lock_irqsave(&rfkill_task.lock, flags);
68 253 if (!rfkill_task.global_op_pending) {
69 if (time_after(jiffies, task->last + msecs_to_jiffies(200))) { 254 set_bit(type, rfkill_task.sw_pending);
70 task->desired_state = desired_state; 255 set_bit(type, rfkill_task.sw_setpending);
71 task->last = jiffies; 256 clear_bit(type, rfkill_task.sw_togglestate);
72 schedule_work(&task->work); 257 if (desired_state)
258 set_bit(type, rfkill_task.sw_newstate);
259 else
260 clear_bit(type, rfkill_task.sw_newstate);
261 rfkill_schedule_ratelimited();
73 } 262 }
74 263 spin_unlock_irqrestore(&rfkill_task.lock, flags);
75 spin_unlock_irqrestore(&task->lock, flags);
76} 264}
265#endif
77 266
78static void rfkill_schedule_toggle(struct rfkill_task *task) 267static void rfkill_schedule_toggle(enum rfkill_type type)
79{ 268{
80 unsigned long flags; 269 unsigned long flags;
81 270
82 if (unlikely(work_pending(&epo_work))) 271 if (rfkill_is_epo_lock_active())
83 return; 272 return;
84 273
85 spin_lock_irqsave(&task->lock, flags); 274 spin_lock_irqsave(&rfkill_task.lock, flags);
86 275 if (!rfkill_task.global_op_pending) {
87 if (time_after(jiffies, task->last + msecs_to_jiffies(200))) { 276 set_bit(type, rfkill_task.sw_pending);
88 task->desired_state = 277 change_bit(type, rfkill_task.sw_togglestate);
89 rfkill_state_complement(task->desired_state); 278 rfkill_schedule_ratelimited();
90 task->last = jiffies;
91 schedule_work(&task->work);
92 } 279 }
93 280 spin_unlock_irqrestore(&rfkill_task.lock, flags);
94 spin_unlock_irqrestore(&task->lock, flags);
95} 281}
96 282
97#define DEFINE_RFKILL_TASK(n, t) \
98 struct rfkill_task n = { \
99 .work = __WORK_INITIALIZER(n.work, \
100 rfkill_task_handler), \
101 .type = t, \
102 .mutex = __MUTEX_INITIALIZER(n.mutex), \
103 .lock = __SPIN_LOCK_UNLOCKED(n.lock), \
104 .desired_state = RFKILL_STATE_UNBLOCKED, \
105 }
106
107static DEFINE_RFKILL_TASK(rfkill_wlan, RFKILL_TYPE_WLAN);
108static DEFINE_RFKILL_TASK(rfkill_bt, RFKILL_TYPE_BLUETOOTH);
109static DEFINE_RFKILL_TASK(rfkill_uwb, RFKILL_TYPE_UWB);
110static DEFINE_RFKILL_TASK(rfkill_wimax, RFKILL_TYPE_WIMAX);
111static DEFINE_RFKILL_TASK(rfkill_wwan, RFKILL_TYPE_WWAN);
112
113static void rfkill_schedule_evsw_rfkillall(int state) 283static void rfkill_schedule_evsw_rfkillall(int state)
114{ 284{
115 /* EVERY radio type. state != 0 means radios ON */
116 /* handle EPO (emergency power off) through shortcut */
117 if (state) { 285 if (state) {
118 rfkill_schedule_set(&rfkill_wwan, 286 switch (rfkill_master_switch_mode) {
119 RFKILL_STATE_UNBLOCKED); 287 case RFKILL_INPUT_MASTER_UNBLOCKALL:
120 rfkill_schedule_set(&rfkill_wimax, 288 rfkill_schedule_global_op(RFKILL_GLOBAL_OP_UNBLOCK);
121 RFKILL_STATE_UNBLOCKED); 289 break;
122 rfkill_schedule_set(&rfkill_uwb, 290 case RFKILL_INPUT_MASTER_RESTORE:
123 RFKILL_STATE_UNBLOCKED); 291 rfkill_schedule_global_op(RFKILL_GLOBAL_OP_RESTORE);
124 rfkill_schedule_set(&rfkill_bt, 292 break;
125 RFKILL_STATE_UNBLOCKED); 293 case RFKILL_INPUT_MASTER_DONOTHING:
126 rfkill_schedule_set(&rfkill_wlan, 294 rfkill_schedule_global_op(RFKILL_GLOBAL_OP_UNLOCK);
127 RFKILL_STATE_UNBLOCKED); 295 break;
296 default:
297 /* memory corruption or driver bug! fail safely */
298 rfkill_schedule_global_op(RFKILL_GLOBAL_OP_EPO);
299 WARN(1, "Unknown rfkill_master_switch_mode (%d), "
300 "driver bug or memory corruption detected!\n",
301 rfkill_master_switch_mode);
302 break;
303 }
128 } else 304 } else
129 rfkill_schedule_epo(); 305 rfkill_schedule_global_op(RFKILL_GLOBAL_OP_EPO);
130} 306}
131 307
132static void rfkill_event(struct input_handle *handle, unsigned int type, 308static void rfkill_event(struct input_handle *handle, unsigned int type,
133 unsigned int code, int data) 309 unsigned int code, int data)
134{ 310{
135 if (type == EV_KEY && data == 1) { 311 if (type == EV_KEY && data == 1) {
312 enum rfkill_type t;
313
136 switch (code) { 314 switch (code) {
137 case KEY_WLAN: 315 case KEY_WLAN:
138 rfkill_schedule_toggle(&rfkill_wlan); 316 t = RFKILL_TYPE_WLAN;
139 break; 317 break;
140 case KEY_BLUETOOTH: 318 case KEY_BLUETOOTH:
141 rfkill_schedule_toggle(&rfkill_bt); 319 t = RFKILL_TYPE_BLUETOOTH;
142 break; 320 break;
143 case KEY_UWB: 321 case KEY_UWB:
144 rfkill_schedule_toggle(&rfkill_uwb); 322 t = RFKILL_TYPE_UWB;
145 break; 323 break;
146 case KEY_WIMAX: 324 case KEY_WIMAX:
147 rfkill_schedule_toggle(&rfkill_wimax); 325 t = RFKILL_TYPE_WIMAX;
148 break; 326 break;
149 default: 327 default:
150 break; 328 return;
151 } 329 }
330 rfkill_schedule_toggle(t);
331 return;
152 } else if (type == EV_SW) { 332 } else if (type == EV_SW) {
153 switch (code) { 333 switch (code) {
154 case SW_RFKILL_ALL: 334 case SW_RFKILL_ALL:
155 rfkill_schedule_evsw_rfkillall(data); 335 rfkill_schedule_evsw_rfkillall(data);
156 break; 336 return;
157 default: 337 default:
158 break; 338 return;
159 } 339 }
160 } 340 }
161} 341}
@@ -256,18 +436,23 @@ static struct input_handler rfkill_handler = {
256 436
257static int __init rfkill_handler_init(void) 437static int __init rfkill_handler_init(void)
258{ 438{
259 unsigned long last_run = jiffies - msecs_to_jiffies(500); 439 if (rfkill_master_switch_mode >= RFKILL_INPUT_MASTER_MAX)
260 rfkill_wlan.last = last_run; 440 return -EINVAL;
261 rfkill_bt.last = last_run; 441
262 rfkill_uwb.last = last_run; 442 /*
263 rfkill_wimax.last = last_run; 443 * The penalty to not doing this is a possible RFKILL_OPS_DELAY delay
444 * at the first use. Acceptable, but if we can avoid it, why not?
445 */
446 rfkill_task.last_scheduled =
447 jiffies - msecs_to_jiffies(RFKILL_OPS_DELAY) - 1;
264 return input_register_handler(&rfkill_handler); 448 return input_register_handler(&rfkill_handler);
265} 449}
266 450
267static void __exit rfkill_handler_exit(void) 451static void __exit rfkill_handler_exit(void)
268{ 452{
269 input_unregister_handler(&rfkill_handler); 453 input_unregister_handler(&rfkill_handler);
270 flush_scheduled_work(); 454 cancel_delayed_work_sync(&rfkill_task.dwork);
455 rfkill_remove_epo_lock();
271} 456}
272 457
273module_init(rfkill_handler_init); 458module_init(rfkill_handler_init);
diff --git a/net/rfkill/rfkill-input.h b/net/rfkill/rfkill-input.h
index bbfa646157c6..fe8df6b5b935 100644
--- a/net/rfkill/rfkill-input.h
+++ b/net/rfkill/rfkill-input.h
@@ -14,5 +14,8 @@
14void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state); 14void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state);
15void rfkill_epo(void); 15void rfkill_epo(void);
16void rfkill_restore_states(void); 16void rfkill_restore_states(void);
17void rfkill_remove_epo_lock(void);
18bool rfkill_is_epo_lock_active(void);
19enum rfkill_state rfkill_get_global_state(const enum rfkill_type type);
17 20
18#endif /* __RFKILL_INPUT_H */ 21#endif /* __RFKILL_INPUT_H */
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 25ba3bd57e66..ec26eae8004d 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -51,6 +51,7 @@ struct rfkill_gsw_state {
51 51
52static struct rfkill_gsw_state rfkill_global_states[RFKILL_TYPE_MAX]; 52static struct rfkill_gsw_state rfkill_global_states[RFKILL_TYPE_MAX];
53static unsigned long rfkill_states_lockdflt[BITS_TO_LONGS(RFKILL_TYPE_MAX)]; 53static unsigned long rfkill_states_lockdflt[BITS_TO_LONGS(RFKILL_TYPE_MAX)];
54static bool rfkill_epo_lock_active;
54 55
55static BLOCKING_NOTIFIER_HEAD(rfkill_notifier_list); 56static BLOCKING_NOTIFIER_HEAD(rfkill_notifier_list);
56 57
@@ -264,11 +265,14 @@ static void __rfkill_switch_all(const enum rfkill_type type,
264 * 265 *
265 * Acquires rfkill_global_mutex and calls __rfkill_switch_all(@type, @state). 266 * Acquires rfkill_global_mutex and calls __rfkill_switch_all(@type, @state).
266 * Please refer to __rfkill_switch_all() for details. 267 * Please refer to __rfkill_switch_all() for details.
268 *
269 * Does nothing if the EPO lock is active.
267 */ 270 */
268void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state) 271void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state)
269{ 272{
270 mutex_lock(&rfkill_global_mutex); 273 mutex_lock(&rfkill_global_mutex);
271 __rfkill_switch_all(type, state); 274 if (!rfkill_epo_lock_active)
275 __rfkill_switch_all(type, state);
272 mutex_unlock(&rfkill_global_mutex); 276 mutex_unlock(&rfkill_global_mutex);
273} 277}
274EXPORT_SYMBOL(rfkill_switch_all); 278EXPORT_SYMBOL(rfkill_switch_all);
@@ -289,6 +293,7 @@ void rfkill_epo(void)
289 293
290 mutex_lock(&rfkill_global_mutex); 294 mutex_lock(&rfkill_global_mutex);
291 295
296 rfkill_epo_lock_active = true;
292 list_for_each_entry(rfkill, &rfkill_list, node) { 297 list_for_each_entry(rfkill, &rfkill_list, node) {
293 mutex_lock(&rfkill->mutex); 298 mutex_lock(&rfkill->mutex);
294 rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); 299 rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
@@ -317,6 +322,7 @@ void rfkill_restore_states(void)
317 322
318 mutex_lock(&rfkill_global_mutex); 323 mutex_lock(&rfkill_global_mutex);
319 324
325 rfkill_epo_lock_active = false;
320 for (i = 0; i < RFKILL_TYPE_MAX; i++) 326 for (i = 0; i < RFKILL_TYPE_MAX; i++)
321 __rfkill_switch_all(i, rfkill_global_states[i].default_state); 327 __rfkill_switch_all(i, rfkill_global_states[i].default_state);
322 mutex_unlock(&rfkill_global_mutex); 328 mutex_unlock(&rfkill_global_mutex);
@@ -324,6 +330,48 @@ void rfkill_restore_states(void)
324EXPORT_SYMBOL_GPL(rfkill_restore_states); 330EXPORT_SYMBOL_GPL(rfkill_restore_states);
325 331
326/** 332/**
333 * rfkill_remove_epo_lock - unlock state changes
334 *
335 * Used by rfkill-input manually unlock state changes, when
336 * the EPO switch is deactivated.
337 */
338void rfkill_remove_epo_lock(void)
339{
340 mutex_lock(&rfkill_global_mutex);
341 rfkill_epo_lock_active = false;
342 mutex_unlock(&rfkill_global_mutex);
343}
344EXPORT_SYMBOL_GPL(rfkill_remove_epo_lock);
345
346/**
347 * rfkill_is_epo_lock_active - returns true EPO is active
348 *
349 * Returns 0 (false) if there is NOT an active EPO contidion,
350 * and 1 (true) if there is an active EPO contition, which
351 * locks all radios in one of the BLOCKED states.
352 *
353 * Can be called in atomic context.
354 */
355bool rfkill_is_epo_lock_active(void)
356{
357 return rfkill_epo_lock_active;
358}
359EXPORT_SYMBOL_GPL(rfkill_is_epo_lock_active);
360
361/**
362 * rfkill_get_global_state - returns global state for a type
363 * @type: the type to get the global state of
364 *
365 * Returns the current global state for a given wireless
366 * device type.
367 */
368enum rfkill_state rfkill_get_global_state(const enum rfkill_type type)
369{
370 return rfkill_global_states[type].current_state;
371}
372EXPORT_SYMBOL_GPL(rfkill_get_global_state);
373
374/**
327 * rfkill_force_state - Force the internal rfkill radio state 375 * rfkill_force_state - Force the internal rfkill radio state
328 * @rfkill: pointer to the rfkill class to modify. 376 * @rfkill: pointer to the rfkill class to modify.
329 * @state: the current radio state the class should be forced to. 377 * @state: the current radio state the class should be forced to.
@@ -431,9 +479,15 @@ static ssize_t rfkill_state_store(struct device *dev,
431 state != RFKILL_STATE_SOFT_BLOCKED) 479 state != RFKILL_STATE_SOFT_BLOCKED)
432 return -EINVAL; 480 return -EINVAL;
433 481
434 if (mutex_lock_interruptible(&rfkill->mutex)) 482 error = mutex_lock_killable(&rfkill->mutex);
435 return -ERESTARTSYS; 483 if (error)
436 error = rfkill_toggle_radio(rfkill, state, 0); 484 return error;
485
486 if (!rfkill_epo_lock_active)
487 error = rfkill_toggle_radio(rfkill, state, 0);
488 else
489 error = -EPERM;
490
437 mutex_unlock(&rfkill->mutex); 491 mutex_unlock(&rfkill->mutex);
438 492
439 return error ? error : count; 493 return error ? error : count;
@@ -472,12 +526,12 @@ static ssize_t rfkill_claim_store(struct device *dev,
472 * Take the global lock to make sure the kernel is not in 526 * Take the global lock to make sure the kernel is not in
473 * the middle of rfkill_switch_all 527 * the middle of rfkill_switch_all
474 */ 528 */
475 error = mutex_lock_interruptible(&rfkill_global_mutex); 529 error = mutex_lock_killable(&rfkill_global_mutex);
476 if (error) 530 if (error)
477 return error; 531 return error;
478 532
479 if (rfkill->user_claim != claim) { 533 if (rfkill->user_claim != claim) {
480 if (!claim) { 534 if (!claim && !rfkill_epo_lock_active) {
481 mutex_lock(&rfkill->mutex); 535 mutex_lock(&rfkill->mutex);
482 rfkill_toggle_radio(rfkill, 536 rfkill_toggle_radio(rfkill,
483 rfkill_global_states[rfkill->type].current_state, 537 rfkill_global_states[rfkill->type].current_state,
@@ -527,8 +581,17 @@ static int rfkill_resume(struct device *dev)
527 581
528 dev->power.power_state.event = PM_EVENT_ON; 582 dev->power.power_state.event = PM_EVENT_ON;
529 583
530 /* restore radio state AND notify everybody */ 584 /*
531 rfkill_toggle_radio(rfkill, rfkill->state, 1); 585 * If we are under EPO, kick transmitter offline,
586 * otherwise restore to pre-suspend state.
587 *
588 * Issue a notification in any case
589 */
590 rfkill_toggle_radio(rfkill,
591 rfkill_epo_lock_active ?
592 RFKILL_STATE_SOFT_BLOCKED :
593 rfkill->state,
594 1);
532 595
533 mutex_unlock(&rfkill->mutex); 596 mutex_unlock(&rfkill->mutex);
534 } 597 }
@@ -711,7 +774,7 @@ static void rfkill_led_trigger_register(struct rfkill *rfkill)
711 int error; 774 int error;
712 775
713 if (!rfkill->led_trigger.name) 776 if (!rfkill->led_trigger.name)
714 rfkill->led_trigger.name = rfkill->dev.bus_id; 777 rfkill->led_trigger.name = dev_name(&rfkill->dev);
715 if (!rfkill->led_trigger.activate) 778 if (!rfkill->led_trigger.activate)
716 rfkill->led_trigger.activate = rfkill_led_trigger_activate; 779 rfkill->led_trigger.activate = rfkill_led_trigger_activate;
717 error = led_trigger_register(&rfkill->led_trigger); 780 error = led_trigger_register(&rfkill->led_trigger);
@@ -752,8 +815,7 @@ int __must_check rfkill_register(struct rfkill *rfkill)
752 "badly initialized rfkill struct\n")) 815 "badly initialized rfkill struct\n"))
753 return -EINVAL; 816 return -EINVAL;
754 817
755 snprintf(dev->bus_id, sizeof(dev->bus_id), 818 dev_set_name(dev, "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1);
756 "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1);
757 819
758 rfkill_led_trigger_register(rfkill); 820 rfkill_led_trigger_register(rfkill);
759 821
@@ -833,6 +895,7 @@ int rfkill_set_default(enum rfkill_type type, enum rfkill_state state)
833 895
834 if (!test_and_set_bit(type, rfkill_states_lockdflt)) { 896 if (!test_and_set_bit(type, rfkill_states_lockdflt)) {
835 rfkill_global_states[type].default_state = state; 897 rfkill_global_states[type].default_state = state;
898 rfkill_global_states[type].current_state = state;
836 error = 0; 899 error = 0;
837 } else 900 } else
838 error = -EPERM; 901 error = -EPERM;
diff --git a/net/rose/sysctl_net_rose.c b/net/rose/sysctl_net_rose.c
index 20be3485a97f..3bfe504faf86 100644
--- a/net/rose/sysctl_net_rose.c
+++ b/net/rose/sysctl_net_rose.c
@@ -31,8 +31,8 @@ static ctl_table rose_table[] = {
31 .data = &sysctl_rose_restart_request_timeout, 31 .data = &sysctl_rose_restart_request_timeout,
32 .maxlen = sizeof(int), 32 .maxlen = sizeof(int),
33 .mode = 0644, 33 .mode = 0644,
34 .proc_handler = &proc_dointvec_minmax, 34 .proc_handler = proc_dointvec_minmax,
35 .strategy = &sysctl_intvec, 35 .strategy = sysctl_intvec,
36 .extra1 = &min_timer, 36 .extra1 = &min_timer,
37 .extra2 = &max_timer 37 .extra2 = &max_timer
38 }, 38 },
@@ -42,8 +42,8 @@ static ctl_table rose_table[] = {
42 .data = &sysctl_rose_call_request_timeout, 42 .data = &sysctl_rose_call_request_timeout,
43 .maxlen = sizeof(int), 43 .maxlen = sizeof(int),
44 .mode = 0644, 44 .mode = 0644,
45 .proc_handler = &proc_dointvec_minmax, 45 .proc_handler = proc_dointvec_minmax,
46 .strategy = &sysctl_intvec, 46 .strategy = sysctl_intvec,
47 .extra1 = &min_timer, 47 .extra1 = &min_timer,
48 .extra2 = &max_timer 48 .extra2 = &max_timer
49 }, 49 },
@@ -53,8 +53,8 @@ static ctl_table rose_table[] = {
53 .data = &sysctl_rose_reset_request_timeout, 53 .data = &sysctl_rose_reset_request_timeout,
54 .maxlen = sizeof(int), 54 .maxlen = sizeof(int),
55 .mode = 0644, 55 .mode = 0644,
56 .proc_handler = &proc_dointvec_minmax, 56 .proc_handler = proc_dointvec_minmax,
57 .strategy = &sysctl_intvec, 57 .strategy = sysctl_intvec,
58 .extra1 = &min_timer, 58 .extra1 = &min_timer,
59 .extra2 = &max_timer 59 .extra2 = &max_timer
60 }, 60 },
@@ -64,8 +64,8 @@ static ctl_table rose_table[] = {
64 .data = &sysctl_rose_clear_request_timeout, 64 .data = &sysctl_rose_clear_request_timeout,
65 .maxlen = sizeof(int), 65 .maxlen = sizeof(int),
66 .mode = 0644, 66 .mode = 0644,
67 .proc_handler = &proc_dointvec_minmax, 67 .proc_handler = proc_dointvec_minmax,
68 .strategy = &sysctl_intvec, 68 .strategy = sysctl_intvec,
69 .extra1 = &min_timer, 69 .extra1 = &min_timer,
70 .extra2 = &max_timer 70 .extra2 = &max_timer
71 }, 71 },
@@ -75,8 +75,8 @@ static ctl_table rose_table[] = {
75 .data = &sysctl_rose_no_activity_timeout, 75 .data = &sysctl_rose_no_activity_timeout,
76 .maxlen = sizeof(int), 76 .maxlen = sizeof(int),
77 .mode = 0644, 77 .mode = 0644,
78 .proc_handler = &proc_dointvec_minmax, 78 .proc_handler = proc_dointvec_minmax,
79 .strategy = &sysctl_intvec, 79 .strategy = sysctl_intvec,
80 .extra1 = &min_idle, 80 .extra1 = &min_idle,
81 .extra2 = &max_idle 81 .extra2 = &max_idle
82 }, 82 },
@@ -86,8 +86,8 @@ static ctl_table rose_table[] = {
86 .data = &sysctl_rose_ack_hold_back_timeout, 86 .data = &sysctl_rose_ack_hold_back_timeout,
87 .maxlen = sizeof(int), 87 .maxlen = sizeof(int),
88 .mode = 0644, 88 .mode = 0644,
89 .proc_handler = &proc_dointvec_minmax, 89 .proc_handler = proc_dointvec_minmax,
90 .strategy = &sysctl_intvec, 90 .strategy = sysctl_intvec,
91 .extra1 = &min_timer, 91 .extra1 = &min_timer,
92 .extra2 = &max_timer 92 .extra2 = &max_timer
93 }, 93 },
@@ -97,8 +97,8 @@ static ctl_table rose_table[] = {
97 .data = &sysctl_rose_routing_control, 97 .data = &sysctl_rose_routing_control,
98 .maxlen = sizeof(int), 98 .maxlen = sizeof(int),
99 .mode = 0644, 99 .mode = 0644,
100 .proc_handler = &proc_dointvec_minmax, 100 .proc_handler = proc_dointvec_minmax,
101 .strategy = &sysctl_intvec, 101 .strategy = sysctl_intvec,
102 .extra1 = &min_route, 102 .extra1 = &min_route,
103 .extra2 = &max_route 103 .extra2 = &max_route
104 }, 104 },
@@ -108,8 +108,8 @@ static ctl_table rose_table[] = {
108 .data = &sysctl_rose_link_fail_timeout, 108 .data = &sysctl_rose_link_fail_timeout,
109 .maxlen = sizeof(int), 109 .maxlen = sizeof(int),
110 .mode = 0644, 110 .mode = 0644,
111 .proc_handler = &proc_dointvec_minmax, 111 .proc_handler = proc_dointvec_minmax,
112 .strategy = &sysctl_intvec, 112 .strategy = sysctl_intvec,
113 .extra1 = &min_ftimer, 113 .extra1 = &min_ftimer,
114 .extra2 = &max_ftimer 114 .extra2 = &max_ftimer
115 }, 115 },
@@ -119,8 +119,8 @@ static ctl_table rose_table[] = {
119 .data = &sysctl_rose_maximum_vcs, 119 .data = &sysctl_rose_maximum_vcs,
120 .maxlen = sizeof(int), 120 .maxlen = sizeof(int),
121 .mode = 0644, 121 .mode = 0644,
122 .proc_handler = &proc_dointvec_minmax, 122 .proc_handler = proc_dointvec_minmax,
123 .strategy = &sysctl_intvec, 123 .strategy = sysctl_intvec,
124 .extra1 = &min_maxvcs, 124 .extra1 = &min_maxvcs,
125 .extra2 = &max_maxvcs 125 .extra2 = &max_maxvcs
126 }, 126 },
@@ -130,8 +130,8 @@ static ctl_table rose_table[] = {
130 .data = &sysctl_rose_window_size, 130 .data = &sysctl_rose_window_size,
131 .maxlen = sizeof(int), 131 .maxlen = sizeof(int),
132 .mode = 0644, 132 .mode = 0644,
133 .proc_handler = &proc_dointvec_minmax, 133 .proc_handler = proc_dointvec_minmax,
134 .strategy = &sysctl_intvec, 134 .strategy = sysctl_intvec,
135 .extra1 = &min_window, 135 .extra1 = &min_window,
136 .extra2 = &max_window 136 .extra2 = &max_window
137 }, 137 },
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 32e489118beb..d7d2bed7a699 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -96,9 +96,9 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
96 96
97 switch (srx->transport.family) { 97 switch (srx->transport.family) {
98 case AF_INET: 98 case AF_INET:
99 _debug("INET: %x @ %u.%u.%u.%u", 99 _debug("INET: %x @ %pI4",
100 ntohs(srx->transport.sin.sin_port), 100 ntohs(srx->transport.sin.sin_port),
101 NIPQUAD(srx->transport.sin.sin_addr)); 101 &srx->transport.sin.sin_addr);
102 if (srx->transport_len > 8) 102 if (srx->transport_len > 8)
103 memset((void *)&srx->transport + 8, 0, 103 memset((void *)&srx->transport + 8, 0,
104 srx->transport_len - 8); 104 srx->transport_len - 8);
diff --git a/net/rxrpc/ar-error.c b/net/rxrpc/ar-error.c
index 6cb3e8890e7e..d4d1ae26d293 100644
--- a/net/rxrpc/ar-error.c
+++ b/net/rxrpc/ar-error.c
@@ -49,8 +49,7 @@ void rxrpc_UDP_error_report(struct sock *sk)
49 addr = *(__be32 *)(skb_network_header(skb) + serr->addr_offset); 49 addr = *(__be32 *)(skb_network_header(skb) + serr->addr_offset);
50 port = serr->port; 50 port = serr->port;
51 51
52 _net("Rx UDP Error from "NIPQUAD_FMT":%hu", 52 _net("Rx UDP Error from %pI4:%hu", &addr, ntohs(port));
53 NIPQUAD(addr), ntohs(port));
54 _debug("Msg l:%d d:%d", skb->len, skb->data_len); 53 _debug("Msg l:%d d:%d", skb->len, skb->data_len);
55 54
56 peer = rxrpc_find_peer(local, addr, port); 55 peer = rxrpc_find_peer(local, addr, port);
diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
index f3a2bd747a8f..807535ff29b5 100644
--- a/net/rxrpc/ar-local.c
+++ b/net/rxrpc/ar-local.c
@@ -131,10 +131,10 @@ struct rxrpc_local *rxrpc_lookup_local(struct sockaddr_rxrpc *srx)
131 struct rxrpc_local *local; 131 struct rxrpc_local *local;
132 int ret; 132 int ret;
133 133
134 _enter("{%d,%u,%u.%u.%u.%u+%hu}", 134 _enter("{%d,%u,%pI4+%hu}",
135 srx->transport_type, 135 srx->transport_type,
136 srx->transport.family, 136 srx->transport.family,
137 NIPQUAD(srx->transport.sin.sin_addr), 137 &srx->transport.sin.sin_addr,
138 ntohs(srx->transport.sin.sin_port)); 138 ntohs(srx->transport.sin.sin_port));
139 139
140 down_write(&rxrpc_local_sem); 140 down_write(&rxrpc_local_sem);
@@ -143,10 +143,10 @@ struct rxrpc_local *rxrpc_lookup_local(struct sockaddr_rxrpc *srx)
143 read_lock_bh(&rxrpc_local_lock); 143 read_lock_bh(&rxrpc_local_lock);
144 144
145 list_for_each_entry(local, &rxrpc_locals, link) { 145 list_for_each_entry(local, &rxrpc_locals, link) {
146 _debug("CMP {%d,%u,%u.%u.%u.%u+%hu}", 146 _debug("CMP {%d,%u,%pI4+%hu}",
147 local->srx.transport_type, 147 local->srx.transport_type,
148 local->srx.transport.family, 148 local->srx.transport.family,
149 NIPQUAD(local->srx.transport.sin.sin_addr), 149 &local->srx.transport.sin.sin_addr,
150 ntohs(local->srx.transport.sin.sin_port)); 150 ntohs(local->srx.transport.sin.sin_port));
151 151
152 if (local->srx.transport_type != srx->transport_type || 152 if (local->srx.transport_type != srx->transport_type ||
@@ -188,11 +188,11 @@ struct rxrpc_local *rxrpc_lookup_local(struct sockaddr_rxrpc *srx)
188 188
189 up_write(&rxrpc_local_sem); 189 up_write(&rxrpc_local_sem);
190 190
191 _net("LOCAL new %d {%d,%u,%u.%u.%u.%u+%hu}", 191 _net("LOCAL new %d {%d,%u,%pI4+%hu}",
192 local->debug_id, 192 local->debug_id,
193 local->srx.transport_type, 193 local->srx.transport_type,
194 local->srx.transport.family, 194 local->srx.transport.family,
195 NIPQUAD(local->srx.transport.sin.sin_addr), 195 &local->srx.transport.sin.sin_addr,
196 ntohs(local->srx.transport.sin.sin_port)); 196 ntohs(local->srx.transport.sin.sin_port));
197 197
198 _leave(" = %p [new]", local); 198 _leave(" = %p [new]", local);
@@ -203,11 +203,11 @@ found_local:
203 read_unlock_bh(&rxrpc_local_lock); 203 read_unlock_bh(&rxrpc_local_lock);
204 up_write(&rxrpc_local_sem); 204 up_write(&rxrpc_local_sem);
205 205
206 _net("LOCAL old %d {%d,%u,%u.%u.%u.%u+%hu}", 206 _net("LOCAL old %d {%d,%u,%pI4+%hu}",
207 local->debug_id, 207 local->debug_id,
208 local->srx.transport_type, 208 local->srx.transport_type,
209 local->srx.transport.family, 209 local->srx.transport.family,
210 NIPQUAD(local->srx.transport.sin.sin_addr), 210 &local->srx.transport.sin.sin_addr,
211 ntohs(local->srx.transport.sin.sin_port)); 211 ntohs(local->srx.transport.sin.sin_port));
212 212
213 _leave(" = %p [reuse]", local); 213 _leave(" = %p [reuse]", local);
diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
index 2abe2081a5e8..edc026c1eb76 100644
--- a/net/rxrpc/ar-peer.c
+++ b/net/rxrpc/ar-peer.c
@@ -123,10 +123,10 @@ struct rxrpc_peer *rxrpc_get_peer(struct sockaddr_rxrpc *srx, gfp_t gfp)
123 const char *new = "old"; 123 const char *new = "old";
124 int usage; 124 int usage;
125 125
126 _enter("{%d,%d,%u.%u.%u.%u+%hu}", 126 _enter("{%d,%d,%pI4+%hu}",
127 srx->transport_type, 127 srx->transport_type,
128 srx->transport_len, 128 srx->transport_len,
129 NIPQUAD(srx->transport.sin.sin_addr), 129 &srx->transport.sin.sin_addr,
130 ntohs(srx->transport.sin.sin_port)); 130 ntohs(srx->transport.sin.sin_port));
131 131
132 /* search the peer list first */ 132 /* search the peer list first */
@@ -177,12 +177,12 @@ struct rxrpc_peer *rxrpc_get_peer(struct sockaddr_rxrpc *srx, gfp_t gfp)
177 new = "new"; 177 new = "new";
178 178
179success: 179success:
180 _net("PEER %s %d {%d,%u,%u.%u.%u.%u+%hu}", 180 _net("PEER %s %d {%d,%u,%pI4+%hu}",
181 new, 181 new,
182 peer->debug_id, 182 peer->debug_id,
183 peer->srx.transport_type, 183 peer->srx.transport_type,
184 peer->srx.transport.family, 184 peer->srx.transport.family,
185 NIPQUAD(peer->srx.transport.sin.sin_addr), 185 &peer->srx.transport.sin.sin_addr,
186 ntohs(peer->srx.transport.sin.sin_port)); 186 ntohs(peer->srx.transport.sin.sin_port));
187 187
188 _leave(" = %p {u=%d}", peer, atomic_read(&peer->usage)); 188 _leave(" = %p {u=%d}", peer, atomic_read(&peer->usage));
diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
index 017322e2786d..38047f713f2c 100644
--- a/net/rxrpc/ar-proc.c
+++ b/net/rxrpc/ar-proc.c
@@ -61,12 +61,12 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
61 call = list_entry(v, struct rxrpc_call, link); 61 call = list_entry(v, struct rxrpc_call, link);
62 trans = call->conn->trans; 62 trans = call->conn->trans;
63 63
64 sprintf(lbuff, NIPQUAD_FMT":%u", 64 sprintf(lbuff, "%pI4:%u",
65 NIPQUAD(trans->local->srx.transport.sin.sin_addr), 65 &trans->local->srx.transport.sin.sin_addr,
66 ntohs(trans->local->srx.transport.sin.sin_port)); 66 ntohs(trans->local->srx.transport.sin.sin_port));
67 67
68 sprintf(rbuff, NIPQUAD_FMT":%u", 68 sprintf(rbuff, "%pI4:%u",
69 NIPQUAD(trans->peer->srx.transport.sin.sin_addr), 69 &trans->peer->srx.transport.sin.sin_addr,
70 ntohs(trans->peer->srx.transport.sin.sin_port)); 70 ntohs(trans->peer->srx.transport.sin.sin_port));
71 71
72 seq_printf(seq, 72 seq_printf(seq,
@@ -144,12 +144,12 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
144 conn = list_entry(v, struct rxrpc_connection, link); 144 conn = list_entry(v, struct rxrpc_connection, link);
145 trans = conn->trans; 145 trans = conn->trans;
146 146
147 sprintf(lbuff, NIPQUAD_FMT":%u", 147 sprintf(lbuff, "%pI4:%u",
148 NIPQUAD(trans->local->srx.transport.sin.sin_addr), 148 &trans->local->srx.transport.sin.sin_addr,
149 ntohs(trans->local->srx.transport.sin.sin_port)); 149 ntohs(trans->local->srx.transport.sin.sin_port));
150 150
151 sprintf(rbuff, NIPQUAD_FMT":%u", 151 sprintf(rbuff, "%pI4:%u",
152 NIPQUAD(trans->peer->srx.transport.sin.sin_addr), 152 &trans->peer->srx.transport.sin.sin_addr,
153 ntohs(trans->peer->srx.transport.sin.sin_port)); 153 ntohs(trans->peer->srx.transport.sin.sin_port));
154 154
155 seq_printf(seq, 155 seq_printf(seq,
diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
index 64069c8769a5..0936e1acc30e 100644
--- a/net/rxrpc/ar-transport.c
+++ b/net/rxrpc/ar-transport.c
@@ -78,10 +78,10 @@ struct rxrpc_transport *rxrpc_get_transport(struct rxrpc_local *local,
78 const char *new = "old"; 78 const char *new = "old";
79 int usage; 79 int usage;
80 80
81 _enter("{%u.%u.%u.%u+%hu},{%u.%u.%u.%u+%hu},", 81 _enter("{%pI4+%hu},{%pI4+%hu},",
82 NIPQUAD(local->srx.transport.sin.sin_addr), 82 &local->srx.transport.sin.sin_addr,
83 ntohs(local->srx.transport.sin.sin_port), 83 ntohs(local->srx.transport.sin.sin_port),
84 NIPQUAD(peer->srx.transport.sin.sin_addr), 84 &peer->srx.transport.sin.sin_addr,
85 ntohs(peer->srx.transport.sin.sin_port)); 85 ntohs(peer->srx.transport.sin.sin_port));
86 86
87 /* search the transport list first */ 87 /* search the transport list first */
@@ -149,10 +149,10 @@ struct rxrpc_transport *rxrpc_find_transport(struct rxrpc_local *local,
149{ 149{
150 struct rxrpc_transport *trans; 150 struct rxrpc_transport *trans;
151 151
152 _enter("{%u.%u.%u.%u+%hu},{%u.%u.%u.%u+%hu},", 152 _enter("{%pI4+%hu},{%pI4+%hu},",
153 NIPQUAD(local->srx.transport.sin.sin_addr), 153 &local->srx.transport.sin.sin_addr,
154 ntohs(local->srx.transport.sin.sin_port), 154 ntohs(local->srx.transport.sin.sin_port),
155 NIPQUAD(peer->srx.transport.sin.sin_addr), 155 &peer->srx.transport.sin.sin_addr,
156 ntohs(peer->srx.transport.sin.sin_port)); 156 ntohs(peer->srx.transport.sin.sin_port));
157 157
158 /* search the transport list */ 158 /* search the transport list */
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index ba3f6e49fddc..ef8f91030a15 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -897,7 +897,7 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn,
897 /* get the IPv4 address of the entity that requested the ticket */ 897 /* get the IPv4 address of the entity that requested the ticket */
898 memcpy(&addr, p, sizeof(addr)); 898 memcpy(&addr, p, sizeof(addr));
899 p += 4; 899 p += 4;
900 _debug("KIV ADDR : "NIPQUAD_FMT, NIPQUAD(addr)); 900 _debug("KIV ADDR : %pI4", &addr);
901 901
902 /* get the session key from the ticket */ 902 /* get the session key from the ticket */
903 memcpy(&key, p, sizeof(key)); 903 memcpy(&key, p, sizeof(key));
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 6767e54155db..4f7ef0db302b 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -194,6 +194,17 @@ config NET_SCH_NETEM
194 194
195 If unsure, say N. 195 If unsure, say N.
196 196
197config NET_SCH_DRR
198 tristate "Deficit Round Robin scheduler (DRR)"
199 help
200 Say Y here if you want to use the Deficit Round Robin (DRR) packet
201 scheduling algorithm.
202
203 To compile this driver as a module, choose M here: the module
204 will be called sch_drr.
205
206 If unsure, say N.
207
197config NET_SCH_INGRESS 208config NET_SCH_INGRESS
198 tristate "Ingress Qdisc" 209 tristate "Ingress Qdisc"
199 depends on NET_CLS_ACT 210 depends on NET_CLS_ACT
@@ -316,6 +327,17 @@ config NET_CLS_FLOW
316 To compile this code as a module, choose M here: the 327 To compile this code as a module, choose M here: the
317 module will be called cls_flow. 328 module will be called cls_flow.
318 329
330config NET_CLS_CGROUP
331 bool "Control Group Classifier"
332 select NET_CLS
333 depends on CGROUPS
334 ---help---
335 Say Y here if you want to classify packets based on the control
336 cgroup of their process.
337
338 To compile this code as a module, choose M here: the
339 module will be called cls_cgroup.
340
319config NET_EMATCH 341config NET_EMATCH
320 bool "Extended Matches" 342 bool "Extended Matches"
321 select NET_CLS 343 select NET_CLS
diff --git a/net/sched/Makefile b/net/sched/Makefile
index e60c9925b269..54d950cd4b8d 100644
--- a/net/sched/Makefile
+++ b/net/sched/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o
30obj-$(CONFIG_NET_SCH_MULTIQ) += sch_multiq.o 30obj-$(CONFIG_NET_SCH_MULTIQ) += sch_multiq.o
31obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o 31obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o
32obj-$(CONFIG_NET_SCH_NETEM) += sch_netem.o 32obj-$(CONFIG_NET_SCH_NETEM) += sch_netem.o
33obj-$(CONFIG_NET_SCH_DRR) += sch_drr.o
33obj-$(CONFIG_NET_CLS_U32) += cls_u32.o 34obj-$(CONFIG_NET_CLS_U32) += cls_u32.o
34obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o 35obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o
35obj-$(CONFIG_NET_CLS_FW) += cls_fw.o 36obj-$(CONFIG_NET_CLS_FW) += cls_fw.o
@@ -38,6 +39,7 @@ obj-$(CONFIG_NET_CLS_TCINDEX) += cls_tcindex.o
38obj-$(CONFIG_NET_CLS_RSVP6) += cls_rsvp6.o 39obj-$(CONFIG_NET_CLS_RSVP6) += cls_rsvp6.o
39obj-$(CONFIG_NET_CLS_BASIC) += cls_basic.o 40obj-$(CONFIG_NET_CLS_BASIC) += cls_basic.o
40obj-$(CONFIG_NET_CLS_FLOW) += cls_flow.o 41obj-$(CONFIG_NET_CLS_FLOW) += cls_flow.o
42obj-$(CONFIG_NET_CLS_CGROUP) += cls_cgroup.o
41obj-$(CONFIG_NET_EMATCH) += ematch.o 43obj-$(CONFIG_NET_EMATCH) += ematch.o
42obj-$(CONFIG_NET_EMATCH_CMP) += em_cmp.o 44obj-$(CONFIG_NET_EMATCH_CMP) += em_cmp.o
43obj-$(CONFIG_NET_EMATCH_NBYTE) += em_nbyte.o 45obj-$(CONFIG_NET_EMATCH_NBYTE) += em_nbyte.o
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 16e7ac9774e5..173fcc4b050d 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -531,7 +531,8 @@ void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
531 if (src->action) { 531 if (src->action) {
532 struct tc_action *act; 532 struct tc_action *act;
533 tcf_tree_lock(tp); 533 tcf_tree_lock(tp);
534 act = xchg(&dst->action, src->action); 534 act = dst->action;
535 dst->action = src->action;
535 tcf_tree_unlock(tp); 536 tcf_tree_unlock(tp);
536 if (act) 537 if (act)
537 tcf_action_destroy(act, TCA_ACT_UNBIND); 538 tcf_action_destroy(act, TCA_ACT_UNBIND);
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index 956915c217d6..4e2bda854119 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -102,7 +102,7 @@ static inline void basic_delete_filter(struct tcf_proto *tp,
102 102
103static void basic_destroy(struct tcf_proto *tp) 103static void basic_destroy(struct tcf_proto *tp)
104{ 104{
105 struct basic_head *head = (struct basic_head *) xchg(&tp->root, NULL); 105 struct basic_head *head = tp->root;
106 struct basic_filter *f, *n; 106 struct basic_filter *f, *n;
107 107
108 list_for_each_entry_safe(f, n, &head->flist, link) { 108 list_for_each_entry_safe(f, n, &head->flist, link) {
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
new file mode 100644
index 000000000000..0d68b1975983
--- /dev/null
+++ b/net/sched/cls_cgroup.c
@@ -0,0 +1,288 @@
1/*
2 * net/sched/cls_cgroup.c Control Group Classifier
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Thomas Graf <tgraf@suug.ch>
10 */
11
12#include <linux/module.h>
13#include <linux/types.h>
14#include <linux/string.h>
15#include <linux/errno.h>
16#include <linux/skbuff.h>
17#include <linux/cgroup.h>
18#include <net/rtnetlink.h>
19#include <net/pkt_cls.h>
20
21struct cgroup_cls_state
22{
23 struct cgroup_subsys_state css;
24 u32 classid;
25};
26
27static inline struct cgroup_cls_state *net_cls_state(struct cgroup *cgrp)
28{
29 return (struct cgroup_cls_state *)
30 cgroup_subsys_state(cgrp, net_cls_subsys_id);
31}
32
33static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss,
34 struct cgroup *cgrp)
35{
36 struct cgroup_cls_state *cs;
37
38 if (!(cs = kzalloc(sizeof(*cs), GFP_KERNEL)))
39 return ERR_PTR(-ENOMEM);
40
41 if (cgrp->parent)
42 cs->classid = net_cls_state(cgrp->parent)->classid;
43
44 return &cs->css;
45}
46
47static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
48{
49 kfree(ss);
50}
51
52static u64 read_classid(struct cgroup *cgrp, struct cftype *cft)
53{
54 return net_cls_state(cgrp)->classid;
55}
56
57static int write_classid(struct cgroup *cgrp, struct cftype *cft, u64 value)
58{
59 if (!cgroup_lock_live_group(cgrp))
60 return -ENODEV;
61
62 net_cls_state(cgrp)->classid = (u32) value;
63
64 cgroup_unlock();
65
66 return 0;
67}
68
69static struct cftype ss_files[] = {
70 {
71 .name = "classid",
72 .read_u64 = read_classid,
73 .write_u64 = write_classid,
74 },
75};
76
77static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
78{
79 return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files));
80}
81
82struct cgroup_subsys net_cls_subsys = {
83 .name = "net_cls",
84 .create = cgrp_create,
85 .destroy = cgrp_destroy,
86 .populate = cgrp_populate,
87 .subsys_id = net_cls_subsys_id,
88};
89
90struct cls_cgroup_head
91{
92 u32 handle;
93 struct tcf_exts exts;
94 struct tcf_ematch_tree ematches;
95};
96
97static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp,
98 struct tcf_result *res)
99{
100 struct cls_cgroup_head *head = tp->root;
101 struct cgroup_cls_state *cs;
102 int ret = 0;
103
104 /*
105 * Due to the nature of the classifier it is required to ignore all
106 * packets originating from softirq context as accessing `current'
107 * would lead to false results.
108 *
109 * This test assumes that all callers of dev_queue_xmit() explicitely
110 * disable bh. Knowing this, it is possible to detect softirq based
111 * calls by looking at the number of nested bh disable calls because
112 * softirqs always disables bh.
113 */
114 if (softirq_count() != SOFTIRQ_OFFSET)
115 return -1;
116
117 rcu_read_lock();
118 cs = (struct cgroup_cls_state *) task_subsys_state(current,
119 net_cls_subsys_id);
120 if (cs->classid && tcf_em_tree_match(skb, &head->ematches, NULL)) {
121 res->classid = cs->classid;
122 res->class = 0;
123 ret = tcf_exts_exec(skb, &head->exts, res);
124 } else
125 ret = -1;
126
127 rcu_read_unlock();
128
129 return ret;
130}
131
132static unsigned long cls_cgroup_get(struct tcf_proto *tp, u32 handle)
133{
134 return 0UL;
135}
136
137static void cls_cgroup_put(struct tcf_proto *tp, unsigned long f)
138{
139}
140
141static int cls_cgroup_init(struct tcf_proto *tp)
142{
143 return 0;
144}
145
146static const struct tcf_ext_map cgroup_ext_map = {
147 .action = TCA_CGROUP_ACT,
148 .police = TCA_CGROUP_POLICE,
149};
150
151static const struct nla_policy cgroup_policy[TCA_CGROUP_MAX + 1] = {
152 [TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED },
153};
154
155static int cls_cgroup_change(struct tcf_proto *tp, unsigned long base,
156 u32 handle, struct nlattr **tca,
157 unsigned long *arg)
158{
159 struct nlattr *tb[TCA_CGROUP_MAX+1];
160 struct cls_cgroup_head *head = tp->root;
161 struct tcf_ematch_tree t;
162 struct tcf_exts e;
163 int err;
164
165 if (head == NULL) {
166 if (!handle)
167 return -EINVAL;
168
169 head = kzalloc(sizeof(*head), GFP_KERNEL);
170 if (head == NULL)
171 return -ENOBUFS;
172
173 head->handle = handle;
174
175 tcf_tree_lock(tp);
176 tp->root = head;
177 tcf_tree_unlock(tp);
178 }
179
180 if (handle != head->handle)
181 return -ENOENT;
182
183 err = nla_parse_nested(tb, TCA_CGROUP_MAX, tca[TCA_OPTIONS],
184 cgroup_policy);
185 if (err < 0)
186 return err;
187
188 err = tcf_exts_validate(tp, tb, tca[TCA_RATE], &e, &cgroup_ext_map);
189 if (err < 0)
190 return err;
191
192 err = tcf_em_tree_validate(tp, tb[TCA_CGROUP_EMATCHES], &t);
193 if (err < 0)
194 return err;
195
196 tcf_exts_change(tp, &head->exts, &e);
197 tcf_em_tree_change(tp, &head->ematches, &t);
198
199 return 0;
200}
201
202static void cls_cgroup_destroy(struct tcf_proto *tp)
203{
204 struct cls_cgroup_head *head = tp->root;
205
206 if (head) {
207 tcf_exts_destroy(tp, &head->exts);
208 tcf_em_tree_destroy(tp, &head->ematches);
209 kfree(head);
210 }
211}
212
213static int cls_cgroup_delete(struct tcf_proto *tp, unsigned long arg)
214{
215 return -EOPNOTSUPP;
216}
217
218static void cls_cgroup_walk(struct tcf_proto *tp, struct tcf_walker *arg)
219{
220 struct cls_cgroup_head *head = tp->root;
221
222 if (arg->count < arg->skip)
223 goto skip;
224
225 if (arg->fn(tp, (unsigned long) head, arg) < 0) {
226 arg->stop = 1;
227 return;
228 }
229skip:
230 arg->count++;
231}
232
233static int cls_cgroup_dump(struct tcf_proto *tp, unsigned long fh,
234 struct sk_buff *skb, struct tcmsg *t)
235{
236 struct cls_cgroup_head *head = tp->root;
237 unsigned char *b = skb_tail_pointer(skb);
238 struct nlattr *nest;
239
240 t->tcm_handle = head->handle;
241
242 nest = nla_nest_start(skb, TCA_OPTIONS);
243 if (nest == NULL)
244 goto nla_put_failure;
245
246 if (tcf_exts_dump(skb, &head->exts, &cgroup_ext_map) < 0 ||
247 tcf_em_tree_dump(skb, &head->ematches, TCA_CGROUP_EMATCHES) < 0)
248 goto nla_put_failure;
249
250 nla_nest_end(skb, nest);
251
252 if (tcf_exts_dump_stats(skb, &head->exts, &cgroup_ext_map) < 0)
253 goto nla_put_failure;
254
255 return skb->len;
256
257nla_put_failure:
258 nlmsg_trim(skb, b);
259 return -1;
260}
261
262static struct tcf_proto_ops cls_cgroup_ops __read_mostly = {
263 .kind = "cgroup",
264 .init = cls_cgroup_init,
265 .change = cls_cgroup_change,
266 .classify = cls_cgroup_classify,
267 .destroy = cls_cgroup_destroy,
268 .get = cls_cgroup_get,
269 .put = cls_cgroup_put,
270 .delete = cls_cgroup_delete,
271 .walk = cls_cgroup_walk,
272 .dump = cls_cgroup_dump,
273 .owner = THIS_MODULE,
274};
275
276static int __init init_cgroup_cls(void)
277{
278 return register_tcf_proto_ops(&cls_cgroup_ops);
279}
280
281static void __exit exit_cgroup_cls(void)
282{
283 unregister_tcf_proto_ops(&cls_cgroup_ops);
284}
285
286module_init(init_cgroup_cls);
287module_exit(exit_cgroup_cls);
288MODULE_LICENSE("GPL");
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index b0f90e593af0..6d6e87585fb1 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -148,7 +148,7 @@ fw_delete_filter(struct tcf_proto *tp, struct fw_filter *f)
148 148
149static void fw_destroy(struct tcf_proto *tp) 149static void fw_destroy(struct tcf_proto *tp)
150{ 150{
151 struct fw_head *head = (struct fw_head*)xchg(&tp->root, NULL); 151 struct fw_head *head = tp->root;
152 struct fw_filter *f; 152 struct fw_filter *f;
153 int h; 153 int h;
154 154
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
index e3d8455eebc2..bdf1f4172eef 100644
--- a/net/sched/cls_route.c
+++ b/net/sched/cls_route.c
@@ -260,7 +260,7 @@ route4_delete_filter(struct tcf_proto *tp, struct route4_filter *f)
260 260
261static void route4_destroy(struct tcf_proto *tp) 261static void route4_destroy(struct tcf_proto *tp)
262{ 262{
263 struct route4_head *head = xchg(&tp->root, NULL); 263 struct route4_head *head = tp->root;
264 int h1, h2; 264 int h1, h2;
265 265
266 if (head == NULL) 266 if (head == NULL)
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 7a7bff5ded24..e806f2314b5e 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -13,12 +13,6 @@
13#include <net/netlink.h> 13#include <net/netlink.h>
14#include <net/pkt_cls.h> 14#include <net/pkt_cls.h>
15 15
16
17/*
18 * Not quite sure if we need all the xchgs Alexey uses when accessing things.
19 * Can always add them later ... :)
20 */
21
22/* 16/*
23 * Passing parameters to the root seems to be done more awkwardly than really 17 * Passing parameters to the root seems to be done more awkwardly than really
24 * necessary. At least, u32 doesn't seem to use such dirty hacks. To be 18 * necessary. At least, u32 doesn't seem to use such dirty hacks. To be
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 246f9065ce34..05d178008cbc 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -387,7 +387,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
387static void u32_destroy(struct tcf_proto *tp) 387static void u32_destroy(struct tcf_proto *tp)
388{ 388{
389 struct tc_u_common *tp_c = tp->data; 389 struct tc_u_common *tp_c = tp->data;
390 struct tc_u_hnode *root_ht = xchg(&tp->root, NULL); 390 struct tc_u_hnode *root_ht = tp->root;
391 391
392 WARN_ON(root_ht == NULL); 392 WARN_ON(root_ht == NULL);
393 393
@@ -479,7 +479,7 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
479 err = -EINVAL; 479 err = -EINVAL;
480 if (tb[TCA_U32_LINK]) { 480 if (tb[TCA_U32_LINK]) {
481 u32 handle = nla_get_u32(tb[TCA_U32_LINK]); 481 u32 handle = nla_get_u32(tb[TCA_U32_LINK]);
482 struct tc_u_hnode *ht_down = NULL; 482 struct tc_u_hnode *ht_down = NULL, *ht_old;
483 483
484 if (TC_U32_KEY(handle)) 484 if (TC_U32_KEY(handle))
485 goto errout; 485 goto errout;
@@ -493,11 +493,12 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
493 } 493 }
494 494
495 tcf_tree_lock(tp); 495 tcf_tree_lock(tp);
496 ht_down = xchg(&n->ht_down, ht_down); 496 ht_old = n->ht_down;
497 n->ht_down = ht_down;
497 tcf_tree_unlock(tp); 498 tcf_tree_unlock(tp);
498 499
499 if (ht_down) 500 if (ht_old)
500 ht_down->refcnt--; 501 ht_old->refcnt--;
501 } 502 }
502 if (tb[TCA_U32_CLASSID]) { 503 if (tb[TCA_U32_CLASSID]) {
503 n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]); 504 n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]);
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index e82519e548d7..aab59409728b 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -71,7 +71,7 @@
71 * 71 *
72 * static void __exit exit_my_ematch(void) 72 * static void __exit exit_my_ematch(void)
73 * { 73 * {
74 * return tcf_em_unregister(&my_ops); 74 * tcf_em_unregister(&my_ops);
75 * } 75 * }
76 * 76 *
77 * module_init(init_my_ematch); 77 * module_init(init_my_ematch);
@@ -154,23 +154,11 @@ EXPORT_SYMBOL(tcf_em_register);
154 * 154 *
155 * Returns -ENOENT if no matching ematch was found. 155 * Returns -ENOENT if no matching ematch was found.
156 */ 156 */
157int tcf_em_unregister(struct tcf_ematch_ops *ops) 157void tcf_em_unregister(struct tcf_ematch_ops *ops)
158{ 158{
159 int err = 0;
160 struct tcf_ematch_ops *e;
161
162 write_lock(&ematch_mod_lock); 159 write_lock(&ematch_mod_lock);
163 list_for_each_entry(e, &ematch_ops, link) { 160 list_del(&ops->link);
164 if (e == ops) {
165 list_del(&e->link);
166 goto out;
167 }
168 }
169
170 err = -ENOENT;
171out:
172 write_unlock(&ematch_mod_lock); 161 write_unlock(&ematch_mod_lock);
173 return err;
174} 162}
175EXPORT_SYMBOL(tcf_em_unregister); 163EXPORT_SYMBOL(tcf_em_unregister);
176 164
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 6ab4a2f92ca0..1ef25e6ee1f9 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -97,10 +97,9 @@ static int tclass_notify(struct sk_buff *oskb, struct nlmsghdr *n,
97 97
98 Auxiliary routines: 98 Auxiliary routines:
99 99
100 ---requeue 100 ---peek
101 101
102 requeues once dequeued packet. It is used for non-standard or 102 like dequeue but without removing a packet from the queue
103 just buggy devices, which can defer output even if netif_queue_stopped()=0.
104 103
105 ---reset 104 ---reset
106 105
@@ -147,8 +146,14 @@ int register_qdisc(struct Qdisc_ops *qops)
147 146
148 if (qops->enqueue == NULL) 147 if (qops->enqueue == NULL)
149 qops->enqueue = noop_qdisc_ops.enqueue; 148 qops->enqueue = noop_qdisc_ops.enqueue;
150 if (qops->requeue == NULL) 149 if (qops->peek == NULL) {
151 qops->requeue = noop_qdisc_ops.requeue; 150 if (qops->dequeue == NULL) {
151 qops->peek = noop_qdisc_ops.peek;
152 } else {
153 rc = -EINVAL;
154 goto out;
155 }
156 }
152 if (qops->dequeue == NULL) 157 if (qops->dequeue == NULL)
153 qops->dequeue = noop_qdisc_ops.dequeue; 158 qops->dequeue = noop_qdisc_ops.dequeue;
154 159
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index 43d37256c15e..2a8b83af7c47 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -62,7 +62,7 @@ struct atm_qdisc_data {
62 struct atm_flow_data link; /* unclassified skbs go here */ 62 struct atm_flow_data link; /* unclassified skbs go here */
63 struct atm_flow_data *flows; /* NB: "link" is also on this 63 struct atm_flow_data *flows; /* NB: "link" is also on this
64 list */ 64 list */
65 struct tasklet_struct task; /* requeue tasklet */ 65 struct tasklet_struct task; /* dequeue tasklet */
66}; 66};
67 67
68/* ------------------------- Class/flow operations ------------------------- */ 68/* ------------------------- Class/flow operations ------------------------- */
@@ -102,7 +102,8 @@ static int atm_tc_graft(struct Qdisc *sch, unsigned long arg,
102 return -EINVAL; 102 return -EINVAL;
103 if (!new) 103 if (!new)
104 new = &noop_qdisc; 104 new = &noop_qdisc;
105 *old = xchg(&flow->q, new); 105 *old = flow->q;
106 flow->q = new;
106 if (*old) 107 if (*old)
107 qdisc_reset(*old); 108 qdisc_reset(*old);
108 return 0; 109 return 0;
@@ -480,11 +481,14 @@ static void sch_atm_dequeue(unsigned long data)
480 * If traffic is properly shaped, this won't generate nasty 481 * If traffic is properly shaped, this won't generate nasty
481 * little bursts. Otherwise, it may ... (but that's okay) 482 * little bursts. Otherwise, it may ... (but that's okay)
482 */ 483 */
483 while ((skb = flow->q->dequeue(flow->q))) { 484 while ((skb = flow->q->ops->peek(flow->q))) {
484 if (!atm_may_send(flow->vcc, skb->truesize)) { 485 if (!atm_may_send(flow->vcc, skb->truesize))
485 (void)flow->q->ops->requeue(skb, flow->q);
486 break; 486 break;
487 } 487
488 skb = qdisc_dequeue_peeked(flow->q);
489 if (unlikely(!skb))
490 break;
491
488 pr_debug("atm_tc_dequeue: sending on class %p\n", flow); 492 pr_debug("atm_tc_dequeue: sending on class %p\n", flow);
489 /* remove any LL header somebody else has attached */ 493 /* remove any LL header somebody else has attached */
490 skb_pull(skb, skb_network_offset(skb)); 494 skb_pull(skb, skb_network_offset(skb));
@@ -516,27 +520,19 @@ static struct sk_buff *atm_tc_dequeue(struct Qdisc *sch)
516 520
517 pr_debug("atm_tc_dequeue(sch %p,[qdisc %p])\n", sch, p); 521 pr_debug("atm_tc_dequeue(sch %p,[qdisc %p])\n", sch, p);
518 tasklet_schedule(&p->task); 522 tasklet_schedule(&p->task);
519 skb = p->link.q->dequeue(p->link.q); 523 skb = qdisc_dequeue_peeked(p->link.q);
520 if (skb) 524 if (skb)
521 sch->q.qlen--; 525 sch->q.qlen--;
522 return skb; 526 return skb;
523} 527}
524 528
525static int atm_tc_requeue(struct sk_buff *skb, struct Qdisc *sch) 529static struct sk_buff *atm_tc_peek(struct Qdisc *sch)
526{ 530{
527 struct atm_qdisc_data *p = qdisc_priv(sch); 531 struct atm_qdisc_data *p = qdisc_priv(sch);
528 int ret;
529 532
530 pr_debug("atm_tc_requeue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p); 533 pr_debug("atm_tc_peek(sch %p,[qdisc %p])\n", sch, p);
531 ret = p->link.q->ops->requeue(skb, p->link.q); 534
532 if (!ret) { 535 return p->link.q->ops->peek(p->link.q);
533 sch->q.qlen++;
534 sch->qstats.requeues++;
535 } else if (net_xmit_drop_count(ret)) {
536 sch->qstats.drops++;
537 p->link.qstats.drops++;
538 }
539 return ret;
540} 536}
541 537
542static unsigned int atm_tc_drop(struct Qdisc *sch) 538static unsigned int atm_tc_drop(struct Qdisc *sch)
@@ -694,7 +690,7 @@ static struct Qdisc_ops atm_qdisc_ops __read_mostly = {
694 .priv_size = sizeof(struct atm_qdisc_data), 690 .priv_size = sizeof(struct atm_qdisc_data),
695 .enqueue = atm_tc_enqueue, 691 .enqueue = atm_tc_enqueue,
696 .dequeue = atm_tc_dequeue, 692 .dequeue = atm_tc_dequeue,
697 .requeue = atm_tc_requeue, 693 .peek = atm_tc_peek,
698 .drop = atm_tc_drop, 694 .drop = atm_tc_drop,
699 .init = atm_tc_init, 695 .init = atm_tc_init,
700 .reset = atm_tc_reset, 696 .reset = atm_tc_reset,
diff --git a/net/sched/sch_blackhole.c b/net/sched/sch_blackhole.c
index 507fb488bc98..094a874b48bc 100644
--- a/net/sched/sch_blackhole.c
+++ b/net/sched/sch_blackhole.c
@@ -33,6 +33,7 @@ static struct Qdisc_ops blackhole_qdisc_ops __read_mostly = {
33 .priv_size = 0, 33 .priv_size = 0,
34 .enqueue = blackhole_enqueue, 34 .enqueue = blackhole_enqueue,
35 .dequeue = blackhole_dequeue, 35 .dequeue = blackhole_dequeue,
36 .peek = blackhole_dequeue,
36 .owner = THIS_MODULE, 37 .owner = THIS_MODULE,
37}; 38};
38 39
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index 03e389e8d945..3a9569a3396c 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -405,40 +405,6 @@ cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
405 return ret; 405 return ret;
406} 406}
407 407
408static int
409cbq_requeue(struct sk_buff *skb, struct Qdisc *sch)
410{
411 struct cbq_sched_data *q = qdisc_priv(sch);
412 struct cbq_class *cl;
413 int ret;
414
415 if ((cl = q->tx_class) == NULL) {
416 kfree_skb(skb);
417 sch->qstats.drops++;
418 return NET_XMIT_CN;
419 }
420 q->tx_class = NULL;
421
422 cbq_mark_toplevel(q, cl);
423
424#ifdef CONFIG_NET_CLS_ACT
425 q->rx_class = cl;
426 cl->q->__parent = sch;
427#endif
428 if ((ret = cl->q->ops->requeue(skb, cl->q)) == 0) {
429 sch->q.qlen++;
430 sch->qstats.requeues++;
431 if (!cl->next_alive)
432 cbq_activate_class(cl);
433 return 0;
434 }
435 if (net_xmit_drop_count(ret)) {
436 sch->qstats.drops++;
437 cl->qstats.drops++;
438 }
439 return ret;
440}
441
442/* Overlimit actions */ 408/* Overlimit actions */
443 409
444/* TC_CBQ_OVL_CLASSIC: (default) penalize leaf class by adding offtime */ 410/* TC_CBQ_OVL_CLASSIC: (default) penalize leaf class by adding offtime */
@@ -1669,7 +1635,8 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
1669#endif 1635#endif
1670 } 1636 }
1671 sch_tree_lock(sch); 1637 sch_tree_lock(sch);
1672 *old = xchg(&cl->q, new); 1638 *old = cl->q;
1639 cl->q = new;
1673 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen); 1640 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
1674 qdisc_reset(*old); 1641 qdisc_reset(*old);
1675 sch_tree_unlock(sch); 1642 sch_tree_unlock(sch);
@@ -1810,8 +1777,8 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
1810 cbq_deactivate_class(cl); 1777 cbq_deactivate_class(cl);
1811 1778
1812 if (rtab) { 1779 if (rtab) {
1813 rtab = xchg(&cl->R_tab, rtab); 1780 qdisc_put_rtab(cl->R_tab);
1814 qdisc_put_rtab(rtab); 1781 cl->R_tab = rtab;
1815 } 1782 }
1816 1783
1817 if (tb[TCA_CBQ_LSSOPT]) 1784 if (tb[TCA_CBQ_LSSOPT])
@@ -2066,7 +2033,7 @@ static struct Qdisc_ops cbq_qdisc_ops __read_mostly = {
2066 .priv_size = sizeof(struct cbq_sched_data), 2033 .priv_size = sizeof(struct cbq_sched_data),
2067 .enqueue = cbq_enqueue, 2034 .enqueue = cbq_enqueue,
2068 .dequeue = cbq_dequeue, 2035 .dequeue = cbq_dequeue,
2069 .requeue = cbq_requeue, 2036 .peek = qdisc_peek_dequeued,
2070 .drop = cbq_drop, 2037 .drop = cbq_drop,
2071 .init = cbq_init, 2038 .init = cbq_init,
2072 .reset = cbq_reset, 2039 .reset = cbq_reset,
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
new file mode 100644
index 000000000000..8d523d9b636c
--- /dev/null
+++ b/net/sched/sch_drr.c
@@ -0,0 +1,506 @@
1/*
2 * net/sched/sch_drr.c Deficit Round Robin scheduler
3 *
4 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/errno.h>
14#include <linux/netdevice.h>
15#include <linux/pkt_sched.h>
16#include <net/sch_generic.h>
17#include <net/pkt_sched.h>
18#include <net/pkt_cls.h>
19
20struct drr_class {
21 struct Qdisc_class_common common;
22 unsigned int refcnt;
23 unsigned int filter_cnt;
24
25 struct gnet_stats_basic bstats;
26 struct gnet_stats_queue qstats;
27 struct gnet_stats_rate_est rate_est;
28 struct list_head alist;
29 struct Qdisc *qdisc;
30
31 u32 quantum;
32 u32 deficit;
33};
34
35struct drr_sched {
36 struct list_head active;
37 struct tcf_proto *filter_list;
38 struct Qdisc_class_hash clhash;
39};
40
41static struct drr_class *drr_find_class(struct Qdisc *sch, u32 classid)
42{
43 struct drr_sched *q = qdisc_priv(sch);
44 struct Qdisc_class_common *clc;
45
46 clc = qdisc_class_find(&q->clhash, classid);
47 if (clc == NULL)
48 return NULL;
49 return container_of(clc, struct drr_class, common);
50}
51
52static void drr_purge_queue(struct drr_class *cl)
53{
54 unsigned int len = cl->qdisc->q.qlen;
55
56 qdisc_reset(cl->qdisc);
57 qdisc_tree_decrease_qlen(cl->qdisc, len);
58}
59
60static const struct nla_policy drr_policy[TCA_DRR_MAX + 1] = {
61 [TCA_DRR_QUANTUM] = { .type = NLA_U32 },
62};
63
64static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
65 struct nlattr **tca, unsigned long *arg)
66{
67 struct drr_sched *q = qdisc_priv(sch);
68 struct drr_class *cl = (struct drr_class *)*arg;
69 struct nlattr *tb[TCA_DRR_MAX + 1];
70 u32 quantum;
71 int err;
72
73 err = nla_parse_nested(tb, TCA_DRR_MAX, tca[TCA_OPTIONS], drr_policy);
74 if (err < 0)
75 return err;
76
77 if (tb[TCA_DRR_QUANTUM]) {
78 quantum = nla_get_u32(tb[TCA_DRR_QUANTUM]);
79 if (quantum == 0)
80 return -EINVAL;
81 } else
82 quantum = psched_mtu(qdisc_dev(sch));
83
84 if (cl != NULL) {
85 sch_tree_lock(sch);
86 if (tb[TCA_DRR_QUANTUM])
87 cl->quantum = quantum;
88 sch_tree_unlock(sch);
89
90 if (tca[TCA_RATE])
91 gen_replace_estimator(&cl->bstats, &cl->rate_est,
92 qdisc_root_sleeping_lock(sch),
93 tca[TCA_RATE]);
94 return 0;
95 }
96
97 cl = kzalloc(sizeof(struct drr_class), GFP_KERNEL);
98 if (cl == NULL)
99 return -ENOBUFS;
100
101 cl->refcnt = 1;
102 cl->common.classid = classid;
103 cl->quantum = quantum;
104 cl->qdisc = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
105 &pfifo_qdisc_ops, classid);
106 if (cl->qdisc == NULL)
107 cl->qdisc = &noop_qdisc;
108
109 if (tca[TCA_RATE])
110 gen_replace_estimator(&cl->bstats, &cl->rate_est,
111 qdisc_root_sleeping_lock(sch),
112 tca[TCA_RATE]);
113
114 sch_tree_lock(sch);
115 qdisc_class_hash_insert(&q->clhash, &cl->common);
116 sch_tree_unlock(sch);
117
118 qdisc_class_hash_grow(sch, &q->clhash);
119
120 *arg = (unsigned long)cl;
121 return 0;
122}
123
124static void drr_destroy_class(struct Qdisc *sch, struct drr_class *cl)
125{
126 gen_kill_estimator(&cl->bstats, &cl->rate_est);
127 qdisc_destroy(cl->qdisc);
128 kfree(cl);
129}
130
131static int drr_delete_class(struct Qdisc *sch, unsigned long arg)
132{
133 struct drr_sched *q = qdisc_priv(sch);
134 struct drr_class *cl = (struct drr_class *)arg;
135
136 if (cl->filter_cnt > 0)
137 return -EBUSY;
138
139 sch_tree_lock(sch);
140
141 drr_purge_queue(cl);
142 qdisc_class_hash_remove(&q->clhash, &cl->common);
143
144 if (--cl->refcnt == 0)
145 drr_destroy_class(sch, cl);
146
147 sch_tree_unlock(sch);
148 return 0;
149}
150
151static unsigned long drr_get_class(struct Qdisc *sch, u32 classid)
152{
153 struct drr_class *cl = drr_find_class(sch, classid);
154
155 if (cl != NULL)
156 cl->refcnt++;
157
158 return (unsigned long)cl;
159}
160
161static void drr_put_class(struct Qdisc *sch, unsigned long arg)
162{
163 struct drr_class *cl = (struct drr_class *)arg;
164
165 if (--cl->refcnt == 0)
166 drr_destroy_class(sch, cl);
167}
168
169static struct tcf_proto **drr_tcf_chain(struct Qdisc *sch, unsigned long cl)
170{
171 struct drr_sched *q = qdisc_priv(sch);
172
173 if (cl)
174 return NULL;
175
176 return &q->filter_list;
177}
178
179static unsigned long drr_bind_tcf(struct Qdisc *sch, unsigned long parent,
180 u32 classid)
181{
182 struct drr_class *cl = drr_find_class(sch, classid);
183
184 if (cl != NULL)
185 cl->filter_cnt++;
186
187 return (unsigned long)cl;
188}
189
190static void drr_unbind_tcf(struct Qdisc *sch, unsigned long arg)
191{
192 struct drr_class *cl = (struct drr_class *)arg;
193
194 cl->filter_cnt--;
195}
196
197static int drr_graft_class(struct Qdisc *sch, unsigned long arg,
198 struct Qdisc *new, struct Qdisc **old)
199{
200 struct drr_class *cl = (struct drr_class *)arg;
201
202 if (new == NULL) {
203 new = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
204 &pfifo_qdisc_ops, cl->common.classid);
205 if (new == NULL)
206 new = &noop_qdisc;
207 }
208
209 sch_tree_lock(sch);
210 drr_purge_queue(cl);
211 *old = cl->qdisc;
212 cl->qdisc = new;
213 sch_tree_unlock(sch);
214 return 0;
215}
216
217static struct Qdisc *drr_class_leaf(struct Qdisc *sch, unsigned long arg)
218{
219 struct drr_class *cl = (struct drr_class *)arg;
220
221 return cl->qdisc;
222}
223
224static void drr_qlen_notify(struct Qdisc *csh, unsigned long arg)
225{
226 struct drr_class *cl = (struct drr_class *)arg;
227
228 if (cl->qdisc->q.qlen == 0)
229 list_del(&cl->alist);
230}
231
232static int drr_dump_class(struct Qdisc *sch, unsigned long arg,
233 struct sk_buff *skb, struct tcmsg *tcm)
234{
235 struct drr_class *cl = (struct drr_class *)arg;
236 struct nlattr *nest;
237
238 tcm->tcm_parent = TC_H_ROOT;
239 tcm->tcm_handle = cl->common.classid;
240 tcm->tcm_info = cl->qdisc->handle;
241
242 nest = nla_nest_start(skb, TCA_OPTIONS);
243 if (nest == NULL)
244 goto nla_put_failure;
245 NLA_PUT_U32(skb, TCA_DRR_QUANTUM, cl->quantum);
246 return nla_nest_end(skb, nest);
247
248nla_put_failure:
249 nla_nest_cancel(skb, nest);
250 return -EMSGSIZE;
251}
252
253static int drr_dump_class_stats(struct Qdisc *sch, unsigned long arg,
254 struct gnet_dump *d)
255{
256 struct drr_class *cl = (struct drr_class *)arg;
257 struct tc_drr_stats xstats;
258
259 memset(&xstats, 0, sizeof(xstats));
260 if (cl->qdisc->q.qlen)
261 xstats.deficit = cl->deficit;
262
263 if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
264 gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
265 gnet_stats_copy_queue(d, &cl->qdisc->qstats) < 0)
266 return -1;
267
268 return gnet_stats_copy_app(d, &xstats, sizeof(xstats));
269}
270
271static void drr_walk(struct Qdisc *sch, struct qdisc_walker *arg)
272{
273 struct drr_sched *q = qdisc_priv(sch);
274 struct drr_class *cl;
275 struct hlist_node *n;
276 unsigned int i;
277
278 if (arg->stop)
279 return;
280
281 for (i = 0; i < q->clhash.hashsize; i++) {
282 hlist_for_each_entry(cl, n, &q->clhash.hash[i], common.hnode) {
283 if (arg->count < arg->skip) {
284 arg->count++;
285 continue;
286 }
287 if (arg->fn(sch, (unsigned long)cl, arg) < 0) {
288 arg->stop = 1;
289 return;
290 }
291 arg->count++;
292 }
293 }
294}
295
296static struct drr_class *drr_classify(struct sk_buff *skb, struct Qdisc *sch,
297 int *qerr)
298{
299 struct drr_sched *q = qdisc_priv(sch);
300 struct drr_class *cl;
301 struct tcf_result res;
302 int result;
303
304 if (TC_H_MAJ(skb->priority ^ sch->handle) == 0) {
305 cl = drr_find_class(sch, skb->priority);
306 if (cl != NULL)
307 return cl;
308 }
309
310 *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
311 result = tc_classify(skb, q->filter_list, &res);
312 if (result >= 0) {
313#ifdef CONFIG_NET_CLS_ACT
314 switch (result) {
315 case TC_ACT_QUEUED:
316 case TC_ACT_STOLEN:
317 *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
318 case TC_ACT_SHOT:
319 return NULL;
320 }
321#endif
322 cl = (struct drr_class *)res.class;
323 if (cl == NULL)
324 cl = drr_find_class(sch, res.classid);
325 return cl;
326 }
327 return NULL;
328}
329
330static int drr_enqueue(struct sk_buff *skb, struct Qdisc *sch)
331{
332 struct drr_sched *q = qdisc_priv(sch);
333 struct drr_class *cl;
334 unsigned int len;
335 int err;
336
337 cl = drr_classify(skb, sch, &err);
338 if (cl == NULL) {
339 if (err & __NET_XMIT_BYPASS)
340 sch->qstats.drops++;
341 kfree_skb(skb);
342 return err;
343 }
344
345 len = qdisc_pkt_len(skb);
346 err = qdisc_enqueue(skb, cl->qdisc);
347 if (unlikely(err != NET_XMIT_SUCCESS)) {
348 if (net_xmit_drop_count(err)) {
349 cl->qstats.drops++;
350 sch->qstats.drops++;
351 }
352 return err;
353 }
354
355 if (cl->qdisc->q.qlen == 1) {
356 list_add_tail(&cl->alist, &q->active);
357 cl->deficit = cl->quantum;
358 }
359
360 cl->bstats.packets++;
361 cl->bstats.bytes += len;
362 sch->bstats.packets++;
363 sch->bstats.bytes += len;
364
365 sch->q.qlen++;
366 return err;
367}
368
369static struct sk_buff *drr_dequeue(struct Qdisc *sch)
370{
371 struct drr_sched *q = qdisc_priv(sch);
372 struct drr_class *cl;
373 struct sk_buff *skb;
374 unsigned int len;
375
376 while (!list_empty(&q->active)) {
377 cl = list_first_entry(&q->active, struct drr_class, alist);
378 skb = cl->qdisc->ops->peek(cl->qdisc);
379 if (skb == NULL)
380 goto skip;
381
382 len = qdisc_pkt_len(skb);
383 if (len <= cl->deficit) {
384 cl->deficit -= len;
385 skb = qdisc_dequeue_peeked(cl->qdisc);
386 if (cl->qdisc->q.qlen == 0)
387 list_del(&cl->alist);
388 sch->q.qlen--;
389 return skb;
390 }
391
392 cl->deficit += cl->quantum;
393skip:
394 list_move_tail(&cl->alist, &q->active);
395 }
396 return NULL;
397}
398
399static unsigned int drr_drop(struct Qdisc *sch)
400{
401 struct drr_sched *q = qdisc_priv(sch);
402 struct drr_class *cl;
403 unsigned int len;
404
405 list_for_each_entry(cl, &q->active, alist) {
406 if (cl->qdisc->ops->drop) {
407 len = cl->qdisc->ops->drop(cl->qdisc);
408 if (len > 0) {
409 if (cl->qdisc->q.qlen == 0)
410 list_del(&cl->alist);
411 return len;
412 }
413 }
414 }
415 return 0;
416}
417
418static int drr_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
419{
420 struct drr_sched *q = qdisc_priv(sch);
421 int err;
422
423 err = qdisc_class_hash_init(&q->clhash);
424 if (err < 0)
425 return err;
426 INIT_LIST_HEAD(&q->active);
427 return 0;
428}
429
430static void drr_reset_qdisc(struct Qdisc *sch)
431{
432 struct drr_sched *q = qdisc_priv(sch);
433 struct drr_class *cl;
434 struct hlist_node *n;
435 unsigned int i;
436
437 for (i = 0; i < q->clhash.hashsize; i++) {
438 hlist_for_each_entry(cl, n, &q->clhash.hash[i], common.hnode) {
439 if (cl->qdisc->q.qlen)
440 list_del(&cl->alist);
441 qdisc_reset(cl->qdisc);
442 }
443 }
444 sch->q.qlen = 0;
445}
446
447static void drr_destroy_qdisc(struct Qdisc *sch)
448{
449 struct drr_sched *q = qdisc_priv(sch);
450 struct drr_class *cl;
451 struct hlist_node *n, *next;
452 unsigned int i;
453
454 tcf_destroy_chain(&q->filter_list);
455
456 for (i = 0; i < q->clhash.hashsize; i++) {
457 hlist_for_each_entry_safe(cl, n, next, &q->clhash.hash[i],
458 common.hnode)
459 drr_destroy_class(sch, cl);
460 }
461 qdisc_class_hash_destroy(&q->clhash);
462}
463
464static const struct Qdisc_class_ops drr_class_ops = {
465 .change = drr_change_class,
466 .delete = drr_delete_class,
467 .get = drr_get_class,
468 .put = drr_put_class,
469 .tcf_chain = drr_tcf_chain,
470 .bind_tcf = drr_bind_tcf,
471 .unbind_tcf = drr_unbind_tcf,
472 .graft = drr_graft_class,
473 .leaf = drr_class_leaf,
474 .qlen_notify = drr_qlen_notify,
475 .dump = drr_dump_class,
476 .dump_stats = drr_dump_class_stats,
477 .walk = drr_walk,
478};
479
480static struct Qdisc_ops drr_qdisc_ops __read_mostly = {
481 .cl_ops = &drr_class_ops,
482 .id = "drr",
483 .priv_size = sizeof(struct drr_sched),
484 .enqueue = drr_enqueue,
485 .dequeue = drr_dequeue,
486 .peek = qdisc_peek_dequeued,
487 .drop = drr_drop,
488 .init = drr_init_qdisc,
489 .reset = drr_reset_qdisc,
490 .destroy = drr_destroy_qdisc,
491 .owner = THIS_MODULE,
492};
493
494static int __init drr_init(void)
495{
496 return register_qdisc(&drr_qdisc_ops);
497}
498
499static void __exit drr_exit(void)
500{
501 unregister_qdisc(&drr_qdisc_ops);
502}
503
504module_init(drr_init);
505module_exit(drr_exit);
506MODULE_LICENSE("GPL");
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
index ba43aab3a851..d303daa45d49 100644
--- a/net/sched/sch_dsmark.c
+++ b/net/sched/sch_dsmark.c
@@ -68,7 +68,8 @@ static int dsmark_graft(struct Qdisc *sch, unsigned long arg,
68 } 68 }
69 69
70 sch_tree_lock(sch); 70 sch_tree_lock(sch);
71 *old = xchg(&p->q, new); 71 *old = p->q;
72 p->q = new;
72 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen); 73 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
73 qdisc_reset(*old); 74 qdisc_reset(*old);
74 sch_tree_unlock(sch); 75 sch_tree_unlock(sch);
@@ -313,24 +314,13 @@ static struct sk_buff *dsmark_dequeue(struct Qdisc *sch)
313 return skb; 314 return skb;
314} 315}
315 316
316static int dsmark_requeue(struct sk_buff *skb, struct Qdisc *sch) 317static struct sk_buff *dsmark_peek(struct Qdisc *sch)
317{ 318{
318 struct dsmark_qdisc_data *p = qdisc_priv(sch); 319 struct dsmark_qdisc_data *p = qdisc_priv(sch);
319 int err;
320
321 pr_debug("dsmark_requeue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p);
322
323 err = p->q->ops->requeue(skb, p->q);
324 if (err != NET_XMIT_SUCCESS) {
325 if (net_xmit_drop_count(err))
326 sch->qstats.drops++;
327 return err;
328 }
329 320
330 sch->q.qlen++; 321 pr_debug("dsmark_peek(sch %p,[qdisc %p])\n", sch, p);
331 sch->qstats.requeues++;
332 322
333 return NET_XMIT_SUCCESS; 323 return p->q->ops->peek(p->q);
334} 324}
335 325
336static unsigned int dsmark_drop(struct Qdisc *sch) 326static unsigned int dsmark_drop(struct Qdisc *sch)
@@ -496,7 +486,7 @@ static struct Qdisc_ops dsmark_qdisc_ops __read_mostly = {
496 .priv_size = sizeof(struct dsmark_qdisc_data), 486 .priv_size = sizeof(struct dsmark_qdisc_data),
497 .enqueue = dsmark_enqueue, 487 .enqueue = dsmark_enqueue,
498 .dequeue = dsmark_dequeue, 488 .dequeue = dsmark_dequeue,
499 .requeue = dsmark_requeue, 489 .peek = dsmark_peek,
500 .drop = dsmark_drop, 490 .drop = dsmark_drop,
501 .init = dsmark_init, 491 .init = dsmark_init,
502 .reset = dsmark_reset, 492 .reset = dsmark_reset,
diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c
index 23d258bfe8ac..92cfc9d7e3b9 100644
--- a/net/sched/sch_fifo.c
+++ b/net/sched/sch_fifo.c
@@ -83,7 +83,7 @@ struct Qdisc_ops pfifo_qdisc_ops __read_mostly = {
83 .priv_size = sizeof(struct fifo_sched_data), 83 .priv_size = sizeof(struct fifo_sched_data),
84 .enqueue = pfifo_enqueue, 84 .enqueue = pfifo_enqueue,
85 .dequeue = qdisc_dequeue_head, 85 .dequeue = qdisc_dequeue_head,
86 .requeue = qdisc_requeue, 86 .peek = qdisc_peek_head,
87 .drop = qdisc_queue_drop, 87 .drop = qdisc_queue_drop,
88 .init = fifo_init, 88 .init = fifo_init,
89 .reset = qdisc_reset_queue, 89 .reset = qdisc_reset_queue,
@@ -98,7 +98,7 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = {
98 .priv_size = sizeof(struct fifo_sched_data), 98 .priv_size = sizeof(struct fifo_sched_data),
99 .enqueue = bfifo_enqueue, 99 .enqueue = bfifo_enqueue,
100 .dequeue = qdisc_dequeue_head, 100 .dequeue = qdisc_dequeue_head,
101 .requeue = qdisc_requeue, 101 .peek = qdisc_peek_head,
102 .drop = qdisc_queue_drop, 102 .drop = qdisc_queue_drop,
103 .init = fifo_init, 103 .init = fifo_init,
104 .reset = qdisc_reset_queue, 104 .reset = qdisc_reset_queue,
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index cdcd16fcfeda..5f5efe4e6072 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -224,7 +224,7 @@ static void dev_watchdog(unsigned long arg)
224 char drivername[64]; 224 char drivername[64];
225 WARN_ONCE(1, KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit timed out\n", 225 WARN_ONCE(1, KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit timed out\n",
226 dev->name, netdev_drivername(dev, drivername, 64)); 226 dev->name, netdev_drivername(dev, drivername, 64));
227 dev->tx_timeout(dev); 227 dev->netdev_ops->ndo_tx_timeout(dev);
228 } 228 }
229 if (!mod_timer(&dev->watchdog_timer, 229 if (!mod_timer(&dev->watchdog_timer,
230 round_jiffies(jiffies + 230 round_jiffies(jiffies +
@@ -239,7 +239,7 @@ static void dev_watchdog(unsigned long arg)
239 239
240void __netdev_watchdog_up(struct net_device *dev) 240void __netdev_watchdog_up(struct net_device *dev)
241{ 241{
242 if (dev->tx_timeout) { 242 if (dev->netdev_ops->ndo_tx_timeout) {
243 if (dev->watchdog_timeo <= 0) 243 if (dev->watchdog_timeo <= 0)
244 dev->watchdog_timeo = 5*HZ; 244 dev->watchdog_timeo = 5*HZ;
245 if (!mod_timer(&dev->watchdog_timer, 245 if (!mod_timer(&dev->watchdog_timer,
@@ -311,21 +311,12 @@ static struct sk_buff *noop_dequeue(struct Qdisc * qdisc)
311 return NULL; 311 return NULL;
312} 312}
313 313
314static int noop_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
315{
316 if (net_ratelimit())
317 printk(KERN_DEBUG "%s deferred output. It is buggy.\n",
318 skb->dev->name);
319 kfree_skb(skb);
320 return NET_XMIT_CN;
321}
322
323struct Qdisc_ops noop_qdisc_ops __read_mostly = { 314struct Qdisc_ops noop_qdisc_ops __read_mostly = {
324 .id = "noop", 315 .id = "noop",
325 .priv_size = 0, 316 .priv_size = 0,
326 .enqueue = noop_enqueue, 317 .enqueue = noop_enqueue,
327 .dequeue = noop_dequeue, 318 .dequeue = noop_dequeue,
328 .requeue = noop_requeue, 319 .peek = noop_dequeue,
329 .owner = THIS_MODULE, 320 .owner = THIS_MODULE,
330}; 321};
331 322
@@ -340,7 +331,6 @@ struct Qdisc noop_qdisc = {
340 .flags = TCQ_F_BUILTIN, 331 .flags = TCQ_F_BUILTIN,
341 .ops = &noop_qdisc_ops, 332 .ops = &noop_qdisc_ops,
342 .list = LIST_HEAD_INIT(noop_qdisc.list), 333 .list = LIST_HEAD_INIT(noop_qdisc.list),
343 .requeue.lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock),
344 .q.lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock), 334 .q.lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock),
345 .dev_queue = &noop_netdev_queue, 335 .dev_queue = &noop_netdev_queue,
346}; 336};
@@ -351,7 +341,7 @@ static struct Qdisc_ops noqueue_qdisc_ops __read_mostly = {
351 .priv_size = 0, 341 .priv_size = 0,
352 .enqueue = noop_enqueue, 342 .enqueue = noop_enqueue,
353 .dequeue = noop_dequeue, 343 .dequeue = noop_dequeue,
354 .requeue = noop_requeue, 344 .peek = noop_dequeue,
355 .owner = THIS_MODULE, 345 .owner = THIS_MODULE,
356}; 346};
357 347
@@ -367,7 +357,6 @@ static struct Qdisc noqueue_qdisc = {
367 .flags = TCQ_F_BUILTIN, 357 .flags = TCQ_F_BUILTIN,
368 .ops = &noqueue_qdisc_ops, 358 .ops = &noqueue_qdisc_ops,
369 .list = LIST_HEAD_INIT(noqueue_qdisc.list), 359 .list = LIST_HEAD_INIT(noqueue_qdisc.list),
370 .requeue.lock = __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock),
371 .q.lock = __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock), 360 .q.lock = __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock),
372 .dev_queue = &noqueue_netdev_queue, 361 .dev_queue = &noqueue_netdev_queue,
373}; 362};
@@ -416,10 +405,17 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
416 return NULL; 405 return NULL;
417} 406}
418 407
419static int pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc) 408static struct sk_buff *pfifo_fast_peek(struct Qdisc* qdisc)
420{ 409{
421 qdisc->q.qlen++; 410 int prio;
422 return __qdisc_requeue(skb, qdisc, prio2list(skb, qdisc)); 411 struct sk_buff_head *list = qdisc_priv(qdisc);
412
413 for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
414 if (!skb_queue_empty(list + prio))
415 return skb_peek(list + prio);
416 }
417
418 return NULL;
423} 419}
424 420
425static void pfifo_fast_reset(struct Qdisc* qdisc) 421static void pfifo_fast_reset(struct Qdisc* qdisc)
@@ -462,7 +458,7 @@ static struct Qdisc_ops pfifo_fast_ops __read_mostly = {
462 .priv_size = PFIFO_FAST_BANDS * sizeof(struct sk_buff_head), 458 .priv_size = PFIFO_FAST_BANDS * sizeof(struct sk_buff_head),
463 .enqueue = pfifo_fast_enqueue, 459 .enqueue = pfifo_fast_enqueue,
464 .dequeue = pfifo_fast_dequeue, 460 .dequeue = pfifo_fast_dequeue,
465 .requeue = pfifo_fast_requeue, 461 .peek = pfifo_fast_peek,
466 .init = pfifo_fast_init, 462 .init = pfifo_fast_init,
467 .reset = pfifo_fast_reset, 463 .reset = pfifo_fast_reset,
468 .dump = pfifo_fast_dump, 464 .dump = pfifo_fast_dump,
@@ -488,7 +484,6 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
488 sch->padded = (char *) sch - (char *) p; 484 sch->padded = (char *) sch - (char *) p;
489 485
490 INIT_LIST_HEAD(&sch->list); 486 INIT_LIST_HEAD(&sch->list);
491 skb_queue_head_init(&sch->requeue);
492 skb_queue_head_init(&sch->q); 487 skb_queue_head_init(&sch->q);
493 sch->ops = ops; 488 sch->ops = ops;
494 sch->enqueue = ops->enqueue; 489 sch->enqueue = ops->enqueue;
@@ -531,6 +526,9 @@ void qdisc_reset(struct Qdisc *qdisc)
531 526
532 if (ops->reset) 527 if (ops->reset)
533 ops->reset(qdisc); 528 ops->reset(qdisc);
529
530 kfree_skb(qdisc->gso_skb);
531 qdisc->gso_skb = NULL;
534} 532}
535EXPORT_SYMBOL(qdisc_reset); 533EXPORT_SYMBOL(qdisc_reset);
536 534
@@ -557,8 +555,6 @@ void qdisc_destroy(struct Qdisc *qdisc)
557 dev_put(qdisc_dev(qdisc)); 555 dev_put(qdisc_dev(qdisc));
558 556
559 kfree_skb(qdisc->gso_skb); 557 kfree_skb(qdisc->gso_skb);
560 __skb_queue_purge(&qdisc->requeue);
561
562 kfree((char *) qdisc - qdisc->padded); 558 kfree((char *) qdisc - qdisc->padded);
563} 559}
564EXPORT_SYMBOL(qdisc_destroy); 560EXPORT_SYMBOL(qdisc_destroy);
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index c1ad6b8de105..40408d595c08 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -240,26 +240,6 @@ congestion_drop:
240 return NET_XMIT_CN; 240 return NET_XMIT_CN;
241} 241}
242 242
243static int gred_requeue(struct sk_buff *skb, struct Qdisc* sch)
244{
245 struct gred_sched *t = qdisc_priv(sch);
246 struct gred_sched_data *q;
247 u16 dp = tc_index_to_dp(skb);
248
249 if (dp >= t->DPs || (q = t->tab[dp]) == NULL) {
250 if (net_ratelimit())
251 printk(KERN_WARNING "GRED: Unable to relocate VQ 0x%x "
252 "for requeue, screwing up backlog.\n",
253 tc_index_to_dp(skb));
254 } else {
255 if (red_is_idling(&q->parms))
256 red_end_of_idle_period(&q->parms);
257 q->backlog += qdisc_pkt_len(skb);
258 }
259
260 return qdisc_requeue(skb, sch);
261}
262
263static struct sk_buff *gred_dequeue(struct Qdisc* sch) 243static struct sk_buff *gred_dequeue(struct Qdisc* sch)
264{ 244{
265 struct sk_buff *skb; 245 struct sk_buff *skb;
@@ -602,7 +582,7 @@ static struct Qdisc_ops gred_qdisc_ops __read_mostly = {
602 .priv_size = sizeof(struct gred_sched), 582 .priv_size = sizeof(struct gred_sched),
603 .enqueue = gred_enqueue, 583 .enqueue = gred_enqueue,
604 .dequeue = gred_dequeue, 584 .dequeue = gred_dequeue,
605 .requeue = gred_requeue, 585 .peek = qdisc_peek_head,
606 .drop = gred_drop, 586 .drop = gred_drop,
607 .init = gred_init, 587 .init = gred_init,
608 .reset = gred_reset, 588 .reset = gred_reset,
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index c1e77da8cd09..51dd3f401623 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -184,7 +184,6 @@ struct hfsc_sched
184 struct rb_root eligible; /* eligible tree */ 184 struct rb_root eligible; /* eligible tree */
185 struct list_head droplist; /* active leaf class list (for 185 struct list_head droplist; /* active leaf class list (for
186 dropping) */ 186 dropping) */
187 struct sk_buff_head requeue; /* requeued packet */
188 struct qdisc_watchdog watchdog; /* watchdog timer */ 187 struct qdisc_watchdog watchdog; /* watchdog timer */
189}; 188};
190 189
@@ -880,28 +879,20 @@ set_passive(struct hfsc_class *cl)
880 */ 879 */
881} 880}
882 881
883/*
884 * hack to get length of first packet in queue.
885 */
886static unsigned int 882static unsigned int
887qdisc_peek_len(struct Qdisc *sch) 883qdisc_peek_len(struct Qdisc *sch)
888{ 884{
889 struct sk_buff *skb; 885 struct sk_buff *skb;
890 unsigned int len; 886 unsigned int len;
891 887
892 skb = sch->dequeue(sch); 888 skb = sch->ops->peek(sch);
893 if (skb == NULL) { 889 if (skb == NULL) {
894 if (net_ratelimit()) 890 if (net_ratelimit())
895 printk("qdisc_peek_len: non work-conserving qdisc ?\n"); 891 printk("qdisc_peek_len: non work-conserving qdisc ?\n");
896 return 0; 892 return 0;
897 } 893 }
898 len = qdisc_pkt_len(skb); 894 len = qdisc_pkt_len(skb);
899 if (unlikely(sch->ops->requeue(skb, sch) != NET_XMIT_SUCCESS)) { 895
900 if (net_ratelimit())
901 printk("qdisc_peek_len: failed to requeue\n");
902 qdisc_tree_decrease_qlen(sch, 1);
903 return 0;
904 }
905 return len; 896 return len;
906} 897}
907 898
@@ -1211,7 +1202,8 @@ hfsc_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
1211 1202
1212 sch_tree_lock(sch); 1203 sch_tree_lock(sch);
1213 hfsc_purge_queue(sch, cl); 1204 hfsc_purge_queue(sch, cl);
1214 *old = xchg(&cl->qdisc, new); 1205 *old = cl->qdisc;
1206 cl->qdisc = new;
1215 sch_tree_unlock(sch); 1207 sch_tree_unlock(sch);
1216 return 0; 1208 return 0;
1217} 1209}
@@ -1440,7 +1432,6 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
1440 return err; 1432 return err;
1441 q->eligible = RB_ROOT; 1433 q->eligible = RB_ROOT;
1442 INIT_LIST_HEAD(&q->droplist); 1434 INIT_LIST_HEAD(&q->droplist);
1443 skb_queue_head_init(&q->requeue);
1444 1435
1445 q->root.cl_common.classid = sch->handle; 1436 q->root.cl_common.classid = sch->handle;
1446 q->root.refcnt = 1; 1437 q->root.refcnt = 1;
@@ -1525,7 +1516,6 @@ hfsc_reset_qdisc(struct Qdisc *sch)
1525 hlist_for_each_entry(cl, n, &q->clhash.hash[i], cl_common.hnode) 1516 hlist_for_each_entry(cl, n, &q->clhash.hash[i], cl_common.hnode)
1526 hfsc_reset_class(cl); 1517 hfsc_reset_class(cl);
1527 } 1518 }
1528 __skb_queue_purge(&q->requeue);
1529 q->eligible = RB_ROOT; 1519 q->eligible = RB_ROOT;
1530 INIT_LIST_HEAD(&q->droplist); 1520 INIT_LIST_HEAD(&q->droplist);
1531 qdisc_watchdog_cancel(&q->watchdog); 1521 qdisc_watchdog_cancel(&q->watchdog);
@@ -1550,7 +1540,6 @@ hfsc_destroy_qdisc(struct Qdisc *sch)
1550 hfsc_destroy_class(sch, cl); 1540 hfsc_destroy_class(sch, cl);
1551 } 1541 }
1552 qdisc_class_hash_destroy(&q->clhash); 1542 qdisc_class_hash_destroy(&q->clhash);
1553 __skb_queue_purge(&q->requeue);
1554 qdisc_watchdog_cancel(&q->watchdog); 1543 qdisc_watchdog_cancel(&q->watchdog);
1555} 1544}
1556 1545
@@ -1617,8 +1606,6 @@ hfsc_dequeue(struct Qdisc *sch)
1617 1606
1618 if (sch->q.qlen == 0) 1607 if (sch->q.qlen == 0)
1619 return NULL; 1608 return NULL;
1620 if ((skb = __skb_dequeue(&q->requeue)))
1621 goto out;
1622 1609
1623 cur_time = psched_get_time(); 1610 cur_time = psched_get_time();
1624 1611
@@ -1642,7 +1629,7 @@ hfsc_dequeue(struct Qdisc *sch)
1642 } 1629 }
1643 } 1630 }
1644 1631
1645 skb = cl->qdisc->dequeue(cl->qdisc); 1632 skb = qdisc_dequeue_peeked(cl->qdisc);
1646 if (skb == NULL) { 1633 if (skb == NULL) {
1647 if (net_ratelimit()) 1634 if (net_ratelimit())
1648 printk("HFSC: Non-work-conserving qdisc ?\n"); 1635 printk("HFSC: Non-work-conserving qdisc ?\n");
@@ -1667,24 +1654,12 @@ hfsc_dequeue(struct Qdisc *sch)
1667 set_passive(cl); 1654 set_passive(cl);
1668 } 1655 }
1669 1656
1670 out:
1671 sch->flags &= ~TCQ_F_THROTTLED; 1657 sch->flags &= ~TCQ_F_THROTTLED;
1672 sch->q.qlen--; 1658 sch->q.qlen--;
1673 1659
1674 return skb; 1660 return skb;
1675} 1661}
1676 1662
1677static int
1678hfsc_requeue(struct sk_buff *skb, struct Qdisc *sch)
1679{
1680 struct hfsc_sched *q = qdisc_priv(sch);
1681
1682 __skb_queue_head(&q->requeue, skb);
1683 sch->q.qlen++;
1684 sch->qstats.requeues++;
1685 return NET_XMIT_SUCCESS;
1686}
1687
1688static unsigned int 1663static unsigned int
1689hfsc_drop(struct Qdisc *sch) 1664hfsc_drop(struct Qdisc *sch)
1690{ 1665{
@@ -1735,7 +1710,7 @@ static struct Qdisc_ops hfsc_qdisc_ops __read_mostly = {
1735 .dump = hfsc_dump_qdisc, 1710 .dump = hfsc_dump_qdisc,
1736 .enqueue = hfsc_enqueue, 1711 .enqueue = hfsc_enqueue,
1737 .dequeue = hfsc_dequeue, 1712 .dequeue = hfsc_dequeue,
1738 .requeue = hfsc_requeue, 1713 .peek = qdisc_peek_dequeued,
1739 .drop = hfsc_drop, 1714 .drop = hfsc_drop,
1740 .cl_ops = &hfsc_class_ops, 1715 .cl_ops = &hfsc_class_ops,
1741 .priv_size = sizeof(struct hfsc_sched), 1716 .priv_size = sizeof(struct hfsc_sched),
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index d14f02056ae6..3a119f576bb3 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -551,7 +551,7 @@ static inline void htb_deactivate(struct htb_sched *q, struct htb_class *cl)
551 551
552static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch) 552static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch)
553{ 553{
554 int ret; 554 int uninitialized_var(ret);
555 struct htb_sched *q = qdisc_priv(sch); 555 struct htb_sched *q = qdisc_priv(sch);
556 struct htb_class *cl = htb_classify(skb, sch, &ret); 556 struct htb_class *cl = htb_classify(skb, sch, &ret);
557 557
@@ -591,47 +591,6 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch)
591 return NET_XMIT_SUCCESS; 591 return NET_XMIT_SUCCESS;
592} 592}
593 593
594/* TODO: requeuing packet charges it to policers again !! */
595static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch)
596{
597 int ret;
598 struct htb_sched *q = qdisc_priv(sch);
599 struct htb_class *cl = htb_classify(skb, sch, &ret);
600 struct sk_buff *tskb;
601
602 if (cl == HTB_DIRECT) {
603 /* enqueue to helper queue */
604 if (q->direct_queue.qlen < q->direct_qlen) {
605 __skb_queue_head(&q->direct_queue, skb);
606 } else {
607 __skb_queue_head(&q->direct_queue, skb);
608 tskb = __skb_dequeue_tail(&q->direct_queue);
609 kfree_skb(tskb);
610 sch->qstats.drops++;
611 return NET_XMIT_CN;
612 }
613#ifdef CONFIG_NET_CLS_ACT
614 } else if (!cl) {
615 if (ret & __NET_XMIT_BYPASS)
616 sch->qstats.drops++;
617 kfree_skb(skb);
618 return ret;
619#endif
620 } else if ((ret = cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q)) !=
621 NET_XMIT_SUCCESS) {
622 if (net_xmit_drop_count(ret)) {
623 sch->qstats.drops++;
624 cl->qstats.drops++;
625 }
626 return ret;
627 } else
628 htb_activate(q, cl);
629
630 sch->q.qlen++;
631 sch->qstats.requeues++;
632 return NET_XMIT_SUCCESS;
633}
634
635/** 594/**
636 * htb_charge_class - charges amount "bytes" to leaf and ancestors 595 * htb_charge_class - charges amount "bytes" to leaf and ancestors
637 * 596 *
@@ -1141,7 +1100,9 @@ static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
1141 == NULL) 1100 == NULL)
1142 return -ENOBUFS; 1101 return -ENOBUFS;
1143 sch_tree_lock(sch); 1102 sch_tree_lock(sch);
1144 if ((*old = xchg(&cl->un.leaf.q, new)) != NULL) { 1103 *old = cl->un.leaf.q;
1104 cl->un.leaf.q = new;
1105 if (*old != NULL) {
1145 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen); 1106 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
1146 qdisc_reset(*old); 1107 qdisc_reset(*old);
1147 } 1108 }
@@ -1565,7 +1526,7 @@ static struct Qdisc_ops htb_qdisc_ops __read_mostly = {
1565 .priv_size = sizeof(struct htb_sched), 1526 .priv_size = sizeof(struct htb_sched),
1566 .enqueue = htb_enqueue, 1527 .enqueue = htb_enqueue,
1567 .dequeue = htb_dequeue, 1528 .dequeue = htb_dequeue,
1568 .requeue = htb_requeue, 1529 .peek = qdisc_peek_dequeued,
1569 .drop = htb_drop, 1530 .drop = htb_drop,
1570 .init = htb_init, 1531 .init = htb_init,
1571 .reset = htb_reset, 1532 .reset = htb_reset,
diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c
index 915f3149dde2..7e151861794b 100644
--- a/net/sched/sch_multiq.c
+++ b/net/sched/sch_multiq.c
@@ -92,40 +92,6 @@ multiq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
92 return ret; 92 return ret;
93} 93}
94 94
95
96static int
97multiq_requeue(struct sk_buff *skb, struct Qdisc *sch)
98{
99 struct Qdisc *qdisc;
100 struct multiq_sched_data *q = qdisc_priv(sch);
101 int ret;
102
103 qdisc = multiq_classify(skb, sch, &ret);
104#ifdef CONFIG_NET_CLS_ACT
105 if (qdisc == NULL) {
106 if (ret & __NET_XMIT_BYPASS)
107 sch->qstats.drops++;
108 kfree_skb(skb);
109 return ret;
110 }
111#endif
112
113 ret = qdisc->ops->requeue(skb, qdisc);
114 if (ret == NET_XMIT_SUCCESS) {
115 sch->q.qlen++;
116 sch->qstats.requeues++;
117 if (q->curband)
118 q->curband--;
119 else
120 q->curband = q->bands - 1;
121 return NET_XMIT_SUCCESS;
122 }
123 if (net_xmit_drop_count(ret))
124 sch->qstats.drops++;
125 return ret;
126}
127
128
129static struct sk_buff *multiq_dequeue(struct Qdisc *sch) 95static struct sk_buff *multiq_dequeue(struct Qdisc *sch)
130{ 96{
131 struct multiq_sched_data *q = qdisc_priv(sch); 97 struct multiq_sched_data *q = qdisc_priv(sch);
@@ -140,7 +106,7 @@ static struct sk_buff *multiq_dequeue(struct Qdisc *sch)
140 q->curband = 0; 106 q->curband = 0;
141 107
142 /* Check that target subqueue is available before 108 /* Check that target subqueue is available before
143 * pulling an skb to avoid excessive requeues 109 * pulling an skb to avoid head-of-line blocking.
144 */ 110 */
145 if (!__netif_subqueue_stopped(qdisc_dev(sch), q->curband)) { 111 if (!__netif_subqueue_stopped(qdisc_dev(sch), q->curband)) {
146 qdisc = q->queues[q->curband]; 112 qdisc = q->queues[q->curband];
@@ -155,6 +121,34 @@ static struct sk_buff *multiq_dequeue(struct Qdisc *sch)
155 121
156} 122}
157 123
124static struct sk_buff *multiq_peek(struct Qdisc *sch)
125{
126 struct multiq_sched_data *q = qdisc_priv(sch);
127 unsigned int curband = q->curband;
128 struct Qdisc *qdisc;
129 struct sk_buff *skb;
130 int band;
131
132 for (band = 0; band < q->bands; band++) {
133 /* cycle through bands to ensure fairness */
134 curband++;
135 if (curband >= q->bands)
136 curband = 0;
137
138 /* Check that target subqueue is available before
139 * pulling an skb to avoid head-of-line blocking.
140 */
141 if (!__netif_subqueue_stopped(qdisc_dev(sch), curband)) {
142 qdisc = q->queues[curband];
143 skb = qdisc->ops->peek(qdisc);
144 if (skb)
145 return skb;
146 }
147 }
148 return NULL;
149
150}
151
158static unsigned int multiq_drop(struct Qdisc *sch) 152static unsigned int multiq_drop(struct Qdisc *sch)
159{ 153{
160 struct multiq_sched_data *q = qdisc_priv(sch); 154 struct multiq_sched_data *q = qdisc_priv(sch);
@@ -220,7 +214,8 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt)
220 q->bands = qopt->bands; 214 q->bands = qopt->bands;
221 for (i = q->bands; i < q->max_bands; i++) { 215 for (i = q->bands; i < q->max_bands; i++) {
222 if (q->queues[i] != &noop_qdisc) { 216 if (q->queues[i] != &noop_qdisc) {
223 struct Qdisc *child = xchg(&q->queues[i], &noop_qdisc); 217 struct Qdisc *child = q->queues[i];
218 q->queues[i] = &noop_qdisc;
224 qdisc_tree_decrease_qlen(child, child->q.qlen); 219 qdisc_tree_decrease_qlen(child, child->q.qlen);
225 qdisc_destroy(child); 220 qdisc_destroy(child);
226 } 221 }
@@ -230,7 +225,7 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt)
230 225
231 for (i = 0; i < q->bands; i++) { 226 for (i = 0; i < q->bands; i++) {
232 if (q->queues[i] == &noop_qdisc) { 227 if (q->queues[i] == &noop_qdisc) {
233 struct Qdisc *child; 228 struct Qdisc *child, *old;
234 child = qdisc_create_dflt(qdisc_dev(sch), 229 child = qdisc_create_dflt(qdisc_dev(sch),
235 sch->dev_queue, 230 sch->dev_queue,
236 &pfifo_qdisc_ops, 231 &pfifo_qdisc_ops,
@@ -238,12 +233,13 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt)
238 i + 1)); 233 i + 1));
239 if (child) { 234 if (child) {
240 sch_tree_lock(sch); 235 sch_tree_lock(sch);
241 child = xchg(&q->queues[i], child); 236 old = q->queues[i];
237 q->queues[i] = child;
242 238
243 if (child != &noop_qdisc) { 239 if (old != &noop_qdisc) {
244 qdisc_tree_decrease_qlen(child, 240 qdisc_tree_decrease_qlen(old,
245 child->q.qlen); 241 old->q.qlen);
246 qdisc_destroy(child); 242 qdisc_destroy(old);
247 } 243 }
248 sch_tree_unlock(sch); 244 sch_tree_unlock(sch);
249 } 245 }
@@ -451,7 +447,7 @@ static struct Qdisc_ops multiq_qdisc_ops __read_mostly = {
451 .priv_size = sizeof(struct multiq_sched_data), 447 .priv_size = sizeof(struct multiq_sched_data),
452 .enqueue = multiq_enqueue, 448 .enqueue = multiq_enqueue,
453 .dequeue = multiq_dequeue, 449 .dequeue = multiq_dequeue,
454 .requeue = multiq_requeue, 450 .peek = multiq_peek,
455 .drop = multiq_drop, 451 .drop = multiq_drop,
456 .init = multiq_init, 452 .init = multiq_init,
457 .reset = multiq_reset, 453 .reset = multiq_reset,
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index a11959908d9a..f840d6b27c65 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -233,7 +233,11 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
233 */ 233 */
234 cb->time_to_send = psched_get_time(); 234 cb->time_to_send = psched_get_time();
235 q->counter = 0; 235 q->counter = 0;
236 ret = q->qdisc->ops->requeue(skb, q->qdisc); 236
237 __skb_queue_head(&q->qdisc->q, skb);
238 q->qdisc->qstats.backlog += qdisc_pkt_len(skb);
239 q->qdisc->qstats.requeues++;
240 ret = NET_XMIT_SUCCESS;
237 } 241 }
238 242
239 if (likely(ret == NET_XMIT_SUCCESS)) { 243 if (likely(ret == NET_XMIT_SUCCESS)) {
@@ -248,20 +252,6 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
248 return ret; 252 return ret;
249} 253}
250 254
251/* Requeue packets but don't change time stamp */
252static int netem_requeue(struct sk_buff *skb, struct Qdisc *sch)
253{
254 struct netem_sched_data *q = qdisc_priv(sch);
255 int ret;
256
257 if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0) {
258 sch->q.qlen++;
259 sch->qstats.requeues++;
260 }
261
262 return ret;
263}
264
265static unsigned int netem_drop(struct Qdisc* sch) 255static unsigned int netem_drop(struct Qdisc* sch)
266{ 256{
267 struct netem_sched_data *q = qdisc_priv(sch); 257 struct netem_sched_data *q = qdisc_priv(sch);
@@ -283,25 +273,22 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
283 if (sch->flags & TCQ_F_THROTTLED) 273 if (sch->flags & TCQ_F_THROTTLED)
284 return NULL; 274 return NULL;
285 275
286 skb = q->qdisc->dequeue(q->qdisc); 276 skb = q->qdisc->ops->peek(q->qdisc);
287 if (skb) { 277 if (skb) {
288 const struct netem_skb_cb *cb = netem_skb_cb(skb); 278 const struct netem_skb_cb *cb = netem_skb_cb(skb);
289 psched_time_t now = psched_get_time(); 279 psched_time_t now = psched_get_time();
290 280
291 /* if more time remaining? */ 281 /* if more time remaining? */
292 if (cb->time_to_send <= now) { 282 if (cb->time_to_send <= now) {
283 skb = qdisc_dequeue_peeked(q->qdisc);
284 if (unlikely(!skb))
285 return NULL;
286
293 pr_debug("netem_dequeue: return skb=%p\n", skb); 287 pr_debug("netem_dequeue: return skb=%p\n", skb);
294 sch->q.qlen--; 288 sch->q.qlen--;
295 return skb; 289 return skb;
296 } 290 }
297 291
298 if (unlikely(q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS)) {
299 qdisc_tree_decrease_qlen(q->qdisc, 1);
300 sch->qstats.drops++;
301 printk(KERN_ERR "netem: %s could not requeue\n",
302 q->qdisc->ops->id);
303 }
304
305 qdisc_watchdog_schedule(&q->watchdog, cb->time_to_send); 292 qdisc_watchdog_schedule(&q->watchdog, cb->time_to_send);
306 } 293 }
307 294
@@ -344,14 +331,13 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
344 root_lock = qdisc_root_sleeping_lock(sch); 331 root_lock = qdisc_root_sleeping_lock(sch);
345 332
346 spin_lock_bh(root_lock); 333 spin_lock_bh(root_lock);
347 d = xchg(&q->delay_dist, d); 334 kfree(q->delay_dist);
335 q->delay_dist = d;
348 spin_unlock_bh(root_lock); 336 spin_unlock_bh(root_lock);
349
350 kfree(d);
351 return 0; 337 return 0;
352} 338}
353 339
354static int get_correlation(struct Qdisc *sch, const struct nlattr *attr) 340static void get_correlation(struct Qdisc *sch, const struct nlattr *attr)
355{ 341{
356 struct netem_sched_data *q = qdisc_priv(sch); 342 struct netem_sched_data *q = qdisc_priv(sch);
357 const struct tc_netem_corr *c = nla_data(attr); 343 const struct tc_netem_corr *c = nla_data(attr);
@@ -359,27 +345,24 @@ static int get_correlation(struct Qdisc *sch, const struct nlattr *attr)
359 init_crandom(&q->delay_cor, c->delay_corr); 345 init_crandom(&q->delay_cor, c->delay_corr);
360 init_crandom(&q->loss_cor, c->loss_corr); 346 init_crandom(&q->loss_cor, c->loss_corr);
361 init_crandom(&q->dup_cor, c->dup_corr); 347 init_crandom(&q->dup_cor, c->dup_corr);
362 return 0;
363} 348}
364 349
365static int get_reorder(struct Qdisc *sch, const struct nlattr *attr) 350static void get_reorder(struct Qdisc *sch, const struct nlattr *attr)
366{ 351{
367 struct netem_sched_data *q = qdisc_priv(sch); 352 struct netem_sched_data *q = qdisc_priv(sch);
368 const struct tc_netem_reorder *r = nla_data(attr); 353 const struct tc_netem_reorder *r = nla_data(attr);
369 354
370 q->reorder = r->probability; 355 q->reorder = r->probability;
371 init_crandom(&q->reorder_cor, r->correlation); 356 init_crandom(&q->reorder_cor, r->correlation);
372 return 0;
373} 357}
374 358
375static int get_corrupt(struct Qdisc *sch, const struct nlattr *attr) 359static void get_corrupt(struct Qdisc *sch, const struct nlattr *attr)
376{ 360{
377 struct netem_sched_data *q = qdisc_priv(sch); 361 struct netem_sched_data *q = qdisc_priv(sch);
378 const struct tc_netem_corrupt *r = nla_data(attr); 362 const struct tc_netem_corrupt *r = nla_data(attr);
379 363
380 q->corrupt = r->probability; 364 q->corrupt = r->probability;
381 init_crandom(&q->corrupt_cor, r->correlation); 365 init_crandom(&q->corrupt_cor, r->correlation);
382 return 0;
383} 366}
384 367
385static const struct nla_policy netem_policy[TCA_NETEM_MAX + 1] = { 368static const struct nla_policy netem_policy[TCA_NETEM_MAX + 1] = {
@@ -438,11 +421,8 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt)
438 if (q->gap) 421 if (q->gap)
439 q->reorder = ~0; 422 q->reorder = ~0;
440 423
441 if (tb[TCA_NETEM_CORR]) { 424 if (tb[TCA_NETEM_CORR])
442 ret = get_correlation(sch, tb[TCA_NETEM_CORR]); 425 get_correlation(sch, tb[TCA_NETEM_CORR]);
443 if (ret)
444 return ret;
445 }
446 426
447 if (tb[TCA_NETEM_DELAY_DIST]) { 427 if (tb[TCA_NETEM_DELAY_DIST]) {
448 ret = get_dist_table(sch, tb[TCA_NETEM_DELAY_DIST]); 428 ret = get_dist_table(sch, tb[TCA_NETEM_DELAY_DIST]);
@@ -450,17 +430,11 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt)
450 return ret; 430 return ret;
451 } 431 }
452 432
453 if (tb[TCA_NETEM_REORDER]) { 433 if (tb[TCA_NETEM_REORDER])
454 ret = get_reorder(sch, tb[TCA_NETEM_REORDER]); 434 get_reorder(sch, tb[TCA_NETEM_REORDER]);
455 if (ret)
456 return ret;
457 }
458 435
459 if (tb[TCA_NETEM_CORRUPT]) { 436 if (tb[TCA_NETEM_CORRUPT])
460 ret = get_corrupt(sch, tb[TCA_NETEM_CORRUPT]); 437 get_corrupt(sch, tb[TCA_NETEM_CORRUPT]);
461 if (ret)
462 return ret;
463 }
464 438
465 return 0; 439 return 0;
466} 440}
@@ -541,7 +515,7 @@ static struct Qdisc_ops tfifo_qdisc_ops __read_mostly = {
541 .priv_size = sizeof(struct fifo_sched_data), 515 .priv_size = sizeof(struct fifo_sched_data),
542 .enqueue = tfifo_enqueue, 516 .enqueue = tfifo_enqueue,
543 .dequeue = qdisc_dequeue_head, 517 .dequeue = qdisc_dequeue_head,
544 .requeue = qdisc_requeue, 518 .peek = qdisc_peek_head,
545 .drop = qdisc_queue_drop, 519 .drop = qdisc_queue_drop,
546 .init = tfifo_init, 520 .init = tfifo_init,
547 .reset = qdisc_reset_queue, 521 .reset = qdisc_reset_queue,
@@ -624,99 +598,12 @@ nla_put_failure:
624 return -1; 598 return -1;
625} 599}
626 600
627static int netem_dump_class(struct Qdisc *sch, unsigned long cl,
628 struct sk_buff *skb, struct tcmsg *tcm)
629{
630 struct netem_sched_data *q = qdisc_priv(sch);
631
632 if (cl != 1) /* only one class */
633 return -ENOENT;
634
635 tcm->tcm_handle |= TC_H_MIN(1);
636 tcm->tcm_info = q->qdisc->handle;
637
638 return 0;
639}
640
641static int netem_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
642 struct Qdisc **old)
643{
644 struct netem_sched_data *q = qdisc_priv(sch);
645
646 if (new == NULL)
647 new = &noop_qdisc;
648
649 sch_tree_lock(sch);
650 *old = xchg(&q->qdisc, new);
651 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
652 qdisc_reset(*old);
653 sch_tree_unlock(sch);
654
655 return 0;
656}
657
658static struct Qdisc *netem_leaf(struct Qdisc *sch, unsigned long arg)
659{
660 struct netem_sched_data *q = qdisc_priv(sch);
661 return q->qdisc;
662}
663
664static unsigned long netem_get(struct Qdisc *sch, u32 classid)
665{
666 return 1;
667}
668
669static void netem_put(struct Qdisc *sch, unsigned long arg)
670{
671}
672
673static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
674 struct nlattr **tca, unsigned long *arg)
675{
676 return -ENOSYS;
677}
678
679static int netem_delete(struct Qdisc *sch, unsigned long arg)
680{
681 return -ENOSYS;
682}
683
684static void netem_walk(struct Qdisc *sch, struct qdisc_walker *walker)
685{
686 if (!walker->stop) {
687 if (walker->count >= walker->skip)
688 if (walker->fn(sch, 1, walker) < 0) {
689 walker->stop = 1;
690 return;
691 }
692 walker->count++;
693 }
694}
695
696static struct tcf_proto **netem_find_tcf(struct Qdisc *sch, unsigned long cl)
697{
698 return NULL;
699}
700
701static const struct Qdisc_class_ops netem_class_ops = {
702 .graft = netem_graft,
703 .leaf = netem_leaf,
704 .get = netem_get,
705 .put = netem_put,
706 .change = netem_change_class,
707 .delete = netem_delete,
708 .walk = netem_walk,
709 .tcf_chain = netem_find_tcf,
710 .dump = netem_dump_class,
711};
712
713static struct Qdisc_ops netem_qdisc_ops __read_mostly = { 601static struct Qdisc_ops netem_qdisc_ops __read_mostly = {
714 .id = "netem", 602 .id = "netem",
715 .cl_ops = &netem_class_ops,
716 .priv_size = sizeof(struct netem_sched_data), 603 .priv_size = sizeof(struct netem_sched_data),
717 .enqueue = netem_enqueue, 604 .enqueue = netem_enqueue,
718 .dequeue = netem_dequeue, 605 .dequeue = netem_dequeue,
719 .requeue = netem_requeue, 606 .peek = qdisc_peek_dequeued,
720 .drop = netem_drop, 607 .drop = netem_drop,
721 .init = netem_init, 608 .init = netem_init,
722 .reset = netem_reset, 609 .reset = netem_reset,
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index 504a78cdb718..94cecef70145 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -93,34 +93,20 @@ prio_enqueue(struct sk_buff *skb, struct Qdisc *sch)
93 return ret; 93 return ret;
94} 94}
95 95
96 96static struct sk_buff *prio_peek(struct Qdisc *sch)
97static int
98prio_requeue(struct sk_buff *skb, struct Qdisc* sch)
99{ 97{
100 struct Qdisc *qdisc; 98 struct prio_sched_data *q = qdisc_priv(sch);
101 int ret; 99 int prio;
102
103 qdisc = prio_classify(skb, sch, &ret);
104#ifdef CONFIG_NET_CLS_ACT
105 if (qdisc == NULL) {
106 if (ret & __NET_XMIT_BYPASS)
107 sch->qstats.drops++;
108 kfree_skb(skb);
109 return ret;
110 }
111#endif
112 100
113 if ((ret = qdisc->ops->requeue(skb, qdisc)) == NET_XMIT_SUCCESS) { 101 for (prio = 0; prio < q->bands; prio++) {
114 sch->q.qlen++; 102 struct Qdisc *qdisc = q->queues[prio];
115 sch->qstats.requeues++; 103 struct sk_buff *skb = qdisc->ops->peek(qdisc);
116 return NET_XMIT_SUCCESS; 104 if (skb)
105 return skb;
117 } 106 }
118 if (net_xmit_drop_count(ret)) 107 return NULL;
119 sch->qstats.drops++;
120 return ret;
121} 108}
122 109
123
124static struct sk_buff *prio_dequeue(struct Qdisc* sch) 110static struct sk_buff *prio_dequeue(struct Qdisc* sch)
125{ 111{
126 struct prio_sched_data *q = qdisc_priv(sch); 112 struct prio_sched_data *q = qdisc_priv(sch);
@@ -201,7 +187,8 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
201 memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1); 187 memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1);
202 188
203 for (i=q->bands; i<TCQ_PRIO_BANDS; i++) { 189 for (i=q->bands; i<TCQ_PRIO_BANDS; i++) {
204 struct Qdisc *child = xchg(&q->queues[i], &noop_qdisc); 190 struct Qdisc *child = q->queues[i];
191 q->queues[i] = &noop_qdisc;
205 if (child != &noop_qdisc) { 192 if (child != &noop_qdisc) {
206 qdisc_tree_decrease_qlen(child, child->q.qlen); 193 qdisc_tree_decrease_qlen(child, child->q.qlen);
207 qdisc_destroy(child); 194 qdisc_destroy(child);
@@ -211,18 +198,19 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
211 198
212 for (i=0; i<q->bands; i++) { 199 for (i=0; i<q->bands; i++) {
213 if (q->queues[i] == &noop_qdisc) { 200 if (q->queues[i] == &noop_qdisc) {
214 struct Qdisc *child; 201 struct Qdisc *child, *old;
215 child = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue, 202 child = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
216 &pfifo_qdisc_ops, 203 &pfifo_qdisc_ops,
217 TC_H_MAKE(sch->handle, i + 1)); 204 TC_H_MAKE(sch->handle, i + 1));
218 if (child) { 205 if (child) {
219 sch_tree_lock(sch); 206 sch_tree_lock(sch);
220 child = xchg(&q->queues[i], child); 207 old = q->queues[i];
208 q->queues[i] = child;
221 209
222 if (child != &noop_qdisc) { 210 if (old != &noop_qdisc) {
223 qdisc_tree_decrease_qlen(child, 211 qdisc_tree_decrease_qlen(old,
224 child->q.qlen); 212 old->q.qlen);
225 qdisc_destroy(child); 213 qdisc_destroy(old);
226 } 214 }
227 sch_tree_unlock(sch); 215 sch_tree_unlock(sch);
228 } 216 }
@@ -421,7 +409,7 @@ static struct Qdisc_ops prio_qdisc_ops __read_mostly = {
421 .priv_size = sizeof(struct prio_sched_data), 409 .priv_size = sizeof(struct prio_sched_data),
422 .enqueue = prio_enqueue, 410 .enqueue = prio_enqueue,
423 .dequeue = prio_dequeue, 411 .dequeue = prio_dequeue,
424 .requeue = prio_requeue, 412 .peek = prio_peek,
425 .drop = prio_drop, 413 .drop = prio_drop,
426 .init = prio_init, 414 .init = prio_init,
427 .reset = prio_reset, 415 .reset = prio_reset,
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index 5da05839e225..2bdf241f6315 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -108,23 +108,6 @@ congestion_drop:
108 return NET_XMIT_CN; 108 return NET_XMIT_CN;
109} 109}
110 110
111static int red_requeue(struct sk_buff *skb, struct Qdisc* sch)
112{
113 struct red_sched_data *q = qdisc_priv(sch);
114 struct Qdisc *child = q->qdisc;
115 int ret;
116
117 if (red_is_idling(&q->parms))
118 red_end_of_idle_period(&q->parms);
119
120 ret = child->ops->requeue(skb, child);
121 if (likely(ret == NET_XMIT_SUCCESS)) {
122 sch->qstats.requeues++;
123 sch->q.qlen++;
124 }
125 return ret;
126}
127
128static struct sk_buff * red_dequeue(struct Qdisc* sch) 111static struct sk_buff * red_dequeue(struct Qdisc* sch)
129{ 112{
130 struct sk_buff *skb; 113 struct sk_buff *skb;
@@ -140,6 +123,14 @@ static struct sk_buff * red_dequeue(struct Qdisc* sch)
140 return skb; 123 return skb;
141} 124}
142 125
126static struct sk_buff * red_peek(struct Qdisc* sch)
127{
128 struct red_sched_data *q = qdisc_priv(sch);
129 struct Qdisc *child = q->qdisc;
130
131 return child->ops->peek(child);
132}
133
143static unsigned int red_drop(struct Qdisc* sch) 134static unsigned int red_drop(struct Qdisc* sch)
144{ 135{
145 struct red_sched_data *q = qdisc_priv(sch); 136 struct red_sched_data *q = qdisc_priv(sch);
@@ -211,7 +202,8 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
211 q->limit = ctl->limit; 202 q->limit = ctl->limit;
212 if (child) { 203 if (child) {
213 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen); 204 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
214 qdisc_destroy(xchg(&q->qdisc, child)); 205 qdisc_destroy(q->qdisc);
206 q->qdisc = child;
215 } 207 }
216 208
217 red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog, 209 red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog,
@@ -292,7 +284,8 @@ static int red_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
292 new = &noop_qdisc; 284 new = &noop_qdisc;
293 285
294 sch_tree_lock(sch); 286 sch_tree_lock(sch);
295 *old = xchg(&q->qdisc, new); 287 *old = q->qdisc;
288 q->qdisc = new;
296 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen); 289 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
297 qdisc_reset(*old); 290 qdisc_reset(*old);
298 sch_tree_unlock(sch); 291 sch_tree_unlock(sch);
@@ -361,7 +354,7 @@ static struct Qdisc_ops red_qdisc_ops __read_mostly = {
361 .cl_ops = &red_class_ops, 354 .cl_ops = &red_class_ops,
362 .enqueue = red_enqueue, 355 .enqueue = red_enqueue,
363 .dequeue = red_dequeue, 356 .dequeue = red_dequeue,
364 .requeue = red_requeue, 357 .peek = red_peek,
365 .drop = red_drop, 358 .drop = red_drop,
366 .init = red_init, 359 .init = red_init,
367 .reset = red_reset, 360 .reset = red_reset,
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index fe1508ef0d3d..ab8cfee3c9ce 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -329,71 +329,20 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
329 return NET_XMIT_CN; 329 return NET_XMIT_CN;
330} 330}
331 331
332static int 332static struct sk_buff *
333sfq_requeue(struct sk_buff *skb, struct Qdisc *sch) 333sfq_peek(struct Qdisc *sch)
334{ 334{
335 struct sfq_sched_data *q = qdisc_priv(sch); 335 struct sfq_sched_data *q = qdisc_priv(sch);
336 unsigned int hash; 336 sfq_index a;
337 sfq_index x;
338 int ret;
339
340 hash = sfq_classify(skb, sch, &ret);
341 if (hash == 0) {
342 if (ret & __NET_XMIT_BYPASS)
343 sch->qstats.drops++;
344 kfree_skb(skb);
345 return ret;
346 }
347 hash--;
348
349 x = q->ht[hash];
350 if (x == SFQ_DEPTH) {
351 q->ht[hash] = x = q->dep[SFQ_DEPTH].next;
352 q->hash[x] = hash;
353 }
354
355 sch->qstats.backlog += qdisc_pkt_len(skb);
356 __skb_queue_head(&q->qs[x], skb);
357 /* If selected queue has length q->limit+1, this means that
358 * all another queues are empty and we do simple tail drop.
359 * This packet is still requeued at head of queue, tail packet
360 * is dropped.
361 */
362 if (q->qs[x].qlen > q->limit) {
363 skb = q->qs[x].prev;
364 __skb_unlink(skb, &q->qs[x]);
365 sch->qstats.drops++;
366 sch->qstats.backlog -= qdisc_pkt_len(skb);
367 kfree_skb(skb);
368 return NET_XMIT_CN;
369 }
370
371 sfq_inc(q, x);
372 if (q->qs[x].qlen == 1) { /* The flow is new */
373 if (q->tail == SFQ_DEPTH) { /* It is the first flow */
374 q->tail = x;
375 q->next[x] = x;
376 q->allot[x] = q->quantum;
377 } else {
378 q->next[x] = q->next[q->tail];
379 q->next[q->tail] = x;
380 q->tail = x;
381 }
382 }
383 337
384 if (++sch->q.qlen <= q->limit) { 338 /* No active slots */
385 sch->qstats.requeues++; 339 if (q->tail == SFQ_DEPTH)
386 return 0; 340 return NULL;
387 }
388 341
389 sch->qstats.drops++; 342 a = q->next[q->tail];
390 sfq_drop(sch); 343 return skb_peek(&q->qs[a]);
391 return NET_XMIT_CN;
392} 344}
393 345
394
395
396
397static struct sk_buff * 346static struct sk_buff *
398sfq_dequeue(struct Qdisc *sch) 347sfq_dequeue(struct Qdisc *sch)
399{ 348{
@@ -624,7 +573,7 @@ static struct Qdisc_ops sfq_qdisc_ops __read_mostly = {
624 .priv_size = sizeof(struct sfq_sched_data), 573 .priv_size = sizeof(struct sfq_sched_data),
625 .enqueue = sfq_enqueue, 574 .enqueue = sfq_enqueue,
626 .dequeue = sfq_dequeue, 575 .dequeue = sfq_dequeue,
627 .requeue = sfq_requeue, 576 .peek = sfq_peek,
628 .drop = sfq_drop, 577 .drop = sfq_drop,
629 .init = sfq_init, 578 .init = sfq_init,
630 .reset = sfq_reset, 579 .reset = sfq_reset,
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 94c61598b86a..a2f93c09f3cc 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -139,19 +139,6 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch)
139 return 0; 139 return 0;
140} 140}
141 141
142static int tbf_requeue(struct sk_buff *skb, struct Qdisc* sch)
143{
144 struct tbf_sched_data *q = qdisc_priv(sch);
145 int ret;
146
147 if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0) {
148 sch->q.qlen++;
149 sch->qstats.requeues++;
150 }
151
152 return ret;
153}
154
155static unsigned int tbf_drop(struct Qdisc* sch) 142static unsigned int tbf_drop(struct Qdisc* sch)
156{ 143{
157 struct tbf_sched_data *q = qdisc_priv(sch); 144 struct tbf_sched_data *q = qdisc_priv(sch);
@@ -169,7 +156,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
169 struct tbf_sched_data *q = qdisc_priv(sch); 156 struct tbf_sched_data *q = qdisc_priv(sch);
170 struct sk_buff *skb; 157 struct sk_buff *skb;
171 158
172 skb = q->qdisc->dequeue(q->qdisc); 159 skb = q->qdisc->ops->peek(q->qdisc);
173 160
174 if (skb) { 161 if (skb) {
175 psched_time_t now; 162 psched_time_t now;
@@ -192,6 +179,10 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
192 toks -= L2T(q, len); 179 toks -= L2T(q, len);
193 180
194 if ((toks|ptoks) >= 0) { 181 if ((toks|ptoks) >= 0) {
182 skb = qdisc_dequeue_peeked(q->qdisc);
183 if (unlikely(!skb))
184 return NULL;
185
195 q->t_c = now; 186 q->t_c = now;
196 q->tokens = toks; 187 q->tokens = toks;
197 q->ptokens = ptoks; 188 q->ptokens = ptoks;
@@ -214,12 +205,6 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
214 (cf. CSZ, HPFQ, HFSC) 205 (cf. CSZ, HPFQ, HFSC)
215 */ 206 */
216 207
217 if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
218 /* When requeue fails skb is dropped */
219 qdisc_tree_decrease_qlen(q->qdisc, 1);
220 sch->qstats.drops++;
221 }
222
223 sch->qstats.overlimits++; 208 sch->qstats.overlimits++;
224 } 209 }
225 return NULL; 210 return NULL;
@@ -251,6 +236,7 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
251 struct tc_tbf_qopt *qopt; 236 struct tc_tbf_qopt *qopt;
252 struct qdisc_rate_table *rtab = NULL; 237 struct qdisc_rate_table *rtab = NULL;
253 struct qdisc_rate_table *ptab = NULL; 238 struct qdisc_rate_table *ptab = NULL;
239 struct qdisc_rate_table *tmp;
254 struct Qdisc *child = NULL; 240 struct Qdisc *child = NULL;
255 int max_size,n; 241 int max_size,n;
256 242
@@ -299,7 +285,8 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
299 sch_tree_lock(sch); 285 sch_tree_lock(sch);
300 if (child) { 286 if (child) {
301 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen); 287 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
302 qdisc_destroy(xchg(&q->qdisc, child)); 288 qdisc_destroy(q->qdisc);
289 q->qdisc = child;
303 } 290 }
304 q->limit = qopt->limit; 291 q->limit = qopt->limit;
305 q->mtu = qopt->mtu; 292 q->mtu = qopt->mtu;
@@ -307,8 +294,14 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
307 q->buffer = qopt->buffer; 294 q->buffer = qopt->buffer;
308 q->tokens = q->buffer; 295 q->tokens = q->buffer;
309 q->ptokens = q->mtu; 296 q->ptokens = q->mtu;
310 rtab = xchg(&q->R_tab, rtab); 297
311 ptab = xchg(&q->P_tab, ptab); 298 tmp = q->R_tab;
299 q->R_tab = rtab;
300 rtab = tmp;
301
302 tmp = q->P_tab;
303 q->P_tab = ptab;
304 ptab = tmp;
312 sch_tree_unlock(sch); 305 sch_tree_unlock(sch);
313 err = 0; 306 err = 0;
314done: 307done:
@@ -398,7 +391,8 @@ static int tbf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
398 new = &noop_qdisc; 391 new = &noop_qdisc;
399 392
400 sch_tree_lock(sch); 393 sch_tree_lock(sch);
401 *old = xchg(&q->qdisc, new); 394 *old = q->qdisc;
395 q->qdisc = new;
402 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen); 396 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
403 qdisc_reset(*old); 397 qdisc_reset(*old);
404 sch_tree_unlock(sch); 398 sch_tree_unlock(sch);
@@ -469,7 +463,7 @@ static struct Qdisc_ops tbf_qdisc_ops __read_mostly = {
469 .priv_size = sizeof(struct tbf_sched_data), 463 .priv_size = sizeof(struct tbf_sched_data),
470 .enqueue = tbf_enqueue, 464 .enqueue = tbf_enqueue,
471 .dequeue = tbf_dequeue, 465 .dequeue = tbf_dequeue,
472 .requeue = tbf_requeue, 466 .peek = qdisc_peek_dequeued,
473 .drop = tbf_drop, 467 .drop = tbf_drop,
474 .init = tbf_init, 468 .init = tbf_init,
475 .reset = tbf_reset, 469 .reset = tbf_reset,
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index d35ef059abb1..cfc8e7caba62 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -93,16 +93,6 @@ teql_enqueue(struct sk_buff *skb, struct Qdisc* sch)
93 return NET_XMIT_DROP; 93 return NET_XMIT_DROP;
94} 94}
95 95
96static int
97teql_requeue(struct sk_buff *skb, struct Qdisc* sch)
98{
99 struct teql_sched_data *q = qdisc_priv(sch);
100
101 __skb_queue_head(&q->q, skb);
102 sch->qstats.requeues++;
103 return 0;
104}
105
106static struct sk_buff * 96static struct sk_buff *
107teql_dequeue(struct Qdisc* sch) 97teql_dequeue(struct Qdisc* sch)
108{ 98{
@@ -123,6 +113,13 @@ teql_dequeue(struct Qdisc* sch)
123 return skb; 113 return skb;
124} 114}
125 115
116static struct sk_buff *
117teql_peek(struct Qdisc* sch)
118{
119 /* teql is meant to be used as root qdisc */
120 return NULL;
121}
122
126static __inline__ void 123static __inline__ void
127teql_neigh_release(struct neighbour *n) 124teql_neigh_release(struct neighbour *n)
128{ 125{
@@ -433,7 +430,7 @@ static __init void teql_master_setup(struct net_device *dev)
433 430
434 ops->enqueue = teql_enqueue; 431 ops->enqueue = teql_enqueue;
435 ops->dequeue = teql_dequeue; 432 ops->dequeue = teql_dequeue;
436 ops->requeue = teql_requeue; 433 ops->peek = teql_peek;
437 ops->init = teql_qdisc_init; 434 ops->init = teql_qdisc_init;
438 ops->reset = teql_reset; 435 ops->reset = teql_reset;
439 ops->destroy = teql_destroy; 436 ops->destroy = teql_destroy;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 4124bbb99947..ceaa4aa066ea 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -223,10 +223,9 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
223 ipv6_addr_copy(&fl.fl6_dst, rt0->addr); 223 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
224 } 224 }
225 225
226 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, " 226 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n",
227 "src:" NIP6_FMT " dst:" NIP6_FMT "\n",
228 __func__, skb, skb->len, 227 __func__, skb, skb->len,
229 NIP6(fl.fl6_src), NIP6(fl.fl6_dst)); 228 &fl.fl6_src, &fl.fl6_dst);
230 229
231 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); 230 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS);
232 231
@@ -252,23 +251,19 @@ static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
252 fl.oif = daddr->v6.sin6_scope_id; 251 fl.oif = daddr->v6.sin6_scope_id;
253 252
254 253
255 SCTP_DEBUG_PRINTK("%s: DST=" NIP6_FMT " ", 254 SCTP_DEBUG_PRINTK("%s: DST=%pI6 ", __func__, &fl.fl6_dst);
256 __func__, NIP6(fl.fl6_dst));
257 255
258 if (saddr) { 256 if (saddr) {
259 ipv6_addr_copy(&fl.fl6_src, &saddr->v6.sin6_addr); 257 ipv6_addr_copy(&fl.fl6_src, &saddr->v6.sin6_addr);
260 SCTP_DEBUG_PRINTK( 258 SCTP_DEBUG_PRINTK("SRC=%pI6 - ", &fl.fl6_src);
261 "SRC=" NIP6_FMT " - ",
262 NIP6(fl.fl6_src));
263 } 259 }
264 260
265 dst = ip6_route_output(&init_net, NULL, &fl); 261 dst = ip6_route_output(&init_net, NULL, &fl);
266 if (!dst->error) { 262 if (!dst->error) {
267 struct rt6_info *rt; 263 struct rt6_info *rt;
268 rt = (struct rt6_info *)dst; 264 rt = (struct rt6_info *)dst;
269 SCTP_DEBUG_PRINTK( 265 SCTP_DEBUG_PRINTK("rt6_dst:%pI6 rt6_src:%pI6\n",
270 "rt6_dst:" NIP6_FMT " rt6_src:" NIP6_FMT "\n", 266 &rt->rt6i_dst.addr, &rt->rt6i_src.addr);
271 NIP6(rt->rt6i_dst.addr), NIP6(rt->rt6i_src.addr));
272 return dst; 267 return dst;
273 } 268 }
274 SCTP_DEBUG_PRINTK("NO ROUTE\n"); 269 SCTP_DEBUG_PRINTK("NO ROUTE\n");
@@ -314,9 +309,8 @@ static void sctp_v6_get_saddr(struct sctp_sock *sk,
314 __u8 matchlen = 0; 309 __u8 matchlen = 0;
315 __u8 bmatchlen; 310 __u8 bmatchlen;
316 311
317 SCTP_DEBUG_PRINTK("%s: asoc:%p dst:%p " 312 SCTP_DEBUG_PRINTK("%s: asoc:%p dst:%p daddr:%pI6 ",
318 "daddr:" NIP6_FMT " ", 313 __func__, asoc, dst, &daddr->v6.sin6_addr);
319 __func__, asoc, dst, NIP6(daddr->v6.sin6_addr));
320 314
321 if (!asoc) { 315 if (!asoc) {
322 ipv6_dev_get_saddr(sock_net(sctp_opt2sk(sk)), 316 ipv6_dev_get_saddr(sock_net(sctp_opt2sk(sk)),
@@ -324,8 +318,8 @@ static void sctp_v6_get_saddr(struct sctp_sock *sk,
324 &daddr->v6.sin6_addr, 318 &daddr->v6.sin6_addr,
325 inet6_sk(&sk->inet.sk)->srcprefs, 319 inet6_sk(&sk->inet.sk)->srcprefs,
326 &saddr->v6.sin6_addr); 320 &saddr->v6.sin6_addr);
327 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n", 321 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
328 NIP6(saddr->v6.sin6_addr)); 322 &saddr->v6.sin6_addr);
329 return; 323 return;
330 } 324 }
331 325
@@ -353,12 +347,11 @@ static void sctp_v6_get_saddr(struct sctp_sock *sk,
353 347
354 if (baddr) { 348 if (baddr) {
355 memcpy(saddr, baddr, sizeof(union sctp_addr)); 349 memcpy(saddr, baddr, sizeof(union sctp_addr));
356 SCTP_DEBUG_PRINTK("saddr: " NIP6_FMT "\n", 350 SCTP_DEBUG_PRINTK("saddr: %pI6\n", &saddr->v6.sin6_addr);
357 NIP6(saddr->v6.sin6_addr));
358 } else { 351 } else {
359 printk(KERN_ERR "%s: asoc:%p Could not find a valid source " 352 printk(KERN_ERR "%s: asoc:%p Could not find a valid source "
360 "address for the dest:" NIP6_FMT "\n", 353 "address for the dest:%pI6\n",
361 __func__, asoc, NIP6(daddr->v6.sin6_addr)); 354 __func__, asoc, &daddr->v6.sin6_addr);
362 } 355 }
363 356
364 rcu_read_unlock(); 357 rcu_read_unlock();
@@ -727,7 +720,7 @@ static int sctp_v6_is_ce(const struct sk_buff *skb)
727/* Dump the v6 addr to the seq file. */ 720/* Dump the v6 addr to the seq file. */
728static void sctp_v6_seq_dump_addr(struct seq_file *seq, union sctp_addr *addr) 721static void sctp_v6_seq_dump_addr(struct seq_file *seq, union sctp_addr *addr)
729{ 722{
730 seq_printf(seq, NIP6_FMT " ", NIP6(addr->v6.sin6_addr)); 723 seq_printf(seq, "%pI6 ", &addr->v6.sin6_addr);
731} 724}
732 725
733static void sctp_v6_ecn_capable(struct sock *sk) 726static void sctp_v6_ecn_capable(struct sock *sk)
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 0b65354aaf64..a8ca743241ee 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -482,9 +482,8 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
482 if (saddr) 482 if (saddr)
483 fl.fl4_src = saddr->v4.sin_addr.s_addr; 483 fl.fl4_src = saddr->v4.sin_addr.s_addr;
484 484
485 SCTP_DEBUG_PRINTK("%s: DST:%u.%u.%u.%u, SRC:%u.%u.%u.%u - ", 485 SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ",
486 __func__, NIPQUAD(fl.fl4_dst), 486 __func__, &fl.fl4_dst, &fl.fl4_src);
487 NIPQUAD(fl.fl4_src));
488 487
489 if (!ip_route_output_key(&init_net, &rt, &fl)) { 488 if (!ip_route_output_key(&init_net, &rt, &fl)) {
490 dst = &rt->u.dst; 489 dst = &rt->u.dst;
@@ -540,8 +539,8 @@ out_unlock:
540 rcu_read_unlock(); 539 rcu_read_unlock();
541out: 540out:
542 if (dst) 541 if (dst)
543 SCTP_DEBUG_PRINTK("rt_dst:%u.%u.%u.%u, rt_src:%u.%u.%u.%u\n", 542 SCTP_DEBUG_PRINTK("rt_dst:%pI4, rt_src:%pI4\n",
544 NIPQUAD(rt->rt_dst), NIPQUAD(rt->rt_src)); 543 &rt->rt_dst, &rt->rt_src);
545 else 544 else
546 SCTP_DEBUG_PRINTK("NO ROUTE\n"); 545 SCTP_DEBUG_PRINTK("NO ROUTE\n");
547 546
@@ -646,7 +645,7 @@ static void sctp_v4_addr_v4map(struct sctp_sock *sp, union sctp_addr *addr)
646/* Dump the v4 addr to the seq file. */ 645/* Dump the v4 addr to the seq file. */
647static void sctp_v4_seq_dump_addr(struct seq_file *seq, union sctp_addr *addr) 646static void sctp_v4_seq_dump_addr(struct seq_file *seq, union sctp_addr *addr)
648{ 647{
649 seq_printf(seq, "%d.%d.%d.%d ", NIPQUAD(addr->v4.sin_addr)); 648 seq_printf(seq, "%pI4 ", &addr->v4.sin_addr);
650} 649}
651 650
652static void sctp_v4_ecn_capable(struct sock *sk) 651static void sctp_v4_ecn_capable(struct sock *sk)
@@ -866,11 +865,10 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
866{ 865{
867 struct inet_sock *inet = inet_sk(skb->sk); 866 struct inet_sock *inet = inet_sk(skb->sk);
868 867
869 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, " 868 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, src:%pI4, dst:%pI4\n",
870 "src:%u.%u.%u.%u, dst:%u.%u.%u.%u\n",
871 __func__, skb, skb->len, 869 __func__, skb, skb->len,
872 NIPQUAD(skb->rtable->rt_src), 870 &skb->rtable->rt_src,
873 NIPQUAD(skb->rtable->rt_dst)); 871 &skb->rtable->rt_dst);
874 872
875 inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? 873 inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ?
876 IP_PMTUDISC_DO : IP_PMTUDISC_DONT; 874 IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index a6a0ea71ae93..9f2a3eb656e5 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -1123,19 +1123,17 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep,
1123 if (from_addr.sa.sa_family == AF_INET6) { 1123 if (from_addr.sa.sa_family == AF_INET6) {
1124 if (net_ratelimit()) 1124 if (net_ratelimit())
1125 printk(KERN_WARNING 1125 printk(KERN_WARNING
1126 "%s association %p could not find address " 1126 "%s association %p could not find address %pI6\n",
1127 NIP6_FMT "\n",
1128 __func__, 1127 __func__,
1129 asoc, 1128 asoc,
1130 NIP6(from_addr.v6.sin6_addr)); 1129 &from_addr.v6.sin6_addr);
1131 } else { 1130 } else {
1132 if (net_ratelimit()) 1131 if (net_ratelimit())
1133 printk(KERN_WARNING 1132 printk(KERN_WARNING
1134 "%s association %p could not find address " 1133 "%s association %p could not find address %pI4\n",
1135 NIPQUAD_FMT "\n",
1136 __func__, 1134 __func__,
1137 asoc, 1135 asoc,
1138 NIPQUAD(from_addr.v4.sin_addr.s_addr)); 1136 &from_addr.v4.sin_addr.s_addr);
1139 } 1137 }
1140 return SCTP_DISPOSITION_DISCARD; 1138 return SCTP_DISPOSITION_DISCARD;
1141 } 1139 }
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index a1b904529d5e..0c70eff0b757 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3614,6 +3614,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3614 3614
3615 SCTP_DBG_OBJCNT_INC(sock); 3615 SCTP_DBG_OBJCNT_INC(sock);
3616 atomic_inc(&sctp_sockets_allocated); 3616 atomic_inc(&sctp_sockets_allocated);
3617 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
3617 return 0; 3618 return 0;
3618} 3619}
3619 3620
@@ -3628,6 +3629,7 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
3628 ep = sctp_sk(sk)->ep; 3629 ep = sctp_sk(sk)->ep;
3629 sctp_endpoint_free(ep); 3630 sctp_endpoint_free(ep);
3630 atomic_dec(&sctp_sockets_allocated); 3631 atomic_dec(&sctp_sockets_allocated);
3632 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
3631} 3633}
3632 3634
3633/* API 4.1.7 shutdown() - TCP Style Syntax 3635/* API 4.1.7 shutdown() - TCP Style Syntax
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 52910697e104..f58e994e6852 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -63,8 +63,8 @@ static ctl_table sctp_table[] = {
63 .data = &sctp_rto_initial, 63 .data = &sctp_rto_initial,
64 .maxlen = sizeof(unsigned int), 64 .maxlen = sizeof(unsigned int),
65 .mode = 0644, 65 .mode = 0644,
66 .proc_handler = &proc_dointvec_minmax, 66 .proc_handler = proc_dointvec_minmax,
67 .strategy = &sysctl_intvec, 67 .strategy = sysctl_intvec,
68 .extra1 = &one, 68 .extra1 = &one,
69 .extra2 = &timer_max 69 .extra2 = &timer_max
70 }, 70 },
@@ -74,8 +74,8 @@ static ctl_table sctp_table[] = {
74 .data = &sctp_rto_min, 74 .data = &sctp_rto_min,
75 .maxlen = sizeof(unsigned int), 75 .maxlen = sizeof(unsigned int),
76 .mode = 0644, 76 .mode = 0644,
77 .proc_handler = &proc_dointvec_minmax, 77 .proc_handler = proc_dointvec_minmax,
78 .strategy = &sysctl_intvec, 78 .strategy = sysctl_intvec,
79 .extra1 = &one, 79 .extra1 = &one,
80 .extra2 = &timer_max 80 .extra2 = &timer_max
81 }, 81 },
@@ -85,8 +85,8 @@ static ctl_table sctp_table[] = {
85 .data = &sctp_rto_max, 85 .data = &sctp_rto_max,
86 .maxlen = sizeof(unsigned int), 86 .maxlen = sizeof(unsigned int),
87 .mode = 0644, 87 .mode = 0644,
88 .proc_handler = &proc_dointvec_minmax, 88 .proc_handler = proc_dointvec_minmax,
89 .strategy = &sysctl_intvec, 89 .strategy = sysctl_intvec,
90 .extra1 = &one, 90 .extra1 = &one,
91 .extra2 = &timer_max 91 .extra2 = &timer_max
92 }, 92 },
@@ -96,8 +96,8 @@ static ctl_table sctp_table[] = {
96 .data = &sctp_valid_cookie_life, 96 .data = &sctp_valid_cookie_life,
97 .maxlen = sizeof(unsigned int), 97 .maxlen = sizeof(unsigned int),
98 .mode = 0644, 98 .mode = 0644,
99 .proc_handler = &proc_dointvec_minmax, 99 .proc_handler = proc_dointvec_minmax,
100 .strategy = &sysctl_intvec, 100 .strategy = sysctl_intvec,
101 .extra1 = &one, 101 .extra1 = &one,
102 .extra2 = &timer_max 102 .extra2 = &timer_max
103 }, 103 },
@@ -107,8 +107,8 @@ static ctl_table sctp_table[] = {
107 .data = &sctp_max_burst, 107 .data = &sctp_max_burst,
108 .maxlen = sizeof(int), 108 .maxlen = sizeof(int),
109 .mode = 0644, 109 .mode = 0644,
110 .proc_handler = &proc_dointvec_minmax, 110 .proc_handler = proc_dointvec_minmax,
111 .strategy = &sysctl_intvec, 111 .strategy = sysctl_intvec,
112 .extra1 = &zero, 112 .extra1 = &zero,
113 .extra2 = &int_max 113 .extra2 = &int_max
114 }, 114 },
@@ -118,8 +118,8 @@ static ctl_table sctp_table[] = {
118 .data = &sctp_max_retrans_association, 118 .data = &sctp_max_retrans_association,
119 .maxlen = sizeof(int), 119 .maxlen = sizeof(int),
120 .mode = 0644, 120 .mode = 0644,
121 .proc_handler = &proc_dointvec_minmax, 121 .proc_handler = proc_dointvec_minmax,
122 .strategy = &sysctl_intvec, 122 .strategy = sysctl_intvec,
123 .extra1 = &one, 123 .extra1 = &one,
124 .extra2 = &int_max 124 .extra2 = &int_max
125 }, 125 },
@@ -129,8 +129,8 @@ static ctl_table sctp_table[] = {
129 .data = &sctp_sndbuf_policy, 129 .data = &sctp_sndbuf_policy,
130 .maxlen = sizeof(int), 130 .maxlen = sizeof(int),
131 .mode = 0644, 131 .mode = 0644,
132 .proc_handler = &proc_dointvec, 132 .proc_handler = proc_dointvec,
133 .strategy = &sysctl_intvec 133 .strategy = sysctl_intvec
134 }, 134 },
135 { 135 {
136 .ctl_name = NET_SCTP_RCVBUF_POLICY, 136 .ctl_name = NET_SCTP_RCVBUF_POLICY,
@@ -138,8 +138,8 @@ static ctl_table sctp_table[] = {
138 .data = &sctp_rcvbuf_policy, 138 .data = &sctp_rcvbuf_policy,
139 .maxlen = sizeof(int), 139 .maxlen = sizeof(int),
140 .mode = 0644, 140 .mode = 0644,
141 .proc_handler = &proc_dointvec, 141 .proc_handler = proc_dointvec,
142 .strategy = &sysctl_intvec 142 .strategy = sysctl_intvec
143 }, 143 },
144 { 144 {
145 .ctl_name = NET_SCTP_PATH_MAX_RETRANS, 145 .ctl_name = NET_SCTP_PATH_MAX_RETRANS,
@@ -147,8 +147,8 @@ static ctl_table sctp_table[] = {
147 .data = &sctp_max_retrans_path, 147 .data = &sctp_max_retrans_path,
148 .maxlen = sizeof(int), 148 .maxlen = sizeof(int),
149 .mode = 0644, 149 .mode = 0644,
150 .proc_handler = &proc_dointvec_minmax, 150 .proc_handler = proc_dointvec_minmax,
151 .strategy = &sysctl_intvec, 151 .strategy = sysctl_intvec,
152 .extra1 = &one, 152 .extra1 = &one,
153 .extra2 = &int_max 153 .extra2 = &int_max
154 }, 154 },
@@ -158,8 +158,8 @@ static ctl_table sctp_table[] = {
158 .data = &sctp_max_retrans_init, 158 .data = &sctp_max_retrans_init,
159 .maxlen = sizeof(int), 159 .maxlen = sizeof(int),
160 .mode = 0644, 160 .mode = 0644,
161 .proc_handler = &proc_dointvec_minmax, 161 .proc_handler = proc_dointvec_minmax,
162 .strategy = &sysctl_intvec, 162 .strategy = sysctl_intvec,
163 .extra1 = &one, 163 .extra1 = &one,
164 .extra2 = &int_max 164 .extra2 = &int_max
165 }, 165 },
@@ -169,8 +169,8 @@ static ctl_table sctp_table[] = {
169 .data = &sctp_hb_interval, 169 .data = &sctp_hb_interval,
170 .maxlen = sizeof(unsigned int), 170 .maxlen = sizeof(unsigned int),
171 .mode = 0644, 171 .mode = 0644,
172 .proc_handler = &proc_dointvec_minmax, 172 .proc_handler = proc_dointvec_minmax,
173 .strategy = &sysctl_intvec, 173 .strategy = sysctl_intvec,
174 .extra1 = &one, 174 .extra1 = &one,
175 .extra2 = &timer_max 175 .extra2 = &timer_max
176 }, 176 },
@@ -180,8 +180,8 @@ static ctl_table sctp_table[] = {
180 .data = &sctp_cookie_preserve_enable, 180 .data = &sctp_cookie_preserve_enable,
181 .maxlen = sizeof(int), 181 .maxlen = sizeof(int),
182 .mode = 0644, 182 .mode = 0644,
183 .proc_handler = &proc_dointvec, 183 .proc_handler = proc_dointvec,
184 .strategy = &sysctl_intvec 184 .strategy = sysctl_intvec
185 }, 185 },
186 { 186 {
187 .ctl_name = NET_SCTP_RTO_ALPHA, 187 .ctl_name = NET_SCTP_RTO_ALPHA,
@@ -189,8 +189,8 @@ static ctl_table sctp_table[] = {
189 .data = &sctp_rto_alpha, 189 .data = &sctp_rto_alpha,
190 .maxlen = sizeof(int), 190 .maxlen = sizeof(int),
191 .mode = 0444, 191 .mode = 0444,
192 .proc_handler = &proc_dointvec, 192 .proc_handler = proc_dointvec,
193 .strategy = &sysctl_intvec 193 .strategy = sysctl_intvec
194 }, 194 },
195 { 195 {
196 .ctl_name = NET_SCTP_RTO_BETA, 196 .ctl_name = NET_SCTP_RTO_BETA,
@@ -198,8 +198,8 @@ static ctl_table sctp_table[] = {
198 .data = &sctp_rto_beta, 198 .data = &sctp_rto_beta,
199 .maxlen = sizeof(int), 199 .maxlen = sizeof(int),
200 .mode = 0444, 200 .mode = 0444,
201 .proc_handler = &proc_dointvec, 201 .proc_handler = proc_dointvec,
202 .strategy = &sysctl_intvec 202 .strategy = sysctl_intvec
203 }, 203 },
204 { 204 {
205 .ctl_name = NET_SCTP_ADDIP_ENABLE, 205 .ctl_name = NET_SCTP_ADDIP_ENABLE,
@@ -207,8 +207,8 @@ static ctl_table sctp_table[] = {
207 .data = &sctp_addip_enable, 207 .data = &sctp_addip_enable,
208 .maxlen = sizeof(int), 208 .maxlen = sizeof(int),
209 .mode = 0644, 209 .mode = 0644,
210 .proc_handler = &proc_dointvec, 210 .proc_handler = proc_dointvec,
211 .strategy = &sysctl_intvec 211 .strategy = sysctl_intvec
212 }, 212 },
213 { 213 {
214 .ctl_name = NET_SCTP_PRSCTP_ENABLE, 214 .ctl_name = NET_SCTP_PRSCTP_ENABLE,
@@ -216,8 +216,8 @@ static ctl_table sctp_table[] = {
216 .data = &sctp_prsctp_enable, 216 .data = &sctp_prsctp_enable,
217 .maxlen = sizeof(int), 217 .maxlen = sizeof(int),
218 .mode = 0644, 218 .mode = 0644,
219 .proc_handler = &proc_dointvec, 219 .proc_handler = proc_dointvec,
220 .strategy = &sysctl_intvec 220 .strategy = sysctl_intvec
221 }, 221 },
222 { 222 {
223 .ctl_name = NET_SCTP_SACK_TIMEOUT, 223 .ctl_name = NET_SCTP_SACK_TIMEOUT,
@@ -225,8 +225,8 @@ static ctl_table sctp_table[] = {
225 .data = &sctp_sack_timeout, 225 .data = &sctp_sack_timeout,
226 .maxlen = sizeof(long), 226 .maxlen = sizeof(long),
227 .mode = 0644, 227 .mode = 0644,
228 .proc_handler = &proc_dointvec_minmax, 228 .proc_handler = proc_dointvec_minmax,
229 .strategy = &sysctl_intvec, 229 .strategy = sysctl_intvec,
230 .extra1 = &sack_timer_min, 230 .extra1 = &sack_timer_min,
231 .extra2 = &sack_timer_max, 231 .extra2 = &sack_timer_max,
232 }, 232 },
@@ -236,7 +236,7 @@ static ctl_table sctp_table[] = {
236 .data = &sysctl_sctp_mem, 236 .data = &sysctl_sctp_mem,
237 .maxlen = sizeof(sysctl_sctp_mem), 237 .maxlen = sizeof(sysctl_sctp_mem),
238 .mode = 0644, 238 .mode = 0644,
239 .proc_handler = &proc_dointvec, 239 .proc_handler = proc_dointvec,
240 }, 240 },
241 { 241 {
242 .ctl_name = CTL_UNNUMBERED, 242 .ctl_name = CTL_UNNUMBERED,
@@ -244,7 +244,7 @@ static ctl_table sctp_table[] = {
244 .data = &sysctl_sctp_rmem, 244 .data = &sysctl_sctp_rmem,
245 .maxlen = sizeof(sysctl_sctp_rmem), 245 .maxlen = sizeof(sysctl_sctp_rmem),
246 .mode = 0644, 246 .mode = 0644,
247 .proc_handler = &proc_dointvec, 247 .proc_handler = proc_dointvec,
248 }, 248 },
249 { 249 {
250 .ctl_name = CTL_UNNUMBERED, 250 .ctl_name = CTL_UNNUMBERED,
@@ -252,7 +252,7 @@ static ctl_table sctp_table[] = {
252 .data = &sysctl_sctp_wmem, 252 .data = &sysctl_sctp_wmem,
253 .maxlen = sizeof(sysctl_sctp_wmem), 253 .maxlen = sizeof(sysctl_sctp_wmem),
254 .mode = 0644, 254 .mode = 0644,
255 .proc_handler = &proc_dointvec, 255 .proc_handler = proc_dointvec,
256 }, 256 },
257 { 257 {
258 .ctl_name = CTL_UNNUMBERED, 258 .ctl_name = CTL_UNNUMBERED,
@@ -260,8 +260,8 @@ static ctl_table sctp_table[] = {
260 .data = &sctp_auth_enable, 260 .data = &sctp_auth_enable,
261 .maxlen = sizeof(int), 261 .maxlen = sizeof(int),
262 .mode = 0644, 262 .mode = 0644,
263 .proc_handler = &proc_dointvec, 263 .proc_handler = proc_dointvec,
264 .strategy = &sysctl_intvec 264 .strategy = sysctl_intvec
265 }, 265 },
266 { 266 {
267 .ctl_name = CTL_UNNUMBERED, 267 .ctl_name = CTL_UNNUMBERED,
@@ -269,8 +269,8 @@ static ctl_table sctp_table[] = {
269 .data = &sctp_addip_noauth, 269 .data = &sctp_addip_noauth,
270 .maxlen = sizeof(int), 270 .maxlen = sizeof(int),
271 .mode = 0644, 271 .mode = 0644,
272 .proc_handler = &proc_dointvec, 272 .proc_handler = proc_dointvec,
273 .strategy = &sysctl_intvec 273 .strategy = sysctl_intvec
274 }, 274 },
275 { .ctl_name = 0 } 275 { .ctl_name = 0 }
276}; 276};
diff --git a/net/socket.c b/net/socket.c
index 92764d836891..e9d65ea2687e 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -69,7 +69,6 @@
69#include <linux/proc_fs.h> 69#include <linux/proc_fs.h>
70#include <linux/seq_file.h> 70#include <linux/seq_file.h>
71#include <linux/mutex.h> 71#include <linux/mutex.h>
72#include <linux/thread_info.h>
73#include <linux/wanrouter.h> 72#include <linux/wanrouter.h>
74#include <linux/if_bridge.h> 73#include <linux/if_bridge.h>
75#include <linux/if_frad.h> 74#include <linux/if_frad.h>
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 4895c341e46d..3ca518386d15 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -271,15 +271,15 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
271 case AF_INET: { 271 case AF_INET: {
272 struct sockaddr_in *sin = 272 struct sockaddr_in *sin =
273 (struct sockaddr_in *)args->address; 273 (struct sockaddr_in *)args->address;
274 snprintf(servername, sizeof(servername), NIPQUAD_FMT, 274 snprintf(servername, sizeof(servername), "%pI4",
275 NIPQUAD(sin->sin_addr.s_addr)); 275 &sin->sin_addr.s_addr);
276 break; 276 break;
277 } 277 }
278 case AF_INET6: { 278 case AF_INET6: {
279 struct sockaddr_in6 *sin = 279 struct sockaddr_in6 *sin =
280 (struct sockaddr_in6 *)args->address; 280 (struct sockaddr_in6 *)args->address;
281 snprintf(servername, sizeof(servername), NIP6_FMT, 281 snprintf(servername, sizeof(servername), "%pI6",
282 NIP6(sin->sin6_addr)); 282 &sin->sin6_addr);
283 break; 283 break;
284 } 284 }
285 default: 285 default:
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index 41013dd66ac3..03ae007641e4 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -270,10 +270,9 @@ static int rpcb_register_netid4(struct sockaddr_in *address_to_register,
270 char buf[32]; 270 char buf[32];
271 271
272 /* Construct AF_INET universal address */ 272 /* Construct AF_INET universal address */
273 snprintf(buf, sizeof(buf), 273 snprintf(buf, sizeof(buf), "%pI4.%u.%u",
274 NIPQUAD_FMT".%u.%u", 274 &address_to_register->sin_addr.s_addr,
275 NIPQUAD(address_to_register->sin_addr.s_addr), 275 port >> 8, port & 0xff);
276 port >> 8, port & 0xff);
277 map->r_addr = buf; 276 map->r_addr = buf;
278 277
279 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " 278 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with "
@@ -305,9 +304,9 @@ static int rpcb_register_netid6(struct sockaddr_in6 *address_to_register,
305 snprintf(buf, sizeof(buf), "::.%u.%u", 304 snprintf(buf, sizeof(buf), "::.%u.%u",
306 port >> 8, port & 0xff); 305 port >> 8, port & 0xff);
307 else 306 else
308 snprintf(buf, sizeof(buf), NIP6_FMT".%u.%u", 307 snprintf(buf, sizeof(buf), "%pI6.%u.%u",
309 NIP6(address_to_register->sin6_addr), 308 &address_to_register->sin6_addr,
310 port >> 8, port & 0xff); 309 port >> 8, port & 0xff);
311 map->r_addr = buf; 310 map->r_addr = buf;
312 311
313 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " 312 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with "
@@ -422,8 +421,8 @@ int rpcb_getport_sync(struct sockaddr_in *sin, u32 prog, u32 vers, int prot)
422 struct rpc_clnt *rpcb_clnt; 421 struct rpc_clnt *rpcb_clnt;
423 int status; 422 int status;
424 423
425 dprintk("RPC: %s(" NIPQUAD_FMT ", %u, %u, %d)\n", 424 dprintk("RPC: %s(%pI4, %u, %u, %d)\n",
426 __func__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot); 425 __func__, &sin->sin_addr.s_addr, prog, vers, prot);
427 426
428 rpcb_clnt = rpcb_create(NULL, (struct sockaddr *)sin, 427 rpcb_clnt = rpcb_create(NULL, (struct sockaddr *)sin,
429 sizeof(*sin), prot, RPCBVERS_2); 428 sizeof(*sin), prot, RPCBVERS_2);
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index f24800f2c098..82240e6127b2 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -162,13 +162,9 @@ static void ip_map_request(struct cache_detail *cd,
162 struct ip_map *im = container_of(h, struct ip_map, h); 162 struct ip_map *im = container_of(h, struct ip_map, h);
163 163
164 if (ipv6_addr_v4mapped(&(im->m_addr))) { 164 if (ipv6_addr_v4mapped(&(im->m_addr))) {
165 snprintf(text_addr, 20, NIPQUAD_FMT, 165 snprintf(text_addr, 20, "%pI4", &im->m_addr.s6_addr32[3]);
166 ntohl(im->m_addr.s6_addr32[3]) >> 24 & 0xff,
167 ntohl(im->m_addr.s6_addr32[3]) >> 16 & 0xff,
168 ntohl(im->m_addr.s6_addr32[3]) >> 8 & 0xff,
169 ntohl(im->m_addr.s6_addr32[3]) >> 0 & 0xff);
170 } else { 166 } else {
171 snprintf(text_addr, 40, NIP6_FMT, NIP6(im->m_addr)); 167 snprintf(text_addr, 40, "%pI6", &im->m_addr);
172 } 168 }
173 qword_add(bpp, blen, im->m_class); 169 qword_add(bpp, blen, im->m_class);
174 qword_add(bpp, blen, text_addr); 170 qword_add(bpp, blen, text_addr);
@@ -208,13 +204,13 @@ static int ip_map_parse(struct cache_detail *cd,
208 len = qword_get(&mesg, buf, mlen); 204 len = qword_get(&mesg, buf, mlen);
209 if (len <= 0) return -EINVAL; 205 if (len <= 0) return -EINVAL;
210 206
211 if (sscanf(buf, NIPQUAD_FMT "%c", &b1, &b2, &b3, &b4, &c) == 4) { 207 if (sscanf(buf, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) == 4) {
212 addr.s6_addr32[0] = 0; 208 addr.s6_addr32[0] = 0;
213 addr.s6_addr32[1] = 0; 209 addr.s6_addr32[1] = 0;
214 addr.s6_addr32[2] = htonl(0xffff); 210 addr.s6_addr32[2] = htonl(0xffff);
215 addr.s6_addr32[3] = 211 addr.s6_addr32[3] =
216 htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4); 212 htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4);
217 } else if (sscanf(buf, NIP6_FMT "%c", 213 } else if (sscanf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x%c",
218 &b1, &b2, &b3, &b4, &b5, &b6, &b7, &b8, &c) == 8) { 214 &b1, &b2, &b3, &b4, &b5, &b6, &b7, &b8, &c) == 8) {
219 addr.s6_addr16[0] = htons(b1); 215 addr.s6_addr16[0] = htons(b1);
220 addr.s6_addr16[1] = htons(b2); 216 addr.s6_addr16[1] = htons(b2);
@@ -278,16 +274,10 @@ static int ip_map_show(struct seq_file *m,
278 dom = im->m_client->h.name; 274 dom = im->m_client->h.name;
279 275
280 if (ipv6_addr_v4mapped(&addr)) { 276 if (ipv6_addr_v4mapped(&addr)) {
281 seq_printf(m, "%s " NIPQUAD_FMT " %s\n", 277 seq_printf(m, "%s %pI4 %s\n",
282 im->m_class, 278 im->m_class, &addr.s6_addr32[3], dom);
283 ntohl(addr.s6_addr32[3]) >> 24 & 0xff,
284 ntohl(addr.s6_addr32[3]) >> 16 & 0xff,
285 ntohl(addr.s6_addr32[3]) >> 8 & 0xff,
286 ntohl(addr.s6_addr32[3]) >> 0 & 0xff,
287 dom);
288 } else { 279 } else {
289 seq_printf(m, "%s " NIP6_FMT " %s\n", 280 seq_printf(m, "%s %pI6 %s\n", im->m_class, &addr, dom);
290 im->m_class, NIP6(addr), dom);
291 } 281 }
292 return 0; 282 return 0;
293} 283}
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 95293f549e9c..6f7d1f2d2f36 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -250,10 +250,10 @@ static int one_sock_name(char *buf, struct svc_sock *svsk)
250 250
251 switch(svsk->sk_sk->sk_family) { 251 switch(svsk->sk_sk->sk_family) {
252 case AF_INET: 252 case AF_INET:
253 len = sprintf(buf, "ipv4 %s %u.%u.%u.%u %d\n", 253 len = sprintf(buf, "ipv4 %s %pI4 %d\n",
254 svsk->sk_sk->sk_protocol==IPPROTO_UDP? 254 svsk->sk_sk->sk_protocol == IPPROTO_UDP ?
255 "udp" : "tcp", 255 "udp" : "tcp",
256 NIPQUAD(inet_sk(svsk->sk_sk)->rcv_saddr), 256 &inet_sk(svsk->sk_sk)->rcv_saddr,
257 inet_sk(svsk->sk_sk)->num); 257 inet_sk(svsk->sk_sk)->num);
258 break; 258 break;
259 default: 259 default:
diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
index 6fb493cbd29f..f8500f018f8a 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
@@ -1048,21 +1048,21 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
1048 1048
1049 dprintk("svcrdma: new connection %p accepted with the following " 1049 dprintk("svcrdma: new connection %p accepted with the following "
1050 "attributes:\n" 1050 "attributes:\n"
1051 " local_ip : %d.%d.%d.%d\n" 1051 " local_ip : %pI4\n"
1052 " local_port : %d\n" 1052 " local_port : %d\n"
1053 " remote_ip : %d.%d.%d.%d\n" 1053 " remote_ip : %pI4\n"
1054 " remote_port : %d\n" 1054 " remote_port : %d\n"
1055 " max_sge : %d\n" 1055 " max_sge : %d\n"
1056 " sq_depth : %d\n" 1056 " sq_depth : %d\n"
1057 " max_requests : %d\n" 1057 " max_requests : %d\n"
1058 " ord : %d\n", 1058 " ord : %d\n",
1059 newxprt, 1059 newxprt,
1060 NIPQUAD(((struct sockaddr_in *)&newxprt->sc_cm_id-> 1060 &((struct sockaddr_in *)&newxprt->sc_cm_id->
1061 route.addr.src_addr)->sin_addr.s_addr), 1061 route.addr.src_addr)->sin_addr.s_addr,
1062 ntohs(((struct sockaddr_in *)&newxprt->sc_cm_id-> 1062 ntohs(((struct sockaddr_in *)&newxprt->sc_cm_id->
1063 route.addr.src_addr)->sin_port), 1063 route.addr.src_addr)->sin_port),
1064 NIPQUAD(((struct sockaddr_in *)&newxprt->sc_cm_id-> 1064 &((struct sockaddr_in *)&newxprt->sc_cm_id->
1065 route.addr.dst_addr)->sin_addr.s_addr), 1065 route.addr.dst_addr)->sin_addr.s_addr,
1066 ntohs(((struct sockaddr_in *)&newxprt->sc_cm_id-> 1066 ntohs(((struct sockaddr_in *)&newxprt->sc_cm_id->
1067 route.addr.dst_addr)->sin_port), 1067 route.addr.dst_addr)->sin_port),
1068 newxprt->sc_max_sge, 1068 newxprt->sc_max_sge,
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 9839c3d94145..1dd6123070e9 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -174,7 +174,7 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt)
174 174
175 buf = kzalloc(20, GFP_KERNEL); 175 buf = kzalloc(20, GFP_KERNEL);
176 if (buf) 176 if (buf)
177 snprintf(buf, 20, NIPQUAD_FMT, NIPQUAD(addr->sin_addr.s_addr)); 177 snprintf(buf, 20, "%pI4", &addr->sin_addr.s_addr);
178 xprt->address_strings[RPC_DISPLAY_ADDR] = buf; 178 xprt->address_strings[RPC_DISPLAY_ADDR] = buf;
179 179
180 buf = kzalloc(8, GFP_KERNEL); 180 buf = kzalloc(8, GFP_KERNEL);
@@ -186,8 +186,8 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt)
186 186
187 buf = kzalloc(48, GFP_KERNEL); 187 buf = kzalloc(48, GFP_KERNEL);
188 if (buf) 188 if (buf)
189 snprintf(buf, 48, "addr="NIPQUAD_FMT" port=%u proto=%s", 189 snprintf(buf, 48, "addr=%pI4 port=%u proto=%s",
190 NIPQUAD(addr->sin_addr.s_addr), 190 &addr->sin_addr.s_addr,
191 ntohs(addr->sin_port), "rdma"); 191 ntohs(addr->sin_port), "rdma");
192 xprt->address_strings[RPC_DISPLAY_ALL] = buf; 192 xprt->address_strings[RPC_DISPLAY_ALL] = buf;
193 193
@@ -204,8 +204,8 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt)
204 204
205 buf = kzalloc(30, GFP_KERNEL); 205 buf = kzalloc(30, GFP_KERNEL);
206 if (buf) 206 if (buf)
207 snprintf(buf, 30, NIPQUAD_FMT".%u.%u", 207 snprintf(buf, 30, "%pI4.%u.%u",
208 NIPQUAD(addr->sin_addr.s_addr), 208 &addr->sin_addr.s_addr,
209 ntohs(addr->sin_port) >> 8, 209 ntohs(addr->sin_port) >> 8,
210 ntohs(addr->sin_port) & 0xff); 210 ntohs(addr->sin_port) & 0xff);
211 xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf; 211 xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf;
@@ -369,8 +369,8 @@ xprt_setup_rdma(struct xprt_create *args)
369 if (ntohs(sin->sin_port) != 0) 369 if (ntohs(sin->sin_port) != 0)
370 xprt_set_bound(xprt); 370 xprt_set_bound(xprt);
371 371
372 dprintk("RPC: %s: %u.%u.%u.%u:%u\n", __func__, 372 dprintk("RPC: %s: %pI4:%u\n",
373 NIPQUAD(sin->sin_addr.s_addr), ntohs(sin->sin_port)); 373 __func__, &sin->sin_addr.s_addr, ntohs(sin->sin_port));
374 374
375 /* Set max requests */ 375 /* Set max requests */
376 cdata.max_requests = xprt->max_reqs; 376 cdata.max_requests = xprt->max_reqs;
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index a5fef5e6c323..78f7f728ef10 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -323,12 +323,11 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
323 case RDMA_CM_EVENT_DEVICE_REMOVAL: 323 case RDMA_CM_EVENT_DEVICE_REMOVAL:
324 connstate = -ENODEV; 324 connstate = -ENODEV;
325connected: 325connected:
326 dprintk("RPC: %s: %s: %u.%u.%u.%u:%u" 326 dprintk("RPC: %s: %s: %pI4:%u (ep 0x%p event 0x%x)\n",
327 " (ep 0x%p event 0x%x)\n",
328 __func__, 327 __func__,
329 (event->event <= 11) ? conn[event->event] : 328 (event->event <= 11) ? conn[event->event] :
330 "unknown connection error", 329 "unknown connection error",
331 NIPQUAD(addr->sin_addr.s_addr), 330 &addr->sin_addr.s_addr,
332 ntohs(addr->sin_port), 331 ntohs(addr->sin_port),
333 ep, event->event); 332 ep, event->event);
334 atomic_set(&rpcx_to_rdmax(ep->rep_xprt)->rx_buf.rb_credits, 1); 333 atomic_set(&rpcx_to_rdmax(ep->rep_xprt)->rx_buf.rb_credits, 1);
@@ -348,18 +347,17 @@ connected:
348 if (connstate == 1) { 347 if (connstate == 1) {
349 int ird = attr.max_dest_rd_atomic; 348 int ird = attr.max_dest_rd_atomic;
350 int tird = ep->rep_remote_cma.responder_resources; 349 int tird = ep->rep_remote_cma.responder_resources;
351 printk(KERN_INFO "rpcrdma: connection to %u.%u.%u.%u:%u " 350 printk(KERN_INFO "rpcrdma: connection to %pI4:%u "
352 "on %s, memreg %d slots %d ird %d%s\n", 351 "on %s, memreg %d slots %d ird %d%s\n",
353 NIPQUAD(addr->sin_addr.s_addr), 352 &addr->sin_addr.s_addr,
354 ntohs(addr->sin_port), 353 ntohs(addr->sin_port),
355 ia->ri_id->device->name, 354 ia->ri_id->device->name,
356 ia->ri_memreg_strategy, 355 ia->ri_memreg_strategy,
357 xprt->rx_buf.rb_max_requests, 356 xprt->rx_buf.rb_max_requests,
358 ird, ird < 4 && ird < tird / 2 ? " (low!)" : ""); 357 ird, ird < 4 && ird < tird / 2 ? " (low!)" : "");
359 } else if (connstate < 0) { 358 } else if (connstate < 0) {
360 printk(KERN_INFO "rpcrdma: connection to %u.%u.%u.%u:%u " 359 printk(KERN_INFO "rpcrdma: connection to %pI4:%u closed (%d)\n",
361 "closed (%d)\n", 360 &addr->sin_addr.s_addr,
362 NIPQUAD(addr->sin_addr.s_addr),
363 ntohs(addr->sin_port), 361 ntohs(addr->sin_port),
364 connstate); 362 connstate);
365 } 363 }
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 0a50361e3d83..5cbb404c4cdf 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -284,8 +284,7 @@ static void xs_format_ipv4_peer_addresses(struct rpc_xprt *xprt,
284 284
285 buf = kzalloc(20, GFP_KERNEL); 285 buf = kzalloc(20, GFP_KERNEL);
286 if (buf) { 286 if (buf) {
287 snprintf(buf, 20, NIPQUAD_FMT, 287 snprintf(buf, 20, "%pI4", &addr->sin_addr.s_addr);
288 NIPQUAD(addr->sin_addr.s_addr));
289 } 288 }
290 xprt->address_strings[RPC_DISPLAY_ADDR] = buf; 289 xprt->address_strings[RPC_DISPLAY_ADDR] = buf;
291 290
@@ -300,8 +299,8 @@ static void xs_format_ipv4_peer_addresses(struct rpc_xprt *xprt,
300 299
301 buf = kzalloc(48, GFP_KERNEL); 300 buf = kzalloc(48, GFP_KERNEL);
302 if (buf) { 301 if (buf) {
303 snprintf(buf, 48, "addr="NIPQUAD_FMT" port=%u proto=%s", 302 snprintf(buf, 48, "addr=%pI4 port=%u proto=%s",
304 NIPQUAD(addr->sin_addr.s_addr), 303 &addr->sin_addr.s_addr,
305 ntohs(addr->sin_port), 304 ntohs(addr->sin_port),
306 protocol); 305 protocol);
307 } 306 }
@@ -323,8 +322,8 @@ static void xs_format_ipv4_peer_addresses(struct rpc_xprt *xprt,
323 322
324 buf = kzalloc(30, GFP_KERNEL); 323 buf = kzalloc(30, GFP_KERNEL);
325 if (buf) { 324 if (buf) {
326 snprintf(buf, 30, NIPQUAD_FMT".%u.%u", 325 snprintf(buf, 30, "%pI4.%u.%u",
327 NIPQUAD(addr->sin_addr.s_addr), 326 &addr->sin_addr.s_addr,
328 ntohs(addr->sin_port) >> 8, 327 ntohs(addr->sin_port) >> 8,
329 ntohs(addr->sin_port) & 0xff); 328 ntohs(addr->sin_port) & 0xff);
330 } 329 }
@@ -342,8 +341,7 @@ static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt,
342 341
343 buf = kzalloc(40, GFP_KERNEL); 342 buf = kzalloc(40, GFP_KERNEL);
344 if (buf) { 343 if (buf) {
345 snprintf(buf, 40, NIP6_FMT, 344 snprintf(buf, 40, "%pI6",&addr->sin6_addr);
346 NIP6(addr->sin6_addr));
347 } 345 }
348 xprt->address_strings[RPC_DISPLAY_ADDR] = buf; 346 xprt->address_strings[RPC_DISPLAY_ADDR] = buf;
349 347
@@ -358,18 +356,17 @@ static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt,
358 356
359 buf = kzalloc(64, GFP_KERNEL); 357 buf = kzalloc(64, GFP_KERNEL);
360 if (buf) { 358 if (buf) {
361 snprintf(buf, 64, "addr="NIP6_FMT" port=%u proto=%s", 359 snprintf(buf, 64, "addr=%pI6 port=%u proto=%s",
362 NIP6(addr->sin6_addr), 360 &addr->sin6_addr,
363 ntohs(addr->sin6_port), 361 ntohs(addr->sin6_port),
364 protocol); 362 protocol);
365 } 363 }
366 xprt->address_strings[RPC_DISPLAY_ALL] = buf; 364 xprt->address_strings[RPC_DISPLAY_ALL] = buf;
367 365
368 buf = kzalloc(36, GFP_KERNEL); 366 buf = kzalloc(36, GFP_KERNEL);
369 if (buf) { 367 if (buf)
370 snprintf(buf, 36, NIP6_SEQFMT, 368 snprintf(buf, 36, "%pi6", &addr->sin6_addr);
371 NIP6(addr->sin6_addr)); 369
372 }
373 xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf; 370 xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf;
374 371
375 buf = kzalloc(8, GFP_KERNEL); 372 buf = kzalloc(8, GFP_KERNEL);
@@ -381,10 +378,10 @@ static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt,
381 378
382 buf = kzalloc(50, GFP_KERNEL); 379 buf = kzalloc(50, GFP_KERNEL);
383 if (buf) { 380 if (buf) {
384 snprintf(buf, 50, NIP6_FMT".%u.%u", 381 snprintf(buf, 50, "%pI6.%u.%u",
385 NIP6(addr->sin6_addr), 382 &addr->sin6_addr,
386 ntohs(addr->sin6_port) >> 8, 383 ntohs(addr->sin6_port) >> 8,
387 ntohs(addr->sin6_port) & 0xff); 384 ntohs(addr->sin6_port) & 0xff);
388 } 385 }
389 xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf; 386 xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf;
390 387
@@ -1415,8 +1412,8 @@ static int xs_bind4(struct sock_xprt *transport, struct socket *sock)
1415 if (port > last) 1412 if (port > last)
1416 nloop++; 1413 nloop++;
1417 } while (err == -EADDRINUSE && nloop != 2); 1414 } while (err == -EADDRINUSE && nloop != 2);
1418 dprintk("RPC: %s "NIPQUAD_FMT":%u: %s (%d)\n", 1415 dprintk("RPC: %s %pI4:%u: %s (%d)\n",
1419 __func__, NIPQUAD(myaddr.sin_addr), 1416 __func__, &myaddr.sin_addr,
1420 port, err ? "failed" : "ok", err); 1417 port, err ? "failed" : "ok", err);
1421 return err; 1418 return err;
1422} 1419}
@@ -1448,8 +1445,8 @@ static int xs_bind6(struct sock_xprt *transport, struct socket *sock)
1448 if (port > last) 1445 if (port > last)
1449 nloop++; 1446 nloop++;
1450 } while (err == -EADDRINUSE && nloop != 2); 1447 } while (err == -EADDRINUSE && nloop != 2);
1451 dprintk("RPC: xs_bind6 "NIP6_FMT":%u: %s (%d)\n", 1448 dprintk("RPC: xs_bind6 %pI6:%u: %s (%d)\n",
1452 NIP6(myaddr.sin6_addr), port, err ? "failed" : "ok", err); 1449 &myaddr.sin6_addr, port, err ? "failed" : "ok", err);
1453 return err; 1450 return err;
1454} 1451}
1455 1452
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index fe43ef7dd7e3..f72ba774c246 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -243,12 +243,11 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
243static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) 243static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
244{ 244{
245 unchar *addr = (unchar *)&a->dev_addr; 245 unchar *addr = (unchar *)&a->dev_addr;
246 DECLARE_MAC_BUF(mac);
247 246
248 if (str_size < 18) 247 if (str_size < 18)
249 *str_buf = '\0'; 248 *str_buf = '\0';
250 else 249 else
251 sprintf(str_buf, "%s", print_mac(mac, addr)); 250 sprintf(str_buf, "%pM", addr);
252 return str_buf; 251 return str_buf;
253} 252}
254 253
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index cd72e22b132b..acab41a48d67 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -555,7 +555,7 @@ static struct name_seq *nametbl_find_seq(u32 type)
555 struct name_seq *ns; 555 struct name_seq *ns;
556 556
557 dbg("find_seq %u,(%u,0x%x) table = %p, hash[type] = %u\n", 557 dbg("find_seq %u,(%u,0x%x) table = %p, hash[type] = %u\n",
558 type, ntohl(type), type, table.types, hash(type)); 558 type, htonl(type), type, table.types, hash(type));
559 559
560 seq_head = &table.types[hash(type)]; 560 seq_head = &table.types[hash(type)];
561 hlist_for_each_entry(ns, seq_node, seq_head, ns_list) { 561 hlist_for_each_entry(ns, seq_node, seq_head, ns_list) {
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index eb90f77bb0e2..e1ca8f744ca5 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -164,7 +164,7 @@ static inline int unix_our_peer(struct sock *sk, struct sock *osk)
164 164
165static inline int unix_may_send(struct sock *sk, struct sock *osk) 165static inline int unix_may_send(struct sock *sk, struct sock *osk)
166{ 166{
167 return (unix_peer(osk) == NULL || unix_our_peer(sk, osk)); 167 return unix_peer(osk) == NULL || unix_our_peer(sk, osk);
168} 168}
169 169
170static inline int unix_recvq_full(struct sock const *sk) 170static inline int unix_recvq_full(struct sock const *sk)
@@ -197,7 +197,7 @@ static inline void unix_release_addr(struct unix_address *addr)
197 * - if started by zero, it is abstract name. 197 * - if started by zero, it is abstract name.
198 */ 198 */
199 199
200static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp) 200static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned *hashp)
201{ 201{
202 if (len <= sizeof(short) || len > sizeof(*sunaddr)) 202 if (len <= sizeof(short) || len > sizeof(*sunaddr))
203 return -EINVAL; 203 return -EINVAL;
@@ -211,12 +211,12 @@ static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp)
211 * we are guaranteed that it is a valid memory location in our 211 * we are guaranteed that it is a valid memory location in our
212 * kernel address buffer. 212 * kernel address buffer.
213 */ 213 */
214 ((char *)sunaddr)[len]=0; 214 ((char *)sunaddr)[len] = 0;
215 len = strlen(sunaddr->sun_path)+1+sizeof(short); 215 len = strlen(sunaddr->sun_path)+1+sizeof(short);
216 return len; 216 return len;
217 } 217 }
218 218
219 *hashp = unix_hash_fold(csum_partial((char*)sunaddr, len, 0)); 219 *hashp = unix_hash_fold(csum_partial(sunaddr, len, 0));
220 return len; 220 return len;
221} 221}
222 222
@@ -295,8 +295,7 @@ static struct sock *unix_find_socket_byinode(struct net *net, struct inode *i)
295 if (!net_eq(sock_net(s), net)) 295 if (!net_eq(sock_net(s), net))
296 continue; 296 continue;
297 297
298 if(dentry && dentry->d_inode == i) 298 if (dentry && dentry->d_inode == i) {
299 {
300 sock_hold(s); 299 sock_hold(s);
301 goto found; 300 goto found;
302 } 301 }
@@ -354,7 +353,7 @@ static void unix_sock_destructor(struct sock *sk)
354 WARN_ON(!sk_unhashed(sk)); 353 WARN_ON(!sk_unhashed(sk));
355 WARN_ON(sk->sk_socket); 354 WARN_ON(sk->sk_socket);
356 if (!sock_flag(sk, SOCK_DEAD)) { 355 if (!sock_flag(sk, SOCK_DEAD)) {
357 printk("Attempt to release alive unix socket: %p\n", sk); 356 printk(KERN_INFO "Attempt to release alive unix socket: %p\n", sk);
358 return; 357 return;
359 } 358 }
360 359
@@ -362,12 +361,14 @@ static void unix_sock_destructor(struct sock *sk)
362 unix_release_addr(u->addr); 361 unix_release_addr(u->addr);
363 362
364 atomic_dec(&unix_nr_socks); 363 atomic_dec(&unix_nr_socks);
364 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
365#ifdef UNIX_REFCNT_DEBUG 365#ifdef UNIX_REFCNT_DEBUG
366 printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk, atomic_read(&unix_nr_socks)); 366 printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk,
367 atomic_read(&unix_nr_socks));
367#endif 368#endif
368} 369}
369 370
370static int unix_release_sock (struct sock *sk, int embrion) 371static int unix_release_sock(struct sock *sk, int embrion)
371{ 372{
372 struct unix_sock *u = unix_sk(sk); 373 struct unix_sock *u = unix_sk(sk);
373 struct dentry *dentry; 374 struct dentry *dentry;
@@ -392,9 +393,9 @@ static int unix_release_sock (struct sock *sk, int embrion)
392 393
393 wake_up_interruptible_all(&u->peer_wait); 394 wake_up_interruptible_all(&u->peer_wait);
394 395
395 skpair=unix_peer(sk); 396 skpair = unix_peer(sk);
396 397
397 if (skpair!=NULL) { 398 if (skpair != NULL) {
398 if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { 399 if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) {
399 unix_state_lock(skpair); 400 unix_state_lock(skpair);
400 /* No more writes */ 401 /* No more writes */
@@ -414,7 +415,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
414 /* Try to flush out this socket. Throw out buffers at least */ 415 /* Try to flush out this socket. Throw out buffers at least */
415 416
416 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 417 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
417 if (state==TCP_LISTEN) 418 if (state == TCP_LISTEN)
418 unix_release_sock(skb->sk, 1); 419 unix_release_sock(skb->sk, 1);
419 /* passed fds are erased in the kfree_skb hook */ 420 /* passed fds are erased in the kfree_skb hook */
420 kfree_skb(skb); 421 kfree_skb(skb);
@@ -453,11 +454,11 @@ static int unix_listen(struct socket *sock, int backlog)
453 struct unix_sock *u = unix_sk(sk); 454 struct unix_sock *u = unix_sk(sk);
454 455
455 err = -EOPNOTSUPP; 456 err = -EOPNOTSUPP;
456 if (sock->type!=SOCK_STREAM && sock->type!=SOCK_SEQPACKET) 457 if (sock->type != SOCK_STREAM && sock->type != SOCK_SEQPACKET)
457 goto out; /* Only stream/seqpacket sockets accept */ 458 goto out; /* Only stream/seqpacket sockets accept */
458 err = -EINVAL; 459 err = -EINVAL;
459 if (!u->addr) 460 if (!u->addr)
460 goto out; /* No listens on an unbound socket */ 461 goto out; /* No listens on an unbound socket */
461 unix_state_lock(sk); 462 unix_state_lock(sk);
462 if (sk->sk_state != TCP_CLOSE && sk->sk_state != TCP_LISTEN) 463 if (sk->sk_state != TCP_CLOSE && sk->sk_state != TCP_LISTEN)
463 goto out_unlock; 464 goto out_unlock;
@@ -566,9 +567,10 @@ static const struct proto_ops unix_seqpacket_ops = {
566}; 567};
567 568
568static struct proto unix_proto = { 569static struct proto unix_proto = {
569 .name = "UNIX", 570 .name = "UNIX",
570 .owner = THIS_MODULE, 571 .owner = THIS_MODULE,
571 .obj_size = sizeof(struct unix_sock), 572 .sockets_allocated = &unix_nr_socks,
573 .obj_size = sizeof(struct unix_sock),
572}; 574};
573 575
574/* 576/*
@@ -579,7 +581,7 @@ static struct proto unix_proto = {
579 */ 581 */
580static struct lock_class_key af_unix_sk_receive_queue_lock_key; 582static struct lock_class_key af_unix_sk_receive_queue_lock_key;
581 583
582static struct sock * unix_create1(struct net *net, struct socket *sock) 584static struct sock *unix_create1(struct net *net, struct socket *sock)
583{ 585{
584 struct sock *sk = NULL; 586 struct sock *sk = NULL;
585 struct unix_sock *u; 587 struct unix_sock *u;
@@ -592,7 +594,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
592 if (!sk) 594 if (!sk)
593 goto out; 595 goto out;
594 596
595 sock_init_data(sock,sk); 597 sock_init_data(sock, sk);
596 lockdep_set_class(&sk->sk_receive_queue.lock, 598 lockdep_set_class(&sk->sk_receive_queue.lock,
597 &af_unix_sk_receive_queue_lock_key); 599 &af_unix_sk_receive_queue_lock_key);
598 600
@@ -611,6 +613,9 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
611out: 613out:
612 if (sk == NULL) 614 if (sk == NULL)
613 atomic_dec(&unix_nr_socks); 615 atomic_dec(&unix_nr_socks);
616 else
617 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
618
614 return sk; 619 return sk;
615} 620}
616 621
@@ -630,7 +635,7 @@ static int unix_create(struct net *net, struct socket *sock, int protocol)
630 * nothing uses it. 635 * nothing uses it.
631 */ 636 */
632 case SOCK_RAW: 637 case SOCK_RAW:
633 sock->type=SOCK_DGRAM; 638 sock->type = SOCK_DGRAM;
634 case SOCK_DGRAM: 639 case SOCK_DGRAM:
635 sock->ops = &unix_dgram_ops; 640 sock->ops = &unix_dgram_ops;
636 break; 641 break;
@@ -653,7 +658,7 @@ static int unix_release(struct socket *sock)
653 658
654 sock->sk = NULL; 659 sock->sk = NULL;
655 660
656 return unix_release_sock (sk, 0); 661 return unix_release_sock(sk, 0);
657} 662}
658 663
659static int unix_autobind(struct socket *sock) 664static int unix_autobind(struct socket *sock)
@@ -662,7 +667,7 @@ static int unix_autobind(struct socket *sock)
662 struct net *net = sock_net(sk); 667 struct net *net = sock_net(sk);
663 struct unix_sock *u = unix_sk(sk); 668 struct unix_sock *u = unix_sk(sk);
664 static u32 ordernum = 1; 669 static u32 ordernum = 1;
665 struct unix_address * addr; 670 struct unix_address *addr;
666 int err; 671 int err;
667 672
668 mutex_lock(&u->readlock); 673 mutex_lock(&u->readlock);
@@ -681,7 +686,7 @@ static int unix_autobind(struct socket *sock)
681 686
682retry: 687retry:
683 addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short); 688 addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short);
684 addr->hash = unix_hash_fold(csum_partial((void*)addr->name, addr->len, 0)); 689 addr->hash = unix_hash_fold(csum_partial(addr->name, addr->len, 0));
685 690
686 spin_lock(&unix_table_lock); 691 spin_lock(&unix_table_lock);
687 ordernum = (ordernum+1)&0xFFFFF; 692 ordernum = (ordernum+1)&0xFFFFF;
@@ -736,14 +741,14 @@ static struct sock *unix_find_other(struct net *net,
736 741
737 path_put(&path); 742 path_put(&path);
738 743
739 err=-EPROTOTYPE; 744 err = -EPROTOTYPE;
740 if (u->sk_type != type) { 745 if (u->sk_type != type) {
741 sock_put(u); 746 sock_put(u);
742 goto fail; 747 goto fail;
743 } 748 }
744 } else { 749 } else {
745 err = -ECONNREFUSED; 750 err = -ECONNREFUSED;
746 u=unix_find_socket_byname(net, sunname, len, type, hash); 751 u = unix_find_socket_byname(net, sunname, len, type, hash);
747 if (u) { 752 if (u) {
748 struct dentry *dentry; 753 struct dentry *dentry;
749 dentry = unix_sk(u)->dentry; 754 dentry = unix_sk(u)->dentry;
@@ -757,7 +762,7 @@ static struct sock *unix_find_other(struct net *net,
757put_fail: 762put_fail:
758 path_put(&path); 763 path_put(&path);
759fail: 764fail:
760 *error=err; 765 *error = err;
761 return NULL; 766 return NULL;
762} 767}
763 768
@@ -767,8 +772,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
767 struct sock *sk = sock->sk; 772 struct sock *sk = sock->sk;
768 struct net *net = sock_net(sk); 773 struct net *net = sock_net(sk);
769 struct unix_sock *u = unix_sk(sk); 774 struct unix_sock *u = unix_sk(sk);
770 struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; 775 struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
771 struct dentry * dentry = NULL; 776 struct dentry *dentry = NULL;
772 struct nameidata nd; 777 struct nameidata nd;
773 int err; 778 int err;
774 unsigned hash; 779 unsigned hash;
@@ -779,7 +784,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
779 if (sunaddr->sun_family != AF_UNIX) 784 if (sunaddr->sun_family != AF_UNIX)
780 goto out; 785 goto out;
781 786
782 if (addr_len==sizeof(short)) { 787 if (addr_len == sizeof(short)) {
783 err = unix_autobind(sock); 788 err = unix_autobind(sock);
784 goto out; 789 goto out;
785 } 790 }
@@ -875,8 +880,8 @@ out_mknod_unlock:
875 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 880 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
876 path_put(&nd.path); 881 path_put(&nd.path);
877out_mknod_parent: 882out_mknod_parent:
878 if (err==-EEXIST) 883 if (err == -EEXIST)
879 err=-EADDRINUSE; 884 err = -EADDRINUSE;
880 unix_release_addr(addr); 885 unix_release_addr(addr);
881 goto out_up; 886 goto out_up;
882} 887}
@@ -911,7 +916,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
911{ 916{
912 struct sock *sk = sock->sk; 917 struct sock *sk = sock->sk;
913 struct net *net = sock_net(sk); 918 struct net *net = sock_net(sk);
914 struct sockaddr_un *sunaddr=(struct sockaddr_un*)addr; 919 struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;
915 struct sock *other; 920 struct sock *other;
916 unsigned hash; 921 unsigned hash;
917 int err; 922 int err;
@@ -927,7 +932,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
927 goto out; 932 goto out;
928 933
929restart: 934restart:
930 other=unix_find_other(net, sunaddr, alen, sock->type, hash, &err); 935 other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);
931 if (!other) 936 if (!other)
932 goto out; 937 goto out;
933 938
@@ -961,14 +966,14 @@ restart:
961 */ 966 */
962 if (unix_peer(sk)) { 967 if (unix_peer(sk)) {
963 struct sock *old_peer = unix_peer(sk); 968 struct sock *old_peer = unix_peer(sk);
964 unix_peer(sk)=other; 969 unix_peer(sk) = other;
965 unix_state_double_unlock(sk, other); 970 unix_state_double_unlock(sk, other);
966 971
967 if (other != old_peer) 972 if (other != old_peer)
968 unix_dgram_disconnected(sk, old_peer); 973 unix_dgram_disconnected(sk, old_peer);
969 sock_put(old_peer); 974 sock_put(old_peer);
970 } else { 975 } else {
971 unix_peer(sk)=other; 976 unix_peer(sk) = other;
972 unix_state_double_unlock(sk, other); 977 unix_state_double_unlock(sk, other);
973 } 978 }
974 return 0; 979 return 0;
@@ -1004,7 +1009,7 @@ static long unix_wait_for_peer(struct sock *other, long timeo)
1004static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, 1009static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
1005 int addr_len, int flags) 1010 int addr_len, int flags)
1006{ 1011{
1007 struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; 1012 struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
1008 struct sock *sk = sock->sk; 1013 struct sock *sk = sock->sk;
1009 struct net *net = sock_net(sk); 1014 struct net *net = sock_net(sk);
1010 struct unix_sock *u = unix_sk(sk), *newu, *otheru; 1015 struct unix_sock *u = unix_sk(sk), *newu, *otheru;
@@ -1179,13 +1184,13 @@ out:
1179 1184
1180static int unix_socketpair(struct socket *socka, struct socket *sockb) 1185static int unix_socketpair(struct socket *socka, struct socket *sockb)
1181{ 1186{
1182 struct sock *ska=socka->sk, *skb = sockb->sk; 1187 struct sock *ska = socka->sk, *skb = sockb->sk;
1183 1188
1184 /* Join our sockets back to back */ 1189 /* Join our sockets back to back */
1185 sock_hold(ska); 1190 sock_hold(ska);
1186 sock_hold(skb); 1191 sock_hold(skb);
1187 unix_peer(ska)=skb; 1192 unix_peer(ska) = skb;
1188 unix_peer(skb)=ska; 1193 unix_peer(skb) = ska;
1189 ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current); 1194 ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current);
1190 ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid; 1195 ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid;
1191 ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid; 1196 ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid;
@@ -1207,7 +1212,7 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags)
1207 int err; 1212 int err;
1208 1213
1209 err = -EOPNOTSUPP; 1214 err = -EOPNOTSUPP;
1210 if (sock->type!=SOCK_STREAM && sock->type!=SOCK_SEQPACKET) 1215 if (sock->type != SOCK_STREAM && sock->type != SOCK_SEQPACKET)
1211 goto out; 1216 goto out;
1212 1217
1213 err = -EINVAL; 1218 err = -EINVAL;
@@ -1246,7 +1251,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_
1246{ 1251{
1247 struct sock *sk = sock->sk; 1252 struct sock *sk = sock->sk;
1248 struct unix_sock *u; 1253 struct unix_sock *u;
1249 struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; 1254 struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
1250 int err = 0; 1255 int err = 0;
1251 1256
1252 if (peer) { 1257 if (peer) {
@@ -1286,7 +1291,7 @@ static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb)
1286 skb->destructor = sock_wfree; 1291 skb->destructor = sock_wfree;
1287 UNIXCB(skb).fp = NULL; 1292 UNIXCB(skb).fp = NULL;
1288 1293
1289 for (i=scm->fp->count-1; i>=0; i--) 1294 for (i = scm->fp->count-1; i >= 0; i--)
1290 unix_notinflight(scm->fp->fp[i]); 1295 unix_notinflight(scm->fp->fp[i]);
1291} 1296}
1292 1297
@@ -1315,7 +1320,7 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
1315 if (!UNIXCB(skb).fp) 1320 if (!UNIXCB(skb).fp)
1316 return -ENOMEM; 1321 return -ENOMEM;
1317 1322
1318 for (i=scm->fp->count-1; i>=0; i--) 1323 for (i = scm->fp->count-1; i >= 0; i--)
1319 unix_inflight(scm->fp->fp[i]); 1324 unix_inflight(scm->fp->fp[i]);
1320 skb->destructor = unix_destruct_fds; 1325 skb->destructor = unix_destruct_fds;
1321 return 0; 1326 return 0;
@@ -1332,7 +1337,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1332 struct sock *sk = sock->sk; 1337 struct sock *sk = sock->sk;
1333 struct net *net = sock_net(sk); 1338 struct net *net = sock_net(sk);
1334 struct unix_sock *u = unix_sk(sk); 1339 struct unix_sock *u = unix_sk(sk);
1335 struct sockaddr_un *sunaddr=msg->msg_name; 1340 struct sockaddr_un *sunaddr = msg->msg_name;
1336 struct sock *other = NULL; 1341 struct sock *other = NULL;
1337 int namelen = 0; /* fake GCC */ 1342 int namelen = 0; /* fake GCC */
1338 int err; 1343 int err;
@@ -1373,7 +1378,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1373 goto out; 1378 goto out;
1374 1379
1375 skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err); 1380 skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err);
1376 if (skb==NULL) 1381 if (skb == NULL)
1377 goto out; 1382 goto out;
1378 1383
1379 memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); 1384 memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred));
@@ -1385,7 +1390,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1385 unix_get_secdata(siocb->scm, skb); 1390 unix_get_secdata(siocb->scm, skb);
1386 1391
1387 skb_reset_transport_header(skb); 1392 skb_reset_transport_header(skb);
1388 err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); 1393 err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
1389 if (err) 1394 if (err)
1390 goto out_free; 1395 goto out_free;
1391 1396
@@ -1399,7 +1404,7 @@ restart:
1399 1404
1400 other = unix_find_other(net, sunaddr, namelen, sk->sk_type, 1405 other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
1401 hash, &err); 1406 hash, &err);
1402 if (other==NULL) 1407 if (other == NULL)
1403 goto out_free; 1408 goto out_free;
1404 } 1409 }
1405 1410
@@ -1419,7 +1424,7 @@ restart:
1419 err = 0; 1424 err = 0;
1420 unix_state_lock(sk); 1425 unix_state_lock(sk);
1421 if (unix_peer(sk) == other) { 1426 if (unix_peer(sk) == other) {
1422 unix_peer(sk)=NULL; 1427 unix_peer(sk) = NULL;
1423 unix_state_unlock(sk); 1428 unix_state_unlock(sk);
1424 1429
1425 unix_dgram_disconnected(sk, other); 1430 unix_dgram_disconnected(sk, other);
@@ -1485,10 +1490,10 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1485 struct sock_iocb *siocb = kiocb_to_siocb(kiocb); 1490 struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
1486 struct sock *sk = sock->sk; 1491 struct sock *sk = sock->sk;
1487 struct sock *other = NULL; 1492 struct sock *other = NULL;
1488 struct sockaddr_un *sunaddr=msg->msg_name; 1493 struct sockaddr_un *sunaddr = msg->msg_name;
1489 int err,size; 1494 int err, size;
1490 struct sk_buff *skb; 1495 struct sk_buff *skb;
1491 int sent=0; 1496 int sent = 0;
1492 struct scm_cookie tmp_scm; 1497 struct scm_cookie tmp_scm;
1493 1498
1494 if (NULL == siocb->scm) 1499 if (NULL == siocb->scm)
@@ -1515,8 +1520,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1515 if (sk->sk_shutdown & SEND_SHUTDOWN) 1520 if (sk->sk_shutdown & SEND_SHUTDOWN)
1516 goto pipe_err; 1521 goto pipe_err;
1517 1522
1518 while(sent < len) 1523 while (sent < len) {
1519 {
1520 /* 1524 /*
1521 * Optimisation for the fact that under 0.01% of X 1525 * Optimisation for the fact that under 0.01% of X
1522 * messages typically need breaking up. 1526 * messages typically need breaking up.
@@ -1535,9 +1539,10 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1535 * Grab a buffer 1539 * Grab a buffer
1536 */ 1540 */
1537 1541
1538 skb=sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err); 1542 skb = sock_alloc_send_skb(sk, size, msg->msg_flags&MSG_DONTWAIT,
1543 &err);
1539 1544
1540 if (skb==NULL) 1545 if (skb == NULL)
1541 goto out_err; 1546 goto out_err;
1542 1547
1543 /* 1548 /*
@@ -1558,7 +1563,8 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1558 } 1563 }
1559 } 1564 }
1560 1565
1561 if ((err = memcpy_fromiovec(skb_put(skb,size), msg->msg_iov, size)) != 0) { 1566 err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
1567 if (err) {
1562 kfree_skb(skb); 1568 kfree_skb(skb);
1563 goto out_err; 1569 goto out_err;
1564 } 1570 }
@@ -1572,7 +1578,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1572 skb_queue_tail(&other->sk_receive_queue, skb); 1578 skb_queue_tail(&other->sk_receive_queue, skb);
1573 unix_state_unlock(other); 1579 unix_state_unlock(other);
1574 other->sk_data_ready(other, size); 1580 other->sk_data_ready(other, size);
1575 sent+=size; 1581 sent += size;
1576 } 1582 }
1577 1583
1578 scm_destroy(siocb->scm); 1584 scm_destroy(siocb->scm);
@@ -1584,8 +1590,8 @@ pipe_err_free:
1584 unix_state_unlock(other); 1590 unix_state_unlock(other);
1585 kfree_skb(skb); 1591 kfree_skb(skb);
1586pipe_err: 1592pipe_err:
1587 if (sent==0 && !(msg->msg_flags&MSG_NOSIGNAL)) 1593 if (sent == 0 && !(msg->msg_flags&MSG_NOSIGNAL))
1588 send_sig(SIGPIPE,current,0); 1594 send_sig(SIGPIPE, current, 0);
1589 err = -EPIPE; 1595 err = -EPIPE;
1590out_err: 1596out_err:
1591 scm_destroy(siocb->scm); 1597 scm_destroy(siocb->scm);
@@ -1675,13 +1681,10 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
1675 siocb->scm->creds = *UNIXCREDS(skb); 1681 siocb->scm->creds = *UNIXCREDS(skb);
1676 unix_set_secdata(siocb->scm, skb); 1682 unix_set_secdata(siocb->scm, skb);
1677 1683
1678 if (!(flags & MSG_PEEK)) 1684 if (!(flags & MSG_PEEK)) {
1679 {
1680 if (UNIXCB(skb).fp) 1685 if (UNIXCB(skb).fp)
1681 unix_detach_fds(siocb->scm, skb); 1686 unix_detach_fds(siocb->scm, skb);
1682 } 1687 } else {
1683 else
1684 {
1685 /* It is questionable: on PEEK we could: 1688 /* It is questionable: on PEEK we could:
1686 - do not return fds - good, but too simple 8) 1689 - do not return fds - good, but too simple 8)
1687 - return fds, and do not return them on read (old strategy, 1690 - return fds, and do not return them on read (old strategy,
@@ -1702,7 +1705,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
1702 scm_recv(sock, msg, siocb->scm, flags); 1705 scm_recv(sock, msg, siocb->scm, flags);
1703 1706
1704out_free: 1707out_free:
1705 skb_free_datagram(sk,skb); 1708 skb_free_datagram(sk, skb);
1706out_unlock: 1709out_unlock:
1707 mutex_unlock(&u->readlock); 1710 mutex_unlock(&u->readlock);
1708out: 1711out:
@@ -1713,7 +1716,7 @@ out:
1713 * Sleep until data has arrive. But check for races.. 1716 * Sleep until data has arrive. But check for races..
1714 */ 1717 */
1715 1718
1716static long unix_stream_data_wait(struct sock * sk, long timeo) 1719static long unix_stream_data_wait(struct sock *sk, long timeo)
1717{ 1720{
1718 DEFINE_WAIT(wait); 1721 DEFINE_WAIT(wait);
1719 1722
@@ -1751,7 +1754,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1751 struct scm_cookie tmp_scm; 1754 struct scm_cookie tmp_scm;
1752 struct sock *sk = sock->sk; 1755 struct sock *sk = sock->sk;
1753 struct unix_sock *u = unix_sk(sk); 1756 struct unix_sock *u = unix_sk(sk);
1754 struct sockaddr_un *sunaddr=msg->msg_name; 1757 struct sockaddr_un *sunaddr = msg->msg_name;
1755 int copied = 0; 1758 int copied = 0;
1756 int check_creds = 0; 1759 int check_creds = 0;
1757 int target; 1760 int target;
@@ -1782,15 +1785,13 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1782 1785
1783 mutex_lock(&u->readlock); 1786 mutex_lock(&u->readlock);
1784 1787
1785 do 1788 do {
1786 {
1787 int chunk; 1789 int chunk;
1788 struct sk_buff *skb; 1790 struct sk_buff *skb;
1789 1791
1790 unix_state_lock(sk); 1792 unix_state_lock(sk);
1791 skb = skb_dequeue(&sk->sk_receive_queue); 1793 skb = skb_dequeue(&sk->sk_receive_queue);
1792 if (skb==NULL) 1794 if (skb == NULL) {
1793 {
1794 if (copied >= target) 1795 if (copied >= target)
1795 goto unlock; 1796 goto unlock;
1796 1797
@@ -1798,7 +1799,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1798 * POSIX 1003.1g mandates this order. 1799 * POSIX 1003.1g mandates this order.
1799 */ 1800 */
1800 1801
1801 if ((err = sock_error(sk)) != 0) 1802 err = sock_error(sk);
1803 if (err)
1802 goto unlock; 1804 goto unlock;
1803 if (sk->sk_shutdown & RCV_SHUTDOWN) 1805 if (sk->sk_shutdown & RCV_SHUTDOWN)
1804 goto unlock; 1806 goto unlock;
@@ -1825,7 +1827,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1825 1827
1826 if (check_creds) { 1828 if (check_creds) {
1827 /* Never glue messages from different writers */ 1829 /* Never glue messages from different writers */
1828 if (memcmp(UNIXCREDS(skb), &siocb->scm->creds, sizeof(siocb->scm->creds)) != 0) { 1830 if (memcmp(UNIXCREDS(skb), &siocb->scm->creds,
1831 sizeof(siocb->scm->creds)) != 0) {
1829 skb_queue_head(&sk->sk_receive_queue, skb); 1832 skb_queue_head(&sk->sk_receive_queue, skb);
1830 break; 1833 break;
1831 } 1834 }
@@ -1836,8 +1839,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1836 } 1839 }
1837 1840
1838 /* Copy address just once */ 1841 /* Copy address just once */
1839 if (sunaddr) 1842 if (sunaddr) {
1840 {
1841 unix_copy_addr(msg, skb->sk); 1843 unix_copy_addr(msg, skb->sk);
1842 sunaddr = NULL; 1844 sunaddr = NULL;
1843 } 1845 }
@@ -1853,16 +1855,14 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1853 size -= chunk; 1855 size -= chunk;
1854 1856
1855 /* Mark read part of skb as used */ 1857 /* Mark read part of skb as used */
1856 if (!(flags & MSG_PEEK)) 1858 if (!(flags & MSG_PEEK)) {
1857 {
1858 skb_pull(skb, chunk); 1859 skb_pull(skb, chunk);
1859 1860
1860 if (UNIXCB(skb).fp) 1861 if (UNIXCB(skb).fp)
1861 unix_detach_fds(siocb->scm, skb); 1862 unix_detach_fds(siocb->scm, skb);
1862 1863
1863 /* put the skb back if we didn't use it up.. */ 1864 /* put the skb back if we didn't use it up.. */
1864 if (skb->len) 1865 if (skb->len) {
1865 {
1866 skb_queue_head(&sk->sk_receive_queue, skb); 1866 skb_queue_head(&sk->sk_receive_queue, skb);
1867 break; 1867 break;
1868 } 1868 }
@@ -1871,9 +1871,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1871 1871
1872 if (siocb->scm->fp) 1872 if (siocb->scm->fp)
1873 break; 1873 break;
1874 } 1874 } else {
1875 else
1876 {
1877 /* It is questionable, see note in unix_dgram_recvmsg. 1875 /* It is questionable, see note in unix_dgram_recvmsg.
1878 */ 1876 */
1879 if (UNIXCB(skb).fp) 1877 if (UNIXCB(skb).fp)
@@ -1901,7 +1899,7 @@ static int unix_shutdown(struct socket *sock, int mode)
1901 if (mode) { 1899 if (mode) {
1902 unix_state_lock(sk); 1900 unix_state_lock(sk);
1903 sk->sk_shutdown |= mode; 1901 sk->sk_shutdown |= mode;
1904 other=unix_peer(sk); 1902 other = unix_peer(sk);
1905 if (other) 1903 if (other)
1906 sock_hold(other); 1904 sock_hold(other);
1907 unix_state_unlock(sk); 1905 unix_state_unlock(sk);
@@ -1936,16 +1934,15 @@ static int unix_shutdown(struct socket *sock, int mode)
1936static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 1934static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1937{ 1935{
1938 struct sock *sk = sock->sk; 1936 struct sock *sk = sock->sk;
1939 long amount=0; 1937 long amount = 0;
1940 int err; 1938 int err;
1941 1939
1942 switch(cmd) 1940 switch (cmd) {
1943 { 1941 case SIOCOUTQ:
1944 case SIOCOUTQ: 1942 amount = atomic_read(&sk->sk_wmem_alloc);
1945 amount = atomic_read(&sk->sk_wmem_alloc); 1943 err = put_user(amount, (int __user *)arg);
1946 err = put_user(amount, (int __user *)arg); 1944 break;
1947 break; 1945 case SIOCINQ:
1948 case SIOCINQ:
1949 { 1946 {
1950 struct sk_buff *skb; 1947 struct sk_buff *skb;
1951 1948
@@ -1962,21 +1959,21 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1962 } else { 1959 } else {
1963 skb = skb_peek(&sk->sk_receive_queue); 1960 skb = skb_peek(&sk->sk_receive_queue);
1964 if (skb) 1961 if (skb)
1965 amount=skb->len; 1962 amount = skb->len;
1966 } 1963 }
1967 spin_unlock(&sk->sk_receive_queue.lock); 1964 spin_unlock(&sk->sk_receive_queue.lock);
1968 err = put_user(amount, (int __user *)arg); 1965 err = put_user(amount, (int __user *)arg);
1969 break; 1966 break;
1970 } 1967 }
1971 1968
1972 default: 1969 default:
1973 err = -ENOIOCTLCMD; 1970 err = -ENOIOCTLCMD;
1974 break; 1971 break;
1975 } 1972 }
1976 return err; 1973 return err;
1977} 1974}
1978 1975
1979static unsigned int unix_poll(struct file * file, struct socket *sock, poll_table *wait) 1976static unsigned int unix_poll(struct file *file, struct socket *sock, poll_table *wait)
1980{ 1977{
1981 struct sock *sk = sock->sk; 1978 struct sock *sk = sock->sk;
1982 unsigned int mask; 1979 unsigned int mask;
@@ -1998,7 +1995,8 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl
1998 mask |= POLLIN | POLLRDNORM; 1995 mask |= POLLIN | POLLRDNORM;
1999 1996
2000 /* Connection-based need to check for termination and startup */ 1997 /* Connection-based need to check for termination and startup */
2001 if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) && sk->sk_state == TCP_CLOSE) 1998 if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) &&
1999 sk->sk_state == TCP_CLOSE)
2002 mask |= POLLHUP; 2000 mask |= POLLHUP;
2003 2001
2004 /* 2002 /*
@@ -2094,6 +2092,7 @@ struct unix_iter_state {
2094 struct seq_net_private p; 2092 struct seq_net_private p;
2095 int i; 2093 int i;
2096}; 2094};
2095
2097static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos) 2096static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
2098{ 2097{
2099 struct unix_iter_state *iter = seq->private; 2098 struct unix_iter_state *iter = seq->private;
@@ -2110,7 +2109,6 @@ static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
2110 return NULL; 2109 return NULL;
2111} 2110}
2112 2111
2113
2114static void *unix_seq_start(struct seq_file *seq, loff_t *pos) 2112static void *unix_seq_start(struct seq_file *seq, loff_t *pos)
2115 __acquires(unix_table_lock) 2113 __acquires(unix_table_lock)
2116{ 2114{
@@ -2190,7 +2188,6 @@ static const struct seq_operations unix_seq_ops = {
2190 .show = unix_seq_show, 2188 .show = unix_seq_show,
2191}; 2189};
2192 2190
2193
2194static int unix_seq_open(struct inode *inode, struct file *file) 2191static int unix_seq_open(struct inode *inode, struct file *file)
2195{ 2192{
2196 return seq_open_net(inode, file, &unix_seq_ops, 2193 return seq_open_net(inode, file, &unix_seq_ops,
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 6d4a9a8de5ef..5a0061d6b9bc 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -104,8 +104,8 @@ static struct sock *unix_get_socket(struct file *filp)
104 * Socket ? 104 * Socket ?
105 */ 105 */
106 if (S_ISSOCK(inode->i_mode)) { 106 if (S_ISSOCK(inode->i_mode)) {
107 struct socket * sock = SOCKET_I(inode); 107 struct socket *sock = SOCKET_I(inode);
108 struct sock * s = sock->sk; 108 struct sock *s = sock->sk;
109 109
110 /* 110 /*
111 * PF_UNIX ? 111 * PF_UNIX ?
@@ -124,7 +124,7 @@ static struct sock *unix_get_socket(struct file *filp)
124void unix_inflight(struct file *fp) 124void unix_inflight(struct file *fp)
125{ 125{
126 struct sock *s = unix_get_socket(fp); 126 struct sock *s = unix_get_socket(fp);
127 if(s) { 127 if (s) {
128 struct unix_sock *u = unix_sk(s); 128 struct unix_sock *u = unix_sk(s);
129 spin_lock(&unix_gc_lock); 129 spin_lock(&unix_gc_lock);
130 if (atomic_long_inc_return(&u->inflight) == 1) { 130 if (atomic_long_inc_return(&u->inflight) == 1) {
@@ -141,7 +141,7 @@ void unix_inflight(struct file *fp)
141void unix_notinflight(struct file *fp) 141void unix_notinflight(struct file *fp)
142{ 142{
143 struct sock *s = unix_get_socket(fp); 143 struct sock *s = unix_get_socket(fp);
144 if(s) { 144 if (s) {
145 struct unix_sock *u = unix_sk(s); 145 struct unix_sock *u = unix_sk(s);
146 spin_lock(&unix_gc_lock); 146 spin_lock(&unix_gc_lock);
147 BUG_ON(list_empty(&u->link)); 147 BUG_ON(list_empty(&u->link));
@@ -154,7 +154,7 @@ void unix_notinflight(struct file *fp)
154 154
155static inline struct sk_buff *sock_queue_head(struct sock *sk) 155static inline struct sk_buff *sock_queue_head(struct sock *sk)
156{ 156{
157 return (struct sk_buff *) &sk->sk_receive_queue; 157 return (struct sk_buff *)&sk->sk_receive_queue;
158} 158}
159 159
160#define receive_queue_for_each_skb(sk, next, skb) \ 160#define receive_queue_for_each_skb(sk, next, skb) \
@@ -364,7 +364,7 @@ void unix_gc(void)
364 */ 364 */
365 skb_queue_head_init(&hitlist); 365 skb_queue_head_init(&hitlist);
366 list_for_each_entry(u, &gc_candidates, link) 366 list_for_each_entry(u, &gc_candidates, link)
367 scan_children(&u->sk, inc_inflight, &hitlist); 367 scan_children(&u->sk, inc_inflight, &hitlist);
368 368
369 spin_unlock(&unix_gc_lock); 369 spin_unlock(&unix_gc_lock);
370 370
diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
index 77513d7e35f2..83c093077ebc 100644
--- a/net/unix/sysctl_net_unix.c
+++ b/net/unix/sysctl_net_unix.c
@@ -21,7 +21,7 @@ static ctl_table unix_table[] = {
21 .data = &init_net.unx.sysctl_max_dgram_qlen, 21 .data = &init_net.unx.sysctl_max_dgram_qlen,
22 .maxlen = sizeof(int), 22 .maxlen = sizeof(int),
23 .mode = 0644, 23 .mode = 0644,
24 .proc_handler = &proc_dointvec 24 .proc_handler = proc_dointvec
25 }, 25 },
26 { .ctl_name = 0 } 26 { .ctl_name = 0 }
27}; 27};
@@ -61,4 +61,3 @@ void unix_sysctl_unregister(struct net *net)
61 unregister_sysctl_table(net->unx.ctl); 61 unregister_sysctl_table(net->unx.ctl);
62 kfree(table); 62 kfree(table);
63} 63}
64
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index 7f07152bc109..39701dec1dba 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -60,6 +60,8 @@
60 60
61#define KMEM_SAFETYZONE 8 61#define KMEM_SAFETYZONE 8
62 62
63#define DEV_TO_SLAVE(dev) (*((struct net_device **)netdev_priv(dev)))
64
63/* 65/*
64 * Function Prototypes 66 * Function Prototypes
65 */ 67 */
@@ -511,7 +513,7 @@ static int wanrouter_device_shutdown(struct wan_device *wandev)
511 if (err) 513 if (err)
512 return err; 514 return err;
513 /* The above function deallocates the current dev 515 /* The above function deallocates the current dev
514 * structure. Therefore, we cannot use dev->priv 516 * structure. Therefore, we cannot use netdev_priv(dev)
515 * as the next element: wandev->dev points to the 517 * as the next element: wandev->dev points to the
516 * next element */ 518 * next element */
517 dev = wandev->dev; 519 dev = wandev->dev;
@@ -589,10 +591,6 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
589 err = -EPROTONOSUPPORT; 591 err = -EPROTONOSUPPORT;
590 goto out; 592 goto out;
591 } else { 593 } else {
592 dev = kzalloc(sizeof(struct net_device), GFP_KERNEL);
593 err = -ENOBUFS;
594 if (dev == NULL)
595 goto out;
596 err = wandev->new_if(wandev, dev, cnf); 594 err = wandev->new_if(wandev, dev, cnf);
597 } 595 }
598 596
@@ -622,10 +620,9 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
622 wandev->dev = dev; 620 wandev->dev = dev;
623 } else { 621 } else {
624 for (slave=wandev->dev; 622 for (slave=wandev->dev;
625 *((struct net_device **)slave->priv); 623 DEV_TO_SLAVE(slave);
626 slave = *((struct net_device **)slave->priv)); 624 slave = DEV_TO_SLAVE(slave))
627 625 DEV_TO_SLAVE(slave) = dev;
628 *((struct net_device **)slave->priv) = dev;
629 } 626 }
630 ++wandev->ndev; 627 ++wandev->ndev;
631 628
@@ -636,15 +633,9 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
636 } 633 }
637 if (wandev->del_if) 634 if (wandev->del_if)
638 wandev->del_if(wandev, dev); 635 wandev->del_if(wandev, dev);
636 free_netdev(dev);
639 } 637 }
640 638
641 /* This code has moved from del_if() function */
642 kfree(dev->priv);
643 dev->priv = NULL;
644
645 /* Sync PPP is disabled */
646 if (cnf->config_id != WANCONFIG_MPPP)
647 kfree(dev);
648out: 639out:
649 kfree(cnf); 640 kfree(cnf);
650 return err; 641 return err;
@@ -734,7 +725,7 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
734 dev = wandev->dev; 725 dev = wandev->dev;
735 prev = NULL; 726 prev = NULL;
736 while (dev && strcmp(name, dev->name)) { 727 while (dev && strcmp(name, dev->name)) {
737 struct net_device **slave = dev->priv; 728 struct net_device **slave = netdev_priv(dev);
738 prev = dev; 729 prev = dev;
739 dev = *slave; 730 dev = *slave;
740 } 731 }
@@ -751,12 +742,12 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
751 742
752 lock_adapter_irq(&wandev->lock, &smp_flags); 743 lock_adapter_irq(&wandev->lock, &smp_flags);
753 if (prev) { 744 if (prev) {
754 struct net_device **prev_slave = prev->priv; 745 struct net_device **prev_slave = netdev_priv(prev);
755 struct net_device **slave = dev->priv; 746 struct net_device **slave = netdev_priv(dev);
756 747
757 *prev_slave = *slave; 748 *prev_slave = *slave;
758 } else { 749 } else {
759 struct net_device **slave = dev->priv; 750 struct net_device **slave = netdev_priv(dev);
760 wandev->dev = *slave; 751 wandev->dev = *slave;
761 } 752 }
762 --wandev->ndev; 753 --wandev->ndev;
@@ -764,11 +755,6 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
764 755
765 printk(KERN_INFO "%s: unregistering '%s'\n", wandev->name, dev->name); 756 printk(KERN_INFO "%s: unregistering '%s'\n", wandev->name, dev->name);
766 757
767 /* Due to new interface linking method using dev->priv,
768 * this code has moved from del_if() function.*/
769 kfree(dev->priv);
770 dev->priv=NULL;
771
772 unregister_netdev(dev); 758 unregister_netdev(dev);
773 759
774 free_netdev(dev); 760 free_netdev(dev);
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig
index 646c7121dbc0..ae7f2262dfb5 100644
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -72,3 +72,13 @@ config WIRELESS_EXT_SYSFS
72 72
73 Say Y if you have programs using it, like old versions of 73 Say Y if you have programs using it, like old versions of
74 hal. 74 hal.
75
76config LIB80211
77 tristate "Common routines for IEEE802.11 drivers"
78 default n
79 help
80 This options enables a library of common routines used
81 by IEEE802.11 wireless LAN drivers.
82
83 Drivers should select this themselves if needed. Say Y if
84 you want this built into your kernel.
diff --git a/net/wireless/Makefile b/net/wireless/Makefile
index b9f943c45f3b..d2d848d445f2 100644
--- a/net/wireless/Makefile
+++ b/net/wireless/Makefile
@@ -1,5 +1,6 @@
1obj-$(CONFIG_WIRELESS_EXT) += wext.o 1obj-$(CONFIG_WIRELESS_EXT) += wext.o
2obj-$(CONFIG_CFG80211) += cfg80211.o 2obj-$(CONFIG_CFG80211) += cfg80211.o
3obj-$(CONFIG_LIB80211) += lib80211.o
3 4
4cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o 5cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o
5cfg80211-$(CONFIG_NL80211) += nl80211.o 6cfg80211-$(CONFIG_NL80211) += nl80211.o
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 5031db7b275b..39e3d10fccde 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -236,8 +236,7 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
236 mutex_unlock(&cfg80211_drv_mutex); 236 mutex_unlock(&cfg80211_drv_mutex);
237 237
238 /* give it a proper name */ 238 /* give it a proper name */
239 snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE, 239 dev_set_name(&drv->wiphy.dev, PHY_NAME "%d", drv->idx);
240 PHY_NAME "%d", drv->idx);
241 240
242 mutex_init(&drv->mtx); 241 mutex_init(&drv->mtx);
243 mutex_init(&drv->devlist_mtx); 242 mutex_init(&drv->devlist_mtx);
@@ -301,12 +300,10 @@ int wiphy_register(struct wiphy *wiphy)
301 /* check and set up bitrates */ 300 /* check and set up bitrates */
302 ieee80211_set_bitrate_flags(wiphy); 301 ieee80211_set_bitrate_flags(wiphy);
303 302
303 mutex_lock(&cfg80211_drv_mutex);
304
304 /* set up regulatory info */ 305 /* set up regulatory info */
305 mutex_lock(&cfg80211_reg_mutex);
306 wiphy_update_regulatory(wiphy, REGDOM_SET_BY_CORE); 306 wiphy_update_regulatory(wiphy, REGDOM_SET_BY_CORE);
307 mutex_unlock(&cfg80211_reg_mutex);
308
309 mutex_lock(&cfg80211_drv_mutex);
310 307
311 res = device_add(&drv->wiphy.dev); 308 res = device_add(&drv->wiphy.dev);
312 if (res) 309 if (res)
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
new file mode 100644
index 000000000000..e71f7d085621
--- /dev/null
+++ b/net/wireless/lib80211.c
@@ -0,0 +1,65 @@
1/*
2 * lib80211 -- common bits for IEEE802.11 drivers
3 *
4 * Copyright(c) 2008 John W. Linville <linville@tuxdriver.com>
5 *
6 */
7
8#include <linux/module.h>
9#include <linux/ctype.h>
10#include <linux/ieee80211.h>
11
12#include <net/lib80211.h>
13
14#define DRV_NAME "lib80211"
15
16#define DRV_DESCRIPTION "common routines for IEEE802.11 drivers"
17
18MODULE_DESCRIPTION(DRV_DESCRIPTION);
19MODULE_AUTHOR("John W. Linville <linville@tuxdriver.com>");
20MODULE_LICENSE("GPL");
21
22const char *print_ssid(char *buf, const char *ssid, u8 ssid_len)
23{
24 const char *s = ssid;
25 char *d = buf;
26
27 ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN);
28 while (ssid_len--) {
29 if (isprint(*s)) {
30 *d++ = *s++;
31 continue;
32 }
33
34 *d++ = '\\';
35 if (*s == '\0')
36 *d++ = '0';
37 else if (*s == '\n')
38 *d++ = 'n';
39 else if (*s == '\r')
40 *d++ = 'r';
41 else if (*s == '\t')
42 *d++ = 't';
43 else if (*s == '\\')
44 *d++ = '\\';
45 else
46 d += snprintf(d, 3, "%03o", *s);
47 s++;
48 }
49 *d = '\0';
50 return buf;
51}
52EXPORT_SYMBOL(print_ssid);
53
54static int __init ieee80211_init(void)
55{
56 printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION "\n");
57 return 0;
58}
59
60static void __exit ieee80211_exit(void)
61{
62}
63
64module_init(ieee80211_init);
65module_exit(ieee80211_exit);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 572793c8c7ab..e3e1494e769a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -58,6 +58,7 @@ static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = {
58 [NL80211_ATTR_WIPHY] = { .type = NLA_U32 }, 58 [NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
59 [NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING, 59 [NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING,
60 .len = BUS_ID_SIZE-1 }, 60 .len = BUS_ID_SIZE-1 },
61 [NL80211_ATTR_WIPHY_TXQ_PARAMS] = { .type = NLA_NESTED },
61 62
62 [NL80211_ATTR_IFTYPE] = { .type = NLA_U32 }, 63 [NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
63 [NL80211_ATTR_IFINDEX] = { .type = NLA_U32 }, 64 [NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
@@ -84,7 +85,7 @@ static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = {
84 .len = NL80211_MAX_SUPP_RATES }, 85 .len = NL80211_MAX_SUPP_RATES },
85 [NL80211_ATTR_STA_PLINK_ACTION] = { .type = NLA_U8 }, 86 [NL80211_ATTR_STA_PLINK_ACTION] = { .type = NLA_U8 },
86 [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 }, 87 [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 },
87 [NL80211_ATTR_MNTR_FLAGS] = { .type = NLA_NESTED }, 88 [NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ },
88 [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY, 89 [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY,
89 .len = IEEE80211_MAX_MESH_ID_LEN }, 90 .len = IEEE80211_MAX_MESH_ID_LEN },
90 [NL80211_ATTR_MPATH_NEXT_HOP] = { .type = NLA_U32 }, 91 [NL80211_ATTR_MPATH_NEXT_HOP] = { .type = NLA_U32 },
@@ -95,6 +96,10 @@ static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = {
95 [NL80211_ATTR_BSS_CTS_PROT] = { .type = NLA_U8 }, 96 [NL80211_ATTR_BSS_CTS_PROT] = { .type = NLA_U8 },
96 [NL80211_ATTR_BSS_SHORT_PREAMBLE] = { .type = NLA_U8 }, 97 [NL80211_ATTR_BSS_SHORT_PREAMBLE] = { .type = NLA_U8 },
97 [NL80211_ATTR_BSS_SHORT_SLOT_TIME] = { .type = NLA_U8 }, 98 [NL80211_ATTR_BSS_SHORT_SLOT_TIME] = { .type = NLA_U8 },
99 [NL80211_ATTR_BSS_BASIC_RATES] = { .type = NLA_BINARY,
100 .len = NL80211_MAX_SUPP_RATES },
101
102 [NL80211_ATTR_MESH_PARAMS] = { .type = NLA_NESTED },
98 103
99 [NL80211_ATTR_HT_CAPABILITY] = { .type = NLA_BINARY, 104 [NL80211_ATTR_HT_CAPABILITY] = { .type = NLA_BINARY,
100 .len = NL80211_HT_CAPABILITY_LEN }, 105 .len = NL80211_HT_CAPABILITY_LEN },
@@ -157,6 +162,19 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
157 if (!nl_band) 162 if (!nl_band)
158 goto nla_put_failure; 163 goto nla_put_failure;
159 164
165 /* add HT info */
166 if (dev->wiphy.bands[band]->ht_cap.ht_supported) {
167 NLA_PUT(msg, NL80211_BAND_ATTR_HT_MCS_SET,
168 sizeof(dev->wiphy.bands[band]->ht_cap.mcs),
169 &dev->wiphy.bands[band]->ht_cap.mcs);
170 NLA_PUT_U16(msg, NL80211_BAND_ATTR_HT_CAPA,
171 dev->wiphy.bands[band]->ht_cap.cap);
172 NLA_PUT_U8(msg, NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
173 dev->wiphy.bands[band]->ht_cap.ampdu_factor);
174 NLA_PUT_U8(msg, NL80211_BAND_ATTR_HT_AMPDU_DENSITY,
175 dev->wiphy.bands[band]->ht_cap.ampdu_density);
176 }
177
160 /* add frequencies */ 178 /* add frequencies */
161 nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS); 179 nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS);
162 if (!nl_freqs) 180 if (!nl_freqs)
@@ -269,20 +287,76 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
269 return -ENOBUFS; 287 return -ENOBUFS;
270} 288}
271 289
290static const struct nla_policy txq_params_policy[NL80211_TXQ_ATTR_MAX + 1] = {
291 [NL80211_TXQ_ATTR_QUEUE] = { .type = NLA_U8 },
292 [NL80211_TXQ_ATTR_TXOP] = { .type = NLA_U16 },
293 [NL80211_TXQ_ATTR_CWMIN] = { .type = NLA_U16 },
294 [NL80211_TXQ_ATTR_CWMAX] = { .type = NLA_U16 },
295 [NL80211_TXQ_ATTR_AIFS] = { .type = NLA_U8 },
296};
297
298static int parse_txq_params(struct nlattr *tb[],
299 struct ieee80211_txq_params *txq_params)
300{
301 if (!tb[NL80211_TXQ_ATTR_QUEUE] || !tb[NL80211_TXQ_ATTR_TXOP] ||
302 !tb[NL80211_TXQ_ATTR_CWMIN] || !tb[NL80211_TXQ_ATTR_CWMAX] ||
303 !tb[NL80211_TXQ_ATTR_AIFS])
304 return -EINVAL;
305
306 txq_params->queue = nla_get_u8(tb[NL80211_TXQ_ATTR_QUEUE]);
307 txq_params->txop = nla_get_u16(tb[NL80211_TXQ_ATTR_TXOP]);
308 txq_params->cwmin = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMIN]);
309 txq_params->cwmax = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMAX]);
310 txq_params->aifs = nla_get_u8(tb[NL80211_TXQ_ATTR_AIFS]);
311
312 return 0;
313}
314
272static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) 315static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
273{ 316{
274 struct cfg80211_registered_device *rdev; 317 struct cfg80211_registered_device *rdev;
275 int result; 318 int result = 0, rem_txq_params = 0;
276 319 struct nlattr *nl_txq_params;
277 if (!info->attrs[NL80211_ATTR_WIPHY_NAME])
278 return -EINVAL;
279 320
280 rdev = cfg80211_get_dev_from_info(info); 321 rdev = cfg80211_get_dev_from_info(info);
281 if (IS_ERR(rdev)) 322 if (IS_ERR(rdev))
282 return PTR_ERR(rdev); 323 return PTR_ERR(rdev);
283 324
284 result = cfg80211_dev_rename(rdev, nla_data(info->attrs[NL80211_ATTR_WIPHY_NAME])); 325 if (info->attrs[NL80211_ATTR_WIPHY_NAME]) {
326 result = cfg80211_dev_rename(
327 rdev, nla_data(info->attrs[NL80211_ATTR_WIPHY_NAME]));
328 if (result)
329 goto bad_res;
330 }
331
332 if (info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS]) {
333 struct ieee80211_txq_params txq_params;
334 struct nlattr *tb[NL80211_TXQ_ATTR_MAX + 1];
335
336 if (!rdev->ops->set_txq_params) {
337 result = -EOPNOTSUPP;
338 goto bad_res;
339 }
285 340
341 nla_for_each_nested(nl_txq_params,
342 info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
343 rem_txq_params) {
344 nla_parse(tb, NL80211_TXQ_ATTR_MAX,
345 nla_data(nl_txq_params),
346 nla_len(nl_txq_params),
347 txq_params_policy);
348 result = parse_txq_params(tb, &txq_params);
349 if (result)
350 goto bad_res;
351
352 result = rdev->ops->set_txq_params(&rdev->wiphy,
353 &txq_params);
354 if (result)
355 goto bad_res;
356 }
357 }
358
359bad_res:
286 cfg80211_put_dev(rdev); 360 cfg80211_put_dev(rdev);
287 return result; 361 return result;
288} 362}
@@ -1598,6 +1672,12 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
1598 if (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]) 1672 if (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME])
1599 params.use_short_slot_time = 1673 params.use_short_slot_time =
1600 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]); 1674 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]);
1675 if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) {
1676 params.basic_rates =
1677 nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
1678 params.basic_rates_len =
1679 nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
1680 }
1601 1681
1602 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1682 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1603 if (err) 1683 if (err)
@@ -1680,11 +1760,188 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
1680 return -EINVAL; 1760 return -EINVAL;
1681#endif 1761#endif
1682 mutex_lock(&cfg80211_drv_mutex); 1762 mutex_lock(&cfg80211_drv_mutex);
1683 r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, NULL); 1763 r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data);
1684 mutex_unlock(&cfg80211_drv_mutex); 1764 mutex_unlock(&cfg80211_drv_mutex);
1685 return r; 1765 return r;
1686} 1766}
1687 1767
1768static int nl80211_get_mesh_params(struct sk_buff *skb,
1769 struct genl_info *info)
1770{
1771 struct cfg80211_registered_device *drv;
1772 struct mesh_config cur_params;
1773 int err;
1774 struct net_device *dev;
1775 void *hdr;
1776 struct nlattr *pinfoattr;
1777 struct sk_buff *msg;
1778
1779 /* Look up our device */
1780 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1781 if (err)
1782 return err;
1783
1784 /* Get the mesh params */
1785 rtnl_lock();
1786 err = drv->ops->get_mesh_params(&drv->wiphy, dev, &cur_params);
1787 rtnl_unlock();
1788 if (err)
1789 goto out;
1790
1791 /* Draw up a netlink message to send back */
1792 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1793 if (!msg) {
1794 err = -ENOBUFS;
1795 goto out;
1796 }
1797 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
1798 NL80211_CMD_GET_MESH_PARAMS);
1799 if (!hdr)
1800 goto nla_put_failure;
1801 pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_PARAMS);
1802 if (!pinfoattr)
1803 goto nla_put_failure;
1804 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
1805 NLA_PUT_U16(msg, NL80211_MESHCONF_RETRY_TIMEOUT,
1806 cur_params.dot11MeshRetryTimeout);
1807 NLA_PUT_U16(msg, NL80211_MESHCONF_CONFIRM_TIMEOUT,
1808 cur_params.dot11MeshConfirmTimeout);
1809 NLA_PUT_U16(msg, NL80211_MESHCONF_HOLDING_TIMEOUT,
1810 cur_params.dot11MeshHoldingTimeout);
1811 NLA_PUT_U16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
1812 cur_params.dot11MeshMaxPeerLinks);
1813 NLA_PUT_U8(msg, NL80211_MESHCONF_MAX_RETRIES,
1814 cur_params.dot11MeshMaxRetries);
1815 NLA_PUT_U8(msg, NL80211_MESHCONF_TTL,
1816 cur_params.dot11MeshTTL);
1817 NLA_PUT_U8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS,
1818 cur_params.auto_open_plinks);
1819 NLA_PUT_U8(msg, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
1820 cur_params.dot11MeshHWMPmaxPREQretries);
1821 NLA_PUT_U32(msg, NL80211_MESHCONF_PATH_REFRESH_TIME,
1822 cur_params.path_refresh_time);
1823 NLA_PUT_U16(msg, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
1824 cur_params.min_discovery_timeout);
1825 NLA_PUT_U32(msg, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
1826 cur_params.dot11MeshHWMPactivePathTimeout);
1827 NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
1828 cur_params.dot11MeshHWMPpreqMinInterval);
1829 NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1830 cur_params.dot11MeshHWMPnetDiameterTraversalTime);
1831 nla_nest_end(msg, pinfoattr);
1832 genlmsg_end(msg, hdr);
1833 err = genlmsg_unicast(msg, info->snd_pid);
1834 goto out;
1835
1836nla_put_failure:
1837 genlmsg_cancel(msg, hdr);
1838 err = -EMSGSIZE;
1839out:
1840 /* Cleanup */
1841 cfg80211_put_dev(drv);
1842 dev_put(dev);
1843 return err;
1844}
1845
1846#define FILL_IN_MESH_PARAM_IF_SET(table, cfg, param, mask, attr_num, nla_fn) \
1847do {\
1848 if (table[attr_num]) {\
1849 cfg.param = nla_fn(table[attr_num]); \
1850 mask |= (1 << (attr_num - 1)); \
1851 } \
1852} while (0);\
1853
1854static struct nla_policy
1855nl80211_meshconf_params_policy[NL80211_MESHCONF_ATTR_MAX+1] __read_mostly = {
1856 [NL80211_MESHCONF_RETRY_TIMEOUT] = { .type = NLA_U16 },
1857 [NL80211_MESHCONF_CONFIRM_TIMEOUT] = { .type = NLA_U16 },
1858 [NL80211_MESHCONF_HOLDING_TIMEOUT] = { .type = NLA_U16 },
1859 [NL80211_MESHCONF_MAX_PEER_LINKS] = { .type = NLA_U16 },
1860 [NL80211_MESHCONF_MAX_RETRIES] = { .type = NLA_U8 },
1861 [NL80211_MESHCONF_TTL] = { .type = NLA_U8 },
1862 [NL80211_MESHCONF_AUTO_OPEN_PLINKS] = { .type = NLA_U8 },
1863
1864 [NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES] = { .type = NLA_U8 },
1865 [NL80211_MESHCONF_PATH_REFRESH_TIME] = { .type = NLA_U32 },
1866 [NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT] = { .type = NLA_U16 },
1867 [NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT] = { .type = NLA_U32 },
1868 [NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL] = { .type = NLA_U16 },
1869 [NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME] = { .type = NLA_U16 },
1870};
1871
1872static int nl80211_set_mesh_params(struct sk_buff *skb, struct genl_info *info)
1873{
1874 int err;
1875 u32 mask;
1876 struct cfg80211_registered_device *drv;
1877 struct net_device *dev;
1878 struct mesh_config cfg;
1879 struct nlattr *tb[NL80211_MESHCONF_ATTR_MAX + 1];
1880 struct nlattr *parent_attr;
1881
1882 parent_attr = info->attrs[NL80211_ATTR_MESH_PARAMS];
1883 if (!parent_attr)
1884 return -EINVAL;
1885 if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
1886 parent_attr, nl80211_meshconf_params_policy))
1887 return -EINVAL;
1888
1889 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1890 if (err)
1891 return err;
1892
1893 /* This makes sure that there aren't more than 32 mesh config
1894 * parameters (otherwise our bitfield scheme would not work.) */
1895 BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);
1896
1897 /* Fill in the params struct */
1898 mask = 0;
1899 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout,
1900 mask, NL80211_MESHCONF_RETRY_TIMEOUT, nla_get_u16);
1901 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout,
1902 mask, NL80211_MESHCONF_CONFIRM_TIMEOUT, nla_get_u16);
1903 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout,
1904 mask, NL80211_MESHCONF_HOLDING_TIMEOUT, nla_get_u16);
1905 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks,
1906 mask, NL80211_MESHCONF_MAX_PEER_LINKS, nla_get_u16);
1907 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries,
1908 mask, NL80211_MESHCONF_MAX_RETRIES, nla_get_u8);
1909 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL,
1910 mask, NL80211_MESHCONF_TTL, nla_get_u8);
1911 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks,
1912 mask, NL80211_MESHCONF_AUTO_OPEN_PLINKS, nla_get_u8);
1913 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries,
1914 mask, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
1915 nla_get_u8);
1916 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time,
1917 mask, NL80211_MESHCONF_PATH_REFRESH_TIME, nla_get_u32);
1918 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout,
1919 mask, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
1920 nla_get_u16);
1921 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout,
1922 mask, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
1923 nla_get_u32);
1924 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval,
1925 mask, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
1926 nla_get_u16);
1927 FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
1928 dot11MeshHWMPnetDiameterTraversalTime,
1929 mask, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1930 nla_get_u16);
1931
1932 /* Apply changes */
1933 rtnl_lock();
1934 err = drv->ops->set_mesh_params(&drv->wiphy, dev, &cfg, mask);
1935 rtnl_unlock();
1936
1937 /* cleanup */
1938 cfg80211_put_dev(drv);
1939 dev_put(dev);
1940 return err;
1941}
1942
1943#undef FILL_IN_MESH_PARAM_IF_SET
1944
1688static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info) 1945static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
1689{ 1946{
1690 struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1]; 1947 struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1];
@@ -1743,12 +2000,9 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
1743 mutex_lock(&cfg80211_drv_mutex); 2000 mutex_lock(&cfg80211_drv_mutex);
1744 r = set_regdom(rd); 2001 r = set_regdom(rd);
1745 mutex_unlock(&cfg80211_drv_mutex); 2002 mutex_unlock(&cfg80211_drv_mutex);
1746 if (r)
1747 goto bad_reg;
1748
1749 return r; 2003 return r;
1750 2004
1751bad_reg: 2005 bad_reg:
1752 kfree(rd); 2006 kfree(rd);
1753 return -EINVAL; 2007 return -EINVAL;
1754} 2008}
@@ -1902,6 +2156,18 @@ static struct genl_ops nl80211_ops[] = {
1902 .policy = nl80211_policy, 2156 .policy = nl80211_policy,
1903 .flags = GENL_ADMIN_PERM, 2157 .flags = GENL_ADMIN_PERM,
1904 }, 2158 },
2159 {
2160 .cmd = NL80211_CMD_GET_MESH_PARAMS,
2161 .doit = nl80211_get_mesh_params,
2162 .policy = nl80211_policy,
2163 /* can be retrieved by unprivileged users */
2164 },
2165 {
2166 .cmd = NL80211_CMD_SET_MESH_PARAMS,
2167 .doit = nl80211_set_mesh_params,
2168 .policy = nl80211_policy,
2169 .flags = GENL_ADMIN_PERM,
2170 },
1905}; 2171};
1906 2172
1907/* multicast groups */ 2173/* multicast groups */
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 626dbb688499..4c7e39d466c4 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -42,17 +42,34 @@
42#include "core.h" 42#include "core.h"
43#include "reg.h" 43#include "reg.h"
44 44
45/* wiphy is set if this request's initiator is REGDOM_SET_BY_DRIVER */ 45/**
46 * struct regulatory_request - receipt of last regulatory request
47 *
48 * @wiphy: this is set if this request's initiator is
49 * %REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This
50 * can be used by the wireless core to deal with conflicts
51 * and potentially inform users of which devices specifically
52 * cased the conflicts.
53 * @initiator: indicates who sent this request, could be any of
54 * of those set in reg_set_by, %REGDOM_SET_BY_*
55 * @alpha2: the ISO / IEC 3166 alpha2 country code of the requested
56 * regulatory domain. We have a few special codes:
57 * 00 - World regulatory domain
58 * 99 - built by driver but a specific alpha2 cannot be determined
59 * 98 - result of an intersection between two regulatory domains
60 * @intersect: indicates whether the wireless core should intersect
61 * the requested regulatory domain with the presently set regulatory
62 * domain.
63 */
46struct regulatory_request { 64struct regulatory_request {
47 struct list_head list;
48 struct wiphy *wiphy; 65 struct wiphy *wiphy;
49 int granted;
50 enum reg_set_by initiator; 66 enum reg_set_by initiator;
51 char alpha2[2]; 67 char alpha2[2];
68 bool intersect;
52}; 69};
53 70
54static LIST_HEAD(regulatory_requests); 71/* Receipt of information from last regulatory request */
55DEFINE_MUTEX(cfg80211_reg_mutex); 72static struct regulatory_request *last_request;
56 73
57/* To trigger userspace events */ 74/* To trigger userspace events */
58static struct platform_device *reg_pdev; 75static struct platform_device *reg_pdev;
@@ -63,8 +80,6 @@ static u32 supported_bandwidths[] = {
63 MHZ_TO_KHZ(20), 80 MHZ_TO_KHZ(20),
64}; 81};
65 82
66static struct list_head regulatory_requests;
67
68/* Central wireless core regulatory domains, we only need two, 83/* Central wireless core regulatory domains, we only need two,
69 * the current one and a world regulatory domain in case we have no 84 * the current one and a world regulatory domain in case we have no
70 * information to give us an alpha2 */ 85 * information to give us an alpha2 */
@@ -204,7 +219,7 @@ static void reset_regdomains(void)
204 * core upon initialization */ 219 * core upon initialization */
205static void update_world_regdomain(const struct ieee80211_regdomain *rd) 220static void update_world_regdomain(const struct ieee80211_regdomain *rd)
206{ 221{
207 BUG_ON(list_empty(&regulatory_requests)); 222 BUG_ON(!last_request);
208 223
209 reset_regdomains(); 224 reset_regdomains();
210 225
@@ -300,121 +315,13 @@ static int call_crda(const char *alpha2)
300 return kobject_uevent_env(&reg_pdev->dev.kobj, KOBJ_CHANGE, envp); 315 return kobject_uevent_env(&reg_pdev->dev.kobj, KOBJ_CHANGE, envp);
301} 316}
302 317
303/* This has the logic which determines when a new request
304 * should be ignored. */
305static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
306 char *alpha2, struct ieee80211_regdomain *rd)
307{
308 struct regulatory_request *last_request = NULL;
309
310 /* All initial requests are respected */
311 if (list_empty(&regulatory_requests))
312 return 0;
313
314 last_request = list_first_entry(&regulatory_requests,
315 struct regulatory_request, list);
316
317 switch (set_by) {
318 case REGDOM_SET_BY_INIT:
319 return -EINVAL;
320 case REGDOM_SET_BY_CORE:
321 /* Always respect new wireless core hints, should only
322 * come in for updating the world regulatory domain at init
323 * anyway */
324 return 0;
325 case REGDOM_SET_BY_COUNTRY_IE:
326 if (last_request->initiator == set_by) {
327 if (last_request->wiphy != wiphy) {
328 /* Two cards with two APs claiming different
329 * different Country IE alpha2s!
330 * You're special!! */
331 if (!alpha2_equal(last_request->alpha2,
332 cfg80211_regdomain->alpha2)) {
333 /* XXX: Deal with conflict, consider
334 * building a new one out of the
335 * intersection */
336 WARN_ON(1);
337 return -EOPNOTSUPP;
338 }
339 return -EALREADY;
340 }
341 /* Two consecutive Country IE hints on the same wiphy */
342 if (!alpha2_equal(cfg80211_regdomain->alpha2, alpha2))
343 return 0;
344 return -EALREADY;
345 }
346 if (WARN_ON(!is_alpha2_set(alpha2) || !is_an_alpha2(alpha2)),
347 "Invalid Country IE regulatory hint passed "
348 "to the wireless core\n")
349 return -EINVAL;
350 /* We ignore Country IE hints for now, as we haven't yet
351 * added the dot11MultiDomainCapabilityEnabled flag
352 * for wiphys */
353 return 1;
354 case REGDOM_SET_BY_DRIVER:
355 BUG_ON(!wiphy);
356 if (last_request->initiator == set_by) {
357 /* Two separate drivers hinting different things,
358 * this is possible if you have two devices present
359 * on a system with different EEPROM regulatory
360 * readings. XXX: Do intersection, we support only
361 * the first regulatory hint for now */
362 if (last_request->wiphy != wiphy)
363 return -EALREADY;
364 if (rd)
365 return -EALREADY;
366 /* Driver should not be trying to hint different
367 * regulatory domains! */
368 BUG_ON(!alpha2_equal(alpha2,
369 cfg80211_regdomain->alpha2));
370 return -EALREADY;
371 }
372 if (last_request->initiator == REGDOM_SET_BY_CORE)
373 return 0;
374 /* XXX: Handle intersection, and add the
375 * dot11MultiDomainCapabilityEnabled flag to wiphy. For now
376 * we assume the driver has this set to false, following the
377 * 802.11d dot11MultiDomainCapabilityEnabled documentation */
378 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE)
379 return 0;
380 return 0;
381 case REGDOM_SET_BY_USER:
382 if (last_request->initiator == set_by ||
383 last_request->initiator == REGDOM_SET_BY_CORE)
384 return 0;
385 /* Drivers can use their wiphy's reg_notifier()
386 * to override any information */
387 if (last_request->initiator == REGDOM_SET_BY_DRIVER)
388 return 0;
389 /* XXX: Handle intersection */
390 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE)
391 return -EOPNOTSUPP;
392 return 0;
393 default:
394 return -EINVAL;
395 }
396}
397
398static bool __reg_is_valid_request(const char *alpha2,
399 struct regulatory_request **request)
400{
401 struct regulatory_request *req;
402 if (list_empty(&regulatory_requests))
403 return false;
404 list_for_each_entry(req, &regulatory_requests, list) {
405 if (alpha2_equal(req->alpha2, alpha2)) {
406 *request = req;
407 return true;
408 }
409 }
410 return false;
411}
412
413/* Used by nl80211 before kmalloc'ing our regulatory domain */ 318/* Used by nl80211 before kmalloc'ing our regulatory domain */
414bool reg_is_valid_request(const char *alpha2) 319bool reg_is_valid_request(const char *alpha2)
415{ 320{
416 struct regulatory_request *request = NULL; 321 if (!last_request)
417 return __reg_is_valid_request(alpha2, &request); 322 return false;
323
324 return alpha2_equal(last_request->alpha2, alpha2);
418} 325}
419 326
420/* Sanity check on a regulatory rule */ 327/* Sanity check on a regulatory rule */
@@ -431,7 +338,7 @@ static bool is_valid_reg_rule(const struct ieee80211_reg_rule *rule)
431 338
432 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; 339 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
433 340
434 if (freq_range->max_bandwidth_khz > freq_diff) 341 if (freq_diff <= 0 || freq_range->max_bandwidth_khz > freq_diff)
435 return false; 342 return false;
436 343
437 return true; 344 return true;
@@ -469,6 +376,143 @@ static u32 freq_max_bandwidth(const struct ieee80211_freq_range *freq_range,
469 return 0; 376 return 0;
470} 377}
471 378
379/* Helper for regdom_intersect(), this does the real
380 * mathematical intersection fun */
381static int reg_rules_intersect(
382 const struct ieee80211_reg_rule *rule1,
383 const struct ieee80211_reg_rule *rule2,
384 struct ieee80211_reg_rule *intersected_rule)
385{
386 const struct ieee80211_freq_range *freq_range1, *freq_range2;
387 struct ieee80211_freq_range *freq_range;
388 const struct ieee80211_power_rule *power_rule1, *power_rule2;
389 struct ieee80211_power_rule *power_rule;
390 u32 freq_diff;
391
392 freq_range1 = &rule1->freq_range;
393 freq_range2 = &rule2->freq_range;
394 freq_range = &intersected_rule->freq_range;
395
396 power_rule1 = &rule1->power_rule;
397 power_rule2 = &rule2->power_rule;
398 power_rule = &intersected_rule->power_rule;
399
400 freq_range->start_freq_khz = max(freq_range1->start_freq_khz,
401 freq_range2->start_freq_khz);
402 freq_range->end_freq_khz = min(freq_range1->end_freq_khz,
403 freq_range2->end_freq_khz);
404 freq_range->max_bandwidth_khz = min(freq_range1->max_bandwidth_khz,
405 freq_range2->max_bandwidth_khz);
406
407 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
408 if (freq_range->max_bandwidth_khz > freq_diff)
409 freq_range->max_bandwidth_khz = freq_diff;
410
411 power_rule->max_eirp = min(power_rule1->max_eirp,
412 power_rule2->max_eirp);
413 power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain,
414 power_rule2->max_antenna_gain);
415
416 intersected_rule->flags = (rule1->flags | rule2->flags);
417
418 if (!is_valid_reg_rule(intersected_rule))
419 return -EINVAL;
420
421 return 0;
422}
423
424/**
425 * regdom_intersect - do the intersection between two regulatory domains
426 * @rd1: first regulatory domain
427 * @rd2: second regulatory domain
428 *
429 * Use this function to get the intersection between two regulatory domains.
430 * Once completed we will mark the alpha2 for the rd as intersected, "98",
431 * as no one single alpha2 can represent this regulatory domain.
432 *
433 * Returns a pointer to the regulatory domain structure which will hold the
434 * resulting intersection of rules between rd1 and rd2. We will
435 * kzalloc() this structure for you.
436 */
437static struct ieee80211_regdomain *regdom_intersect(
438 const struct ieee80211_regdomain *rd1,
439 const struct ieee80211_regdomain *rd2)
440{
441 int r, size_of_regd;
442 unsigned int x, y;
443 unsigned int num_rules = 0, rule_idx = 0;
444 const struct ieee80211_reg_rule *rule1, *rule2;
445 struct ieee80211_reg_rule *intersected_rule;
446 struct ieee80211_regdomain *rd;
447 /* This is just a dummy holder to help us count */
448 struct ieee80211_reg_rule irule;
449
450 /* Uses the stack temporarily for counter arithmetic */
451 intersected_rule = &irule;
452
453 memset(intersected_rule, 0, sizeof(struct ieee80211_reg_rule));
454
455 if (!rd1 || !rd2)
456 return NULL;
457
458 /* First we get a count of the rules we'll need, then we actually
459 * build them. This is to so we can malloc() and free() a
460 * regdomain once. The reason we use reg_rules_intersect() here
461 * is it will return -EINVAL if the rule computed makes no sense.
462 * All rules that do check out OK are valid. */
463
464 for (x = 0; x < rd1->n_reg_rules; x++) {
465 rule1 = &rd1->reg_rules[x];
466 for (y = 0; y < rd2->n_reg_rules; y++) {
467 rule2 = &rd2->reg_rules[y];
468 if (!reg_rules_intersect(rule1, rule2,
469 intersected_rule))
470 num_rules++;
471 memset(intersected_rule, 0,
472 sizeof(struct ieee80211_reg_rule));
473 }
474 }
475
476 if (!num_rules)
477 return NULL;
478
479 size_of_regd = sizeof(struct ieee80211_regdomain) +
480 ((num_rules + 1) * sizeof(struct ieee80211_reg_rule));
481
482 rd = kzalloc(size_of_regd, GFP_KERNEL);
483 if (!rd)
484 return NULL;
485
486 for (x = 0; x < rd1->n_reg_rules; x++) {
487 rule1 = &rd1->reg_rules[x];
488 for (y = 0; y < rd2->n_reg_rules; y++) {
489 rule2 = &rd2->reg_rules[y];
490 /* This time around instead of using the stack lets
491 * write to the target rule directly saving ourselves
492 * a memcpy() */
493 intersected_rule = &rd->reg_rules[rule_idx];
494 r = reg_rules_intersect(rule1, rule2,
495 intersected_rule);
496 /* No need to memset here the intersected rule here as
497 * we're not using the stack anymore */
498 if (r)
499 continue;
500 rule_idx++;
501 }
502 }
503
504 if (rule_idx != num_rules) {
505 kfree(rd);
506 return NULL;
507 }
508
509 rd->n_reg_rules = num_rules;
510 rd->alpha2[0] = '9';
511 rd->alpha2[1] = '8';
512
513 return rd;
514}
515
472/* XXX: add support for the rest of enum nl80211_reg_rule_flags, we may 516/* XXX: add support for the rest of enum nl80211_reg_rule_flags, we may
473 * want to just have the channel structure use these */ 517 * want to just have the channel structure use these */
474static u32 map_regdom_flags(u32 rd_flags) 518static u32 map_regdom_flags(u32 rd_flags)
@@ -578,22 +622,81 @@ void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby)
578 } 622 }
579} 623}
580 624
625/* Return value which can be used by ignore_request() to indicate
626 * it has been determined we should intersect two regulatory domains */
627#define REG_INTERSECT 1
628
629/* This has the logic which determines when a new request
630 * should be ignored. */
631static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
632 const char *alpha2)
633{
634 /* All initial requests are respected */
635 if (!last_request)
636 return 0;
637
638 switch (set_by) {
639 case REGDOM_SET_BY_INIT:
640 return -EINVAL;
641 case REGDOM_SET_BY_CORE:
642 /*
643 * Always respect new wireless core hints, should only happen
644 * when updating the world regulatory domain at init.
645 */
646 return 0;
647 case REGDOM_SET_BY_COUNTRY_IE:
648 if (unlikely(!is_an_alpha2(alpha2)))
649 return -EINVAL;
650 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) {
651 if (last_request->wiphy != wiphy) {
652 /*
653 * Two cards with two APs claiming different
654 * different Country IE alpha2s. We could
655 * intersect them, but that seems unlikely
656 * to be correct. Reject second one for now.
657 */
658 if (!alpha2_equal(alpha2,
659 cfg80211_regdomain->alpha2))
660 return -EOPNOTSUPP;
661 return -EALREADY;
662 }
663 /* Two consecutive Country IE hints on the same wiphy */
664 if (!alpha2_equal(cfg80211_regdomain->alpha2, alpha2))
665 return 0;
666 return -EALREADY;
667 }
668 /*
669 * Ignore Country IE hints for now, need to think about
670 * what we need to do to support multi-domain operation.
671 */
672 return -EOPNOTSUPP;
673 case REGDOM_SET_BY_DRIVER:
674 if (last_request->initiator == REGDOM_SET_BY_DRIVER)
675 return -EALREADY;
676 return 0;
677 case REGDOM_SET_BY_USER:
678 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE)
679 return REG_INTERSECT;
680 return 0;
681 }
682
683 return -EINVAL;
684}
685
581/* Caller must hold &cfg80211_drv_mutex */ 686/* Caller must hold &cfg80211_drv_mutex */
582int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by, 687int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
583 const char *alpha2, struct ieee80211_regdomain *rd) 688 const char *alpha2)
584{ 689{
585 struct regulatory_request *request; 690 struct regulatory_request *request;
586 char *rd_alpha2; 691 bool intersect = false;
587 int r = 0; 692 int r = 0;
588 693
589 r = ignore_request(wiphy, set_by, (char *) alpha2, rd); 694 r = ignore_request(wiphy, set_by, alpha2);
590 if (r)
591 return r;
592 695
593 if (rd) 696 if (r == REG_INTERSECT)
594 rd_alpha2 = rd->alpha2; 697 intersect = true;
595 else 698 else if (r)
596 rd_alpha2 = (char *) alpha2; 699 return r;
597 700
598 switch (set_by) { 701 switch (set_by) {
599 case REGDOM_SET_BY_CORE: 702 case REGDOM_SET_BY_CORE:
@@ -601,18 +704,18 @@ int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
601 case REGDOM_SET_BY_DRIVER: 704 case REGDOM_SET_BY_DRIVER:
602 case REGDOM_SET_BY_USER: 705 case REGDOM_SET_BY_USER:
603 request = kzalloc(sizeof(struct regulatory_request), 706 request = kzalloc(sizeof(struct regulatory_request),
604 GFP_KERNEL); 707 GFP_KERNEL);
605 if (!request) 708 if (!request)
606 return -ENOMEM; 709 return -ENOMEM;
607 710
608 request->alpha2[0] = rd_alpha2[0]; 711 request->alpha2[0] = alpha2[0];
609 request->alpha2[1] = rd_alpha2[1]; 712 request->alpha2[1] = alpha2[1];
610 request->initiator = set_by; 713 request->initiator = set_by;
611 request->wiphy = wiphy; 714 request->wiphy = wiphy;
715 request->intersect = intersect;
612 716
613 list_add_tail(&request->list, &regulatory_requests); 717 kfree(last_request);
614 if (rd) 718 last_request = request;
615 break;
616 r = call_crda(alpha2); 719 r = call_crda(alpha2);
617#ifndef CONFIG_WIRELESS_OLD_REGULATORY 720#ifndef CONFIG_WIRELESS_OLD_REGULATORY
618 if (r) 721 if (r)
@@ -627,26 +730,13 @@ int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
627 return r; 730 return r;
628} 731}
629 732
630/* If rd is not NULL and if this call fails the caller must free it */ 733void regulatory_hint(struct wiphy *wiphy, const char *alpha2)
631int regulatory_hint(struct wiphy *wiphy, const char *alpha2,
632 struct ieee80211_regdomain *rd)
633{ 734{
634 int r; 735 BUG_ON(!alpha2);
635 BUG_ON(!rd && !alpha2);
636 736
637 mutex_lock(&cfg80211_drv_mutex); 737 mutex_lock(&cfg80211_drv_mutex);
638 738 __regulatory_hint(wiphy, REGDOM_SET_BY_DRIVER, alpha2);
639 r = __regulatory_hint(wiphy, REGDOM_SET_BY_DRIVER, alpha2, rd);
640 if (r || !rd)
641 goto unlock_and_exit;
642
643 /* If the driver passed a regulatory domain we skipped asking
644 * userspace for one so we can now go ahead and set it */
645 r = set_regdom(rd);
646
647unlock_and_exit:
648 mutex_unlock(&cfg80211_drv_mutex); 739 mutex_unlock(&cfg80211_drv_mutex);
649 return r;
650} 740}
651EXPORT_SYMBOL(regulatory_hint); 741EXPORT_SYMBOL(regulatory_hint);
652 742
@@ -705,21 +795,21 @@ static void print_regdomain(const struct ieee80211_regdomain *rd)
705 print_rd_rules(rd); 795 print_rd_rules(rd);
706} 796}
707 797
708void print_regdomain_info(const struct ieee80211_regdomain *rd) 798static void print_regdomain_info(const struct ieee80211_regdomain *rd)
709{ 799{
710 printk(KERN_INFO "cfg80211: Regulatory domain: %c%c\n", 800 printk(KERN_INFO "cfg80211: Regulatory domain: %c%c\n",
711 rd->alpha2[0], rd->alpha2[1]); 801 rd->alpha2[0], rd->alpha2[1]);
712 print_rd_rules(rd); 802 print_rd_rules(rd);
713} 803}
714 804
805/* Takes ownership of rd only if it doesn't fail */
715static int __set_regdom(const struct ieee80211_regdomain *rd) 806static int __set_regdom(const struct ieee80211_regdomain *rd)
716{ 807{
717 struct regulatory_request *request = NULL; 808 const struct ieee80211_regdomain *intersected_rd = NULL;
718
719 /* Some basic sanity checks first */ 809 /* Some basic sanity checks first */
720 810
721 if (is_world_regdom(rd->alpha2)) { 811 if (is_world_regdom(rd->alpha2)) {
722 if (WARN_ON(!__reg_is_valid_request(rd->alpha2, &request))) 812 if (WARN_ON(!reg_is_valid_request(rd->alpha2)))
723 return -EINVAL; 813 return -EINVAL;
724 update_world_regdomain(rd); 814 update_world_regdomain(rd);
725 return 0; 815 return 0;
@@ -729,7 +819,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
729 !is_unknown_alpha2(rd->alpha2)) 819 !is_unknown_alpha2(rd->alpha2))
730 return -EINVAL; 820 return -EINVAL;
731 821
732 if (list_empty(&regulatory_requests)) 822 if (!last_request)
733 return -EINVAL; 823 return -EINVAL;
734 824
735 /* allow overriding the static definitions if CRDA is present */ 825 /* allow overriding the static definitions if CRDA is present */
@@ -742,13 +832,13 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
742 * to review or adjust their own settings based on their own 832 * to review or adjust their own settings based on their own
743 * internal EEPROM data */ 833 * internal EEPROM data */
744 834
745 if (WARN_ON(!__reg_is_valid_request(rd->alpha2, &request))) 835 if (WARN_ON(!reg_is_valid_request(rd->alpha2)))
746 return -EINVAL; 836 return -EINVAL;
747 837
748 reset_regdomains(); 838 reset_regdomains();
749 839
750 /* Country IE parsing coming soon */ 840 /* Country IE parsing coming soon */
751 switch (request->initiator) { 841 switch (last_request->initiator) {
752 case REGDOM_SET_BY_CORE: 842 case REGDOM_SET_BY_CORE:
753 case REGDOM_SET_BY_DRIVER: 843 case REGDOM_SET_BY_DRIVER:
754 case REGDOM_SET_BY_USER: 844 case REGDOM_SET_BY_USER:
@@ -765,9 +855,16 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
765 return -EOPNOTSUPP; 855 return -EOPNOTSUPP;
766 } 856 }
767 857
858 if (unlikely(last_request->intersect)) {
859 intersected_rd = regdom_intersect(rd, cfg80211_regdomain);
860 if (!intersected_rd)
861 return -EINVAL;
862 kfree(rd);
863 rd = intersected_rd;
864 }
865
768 /* Tada! */ 866 /* Tada! */
769 cfg80211_regdomain = rd; 867 cfg80211_regdomain = rd;
770 request->granted = 1;
771 868
772 return 0; 869 return 0;
773} 870}
@@ -775,46 +872,23 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
775 872
776/* Use this call to set the current regulatory domain. Conflicts with 873/* Use this call to set the current regulatory domain. Conflicts with
777 * multiple drivers can be ironed out later. Caller must've already 874 * multiple drivers can be ironed out later. Caller must've already
778 * kmalloc'd the rd structure. If this calls fails you should kfree() 875 * kmalloc'd the rd structure. Caller must hold cfg80211_drv_mutex */
779 * the passed rd. Caller must hold cfg80211_drv_mutex */
780int set_regdom(const struct ieee80211_regdomain *rd) 876int set_regdom(const struct ieee80211_regdomain *rd)
781{ 877{
782 struct regulatory_request *this_request = NULL, *prev_request = NULL;
783 int r; 878 int r;
784 879
785 if (!list_empty(&regulatory_requests))
786 prev_request = list_first_entry(&regulatory_requests,
787 struct regulatory_request, list);
788
789 /* Note that this doesn't update the wiphys, this is done below */ 880 /* Note that this doesn't update the wiphys, this is done below */
790 r = __set_regdom(rd); 881 r = __set_regdom(rd);
791 if (r) 882 if (r) {
883 kfree(rd);
792 return r; 884 return r;
793
794 BUG_ON((!__reg_is_valid_request(rd->alpha2, &this_request)));
795
796 /* The initial standard core update of the world regulatory domain, no
797 * need to keep that request info around if it didn't fail. */
798 if (is_world_regdom(rd->alpha2) &&
799 this_request->initiator == REGDOM_SET_BY_CORE &&
800 this_request->granted) {
801 list_del(&this_request->list);
802 kfree(this_request);
803 this_request = NULL;
804 }
805
806 /* Remove old requests, we only leave behind the last one */
807 if (prev_request) {
808 list_del(&prev_request->list);
809 kfree(prev_request);
810 prev_request = NULL;
811 } 885 }
812 886
813 /* This would make this whole thing pointless */ 887 /* This would make this whole thing pointless */
814 BUG_ON(rd != cfg80211_regdomain); 888 BUG_ON(rd != cfg80211_regdomain);
815 889
816 /* update all wiphys now with the new established regulatory domain */ 890 /* update all wiphys now with the new established regulatory domain */
817 update_all_wiphy_regulatory(this_request->initiator); 891 update_all_wiphy_regulatory(last_request->initiator);
818 892
819 print_regdomain(rd); 893 print_regdomain(rd);
820 894
@@ -838,13 +912,13 @@ int regulatory_init(void)
838 * you have CRDA you get it updated, otherwise you get 912 * you have CRDA you get it updated, otherwise you get
839 * stuck with the static values. We ignore "EU" code as 913 * stuck with the static values. We ignore "EU" code as
840 * that is not a valid ISO / IEC 3166 alpha2 */ 914 * that is not a valid ISO / IEC 3166 alpha2 */
841 if (ieee80211_regdom[0] != 'E' && ieee80211_regdom[1] != 'U') 915 if (ieee80211_regdom[0] != 'E' || ieee80211_regdom[1] != 'U')
842 err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, 916 err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE,
843 ieee80211_regdom, NULL); 917 ieee80211_regdom);
844#else 918#else
845 cfg80211_regdomain = cfg80211_world_regdom; 919 cfg80211_regdomain = cfg80211_world_regdom;
846 920
847 err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, "00", NULL); 921 err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, "00");
848 if (err) 922 if (err)
849 printk(KERN_ERR "cfg80211: calling CRDA failed - " 923 printk(KERN_ERR "cfg80211: calling CRDA failed - "
850 "unable to update world regulatory domain, " 924 "unable to update world regulatory domain, "
@@ -856,16 +930,12 @@ int regulatory_init(void)
856 930
857void regulatory_exit(void) 931void regulatory_exit(void)
858{ 932{
859 struct regulatory_request *req, *req_tmp;
860
861 mutex_lock(&cfg80211_drv_mutex); 933 mutex_lock(&cfg80211_drv_mutex);
862 934
863 reset_regdomains(); 935 reset_regdomains();
864 936
865 list_for_each_entry_safe(req, req_tmp, &regulatory_requests, list) { 937 kfree(last_request);
866 list_del(&req->list); 938
867 kfree(req);
868 }
869 platform_device_unregister(reg_pdev); 939 platform_device_unregister(reg_pdev);
870 940
871 mutex_unlock(&cfg80211_drv_mutex); 941 mutex_unlock(&cfg80211_drv_mutex);
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index a33362872f3c..c9b6b6358bbe 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -1,7 +1,6 @@
1#ifndef __NET_WIRELESS_REG_H 1#ifndef __NET_WIRELESS_REG_H
2#define __NET_WIRELESS_REG_H 2#define __NET_WIRELESS_REG_H
3 3
4extern struct mutex cfg80211_reg_mutex;
5bool is_world_regdom(const char *alpha2); 4bool is_world_regdom(const char *alpha2);
6bool reg_is_valid_request(const char *alpha2); 5bool reg_is_valid_request(const char *alpha2);
7 6
@@ -10,4 +9,23 @@ void regulatory_exit(void);
10 9
11int set_regdom(const struct ieee80211_regdomain *rd); 10int set_regdom(const struct ieee80211_regdomain *rd);
12 11
12/**
13 * __regulatory_hint - hint to the wireless core a regulatory domain
14 * @wiphy: if the hint comes from country information from an AP, this
15 * is required to be set to the wiphy that received the information
16 * @alpha2: the ISO/IEC 3166 alpha2 being claimed the regulatory domain
17 * should be in.
18 *
19 * The Wireless subsystem can use this function to hint to the wireless core
20 * what it believes should be the current regulatory domain by
21 * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
22 * domain should be in.
23 *
24 * Returns zero if all went fine, %-EALREADY if a regulatory domain had
25 * already been set or other standard error codes.
26 *
27 */
28extern int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
29 const char *alpha2);
30
13#endif /* __NET_WIRELESS_REG_H */ 31#endif /* __NET_WIRELESS_REG_H */
diff --git a/net/wireless/util.c b/net/wireless/util.c
index f54424693a38..e76cc28b0345 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -7,6 +7,25 @@
7#include <asm/bitops.h> 7#include <asm/bitops.h>
8#include "core.h" 8#include "core.h"
9 9
10struct ieee80211_rate *
11ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
12 u64 basic_rates, int bitrate)
13{
14 struct ieee80211_rate *result = &sband->bitrates[0];
15 int i;
16
17 for (i = 0; i < sband->n_bitrates; i++) {
18 if (!(basic_rates & BIT(i)))
19 continue;
20 if (sband->bitrates[i].bitrate > bitrate)
21 continue;
22 result = &sband->bitrates[i];
23 }
24
25 return result;
26}
27EXPORT_SYMBOL(ieee80211_get_response_rate);
28
10int ieee80211_channel_to_frequency(int chan) 29int ieee80211_channel_to_frequency(int chan)
11{ 30{
12 if (chan < 14) 31 if (chan < 14)
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index 6ebda25c24e9..a5d3416522de 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -24,8 +24,8 @@ static struct ctl_table x25_table[] = {
24 .data = &sysctl_x25_restart_request_timeout, 24 .data = &sysctl_x25_restart_request_timeout,
25 .maxlen = sizeof(int), 25 .maxlen = sizeof(int),
26 .mode = 0644, 26 .mode = 0644,
27 .proc_handler = &proc_dointvec_minmax, 27 .proc_handler = proc_dointvec_minmax,
28 .strategy = &sysctl_intvec, 28 .strategy = sysctl_intvec,
29 .extra1 = &min_timer, 29 .extra1 = &min_timer,
30 .extra2 = &max_timer, 30 .extra2 = &max_timer,
31 }, 31 },
@@ -35,8 +35,8 @@ static struct ctl_table x25_table[] = {
35 .data = &sysctl_x25_call_request_timeout, 35 .data = &sysctl_x25_call_request_timeout,
36 .maxlen = sizeof(int), 36 .maxlen = sizeof(int),
37 .mode = 0644, 37 .mode = 0644,
38 .proc_handler = &proc_dointvec_minmax, 38 .proc_handler = proc_dointvec_minmax,
39 .strategy = &sysctl_intvec, 39 .strategy = sysctl_intvec,
40 .extra1 = &min_timer, 40 .extra1 = &min_timer,
41 .extra2 = &max_timer, 41 .extra2 = &max_timer,
42 }, 42 },
@@ -46,8 +46,8 @@ static struct ctl_table x25_table[] = {
46 .data = &sysctl_x25_reset_request_timeout, 46 .data = &sysctl_x25_reset_request_timeout,
47 .maxlen = sizeof(int), 47 .maxlen = sizeof(int),
48 .mode = 0644, 48 .mode = 0644,
49 .proc_handler = &proc_dointvec_minmax, 49 .proc_handler = proc_dointvec_minmax,
50 .strategy = &sysctl_intvec, 50 .strategy = sysctl_intvec,
51 .extra1 = &min_timer, 51 .extra1 = &min_timer,
52 .extra2 = &max_timer, 52 .extra2 = &max_timer,
53 }, 53 },
@@ -57,8 +57,8 @@ static struct ctl_table x25_table[] = {
57 .data = &sysctl_x25_clear_request_timeout, 57 .data = &sysctl_x25_clear_request_timeout,
58 .maxlen = sizeof(int), 58 .maxlen = sizeof(int),
59 .mode = 0644, 59 .mode = 0644,
60 .proc_handler = &proc_dointvec_minmax, 60 .proc_handler = proc_dointvec_minmax,
61 .strategy = &sysctl_intvec, 61 .strategy = sysctl_intvec,
62 .extra1 = &min_timer, 62 .extra1 = &min_timer,
63 .extra2 = &max_timer, 63 .extra2 = &max_timer,
64 }, 64 },
@@ -68,8 +68,8 @@ static struct ctl_table x25_table[] = {
68 .data = &sysctl_x25_ack_holdback_timeout, 68 .data = &sysctl_x25_ack_holdback_timeout,
69 .maxlen = sizeof(int), 69 .maxlen = sizeof(int),
70 .mode = 0644, 70 .mode = 0644,
71 .proc_handler = &proc_dointvec_minmax, 71 .proc_handler = proc_dointvec_minmax,
72 .strategy = &sysctl_intvec, 72 .strategy = sysctl_intvec,
73 .extra1 = &min_timer, 73 .extra1 = &min_timer,
74 .extra2 = &max_timer, 74 .extra2 = &max_timer,
75 }, 75 },
@@ -79,7 +79,7 @@ static struct ctl_table x25_table[] = {
79 .data = &sysctl_x25_forward, 79 .data = &sysctl_x25_forward,
80 .maxlen = sizeof(int), 80 .maxlen = sizeof(int),
81 .mode = 0644, 81 .mode = 0644,
82 .proc_handler = &proc_dointvec, 82 .proc_handler = proc_dointvec,
83 }, 83 },
84 { 0, }, 84 { 0, },
85}; 85};
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 058f04f54b90..17854884f6ff 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -521,7 +521,7 @@ static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize);
521 521
522/* Generate new index... KAME seems to generate them ordered by cost 522/* Generate new index... KAME seems to generate them ordered by cost
523 * of an absolute inpredictability of ordering of rules. This will not pass. */ 523 * of an absolute inpredictability of ordering of rules. This will not pass. */
524static u32 xfrm_gen_index(u8 type, int dir) 524static u32 xfrm_gen_index(int dir)
525{ 525{
526 static u32 idx_generator; 526 static u32 idx_generator;
527 527
@@ -608,7 +608,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
608 list_del(&delpol->walk.all); 608 list_del(&delpol->walk.all);
609 xfrm_policy_count[dir]--; 609 xfrm_policy_count[dir]--;
610 } 610 }
611 policy->index = delpol ? delpol->index : xfrm_gen_index(policy->type, dir); 611 policy->index = delpol ? delpol->index : xfrm_gen_index(dir);
612 hlist_add_head(&policy->byidx, xfrm_policy_byidx+idx_hash(policy->index)); 612 hlist_add_head(&policy->byidx, xfrm_policy_byidx+idx_hash(policy->index));
613 policy->curlft.add_time = get_seconds(); 613 policy->curlft.add_time = get_seconds();
614 policy->curlft.use_time = 0; 614 policy->curlft.use_time = 0;
@@ -1138,7 +1138,7 @@ int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol)
1138 sk->sk_policy[dir] = pol; 1138 sk->sk_policy[dir] = pol;
1139 if (pol) { 1139 if (pol) {
1140 pol->curlft.add_time = get_seconds(); 1140 pol->curlft.add_time = get_seconds();
1141 pol->index = xfrm_gen_index(pol->type, XFRM_POLICY_MAX+dir); 1141 pol->index = xfrm_gen_index(XFRM_POLICY_MAX+dir);
1142 __xfrm_policy_link(pol, XFRM_POLICY_MAX+dir); 1142 __xfrm_policy_link(pol, XFRM_POLICY_MAX+dir);
1143 } 1143 }
1144 if (old_pol) 1144 if (old_pol)
@@ -2381,9 +2381,7 @@ static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void
2381} 2381}
2382 2382
2383static struct notifier_block xfrm_dev_notifier = { 2383static struct notifier_block xfrm_dev_notifier = {
2384 xfrm_dev_event, 2384 .notifier_call = xfrm_dev_event,
2385 NULL,
2386 0
2387}; 2385};
2388 2386
2389#ifdef CONFIG_XFRM_STATISTICS 2387#ifdef CONFIG_XFRM_STATISTICS
@@ -2457,25 +2455,21 @@ static void xfrm_audit_common_policyinfo(struct xfrm_policy *xp,
2457 2455
2458 switch(sel->family) { 2456 switch(sel->family) {
2459 case AF_INET: 2457 case AF_INET:
2460 audit_log_format(audit_buf, " src=" NIPQUAD_FMT, 2458 audit_log_format(audit_buf, " src=%pI4", &sel->saddr.a4);
2461 NIPQUAD(sel->saddr.a4));
2462 if (sel->prefixlen_s != 32) 2459 if (sel->prefixlen_s != 32)
2463 audit_log_format(audit_buf, " src_prefixlen=%d", 2460 audit_log_format(audit_buf, " src_prefixlen=%d",
2464 sel->prefixlen_s); 2461 sel->prefixlen_s);
2465 audit_log_format(audit_buf, " dst=" NIPQUAD_FMT, 2462 audit_log_format(audit_buf, " dst=%pI4", &sel->daddr.a4);
2466 NIPQUAD(sel->daddr.a4));
2467 if (sel->prefixlen_d != 32) 2463 if (sel->prefixlen_d != 32)
2468 audit_log_format(audit_buf, " dst_prefixlen=%d", 2464 audit_log_format(audit_buf, " dst_prefixlen=%d",
2469 sel->prefixlen_d); 2465 sel->prefixlen_d);
2470 break; 2466 break;
2471 case AF_INET6: 2467 case AF_INET6:
2472 audit_log_format(audit_buf, " src=" NIP6_FMT, 2468 audit_log_format(audit_buf, " src=%pI6", sel->saddr.a6);
2473 NIP6(*(struct in6_addr *)sel->saddr.a6));
2474 if (sel->prefixlen_s != 128) 2469 if (sel->prefixlen_s != 128)
2475 audit_log_format(audit_buf, " src_prefixlen=%d", 2470 audit_log_format(audit_buf, " src_prefixlen=%d",
2476 sel->prefixlen_s); 2471 sel->prefixlen_s);
2477 audit_log_format(audit_buf, " dst=" NIP6_FMT, 2472 audit_log_format(audit_buf, " dst=%pI6", sel->daddr.a6);
2478 NIP6(*(struct in6_addr *)sel->daddr.a6));
2479 if (sel->prefixlen_d != 128) 2473 if (sel->prefixlen_d != 128)
2480 audit_log_format(audit_buf, " dst_prefixlen=%d", 2474 audit_log_format(audit_buf, " dst_prefixlen=%d",
2481 sel->prefixlen_d); 2475 sel->prefixlen_d);
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 508337f97249..cd9d9171ded7 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2109,16 +2109,12 @@ static void xfrm_audit_helper_sainfo(struct xfrm_state *x,
2109 2109
2110 switch(x->props.family) { 2110 switch(x->props.family) {
2111 case AF_INET: 2111 case AF_INET:
2112 audit_log_format(audit_buf, 2112 audit_log_format(audit_buf, " src=%pI4 dst=%pI4",
2113 " src=" NIPQUAD_FMT " dst=" NIPQUAD_FMT, 2113 &x->props.saddr.a4, &x->id.daddr.a4);
2114 NIPQUAD(x->props.saddr.a4),
2115 NIPQUAD(x->id.daddr.a4));
2116 break; 2114 break;
2117 case AF_INET6: 2115 case AF_INET6:
2118 audit_log_format(audit_buf, 2116 audit_log_format(audit_buf, " src=%pI6 dst=%pI6",
2119 " src=" NIP6_FMT " dst=" NIP6_FMT, 2117 x->props.saddr.a6, x->id.daddr.a6);
2120 NIP6(*(struct in6_addr *)x->props.saddr.a6),
2121 NIP6(*(struct in6_addr *)x->id.daddr.a6));
2122 break; 2118 break;
2123 } 2119 }
2124 2120
@@ -2134,18 +2130,14 @@ static void xfrm_audit_helper_pktinfo(struct sk_buff *skb, u16 family,
2134 switch (family) { 2130 switch (family) {
2135 case AF_INET: 2131 case AF_INET:
2136 iph4 = ip_hdr(skb); 2132 iph4 = ip_hdr(skb);
2137 audit_log_format(audit_buf, 2133 audit_log_format(audit_buf, " src=%pI4 dst=%pI4",
2138 " src=" NIPQUAD_FMT " dst=" NIPQUAD_FMT, 2134 &iph4->saddr, &iph4->daddr);
2139 NIPQUAD(iph4->saddr),
2140 NIPQUAD(iph4->daddr));
2141 break; 2135 break;
2142 case AF_INET6: 2136 case AF_INET6:
2143 iph6 = ipv6_hdr(skb); 2137 iph6 = ipv6_hdr(skb);
2144 audit_log_format(audit_buf, 2138 audit_log_format(audit_buf,
2145 " src=" NIP6_FMT " dst=" NIP6_FMT 2139 " src=%pI6 dst=%pI6 flowlbl=0x%x%02x%02x",
2146 " flowlbl=0x%x%02x%02x", 2140 &iph6->saddr,&iph6->daddr,
2147 NIP6(iph6->saddr),
2148 NIP6(iph6->daddr),
2149 iph6->flow_lbl[0] & 0x0f, 2141 iph6->flow_lbl[0] & 0x0f,
2150 iph6->flow_lbl[1], 2142 iph6->flow_lbl[1],
2151 iph6->flow_lbl[2]); 2143 iph6->flow_lbl[2]);
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index a278a6f3b991..ee15d5dd6544 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2503,6 +2503,57 @@ static int xfrm_send_report(u8 proto, struct xfrm_selector *sel,
2503 return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_REPORT, GFP_ATOMIC); 2503 return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_REPORT, GFP_ATOMIC);
2504} 2504}
2505 2505
2506static inline size_t xfrm_mapping_msgsize(void)
2507{
2508 return NLMSG_ALIGN(sizeof(struct xfrm_user_mapping));
2509}
2510
2511static int build_mapping(struct sk_buff *skb, struct xfrm_state *x,
2512 xfrm_address_t *new_saddr, __be16 new_sport)
2513{
2514 struct xfrm_user_mapping *um;
2515 struct nlmsghdr *nlh;
2516
2517 nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_MAPPING, sizeof(*um), 0);
2518 if (nlh == NULL)
2519 return -EMSGSIZE;
2520
2521 um = nlmsg_data(nlh);
2522
2523 memcpy(&um->id.daddr, &x->id.daddr, sizeof(um->id.daddr));
2524 um->id.spi = x->id.spi;
2525 um->id.family = x->props.family;
2526 um->id.proto = x->id.proto;
2527 memcpy(&um->new_saddr, new_saddr, sizeof(um->new_saddr));
2528 memcpy(&um->old_saddr, &x->props.saddr, sizeof(um->old_saddr));
2529 um->new_sport = new_sport;
2530 um->old_sport = x->encap->encap_sport;
2531 um->reqid = x->props.reqid;
2532
2533 return nlmsg_end(skb, nlh);
2534}
2535
2536static int xfrm_send_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
2537 __be16 sport)
2538{
2539 struct sk_buff *skb;
2540
2541 if (x->id.proto != IPPROTO_ESP)
2542 return -EINVAL;
2543
2544 if (!x->encap)
2545 return -EINVAL;
2546
2547 skb = nlmsg_new(xfrm_mapping_msgsize(), GFP_ATOMIC);
2548 if (skb == NULL)
2549 return -ENOMEM;
2550
2551 if (build_mapping(skb, x, ipaddr, sport) < 0)
2552 BUG();
2553
2554 return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_MAPPING, GFP_ATOMIC);
2555}
2556
2506static struct xfrm_mgr netlink_mgr = { 2557static struct xfrm_mgr netlink_mgr = {
2507 .id = "netlink", 2558 .id = "netlink",
2508 .notify = xfrm_send_state_notify, 2559 .notify = xfrm_send_state_notify,
@@ -2511,6 +2562,7 @@ static struct xfrm_mgr netlink_mgr = {
2511 .notify_policy = xfrm_send_policy_notify, 2562 .notify_policy = xfrm_send_policy_notify,
2512 .report = xfrm_send_report, 2563 .report = xfrm_send_report,
2513 .migrate = xfrm_send_migrate, 2564 .migrate = xfrm_send_migrate,
2565 .new_mapping = xfrm_send_mapping,
2514}; 2566};
2515 2567
2516static int __init xfrm_user_init(void) 2568static int __init xfrm_user_init(void)