History

Merge tag 'net-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Paolo Abeni: "Quite unusually, this does not contains any fix coming from subtrees (nf, ebpf, wifi, etc). Current release - regressions: - bcmasp: fix possible OOB write in bcmasp_netfilt_get_all_active() Previous releases - regressions: - ipv4: fix one memleak in __inet_del_ifa() - tcp: fix bind() regressions for v4-mapped-v6 addresses. - tls: do not free tls_rec on async operation in bpf_exec_tx_verdict() - dsa: fixes for SJA1105 FDB regressions - veth: update XDP feature set when bringing up device - igb: fix hangup when enabling SR-IOV Previous releases - always broken: - kcm: fix memory leak in error path of kcm_sendmsg() - smc: fix data corruption in smcr_port_add - microchip: fix possible memory leak for vcap_dup_rule()" * tag 'net-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (37 commits) kcm: Fix error handling for SOCK_DGRAM in kcm_sendmsg(). net: renesas: rswitch: Add spin lock protection for irq {un}mask net: renesas: rswitch: Fix unmasking irq condition igb: clean up in all error paths when enabling SR-IOV ixgbe: fix timestamp configuration code selftest: tcp: Add v4-mapped-v6 cases in bind_wildcard.c. selftest: tcp: Move expected_errno into each test case in bind_wildcard.c. selftest: tcp: Fix address length in bind_wildcard.c. tcp: Fix bind() regression for v4-mapped-v6 non-wildcard address. tcp: Fix bind() regression for v4-mapped-v6 wildcard address. tcp: Factorise sk_family-independent comparison in inet_bind2_bucket_match(_addr_any). ipv6: fix ip6_sock_set_addr_preferences() typo veth: Update XDP feature set when bringing up device net: macb: fix sleep inside spinlock net/tls: do not free tls_rec on async operation in bpf_exec_tx_verdict() net: ethernet: mtk_eth_soc: fix pse_port configuration for MT7988 net: ethernet: mtk_eth_soc: fix uninitialized variable kcm: Fix memory leak in error path of kcm_sendmsg() r8152: check budget for r8152_poll() net: dsa: sja1105: block FDB accesses that are concurrent with a switch reset ...

Linus Torvalds committed 3 years ago

Commit 9fdfb152 parents aed8aee a22730b36 files · +352 −207Browse files

Unified · Split

36 files
  1. drivers/net/dsa/sja1105/sja1105.h +2 −0
  2. drivers/net/dsa/sja1105/sja1105_dynamic_config.c +44 −49
  3. drivers/net/dsa/sja1105/sja1105_main.c +51 −18
  4. drivers/net/ethernet/adi/adin1110.c +1 −1
  5. drivers/net/ethernet/broadcom/asp2/bcmasp.c +8 −2
  6. drivers/net/ethernet/broadcom/asp2/bcmasp.h +2 −2
  7. drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c +1 −1
  8. drivers/net/ethernet/cadence/macb_main.c +3 −2
  9. drivers/net/ethernet/intel/igb/igb_main.c +4 −1
  10. drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +15 −13
  11. drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +5 −0
  12. drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c +4 −2
  13. drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h +1 −1
  14. drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +6 −37
  15. drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2 −1
  16. drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +4 −3
  17. drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +25 −5
  18. drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +2 −2
  19. drivers/net/ethernet/mediatek/mtk_eth_soc.c +6 −2
  20. drivers/net/ethernet/mediatek/mtk_ppe_offload.c +4 −2
  21. drivers/net/ethernet/microchip/vcap/vcap_api.c +16 −2
  22. drivers/net/ethernet/renesas/rswitch.c +16 −4
  23. drivers/net/ethernet/renesas/rswitch.h +2 −0
  24. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 −4
  25. drivers/net/usb/r8152.c +3 −0
  26. drivers/net/veth.c +2 −0
  27. include/net/ipv6.h +6 −1
  28. net/hsr/hsr_forward.c +1 −0
  29. net/ipv4/devinet.c +5 −5
  30. net/ipv4/inet_hashtables.c +20 −16
  31. net/kcm/kcmsock.c +8 −5
  32. net/smc/smc_core.c +2 −0
  33. net/smc/smc_stats.h +2 −1
  34. net/tls/tls_sw.c +2 −2
  35. tools/testing/selftests/net/bind_bhash.sh +14 −12
  36. tools/testing/selftests/net/bind_wildcard.c +57 −11
drivers/net/dsa/sja1105/sja1105.h+2−0
@@ -266,6 +266,8 @@ struct sja1105_private { · 265 unmodified lines
266266 * the switch doesn't confuse them with one another.
267267 */
268268 struct mutex mgmt_lock;
269+ /* Serializes accesses to the FDB */
270+ struct mutex fdb_lock;
269271 /* PTP two-step TX timestamp ID, and its serialization lock */
270272 spinlock_t ts_id_lock;
271273 u8 ts_id;
drivers/net/dsa/sja1105/sja1105_dynamic_config.c+44−49
@@ -1175,18 +1175,15 @@ const struct sja1105_dynamic_table_ops sja1110_dyn_ops[BLK_IDX_MAX_DYN] = { · 1174 unmodified lines
11751175
11761176 static int
11771177 sja1105_dynamic_config_poll_valid(struct sja1105_private *priv,
1178− struct sja1105_dyn_cmd *cmd,
1179− const struct sja1105_dynamic_table_ops *ops)
1178+ const struct sja1105_dynamic_table_ops *ops,
1179+ void *entry, bool check_valident,
1180+ bool check_errors)
11801181 {
11811182 u8 packed_buf[SJA1105_MAX_DYN_CMD_SIZE] = {};
1183+ struct sja1105_dyn_cmd cmd = {};
11821184 int rc;
11831185
1184− /* We don't _need_ to read the full entry, just the command area which
1185− * is a fixed SJA1105_SIZE_DYN_CMD. But our cmd_packing() API expects a
1186− * buffer that contains the full entry too. Additionally, our API
1187− * doesn't really know how many bytes into the buffer does the command
1188− * area really begin. So just read back the whole entry.
1189− */
1186+ /* Read back the whole entry + command structure. */
11901187 rc = sja1105_xfer_buf(priv, SPI_READ, ops->addr, packed_buf,
11911188 ops->packed_size);
11921189 if (rc)
@@ -1195,11 +1192,25 @@ sja1105_dynamic_config_poll_valid(struct sja1105_private *priv, · 2 unmodified lines
11951192 /* Unpack the command structure, and return it to the caller in case it
11961193 * needs to perform further checks on it (VALIDENT).
11971194 */
1198− memset(cmd, 0, sizeof(*cmd));
1199− ops->cmd_packing(packed_buf, cmd, UNPACK);
1195+ ops->cmd_packing(packed_buf, &cmd, UNPACK);
12001196
12011197 /* Hardware hasn't cleared VALID => still working on it */
1202− return cmd->valid ? -EAGAIN : 0;
1198+ if (cmd.valid)
1199+ return -EAGAIN;
1200+
1201+ if (check_valident && !cmd.valident && !(ops->access & OP_VALID_ANYWAY))
1202+ return -ENOENT;
1203+
1204+ if (check_errors && cmd.errors)
1205+ return -EINVAL;
1206+
1207+ /* Don't dereference possibly NULL pointer - maybe caller
1208+ * only wanted to see whether the entry existed or not.
1209+ */
1210+ if (entry)
1211+ ops->entry_packing(packed_buf, entry, UNPACK);
1212+
1213+ return 0;
12031214 }
12041215
12051216 /* Poll the dynamic config entry's control area until the hardware has
@@ -1208,16 +1219,19 @@ sja1105_dynamic_config_poll_valid(struct sja1105_private *priv, · 2 unmodified lines
12081219 */
12091220 static int
12101221 sja1105_dynamic_config_wait_complete(struct sja1105_private *priv,
1211− struct sja1105_dyn_cmd *cmd,
1212− const struct sja1105_dynamic_table_ops *ops)
1222+ const struct sja1105_dynamic_table_ops *ops,
1223+ void *entry, bool check_valident,
1224+ bool check_errors)
12131225 {
1214− int rc;
1215−
1216− return read_poll_timeout(sja1105_dynamic_config_poll_valid,
1217− rc, rc != -EAGAIN,
1218− SJA1105_DYNAMIC_CONFIG_SLEEP_US,
1219− SJA1105_DYNAMIC_CONFIG_TIMEOUT_US,
1220− false, priv, cmd, ops);
1226+ int err, rc;
1227+
1228+ err = read_poll_timeout(sja1105_dynamic_config_poll_valid,
1229+ rc, rc != -EAGAIN,
1230+ SJA1105_DYNAMIC_CONFIG_SLEEP_US,
1231+ SJA1105_DYNAMIC_CONFIG_TIMEOUT_US,
1232+ false, priv, ops, entry, check_valident,
1233+ check_errors);
1234+ return err < 0 ? err : rc;
12211235 }
12221236
12231237 /* Provides read access to the settings through the dynamic interface
@@ -1286,25 +1300,14 @@ int sja1105_dynamic_config_read(struct sja1105_private *priv, · 62 unmodified lines
12861300 mutex_lock(&priv->dynamic_config_lock);
12871301 rc = sja1105_xfer_buf(priv, SPI_WRITE, ops->addr, packed_buf,
12881302 ops->packed_size);
1289− if (rc < 0) {
1290− mutex_unlock(&priv->dynamic_config_lock);
1291− return rc;
1292− }
1293−
1294− rc = sja1105_dynamic_config_wait_complete(priv, &cmd, ops);
1295− mutex_unlock(&priv->dynamic_config_lock);
12961303 if (rc < 0)
1297− return rc;
1304+ goto out;
12981305
1299− if (!cmd.valident && !(ops->access & OP_VALID_ANYWAY))
1300− return -ENOENT;
1306+ rc = sja1105_dynamic_config_wait_complete(priv, ops, entry, true, false);
1307+out:
1308+ mutex_unlock(&priv->dynamic_config_lock);
13011309
1302− /* Don't dereference possibly NULL pointer - maybe caller
1303− * only wanted to see whether the entry existed or not.
1304− */
1305− if (entry)
1306− ops->entry_packing(packed_buf, entry, UNPACK);
1307− return 0;
1310+ return rc;
13081311 }
13091312
13101313 int sja1105_dynamic_config_write(struct sja1105_private *priv,
@@ -1356,22 +1359,14 @@ int sja1105_dynamic_config_write(struct sja1105_private *priv, · 45 unmodified lines
13561359 mutex_lock(&priv->dynamic_config_lock);
13571360 rc = sja1105_xfer_buf(priv, SPI_WRITE, ops->addr, packed_buf,
13581361 ops->packed_size);
1359− if (rc < 0) {
1360− mutex_unlock(&priv->dynamic_config_lock);
1361− return rc;
1362− }
1363−
1364− rc = sja1105_dynamic_config_wait_complete(priv, &cmd, ops);
1365− mutex_unlock(&priv->dynamic_config_lock);
13661362 if (rc < 0)
1367− return rc;
1363+ goto out;
13681364
1369− cmd = (struct sja1105_dyn_cmd) {0};
1370− ops->cmd_packing(packed_buf, &cmd, UNPACK);
1371− if (cmd.errors)
1372− return -EINVAL;
1365+ rc = sja1105_dynamic_config_wait_complete(priv, ops, NULL, false, true);
1366+out:
1367+ mutex_unlock(&priv->dynamic_config_lock);
13731368
1374− return 0;
1369+ return rc;
13751370 }
13761371
13771372 static u8 sja1105_crc8_add(u8 crc, u8 byte, u8 poly)
drivers/net/dsa/sja1105/sja1105_main.c+51−18
@@ -1798,6 +1798,7 @@ static int sja1105_fdb_add(struct dsa_switch *ds, int port, · 1797 unmodified lines
17981798 struct dsa_db db)
17991799 {
18001800 struct sja1105_private *priv = ds->priv;
1801+ int rc;
18011802
18021803 if (!vid) {
18031804 switch (db.type) {
@@ -1812,12 +1813,16 @@ static int sja1105_fdb_add(struct dsa_switch *ds, int port, · 8 unmodified lines
18121813 }
18131814 }
18141815
1815− return priv->info->fdb_add_cmd(ds, port, addr, vid);
1816+ mutex_lock(&priv->fdb_lock);
1817+ rc = priv->info->fdb_add_cmd(ds, port, addr, vid);
1818+ mutex_unlock(&priv->fdb_lock);
1819+
1820+ return rc;
18161821 }
18171822
1818−static int sja1105_fdb_del(struct dsa_switch *ds, int port,
1819− const unsigned char *addr, u16 vid,
1820− struct dsa_db db)
1823+static int __sja1105_fdb_del(struct dsa_switch *ds, int port,
1824+ const unsigned char *addr, u16 vid,
1825+ struct dsa_db db)
18211826 {
18221827 struct sja1105_private *priv = ds->priv;
18231828
@@ -1837,6 +1842,20 @@ static int sja1105_fdb_del(struct dsa_switch *ds, int port, · 13 unmodified lines
18371842 return priv->info->fdb_del_cmd(ds, port, addr, vid);
18381843 }
18391844
1845+static int sja1105_fdb_del(struct dsa_switch *ds, int port,
1846+ const unsigned char *addr, u16 vid,
1847+ struct dsa_db db)
1848+{
1849+ struct sja1105_private *priv = ds->priv;
1850+ int rc;
1851+
1852+ mutex_lock(&priv->fdb_lock);
1853+ rc = __sja1105_fdb_del(ds, port, addr, vid, db);
1854+ mutex_unlock(&priv->fdb_lock);
1855+
1856+ return rc;
1857+}
1858+
18401859 static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
18411860 dsa_fdb_dump_cb_t *cb, void *data)
18421861 {
@@ -1868,13 +1887,14 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port, · 25 unmodified lines
18681887 if (!(l2_lookup.destports & BIT(port)))
18691888 continue;
18701889
1871− /* We need to hide the FDB entry for unknown multicast */
1872− if (l2_lookup.macaddr == SJA1105_UNKNOWN_MULTICAST &&
1873− l2_lookup.mask_macaddr == SJA1105_UNKNOWN_MULTICAST)
1874− continue;
1875−
18761890 u64_to_ether_addr(l2_lookup.macaddr, macaddr);
18771891
1892+ /* Hardware FDB is shared for fdb and mdb, "bridge fdb show"
1893+ * only wants to see unicast
1894+ */
1895+ if (is_multicast_ether_addr(macaddr))
1896+ continue;
1897+
18781898 /* We need to hide the dsa_8021q VLANs from the user. */
18791899 if (vid_is_dsa_8021q(l2_lookup.vlanid))
18801900 l2_lookup.vlanid = 0;
@@ -1898,6 +1918,8 @@ static void sja1105_fast_age(struct dsa_switch *ds, int port) · 17 unmodified lines
18981918 };
18991919 int i;
19001920
1921+ mutex_lock(&priv->fdb_lock);
1922+
19011923 for (i = 0; i < SJA1105_MAX_L2_LOOKUP_COUNT; i++) {
19021924 struct sja1105_l2_lookup_entry l2_lookup = {0};
19031925 u8 macaddr[ETH_ALEN];
@@ -1911,7 +1933,7 @@ static void sja1105_fast_age(struct dsa_switch *ds, int port) · 7 unmodified lines
19111933 if (rc) {
19121934 dev_err(ds->dev, "Failed to read FDB: %pe\n",
19131935 ERR_PTR(rc));
1914− return;
1936+ break;
19151937 }
19161938
19171939 if (!(l2_lookup.destports & BIT(port)))
@@ -1923,14 +1945,16 @@ static void sja1105_fast_age(struct dsa_switch *ds, int port) · 5 unmodified lines
19231945
19241946 u64_to_ether_addr(l2_lookup.macaddr, macaddr);
19251947
1926− rc = sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid, db);
1948+ rc = __sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid, db);
19271949 if (rc) {
19281950 dev_err(ds->dev,
19291951 "Failed to delete FDB entry %pM vid %lld: %pe\n",
19301952 macaddr, l2_lookup.vlanid, ERR_PTR(rc));
1931− return;
1953+ break;
19321954 }
19331955 }
1956+
1957+ mutex_unlock(&priv->fdb_lock);
19341958 }
19351959
19361960 static int sja1105_mdb_add(struct dsa_switch *ds, int port,
@@ -2273,6 +2297,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv, · 336 unmodified lines
22732297 int rc, i;
22742298 s64 now;
22752299
2300+ mutex_lock(&priv->fdb_lock);
22762301 mutex_lock(&priv->mgmt_lock);
22772302
22782303 mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries;
@@ -2385,6 +2410,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv, · 106 unmodified lines
23852410 goto out;
23862411 out:
23872412 mutex_unlock(&priv->mgmt_lock);
2413+ mutex_unlock(&priv->fdb_lock);
23882414
23892415 return rc;
23902416 }
@@ -2954,7 +2980,9 @@ static int sja1105_port_mcast_flood(struct sja1105_private *priv, int to, · 563 unmodified lines
29542980 {
29552981 struct sja1105_l2_lookup_entry *l2_lookup;
29562982 struct sja1105_table *table;
2957− int match;
2983+ int match, rc;
2984+
2985+ mutex_lock(&priv->fdb_lock);
29582986
29592987 table = &priv->static_config.tables[BLK_IDX_L2_LOOKUP];
29602988 l2_lookup = table->entries;
@@ -2967,7 +2995,8 @@ static int sja1105_port_mcast_flood(struct sja1105_private *priv, int to, · 6 unmodified lines
29672995 if (match == table->entry_count) {
29682996 NL_SET_ERR_MSG_MOD(extack,
29692997 "Could not find FDB entry for unknown multicast");
2970− return -ENOSPC;
2998+ rc = -ENOSPC;
2999+ goto out;
29713000 }
29723001
29733002 if (flags.val & BR_MCAST_FLOOD)
@@ -2975,10 +3004,13 @@ static int sja1105_port_mcast_flood(struct sja1105_private *priv, int to, · 1 unmodified line
29753004 else
29763005 l2_lookup[match].destports &= ~BIT(to);
29773006
2978− return sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP,
2979− l2_lookup[match].index,
2980− &l2_lookup[match],
2981− true);
3007+ rc = sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP,
3008+ l2_lookup[match].index,
3009+ &l2_lookup[match], true);
3010+out:
3011+ mutex_unlock(&priv->fdb_lock);
3012+
3013+ return rc;
29823014 }
29833015
29843016 static int sja1105_port_pre_bridge_flags(struct dsa_switch *ds, int port,
@@ -3348,6 +3380,7 @@ static int sja1105_probe(struct spi_device *spi) · 363 unmodified lines
33483380 mutex_init(&priv->ptp_data.lock);
33493381 mutex_init(&priv->dynamic_config_lock);
33503382 mutex_init(&priv->mgmt_lock);
3383+ mutex_init(&priv->fdb_lock);
33513384 spin_lock_init(&priv->ts_id_lock);
33523385
33533386 rc = sja1105_parse_dt(priv);
drivers/net/ethernet/adi/adin1110.c+1−1
@@ -1385,7 +1385,7 @@ static int adin1110_fdb_add(struct adin1110_port_priv *port_priv, · 1384 unmodified lines
13851385 return -ENOMEM;
13861386
13871387 other_port = priv->ports[!port_priv->nr];
1388− port_rules = adin1110_port_rules(port_priv, false, true);
1388+ port_rules = adin1110_port_rules(other_port, false, true);
13891389 eth_broadcast_addr(mask);
13901390
13911391 return adin1110_write_mac_address(other_port, mac_nr, (u8 *)fdb->addr,
drivers/net/ethernet/broadcom/asp2/bcmasp.c+8−2
@@ -528,13 +528,16 @@ void bcmasp_netfilt_suspend(struct bcmasp_intf *intf) · 527 unmodified lines
528528 ASP_RX_FILTER_BLK_CTRL);
529529 }
530530
531−void bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
532− u32 *rule_cnt)
531+int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
532+ u32 *rule_cnt)
533533 {
534534 struct bcmasp_priv *priv = intf->parent;
535535 int j = 0, i;
536536
537537 for (i = 0; i < NUM_NET_FILTERS; i++) {
538+ if (j == *rule_cnt)
539+ return -EMSGSIZE;
540+
538541 if (!priv->net_filters[i].claimed ||
539542 priv->net_filters[i].port != intf->port)
540543 continue;
@@ -548,6 +551,8 @@ void bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs, · 7 unmodified lines
548551 }
549552
550553 *rule_cnt = j;
554+
555+ return 0;
551556 }
552557
553558 int bcmasp_netfilt_get_active(struct bcmasp_intf *intf)
@@ -1300,6 +1305,7 @@ static int bcmasp_probe(struct platform_device *pdev) · 746 unmodified lines
13001305 if (!intf) {
13011306 dev_err(dev, "Cannot create eth interface %d\n", i);
13021307 bcmasp_remove_intfs(priv);
1308+ of_node_put(intf_node);
13031309 goto of_put_exit;
13041310 }
13051311 list_add_tail(&intf->list, &priv->intfs);
drivers/net/ethernet/broadcom/asp2/bcmasp.h+2−2
@@ -577,8 +577,8 @@ void bcmasp_netfilt_release(struct bcmasp_intf *intf, · 576 unmodified lines
577577
578578 int bcmasp_netfilt_get_active(struct bcmasp_intf *intf);
579579
580−void bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
581− u32 *rule_cnt);
580+int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
581+ u32 *rule_cnt);
582582
583583 void bcmasp_netfilt_suspend(struct bcmasp_intf *intf);
584584
drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c+1−1
@@ -335,7 +335,7 @@ static int bcmasp_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, · 334 unmodified lines
335335 err = bcmasp_flow_get(intf, cmd);
336336 break;
337337 case ETHTOOL_GRXCLSRLALL:
338− bcmasp_netfilt_get_all_active(intf, rule_locs, &cmd->rule_cnt);
338+ err = bcmasp_netfilt_get_all_active(intf, rule_locs, &cmd->rule_cnt);
339339 cmd->data = NUM_NET_FILTERS;
340340 break;
341341 default:
drivers/net/ethernet/cadence/macb_main.c+3−2
@@ -756,8 +756,6 @@ static void macb_mac_link_up(struct phylink_config *config, · 755 unmodified lines
756756 if (rx_pause)
757757 ctrl |= MACB_BIT(PAE);
758758
759− macb_set_tx_clk(bp, speed);
760−
761759 /* Initialize rings & buffers as clearing MACB_BIT(TE) in link down
762760 * cleared the pipeline and control registers.
763761 */
@@ -777,6 +775,9 @@ static void macb_mac_link_up(struct phylink_config *config, · 13 unmodified lines
777775
778776 spin_unlock_irqrestore(&bp->lock, flags);
779777
778+ if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC))
779+ macb_set_tx_clk(bp, speed);
780+
780781 /* Enable Rx and Tx; Enable PTP unicast */
781782 ctrl = macb_readl(bp, NCR);
782783 if (gem_has_ptp(bp))
drivers/net/ethernet/intel/igb/igb_main.c+4−1
@@ -3827,8 +3827,11 @@ static int igb_enable_sriov(struct pci_dev *pdev, int num_vfs, bool reinit) · 3826 unmodified lines
38273827 }
38283828
38293829 /* only call pci_enable_sriov() if no VFs are allocated already */
3830− if (!old_vfs)
3830+ if (!old_vfs) {
38313831 err = pci_enable_sriov(pdev, adapter->vfs_allocated_count);
3832+ if (err)
3833+ goto err_out;
3834+ }
38323835
38333836 goto out;
38343837
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c+15−13
@@ -979,6 +979,7 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, · 978 unmodified lines
979979 u32 tsync_tx_ctl = IXGBE_TSYNCTXCTL_ENABLED;
980980 u32 tsync_rx_ctl = IXGBE_TSYNCRXCTL_ENABLED;
981981 u32 tsync_rx_mtrl = PTP_EV_PORT << 16;
982+ u32 aflags = adapter->flags;
982983 bool is_l2 = false;
983984 u32 regval;
984985
@@ -996,20 +997,20 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, · 11 unmodified lines
996997 case HWTSTAMP_FILTER_NONE:
997998 tsync_rx_ctl = 0;
998999 tsync_rx_mtrl = 0;
999− adapter->flags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1000− IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
1000+ aflags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1001+ IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10011002 break;
10021003 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
10031004 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1;
10041005 tsync_rx_mtrl |= IXGBE_RXMTRL_V1_SYNC_MSG;
1005− adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1006− IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
1006+ aflags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1007+ IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10071008 break;
10081009 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
10091010 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1;
10101011 tsync_rx_mtrl |= IXGBE_RXMTRL_V1_DELAY_REQ_MSG;
1011− adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1012− IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
1012+ aflags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1013+ IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10131014 break;
10141015 case HWTSTAMP_FILTER_PTP_V2_EVENT:
10151016 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
@@ -1023,8 +1024,8 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, · 7 unmodified lines
10231024 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_EVENT_V2;
10241025 is_l2 = true;
10251026 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
1026− adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1027− IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
1027+ aflags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1028+ IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10281029 break;
10291030 case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
10301031 case HWTSTAMP_FILTER_NTP_ALL:
@@ -1035,7 +1036,7 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, · 4 unmodified lines
10351036 if (hw->mac.type >= ixgbe_mac_X550) {
10361037 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_ALL;
10371038 config->rx_filter = HWTSTAMP_FILTER_ALL;
1038− adapter->flags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED;
1039+ aflags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED;
10391040 break;
10401041 }
10411042 fallthrough;
@@ -1046,8 +1047,6 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, · 4 unmodified lines
10461047 * Delay_Req messages and hardware does not support
10471048 * timestamping all packets => return error
10481049 */
1049− adapter->flags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1050− IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10511050 config->rx_filter = HWTSTAMP_FILTER_NONE;
10521051 return -ERANGE;
10531052 }
@@ -1079,8 +1078,8 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, · 25 unmodified lines
10791078 IXGBE_TSYNCRXCTL_TYPE_ALL |
10801079 IXGBE_TSYNCRXCTL_TSIP_UT_EN;
10811080 config->rx_filter = HWTSTAMP_FILTER_ALL;
1082− adapter->flags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED;
1083− adapter->flags &= ~IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER;
1081+ aflags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED;
1082+ aflags &= ~IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER;
10841083 is_l2 = true;
10851084 break;
10861085 default:
@@ -1113,6 +1112,9 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, · 26 unmodified lines
11131112
11141113 IXGBE_WRITE_FLUSH(hw);
11151114
1115+ /* configure adapter flags only when HW is actually configured */
1116+ adapter->flags = aflags;
1117+
11161118 /* clear TX/RX time stamp registers, just to be sure */
11171119 ixgbe_ptp_clear_tx_timestamp(adapter);
11181120 IXGBE_READ_REG(hw, IXGBE_RXSTMPH);
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c+5−0
@@ -5586,6 +5586,11 @@ static int mvpp2_ethtool_get_rxnfc(struct net_device *dev, · 5585 unmodified lines
55865586 break;
55875587 case ETHTOOL_GRXCLSRLALL:
55885588 for (i = 0; i < MVPP2_N_RFS_ENTRIES_PER_FLOW; i++) {
5589+ if (loc == info->rule_cnt) {
5590+ ret = -EMSGSIZE;
5591+ break;
5592+ }
5593+
55895594 if (port->rfs_rules[i])
55905595 rules[loc++] = i;
55915596 }
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c+4−2
@@ -107,12 +107,13 @@ int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura) · 106 unmodified lines
107107 }
108108
109109 #define NPA_MAX_BURST 16
110−void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq)
110+int cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq)
111111 {
112112 struct otx2_nic *pfvf = dev;
113+ int cnt = cq->pool_ptrs;
113114 u64 ptrs[NPA_MAX_BURST];
114− int num_ptrs = 1;
115115 dma_addr_t bufptr;
116+ int num_ptrs = 1;
116117
117118 /* Refill pool with new buffers */
118119 while (cq->pool_ptrs) {
@@ -131,6 +132,7 @@ void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq) · 12 unmodified lines
131132 num_ptrs = 1;
132133 }
133134 }
135+ return cnt - cq->pool_ptrs;
134136 }
135137
136138 void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h+1−1
@@ -24,7 +24,7 @@ static inline int mtu_to_dwrr_weight(struct otx2_nic *pfvf, int mtu) · 23 unmodified lines
2424 return weight;
2525 }
2626
27−void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
27+int cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
2828 void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx);
2929 int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
3030 int cn10k_lmtst_init(struct otx2_nic *pfvf);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c+6−37
@@ -574,20 +574,8 @@ int otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool, · 573 unmodified lines
574574 int otx2_alloc_buffer(struct otx2_nic *pfvf, struct otx2_cq_queue *cq,
575575 dma_addr_t *dma)
576576 {
577− if (unlikely(__otx2_alloc_rbuf(pfvf, cq->rbpool, dma))) {
578− struct refill_work *work;
579− struct delayed_work *dwork;
580−
581− work = &pfvf->refill_wrk[cq->cq_idx];
582− dwork = &work->pool_refill_work;
583− /* Schedule a task if no other task is running */
584− if (!cq->refill_task_sched) {
585− cq->refill_task_sched = true;
586− schedule_delayed_work(dwork,
587− msecs_to_jiffies(100));
588− }
577+ if (unlikely(__otx2_alloc_rbuf(pfvf, cq->rbpool, dma)))
589578 return -ENOMEM;
590− }
591579 return 0;
592580 }
593581
@@ -1082,39 +1070,20 @@ static int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) · 488 unmodified lines
10821070 static void otx2_pool_refill_task(struct work_struct *work)
10831071 {
10841072 struct otx2_cq_queue *cq;
1085− struct otx2_pool *rbpool;
10861073 struct refill_work *wrk;
1087− int qidx, free_ptrs = 0;
10881074 struct otx2_nic *pfvf;
1089− dma_addr_t bufptr;
1075+ int qidx;
10901076
10911077 wrk = container_of(work, struct refill_work, pool_refill_work.work);
10921078 pfvf = wrk->pf;
10931079 qidx = wrk - pfvf->refill_wrk;
10941080 cq = &pfvf->qset.cq[qidx];
1095− rbpool = cq->rbpool;
1096− free_ptrs = cq->pool_ptrs;
10971081
1098− while (cq->pool_ptrs) {
1099− if (otx2_alloc_rbuf(pfvf, rbpool, &bufptr)) {
1100− /* Schedule a WQ if we fails to free atleast half of the
1101− * pointers else enable napi for this RQ.
1102− */
1103− if (!((free_ptrs - cq->pool_ptrs) > free_ptrs / 2)) {
1104− struct delayed_work *dwork;
1105−
1106− dwork = &wrk->pool_refill_work;
1107− schedule_delayed_work(dwork,
1108− msecs_to_jiffies(100));
1109− } else {
1110− cq->refill_task_sched = false;
1111− }
1112− return;
1113− }
1114− pfvf->hw_ops->aura_freeptr(pfvf, qidx, bufptr + OTX2_HEAD_ROOM);
1115− cq->pool_ptrs--;
1116− }
11171082 cq->refill_task_sched = false;
1083+
1084+ local_bh_disable();
1085+ napi_schedule(wrk->napi);
1086+ local_bh_enable();
11181087 }
11191088
11201089 int otx2_config_nix_queues(struct otx2_nic *pfvf)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h+2−1
@@ -302,6 +302,7 @@ struct flr_work { · 301 unmodified lines
302302 struct refill_work {
303303 struct delayed_work pool_refill_work;
304304 struct otx2_nic *pf;
305+ struct napi_struct *napi;
305306 };
306307
307308 /* PTPv2 originTimestamp structure */
@@ -370,7 +371,7 @@ struct dev_hw_ops { · 62 unmodified lines
370371 int (*sq_aq_init)(void *dev, u16 qidx, u16 sqb_aura);
371372 void (*sqe_flush)(void *dev, struct otx2_snd_queue *sq,
372373 int size, int qidx);
373− void (*refill_pool_ptrs)(void *dev, struct otx2_cq_queue *cq);
374+ int (*refill_pool_ptrs)(void *dev, struct otx2_cq_queue *cq);
374375 void (*aura_freeptr)(void *dev, int aura, u64 buf);
375376 };
376377
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c+4−3
@@ -1943,6 +1943,10 @@ int otx2_stop(struct net_device *netdev) · 1942 unmodified lines
19431943
19441944 netif_tx_disable(netdev);
19451945
1946+ for (wrk = 0; wrk < pf->qset.cq_cnt; wrk++)
1947+ cancel_delayed_work_sync(&pf->refill_wrk[wrk].pool_refill_work);
1948+ devm_kfree(pf->dev, pf->refill_wrk);
1949+
19461950 otx2_free_hw_resources(pf);
19471951 otx2_free_cints(pf, pf->hw.cint_cnt);
19481952 otx2_disable_napi(pf);
@@ -1950,9 +1954,6 @@ int otx2_stop(struct net_device *netdev) · 1 unmodified line
19501954 for (qidx = 0; qidx < netdev->num_tx_queues; qidx++)
19511955 netdev_tx_reset_queue(netdev_get_tx_queue(netdev, qidx));
19521956
1953− for (wrk = 0; wrk < pf->qset.cq_cnt; wrk++)
1954− cancel_delayed_work_sync(&pf->refill_wrk[wrk].pool_refill_work);
1955− devm_kfree(pf->dev, pf->refill_wrk);
19561957
19571958 kfree(qset->sq);
19581959 kfree(qset->cq);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c+25−5
@@ -424,9 +424,10 @@ process_cqe: · 423 unmodified lines
424424 return processed_cqe;
425425 }
426426
427−void otx2_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq)
427+int otx2_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq)
428428 {
429429 struct otx2_nic *pfvf = dev;
430+ int cnt = cq->pool_ptrs;
430431 dma_addr_t bufptr;
431432
432433 while (cq->pool_ptrs) {
@@ -435,6 +436,8 @@ void otx2_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq) · 2 unmodified lines
435436 otx2_aura_freeptr(pfvf, cq->cq_idx, bufptr + OTX2_HEAD_ROOM);
436437 cq->pool_ptrs--;
437438 }
439+
440+ return cnt - cq->pool_ptrs;
438441 }
439442
440443 static int otx2_tx_napi_handler(struct otx2_nic *pfvf,
@@ -521,6 +524,7 @@ int otx2_napi_handler(struct napi_struct *napi, int budget) · 80 unmodified lines
521524 struct otx2_cq_queue *cq;
522525 struct otx2_qset *qset;
523526 struct otx2_nic *pfvf;
527+ int filled_cnt = -1;
524528
525529 cq_poll = container_of(napi, struct otx2_cq_poll, napi);
526530 pfvf = (struct otx2_nic *)cq_poll->dev;
@@ -541,7 +545,7 @@ int otx2_napi_handler(struct napi_struct *napi, int budget) · 14 unmodified lines
541545 }
542546
543547 if (rx_cq && rx_cq->pool_ptrs)
544− pfvf->hw_ops->refill_pool_ptrs(pfvf, rx_cq);
548+ filled_cnt = pfvf->hw_ops->refill_pool_ptrs(pfvf, rx_cq);
545549 /* Clear the IRQ */
546550 otx2_write64(pfvf, NIX_LF_CINTX_INT(cq_poll->cint_idx), BIT_ULL(0));
547551
@@ -561,9 +565,25 @@ int otx2_napi_handler(struct napi_struct *napi, int budget) · 13 unmodified lines
561565 otx2_config_irq_coalescing(pfvf, i);
562566 }
563567
564− /* Re-enable interrupts */
565− otx2_write64(pfvf, NIX_LF_CINTX_ENA_W1S(cq_poll->cint_idx),
566− BIT_ULL(0));
568+ if (unlikely(!filled_cnt)) {
569+ struct refill_work *work;
570+ struct delayed_work *dwork;
571+
572+ work = &pfvf->refill_wrk[cq->cq_idx];
573+ dwork = &work->pool_refill_work;
574+ /* Schedule a task if no other task is running */
575+ if (!cq->refill_task_sched) {
576+ work->napi = napi;
577+ cq->refill_task_sched = true;
578+ schedule_delayed_work(dwork,
579+ msecs_to_jiffies(100));
580+ }
581+ } else {
582+ /* Re-enable interrupts */
583+ otx2_write64(pfvf,
584+ NIX_LF_CINTX_ENA_W1S(cq_poll->cint_idx),
585+ BIT_ULL(0));
586+ }
567587 }
568588 return workdone;
569589 }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h+2−2
@@ -170,6 +170,6 @@ void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, · 169 unmodified lines
170170 int size, int qidx);
171171 void otx2_sqe_flush(void *dev, struct otx2_snd_queue *sq,
172172 int size, int qidx);
173−void otx2_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
174−void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
173+int otx2_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
174+int cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
175175 #endif /* OTX2_TXRX_H */
drivers/net/ethernet/mediatek/mtk_eth_soc.c+6−2
@@ -2005,11 +2005,11 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, · 2004 unmodified lines
20052005 u8 *data, *new_data;
20062006 struct mtk_rx_dma_v2 *rxd, trxd;
20072007 int done = 0, bytes = 0;
2008+ dma_addr_t dma_addr = DMA_MAPPING_ERROR;
20082009
20092010 while (done < budget) {
20102011 unsigned int pktlen, *rxdcsum;
20112012 struct net_device *netdev;
2012− dma_addr_t dma_addr;
20132013 u32 hash, reason;
20142014 int mac = 0;
20152015
@@ -2186,7 +2186,8 @@ release_desc: · 170 unmodified lines
21862186 else
21872187 rxd->rxd2 = RX_DMA_PREP_PLEN0(ring->buf_size);
21882188
2189− if (MTK_HAS_CAPS(eth->soc->caps, MTK_36BIT_DMA))
2189+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_36BIT_DMA) &&
2190+ likely(dma_addr != DMA_MAPPING_ERROR))
21902191 rxd->rxd2 |= RX_DMA_PREP_ADDR64(dma_addr);
21912192
21922193 ring->calc_idx = idx;
@@ -2994,6 +2995,9 @@ static int mtk_hwlro_get_fdir_all(struct net_device *dev, · 801 unmodified lines
29942995 int i;
29952996
29962997 for (i = 0; i < MTK_MAX_LRO_IP_CNT; i++) {
2998+ if (cnt == cmd->rule_cnt)
2999+ return -EMSGSIZE;
3000+
29973001 if (mac->hwlro_ip[i]) {
29983002 rule_locs[cnt] = i;
29993003 cnt++;
drivers/net/ethernet/mediatek/mtk_ppe_offload.c+4−2
@@ -214,9 +214,11 @@ mtk_flow_set_output_device(struct mtk_eth *eth, struct mtk_foe_entry *foe, · 213 unmodified lines
214214 dsa_port = mtk_flow_get_dsa_port(&dev);
215215
216216 if (dev == eth->netdev[0])
217− pse_port = 1;
217+ pse_port = PSE_GDM1_PORT;
218218 else if (dev == eth->netdev[1])
219− pse_port = 2;
219+ pse_port = PSE_GDM2_PORT;
220+ else if (dev == eth->netdev[2])
221+ pse_port = PSE_GDM3_PORT;
220222 else
221223 return -EOPNOTSUPP;
222224
drivers/net/ethernet/microchip/vcap/vcap_api.c+16−2
@@ -1021,18 +1021,32 @@ static struct vcap_rule_internal *vcap_dup_rule(struct vcap_rule_internal *ri, · 1020 unmodified lines
10211021 list_for_each_entry(ckf, &ri->data.keyfields, ctrl.list) {
10221022 newckf = kmemdup(ckf, sizeof(*newckf), GFP_KERNEL);
10231023 if (!newckf)
1024− return ERR_PTR(-ENOMEM);
1024+ goto err;
10251025 list_add_tail(&newckf->ctrl.list, &duprule->data.keyfields);
10261026 }
10271027
10281028 list_for_each_entry(caf, &ri->data.actionfields, ctrl.list) {
10291029 newcaf = kmemdup(caf, sizeof(*newcaf), GFP_KERNEL);
10301030 if (!newcaf)
1031− return ERR_PTR(-ENOMEM);
1031+ goto err;
10321032 list_add_tail(&newcaf->ctrl.list, &duprule->data.actionfields);
10331033 }
10341034
10351035 return duprule;
1036+
1037+err:
1038+ list_for_each_entry_safe(ckf, newckf, &duprule->data.keyfields, ctrl.list) {
1039+ list_del(&ckf->ctrl.list);
1040+ kfree(ckf);
1041+ }
1042+
1043+ list_for_each_entry_safe(caf, newcaf, &duprule->data.actionfields, ctrl.list) {
1044+ list_del(&caf->ctrl.list);
1045+ kfree(caf);
1046+ }
1047+
1048+ kfree(duprule);
1049+ return ERR_PTR(-ENOMEM);
10361050 }
10371051
10381052 static void vcap_apply_width(u8 *dst, int width, int bytes)
drivers/net/ethernet/renesas/rswitch.c+16−4
@@ -799,6 +799,7 @@ static int rswitch_poll(struct napi_struct *napi, int budget) · 798 unmodified lines
799799 struct net_device *ndev = napi->dev;
800800 struct rswitch_private *priv;
801801 struct rswitch_device *rdev;
802+ unsigned long flags;
802803 int quota = budget;
803804
804805 rdev = netdev_priv(ndev);
@@ -816,10 +817,12 @@ retry: · 11 unmodified lines
816817
817818 netif_wake_subqueue(ndev, 0);
818819
819− napi_complete(napi);
820−
821− rswitch_enadis_data_irq(priv, rdev->tx_queue->index, true);
822− rswitch_enadis_data_irq(priv, rdev->rx_queue->index, true);
820+ if (napi_complete_done(napi, budget - quota)) {
821+ spin_lock_irqsave(&priv->lock, flags);
822+ rswitch_enadis_data_irq(priv, rdev->tx_queue->index, true);
823+ rswitch_enadis_data_irq(priv, rdev->rx_queue->index, true);
824+ spin_unlock_irqrestore(&priv->lock, flags);
825+ }
823826
824827 out:
825828 return budget - quota;
@@ -835,8 +838,10 @@ static void rswitch_queue_interrupt(struct net_device *ndev) · 9 unmodified lines
835838 struct rswitch_device *rdev = netdev_priv(ndev);
836839
837840 if (napi_schedule_prep(&rdev->napi)) {
841+ spin_lock(&rdev->priv->lock);
838842 rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, false);
839843 rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, false);
844+ spin_unlock(&rdev->priv->lock);
840845 __napi_schedule(&rdev->napi);
841846 }
842847 }
@@ -1440,14 +1445,17 @@ static void rswitch_ether_port_deinit_all(struct rswitch_private *priv) · 597 unmodified lines
14401445 static int rswitch_open(struct net_device *ndev)
14411446 {
14421447 struct rswitch_device *rdev = netdev_priv(ndev);
1448+ unsigned long flags;
14431449
14441450 phy_start(ndev->phydev);
14451451
14461452 napi_enable(&rdev->napi);
14471453 netif_start_queue(ndev);
14481454
1455+ spin_lock_irqsave(&rdev->priv->lock, flags);
14491456 rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, true);
14501457 rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, true);
1458+ spin_unlock_irqrestore(&rdev->priv->lock, flags);
14511459
14521460 if (bitmap_empty(rdev->priv->opened_ports, RSWITCH_NUM_PORTS))
14531461 iowrite32(GWCA_TS_IRQ_BIT, rdev->priv->addr + GWTSDIE);
@@ -1461,6 +1469,7 @@ static int rswitch_stop(struct net_device *ndev) · 7 unmodified lines
14611469 {
14621470 struct rswitch_device *rdev = netdev_priv(ndev);
14631471 struct rswitch_gwca_ts_info *ts_info, *ts_info2;
1472+ unsigned long flags;
14641473
14651474 netif_tx_stop_all_queues(ndev);
14661475 bitmap_clear(rdev->priv->opened_ports, rdev->port, 1);
@@ -1476,8 +1485,10 @@ static int rswitch_stop(struct net_device *ndev) · 9 unmodified lines
14761485 kfree(ts_info);
14771486 }
14781487
1488+ spin_lock_irqsave(&rdev->priv->lock, flags);
14791489 rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, false);
14801490 rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, false);
1491+ spin_unlock_irqrestore(&rdev->priv->lock, flags);
14811492
14821493 phy_stop(ndev->phydev);
14831494 napi_disable(&rdev->napi);
@@ -1887,6 +1898,7 @@ static int renesas_eth_sw_probe(struct platform_device *pdev) · 403 unmodified lines
18871898 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
18881899 if (!priv)
18891900 return -ENOMEM;
1901+ spin_lock_init(&priv->lock);
18901902
18911903 attr = soc_device_match(rswitch_soc_no_speed_change);
18921904 if (attr)
drivers/net/ethernet/renesas/rswitch.h+2−0
@@ -1011,6 +1011,8 @@ struct rswitch_private { · 1010 unmodified lines
10111011 struct rswitch_etha etha[RSWITCH_NUM_PORTS];
10121012 struct rswitch_mfwd mfwd;
10131013
1014+ spinlock_t lock; /* lock interrupt registers' control */
1015+
10141016 bool etha_no_runtime_change;
10151017 bool gwca_halt;
10161018 };
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c+6−4
@@ -2704,9 +2704,7 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue) · 2703 unmodified lines
27042704
27052705 /* We still have pending packets, let's call for a new scheduling */
27062706 if (tx_q->dirty_tx != tx_q->cur_tx)
2707− hrtimer_start(&tx_q->txtimer,
2708− STMMAC_COAL_TIMER(priv->tx_coal_timer[queue]),
2709− HRTIMER_MODE_REL);
2707+ stmmac_tx_timer_arm(priv, queue);
27102708
27112709 flags = u64_stats_update_begin_irqsave(&tx_q->txq_stats.syncp);
27122710 tx_q->txq_stats.tx_packets += tx_packets;
@@ -2995,9 +2993,13 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) · 282 unmodified lines
29952993 static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue)
29962994 {
29972995 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
2996+ u32 tx_coal_timer = priv->tx_coal_timer[queue];
2997+
2998+ if (!tx_coal_timer)
2999+ return;
29983000
29993001 hrtimer_start(&tx_q->txtimer,
3000− STMMAC_COAL_TIMER(priv->tx_coal_timer[queue]),
3002+ STMMAC_COAL_TIMER(tx_coal_timer),
30013003 HRTIMER_MODE_REL);
30023004 }
30033005
drivers/net/usb/r8152.c+3−0
@@ -2636,6 +2636,9 @@ static int r8152_poll(struct napi_struct *napi, int budget) · 2635 unmodified lines
26362636 struct r8152 *tp = container_of(napi, struct r8152, napi);
26372637 int work_done;
26382638
2639+ if (!budget)
2640+ return 0;
2641+
26392642 work_done = rx_bottom(tp, budget);
26402643
26412644 if (work_done < budget) {
drivers/net/veth.c+2−0
@@ -1446,6 +1446,8 @@ static int veth_open(struct net_device *dev) · 1445 unmodified lines
14461446 netif_carrier_on(peer);
14471447 }
14481448
1449+ veth_set_xdp_features(dev);
1450+
14491451 return 0;
14501452 }
14511453
include/net/ipv6.h+6−1
@@ -784,6 +784,11 @@ static inline bool ipv6_addr_v4mapped(const struct in6_addr *a) · 783 unmodified lines
784784 cpu_to_be32(0x0000ffff))) == 0UL;
785785 }
786786
787+static inline bool ipv6_addr_v4mapped_any(const struct in6_addr *a)
788+{
789+ return ipv6_addr_v4mapped(a) && ipv4_is_zeronet(a->s6_addr32[3]);
790+}
791+
787792 static inline bool ipv6_addr_v4mapped_loopback(const struct in6_addr *a)
788793 {
789794 return ipv6_addr_v4mapped(a) && ipv4_is_loopback(a->s6_addr32[3]);
@@ -1360,7 +1365,7 @@ static inline int __ip6_sock_set_addr_preferences(struct sock *sk, int val) · 570 unmodified lines
13601365 return 0;
13611366 }
13621367
1363−static inline int ip6_sock_set_addr_preferences(struct sock *sk, bool val)
1368+static inline int ip6_sock_set_addr_preferences(struct sock *sk, int val)
13641369 {
13651370 int ret;
13661371
net/hsr/hsr_forward.c+1−0
@@ -594,6 +594,7 @@ static int fill_frame_info(struct hsr_frame_info *frame, · 593 unmodified lines
594594 proto = vlan_hdr->vlanhdr.h_vlan_encapsulated_proto;
595595 /* FIXME: */
596596 netdev_warn_once(skb->dev, "VLAN not yet supported");
597+ return -EINVAL;
597598 }
598599
599600 frame->is_from_san = false;
net/ipv4/devinet.c+5−5
@@ -355,14 +355,14 @@ static void __inet_del_ifa(struct in_device *in_dev, · 354 unmodified lines
355355 {
356356 struct in_ifaddr *promote = NULL;
357357 struct in_ifaddr *ifa, *ifa1;
358− struct in_ifaddr *last_prim;
358+ struct in_ifaddr __rcu **last_prim;
359359 struct in_ifaddr *prev_prom = NULL;
360360 int do_promote = IN_DEV_PROMOTE_SECONDARIES(in_dev);
361361
362362 ASSERT_RTNL();
363363
364364 ifa1 = rtnl_dereference(*ifap);
365− last_prim = rtnl_dereference(in_dev->ifa_list);
365+ last_prim = ifap;
366366 if (in_dev->dead)
367367 goto no_promotions;
368368
@@ -376,7 +376,7 @@ static void __inet_del_ifa(struct in_device *in_dev, · 7 unmodified lines
376376 while ((ifa = rtnl_dereference(*ifap1)) != NULL) {
377377 if (!(ifa->ifa_flags & IFA_F_SECONDARY) &&
378378 ifa1->ifa_scope <= ifa->ifa_scope)
379− last_prim = ifa;
379+ last_prim = &ifa->ifa_next;
380380
381381 if (!(ifa->ifa_flags & IFA_F_SECONDARY) ||
382382 ifa1->ifa_mask != ifa->ifa_mask ||
@@ -440,9 +440,9 @@ no_promotions: · 57 unmodified lines
440440
441441 rcu_assign_pointer(prev_prom->ifa_next, next_sec);
442442
443− last_sec = rtnl_dereference(last_prim->ifa_next);
443+ last_sec = rtnl_dereference(*last_prim);
444444 rcu_assign_pointer(promote->ifa_next, last_sec);
445− rcu_assign_pointer(last_prim->ifa_next, promote);
445+ rcu_assign_pointer(*last_prim, promote);
446446 }
447447
448448 promote->ifa_flags &= ~IFA_F_SECONDARY;
net/ipv4/inet_hashtables.c+20−16
@@ -815,41 +815,45 @@ static bool inet_bind2_bucket_match(const struct inet_bind2_bucket *tb, · 814 unmodified lines
815815 const struct net *net, unsigned short port,
816816 int l3mdev, const struct sock *sk)
817817 {
818+ if (!net_eq(ib2_net(tb), net) || tb->port != port ||
819+ tb->l3mdev != l3mdev)
820+ return false;
821+
818822 #if IS_ENABLED(CONFIG_IPV6)
819− if (sk->sk_family != tb->family)
823+ if (sk->sk_family != tb->family) {
824+ if (sk->sk_family == AF_INET)
825+ return ipv6_addr_v4mapped(&tb->v6_rcv_saddr) &&
826+ tb->v6_rcv_saddr.s6_addr32[3] == sk->sk_rcv_saddr;
827+
820828 return false;
829+ }
821830
822831 if (sk->sk_family == AF_INET6)
823− return net_eq(ib2_net(tb), net) && tb->port == port &&
824− tb->l3mdev == l3mdev &&
825− ipv6_addr_equal(&tb->v6_rcv_saddr, &sk->sk_v6_rcv_saddr);
826− else
832+ return ipv6_addr_equal(&tb->v6_rcv_saddr, &sk->sk_v6_rcv_saddr);
827833 #endif
828− return net_eq(ib2_net(tb), net) && tb->port == port &&
829− tb->l3mdev == l3mdev && tb->rcv_saddr == sk->sk_rcv_saddr;
834+ return tb->rcv_saddr == sk->sk_rcv_saddr;
830835 }
831836
832837 bool inet_bind2_bucket_match_addr_any(const struct inet_bind2_bucket *tb, const struct net *net,
833838 unsigned short port, int l3mdev, const struct sock *sk)
834839 {
840+ if (!net_eq(ib2_net(tb), net) || tb->port != port ||
841+ tb->l3mdev != l3mdev)
842+ return false;
843+
835844 #if IS_ENABLED(CONFIG_IPV6)
836845 if (sk->sk_family != tb->family) {
837846 if (sk->sk_family == AF_INET)
838− return net_eq(ib2_net(tb), net) && tb->port == port &&
839− tb->l3mdev == l3mdev &&
840− ipv6_addr_any(&tb->v6_rcv_saddr);
847+ return ipv6_addr_any(&tb->v6_rcv_saddr) ||
848+ ipv6_addr_v4mapped_any(&tb->v6_rcv_saddr);
841849
842850 return false;
843851 }
844852
845853 if (sk->sk_family == AF_INET6)
846− return net_eq(ib2_net(tb), net) && tb->port == port &&
847− tb->l3mdev == l3mdev &&
848− ipv6_addr_any(&tb->v6_rcv_saddr);
849− else
854+ return ipv6_addr_any(&tb->v6_rcv_saddr);
850855 #endif
851− return net_eq(ib2_net(tb), net) && tb->port == port &&
852− tb->l3mdev == l3mdev && tb->rcv_saddr == 0;
856+ return tb->rcv_saddr == 0;
853857 }
854858
855859 /* The socket's bhash2 hashbucket spinlock must be held when this is called */
net/kcm/kcmsock.c+8−5
@@ -930,15 +930,18 @@ partial_message: · 929 unmodified lines
930930 out_error:
931931 kcm_push(kcm);
932932
933− if (copied && sock->type == SOCK_SEQPACKET) {
933+ if (sock->type == SOCK_SEQPACKET) {
934934 /* Wrote some bytes before encountering an
935935 * error, return partial success.
936936 */
937− goto partial_message;
938− }
939−
940− if (head != kcm->seq_skb)
937+ if (copied)
938+ goto partial_message;
939+ if (head != kcm->seq_skb)
940+ kfree_skb(head);
941+ } else {
941942 kfree_skb(head);
943+ kcm->seq_skb = NULL;
944+ }
942945
943946 err = sk_stream_error(sk, msg->msg_flags, err);
944947
net/smc/smc_core.c+2−0
@@ -1662,6 +1662,7 @@ void smcr_port_add(struct smc_ib_device *smcibdev, u8 ibport) · 1661 unmodified lines
16621662 {
16631663 struct smc_link_group *lgr, *n;
16641664
1665+ spin_lock_bh(&smc_lgr_list.lock);
16651666 list_for_each_entry_safe(lgr, n, &smc_lgr_list.list, list) {
16661667 struct smc_link *link;
16671668
@@ -1680,6 +1681,7 @@ void smcr_port_add(struct smc_ib_device *smcibdev, u8 ibport) · 12 unmodified lines
16801681 if (link)
16811682 smc_llc_add_link_local(link);
16821683 }
1684+ spin_unlock_bh(&smc_lgr_list.lock);
16831685 }
16841686
16851687 /* link is down - switch connections to alternate link,
net/smc/smc_stats.h+2−1
@@ -243,8 +243,9 @@ while (0) · 242 unmodified lines
243243 #define SMC_STAT_SERV_SUCC_INC(net, _ini) \
244244 do { \
245245 typeof(_ini) i = (_ini); \
246− bool is_v2 = (i->smcd_version & SMC_V2); \
247246 bool is_smcd = (i->is_smcd); \
247+ u8 version = is_smcd ? i->smcd_version : i->smcr_version; \
248+ bool is_v2 = (version & SMC_V2); \
248249 typeof(net->smc.smc_stats) smc_stats = (net)->smc.smc_stats; \
249250 if (is_v2 && is_smcd) \
250251 this_cpu_inc(smc_stats->smc[SMC_TYPE_D].srv_v2_succ_cnt); \
net/tls/tls_sw.c+2−2
@@ -817,7 +817,7 @@ static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk, · 816 unmodified lines
817817 psock = sk_psock_get(sk);
818818 if (!psock || !policy) {
819819 err = tls_push_record(sk, flags, record_type);
820− if (err && sk->sk_err == EBADMSG) {
820+ if (err && err != -EINPROGRESS && sk->sk_err == EBADMSG) {
821821 *copied -= sk_msg_free(sk, msg);
822822 tls_free_open_rec(sk);
823823 err = -sk->sk_err;
@@ -846,7 +846,7 @@ more_data: · 22 unmodified lines
846846 switch (psock->eval) {
847847 case __SK_PASS:
848848 err = tls_push_record(sk, flags, record_type);
849− if (err && sk->sk_err == EBADMSG) {
849+ if (err && err != -EINPROGRESS && sk->sk_err == EBADMSG) {
850850 *copied -= sk_msg_free(sk, msg);
851851 tls_free_open_rec(sk);
852852 err = -sk->sk_err;
tools/testing/selftests/net/bind_bhash.sh+14−12
@@ -2,7 +2,7 @@ · 1 unmodified line
22 # SPDX-License-Identifier: GPL-2.0
33
44 NR_FILES=32768
5−SAVED_NR_FILES=$(ulimit -n)
5+readonly NETNS="ns-$(mktemp -u XXXXXX)"
66
77 # default values
88 port=443
@@ -36,21 +36,21 @@ while getopts "ha:p:64" opt; do · 27 unmodified lines
3636 done
3737
3838 setup() {
39+ ip netns add "${NETNS}"
40+ ip -netns "${NETNS}" link add veth0 type veth peer name veth1
41+ ip -netns "${NETNS}" link set lo up
42+ ip -netns "${NETNS}" link set veth0 up
43+ ip -netns "${NETNS}" link set veth1 up
44+
3945 if [[ "$use_v6" == true ]]; then
40− ip addr add $addr_v6 nodad dev eth0
46+ ip -netns "${NETNS}" addr add $addr_v6 nodad dev veth0
4147 else
42− ip addr add $addr_v4 dev lo
48+ ip -netns "${NETNS}" addr add $addr_v4 dev lo
4349 fi
44− ulimit -n $NR_FILES
4550 }
4651
4752 cleanup() {
48− if [[ "$use_v6" == true ]]; then
49− ip addr del $addr_v6 dev eth0
50− else
51− ip addr del $addr_v4/32 dev lo
52− fi
53− ulimit -n $SAVED_NR_FILES
53+ ip netns del "${NETNS}"
5454 }
5555
5656 if [[ "$addr" != "" ]]; then
@@ -59,8 +59,10 @@ if [[ "$addr" != "" ]]; then · 2 unmodified lines
5959 fi
6060 setup
6161 if [[ "$use_v6" == true ]] ; then
62− ./bind_bhash $port "ipv6" $addr_v6
62+ ip netns exec "${NETNS}" sh -c \
63+ "ulimit -n ${NR_FILES};./bind_bhash ${port} ipv6 ${addr_v6}"
6364 else
64− ./bind_bhash $port "ipv4" $addr_v4
65+ ip netns exec "${NETNS}" sh -c \
66+ "ulimit -n ${NR_FILES};./bind_bhash ${port} ipv4 ${addr_v4}"
6567 fi
6668 cleanup
tools/testing/selftests/net/bind_wildcard.c+57−11
@@ -6,41 +6,91 @@ · 5 unmodified lines
66
77 #include "../kselftest_harness.h"
88
9+struct in6_addr in6addr_v4mapped_any = {
10+ .s6_addr = {
11+ 0, 0, 0, 0,
12+ 0, 0, 0, 0,
13+ 0, 0, 255, 255,
14+ 0, 0, 0, 0
15+ }
16+};
17+
18+struct in6_addr in6addr_v4mapped_loopback = {
19+ .s6_addr = {
20+ 0, 0, 0, 0,
21+ 0, 0, 0, 0,
22+ 0, 0, 255, 255,
23+ 127, 0, 0, 1
24+ }
25+};
26+
927 FIXTURE(bind_wildcard)
1028 {
1129 struct sockaddr_in addr4;
1230 struct sockaddr_in6 addr6;
13− int expected_errno;
1431 };
1532
1633 FIXTURE_VARIANT(bind_wildcard)
1734 {
1835 const __u32 addr4_const;
1936 const struct in6_addr *addr6_const;
37+ int expected_errno;
2038 };
2139
2240 FIXTURE_VARIANT_ADD(bind_wildcard, v4_any_v6_any)
2341 {
2442 .addr4_const = INADDR_ANY,
2543 .addr6_const = &in6addr_any,
44+ .expected_errno = EADDRINUSE,
2645 };
2746
2847 FIXTURE_VARIANT_ADD(bind_wildcard, v4_any_v6_local)
2948 {
3049 .addr4_const = INADDR_ANY,
3150 .addr6_const = &in6addr_loopback,
51+ .expected_errno = 0,
52+};
53+
54+FIXTURE_VARIANT_ADD(bind_wildcard, v4_any_v6_v4mapped_any)
55+{
56+ .addr4_const = INADDR_ANY,
57+ .addr6_const = &in6addr_v4mapped_any,
58+ .expected_errno = EADDRINUSE,
59+};
60+
61+FIXTURE_VARIANT_ADD(bind_wildcard, v4_any_v6_v4mapped_local)
62+{
63+ .addr4_const = INADDR_ANY,
64+ .addr6_const = &in6addr_v4mapped_loopback,
65+ .expected_errno = EADDRINUSE,
3266 };
3367
3468 FIXTURE_VARIANT_ADD(bind_wildcard, v4_local_v6_any)
3569 {
3670 .addr4_const = INADDR_LOOPBACK,
3771 .addr6_const = &in6addr_any,
72+ .expected_errno = EADDRINUSE,
3873 };
3974
4075 FIXTURE_VARIANT_ADD(bind_wildcard, v4_local_v6_local)
4176 {
4277 .addr4_const = INADDR_LOOPBACK,
4378 .addr6_const = &in6addr_loopback,
79+ .expected_errno = 0,
80+};
81+
82+FIXTURE_VARIANT_ADD(bind_wildcard, v4_local_v6_v4mapped_any)
83+{
84+ .addr4_const = INADDR_LOOPBACK,
85+ .addr6_const = &in6addr_v4mapped_any,
86+ .expected_errno = EADDRINUSE,
87+};
88+
89+FIXTURE_VARIANT_ADD(bind_wildcard, v4_local_v6_v4mapped_local)
90+{
91+ .addr4_const = INADDR_LOOPBACK,
92+ .addr6_const = &in6addr_v4mapped_loopback,
93+ .expected_errno = EADDRINUSE,
4494 };
4595
4696 FIXTURE_SETUP(bind_wildcard)
@@ -52,11 +102,6 @@ FIXTURE_SETUP(bind_wildcard) · 5 unmodified lines
52102 self->addr6.sin6_family = AF_INET6;
53103 self->addr6.sin6_port = htons(0);
54104 self->addr6.sin6_addr = *variant->addr6_const;
55−
56− if (variant->addr6_const == &in6addr_any)
57− self->expected_errno = EADDRINUSE;
58− else
59− self->expected_errno = 0;
60105 }
61106
62107 FIXTURE_TEARDOWN(bind_wildcard)
@@ -65,6 +110,7 @@ FIXTURE_TEARDOWN(bind_wildcard) · 2 unmodified lines
65110
66111 void bind_sockets(struct __test_metadata *_metadata,
67112 FIXTURE_DATA(bind_wildcard) *self,
113+ int expected_errno,
68114 struct sockaddr *addr1, socklen_t addrlen1,
69115 struct sockaddr *addr2, socklen_t addrlen2)
70116 {
@@ -86,9 +132,9 @@ void bind_sockets(struct __test_metadata *_metadata, · 15 unmodified lines
86132 ASSERT_GT(fd[1], 0);
87133
88134 ret = bind(fd[1], addr2, addrlen2);
89− if (self->expected_errno) {
135+ if (expected_errno) {
90136 ASSERT_EQ(ret, -1);
91− ASSERT_EQ(errno, self->expected_errno);
137+ ASSERT_EQ(errno, expected_errno);
92138 } else {
93139 ASSERT_EQ(ret, 0);
94140 }
@@ -99,14 +145,14 @@ void bind_sockets(struct __test_metadata *_metadata, · 4 unmodified lines
99145
100146 TEST_F(bind_wildcard, v4_v6)
101147 {
102− bind_sockets(_metadata, self,
103− (struct sockaddr *)&self->addr4, sizeof(self->addr6),
148+ bind_sockets(_metadata, self, variant->expected_errno,
149+ (struct sockaddr *)&self->addr4, sizeof(self->addr4),
104150 (struct sockaddr *)&self->addr6, sizeof(self->addr6));
105151 }
106152
107153 TEST_F(bind_wildcard, v6_v4)
108154 {
109− bind_sockets(_metadata, self,
155+ bind_sockets(_metadata, self, variant->expected_errno,
110156 (struct sockaddr *)&self->addr6, sizeof(self->addr6),
111157 (struct sockaddr *)&self->addr4, sizeof(self->addr4));
112158 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t