aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-19 18:50:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-19 18:50:47 -0500
commit1ee2dcc2245340cf4ac94b99c4d00efbeba61824 (patch)
tree5339e55add987379525177011dde6e3756b1430c
parent4457e6f6c9f6052cd5f44a79037108b5ddeb0ce7 (diff)
parent091e0662ee2c37867ad918ce7b6ddd17f0e090e2 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: "Mostly these are fixes for fallout due to merge window changes, as well as cures for problems that have been with us for a much longer period of time" 1) Johannes Berg noticed two major deficiencies in our genetlink registration. Some genetlink protocols we passing in constant counts for their ops array rather than something like ARRAY_SIZE(ops) or similar. Also, some genetlink protocols were using fixed IDs for their multicast groups. We have to retain these fixed IDs to keep existing userland tools working, but reserve them so that other multicast groups used by other protocols can not possibly conflict. In dealing with these two problems, we actually now use less state management for genetlink operations and multicast groups. 2) When configuring interface hardware timestamping, fix several drivers that simply do not validate that the hwtstamp_config value is one the driver actually supports. From Ben Hutchings. 3) Invalid memory references in mwifiex driver, from Amitkumar Karwar. 4) In dev_forward_skb(), set the skb->protocol in the right order relative to skb_scrub_packet(). From Alexei Starovoitov. 5) Bridge erroneously fails to use the proper wrapper functions to make calls to netdev_ops->ndo_vlan_rx_{add,kill}_vid. Fix from Toshiaki Makita. 6) When detaching a bridge port, make sure to flush all VLAN IDs to prevent them from leaking, also from Toshiaki Makita. 7) Put in a compromise for TCP Small Queues so that deep queued devices that delay TX reclaim non-trivially don't have such a performance decrease. One particularly problematic area is 802.11 AMPDU in wireless. From Eric Dumazet. 8) Fix crashes in tcp_fastopen_cache_get(), we can see NULL socket dsts here. Fix from Eric Dumzaet, reported by Dave Jones. 9) Fix use after free in ipv6 SIT driver, from Willem de Bruijn. 10) When computing mergeable buffer sizes, virtio-net fails to take the virtio-net header into account. From Michael Dalton. 11) Fix seqlock deadlock in ip4_datagram_connect() wrt. statistic bumping, this one has been with us for a while. From Eric Dumazet. 12) Fix NULL deref in the new TIPC fragmentation handling, from Erik Hugne. 13) 6lowpan bit used for traffic classification was wrong, from Jukka Rissanen. 14) macvlan has the same issue as normal vlans did wrt. propagating LRO disabling down to the real device, fix it the same way. From Michal Kubecek. 15) CPSW driver needs to soft reset all slaves during suspend, from Daniel Mack. 16) Fix small frame pacing in FQ packet scheduler, from Eric Dumazet. 17) The xen-netfront RX buffer refill timer isn't properly scheduled on partial RX allocation success, from Ma JieYue. 18) When ipv6 ping protocol support was added, the AF_INET6 protocol initialization cleanup path on failure was borked a little. Fix from Vlad Yasevich. 19) If a socket disconnects during a read/recvmsg/recvfrom/etc that blocks we can do the wrong thing with the msg_name we write back to userspace. From Hannes Frederic Sowa. There is another fix in the works from Hannes which will prevent future problems of this nature. 20) Fix route leak in VTI tunnel transmit, from Fan Du. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (106 commits) genetlink: make multicast groups const, prevent abuse genetlink: pass family to functions using groups genetlink: add and use genl_set_err() genetlink: remove family pointer from genl_multicast_group genetlink: remove genl_unregister_mc_group() hsr: don't call genl_unregister_mc_group() quota/genetlink: use proper genetlink multicast APIs drop_monitor/genetlink: use proper genetlink multicast APIs genetlink: only pass array to genl_register_family_with_ops() tcp: don't update snd_nxt, when a socket is switched from repair mode atm: idt77252: fix dev refcnt leak xfrm: Release dst if this dst is improper for vti tunnel netlink: fix documentation typo in netlink_set_err() be2net: Delete secondary unicast MAC addresses during be_close be2net: Fix unconditional enabling of Rx interface options net, virtio_net: replace the magic value ping: prevent NULL pointer dereference on write to msg_name bnx2x: Prevent "timeout waiting for state X" bnx2x: prevent CFC attention bnx2x: Prevent panic during DMAE timeout ...
-rw-r--r--Documentation/networking/ip-sysctl.txt3
-rw-r--r--MAINTAINERS10
-rw-r--r--drivers/acpi/event.c25
-rw-r--r--drivers/atm/idt77252.c2
-rw-r--r--drivers/connector/cn_proc.c72
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c8
-rw-r--r--drivers/net/bonding/bond_sysfs.c30
-rw-r--r--drivers/net/bonding/bonding.h3
-rw-r--r--drivers/net/ethernet/atheros/alx/main.c3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c5
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c17
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h11
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c16
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c16
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h2
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c7
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c31
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c14
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c3
-rw-r--r--drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c12
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c12
-rw-r--r--drivers/net/ethernet/ti/cpsw.c36
-rw-r--r--drivers/net/ethernet/xscale/ixp4xx_eth.c12
-rw-r--r--drivers/net/macvtap.c8
-rw-r--r--drivers/net/team/team.c29
-rw-r--r--drivers/net/tun.c10
-rw-r--r--drivers/net/usb/cdc_ncm.c2
-rw-r--r--drivers/net/usb/usbnet.c3
-rw-r--r--drivers/net/virtio_net.c34
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_hw.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9485_initvals.h42
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h19
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_debug.c13
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c87
-rw-r--r--drivers/net/wireless/ath/wcn36xx/debug.c2
-rw-r--r--drivers/net/wireless/ath/wcn36xx/smd.c9
-rw-r--r--drivers/net/wireless/libertas/debugfs.c6
-rw-r--r--drivers/net/wireless/libertas/if_cs.c1
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c5
-rw-r--r--drivers/net/wireless/mwifiex/fw.h4
-rw-r--r--drivers/net/wireless/mwifiex/ie.c11
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c3
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmd.c4
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmdresp.c46
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c5
-rw-r--r--drivers/net/wireless/mwifiex/uap_txrx.c29
-rw-r--r--drivers/net/wireless/mwifiex/wmm.c3
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c4
-rw-r--r--drivers/net/wireless/rtlwifi/base.c93
-rw-r--r--drivers/net/wireless/rtlwifi/efuse.c5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/trx.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/trx.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/rf.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.c2
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h6
-rw-r--r--drivers/net/xen-netfront.c7
-rw-r--r--drivers/scsi/pmcraid.c3
-rw-r--r--drivers/thermal/thermal_core.c25
-rw-r--r--fs/dlm/netlink.c10
-rw-r--r--fs/quota/netlink.c16
-rw-r--r--include/linux/genl_magic_func.h53
-rw-r--r--include/linux/if_macvlan.h17
-rw-r--r--include/linux/skbuff.h39
-rw-r--r--include/net/genetlink.h131
-rw-r--r--include/uapi/linux/genetlink.h1
-rw-r--r--include/uapi/linux/pkt_sched.h7
-rw-r--r--kernel/taskstats.c38
-rw-r--r--lib/random32.c12
-rw-r--r--net/bridge/br_if.c1
-rw-r--r--net/bridge/br_vlan.c24
-rw-r--r--net/core/dev.c11
-rw-r--r--net/core/drop_monitor.c15
-rw-r--r--net/hsr/hsr_netlink.c64
-rw-r--r--net/ieee802154/6lowpan.c4
-rw-r--r--net/ieee802154/dgram.c3
-rw-r--r--net/ieee802154/ieee802154.h21
-rw-r--r--net/ieee802154/netlink.c45
-rw-r--r--net/ieee802154/nl-mac.c79
-rw-r--r--net/ieee802154/nl-phy.c37
-rw-r--r--net/ipv4/datagram.c2
-rw-r--r--net/ipv4/ip_tunnel.c4
-rw-r--r--net/ipv4/ip_vti.c1
-rw-r--r--net/ipv4/ping.c49
-rw-r--r--net/ipv4/raw.c4
-rw-r--r--net/ipv4/tcp.c6
-rw-r--r--net/ipv4/tcp_metrics.c10
-rw-r--r--net/ipv4/tcp_output.c7
-rw-r--r--net/ipv4/udp.c7
-rw-r--r--net/ipv6/addrconf.c38
-rw-r--r--net/ipv6/af_inet6.c4
-rw-r--r--net/ipv6/ip6_tunnel.c18
-rw-r--r--net/ipv6/ndisc.c2
-rw-r--r--net/ipv6/raw.c4
-rw-r--r--net/ipv6/sit.c18
-rw-r--r--net/ipv6/udp.c5
-rw-r--r--net/irda/irnetlink.c5
-rw-r--r--net/l2tp/l2tp_ip.c4
-rw-r--r--net/l2tp/l2tp_netlink.c9
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c4
-rw-r--r--net/netlabel/netlabel_cipso_v4.c4
-rw-r--r--net/netlabel/netlabel_mgmt.c4
-rw-r--r--net/netlabel/netlabel_unlabeled.c4
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/netlink/genetlink.c524
-rw-r--r--net/nfc/netlink.c41
-rw-r--r--net/openvswitch/datapath.c59
-rw-r--r--net/openvswitch/datapath.h1
-rw-r--r--net/openvswitch/dp_notify.c11
-rw-r--r--net/phonet/datagram.c9
-rw-r--r--net/sched/sch_fq.c40
-rw-r--r--net/sctp/associola.c6
-rw-r--r--net/tipc/link.c3
-rw-r--r--net/tipc/netlink.c11
-rw-r--r--net/wimax/op-msg.c27
-rw-r--r--net/wimax/op-reset.c17
-rw-r--r--net/wimax/op-rfkill.c21
-rw-r--r--net/wimax/op-state-get.c17
-rw-r--r--net/wimax/stack.c95
-rw-r--r--net/wimax/wimax-internal.h8
-rw-r--r--net/wireless/nl80211.c206
129 files changed, 1437 insertions, 1432 deletions
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 8b8a05787641..3c12d9a7ed00 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -577,9 +577,6 @@ tcp_limit_output_bytes - INTEGER
577 typical pfifo_fast qdiscs. 577 typical pfifo_fast qdiscs.
578 tcp_limit_output_bytes limits the number of bytes on qdisc 578 tcp_limit_output_bytes limits the number of bytes on qdisc
579 or device to reduce artificial RTT/cwnd and reduce bufferbloat. 579 or device to reduce artificial RTT/cwnd and reduce bufferbloat.
580 Note: For GSO/TSO enabled flows, we try to have at least two
581 packets in flight. Reducing tcp_limit_output_bytes might also
582 reduce the size of individual GSO packet (64KB being the max)
583 Default: 131072 580 Default: 131072
584 581
585tcp_challenge_ack_limit - INTEGER 582tcp_challenge_ack_limit - INTEGER
diff --git a/MAINTAINERS b/MAINTAINERS
index 0e598aeed539..63f30484932b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2468,7 +2468,7 @@ S: Maintained
2468F: drivers/media/dvb-frontends/cxd2820r* 2468F: drivers/media/dvb-frontends/cxd2820r*
2469 2469
2470CXGB3 ETHERNET DRIVER (CXGB3) 2470CXGB3 ETHERNET DRIVER (CXGB3)
2471M: Divy Le Ray <divy@chelsio.com> 2471M: Santosh Raspatur <santosh@chelsio.com>
2472L: netdev@vger.kernel.org 2472L: netdev@vger.kernel.org
2473W: http://www.chelsio.com 2473W: http://www.chelsio.com
2474S: Supported 2474S: Supported
@@ -8960,8 +8960,8 @@ USB PEGASUS DRIVER
8960M: Petko Manolov <petkan@nucleusys.com> 8960M: Petko Manolov <petkan@nucleusys.com>
8961L: linux-usb@vger.kernel.org 8961L: linux-usb@vger.kernel.org
8962L: netdev@vger.kernel.org 8962L: netdev@vger.kernel.org
8963T: git git://git.code.sf.net/p/pegasus2/git 8963T: git git://github.com/petkan/pegasus.git
8964W: http://pegasus2.sourceforge.net/ 8964W: https://github.com/petkan/pegasus
8965S: Maintained 8965S: Maintained
8966F: drivers/net/usb/pegasus.* 8966F: drivers/net/usb/pegasus.*
8967 8967
@@ -8982,8 +8982,8 @@ USB RTL8150 DRIVER
8982M: Petko Manolov <petkan@nucleusys.com> 8982M: Petko Manolov <petkan@nucleusys.com>
8983L: linux-usb@vger.kernel.org 8983L: linux-usb@vger.kernel.org
8984L: netdev@vger.kernel.org 8984L: netdev@vger.kernel.org
8985T: git git://git.code.sf.net/p/pegasus2/git 8985T: git git://github.com/petkan/rtl8150.git
8986W: http://pegasus2.sourceforge.net/ 8986W: https://github.com/petkan/rtl8150
8987S: Maintained 8987S: Maintained
8988F: drivers/net/usb/rtl8150.c 8988F: drivers/net/usb/rtl8150.c
8989 8989
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index fdef416c0ff6..cae3b387b867 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -78,15 +78,17 @@ enum {
78#define ACPI_GENL_VERSION 0x01 78#define ACPI_GENL_VERSION 0x01
79#define ACPI_GENL_MCAST_GROUP_NAME "acpi_mc_group" 79#define ACPI_GENL_MCAST_GROUP_NAME "acpi_mc_group"
80 80
81static const struct genl_multicast_group acpi_event_mcgrps[] = {
82 { .name = ACPI_GENL_MCAST_GROUP_NAME, },
83};
84
81static struct genl_family acpi_event_genl_family = { 85static struct genl_family acpi_event_genl_family = {
82 .id = GENL_ID_GENERATE, 86 .id = GENL_ID_GENERATE,
83 .name = ACPI_GENL_FAMILY_NAME, 87 .name = ACPI_GENL_FAMILY_NAME,
84 .version = ACPI_GENL_VERSION, 88 .version = ACPI_GENL_VERSION,
85 .maxattr = ACPI_GENL_ATTR_MAX, 89 .maxattr = ACPI_GENL_ATTR_MAX,
86}; 90 .mcgrps = acpi_event_mcgrps,
87 91 .n_mcgrps = ARRAY_SIZE(acpi_event_mcgrps),
88static struct genl_multicast_group acpi_event_mcgrp = {
89 .name = ACPI_GENL_MCAST_GROUP_NAME,
90}; 92};
91 93
92int acpi_bus_generate_netlink_event(const char *device_class, 94int acpi_bus_generate_netlink_event(const char *device_class,
@@ -141,7 +143,7 @@ int acpi_bus_generate_netlink_event(const char *device_class,
141 return result; 143 return result;
142 } 144 }
143 145
144 genlmsg_multicast(skb, 0, acpi_event_mcgrp.id, GFP_ATOMIC); 146 genlmsg_multicast(&acpi_event_genl_family, skb, 0, 0, GFP_ATOMIC);
145 return 0; 147 return 0;
146} 148}
147 149
@@ -149,18 +151,7 @@ EXPORT_SYMBOL(acpi_bus_generate_netlink_event);
149 151
150static int acpi_event_genetlink_init(void) 152static int acpi_event_genetlink_init(void)
151{ 153{
152 int result; 154 return genl_register_family(&acpi_event_genl_family);
153
154 result = genl_register_family(&acpi_event_genl_family);
155 if (result)
156 return result;
157
158 result = genl_register_mc_group(&acpi_event_genl_family,
159 &acpi_event_mcgrp);
160 if (result)
161 genl_unregister_family(&acpi_event_genl_family);
162
163 return result;
164} 155}
165 156
166#else 157#else
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 272f00927761..1bdf104e90bb 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -3511,7 +3511,7 @@ static int init_card(struct atm_dev *dev)
3511 tmp = dev_get_by_name(&init_net, tname); /* jhs: was "tmp = dev_get(tname);" */ 3511 tmp = dev_get_by_name(&init_net, tname); /* jhs: was "tmp = dev_get(tname);" */
3512 if (tmp) { 3512 if (tmp) {
3513 memcpy(card->atmdev->esi, tmp->dev_addr, 6); 3513 memcpy(card->atmdev->esi, tmp->dev_addr, 6);
3514 3514 dev_put(tmp);
3515 printk("%s: ESI %pM\n", card->name, card->atmdev->esi); 3515 printk("%s: ESI %pM\n", card->name, card->atmdev->esi);
3516 } 3516 }
3517 /* 3517 /*
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index c73fc2b74de2..18c5b9b16645 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -32,11 +32,23 @@
32#include <linux/atomic.h> 32#include <linux/atomic.h>
33#include <linux/pid_namespace.h> 33#include <linux/pid_namespace.h>
34 34
35#include <asm/unaligned.h>
36
37#include <linux/cn_proc.h> 35#include <linux/cn_proc.h>
38 36
39#define CN_PROC_MSG_SIZE (sizeof(struct cn_msg) + sizeof(struct proc_event)) 37/*
38 * Size of a cn_msg followed by a proc_event structure. Since the
39 * sizeof struct cn_msg is a multiple of 4 bytes, but not 8 bytes, we
40 * add one 4-byte word to the size here, and then start the actual
41 * cn_msg structure 4 bytes into the stack buffer. The result is that
42 * the immediately following proc_event structure is aligned to 8 bytes.
43 */
44#define CN_PROC_MSG_SIZE (sizeof(struct cn_msg) + sizeof(struct proc_event) + 4)
45
46/* See comment above; we test our assumption about sizeof struct cn_msg here. */
47static inline struct cn_msg *buffer_to_cn_msg(__u8 *buffer)
48{
49 BUILD_BUG_ON(sizeof(struct cn_msg) != 20);
50 return (struct cn_msg *)(buffer + 4);
51}
40 52
41static atomic_t proc_event_num_listeners = ATOMIC_INIT(0); 53static atomic_t proc_event_num_listeners = ATOMIC_INIT(0);
42static struct cb_id cn_proc_event_id = { CN_IDX_PROC, CN_VAL_PROC }; 54static struct cb_id cn_proc_event_id = { CN_IDX_PROC, CN_VAL_PROC };
@@ -56,19 +68,19 @@ void proc_fork_connector(struct task_struct *task)
56{ 68{
57 struct cn_msg *msg; 69 struct cn_msg *msg;
58 struct proc_event *ev; 70 struct proc_event *ev;
59 __u8 buffer[CN_PROC_MSG_SIZE]; 71 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
60 struct timespec ts; 72 struct timespec ts;
61 struct task_struct *parent; 73 struct task_struct *parent;
62 74
63 if (atomic_read(&proc_event_num_listeners) < 1) 75 if (atomic_read(&proc_event_num_listeners) < 1)
64 return; 76 return;
65 77
66 msg = (struct cn_msg *)buffer; 78 msg = buffer_to_cn_msg(buffer);
67 ev = (struct proc_event *)msg->data; 79 ev = (struct proc_event *)msg->data;
68 memset(&ev->event_data, 0, sizeof(ev->event_data)); 80 memset(&ev->event_data, 0, sizeof(ev->event_data));
69 get_seq(&msg->seq, &ev->cpu); 81 get_seq(&msg->seq, &ev->cpu);
70 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 82 ktime_get_ts(&ts); /* get high res monotonic timestamp */
71 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 83 ev->timestamp_ns = timespec_to_ns(&ts);
72 ev->what = PROC_EVENT_FORK; 84 ev->what = PROC_EVENT_FORK;
73 rcu_read_lock(); 85 rcu_read_lock();
74 parent = rcu_dereference(task->real_parent); 86 parent = rcu_dereference(task->real_parent);
@@ -91,17 +103,17 @@ void proc_exec_connector(struct task_struct *task)
91 struct cn_msg *msg; 103 struct cn_msg *msg;
92 struct proc_event *ev; 104 struct proc_event *ev;
93 struct timespec ts; 105 struct timespec ts;
94 __u8 buffer[CN_PROC_MSG_SIZE]; 106 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
95 107
96 if (atomic_read(&proc_event_num_listeners) < 1) 108 if (atomic_read(&proc_event_num_listeners) < 1)
97 return; 109 return;
98 110
99 msg = (struct cn_msg *)buffer; 111 msg = buffer_to_cn_msg(buffer);
100 ev = (struct proc_event *)msg->data; 112 ev = (struct proc_event *)msg->data;
101 memset(&ev->event_data, 0, sizeof(ev->event_data)); 113 memset(&ev->event_data, 0, sizeof(ev->event_data));
102 get_seq(&msg->seq, &ev->cpu); 114 get_seq(&msg->seq, &ev->cpu);
103 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 115 ktime_get_ts(&ts); /* get high res monotonic timestamp */
104 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 116 ev->timestamp_ns = timespec_to_ns(&ts);
105 ev->what = PROC_EVENT_EXEC; 117 ev->what = PROC_EVENT_EXEC;
106 ev->event_data.exec.process_pid = task->pid; 118 ev->event_data.exec.process_pid = task->pid;
107 ev->event_data.exec.process_tgid = task->tgid; 119 ev->event_data.exec.process_tgid = task->tgid;
@@ -117,14 +129,14 @@ void proc_id_connector(struct task_struct *task, int which_id)
117{ 129{
118 struct cn_msg *msg; 130 struct cn_msg *msg;
119 struct proc_event *ev; 131 struct proc_event *ev;
120 __u8 buffer[CN_PROC_MSG_SIZE]; 132 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
121 struct timespec ts; 133 struct timespec ts;
122 const struct cred *cred; 134 const struct cred *cred;
123 135
124 if (atomic_read(&proc_event_num_listeners) < 1) 136 if (atomic_read(&proc_event_num_listeners) < 1)
125 return; 137 return;
126 138
127 msg = (struct cn_msg *)buffer; 139 msg = buffer_to_cn_msg(buffer);
128 ev = (struct proc_event *)msg->data; 140 ev = (struct proc_event *)msg->data;
129 memset(&ev->event_data, 0, sizeof(ev->event_data)); 141 memset(&ev->event_data, 0, sizeof(ev->event_data));
130 ev->what = which_id; 142 ev->what = which_id;
@@ -145,7 +157,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
145 rcu_read_unlock(); 157 rcu_read_unlock();
146 get_seq(&msg->seq, &ev->cpu); 158 get_seq(&msg->seq, &ev->cpu);
147 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 159 ktime_get_ts(&ts); /* get high res monotonic timestamp */
148 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 160 ev->timestamp_ns = timespec_to_ns(&ts);
149 161
150 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); 162 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
151 msg->ack = 0; /* not used */ 163 msg->ack = 0; /* not used */
@@ -159,17 +171,17 @@ void proc_sid_connector(struct task_struct *task)
159 struct cn_msg *msg; 171 struct cn_msg *msg;
160 struct proc_event *ev; 172 struct proc_event *ev;
161 struct timespec ts; 173 struct timespec ts;
162 __u8 buffer[CN_PROC_MSG_SIZE]; 174 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
163 175
164 if (atomic_read(&proc_event_num_listeners) < 1) 176 if (atomic_read(&proc_event_num_listeners) < 1)
165 return; 177 return;
166 178
167 msg = (struct cn_msg *)buffer; 179 msg = buffer_to_cn_msg(buffer);
168 ev = (struct proc_event *)msg->data; 180 ev = (struct proc_event *)msg->data;
169 memset(&ev->event_data, 0, sizeof(ev->event_data)); 181 memset(&ev->event_data, 0, sizeof(ev->event_data));
170 get_seq(&msg->seq, &ev->cpu); 182 get_seq(&msg->seq, &ev->cpu);
171 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 183 ktime_get_ts(&ts); /* get high res monotonic timestamp */
172 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 184 ev->timestamp_ns = timespec_to_ns(&ts);
173 ev->what = PROC_EVENT_SID; 185 ev->what = PROC_EVENT_SID;
174 ev->event_data.sid.process_pid = task->pid; 186 ev->event_data.sid.process_pid = task->pid;
175 ev->event_data.sid.process_tgid = task->tgid; 187 ev->event_data.sid.process_tgid = task->tgid;
@@ -186,17 +198,17 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
186 struct cn_msg *msg; 198 struct cn_msg *msg;
187 struct proc_event *ev; 199 struct proc_event *ev;
188 struct timespec ts; 200 struct timespec ts;
189 __u8 buffer[CN_PROC_MSG_SIZE]; 201 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
190 202
191 if (atomic_read(&proc_event_num_listeners) < 1) 203 if (atomic_read(&proc_event_num_listeners) < 1)
192 return; 204 return;
193 205
194 msg = (struct cn_msg *)buffer; 206 msg = buffer_to_cn_msg(buffer);
195 ev = (struct proc_event *)msg->data; 207 ev = (struct proc_event *)msg->data;
196 memset(&ev->event_data, 0, sizeof(ev->event_data)); 208 memset(&ev->event_data, 0, sizeof(ev->event_data));
197 get_seq(&msg->seq, &ev->cpu); 209 get_seq(&msg->seq, &ev->cpu);
198 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 210 ktime_get_ts(&ts); /* get high res monotonic timestamp */
199 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 211 ev->timestamp_ns = timespec_to_ns(&ts);
200 ev->what = PROC_EVENT_PTRACE; 212 ev->what = PROC_EVENT_PTRACE;
201 ev->event_data.ptrace.process_pid = task->pid; 213 ev->event_data.ptrace.process_pid = task->pid;
202 ev->event_data.ptrace.process_tgid = task->tgid; 214 ev->event_data.ptrace.process_tgid = task->tgid;
@@ -221,17 +233,17 @@ void proc_comm_connector(struct task_struct *task)
221 struct cn_msg *msg; 233 struct cn_msg *msg;
222 struct proc_event *ev; 234 struct proc_event *ev;
223 struct timespec ts; 235 struct timespec ts;
224 __u8 buffer[CN_PROC_MSG_SIZE]; 236 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
225 237
226 if (atomic_read(&proc_event_num_listeners) < 1) 238 if (atomic_read(&proc_event_num_listeners) < 1)
227 return; 239 return;
228 240
229 msg = (struct cn_msg *)buffer; 241 msg = buffer_to_cn_msg(buffer);
230 ev = (struct proc_event *)msg->data; 242 ev = (struct proc_event *)msg->data;
231 memset(&ev->event_data, 0, sizeof(ev->event_data)); 243 memset(&ev->event_data, 0, sizeof(ev->event_data));
232 get_seq(&msg->seq, &ev->cpu); 244 get_seq(&msg->seq, &ev->cpu);
233 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 245 ktime_get_ts(&ts); /* get high res monotonic timestamp */
234 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 246 ev->timestamp_ns = timespec_to_ns(&ts);
235 ev->what = PROC_EVENT_COMM; 247 ev->what = PROC_EVENT_COMM;
236 ev->event_data.comm.process_pid = task->pid; 248 ev->event_data.comm.process_pid = task->pid;
237 ev->event_data.comm.process_tgid = task->tgid; 249 ev->event_data.comm.process_tgid = task->tgid;
@@ -248,18 +260,18 @@ void proc_coredump_connector(struct task_struct *task)
248{ 260{
249 struct cn_msg *msg; 261 struct cn_msg *msg;
250 struct proc_event *ev; 262 struct proc_event *ev;
251 __u8 buffer[CN_PROC_MSG_SIZE]; 263 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
252 struct timespec ts; 264 struct timespec ts;
253 265
254 if (atomic_read(&proc_event_num_listeners) < 1) 266 if (atomic_read(&proc_event_num_listeners) < 1)
255 return; 267 return;
256 268
257 msg = (struct cn_msg *)buffer; 269 msg = buffer_to_cn_msg(buffer);
258 ev = (struct proc_event *)msg->data; 270 ev = (struct proc_event *)msg->data;
259 memset(&ev->event_data, 0, sizeof(ev->event_data)); 271 memset(&ev->event_data, 0, sizeof(ev->event_data));
260 get_seq(&msg->seq, &ev->cpu); 272 get_seq(&msg->seq, &ev->cpu);
261 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 273 ktime_get_ts(&ts); /* get high res monotonic timestamp */
262 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 274 ev->timestamp_ns = timespec_to_ns(&ts);
263 ev->what = PROC_EVENT_COREDUMP; 275 ev->what = PROC_EVENT_COREDUMP;
264 ev->event_data.coredump.process_pid = task->pid; 276 ev->event_data.coredump.process_pid = task->pid;
265 ev->event_data.coredump.process_tgid = task->tgid; 277 ev->event_data.coredump.process_tgid = task->tgid;
@@ -275,18 +287,18 @@ void proc_exit_connector(struct task_struct *task)
275{ 287{
276 struct cn_msg *msg; 288 struct cn_msg *msg;
277 struct proc_event *ev; 289 struct proc_event *ev;
278 __u8 buffer[CN_PROC_MSG_SIZE]; 290 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
279 struct timespec ts; 291 struct timespec ts;
280 292
281 if (atomic_read(&proc_event_num_listeners) < 1) 293 if (atomic_read(&proc_event_num_listeners) < 1)
282 return; 294 return;
283 295
284 msg = (struct cn_msg *)buffer; 296 msg = buffer_to_cn_msg(buffer);
285 ev = (struct proc_event *)msg->data; 297 ev = (struct proc_event *)msg->data;
286 memset(&ev->event_data, 0, sizeof(ev->event_data)); 298 memset(&ev->event_data, 0, sizeof(ev->event_data));
287 get_seq(&msg->seq, &ev->cpu); 299 get_seq(&msg->seq, &ev->cpu);
288 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 300 ktime_get_ts(&ts); /* get high res monotonic timestamp */
289 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 301 ev->timestamp_ns = timespec_to_ns(&ts);
290 ev->what = PROC_EVENT_EXIT; 302 ev->what = PROC_EVENT_EXIT;
291 ev->event_data.exit.process_pid = task->pid; 303 ev->event_data.exit.process_pid = task->pid;
292 ev->event_data.exit.process_tgid = task->tgid; 304 ev->event_data.exit.process_tgid = task->tgid;
@@ -312,18 +324,18 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
312{ 324{
313 struct cn_msg *msg; 325 struct cn_msg *msg;
314 struct proc_event *ev; 326 struct proc_event *ev;
315 __u8 buffer[CN_PROC_MSG_SIZE]; 327 __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
316 struct timespec ts; 328 struct timespec ts;
317 329
318 if (atomic_read(&proc_event_num_listeners) < 1) 330 if (atomic_read(&proc_event_num_listeners) < 1)
319 return; 331 return;
320 332
321 msg = (struct cn_msg *)buffer; 333 msg = buffer_to_cn_msg(buffer);
322 ev = (struct proc_event *)msg->data; 334 ev = (struct proc_event *)msg->data;
323 memset(&ev->event_data, 0, sizeof(ev->event_data)); 335 memset(&ev->event_data, 0, sizeof(ev->event_data));
324 msg->seq = rcvd_seq; 336 msg->seq = rcvd_seq;
325 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 337 ktime_get_ts(&ts); /* get high res monotonic timestamp */
326 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 338 ev->timestamp_ns = timespec_to_ns(&ts);
327 ev->cpu = -1; 339 ev->cpu = -1;
328 ev->what = PROC_EVENT_NONE; 340 ev->what = PROC_EVENT_NONE;
329 ev->event_data.ack.err = err; 341 ev->event_data.ack.err = err;
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index baf2686aa8eb..02125e6a9109 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
1083 spin_unlock_irqrestore(&card->isdnloop_lock, flags); 1083 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1084 return -ENOMEM; 1084 return -ENOMEM;
1085 } 1085 }
1086 for (i = 0; i < 3; i++) 1086 for (i = 0; i < 3; i++) {
1087 strcpy(card->s0num[i], sdef.num[i]); 1087 strlcpy(card->s0num[i], sdef.num[i],
1088 sizeof(card->s0num[0]));
1089 }
1088 break; 1090 break;
1089 case ISDN_PTYPE_1TR6: 1091 case ISDN_PTYPE_1TR6:
1090 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", 1092 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
@@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
1097 spin_unlock_irqrestore(&card->isdnloop_lock, flags); 1099 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1098 return -ENOMEM; 1100 return -ENOMEM;
1099 } 1101 }
1100 strcpy(card->s0num[0], sdef.num[0]); 1102 strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0]));
1101 card->s0num[1][0] = '\0'; 1103 card->s0num[1][0] = '\0';
1102 card->s0num[2][0] = '\0'; 1104 card->s0num[2][0] = '\0';
1103 break; 1105 break;
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index bc8fd362a5aa..0ec2a7e8c8a9 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -524,8 +524,9 @@ static ssize_t bonding_store_arp_interval(struct device *d,
524 goto out; 524 goto out;
525 } 525 }
526 if (bond->params.mode == BOND_MODE_ALB || 526 if (bond->params.mode == BOND_MODE_ALB ||
527 bond->params.mode == BOND_MODE_TLB) { 527 bond->params.mode == BOND_MODE_TLB ||
528 pr_info("%s: ARP monitoring cannot be used with ALB/TLB. Only MII monitoring is supported on %s.\n", 528 bond->params.mode == BOND_MODE_8023AD) {
529 pr_info("%s: ARP monitoring cannot be used with ALB/TLB/802.3ad. Only MII monitoring is supported on %s.\n",
529 bond->dev->name, bond->dev->name); 530 bond->dev->name, bond->dev->name);
530 ret = -EINVAL; 531 ret = -EINVAL;
531 goto out; 532 goto out;
@@ -603,15 +604,14 @@ static ssize_t bonding_store_arp_targets(struct device *d,
603 return restart_syscall(); 604 return restart_syscall();
604 605
605 targets = bond->params.arp_targets; 606 targets = bond->params.arp_targets;
606 newtarget = in_aton(buf + 1); 607 if (!in4_pton(buf + 1, -1, (u8 *)&newtarget, -1, NULL) ||
608 IS_IP_TARGET_UNUSABLE_ADDRESS(newtarget)) {
609 pr_err("%s: invalid ARP target %pI4 specified for addition\n",
610 bond->dev->name, &newtarget);
611 goto out;
612 }
607 /* look for adds */ 613 /* look for adds */
608 if (buf[0] == '+') { 614 if (buf[0] == '+') {
609 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
610 pr_err("%s: invalid ARP target %pI4 specified for addition\n",
611 bond->dev->name, &newtarget);
612 goto out;
613 }
614
615 if (bond_get_targets_ip(targets, newtarget) != -1) { /* dup */ 615 if (bond_get_targets_ip(targets, newtarget) != -1) { /* dup */
616 pr_err("%s: ARP target %pI4 is already present\n", 616 pr_err("%s: ARP target %pI4 is already present\n",
617 bond->dev->name, &newtarget); 617 bond->dev->name, &newtarget);
@@ -634,12 +634,6 @@ static ssize_t bonding_store_arp_targets(struct device *d,
634 targets[ind] = newtarget; 634 targets[ind] = newtarget;
635 write_unlock_bh(&bond->lock); 635 write_unlock_bh(&bond->lock);
636 } else if (buf[0] == '-') { 636 } else if (buf[0] == '-') {
637 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
638 pr_err("%s: invalid ARP target %pI4 specified for removal\n",
639 bond->dev->name, &newtarget);
640 goto out;
641 }
642
643 ind = bond_get_targets_ip(targets, newtarget); 637 ind = bond_get_targets_ip(targets, newtarget);
644 if (ind == -1) { 638 if (ind == -1) {
645 pr_err("%s: unable to remove nonexistent ARP target %pI4.\n", 639 pr_err("%s: unable to remove nonexistent ARP target %pI4.\n",
@@ -701,6 +695,8 @@ static ssize_t bonding_store_downdelay(struct device *d,
701 int new_value, ret = count; 695 int new_value, ret = count;
702 struct bonding *bond = to_bond(d); 696 struct bonding *bond = to_bond(d);
703 697
698 if (!rtnl_trylock())
699 return restart_syscall();
704 if (!(bond->params.miimon)) { 700 if (!(bond->params.miimon)) {
705 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n", 701 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
706 bond->dev->name); 702 bond->dev->name);
@@ -734,6 +730,7 @@ static ssize_t bonding_store_downdelay(struct device *d,
734 } 730 }
735 731
736out: 732out:
733 rtnl_unlock();
737 return ret; 734 return ret;
738} 735}
739static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR, 736static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR,
@@ -756,6 +753,8 @@ static ssize_t bonding_store_updelay(struct device *d,
756 int new_value, ret = count; 753 int new_value, ret = count;
757 struct bonding *bond = to_bond(d); 754 struct bonding *bond = to_bond(d);
758 755
756 if (!rtnl_trylock())
757 return restart_syscall();
759 if (!(bond->params.miimon)) { 758 if (!(bond->params.miimon)) {
760 pr_err("%s: Unable to set up delay as MII monitoring is disabled\n", 759 pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
761 bond->dev->name); 760 bond->dev->name);
@@ -789,6 +788,7 @@ static ssize_t bonding_store_updelay(struct device *d,
789 } 788 }
790 789
791out: 790out:
791 rtnl_unlock();
792 return ret; 792 return ret;
793} 793}
794static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR, 794static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 77a07a12e77f..ca31286aa028 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -63,6 +63,9 @@
63 (((mode) == BOND_MODE_TLB) || \ 63 (((mode) == BOND_MODE_TLB) || \
64 ((mode) == BOND_MODE_ALB)) 64 ((mode) == BOND_MODE_ALB))
65 65
66#define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \
67 ((htonl(INADDR_BROADCAST) == a) || \
68 ipv4_is_zeronet(a))
66/* 69/*
67 * Less bad way to call ioctl from within the kernel; this needs to be 70 * Less bad way to call ioctl from within the kernel; this needs to be
68 * done some other way to get the call out of interrupt context. 71 * done some other way to get the call out of interrupt context.
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index 5aa5e8146496..c3c4c266b846 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -1388,6 +1388,9 @@ static int alx_resume(struct device *dev)
1388{ 1388{
1389 struct pci_dev *pdev = to_pci_dev(dev); 1389 struct pci_dev *pdev = to_pci_dev(dev);
1390 struct alx_priv *alx = pci_get_drvdata(pdev); 1390 struct alx_priv *alx = pci_get_drvdata(pdev);
1391 struct alx_hw *hw = &alx->hw;
1392
1393 alx_reset_phy(hw);
1391 1394
1392 if (!netif_running(alx->dev)) 1395 if (!netif_running(alx->dev))
1393 return 0; 1396 return 0;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 4e01c57d8c8d..a1f66e2c9a86 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1376,7 +1376,6 @@ enum {
1376 BNX2X_SP_RTNL_RX_MODE, 1376 BNX2X_SP_RTNL_RX_MODE,
1377 BNX2X_SP_RTNL_HYPERVISOR_VLAN, 1377 BNX2X_SP_RTNL_HYPERVISOR_VLAN,
1378 BNX2X_SP_RTNL_TX_STOP, 1378 BNX2X_SP_RTNL_TX_STOP,
1379 BNX2X_SP_RTNL_TX_RESUME,
1380}; 1379};
1381 1380
1382struct bnx2x_prev_path_list { 1381struct bnx2x_prev_path_list {
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index dcafbda3e5be..ec96130533cc 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -2959,6 +2959,10 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
2959 2959
2960 bp->port.pmf = 0; 2960 bp->port.pmf = 0;
2961 2961
2962 /* clear pending work in rtnl task */
2963 bp->sp_rtnl_state = 0;
2964 smp_mb();
2965
2962 /* Free SKBs, SGEs, TPA pool and driver internals */ 2966 /* Free SKBs, SGEs, TPA pool and driver internals */
2963 bnx2x_free_skbs(bp); 2967 bnx2x_free_skbs(bp);
2964 if (CNIC_LOADED(bp)) 2968 if (CNIC_LOADED(bp))
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
index fcf2761d8828..fdace204b054 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
@@ -778,11 +778,6 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
778 778
779 /* ets may affect cmng configuration: reinit it in hw */ 779 /* ets may affect cmng configuration: reinit it in hw */
780 bnx2x_set_local_cmng(bp); 780 bnx2x_set_local_cmng(bp);
781
782 set_bit(BNX2X_SP_RTNL_TX_RESUME, &bp->sp_rtnl_state);
783
784 schedule_delayed_work(&bp->sp_rtnl_task, 0);
785
786 return; 781 return;
787 case BNX2X_DCBX_STATE_TX_RELEASED: 782 case BNX2X_DCBX_STATE_TX_RELEASED:
788 DP(BNX2X_MSG_DCB, "BNX2X_DCBX_STATE_TX_RELEASED\n"); 783 DP(BNX2X_MSG_DCB, "BNX2X_DCBX_STATE_TX_RELEASED\n");
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index e622cc1f96ff..814d0eca9b33 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -577,7 +577,9 @@ void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
577 rc = bnx2x_issue_dmae_with_comp(bp, &dmae, bnx2x_sp(bp, wb_comp)); 577 rc = bnx2x_issue_dmae_with_comp(bp, &dmae, bnx2x_sp(bp, wb_comp));
578 if (rc) { 578 if (rc) {
579 BNX2X_ERR("DMAE returned failure %d\n", rc); 579 BNX2X_ERR("DMAE returned failure %d\n", rc);
580#ifdef BNX2X_STOP_ON_ERROR
580 bnx2x_panic(); 581 bnx2x_panic();
582#endif
581 } 583 }
582} 584}
583 585
@@ -614,7 +616,9 @@ void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32)
614 rc = bnx2x_issue_dmae_with_comp(bp, &dmae, bnx2x_sp(bp, wb_comp)); 616 rc = bnx2x_issue_dmae_with_comp(bp, &dmae, bnx2x_sp(bp, wb_comp));
615 if (rc) { 617 if (rc) {
616 BNX2X_ERR("DMAE returned failure %d\n", rc); 618 BNX2X_ERR("DMAE returned failure %d\n", rc);
619#ifdef BNX2X_STOP_ON_ERROR
617 bnx2x_panic(); 620 bnx2x_panic();
621#endif
618 } 622 }
619} 623}
620 624
@@ -5231,18 +5235,18 @@ static void bnx2x_eq_int(struct bnx2x *bp)
5231 5235
5232 case EVENT_RING_OPCODE_STOP_TRAFFIC: 5236 case EVENT_RING_OPCODE_STOP_TRAFFIC:
5233 DP(BNX2X_MSG_SP | BNX2X_MSG_DCB, "got STOP TRAFFIC\n"); 5237 DP(BNX2X_MSG_SP | BNX2X_MSG_DCB, "got STOP TRAFFIC\n");
5238 bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_PAUSED);
5234 if (f_obj->complete_cmd(bp, f_obj, 5239 if (f_obj->complete_cmd(bp, f_obj,
5235 BNX2X_F_CMD_TX_STOP)) 5240 BNX2X_F_CMD_TX_STOP))
5236 break; 5241 break;
5237 bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_PAUSED);
5238 goto next_spqe; 5242 goto next_spqe;
5239 5243
5240 case EVENT_RING_OPCODE_START_TRAFFIC: 5244 case EVENT_RING_OPCODE_START_TRAFFIC:
5241 DP(BNX2X_MSG_SP | BNX2X_MSG_DCB, "got START TRAFFIC\n"); 5245 DP(BNX2X_MSG_SP | BNX2X_MSG_DCB, "got START TRAFFIC\n");
5246 bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_RELEASED);
5242 if (f_obj->complete_cmd(bp, f_obj, 5247 if (f_obj->complete_cmd(bp, f_obj,
5243 BNX2X_F_CMD_TX_START)) 5248 BNX2X_F_CMD_TX_START))
5244 break; 5249 break;
5245 bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_RELEASED);
5246 goto next_spqe; 5250 goto next_spqe;
5247 5251
5248 case EVENT_RING_OPCODE_FUNCTION_UPDATE: 5252 case EVENT_RING_OPCODE_FUNCTION_UPDATE:
@@ -9352,6 +9356,10 @@ static int bnx2x_process_kill(struct bnx2x *bp, bool global)
9352 bnx2x_process_kill_chip_reset(bp, global); 9356 bnx2x_process_kill_chip_reset(bp, global);
9353 barrier(); 9357 barrier();
9354 9358
9359 /* clear errors in PGB */
9360 if (!CHIP_IS_E1x(bp))
9361 REG_WR(bp, PGLUE_B_REG_LATCHED_ERRORS_CLR, 0x7f);
9362
9355 /* Recover after reset: */ 9363 /* Recover after reset: */
9356 /* MCP */ 9364 /* MCP */
9357 if (global && bnx2x_reset_mcp_comp(bp, val)) 9365 if (global && bnx2x_reset_mcp_comp(bp, val))
@@ -9706,11 +9714,10 @@ sp_rtnl_not_reset:
9706 &bp->sp_rtnl_state)) 9714 &bp->sp_rtnl_state))
9707 bnx2x_pf_set_vfs_vlan(bp); 9715 bnx2x_pf_set_vfs_vlan(bp);
9708 9716
9709 if (test_and_clear_bit(BNX2X_SP_RTNL_TX_STOP, &bp->sp_rtnl_state)) 9717 if (test_and_clear_bit(BNX2X_SP_RTNL_TX_STOP, &bp->sp_rtnl_state)) {
9710 bnx2x_dcbx_stop_hw_tx(bp); 9718 bnx2x_dcbx_stop_hw_tx(bp);
9711
9712 if (test_and_clear_bit(BNX2X_SP_RTNL_TX_RESUME, &bp->sp_rtnl_state))
9713 bnx2x_dcbx_resume_hw_tx(bp); 9719 bnx2x_dcbx_resume_hw_tx(bp);
9720 }
9714 9721
9715 /* work which needs rtnl lock not-taken (as it takes the lock itself and 9722 /* work which needs rtnl lock not-taken (as it takes the lock itself and
9716 * can be called from other contexts as well) 9723 * can be called from other contexts as well)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
index 5ecf267dc4cc..3efbb35267c8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
@@ -2864,6 +2864,17 @@
2864#define PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ 0x9430 2864#define PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ 0x9430
2865#define PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_WRITE 0x9434 2865#define PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_WRITE 0x9434
2866#define PGLUE_B_REG_INTERNAL_VFID_ENABLE 0x9438 2866#define PGLUE_B_REG_INTERNAL_VFID_ENABLE 0x9438
2867/* [W 7] Writing 1 to each bit in this register clears a corresponding error
2868 * details register and enables logging new error details. Bit 0 - clears
2869 * INCORRECT_RCV_DETAILS; Bit 1 - clears RX_ERR_DETAILS; Bit 2 - clears
2870 * TX_ERR_WR_ADD_31_0 TX_ERR_WR_ADD_63_32 TX_ERR_WR_DETAILS
2871 * TX_ERR_WR_DETAILS2 TX_ERR_RD_ADD_31_0 TX_ERR_RD_ADD_63_32
2872 * TX_ERR_RD_DETAILS TX_ERR_RD_DETAILS2 TX_ERR_WR_DETAILS_ICPL; Bit 3 -
2873 * clears VF_LENGTH_VIOLATION_DETAILS. Bit 4 - clears
2874 * VF_GRC_SPACE_VIOLATION_DETAILS. Bit 5 - clears RX_TCPL_ERR_DETAILS. Bit 6
2875 * - clears TCPL_IN_TWO_RCBS_DETAILS. */
2876#define PGLUE_B_REG_LATCHED_ERRORS_CLR 0x943c
2877
2867/* [R 9] Interrupt register #0 read */ 2878/* [R 9] Interrupt register #0 read */
2868#define PGLUE_B_REG_PGLUE_B_INT_STS 0x9298 2879#define PGLUE_B_REG_PGLUE_B_INT_STS 0x9298
2869/* [RC 9] Interrupt register #0 read clear */ 2880/* [RC 9] Interrupt register #0 read clear */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
index 9199adf32d33..efa8a151d789 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
@@ -152,7 +152,7 @@ static int bnx2x_send_msg2pf(struct bnx2x *bp, u8 *done, dma_addr_t msg_mapping)
152 if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) { 152 if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) {
153 DP(BNX2X_MSG_IOV, "detecting channel down. Aborting message\n"); 153 DP(BNX2X_MSG_IOV, "detecting channel down. Aborting message\n");
154 *done = PFVF_STATUS_SUCCESS; 154 *done = PFVF_STATUS_SUCCESS;
155 return 0; 155 return -EINVAL;
156 } 156 }
157 157
158 /* Write message address */ 158 /* Write message address */
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 00c5be8c55b8..a9e068423ba0 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -13618,16 +13618,9 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev,
13618 if (stmpconf.flags) 13618 if (stmpconf.flags)
13619 return -EINVAL; 13619 return -EINVAL;
13620 13620
13621 switch (stmpconf.tx_type) { 13621 if (stmpconf.tx_type != HWTSTAMP_TX_ON &&
13622 case HWTSTAMP_TX_ON: 13622 stmpconf.tx_type != HWTSTAMP_TX_OFF)
13623 tg3_flag_set(tp, TX_TSTAMP_EN);
13624 break;
13625 case HWTSTAMP_TX_OFF:
13626 tg3_flag_clear(tp, TX_TSTAMP_EN);
13627 break;
13628 default:
13629 return -ERANGE; 13623 return -ERANGE;
13630 }
13631 13624
13632 switch (stmpconf.rx_filter) { 13625 switch (stmpconf.rx_filter) {
13633 case HWTSTAMP_FILTER_NONE: 13626 case HWTSTAMP_FILTER_NONE:
@@ -13689,6 +13682,11 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev,
13689 tw32(TG3_RX_PTP_CTL, 13682 tw32(TG3_RX_PTP_CTL,
13690 tp->rxptpctl | TG3_RX_PTP_CTL_HWTS_INTERLOCK); 13683 tp->rxptpctl | TG3_RX_PTP_CTL_HWTS_INTERLOCK);
13691 13684
13685 if (stmpconf.tx_type == HWTSTAMP_TX_ON)
13686 tg3_flag_set(tp, TX_TSTAMP_EN);
13687 else
13688 tg3_flag_clear(tp, TX_TSTAMP_EN);
13689
13692 return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ? 13690 return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ?
13693 -EFAULT : 0; 13691 -EFAULT : 0;
13694} 13692}
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 7fb0edfe3d24..dbcd5262c016 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1758,7 +1758,7 @@ err:
1758 1758
1759/* Uses sycnhronous mcc */ 1759/* Uses sycnhronous mcc */
1760int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, 1760int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
1761 u32 num, bool untagged, bool promiscuous) 1761 u32 num, bool promiscuous)
1762{ 1762{
1763 struct be_mcc_wrb *wrb; 1763 struct be_mcc_wrb *wrb;
1764 struct be_cmd_req_vlan_config *req; 1764 struct be_cmd_req_vlan_config *req;
@@ -1778,7 +1778,7 @@ int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
1778 1778
1779 req->interface_id = if_id; 1779 req->interface_id = if_id;
1780 req->promiscuous = promiscuous; 1780 req->promiscuous = promiscuous;
1781 req->untagged = untagged; 1781 req->untagged = BE_IF_FLAGS_UNTAGGED & be_if_cap_flags(adapter) ? 1 : 0;
1782 req->num_vlan = num; 1782 req->num_vlan = num;
1783 if (!promiscuous) { 1783 if (!promiscuous) {
1784 memcpy(req->normal_vlan, vtag_array, 1784 memcpy(req->normal_vlan, vtag_array,
@@ -1847,7 +1847,19 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
1847 memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN); 1847 memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN);
1848 } 1848 }
1849 1849
1850 if ((req->if_flags_mask & cpu_to_le32(be_if_cap_flags(adapter))) !=
1851 req->if_flags_mask) {
1852 dev_warn(&adapter->pdev->dev,
1853 "Cannot set rx filter flags 0x%x\n",
1854 req->if_flags_mask);
1855 dev_warn(&adapter->pdev->dev,
1856 "Interface is capable of 0x%x flags only\n",
1857 be_if_cap_flags(adapter));
1858 }
1859 req->if_flags_mask &= cpu_to_le32(be_if_cap_flags(adapter));
1860
1850 status = be_mcc_notify_wait(adapter); 1861 status = be_mcc_notify_wait(adapter);
1862
1851err: 1863err:
1852 spin_unlock_bh(&adapter->mcc_lock); 1864 spin_unlock_bh(&adapter->mcc_lock);
1853 return status; 1865 return status;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index edf3e8a0ff83..0075686276aa 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1984,7 +1984,7 @@ int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver,
1984 char *fw_on_flash); 1984 char *fw_on_flash);
1985int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *, int num); 1985int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *, int num);
1986int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, 1986int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
1987 u32 num, bool untagged, bool promiscuous); 1987 u32 num, bool promiscuous);
1988int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 status); 1988int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 status);
1989int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc); 1989int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc);
1990int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc); 1990int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index eaecaadfa8c5..abde97471636 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1079,7 +1079,7 @@ static int be_vid_config(struct be_adapter *adapter)
1079 vids[num++] = cpu_to_le16(i); 1079 vids[num++] = cpu_to_le16(i);
1080 1080
1081 status = be_cmd_vlan_config(adapter, adapter->if_handle, 1081 status = be_cmd_vlan_config(adapter, adapter->if_handle,
1082 vids, num, 1, 0); 1082 vids, num, 0);
1083 1083
1084 if (status) { 1084 if (status) {
1085 /* Set to VLAN promisc mode as setting VLAN filter failed */ 1085 /* Set to VLAN promisc mode as setting VLAN filter failed */
@@ -2676,6 +2676,11 @@ static int be_close(struct net_device *netdev)
2676 2676
2677 be_rx_qs_destroy(adapter); 2677 be_rx_qs_destroy(adapter);
2678 2678
2679 for (i = 1; i < (adapter->uc_macs + 1); i++)
2680 be_cmd_pmac_del(adapter, adapter->if_handle,
2681 adapter->pmac_id[i], 0);
2682 adapter->uc_macs = 0;
2683
2679 for_all_evt_queues(adapter, eqo, i) { 2684 for_all_evt_queues(adapter, eqo, i) {
2680 if (msix_enabled(adapter)) 2685 if (msix_enabled(adapter))
2681 synchronize_irq(be_msix_vec_get(adapter, eqo)); 2686 synchronize_irq(be_msix_vec_get(adapter, eqo));
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index b2793b91cc55..4cbebf3d80eb 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -386,7 +386,14 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
386 */ 386 */
387 bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr, 387 bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr,
388 FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); 388 FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
389 389 if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) {
390 bdp->cbd_bufaddr = 0;
391 fep->tx_skbuff[index] = NULL;
392 dev_kfree_skb_any(skb);
393 if (net_ratelimit())
394 netdev_err(ndev, "Tx DMA memory map failed\n");
395 return NETDEV_TX_OK;
396 }
390 /* Send it on its way. Tell FEC it's ready, interrupt when done, 397 /* Send it on its way. Tell FEC it's ready, interrupt when done,
391 * it's the last BD of the frame, and to put the CRC on the end. 398 * it's the last BD of the frame, and to put the CRC on the end.
392 */ 399 */
@@ -861,6 +868,7 @@ fec_enet_rx(struct net_device *ndev, int budget)
861 struct bufdesc_ex *ebdp = NULL; 868 struct bufdesc_ex *ebdp = NULL;
862 bool vlan_packet_rcvd = false; 869 bool vlan_packet_rcvd = false;
863 u16 vlan_tag; 870 u16 vlan_tag;
871 int index = 0;
864 872
865#ifdef CONFIG_M532x 873#ifdef CONFIG_M532x
866 flush_cache_all(); 874 flush_cache_all();
@@ -916,10 +924,15 @@ fec_enet_rx(struct net_device *ndev, int budget)
916 ndev->stats.rx_packets++; 924 ndev->stats.rx_packets++;
917 pkt_len = bdp->cbd_datlen; 925 pkt_len = bdp->cbd_datlen;
918 ndev->stats.rx_bytes += pkt_len; 926 ndev->stats.rx_bytes += pkt_len;
919 data = (__u8*)__va(bdp->cbd_bufaddr);
920 927
921 dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, 928 if (fep->bufdesc_ex)
922 FEC_ENET_TX_FRSIZE, DMA_FROM_DEVICE); 929 index = (struct bufdesc_ex *)bdp -
930 (struct bufdesc_ex *)fep->rx_bd_base;
931 else
932 index = bdp - fep->rx_bd_base;
933 data = fep->rx_skbuff[index]->data;
934 dma_sync_single_for_cpu(&fep->pdev->dev, bdp->cbd_bufaddr,
935 FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE);
923 936
924 if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) 937 if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME)
925 swap_buffer(data, pkt_len); 938 swap_buffer(data, pkt_len);
@@ -999,8 +1012,8 @@ fec_enet_rx(struct net_device *ndev, int budget)
999 napi_gro_receive(&fep->napi, skb); 1012 napi_gro_receive(&fep->napi, skb);
1000 } 1013 }
1001 1014
1002 bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, data, 1015 dma_sync_single_for_device(&fep->pdev->dev, bdp->cbd_bufaddr,
1003 FEC_ENET_TX_FRSIZE, DMA_FROM_DEVICE); 1016 FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE);
1004rx_processing_done: 1017rx_processing_done:
1005 /* Clear the status flags for this buffer */ 1018 /* Clear the status flags for this buffer */
1006 status &= ~BD_ENET_RX_STATS; 1019 status &= ~BD_ENET_RX_STATS;
@@ -1719,6 +1732,12 @@ static int fec_enet_alloc_buffers(struct net_device *ndev)
1719 1732
1720 bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, skb->data, 1733 bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, skb->data,
1721 FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); 1734 FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE);
1735 if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) {
1736 fec_enet_free_buffers(ndev);
1737 if (net_ratelimit())
1738 netdev_err(ndev, "Rx DMA memory map failed\n");
1739 return -ENOMEM;
1740 }
1722 bdp->cbd_sc = BD_ENET_RX_EMPTY; 1741 bdp->cbd_sc = BD_ENET_RX_EMPTY;
1723 1742
1724 if (fep->bufdesc_ex) { 1743 if (fep->bufdesc_ex) {
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index aedd5736a87d..8d3945ab7334 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -3482,10 +3482,10 @@ s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca)
3482 * specified. Matching the kind of event packet is not supported, with the 3482 * specified. Matching the kind of event packet is not supported, with the
3483 * exception of "all V2 events regardless of level 2 or 4". 3483 * exception of "all V2 events regardless of level 2 or 4".
3484 **/ 3484 **/
3485static int e1000e_config_hwtstamp(struct e1000_adapter *adapter) 3485static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,
3486 struct hwtstamp_config *config)
3486{ 3487{
3487 struct e1000_hw *hw = &adapter->hw; 3488 struct e1000_hw *hw = &adapter->hw;
3488 struct hwtstamp_config *config = &adapter->hwtstamp_config;
3489 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED; 3489 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
3490 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED; 3490 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
3491 u32 rxmtrl = 0; 3491 u32 rxmtrl = 0;
@@ -3586,6 +3586,8 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter)
3586 return -ERANGE; 3586 return -ERANGE;
3587 } 3587 }
3588 3588
3589 adapter->hwtstamp_config = *config;
3590
3589 /* enable/disable Tx h/w time stamping */ 3591 /* enable/disable Tx h/w time stamping */
3590 regval = er32(TSYNCTXCTL); 3592 regval = er32(TSYNCTXCTL);
3591 regval &= ~E1000_TSYNCTXCTL_ENABLED; 3593 regval &= ~E1000_TSYNCTXCTL_ENABLED;
@@ -3874,7 +3876,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
3874 e1000e_reset_adaptive(hw); 3876 e1000e_reset_adaptive(hw);
3875 3877
3876 /* initialize systim and reset the ns time counter */ 3878 /* initialize systim and reset the ns time counter */
3877 e1000e_config_hwtstamp(adapter); 3879 e1000e_config_hwtstamp(adapter, &adapter->hwtstamp_config);
3878 3880
3879 /* Set EEE advertisement as appropriate */ 3881 /* Set EEE advertisement as appropriate */
3880 if (adapter->flags2 & FLAG2_HAS_EEE) { 3882 if (adapter->flags2 & FLAG2_HAS_EEE) {
@@ -5797,14 +5799,10 @@ static int e1000e_hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)
5797 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 5799 if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
5798 return -EFAULT; 5800 return -EFAULT;
5799 5801
5800 adapter->hwtstamp_config = config; 5802 ret_val = e1000e_config_hwtstamp(adapter, &config);
5801
5802 ret_val = e1000e_config_hwtstamp(adapter);
5803 if (ret_val) 5803 if (ret_val)
5804 return ret_val; 5804 return ret_val;
5805 5805
5806 config = adapter->hwtstamp_config;
5807
5808 switch (config.rx_filter) { 5806 switch (config.rx_filter) {
5809 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: 5807 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
5810 case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: 5808 case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 00cd36e08601..61088a6a9424 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2890,7 +2890,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
2890 PHY_INTERFACE_MODE_GMII); 2890 PHY_INTERFACE_MODE_GMII);
2891 if (!mp->phy) 2891 if (!mp->phy)
2892 err = -ENODEV; 2892 err = -ENODEV;
2893 phy_addr_set(mp, mp->phy->addr); 2893 else
2894 phy_addr_set(mp, mp->phy->addr);
2894 } else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) { 2895 } else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
2895 mp->phy = phy_scan(mp, pd->phy_addr); 2896 mp->phy = phy_scan(mp, pd->phy_addr);
2896 2897
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 5a0f04c2c813..27ffe0ebf0a6 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -245,16 +245,8 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
245 /* Get ieee1588's dev information */ 245 /* Get ieee1588's dev information */
246 pdev = adapter->ptp_pdev; 246 pdev = adapter->ptp_pdev;
247 247
248 switch (cfg.tx_type) { 248 if (cfg.tx_type != HWTSTAMP_TX_OFF && cfg.tx_type != HWTSTAMP_TX_ON)
249 case HWTSTAMP_TX_OFF:
250 adapter->hwts_tx_en = 0;
251 break;
252 case HWTSTAMP_TX_ON:
253 adapter->hwts_tx_en = 1;
254 break;
255 default:
256 return -ERANGE; 249 return -ERANGE;
257 }
258 250
259 switch (cfg.rx_filter) { 251 switch (cfg.rx_filter) {
260 case HWTSTAMP_FILTER_NONE: 252 case HWTSTAMP_FILTER_NONE:
@@ -284,6 +276,8 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
284 return -ERANGE; 276 return -ERANGE;
285 } 277 }
286 278
279 adapter->hwts_tx_en = cfg.tx_type == HWTSTAMP_TX_ON;
280
287 /* Clear out any old time stamps. */ 281 /* Clear out any old time stamps. */
288 pch_ch_event_write(pdev, TX_SNAPSHOT_LOCKED | RX_SNAPSHOT_LOCKED); 282 pch_ch_event_write(pdev, TX_SNAPSHOT_LOCKED | RX_SNAPSHOT_LOCKED);
289 283
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8d4ccd35a016..8a7a23a84ac5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -435,16 +435,9 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
435 if (config.flags) 435 if (config.flags)
436 return -EINVAL; 436 return -EINVAL;
437 437
438 switch (config.tx_type) { 438 if (config.tx_type != HWTSTAMP_TX_OFF &&
439 case HWTSTAMP_TX_OFF: 439 config.tx_type != HWTSTAMP_TX_ON)
440 priv->hwts_tx_en = 0;
441 break;
442 case HWTSTAMP_TX_ON:
443 priv->hwts_tx_en = 1;
444 break;
445 default:
446 return -ERANGE; 440 return -ERANGE;
447 }
448 441
449 if (priv->adv_ts) { 442 if (priv->adv_ts) {
450 switch (config.rx_filter) { 443 switch (config.rx_filter) {
@@ -576,6 +569,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
576 } 569 }
577 } 570 }
578 priv->hwts_rx_en = ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1); 571 priv->hwts_rx_en = ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1);
572 priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON;
579 573
580 if (!priv->hwts_tx_en && !priv->hwts_rx_en) 574 if (!priv->hwts_tx_en && !priv->hwts_rx_en)
581 priv->hw->ptp->config_hw_tstamping(priv->ioaddr, 0); 575 priv->hw->ptp->config_hw_tstamping(priv->ioaddr, 0);
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 90d41d26ec6d..7536a4c01293 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -967,14 +967,19 @@ static inline void cpsw_add_dual_emac_def_ale_entries(
967 priv->host_port, ALE_VLAN, slave->port_vlan); 967 priv->host_port, ALE_VLAN, slave->port_vlan);
968} 968}
969 969
970static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) 970static void soft_reset_slave(struct cpsw_slave *slave)
971{ 971{
972 char name[32]; 972 char name[32];
973 u32 slave_port;
974
975 sprintf(name, "slave-%d", slave->slave_num);
976 973
974 snprintf(name, sizeof(name), "slave-%d", slave->slave_num);
977 soft_reset(name, &slave->sliver->soft_reset); 975 soft_reset(name, &slave->sliver->soft_reset);
976}
977
978static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
979{
980 u32 slave_port;
981
982 soft_reset_slave(slave);
978 983
979 /* setup priority mapping */ 984 /* setup priority mapping */
980 __raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map); 985 __raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map);
@@ -1323,6 +1328,10 @@ static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
1323 struct cpts *cpts = priv->cpts; 1328 struct cpts *cpts = priv->cpts;
1324 struct hwtstamp_config cfg; 1329 struct hwtstamp_config cfg;
1325 1330
1331 if (priv->version != CPSW_VERSION_1 &&
1332 priv->version != CPSW_VERSION_2)
1333 return -EOPNOTSUPP;
1334
1326 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) 1335 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
1327 return -EFAULT; 1336 return -EFAULT;
1328 1337
@@ -1330,16 +1339,8 @@ static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
1330 if (cfg.flags) 1339 if (cfg.flags)
1331 return -EINVAL; 1340 return -EINVAL;
1332 1341
1333 switch (cfg.tx_type) { 1342 if (cfg.tx_type != HWTSTAMP_TX_OFF && cfg.tx_type != HWTSTAMP_TX_ON)
1334 case HWTSTAMP_TX_OFF:
1335 cpts->tx_enable = 0;
1336 break;
1337 case HWTSTAMP_TX_ON:
1338 cpts->tx_enable = 1;
1339 break;
1340 default:
1341 return -ERANGE; 1343 return -ERANGE;
1342 }
1343 1344
1344 switch (cfg.rx_filter) { 1345 switch (cfg.rx_filter) {
1345 case HWTSTAMP_FILTER_NONE: 1346 case HWTSTAMP_FILTER_NONE:
@@ -1366,6 +1367,8 @@ static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
1366 return -ERANGE; 1367 return -ERANGE;
1367 } 1368 }
1368 1369
1370 cpts->tx_enable = cfg.tx_type == HWTSTAMP_TX_ON;
1371
1369 switch (priv->version) { 1372 switch (priv->version) {
1370 case CPSW_VERSION_1: 1373 case CPSW_VERSION_1:
1371 cpsw_hwtstamp_v1(priv); 1374 cpsw_hwtstamp_v1(priv);
@@ -1374,7 +1377,7 @@ static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
1374 cpsw_hwtstamp_v2(priv); 1377 cpsw_hwtstamp_v2(priv);
1375 break; 1378 break;
1376 default: 1379 default:
1377 return -ENOTSUPP; 1380 WARN_ON(1);
1378 } 1381 }
1379 1382
1380 return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; 1383 return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
@@ -2173,8 +2176,9 @@ static int cpsw_suspend(struct device *dev)
2173 2176
2174 if (netif_running(ndev)) 2177 if (netif_running(ndev))
2175 cpsw_ndo_stop(ndev); 2178 cpsw_ndo_stop(ndev);
2176 soft_reset("sliver 0", &priv->slaves[0].sliver->soft_reset); 2179
2177 soft_reset("sliver 1", &priv->slaves[1].sliver->soft_reset); 2180 for_each_slave(priv, soft_reset_slave);
2181
2178 pm_runtime_put_sync(&pdev->dev); 2182 pm_runtime_put_sync(&pdev->dev);
2179 2183
2180 /* Select sleep pin state */ 2184 /* Select sleep pin state */
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index e78802e75ea6..bcc224a83734 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -389,16 +389,8 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
389 ch = PORT2CHANNEL(port); 389 ch = PORT2CHANNEL(port);
390 regs = (struct ixp46x_ts_regs __iomem *) IXP4XX_TIMESYNC_BASE_VIRT; 390 regs = (struct ixp46x_ts_regs __iomem *) IXP4XX_TIMESYNC_BASE_VIRT;
391 391
392 switch (cfg.tx_type) { 392 if (cfg.tx_type != HWTSTAMP_TX_OFF && cfg.tx_type != HWTSTAMP_TX_ON)
393 case HWTSTAMP_TX_OFF:
394 port->hwts_tx_en = 0;
395 break;
396 case HWTSTAMP_TX_ON:
397 port->hwts_tx_en = 1;
398 break;
399 default:
400 return -ERANGE; 393 return -ERANGE;
401 }
402 394
403 switch (cfg.rx_filter) { 395 switch (cfg.rx_filter) {
404 case HWTSTAMP_FILTER_NONE: 396 case HWTSTAMP_FILTER_NONE:
@@ -416,6 +408,8 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
416 return -ERANGE; 408 return -ERANGE;
417 } 409 }
418 410
411 port->hwts_tx_en = cfg.tx_type == HWTSTAMP_TX_ON;
412
419 /* Clear out any old time stamps. */ 413 /* Clear out any old time stamps. */
420 __raw_writel(TX_SNAPSHOT_LOCKED | RX_SNAPSHOT_LOCKED, 414 __raw_writel(TX_SNAPSHOT_LOCKED | RX_SNAPSHOT_LOCKED,
421 &regs->channel[ch].ch_event); 415 &regs->channel[ch].ch_event);
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 9dccb1edfd2a..dc76670c2f2a 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -628,6 +628,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
628 const struct iovec *iv, unsigned long total_len, 628 const struct iovec *iv, unsigned long total_len,
629 size_t count, int noblock) 629 size_t count, int noblock)
630{ 630{
631 int good_linear = SKB_MAX_HEAD(NET_IP_ALIGN);
631 struct sk_buff *skb; 632 struct sk_buff *skb;
632 struct macvlan_dev *vlan; 633 struct macvlan_dev *vlan;
633 unsigned long len = total_len; 634 unsigned long len = total_len;
@@ -670,6 +671,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
670 671
671 if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) { 672 if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) {
672 copylen = vnet_hdr.hdr_len ? vnet_hdr.hdr_len : GOODCOPY_LEN; 673 copylen = vnet_hdr.hdr_len ? vnet_hdr.hdr_len : GOODCOPY_LEN;
674 if (copylen > good_linear)
675 copylen = good_linear;
673 linear = copylen; 676 linear = copylen;
674 if (iov_pages(iv, vnet_hdr_len + copylen, count) 677 if (iov_pages(iv, vnet_hdr_len + copylen, count)
675 <= MAX_SKB_FRAGS) 678 <= MAX_SKB_FRAGS)
@@ -678,7 +681,10 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
678 681
679 if (!zerocopy) { 682 if (!zerocopy) {
680 copylen = len; 683 copylen = len;
681 linear = vnet_hdr.hdr_len; 684 if (vnet_hdr.hdr_len > good_linear)
685 linear = good_linear;
686 else
687 linear = vnet_hdr.hdr_len;
682 } 688 }
683 689
684 skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen, 690 skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen,
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 6574eb8766f9..34b0de09d881 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2650,7 +2650,7 @@ static int team_nl_cmd_port_list_get(struct sk_buff *skb,
2650 return err; 2650 return err;
2651} 2651}
2652 2652
2653static struct genl_ops team_nl_ops[] = { 2653static const struct genl_ops team_nl_ops[] = {
2654 { 2654 {
2655 .cmd = TEAM_CMD_NOOP, 2655 .cmd = TEAM_CMD_NOOP,
2656 .doit = team_nl_cmd_noop, 2656 .doit = team_nl_cmd_noop,
@@ -2676,15 +2676,15 @@ static struct genl_ops team_nl_ops[] = {
2676 }, 2676 },
2677}; 2677};
2678 2678
2679static struct genl_multicast_group team_change_event_mcgrp = { 2679static const struct genl_multicast_group team_nl_mcgrps[] = {
2680 .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, 2680 { .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, },
2681}; 2681};
2682 2682
2683static int team_nl_send_multicast(struct sk_buff *skb, 2683static int team_nl_send_multicast(struct sk_buff *skb,
2684 struct team *team, u32 portid) 2684 struct team *team, u32 portid)
2685{ 2685{
2686 return genlmsg_multicast_netns(dev_net(team->dev), skb, 0, 2686 return genlmsg_multicast_netns(&team_nl_family, dev_net(team->dev),
2687 team_change_event_mcgrp.id, GFP_KERNEL); 2687 skb, 0, 0, GFP_KERNEL);
2688} 2688}
2689 2689
2690static int team_nl_send_event_options_get(struct team *team, 2690static int team_nl_send_event_options_get(struct team *team,
@@ -2703,23 +2703,8 @@ static int team_nl_send_event_port_get(struct team *team,
2703 2703
2704static int team_nl_init(void) 2704static int team_nl_init(void)
2705{ 2705{
2706 int err; 2706 return genl_register_family_with_ops_groups(&team_nl_family, team_nl_ops,
2707 2707 team_nl_mcgrps);
2708 err = genl_register_family_with_ops(&team_nl_family, team_nl_ops,
2709 ARRAY_SIZE(team_nl_ops));
2710 if (err)
2711 return err;
2712
2713 err = genl_register_mc_group(&team_nl_family, &team_change_event_mcgrp);
2714 if (err)
2715 goto err_change_event_grp_reg;
2716
2717 return 0;
2718
2719err_change_event_grp_reg:
2720 genl_unregister_family(&team_nl_family);
2721
2722 return err;
2723} 2708}
2724 2709
2725static void team_nl_fini(void) 2710static void team_nl_fini(void)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 7cb105c103fe..782e38bfc1ee 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -981,6 +981,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
981 struct sk_buff *skb; 981 struct sk_buff *skb;
982 size_t len = total_len, align = NET_SKB_PAD, linear; 982 size_t len = total_len, align = NET_SKB_PAD, linear;
983 struct virtio_net_hdr gso = { 0 }; 983 struct virtio_net_hdr gso = { 0 };
984 int good_linear;
984 int offset = 0; 985 int offset = 0;
985 int copylen; 986 int copylen;
986 bool zerocopy = false; 987 bool zerocopy = false;
@@ -1021,12 +1022,16 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1021 return -EINVAL; 1022 return -EINVAL;
1022 } 1023 }
1023 1024
1025 good_linear = SKB_MAX_HEAD(align);
1026
1024 if (msg_control) { 1027 if (msg_control) {
1025 /* There are 256 bytes to be copied in skb, so there is 1028 /* There are 256 bytes to be copied in skb, so there is
1026 * enough room for skb expand head in case it is used. 1029 * enough room for skb expand head in case it is used.
1027 * The rest of the buffer is mapped from userspace. 1030 * The rest of the buffer is mapped from userspace.
1028 */ 1031 */
1029 copylen = gso.hdr_len ? gso.hdr_len : GOODCOPY_LEN; 1032 copylen = gso.hdr_len ? gso.hdr_len : GOODCOPY_LEN;
1033 if (copylen > good_linear)
1034 copylen = good_linear;
1030 linear = copylen; 1035 linear = copylen;
1031 if (iov_pages(iv, offset + copylen, count) <= MAX_SKB_FRAGS) 1036 if (iov_pages(iv, offset + copylen, count) <= MAX_SKB_FRAGS)
1032 zerocopy = true; 1037 zerocopy = true;
@@ -1034,7 +1039,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1034 1039
1035 if (!zerocopy) { 1040 if (!zerocopy) {
1036 copylen = len; 1041 copylen = len;
1037 linear = gso.hdr_len; 1042 if (gso.hdr_len > good_linear)
1043 linear = good_linear;
1044 else
1045 linear = gso.hdr_len;
1038 } 1046 }
1039 1047
1040 skb = tun_alloc_skb(tfile, align, copylen, linear, noblock); 1048 skb = tun_alloc_skb(tfile, align, copylen, linear, noblock);
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index f74786aa37be..e15ec2b12035 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -66,7 +66,7 @@ static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx);
66static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer); 66static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer);
67static struct usb_driver cdc_ncm_driver; 67static struct usb_driver cdc_ncm_driver;
68 68
69static u8 cdc_ncm_setup(struct usbnet *dev) 69static int cdc_ncm_setup(struct usbnet *dev)
70{ 70{
71 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; 71 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
72 struct usb_cdc_ncm_ntb_parameters ncm_parm; 72 struct usb_cdc_ncm_ntb_parameters ncm_parm;
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 90a429b7ebad..8494bb53ebdc 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -204,9 +204,6 @@ static void intr_complete (struct urb *urb)
204 break; 204 break;
205 } 205 }
206 206
207 if (!netif_running (dev->net))
208 return;
209
210 status = usb_submit_urb (urb, GFP_ATOMIC); 207 status = usb_submit_urb (urb, GFP_ATOMIC);
211 if (status != 0) 208 if (status != 0)
212 netif_err(dev, timer, dev->net, 209 netif_err(dev, timer, dev->net,
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index cdc7c90a6a9e..7bab4de658a9 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -36,7 +36,10 @@ module_param(csum, bool, 0444);
36module_param(gso, bool, 0444); 36module_param(gso, bool, 0444);
37 37
38/* FIXME: MTU in config. */ 38/* FIXME: MTU in config. */
39#define MAX_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN) 39#define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
40#define MERGE_BUFFER_LEN (ALIGN(GOOD_PACKET_LEN + \
41 sizeof(struct virtio_net_hdr_mrg_rxbuf), \
42 L1_CACHE_BYTES))
40#define GOOD_COPY_LEN 128 43#define GOOD_COPY_LEN 128
41 44
42#define VIRTNET_DRIVER_VERSION "1.0.0" 45#define VIRTNET_DRIVER_VERSION "1.0.0"
@@ -314,10 +317,10 @@ static int receive_mergeable(struct receive_queue *rq, struct sk_buff *head_skb)
314 head_skb->dev->stats.rx_length_errors++; 317 head_skb->dev->stats.rx_length_errors++;
315 return -EINVAL; 318 return -EINVAL;
316 } 319 }
317 if (unlikely(len > MAX_PACKET_LEN)) { 320 if (unlikely(len > MERGE_BUFFER_LEN)) {
318 pr_debug("%s: rx error: merge buffer too long\n", 321 pr_debug("%s: rx error: merge buffer too long\n",
319 head_skb->dev->name); 322 head_skb->dev->name);
320 len = MAX_PACKET_LEN; 323 len = MERGE_BUFFER_LEN;
321 } 324 }
322 if (unlikely(num_skb_frags == MAX_SKB_FRAGS)) { 325 if (unlikely(num_skb_frags == MAX_SKB_FRAGS)) {
323 struct sk_buff *nskb = alloc_skb(0, GFP_ATOMIC); 326 struct sk_buff *nskb = alloc_skb(0, GFP_ATOMIC);
@@ -336,18 +339,17 @@ static int receive_mergeable(struct receive_queue *rq, struct sk_buff *head_skb)
336 if (curr_skb != head_skb) { 339 if (curr_skb != head_skb) {
337 head_skb->data_len += len; 340 head_skb->data_len += len;
338 head_skb->len += len; 341 head_skb->len += len;
339 head_skb->truesize += MAX_PACKET_LEN; 342 head_skb->truesize += MERGE_BUFFER_LEN;
340 } 343 }
341 page = virt_to_head_page(buf); 344 page = virt_to_head_page(buf);
342 offset = buf - (char *)page_address(page); 345 offset = buf - (char *)page_address(page);
343 if (skb_can_coalesce(curr_skb, num_skb_frags, page, offset)) { 346 if (skb_can_coalesce(curr_skb, num_skb_frags, page, offset)) {
344 put_page(page); 347 put_page(page);
345 skb_coalesce_rx_frag(curr_skb, num_skb_frags - 1, 348 skb_coalesce_rx_frag(curr_skb, num_skb_frags - 1,
346 len, MAX_PACKET_LEN); 349 len, MERGE_BUFFER_LEN);
347 } else { 350 } else {
348 skb_add_rx_frag(curr_skb, num_skb_frags, page, 351 skb_add_rx_frag(curr_skb, num_skb_frags, page,
349 offset, len, 352 offset, len, MERGE_BUFFER_LEN);
350 MAX_PACKET_LEN);
351 } 353 }
352 --rq->num; 354 --rq->num;
353 } 355 }
@@ -383,7 +385,7 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
383 struct page *page = virt_to_head_page(buf); 385 struct page *page = virt_to_head_page(buf);
384 skb = page_to_skb(rq, page, 386 skb = page_to_skb(rq, page,
385 (char *)buf - (char *)page_address(page), 387 (char *)buf - (char *)page_address(page),
386 len, MAX_PACKET_LEN); 388 len, MERGE_BUFFER_LEN);
387 if (unlikely(!skb)) { 389 if (unlikely(!skb)) {
388 dev->stats.rx_dropped++; 390 dev->stats.rx_dropped++;
389 put_page(page); 391 put_page(page);
@@ -471,11 +473,11 @@ static int add_recvbuf_small(struct receive_queue *rq, gfp_t gfp)
471 struct skb_vnet_hdr *hdr; 473 struct skb_vnet_hdr *hdr;
472 int err; 474 int err;
473 475
474 skb = __netdev_alloc_skb_ip_align(vi->dev, MAX_PACKET_LEN, gfp); 476 skb = __netdev_alloc_skb_ip_align(vi->dev, GOOD_PACKET_LEN, gfp);
475 if (unlikely(!skb)) 477 if (unlikely(!skb))
476 return -ENOMEM; 478 return -ENOMEM;
477 479
478 skb_put(skb, MAX_PACKET_LEN); 480 skb_put(skb, GOOD_PACKET_LEN);
479 481
480 hdr = skb_vnet_hdr(skb); 482 hdr = skb_vnet_hdr(skb);
481 sg_set_buf(rq->sg, &hdr->hdr, sizeof hdr->hdr); 483 sg_set_buf(rq->sg, &hdr->hdr, sizeof hdr->hdr);
@@ -542,20 +544,20 @@ static int add_recvbuf_mergeable(struct receive_queue *rq, gfp_t gfp)
542 int err; 544 int err;
543 545
544 if (gfp & __GFP_WAIT) { 546 if (gfp & __GFP_WAIT) {
545 if (skb_page_frag_refill(MAX_PACKET_LEN, &vi->alloc_frag, 547 if (skb_page_frag_refill(MERGE_BUFFER_LEN, &vi->alloc_frag,
546 gfp)) { 548 gfp)) {
547 buf = (char *)page_address(vi->alloc_frag.page) + 549 buf = (char *)page_address(vi->alloc_frag.page) +
548 vi->alloc_frag.offset; 550 vi->alloc_frag.offset;
549 get_page(vi->alloc_frag.page); 551 get_page(vi->alloc_frag.page);
550 vi->alloc_frag.offset += MAX_PACKET_LEN; 552 vi->alloc_frag.offset += MERGE_BUFFER_LEN;
551 } 553 }
552 } else { 554 } else {
553 buf = netdev_alloc_frag(MAX_PACKET_LEN); 555 buf = netdev_alloc_frag(MERGE_BUFFER_LEN);
554 } 556 }
555 if (!buf) 557 if (!buf)
556 return -ENOMEM; 558 return -ENOMEM;
557 559
558 sg_init_one(rq->sg, buf, MAX_PACKET_LEN); 560 sg_init_one(rq->sg, buf, MERGE_BUFFER_LEN);
559 err = virtqueue_add_inbuf(rq->vq, rq->sg, 1, buf, gfp); 561 err = virtqueue_add_inbuf(rq->vq, rq->sg, 1, buf, gfp);
560 if (err < 0) 562 if (err < 0)
561 put_page(virt_to_head_page(buf)); 563 put_page(virt_to_head_page(buf));
@@ -1619,8 +1621,8 @@ static int virtnet_probe(struct virtio_device *vdev)
1619 if (err) 1621 if (err)
1620 goto free_stats; 1622 goto free_stats;
1621 1623
1622 netif_set_real_num_tx_queues(dev, 1); 1624 netif_set_real_num_tx_queues(dev, vi->curr_queue_pairs);
1623 netif_set_real_num_rx_queues(dev, 1); 1625 netif_set_real_num_rx_queues(dev, vi->curr_queue_pairs);
1624 1626
1625 err = register_netdev(dev); 1627 err = register_netdev(dev);
1626 if (err) { 1628 if (err) {
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
index b07f164d65cf..20e49095db2a 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
@@ -187,17 +187,17 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
187 INIT_INI_ARRAY(&ah->iniCckfirJapan2484, 187 INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
188 ar9485_1_1_baseband_core_txfir_coeff_japan_2484); 188 ar9485_1_1_baseband_core_txfir_coeff_japan_2484);
189 189
190 /* Load PCIE SERDES settings from INI */ 190 if (ah->config.no_pll_pwrsave) {
191 191 INIT_INI_ARRAY(&ah->iniPcieSerdes,
192 /* Awake Setting */ 192 ar9485_1_1_pcie_phy_clkreq_disable_L1);
193 193 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
194 INIT_INI_ARRAY(&ah->iniPcieSerdes, 194 ar9485_1_1_pcie_phy_clkreq_disable_L1);
195 ar9485_1_1_pcie_phy_clkreq_disable_L1); 195 } else {
196 196 INIT_INI_ARRAY(&ah->iniPcieSerdes,
197 /* Sleep Setting */ 197 ar9485_1_1_pll_on_cdr_on_clkreq_disable_L1);
198 198 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
199 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower, 199 ar9485_1_1_pll_on_cdr_on_clkreq_disable_L1);
200 ar9485_1_1_pcie_phy_clkreq_disable_L1); 200 }
201 } else if (AR_SREV_9462_21(ah)) { 201 } else if (AR_SREV_9462_21(ah)) {
202 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 202 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
203 ar9462_2p1_mac_core); 203 ar9462_2p1_mac_core);
diff --git a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
index 6f899c692647..7c1845221e1c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
@@ -32,13 +32,6 @@ static const u32 ar9485_1_1_mac_postamble[][5] = {
32 {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440}, 32 {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440},
33}; 33};
34 34
35static const u32 ar9485_1_1_pcie_phy_pll_on_clkreq_disable_L1[][2] = {
36 /* Addr allmodes */
37 {0x00018c00, 0x18012e5e},
38 {0x00018c04, 0x000801d8},
39 {0x00018c08, 0x0000080c},
40};
41
42static const u32 ar9485Common_wo_xlna_rx_gain_1_1[][2] = { 35static const u32 ar9485Common_wo_xlna_rx_gain_1_1[][2] = {
43 /* Addr allmodes */ 36 /* Addr allmodes */
44 {0x00009e00, 0x037216a0}, 37 {0x00009e00, 0x037216a0},
@@ -1101,20 +1094,6 @@ static const u32 ar9485_common_rx_gain_1_1[][2] = {
1101 {0x0000a1fc, 0x00000296}, 1094 {0x0000a1fc, 0x00000296},
1102}; 1095};
1103 1096
1104static const u32 ar9485_1_1_pcie_phy_pll_on_clkreq_enable_L1[][2] = {
1105 /* Addr allmodes */
1106 {0x00018c00, 0x18052e5e},
1107 {0x00018c04, 0x000801d8},
1108 {0x00018c08, 0x0000080c},
1109};
1110
1111static const u32 ar9485_1_1_pcie_phy_clkreq_enable_L1[][2] = {
1112 /* Addr allmodes */
1113 {0x00018c00, 0x18053e5e},
1114 {0x00018c04, 0x000801d8},
1115 {0x00018c08, 0x0000080c},
1116};
1117
1118static const u32 ar9485_1_1_soc_preamble[][2] = { 1097static const u32 ar9485_1_1_soc_preamble[][2] = {
1119 /* Addr allmodes */ 1098 /* Addr allmodes */
1120 {0x00004014, 0xba280400}, 1099 {0x00004014, 0xba280400},
@@ -1173,13 +1152,6 @@ static const u32 ar9485_1_1_baseband_postamble[][5] = {
1173 {0x0000be18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1152 {0x0000be18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1174}; 1153};
1175 1154
1176static const u32 ar9485_1_1_pcie_phy_clkreq_disable_L1[][2] = {
1177 /* Addr allmodes */
1178 {0x00018c00, 0x18013e5e},
1179 {0x00018c04, 0x000801d8},
1180 {0x00018c08, 0x0000080c},
1181};
1182
1183static const u32 ar9485_1_1_radio_postamble[][2] = { 1155static const u32 ar9485_1_1_radio_postamble[][2] = {
1184 /* Addr allmodes */ 1156 /* Addr allmodes */
1185 {0x0001609c, 0x0b283f31}, 1157 {0x0001609c, 0x0b283f31},
@@ -1358,4 +1330,18 @@ static const u32 ar9485_1_1_baseband_core_txfir_coeff_japan_2484[][2] = {
1358 {0x0000a3a0, 0xca9228ee}, 1330 {0x0000a3a0, 0xca9228ee},
1359}; 1331};
1360 1332
1333static const u32 ar9485_1_1_pcie_phy_clkreq_disable_L1[][2] = {
1334 /* Addr allmodes */
1335 {0x00018c00, 0x18013e5e},
1336 {0x00018c04, 0x000801d8},
1337 {0x00018c08, 0x0000080c},
1338};
1339
1340static const u32 ar9485_1_1_pll_on_cdr_on_clkreq_disable_L1[][2] = {
1341 /* Addr allmodes */
1342 {0x00018c00, 0x1801265e},
1343 {0x00018c04, 0x000801d8},
1344 {0x00018c08, 0x0000080c},
1345};
1346
1361#endif /* INITVALS_9485_H */ 1347#endif /* INITVALS_9485_H */
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index e7a38d844a6a..60a5da53668f 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -632,15 +632,16 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
632/* Main driver core */ 632/* Main driver core */
633/********************/ 633/********************/
634 634
635#define ATH9K_PCI_CUS198 0x0001 635#define ATH9K_PCI_CUS198 0x0001
636#define ATH9K_PCI_CUS230 0x0002 636#define ATH9K_PCI_CUS230 0x0002
637#define ATH9K_PCI_CUS217 0x0004 637#define ATH9K_PCI_CUS217 0x0004
638#define ATH9K_PCI_CUS252 0x0008 638#define ATH9K_PCI_CUS252 0x0008
639#define ATH9K_PCI_WOW 0x0010 639#define ATH9K_PCI_WOW 0x0010
640#define ATH9K_PCI_BT_ANT_DIV 0x0020 640#define ATH9K_PCI_BT_ANT_DIV 0x0020
641#define ATH9K_PCI_D3_L1_WAR 0x0040 641#define ATH9K_PCI_D3_L1_WAR 0x0040
642#define ATH9K_PCI_AR9565_1ANT 0x0080 642#define ATH9K_PCI_AR9565_1ANT 0x0080
643#define ATH9K_PCI_AR9565_2ANT 0x0100 643#define ATH9K_PCI_AR9565_2ANT 0x0100
644#define ATH9K_PCI_NO_PLL_PWRSAVE 0x0200
644 645
645/* 646/*
646 * Default cache line size, in bytes. 647 * Default cache line size, in bytes.
diff --git a/drivers/net/wireless/ath/ath9k/dfs_debug.c b/drivers/net/wireless/ath/ath9k/dfs_debug.c
index 90b8342d1ed4..8824610c21fb 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_debug.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_debug.c
@@ -44,14 +44,20 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
44 if (buf == NULL) 44 if (buf == NULL)
45 return -ENOMEM; 45 return -ENOMEM;
46 46
47 if (sc->dfs_detector)
48 dfs_pool_stats = sc->dfs_detector->get_stats(sc->dfs_detector);
49
50 len += scnprintf(buf + len, size - len, "DFS support for " 47 len += scnprintf(buf + len, size - len, "DFS support for "
51 "macVersion = 0x%x, macRev = 0x%x: %s\n", 48 "macVersion = 0x%x, macRev = 0x%x: %s\n",
52 hw_ver->macVersion, hw_ver->macRev, 49 hw_ver->macVersion, hw_ver->macRev,
53 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_DFS) ? 50 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_DFS) ?
54 "enabled" : "disabled"); 51 "enabled" : "disabled");
52
53 if (!sc->dfs_detector) {
54 len += scnprintf(buf + len, size - len,
55 "DFS detector not enabled\n");
56 goto exit;
57 }
58
59 dfs_pool_stats = sc->dfs_detector->get_stats(sc->dfs_detector);
60
55 len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n"); 61 len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n");
56 ATH9K_DFS_STAT("pulse events reported ", pulses_total); 62 ATH9K_DFS_STAT("pulse events reported ", pulses_total);
57 ATH9K_DFS_STAT("invalid pulse events ", pulses_no_dfs); 63 ATH9K_DFS_STAT("invalid pulse events ", pulses_no_dfs);
@@ -76,6 +82,7 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
76 ATH9K_DFS_POOL_STAT("Seqs. alloc error ", pseq_alloc_error); 82 ATH9K_DFS_POOL_STAT("Seqs. alloc error ", pseq_alloc_error);
77 ATH9K_DFS_POOL_STAT("Seqs. in use ", pseq_used); 83 ATH9K_DFS_POOL_STAT("Seqs. in use ", pseq_used);
78 84
85exit:
79 if (len > size) 86 if (len > size)
80 len = size; 87 len = size;
81 88
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 9ea24f1cba73..a2c9a5dbac6b 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -316,6 +316,7 @@ struct ath9k_ops_config {
316 u32 ant_ctrl_comm2g_switch_enable; 316 u32 ant_ctrl_comm2g_switch_enable;
317 bool xatten_margin_cfg; 317 bool xatten_margin_cfg;
318 bool alt_mingainidx; 318 bool alt_mingainidx;
319 bool no_pll_pwrsave;
319}; 320};
320 321
321enum ath9k_int { 322enum ath9k_int {
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index d8643ebabd30..710192ed27ed 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -609,6 +609,11 @@ static void ath9k_init_platform(struct ath_softc *sc)
609 ah->config.pcie_waen = 0x0040473b; 609 ah->config.pcie_waen = 0x0040473b;
610 ath_info(common, "Enable WAR for ASPM D3/L1\n"); 610 ath_info(common, "Enable WAR for ASPM D3/L1\n");
611 } 611 }
612
613 if (sc->driver_data & ATH9K_PCI_NO_PLL_PWRSAVE) {
614 ah->config.no_pll_pwrsave = true;
615 ath_info(common, "Disable PLL PowerSave\n");
616 }
612} 617}
613 618
614static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob, 619static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob,
@@ -863,8 +868,8 @@ static const struct ieee80211_iface_combination if_comb[] = {
863 .max_interfaces = 1, 868 .max_interfaces = 1,
864 .num_different_channels = 1, 869 .num_different_channels = 1,
865 .beacon_int_infra_match = true, 870 .beacon_int_infra_match = true,
866 .radar_detect_widths = BIT(NL80211_CHAN_NO_HT) | 871 .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
867 BIT(NL80211_CHAN_HT20), 872 BIT(NL80211_CHAN_WIDTH_20),
868 } 873 }
869}; 874};
870 875
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 7e4c2524b630..b5656fce4ff5 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -195,6 +195,93 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = {
195 0x3219), 195 0x3219),
196 .driver_data = ATH9K_PCI_BT_ANT_DIV }, 196 .driver_data = ATH9K_PCI_BT_ANT_DIV },
197 197
198 /* AR9485 cards with PLL power-save disabled by default. */
199 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
200 0x0032,
201 PCI_VENDOR_ID_AZWAVE,
202 0x2C97),
203 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
204 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
205 0x0032,
206 PCI_VENDOR_ID_AZWAVE,
207 0x2100),
208 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
209 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
210 0x0032,
211 0x1C56, /* ASKEY */
212 0x4001),
213 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
214 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
215 0x0032,
216 0x11AD, /* LITEON */
217 0x6627),
218 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
219 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
220 0x0032,
221 0x11AD, /* LITEON */
222 0x6628),
223 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
224 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
225 0x0032,
226 PCI_VENDOR_ID_FOXCONN,
227 0xE04E),
228 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
229 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
230 0x0032,
231 PCI_VENDOR_ID_FOXCONN,
232 0xE04F),
233 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
234 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
235 0x0032,
236 0x144F, /* ASKEY */
237 0x7197),
238 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
239 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
240 0x0032,
241 0x1B9A, /* XAVI */
242 0x2000),
243 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
244 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
245 0x0032,
246 0x1B9A, /* XAVI */
247 0x2001),
248 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
249 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
250 0x0032,
251 PCI_VENDOR_ID_AZWAVE,
252 0x1186),
253 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
254 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
255 0x0032,
256 PCI_VENDOR_ID_AZWAVE,
257 0x1F86),
258 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
259 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
260 0x0032,
261 PCI_VENDOR_ID_AZWAVE,
262 0x1195),
263 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
264 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
265 0x0032,
266 PCI_VENDOR_ID_AZWAVE,
267 0x1F95),
268 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
269 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
270 0x0032,
271 0x1B9A, /* XAVI */
272 0x1C00),
273 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
274 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
275 0x0032,
276 0x1B9A, /* XAVI */
277 0x1C01),
278 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
279 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
280 0x0032,
281 PCI_VENDOR_ID_ASUSTEK,
282 0x850D),
283 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
284
198 { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */ 285 { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */
199 { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */ 286 { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */
200 287
diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c b/drivers/net/wireless/ath/wcn36xx/debug.c
index 5b84f7ae0b1e..ef44a2da644d 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.c
+++ b/drivers/net/wireless/ath/wcn36xx/debug.c
@@ -126,7 +126,7 @@ static ssize_t write_file_dump(struct file *file,
126 if (begin == NULL) 126 if (begin == NULL)
127 break; 127 break;
128 128
129 if (kstrtoul(begin, 0, (unsigned long *)(arg + i)) != 0) 129 if (kstrtou32(begin, 0, &arg[i]) != 0)
130 break; 130 break;
131 } 131 }
132 132
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index f8c3a10510c2..de9eb2cfbf4b 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1286,7 +1286,8 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct ieee80211_vif *vif,
1286 } else { 1286 } else {
1287 wcn36xx_err("Beacon is to big: beacon size=%d\n", 1287 wcn36xx_err("Beacon is to big: beacon size=%d\n",
1288 msg_body.beacon_length); 1288 msg_body.beacon_length);
1289 return -ENOMEM; 1289 ret = -ENOMEM;
1290 goto out;
1290 } 1291 }
1291 memcpy(msg_body.bssid, vif->addr, ETH_ALEN); 1292 memcpy(msg_body.bssid, vif->addr, ETH_ALEN);
1292 1293
@@ -1327,7 +1328,8 @@ int wcn36xx_smd_update_proberesp_tmpl(struct wcn36xx *wcn,
1327 if (skb->len > BEACON_TEMPLATE_SIZE) { 1328 if (skb->len > BEACON_TEMPLATE_SIZE) {
1328 wcn36xx_warn("probe response template is too big: %d\n", 1329 wcn36xx_warn("probe response template is too big: %d\n",
1329 skb->len); 1330 skb->len);
1330 return -E2BIG; 1331 ret = -E2BIG;
1332 goto out;
1331 } 1333 }
1332 1334
1333 msg.probe_resp_template_len = skb->len; 1335 msg.probe_resp_template_len = skb->len;
@@ -1606,7 +1608,8 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
1606 /* TODO: it also support ARP response type */ 1608 /* TODO: it also support ARP response type */
1607 } else { 1609 } else {
1608 wcn36xx_warn("unknow keep alive packet type %d\n", packet_type); 1610 wcn36xx_warn("unknow keep alive packet type %d\n", packet_type);
1609 return -EINVAL; 1611 ret = -EINVAL;
1612 goto out;
1610 } 1613 }
1611 1614
1612 PREPARE_HAL_BUF(wcn->hal_buf, msg_body); 1615 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 668dd27616a0..cc6a0a586f0b 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -913,7 +913,10 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
913 char *p2; 913 char *p2;
914 struct debug_data *d = f->private_data; 914 struct debug_data *d = f->private_data;
915 915
916 pdata = kmalloc(cnt, GFP_KERNEL); 916 if (cnt == 0)
917 return 0;
918
919 pdata = kmalloc(cnt + 1, GFP_KERNEL);
917 if (pdata == NULL) 920 if (pdata == NULL)
918 return 0; 921 return 0;
919 922
@@ -922,6 +925,7 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
922 kfree(pdata); 925 kfree(pdata);
923 return 0; 926 return 0;
924 } 927 }
928 pdata[cnt] = '\0';
925 929
926 p0 = pdata; 930 p0 = pdata;
927 for (i = 0; i < num_of_items; i++) { 931 for (i = 0; i < num_of_items; i++) {
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index ef8c98e21098..f499efc6abcf 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -902,6 +902,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
902 if (card->model == MODEL_UNKNOWN) { 902 if (card->model == MODEL_UNKNOWN) {
903 pr_err("unsupported manf_id 0x%04x / card_id 0x%04x\n", 903 pr_err("unsupported manf_id 0x%04x / card_id 0x%04x\n",
904 p_dev->manf_id, p_dev->card_id); 904 p_dev->manf_id, p_dev->card_id);
905 ret = -ENODEV;
905 goto out2; 906 goto out2;
906 } 907 }
907 908
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index de0df86704e7..9df7bc91a26f 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2097,7 +2097,7 @@ out:
2097} 2097}
2098 2098
2099/* Generic Netlink operations array */ 2099/* Generic Netlink operations array */
2100static struct genl_ops hwsim_ops[] = { 2100static const struct genl_ops hwsim_ops[] = {
2101 { 2101 {
2102 .cmd = HWSIM_CMD_REGISTER, 2102 .cmd = HWSIM_CMD_REGISTER,
2103 .policy = hwsim_genl_policy, 2103 .policy = hwsim_genl_policy,
@@ -2148,8 +2148,7 @@ static int hwsim_init_netlink(void)
2148 2148
2149 printk(KERN_INFO "mac80211_hwsim: initializing netlink\n"); 2149 printk(KERN_INFO "mac80211_hwsim: initializing netlink\n");
2150 2150
2151 rc = genl_register_family_with_ops(&hwsim_genl_family, 2151 rc = genl_register_family_with_ops(&hwsim_genl_family, hwsim_ops);
2152 hwsim_ops, ARRAY_SIZE(hwsim_ops));
2153 if (rc) 2152 if (rc)
2154 goto failure; 2153 goto failure;
2155 2154
diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h
index f80f30b6160e..c8385ec77a86 100644
--- a/drivers/net/wireless/mwifiex/fw.h
+++ b/drivers/net/wireless/mwifiex/fw.h
@@ -1020,8 +1020,8 @@ struct mwifiex_power_group {
1020} __packed; 1020} __packed;
1021 1021
1022struct mwifiex_types_power_group { 1022struct mwifiex_types_power_group {
1023 u16 type; 1023 __le16 type;
1024 u16 length; 1024 __le16 length;
1025} __packed; 1025} __packed;
1026 1026
1027struct host_cmd_ds_txpwr_cfg { 1027struct host_cmd_ds_txpwr_cfg {
diff --git a/drivers/net/wireless/mwifiex/ie.c b/drivers/net/wireless/mwifiex/ie.c
index 220af4fe0fc6..81ac001ee741 100644
--- a/drivers/net/wireless/mwifiex/ie.c
+++ b/drivers/net/wireless/mwifiex/ie.c
@@ -82,7 +82,7 @@ mwifiex_update_autoindex_ies(struct mwifiex_private *priv,
82 struct mwifiex_ie_list *ie_list) 82 struct mwifiex_ie_list *ie_list)
83{ 83{
84 u16 travel_len, index, mask; 84 u16 travel_len, index, mask;
85 s16 input_len; 85 s16 input_len, tlv_len;
86 struct mwifiex_ie *ie; 86 struct mwifiex_ie *ie;
87 u8 *tmp; 87 u8 *tmp;
88 88
@@ -91,11 +91,13 @@ mwifiex_update_autoindex_ies(struct mwifiex_private *priv,
91 91
92 ie_list->len = 0; 92 ie_list->len = 0;
93 93
94 while (input_len > 0) { 94 while (input_len >= sizeof(struct mwifiex_ie_types_header)) {
95 ie = (struct mwifiex_ie *)(((u8 *)ie_list) + travel_len); 95 ie = (struct mwifiex_ie *)(((u8 *)ie_list) + travel_len);
96 input_len -= le16_to_cpu(ie->ie_length) + MWIFIEX_IE_HDR_SIZE; 96 tlv_len = le16_to_cpu(ie->ie_length);
97 travel_len += le16_to_cpu(ie->ie_length) + MWIFIEX_IE_HDR_SIZE; 97 travel_len += tlv_len + MWIFIEX_IE_HDR_SIZE;
98 98
99 if (input_len < tlv_len + MWIFIEX_IE_HDR_SIZE)
100 return -1;
99 index = le16_to_cpu(ie->ie_index); 101 index = le16_to_cpu(ie->ie_index);
100 mask = le16_to_cpu(ie->mgmt_subtype_mask); 102 mask = le16_to_cpu(ie->mgmt_subtype_mask);
101 103
@@ -132,6 +134,7 @@ mwifiex_update_autoindex_ies(struct mwifiex_private *priv,
132 le16_add_cpu(&ie_list->len, 134 le16_add_cpu(&ie_list->len,
133 le16_to_cpu(priv->mgmt_ie[index].ie_length) + 135 le16_to_cpu(priv->mgmt_ie[index].ie_length) +
134 MWIFIEX_IE_HDR_SIZE); 136 MWIFIEX_IE_HDR_SIZE);
137 input_len -= tlv_len + MWIFIEX_IE_HDR_SIZE;
135 } 138 }
136 139
137 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) 140 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP)
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index 1576104e3d95..9bf8898743ab 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -1029,7 +1029,10 @@ static int mwifiex_decode_rx_packet(struct mwifiex_adapter *adapter,
1029 struct sk_buff *skb, u32 upld_typ) 1029 struct sk_buff *skb, u32 upld_typ)
1030{ 1030{
1031 u8 *cmd_buf; 1031 u8 *cmd_buf;
1032 __le16 *curr_ptr = (__le16 *)skb->data;
1033 u16 pkt_len = le16_to_cpu(*curr_ptr);
1032 1034
1035 skb_trim(skb, pkt_len);
1033 skb_pull(skb, INTF_HEADER_LEN); 1036 skb_pull(skb, INTF_HEADER_LEN);
1034 1037
1035 switch (upld_typ) { 1038 switch (upld_typ) {
diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c
index 7d66018a2e33..2181ee283d82 100644
--- a/drivers/net/wireless/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/mwifiex/sta_cmd.c
@@ -239,14 +239,14 @@ static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd,
239 memmove(cmd_txp_cfg, txp, 239 memmove(cmd_txp_cfg, txp,
240 sizeof(struct host_cmd_ds_txpwr_cfg) + 240 sizeof(struct host_cmd_ds_txpwr_cfg) +
241 sizeof(struct mwifiex_types_power_group) + 241 sizeof(struct mwifiex_types_power_group) +
242 pg_tlv->length); 242 le16_to_cpu(pg_tlv->length));
243 243
244 pg_tlv = (struct mwifiex_types_power_group *) ((u8 *) 244 pg_tlv = (struct mwifiex_types_power_group *) ((u8 *)
245 cmd_txp_cfg + 245 cmd_txp_cfg +
246 sizeof(struct host_cmd_ds_txpwr_cfg)); 246 sizeof(struct host_cmd_ds_txpwr_cfg));
247 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + 247 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) +
248 sizeof(struct mwifiex_types_power_group) + 248 sizeof(struct mwifiex_types_power_group) +
249 pg_tlv->length); 249 le16_to_cpu(pg_tlv->length));
250 } else { 250 } else {
251 memmove(cmd_txp_cfg, txp, sizeof(*txp)); 251 memmove(cmd_txp_cfg, txp, sizeof(*txp));
252 } 252 }
diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c
index 58a6013712d2..2675ca7f8d14 100644
--- a/drivers/net/wireless/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c
@@ -274,17 +274,20 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
274 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg; 274 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
275 struct mwifiex_rate_scope *rate_scope; 275 struct mwifiex_rate_scope *rate_scope;
276 struct mwifiex_ie_types_header *head; 276 struct mwifiex_ie_types_header *head;
277 u16 tlv, tlv_buf_len; 277 u16 tlv, tlv_buf_len, tlv_buf_left;
278 u8 *tlv_buf; 278 u8 *tlv_buf;
279 u32 i; 279 u32 i;
280 280
281 tlv_buf = ((u8 *)rate_cfg) + 281 tlv_buf = ((u8 *)rate_cfg) + sizeof(struct host_cmd_ds_tx_rate_cfg);
282 sizeof(struct host_cmd_ds_tx_rate_cfg); 282 tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*rate_cfg);
283 tlv_buf_len = le16_to_cpu(*(__le16 *) (tlv_buf + sizeof(u16)));
284 283
285 while (tlv_buf && tlv_buf_len > 0) { 284 while (tlv_buf_left >= sizeof(*head)) {
286 tlv = (*tlv_buf); 285 head = (struct mwifiex_ie_types_header *)tlv_buf;
287 tlv = tlv | (*(tlv_buf + 1) << 8); 286 tlv = le16_to_cpu(head->type);
287 tlv_buf_len = le16_to_cpu(head->len);
288
289 if (tlv_buf_left < (sizeof(*head) + tlv_buf_len))
290 break;
288 291
289 switch (tlv) { 292 switch (tlv) {
290 case TLV_TYPE_RATE_SCOPE: 293 case TLV_TYPE_RATE_SCOPE:
@@ -304,9 +307,8 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
304 /* Add RATE_DROP tlv here */ 307 /* Add RATE_DROP tlv here */
305 } 308 }
306 309
307 head = (struct mwifiex_ie_types_header *) tlv_buf; 310 tlv_buf += (sizeof(*head) + tlv_buf_len);
308 tlv_buf += le16_to_cpu(head->len) + sizeof(*head); 311 tlv_buf_left -= (sizeof(*head) + tlv_buf_len);
309 tlv_buf_len -= le16_to_cpu(head->len);
310 } 312 }
311 313
312 priv->is_data_rate_auto = mwifiex_is_rate_auto(priv); 314 priv->is_data_rate_auto = mwifiex_is_rate_auto(priv);
@@ -340,13 +342,17 @@ static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
340 ((u8 *) data_buf + sizeof(struct host_cmd_ds_txpwr_cfg)); 342 ((u8 *) data_buf + sizeof(struct host_cmd_ds_txpwr_cfg));
341 pg = (struct mwifiex_power_group *) 343 pg = (struct mwifiex_power_group *)
342 ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group)); 344 ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group));
343 length = pg_tlv_hdr->length; 345 length = le16_to_cpu(pg_tlv_hdr->length);
344 if (length > 0) { 346
345 max_power = pg->power_max; 347 /* At least one structure required to update power */
346 min_power = pg->power_min; 348 if (length < sizeof(struct mwifiex_power_group))
347 length -= sizeof(struct mwifiex_power_group); 349 return 0;
348 } 350
349 while (length) { 351 max_power = pg->power_max;
352 min_power = pg->power_min;
353 length -= sizeof(struct mwifiex_power_group);
354
355 while (length >= sizeof(struct mwifiex_power_group)) {
350 pg++; 356 pg++;
351 if (max_power < pg->power_max) 357 if (max_power < pg->power_max)
352 max_power = pg->power_max; 358 max_power = pg->power_max;
@@ -356,10 +362,8 @@ static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
356 362
357 length -= sizeof(struct mwifiex_power_group); 363 length -= sizeof(struct mwifiex_power_group);
358 } 364 }
359 if (pg_tlv_hdr->length > 0) { 365 priv->min_tx_power_level = (u8) min_power;
360 priv->min_tx_power_level = (u8) min_power; 366 priv->max_tx_power_level = (u8) max_power;
361 priv->max_tx_power_level = (u8) max_power;
362 }
363 367
364 return 0; 368 return 0;
365} 369}
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index f084412eee0b..c8e029df770e 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -638,8 +638,9 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
638 txp_cfg->mode = cpu_to_le32(1); 638 txp_cfg->mode = cpu_to_le32(1);
639 pg_tlv = (struct mwifiex_types_power_group *) 639 pg_tlv = (struct mwifiex_types_power_group *)
640 (buf + sizeof(struct host_cmd_ds_txpwr_cfg)); 640 (buf + sizeof(struct host_cmd_ds_txpwr_cfg));
641 pg_tlv->type = TLV_TYPE_POWER_GROUP; 641 pg_tlv->type = cpu_to_le16(TLV_TYPE_POWER_GROUP);
642 pg_tlv->length = 4 * sizeof(struct mwifiex_power_group); 642 pg_tlv->length =
643 cpu_to_le16(4 * sizeof(struct mwifiex_power_group));
643 pg = (struct mwifiex_power_group *) 644 pg = (struct mwifiex_power_group *)
644 (buf + sizeof(struct host_cmd_ds_txpwr_cfg) 645 (buf + sizeof(struct host_cmd_ds_txpwr_cfg)
645 + sizeof(struct mwifiex_types_power_group)); 646 + sizeof(struct mwifiex_types_power_group));
diff --git a/drivers/net/wireless/mwifiex/uap_txrx.c b/drivers/net/wireless/mwifiex/uap_txrx.c
index 1cfe5a738c47..92f76d655e6c 100644
--- a/drivers/net/wireless/mwifiex/uap_txrx.c
+++ b/drivers/net/wireless/mwifiex/uap_txrx.c
@@ -97,6 +97,7 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
97 struct mwifiex_txinfo *tx_info; 97 struct mwifiex_txinfo *tx_info;
98 int hdr_chop; 98 int hdr_chop;
99 struct timeval tv; 99 struct timeval tv;
100 struct ethhdr *p_ethhdr;
100 u8 rfc1042_eth_hdr[ETH_ALEN] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; 101 u8 rfc1042_eth_hdr[ETH_ALEN] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
101 102
102 uap_rx_pd = (struct uap_rxpd *)(skb->data); 103 uap_rx_pd = (struct uap_rxpd *)(skb->data);
@@ -112,14 +113,36 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
112 } 113 }
113 114
114 if (!memcmp(&rx_pkt_hdr->rfc1042_hdr, 115 if (!memcmp(&rx_pkt_hdr->rfc1042_hdr,
115 rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr))) 116 rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr))) {
117 /* Replace the 803 header and rfc1042 header (llc/snap) with
118 * an Ethernet II header, keep the src/dst and snap_type
119 * (ethertype).
120 *
121 * The firmware only passes up SNAP frames converting all RX
122 * data from 802.11 to 802.2/LLC/SNAP frames.
123 *
124 * To create the Ethernet II, just move the src, dst address
125 * right before the snap_type.
126 */
127 p_ethhdr = (struct ethhdr *)
128 ((u8 *)(&rx_pkt_hdr->eth803_hdr)
129 + sizeof(rx_pkt_hdr->eth803_hdr)
130 + sizeof(rx_pkt_hdr->rfc1042_hdr)
131 - sizeof(rx_pkt_hdr->eth803_hdr.h_dest)
132 - sizeof(rx_pkt_hdr->eth803_hdr.h_source)
133 - sizeof(rx_pkt_hdr->rfc1042_hdr.snap_type));
134 memcpy(p_ethhdr->h_source, rx_pkt_hdr->eth803_hdr.h_source,
135 sizeof(p_ethhdr->h_source));
136 memcpy(p_ethhdr->h_dest, rx_pkt_hdr->eth803_hdr.h_dest,
137 sizeof(p_ethhdr->h_dest));
116 /* Chop off the rxpd + the excess memory from 138 /* Chop off the rxpd + the excess memory from
117 * 802.2/llc/snap header that was removed. 139 * 802.2/llc/snap header that was removed.
118 */ 140 */
119 hdr_chop = (u8 *)eth_hdr - (u8 *)uap_rx_pd; 141 hdr_chop = (u8 *)p_ethhdr - (u8 *)uap_rx_pd;
120 else 142 } else {
121 /* Chop off the rxpd */ 143 /* Chop off the rxpd */
122 hdr_chop = (u8 *)&rx_pkt_hdr->eth803_hdr - (u8 *)uap_rx_pd; 144 hdr_chop = (u8 *)&rx_pkt_hdr->eth803_hdr - (u8 *)uap_rx_pd;
145 }
123 146
124 /* Chop off the leading header bytes so the it points 147 /* Chop off the leading header bytes so the it points
125 * to the start of either the reconstructed EthII frame 148 * to the start of either the reconstructed EthII frame
diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c
index 5dd0ccc70b86..13eaeed03898 100644
--- a/drivers/net/wireless/mwifiex/wmm.c
+++ b/drivers/net/wireless/mwifiex/wmm.c
@@ -722,6 +722,9 @@ int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv,
722 tlv_hdr = (struct mwifiex_ie_types_data *) curr; 722 tlv_hdr = (struct mwifiex_ie_types_data *) curr;
723 tlv_len = le16_to_cpu(tlv_hdr->header.len); 723 tlv_len = le16_to_cpu(tlv_hdr->header.len);
724 724
725 if (resp_len < tlv_len + sizeof(tlv_hdr->header))
726 break;
727
725 switch (le16_to_cpu(tlv_hdr->header.type)) { 728 switch (le16_to_cpu(tlv_hdr->header.type)) {
726 case TLV_TYPE_WMMQSTATUS: 729 case TLV_TYPE_WMMQSTATUS:
727 tlv_wmm_qstatus = 730 tlv_wmm_qstatus =
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index 41a16d30c79c..e05d9b4c8317 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -811,6 +811,10 @@ static const struct net_device_ops islpci_netdev_ops = {
811 .ndo_validate_addr = eth_validate_addr, 811 .ndo_validate_addr = eth_validate_addr,
812}; 812};
813 813
814static struct device_type wlan_type = {
815 .name = "wlan",
816};
817
814struct net_device * 818struct net_device *
815islpci_setup(struct pci_dev *pdev) 819islpci_setup(struct pci_dev *pdev)
816{ 820{
@@ -821,9 +825,8 @@ islpci_setup(struct pci_dev *pdev)
821 return ndev; 825 return ndev;
822 826
823 pci_set_drvdata(pdev, ndev); 827 pci_set_drvdata(pdev, ndev);
824#if defined(SET_NETDEV_DEV)
825 SET_NETDEV_DEV(ndev, &pdev->dev); 828 SET_NETDEV_DEV(ndev, &pdev->dev);
826#endif 829 SET_NETDEV_DEVTYPE(ndev, &wlan_type);
827 830
828 /* setup the structure members */ 831 /* setup the structure members */
829 ndev->base_addr = pci_resource_start(pdev, 0); 832 ndev->base_addr = pci_resource_start(pdev, 0);
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index c5738f14c4ba..776aff3678ff 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2640,7 +2640,7 @@ static void rt2800_config_channel_rf53xx(struct rt2x00_dev *rt2x00dev,
2640 2640
2641 if (rt2x00_rt(rt2x00dev, RT5392)) { 2641 if (rt2x00_rt(rt2x00dev, RT5392)) {
2642 rt2800_rfcsr_read(rt2x00dev, 50, &rfcsr); 2642 rt2800_rfcsr_read(rt2x00dev, 50, &rfcsr);
2643 if (info->default_power1 > POWER_BOUND) 2643 if (info->default_power2 > POWER_BOUND)
2644 rt2x00_set_field8(&rfcsr, RFCSR50_TX, POWER_BOUND); 2644 rt2x00_set_field8(&rfcsr, RFCSR50_TX, POWER_BOUND);
2645 else 2645 else
2646 rt2x00_set_field8(&rfcsr, RFCSR50_TX, 2646 rt2x00_set_field8(&rfcsr, RFCSR50_TX,
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index a0935987fa3a..7f40ab8e1bd8 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -146,7 +146,7 @@ void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length);
146 * @local: frame is not from mac80211 146 * @local: frame is not from mac80211
147 */ 147 */
148int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, 148int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
149 bool local); 149 struct ieee80211_sta *sta, bool local);
150 150
151/** 151/**
152 * rt2x00queue_update_beacon - Send new beacon from mac80211 152 * rt2x00queue_update_beacon - Send new beacon from mac80211
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 7c157857f5ce..2183e7978399 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -90,7 +90,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
90 frag_skb->data, data_length, tx_info, 90 frag_skb->data, data_length, tx_info,
91 (struct ieee80211_rts *)(skb->data)); 91 (struct ieee80211_rts *)(skb->data));
92 92
93 retval = rt2x00queue_write_tx_frame(queue, skb, true); 93 retval = rt2x00queue_write_tx_frame(queue, skb, NULL, true);
94 if (retval) { 94 if (retval) {
95 dev_kfree_skb_any(skb); 95 dev_kfree_skb_any(skb);
96 rt2x00_warn(rt2x00dev, "Failed to send RTS/CTS frame\n"); 96 rt2x00_warn(rt2x00dev, "Failed to send RTS/CTS frame\n");
@@ -151,7 +151,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw,
151 goto exit_fail; 151 goto exit_fail;
152 } 152 }
153 153
154 if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false))) 154 if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false)))
155 goto exit_fail; 155 goto exit_fail;
156 156
157 /* 157 /*
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 50590b1420a5..a5d38e8ad9e4 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -635,7 +635,7 @@ static void rt2x00queue_bar_check(struct queue_entry *entry)
635} 635}
636 636
637int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, 637int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
638 bool local) 638 struct ieee80211_sta *sta, bool local)
639{ 639{
640 struct ieee80211_tx_info *tx_info; 640 struct ieee80211_tx_info *tx_info;
641 struct queue_entry *entry; 641 struct queue_entry *entry;
@@ -649,7 +649,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
649 * after that we are free to use the skb->cb array 649 * after that we are free to use the skb->cb array
650 * for our information. 650 * for our information.
651 */ 651 */
652 rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, NULL); 652 rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, sta);
653 653
654 /* 654 /*
655 * All information is retrieved from the skb->cb array, 655 * All information is retrieved from the skb->cb array,
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 9a78e3daf742..ff784072fb42 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -37,6 +37,7 @@
37 37
38#include <linux/ip.h> 38#include <linux/ip.h>
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/udp.h>
40 41
41/* 42/*
42 *NOTICE!!!: This file will be very big, we should 43 *NOTICE!!!: This file will be very big, we should
@@ -1074,64 +1075,52 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
1074 if (!ieee80211_is_data(fc)) 1075 if (!ieee80211_is_data(fc))
1075 return false; 1076 return false;
1076 1077
1078 ip = (const struct iphdr *)(skb->data + mac_hdr_len +
1079 SNAP_SIZE + PROTOC_TYPE_SIZE);
1080 ether_type = be16_to_cpup((__be16 *)
1081 (skb->data + mac_hdr_len + SNAP_SIZE));
1077 1082
1078 ip = (struct iphdr *)((u8 *) skb->data + mac_hdr_len + 1083 switch (ether_type) {
1079 SNAP_SIZE + PROTOC_TYPE_SIZE); 1084 case ETH_P_IP: {
1080 ether_type = *(u16 *) ((u8 *) skb->data + mac_hdr_len + SNAP_SIZE); 1085 struct udphdr *udp;
1081 /* ether_type = ntohs(ether_type); */ 1086 u16 src;
1082 1087 u16 dst;
1083 if (ETH_P_IP == ether_type) {
1084 if (IPPROTO_UDP == ip->protocol) {
1085 struct udphdr *udp = (struct udphdr *)((u8 *) ip +
1086 (ip->ihl << 2));
1087 if (((((u8 *) udp)[1] == 68) &&
1088 (((u8 *) udp)[3] == 67)) ||
1089 ((((u8 *) udp)[1] == 67) &&
1090 (((u8 *) udp)[3] == 68))) {
1091 /*
1092 * 68 : UDP BOOTP client
1093 * 67 : UDP BOOTP server
1094 */
1095 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV),
1096 DBG_DMESG, "dhcp %s !!\n",
1097 is_tx ? "Tx" : "Rx");
1098
1099 if (is_tx) {
1100 rtlpriv->enter_ps = false;
1101 schedule_work(&rtlpriv->
1102 works.lps_change_work);
1103 ppsc->last_delaylps_stamp_jiffies =
1104 jiffies;
1105 }
1106 1088
1107 return true; 1089 if (ip->protocol != IPPROTO_UDP)
1108 } 1090 return false;
1109 } 1091 udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
1110 } else if (ETH_P_ARP == ether_type) { 1092 src = be16_to_cpu(udp->source);
1111 if (is_tx) { 1093 dst = be16_to_cpu(udp->dest);
1112 rtlpriv->enter_ps = false;
1113 schedule_work(&rtlpriv->works.lps_change_work);
1114 ppsc->last_delaylps_stamp_jiffies = jiffies;
1115 }
1116 1094
1117 return true; 1095 /* If this case involves port 68 (UDP BOOTP client) connecting
1118 } else if (ETH_P_PAE == ether_type) { 1096 * with port 67 (UDP BOOTP server), then return true so that
1097 * the lowest speed is used.
1098 */
1099 if (!((src == 68 && dst == 67) || (src == 67 && dst == 68)))
1100 return false;
1101
1102 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
1103 "dhcp %s !!\n", is_tx ? "Tx" : "Rx");
1104 break;
1105 }
1106 case ETH_P_ARP:
1107 break;
1108 case ETH_P_PAE:
1119 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 1109 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
1120 "802.1X %s EAPOL pkt!!\n", is_tx ? "Tx" : "Rx"); 1110 "802.1X %s EAPOL pkt!!\n", is_tx ? "Tx" : "Rx");
1121 1111 break;
1122 if (is_tx) { 1112 case ETH_P_IPV6:
1123 rtlpriv->enter_ps = false; 1113 /* TODO: Is this right? */
1124 schedule_work(&rtlpriv->works.lps_change_work); 1114 return false;
1125 ppsc->last_delaylps_stamp_jiffies = jiffies; 1115 default:
1126 } 1116 return false;
1127
1128 return true;
1129 } else if (ETH_P_IPV6 == ether_type) {
1130 /* IPv6 */
1131 return true;
1132 } 1117 }
1133 1118 if (is_tx) {
1134 return false; 1119 rtlpriv->enter_ps = false;
1120 schedule_work(&rtlpriv->works.lps_change_work);
1121 ppsc->last_delaylps_stamp_jiffies = jiffies;
1122 }
1123 return true;
1135} 1124}
1136EXPORT_SYMBOL_GPL(rtl_is_special_data); 1125EXPORT_SYMBOL_GPL(rtl_is_special_data);
1137 1126
diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c
index ae13fb94b2e8..2ffc7298f686 100644
--- a/drivers/net/wireless/rtlwifi/efuse.c
+++ b/drivers/net/wireless/rtlwifi/efuse.c
@@ -262,9 +262,9 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
262 sizeof(u8), GFP_ATOMIC); 262 sizeof(u8), GFP_ATOMIC);
263 if (!efuse_tbl) 263 if (!efuse_tbl)
264 return; 264 return;
265 efuse_word = kmalloc(EFUSE_MAX_WORD_UNIT * sizeof(u16 *), GFP_ATOMIC); 265 efuse_word = kzalloc(EFUSE_MAX_WORD_UNIT * sizeof(u16 *), GFP_ATOMIC);
266 if (!efuse_word) 266 if (!efuse_word)
267 goto done; 267 goto out;
268 for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { 268 for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
269 efuse_word[i] = kmalloc(efuse_max_section * sizeof(u16), 269 efuse_word[i] = kmalloc(efuse_max_section * sizeof(u16),
270 GFP_ATOMIC); 270 GFP_ATOMIC);
@@ -378,6 +378,7 @@ done:
378 for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) 378 for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++)
379 kfree(efuse_word[i]); 379 kfree(efuse_word[i]);
380 kfree(efuse_word); 380 kfree(efuse_word);
381out:
381 kfree(efuse_tbl); 382 kfree(efuse_tbl);
382} 383}
383 384
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
index 25e50ffc44ec..b0c346a9e4b8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
@@ -349,7 +349,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
349 p_drvinfo); 349 p_drvinfo);
350 } 350 }
351 /*rx_status->qual = stats->signal; */ 351 /*rx_status->qual = stats->signal; */
352 rx_status->signal = stats->rssi + 10; 352 rx_status->signal = stats->recvsignalpower + 10;
353 return true; 353 return true;
354} 354}
355 355
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
index 945ddecf90c9..0eb0f4ae5920 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -525,7 +525,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
525 p_drvinfo); 525 p_drvinfo);
526 } 526 }
527 /*rx_status->qual = stats->signal; */ 527 /*rx_status->qual = stats->signal; */
528 rx_status->signal = stats->rssi + 10; 528 rx_status->signal = stats->recvsignalpower + 10;
529 return true; 529 return true;
530} 530}
531 531
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
index 5061f1db3f02..92d38ab3c60e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
@@ -265,7 +265,7 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw,
265 rtlefuse->pwrgroup_ht40 265 rtlefuse->pwrgroup_ht40
266 [RF90_PATH_A][chnl - 1]) { 266 [RF90_PATH_A][chnl - 1]) {
267 pwrdiff_limit[i] = 267 pwrdiff_limit[i] =
268 rtlefuse->pwrgroup_ht20 268 rtlefuse->pwrgroup_ht40
269 [RF90_PATH_A][chnl - 1]; 269 [RF90_PATH_A][chnl - 1];
270 } 270 }
271 } else { 271 } else {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index 222d2e792ca6..27efbcdac6a9 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -329,7 +329,7 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
329 } 329 }
330 330
331 /*rx_status->qual = stats->signal; */ 331 /*rx_status->qual = stats->signal; */
332 rx_status->signal = stats->rssi + 10; 332 rx_status->signal = stats->recvsignalpower + 10;
333 333
334 return true; 334 return true;
335} 335}
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index d224dc3bb092..0c65386fa30d 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -77,11 +77,7 @@
77#define RTL_SLOT_TIME_9 9 77#define RTL_SLOT_TIME_9 9
78#define RTL_SLOT_TIME_20 20 78#define RTL_SLOT_TIME_20 20
79 79
80/*related with tcp/ip. */ 80/*related to tcp/ip. */
81/*if_ehther.h*/
82#define ETH_P_PAE 0x888E /*Port Access Entity (IEEE 802.1X) */
83#define ETH_P_IP 0x0800 /*Internet Protocol packet */
84#define ETH_P_ARP 0x0806 /*Address Resolution packet */
85#define SNAP_SIZE 6 81#define SNAP_SIZE 6
86#define PROTOC_TYPE_SIZE 2 82#define PROTOC_TYPE_SIZE 2
87 83
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index d85e66979711..e59acb1daa23 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -277,12 +277,13 @@ static void xennet_alloc_rx_buffers(struct net_device *dev)
277 if (!page) { 277 if (!page) {
278 kfree_skb(skb); 278 kfree_skb(skb);
279no_skb: 279no_skb:
280 /* Any skbuffs queued for refill? Force them out. */
281 if (i != 0)
282 goto refill;
283 /* Could not allocate any skbuffs. Try again later. */ 280 /* Could not allocate any skbuffs. Try again later. */
284 mod_timer(&np->rx_refill_timer, 281 mod_timer(&np->rx_refill_timer,
285 jiffies + (HZ/10)); 282 jiffies + (HZ/10));
283
284 /* Any skbuffs queued for refill? Force them out. */
285 if (i != 0)
286 goto refill;
286 break; 287 break;
287 } 288 }
288 289
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index e43db7742047..bd6f743d87a7 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -1512,7 +1512,8 @@ static int pmcraid_notify_aen(
1512 } 1512 }
1513 1513
1514 result = 1514 result =
1515 genlmsg_multicast(skb, 0, pmcraid_event_family.id, GFP_ATOMIC); 1515 genlmsg_multicast(&pmcraid_event_family, skb, 0,
1516 pmcraid_event_family.id, GFP_ATOMIC);
1516 1517
1517 /* If there are no listeners, genlmsg_multicast may return non-zero 1518 /* If there are no listeners, genlmsg_multicast may return non-zero
1518 * value. 1519 * value.
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 03a567199bbe..f1d511a9475b 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1608,15 +1608,17 @@ exit:
1608EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name); 1608EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name);
1609 1609
1610#ifdef CONFIG_NET 1610#ifdef CONFIG_NET
1611static const struct genl_multicast_group thermal_event_mcgrps[] = {
1612 { .name = THERMAL_GENL_MCAST_GROUP_NAME, },
1613};
1614
1611static struct genl_family thermal_event_genl_family = { 1615static struct genl_family thermal_event_genl_family = {
1612 .id = GENL_ID_GENERATE, 1616 .id = GENL_ID_GENERATE,
1613 .name = THERMAL_GENL_FAMILY_NAME, 1617 .name = THERMAL_GENL_FAMILY_NAME,
1614 .version = THERMAL_GENL_VERSION, 1618 .version = THERMAL_GENL_VERSION,
1615 .maxattr = THERMAL_GENL_ATTR_MAX, 1619 .maxattr = THERMAL_GENL_ATTR_MAX,
1616}; 1620 .mcgrps = thermal_event_mcgrps,
1617 1621 .n_mcgrps = ARRAY_SIZE(thermal_event_mcgrps),
1618static struct genl_multicast_group thermal_event_mcgrp = {
1619 .name = THERMAL_GENL_MCAST_GROUP_NAME,
1620}; 1622};
1621 1623
1622int thermal_generate_netlink_event(struct thermal_zone_device *tz, 1624int thermal_generate_netlink_event(struct thermal_zone_device *tz,
@@ -1677,7 +1679,8 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz,
1677 return result; 1679 return result;
1678 } 1680 }
1679 1681
1680 result = genlmsg_multicast(skb, 0, thermal_event_mcgrp.id, GFP_ATOMIC); 1682 result = genlmsg_multicast(&thermal_event_genl_family, skb, 0,
1683 0, GFP_ATOMIC);
1681 if (result) 1684 if (result)
1682 dev_err(&tz->device, "Failed to send netlink event:%d", result); 1685 dev_err(&tz->device, "Failed to send netlink event:%d", result);
1683 1686
@@ -1687,17 +1690,7 @@ EXPORT_SYMBOL_GPL(thermal_generate_netlink_event);
1687 1690
1688static int genetlink_init(void) 1691static int genetlink_init(void)
1689{ 1692{
1690 int result; 1693 return genl_register_family(&thermal_event_genl_family);
1691
1692 result = genl_register_family(&thermal_event_genl_family);
1693 if (result)
1694 return result;
1695
1696 result = genl_register_mc_group(&thermal_event_genl_family,
1697 &thermal_event_mcgrp);
1698 if (result)
1699 genl_unregister_family(&thermal_event_genl_family);
1700 return result;
1701} 1694}
1702 1695
1703static void genetlink_exit(void) 1696static void genetlink_exit(void)
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c
index 60a327863b11..e7cfbaf8d0e2 100644
--- a/fs/dlm/netlink.c
+++ b/fs/dlm/netlink.c
@@ -74,14 +74,16 @@ static int user_cmd(struct sk_buff *skb, struct genl_info *info)
74 return 0; 74 return 0;
75} 75}
76 76
77static struct genl_ops dlm_nl_ops = { 77static struct genl_ops dlm_nl_ops[] = {
78 .cmd = DLM_CMD_HELLO, 78 {
79 .doit = user_cmd, 79 .cmd = DLM_CMD_HELLO,
80 .doit = user_cmd,
81 },
80}; 82};
81 83
82int __init dlm_netlink_init(void) 84int __init dlm_netlink_init(void)
83{ 85{
84 return genl_register_family_with_ops(&family, &dlm_nl_ops, 1); 86 return genl_register_family_with_ops(&family, dlm_nl_ops);
85} 87}
86 88
87void dlm_netlink_exit(void) 89void dlm_netlink_exit(void)
diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
index 16e8abb7709b..72d29177998e 100644
--- a/fs/quota/netlink.c
+++ b/fs/quota/netlink.c
@@ -9,13 +9,25 @@
9#include <net/netlink.h> 9#include <net/netlink.h>
10#include <net/genetlink.h> 10#include <net/genetlink.h>
11 11
12static const struct genl_multicast_group quota_mcgrps[] = {
13 { .name = "events", },
14};
15
12/* Netlink family structure for quota */ 16/* Netlink family structure for quota */
13static struct genl_family quota_genl_family = { 17static struct genl_family quota_genl_family = {
14 .id = GENL_ID_GENERATE, 18 /*
19 * Needed due to multicast group ID abuse - old code assumed
20 * the family ID was also a valid multicast group ID (which
21 * isn't true) and userspace might thus rely on it. Assign a
22 * static ID for this group to make dealing with that easier.
23 */
24 .id = GENL_ID_VFS_DQUOT,
15 .hdrsize = 0, 25 .hdrsize = 0,
16 .name = "VFS_DQUOT", 26 .name = "VFS_DQUOT",
17 .version = 1, 27 .version = 1,
18 .maxattr = QUOTA_NL_A_MAX, 28 .maxattr = QUOTA_NL_A_MAX,
29 .mcgrps = quota_mcgrps,
30 .n_mcgrps = ARRAY_SIZE(quota_mcgrps),
19}; 31};
20 32
21/** 33/**
@@ -78,7 +90,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
78 goto attr_err_out; 90 goto attr_err_out;
79 genlmsg_end(skb, msg_head); 91 genlmsg_end(skb, msg_head);
80 92
81 genlmsg_multicast(skb, 0, quota_genl_family.id, GFP_NOFS); 93 genlmsg_multicast(&quota_genl_family, skb, 0, 0, GFP_NOFS);
82 return; 94 return;
83attr_err_out: 95attr_err_out:
84 printk(KERN_ERR "VFS: Not enough space to compose quota message!\n"); 96 printk(KERN_ERR "VFS: Not enough space to compose quota message!\n");
diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
index 023bc346b877..c0894dd8827b 100644
--- a/include/linux/genl_magic_func.h
+++ b/include/linux/genl_magic_func.h
@@ -273,49 +273,40 @@ static struct genl_family ZZZ_genl_family __read_mostly = {
273 * Magic: define multicast groups 273 * Magic: define multicast groups
274 * Magic: define multicast group registration helper 274 * Magic: define multicast group registration helper
275 */ 275 */
276#define ZZZ_genl_mcgrps CONCAT_(GENL_MAGIC_FAMILY, _genl_mcgrps)
277static const struct genl_multicast_group ZZZ_genl_mcgrps[] = {
278#undef GENL_mc_group
279#define GENL_mc_group(group) { .name = #group, },
280#include GENL_MAGIC_INCLUDE_FILE
281};
282
283enum CONCAT_(GENL_MAGIC_FAMILY, group_ids) {
284#undef GENL_mc_group
285#define GENL_mc_group(group) CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group),
286#include GENL_MAGIC_INCLUDE_FILE
287};
288
276#undef GENL_mc_group 289#undef GENL_mc_group
277#define GENL_mc_group(group) \ 290#define GENL_mc_group(group) \
278static struct genl_multicast_group \
279CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group) __read_mostly = { \
280 .name = #group, \
281}; \
282static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ 291static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \
283 struct sk_buff *skb, gfp_t flags) \ 292 struct sk_buff *skb, gfp_t flags) \
284{ \ 293{ \
285 unsigned int group_id = \ 294 unsigned int group_id = \
286 CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group).id; \ 295 CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group); \
287 if (!group_id) \ 296 return genlmsg_multicast(&ZZZ_genl_family, skb, 0, \
288 return -EINVAL; \ 297 group_id, flags); \
289 return genlmsg_multicast(skb, 0, group_id, flags); \
290} 298}
291 299
292#include GENL_MAGIC_INCLUDE_FILE 300#include GENL_MAGIC_INCLUDE_FILE
293 301
294int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void)
295{
296 int err = genl_register_family_with_ops(&ZZZ_genl_family,
297 ZZZ_genl_ops, ARRAY_SIZE(ZZZ_genl_ops));
298 if (err)
299 return err;
300#undef GENL_mc_group
301#define GENL_mc_group(group) \
302 err = genl_register_mc_group(&ZZZ_genl_family, \
303 &CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group)); \
304 if (err) \
305 goto fail; \
306 else \
307 pr_info("%s: mcg %s: %u\n", #group, \
308 __stringify(GENL_MAGIC_FAMILY), \
309 CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group).id);
310
311#include GENL_MAGIC_INCLUDE_FILE
312
313#undef GENL_mc_group 302#undef GENL_mc_group
314#define GENL_mc_group(group) 303#define GENL_mc_group(group)
315 return 0; 304
316fail: 305int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void)
317 genl_unregister_family(&ZZZ_genl_family); 306{
318 return err; 307 return genl_register_family_with_ops_groups(&ZZZ_genl_family, \
308 ZZZ_genl_ops, \
309 ZZZ_genl_mcgrps);
319} 310}
320 311
321void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void) 312void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void)
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
index c2702856295e..84ba5ac39e03 100644
--- a/include/linux/if_macvlan.h
+++ b/include/linux/if_macvlan.h
@@ -119,4 +119,21 @@ extern int macvlan_link_register(struct rtnl_link_ops *ops);
119extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb, 119extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
120 struct net_device *dev); 120 struct net_device *dev);
121 121
122#if IS_ENABLED(CONFIG_MACVLAN)
123static inline struct net_device *
124macvlan_dev_real_dev(const struct net_device *dev)
125{
126 struct macvlan_dev *macvlan = netdev_priv(dev);
127
128 return macvlan->lowerdev;
129}
130#else
131static inline struct net_device *
132macvlan_dev_real_dev(const struct net_device *dev)
133{
134 BUG();
135 return NULL;
136}
137#endif
138
122#endif /* _LINUX_IF_MACVLAN_H */ 139#endif /* _LINUX_IF_MACVLAN_H */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 215b5ea1cb30..bec1cc7d5e3c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2263,24 +2263,6 @@ static inline void skb_postpull_rcsum(struct sk_buff *skb,
2263 2263
2264unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len); 2264unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);
2265 2265
2266/**
2267 * pskb_trim_rcsum - trim received skb and update checksum
2268 * @skb: buffer to trim
2269 * @len: new length
2270 *
2271 * This is exactly the same as pskb_trim except that it ensures the
2272 * checksum of received packets are still valid after the operation.
2273 */
2274
2275static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
2276{
2277 if (likely(len >= skb->len))
2278 return 0;
2279 if (skb->ip_summed == CHECKSUM_COMPLETE)
2280 skb->ip_summed = CHECKSUM_NONE;
2281 return __pskb_trim(skb, len);
2282}
2283
2284#define skb_queue_walk(queue, skb) \ 2266#define skb_queue_walk(queue, skb) \
2285 for (skb = (queue)->next; \ 2267 for (skb = (queue)->next; \
2286 skb != (struct sk_buff *)(queue); \ 2268 skb != (struct sk_buff *)(queue); \
@@ -2378,6 +2360,27 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
2378__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, 2360__wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
2379 __wsum csum); 2361 __wsum csum);
2380 2362
2363/**
2364 * pskb_trim_rcsum - trim received skb and update checksum
2365 * @skb: buffer to trim
2366 * @len: new length
2367 *
2368 * This is exactly the same as pskb_trim except that it ensures the
2369 * checksum of received packets are still valid after the operation.
2370 */
2371
2372static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
2373{
2374 if (likely(len >= skb->len))
2375 return 0;
2376 if (skb->ip_summed == CHECKSUM_COMPLETE) {
2377 __wsum adj = skb_checksum(skb, len, skb->len - len, 0);
2378
2379 skb->csum = csum_sub(skb->csum, adj);
2380 }
2381 return __pskb_trim(skb, len);
2382}
2383
2381static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, 2384static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
2382 int len, void *buffer) 2385 int len, void *buffer)
2383{ 2386{
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 9b787b62cf16..ace4abf118d7 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -10,16 +10,9 @@
10/** 10/**
11 * struct genl_multicast_group - generic netlink multicast group 11 * struct genl_multicast_group - generic netlink multicast group
12 * @name: name of the multicast group, names are per-family 12 * @name: name of the multicast group, names are per-family
13 * @id: multicast group ID, assigned by the core, to use with
14 * genlmsg_multicast().
15 * @list: list entry for linking
16 * @family: pointer to family, need not be set before registering
17 */ 13 */
18struct genl_multicast_group { 14struct genl_multicast_group {
19 struct genl_family *family; /* private */
20 struct list_head list; /* private */
21 char name[GENL_NAMSIZ]; 15 char name[GENL_NAMSIZ];
22 u32 id;
23}; 16};
24 17
25struct genl_ops; 18struct genl_ops;
@@ -39,9 +32,12 @@ struct genl_info;
39 * @post_doit: called after an operation's doit callback, it may 32 * @post_doit: called after an operation's doit callback, it may
40 * undo operations done by pre_doit, for example release locks 33 * undo operations done by pre_doit, for example release locks
41 * @attrbuf: buffer to store parsed attributes 34 * @attrbuf: buffer to store parsed attributes
42 * @ops_list: list of all assigned operations
43 * @family_list: family list 35 * @family_list: family list
44 * @mcast_groups: multicast groups list 36 * @mcgrps: multicast groups used by this family (private)
37 * @n_mcgrps: number of multicast groups (private)
38 * @mcgrp_offset: starting number of multicast group IDs in this family
39 * @ops: the operations supported by this family (private)
40 * @n_ops: number of operations supported by this family (private)
45 */ 41 */
46struct genl_family { 42struct genl_family {
47 unsigned int id; 43 unsigned int id;
@@ -51,16 +47,19 @@ struct genl_family {
51 unsigned int maxattr; 47 unsigned int maxattr;
52 bool netnsok; 48 bool netnsok;
53 bool parallel_ops; 49 bool parallel_ops;
54 int (*pre_doit)(struct genl_ops *ops, 50 int (*pre_doit)(const struct genl_ops *ops,
55 struct sk_buff *skb, 51 struct sk_buff *skb,
56 struct genl_info *info); 52 struct genl_info *info);
57 void (*post_doit)(struct genl_ops *ops, 53 void (*post_doit)(const struct genl_ops *ops,
58 struct sk_buff *skb, 54 struct sk_buff *skb,
59 struct genl_info *info); 55 struct genl_info *info);
60 struct nlattr ** attrbuf; /* private */ 56 struct nlattr ** attrbuf; /* private */
61 struct list_head ops_list; /* private */ 57 const struct genl_ops * ops; /* private */
58 const struct genl_multicast_group *mcgrps; /* private */
59 unsigned int n_ops; /* private */
60 unsigned int n_mcgrps; /* private */
61 unsigned int mcgrp_offset; /* private */
62 struct list_head family_list; /* private */ 62 struct list_head family_list; /* private */
63 struct list_head mcast_groups; /* private */
64 struct module *module; 63 struct module *module;
65}; 64};
66 65
@@ -110,16 +109,15 @@ static inline void genl_info_net_set(struct genl_info *info, struct net *net)
110 * @ops_list: operations list 109 * @ops_list: operations list
111 */ 110 */
112struct genl_ops { 111struct genl_ops {
113 u8 cmd;
114 u8 internal_flags;
115 unsigned int flags;
116 const struct nla_policy *policy; 112 const struct nla_policy *policy;
117 int (*doit)(struct sk_buff *skb, 113 int (*doit)(struct sk_buff *skb,
118 struct genl_info *info); 114 struct genl_info *info);
119 int (*dumpit)(struct sk_buff *skb, 115 int (*dumpit)(struct sk_buff *skb,
120 struct netlink_callback *cb); 116 struct netlink_callback *cb);
121 int (*done)(struct netlink_callback *cb); 117 int (*done)(struct netlink_callback *cb);
122 struct list_head ops_list; 118 u8 cmd;
119 u8 internal_flags;
120 u8 flags;
123}; 121};
124 122
125int __genl_register_family(struct genl_family *family); 123int __genl_register_family(struct genl_family *family);
@@ -130,24 +128,53 @@ static inline int genl_register_family(struct genl_family *family)
130 return __genl_register_family(family); 128 return __genl_register_family(family);
131} 129}
132 130
133int __genl_register_family_with_ops(struct genl_family *family, 131/**
134 struct genl_ops *ops, size_t n_ops); 132 * genl_register_family_with_ops - register a generic netlink family with ops
135 133 * @family: generic netlink family
136static inline int genl_register_family_with_ops(struct genl_family *family, 134 * @ops: operations to be registered
137 struct genl_ops *ops, size_t n_ops) 135 * @n_ops: number of elements to register
136 *
137 * Registers the specified family and operations from the specified table.
138 * Only one family may be registered with the same family name or identifier.
139 *
140 * The family id may equal GENL_ID_GENERATE causing an unique id to
141 * be automatically generated and assigned.
142 *
143 * Either a doit or dumpit callback must be specified for every registered
144 * operation or the function will fail. Only one operation structure per
145 * command identifier may be registered.
146 *
147 * See include/net/genetlink.h for more documenation on the operations
148 * structure.
149 *
150 * Return 0 on success or a negative error code.
151 */
152static inline int
153_genl_register_family_with_ops_grps(struct genl_family *family,
154 const struct genl_ops *ops, size_t n_ops,
155 const struct genl_multicast_group *mcgrps,
156 size_t n_mcgrps)
138{ 157{
139 family->module = THIS_MODULE; 158 family->module = THIS_MODULE;
140 return __genl_register_family_with_ops(family, ops, n_ops); 159 family->ops = ops;
160 family->n_ops = n_ops;
161 family->mcgrps = mcgrps;
162 family->n_mcgrps = n_mcgrps;
163 return __genl_register_family(family);
141} 164}
142 165
166#define genl_register_family_with_ops(family, ops) \
167 _genl_register_family_with_ops_grps((family), \
168 (ops), ARRAY_SIZE(ops), \
169 NULL, 0)
170#define genl_register_family_with_ops_groups(family, ops, grps) \
171 _genl_register_family_with_ops_grps((family), \
172 (ops), ARRAY_SIZE(ops), \
173 (grps), ARRAY_SIZE(grps))
174
143int genl_unregister_family(struct genl_family *family); 175int genl_unregister_family(struct genl_family *family);
144int genl_register_ops(struct genl_family *, struct genl_ops *ops); 176void genl_notify(struct genl_family *family,
145int genl_unregister_ops(struct genl_family *, struct genl_ops *ops); 177 struct sk_buff *skb, struct net *net, u32 portid,
146int genl_register_mc_group(struct genl_family *family,
147 struct genl_multicast_group *grp);
148void genl_unregister_mc_group(struct genl_family *family,
149 struct genl_multicast_group *grp);
150void genl_notify(struct sk_buff *skb, struct net *net, u32 portid,
151 u32 group, struct nlmsghdr *nlh, gfp_t flags); 178 u32 group, struct nlmsghdr *nlh, gfp_t flags);
152 179
153void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, 180void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq,
@@ -227,41 +254,54 @@ static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr)
227 254
228/** 255/**
229 * genlmsg_multicast_netns - multicast a netlink message to a specific netns 256 * genlmsg_multicast_netns - multicast a netlink message to a specific netns
257 * @family: the generic netlink family
230 * @net: the net namespace 258 * @net: the net namespace
231 * @skb: netlink message as socket buffer 259 * @skb: netlink message as socket buffer
232 * @portid: own netlink portid to avoid sending to yourself 260 * @portid: own netlink portid to avoid sending to yourself
233 * @group: multicast group id 261 * @group: offset of multicast group in groups array
234 * @flags: allocation flags 262 * @flags: allocation flags
235 */ 263 */
236static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb, 264static inline int genlmsg_multicast_netns(struct genl_family *family,
265 struct net *net, struct sk_buff *skb,
237 u32 portid, unsigned int group, gfp_t flags) 266 u32 portid, unsigned int group, gfp_t flags)
238{ 267{
268 if (group >= family->n_mcgrps)
269 return -EINVAL;
270 group = family->mcgrp_offset + group;
239 return nlmsg_multicast(net->genl_sock, skb, portid, group, flags); 271 return nlmsg_multicast(net->genl_sock, skb, portid, group, flags);
240} 272}
241 273
242/** 274/**
243 * genlmsg_multicast - multicast a netlink message to the default netns 275 * genlmsg_multicast - multicast a netlink message to the default netns
276 * @family: the generic netlink family
244 * @skb: netlink message as socket buffer 277 * @skb: netlink message as socket buffer
245 * @portid: own netlink portid to avoid sending to yourself 278 * @portid: own netlink portid to avoid sending to yourself
246 * @group: multicast group id 279 * @group: offset of multicast group in groups array
247 * @flags: allocation flags 280 * @flags: allocation flags
248 */ 281 */
249static inline int genlmsg_multicast(struct sk_buff *skb, u32 portid, 282static inline int genlmsg_multicast(struct genl_family *family,
283 struct sk_buff *skb, u32 portid,
250 unsigned int group, gfp_t flags) 284 unsigned int group, gfp_t flags)
251{ 285{
252 return genlmsg_multicast_netns(&init_net, skb, portid, group, flags); 286 if (group >= family->n_mcgrps)
287 return -EINVAL;
288 group = family->mcgrp_offset + group;
289 return genlmsg_multicast_netns(family, &init_net, skb,
290 portid, group, flags);
253} 291}
254 292
255/** 293/**
256 * genlmsg_multicast_allns - multicast a netlink message to all net namespaces 294 * genlmsg_multicast_allns - multicast a netlink message to all net namespaces
295 * @family: the generic netlink family
257 * @skb: netlink message as socket buffer 296 * @skb: netlink message as socket buffer
258 * @portid: own netlink portid to avoid sending to yourself 297 * @portid: own netlink portid to avoid sending to yourself
259 * @group: multicast group id 298 * @group: offset of multicast group in groups array
260 * @flags: allocation flags 299 * @flags: allocation flags
261 * 300 *
262 * This function must hold the RTNL or rcu_read_lock(). 301 * This function must hold the RTNL or rcu_read_lock().
263 */ 302 */
264int genlmsg_multicast_allns(struct sk_buff *skb, u32 portid, 303int genlmsg_multicast_allns(struct genl_family *family,
304 struct sk_buff *skb, u32 portid,
265 unsigned int group, gfp_t flags); 305 unsigned int group, gfp_t flags);
266 306
267/** 307/**
@@ -332,5 +372,22 @@ static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
332 return nlmsg_new(genlmsg_total_size(payload), flags); 372 return nlmsg_new(genlmsg_total_size(payload), flags);
333} 373}
334 374
375/**
376 * genl_set_err - report error to genetlink broadcast listeners
377 * @family: the generic netlink family
378 * @net: the network namespace to report the error to
379 * @portid: the PORTID of a process that we want to skip (if any)
380 * @group: the broadcast group that will notice the error
381 * (this is the offset of the multicast group in the groups array)
382 * @code: error code, must be negative (as usual in kernelspace)
383 *
384 * This function returns the number of broadcast listeners that have set the
385 * NETLINK_RECV_NO_ENOBUFS socket option.
386 */
387static inline int genl_set_err(struct genl_family *family, struct net *net,
388 u32 portid, u32 group, int code)
389{
390 return netlink_set_err(net->genl_sock, portid, group, code);
391}
335 392
336#endif /* __NET_GENERIC_NETLINK_H */ 393#endif /* __NET_GENERIC_NETLINK_H */
diff --git a/include/uapi/linux/genetlink.h b/include/uapi/linux/genetlink.h
index c880a417d8a9..1af72d8228e0 100644
--- a/include/uapi/linux/genetlink.h
+++ b/include/uapi/linux/genetlink.h
@@ -27,6 +27,7 @@ struct genlmsghdr {
27 */ 27 */
28#define GENL_ID_GENERATE 0 28#define GENL_ID_GENERATE 0
29#define GENL_ID_CTRL NLMSG_MIN_TYPE 29#define GENL_ID_CTRL NLMSG_MIN_TYPE
30#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
30 31
31/************************************************************************** 32/**************************************************************************
32 * Controller 33 * Controller
diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index 307f293477e8..a806687ad98f 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -763,13 +763,14 @@ enum {
763 763
764 TCA_FQ_RATE_ENABLE, /* enable/disable rate limiting */ 764 TCA_FQ_RATE_ENABLE, /* enable/disable rate limiting */
765 765
766 TCA_FQ_FLOW_DEFAULT_RATE,/* for sockets with unspecified sk_rate, 766 TCA_FQ_FLOW_DEFAULT_RATE,/* obsolete, do not use */
767 * use the following rate
768 */
769 767
770 TCA_FQ_FLOW_MAX_RATE, /* per flow max rate */ 768 TCA_FQ_FLOW_MAX_RATE, /* per flow max rate */
771 769
772 TCA_FQ_BUCKETS_LOG, /* log2(number of buckets) */ 770 TCA_FQ_BUCKETS_LOG, /* log2(number of buckets) */
771
772 TCA_FQ_FLOW_REFILL_DELAY, /* flow credit refill delay in usec */
773
773 __TCA_FQ_MAX 774 __TCA_FQ_MAX
774}; 775};
775 776
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 9f4618eb51c8..13d2f7cd65db 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -673,17 +673,18 @@ err:
673 nlmsg_free(rep_skb); 673 nlmsg_free(rep_skb);
674} 674}
675 675
676static struct genl_ops taskstats_ops = { 676static const struct genl_ops taskstats_ops[] = {
677 .cmd = TASKSTATS_CMD_GET, 677 {
678 .doit = taskstats_user_cmd, 678 .cmd = TASKSTATS_CMD_GET,
679 .policy = taskstats_cmd_get_policy, 679 .doit = taskstats_user_cmd,
680 .flags = GENL_ADMIN_PERM, 680 .policy = taskstats_cmd_get_policy,
681}; 681 .flags = GENL_ADMIN_PERM,
682 682 },
683static struct genl_ops cgroupstats_ops = { 683 {
684 .cmd = CGROUPSTATS_CMD_GET, 684 .cmd = CGROUPSTATS_CMD_GET,
685 .doit = cgroupstats_user_cmd, 685 .doit = cgroupstats_user_cmd,
686 .policy = cgroupstats_cmd_get_policy, 686 .policy = cgroupstats_cmd_get_policy,
687 },
687}; 688};
688 689
689/* Needed early in initialization */ 690/* Needed early in initialization */
@@ -702,26 +703,13 @@ static int __init taskstats_init(void)
702{ 703{
703 int rc; 704 int rc;
704 705
705 rc = genl_register_family(&family); 706 rc = genl_register_family_with_ops(&family, taskstats_ops);
706 if (rc) 707 if (rc)
707 return rc; 708 return rc;
708 709
709 rc = genl_register_ops(&family, &taskstats_ops);
710 if (rc < 0)
711 goto err;
712
713 rc = genl_register_ops(&family, &cgroupstats_ops);
714 if (rc < 0)
715 goto err_cgroup_ops;
716
717 family_registered = 1; 710 family_registered = 1;
718 pr_info("registered taskstats version %d\n", TASKSTATS_GENL_VERSION); 711 pr_info("registered taskstats version %d\n", TASKSTATS_GENL_VERSION);
719 return 0; 712 return 0;
720err_cgroup_ops:
721 genl_unregister_ops(&family, &taskstats_ops);
722err:
723 genl_unregister_family(&family);
724 return rc;
725} 713}
726 714
727/* 715/*
diff --git a/lib/random32.c b/lib/random32.c
index 82da4f4c3489..1e5b2df44291 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -214,18 +214,22 @@ static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0);
214static void __prandom_timer(unsigned long dontcare) 214static void __prandom_timer(unsigned long dontcare)
215{ 215{
216 u32 entropy; 216 u32 entropy;
217 unsigned long expires;
217 218
218 get_random_bytes(&entropy, sizeof(entropy)); 219 get_random_bytes(&entropy, sizeof(entropy));
219 prandom_seed(entropy); 220 prandom_seed(entropy);
221
220 /* reseed every ~60 seconds, in [40 .. 80) interval with slack */ 222 /* reseed every ~60 seconds, in [40 .. 80) interval with slack */
221 seed_timer.expires = jiffies + (40 * HZ + (prandom_u32() % (40 * HZ))); 223 expires = 40 + (prandom_u32() % 40);
224 seed_timer.expires = jiffies + msecs_to_jiffies(expires * MSEC_PER_SEC);
225
222 add_timer(&seed_timer); 226 add_timer(&seed_timer);
223} 227}
224 228
225static void prandom_start_seed_timer(void) 229static void __init __prandom_start_seed_timer(void)
226{ 230{
227 set_timer_slack(&seed_timer, HZ); 231 set_timer_slack(&seed_timer, HZ);
228 seed_timer.expires = jiffies + 40 * HZ; 232 seed_timer.expires = jiffies + msecs_to_jiffies(40 * MSEC_PER_SEC);
229 add_timer(&seed_timer); 233 add_timer(&seed_timer);
230} 234}
231 235
@@ -270,7 +274,7 @@ void prandom_reseed_late(void)
270static int __init prandom_reseed(void) 274static int __init prandom_reseed(void)
271{ 275{
272 __prandom_reseed(false); 276 __prandom_reseed(false);
273 prandom_start_seed_timer(); 277 __prandom_start_seed_timer();
274 return 0; 278 return 0;
275} 279}
276late_initcall(prandom_reseed); 280late_initcall(prandom_reseed);
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index c41d5fbb91d0..6e6194fcd88e 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -172,6 +172,7 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)
172 del_nbp(p); 172 del_nbp(p);
173 } 173 }
174 174
175 br_vlan_flush(br);
175 del_timer_sync(&br->gc_timer); 176 del_timer_sync(&br->gc_timer);
176 177
177 br_sysfs_delbr(br->dev); 178 br_sysfs_delbr(br->dev);
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 53f0990eab58..af5ebd18d705 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -34,7 +34,6 @@ static void __vlan_add_flags(struct net_port_vlans *v, u16 vid, u16 flags)
34 34
35static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags) 35static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
36{ 36{
37 const struct net_device_ops *ops;
38 struct net_bridge_port *p = NULL; 37 struct net_bridge_port *p = NULL;
39 struct net_bridge *br; 38 struct net_bridge *br;
40 struct net_device *dev; 39 struct net_device *dev;
@@ -53,17 +52,15 @@ static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
53 br = v->parent.br; 52 br = v->parent.br;
54 dev = br->dev; 53 dev = br->dev;
55 } 54 }
56 ops = dev->netdev_ops;
57 55
58 if (p && (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) { 56 if (p) {
59 /* Add VLAN to the device filter if it is supported. 57 /* Add VLAN to the device filter if it is supported.
60 * Stricly speaking, this is not necessary now, since 58 * Stricly speaking, this is not necessary now, since
61 * devices are made promiscuous by the bridge, but if 59 * devices are made promiscuous by the bridge, but if
62 * that ever changes this code will allow tagged 60 * that ever changes this code will allow tagged
63 * traffic to enter the bridge. 61 * traffic to enter the bridge.
64 */ 62 */
65 err = ops->ndo_vlan_rx_add_vid(dev, htons(ETH_P_8021Q), 63 err = vlan_vid_add(dev, htons(ETH_P_8021Q), vid);
66 vid);
67 if (err) 64 if (err)
68 return err; 65 return err;
69 } 66 }
@@ -82,8 +79,8 @@ static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
82 return 0; 79 return 0;
83 80
84out_filt: 81out_filt:
85 if (p && (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) 82 if (p)
86 ops->ndo_vlan_rx_kill_vid(dev, htons(ETH_P_8021Q), vid); 83 vlan_vid_del(dev, htons(ETH_P_8021Q), vid);
87 return err; 84 return err;
88} 85}
89 86
@@ -95,13 +92,8 @@ static int __vlan_del(struct net_port_vlans *v, u16 vid)
95 __vlan_delete_pvid(v, vid); 92 __vlan_delete_pvid(v, vid);
96 clear_bit(vid, v->untagged_bitmap); 93 clear_bit(vid, v->untagged_bitmap);
97 94
98 if (v->port_idx) { 95 if (v->port_idx)
99 struct net_device *dev = v->parent.port->dev; 96 vlan_vid_del(v->parent.port->dev, htons(ETH_P_8021Q), vid);
100 const struct net_device_ops *ops = dev->netdev_ops;
101
102 if (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
103 ops->ndo_vlan_rx_kill_vid(dev, htons(ETH_P_8021Q), vid);
104 }
105 97
106 clear_bit(vid, v->vlan_bitmap); 98 clear_bit(vid, v->vlan_bitmap);
107 v->num_vlans--; 99 v->num_vlans--;
@@ -398,6 +390,7 @@ int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
398void nbp_vlan_flush(struct net_bridge_port *port) 390void nbp_vlan_flush(struct net_bridge_port *port)
399{ 391{
400 struct net_port_vlans *pv; 392 struct net_port_vlans *pv;
393 u16 vid;
401 394
402 ASSERT_RTNL(); 395 ASSERT_RTNL();
403 396
@@ -405,6 +398,9 @@ void nbp_vlan_flush(struct net_bridge_port *port)
405 if (!pv) 398 if (!pv)
406 return; 399 return;
407 400
401 for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID)
402 vlan_vid_del(port->dev, htons(ETH_P_8021Q), vid);
403
408 __vlan_flush(pv); 404 __vlan_flush(pv);
409} 405}
410 406
diff --git a/net/core/dev.c b/net/core/dev.c
index 8ffc52e01ece..7e00a7342ee6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -131,6 +131,7 @@
131#include <linux/static_key.h> 131#include <linux/static_key.h>
132#include <linux/hashtable.h> 132#include <linux/hashtable.h>
133#include <linux/vmalloc.h> 133#include <linux/vmalloc.h>
134#include <linux/if_macvlan.h>
134 135
135#include "net-sysfs.h" 136#include "net-sysfs.h"
136 137
@@ -1424,6 +1425,10 @@ void dev_disable_lro(struct net_device *dev)
1424 if (is_vlan_dev(dev)) 1425 if (is_vlan_dev(dev))
1425 dev = vlan_dev_real_dev(dev); 1426 dev = vlan_dev_real_dev(dev);
1426 1427
1428 /* the same for macvlan devices */
1429 if (netif_is_macvlan(dev))
1430 dev = macvlan_dev_real_dev(dev);
1431
1427 dev->wanted_features &= ~NETIF_F_LRO; 1432 dev->wanted_features &= ~NETIF_F_LRO;
1428 netdev_update_features(dev); 1433 netdev_update_features(dev);
1429 1434
@@ -1690,13 +1695,9 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
1690 kfree_skb(skb); 1695 kfree_skb(skb);
1691 return NET_RX_DROP; 1696 return NET_RX_DROP;
1692 } 1697 }
1693 skb->protocol = eth_type_trans(skb, dev);
1694 1698
1695 /* eth_type_trans() can set pkt_type.
1696 * call skb_scrub_packet() after it to clear pkt_type _after_ calling
1697 * eth_type_trans().
1698 */
1699 skb_scrub_packet(skb, true); 1699 skb_scrub_packet(skb, true);
1700 skb->protocol = eth_type_trans(skb, dev);
1700 1701
1701 return netif_rx(skb); 1702 return netif_rx(skb);
1702} 1703}
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 5e78d44333b9..95897183226e 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -106,6 +106,10 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
106 return skb; 106 return skb;
107} 107}
108 108
109static struct genl_multicast_group dropmon_mcgrps[] = {
110 { .name = "events", },
111};
112
109static void send_dm_alert(struct work_struct *work) 113static void send_dm_alert(struct work_struct *work)
110{ 114{
111 struct sk_buff *skb; 115 struct sk_buff *skb;
@@ -116,7 +120,8 @@ static void send_dm_alert(struct work_struct *work)
116 skb = reset_per_cpu_data(data); 120 skb = reset_per_cpu_data(data);
117 121
118 if (skb) 122 if (skb)
119 genlmsg_multicast(skb, 0, NET_DM_GRP_ALERT, GFP_KERNEL); 123 genlmsg_multicast(&net_drop_monitor_family, skb, 0,
124 0, GFP_KERNEL);
120} 125}
121 126
122/* 127/*
@@ -333,7 +338,7 @@ out:
333 return NOTIFY_DONE; 338 return NOTIFY_DONE;
334} 339}
335 340
336static struct genl_ops dropmon_ops[] = { 341static const struct genl_ops dropmon_ops[] = {
337 { 342 {
338 .cmd = NET_DM_CMD_CONFIG, 343 .cmd = NET_DM_CMD_CONFIG,
339 .doit = net_dm_cmd_config, 344 .doit = net_dm_cmd_config,
@@ -364,13 +369,13 @@ static int __init init_net_drop_monitor(void)
364 return -ENOSPC; 369 return -ENOSPC;
365 } 370 }
366 371
367 rc = genl_register_family_with_ops(&net_drop_monitor_family, 372 rc = genl_register_family_with_ops_groups(&net_drop_monitor_family,
368 dropmon_ops, 373 dropmon_ops, dropmon_mcgrps);
369 ARRAY_SIZE(dropmon_ops));
370 if (rc) { 374 if (rc) {
371 pr_err("Could not create drop monitor netlink family\n"); 375 pr_err("Could not create drop monitor netlink family\n");
372 return rc; 376 return rc;
373 } 377 }
378 WARN_ON(net_drop_monitor_family.mcgrp_offset != NET_DM_GRP_ALERT);
374 379
375 rc = register_netdevice_notifier(&dropmon_net_notifier); 380 rc = register_netdevice_notifier(&dropmon_net_notifier);
376 if (rc < 0) { 381 if (rc < 0) {
diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
index 4e66bf61f585..5325af85eea6 100644
--- a/net/hsr/hsr_netlink.c
+++ b/net/hsr/hsr_netlink.c
@@ -90,8 +90,8 @@ static struct genl_family hsr_genl_family = {
90 .maxattr = HSR_A_MAX, 90 .maxattr = HSR_A_MAX,
91}; 91};
92 92
93static struct genl_multicast_group hsr_network_genl_mcgrp = { 93static const struct genl_multicast_group hsr_mcgrps[] = {
94 .name = "hsr-network", 94 { .name = "hsr-network", },
95}; 95};
96 96
97 97
@@ -129,7 +129,7 @@ void hsr_nl_ringerror(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN],
129 goto nla_put_failure; 129 goto nla_put_failure;
130 130
131 genlmsg_end(skb, msg_head); 131 genlmsg_end(skb, msg_head);
132 genlmsg_multicast(skb, 0, hsr_network_genl_mcgrp.id, GFP_ATOMIC); 132 genlmsg_multicast(&hsr_genl_family, skb, 0, 0, GFP_ATOMIC);
133 133
134 return; 134 return;
135 135
@@ -163,7 +163,7 @@ void hsr_nl_nodedown(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN])
163 goto nla_put_failure; 163 goto nla_put_failure;
164 164
165 genlmsg_end(skb, msg_head); 165 genlmsg_end(skb, msg_head);
166 genlmsg_multicast(skb, 0, hsr_network_genl_mcgrp.id, GFP_ATOMIC); 166 genlmsg_multicast(&hsr_genl_family, skb, 0, 0, GFP_ATOMIC);
167 167
168 return; 168 return;
169 169
@@ -249,7 +249,7 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
249 &hsr_node_if2_age, 249 &hsr_node_if2_age,
250 &hsr_node_if2_seq); 250 &hsr_node_if2_seq);
251 if (res < 0) 251 if (res < 0)
252 goto fail; 252 goto nla_put_failure;
253 253
254 res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, 254 res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN,
255 nla_data(info->attrs[HSR_A_NODE_ADDR])); 255 nla_data(info->attrs[HSR_A_NODE_ADDR]));
@@ -306,15 +306,6 @@ fail:
306 return res; 306 return res;
307} 307}
308 308
309static struct genl_ops hsr_ops_get_node_status = {
310 .cmd = HSR_C_GET_NODE_STATUS,
311 .flags = 0,
312 .policy = hsr_genl_policy,
313 .doit = hsr_get_node_status,
314 .dumpit = NULL,
315};
316
317
318/* Get a list of MacAddressA of all nodes known to this node (other than self). 309/* Get a list of MacAddressA of all nodes known to this node (other than self).
319 */ 310 */
320static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) 311static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
@@ -398,12 +389,21 @@ fail:
398} 389}
399 390
400 391
401static struct genl_ops hsr_ops_get_node_list = { 392static const struct genl_ops hsr_ops[] = {
402 .cmd = HSR_C_GET_NODE_LIST, 393 {
403 .flags = 0, 394 .cmd = HSR_C_GET_NODE_STATUS,
404 .policy = hsr_genl_policy, 395 .flags = 0,
405 .doit = hsr_get_node_list, 396 .policy = hsr_genl_policy,
406 .dumpit = NULL, 397 .doit = hsr_get_node_status,
398 .dumpit = NULL,
399 },
400 {
401 .cmd = HSR_C_GET_NODE_LIST,
402 .flags = 0,
403 .policy = hsr_genl_policy,
404 .doit = hsr_get_node_list,
405 .dumpit = NULL,
406 },
407}; 407};
408 408
409int __init hsr_netlink_init(void) 409int __init hsr_netlink_init(void)
@@ -414,30 +414,13 @@ int __init hsr_netlink_init(void)
414 if (rc) 414 if (rc)
415 goto fail_rtnl_link_register; 415 goto fail_rtnl_link_register;
416 416
417 rc = genl_register_family(&hsr_genl_family); 417 rc = genl_register_family_with_ops_groups(&hsr_genl_family, hsr_ops,
418 hsr_mcgrps);
418 if (rc) 419 if (rc)
419 goto fail_genl_register_family; 420 goto fail_genl_register_family;
420 421
421 rc = genl_register_ops(&hsr_genl_family, &hsr_ops_get_node_status);
422 if (rc)
423 goto fail_genl_register_ops;
424
425 rc = genl_register_ops(&hsr_genl_family, &hsr_ops_get_node_list);
426 if (rc)
427 goto fail_genl_register_ops_node_list;
428
429 rc = genl_register_mc_group(&hsr_genl_family, &hsr_network_genl_mcgrp);
430 if (rc)
431 goto fail_genl_register_mc_group;
432
433 return 0; 422 return 0;
434 423
435fail_genl_register_mc_group:
436 genl_unregister_ops(&hsr_genl_family, &hsr_ops_get_node_list);
437fail_genl_register_ops_node_list:
438 genl_unregister_ops(&hsr_genl_family, &hsr_ops_get_node_status);
439fail_genl_register_ops:
440 genl_unregister_family(&hsr_genl_family);
441fail_genl_register_family: 424fail_genl_register_family:
442 rtnl_link_unregister(&hsr_link_ops); 425 rtnl_link_unregister(&hsr_link_ops);
443fail_rtnl_link_register: 426fail_rtnl_link_register:
@@ -447,10 +430,7 @@ fail_rtnl_link_register:
447 430
448void __exit hsr_netlink_exit(void) 431void __exit hsr_netlink_exit(void)
449{ 432{
450 genl_unregister_mc_group(&hsr_genl_family, &hsr_network_genl_mcgrp);
451 genl_unregister_ops(&hsr_genl_family, &hsr_ops_get_node_status);
452 genl_unregister_family(&hsr_genl_family); 433 genl_unregister_family(&hsr_genl_family);
453
454 rtnl_link_unregister(&hsr_link_ops); 434 rtnl_link_unregister(&hsr_link_ops);
455} 435}
456 436
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 426b5df1c98f..459e200c08a4 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -956,7 +956,7 @@ lowpan_process_data(struct sk_buff *skb)
956 * Traffic class carried in-line 956 * Traffic class carried in-line
957 * ECN + DSCP (1 byte), Flow Label is elided 957 * ECN + DSCP (1 byte), Flow Label is elided
958 */ 958 */
959 case 1: /* 10b */ 959 case 2: /* 10b */
960 if (lowpan_fetch_skb_u8(skb, &tmp)) 960 if (lowpan_fetch_skb_u8(skb, &tmp))
961 goto drop; 961 goto drop;
962 962
@@ -967,7 +967,7 @@ lowpan_process_data(struct sk_buff *skb)
967 * Flow Label carried in-line 967 * Flow Label carried in-line
968 * ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided 968 * ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided
969 */ 969 */
970 case 2: /* 01b */ 970 case 1: /* 01b */
971 if (lowpan_fetch_skb_u8(skb, &tmp)) 971 if (lowpan_fetch_skb_u8(skb, &tmp))
972 goto drop; 972 goto drop;
973 973
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index 581a59504bd5..1865fdf5a5a5 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -315,9 +315,8 @@ static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk,
315 if (saddr) { 315 if (saddr) {
316 saddr->family = AF_IEEE802154; 316 saddr->family = AF_IEEE802154;
317 saddr->addr = mac_cb(skb)->sa; 317 saddr->addr = mac_cb(skb)->sa;
318 }
319 if (addr_len)
320 *addr_len = sizeof(*saddr); 318 *addr_len = sizeof(*saddr);
319 }
321 320
322 if (flags & MSG_TRUNC) 321 if (flags & MSG_TRUNC)
323 copied = skb->len; 322 copied = skb->len;
diff --git a/net/ieee802154/ieee802154.h b/net/ieee802154/ieee802154.h
index aadec428e6ec..cee4425b9956 100644
--- a/net/ieee802154/ieee802154.h
+++ b/net/ieee802154/ieee802154.h
@@ -47,7 +47,24 @@ struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
47int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info); 47int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info);
48 48
49extern struct genl_family nl802154_family; 49extern struct genl_family nl802154_family;
50int nl802154_mac_register(void); 50
51int nl802154_phy_register(void); 51/* genetlink ops/groups */
52int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info);
53int ieee802154_dump_phy(struct sk_buff *skb, struct netlink_callback *cb);
54int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info);
55int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info);
56
57enum ieee802154_mcgrp_ids {
58 IEEE802154_COORD_MCGRP,
59 IEEE802154_BEACON_MCGRP,
60};
61
62int ieee802154_associate_req(struct sk_buff *skb, struct genl_info *info);
63int ieee802154_associate_resp(struct sk_buff *skb, struct genl_info *info);
64int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info);
65int ieee802154_scan_req(struct sk_buff *skb, struct genl_info *info);
66int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info);
67int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info);
68int ieee802154_dump_iface(struct sk_buff *skb, struct netlink_callback *cb);
52 69
53#endif 70#endif
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c
index 7e49bbcc6967..43f1b2bf469f 100644
--- a/net/ieee802154/netlink.c
+++ b/net/ieee802154/netlink.c
@@ -70,7 +70,7 @@ int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group)
70 if (genlmsg_end(msg, hdr) < 0) 70 if (genlmsg_end(msg, hdr) < 0)
71 goto out; 71 goto out;
72 72
73 return genlmsg_multicast(msg, 0, group, GFP_ATOMIC); 73 return genlmsg_multicast(&nl802154_family, msg, 0, group, GFP_ATOMIC);
74out: 74out:
75 nlmsg_free(msg); 75 nlmsg_free(msg);
76 return -ENOBUFS; 76 return -ENOBUFS;
@@ -109,31 +109,36 @@ out:
109 return -ENOBUFS; 109 return -ENOBUFS;
110} 110}
111 111
112int __init ieee802154_nl_init(void) 112static const struct genl_ops ieee8021154_ops[] = {
113{ 113 /* see nl-phy.c */
114 int rc; 114 IEEE802154_DUMP(IEEE802154_LIST_PHY, ieee802154_list_phy,
115 115 ieee802154_dump_phy),
116 rc = genl_register_family(&nl802154_family); 116 IEEE802154_OP(IEEE802154_ADD_IFACE, ieee802154_add_iface),
117 if (rc) 117 IEEE802154_OP(IEEE802154_DEL_IFACE, ieee802154_del_iface),
118 goto fail; 118 /* see nl-mac.c */
119 119 IEEE802154_OP(IEEE802154_ASSOCIATE_REQ, ieee802154_associate_req),
120 rc = nl802154_mac_register(); 120 IEEE802154_OP(IEEE802154_ASSOCIATE_RESP, ieee802154_associate_resp),
121 if (rc) 121 IEEE802154_OP(IEEE802154_DISASSOCIATE_REQ, ieee802154_disassociate_req),
122 goto fail; 122 IEEE802154_OP(IEEE802154_SCAN_REQ, ieee802154_scan_req),
123 IEEE802154_OP(IEEE802154_START_REQ, ieee802154_start_req),
124 IEEE802154_DUMP(IEEE802154_LIST_IFACE, ieee802154_list_iface,
125 ieee802154_dump_iface),
126};
123 127
124 rc = nl802154_phy_register(); 128static const struct genl_multicast_group ieee802154_mcgrps[] = {
125 if (rc) 129 [IEEE802154_COORD_MCGRP] = { .name = IEEE802154_MCAST_COORD_NAME, },
126 goto fail; 130 [IEEE802154_BEACON_MCGRP] = { .name = IEEE802154_MCAST_BEACON_NAME, },
131};
127 132
128 return 0;
129 133
130fail: 134int __init ieee802154_nl_init(void)
131 genl_unregister_family(&nl802154_family); 135{
132 return rc; 136 return genl_register_family_with_ops_groups(&nl802154_family,
137 ieee8021154_ops,
138 ieee802154_mcgrps);
133} 139}
134 140
135void __exit ieee802154_nl_exit(void) 141void __exit ieee802154_nl_exit(void)
136{ 142{
137 genl_unregister_family(&nl802154_family); 143 genl_unregister_family(&nl802154_family);
138} 144}
139
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index b0bdd8c51e9c..ba5c1e002f37 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -39,14 +39,6 @@
39 39
40#include "ieee802154.h" 40#include "ieee802154.h"
41 41
42static struct genl_multicast_group ieee802154_coord_mcgrp = {
43 .name = IEEE802154_MCAST_COORD_NAME,
44};
45
46static struct genl_multicast_group ieee802154_beacon_mcgrp = {
47 .name = IEEE802154_MCAST_BEACON_NAME,
48};
49
50int ieee802154_nl_assoc_indic(struct net_device *dev, 42int ieee802154_nl_assoc_indic(struct net_device *dev,
51 struct ieee802154_addr *addr, u8 cap) 43 struct ieee802154_addr *addr, u8 cap)
52{ 44{
@@ -72,7 +64,7 @@ int ieee802154_nl_assoc_indic(struct net_device *dev,
72 nla_put_u8(msg, IEEE802154_ATTR_CAPABILITY, cap)) 64 nla_put_u8(msg, IEEE802154_ATTR_CAPABILITY, cap))
73 goto nla_put_failure; 65 goto nla_put_failure;
74 66
75 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 67 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
76 68
77nla_put_failure: 69nla_put_failure:
78 nlmsg_free(msg); 70 nlmsg_free(msg);
@@ -98,7 +90,7 @@ int ieee802154_nl_assoc_confirm(struct net_device *dev, u16 short_addr,
98 nla_put_u16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr) || 90 nla_put_u16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr) ||
99 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) 91 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status))
100 goto nla_put_failure; 92 goto nla_put_failure;
101 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 93 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
102 94
103nla_put_failure: 95nla_put_failure:
104 nlmsg_free(msg); 96 nlmsg_free(msg);
@@ -133,7 +125,7 @@ int ieee802154_nl_disassoc_indic(struct net_device *dev,
133 } 125 }
134 if (nla_put_u8(msg, IEEE802154_ATTR_REASON, reason)) 126 if (nla_put_u8(msg, IEEE802154_ATTR_REASON, reason))
135 goto nla_put_failure; 127 goto nla_put_failure;
136 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 128 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
137 129
138nla_put_failure: 130nla_put_failure:
139 nlmsg_free(msg); 131 nlmsg_free(msg);
@@ -157,7 +149,7 @@ int ieee802154_nl_disassoc_confirm(struct net_device *dev, u8 status)
157 dev->dev_addr) || 149 dev->dev_addr) ||
158 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) 150 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status))
159 goto nla_put_failure; 151 goto nla_put_failure;
160 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 152 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
161 153
162nla_put_failure: 154nla_put_failure:
163 nlmsg_free(msg); 155 nlmsg_free(msg);
@@ -183,7 +175,7 @@ int ieee802154_nl_beacon_indic(struct net_device *dev,
183 nla_put_u16(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, coord_addr) || 175 nla_put_u16(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, coord_addr) ||
184 nla_put_u16(msg, IEEE802154_ATTR_COORD_PAN_ID, panid)) 176 nla_put_u16(msg, IEEE802154_ATTR_COORD_PAN_ID, panid))
185 goto nla_put_failure; 177 goto nla_put_failure;
186 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 178 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
187 179
188nla_put_failure: 180nla_put_failure:
189 nlmsg_free(msg); 181 nlmsg_free(msg);
@@ -214,7 +206,7 @@ int ieee802154_nl_scan_confirm(struct net_device *dev,
214 (edl && 206 (edl &&
215 nla_put(msg, IEEE802154_ATTR_ED_LIST, 27, edl))) 207 nla_put(msg, IEEE802154_ATTR_ED_LIST, 27, edl)))
216 goto nla_put_failure; 208 goto nla_put_failure;
217 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 209 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
218 210
219nla_put_failure: 211nla_put_failure:
220 nlmsg_free(msg); 212 nlmsg_free(msg);
@@ -238,7 +230,7 @@ int ieee802154_nl_start_confirm(struct net_device *dev, u8 status)
238 dev->dev_addr) || 230 dev->dev_addr) ||
239 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) 231 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status))
240 goto nla_put_failure; 232 goto nla_put_failure;
241 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 233 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
242 234
243nla_put_failure: 235nla_put_failure:
244 nlmsg_free(msg); 236 nlmsg_free(msg);
@@ -309,8 +301,7 @@ static struct net_device *ieee802154_nl_get_dev(struct genl_info *info)
309 return dev; 301 return dev;
310} 302}
311 303
312static int ieee802154_associate_req(struct sk_buff *skb, 304int ieee802154_associate_req(struct sk_buff *skb, struct genl_info *info)
313 struct genl_info *info)
314{ 305{
315 struct net_device *dev; 306 struct net_device *dev;
316 struct ieee802154_addr addr; 307 struct ieee802154_addr addr;
@@ -357,8 +348,7 @@ out:
357 return ret; 348 return ret;
358} 349}
359 350
360static int ieee802154_associate_resp(struct sk_buff *skb, 351int ieee802154_associate_resp(struct sk_buff *skb, struct genl_info *info)
361 struct genl_info *info)
362{ 352{
363 struct net_device *dev; 353 struct net_device *dev;
364 struct ieee802154_addr addr; 354 struct ieee802154_addr addr;
@@ -390,8 +380,7 @@ out:
390 return ret; 380 return ret;
391} 381}
392 382
393static int ieee802154_disassociate_req(struct sk_buff *skb, 383int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info)
394 struct genl_info *info)
395{ 384{
396 struct net_device *dev; 385 struct net_device *dev;
397 struct ieee802154_addr addr; 386 struct ieee802154_addr addr;
@@ -433,7 +422,7 @@ out:
433 * PAN_coordinator, battery_life_extension = 0, 422 * PAN_coordinator, battery_life_extension = 0,
434 * coord_realignment = 0, security_enable = 0 423 * coord_realignment = 0, security_enable = 0
435*/ 424*/
436static int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info) 425int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info)
437{ 426{
438 struct net_device *dev; 427 struct net_device *dev;
439 struct ieee802154_addr addr; 428 struct ieee802154_addr addr;
@@ -492,7 +481,7 @@ out:
492 return ret; 481 return ret;
493} 482}
494 483
495static int ieee802154_scan_req(struct sk_buff *skb, struct genl_info *info) 484int ieee802154_scan_req(struct sk_buff *skb, struct genl_info *info)
496{ 485{
497 struct net_device *dev; 486 struct net_device *dev;
498 int ret = -EOPNOTSUPP; 487 int ret = -EOPNOTSUPP;
@@ -530,8 +519,7 @@ out:
530 return ret; 519 return ret;
531} 520}
532 521
533static int ieee802154_list_iface(struct sk_buff *skb, 522int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info)
534 struct genl_info *info)
535{ 523{
536 /* Request for interface name, index, type, IEEE address, 524 /* Request for interface name, index, type, IEEE address,
537 PAN Id, short address */ 525 PAN Id, short address */
@@ -565,8 +553,7 @@ out_dev:
565 553
566} 554}
567 555
568static int ieee802154_dump_iface(struct sk_buff *skb, 556int ieee802154_dump_iface(struct sk_buff *skb, struct netlink_callback *cb)
569 struct netlink_callback *cb)
570{ 557{
571 struct net *net = sock_net(skb->sk); 558 struct net *net = sock_net(skb->sk);
572 struct net_device *dev; 559 struct net_device *dev;
@@ -590,41 +577,3 @@ cont:
590 577
591 return skb->len; 578 return skb->len;
592} 579}
593
594static struct genl_ops ieee802154_coordinator_ops[] = {
595 IEEE802154_OP(IEEE802154_ASSOCIATE_REQ, ieee802154_associate_req),
596 IEEE802154_OP(IEEE802154_ASSOCIATE_RESP, ieee802154_associate_resp),
597 IEEE802154_OP(IEEE802154_DISASSOCIATE_REQ, ieee802154_disassociate_req),
598 IEEE802154_OP(IEEE802154_SCAN_REQ, ieee802154_scan_req),
599 IEEE802154_OP(IEEE802154_START_REQ, ieee802154_start_req),
600 IEEE802154_DUMP(IEEE802154_LIST_IFACE, ieee802154_list_iface,
601 ieee802154_dump_iface),
602};
603
604/*
605 * No need to unregister as family unregistration will do it.
606 */
607int nl802154_mac_register(void)
608{
609 int i;
610 int rc;
611
612 rc = genl_register_mc_group(&nl802154_family,
613 &ieee802154_coord_mcgrp);
614 if (rc)
615 return rc;
616
617 rc = genl_register_mc_group(&nl802154_family,
618 &ieee802154_beacon_mcgrp);
619 if (rc)
620 return rc;
621
622 for (i = 0; i < ARRAY_SIZE(ieee802154_coordinator_ops); i++) {
623 rc = genl_register_ops(&nl802154_family,
624 &ieee802154_coordinator_ops[i]);
625 if (rc)
626 return rc;
627 }
628
629 return 0;
630}
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index 22b1a7058fd3..d08c7a43dcd1 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -77,8 +77,7 @@ out:
77 return -EMSGSIZE; 77 return -EMSGSIZE;
78} 78}
79 79
80static int ieee802154_list_phy(struct sk_buff *skb, 80int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info)
81 struct genl_info *info)
82{ 81{
83 /* Request for interface name, index, type, IEEE address, 82 /* Request for interface name, index, type, IEEE address,
84 PAN Id, short address */ 83 PAN Id, short address */
@@ -151,8 +150,7 @@ static int ieee802154_dump_phy_iter(struct wpan_phy *phy, void *_data)
151 return 0; 150 return 0;
152} 151}
153 152
154static int ieee802154_dump_phy(struct sk_buff *skb, 153int ieee802154_dump_phy(struct sk_buff *skb, struct netlink_callback *cb)
155 struct netlink_callback *cb)
156{ 154{
157 struct dump_phy_data data = { 155 struct dump_phy_data data = {
158 .cb = cb, 156 .cb = cb,
@@ -170,8 +168,7 @@ static int ieee802154_dump_phy(struct sk_buff *skb,
170 return skb->len; 168 return skb->len;
171} 169}
172 170
173static int ieee802154_add_iface(struct sk_buff *skb, 171int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
174 struct genl_info *info)
175{ 172{
176 struct sk_buff *msg; 173 struct sk_buff *msg;
177 struct wpan_phy *phy; 174 struct wpan_phy *phy;
@@ -273,8 +270,7 @@ out_dev:
273 return rc; 270 return rc;
274} 271}
275 272
276static int ieee802154_del_iface(struct sk_buff *skb, 273int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info)
277 struct genl_info *info)
278{ 274{
279 struct sk_buff *msg; 275 struct sk_buff *msg;
280 struct wpan_phy *phy; 276 struct wpan_phy *phy;
@@ -356,28 +352,3 @@ out_dev:
356 352
357 return rc; 353 return rc;
358} 354}
359
360static struct genl_ops ieee802154_phy_ops[] = {
361 IEEE802154_DUMP(IEEE802154_LIST_PHY, ieee802154_list_phy,
362 ieee802154_dump_phy),
363 IEEE802154_OP(IEEE802154_ADD_IFACE, ieee802154_add_iface),
364 IEEE802154_OP(IEEE802154_DEL_IFACE, ieee802154_del_iface),
365};
366
367/*
368 * No need to unregister as family unregistration will do it.
369 */
370int nl802154_phy_register(void)
371{
372 int i;
373 int rc;
374
375 for (i = 0; i < ARRAY_SIZE(ieee802154_phy_ops); i++) {
376 rc = genl_register_ops(&nl802154_family,
377 &ieee802154_phy_ops[i]);
378 if (rc)
379 return rc;
380 }
381
382 return 0;
383}
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index b28e863fe0a7..19e36376d2a0 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
57 if (IS_ERR(rt)) { 57 if (IS_ERR(rt)) {
58 err = PTR_ERR(rt); 58 err = PTR_ERR(rt);
59 if (err == -ENETUNREACH) 59 if (err == -ENETUNREACH)
60 IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); 60 IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
61 goto out; 61 goto out;
62 } 62 }
63 63
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index caf01176a5e4..90ff9570d7d4 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -454,6 +454,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
454 tstats->rx_bytes += skb->len; 454 tstats->rx_bytes += skb->len;
455 u64_stats_update_end(&tstats->syncp); 455 u64_stats_update_end(&tstats->syncp);
456 456
457 skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(tunnel->dev)));
458
457 if (tunnel->dev->type == ARPHRD_ETHER) { 459 if (tunnel->dev->type == ARPHRD_ETHER) {
458 skb->protocol = eth_type_trans(skb, tunnel->dev); 460 skb->protocol = eth_type_trans(skb, tunnel->dev);
459 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); 461 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
@@ -461,8 +463,6 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
461 skb->dev = tunnel->dev; 463 skb->dev = tunnel->dev;
462 } 464 }
463 465
464 skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(tunnel->dev)));
465
466 gro_cells_receive(&tunnel->gro_cells, skb); 466 gro_cells_receive(&tunnel->gro_cells, skb);
467 return 0; 467 return 0;
468 468
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 5d9c845d288a..52b802a0cd8c 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -126,6 +126,7 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
126 if (!rt->dst.xfrm || 126 if (!rt->dst.xfrm ||
127 rt->dst.xfrm->props.mode != XFRM_MODE_TUNNEL) { 127 rt->dst.xfrm->props.mode != XFRM_MODE_TUNNEL) {
128 dev->stats.tx_carrier_errors++; 128 dev->stats.tx_carrier_errors++;
129 ip_rt_put(rt);
129 goto tx_error_icmp; 130 goto tx_error_icmp;
130 } 131 }
131 tdev = rt->dst.dev; 132 tdev = rt->dst.dev;
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index cbc85f660d54..876c6ca2d8f9 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -830,8 +830,6 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
830{ 830{
831 struct inet_sock *isk = inet_sk(sk); 831 struct inet_sock *isk = inet_sk(sk);
832 int family = sk->sk_family; 832 int family = sk->sk_family;
833 struct sockaddr_in *sin;
834 struct sockaddr_in6 *sin6;
835 struct sk_buff *skb; 833 struct sk_buff *skb;
836 int copied, err; 834 int copied, err;
837 835
@@ -841,13 +839,6 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
841 if (flags & MSG_OOB) 839 if (flags & MSG_OOB)
842 goto out; 840 goto out;
843 841
844 if (addr_len) {
845 if (family == AF_INET)
846 *addr_len = sizeof(*sin);
847 else if (family == AF_INET6 && addr_len)
848 *addr_len = sizeof(*sin6);
849 }
850
851 if (flags & MSG_ERRQUEUE) { 842 if (flags & MSG_ERRQUEUE) {
852 if (family == AF_INET) { 843 if (family == AF_INET) {
853 return ip_recv_error(sk, msg, len); 844 return ip_recv_error(sk, msg, len);
@@ -877,11 +868,15 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
877 868
878 /* Copy the address and add cmsg data. */ 869 /* Copy the address and add cmsg data. */
879 if (family == AF_INET) { 870 if (family == AF_INET) {
880 sin = (struct sockaddr_in *) msg->msg_name; 871 struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
881 sin->sin_family = AF_INET; 872
882 sin->sin_port = 0 /* skb->h.uh->source */; 873 if (sin) {
883 sin->sin_addr.s_addr = ip_hdr(skb)->saddr; 874 sin->sin_family = AF_INET;
884 memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); 875 sin->sin_port = 0 /* skb->h.uh->source */;
876 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
877 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
878 *addr_len = sizeof(*sin);
879 }
885 880
886 if (isk->cmsg_flags) 881 if (isk->cmsg_flags)
887 ip_cmsg_recv(msg, skb); 882 ip_cmsg_recv(msg, skb);
@@ -890,17 +885,21 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
890 } else if (family == AF_INET6) { 885 } else if (family == AF_INET6) {
891 struct ipv6_pinfo *np = inet6_sk(sk); 886 struct ipv6_pinfo *np = inet6_sk(sk);
892 struct ipv6hdr *ip6 = ipv6_hdr(skb); 887 struct ipv6hdr *ip6 = ipv6_hdr(skb);
893 sin6 = (struct sockaddr_in6 *) msg->msg_name; 888 struct sockaddr_in6 *sin6 =
894 sin6->sin6_family = AF_INET6; 889 (struct sockaddr_in6 *)msg->msg_name;
895 sin6->sin6_port = 0; 890
896 sin6->sin6_addr = ip6->saddr; 891 if (sin6) {
897 892 sin6->sin6_family = AF_INET6;
898 sin6->sin6_flowinfo = 0; 893 sin6->sin6_port = 0;
899 if (np->sndflow) 894 sin6->sin6_addr = ip6->saddr;
900 sin6->sin6_flowinfo = ip6_flowinfo(ip6); 895 sin6->sin6_flowinfo = 0;
901 896 if (np->sndflow)
902 sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr, 897 sin6->sin6_flowinfo = ip6_flowinfo(ip6);
903 IP6CB(skb)->iif); 898 sin6->sin6_scope_id =
899 ipv6_iface_scope_id(&sin6->sin6_addr,
900 IP6CB(skb)->iif);
901 *addr_len = sizeof(*sin6);
902 }
904 903
905 if (inet6_sk(sk)->rxopt.all) 904 if (inet6_sk(sk)->rxopt.all)
906 pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb); 905 pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 41e1d2845c8f..5cb8ddb505ee 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -696,9 +696,6 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
696 if (flags & MSG_OOB) 696 if (flags & MSG_OOB)
697 goto out; 697 goto out;
698 698
699 if (addr_len)
700 *addr_len = sizeof(*sin);
701
702 if (flags & MSG_ERRQUEUE) { 699 if (flags & MSG_ERRQUEUE) {
703 err = ip_recv_error(sk, msg, len); 700 err = ip_recv_error(sk, msg, len);
704 goto out; 701 goto out;
@@ -726,6 +723,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
726 sin->sin_addr.s_addr = ip_hdr(skb)->saddr; 723 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
727 sin->sin_port = 0; 724 sin->sin_port = 0;
728 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); 725 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
726 *addr_len = sizeof(*sin);
729 } 727 }
730 if (inet->cmsg_flags) 728 if (inet->cmsg_flags)
731 ip_cmsg_recv(msg, skb); 729 ip_cmsg_recv(msg, skb);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8e8529d3c8c9..3dc0c6cf02a8 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -808,12 +808,6 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now,
808 xmit_size_goal = min_t(u32, gso_size, 808 xmit_size_goal = min_t(u32, gso_size,
809 sk->sk_gso_max_size - 1 - hlen); 809 sk->sk_gso_max_size - 1 - hlen);
810 810
811 /* TSQ : try to have at least two segments in flight
812 * (one in NIC TX ring, another in Qdisc)
813 */
814 xmit_size_goal = min_t(u32, xmit_size_goal,
815 sysctl_tcp_limit_output_bytes >> 1);
816
817 xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal); 811 xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal);
818 812
819 /* We try hard to avoid divides here */ 813 /* We try hard to avoid divides here */
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 2ab09cbae74d..06493736fbc8 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -663,10 +663,13 @@ void tcp_fastopen_cache_get(struct sock *sk, u16 *mss,
663void tcp_fastopen_cache_set(struct sock *sk, u16 mss, 663void tcp_fastopen_cache_set(struct sock *sk, u16 mss,
664 struct tcp_fastopen_cookie *cookie, bool syn_lost) 664 struct tcp_fastopen_cookie *cookie, bool syn_lost)
665{ 665{
666 struct dst_entry *dst = __sk_dst_get(sk);
666 struct tcp_metrics_block *tm; 667 struct tcp_metrics_block *tm;
667 668
669 if (!dst)
670 return;
668 rcu_read_lock(); 671 rcu_read_lock();
669 tm = tcp_get_metrics(sk, __sk_dst_get(sk), true); 672 tm = tcp_get_metrics(sk, dst, true);
670 if (tm) { 673 if (tm) {
671 struct tcp_fastopen_metrics *tfom = &tm->tcpm_fastopen; 674 struct tcp_fastopen_metrics *tfom = &tm->tcpm_fastopen;
672 675
@@ -988,7 +991,7 @@ static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info)
988 return 0; 991 return 0;
989} 992}
990 993
991static struct genl_ops tcp_metrics_nl_ops[] = { 994static const struct genl_ops tcp_metrics_nl_ops[] = {
992 { 995 {
993 .cmd = TCP_METRICS_CMD_GET, 996 .cmd = TCP_METRICS_CMD_GET,
994 .doit = tcp_metrics_nl_cmd_get, 997 .doit = tcp_metrics_nl_cmd_get,
@@ -1079,8 +1082,7 @@ void __init tcp_metrics_init(void)
1079 if (ret < 0) 1082 if (ret < 0)
1080 goto cleanup; 1083 goto cleanup;
1081 ret = genl_register_family_with_ops(&tcp_metrics_nl_family, 1084 ret = genl_register_family_with_ops(&tcp_metrics_nl_family,
1082 tcp_metrics_nl_ops, 1085 tcp_metrics_nl_ops);
1083 ARRAY_SIZE(tcp_metrics_nl_ops));
1084 if (ret < 0) 1086 if (ret < 0)
1085 goto cleanup_subsys; 1087 goto cleanup_subsys;
1086 return; 1088 return;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 672854664ff5..7820f3a7dd70 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1875,8 +1875,12 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
1875 * - better RTT estimation and ACK scheduling 1875 * - better RTT estimation and ACK scheduling
1876 * - faster recovery 1876 * - faster recovery
1877 * - high rates 1877 * - high rates
1878 * Alas, some drivers / subsystems require a fair amount
1879 * of queued bytes to ensure line rate.
1880 * One example is wifi aggregation (802.11 AMPDU)
1878 */ 1881 */
1879 limit = max(skb->truesize, sk->sk_pacing_rate >> 10); 1882 limit = max_t(unsigned int, sysctl_tcp_limit_output_bytes,
1883 sk->sk_pacing_rate >> 10);
1880 1884
1881 if (atomic_read(&sk->sk_wmem_alloc) > limit) { 1885 if (atomic_read(&sk->sk_wmem_alloc) > limit) {
1882 set_bit(TSQ_THROTTLED, &tp->tsq_flags); 1886 set_bit(TSQ_THROTTLED, &tp->tsq_flags);
@@ -3093,7 +3097,6 @@ void tcp_send_window_probe(struct sock *sk)
3093{ 3097{
3094 if (sk->sk_state == TCP_ESTABLISHED) { 3098 if (sk->sk_state == TCP_ESTABLISHED) {
3095 tcp_sk(sk)->snd_wl1 = tcp_sk(sk)->rcv_nxt - 1; 3099 tcp_sk(sk)->snd_wl1 = tcp_sk(sk)->rcv_nxt - 1;
3096 tcp_sk(sk)->snd_nxt = tcp_sk(sk)->write_seq;
3097 tcp_xmit_probe_skb(sk, 0); 3100 tcp_xmit_probe_skb(sk, 0);
3098 } 3101 }
3099} 3102}
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index de86e5bc4462..5944d7d668dd 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1235,12 +1235,6 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1235 int is_udplite = IS_UDPLITE(sk); 1235 int is_udplite = IS_UDPLITE(sk);
1236 bool slow; 1236 bool slow;
1237 1237
1238 /*
1239 * Check any passed addresses
1240 */
1241 if (addr_len)
1242 *addr_len = sizeof(*sin);
1243
1244 if (flags & MSG_ERRQUEUE) 1238 if (flags & MSG_ERRQUEUE)
1245 return ip_recv_error(sk, msg, len); 1239 return ip_recv_error(sk, msg, len);
1246 1240
@@ -1302,6 +1296,7 @@ try_again:
1302 sin->sin_port = udp_hdr(skb)->source; 1296 sin->sin_port = udp_hdr(skb)->source;
1303 sin->sin_addr.s_addr = ip_hdr(skb)->saddr; 1297 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
1304 memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); 1298 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
1299 *addr_len = sizeof(*sin);
1305 } 1300 }
1306 if (inet->cmsg_flags) 1301 if (inet->cmsg_flags)
1307 ip_cmsg_recv(msg, skb); 1302 ip_cmsg_recv(msg, skb);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 5658d9d51637..12c97d8aa6bb 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1996,23 +1996,6 @@ static void addrconf_add_mroute(struct net_device *dev)
1996 ip6_route_add(&cfg); 1996 ip6_route_add(&cfg);
1997} 1997}
1998 1998
1999#if IS_ENABLED(CONFIG_IPV6_SIT)
2000static void sit_route_add(struct net_device *dev)
2001{
2002 struct fib6_config cfg = {
2003 .fc_table = RT6_TABLE_MAIN,
2004 .fc_metric = IP6_RT_PRIO_ADDRCONF,
2005 .fc_ifindex = dev->ifindex,
2006 .fc_dst_len = 96,
2007 .fc_flags = RTF_UP | RTF_NONEXTHOP,
2008 .fc_nlinfo.nl_net = dev_net(dev),
2009 };
2010
2011 /* prefix length - 96 bits "::d.d.d.d" */
2012 ip6_route_add(&cfg);
2013}
2014#endif
2015
2016static struct inet6_dev *addrconf_add_dev(struct net_device *dev) 1999static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
2017{ 2000{
2018 struct inet6_dev *idev; 2001 struct inet6_dev *idev;
@@ -2542,7 +2525,8 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2542 struct in6_addr addr; 2525 struct in6_addr addr;
2543 struct net_device *dev; 2526 struct net_device *dev;
2544 struct net *net = dev_net(idev->dev); 2527 struct net *net = dev_net(idev->dev);
2545 int scope; 2528 int scope, plen;
2529 u32 pflags = 0;
2546 2530
2547 ASSERT_RTNL(); 2531 ASSERT_RTNL();
2548 2532
@@ -2552,12 +2536,16 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2552 if (idev->dev->flags&IFF_POINTOPOINT) { 2536 if (idev->dev->flags&IFF_POINTOPOINT) {
2553 addr.s6_addr32[0] = htonl(0xfe800000); 2537 addr.s6_addr32[0] = htonl(0xfe800000);
2554 scope = IFA_LINK; 2538 scope = IFA_LINK;
2539 plen = 64;
2555 } else { 2540 } else {
2556 scope = IPV6_ADDR_COMPATv4; 2541 scope = IPV6_ADDR_COMPATv4;
2542 plen = 96;
2543 pflags |= RTF_NONEXTHOP;
2557 } 2544 }
2558 2545
2559 if (addr.s6_addr32[3]) { 2546 if (addr.s6_addr32[3]) {
2560 add_addr(idev, &addr, 128, scope); 2547 add_addr(idev, &addr, plen, scope);
2548 addrconf_prefix_route(&addr, plen, idev->dev, 0, pflags);
2561 return; 2549 return;
2562 } 2550 }
2563 2551
@@ -2569,7 +2557,6 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2569 int flag = scope; 2557 int flag = scope;
2570 2558
2571 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { 2559 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
2572 int plen;
2573 2560
2574 addr.s6_addr32[3] = ifa->ifa_local; 2561 addr.s6_addr32[3] = ifa->ifa_local;
2575 2562
@@ -2580,12 +2567,10 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2580 continue; 2567 continue;
2581 flag |= IFA_HOST; 2568 flag |= IFA_HOST;
2582 } 2569 }
2583 if (idev->dev->flags&IFF_POINTOPOINT)
2584 plen = 64;
2585 else
2586 plen = 96;
2587 2570
2588 add_addr(idev, &addr, plen, flag); 2571 add_addr(idev, &addr, plen, flag);
2572 addrconf_prefix_route(&addr, plen, idev->dev, 0,
2573 pflags);
2589 } 2574 }
2590 } 2575 }
2591 } 2576 }
@@ -2711,7 +2696,6 @@ static void addrconf_sit_config(struct net_device *dev)
2711 struct in6_addr addr; 2696 struct in6_addr addr;
2712 2697
2713 ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0); 2698 ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
2714 addrconf_prefix_route(&addr, 64, dev, 0, 0);
2715 if (!ipv6_generate_eui64(addr.s6_addr + 8, dev)) 2699 if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
2716 addrconf_add_linklocal(idev, &addr); 2700 addrconf_add_linklocal(idev, &addr);
2717 return; 2701 return;
@@ -2721,8 +2705,6 @@ static void addrconf_sit_config(struct net_device *dev)
2721 2705
2722 if (dev->flags&IFF_POINTOPOINT) 2706 if (dev->flags&IFF_POINTOPOINT)
2723 addrconf_add_mroute(dev); 2707 addrconf_add_mroute(dev);
2724 else
2725 sit_route_add(dev);
2726} 2708}
2727#endif 2709#endif
2728 2710
@@ -2740,8 +2722,6 @@ static void addrconf_gre_config(struct net_device *dev)
2740 } 2722 }
2741 2723
2742 ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0); 2724 ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
2743 addrconf_prefix_route(&addr, 64, dev, 0, 0);
2744
2745 if (!ipv6_generate_eui64(addr.s6_addr + 8, dev)) 2725 if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
2746 addrconf_add_linklocal(idev, &addr); 2726 addrconf_add_linklocal(idev, &addr);
2747} 2727}
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index ff75313f27a8..4fbdb7046d28 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -972,10 +972,10 @@ out:
972 972
973#ifdef CONFIG_SYSCTL 973#ifdef CONFIG_SYSCTL
974sysctl_fail: 974sysctl_fail:
975 ipv6_packet_cleanup(); 975 pingv6_exit();
976#endif 976#endif
977pingv6_fail: 977pingv6_fail:
978 pingv6_exit(); 978 ipv6_packet_cleanup();
979ipv6_packet_fail: 979ipv6_packet_fail:
980 tcpv6_exit(); 980 tcpv6_exit();
981tcpv6_fail: 981tcpv6_fail:
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index df1fa58528c6..d6062325db08 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1642,6 +1642,15 @@ static int ip6_tnl_changelink(struct net_device *dev, struct nlattr *tb[],
1642 return ip6_tnl_update(t, &p); 1642 return ip6_tnl_update(t, &p);
1643} 1643}
1644 1644
1645static void ip6_tnl_dellink(struct net_device *dev, struct list_head *head)
1646{
1647 struct net *net = dev_net(dev);
1648 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
1649
1650 if (dev != ip6n->fb_tnl_dev)
1651 unregister_netdevice_queue(dev, head);
1652}
1653
1645static size_t ip6_tnl_get_size(const struct net_device *dev) 1654static size_t ip6_tnl_get_size(const struct net_device *dev)
1646{ 1655{
1647 return 1656 return
@@ -1706,6 +1715,7 @@ static struct rtnl_link_ops ip6_link_ops __read_mostly = {
1706 .validate = ip6_tnl_validate, 1715 .validate = ip6_tnl_validate,
1707 .newlink = ip6_tnl_newlink, 1716 .newlink = ip6_tnl_newlink,
1708 .changelink = ip6_tnl_changelink, 1717 .changelink = ip6_tnl_changelink,
1718 .dellink = ip6_tnl_dellink,
1709 .get_size = ip6_tnl_get_size, 1719 .get_size = ip6_tnl_get_size,
1710 .fill_info = ip6_tnl_fill_info, 1720 .fill_info = ip6_tnl_fill_info,
1711}; 1721};
@@ -1722,9 +1732,9 @@ static struct xfrm6_tunnel ip6ip6_handler __read_mostly = {
1722 .priority = 1, 1732 .priority = 1,
1723}; 1733};
1724 1734
1725static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n) 1735static void __net_exit ip6_tnl_destroy_tunnels(struct net *net)
1726{ 1736{
1727 struct net *net = dev_net(ip6n->fb_tnl_dev); 1737 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
1728 struct net_device *dev, *aux; 1738 struct net_device *dev, *aux;
1729 int h; 1739 int h;
1730 struct ip6_tnl *t; 1740 struct ip6_tnl *t;
@@ -1792,10 +1802,8 @@ err_alloc_dev:
1792 1802
1793static void __net_exit ip6_tnl_exit_net(struct net *net) 1803static void __net_exit ip6_tnl_exit_net(struct net *net)
1794{ 1804{
1795 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
1796
1797 rtnl_lock(); 1805 rtnl_lock();
1798 ip6_tnl_destroy_tunnels(ip6n); 1806 ip6_tnl_destroy_tunnels(net);
1799 rtnl_unlock(); 1807 rtnl_unlock();
1800} 1808}
1801 1809
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index f8a55ff1971b..3512177deb4d 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1726,8 +1726,8 @@ int __init ndisc_init(void)
1726 &ndisc_ifinfo_sysctl_change); 1726 &ndisc_ifinfo_sysctl_change);
1727 if (err) 1727 if (err)
1728 goto out_unregister_pernet; 1728 goto out_unregister_pernet;
1729#endif
1730out: 1729out:
1730#endif
1731 return err; 1731 return err;
1732 1732
1733#ifdef CONFIG_SYSCTL 1733#ifdef CONFIG_SYSCTL
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 3c00842b0079..e24ff1df0401 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -465,9 +465,6 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
465 if (flags & MSG_OOB) 465 if (flags & MSG_OOB)
466 return -EOPNOTSUPP; 466 return -EOPNOTSUPP;
467 467
468 if (addr_len)
469 *addr_len=sizeof(*sin6);
470
471 if (flags & MSG_ERRQUEUE) 468 if (flags & MSG_ERRQUEUE)
472 return ipv6_recv_error(sk, msg, len); 469 return ipv6_recv_error(sk, msg, len);
473 470
@@ -506,6 +503,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
506 sin6->sin6_flowinfo = 0; 503 sin6->sin6_flowinfo = 0;
507 sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr, 504 sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
508 IP6CB(skb)->iif); 505 IP6CB(skb)->iif);
506 *addr_len = sizeof(*sin6);
509 } 507 }
510 508
511 sock_recv_ts_and_drops(msg, sk, skb); 509 sock_recv_ts_and_drops(msg, sk, skb);
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index bfc6fcea3841..1b4a4a953675 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1619,6 +1619,15 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
1619#endif 1619#endif
1620}; 1620};
1621 1621
1622static void ipip6_dellink(struct net_device *dev, struct list_head *head)
1623{
1624 struct net *net = dev_net(dev);
1625 struct sit_net *sitn = net_generic(net, sit_net_id);
1626
1627 if (dev != sitn->fb_tunnel_dev)
1628 unregister_netdevice_queue(dev, head);
1629}
1630
1622static struct rtnl_link_ops sit_link_ops __read_mostly = { 1631static struct rtnl_link_ops sit_link_ops __read_mostly = {
1623 .kind = "sit", 1632 .kind = "sit",
1624 .maxtype = IFLA_IPTUN_MAX, 1633 .maxtype = IFLA_IPTUN_MAX,
@@ -1630,6 +1639,7 @@ static struct rtnl_link_ops sit_link_ops __read_mostly = {
1630 .changelink = ipip6_changelink, 1639 .changelink = ipip6_changelink,
1631 .get_size = ipip6_get_size, 1640 .get_size = ipip6_get_size,
1632 .fill_info = ipip6_fill_info, 1641 .fill_info = ipip6_fill_info,
1642 .dellink = ipip6_dellink,
1633}; 1643};
1634 1644
1635static struct xfrm_tunnel sit_handler __read_mostly = { 1645static struct xfrm_tunnel sit_handler __read_mostly = {
@@ -1644,9 +1654,10 @@ static struct xfrm_tunnel ipip_handler __read_mostly = {
1644 .priority = 2, 1654 .priority = 2,
1645}; 1655};
1646 1656
1647static void __net_exit sit_destroy_tunnels(struct sit_net *sitn, struct list_head *head) 1657static void __net_exit sit_destroy_tunnels(struct net *net,
1658 struct list_head *head)
1648{ 1659{
1649 struct net *net = dev_net(sitn->fb_tunnel_dev); 1660 struct sit_net *sitn = net_generic(net, sit_net_id);
1650 struct net_device *dev, *aux; 1661 struct net_device *dev, *aux;
1651 int prio; 1662 int prio;
1652 1663
@@ -1721,11 +1732,10 @@ err_alloc_dev:
1721 1732
1722static void __net_exit sit_exit_net(struct net *net) 1733static void __net_exit sit_exit_net(struct net *net)
1723{ 1734{
1724 struct sit_net *sitn = net_generic(net, sit_net_id);
1725 LIST_HEAD(list); 1735 LIST_HEAD(list);
1726 1736
1727 rtnl_lock(); 1737 rtnl_lock();
1728 sit_destroy_tunnels(sitn, &list); 1738 sit_destroy_tunnels(net, &list);
1729 unregister_netdevice_many(&list); 1739 unregister_netdevice_many(&list);
1730 rtnl_unlock(); 1740 rtnl_unlock();
1731} 1741}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index f3893e897f72..81eb8cf8389b 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -392,9 +392,6 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
392 int is_udp4; 392 int is_udp4;
393 bool slow; 393 bool slow;
394 394
395 if (addr_len)
396 *addr_len = sizeof(struct sockaddr_in6);
397
398 if (flags & MSG_ERRQUEUE) 395 if (flags & MSG_ERRQUEUE)
399 return ipv6_recv_error(sk, msg, len); 396 return ipv6_recv_error(sk, msg, len);
400 397
@@ -480,7 +477,7 @@ try_again:
480 ipv6_iface_scope_id(&sin6->sin6_addr, 477 ipv6_iface_scope_id(&sin6->sin6_addr,
481 IP6CB(skb)->iif); 478 IP6CB(skb)->iif);
482 } 479 }
483 480 *addr_len = sizeof(*sin6);
484 } 481 }
485 if (is_udp4) { 482 if (is_udp4) {
486 if (inet->cmsg_flags) 483 if (inet->cmsg_flags)
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c
index c32971269280..a37b81fe0479 100644
--- a/net/irda/irnetlink.c
+++ b/net/irda/irnetlink.c
@@ -131,7 +131,7 @@ static const struct nla_policy irda_nl_policy[IRDA_NL_ATTR_MAX + 1] = {
131 [IRDA_NL_ATTR_MODE] = { .type = NLA_U32 }, 131 [IRDA_NL_ATTR_MODE] = { .type = NLA_U32 },
132}; 132};
133 133
134static struct genl_ops irda_nl_ops[] = { 134static const struct genl_ops irda_nl_ops[] = {
135 { 135 {
136 .cmd = IRDA_NL_CMD_SET_MODE, 136 .cmd = IRDA_NL_CMD_SET_MODE,
137 .doit = irda_nl_set_mode, 137 .doit = irda_nl_set_mode,
@@ -149,8 +149,7 @@ static struct genl_ops irda_nl_ops[] = {
149 149
150int irda_nl_register(void) 150int irda_nl_register(void)
151{ 151{
152 return genl_register_family_with_ops(&irda_nl_family, 152 return genl_register_family_with_ops(&irda_nl_family, irda_nl_ops);
153 irda_nl_ops, ARRAY_SIZE(irda_nl_ops));
154} 153}
155 154
156void irda_nl_unregister(void) 155void irda_nl_unregister(void)
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 571db8dd2292..da1a1cee1a08 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -518,9 +518,6 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
518 if (flags & MSG_OOB) 518 if (flags & MSG_OOB)
519 goto out; 519 goto out;
520 520
521 if (addr_len)
522 *addr_len = sizeof(*sin);
523
524 skb = skb_recv_datagram(sk, flags, noblock, &err); 521 skb = skb_recv_datagram(sk, flags, noblock, &err);
525 if (!skb) 522 if (!skb)
526 goto out; 523 goto out;
@@ -543,6 +540,7 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
543 sin->sin_addr.s_addr = ip_hdr(skb)->saddr; 540 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
544 sin->sin_port = 0; 541 sin->sin_port = 0;
545 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); 542 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
543 *addr_len = sizeof(*sin);
546 } 544 }
547 if (inet->cmsg_flags) 545 if (inet->cmsg_flags)
548 ip_cmsg_recv(msg, skb); 546 ip_cmsg_recv(msg, skb);
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index be446d517bc9..4cfd722e9153 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -793,7 +793,7 @@ static struct nla_policy l2tp_nl_policy[L2TP_ATTR_MAX + 1] = {
793 }, 793 },
794}; 794};
795 795
796static struct genl_ops l2tp_nl_ops[] = { 796static const struct genl_ops l2tp_nl_ops[] = {
797 { 797 {
798 .cmd = L2TP_CMD_NOOP, 798 .cmd = L2TP_CMD_NOOP,
799 .doit = l2tp_nl_cmd_noop, 799 .doit = l2tp_nl_cmd_noop,
@@ -887,13 +887,8 @@ EXPORT_SYMBOL_GPL(l2tp_nl_unregister_ops);
887 887
888static int l2tp_nl_init(void) 888static int l2tp_nl_init(void)
889{ 889{
890 int err;
891
892 pr_info("L2TP netlink interface\n"); 890 pr_info("L2TP netlink interface\n");
893 err = genl_register_family_with_ops(&l2tp_nl_family, l2tp_nl_ops, 891 return genl_register_family_with_ops(&l2tp_nl_family, l2tp_nl_ops);
894 ARRAY_SIZE(l2tp_nl_ops));
895
896 return err;
897} 892}
898 893
899static void l2tp_nl_cleanup(void) 894static void l2tp_nl_cleanup(void)
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 1ded5c6d268c..35be035ee0ce 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -3580,7 +3580,7 @@ out:
3580} 3580}
3581 3581
3582 3582
3583static struct genl_ops ip_vs_genl_ops[] __read_mostly = { 3583static const struct genl_ops ip_vs_genl_ops[] __read_mostly = {
3584 { 3584 {
3585 .cmd = IPVS_CMD_NEW_SERVICE, 3585 .cmd = IPVS_CMD_NEW_SERVICE,
3586 .flags = GENL_ADMIN_PERM, 3586 .flags = GENL_ADMIN_PERM,
@@ -3679,7 +3679,7 @@ static struct genl_ops ip_vs_genl_ops[] __read_mostly = {
3679static int __init ip_vs_genl_register(void) 3679static int __init ip_vs_genl_register(void)
3680{ 3680{
3681 return genl_register_family_with_ops(&ip_vs_genl_family, 3681 return genl_register_family_with_ops(&ip_vs_genl_family,
3682 ip_vs_genl_ops, ARRAY_SIZE(ip_vs_genl_ops)); 3682 ip_vs_genl_ops);
3683} 3683}
3684 3684
3685static void ip_vs_genl_unregister(void) 3685static void ip_vs_genl_unregister(void)
diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index a1100640495d..69345cebe3a3 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -737,7 +737,7 @@ static int netlbl_cipsov4_remove(struct sk_buff *skb, struct genl_info *info)
737 * NetLabel Generic NETLINK Command Definitions 737 * NetLabel Generic NETLINK Command Definitions
738 */ 738 */
739 739
740static struct genl_ops netlbl_cipsov4_ops[] = { 740static const struct genl_ops netlbl_cipsov4_ops[] = {
741 { 741 {
742 .cmd = NLBL_CIPSOV4_C_ADD, 742 .cmd = NLBL_CIPSOV4_C_ADD,
743 .flags = GENL_ADMIN_PERM, 743 .flags = GENL_ADMIN_PERM,
@@ -783,5 +783,5 @@ static struct genl_ops netlbl_cipsov4_ops[] = {
783int __init netlbl_cipsov4_genl_init(void) 783int __init netlbl_cipsov4_genl_init(void)
784{ 784{
785 return genl_register_family_with_ops(&netlbl_cipsov4_gnl_family, 785 return genl_register_family_with_ops(&netlbl_cipsov4_gnl_family,
786 netlbl_cipsov4_ops, ARRAY_SIZE(netlbl_cipsov4_ops)); 786 netlbl_cipsov4_ops);
787} 787}
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index dd1c37d7acbc..8ef83ee97c6a 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -705,7 +705,7 @@ version_failure:
705 * NetLabel Generic NETLINK Command Definitions 705 * NetLabel Generic NETLINK Command Definitions
706 */ 706 */
707 707
708static struct genl_ops netlbl_mgmt_genl_ops[] = { 708static const struct genl_ops netlbl_mgmt_genl_ops[] = {
709 { 709 {
710 .cmd = NLBL_MGMT_C_ADD, 710 .cmd = NLBL_MGMT_C_ADD,
711 .flags = GENL_ADMIN_PERM, 711 .flags = GENL_ADMIN_PERM,
@@ -779,5 +779,5 @@ static struct genl_ops netlbl_mgmt_genl_ops[] = {
779int __init netlbl_mgmt_genl_init(void) 779int __init netlbl_mgmt_genl_init(void)
780{ 780{
781 return genl_register_family_with_ops(&netlbl_mgmt_gnl_family, 781 return genl_register_family_with_ops(&netlbl_mgmt_gnl_family,
782 netlbl_mgmt_genl_ops, ARRAY_SIZE(netlbl_mgmt_genl_ops)); 782 netlbl_mgmt_genl_ops);
783} 783}
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 8f0897407a2c..43817d73ccf9 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -1323,7 +1323,7 @@ unlabel_staticlistdef_return:
1323 * NetLabel Generic NETLINK Command Definitions 1323 * NetLabel Generic NETLINK Command Definitions
1324 */ 1324 */
1325 1325
1326static struct genl_ops netlbl_unlabel_genl_ops[] = { 1326static const struct genl_ops netlbl_unlabel_genl_ops[] = {
1327 { 1327 {
1328 .cmd = NLBL_UNLABEL_C_STATICADD, 1328 .cmd = NLBL_UNLABEL_C_STATICADD,
1329 .flags = GENL_ADMIN_PERM, 1329 .flags = GENL_ADMIN_PERM,
@@ -1397,7 +1397,7 @@ static struct genl_ops netlbl_unlabel_genl_ops[] = {
1397int __init netlbl_unlabel_genl_init(void) 1397int __init netlbl_unlabel_genl_init(void)
1398{ 1398{
1399 return genl_register_family_with_ops(&netlbl_unlabel_gnl_family, 1399 return genl_register_family_with_ops(&netlbl_unlabel_gnl_family,
1400 netlbl_unlabel_genl_ops, ARRAY_SIZE(netlbl_unlabel_genl_ops)); 1400 netlbl_unlabel_genl_ops);
1401} 1401}
1402 1402
1403/* 1403/*
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 8df7f64c6db3..f0176e1a5a81 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2017,7 +2017,7 @@ out:
2017 * netlink_set_err - report error to broadcast listeners 2017 * netlink_set_err - report error to broadcast listeners
2018 * @ssk: the kernel netlink socket, as returned by netlink_kernel_create() 2018 * @ssk: the kernel netlink socket, as returned by netlink_kernel_create()
2019 * @portid: the PORTID of a process that we want to skip (if any) 2019 * @portid: the PORTID of a process that we want to skip (if any)
2020 * @groups: the broadcast group that will notice the error 2020 * @group: the broadcast group that will notice the error
2021 * @code: error code, must be negative (as usual in kernelspace) 2021 * @code: error code, must be negative (as usual in kernelspace)
2022 * 2022 *
2023 * This function returns the number of broadcast listeners that have set the 2023 * This function returns the number of broadcast listeners that have set the
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 0c741cec4d0d..7dbc4f732c75 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -65,12 +65,24 @@ static struct list_head family_ht[GENL_FAM_TAB_SIZE];
65 * To avoid an allocation at boot of just one unsigned long, 65 * To avoid an allocation at boot of just one unsigned long,
66 * declare it global instead. 66 * declare it global instead.
67 * Bit 0 is marked as already used since group 0 is invalid. 67 * Bit 0 is marked as already used since group 0 is invalid.
68 * Bit 1 is marked as already used since the drop-monitor code
69 * abuses the API and thinks it can statically use group 1.
70 * That group will typically conflict with other groups that
71 * any proper users use.
72 * Bit 16 is marked as used since it's used for generic netlink
73 * and the code no longer marks pre-reserved IDs as used.
74 * Bit 17 is marked as already used since the VFS quota code
75 * also abused this API and relied on family == group ID, we
76 * cater to that by giving it a static family and group ID.
68 */ 77 */
69static unsigned long mc_group_start = 0x1; 78static unsigned long mc_group_start = 0x3 | BIT(GENL_ID_CTRL) |
79 BIT(GENL_ID_VFS_DQUOT);
70static unsigned long *mc_groups = &mc_group_start; 80static unsigned long *mc_groups = &mc_group_start;
71static unsigned long mc_groups_longs = 1; 81static unsigned long mc_groups_longs = 1;
72 82
73static int genl_ctrl_event(int event, void *data); 83static int genl_ctrl_event(int event, struct genl_family *family,
84 const struct genl_multicast_group *grp,
85 int grp_id);
74 86
75static inline unsigned int genl_family_hash(unsigned int id) 87static inline unsigned int genl_family_hash(unsigned int id)
76{ 88{
@@ -106,13 +118,13 @@ static struct genl_family *genl_family_find_byname(char *name)
106 return NULL; 118 return NULL;
107} 119}
108 120
109static struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family) 121static const struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family)
110{ 122{
111 struct genl_ops *ops; 123 int i;
112 124
113 list_for_each_entry(ops, &family->ops_list, ops_list) 125 for (i = 0; i < family->n_ops; i++)
114 if (ops->cmd == cmd) 126 if (family->ops[i].cmd == cmd)
115 return ops; 127 return &family->ops[i];
116 128
117 return NULL; 129 return NULL;
118} 130}
@@ -126,7 +138,8 @@ static u16 genl_generate_id(void)
126 int i; 138 int i;
127 139
128 for (i = 0; i <= GENL_MAX_ID - GENL_MIN_ID; i++) { 140 for (i = 0; i <= GENL_MAX_ID - GENL_MIN_ID; i++) {
129 if (!genl_family_find_byid(id_gen_idx)) 141 if (id_gen_idx != GENL_ID_VFS_DQUOT &&
142 !genl_family_find_byid(id_gen_idx))
130 return id_gen_idx; 143 return id_gen_idx;
131 if (++id_gen_idx > GENL_MAX_ID) 144 if (++id_gen_idx > GENL_MAX_ID)
132 id_gen_idx = GENL_MIN_ID; 145 id_gen_idx = GENL_MIN_ID;
@@ -135,62 +148,110 @@ static u16 genl_generate_id(void)
135 return 0; 148 return 0;
136} 149}
137 150
138static struct genl_multicast_group notify_grp; 151static int genl_allocate_reserve_groups(int n_groups, int *first_id)
139
140/**
141 * genl_register_mc_group - register a multicast group
142 *
143 * Registers the specified multicast group and notifies userspace
144 * about the new group.
145 *
146 * Returns 0 on success or a negative error code.
147 *
148 * @family: The generic netlink family the group shall be registered for.
149 * @grp: The group to register, must have a name.
150 */
151int genl_register_mc_group(struct genl_family *family,
152 struct genl_multicast_group *grp)
153{ 152{
154 int id;
155 unsigned long *new_groups; 153 unsigned long *new_groups;
156 int err = 0; 154 int start = 0;
155 int i;
156 int id;
157 bool fits;
158
159 do {
160 if (start == 0)
161 id = find_first_zero_bit(mc_groups,
162 mc_groups_longs *
163 BITS_PER_LONG);
164 else
165 id = find_next_zero_bit(mc_groups,
166 mc_groups_longs * BITS_PER_LONG,
167 start);
168
169 fits = true;
170 for (i = id;
171 i < min_t(int, id + n_groups,
172 mc_groups_longs * BITS_PER_LONG);
173 i++) {
174 if (test_bit(i, mc_groups)) {
175 start = i;
176 fits = false;
177 break;
178 }
179 }
157 180
158 BUG_ON(grp->name[0] == '\0'); 181 if (id >= mc_groups_longs * BITS_PER_LONG) {
159 BUG_ON(memchr(grp->name, '\0', GENL_NAMSIZ) == NULL); 182 unsigned long new_longs = mc_groups_longs +
183 BITS_TO_LONGS(n_groups);
184 size_t nlen = new_longs * sizeof(unsigned long);
185
186 if (mc_groups == &mc_group_start) {
187 new_groups = kzalloc(nlen, GFP_KERNEL);
188 if (!new_groups)
189 return -ENOMEM;
190 mc_groups = new_groups;
191 *mc_groups = mc_group_start;
192 } else {
193 new_groups = krealloc(mc_groups, nlen,
194 GFP_KERNEL);
195 if (!new_groups)
196 return -ENOMEM;
197 mc_groups = new_groups;
198 for (i = 0; i < BITS_TO_LONGS(n_groups); i++)
199 mc_groups[mc_groups_longs + i] = 0;
200 }
201 mc_groups_longs = new_longs;
202 }
203 } while (!fits);
160 204
161 genl_lock_all(); 205 for (i = id; i < id + n_groups; i++)
206 set_bit(i, mc_groups);
207 *first_id = id;
208 return 0;
209}
162 210
163 /* special-case our own group */ 211static struct genl_family genl_ctrl;
164 if (grp == &notify_grp)
165 id = GENL_ID_CTRL;
166 else
167 id = find_first_zero_bit(mc_groups,
168 mc_groups_longs * BITS_PER_LONG);
169 212
213static int genl_validate_assign_mc_groups(struct genl_family *family)
214{
215 int first_id;
216 int n_groups = family->n_mcgrps;
217 int err, i;
218 bool groups_allocated = false;
170 219
171 if (id >= mc_groups_longs * BITS_PER_LONG) { 220 if (!n_groups)
172 size_t nlen = (mc_groups_longs + 1) * sizeof(unsigned long); 221 return 0;
173 222
174 if (mc_groups == &mc_group_start) { 223 for (i = 0; i < n_groups; i++) {
175 new_groups = kzalloc(nlen, GFP_KERNEL); 224 const struct genl_multicast_group *grp = &family->mcgrps[i];
176 if (!new_groups) { 225
177 err = -ENOMEM; 226 if (WARN_ON(grp->name[0] == '\0'))
178 goto out; 227 return -EINVAL;
179 } 228 if (WARN_ON(memchr(grp->name, '\0', GENL_NAMSIZ) == NULL))
180 mc_groups = new_groups; 229 return -EINVAL;
181 *mc_groups = mc_group_start; 230 }
182 } else { 231
183 new_groups = krealloc(mc_groups, nlen, GFP_KERNEL); 232 /* special-case our own group and hacks */
184 if (!new_groups) { 233 if (family == &genl_ctrl) {
185 err = -ENOMEM; 234 first_id = GENL_ID_CTRL;
186 goto out; 235 BUG_ON(n_groups != 1);
187 } 236 } else if (strcmp(family->name, "NET_DM") == 0) {
188 mc_groups = new_groups; 237 first_id = 1;
189 mc_groups[mc_groups_longs] = 0; 238 BUG_ON(n_groups != 1);
190 } 239 } else if (strcmp(family->name, "VFS_DQUOT") == 0) {
191 mc_groups_longs++; 240 first_id = GENL_ID_VFS_DQUOT;
241 BUG_ON(n_groups != 1);
242 } else {
243 groups_allocated = true;
244 err = genl_allocate_reserve_groups(n_groups, &first_id);
245 if (err)
246 return err;
192 } 247 }
193 248
249 family->mcgrp_offset = first_id;
250
251 /* if still initializing, can't and don't need to to realloc bitmaps */
252 if (!init_net.genl_sock)
253 return 0;
254
194 if (family->netnsok) { 255 if (family->netnsok) {
195 struct net *net; 256 struct net *net;
196 257
@@ -206,9 +267,7 @@ int genl_register_mc_group(struct genl_family *family,
206 * number of _possible_ groups has been 267 * number of _possible_ groups has been
207 * increased on some sockets which is ok. 268 * increased on some sockets which is ok.
208 */ 269 */
209 rcu_read_unlock(); 270 break;
210 netlink_table_ungrab();
211 goto out;
212 } 271 }
213 } 272 }
214 rcu_read_unlock(); 273 rcu_read_unlock();
@@ -216,152 +275,67 @@ int genl_register_mc_group(struct genl_family *family,
216 } else { 275 } else {
217 err = netlink_change_ngroups(init_net.genl_sock, 276 err = netlink_change_ngroups(init_net.genl_sock,
218 mc_groups_longs * BITS_PER_LONG); 277 mc_groups_longs * BITS_PER_LONG);
219 if (err)
220 goto out;
221 } 278 }
222 279
223 grp->id = id; 280 if (groups_allocated && err) {
224 set_bit(id, mc_groups); 281 for (i = 0; i < family->n_mcgrps; i++)
225 list_add_tail(&grp->list, &family->mcast_groups); 282 clear_bit(family->mcgrp_offset + i, mc_groups);
226 grp->family = family; 283 }
227 284
228 genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp);
229 out:
230 genl_unlock_all();
231 return err; 285 return err;
232} 286}
233EXPORT_SYMBOL(genl_register_mc_group);
234 287
235static void __genl_unregister_mc_group(struct genl_family *family, 288static void genl_unregister_mc_groups(struct genl_family *family)
236 struct genl_multicast_group *grp)
237{ 289{
238 struct net *net; 290 struct net *net;
239 BUG_ON(grp->family != family); 291 int i;
240 292
241 netlink_table_grab(); 293 netlink_table_grab();
242 rcu_read_lock(); 294 rcu_read_lock();
243 for_each_net_rcu(net) 295 for_each_net_rcu(net) {
244 __netlink_clear_multicast_users(net->genl_sock, grp->id); 296 for (i = 0; i < family->n_mcgrps; i++)
297 __netlink_clear_multicast_users(
298 net->genl_sock, family->mcgrp_offset + i);
299 }
245 rcu_read_unlock(); 300 rcu_read_unlock();
246 netlink_table_ungrab(); 301 netlink_table_ungrab();
247 302
248 clear_bit(grp->id, mc_groups); 303 for (i = 0; i < family->n_mcgrps; i++) {
249 list_del(&grp->list); 304 int grp_id = family->mcgrp_offset + i;
250 genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
251 grp->id = 0;
252 grp->family = NULL;
253}
254 305
255/** 306 if (grp_id != 1)
256 * genl_unregister_mc_group - unregister a multicast group 307 clear_bit(grp_id, mc_groups);
257 * 308 genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, family,
258 * Unregisters the specified multicast group and notifies userspace 309 &family->mcgrps[i], grp_id);
259 * about it. All current listeners on the group are removed. 310 }
260 *
261 * Note: It is not necessary to unregister all multicast groups before
262 * unregistering the family, unregistering the family will cause
263 * all assigned multicast groups to be unregistered automatically.
264 *
265 * @family: Generic netlink family the group belongs to.
266 * @grp: The group to unregister, must have been registered successfully
267 * previously.
268 */
269void genl_unregister_mc_group(struct genl_family *family,
270 struct genl_multicast_group *grp)
271{
272 genl_lock_all();
273 __genl_unregister_mc_group(family, grp);
274 genl_unlock_all();
275} 311}
276EXPORT_SYMBOL(genl_unregister_mc_group);
277 312
278static void genl_unregister_mc_groups(struct genl_family *family) 313static int genl_validate_ops(struct genl_family *family)
279{ 314{
280 struct genl_multicast_group *grp, *tmp; 315 const struct genl_ops *ops = family->ops;
316 unsigned int n_ops = family->n_ops;
317 int i, j;
281 318
282 list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list) 319 if (WARN_ON(n_ops && !ops))
283 __genl_unregister_mc_group(family, grp); 320 return -EINVAL;
284}
285
286/**
287 * genl_register_ops - register generic netlink operations
288 * @family: generic netlink family
289 * @ops: operations to be registered
290 *
291 * Registers the specified operations and assigns them to the specified
292 * family. Either a doit or dumpit callback must be specified or the
293 * operation will fail. Only one operation structure per command
294 * identifier may be registered.
295 *
296 * See include/net/genetlink.h for more documenation on the operations
297 * structure.
298 *
299 * Returns 0 on success or a negative error code.
300 */
301int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
302{
303 int err = -EINVAL;
304 321
305 if (ops->dumpit == NULL && ops->doit == NULL) 322 if (!n_ops)
306 goto errout; 323 return 0;
307 324
308 if (genl_get_cmd(ops->cmd, family)) { 325 for (i = 0; i < n_ops; i++) {
309 err = -EEXIST; 326 if (ops[i].dumpit == NULL && ops[i].doit == NULL)
310 goto errout; 327 return -EINVAL;
328 for (j = i + 1; j < n_ops; j++)
329 if (ops[i].cmd == ops[j].cmd)
330 return -EINVAL;
311 } 331 }
312 332
313 if (ops->dumpit) 333 /* family is not registered yet, so no locking needed */
314 ops->flags |= GENL_CMD_CAP_DUMP; 334 family->ops = ops;
315 if (ops->doit) 335 family->n_ops = n_ops;
316 ops->flags |= GENL_CMD_CAP_DO;
317 if (ops->policy)
318 ops->flags |= GENL_CMD_CAP_HASPOL;
319 336
320 genl_lock_all(); 337 return 0;
321 list_add_tail(&ops->ops_list, &family->ops_list);
322 genl_unlock_all();
323
324 genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
325 err = 0;
326errout:
327 return err;
328}
329EXPORT_SYMBOL(genl_register_ops);
330
331/**
332 * genl_unregister_ops - unregister generic netlink operations
333 * @family: generic netlink family
334 * @ops: operations to be unregistered
335 *
336 * Unregisters the specified operations and unassigns them from the
337 * specified family. The operation blocks until the current message
338 * processing has finished and doesn't start again until the
339 * unregister process has finished.
340 *
341 * Note: It is not necessary to unregister all operations before
342 * unregistering the family, unregistering the family will cause
343 * all assigned operations to be unregistered automatically.
344 *
345 * Returns 0 on success or a negative error code.
346 */
347int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
348{
349 struct genl_ops *rc;
350
351 genl_lock_all();
352 list_for_each_entry(rc, &family->ops_list, ops_list) {
353 if (rc == ops) {
354 list_del(&ops->ops_list);
355 genl_unlock_all();
356 genl_ctrl_event(CTRL_CMD_DELOPS, ops);
357 return 0;
358 }
359 }
360 genl_unlock_all();
361
362 return -ENOENT;
363} 338}
364EXPORT_SYMBOL(genl_unregister_ops);
365 339
366/** 340/**
367 * __genl_register_family - register a generic netlink family 341 * __genl_register_family - register a generic netlink family
@@ -372,11 +346,14 @@ EXPORT_SYMBOL(genl_unregister_ops);
372 * The family id may equal GENL_ID_GENERATE causing an unique id to 346 * The family id may equal GENL_ID_GENERATE causing an unique id to
373 * be automatically generated and assigned. 347 * be automatically generated and assigned.
374 * 348 *
349 * The family's ops array must already be assigned, you can use the
350 * genl_register_family_with_ops() helper function.
351 *
375 * Return 0 on success or a negative error code. 352 * Return 0 on success or a negative error code.
376 */ 353 */
377int __genl_register_family(struct genl_family *family) 354int __genl_register_family(struct genl_family *family)
378{ 355{
379 int err = -EINVAL; 356 int err = -EINVAL, i;
380 357
381 if (family->id && family->id < GENL_MIN_ID) 358 if (family->id && family->id < GENL_MIN_ID)
382 goto errout; 359 goto errout;
@@ -384,8 +361,9 @@ int __genl_register_family(struct genl_family *family)
384 if (family->id > GENL_MAX_ID) 361 if (family->id > GENL_MAX_ID)
385 goto errout; 362 goto errout;
386 363
387 INIT_LIST_HEAD(&family->ops_list); 364 err = genl_validate_ops(family);
388 INIT_LIST_HEAD(&family->mcast_groups); 365 if (err)
366 return err;
389 367
390 genl_lock_all(); 368 genl_lock_all();
391 369
@@ -418,10 +396,18 @@ int __genl_register_family(struct genl_family *family)
418 } else 396 } else
419 family->attrbuf = NULL; 397 family->attrbuf = NULL;
420 398
399 err = genl_validate_assign_mc_groups(family);
400 if (err)
401 goto errout_locked;
402
421 list_add_tail(&family->family_list, genl_family_chain(family->id)); 403 list_add_tail(&family->family_list, genl_family_chain(family->id));
422 genl_unlock_all(); 404 genl_unlock_all();
423 405
424 genl_ctrl_event(CTRL_CMD_NEWFAMILY, family); 406 /* send all events */
407 genl_ctrl_event(CTRL_CMD_NEWFAMILY, family, NULL, 0);
408 for (i = 0; i < family->n_mcgrps; i++)
409 genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, family,
410 &family->mcgrps[i], family->mcgrp_offset + i);
425 411
426 return 0; 412 return 0;
427 413
@@ -433,52 +419,6 @@ errout:
433EXPORT_SYMBOL(__genl_register_family); 419EXPORT_SYMBOL(__genl_register_family);
434 420
435/** 421/**
436 * __genl_register_family_with_ops - register a generic netlink family
437 * @family: generic netlink family
438 * @ops: operations to be registered
439 * @n_ops: number of elements to register
440 *
441 * Registers the specified family and operations from the specified table.
442 * Only one family may be registered with the same family name or identifier.
443 *
444 * The family id may equal GENL_ID_GENERATE causing an unique id to
445 * be automatically generated and assigned.
446 *
447 * Either a doit or dumpit callback must be specified for every registered
448 * operation or the function will fail. Only one operation structure per
449 * command identifier may be registered.
450 *
451 * See include/net/genetlink.h for more documenation on the operations
452 * structure.
453 *
454 * This is equivalent to calling genl_register_family() followed by
455 * genl_register_ops() for every operation entry in the table taking
456 * care to unregister the family on error path.
457 *
458 * Return 0 on success or a negative error code.
459 */
460int __genl_register_family_with_ops(struct genl_family *family,
461 struct genl_ops *ops, size_t n_ops)
462{
463 int err, i;
464
465 err = __genl_register_family(family);
466 if (err)
467 return err;
468
469 for (i = 0; i < n_ops; ++i, ++ops) {
470 err = genl_register_ops(family, ops);
471 if (err)
472 goto err_out;
473 }
474 return 0;
475err_out:
476 genl_unregister_family(family);
477 return err;
478}
479EXPORT_SYMBOL(__genl_register_family_with_ops);
480
481/**
482 * genl_unregister_family - unregister generic netlink family 422 * genl_unregister_family - unregister generic netlink family
483 * @family: generic netlink family 423 * @family: generic netlink family
484 * 424 *
@@ -499,11 +439,11 @@ int genl_unregister_family(struct genl_family *family)
499 continue; 439 continue;
500 440
501 list_del(&rc->family_list); 441 list_del(&rc->family_list);
502 INIT_LIST_HEAD(&family->ops_list); 442 family->n_ops = 0;
503 genl_unlock_all(); 443 genl_unlock_all();
504 444
505 kfree(family->attrbuf); 445 kfree(family->attrbuf);
506 genl_ctrl_event(CTRL_CMD_DELFAMILY, family); 446 genl_ctrl_event(CTRL_CMD_DELFAMILY, family, NULL, 0);
507 return 0; 447 return 0;
508 } 448 }
509 449
@@ -546,7 +486,8 @@ EXPORT_SYMBOL(genlmsg_put);
546 486
547static int genl_lock_dumpit(struct sk_buff *skb, struct netlink_callback *cb) 487static int genl_lock_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
548{ 488{
549 struct genl_ops *ops = cb->data; 489 /* our ops are always const - netlink API doesn't propagate that */
490 const struct genl_ops *ops = cb->data;
550 int rc; 491 int rc;
551 492
552 genl_lock(); 493 genl_lock();
@@ -557,7 +498,8 @@ static int genl_lock_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
557 498
558static int genl_lock_done(struct netlink_callback *cb) 499static int genl_lock_done(struct netlink_callback *cb)
559{ 500{
560 struct genl_ops *ops = cb->data; 501 /* our ops are always const - netlink API doesn't propagate that */
502 const struct genl_ops *ops = cb->data;
561 int rc = 0; 503 int rc = 0;
562 504
563 if (ops->done) { 505 if (ops->done) {
@@ -572,7 +514,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
572 struct sk_buff *skb, 514 struct sk_buff *skb,
573 struct nlmsghdr *nlh) 515 struct nlmsghdr *nlh)
574{ 516{
575 struct genl_ops *ops; 517 const struct genl_ops *ops;
576 struct net *net = sock_net(skb->sk); 518 struct net *net = sock_net(skb->sk);
577 struct genl_info info; 519 struct genl_info info;
578 struct genlmsghdr *hdr = nlmsg_data(nlh); 520 struct genlmsghdr *hdr = nlmsg_data(nlh);
@@ -604,7 +546,8 @@ static int genl_family_rcv_msg(struct genl_family *family,
604 if (!family->parallel_ops) { 546 if (!family->parallel_ops) {
605 struct netlink_dump_control c = { 547 struct netlink_dump_control c = {
606 .module = family->module, 548 .module = family->module,
607 .data = ops, 549 /* we have const, but the netlink API doesn't */
550 .data = (void *)ops,
608 .dump = genl_lock_dumpit, 551 .dump = genl_lock_dumpit,
609 .done = genl_lock_done, 552 .done = genl_lock_done,
610 }; 553 };
@@ -726,24 +669,32 @@ static int ctrl_fill_info(struct genl_family *family, u32 portid, u32 seq,
726 nla_put_u32(skb, CTRL_ATTR_MAXATTR, family->maxattr)) 669 nla_put_u32(skb, CTRL_ATTR_MAXATTR, family->maxattr))
727 goto nla_put_failure; 670 goto nla_put_failure;
728 671
729 if (!list_empty(&family->ops_list)) { 672 if (family->n_ops) {
730 struct nlattr *nla_ops; 673 struct nlattr *nla_ops;
731 struct genl_ops *ops; 674 int i;
732 int idx = 1;
733 675
734 nla_ops = nla_nest_start(skb, CTRL_ATTR_OPS); 676 nla_ops = nla_nest_start(skb, CTRL_ATTR_OPS);
735 if (nla_ops == NULL) 677 if (nla_ops == NULL)
736 goto nla_put_failure; 678 goto nla_put_failure;
737 679
738 list_for_each_entry(ops, &family->ops_list, ops_list) { 680 for (i = 0; i < family->n_ops; i++) {
739 struct nlattr *nest; 681 struct nlattr *nest;
682 const struct genl_ops *ops = &family->ops[i];
683 u32 op_flags = ops->flags;
740 684
741 nest = nla_nest_start(skb, idx++); 685 if (ops->dumpit)
686 op_flags |= GENL_CMD_CAP_DUMP;
687 if (ops->doit)
688 op_flags |= GENL_CMD_CAP_DO;
689 if (ops->policy)
690 op_flags |= GENL_CMD_CAP_HASPOL;
691
692 nest = nla_nest_start(skb, i + 1);
742 if (nest == NULL) 693 if (nest == NULL)
743 goto nla_put_failure; 694 goto nla_put_failure;
744 695
745 if (nla_put_u32(skb, CTRL_ATTR_OP_ID, ops->cmd) || 696 if (nla_put_u32(skb, CTRL_ATTR_OP_ID, ops->cmd) ||
746 nla_put_u32(skb, CTRL_ATTR_OP_FLAGS, ops->flags)) 697 nla_put_u32(skb, CTRL_ATTR_OP_FLAGS, op_flags))
747 goto nla_put_failure; 698 goto nla_put_failure;
748 699
749 nla_nest_end(skb, nest); 700 nla_nest_end(skb, nest);
@@ -752,23 +703,26 @@ static int ctrl_fill_info(struct genl_family *family, u32 portid, u32 seq,
752 nla_nest_end(skb, nla_ops); 703 nla_nest_end(skb, nla_ops);
753 } 704 }
754 705
755 if (!list_empty(&family->mcast_groups)) { 706 if (family->n_mcgrps) {
756 struct genl_multicast_group *grp;
757 struct nlattr *nla_grps; 707 struct nlattr *nla_grps;
758 int idx = 1; 708 int i;
759 709
760 nla_grps = nla_nest_start(skb, CTRL_ATTR_MCAST_GROUPS); 710 nla_grps = nla_nest_start(skb, CTRL_ATTR_MCAST_GROUPS);
761 if (nla_grps == NULL) 711 if (nla_grps == NULL)
762 goto nla_put_failure; 712 goto nla_put_failure;
763 713
764 list_for_each_entry(grp, &family->mcast_groups, list) { 714 for (i = 0; i < family->n_mcgrps; i++) {
765 struct nlattr *nest; 715 struct nlattr *nest;
716 const struct genl_multicast_group *grp;
717
718 grp = &family->mcgrps[i];
766 719
767 nest = nla_nest_start(skb, idx++); 720 nest = nla_nest_start(skb, i + 1);
768 if (nest == NULL) 721 if (nest == NULL)
769 goto nla_put_failure; 722 goto nla_put_failure;
770 723
771 if (nla_put_u32(skb, CTRL_ATTR_MCAST_GRP_ID, grp->id) || 724 if (nla_put_u32(skb, CTRL_ATTR_MCAST_GRP_ID,
725 family->mcgrp_offset + i) ||
772 nla_put_string(skb, CTRL_ATTR_MCAST_GRP_NAME, 726 nla_put_string(skb, CTRL_ATTR_MCAST_GRP_NAME,
773 grp->name)) 727 grp->name))
774 goto nla_put_failure; 728 goto nla_put_failure;
@@ -785,9 +739,10 @@ nla_put_failure:
785 return -EMSGSIZE; 739 return -EMSGSIZE;
786} 740}
787 741
788static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 portid, 742static int ctrl_fill_mcgrp_info(struct genl_family *family,
789 u32 seq, u32 flags, struct sk_buff *skb, 743 const struct genl_multicast_group *grp,
790 u8 cmd) 744 int grp_id, u32 portid, u32 seq, u32 flags,
745 struct sk_buff *skb, u8 cmd)
791{ 746{
792 void *hdr; 747 void *hdr;
793 struct nlattr *nla_grps; 748 struct nlattr *nla_grps;
@@ -797,8 +752,8 @@ static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 portid,
797 if (hdr == NULL) 752 if (hdr == NULL)
798 return -1; 753 return -1;
799 754
800 if (nla_put_string(skb, CTRL_ATTR_FAMILY_NAME, grp->family->name) || 755 if (nla_put_string(skb, CTRL_ATTR_FAMILY_NAME, family->name) ||
801 nla_put_u16(skb, CTRL_ATTR_FAMILY_ID, grp->family->id)) 756 nla_put_u16(skb, CTRL_ATTR_FAMILY_ID, family->id))
802 goto nla_put_failure; 757 goto nla_put_failure;
803 758
804 nla_grps = nla_nest_start(skb, CTRL_ATTR_MCAST_GROUPS); 759 nla_grps = nla_nest_start(skb, CTRL_ATTR_MCAST_GROUPS);
@@ -809,7 +764,7 @@ static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 portid,
809 if (nest == NULL) 764 if (nest == NULL)
810 goto nla_put_failure; 765 goto nla_put_failure;
811 766
812 if (nla_put_u32(skb, CTRL_ATTR_MCAST_GRP_ID, grp->id) || 767 if (nla_put_u32(skb, CTRL_ATTR_MCAST_GRP_ID, grp_id) ||
813 nla_put_string(skb, CTRL_ATTR_MCAST_GRP_NAME, 768 nla_put_string(skb, CTRL_ATTR_MCAST_GRP_NAME,
814 grp->name)) 769 grp->name))
815 goto nla_put_failure; 770 goto nla_put_failure;
@@ -875,8 +830,10 @@ static struct sk_buff *ctrl_build_family_msg(struct genl_family *family,
875 return skb; 830 return skb;
876} 831}
877 832
878static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp, 833static struct sk_buff *
879 u32 portid, int seq, u8 cmd) 834ctrl_build_mcgrp_msg(struct genl_family *family,
835 const struct genl_multicast_group *grp,
836 int grp_id, u32 portid, int seq, u8 cmd)
880{ 837{
881 struct sk_buff *skb; 838 struct sk_buff *skb;
882 int err; 839 int err;
@@ -885,7 +842,8 @@ static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp,
885 if (skb == NULL) 842 if (skb == NULL)
886 return ERR_PTR(-ENOBUFS); 843 return ERR_PTR(-ENOBUFS);
887 844
888 err = ctrl_fill_mcgrp_info(grp, portid, seq, 0, skb, cmd); 845 err = ctrl_fill_mcgrp_info(family, grp, grp_id, portid,
846 seq, 0, skb, cmd);
889 if (err < 0) { 847 if (err < 0) {
890 nlmsg_free(skb); 848 nlmsg_free(skb);
891 return ERR_PTR(err); 849 return ERR_PTR(err);
@@ -947,11 +905,11 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info)
947 return genlmsg_reply(msg, info); 905 return genlmsg_reply(msg, info);
948} 906}
949 907
950static int genl_ctrl_event(int event, void *data) 908static int genl_ctrl_event(int event, struct genl_family *family,
909 const struct genl_multicast_group *grp,
910 int grp_id)
951{ 911{
952 struct sk_buff *msg; 912 struct sk_buff *msg;
953 struct genl_family *family;
954 struct genl_multicast_group *grp;
955 913
956 /* genl is still initialising */ 914 /* genl is still initialising */
957 if (!init_net.genl_sock) 915 if (!init_net.genl_sock)
@@ -960,14 +918,13 @@ static int genl_ctrl_event(int event, void *data)
960 switch (event) { 918 switch (event) {
961 case CTRL_CMD_NEWFAMILY: 919 case CTRL_CMD_NEWFAMILY:
962 case CTRL_CMD_DELFAMILY: 920 case CTRL_CMD_DELFAMILY:
963 family = data; 921 WARN_ON(grp);
964 msg = ctrl_build_family_msg(family, 0, 0, event); 922 msg = ctrl_build_family_msg(family, 0, 0, event);
965 break; 923 break;
966 case CTRL_CMD_NEWMCAST_GRP: 924 case CTRL_CMD_NEWMCAST_GRP:
967 case CTRL_CMD_DELMCAST_GRP: 925 case CTRL_CMD_DELMCAST_GRP:
968 grp = data; 926 BUG_ON(!grp);
969 family = grp->family; 927 msg = ctrl_build_mcgrp_msg(family, grp, grp_id, 0, 0, event);
970 msg = ctrl_build_mcgrp_msg(data, 0, 0, event);
971 break; 928 break;
972 default: 929 default:
973 return -EINVAL; 930 return -EINVAL;
@@ -977,26 +934,29 @@ static int genl_ctrl_event(int event, void *data)
977 return PTR_ERR(msg); 934 return PTR_ERR(msg);
978 935
979 if (!family->netnsok) { 936 if (!family->netnsok) {
980 genlmsg_multicast_netns(&init_net, msg, 0, 937 genlmsg_multicast_netns(&genl_ctrl, &init_net, msg, 0,
981 GENL_ID_CTRL, GFP_KERNEL); 938 0, GFP_KERNEL);
982 } else { 939 } else {
983 rcu_read_lock(); 940 rcu_read_lock();
984 genlmsg_multicast_allns(msg, 0, GENL_ID_CTRL, GFP_ATOMIC); 941 genlmsg_multicast_allns(&genl_ctrl, msg, 0,
942 0, GFP_ATOMIC);
985 rcu_read_unlock(); 943 rcu_read_unlock();
986 } 944 }
987 945
988 return 0; 946 return 0;
989} 947}
990 948
991static struct genl_ops genl_ctrl_ops = { 949static struct genl_ops genl_ctrl_ops[] = {
992 .cmd = CTRL_CMD_GETFAMILY, 950 {
993 .doit = ctrl_getfamily, 951 .cmd = CTRL_CMD_GETFAMILY,
994 .dumpit = ctrl_dumpfamily, 952 .doit = ctrl_getfamily,
995 .policy = ctrl_policy, 953 .dumpit = ctrl_dumpfamily,
954 .policy = ctrl_policy,
955 },
996}; 956};
997 957
998static struct genl_multicast_group notify_grp = { 958static struct genl_multicast_group genl_ctrl_groups[] = {
999 .name = "notify", 959 { .name = "notify", },
1000}; 960};
1001 961
1002static int __net_init genl_pernet_init(struct net *net) 962static int __net_init genl_pernet_init(struct net *net)
@@ -1036,7 +996,8 @@ static int __init genl_init(void)
1036 for (i = 0; i < GENL_FAM_TAB_SIZE; i++) 996 for (i = 0; i < GENL_FAM_TAB_SIZE; i++)
1037 INIT_LIST_HEAD(&family_ht[i]); 997 INIT_LIST_HEAD(&family_ht[i]);
1038 998
1039 err = genl_register_family_with_ops(&genl_ctrl, &genl_ctrl_ops, 1); 999 err = genl_register_family_with_ops_groups(&genl_ctrl, genl_ctrl_ops,
1000 genl_ctrl_groups);
1040 if (err < 0) 1001 if (err < 0)
1041 goto problem; 1002 goto problem;
1042 1003
@@ -1044,10 +1005,6 @@ static int __init genl_init(void)
1044 if (err) 1005 if (err)
1045 goto problem; 1006 goto problem;
1046 1007
1047 err = genl_register_mc_group(&genl_ctrl, &notify_grp);
1048 if (err < 0)
1049 goto problem;
1050
1051 return 0; 1008 return 0;
1052 1009
1053problem: 1010problem:
@@ -1085,14 +1042,18 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
1085 return err; 1042 return err;
1086} 1043}
1087 1044
1088int genlmsg_multicast_allns(struct sk_buff *skb, u32 portid, unsigned int group, 1045int genlmsg_multicast_allns(struct genl_family *family, struct sk_buff *skb,
1089 gfp_t flags) 1046 u32 portid, unsigned int group, gfp_t flags)
1090{ 1047{
1048 if (group >= family->n_mcgrps)
1049 return -EINVAL;
1050 group = family->mcgrp_offset + group;
1091 return genlmsg_mcast(skb, portid, group, flags); 1051 return genlmsg_mcast(skb, portid, group, flags);
1092} 1052}
1093EXPORT_SYMBOL(genlmsg_multicast_allns); 1053EXPORT_SYMBOL(genlmsg_multicast_allns);
1094 1054
1095void genl_notify(struct sk_buff *skb, struct net *net, u32 portid, u32 group, 1055void genl_notify(struct genl_family *family,
1056 struct sk_buff *skb, struct net *net, u32 portid, u32 group,
1096 struct nlmsghdr *nlh, gfp_t flags) 1057 struct nlmsghdr *nlh, gfp_t flags)
1097{ 1058{
1098 struct sock *sk = net->genl_sock; 1059 struct sock *sk = net->genl_sock;
@@ -1101,6 +1062,9 @@ void genl_notify(struct sk_buff *skb, struct net *net, u32 portid, u32 group,
1101 if (nlh) 1062 if (nlh)
1102 report = nlmsg_report(nlh); 1063 report = nlmsg_report(nlh);
1103 1064
1065 if (group >= family->n_mcgrps)
1066 return;
1067 group = family->mcgrp_offset + group;
1104 nlmsg_notify(sk, skb, portid, group, report, flags); 1068 nlmsg_notify(sk, skb, portid, group, report, flags);
1105} 1069}
1106EXPORT_SYMBOL(genl_notify); 1070EXPORT_SYMBOL(genl_notify);
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 84b7e3ea7b7a..a9b2342d5253 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -30,8 +30,8 @@
30#include "nfc.h" 30#include "nfc.h"
31#include "llcp.h" 31#include "llcp.h"
32 32
33static struct genl_multicast_group nfc_genl_event_mcgrp = { 33static const struct genl_multicast_group nfc_genl_mcgrps[] = {
34 .name = NFC_GENL_MCAST_EVENT_NAME, 34 { .name = NFC_GENL_MCAST_EVENT_NAME, },
35}; 35};
36 36
37static struct genl_family nfc_genl_family = { 37static struct genl_family nfc_genl_family = {
@@ -194,7 +194,7 @@ int nfc_genl_targets_found(struct nfc_dev *dev)
194 194
195 genlmsg_end(msg, hdr); 195 genlmsg_end(msg, hdr);
196 196
197 return genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_ATOMIC); 197 return genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
198 198
199nla_put_failure: 199nla_put_failure:
200 genlmsg_cancel(msg, hdr); 200 genlmsg_cancel(msg, hdr);
@@ -223,7 +223,7 @@ int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx)
223 223
224 genlmsg_end(msg, hdr); 224 genlmsg_end(msg, hdr);
225 225
226 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 226 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
227 227
228 return 0; 228 return 0;
229 229
@@ -255,7 +255,7 @@ int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol)
255 255
256 genlmsg_end(msg, hdr); 256 genlmsg_end(msg, hdr);
257 257
258 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 258 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
259 259
260 return 0; 260 return 0;
261 261
@@ -285,7 +285,7 @@ int nfc_genl_tm_deactivated(struct nfc_dev *dev)
285 285
286 genlmsg_end(msg, hdr); 286 genlmsg_end(msg, hdr);
287 287
288 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 288 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
289 289
290 return 0; 290 return 0;
291 291
@@ -318,7 +318,7 @@ int nfc_genl_device_added(struct nfc_dev *dev)
318 318
319 genlmsg_end(msg, hdr); 319 genlmsg_end(msg, hdr);
320 320
321 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 321 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
322 322
323 return 0; 323 return 0;
324 324
@@ -348,7 +348,7 @@ int nfc_genl_device_removed(struct nfc_dev *dev)
348 348
349 genlmsg_end(msg, hdr); 349 genlmsg_end(msg, hdr);
350 350
351 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 351 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
352 352
353 return 0; 353 return 0;
354 354
@@ -414,7 +414,7 @@ int nfc_genl_llc_send_sdres(struct nfc_dev *dev, struct hlist_head *sdres_list)
414 414
415 genlmsg_end(msg, hdr); 415 genlmsg_end(msg, hdr);
416 416
417 return genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_ATOMIC); 417 return genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
418 418
419nla_put_failure: 419nla_put_failure:
420 genlmsg_cancel(msg, hdr); 420 genlmsg_cancel(msg, hdr);
@@ -448,7 +448,7 @@ int nfc_genl_se_added(struct nfc_dev *dev, u32 se_idx, u16 type)
448 448
449 genlmsg_end(msg, hdr); 449 genlmsg_end(msg, hdr);
450 450
451 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 451 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
452 452
453 return 0; 453 return 0;
454 454
@@ -479,7 +479,7 @@ int nfc_genl_se_removed(struct nfc_dev *dev, u32 se_idx)
479 479
480 genlmsg_end(msg, hdr); 480 genlmsg_end(msg, hdr);
481 481
482 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 482 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
483 483
484 return 0; 484 return 0;
485 485
@@ -600,7 +600,7 @@ int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx,
600 600
601 dev->dep_link_up = true; 601 dev->dep_link_up = true;
602 602
603 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_ATOMIC); 603 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
604 604
605 return 0; 605 return 0;
606 606
@@ -632,7 +632,7 @@ int nfc_genl_dep_link_down_event(struct nfc_dev *dev)
632 632
633 genlmsg_end(msg, hdr); 633 genlmsg_end(msg, hdr);
634 634
635 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_ATOMIC); 635 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
636 636
637 return 0; 637 return 0;
638 638
@@ -1137,7 +1137,7 @@ int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name,
1137 1137
1138 genlmsg_end(msg, hdr); 1138 genlmsg_end(msg, hdr);
1139 1139
1140 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 1140 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
1141 1141
1142 return 0; 1142 return 0;
1143 1143
@@ -1308,7 +1308,7 @@ static void se_io_cb(void *context, u8 *apdu, size_t apdu_len, int err)
1308 1308
1309 genlmsg_end(msg, hdr); 1309 genlmsg_end(msg, hdr);
1310 1310
1311 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); 1311 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
1312 1312
1313 kfree(ctx); 1313 kfree(ctx);
1314 1314
@@ -1364,7 +1364,7 @@ static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
1364 return dev->ops->se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx); 1364 return dev->ops->se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx);
1365} 1365}
1366 1366
1367static struct genl_ops nfc_genl_ops[] = { 1367static const struct genl_ops nfc_genl_ops[] = {
1368 { 1368 {
1369 .cmd = NFC_CMD_GET_DEVICE, 1369 .cmd = NFC_CMD_GET_DEVICE,
1370 .doit = nfc_genl_get_device, 1370 .doit = nfc_genl_get_device,
@@ -1536,16 +1536,15 @@ int __init nfc_genl_init(void)
1536{ 1536{
1537 int rc; 1537 int rc;
1538 1538
1539 rc = genl_register_family_with_ops(&nfc_genl_family, nfc_genl_ops, 1539 rc = genl_register_family_with_ops_groups(&nfc_genl_family,
1540 ARRAY_SIZE(nfc_genl_ops)); 1540 nfc_genl_ops,
1541 nfc_genl_mcgrps);
1541 if (rc) 1542 if (rc)
1542 return rc; 1543 return rc;
1543 1544
1544 rc = genl_register_mc_group(&nfc_genl_family, &nfc_genl_event_mcgrp);
1545
1546 netlink_register_notifier(&nl_notifier); 1545 netlink_register_notifier(&nl_notifier);
1547 1546
1548 return rc; 1547 return 0;
1549} 1548}
1550 1549
1551/** 1550/**
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 449e0776a2c0..6f5e1dd3be2d 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -61,11 +61,11 @@
61 61
62int ovs_net_id __read_mostly; 62int ovs_net_id __read_mostly;
63 63
64static void ovs_notify(struct sk_buff *skb, struct genl_info *info, 64static void ovs_notify(struct genl_family *family,
65 struct genl_multicast_group *grp) 65 struct sk_buff *skb, struct genl_info *info)
66{ 66{
67 genl_notify(skb, genl_info_net(info), info->snd_portid, 67 genl_notify(family, skb, genl_info_net(info), info->snd_portid,
68 grp->id, info->nlhdr, GFP_KERNEL); 68 0, info->nlhdr, GFP_KERNEL);
69} 69}
70 70
71/** 71/**
@@ -557,7 +557,7 @@ static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
557 [OVS_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED }, 557 [OVS_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED },
558}; 558};
559 559
560static struct genl_ops dp_packet_genl_ops[] = { 560static const struct genl_ops dp_packet_genl_ops[] = {
561 { .cmd = OVS_PACKET_CMD_EXECUTE, 561 { .cmd = OVS_PACKET_CMD_EXECUTE,
562 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 562 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
563 .policy = packet_policy, 563 .policy = packet_policy,
@@ -877,10 +877,10 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
877 ovs_unlock(); 877 ovs_unlock();
878 878
879 if (!IS_ERR(reply)) 879 if (!IS_ERR(reply))
880 ovs_notify(reply, info, &ovs_dp_flow_multicast_group); 880 ovs_notify(&dp_flow_genl_family, reply, info);
881 else 881 else
882 netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 882 genl_set_err(&dp_flow_genl_family, sock_net(skb->sk), 0,
883 ovs_dp_flow_multicast_group.id, PTR_ERR(reply)); 883 0, PTR_ERR(reply));
884 return 0; 884 return 0;
885 885
886err_flow_free: 886err_flow_free:
@@ -990,7 +990,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
990 ovs_flow_free(flow, true); 990 ovs_flow_free(flow, true);
991 ovs_unlock(); 991 ovs_unlock();
992 992
993 ovs_notify(reply, info, &ovs_dp_flow_multicast_group); 993 ovs_notify(&dp_flow_genl_family, reply, info);
994 return 0; 994 return 0;
995unlock: 995unlock:
996 ovs_unlock(); 996 ovs_unlock();
@@ -1034,7 +1034,7 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
1034 return skb->len; 1034 return skb->len;
1035} 1035}
1036 1036
1037static struct genl_ops dp_flow_genl_ops[] = { 1037static const struct genl_ops dp_flow_genl_ops[] = {
1038 { .cmd = OVS_FLOW_CMD_NEW, 1038 { .cmd = OVS_FLOW_CMD_NEW,
1039 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1039 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1040 .policy = flow_policy, 1040 .policy = flow_policy,
@@ -1243,7 +1243,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
1243 1243
1244 ovs_unlock(); 1244 ovs_unlock();
1245 1245
1246 ovs_notify(reply, info, &ovs_dp_datapath_multicast_group); 1246 ovs_notify(&dp_datapath_genl_family, reply, info);
1247 return 0; 1247 return 0;
1248 1248
1249err_destroy_local_port: 1249err_destroy_local_port:
@@ -1308,7 +1308,7 @@ static int ovs_dp_cmd_del(struct sk_buff *skb, struct genl_info *info)
1308 __dp_destroy(dp); 1308 __dp_destroy(dp);
1309 ovs_unlock(); 1309 ovs_unlock();
1310 1310
1311 ovs_notify(reply, info, &ovs_dp_datapath_multicast_group); 1311 ovs_notify(&dp_datapath_genl_family, reply, info);
1312 1312
1313 return 0; 1313 return 0;
1314unlock: 1314unlock:
@@ -1332,14 +1332,14 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct genl_info *info)
1332 info->snd_seq, OVS_DP_CMD_NEW); 1332 info->snd_seq, OVS_DP_CMD_NEW);
1333 if (IS_ERR(reply)) { 1333 if (IS_ERR(reply)) {
1334 err = PTR_ERR(reply); 1334 err = PTR_ERR(reply);
1335 netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 1335 genl_set_err(&dp_datapath_genl_family, sock_net(skb->sk), 0,
1336 ovs_dp_datapath_multicast_group.id, err); 1336 0, err);
1337 err = 0; 1337 err = 0;
1338 goto unlock; 1338 goto unlock;
1339 } 1339 }
1340 1340
1341 ovs_unlock(); 1341 ovs_unlock();
1342 ovs_notify(reply, info, &ovs_dp_datapath_multicast_group); 1342 ovs_notify(&dp_datapath_genl_family, reply, info);
1343 1343
1344 return 0; 1344 return 0;
1345unlock: 1345unlock:
@@ -1398,7 +1398,7 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
1398 return skb->len; 1398 return skb->len;
1399} 1399}
1400 1400
1401static struct genl_ops dp_datapath_genl_ops[] = { 1401static const struct genl_ops dp_datapath_genl_ops[] = {
1402 { .cmd = OVS_DP_CMD_NEW, 1402 { .cmd = OVS_DP_CMD_NEW,
1403 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1403 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1404 .policy = datapath_policy, 1404 .policy = datapath_policy,
@@ -1431,7 +1431,7 @@ static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
1431 [OVS_VPORT_ATTR_OPTIONS] = { .type = NLA_NESTED }, 1431 [OVS_VPORT_ATTR_OPTIONS] = { .type = NLA_NESTED },
1432}; 1432};
1433 1433
1434static struct genl_family dp_vport_genl_family = { 1434struct genl_family dp_vport_genl_family = {
1435 .id = GENL_ID_GENERATE, 1435 .id = GENL_ID_GENERATE,
1436 .hdrsize = sizeof(struct ovs_header), 1436 .hdrsize = sizeof(struct ovs_header),
1437 .name = OVS_VPORT_FAMILY, 1437 .name = OVS_VPORT_FAMILY,
@@ -1601,7 +1601,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
1601 goto exit_unlock; 1601 goto exit_unlock;
1602 } 1602 }
1603 1603
1604 ovs_notify(reply, info, &ovs_dp_vport_multicast_group); 1604 ovs_notify(&dp_vport_genl_family, reply, info);
1605 1605
1606exit_unlock: 1606exit_unlock:
1607 ovs_unlock(); 1607 ovs_unlock();
@@ -1648,7 +1648,7 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
1648 BUG_ON(err < 0); 1648 BUG_ON(err < 0);
1649 1649
1650 ovs_unlock(); 1650 ovs_unlock();
1651 ovs_notify(reply, info, &ovs_dp_vport_multicast_group); 1651 ovs_notify(&dp_vport_genl_family, reply, info);
1652 return 0; 1652 return 0;
1653 1653
1654exit_free: 1654exit_free:
@@ -1685,7 +1685,7 @@ static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info)
1685 err = 0; 1685 err = 0;
1686 ovs_dp_detach_port(vport); 1686 ovs_dp_detach_port(vport);
1687 1687
1688 ovs_notify(reply, info, &ovs_dp_vport_multicast_group); 1688 ovs_notify(&dp_vport_genl_family, reply, info);
1689 1689
1690exit_unlock: 1690exit_unlock:
1691 ovs_unlock(); 1691 ovs_unlock();
@@ -1759,7 +1759,7 @@ out:
1759 return skb->len; 1759 return skb->len;
1760} 1760}
1761 1761
1762static struct genl_ops dp_vport_genl_ops[] = { 1762static const struct genl_ops dp_vport_genl_ops[] = {
1763 { .cmd = OVS_VPORT_CMD_NEW, 1763 { .cmd = OVS_VPORT_CMD_NEW,
1764 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1764 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1765 .policy = vport_policy, 1765 .policy = vport_policy,
@@ -1785,9 +1785,9 @@ static struct genl_ops dp_vport_genl_ops[] = {
1785 1785
1786struct genl_family_and_ops { 1786struct genl_family_and_ops {
1787 struct genl_family *family; 1787 struct genl_family *family;
1788 struct genl_ops *ops; 1788 const struct genl_ops *ops;
1789 int n_ops; 1789 int n_ops;
1790 struct genl_multicast_group *group; 1790 const struct genl_multicast_group *group;
1791}; 1791};
1792 1792
1793static const struct genl_family_and_ops dp_genl_families[] = { 1793static const struct genl_family_and_ops dp_genl_families[] = {
@@ -1823,17 +1823,14 @@ static int dp_register_genl(void)
1823 for (i = 0; i < ARRAY_SIZE(dp_genl_families); i++) { 1823 for (i = 0; i < ARRAY_SIZE(dp_genl_families); i++) {
1824 const struct genl_family_and_ops *f = &dp_genl_families[i]; 1824 const struct genl_family_and_ops *f = &dp_genl_families[i];
1825 1825
1826 err = genl_register_family_with_ops(f->family, f->ops, 1826 f->family->ops = f->ops;
1827 f->n_ops); 1827 f->family->n_ops = f->n_ops;
1828 f->family->mcgrps = f->group;
1829 f->family->n_mcgrps = f->group ? 1 : 0;
1830 err = genl_register_family(f->family);
1828 if (err) 1831 if (err)
1829 goto error; 1832 goto error;
1830 n_registered++; 1833 n_registered++;
1831
1832 if (f->group) {
1833 err = genl_register_mc_group(f->family, f->group);
1834 if (err)
1835 goto error;
1836 }
1837 } 1834 }
1838 1835
1839 return 0; 1836 return 0;
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index d3d14a58aa91..4067ea41be28 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -177,6 +177,7 @@ static inline struct vport *ovs_vport_ovsl(const struct datapath *dp, int port_n
177} 177}
178 178
179extern struct notifier_block ovs_dp_device_notifier; 179extern struct notifier_block ovs_dp_device_notifier;
180extern struct genl_family dp_vport_genl_family;
180extern struct genl_multicast_group ovs_dp_vport_multicast_group; 181extern struct genl_multicast_group ovs_dp_vport_multicast_group;
181 182
182void ovs_dp_process_received_packet(struct vport *, struct sk_buff *); 183void ovs_dp_process_received_packet(struct vport *, struct sk_buff *);
diff --git a/net/openvswitch/dp_notify.c b/net/openvswitch/dp_notify.c
index 5c2dab276109..2c631fe76be1 100644
--- a/net/openvswitch/dp_notify.c
+++ b/net/openvswitch/dp_notify.c
@@ -34,15 +34,14 @@ static void dp_detach_port_notify(struct vport *vport)
34 OVS_VPORT_CMD_DEL); 34 OVS_VPORT_CMD_DEL);
35 ovs_dp_detach_port(vport); 35 ovs_dp_detach_port(vport);
36 if (IS_ERR(notify)) { 36 if (IS_ERR(notify)) {
37 netlink_set_err(ovs_dp_get_net(dp)->genl_sock, 0, 37 genl_set_err(&dp_vport_genl_family, ovs_dp_get_net(dp), 0,
38 ovs_dp_vport_multicast_group.id, 38 0, PTR_ERR(notify));
39 PTR_ERR(notify));
40 return; 39 return;
41 } 40 }
42 41
43 genlmsg_multicast_netns(ovs_dp_get_net(dp), notify, 0, 42 genlmsg_multicast_netns(&dp_vport_genl_family,
44 ovs_dp_vport_multicast_group.id, 43 ovs_dp_get_net(dp), notify, 0,
45 GFP_KERNEL); 44 0, GFP_KERNEL);
46} 45}
47 46
48void ovs_dp_notify_wq(struct work_struct *work) 47void ovs_dp_notify_wq(struct work_struct *work)
diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c
index 12c30f3e643e..38946b26e471 100644
--- a/net/phonet/datagram.c
+++ b/net/phonet/datagram.c
@@ -139,9 +139,6 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
139 MSG_CMSG_COMPAT)) 139 MSG_CMSG_COMPAT))
140 goto out_nofree; 140 goto out_nofree;
141 141
142 if (addr_len)
143 *addr_len = sizeof(sa);
144
145 skb = skb_recv_datagram(sk, flags, noblock, &rval); 142 skb = skb_recv_datagram(sk, flags, noblock, &rval);
146 if (skb == NULL) 143 if (skb == NULL)
147 goto out_nofree; 144 goto out_nofree;
@@ -162,8 +159,10 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
162 159
163 rval = (flags & MSG_TRUNC) ? skb->len : copylen; 160 rval = (flags & MSG_TRUNC) ? skb->len : copylen;
164 161
165 if (msg->msg_name != NULL) 162 if (msg->msg_name != NULL) {
166 memcpy(msg->msg_name, &sa, sizeof(struct sockaddr_pn)); 163 memcpy(msg->msg_name, &sa, sizeof(sa));
164 *addr_len = sizeof(sa);
165 }
167 166
168out: 167out:
169 skb_free_datagram(sk, skb); 168 skb_free_datagram(sk, skb);
diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c
index fdc041c57853..95d843961907 100644
--- a/net/sched/sch_fq.c
+++ b/net/sched/sch_fq.c
@@ -88,7 +88,7 @@ struct fq_sched_data {
88 struct fq_flow internal; /* for non classified or high prio packets */ 88 struct fq_flow internal; /* for non classified or high prio packets */
89 u32 quantum; 89 u32 quantum;
90 u32 initial_quantum; 90 u32 initial_quantum;
91 u32 flow_default_rate;/* rate per flow : bytes per second */ 91 u32 flow_refill_delay;
92 u32 flow_max_rate; /* optional max rate per flow */ 92 u32 flow_max_rate; /* optional max rate per flow */
93 u32 flow_plimit; /* max packets per flow */ 93 u32 flow_plimit; /* max packets per flow */
94 struct rb_root *fq_root; 94 struct rb_root *fq_root;
@@ -115,6 +115,7 @@ static struct fq_flow detached, throttled;
115static void fq_flow_set_detached(struct fq_flow *f) 115static void fq_flow_set_detached(struct fq_flow *f)
116{ 116{
117 f->next = &detached; 117 f->next = &detached;
118 f->age = jiffies;
118} 119}
119 120
120static bool fq_flow_is_detached(const struct fq_flow *f) 121static bool fq_flow_is_detached(const struct fq_flow *f)
@@ -209,21 +210,15 @@ static void fq_gc(struct fq_sched_data *q,
209 } 210 }
210} 211}
211 212
212static const u8 prio2band[TC_PRIO_MAX + 1] = {
213 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1
214};
215
216static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q) 213static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q)
217{ 214{
218 struct rb_node **p, *parent; 215 struct rb_node **p, *parent;
219 struct sock *sk = skb->sk; 216 struct sock *sk = skb->sk;
220 struct rb_root *root; 217 struct rb_root *root;
221 struct fq_flow *f; 218 struct fq_flow *f;
222 int band;
223 219
224 /* warning: no starvation prevention... */ 220 /* warning: no starvation prevention... */
225 band = prio2band[skb->priority & TC_PRIO_MAX]; 221 if (unlikely((skb->priority & TC_PRIO_MAX) == TC_PRIO_CONTROL))
226 if (unlikely(band == 0))
227 return &q->internal; 222 return &q->internal;
228 223
229 if (unlikely(!sk)) { 224 if (unlikely(!sk)) {
@@ -373,17 +368,20 @@ static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
373 } 368 }
374 369
375 f->qlen++; 370 f->qlen++;
376 flow_queue_add(f, skb);
377 if (skb_is_retransmit(skb)) 371 if (skb_is_retransmit(skb))
378 q->stat_tcp_retrans++; 372 q->stat_tcp_retrans++;
379 sch->qstats.backlog += qdisc_pkt_len(skb); 373 sch->qstats.backlog += qdisc_pkt_len(skb);
380 if (fq_flow_is_detached(f)) { 374 if (fq_flow_is_detached(f)) {
381 fq_flow_add_tail(&q->new_flows, f); 375 fq_flow_add_tail(&q->new_flows, f);
382 if (q->quantum > f->credit) 376 if (time_after(jiffies, f->age + q->flow_refill_delay))
383 f->credit = q->quantum; 377 f->credit = max_t(u32, f->credit, q->quantum);
384 q->inactive_flows--; 378 q->inactive_flows--;
385 qdisc_unthrottled(sch); 379 qdisc_unthrottled(sch);
386 } 380 }
381
382 /* Note: this overwrites f->age */
383 flow_queue_add(f, skb);
384
387 if (unlikely(f == &q->internal)) { 385 if (unlikely(f == &q->internal)) {
388 q->stat_internal_packets++; 386 q->stat_internal_packets++;
389 qdisc_unthrottled(sch); 387 qdisc_unthrottled(sch);
@@ -461,7 +459,6 @@ begin:
461 fq_flow_add_tail(&q->old_flows, f); 459 fq_flow_add_tail(&q->old_flows, f);
462 } else { 460 } else {
463 fq_flow_set_detached(f); 461 fq_flow_set_detached(f);
464 f->age = jiffies;
465 q->inactive_flows++; 462 q->inactive_flows++;
466 } 463 }
467 goto begin; 464 goto begin;
@@ -615,6 +612,7 @@ static const struct nla_policy fq_policy[TCA_FQ_MAX + 1] = {
615 [TCA_FQ_FLOW_DEFAULT_RATE] = { .type = NLA_U32 }, 612 [TCA_FQ_FLOW_DEFAULT_RATE] = { .type = NLA_U32 },
616 [TCA_FQ_FLOW_MAX_RATE] = { .type = NLA_U32 }, 613 [TCA_FQ_FLOW_MAX_RATE] = { .type = NLA_U32 },
617 [TCA_FQ_BUCKETS_LOG] = { .type = NLA_U32 }, 614 [TCA_FQ_BUCKETS_LOG] = { .type = NLA_U32 },
615 [TCA_FQ_FLOW_REFILL_DELAY] = { .type = NLA_U32 },
618}; 616};
619 617
620static int fq_change(struct Qdisc *sch, struct nlattr *opt) 618static int fq_change(struct Qdisc *sch, struct nlattr *opt)
@@ -656,7 +654,8 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt)
656 q->initial_quantum = nla_get_u32(tb[TCA_FQ_INITIAL_QUANTUM]); 654 q->initial_quantum = nla_get_u32(tb[TCA_FQ_INITIAL_QUANTUM]);
657 655
658 if (tb[TCA_FQ_FLOW_DEFAULT_RATE]) 656 if (tb[TCA_FQ_FLOW_DEFAULT_RATE])
659 q->flow_default_rate = nla_get_u32(tb[TCA_FQ_FLOW_DEFAULT_RATE]); 657 pr_warn_ratelimited("sch_fq: defrate %u ignored.\n",
658 nla_get_u32(tb[TCA_FQ_FLOW_DEFAULT_RATE]));
660 659
661 if (tb[TCA_FQ_FLOW_MAX_RATE]) 660 if (tb[TCA_FQ_FLOW_MAX_RATE])
662 q->flow_max_rate = nla_get_u32(tb[TCA_FQ_FLOW_MAX_RATE]); 661 q->flow_max_rate = nla_get_u32(tb[TCA_FQ_FLOW_MAX_RATE]);
@@ -670,6 +669,12 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt)
670 err = -EINVAL; 669 err = -EINVAL;
671 } 670 }
672 671
672 if (tb[TCA_FQ_FLOW_REFILL_DELAY]) {
673 u32 usecs_delay = nla_get_u32(tb[TCA_FQ_FLOW_REFILL_DELAY]) ;
674
675 q->flow_refill_delay = usecs_to_jiffies(usecs_delay);
676 }
677
673 if (!err) 678 if (!err)
674 err = fq_resize(q, fq_log); 679 err = fq_resize(q, fq_log);
675 680
@@ -705,7 +710,7 @@ static int fq_init(struct Qdisc *sch, struct nlattr *opt)
705 q->flow_plimit = 100; 710 q->flow_plimit = 100;
706 q->quantum = 2 * psched_mtu(qdisc_dev(sch)); 711 q->quantum = 2 * psched_mtu(qdisc_dev(sch));
707 q->initial_quantum = 10 * psched_mtu(qdisc_dev(sch)); 712 q->initial_quantum = 10 * psched_mtu(qdisc_dev(sch));
708 q->flow_default_rate = 0; 713 q->flow_refill_delay = msecs_to_jiffies(40);
709 q->flow_max_rate = ~0U; 714 q->flow_max_rate = ~0U;
710 q->rate_enable = 1; 715 q->rate_enable = 1;
711 q->new_flows.first = NULL; 716 q->new_flows.first = NULL;
@@ -732,15 +737,16 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb)
732 if (opts == NULL) 737 if (opts == NULL)
733 goto nla_put_failure; 738 goto nla_put_failure;
734 739
735 /* TCA_FQ_FLOW_DEFAULT_RATE is not used anymore, 740 /* TCA_FQ_FLOW_DEFAULT_RATE is not used anymore */
736 * do not bother giving its value 741
737 */
738 if (nla_put_u32(skb, TCA_FQ_PLIMIT, sch->limit) || 742 if (nla_put_u32(skb, TCA_FQ_PLIMIT, sch->limit) ||
739 nla_put_u32(skb, TCA_FQ_FLOW_PLIMIT, q->flow_plimit) || 743 nla_put_u32(skb, TCA_FQ_FLOW_PLIMIT, q->flow_plimit) ||
740 nla_put_u32(skb, TCA_FQ_QUANTUM, q->quantum) || 744 nla_put_u32(skb, TCA_FQ_QUANTUM, q->quantum) ||
741 nla_put_u32(skb, TCA_FQ_INITIAL_QUANTUM, q->initial_quantum) || 745 nla_put_u32(skb, TCA_FQ_INITIAL_QUANTUM, q->initial_quantum) ||
742 nla_put_u32(skb, TCA_FQ_RATE_ENABLE, q->rate_enable) || 746 nla_put_u32(skb, TCA_FQ_RATE_ENABLE, q->rate_enable) ||
743 nla_put_u32(skb, TCA_FQ_FLOW_MAX_RATE, q->flow_max_rate) || 747 nla_put_u32(skb, TCA_FQ_FLOW_MAX_RATE, q->flow_max_rate) ||
748 nla_put_u32(skb, TCA_FQ_FLOW_REFILL_DELAY,
749 jiffies_to_usecs(q->flow_refill_delay)) ||
744 nla_put_u32(skb, TCA_FQ_BUCKETS_LOG, q->fq_trees_log)) 750 nla_put_u32(skb, TCA_FQ_BUCKETS_LOG, q->fq_trees_log))
745 goto nla_put_failure; 751 goto nla_put_failure;
746 752
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index c9b91cb1cb0d..68a27f9796d2 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -907,8 +907,8 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
907 if (!first || t->last_time_heard > first->last_time_heard) { 907 if (!first || t->last_time_heard > first->last_time_heard) {
908 second = first; 908 second = first;
909 first = t; 909 first = t;
910 } 910 } else if (!second ||
911 if (!second || t->last_time_heard > second->last_time_heard) 911 t->last_time_heard > second->last_time_heard)
912 second = t; 912 second = t;
913 } 913 }
914 914
@@ -929,6 +929,8 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
929 first = asoc->peer.primary_path; 929 first = asoc->peer.primary_path;
930 } 930 }
931 931
932 if (!second)
933 second = first;
932 /* If we failed to find a usable transport, just camp on the 934 /* If we failed to find a usable transport, just camp on the
933 * primary, even if it is inactive. 935 * primary, even if it is inactive.
934 */ 936 */
diff --git a/net/tipc/link.c b/net/tipc/link.c
index cf465d66ccde..69cd9bf3f561 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -2358,7 +2358,8 @@ int tipc_link_recv_fragment(struct sk_buff **head, struct sk_buff **tail,
2358 *head = frag; 2358 *head = frag;
2359 skb_frag_list_init(*head); 2359 skb_frag_list_init(*head);
2360 return 0; 2360 return 0;
2361 } else if (skb_try_coalesce(*head, frag, &headstolen, &delta)) { 2361 } else if (*head &&
2362 skb_try_coalesce(*head, frag, &headstolen, &delta)) {
2362 kfree_skb_partial(frag, headstolen); 2363 kfree_skb_partial(frag, headstolen);
2363 } else { 2364 } else {
2364 if (!*head) 2365 if (!*head)
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 8bcd4985d0fb..9f72a6376362 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -76,9 +76,11 @@ static struct genl_family tipc_genl_family = {
76 .maxattr = 0, 76 .maxattr = 0,
77}; 77};
78 78
79static struct genl_ops tipc_genl_ops = { 79static struct genl_ops tipc_genl_ops[] = {
80 .cmd = TIPC_GENL_CMD, 80 {
81 .doit = handle_cmd, 81 .cmd = TIPC_GENL_CMD,
82 .doit = handle_cmd,
83 },
82}; 84};
83 85
84static int tipc_genl_family_registered; 86static int tipc_genl_family_registered;
@@ -87,8 +89,7 @@ int tipc_netlink_start(void)
87{ 89{
88 int res; 90 int res;
89 91
90 res = genl_register_family_with_ops(&tipc_genl_family, 92 res = genl_register_family_with_ops(&tipc_genl_family, tipc_genl_ops);
91 &tipc_genl_ops, 1);
92 if (res) { 93 if (res) {
93 pr_err("Failed to register netlink interface\n"); 94 pr_err("Failed to register netlink interface\n");
94 return res; 95 return res;
diff --git a/net/wimax/op-msg.c b/net/wimax/op-msg.c
index 0694d62e4dbc..c278b3356f75 100644
--- a/net/wimax/op-msg.c
+++ b/net/wimax/op-msg.c
@@ -279,7 +279,7 @@ int wimax_msg_send(struct wimax_dev *wimax_dev, struct sk_buff *skb)
279 279
280 d_printf(1, dev, "CTX: wimax msg, %zu bytes\n", size); 280 d_printf(1, dev, "CTX: wimax msg, %zu bytes\n", size);
281 d_dump(2, dev, msg, size); 281 d_dump(2, dev, msg, size);
282 genlmsg_multicast(skb, 0, wimax_gnl_mcg.id, GFP_KERNEL); 282 genlmsg_multicast(&wimax_gnl_family, skb, 0, 0, GFP_KERNEL);
283 d_printf(1, dev, "CTX: genl multicast done\n"); 283 d_printf(1, dev, "CTX: genl multicast done\n");
284 return 0; 284 return 0;
285} 285}
@@ -321,17 +321,6 @@ int wimax_msg(struct wimax_dev *wimax_dev, const char *pipe_name,
321} 321}
322EXPORT_SYMBOL_GPL(wimax_msg); 322EXPORT_SYMBOL_GPL(wimax_msg);
323 323
324
325static const struct nla_policy wimax_gnl_msg_policy[WIMAX_GNL_ATTR_MAX + 1] = {
326 [WIMAX_GNL_MSG_IFIDX] = {
327 .type = NLA_U32,
328 },
329 [WIMAX_GNL_MSG_DATA] = {
330 .type = NLA_UNSPEC, /* libnl doesn't grok BINARY yet */
331 },
332};
333
334
335/* 324/*
336 * Relays a message from user space to the driver 325 * Relays a message from user space to the driver
337 * 326 *
@@ -340,7 +329,6 @@ static const struct nla_policy wimax_gnl_msg_policy[WIMAX_GNL_ATTR_MAX + 1] = {
340 * 329 *
341 * This call will block while handling/relaying the message. 330 * This call will block while handling/relaying the message.
342 */ 331 */
343static
344int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info) 332int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info)
345{ 333{
346 int result, ifindex; 334 int result, ifindex;
@@ -418,16 +406,3 @@ error_no_wimax_dev:
418 return result; 406 return result;
419} 407}
420 408
421
422/*
423 * Generic Netlink glue
424 */
425
426struct genl_ops wimax_gnl_msg_from_user = {
427 .cmd = WIMAX_GNL_OP_MSG_FROM_USER,
428 .flags = GENL_ADMIN_PERM,
429 .policy = wimax_gnl_msg_policy,
430 .doit = wimax_gnl_doit_msg_from_user,
431 .dumpit = NULL,
432};
433
diff --git a/net/wimax/op-reset.c b/net/wimax/op-reset.c
index 7ceffe39d70e..eb4580784d9d 100644
--- a/net/wimax/op-reset.c
+++ b/net/wimax/op-reset.c
@@ -92,13 +92,6 @@ int wimax_reset(struct wimax_dev *wimax_dev)
92EXPORT_SYMBOL(wimax_reset); 92EXPORT_SYMBOL(wimax_reset);
93 93
94 94
95static const struct nla_policy wimax_gnl_reset_policy[WIMAX_GNL_ATTR_MAX + 1] = {
96 [WIMAX_GNL_RESET_IFIDX] = {
97 .type = NLA_U32,
98 },
99};
100
101
102/* 95/*
103 * Exporting to user space over generic netlink 96 * Exporting to user space over generic netlink
104 * 97 *
@@ -106,7 +99,6 @@ static const struct nla_policy wimax_gnl_reset_policy[WIMAX_GNL_ATTR_MAX + 1] =
106 * 99 *
107 * No attributes. 100 * No attributes.
108 */ 101 */
109static
110int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info) 102int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info)
111{ 103{
112 int result, ifindex; 104 int result, ifindex;
@@ -130,12 +122,3 @@ error_no_wimax_dev:
130 d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result); 122 d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
131 return result; 123 return result;
132} 124}
133
134
135struct genl_ops wimax_gnl_reset = {
136 .cmd = WIMAX_GNL_OP_RESET,
137 .flags = GENL_ADMIN_PERM,
138 .policy = wimax_gnl_reset_policy,
139 .doit = wimax_gnl_doit_reset,
140 .dumpit = NULL,
141};
diff --git a/net/wimax/op-rfkill.c b/net/wimax/op-rfkill.c
index 7ab60babdd22..403078d670a9 100644
--- a/net/wimax/op-rfkill.c
+++ b/net/wimax/op-rfkill.c
@@ -411,17 +411,6 @@ void wimax_rfkill_rm(struct wimax_dev *wimax_dev)
411 * just query). 411 * just query).
412 */ 412 */
413 413
414static const struct nla_policy wimax_gnl_rfkill_policy[WIMAX_GNL_ATTR_MAX + 1] = {
415 [WIMAX_GNL_RFKILL_IFIDX] = {
416 .type = NLA_U32,
417 },
418 [WIMAX_GNL_RFKILL_STATE] = {
419 .type = NLA_U32 /* enum wimax_rf_state */
420 },
421};
422
423
424static
425int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info) 414int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info)
426{ 415{
427 int result, ifindex; 416 int result, ifindex;
@@ -457,13 +446,3 @@ error_no_wimax_dev:
457 d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result); 446 d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
458 return result; 447 return result;
459} 448}
460
461
462struct genl_ops wimax_gnl_rfkill = {
463 .cmd = WIMAX_GNL_OP_RFKILL,
464 .flags = GENL_ADMIN_PERM,
465 .policy = wimax_gnl_rfkill_policy,
466 .doit = wimax_gnl_doit_rfkill,
467 .dumpit = NULL,
468};
469
diff --git a/net/wimax/op-state-get.c b/net/wimax/op-state-get.c
index aff8776e2d41..995c08c827b5 100644
--- a/net/wimax/op-state-get.c
+++ b/net/wimax/op-state-get.c
@@ -33,13 +33,6 @@
33#include "debug-levels.h" 33#include "debug-levels.h"
34 34
35 35
36static const struct nla_policy wimax_gnl_state_get_policy[WIMAX_GNL_ATTR_MAX + 1] = {
37 [WIMAX_GNL_STGET_IFIDX] = {
38 .type = NLA_U32,
39 },
40};
41
42
43/* 36/*
44 * Exporting to user space over generic netlink 37 * Exporting to user space over generic netlink
45 * 38 *
@@ -48,7 +41,6 @@ static const struct nla_policy wimax_gnl_state_get_policy[WIMAX_GNL_ATTR_MAX + 1
48 * 41 *
49 * No attributes. 42 * No attributes.
50 */ 43 */
51static
52int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info) 44int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info)
53{ 45{
54 int result, ifindex; 46 int result, ifindex;
@@ -72,12 +64,3 @@ error_no_wimax_dev:
72 d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result); 64 d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
73 return result; 65 return result;
74} 66}
75
76
77struct genl_ops wimax_gnl_state_get = {
78 .cmd = WIMAX_GNL_OP_STATE_GET,
79 .flags = GENL_ADMIN_PERM,
80 .policy = wimax_gnl_state_get_policy,
81 .doit = wimax_gnl_doit_state_get,
82 .dumpit = NULL,
83};
diff --git a/net/wimax/stack.c b/net/wimax/stack.c
index a6470ac39498..ef2191b969a7 100644
--- a/net/wimax/stack.c
+++ b/net/wimax/stack.c
@@ -116,8 +116,9 @@ struct sk_buff *wimax_gnl_re_state_change_alloc(
116 dev_err(dev, "RE_STCH: can't create message\n"); 116 dev_err(dev, "RE_STCH: can't create message\n");
117 goto error_new; 117 goto error_new;
118 } 118 }
119 data = genlmsg_put(report_skb, 0, wimax_gnl_mcg.id, &wimax_gnl_family, 119 /* FIXME: sending a group ID as the seq is wrong */
120 0, WIMAX_GNL_RE_STATE_CHANGE); 120 data = genlmsg_put(report_skb, 0, wimax_gnl_family.mcgrp_offset,
121 &wimax_gnl_family, 0, WIMAX_GNL_RE_STATE_CHANGE);
121 if (data == NULL) { 122 if (data == NULL) {
122 dev_err(dev, "RE_STCH: can't put data into message\n"); 123 dev_err(dev, "RE_STCH: can't put data into message\n");
123 goto error_put; 124 goto error_put;
@@ -177,7 +178,7 @@ int wimax_gnl_re_state_change_send(
177 goto out; 178 goto out;
178 } 179 }
179 genlmsg_end(report_skb, header); 180 genlmsg_end(report_skb, header);
180 genlmsg_multicast(report_skb, 0, wimax_gnl_mcg.id, GFP_KERNEL); 181 genlmsg_multicast(&wimax_gnl_family, report_skb, 0, 0, GFP_KERNEL);
181out: 182out:
182 d_fnend(3, dev, "(wimax_dev %p report_skb %p) = %d\n", 183 d_fnend(3, dev, "(wimax_dev %p report_skb %p) = %d\n",
183 wimax_dev, report_skb, result); 184 wimax_dev, report_skb, result);
@@ -402,22 +403,44 @@ void wimax_dev_init(struct wimax_dev *wimax_dev)
402} 403}
403EXPORT_SYMBOL_GPL(wimax_dev_init); 404EXPORT_SYMBOL_GPL(wimax_dev_init);
404 405
405/* 406static const struct nla_policy wimax_gnl_policy[WIMAX_GNL_ATTR_MAX + 1] = {
406 * This extern is declared here because it's easier to keep track -- 407 [WIMAX_GNL_RESET_IFIDX] = { .type = NLA_U32, },
407 * both declarations are a list of the same 408 [WIMAX_GNL_RFKILL_IFIDX] = { .type = NLA_U32, },
408 */ 409 [WIMAX_GNL_RFKILL_STATE] = {
409extern struct genl_ops 410 .type = NLA_U32 /* enum wimax_rf_state */
410 wimax_gnl_msg_from_user, 411 },
411 wimax_gnl_reset, 412 [WIMAX_GNL_STGET_IFIDX] = { .type = NLA_U32, },
412 wimax_gnl_rfkill, 413 [WIMAX_GNL_MSG_IFIDX] = { .type = NLA_U32, },
413 wimax_gnl_state_get; 414 [WIMAX_GNL_MSG_DATA] = {
415 .type = NLA_UNSPEC, /* libnl doesn't grok BINARY yet */
416 },
417};
414 418
415static 419static const struct genl_ops wimax_gnl_ops[] = {
416struct genl_ops *wimax_gnl_ops[] = { 420 {
417 &wimax_gnl_msg_from_user, 421 .cmd = WIMAX_GNL_OP_MSG_FROM_USER,
418 &wimax_gnl_reset, 422 .flags = GENL_ADMIN_PERM,
419 &wimax_gnl_rfkill, 423 .policy = wimax_gnl_policy,
420 &wimax_gnl_state_get, 424 .doit = wimax_gnl_doit_msg_from_user,
425 },
426 {
427 .cmd = WIMAX_GNL_OP_RESET,
428 .flags = GENL_ADMIN_PERM,
429 .policy = wimax_gnl_policy,
430 .doit = wimax_gnl_doit_reset,
431 },
432 {
433 .cmd = WIMAX_GNL_OP_RFKILL,
434 .flags = GENL_ADMIN_PERM,
435 .policy = wimax_gnl_policy,
436 .doit = wimax_gnl_doit_rfkill,
437 },
438 {
439 .cmd = WIMAX_GNL_OP_STATE_GET,
440 .flags = GENL_ADMIN_PERM,
441 .policy = wimax_gnl_policy,
442 .doit = wimax_gnl_doit_state_get,
443 },
421}; 444};
422 445
423 446
@@ -557,8 +580,8 @@ struct genl_family wimax_gnl_family = {
557 .maxattr = WIMAX_GNL_ATTR_MAX, 580 .maxattr = WIMAX_GNL_ATTR_MAX,
558}; 581};
559 582
560struct genl_multicast_group wimax_gnl_mcg = { 583static const struct genl_multicast_group wimax_gnl_mcgrps[] = {
561 .name = "msg", 584 { .name = "msg", },
562}; 585};
563 586
564 587
@@ -567,7 +590,7 @@ struct genl_multicast_group wimax_gnl_mcg = {
567static 590static
568int __init wimax_subsys_init(void) 591int __init wimax_subsys_init(void)
569{ 592{
570 int result, cnt; 593 int result;
571 594
572 d_fnstart(4, NULL, "()\n"); 595 d_fnstart(4, NULL, "()\n");
573 d_parse_params(D_LEVEL, D_LEVEL_SIZE, wimax_debug_params, 596 d_parse_params(D_LEVEL, D_LEVEL_SIZE, wimax_debug_params,
@@ -575,37 +598,18 @@ int __init wimax_subsys_init(void)
575 598
576 snprintf(wimax_gnl_family.name, sizeof(wimax_gnl_family.name), 599 snprintf(wimax_gnl_family.name, sizeof(wimax_gnl_family.name),
577 "WiMAX"); 600 "WiMAX");
578 result = genl_register_family(&wimax_gnl_family); 601 result = genl_register_family_with_ops_groups(&wimax_gnl_family,
602 wimax_gnl_ops,
603 wimax_gnl_mcgrps);
579 if (unlikely(result < 0)) { 604 if (unlikely(result < 0)) {
580 printk(KERN_ERR "cannot register generic netlink family: %d\n", 605 printk(KERN_ERR "cannot register generic netlink family: %d\n",
581 result); 606 result);
582 goto error_register_family; 607 goto error_register_family;
583 } 608 }
584 609
585 for (cnt = 0; cnt < ARRAY_SIZE(wimax_gnl_ops); cnt++) {
586 result = genl_register_ops(&wimax_gnl_family,
587 wimax_gnl_ops[cnt]);
588 d_printf(4, NULL, "registering generic netlink op code "
589 "%u: %d\n", wimax_gnl_ops[cnt]->cmd, result);
590 if (unlikely(result < 0)) {
591 printk(KERN_ERR "cannot register generic netlink op "
592 "code %u: %d\n",
593 wimax_gnl_ops[cnt]->cmd, result);
594 goto error_register_ops;
595 }
596 }
597
598 result = genl_register_mc_group(&wimax_gnl_family, &wimax_gnl_mcg);
599 if (result < 0)
600 goto error_mc_group;
601 d_fnend(4, NULL, "() = 0\n"); 610 d_fnend(4, NULL, "() = 0\n");
602 return 0; 611 return 0;
603 612
604error_mc_group:
605error_register_ops:
606 for (cnt--; cnt >= 0; cnt--)
607 genl_unregister_ops(&wimax_gnl_family,
608 wimax_gnl_ops[cnt]);
609 genl_unregister_family(&wimax_gnl_family); 613 genl_unregister_family(&wimax_gnl_family);
610error_register_family: 614error_register_family:
611 d_fnend(4, NULL, "() = %d\n", result); 615 d_fnend(4, NULL, "() = %d\n", result);
@@ -619,12 +623,7 @@ module_init(wimax_subsys_init);
619static 623static
620void __exit wimax_subsys_exit(void) 624void __exit wimax_subsys_exit(void)
621{ 625{
622 int cnt;
623 wimax_id_table_release(); 626 wimax_id_table_release();
624 genl_unregister_mc_group(&wimax_gnl_family, &wimax_gnl_mcg);
625 for (cnt = ARRAY_SIZE(wimax_gnl_ops) - 1; cnt >= 0; cnt--)
626 genl_unregister_ops(&wimax_gnl_family,
627 wimax_gnl_ops[cnt]);
628 genl_unregister_family(&wimax_gnl_family); 627 genl_unregister_family(&wimax_gnl_family);
629} 628}
630module_exit(wimax_subsys_exit); 629module_exit(wimax_subsys_exit);
diff --git a/net/wimax/wimax-internal.h b/net/wimax/wimax-internal.h
index 5dcd9c067bf0..b445b82020a8 100644
--- a/net/wimax/wimax-internal.h
+++ b/net/wimax/wimax-internal.h
@@ -84,8 +84,14 @@ void wimax_id_table_release(void);
84int wimax_rfkill_add(struct wimax_dev *); 84int wimax_rfkill_add(struct wimax_dev *);
85void wimax_rfkill_rm(struct wimax_dev *); 85void wimax_rfkill_rm(struct wimax_dev *);
86 86
87/* generic netlink */
87extern struct genl_family wimax_gnl_family; 88extern struct genl_family wimax_gnl_family;
88extern struct genl_multicast_group wimax_gnl_mcg; 89
90/* ops */
91int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info);
92int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info);
93int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info);
94int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info);
89 95
90#endif /* #ifdef __KERNEL__ */ 96#endif /* #ifdef __KERNEL__ */
91#endif /* #ifndef __WIMAX_INTERNAL_H__ */ 97#endif /* #ifndef __WIMAX_INTERNAL_H__ */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index a7f4e7902104..a1eb21073176 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -30,9 +30,9 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
30 struct cfg80211_crypto_settings *settings, 30 struct cfg80211_crypto_settings *settings,
31 int cipher_limit); 31 int cipher_limit);
32 32
33static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, 33static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb,
34 struct genl_info *info); 34 struct genl_info *info);
35static void nl80211_post_doit(struct genl_ops *ops, struct sk_buff *skb, 35static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
36 struct genl_info *info); 36 struct genl_info *info);
37 37
38/* the netlink family */ 38/* the netlink family */
@@ -47,6 +47,25 @@ static struct genl_family nl80211_fam = {
47 .post_doit = nl80211_post_doit, 47 .post_doit = nl80211_post_doit,
48}; 48};
49 49
50/* multicast groups */
51enum nl80211_multicast_groups {
52 NL80211_MCGRP_CONFIG,
53 NL80211_MCGRP_SCAN,
54 NL80211_MCGRP_REGULATORY,
55 NL80211_MCGRP_MLME,
56 NL80211_MCGRP_TESTMODE /* keep last - ifdef! */
57};
58
59static const struct genl_multicast_group nl80211_mcgrps[] = {
60 [NL80211_MCGRP_CONFIG] = { .name = "config", },
61 [NL80211_MCGRP_SCAN] = { .name = "scan", },
62 [NL80211_MCGRP_REGULATORY] = { .name = "regulatory", },
63 [NL80211_MCGRP_MLME] = { .name = "mlme", },
64#ifdef CONFIG_NL80211_TESTMODE
65 [NL80211_MCGRP_TESTMODE] = { .name = "testmode", }
66#endif
67};
68
50/* returns ERR_PTR values */ 69/* returns ERR_PTR values */
51static struct wireless_dev * 70static struct wireless_dev *
52__cfg80211_wdev_from_attrs(struct net *netns, struct nlattr **attrs) 71__cfg80211_wdev_from_attrs(struct net *netns, struct nlattr **attrs)
@@ -6656,10 +6675,6 @@ static int nl80211_set_mcast_rate(struct sk_buff *skb, struct genl_info *info)
6656 6675
6657 6676
6658#ifdef CONFIG_NL80211_TESTMODE 6677#ifdef CONFIG_NL80211_TESTMODE
6659static struct genl_multicast_group nl80211_testmode_mcgrp = {
6660 .name = "testmode",
6661};
6662
6663static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) 6678static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info)
6664{ 6679{
6665 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 6680 struct cfg80211_registered_device *rdev = info->user_ptr[0];
@@ -6868,8 +6883,8 @@ void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
6868 6883
6869 nla_nest_end(skb, data); 6884 nla_nest_end(skb, data);
6870 genlmsg_end(skb, hdr); 6885 genlmsg_end(skb, hdr);
6871 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0, 6886 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), skb, 0,
6872 nl80211_testmode_mcgrp.id, gfp); 6887 NL80211_MCGRP_TESTMODE, gfp);
6873} 6888}
6874EXPORT_SYMBOL(cfg80211_testmode_event); 6889EXPORT_SYMBOL(cfg80211_testmode_event);
6875#endif 6890#endif
@@ -8851,7 +8866,7 @@ static int nl80211_crit_protocol_stop(struct sk_buff *skb,
8851#define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\ 8866#define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\
8852 NL80211_FLAG_CHECK_NETDEV_UP) 8867 NL80211_FLAG_CHECK_NETDEV_UP)
8853 8868
8854static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, 8869static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb,
8855 struct genl_info *info) 8870 struct genl_info *info)
8856{ 8871{
8857 struct cfg80211_registered_device *rdev; 8872 struct cfg80211_registered_device *rdev;
@@ -8920,7 +8935,7 @@ static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb,
8920 return 0; 8935 return 0;
8921} 8936}
8922 8937
8923static void nl80211_post_doit(struct genl_ops *ops, struct sk_buff *skb, 8938static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
8924 struct genl_info *info) 8939 struct genl_info *info)
8925{ 8940{
8926 if (info->user_ptr[1]) { 8941 if (info->user_ptr[1]) {
@@ -8937,7 +8952,7 @@ static void nl80211_post_doit(struct genl_ops *ops, struct sk_buff *skb,
8937 rtnl_unlock(); 8952 rtnl_unlock();
8938} 8953}
8939 8954
8940static struct genl_ops nl80211_ops[] = { 8955static const struct genl_ops nl80211_ops[] = {
8941 { 8956 {
8942 .cmd = NL80211_CMD_GET_WIPHY, 8957 .cmd = NL80211_CMD_GET_WIPHY,
8943 .doit = nl80211_get_wiphy, 8958 .doit = nl80211_get_wiphy,
@@ -9566,21 +9581,6 @@ static struct genl_ops nl80211_ops[] = {
9566 }, 9581 },
9567}; 9582};
9568 9583
9569static struct genl_multicast_group nl80211_mlme_mcgrp = {
9570 .name = "mlme",
9571};
9572
9573/* multicast groups */
9574static struct genl_multicast_group nl80211_config_mcgrp = {
9575 .name = "config",
9576};
9577static struct genl_multicast_group nl80211_scan_mcgrp = {
9578 .name = "scan",
9579};
9580static struct genl_multicast_group nl80211_regulatory_mcgrp = {
9581 .name = "regulatory",
9582};
9583
9584/* notification functions */ 9584/* notification functions */
9585 9585
9586void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev) 9586void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
@@ -9597,8 +9597,8 @@ void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
9597 return; 9597 return;
9598 } 9598 }
9599 9599
9600 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9600 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
9601 nl80211_config_mcgrp.id, GFP_KERNEL); 9601 NL80211_MCGRP_CONFIG, GFP_KERNEL);
9602} 9602}
9603 9603
9604static int nl80211_add_scan_req(struct sk_buff *msg, 9604static int nl80211_add_scan_req(struct sk_buff *msg,
@@ -9707,8 +9707,8 @@ void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
9707 return; 9707 return;
9708 } 9708 }
9709 9709
9710 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9710 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
9711 nl80211_scan_mcgrp.id, GFP_KERNEL); 9711 NL80211_MCGRP_SCAN, GFP_KERNEL);
9712} 9712}
9713 9713
9714void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, 9714void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
@@ -9726,8 +9726,8 @@ void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
9726 return; 9726 return;
9727 } 9727 }
9728 9728
9729 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9729 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
9730 nl80211_scan_mcgrp.id, GFP_KERNEL); 9730 NL80211_MCGRP_SCAN, GFP_KERNEL);
9731} 9731}
9732 9732
9733void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev, 9733void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
@@ -9745,8 +9745,8 @@ void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
9745 return; 9745 return;
9746 } 9746 }
9747 9747
9748 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9748 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
9749 nl80211_scan_mcgrp.id, GFP_KERNEL); 9749 NL80211_MCGRP_SCAN, GFP_KERNEL);
9750} 9750}
9751 9751
9752void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev, 9752void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
@@ -9764,8 +9764,8 @@ void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
9764 return; 9764 return;
9765 } 9765 }
9766 9766
9767 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9767 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
9768 nl80211_scan_mcgrp.id, GFP_KERNEL); 9768 NL80211_MCGRP_SCAN, GFP_KERNEL);
9769} 9769}
9770 9770
9771void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev, 9771void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
@@ -9782,8 +9782,8 @@ void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
9782 return; 9782 return;
9783 } 9783 }
9784 9784
9785 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9785 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
9786 nl80211_scan_mcgrp.id, GFP_KERNEL); 9786 NL80211_MCGRP_SCAN, GFP_KERNEL);
9787} 9787}
9788 9788
9789/* 9789/*
@@ -9837,8 +9837,8 @@ void nl80211_send_reg_change_event(struct regulatory_request *request)
9837 genlmsg_end(msg, hdr); 9837 genlmsg_end(msg, hdr);
9838 9838
9839 rcu_read_lock(); 9839 rcu_read_lock();
9840 genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, 9840 genlmsg_multicast_allns(&nl80211_fam, msg, 0,
9841 GFP_ATOMIC); 9841 NL80211_MCGRP_REGULATORY, GFP_ATOMIC);
9842 rcu_read_unlock(); 9842 rcu_read_unlock();
9843 9843
9844 return; 9844 return;
@@ -9873,8 +9873,8 @@ static void nl80211_send_mlme_event(struct cfg80211_registered_device *rdev,
9873 9873
9874 genlmsg_end(msg, hdr); 9874 genlmsg_end(msg, hdr);
9875 9875
9876 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9876 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
9877 nl80211_mlme_mcgrp.id, gfp); 9877 NL80211_MCGRP_MLME, gfp);
9878 return; 9878 return;
9879 9879
9880 nla_put_failure: 9880 nla_put_failure:
@@ -9961,8 +9961,8 @@ static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev,
9961 9961
9962 genlmsg_end(msg, hdr); 9962 genlmsg_end(msg, hdr);
9963 9963
9964 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9964 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
9965 nl80211_mlme_mcgrp.id, gfp); 9965 NL80211_MCGRP_MLME, gfp);
9966 return; 9966 return;
9967 9967
9968 nla_put_failure: 9968 nla_put_failure:
@@ -10017,8 +10017,8 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev,
10017 10017
10018 genlmsg_end(msg, hdr); 10018 genlmsg_end(msg, hdr);
10019 10019
10020 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10020 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10021 nl80211_mlme_mcgrp.id, gfp); 10021 NL80211_MCGRP_MLME, gfp);
10022 return; 10022 return;
10023 10023
10024 nla_put_failure: 10024 nla_put_failure:
@@ -10056,8 +10056,8 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
10056 10056
10057 genlmsg_end(msg, hdr); 10057 genlmsg_end(msg, hdr);
10058 10058
10059 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10059 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10060 nl80211_mlme_mcgrp.id, gfp); 10060 NL80211_MCGRP_MLME, gfp);
10061 return; 10061 return;
10062 10062
10063 nla_put_failure: 10063 nla_put_failure:
@@ -10094,8 +10094,8 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev,
10094 10094
10095 genlmsg_end(msg, hdr); 10095 genlmsg_end(msg, hdr);
10096 10096
10097 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10097 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10098 nl80211_mlme_mcgrp.id, GFP_KERNEL); 10098 NL80211_MCGRP_MLME, GFP_KERNEL);
10099 return; 10099 return;
10100 10100
10101 nla_put_failure: 10101 nla_put_failure:
@@ -10128,8 +10128,8 @@ void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev,
10128 10128
10129 genlmsg_end(msg, hdr); 10129 genlmsg_end(msg, hdr);
10130 10130
10131 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10131 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10132 nl80211_mlme_mcgrp.id, gfp); 10132 NL80211_MCGRP_MLME, gfp);
10133 return; 10133 return;
10134 10134
10135 nla_put_failure: 10135 nla_put_failure:
@@ -10169,8 +10169,8 @@ void cfg80211_notify_new_peer_candidate(struct net_device *dev, const u8 *addr,
10169 10169
10170 genlmsg_end(msg, hdr); 10170 genlmsg_end(msg, hdr);
10171 10171
10172 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10172 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10173 nl80211_mlme_mcgrp.id, gfp); 10173 NL80211_MCGRP_MLME, gfp);
10174 return; 10174 return;
10175 10175
10176 nla_put_failure: 10176 nla_put_failure:
@@ -10208,8 +10208,8 @@ void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev,
10208 10208
10209 genlmsg_end(msg, hdr); 10209 genlmsg_end(msg, hdr);
10210 10210
10211 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10211 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10212 nl80211_mlme_mcgrp.id, gfp); 10212 NL80211_MCGRP_MLME, gfp);
10213 return; 10213 return;
10214 10214
10215 nla_put_failure: 10215 nla_put_failure:
@@ -10261,8 +10261,8 @@ void nl80211_send_beacon_hint_event(struct wiphy *wiphy,
10261 genlmsg_end(msg, hdr); 10261 genlmsg_end(msg, hdr);
10262 10262
10263 rcu_read_lock(); 10263 rcu_read_lock();
10264 genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, 10264 genlmsg_multicast_allns(&nl80211_fam, msg, 0,
10265 GFP_ATOMIC); 10265 NL80211_MCGRP_REGULATORY, GFP_ATOMIC);
10266 rcu_read_unlock(); 10266 rcu_read_unlock();
10267 10267
10268 return; 10268 return;
@@ -10307,8 +10307,8 @@ static void nl80211_send_remain_on_chan_event(
10307 10307
10308 genlmsg_end(msg, hdr); 10308 genlmsg_end(msg, hdr);
10309 10309
10310 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10310 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10311 nl80211_mlme_mcgrp.id, gfp); 10311 NL80211_MCGRP_MLME, gfp);
10312 return; 10312 return;
10313 10313
10314 nla_put_failure: 10314 nla_put_failure:
@@ -10362,8 +10362,8 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
10362 return; 10362 return;
10363 } 10363 }
10364 10364
10365 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10365 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10366 nl80211_mlme_mcgrp.id, gfp); 10366 NL80211_MCGRP_MLME, gfp);
10367} 10367}
10368EXPORT_SYMBOL(cfg80211_new_sta); 10368EXPORT_SYMBOL(cfg80211_new_sta);
10369 10369
@@ -10392,8 +10392,8 @@ void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
10392 10392
10393 genlmsg_end(msg, hdr); 10393 genlmsg_end(msg, hdr);
10394 10394
10395 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10395 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10396 nl80211_mlme_mcgrp.id, gfp); 10396 NL80211_MCGRP_MLME, gfp);
10397 return; 10397 return;
10398 10398
10399 nla_put_failure: 10399 nla_put_failure:
@@ -10428,8 +10428,8 @@ void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
10428 10428
10429 genlmsg_end(msg, hdr); 10429 genlmsg_end(msg, hdr);
10430 10430
10431 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10431 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10432 nl80211_mlme_mcgrp.id, gfp); 10432 NL80211_MCGRP_MLME, gfp);
10433 return; 10433 return;
10434 10434
10435 nla_put_failure: 10435 nla_put_failure:
@@ -10590,8 +10590,8 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
10590 10590
10591 genlmsg_end(msg, hdr); 10591 genlmsg_end(msg, hdr);
10592 10592
10593 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10593 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10594 nl80211_mlme_mcgrp.id, gfp); 10594 NL80211_MCGRP_MLME, gfp);
10595 return; 10595 return;
10596 10596
10597 nla_put_failure: 10597 nla_put_failure:
@@ -10639,8 +10639,8 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
10639 10639
10640 genlmsg_end(msg, hdr); 10640 genlmsg_end(msg, hdr);
10641 10641
10642 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10642 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10643 nl80211_mlme_mcgrp.id, gfp); 10643 NL80211_MCGRP_MLME, gfp);
10644 return; 10644 return;
10645 10645
10646 nla_put_failure: 10646 nla_put_failure:
@@ -10684,8 +10684,8 @@ static void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev,
10684 10684
10685 genlmsg_end(msg, hdr); 10685 genlmsg_end(msg, hdr);
10686 10686
10687 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10687 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10688 nl80211_mlme_mcgrp.id, gfp); 10688 NL80211_MCGRP_MLME, gfp);
10689 return; 10689 return;
10690 10690
10691 nla_put_failure: 10691 nla_put_failure:
@@ -10742,8 +10742,8 @@ nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,
10742 10742
10743 genlmsg_end(msg, hdr); 10743 genlmsg_end(msg, hdr);
10744 10744
10745 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10745 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10746 nl80211_mlme_mcgrp.id, gfp); 10746 NL80211_MCGRP_MLME, gfp);
10747 return; 10747 return;
10748 10748
10749 nla_put_failure: 10749 nla_put_failure:
@@ -10789,8 +10789,8 @@ static void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
10789 10789
10790 genlmsg_end(msg, hdr); 10790 genlmsg_end(msg, hdr);
10791 10791
10792 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10792 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10793 nl80211_mlme_mcgrp.id, gfp); 10793 NL80211_MCGRP_MLME, gfp);
10794 return; 10794 return;
10795 10795
10796 nla_put_failure: 10796 nla_put_failure:
@@ -10866,8 +10866,8 @@ void cfg80211_cqm_txe_notify(struct net_device *dev,
10866 10866
10867 genlmsg_end(msg, hdr); 10867 genlmsg_end(msg, hdr);
10868 10868
10869 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10869 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10870 nl80211_mlme_mcgrp.id, gfp); 10870 NL80211_MCGRP_MLME, gfp);
10871 return; 10871 return;
10872 10872
10873 nla_put_failure: 10873 nla_put_failure:
@@ -10915,8 +10915,8 @@ nl80211_radar_notify(struct cfg80211_registered_device *rdev,
10915 10915
10916 genlmsg_end(msg, hdr); 10916 genlmsg_end(msg, hdr);
10917 10917
10918 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10918 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10919 nl80211_mlme_mcgrp.id, gfp); 10919 NL80211_MCGRP_MLME, gfp);
10920 return; 10920 return;
10921 10921
10922 nla_put_failure: 10922 nla_put_failure:
@@ -10962,8 +10962,8 @@ void cfg80211_cqm_pktloss_notify(struct net_device *dev,
10962 10962
10963 genlmsg_end(msg, hdr); 10963 genlmsg_end(msg, hdr);
10964 10964
10965 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10965 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
10966 nl80211_mlme_mcgrp.id, gfp); 10966 NL80211_MCGRP_MLME, gfp);
10967 return; 10967 return;
10968 10968
10969 nla_put_failure: 10969 nla_put_failure:
@@ -11002,8 +11002,8 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
11002 11002
11003 genlmsg_end(msg, hdr); 11003 genlmsg_end(msg, hdr);
11004 11004
11005 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 11005 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
11006 nl80211_mlme_mcgrp.id, gfp); 11006 NL80211_MCGRP_MLME, gfp);
11007 return; 11007 return;
11008 11008
11009 nla_put_failure: 11009 nla_put_failure:
@@ -11154,8 +11154,8 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
11154 11154
11155 genlmsg_end(msg, hdr); 11155 genlmsg_end(msg, hdr);
11156 11156
11157 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 11157 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
11158 nl80211_mlme_mcgrp.id, gfp); 11158 NL80211_MCGRP_MLME, gfp);
11159 return; 11159 return;
11160 11160
11161 free_msg: 11161 free_msg:
@@ -11196,8 +11196,8 @@ void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer,
11196 11196
11197 genlmsg_end(msg, hdr); 11197 genlmsg_end(msg, hdr);
11198 11198
11199 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 11199 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
11200 nl80211_mlme_mcgrp.id, gfp); 11200 NL80211_MCGRP_MLME, gfp);
11201 return; 11201 return;
11202 11202
11203 nla_put_failure: 11203 nla_put_failure:
@@ -11279,8 +11279,8 @@ void cfg80211_ft_event(struct net_device *netdev,
11279 11279
11280 genlmsg_end(msg, hdr); 11280 genlmsg_end(msg, hdr);
11281 11281
11282 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 11282 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
11283 nl80211_mlme_mcgrp.id, GFP_KERNEL); 11283 NL80211_MCGRP_MLME, GFP_KERNEL);
11284} 11284}
11285EXPORT_SYMBOL(cfg80211_ft_event); 11285EXPORT_SYMBOL(cfg80211_ft_event);
11286 11286
@@ -11329,33 +11329,11 @@ int nl80211_init(void)
11329{ 11329{
11330 int err; 11330 int err;
11331 11331
11332 err = genl_register_family_with_ops(&nl80211_fam, 11332 err = genl_register_family_with_ops_groups(&nl80211_fam, nl80211_ops,
11333 nl80211_ops, ARRAY_SIZE(nl80211_ops)); 11333 nl80211_mcgrps);
11334 if (err) 11334 if (err)
11335 return err; 11335 return err;
11336 11336
11337 err = genl_register_mc_group(&nl80211_fam, &nl80211_config_mcgrp);
11338 if (err)
11339 goto err_out;
11340
11341 err = genl_register_mc_group(&nl80211_fam, &nl80211_scan_mcgrp);
11342 if (err)
11343 goto err_out;
11344
11345 err = genl_register_mc_group(&nl80211_fam, &nl80211_regulatory_mcgrp);
11346 if (err)
11347 goto err_out;
11348
11349 err = genl_register_mc_group(&nl80211_fam, &nl80211_mlme_mcgrp);
11350 if (err)
11351 goto err_out;
11352
11353#ifdef CONFIG_NL80211_TESTMODE
11354 err = genl_register_mc_group(&nl80211_fam, &nl80211_testmode_mcgrp);
11355 if (err)
11356 goto err_out;
11357#endif
11358
11359 err = netlink_register_notifier(&nl80211_netlink_notifier); 11337 err = netlink_register_notifier(&nl80211_netlink_notifier);
11360 if (err) 11338 if (err)
11361 goto err_out; 11339 goto err_out;