aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-09 14:05:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-09 14:05:20 -0400
commitfbd01410e89a66f346ba1b3c0161e1198449b746 (patch)
tree1a3cfbb076c8b995e5f6e752c30163532dcbd781
parentfbf4432ff71b7a25bef993a5312906946d27f446 (diff)
parent9beb8bedb05c5f3a353dba62b8fa7cbbb9ec685e (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: "The iwlwifi firmware compat fix is in here as well as some other stuff: 1) Fix request socket leak introduced by BPF deadlock fix, from Eric Dumazet. 2) Fix VLAN handling with TXQs in mac80211, from Johannes Berg. 3) Missing __qdisc_drop conversions in prio and qfq schedulers, from Gao Feng. 4) Use after free in netlink nlk groups handling, from Xin Long. 5) Handle MTU update properly in ipv6 gre tunnels, from Xin Long. 6) Fix leak of ipv6 fib tables on netns teardown, from Sabrina Dubroca with follow-on fix from Eric Dumazet. 7) Need RCU and preemption disabled during generic XDP data patch, from John Fastabend" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (54 commits) bpf: make error reporting in bpf_warn_invalid_xdp_action more clear Revert "mdio_bus: Remove unneeded gpiod NULL check" bpf: devmap, use cond_resched instead of cpu_relax bpf: add support for sockmap detach programs net: rcu lock and preempt disable missing around generic xdp bpf: don't select potentially stale ri->map from buggy xdp progs net: tulip: Constify tulip_tbl net: ethernet: ti: netcp_core: no need in netif_napi_del davicom: Display proper debug level up to 6 net: phy: sfp: rename dt properties to match the binding dt-binding: net: sfp binding documentation dt-bindings: add SFF vendor prefix dt-bindings: net: don't confuse with generic PHY property ip6_tunnel: fix setting hop_limit value for ipv6 tunnel ip_tunnel: fix setting ttl and tos value in collect_md mode ipv6: fix typo in fib6_net_exit() tcp: fix a request socket leak sctp: fix missing wake ups in some situations netfilter: xt_hashlimit: fix build error caused by 64bit division netfilter: xt_hashlimit: alloc hashtable with right size ...
-rw-r--r--Documentation/devicetree/bindings/net/ethernet.txt4
-rw-r--r--Documentation/devicetree/bindings/net/sff,sfp.txt76
-rw-r--r--Documentation/devicetree/bindings/phy/phy-bindings.txt4
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt1
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c2
-rw-r--r--drivers/net/ethernet/davicom/dm9000.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/tulip.h2
-rw-r--r--drivers/net/ethernet/dec/tulip/tulip_core.c2
-rw-r--r--drivers/net/ethernet/ti/netcp_core.c1
-rw-r--r--drivers/net/phy/mdio_bus.c6
-rw-r--r--drivers/net/phy/sfp.c4
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/file.h1
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/led.c3
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c5
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c23
-rw-r--r--include/linux/bpf.h8
-rw-r--r--include/linux/skbuff.h2
-rw-r--r--include/net/mac80211.h15
-rw-r--r--include/net/netfilter/nf_conntrack.h3
-rw-r--r--include/net/netfilter/nf_nat.h1
-rw-r--r--include/uapi/linux/bpf.h4
-rw-r--r--kernel/bpf/devmap.c2
-rw-r--r--kernel/bpf/sockmap.c2
-rw-r--r--kernel/bpf/syscall.c27
-rw-r--r--kernel/bpf/verifier.c16
-rw-r--r--net/core/dev.c25
-rw-r--r--net/core/filter.c27
-rw-r--r--net/core/skbuff.c9
-rw-r--r--net/ipv4/ip_tunnel.c4
-rw-r--r--net/ipv4/netfilter/arp_tables.c1
-rw-r--r--net/ipv4/netfilter/ip_tables.c1
-rw-r--r--net/ipv4/tcp_ipv4.c6
-rw-r--r--net/ipv4/udp.c5
-rw-r--r--net/ipv6/ip6_fib.c25
-rw-r--r--net/ipv6/ip6_gre.c4
-rw-r--r--net/ipv6/ip6_tunnel.c1
-rw-r--r--net/ipv6/netfilter/ip6_tables.c1
-rw-r--r--net/ipv6/tcp_ipv6.c6
-rw-r--r--net/mac80211/agg-rx.c32
-rw-r--r--net/mac80211/agg-tx.c8
-rw-r--r--net/mac80211/ht.c24
-rw-r--r--net/mac80211/ieee80211_i.h4
-rw-r--r--net/mac80211/iface.c20
-rw-r--r--net/mac80211/mlme.c2
-rw-r--r--net/mac80211/offchannel.c2
-rw-r--r--net/mac80211/tx.c36
-rw-r--r--net/mac80211/util.c2
-rw-r--r--net/netfilter/core.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_proto_sctp.c8
-rw-r--r--net/netfilter/nf_nat_core.c146
-rw-r--r--net/netfilter/xt_hashlimit.c16
-rw-r--r--net/netlink/af_netlink.c22
-rw-r--r--net/rds/send.c10
-rw-r--r--net/sched/cls_api.c18
-rw-r--r--net/sched/sch_prio.c2
-rw-r--r--net/sched/sch_qfq.c2
-rw-r--r--net/sctp/ulpqueue.c3
-rw-r--r--net/tipc/bearer.c2
-rw-r--r--net/wireless/nl80211.c4
-rw-r--r--net/wireless/reg.c20
-rw-r--r--tools/testing/selftests/bpf/test_maps.c51
63 files changed, 537 insertions, 235 deletions
diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
index 7da86f22a13b..2974e63ba311 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -1,5 +1,9 @@
1The following properties are common to the Ethernet controllers: 1The following properties are common to the Ethernet controllers:
2 2
3NOTE: All 'phy*' properties documented below are Ethernet specific. For the
4generic PHY 'phys' property, see
5Documentation/devicetree/bindings/phy/phy-bindings.txt.
6
3- local-mac-address: array of 6 bytes, specifies the MAC address that was 7- local-mac-address: array of 6 bytes, specifies the MAC address that was
4 assigned to the network device; 8 assigned to the network device;
5- mac-address: array of 6 bytes, specifies the MAC address that was last used by 9- mac-address: array of 6 bytes, specifies the MAC address that was last used by
diff --git a/Documentation/devicetree/bindings/net/sff,sfp.txt b/Documentation/devicetree/bindings/net/sff,sfp.txt
new file mode 100644
index 000000000000..60e970ce10ee
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/sff,sfp.txt
@@ -0,0 +1,76 @@
1Small Form Factor (SFF) Committee Small Form-factor Pluggable (SFP)
2Transceiver
3
4Required properties:
5
6- compatible : must be "sff,sfp"
7
8Optional Properties:
9
10- i2c-bus : phandle of an I2C bus controller for the SFP two wire serial
11 interface
12
13- mod-def0-gpios : GPIO phandle and a specifier of the MOD-DEF0 (AKA Mod_ABS)
14 module presence input gpio signal, active (module absent) high
15
16- los-gpios : GPIO phandle and a specifier of the Receiver Loss of Signal
17 Indication input gpio signal, active (signal lost) high
18
19- tx-fault-gpios : GPIO phandle and a specifier of the Module Transmitter
20 Fault input gpio signal, active (fault condition) high
21
22- tx-disable-gpios : GPIO phandle and a specifier of the Transmitter Disable
23 output gpio signal, active (Tx disable) high
24
25- rate-select0-gpios : GPIO phandle and a specifier of the Rx Signaling Rate
26 Select (AKA RS0) output gpio signal, low: low Rx rate, high: high Rx rate
27
28- rate-select1-gpios : GPIO phandle and a specifier of the Tx Signaling Rate
29 Select (AKA RS1) output gpio signal (SFP+ only), low: low Tx rate, high:
30 high Tx rate
31
32Example #1: Direct serdes to SFP connection
33
34sfp_eth3: sfp-eth3 {
35 compatible = "sff,sfp";
36 i2c-bus = <&sfp_1g_i2c>;
37 los-gpios = <&cpm_gpio2 22 GPIO_ACTIVE_HIGH>;
38 mod-def0-gpios = <&cpm_gpio2 21 GPIO_ACTIVE_LOW>;
39 pinctrl-names = "default";
40 pinctrl-0 = <&cpm_sfp_1g_pins &cps_sfp_1g_pins>;
41 tx-disable-gpios = <&cps_gpio1 24 GPIO_ACTIVE_HIGH>;
42 tx-fault-gpios = <&cpm_gpio2 19 GPIO_ACTIVE_HIGH>;
43};
44
45&cps_emac3 {
46 phy-names = "comphy";
47 phys = <&cps_comphy5 0>;
48 sfp = <&sfp_eth3>;
49};
50
51Example #2: Serdes to PHY to SFP connection
52
53sfp_eth0: sfp-eth0 {
54 compatible = "sff,sfp";
55 i2c-bus = <&sfpp0_i2c>;
56 los-gpios = <&cps_gpio1 28 GPIO_ACTIVE_HIGH>;
57 mod-def0-gpios = <&cps_gpio1 27 GPIO_ACTIVE_LOW>;
58 pinctrl-names = "default";
59 pinctrl-0 = <&cps_sfpp0_pins>;
60 tx-disable-gpios = <&cps_gpio1 29 GPIO_ACTIVE_HIGH>;
61 tx-fault-gpios = <&cps_gpio1 26 GPIO_ACTIVE_HIGH>;
62};
63
64p0_phy: ethernet-phy@0 {
65 compatible = "ethernet-phy-ieee802.3-c45";
66 pinctrl-names = "default";
67 pinctrl-0 = <&cpm_phy0_pins &cps_phy0_pins>;
68 reg = <0>;
69 interrupt = <&cpm_gpio2 18 IRQ_TYPE_EDGE_FALLING>;
70 sfp = <&sfp_eth0>;
71};
72
73&cpm_eth0 {
74 phy = <&p0_phy>;
75 phy-mode = "10gbase-kr";
76};
diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt b/Documentation/devicetree/bindings/phy/phy-bindings.txt
index 1293c321754c..a403b81d0679 100644
--- a/Documentation/devicetree/bindings/phy/phy-bindings.txt
+++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt
@@ -34,7 +34,9 @@ PHY user node
34============= 34=============
35 35
36Required Properties: 36Required Properties:
37phys : the phandle for the PHY device (used by the PHY subsystem) 37phys : the phandle for the PHY device (used by the PHY subsystem; not to be
38 confused with the Ethernet specific 'phy' and 'phy-handle' properties,
39 see Documentation/devicetree/bindings/net/ethernet.txt for these)
38phy-names : the names of the PHY corresponding to the PHYs present in the 40phy-names : the names of the PHY corresponding to the PHYs present in the
39 *phys* phandle 41 *phys* phandle
40 42
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 401ed98cab18..5a79aeb620b3 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -292,6 +292,7 @@ schindler Schindler
292seagate Seagate Technology PLC 292seagate Seagate Technology PLC
293semtech Semtech Corporation 293semtech Semtech Corporation
294sensirion Sensirion AG 294sensirion Sensirion AG
295sff Small Form Factor Committee
295sgx SGX Sensortech 296sgx SGX Sensortech
296sharp Sharp Corporation 297sharp Sharp Corporation
297si-en Si-En Technology Ltd. 298si-en Si-En Technology Ltd.
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index 6ffd13466b8c..e97232646ba1 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -409,7 +409,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card *card)
409 return -EINVAL; 409 return -EINVAL;
410 } 410 }
411 if (len) { 411 if (len) {
412 if (!(card->flags & (channel) ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE)) 412 if (!(card->flags & (channel ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE)))
413 return 0; 413 return 0;
414 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE) 414 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE)
415 return 0; 415 return 0;
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 16fe776ddbe5..50222b7b81f3 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -65,7 +65,7 @@ MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
65 */ 65 */
66static int debug; 66static int debug;
67module_param(debug, int, 0644); 67module_param(debug, int, 0644);
68MODULE_PARM_DESC(debug, "dm9000 debug level (0-4)"); 68MODULE_PARM_DESC(debug, "dm9000 debug level (0-6)");
69 69
70/* DM9000 register address locking. 70/* DM9000 register address locking.
71 * 71 *
diff --git a/drivers/net/ethernet/dec/tulip/tulip.h b/drivers/net/ethernet/dec/tulip/tulip.h
index 38431a155f09..06660dbc44b7 100644
--- a/drivers/net/ethernet/dec/tulip/tulip.h
+++ b/drivers/net/ethernet/dec/tulip/tulip.h
@@ -515,7 +515,7 @@ void comet_timer(unsigned long data);
515extern int tulip_debug; 515extern int tulip_debug;
516extern const char * const medianame[]; 516extern const char * const medianame[];
517extern const char tulip_media_cap[]; 517extern const char tulip_media_cap[];
518extern struct tulip_chip_table tulip_tbl[]; 518extern const struct tulip_chip_table tulip_tbl[];
519void oom_timer(unsigned long data); 519void oom_timer(unsigned long data);
520extern u8 t21040_csr13[]; 520extern u8 t21040_csr13[];
521 521
diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c
index 84394b43c0a1..851b6d1f5a42 100644
--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
+++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
@@ -138,7 +138,7 @@ static void tulip_timer(unsigned long data)
138 * It is indexed via the values in 'enum chips' 138 * It is indexed via the values in 'enum chips'
139 */ 139 */
140 140
141struct tulip_chip_table tulip_tbl[] = { 141const struct tulip_chip_table tulip_tbl[] = {
142 { }, /* placeholder for array, slot unused currently */ 142 { }, /* placeholder for array, slot unused currently */
143 { }, /* placeholder for array, slot unused currently */ 143 { }, /* placeholder for array, slot unused currently */
144 144
diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index eb96a6913235..437d36289786 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2145,7 +2145,6 @@ static void netcp_delete_interface(struct netcp_device *netcp_device,
2145 2145
2146 of_node_put(netcp->node_interface); 2146 of_node_put(netcp->node_interface);
2147 unregister_netdev(ndev); 2147 unregister_netdev(ndev);
2148 netif_napi_del(&netcp->rx_napi);
2149 free_netdev(ndev); 2148 free_netdev(ndev);
2150} 2149}
2151 2150
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index b6f9fa670168..2df7b62c1a36 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -399,7 +399,8 @@ error:
399 } 399 }
400 400
401 /* Put PHYs in RESET to save power */ 401 /* Put PHYs in RESET to save power */
402 gpiod_set_value_cansleep(bus->reset_gpiod, 1); 402 if (bus->reset_gpiod)
403 gpiod_set_value_cansleep(bus->reset_gpiod, 1);
403 404
404 device_del(&bus->dev); 405 device_del(&bus->dev);
405 return err; 406 return err;
@@ -424,7 +425,8 @@ void mdiobus_unregister(struct mii_bus *bus)
424 } 425 }
425 426
426 /* Put PHYs in RESET to save power */ 427 /* Put PHYs in RESET to save power */
427 gpiod_set_value_cansleep(bus->reset_gpiod, 1); 428 if (bus->reset_gpiod)
429 gpiod_set_value_cansleep(bus->reset_gpiod, 1);
428 430
429 device_del(&bus->dev); 431 device_del(&bus->dev);
430} 432}
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index fb2cf4342f48..baee371bf767 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -58,11 +58,11 @@ enum {
58}; 58};
59 59
60static const char *gpio_of_names[] = { 60static const char *gpio_of_names[] = {
61 "moddef0", 61 "mod-def0",
62 "los", 62 "los",
63 "tx-fault", 63 "tx-fault",
64 "tx-disable", 64 "tx-disable",
65 "rate-select", 65 "rate-select0",
66}; 66};
67 67
68static const enum gpiod_flags gpio_flags[] = { 68static const enum gpiod_flags gpio_flags[] = {
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
index f1b60740e020..53ae30259989 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
@@ -159,7 +159,8 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)
159 159
160 brcmf_feat_firmware_capabilities(ifp); 160 brcmf_feat_firmware_capabilities(ifp);
161 memset(&gscan_cfg, 0, sizeof(gscan_cfg)); 161 memset(&gscan_cfg, 0, sizeof(gscan_cfg));
162 if (drvr->bus_if->chip != BRCM_CC_43430_CHIP_ID) 162 if (drvr->bus_if->chip != BRCM_CC_43430_CHIP_ID &&
163 drvr->bus_if->chip != BRCM_CC_4345_CHIP_ID)
163 brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN, 164 brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN,
164 "pfn_gscan_cfg", 165 "pfn_gscan_cfg",
165 &gscan_cfg, sizeof(gscan_cfg)); 166 &gscan_cfg, sizeof(gscan_cfg));
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index 887f6d8fc8a7..279248cd9cfb 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -378,6 +378,7 @@ enum iwl_ucode_tlv_capa {
378 IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG = (__force iwl_ucode_tlv_capa_t)80, 378 IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG = (__force iwl_ucode_tlv_capa_t)80,
379 IWL_UCODE_TLV_CAPA_LQM_SUPPORT = (__force iwl_ucode_tlv_capa_t)81, 379 IWL_UCODE_TLV_CAPA_LQM_SUPPORT = (__force iwl_ucode_tlv_capa_t)81,
380 IWL_UCODE_TLV_CAPA_TX_POWER_ACK = (__force iwl_ucode_tlv_capa_t)84, 380 IWL_UCODE_TLV_CAPA_TX_POWER_ACK = (__force iwl_ucode_tlv_capa_t)84,
381 IWL_UCODE_TLV_CAPA_LED_CMD_SUPPORT = (__force iwl_ucode_tlv_capa_t)86,
381 IWL_UCODE_TLV_CAPA_MLME_OFFLOAD = (__force iwl_ucode_tlv_capa_t)96, 382 IWL_UCODE_TLV_CAPA_MLME_OFFLOAD = (__force iwl_ucode_tlv_capa_t)96,
382 383
383 NUM_IWL_UCODE_TLV_CAPA 384 NUM_IWL_UCODE_TLV_CAPA
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/led.c b/drivers/net/wireless/intel/iwlwifi/mvm/led.c
index 005e2e7278a5..b27269504a62 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/led.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/led.c
@@ -92,7 +92,8 @@ static void iwl_mvm_send_led_fw_cmd(struct iwl_mvm *mvm, bool on)
92 92
93static void iwl_mvm_led_set(struct iwl_mvm *mvm, bool on) 93static void iwl_mvm_led_set(struct iwl_mvm *mvm, bool on)
94{ 94{
95 if (mvm->cfg->device_family >= IWL_DEVICE_FAMILY_8000) { 95 if (fw_has_capa(&mvm->fw->ucode_capa,
96 IWL_UCODE_TLV_CAPA_LED_CMD_SUPPORT)) {
96 iwl_mvm_send_led_fw_cmd(mvm, on); 97 iwl_mvm_send_led_fw_cmd(mvm, on);
97 return; 98 return;
98 } 99 }
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index c8852acc1462..6467ffac9811 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1362,8 +1362,6 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
1362 txi->control.rates, 1362 txi->control.rates,
1363 ARRAY_SIZE(txi->control.rates)); 1363 ARRAY_SIZE(txi->control.rates));
1364 1364
1365 txi->rate_driver_data[0] = channel;
1366
1367 if (skb->len >= 24 + 8 && 1365 if (skb->len >= 24 + 8 &&
1368 ieee80211_is_probe_resp(hdr->frame_control)) { 1366 ieee80211_is_probe_resp(hdr->frame_control)) {
1369 /* fake header transmission time */ 1367 /* fake header transmission time */
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 31965f0ef69d..e8f07573aed9 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -1183,7 +1183,10 @@ static void btc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
1183 } 1183 }
1184 1184
1185 /* fixed internal switch S1->WiFi, S0->BT */ 1185 /* fixed internal switch S1->WiFi, S0->BT */
1186 btcoexist->btc_write_4byte(btcoexist, 0x948, 0x0); 1186 if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
1187 btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
1188 else
1189 btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
1187 1190
1188 switch (antpos_type) { 1191 switch (antpos_type) {
1189 case BTC_ANT_WIFI_AT_MAIN: 1192 case BTC_ANT_WIFI_AT_MAIN:
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index c1eacd8352a2..b5e9877d935c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -173,6 +173,16 @@ static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist)
173 173
174u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv) 174u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
175{ 175{
176 struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
177
178 /* override ant_num / ant_path */
179 if (mod_params->ant_sel) {
180 rtlpriv->btcoexist.btc_info.ant_num =
181 (mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
182
183 rtlpriv->btcoexist.btc_info.single_ant_path =
184 (mod_params->ant_sel == 1 ? 0 : 1);
185 }
176 return rtlpriv->btcoexist.btc_info.single_ant_path; 186 return rtlpriv->btcoexist.btc_info.single_ant_path;
177} 187}
178 188
@@ -183,6 +193,7 @@ u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
183 193
184u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv) 194u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
185{ 195{
196 struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
186 u8 num; 197 u8 num;
187 198
188 if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2) 199 if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
@@ -190,6 +201,10 @@ u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
190 else 201 else
191 num = 1; 202 num = 1;
192 203
204 /* override ant_num / ant_path */
205 if (mod_params->ant_sel)
206 num = (mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1) + 1;
207
193 return num; 208 return num;
194} 209}
195 210
@@ -876,7 +891,7 @@ bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
876{ 891{
877 struct btc_coexist *btcoexist = &gl_bt_coexist; 892 struct btc_coexist *btcoexist = &gl_bt_coexist;
878 struct rtl_priv *rtlpriv = adapter; 893 struct rtl_priv *rtlpriv = adapter;
879 u8 ant_num = 2, chip_type, single_ant_path = 0; 894 u8 ant_num = 2, chip_type;
880 895
881 if (btcoexist->binded) 896 if (btcoexist->binded)
882 return false; 897 return false;
@@ -911,12 +926,6 @@ bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
911 ant_num = rtl_get_hwpg_ant_num(rtlpriv); 926 ant_num = rtl_get_hwpg_ant_num(rtlpriv);
912 exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num); 927 exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
913 928
914 /* set default antenna position to main port */
915 btcoexist->board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
916
917 single_ant_path = rtl_get_hwpg_single_ant_path(rtlpriv);
918 exhalbtc_set_single_ant_path(single_ant_path);
919
920 if (rtl_get_hwpg_package_type(rtlpriv) == 0) 929 if (rtl_get_hwpg_package_type(rtlpriv) == 0)
921 btcoexist->board_info.tfbga_package = false; 930 btcoexist->board_info.tfbga_package = false;
922 else if (rtl_get_hwpg_package_type(rtlpriv) == 1) 931 else if (rtl_get_hwpg_package_type(rtlpriv) == 1)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index c2cb1b5c094e..8390859e79e7 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -385,16 +385,16 @@ static inline void __dev_map_flush(struct bpf_map *map)
385 385
386#if defined(CONFIG_STREAM_PARSER) && defined(CONFIG_BPF_SYSCALL) 386#if defined(CONFIG_STREAM_PARSER) && defined(CONFIG_BPF_SYSCALL)
387struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key); 387struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key);
388int sock_map_attach_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type); 388int sock_map_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type);
389#else 389#else
390static inline struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key) 390static inline struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key)
391{ 391{
392 return NULL; 392 return NULL;
393} 393}
394 394
395static inline int sock_map_attach_prog(struct bpf_map *map, 395static inline int sock_map_prog(struct bpf_map *map,
396 struct bpf_prog *prog, 396 struct bpf_prog *prog,
397 u32 type) 397 u32 type)
398{ 398{
399 return -EOPNOTSUPP; 399 return -EOPNOTSUPP;
400} 400}
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f751f3b93039..72299ef00061 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -958,7 +958,7 @@ void kfree_skb(struct sk_buff *skb);
958void kfree_skb_list(struct sk_buff *segs); 958void kfree_skb_list(struct sk_buff *segs);
959void skb_tx_error(struct sk_buff *skb); 959void skb_tx_error(struct sk_buff *skb);
960void consume_skb(struct sk_buff *skb); 960void consume_skb(struct sk_buff *skb);
961void consume_stateless_skb(struct sk_buff *skb); 961void __consume_stateless_skb(struct sk_buff *skb);
962void __kfree_skb(struct sk_buff *skb); 962void __kfree_skb(struct sk_buff *skb);
963extern struct kmem_cache *skbuff_head_cache; 963extern struct kmem_cache *skbuff_head_cache;
964 964
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index f8149ca192b4..885690fa39c8 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -919,21 +919,10 @@ struct ieee80211_tx_info {
919 unsigned long jiffies; 919 unsigned long jiffies;
920 }; 920 };
921 /* NB: vif can be NULL for injected frames */ 921 /* NB: vif can be NULL for injected frames */
922 union { 922 struct ieee80211_vif *vif;
923 /* NB: vif can be NULL for injected frames */
924 struct ieee80211_vif *vif;
925
926 /* When packets are enqueued on txq it's easy
927 * to re-construct the vif pointer. There's no
928 * more space in tx_info so it can be used to
929 * store the necessary enqueue time for packet
930 * sojourn time computation.
931 */
932 codel_time_t enqueue_time;
933 };
934 struct ieee80211_key_conf *hw_key; 923 struct ieee80211_key_conf *hw_key;
935 u32 flags; 924 u32 flags;
936 /* 4 bytes free */ 925 codel_time_t enqueue_time;
937 } control; 926 } control;
938 struct { 927 struct {
939 u64 cookie; 928 u64 cookie;
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index fdc9c64a1c94..8f3bd30511de 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -17,7 +17,6 @@
17#include <linux/bitops.h> 17#include <linux/bitops.h>
18#include <linux/compiler.h> 18#include <linux/compiler.h>
19#include <linux/atomic.h> 19#include <linux/atomic.h>
20#include <linux/rhashtable.h>
21 20
22#include <linux/netfilter/nf_conntrack_tcp.h> 21#include <linux/netfilter/nf_conntrack_tcp.h>
23#include <linux/netfilter/nf_conntrack_dccp.h> 22#include <linux/netfilter/nf_conntrack_dccp.h>
@@ -77,7 +76,7 @@ struct nf_conn {
77 possible_net_t ct_net; 76 possible_net_t ct_net;
78 77
79#if IS_ENABLED(CONFIG_NF_NAT) 78#if IS_ENABLED(CONFIG_NF_NAT)
80 struct rhlist_head nat_bysource; 79 struct hlist_node nat_bysource;
81#endif 80#endif
82 /* all members below initialized via memset */ 81 /* all members below initialized via memset */
83 u8 __nfct_init_offset[0]; 82 u8 __nfct_init_offset[0];
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h
index 05c82a1a4267..b71701302e61 100644
--- a/include/net/netfilter/nf_nat.h
+++ b/include/net/netfilter/nf_nat.h
@@ -1,6 +1,5 @@
1#ifndef _NF_NAT_H 1#ifndef _NF_NAT_H
2#define _NF_NAT_H 2#define _NF_NAT_H
3#include <linux/rhashtable.h>
4#include <linux/netfilter_ipv4.h> 3#include <linux/netfilter_ipv4.h>
5#include <linux/netfilter/nf_nat.h> 4#include <linux/netfilter/nf_nat.h>
6#include <net/netfilter/nf_conntrack_tuple.h> 5#include <net/netfilter/nf_conntrack_tuple.h>
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index ba848b761cfb..43ab5c402f98 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -766,8 +766,8 @@ struct bpf_sock {
766 766
767/* User return codes for XDP prog type. 767/* User return codes for XDP prog type.
768 * A valid XDP program must return one of these defined values. All other 768 * A valid XDP program must return one of these defined values. All other
769 * return codes are reserved for future use. Unknown return codes will result 769 * return codes are reserved for future use. Unknown return codes will
770 * in packet drop. 770 * result in packet drops and a warning via bpf_warn_invalid_xdp_action().
771 */ 771 */
772enum xdp_action { 772enum xdp_action {
773 XDP_ABORTED = 0, 773 XDP_ABORTED = 0,
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index ecf9f99ecc57..959c9a07f318 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -159,7 +159,7 @@ static void dev_map_free(struct bpf_map *map)
159 unsigned long *bitmap = per_cpu_ptr(dtab->flush_needed, cpu); 159 unsigned long *bitmap = per_cpu_ptr(dtab->flush_needed, cpu);
160 160
161 while (!bitmap_empty(bitmap, dtab->map.max_entries)) 161 while (!bitmap_empty(bitmap, dtab->map.max_entries))
162 cpu_relax(); 162 cond_resched();
163 } 163 }
164 164
165 for (i = 0; i < dtab->map.max_entries; i++) { 165 for (i = 0; i < dtab->map.max_entries; i++) {
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index f6ffde9c6a68..6424ce0e4969 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -792,7 +792,7 @@ out_progs:
792 return err; 792 return err;
793} 793}
794 794
795int sock_map_attach_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type) 795int sock_map_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type)
796{ 796{
797 struct bpf_stab *stab = container_of(map, struct bpf_stab, map); 797 struct bpf_stab *stab = container_of(map, struct bpf_stab, map);
798 struct bpf_prog *orig; 798 struct bpf_prog *orig;
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 70ad8e220343..cb17e1cd1d43 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1096,10 +1096,10 @@ static int bpf_obj_get(const union bpf_attr *attr)
1096 1096
1097#define BPF_PROG_ATTACH_LAST_FIELD attach_flags 1097#define BPF_PROG_ATTACH_LAST_FIELD attach_flags
1098 1098
1099static int sockmap_get_from_fd(const union bpf_attr *attr) 1099static int sockmap_get_from_fd(const union bpf_attr *attr, bool attach)
1100{ 1100{
1101 struct bpf_prog *prog = NULL;
1101 int ufd = attr->target_fd; 1102 int ufd = attr->target_fd;
1102 struct bpf_prog *prog;
1103 struct bpf_map *map; 1103 struct bpf_map *map;
1104 struct fd f; 1104 struct fd f;
1105 int err; 1105 int err;
@@ -1109,16 +1109,20 @@ static int sockmap_get_from_fd(const union bpf_attr *attr)
1109 if (IS_ERR(map)) 1109 if (IS_ERR(map))
1110 return PTR_ERR(map); 1110 return PTR_ERR(map);
1111 1111
1112 prog = bpf_prog_get_type(attr->attach_bpf_fd, BPF_PROG_TYPE_SK_SKB); 1112 if (attach) {
1113 if (IS_ERR(prog)) { 1113 prog = bpf_prog_get_type(attr->attach_bpf_fd,
1114 fdput(f); 1114 BPF_PROG_TYPE_SK_SKB);
1115 return PTR_ERR(prog); 1115 if (IS_ERR(prog)) {
1116 fdput(f);
1117 return PTR_ERR(prog);
1118 }
1116 } 1119 }
1117 1120
1118 err = sock_map_attach_prog(map, prog, attr->attach_type); 1121 err = sock_map_prog(map, prog, attr->attach_type);
1119 if (err) { 1122 if (err) {
1120 fdput(f); 1123 fdput(f);
1121 bpf_prog_put(prog); 1124 if (prog)
1125 bpf_prog_put(prog);
1122 return err; 1126 return err;
1123 } 1127 }
1124 1128
@@ -1155,7 +1159,7 @@ static int bpf_prog_attach(const union bpf_attr *attr)
1155 break; 1159 break;
1156 case BPF_SK_SKB_STREAM_PARSER: 1160 case BPF_SK_SKB_STREAM_PARSER:
1157 case BPF_SK_SKB_STREAM_VERDICT: 1161 case BPF_SK_SKB_STREAM_VERDICT:
1158 return sockmap_get_from_fd(attr); 1162 return sockmap_get_from_fd(attr, true);
1159 default: 1163 default:
1160 return -EINVAL; 1164 return -EINVAL;
1161 } 1165 }
@@ -1204,7 +1208,10 @@ static int bpf_prog_detach(const union bpf_attr *attr)
1204 ret = cgroup_bpf_update(cgrp, NULL, attr->attach_type, false); 1208 ret = cgroup_bpf_update(cgrp, NULL, attr->attach_type, false);
1205 cgroup_put(cgrp); 1209 cgroup_put(cgrp);
1206 break; 1210 break;
1207 1211 case BPF_SK_SKB_STREAM_PARSER:
1212 case BPF_SK_SKB_STREAM_VERDICT:
1213 ret = sockmap_get_from_fd(attr, false);
1214 break;
1208 default: 1215 default:
1209 return -EINVAL; 1216 return -EINVAL;
1210 } 1217 }
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index d690c7dd1f1a..477b6932c3c1 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4203,6 +4203,22 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
4203 continue; 4203 continue;
4204 } 4204 }
4205 4205
4206 if (insn->imm == BPF_FUNC_redirect_map) {
4207 u64 addr = (unsigned long)prog;
4208 struct bpf_insn r4_ld[] = {
4209 BPF_LD_IMM64(BPF_REG_4, addr),
4210 *insn,
4211 };
4212 cnt = ARRAY_SIZE(r4_ld);
4213
4214 new_prog = bpf_patch_insn_data(env, i + delta, r4_ld, cnt);
4215 if (!new_prog)
4216 return -ENOMEM;
4217
4218 delta += cnt - 1;
4219 env->prog = prog = new_prog;
4220 insn = new_prog->insnsi + i + delta;
4221 }
4206patch_call_imm: 4222patch_call_imm:
4207 fn = prog->aux->ops->get_func_proto(insn->imm); 4223 fn = prog->aux->ops->get_func_proto(insn->imm);
4208 /* all functions that have prototype and verifier allowed 4224 /* all functions that have prototype and verifier allowed
diff --git a/net/core/dev.c b/net/core/dev.c
index 6f845e4fec17..fb766d906148 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3981,8 +3981,13 @@ static int netif_rx_internal(struct sk_buff *skb)
3981 trace_netif_rx(skb); 3981 trace_netif_rx(skb);
3982 3982
3983 if (static_key_false(&generic_xdp_needed)) { 3983 if (static_key_false(&generic_xdp_needed)) {
3984 int ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), 3984 int ret;
3985 skb); 3985
3986 preempt_disable();
3987 rcu_read_lock();
3988 ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb);
3989 rcu_read_unlock();
3990 preempt_enable();
3986 3991
3987 /* Consider XDP consuming the packet a success from 3992 /* Consider XDP consuming the packet a success from
3988 * the netdev point of view we do not want to count 3993 * the netdev point of view we do not want to count
@@ -4500,18 +4505,20 @@ static int netif_receive_skb_internal(struct sk_buff *skb)
4500 if (skb_defer_rx_timestamp(skb)) 4505 if (skb_defer_rx_timestamp(skb))
4501 return NET_RX_SUCCESS; 4506 return NET_RX_SUCCESS;
4502 4507
4503 rcu_read_lock();
4504
4505 if (static_key_false(&generic_xdp_needed)) { 4508 if (static_key_false(&generic_xdp_needed)) {
4506 int ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), 4509 int ret;
4507 skb);
4508 4510
4509 if (ret != XDP_PASS) { 4511 preempt_disable();
4510 rcu_read_unlock(); 4512 rcu_read_lock();
4513 ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb);
4514 rcu_read_unlock();
4515 preempt_enable();
4516
4517 if (ret != XDP_PASS)
4511 return NET_RX_DROP; 4518 return NET_RX_DROP;
4512 }
4513 } 4519 }
4514 4520
4521 rcu_read_lock();
4515#ifdef CONFIG_RPS 4522#ifdef CONFIG_RPS
4516 if (static_key_false(&rps_needed)) { 4523 if (static_key_false(&rps_needed)) {
4517 struct rps_dev_flow voidflow, *rflow = &voidflow; 4524 struct rps_dev_flow voidflow, *rflow = &voidflow;
diff --git a/net/core/filter.c b/net/core/filter.c
index 5912c738a7b2..3a50a9b021e2 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1794,6 +1794,7 @@ struct redirect_info {
1794 u32 flags; 1794 u32 flags;
1795 struct bpf_map *map; 1795 struct bpf_map *map;
1796 struct bpf_map *map_to_flush; 1796 struct bpf_map *map_to_flush;
1797 const struct bpf_prog *map_owner;
1797}; 1798};
1798 1799
1799static DEFINE_PER_CPU(struct redirect_info, redirect_info); 1800static DEFINE_PER_CPU(struct redirect_info, redirect_info);
@@ -1807,7 +1808,6 @@ BPF_CALL_2(bpf_redirect, u32, ifindex, u64, flags)
1807 1808
1808 ri->ifindex = ifindex; 1809 ri->ifindex = ifindex;
1809 ri->flags = flags; 1810 ri->flags = flags;
1810 ri->map = NULL;
1811 1811
1812 return TC_ACT_REDIRECT; 1812 return TC_ACT_REDIRECT;
1813} 1813}
@@ -2504,6 +2504,7 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
2504 struct bpf_prog *xdp_prog) 2504 struct bpf_prog *xdp_prog)
2505{ 2505{
2506 struct redirect_info *ri = this_cpu_ptr(&redirect_info); 2506 struct redirect_info *ri = this_cpu_ptr(&redirect_info);
2507 const struct bpf_prog *map_owner = ri->map_owner;
2507 struct bpf_map *map = ri->map; 2508 struct bpf_map *map = ri->map;
2508 u32 index = ri->ifindex; 2509 u32 index = ri->ifindex;
2509 struct net_device *fwd; 2510 struct net_device *fwd;
@@ -2511,6 +2512,15 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
2511 2512
2512 ri->ifindex = 0; 2513 ri->ifindex = 0;
2513 ri->map = NULL; 2514 ri->map = NULL;
2515 ri->map_owner = NULL;
2516
2517 /* This is really only caused by a deliberately crappy
2518 * BPF program, normally we would never hit that case,
2519 * so no need to inform someone via tracepoints either,
2520 * just bail out.
2521 */
2522 if (unlikely(map_owner != xdp_prog))
2523 return -EINVAL;
2514 2524
2515 fwd = __dev_map_lookup_elem(map, index); 2525 fwd = __dev_map_lookup_elem(map, index);
2516 if (!fwd) { 2526 if (!fwd) {
@@ -2607,6 +2617,8 @@ BPF_CALL_2(bpf_xdp_redirect, u32, ifindex, u64, flags)
2607 2617
2608 ri->ifindex = ifindex; 2618 ri->ifindex = ifindex;
2609 ri->flags = flags; 2619 ri->flags = flags;
2620 ri->map = NULL;
2621 ri->map_owner = NULL;
2610 2622
2611 return XDP_REDIRECT; 2623 return XDP_REDIRECT;
2612} 2624}
@@ -2619,7 +2631,8 @@ static const struct bpf_func_proto bpf_xdp_redirect_proto = {
2619 .arg2_type = ARG_ANYTHING, 2631 .arg2_type = ARG_ANYTHING,
2620}; 2632};
2621 2633
2622BPF_CALL_3(bpf_xdp_redirect_map, struct bpf_map *, map, u32, ifindex, u64, flags) 2634BPF_CALL_4(bpf_xdp_redirect_map, struct bpf_map *, map, u32, ifindex, u64, flags,
2635 const struct bpf_prog *, map_owner)
2623{ 2636{
2624 struct redirect_info *ri = this_cpu_ptr(&redirect_info); 2637 struct redirect_info *ri = this_cpu_ptr(&redirect_info);
2625 2638
@@ -2629,10 +2642,14 @@ BPF_CALL_3(bpf_xdp_redirect_map, struct bpf_map *, map, u32, ifindex, u64, flags
2629 ri->ifindex = ifindex; 2642 ri->ifindex = ifindex;
2630 ri->flags = flags; 2643 ri->flags = flags;
2631 ri->map = map; 2644 ri->map = map;
2645 ri->map_owner = map_owner;
2632 2646
2633 return XDP_REDIRECT; 2647 return XDP_REDIRECT;
2634} 2648}
2635 2649
2650/* Note, arg4 is hidden from users and populated by the verifier
2651 * with the right pointer.
2652 */
2636static const struct bpf_func_proto bpf_xdp_redirect_map_proto = { 2653static const struct bpf_func_proto bpf_xdp_redirect_map_proto = {
2637 .func = bpf_xdp_redirect_map, 2654 .func = bpf_xdp_redirect_map,
2638 .gpl_only = false, 2655 .gpl_only = false,
@@ -3592,7 +3609,11 @@ static bool xdp_is_valid_access(int off, int size,
3592 3609
3593void bpf_warn_invalid_xdp_action(u32 act) 3610void bpf_warn_invalid_xdp_action(u32 act)
3594{ 3611{
3595 WARN_ONCE(1, "Illegal XDP return value %u, expect packet loss\n", act); 3612 const u32 act_max = XDP_REDIRECT;
3613
3614 WARN_ONCE(1, "%s XDP return value %u, expect packet loss!\n",
3615 act > act_max ? "Illegal" : "Driver unsupported",
3616 act);
3596} 3617}
3597EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action); 3618EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action);
3598 3619
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 68065d7d383f..16982de649b9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -710,14 +710,11 @@ EXPORT_SYMBOL(consume_skb);
710 * consume_stateless_skb - free an skbuff, assuming it is stateless 710 * consume_stateless_skb - free an skbuff, assuming it is stateless
711 * @skb: buffer to free 711 * @skb: buffer to free
712 * 712 *
713 * Works like consume_skb(), but this variant assumes that all the head 713 * Alike consume_skb(), but this variant assumes that this is the last
714 * states have been already dropped. 714 * skb reference and all the head states have been already dropped
715 */ 715 */
716void consume_stateless_skb(struct sk_buff *skb) 716void __consume_stateless_skb(struct sk_buff *skb)
717{ 717{
718 if (!skb_unref(skb))
719 return;
720
721 trace_consume_skb(skb); 718 trace_consume_skb(skb);
722 skb_release_data(skb); 719 skb_release_data(skb);
723 kfree_skbmem(skb); 720 kfree_skbmem(skb);
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 129d1a3616f8..e1856bfa753d 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -618,8 +618,8 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, u8 proto)
618 ip_rt_put(rt); 618 ip_rt_put(rt);
619 goto tx_dropped; 619 goto tx_dropped;
620 } 620 }
621 iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, proto, key->tos, 621 iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, proto, tos, ttl,
622 key->ttl, df, !net_eq(tunnel->net, dev_net(dev))); 622 df, !net_eq(tunnel->net, dev_net(dev)));
623 return; 623 return;
624tx_error: 624tx_error:
625 dev->stats.tx_errors++; 625 dev->stats.tx_errors++;
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index e04457198f93..9e2770fd00be 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -629,6 +629,7 @@ static void get_counters(const struct xt_table_info *t,
629 629
630 ADD_COUNTER(counters[i], bcnt, pcnt); 630 ADD_COUNTER(counters[i], bcnt, pcnt);
631 ++i; 631 ++i;
632 cond_resched();
632 } 633 }
633 } 634 }
634} 635}
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 576cba2b57e9..39286e543ee6 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -776,6 +776,7 @@ get_counters(const struct xt_table_info *t,
776 776
777 ADD_COUNTER(counters[i], bcnt, pcnt); 777 ADD_COUNTER(counters[i], bcnt, pcnt);
778 ++i; /* macro does multi eval of i */ 778 ++i; /* macro does multi eval of i */
779 cond_resched();
779 } 780 }
780 } 781 }
781} 782}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index a63486afa7a7..d9416b5162bc 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1669,9 +1669,9 @@ process:
1669 */ 1669 */
1670 sock_hold(sk); 1670 sock_hold(sk);
1671 refcounted = true; 1671 refcounted = true;
1672 if (tcp_filter(sk, skb)) 1672 nsk = NULL;
1673 goto discard_and_relse; 1673 if (!tcp_filter(sk, skb))
1674 nsk = tcp_check_req(sk, skb, req, false); 1674 nsk = tcp_check_req(sk, skb, req, false);
1675 if (!nsk) { 1675 if (!nsk) {
1676 reqsk_put(req); 1676 reqsk_put(req);
1677 goto discard_and_relse; 1677 goto discard_and_relse;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index db1c9e78c83c..ef29df8648e4 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1397,12 +1397,15 @@ void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len)
1397 unlock_sock_fast(sk, slow); 1397 unlock_sock_fast(sk, slow);
1398 } 1398 }
1399 1399
1400 if (!skb_unref(skb))
1401 return;
1402
1400 /* In the more common cases we cleared the head states previously, 1403 /* In the more common cases we cleared the head states previously,
1401 * see __udp_queue_rcv_skb(). 1404 * see __udp_queue_rcv_skb().
1402 */ 1405 */
1403 if (unlikely(udp_skb_has_head_state(skb))) 1406 if (unlikely(udp_skb_has_head_state(skb)))
1404 skb_release_head_state(skb); 1407 skb_release_head_state(skb);
1405 consume_stateless_skb(skb); 1408 __consume_stateless_skb(skb);
1406} 1409}
1407EXPORT_SYMBOL_GPL(skb_consume_udp); 1410EXPORT_SYMBOL_GPL(skb_consume_udp);
1408 1411
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index a3b5c163325f..e5308d7cbd75 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -191,6 +191,12 @@ void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
191} 191}
192EXPORT_SYMBOL_GPL(rt6_free_pcpu); 192EXPORT_SYMBOL_GPL(rt6_free_pcpu);
193 193
194static void fib6_free_table(struct fib6_table *table)
195{
196 inetpeer_invalidate_tree(&table->tb6_peers);
197 kfree(table);
198}
199
194static void fib6_link_table(struct net *net, struct fib6_table *tb) 200static void fib6_link_table(struct net *net, struct fib6_table *tb)
195{ 201{
196 unsigned int h; 202 unsigned int h;
@@ -2022,15 +2028,22 @@ out_timer:
2022 2028
2023static void fib6_net_exit(struct net *net) 2029static void fib6_net_exit(struct net *net)
2024{ 2030{
2031 unsigned int i;
2032
2025 rt6_ifdown(net, NULL); 2033 rt6_ifdown(net, NULL);
2026 del_timer_sync(&net->ipv6.ip6_fib_timer); 2034 del_timer_sync(&net->ipv6.ip6_fib_timer);
2027 2035
2028#ifdef CONFIG_IPV6_MULTIPLE_TABLES 2036 for (i = 0; i < FIB6_TABLE_HASHSZ; i++) {
2029 inetpeer_invalidate_tree(&net->ipv6.fib6_local_tbl->tb6_peers); 2037 struct hlist_head *head = &net->ipv6.fib_table_hash[i];
2030 kfree(net->ipv6.fib6_local_tbl); 2038 struct hlist_node *tmp;
2031#endif 2039 struct fib6_table *tb;
2032 inetpeer_invalidate_tree(&net->ipv6.fib6_main_tbl->tb6_peers); 2040
2033 kfree(net->ipv6.fib6_main_tbl); 2041 hlist_for_each_entry_safe(tb, tmp, head, tb6_hlist) {
2042 hlist_del(&tb->tb6_hlist);
2043 fib6_free_table(tb);
2044 }
2045 }
2046
2034 kfree(net->ipv6.fib_table_hash); 2047 kfree(net->ipv6.fib_table_hash);
2035 kfree(net->ipv6.rt6_stats); 2048 kfree(net->ipv6.rt6_stats);
2036 fib6_notifier_exit(net); 2049 fib6_notifier_exit(net);
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 67ff2aaf5dcb..b7a72d409334 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -432,7 +432,9 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
432 } 432 }
433 break; 433 break;
434 case ICMPV6_PKT_TOOBIG: 434 case ICMPV6_PKT_TOOBIG:
435 mtu = be32_to_cpu(info) - offset; 435 mtu = be32_to_cpu(info) - offset - t->tun_hlen;
436 if (t->dev->type == ARPHRD_ETHER)
437 mtu -= ETH_HLEN;
436 if (mtu < IPV6_MIN_MTU) 438 if (mtu < IPV6_MIN_MTU)
437 mtu = IPV6_MIN_MTU; 439 mtu = IPV6_MIN_MTU;
438 t->dev->mtu = mtu; 440 t->dev->mtu = mtu;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 3a0ba2ae4b0f..10a693a19323 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1184,6 +1184,7 @@ route_lookup:
1184 init_tel_txopt(&opt, encap_limit); 1184 init_tel_txopt(&opt, encap_limit);
1185 ipv6_push_frag_opts(skb, &opt.ops, &proto); 1185 ipv6_push_frag_opts(skb, &opt.ops, &proto);
1186 } 1186 }
1187 hop_limit = hop_limit ? : ip6_dst_hoplimit(dst);
1187 1188
1188 /* Calculate max headroom for all the headers and adjust 1189 /* Calculate max headroom for all the headers and adjust
1189 * needed_headroom if necessary. 1190 * needed_headroom if necessary.
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 54b1e75eded1..01bd3ee5ebc6 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -795,6 +795,7 @@ get_counters(const struct xt_table_info *t,
795 795
796 ADD_COUNTER(counters[i], bcnt, pcnt); 796 ADD_COUNTER(counters[i], bcnt, pcnt);
797 ++i; 797 ++i;
798 cond_resched();
798 } 799 }
799 } 800 }
800} 801}
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 38f76d8b231e..64d94afa427f 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1460,9 +1460,9 @@ process:
1460 } 1460 }
1461 sock_hold(sk); 1461 sock_hold(sk);
1462 refcounted = true; 1462 refcounted = true;
1463 if (tcp_filter(sk, skb)) 1463 nsk = NULL;
1464 goto discard_and_relse; 1464 if (!tcp_filter(sk, skb))
1465 nsk = tcp_check_req(sk, skb, req, false); 1465 nsk = tcp_check_req(sk, skb, req, false);
1466 if (!nsk) { 1466 if (!nsk) {
1467 reqsk_put(req); 1467 reqsk_put(req);
1468 goto discard_and_relse; 1468 goto discard_and_relse;
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c
index 2b36eff5d97e..2849a1fc41c5 100644
--- a/net/mac80211/agg-rx.c
+++ b/net/mac80211/agg-rx.c
@@ -245,10 +245,10 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d
245 ieee80211_tx_skb(sdata, skb); 245 ieee80211_tx_skb(sdata, skb);
246} 246}
247 247
248void __ieee80211_start_rx_ba_session(struct sta_info *sta, 248void ___ieee80211_start_rx_ba_session(struct sta_info *sta,
249 u8 dialog_token, u16 timeout, 249 u8 dialog_token, u16 timeout,
250 u16 start_seq_num, u16 ba_policy, u16 tid, 250 u16 start_seq_num, u16 ba_policy, u16 tid,
251 u16 buf_size, bool tx, bool auto_seq) 251 u16 buf_size, bool tx, bool auto_seq)
252{ 252{
253 struct ieee80211_local *local = sta->sdata->local; 253 struct ieee80211_local *local = sta->sdata->local;
254 struct tid_ampdu_rx *tid_agg_rx; 254 struct tid_ampdu_rx *tid_agg_rx;
@@ -267,7 +267,7 @@ void __ieee80211_start_rx_ba_session(struct sta_info *sta,
267 ht_dbg(sta->sdata, 267 ht_dbg(sta->sdata,
268 "STA %pM requests BA session on unsupported tid %d\n", 268 "STA %pM requests BA session on unsupported tid %d\n",
269 sta->sta.addr, tid); 269 sta->sta.addr, tid);
270 goto end_no_lock; 270 goto end;
271 } 271 }
272 272
273 if (!sta->sta.ht_cap.ht_supported) { 273 if (!sta->sta.ht_cap.ht_supported) {
@@ -275,14 +275,14 @@ void __ieee80211_start_rx_ba_session(struct sta_info *sta,
275 "STA %pM erroneously requests BA session on tid %d w/o QoS\n", 275 "STA %pM erroneously requests BA session on tid %d w/o QoS\n",
276 sta->sta.addr, tid); 276 sta->sta.addr, tid);
277 /* send a response anyway, it's an error case if we get here */ 277 /* send a response anyway, it's an error case if we get here */
278 goto end_no_lock; 278 goto end;
279 } 279 }
280 280
281 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) { 281 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
282 ht_dbg(sta->sdata, 282 ht_dbg(sta->sdata,
283 "Suspend in progress - Denying ADDBA request (%pM tid %d)\n", 283 "Suspend in progress - Denying ADDBA request (%pM tid %d)\n",
284 sta->sta.addr, tid); 284 sta->sta.addr, tid);
285 goto end_no_lock; 285 goto end;
286 } 286 }
287 287
288 /* sanity check for incoming parameters: 288 /* sanity check for incoming parameters:
@@ -296,7 +296,7 @@ void __ieee80211_start_rx_ba_session(struct sta_info *sta,
296 ht_dbg_ratelimited(sta->sdata, 296 ht_dbg_ratelimited(sta->sdata,
297 "AddBA Req with bad params from %pM on tid %u. policy %d, buffer size %d\n", 297 "AddBA Req with bad params from %pM on tid %u. policy %d, buffer size %d\n",
298 sta->sta.addr, tid, ba_policy, buf_size); 298 sta->sta.addr, tid, ba_policy, buf_size);
299 goto end_no_lock; 299 goto end;
300 } 300 }
301 /* determine default buffer size */ 301 /* determine default buffer size */
302 if (buf_size == 0) 302 if (buf_size == 0)
@@ -311,7 +311,7 @@ void __ieee80211_start_rx_ba_session(struct sta_info *sta,
311 buf_size, sta->sta.addr); 311 buf_size, sta->sta.addr);
312 312
313 /* examine state machine */ 313 /* examine state machine */
314 mutex_lock(&sta->ampdu_mlme.mtx); 314 lockdep_assert_held(&sta->ampdu_mlme.mtx);
315 315
316 if (test_bit(tid, sta->ampdu_mlme.agg_session_valid)) { 316 if (test_bit(tid, sta->ampdu_mlme.agg_session_valid)) {
317 if (sta->ampdu_mlme.tid_rx_token[tid] == dialog_token) { 317 if (sta->ampdu_mlme.tid_rx_token[tid] == dialog_token) {
@@ -415,15 +415,25 @@ end:
415 __clear_bit(tid, sta->ampdu_mlme.unexpected_agg); 415 __clear_bit(tid, sta->ampdu_mlme.unexpected_agg);
416 sta->ampdu_mlme.tid_rx_token[tid] = dialog_token; 416 sta->ampdu_mlme.tid_rx_token[tid] = dialog_token;
417 } 417 }
418 mutex_unlock(&sta->ampdu_mlme.mtx);
419 418
420end_no_lock:
421 if (tx) 419 if (tx)
422 ieee80211_send_addba_resp(sta->sdata, sta->sta.addr, tid, 420 ieee80211_send_addba_resp(sta->sdata, sta->sta.addr, tid,
423 dialog_token, status, 1, buf_size, 421 dialog_token, status, 1, buf_size,
424 timeout); 422 timeout);
425} 423}
426 424
425void __ieee80211_start_rx_ba_session(struct sta_info *sta,
426 u8 dialog_token, u16 timeout,
427 u16 start_seq_num, u16 ba_policy, u16 tid,
428 u16 buf_size, bool tx, bool auto_seq)
429{
430 mutex_lock(&sta->ampdu_mlme.mtx);
431 ___ieee80211_start_rx_ba_session(sta, dialog_token, timeout,
432 start_seq_num, ba_policy, tid,
433 buf_size, tx, auto_seq);
434 mutex_unlock(&sta->ampdu_mlme.mtx);
435}
436
427void ieee80211_process_addba_request(struct ieee80211_local *local, 437void ieee80211_process_addba_request(struct ieee80211_local *local,
428 struct sta_info *sta, 438 struct sta_info *sta,
429 struct ieee80211_mgmt *mgmt, 439 struct ieee80211_mgmt *mgmt,
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index cbd48762256c..bef516ec47f9 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -226,7 +226,11 @@ ieee80211_agg_start_txq(struct sta_info *sta, int tid, bool enable)
226 clear_bit(IEEE80211_TXQ_AMPDU, &txqi->flags); 226 clear_bit(IEEE80211_TXQ_AMPDU, &txqi->flags);
227 227
228 clear_bit(IEEE80211_TXQ_STOP, &txqi->flags); 228 clear_bit(IEEE80211_TXQ_STOP, &txqi->flags);
229 local_bh_disable();
230 rcu_read_lock();
229 drv_wake_tx_queue(sta->sdata->local, txqi); 231 drv_wake_tx_queue(sta->sdata->local, txqi);
232 rcu_read_unlock();
233 local_bh_enable();
230} 234}
231 235
232/* 236/*
@@ -436,7 +440,7 @@ static void sta_addba_resp_timer_expired(unsigned long data)
436 test_bit(HT_AGG_STATE_RESPONSE_RECEIVED, &tid_tx->state)) { 440 test_bit(HT_AGG_STATE_RESPONSE_RECEIVED, &tid_tx->state)) {
437 rcu_read_unlock(); 441 rcu_read_unlock();
438 ht_dbg(sta->sdata, 442 ht_dbg(sta->sdata,
439 "timer expired on %pM tid %d but we are not (or no longer) expecting addBA response there\n", 443 "timer expired on %pM tid %d not expecting addBA response\n",
440 sta->sta.addr, tid); 444 sta->sta.addr, tid);
441 return; 445 return;
442 } 446 }
@@ -639,7 +643,7 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid,
639 time_before(jiffies, sta->ampdu_mlme.last_addba_req_time[tid] + 643 time_before(jiffies, sta->ampdu_mlme.last_addba_req_time[tid] +
640 HT_AGG_RETRIES_PERIOD)) { 644 HT_AGG_RETRIES_PERIOD)) {
641 ht_dbg(sdata, 645 ht_dbg(sdata,
642 "BA request denied - waiting a grace period after %d failed requests on %pM tid %u\n", 646 "BA request denied - %d failed requests on %pM tid %u\n",
643 sta->ampdu_mlme.addba_req_num[tid], sta->sta.addr, tid); 647 sta->ampdu_mlme.addba_req_num[tid], sta->sta.addr, tid);
644 ret = -EBUSY; 648 ret = -EBUSY;
645 goto err_unlock_sta; 649 goto err_unlock_sta;
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index c92df492e898..d6d0b4201e40 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -300,6 +300,24 @@ void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
300 300
301 /* stopping might queue the work again - so cancel only afterwards */ 301 /* stopping might queue the work again - so cancel only afterwards */
302 cancel_work_sync(&sta->ampdu_mlme.work); 302 cancel_work_sync(&sta->ampdu_mlme.work);
303
304 /*
305 * In case the tear down is part of a reconfigure due to HW restart
306 * request, it is possible that the low level driver requested to stop
307 * the BA session, so handle it to properly clean tid_tx data.
308 */
309 mutex_lock(&sta->ampdu_mlme.mtx);
310 for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
311 struct tid_ampdu_tx *tid_tx =
312 rcu_dereference_protected_tid_tx(sta, i);
313
314 if (!tid_tx)
315 continue;
316
317 if (test_and_clear_bit(HT_AGG_STATE_STOP_CB, &tid_tx->state))
318 ieee80211_stop_tx_ba_cb(sta, i, tid_tx);
319 }
320 mutex_unlock(&sta->ampdu_mlme.mtx);
303} 321}
304 322
305void ieee80211_ba_session_work(struct work_struct *work) 323void ieee80211_ba_session_work(struct work_struct *work)
@@ -333,9 +351,9 @@ void ieee80211_ba_session_work(struct work_struct *work)
333 351
334 if (test_and_clear_bit(tid, 352 if (test_and_clear_bit(tid,
335 sta->ampdu_mlme.tid_rx_manage_offl)) 353 sta->ampdu_mlme.tid_rx_manage_offl))
336 __ieee80211_start_rx_ba_session(sta, 0, 0, 0, 1, tid, 354 ___ieee80211_start_rx_ba_session(sta, 0, 0, 0, 1, tid,
337 IEEE80211_MAX_AMPDU_BUF, 355 IEEE80211_MAX_AMPDU_BUF,
338 false, true); 356 false, true);
339 357
340 if (test_and_clear_bit(tid + IEEE80211_NUM_TIDS, 358 if (test_and_clear_bit(tid + IEEE80211_NUM_TIDS,
341 sta->ampdu_mlme.tid_rx_manage_offl)) 359 sta->ampdu_mlme.tid_rx_manage_offl))
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 2197c62a0a6e..9675814f64db 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1760,6 +1760,10 @@ void __ieee80211_start_rx_ba_session(struct sta_info *sta,
1760 u8 dialog_token, u16 timeout, 1760 u8 dialog_token, u16 timeout,
1761 u16 start_seq_num, u16 ba_policy, u16 tid, 1761 u16 start_seq_num, u16 ba_policy, u16 tid,
1762 u16 buf_size, bool tx, bool auto_seq); 1762 u16 buf_size, bool tx, bool auto_seq);
1763void ___ieee80211_start_rx_ba_session(struct sta_info *sta,
1764 u8 dialog_token, u16 timeout,
1765 u16 start_seq_num, u16 ba_policy, u16 tid,
1766 u16 buf_size, bool tx, bool auto_seq);
1763void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta, 1767void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
1764 enum ieee80211_agg_stop_reason reason); 1768 enum ieee80211_agg_stop_reason reason);
1765void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, 1769void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 9228ac73c429..f75029abf728 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -731,7 +731,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
731 sdata->vif.type == NL80211_IFTYPE_AP_VLAN || 731 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
732 local->ops->wake_tx_queue) { 732 local->ops->wake_tx_queue) {
733 /* XXX: for AP_VLAN, actually track AP queues */ 733 /* XXX: for AP_VLAN, actually track AP queues */
734 netif_tx_start_all_queues(dev); 734 if (dev)
735 netif_tx_start_all_queues(dev);
735 } else if (dev) { 736 } else if (dev) {
736 unsigned long flags; 737 unsigned long flags;
737 int n_acs = IEEE80211_NUM_ACS; 738 int n_acs = IEEE80211_NUM_ACS;
@@ -792,6 +793,7 @@ static int ieee80211_open(struct net_device *dev)
792static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, 793static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
793 bool going_down) 794 bool going_down)
794{ 795{
796 struct ieee80211_sub_if_data *txq_sdata = sdata;
795 struct ieee80211_local *local = sdata->local; 797 struct ieee80211_local *local = sdata->local;
796 struct fq *fq = &local->fq; 798 struct fq *fq = &local->fq;
797 unsigned long flags; 799 unsigned long flags;
@@ -937,6 +939,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
937 939
938 switch (sdata->vif.type) { 940 switch (sdata->vif.type) {
939 case NL80211_IFTYPE_AP_VLAN: 941 case NL80211_IFTYPE_AP_VLAN:
942 txq_sdata = container_of(sdata->bss,
943 struct ieee80211_sub_if_data, u.ap);
944
940 mutex_lock(&local->mtx); 945 mutex_lock(&local->mtx);
941 list_del(&sdata->u.vlan.list); 946 list_del(&sdata->u.vlan.list);
942 mutex_unlock(&local->mtx); 947 mutex_unlock(&local->mtx);
@@ -1007,8 +1012,17 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
1007 } 1012 }
1008 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 1013 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
1009 1014
1010 if (sdata->vif.txq) { 1015 if (txq_sdata->vif.txq) {
1011 struct txq_info *txqi = to_txq_info(sdata->vif.txq); 1016 struct txq_info *txqi = to_txq_info(txq_sdata->vif.txq);
1017
1018 /*
1019 * FIXME FIXME
1020 *
1021 * We really shouldn't purge the *entire* txqi since that
1022 * contains frames for the other AP_VLANs (and possibly
1023 * the AP itself) as well, but there's no API in FQ now
1024 * to be able to filter.
1025 */
1012 1026
1013 spin_lock_bh(&fq->lock); 1027 spin_lock_bh(&fq->lock);
1014 ieee80211_txq_purge(local, txqi); 1028 ieee80211_txq_purge(local, txqi);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index b588e593b0ec..3b8e2709d8de 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -3155,7 +3155,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
3155 if (len < 24 + 6) 3155 if (len < 24 + 6)
3156 return; 3156 return;
3157 3157
3158 reassoc = ieee80211_is_reassoc_req(mgmt->frame_control); 3158 reassoc = ieee80211_is_reassoc_resp(mgmt->frame_control);
3159 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); 3159 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
3160 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); 3160 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
3161 aid = le16_to_cpu(mgmt->u.assoc_resp.aid); 3161 aid = le16_to_cpu(mgmt->u.assoc_resp.aid);
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index f8e7a8bbc618..faf4f6055000 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -707,6 +707,8 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
707 if (!cookie) 707 if (!cookie)
708 return -ENOENT; 708 return -ENOENT;
709 709
710 flush_work(&local->hw_roc_start);
711
710 mutex_lock(&local->mtx); 712 mutex_lock(&local->mtx);
711 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) { 713 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
712 if (!mgmt_tx && roc->cookie != cookie) 714 if (!mgmt_tx && roc->cookie != cookie)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 8858f4f185e9..94826680cf2b 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1276,11 +1276,6 @@ static void ieee80211_set_skb_enqueue_time(struct sk_buff *skb)
1276 IEEE80211_SKB_CB(skb)->control.enqueue_time = codel_get_time(); 1276 IEEE80211_SKB_CB(skb)->control.enqueue_time = codel_get_time();
1277} 1277}
1278 1278
1279static void ieee80211_set_skb_vif(struct sk_buff *skb, struct txq_info *txqi)
1280{
1281 IEEE80211_SKB_CB(skb)->control.vif = txqi->txq.vif;
1282}
1283
1284static u32 codel_skb_len_func(const struct sk_buff *skb) 1279static u32 codel_skb_len_func(const struct sk_buff *skb)
1285{ 1280{
1286 return skb->len; 1281 return skb->len;
@@ -3414,6 +3409,7 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
3414 struct ieee80211_tx_info *info; 3409 struct ieee80211_tx_info *info;
3415 struct ieee80211_tx_data tx; 3410 struct ieee80211_tx_data tx;
3416 ieee80211_tx_result r; 3411 ieee80211_tx_result r;
3412 struct ieee80211_vif *vif;
3417 3413
3418 spin_lock_bh(&fq->lock); 3414 spin_lock_bh(&fq->lock);
3419 3415
@@ -3430,8 +3426,6 @@ begin:
3430 if (!skb) 3426 if (!skb)
3431 goto out; 3427 goto out;
3432 3428
3433 ieee80211_set_skb_vif(skb, txqi);
3434
3435 hdr = (struct ieee80211_hdr *)skb->data; 3429 hdr = (struct ieee80211_hdr *)skb->data;
3436 info = IEEE80211_SKB_CB(skb); 3430 info = IEEE80211_SKB_CB(skb);
3437 3431
@@ -3488,6 +3482,34 @@ begin:
3488 } 3482 }
3489 } 3483 }
3490 3484
3485 switch (tx.sdata->vif.type) {
3486 case NL80211_IFTYPE_MONITOR:
3487 if (tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) {
3488 vif = &tx.sdata->vif;
3489 break;
3490 }
3491 tx.sdata = rcu_dereference(local->monitor_sdata);
3492 if (tx.sdata) {
3493 vif = &tx.sdata->vif;
3494 info->hw_queue =
3495 vif->hw_queue[skb_get_queue_mapping(skb)];
3496 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) {
3497 ieee80211_free_txskb(&local->hw, skb);
3498 goto begin;
3499 } else {
3500 vif = NULL;
3501 }
3502 break;
3503 case NL80211_IFTYPE_AP_VLAN:
3504 tx.sdata = container_of(tx.sdata->bss,
3505 struct ieee80211_sub_if_data, u.ap);
3506 /* fall through */
3507 default:
3508 vif = &tx.sdata->vif;
3509 break;
3510 }
3511
3512 IEEE80211_SKB_CB(skb)->control.vif = vif;
3491out: 3513out:
3492 spin_unlock_bh(&fq->lock); 3514 spin_unlock_bh(&fq->lock);
3493 3515
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 259698de569f..6aef6793d052 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1436,7 +1436,7 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_local *local,
1436 WLAN_EID_SSID_LIST, 1436 WLAN_EID_SSID_LIST,
1437 WLAN_EID_CHANNEL_USAGE, 1437 WLAN_EID_CHANNEL_USAGE,
1438 WLAN_EID_INTERWORKING, 1438 WLAN_EID_INTERWORKING,
1439 /* mesh ID can't happen here */ 1439 WLAN_EID_MESH_ID,
1440 /* 60 GHz can't happen here right now */ 1440 /* 60 GHz can't happen here right now */
1441 }; 1441 };
1442 noffset = ieee80211_ie_split(ie, ie_len, 1442 noffset = ieee80211_ie_split(ie, ie_len,
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 04fe25abc5f6..52cd2901a097 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -215,7 +215,7 @@ static void *__nf_hook_entries_try_shrink(struct nf_hook_entries __rcu **pp)
215 if (skip == hook_entries) 215 if (skip == hook_entries)
216 goto out_assign; 216 goto out_assign;
217 217
218 if (WARN_ON(skip == 0)) 218 if (skip == 0)
219 return NULL; 219 return NULL;
220 220
221 hook_entries -= skip; 221 hook_entries -= skip;
diff --git a/net/netfilter/ipvs/ip_vs_proto_sctp.c b/net/netfilter/ipvs/ip_vs_proto_sctp.c
index e1efa446b305..57c8ee66491e 100644
--- a/net/netfilter/ipvs/ip_vs_proto_sctp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_sctp.c
@@ -24,9 +24,13 @@ sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
24 if (sh) { 24 if (sh) {
25 sch = skb_header_pointer(skb, iph->len + sizeof(_sctph), 25 sch = skb_header_pointer(skb, iph->len + sizeof(_sctph),
26 sizeof(_schunkh), &_schunkh); 26 sizeof(_schunkh), &_schunkh);
27 if (sch && (sch->type == SCTP_CID_INIT || 27 if (sch) {
28 sysctl_sloppy_sctp(ipvs))) 28 if (sch->type == SCTP_CID_ABORT ||
29 !(sysctl_sloppy_sctp(ipvs) ||
30 sch->type == SCTP_CID_INIT))
31 return 1;
29 ports = &sh->source; 32 ports = &sh->source;
33 }
30 } 34 }
31 } else { 35 } else {
32 ports = skb_header_pointer( 36 ports = skb_header_pointer(
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 40573aa6c133..f393a7086025 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -30,19 +30,17 @@
30#include <net/netfilter/nf_conntrack_zones.h> 30#include <net/netfilter/nf_conntrack_zones.h>
31#include <linux/netfilter/nf_nat.h> 31#include <linux/netfilter/nf_nat.h>
32 32
33static spinlock_t nf_nat_locks[CONNTRACK_LOCKS];
34
33static DEFINE_MUTEX(nf_nat_proto_mutex); 35static DEFINE_MUTEX(nf_nat_proto_mutex);
34static const struct nf_nat_l3proto __rcu *nf_nat_l3protos[NFPROTO_NUMPROTO] 36static const struct nf_nat_l3proto __rcu *nf_nat_l3protos[NFPROTO_NUMPROTO]
35 __read_mostly; 37 __read_mostly;
36static const struct nf_nat_l4proto __rcu **nf_nat_l4protos[NFPROTO_NUMPROTO] 38static const struct nf_nat_l4proto __rcu **nf_nat_l4protos[NFPROTO_NUMPROTO]
37 __read_mostly; 39 __read_mostly;
38 40
39struct nf_nat_conn_key { 41static struct hlist_head *nf_nat_bysource __read_mostly;
40 const struct net *net; 42static unsigned int nf_nat_htable_size __read_mostly;
41 const struct nf_conntrack_tuple *tuple; 43static unsigned int nf_nat_hash_rnd __read_mostly;
42 const struct nf_conntrack_zone *zone;
43};
44
45static struct rhltable nf_nat_bysource_table;
46 44
47inline const struct nf_nat_l3proto * 45inline const struct nf_nat_l3proto *
48__nf_nat_l3proto_find(u8 family) 46__nf_nat_l3proto_find(u8 family)
@@ -118,17 +116,19 @@ int nf_xfrm_me_harder(struct net *net, struct sk_buff *skb, unsigned int family)
118EXPORT_SYMBOL(nf_xfrm_me_harder); 116EXPORT_SYMBOL(nf_xfrm_me_harder);
119#endif /* CONFIG_XFRM */ 117#endif /* CONFIG_XFRM */
120 118
121static u32 nf_nat_bysource_hash(const void *data, u32 len, u32 seed) 119/* We keep an extra hash for each conntrack, for fast searching. */
120static unsigned int
121hash_by_src(const struct net *n, const struct nf_conntrack_tuple *tuple)
122{ 122{
123 const struct nf_conntrack_tuple *t; 123 unsigned int hash;
124 const struct nf_conn *ct = data; 124
125 get_random_once(&nf_nat_hash_rnd, sizeof(nf_nat_hash_rnd));
125 126
126 t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
127 /* Original src, to ensure we map it consistently if poss. */ 127 /* Original src, to ensure we map it consistently if poss. */
128 hash = jhash2((u32 *)&tuple->src, sizeof(tuple->src) / sizeof(u32),
129 tuple->dst.protonum ^ nf_nat_hash_rnd ^ net_hash_mix(n));
128 130
129 seed ^= net_hash_mix(nf_ct_net(ct)); 131 return reciprocal_scale(hash, nf_nat_htable_size);
130 return jhash2((const u32 *)&t->src, sizeof(t->src) / sizeof(u32),
131 t->dst.protonum ^ seed);
132} 132}
133 133
134/* Is this tuple already taken? (not by us) */ 134/* Is this tuple already taken? (not by us) */
@@ -184,28 +184,6 @@ same_src(const struct nf_conn *ct,
184 t->src.u.all == tuple->src.u.all); 184 t->src.u.all == tuple->src.u.all);
185} 185}
186 186
187static int nf_nat_bysource_cmp(struct rhashtable_compare_arg *arg,
188 const void *obj)
189{
190 const struct nf_nat_conn_key *key = arg->key;
191 const struct nf_conn *ct = obj;
192
193 if (!same_src(ct, key->tuple) ||
194 !net_eq(nf_ct_net(ct), key->net) ||
195 !nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL))
196 return 1;
197
198 return 0;
199}
200
201static struct rhashtable_params nf_nat_bysource_params = {
202 .head_offset = offsetof(struct nf_conn, nat_bysource),
203 .obj_hashfn = nf_nat_bysource_hash,
204 .obj_cmpfn = nf_nat_bysource_cmp,
205 .nelem_hint = 256,
206 .min_size = 1024,
207};
208
209/* Only called for SRC manip */ 187/* Only called for SRC manip */
210static int 188static int
211find_appropriate_src(struct net *net, 189find_appropriate_src(struct net *net,
@@ -216,26 +194,22 @@ find_appropriate_src(struct net *net,
216 struct nf_conntrack_tuple *result, 194 struct nf_conntrack_tuple *result,
217 const struct nf_nat_range *range) 195 const struct nf_nat_range *range)
218{ 196{
197 unsigned int h = hash_by_src(net, tuple);
219 const struct nf_conn *ct; 198 const struct nf_conn *ct;
220 struct nf_nat_conn_key key = {
221 .net = net,
222 .tuple = tuple,
223 .zone = zone
224 };
225 struct rhlist_head *hl, *h;
226
227 hl = rhltable_lookup(&nf_nat_bysource_table, &key,
228 nf_nat_bysource_params);
229
230 rhl_for_each_entry_rcu(ct, h, hl, nat_bysource) {
231 nf_ct_invert_tuplepr(result,
232 &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
233 result->dst = tuple->dst;
234 199
235 if (in_range(l3proto, l4proto, result, range)) 200 hlist_for_each_entry_rcu(ct, &nf_nat_bysource[h], nat_bysource) {
236 return 1; 201 if (same_src(ct, tuple) &&
202 net_eq(net, nf_ct_net(ct)) &&
203 nf_ct_zone_equal(ct, zone, IP_CT_DIR_ORIGINAL)) {
204 /* Copy source part from reply tuple. */
205 nf_ct_invert_tuplepr(result,
206 &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
207 result->dst = tuple->dst;
208
209 if (in_range(l3proto, l4proto, result, range))
210 return 1;
211 }
237 } 212 }
238
239 return 0; 213 return 0;
240} 214}
241 215
@@ -408,6 +382,7 @@ nf_nat_setup_info(struct nf_conn *ct,
408 const struct nf_nat_range *range, 382 const struct nf_nat_range *range,
409 enum nf_nat_manip_type maniptype) 383 enum nf_nat_manip_type maniptype)
410{ 384{
385 struct net *net = nf_ct_net(ct);
411 struct nf_conntrack_tuple curr_tuple, new_tuple; 386 struct nf_conntrack_tuple curr_tuple, new_tuple;
412 387
413 /* Can't setup nat info for confirmed ct. */ 388 /* Can't setup nat info for confirmed ct. */
@@ -416,7 +391,9 @@ nf_nat_setup_info(struct nf_conn *ct,
416 391
417 WARN_ON(maniptype != NF_NAT_MANIP_SRC && 392 WARN_ON(maniptype != NF_NAT_MANIP_SRC &&
418 maniptype != NF_NAT_MANIP_DST); 393 maniptype != NF_NAT_MANIP_DST);
419 BUG_ON(nf_nat_initialized(ct, maniptype)); 394
395 if (WARN_ON(nf_nat_initialized(ct, maniptype)))
396 return NF_DROP;
420 397
421 /* What we've got will look like inverse of reply. Normally 398 /* What we've got will look like inverse of reply. Normally
422 * this is what is in the conntrack, except for prior 399 * this is what is in the conntrack, except for prior
@@ -447,19 +424,16 @@ nf_nat_setup_info(struct nf_conn *ct,
447 } 424 }
448 425
449 if (maniptype == NF_NAT_MANIP_SRC) { 426 if (maniptype == NF_NAT_MANIP_SRC) {
450 struct nf_nat_conn_key key = { 427 unsigned int srchash;
451 .net = nf_ct_net(ct), 428 spinlock_t *lock;
452 .tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, 429
453 .zone = nf_ct_zone(ct), 430 srchash = hash_by_src(net,
454 }; 431 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
455 int err; 432 lock = &nf_nat_locks[srchash % ARRAY_SIZE(nf_nat_locks)];
456 433 spin_lock_bh(lock);
457 err = rhltable_insert_key(&nf_nat_bysource_table, 434 hlist_add_head_rcu(&ct->nat_bysource,
458 &key, 435 &nf_nat_bysource[srchash]);
459 &ct->nat_bysource, 436 spin_unlock_bh(lock);
460 nf_nat_bysource_params);
461 if (err)
462 return NF_DROP;
463 } 437 }
464 438
465 /* It's done. */ 439 /* It's done. */
@@ -553,6 +527,16 @@ static int nf_nat_proto_remove(struct nf_conn *i, void *data)
553 return i->status & IPS_NAT_MASK ? 1 : 0; 527 return i->status & IPS_NAT_MASK ? 1 : 0;
554} 528}
555 529
530static void __nf_nat_cleanup_conntrack(struct nf_conn *ct)
531{
532 unsigned int h;
533
534 h = hash_by_src(nf_ct_net(ct), &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
535 spin_lock_bh(&nf_nat_locks[h % ARRAY_SIZE(nf_nat_locks)]);
536 hlist_del_rcu(&ct->nat_bysource);
537 spin_unlock_bh(&nf_nat_locks[h % ARRAY_SIZE(nf_nat_locks)]);
538}
539
556static int nf_nat_proto_clean(struct nf_conn *ct, void *data) 540static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
557{ 541{
558 if (nf_nat_proto_remove(ct, data)) 542 if (nf_nat_proto_remove(ct, data))
@@ -568,8 +552,7 @@ static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
568 * will delete entry from already-freed table. 552 * will delete entry from already-freed table.
569 */ 553 */
570 clear_bit(IPS_SRC_NAT_DONE_BIT, &ct->status); 554 clear_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
571 rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource, 555 __nf_nat_cleanup_conntrack(ct);
572 nf_nat_bysource_params);
573 556
574 /* don't delete conntrack. Although that would make things a lot 557 /* don't delete conntrack. Although that would make things a lot
575 * simpler, we'd end up flushing all conntracks on nat rmmod. 558 * simpler, we'd end up flushing all conntracks on nat rmmod.
@@ -698,8 +681,7 @@ EXPORT_SYMBOL_GPL(nf_nat_l3proto_unregister);
698static void nf_nat_cleanup_conntrack(struct nf_conn *ct) 681static void nf_nat_cleanup_conntrack(struct nf_conn *ct)
699{ 682{
700 if (ct->status & IPS_SRC_NAT_DONE) 683 if (ct->status & IPS_SRC_NAT_DONE)
701 rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource, 684 __nf_nat_cleanup_conntrack(ct);
702 nf_nat_bysource_params);
703} 685}
704 686
705static struct nf_ct_ext_type nat_extend __read_mostly = { 687static struct nf_ct_ext_type nat_extend __read_mostly = {
@@ -821,19 +803,27 @@ static struct nf_ct_helper_expectfn follow_master_nat = {
821 803
822static int __init nf_nat_init(void) 804static int __init nf_nat_init(void)
823{ 805{
824 int ret; 806 int ret, i;
825 807
826 ret = rhltable_init(&nf_nat_bysource_table, &nf_nat_bysource_params); 808 /* Leave them the same for the moment. */
827 if (ret) 809 nf_nat_htable_size = nf_conntrack_htable_size;
828 return ret; 810 if (nf_nat_htable_size < ARRAY_SIZE(nf_nat_locks))
811 nf_nat_htable_size = ARRAY_SIZE(nf_nat_locks);
812
813 nf_nat_bysource = nf_ct_alloc_hashtable(&nf_nat_htable_size, 0);
814 if (!nf_nat_bysource)
815 return -ENOMEM;
829 816
830 ret = nf_ct_extend_register(&nat_extend); 817 ret = nf_ct_extend_register(&nat_extend);
831 if (ret < 0) { 818 if (ret < 0) {
832 rhltable_destroy(&nf_nat_bysource_table); 819 nf_ct_free_hashtable(nf_nat_bysource, nf_nat_htable_size);
833 printk(KERN_ERR "nf_nat_core: Unable to register extension\n"); 820 printk(KERN_ERR "nf_nat_core: Unable to register extension\n");
834 return ret; 821 return ret;
835 } 822 }
836 823
824 for (i = 0; i < ARRAY_SIZE(nf_nat_locks); i++)
825 spin_lock_init(&nf_nat_locks[i]);
826
837 nf_ct_helper_expectfn_register(&follow_master_nat); 827 nf_ct_helper_expectfn_register(&follow_master_nat);
838 828
839 BUG_ON(nfnetlink_parse_nat_setup_hook != NULL); 829 BUG_ON(nfnetlink_parse_nat_setup_hook != NULL);
@@ -863,8 +853,8 @@ static void __exit nf_nat_cleanup(void)
863 853
864 for (i = 0; i < NFPROTO_NUMPROTO; i++) 854 for (i = 0; i < NFPROTO_NUMPROTO; i++)
865 kfree(nf_nat_l4protos[i]); 855 kfree(nf_nat_l4protos[i]);
866 856 synchronize_net();
867 rhltable_destroy(&nf_nat_bysource_table); 857 nf_ct_free_hashtable(nf_nat_bysource, nf_nat_htable_size);
868} 858}
869 859
870MODULE_LICENSE("GPL"); 860MODULE_LICENSE("GPL");
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 10d48234f5f4..5da8746f7b88 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -35,6 +35,7 @@
35#include <linux/netfilter_ipv6/ip6_tables.h> 35#include <linux/netfilter_ipv6/ip6_tables.h>
36#include <linux/netfilter/xt_hashlimit.h> 36#include <linux/netfilter/xt_hashlimit.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/kernel.h>
38 39
39MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
40MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 41MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
@@ -279,7 +280,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
279 size = cfg->size; 280 size = cfg->size;
280 } else { 281 } else {
281 size = (totalram_pages << PAGE_SHIFT) / 16384 / 282 size = (totalram_pages << PAGE_SHIFT) / 16384 /
282 sizeof(struct list_head); 283 sizeof(struct hlist_head);
283 if (totalram_pages > 1024 * 1024 * 1024 / PAGE_SIZE) 284 if (totalram_pages > 1024 * 1024 * 1024 / PAGE_SIZE)
284 size = 8192; 285 size = 8192;
285 if (size < 16) 286 if (size < 16)
@@ -287,7 +288,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
287 } 288 }
288 /* FIXME: don't use vmalloc() here or anywhere else -HW */ 289 /* FIXME: don't use vmalloc() here or anywhere else -HW */
289 hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) + 290 hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) +
290 sizeof(struct list_head) * size); 291 sizeof(struct hlist_head) * size);
291 if (hinfo == NULL) 292 if (hinfo == NULL)
292 return -ENOMEM; 293 return -ENOMEM;
293 *out_hinfo = hinfo; 294 *out_hinfo = hinfo;
@@ -527,12 +528,12 @@ static u64 user2rate(u64 user)
527 } 528 }
528} 529}
529 530
530static u64 user2rate_bytes(u64 user) 531static u64 user2rate_bytes(u32 user)
531{ 532{
532 u64 r; 533 u64 r;
533 534
534 r = user ? 0xFFFFFFFFULL / user : 0xFFFFFFFFULL; 535 r = user ? U32_MAX / user : U32_MAX;
535 r = (r - 1) << 4; 536 r = (r - 1) << XT_HASHLIMIT_BYTE_SHIFT;
536 return r; 537 return r;
537} 538}
538 539
@@ -588,7 +589,8 @@ static void rateinfo_init(struct dsthash_ent *dh,
588 dh->rateinfo.prev_window = 0; 589 dh->rateinfo.prev_window = 0;
589 dh->rateinfo.current_rate = 0; 590 dh->rateinfo.current_rate = 0;
590 if (hinfo->cfg.mode & XT_HASHLIMIT_BYTES) { 591 if (hinfo->cfg.mode & XT_HASHLIMIT_BYTES) {
591 dh->rateinfo.rate = user2rate_bytes(hinfo->cfg.avg); 592 dh->rateinfo.rate =
593 user2rate_bytes((u32)hinfo->cfg.avg);
592 if (hinfo->cfg.burst) 594 if (hinfo->cfg.burst)
593 dh->rateinfo.burst = 595 dh->rateinfo.burst =
594 hinfo->cfg.burst * dh->rateinfo.rate; 596 hinfo->cfg.burst * dh->rateinfo.rate;
@@ -870,7 +872,7 @@ static int hashlimit_mt_check_common(const struct xt_mtchk_param *par,
870 872
871 /* Check for overflow. */ 873 /* Check for overflow. */
872 if (revision >= 3 && cfg->mode & XT_HASHLIMIT_RATE_MATCH) { 874 if (revision >= 3 && cfg->mode & XT_HASHLIMIT_RATE_MATCH) {
873 if (cfg->avg == 0) { 875 if (cfg->avg == 0 || cfg->avg > U32_MAX) {
874 pr_info("hashlimit invalid rate\n"); 876 pr_info("hashlimit invalid rate\n");
875 return -ERANGE; 877 return -ERANGE;
876 } 878 }
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 5acee49db90b..327807731b44 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -691,6 +691,9 @@ static void deferred_put_nlk_sk(struct rcu_head *head)
691 struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu); 691 struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu);
692 struct sock *sk = &nlk->sk; 692 struct sock *sk = &nlk->sk;
693 693
694 kfree(nlk->groups);
695 nlk->groups = NULL;
696
694 if (!refcount_dec_and_test(&sk->sk_refcnt)) 697 if (!refcount_dec_and_test(&sk->sk_refcnt))
695 return; 698 return;
696 699
@@ -769,9 +772,6 @@ static int netlink_release(struct socket *sock)
769 netlink_table_ungrab(); 772 netlink_table_ungrab();
770 } 773 }
771 774
772 kfree(nlk->groups);
773 nlk->groups = NULL;
774
775 local_bh_disable(); 775 local_bh_disable();
776 sock_prot_inuse_add(sock_net(sk), &netlink_proto, -1); 776 sock_prot_inuse_add(sock_net(sk), &netlink_proto, -1);
777 local_bh_enable(); 777 local_bh_enable();
@@ -955,7 +955,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
955 struct net *net = sock_net(sk); 955 struct net *net = sock_net(sk);
956 struct netlink_sock *nlk = nlk_sk(sk); 956 struct netlink_sock *nlk = nlk_sk(sk);
957 struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr; 957 struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
958 int err; 958 int err = 0;
959 long unsigned int groups = nladdr->nl_groups; 959 long unsigned int groups = nladdr->nl_groups;
960 bool bound; 960 bool bound;
961 961
@@ -983,6 +983,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
983 return -EINVAL; 983 return -EINVAL;
984 } 984 }
985 985
986 netlink_lock_table();
986 if (nlk->netlink_bind && groups) { 987 if (nlk->netlink_bind && groups) {
987 int group; 988 int group;
988 989
@@ -993,7 +994,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
993 if (!err) 994 if (!err)
994 continue; 995 continue;
995 netlink_undo_bind(group, groups, sk); 996 netlink_undo_bind(group, groups, sk);
996 return err; 997 goto unlock;
997 } 998 }
998 } 999 }
999 1000
@@ -1006,12 +1007,13 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1006 netlink_autobind(sock); 1007 netlink_autobind(sock);
1007 if (err) { 1008 if (err) {
1008 netlink_undo_bind(nlk->ngroups, groups, sk); 1009 netlink_undo_bind(nlk->ngroups, groups, sk);
1009 return err; 1010 goto unlock;
1010 } 1011 }
1011 } 1012 }
1012 1013
1013 if (!groups && (nlk->groups == NULL || !(u32)nlk->groups[0])) 1014 if (!groups && (nlk->groups == NULL || !(u32)nlk->groups[0]))
1014 return 0; 1015 goto unlock;
1016 netlink_unlock_table();
1015 1017
1016 netlink_table_grab(); 1018 netlink_table_grab();
1017 netlink_update_subscriptions(sk, nlk->subscriptions + 1019 netlink_update_subscriptions(sk, nlk->subscriptions +
@@ -1022,6 +1024,10 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1022 netlink_table_ungrab(); 1024 netlink_table_ungrab();
1023 1025
1024 return 0; 1026 return 0;
1027
1028unlock:
1029 netlink_unlock_table();
1030 return err;
1025} 1031}
1026 1032
1027static int netlink_connect(struct socket *sock, struct sockaddr *addr, 1033static int netlink_connect(struct socket *sock, struct sockaddr *addr,
@@ -1079,7 +1085,9 @@ static int netlink_getname(struct socket *sock, struct sockaddr *addr,
1079 nladdr->nl_groups = netlink_group_mask(nlk->dst_group); 1085 nladdr->nl_groups = netlink_group_mask(nlk->dst_group);
1080 } else { 1086 } else {
1081 nladdr->nl_pid = nlk->portid; 1087 nladdr->nl_pid = nlk->portid;
1088 netlink_lock_table();
1082 nladdr->nl_groups = nlk->groups ? nlk->groups[0] : 0; 1089 nladdr->nl_groups = nlk->groups ? nlk->groups[0] : 0;
1090 netlink_unlock_table();
1083 } 1091 }
1084 return 0; 1092 return 0;
1085} 1093}
diff --git a/net/rds/send.c b/net/rds/send.c
index 058a40743041..b52cdc8ae428 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -428,14 +428,18 @@ over_batch:
428 * some work and we will skip our goto 428 * some work and we will skip our goto
429 */ 429 */
430 if (ret == 0) { 430 if (ret == 0) {
431 bool raced;
432
431 smp_mb(); 433 smp_mb();
434 raced = send_gen != READ_ONCE(cp->cp_send_gen);
435
432 if ((test_bit(0, &conn->c_map_queued) || 436 if ((test_bit(0, &conn->c_map_queued) ||
433 !list_empty(&cp->cp_send_queue)) && 437 !list_empty(&cp->cp_send_queue)) && !raced) {
434 send_gen == READ_ONCE(cp->cp_send_gen)) {
435 rds_stats_inc(s_send_lock_queue_raced);
436 if (batch_count < send_batch_count) 438 if (batch_count < send_batch_count)
437 goto restart; 439 goto restart;
438 queue_delayed_work(rds_wq, &cp->cp_send_w, 1); 440 queue_delayed_work(rds_wq, &cp->cp_send_w, 1);
441 } else if (raced) {
442 rds_stats_inc(s_send_lock_queue_raced);
439 } 443 }
440 } 444 }
441out: 445out:
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index ea6c65fd5fc5..c743f03cfebd 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -182,7 +182,7 @@ static struct tcf_chain *tcf_chain_create(struct tcf_block *block,
182 list_add_tail(&chain->list, &block->chain_list); 182 list_add_tail(&chain->list, &block->chain_list);
183 chain->block = block; 183 chain->block = block;
184 chain->index = chain_index; 184 chain->index = chain_index;
185 chain->refcnt = 1; 185 chain->refcnt = 0;
186 return chain; 186 return chain;
187} 187}
188 188
@@ -217,15 +217,15 @@ struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
217 struct tcf_chain *chain; 217 struct tcf_chain *chain;
218 218
219 list_for_each_entry(chain, &block->chain_list, list) { 219 list_for_each_entry(chain, &block->chain_list, list) {
220 if (chain->index == chain_index) { 220 if (chain->index == chain_index)
221 chain->refcnt++; 221 goto incref;
222 return chain;
223 }
224 } 222 }
225 if (create) 223 chain = create ? tcf_chain_create(block, chain_index) : NULL;
226 return tcf_chain_create(block, chain_index); 224
227 else 225incref:
228 return NULL; 226 if (chain)
227 chain->refcnt++;
228 return chain;
229} 229}
230EXPORT_SYMBOL(tcf_chain_get); 230EXPORT_SYMBOL(tcf_chain_get);
231 231
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index f31b28f788c0..2dd6c68ae91e 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -80,7 +80,7 @@ prio_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
80 80
81 if (ret & __NET_XMIT_BYPASS) 81 if (ret & __NET_XMIT_BYPASS)
82 qdisc_qstats_drop(sch); 82 qdisc_qstats_drop(sch);
83 kfree_skb(skb); 83 __qdisc_drop(skb, to_free);
84 return ret; 84 return ret;
85 } 85 }
86#endif 86#endif
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index cd661a7f81e6..6ddfd4991108 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -1215,7 +1215,7 @@ static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
1215 if (cl == NULL) { 1215 if (cl == NULL) {
1216 if (err & __NET_XMIT_BYPASS) 1216 if (err & __NET_XMIT_BYPASS)
1217 qdisc_qstats_drop(sch); 1217 qdisc_qstats_drop(sch);
1218 kfree_skb(skb); 1218 __qdisc_drop(skb, to_free);
1219 return err; 1219 return err;
1220 } 1220 }
1221 pr_debug("qfq_enqueue: cl = %x\n", cl->common.classid); 1221 pr_debug("qfq_enqueue: cl = %x\n", cl->common.classid);
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 0225d62a869f..a71be33f3afe 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -265,7 +265,8 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event)
265 sctp_ulpq_clear_pd(ulpq); 265 sctp_ulpq_clear_pd(ulpq);
266 266
267 if (queue == &sk->sk_receive_queue && !sp->data_ready_signalled) { 267 if (queue == &sk->sk_receive_queue && !sp->data_ready_signalled) {
268 sp->data_ready_signalled = 1; 268 if (!sock_owned_by_user(sk))
269 sp->data_ready_signalled = 1;
269 sk->sk_data_ready(sk); 270 sk->sk_data_ready(sk);
270 } 271 }
271 return 1; 272 return 1;
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index ac1d66d7e1fd..47ec121574ce 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -637,7 +637,7 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
637 break; 637 break;
638 case NETDEV_UNREGISTER: 638 case NETDEV_UNREGISTER:
639 case NETDEV_CHANGENAME: 639 case NETDEV_CHANGENAME:
640 bearer_disable(dev_net(dev), b); 640 bearer_disable(net, b);
641 break; 641 break;
642 } 642 }
643 return NOTIFY_OK; 643 return NOTIFY_OK;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 8ce85420ecb0..0df8023f480b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3791,8 +3791,8 @@ static void nl80211_check_ap_rate_selectors(struct cfg80211_ap_settings *params,
3791static void nl80211_calculate_ap_params(struct cfg80211_ap_settings *params) 3791static void nl80211_calculate_ap_params(struct cfg80211_ap_settings *params)
3792{ 3792{
3793 const struct cfg80211_beacon_data *bcn = &params->beacon; 3793 const struct cfg80211_beacon_data *bcn = &params->beacon;
3794 size_t ies_len = bcn->beacon_ies_len; 3794 size_t ies_len = bcn->tail_len;
3795 const u8 *ies = bcn->beacon_ies; 3795 const u8 *ies = bcn->tail;
3796 const u8 *rates; 3796 const u8 *rates;
3797 const u8 *cap; 3797 const u8 *cap;
3798 3798
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 5fae296a6a58..6e94f6934a0e 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -4,6 +4,7 @@
4 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> 4 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
5 * Copyright 2008-2011 Luis R. Rodriguez <mcgrof@qca.qualcomm.com> 5 * Copyright 2008-2011 Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH 6 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * Copyright 2017 Intel Deutschland GmbH
7 * 8 *
8 * Permission to use, copy, modify, and/or distribute this software for any 9 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 10 * purpose with or without fee is hereby granted, provided that the above
@@ -1483,7 +1484,9 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy,
1483{ 1484{
1484 struct ieee80211_supported_band *sband = wiphy->bands[channel->band]; 1485 struct ieee80211_supported_band *sband = wiphy->bands[channel->band];
1485 struct ieee80211_channel *channel_before = NULL, *channel_after = NULL; 1486 struct ieee80211_channel *channel_before = NULL, *channel_after = NULL;
1487 const struct ieee80211_regdomain *regd;
1486 unsigned int i; 1488 unsigned int i;
1489 u32 flags;
1487 1490
1488 if (!is_ht40_allowed(channel)) { 1491 if (!is_ht40_allowed(channel)) {
1489 channel->flags |= IEEE80211_CHAN_NO_HT40; 1492 channel->flags |= IEEE80211_CHAN_NO_HT40;
@@ -1503,17 +1506,30 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy,
1503 channel_after = c; 1506 channel_after = c;
1504 } 1507 }
1505 1508
1509 flags = 0;
1510 regd = get_wiphy_regdom(wiphy);
1511 if (regd) {
1512 const struct ieee80211_reg_rule *reg_rule =
1513 freq_reg_info_regd(MHZ_TO_KHZ(channel->center_freq),
1514 regd, MHZ_TO_KHZ(20));
1515
1516 if (!IS_ERR(reg_rule))
1517 flags = reg_rule->flags;
1518 }
1519
1506 /* 1520 /*
1507 * Please note that this assumes target bandwidth is 20 MHz, 1521 * Please note that this assumes target bandwidth is 20 MHz,
1508 * if that ever changes we also need to change the below logic 1522 * if that ever changes we also need to change the below logic
1509 * to include that as well. 1523 * to include that as well.
1510 */ 1524 */
1511 if (!is_ht40_allowed(channel_before)) 1525 if (!is_ht40_allowed(channel_before) ||
1526 flags & NL80211_RRF_NO_HT40MINUS)
1512 channel->flags |= IEEE80211_CHAN_NO_HT40MINUS; 1527 channel->flags |= IEEE80211_CHAN_NO_HT40MINUS;
1513 else 1528 else
1514 channel->flags &= ~IEEE80211_CHAN_NO_HT40MINUS; 1529 channel->flags &= ~IEEE80211_CHAN_NO_HT40MINUS;
1515 1530
1516 if (!is_ht40_allowed(channel_after)) 1531 if (!is_ht40_allowed(channel_after) ||
1532 flags & NL80211_RRF_NO_HT40PLUS)
1517 channel->flags |= IEEE80211_CHAN_NO_HT40PLUS; 1533 channel->flags |= IEEE80211_CHAN_NO_HT40PLUS;
1518 else 1534 else
1519 channel->flags &= ~IEEE80211_CHAN_NO_HT40PLUS; 1535 channel->flags &= ~IEEE80211_CHAN_NO_HT40PLUS;
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index 4acc772a28c0..fe3a443a1102 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -558,7 +558,7 @@ static void test_sockmap(int tasks, void *data)
558 } 558 }
559 } 559 }
560 560
561 /* Test attaching bad fds */ 561 /* Test attaching/detaching bad fds */
562 err = bpf_prog_attach(-1, fd, BPF_SK_SKB_STREAM_PARSER, 0); 562 err = bpf_prog_attach(-1, fd, BPF_SK_SKB_STREAM_PARSER, 0);
563 if (!err) { 563 if (!err) {
564 printf("Failed invalid parser prog attach\n"); 564 printf("Failed invalid parser prog attach\n");
@@ -571,6 +571,30 @@ static void test_sockmap(int tasks, void *data)
571 goto out_sockmap; 571 goto out_sockmap;
572 } 572 }
573 573
574 err = bpf_prog_attach(-1, fd, __MAX_BPF_ATTACH_TYPE, 0);
575 if (!err) {
576 printf("Failed unknown prog attach\n");
577 goto out_sockmap;
578 }
579
580 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER);
581 if (err) {
582 printf("Failed empty parser prog detach\n");
583 goto out_sockmap;
584 }
585
586 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT);
587 if (err) {
588 printf("Failed empty verdict prog detach\n");
589 goto out_sockmap;
590 }
591
592 err = bpf_prog_detach(fd, __MAX_BPF_ATTACH_TYPE);
593 if (!err) {
594 printf("Detach invalid prog successful\n");
595 goto out_sockmap;
596 }
597
574 /* Load SK_SKB program and Attach */ 598 /* Load SK_SKB program and Attach */
575 err = bpf_prog_load(SOCKMAP_PARSE_PROG, 599 err = bpf_prog_load(SOCKMAP_PARSE_PROG,
576 BPF_PROG_TYPE_SK_SKB, &obj, &parse_prog); 600 BPF_PROG_TYPE_SK_SKB, &obj, &parse_prog);
@@ -643,6 +667,13 @@ static void test_sockmap(int tasks, void *data)
643 goto out_sockmap; 667 goto out_sockmap;
644 } 668 }
645 669
670 err = bpf_prog_attach(verdict_prog, map_fd_rx,
671 __MAX_BPF_ATTACH_TYPE, 0);
672 if (!err) {
673 printf("Attached unknown bpf prog\n");
674 goto out_sockmap;
675 }
676
646 /* Test map update elem afterwards fd lives in fd and map_fd */ 677 /* Test map update elem afterwards fd lives in fd and map_fd */
647 for (i = 0; i < 6; i++) { 678 for (i = 0; i < 6; i++) {
648 err = bpf_map_update_elem(map_fd_rx, &i, &sfd[i], BPF_ANY); 679 err = bpf_map_update_elem(map_fd_rx, &i, &sfd[i], BPF_ANY);
@@ -809,6 +840,24 @@ static void test_sockmap(int tasks, void *data)
809 assert(status == 0); 840 assert(status == 0);
810 } 841 }
811 842
843 err = bpf_prog_detach(map_fd_rx, __MAX_BPF_ATTACH_TYPE);
844 if (!err) {
845 printf("Detached an invalid prog type.\n");
846 goto out_sockmap;
847 }
848
849 err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_PARSER);
850 if (err) {
851 printf("Failed parser prog detach\n");
852 goto out_sockmap;
853 }
854
855 err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_VERDICT);
856 if (err) {
857 printf("Failed parser prog detach\n");
858 goto out_sockmap;
859 }
860
812 /* Test map close sockets */ 861 /* Test map close sockets */
813 for (i = 0; i < 6; i++) 862 for (i = 0; i < 6; i++)
814 close(sfd[i]); 863 close(sfd[i]);