Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Pull networking fixes from Jakub Kicinski:
"Networking fixes, including fixes from netfilter.

Current release - regressions:

- r8169: fix incorrect mac address assignment

- vlan: fix underflow for the real_dev refcnt when vlan creation
fails

- smc: avoid warning of possible recursive locking

Current release - new code bugs:

- vsock/virtio: suppress used length validation

- neigh: fix crash in v6 module initialization error path

Previous releases - regressions:

- af_unix: fix change in behavior in read after shutdown

- igb: fix netpoll exit with traffic, avoid warning

- tls: fix splice_read() when starting mid-record

- lan743x: fix deadlock in lan743x_phy_link_status_change()

- marvell: prestera: fix bridge port operation

Previous releases - always broken:

- tcp_cubic: fix spurious Hystart ACK train detections for
not-cwnd-limited flows

- nexthop: fix refcount issues when replacing IPv6 groups

- nexthop: fix null pointer dereference when IPv6 is not enabled

- phylink: force link down and retrigger resolve on interface change

- mptcp: fix delack timer length calculation and incorrect early
clearing

- ieee802154: handle iftypes as u32, prevent shift-out-of-bounds

- nfc: virtual_ncidev: change default device permissions

- netfilter: ctnetlink: fix error codes and flags used for kernel
side filtering of dumps

- netfilter: flowtable: fix IPv6 tunnel addr match

- ncsi: align payload to 32-bit to fix dropped packets

- iavf: fix deadlock and loss of config during VF interface reset

- ice: avoid bpf_prog refcount underflow

- ocelot: fix broken PTP over IP and PTP API violations

Misc:

- marvell: mvpp2: increase MTU limit when XDP enabled"

* tag 'net-5.16-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (94 commits)
net: dsa: microchip: implement multi-bridge support
net: mscc: ocelot: correctly report the timestamping RX filters in ethtool
net: mscc: ocelot: set up traps for PTP packets
net: ptp: add a definition for the UDP port for IEEE 1588 general messages
net: mscc: ocelot: create a function that replaces an existing VCAP filter
net: mscc: ocelot: don't downgrade timestamping RX filters in SIOCSHWTSTAMP
net: hns3: fix incorrect components info of ethtool --reset command
net: hns3: fix one incorrect value of page pool info when queried by debugfs
net: hns3: add check NULL address for page pool
net: hns3: fix VF RSS failed problem after PF enable multi-TCs
net: qed: fix the array may be out of bound
net/smc: Don't call clcsock shutdown twice when smc shutdown
net: vlan: fix underflow for the real_dev refcnt
ptp: fix filter names in the documentation
ethtool: ioctl: fix potential NULL deref in ethtool_set_coalesce()
nfc: virtual_ncidev: change default device permissions
net/sched: sch_ets: don't peek at classes beyond 'nbands'
net: stmmac: Disable Tx queues when reconfiguring the interface
selftests: tls: test for correct proto_ops
tls: fix replacing proto_ops
...

+1965 -668
+1 -2
Documentation/networking/ipvs-sysctl.rst
··· 37 37 38 38 0: disable any special handling on port reuse. The new 39 39 connection will be delivered to the same real server that was 40 - servicing the previous connection. This will effectively 41 - disable expire_nodest_conn. 40 + servicing the previous connection. 42 41 43 42 bit 1: enable rescheduling of new connections when it is safe. 44 43 That is, whenever expire_nodest_conn and for TCP sockets, when
+2 -2
Documentation/networking/timestamping.rst
··· 486 486 Drivers are free to use a more permissive configuration than the requested 487 487 configuration. It is expected that drivers should only implement directly the 488 488 most generic mode that can be supported. For example if the hardware can 489 - support HWTSTAMP_FILTER_V2_EVENT, then it should generally always upscale 490 - HWTSTAMP_FILTER_V2_L2_SYNC_MESSAGE, and so forth, as HWTSTAMP_FILTER_V2_EVENT 489 + support HWTSTAMP_FILTER_PTP_V2_EVENT, then it should generally always upscale 490 + HWTSTAMP_FILTER_PTP_V2_L2_SYNC, and so forth, as HWTSTAMP_FILTER_PTP_V2_EVENT 491 491 is more generic (and more useful to applications). 492 492 493 493 A driver which supports hardware time stamping shall update the struct
+3 -1
MAINTAINERS
··· 3580 3580 S: Supported 3581 3581 F: drivers/net/ethernet/broadcom/b44.* 3582 3582 3583 - BROADCOM B53 ETHERNET SWITCH DRIVER 3583 + BROADCOM B53/SF2 ETHERNET SWITCH DRIVER 3584 3584 M: Florian Fainelli <f.fainelli@gmail.com> 3585 3585 L: netdev@vger.kernel.org 3586 3586 L: openwrt-devel@lists.openwrt.org (subscribers-only) 3587 3587 S: Supported 3588 3588 F: Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml 3589 3589 F: drivers/net/dsa/b53/* 3590 + F: drivers/net/dsa/bcm_sf2* 3590 3591 F: include/linux/dsa/brcm.h 3591 3592 F: include/linux/platform_data/b53.h 3592 3593 ··· 18494 18493 F: include/uapi/linux/tc_act/ 18495 18494 F: include/uapi/linux/tc_ematch/ 18496 18495 F: net/sched/ 18496 + F: tools/testing/selftests/tc-testing 18497 18497 18498 18498 TC90522 MEDIA DRIVER 18499 18499 M: Akihiro Tsukada <tskd08@gmail.com>
+7 -49
drivers/net/dsa/microchip/ksz8795.c
··· 1002 1002 data &= ~PORT_VLAN_MEMBERSHIP; 1003 1003 data |= (member & dev->port_mask); 1004 1004 ksz_pwrite8(dev, port, P_MIRROR_CTRL, data); 1005 - dev->ports[port].member = member; 1006 1005 } 1007 1006 1008 1007 static void ksz8_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) 1009 1008 { 1010 1009 struct ksz_device *dev = ds->priv; 1011 - int forward = dev->member; 1012 1010 struct ksz_port *p; 1013 - int member = -1; 1014 1011 u8 data; 1015 - 1016 - p = &dev->ports[port]; 1017 1012 1018 1013 ksz_pread8(dev, port, P_STP_CTRL, &data); 1019 1014 data &= ~(PORT_TX_ENABLE | PORT_RX_ENABLE | PORT_LEARN_DISABLE); ··· 1016 1021 switch (state) { 1017 1022 case BR_STATE_DISABLED: 1018 1023 data |= PORT_LEARN_DISABLE; 1019 - if (port < dev->phy_port_cnt) 1020 - member = 0; 1021 1024 break; 1022 1025 case BR_STATE_LISTENING: 1023 1026 data |= (PORT_RX_ENABLE | PORT_LEARN_DISABLE); 1024 - if (port < dev->phy_port_cnt && 1025 - p->stp_state == BR_STATE_DISABLED) 1026 - member = dev->host_mask | p->vid_member; 1027 1027 break; 1028 1028 case BR_STATE_LEARNING: 1029 1029 data |= PORT_RX_ENABLE; 1030 1030 break; 1031 1031 case BR_STATE_FORWARDING: 1032 1032 data |= (PORT_TX_ENABLE | PORT_RX_ENABLE); 1033 - 1034 - /* This function is also used internally. */ 1035 - if (port == dev->cpu_port) 1036 - break; 1037 - 1038 - /* Port is a member of a bridge. */ 1039 - if (dev->br_member & BIT(port)) { 1040 - dev->member |= BIT(port); 1041 - member = dev->member; 1042 - } else { 1043 - member = dev->host_mask | p->vid_member; 1044 - } 1045 1033 break; 1046 1034 case BR_STATE_BLOCKING: 1047 1035 data |= PORT_LEARN_DISABLE; 1048 - if (port < dev->phy_port_cnt && 1049 - p->stp_state == BR_STATE_DISABLED) 1050 - member = dev->host_mask | p->vid_member; 1051 1036 break; 1052 1037 default: 1053 1038 dev_err(ds->dev, "invalid STP state: %d\n", state); ··· 1035 1060 } 1036 1061 1037 1062 ksz_pwrite8(dev, port, P_STP_CTRL, data); 1063 + 1064 + p = &dev->ports[port]; 1038 1065 p->stp_state = state; 1039 - /* Port membership may share register with STP state. */ 1040 - if (member >= 0 && member != p->member) 1041 - ksz8_cfg_port_member(dev, port, (u8)member); 1042 1066 1043 - /* Check if forwarding needs to be updated. */ 1044 - if (state != BR_STATE_FORWARDING) { 1045 - if (dev->br_member & BIT(port)) 1046 - dev->member &= ~BIT(port); 1047 - } 1048 - 1049 - /* When topology has changed the function ksz_update_port_member 1050 - * should be called to modify port forwarding behavior. 1051 - */ 1052 - if (forward != dev->member) 1053 - ksz_update_port_member(dev, port); 1067 + ksz_update_port_member(dev, port); 1054 1068 } 1055 1069 1056 1070 static void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port) ··· 1305 1341 1306 1342 static void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port) 1307 1343 { 1308 - struct ksz_port *p = &dev->ports[port]; 1344 + struct dsa_switch *ds = dev->ds; 1309 1345 struct ksz8 *ksz8 = dev->priv; 1310 1346 const u32 *masks; 1311 1347 u8 member; ··· 1332 1368 if (!ksz_is_ksz88x3(dev)) 1333 1369 ksz8795_cpu_interface_select(dev, port); 1334 1370 1335 - member = dev->port_mask; 1371 + member = dsa_user_ports(ds); 1336 1372 } else { 1337 - member = dev->host_mask | p->vid_member; 1373 + member = BIT(dsa_upstream_port(ds, port)); 1338 1374 } 1375 + 1339 1376 ksz8_cfg_port_member(dev, port, member); 1340 1377 } 1341 1378 ··· 1357 1392 ksz_cfg(dev, regs[S_TAIL_TAG_CTRL], masks[SW_TAIL_TAG_ENABLE], true); 1358 1393 1359 1394 p = &dev->ports[dev->cpu_port]; 1360 - p->vid_member = dev->port_mask; 1361 1395 p->on = 1; 1362 1396 1363 1397 ksz8_port_setup(dev, dev->cpu_port, true); 1364 - dev->member = dev->host_mask; 1365 1398 1366 1399 for (i = 0; i < dev->phy_port_cnt; i++) { 1367 1400 p = &dev->ports[i]; 1368 1401 1369 - /* Initialize to non-zero so that ksz_cfg_port_member() will 1370 - * be called. 1371 - */ 1372 - p->vid_member = BIT(i); 1373 - p->member = dev->port_mask; 1374 1402 ksz8_port_stp_state_set(ds, i, BR_STATE_DISABLED); 1375 1403 1376 1404 /* Last port may be disabled. */
+8 -58
drivers/net/dsa/microchip/ksz9477.c
··· 391 391 u8 member) 392 392 { 393 393 ksz_pwrite32(dev, port, REG_PORT_VLAN_MEMBERSHIP__4, member); 394 - dev->ports[port].member = member; 395 394 } 396 395 397 396 static void ksz9477_port_stp_state_set(struct dsa_switch *ds, int port, ··· 399 400 struct ksz_device *dev = ds->priv; 400 401 struct ksz_port *p = &dev->ports[port]; 401 402 u8 data; 402 - int member = -1; 403 - int forward = dev->member; 404 403 405 404 ksz_pread8(dev, port, P_STP_CTRL, &data); 406 405 data &= ~(PORT_TX_ENABLE | PORT_RX_ENABLE | PORT_LEARN_DISABLE); ··· 406 409 switch (state) { 407 410 case BR_STATE_DISABLED: 408 411 data |= PORT_LEARN_DISABLE; 409 - if (port != dev->cpu_port) 410 - member = 0; 411 412 break; 412 413 case BR_STATE_LISTENING: 413 414 data |= (PORT_RX_ENABLE | PORT_LEARN_DISABLE); 414 - if (port != dev->cpu_port && 415 - p->stp_state == BR_STATE_DISABLED) 416 - member = dev->host_mask | p->vid_member; 417 415 break; 418 416 case BR_STATE_LEARNING: 419 417 data |= PORT_RX_ENABLE; 420 418 break; 421 419 case BR_STATE_FORWARDING: 422 420 data |= (PORT_TX_ENABLE | PORT_RX_ENABLE); 423 - 424 - /* This function is also used internally. */ 425 - if (port == dev->cpu_port) 426 - break; 427 - 428 - member = dev->host_mask | p->vid_member; 429 - mutex_lock(&dev->dev_mutex); 430 - 431 - /* Port is a member of a bridge. */ 432 - if (dev->br_member & (1 << port)) { 433 - dev->member |= (1 << port); 434 - member = dev->member; 435 - } 436 - mutex_unlock(&dev->dev_mutex); 437 421 break; 438 422 case BR_STATE_BLOCKING: 439 423 data |= PORT_LEARN_DISABLE; 440 - if (port != dev->cpu_port && 441 - p->stp_state == BR_STATE_DISABLED) 442 - member = dev->host_mask | p->vid_member; 443 424 break; 444 425 default: 445 426 dev_err(ds->dev, "invalid STP state: %d\n", state); ··· 426 451 427 452 ksz_pwrite8(dev, port, P_STP_CTRL, data); 428 453 p->stp_state = state; 429 - mutex_lock(&dev->dev_mutex); 430 - /* Port membership may share register with STP state. */ 431 - if (member >= 0 && member != p->member) 432 - ksz9477_cfg_port_member(dev, port, (u8)member); 433 454 434 - /* Check if forwarding needs to be updated. */ 435 - if (state != BR_STATE_FORWARDING) { 436 - if (dev->br_member & (1 << port)) 437 - dev->member &= ~(1 << port); 438 - } 439 - 440 - /* When topology has changed the function ksz_update_port_member 441 - * should be called to modify port forwarding behavior. 442 - */ 443 - if (forward != dev->member) 444 - ksz_update_port_member(dev, port); 445 - mutex_unlock(&dev->dev_mutex); 455 + ksz_update_port_member(dev, port); 446 456 } 447 457 448 458 static void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port) ··· 1128 1168 1129 1169 static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port) 1130 1170 { 1131 - u8 data8; 1132 - u8 member; 1133 - u16 data16; 1134 1171 struct ksz_port *p = &dev->ports[port]; 1172 + struct dsa_switch *ds = dev->ds; 1173 + u8 data8, member; 1174 + u16 data16; 1135 1175 1136 1176 /* enable tag tail for host port */ 1137 1177 if (cpu_port) ··· 1210 1250 ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_1, data8); 1211 1251 p->phydev.duplex = 1; 1212 1252 } 1213 - mutex_lock(&dev->dev_mutex); 1253 + 1214 1254 if (cpu_port) 1215 - member = dev->port_mask; 1255 + member = dsa_user_ports(ds); 1216 1256 else 1217 - member = dev->host_mask | p->vid_member; 1218 - mutex_unlock(&dev->dev_mutex); 1257 + member = BIT(dsa_upstream_port(ds, port)); 1258 + 1219 1259 ksz9477_cfg_port_member(dev, port, member); 1220 1260 1221 1261 /* clear pending interrupts */ ··· 1236 1276 const char *prev_mode; 1237 1277 1238 1278 dev->cpu_port = i; 1239 - dev->host_mask = (1 << dev->cpu_port); 1240 - dev->port_mask |= dev->host_mask; 1241 1279 p = &dev->ports[i]; 1242 1280 1243 1281 /* Read from XMII register to determine host port ··· 1270 1312 1271 1313 /* enable cpu port */ 1272 1314 ksz9477_port_setup(dev, i, true); 1273 - p->vid_member = dev->port_mask; 1274 1315 p->on = 1; 1275 1316 } 1276 1317 } 1277 - 1278 - dev->member = dev->host_mask; 1279 1318 1280 1319 for (i = 0; i < dev->port_cnt; i++) { 1281 1320 if (i == dev->cpu_port) 1282 1321 continue; 1283 1322 p = &dev->ports[i]; 1284 1323 1285 - /* Initialize to non-zero so that ksz_cfg_port_member() will 1286 - * be called. 1287 - */ 1288 - p->vid_member = (1 << i); 1289 - p->member = dev->port_mask; 1290 1324 ksz9477_port_stp_state_set(ds, i, BR_STATE_DISABLED); 1291 1325 p->on = 1; 1292 1326 if (i < dev->phy_port_cnt)
+28 -22
drivers/net/dsa/microchip/ksz_common.c
··· 22 22 23 23 void ksz_update_port_member(struct ksz_device *dev, int port) 24 24 { 25 - struct ksz_port *p; 25 + struct ksz_port *p = &dev->ports[port]; 26 + struct dsa_switch *ds = dev->ds; 27 + u8 port_member = 0, cpu_port; 28 + const struct dsa_port *dp; 26 29 int i; 27 30 28 - for (i = 0; i < dev->port_cnt; i++) { 29 - if (i == port || i == dev->cpu_port) 31 + if (!dsa_is_user_port(ds, port)) 32 + return; 33 + 34 + dp = dsa_to_port(ds, port); 35 + cpu_port = BIT(dsa_upstream_port(ds, port)); 36 + 37 + for (i = 0; i < ds->num_ports; i++) { 38 + const struct dsa_port *other_dp = dsa_to_port(ds, i); 39 + struct ksz_port *other_p = &dev->ports[i]; 40 + u8 val = 0; 41 + 42 + if (!dsa_is_user_port(ds, i)) 30 43 continue; 31 - p = &dev->ports[i]; 32 - if (!(dev->member & (1 << i))) 44 + if (port == i) 45 + continue; 46 + if (!dp->bridge_dev || dp->bridge_dev != other_dp->bridge_dev) 33 47 continue; 34 48 35 - /* Port is a member of the bridge and is forwarding. */ 36 - if (p->stp_state == BR_STATE_FORWARDING && 37 - p->member != dev->member) 38 - dev->dev_ops->cfg_port_member(dev, i, dev->member); 49 + if (other_p->stp_state == BR_STATE_FORWARDING && 50 + p->stp_state == BR_STATE_FORWARDING) { 51 + val |= BIT(port); 52 + port_member |= BIT(i); 53 + } 54 + 55 + dev->dev_ops->cfg_port_member(dev, i, val | cpu_port); 39 56 } 57 + 58 + dev->dev_ops->cfg_port_member(dev, port, port_member | cpu_port); 40 59 } 41 60 EXPORT_SYMBOL_GPL(ksz_update_port_member); 42 61 ··· 194 175 int ksz_port_bridge_join(struct dsa_switch *ds, int port, 195 176 struct net_device *br) 196 177 { 197 - struct ksz_device *dev = ds->priv; 198 - 199 - mutex_lock(&dev->dev_mutex); 200 - dev->br_member |= (1 << port); 201 - mutex_unlock(&dev->dev_mutex); 202 - 203 178 /* port_stp_state_set() will be called after to put the port in 204 179 * appropriate state so there is no need to do anything. 205 180 */ ··· 205 192 void ksz_port_bridge_leave(struct dsa_switch *ds, int port, 206 193 struct net_device *br) 207 194 { 208 - struct ksz_device *dev = ds->priv; 209 - 210 - mutex_lock(&dev->dev_mutex); 211 - dev->br_member &= ~(1 << port); 212 - dev->member &= ~(1 << port); 213 - mutex_unlock(&dev->dev_mutex); 214 - 215 195 /* port_stp_state_set() will be called after to put the port in 216 196 * forwarding state so there is no need to do anything. 217 197 */
-4
drivers/net/dsa/microchip/ksz_common.h
··· 25 25 }; 26 26 27 27 struct ksz_port { 28 - u16 member; 29 - u16 vid_member; 30 28 bool remove_tag; /* Remove Tag flag set, for ksz8795 only */ 31 29 int stp_state; 32 30 struct phy_device phydev; ··· 81 83 struct ksz_port *ports; 82 84 struct delayed_work mib_read; 83 85 unsigned long mib_read_interval; 84 - u16 br_member; 85 - u16 member; 86 86 u16 mirror_rx; 87 87 u16 mirror_tx; 88 88 u32 features; /* chip specific features */
+11 -7
drivers/net/dsa/qca8k.c
··· 1256 1256 /* Set initial MTU for every port. 1257 1257 * We have only have a general MTU setting. So track 1258 1258 * every port and set the max across all port. 1259 + * Set per port MTU to 1500 as the MTU change function 1260 + * will add the overhead and if its set to 1518 then it 1261 + * will apply the overhead again and we will end up with 1262 + * MTU of 1536 instead of 1518 1259 1263 */ 1260 - priv->port_mtu[i] = ETH_FRAME_LEN + ETH_FCS_LEN; 1264 + priv->port_mtu[i] = ETH_DATA_LEN; 1261 1265 } 1262 1266 1263 1267 /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */ ··· 1437 1433 1438 1434 qca8k_write(priv, QCA8K_REG_SGMII_CTRL, val); 1439 1435 1436 + /* From original code is reported port instability as SGMII also 1437 + * require delay set. Apply advised values here or take them from DT. 1438 + */ 1439 + if (state->interface == PHY_INTERFACE_MODE_SGMII) 1440 + qca8k_mac_config_setup_internal_delay(priv, cpu_port_index, reg); 1441 + 1440 1442 /* For qca8327/qca8328/qca8334/qca8338 sgmii is unique and 1441 1443 * falling edge is set writing in the PORT0 PAD reg 1442 1444 */ ··· 1464 1454 QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE | 1465 1455 QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE, 1466 1456 val); 1467 - 1468 - /* From original code is reported port instability as SGMII also 1469 - * require delay set. Apply advised values here or take them from DT. 1470 - */ 1471 - if (state->interface == PHY_INTERFACE_MODE_SGMII) 1472 - qca8k_mac_config_setup_internal_delay(priv, cpu_port_index, reg); 1473 1457 1474 1458 break; 1475 1459 default:
+2 -1
drivers/net/ethernet/aquantia/atlantic/aq_ring.c
··· 298 298 } 299 299 } 300 300 301 - if (unlikely(buff->is_eop)) { 301 + if (unlikely(buff->is_eop && buff->skb)) { 302 302 u64_stats_update_begin(&self->stats.tx.syncp); 303 303 ++self->stats.tx.packets; 304 304 self->stats.tx.bytes += buff->skb->len; 305 305 u64_stats_update_end(&self->stats.tx.syncp); 306 306 307 307 dev_kfree_skb_any(buff->skb); 308 + buff->skb = NULL; 308 309 } 309 310 buff->pa = 0U; 310 311 buff->eop_index = 0xffffU;
+1 -1
drivers/net/ethernet/asix/ax88796c_spi.c
··· 34 34 35 35 /* OP */ 36 36 ax_spi->cmd_buf[0] = AX_SPICMD_READ_STATUS; 37 - ret = spi_write_then_read(ax_spi->spi, ax_spi->cmd_buf, 1, (u8 *)&status, 3); 37 + ret = spi_write_then_read(ax_spi->spi, ax_spi->cmd_buf, 1, (u8 *)status, 3); 38 38 if (ret) 39 39 dev_err(&ax_spi->spi->dev, "%s() failed: ret = %d\n", __func__, ret); 40 40 else
+1
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
··· 3196 3196 } 3197 3197 if (adapter->registered_device_map == 0) { 3198 3198 dev_err(&pdev->dev, "could not register any net devices\n"); 3199 + err = -EINVAL; 3199 3200 goto err_disable_interrupts; 3200 3201 } 3201 3202
+7 -1
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
··· 1081 1081 u32 j = 0; 1082 1082 1083 1083 sprintf(result[j++], "%u", index); 1084 - sprintf(result[j++], "%u", ring->page_pool->pages_state_hold_cnt); 1084 + sprintf(result[j++], "%u", 1085 + READ_ONCE(ring->page_pool->pages_state_hold_cnt)); 1085 1086 sprintf(result[j++], "%u", 1086 1087 atomic_read(&ring->page_pool->pages_state_release_cnt)); 1087 1088 sprintf(result[j++], "%u", ring->page_pool->p.pool_size); ··· 1104 1103 1105 1104 if (!priv->ring) { 1106 1105 dev_err(&h->pdev->dev, "priv->ring is NULL\n"); 1106 + return -EFAULT; 1107 + } 1108 + 1109 + if (!priv->ring[h->kinfo.num_tqps].page_pool) { 1110 + dev_err(&h->pdev->dev, "page pool is not initialized\n"); 1107 1111 return -EFAULT; 1108 1112 } 1109 1113
+4
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
··· 987 987 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); 988 988 const struct hnae3_ae_ops *ops = h->ae_algo->ops; 989 989 const struct hns3_reset_type_map *rst_type_map; 990 + enum ethtool_reset_flags rst_flags; 990 991 u32 i, size; 991 992 992 993 if (ops->ae_dev_resetting && ops->ae_dev_resetting(h)) ··· 1007 1006 for (i = 0; i < size; i++) { 1008 1007 if (rst_type_map[i].rst_flags == *flags) { 1009 1008 rst_type = rst_type_map[i].rst_type; 1009 + rst_flags = rst_type_map[i].rst_flags; 1010 1010 break; 1011 1011 } 1012 1012 } ··· 1022 1020 ops->set_default_reset_request(ae_dev, rst_type); 1023 1021 1024 1022 ops->reset_event(h->pdev, h); 1023 + 1024 + *flags &= ~rst_flags; 1025 1025 1026 1026 return 0; 1027 1027 }
+2 -2
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
··· 703 703 roundup_size = ilog2(roundup_size); 704 704 705 705 for (i = 0; i < HCLGEVF_MAX_TC_NUM; i++) { 706 - tc_valid[i] = !!(hdev->hw_tc_map & BIT(i)); 706 + tc_valid[i] = 1; 707 707 tc_size[i] = roundup_size; 708 - tc_offset[i] = rss_size * i; 708 + tc_offset[i] = (hdev->hw_tc_map & BIT(i)) ? rss_size * i : 0; 709 709 } 710 710 711 711 hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_RSS_TC_MODE, false);
+3
drivers/net/ethernet/intel/iavf/iavf.h
··· 305 305 #define IAVF_FLAG_AQ_DEL_FDIR_FILTER BIT(26) 306 306 #define IAVF_FLAG_AQ_ADD_ADV_RSS_CFG BIT(27) 307 307 #define IAVF_FLAG_AQ_DEL_ADV_RSS_CFG BIT(28) 308 + #define IAVF_FLAG_AQ_REQUEST_STATS BIT(29) 308 309 309 310 /* OS defined structs */ 310 311 struct net_device *netdev; ··· 445 444 void iavf_down(struct iavf_adapter *adapter); 446 445 int iavf_process_config(struct iavf_adapter *adapter); 447 446 void iavf_schedule_reset(struct iavf_adapter *adapter); 447 + void iavf_schedule_request_stats(struct iavf_adapter *adapter); 448 448 void iavf_reset(struct iavf_adapter *adapter); 449 449 void iavf_set_ethtool_ops(struct net_device *netdev); 450 450 void iavf_update_stats(struct iavf_adapter *adapter); ··· 503 501 void iavf_del_adv_rss_cfg(struct iavf_adapter *adapter); 504 502 struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter, 505 503 const u8 *macaddr); 504 + int iavf_lock_timeout(struct mutex *lock, unsigned int msecs); 506 505 #endif /* _IAVF_H_ */
+29 -4
drivers/net/ethernet/intel/iavf/iavf_ethtool.c
··· 354 354 struct iavf_adapter *adapter = netdev_priv(netdev); 355 355 unsigned int i; 356 356 357 + /* Explicitly request stats refresh */ 358 + iavf_schedule_request_stats(adapter); 359 + 357 360 iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats); 358 361 359 362 rcu_read_lock(); ··· 726 723 * 727 724 * Change the ITR settings for a specific queue. 728 725 **/ 729 - static void iavf_set_itr_per_queue(struct iavf_adapter *adapter, 730 - struct ethtool_coalesce *ec, int queue) 726 + static int iavf_set_itr_per_queue(struct iavf_adapter *adapter, 727 + struct ethtool_coalesce *ec, int queue) 731 728 { 732 729 struct iavf_ring *rx_ring = &adapter->rx_rings[queue]; 733 730 struct iavf_ring *tx_ring = &adapter->tx_rings[queue]; 734 731 struct iavf_q_vector *q_vector; 732 + u16 itr_setting; 733 + 734 + itr_setting = rx_ring->itr_setting & ~IAVF_ITR_DYNAMIC; 735 + 736 + if (ec->rx_coalesce_usecs != itr_setting && 737 + ec->use_adaptive_rx_coalesce) { 738 + netif_info(adapter, drv, adapter->netdev, 739 + "Rx interrupt throttling cannot be changed if adaptive-rx is enabled\n"); 740 + return -EINVAL; 741 + } 742 + 743 + itr_setting = tx_ring->itr_setting & ~IAVF_ITR_DYNAMIC; 744 + 745 + if (ec->tx_coalesce_usecs != itr_setting && 746 + ec->use_adaptive_tx_coalesce) { 747 + netif_info(adapter, drv, adapter->netdev, 748 + "Tx interrupt throttling cannot be changed if adaptive-tx is enabled\n"); 749 + return -EINVAL; 750 + } 735 751 736 752 rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs); 737 753 tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs); ··· 773 751 * the Tx and Rx ITR values based on the values we have entered 774 752 * into the q_vector, no need to write the values now. 775 753 */ 754 + return 0; 776 755 } 777 756 778 757 /** ··· 815 792 */ 816 793 if (queue < 0) { 817 794 for (i = 0; i < adapter->num_active_queues; i++) 818 - iavf_set_itr_per_queue(adapter, ec, i); 795 + if (iavf_set_itr_per_queue(adapter, ec, i)) 796 + return -EINVAL; 819 797 } else if (queue < adapter->num_active_queues) { 820 - iavf_set_itr_per_queue(adapter, ec, queue); 798 + if (iavf_set_itr_per_queue(adapter, ec, queue)) 799 + return -EINVAL; 821 800 } else { 822 801 netif_info(adapter, drv, netdev, "Invalid queue value, queue range is 0 - %d\n", 823 802 adapter->num_active_queues - 1);
+36 -22
drivers/net/ethernet/intel/iavf/iavf_main.c
··· 147 147 * 148 148 * Returns 0 on success, negative on failure 149 149 **/ 150 - static int iavf_lock_timeout(struct mutex *lock, unsigned int msecs) 150 + int iavf_lock_timeout(struct mutex *lock, unsigned int msecs) 151 151 { 152 152 unsigned int wait, delay = 10; 153 153 ··· 172 172 adapter->flags |= IAVF_FLAG_RESET_NEEDED; 173 173 queue_work(iavf_wq, &adapter->reset_task); 174 174 } 175 + } 176 + 177 + /** 178 + * iavf_schedule_request_stats - Set the flags and schedule statistics request 179 + * @adapter: board private structure 180 + * 181 + * Sets IAVF_FLAG_AQ_REQUEST_STATS flag so iavf_watchdog_task() will explicitly 182 + * request and refresh ethtool stats 183 + **/ 184 + void iavf_schedule_request_stats(struct iavf_adapter *adapter) 185 + { 186 + adapter->aq_required |= IAVF_FLAG_AQ_REQUEST_STATS; 187 + mod_delayed_work(iavf_wq, &adapter->watchdog_task, 0); 175 188 } 176 189 177 190 /** ··· 717 704 **/ 718 705 static void iavf_restore_filters(struct iavf_adapter *adapter) 719 706 { 720 - /* re-add all VLAN filters */ 721 - if (VLAN_ALLOWED(adapter)) { 722 - u16 vid; 707 + u16 vid; 723 708 724 - for_each_set_bit(vid, adapter->vsi.active_vlans, VLAN_N_VID) 725 - iavf_add_vlan(adapter, vid); 726 - } 709 + /* re-add all VLAN filters */ 710 + for_each_set_bit(vid, adapter->vsi.active_vlans, VLAN_N_VID) 711 + iavf_add_vlan(adapter, vid); 727 712 } 728 713 729 714 /** ··· 755 744 __always_unused __be16 proto, u16 vid) 756 745 { 757 746 struct iavf_adapter *adapter = netdev_priv(netdev); 758 - 759 - if (!VLAN_ALLOWED(adapter)) 760 - return -EIO; 761 747 762 748 iavf_del_vlan(adapter, vid); 763 749 clear_bit(vid, adapter->vsi.active_vlans); ··· 1717 1709 iavf_del_adv_rss_cfg(adapter); 1718 1710 return 0; 1719 1711 } 1712 + if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_STATS) { 1713 + iavf_request_stats(adapter); 1714 + return 0; 1715 + } 1716 + 1720 1717 return -EAGAIN; 1721 1718 } 1722 1719 ··· 2186 2173 struct net_device *netdev = adapter->netdev; 2187 2174 struct iavf_hw *hw = &adapter->hw; 2188 2175 struct iavf_mac_filter *f, *ftmp; 2189 - struct iavf_vlan_filter *vlf; 2190 2176 struct iavf_cloud_filter *cf; 2191 2177 u32 reg_val; 2192 2178 int i = 0, err; ··· 2266 2254 (adapter->state == __IAVF_RESETTING)); 2267 2255 2268 2256 if (running) { 2257 + netdev->flags &= ~IFF_UP; 2269 2258 netif_carrier_off(netdev); 2270 2259 netif_tx_stop_all_queues(netdev); 2271 2260 adapter->link_up = false; ··· 2326 2313 list_for_each_entry(f, &adapter->mac_filter_list, list) { 2327 2314 f->add = true; 2328 2315 } 2329 - /* re-add all VLAN filters */ 2330 - list_for_each_entry(vlf, &adapter->vlan_filter_list, list) { 2331 - vlf->add = true; 2332 - } 2333 - 2334 2316 spin_unlock_bh(&adapter->mac_vlan_list_lock); 2335 2317 2336 2318 /* check if TCs are running and re-add all cloud filters */ ··· 2339 2331 spin_unlock_bh(&adapter->cloud_filter_list_lock); 2340 2332 2341 2333 adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; 2342 - adapter->aq_required |= IAVF_FLAG_AQ_ADD_VLAN_FILTER; 2343 2334 adapter->aq_required |= IAVF_FLAG_AQ_ADD_CLOUD_FILTER; 2344 2335 iavf_misc_irq_enable(adapter); 2345 2336 ··· 2372 2365 * to __IAVF_RUNNING 2373 2366 */ 2374 2367 iavf_up_complete(adapter); 2375 - 2368 + netdev->flags |= IFF_UP; 2376 2369 iavf_irq_enable(adapter, true); 2377 2370 } else { 2378 2371 iavf_change_state(adapter, __IAVF_DOWN); ··· 2385 2378 reset_err: 2386 2379 mutex_unlock(&adapter->client_lock); 2387 2380 mutex_unlock(&adapter->crit_lock); 2388 - if (running) 2381 + if (running) { 2389 2382 iavf_change_state(adapter, __IAVF_RUNNING); 2383 + netdev->flags |= IFF_UP; 2384 + } 2390 2385 dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n"); 2391 2386 iavf_close(netdev); 2392 2387 } ··· 3450 3441 { 3451 3442 struct iavf_adapter *adapter = netdev_priv(netdev); 3452 3443 3453 - /* Don't allow changing VLAN_RX flag when adapter is not capable 3454 - * of VLAN offload 3444 + /* Don't allow enabling VLAN features when adapter is not capable 3445 + * of VLAN offload/filtering 3455 3446 */ 3456 3447 if (!VLAN_ALLOWED(adapter)) { 3457 - if ((netdev->features ^ features) & NETIF_F_HW_VLAN_CTAG_RX) 3448 + netdev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_RX | 3449 + NETIF_F_HW_VLAN_CTAG_TX | 3450 + NETIF_F_HW_VLAN_CTAG_FILTER); 3451 + if (features & (NETIF_F_HW_VLAN_CTAG_RX | 3452 + NETIF_F_HW_VLAN_CTAG_TX | 3453 + NETIF_F_HW_VLAN_CTAG_FILTER)) 3458 3454 return -EINVAL; 3459 3455 } else if ((netdev->features ^ features) & NETIF_F_HW_VLAN_CTAG_RX) { 3460 3456 if (features & NETIF_F_HW_VLAN_CTAG_RX)
+44 -3
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
··· 607 607 if (f->add) 608 608 count++; 609 609 } 610 - if (!count) { 610 + if (!count || !VLAN_ALLOWED(adapter)) { 611 611 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER; 612 612 spin_unlock_bh(&adapter->mac_vlan_list_lock); 613 613 return; ··· 673 673 674 674 spin_lock_bh(&adapter->mac_vlan_list_lock); 675 675 676 - list_for_each_entry(f, &adapter->vlan_filter_list, list) { 677 - if (f->remove) 676 + list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { 677 + /* since VLAN capabilities are not allowed, we dont want to send 678 + * a VLAN delete request because it will most likely fail and 679 + * create unnecessary errors/noise, so just free the VLAN 680 + * filters marked for removal to enable bailing out before 681 + * sending a virtchnl message 682 + */ 683 + if (f->remove && !VLAN_ALLOWED(adapter)) { 684 + list_del(&f->list); 685 + kfree(f); 686 + } else if (f->remove) { 678 687 count++; 688 + } 679 689 } 680 690 if (!count) { 681 691 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER; ··· 794 784 /* no error message, this isn't crucial */ 795 785 return; 796 786 } 787 + 788 + adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_STATS; 797 789 adapter->current_op = VIRTCHNL_OP_GET_STATS; 798 790 vqs.vsi_id = adapter->vsi_res->vsi_id; 799 791 /* queue maps are ignored for this message - only the vsi is used */ ··· 1734 1722 } 1735 1723 spin_lock_bh(&adapter->mac_vlan_list_lock); 1736 1724 iavf_add_filter(adapter, adapter->hw.mac.addr); 1725 + 1726 + if (VLAN_ALLOWED(adapter)) { 1727 + if (!list_empty(&adapter->vlan_filter_list)) { 1728 + struct iavf_vlan_filter *vlf; 1729 + 1730 + /* re-add all VLAN filters over virtchnl */ 1731 + list_for_each_entry(vlf, 1732 + &adapter->vlan_filter_list, 1733 + list) 1734 + vlf->add = true; 1735 + 1736 + adapter->aq_required |= 1737 + IAVF_FLAG_AQ_ADD_VLAN_FILTER; 1738 + } 1739 + } 1740 + 1737 1741 spin_unlock_bh(&adapter->mac_vlan_list_lock); 1738 1742 iavf_process_config(adapter); 1743 + 1744 + /* unlock crit_lock before acquiring rtnl_lock as other 1745 + * processes holding rtnl_lock could be waiting for the same 1746 + * crit_lock 1747 + */ 1748 + mutex_unlock(&adapter->crit_lock); 1749 + rtnl_lock(); 1750 + netdev_update_features(adapter->netdev); 1751 + rtnl_unlock(); 1752 + if (iavf_lock_timeout(&adapter->crit_lock, 10000)) 1753 + dev_warn(&adapter->pdev->dev, "failed to acquire crit_lock in %s\n", 1754 + __FUNCTION__); 1755 + 1739 1756 } 1740 1757 break; 1741 1758 case VIRTCHNL_OP_ENABLE_QUEUES:
+7 -2
drivers/net/ethernet/intel/ice/ice_lib.c
··· 89 89 if (!vsi->rx_rings) 90 90 goto err_rings; 91 91 92 - /* XDP will have vsi->alloc_txq Tx queues as well, so double the size */ 93 - vsi->txq_map = devm_kcalloc(dev, (2 * vsi->alloc_txq), 92 + /* txq_map needs to have enough space to track both Tx (stack) rings 93 + * and XDP rings; at this point vsi->num_xdp_txq might not be set, 94 + * so use num_possible_cpus() as we want to always provide XDP ring 95 + * per CPU, regardless of queue count settings from user that might 96 + * have come from ethtool's set_channels() callback; 97 + */ 98 + vsi->txq_map = devm_kcalloc(dev, (vsi->alloc_txq + num_possible_cpus()), 94 99 sizeof(*vsi->txq_map), GFP_KERNEL); 95 100 96 101 if (!vsi->txq_map)
+17 -1
drivers/net/ethernet/intel/ice/ice_main.c
··· 2609 2609 ice_stat_str(status)); 2610 2610 goto clear_xdp_rings; 2611 2611 } 2612 - ice_vsi_assign_bpf_prog(vsi, prog); 2612 + 2613 + /* assign the prog only when it's not already present on VSI; 2614 + * this flow is a subject of both ethtool -L and ndo_bpf flows; 2615 + * VSI rebuild that happens under ethtool -L can expose us to 2616 + * the bpf_prog refcount issues as we would be swapping same 2617 + * bpf_prog pointers from vsi->xdp_prog and calling bpf_prog_put 2618 + * on it as it would be treated as an 'old_prog'; for ndo_bpf 2619 + * this is not harmful as dev_xdp_install bumps the refcount 2620 + * before calling the op exposed by the driver; 2621 + */ 2622 + if (!ice_is_xdp_ena_vsi(vsi)) 2623 + ice_vsi_assign_bpf_prog(vsi, prog); 2613 2624 2614 2625 return 0; 2615 2626 clear_xdp_rings: ··· 2796 2785 if (xdp_ring_err) 2797 2786 NL_SET_ERR_MSG_MOD(extack, "Freeing XDP Tx resources failed"); 2798 2787 } else { 2788 + /* safe to call even when prog == vsi->xdp_prog as 2789 + * dev_xdp_install in net/core/dev.c incremented prog's 2790 + * refcount so corresponding bpf_prog_put won't cause 2791 + * underflow 2792 + */ 2799 2793 ice_vsi_assign_bpf_prog(vsi, prog); 2800 2794 } 2801 2795
+1 -1
drivers/net/ethernet/intel/igb/igb_main.c
··· 8026 8026 if (likely(napi_complete_done(napi, work_done))) 8027 8027 igb_ring_irq_enable(q_vector); 8028 8028 8029 - return min(work_done, budget - 1); 8029 + return work_done; 8030 8030 } 8031 8031 8032 8032 /**
+8 -6
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
··· 5017 5017 mtu = ALIGN(MVPP2_RX_PKT_SIZE(mtu), 8); 5018 5018 } 5019 5019 5020 + if (port->xdp_prog && mtu > MVPP2_MAX_RX_BUF_SIZE) { 5021 + netdev_err(dev, "Illegal MTU value %d (> %d) for XDP mode\n", 5022 + mtu, (int)MVPP2_MAX_RX_BUF_SIZE); 5023 + return -EINVAL; 5024 + } 5025 + 5020 5026 if (MVPP2_RX_PKT_SIZE(mtu) > MVPP2_BM_LONG_PKT_SIZE) { 5021 - if (port->xdp_prog) { 5022 - netdev_err(dev, "Jumbo frames are not supported with XDP\n"); 5023 - return -EINVAL; 5024 - } 5025 5027 if (priv->percpu_pools) { 5026 5028 netdev_warn(dev, "mtu %d too high, switching to shared buffers", mtu); 5027 5029 mvpp2_bm_switch_buffers(priv, false); ··· 5309 5307 bool running = netif_running(port->dev); 5310 5308 bool reset = !prog != !port->xdp_prog; 5311 5309 5312 - if (port->dev->mtu > ETH_DATA_LEN) { 5313 - NL_SET_ERR_MSG_MOD(bpf->extack, "XDP is not supported with jumbo frames enabled"); 5310 + if (port->dev->mtu > MVPP2_MAX_RX_BUF_SIZE) { 5311 + NL_SET_ERR_MSG_MOD(bpf->extack, "MTU too large for XDP"); 5314 5312 return -EOPNOTSUPP; 5315 5313 } 5316 5314
+3 -5
drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
··· 497 497 498 498 br_port = prestera_bridge_port_add(bridge, port->dev); 499 499 if (IS_ERR(br_port)) { 500 - err = PTR_ERR(br_port); 501 - goto err_brport_create; 500 + prestera_bridge_put(bridge); 501 + return PTR_ERR(br_port); 502 502 } 503 503 504 504 err = switchdev_bridge_port_offload(br_port->dev, port->dev, NULL, ··· 519 519 switchdev_bridge_port_unoffload(br_port->dev, NULL, NULL, NULL); 520 520 err_switchdev_offload: 521 521 prestera_bridge_port_put(br_port); 522 - err_brport_create: 523 - prestera_bridge_put(bridge); 524 522 return err; 525 523 } 526 524 ··· 1122 1124 prestera_port_obj_attr_set); 1123 1125 break; 1124 1126 default: 1125 - err = -EOPNOTSUPP; 1127 + return NOTIFY_DONE; 1126 1128 } 1127 1129 1128 1130 return notifier_from_errno(err);
+5 -5
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
··· 2153 2153 max_ports = mlxsw_core_max_ports(mlxsw_sp->core); 2154 2154 local_port = mlxsw_reg_pude_local_port_get(pude_pl); 2155 2155 2156 - if (WARN_ON_ONCE(local_port >= max_ports)) 2156 + if (WARN_ON_ONCE(!local_port || local_port >= max_ports)) 2157 2157 return; 2158 2158 mlxsw_sp_port = mlxsw_sp->ports[local_port]; 2159 2159 if (!mlxsw_sp_port) ··· 3290 3290 u8 max_rif_mac_profiles; 3291 3291 3292 3292 if (!MLXSW_CORE_RES_VALID(mlxsw_core, MAX_RIF_MAC_PROFILES)) 3293 - return -EIO; 3294 - 3295 - max_rif_mac_profiles = MLXSW_CORE_RES_GET(mlxsw_core, 3296 - MAX_RIF_MAC_PROFILES); 3293 + max_rif_mac_profiles = 1; 3294 + else 3295 + max_rif_mac_profiles = MLXSW_CORE_RES_GET(mlxsw_core, 3296 + MAX_RIF_MAC_PROFILES); 3297 3297 devlink_resource_size_params_init(&size_params, max_rif_mac_profiles, 3298 3298 max_rif_mac_profiles, 1, 3299 3299 DEVLINK_RESOURCE_UNIT_ENTRY);
+3 -9
drivers/net/ethernet/microchip/lan743x_main.c
··· 914 914 } 915 915 916 916 static void lan743x_phy_update_flowcontrol(struct lan743x_adapter *adapter, 917 - u8 duplex, u16 local_adv, 918 - u16 remote_adv) 917 + u16 local_adv, u16 remote_adv) 919 918 { 920 919 struct lan743x_phy *phy = &adapter->phy; 921 920 u8 cap; ··· 942 943 943 944 phy_print_status(phydev); 944 945 if (phydev->state == PHY_RUNNING) { 945 - struct ethtool_link_ksettings ksettings; 946 946 int remote_advertisement = 0; 947 947 int local_advertisement = 0; 948 948 ··· 978 980 } 979 981 lan743x_csr_write(adapter, MAC_CR, data); 980 982 981 - memset(&ksettings, 0, sizeof(ksettings)); 982 - phy_ethtool_get_link_ksettings(netdev, &ksettings); 983 983 local_advertisement = 984 984 linkmode_adv_to_mii_adv_t(phydev->advertising); 985 985 remote_advertisement = 986 986 linkmode_adv_to_mii_adv_t(phydev->lp_advertising); 987 987 988 - lan743x_phy_update_flowcontrol(adapter, 989 - ksettings.base.duplex, 990 - local_advertisement, 988 + lan743x_phy_update_flowcontrol(adapter, local_advertisement, 991 989 remote_advertisement); 992 - lan743x_ptp_update_latency(adapter, ksettings.base.speed); 990 + lan743x_ptp_update_latency(adapter, phydev->speed); 993 991 } 994 992 } 995 993
+244 -8
drivers/net/ethernet/mscc/ocelot.c
··· 1278 1278 } 1279 1279 EXPORT_SYMBOL(ocelot_fdb_dump); 1280 1280 1281 + static void ocelot_populate_l2_ptp_trap_key(struct ocelot_vcap_filter *trap) 1282 + { 1283 + trap->key_type = OCELOT_VCAP_KEY_ETYPE; 1284 + *(__be16 *)trap->key.etype.etype.value = htons(ETH_P_1588); 1285 + *(__be16 *)trap->key.etype.etype.mask = htons(0xffff); 1286 + } 1287 + 1288 + static void 1289 + ocelot_populate_ipv4_ptp_event_trap_key(struct ocelot_vcap_filter *trap) 1290 + { 1291 + trap->key_type = OCELOT_VCAP_KEY_IPV4; 1292 + trap->key.ipv4.dport.value = PTP_EV_PORT; 1293 + trap->key.ipv4.dport.mask = 0xffff; 1294 + } 1295 + 1296 + static void 1297 + ocelot_populate_ipv6_ptp_event_trap_key(struct ocelot_vcap_filter *trap) 1298 + { 1299 + trap->key_type = OCELOT_VCAP_KEY_IPV6; 1300 + trap->key.ipv6.dport.value = PTP_EV_PORT; 1301 + trap->key.ipv6.dport.mask = 0xffff; 1302 + } 1303 + 1304 + static void 1305 + ocelot_populate_ipv4_ptp_general_trap_key(struct ocelot_vcap_filter *trap) 1306 + { 1307 + trap->key_type = OCELOT_VCAP_KEY_IPV4; 1308 + trap->key.ipv4.dport.value = PTP_GEN_PORT; 1309 + trap->key.ipv4.dport.mask = 0xffff; 1310 + } 1311 + 1312 + static void 1313 + ocelot_populate_ipv6_ptp_general_trap_key(struct ocelot_vcap_filter *trap) 1314 + { 1315 + trap->key_type = OCELOT_VCAP_KEY_IPV6; 1316 + trap->key.ipv6.dport.value = PTP_GEN_PORT; 1317 + trap->key.ipv6.dport.mask = 0xffff; 1318 + } 1319 + 1320 + static int ocelot_trap_add(struct ocelot *ocelot, int port, 1321 + unsigned long cookie, 1322 + void (*populate)(struct ocelot_vcap_filter *f)) 1323 + { 1324 + struct ocelot_vcap_block *block_vcap_is2; 1325 + struct ocelot_vcap_filter *trap; 1326 + bool new = false; 1327 + int err; 1328 + 1329 + block_vcap_is2 = &ocelot->block[VCAP_IS2]; 1330 + 1331 + trap = ocelot_vcap_block_find_filter_by_id(block_vcap_is2, cookie, 1332 + false); 1333 + if (!trap) { 1334 + trap = kzalloc(sizeof(*trap), GFP_KERNEL); 1335 + if (!trap) 1336 + return -ENOMEM; 1337 + 1338 + populate(trap); 1339 + trap->prio = 1; 1340 + trap->id.cookie = cookie; 1341 + trap->id.tc_offload = false; 1342 + trap->block_id = VCAP_IS2; 1343 + trap->type = OCELOT_VCAP_FILTER_OFFLOAD; 1344 + trap->lookup = 0; 1345 + trap->action.cpu_copy_ena = true; 1346 + trap->action.mask_mode = OCELOT_MASK_MODE_PERMIT_DENY; 1347 + trap->action.port_mask = 0; 1348 + new = true; 1349 + } 1350 + 1351 + trap->ingress_port_mask |= BIT(port); 1352 + 1353 + if (new) 1354 + err = ocelot_vcap_filter_add(ocelot, trap, NULL); 1355 + else 1356 + err = ocelot_vcap_filter_replace(ocelot, trap); 1357 + if (err) { 1358 + trap->ingress_port_mask &= ~BIT(port); 1359 + if (!trap->ingress_port_mask) 1360 + kfree(trap); 1361 + return err; 1362 + } 1363 + 1364 + return 0; 1365 + } 1366 + 1367 + static int ocelot_trap_del(struct ocelot *ocelot, int port, 1368 + unsigned long cookie) 1369 + { 1370 + struct ocelot_vcap_block *block_vcap_is2; 1371 + struct ocelot_vcap_filter *trap; 1372 + 1373 + block_vcap_is2 = &ocelot->block[VCAP_IS2]; 1374 + 1375 + trap = ocelot_vcap_block_find_filter_by_id(block_vcap_is2, cookie, 1376 + false); 1377 + if (!trap) 1378 + return 0; 1379 + 1380 + trap->ingress_port_mask &= ~BIT(port); 1381 + if (!trap->ingress_port_mask) 1382 + return ocelot_vcap_filter_del(ocelot, trap); 1383 + 1384 + return ocelot_vcap_filter_replace(ocelot, trap); 1385 + } 1386 + 1387 + static int ocelot_l2_ptp_trap_add(struct ocelot *ocelot, int port) 1388 + { 1389 + unsigned long l2_cookie = ocelot->num_phys_ports + 1; 1390 + 1391 + return ocelot_trap_add(ocelot, port, l2_cookie, 1392 + ocelot_populate_l2_ptp_trap_key); 1393 + } 1394 + 1395 + static int ocelot_l2_ptp_trap_del(struct ocelot *ocelot, int port) 1396 + { 1397 + unsigned long l2_cookie = ocelot->num_phys_ports + 1; 1398 + 1399 + return ocelot_trap_del(ocelot, port, l2_cookie); 1400 + } 1401 + 1402 + static int ocelot_ipv4_ptp_trap_add(struct ocelot *ocelot, int port) 1403 + { 1404 + unsigned long ipv4_gen_cookie = ocelot->num_phys_ports + 2; 1405 + unsigned long ipv4_ev_cookie = ocelot->num_phys_ports + 3; 1406 + int err; 1407 + 1408 + err = ocelot_trap_add(ocelot, port, ipv4_ev_cookie, 1409 + ocelot_populate_ipv4_ptp_event_trap_key); 1410 + if (err) 1411 + return err; 1412 + 1413 + err = ocelot_trap_add(ocelot, port, ipv4_gen_cookie, 1414 + ocelot_populate_ipv4_ptp_general_trap_key); 1415 + if (err) 1416 + ocelot_trap_del(ocelot, port, ipv4_ev_cookie); 1417 + 1418 + return err; 1419 + } 1420 + 1421 + static int ocelot_ipv4_ptp_trap_del(struct ocelot *ocelot, int port) 1422 + { 1423 + unsigned long ipv4_gen_cookie = ocelot->num_phys_ports + 2; 1424 + unsigned long ipv4_ev_cookie = ocelot->num_phys_ports + 3; 1425 + int err; 1426 + 1427 + err = ocelot_trap_del(ocelot, port, ipv4_ev_cookie); 1428 + err |= ocelot_trap_del(ocelot, port, ipv4_gen_cookie); 1429 + return err; 1430 + } 1431 + 1432 + static int ocelot_ipv6_ptp_trap_add(struct ocelot *ocelot, int port) 1433 + { 1434 + unsigned long ipv6_gen_cookie = ocelot->num_phys_ports + 4; 1435 + unsigned long ipv6_ev_cookie = ocelot->num_phys_ports + 5; 1436 + int err; 1437 + 1438 + err = ocelot_trap_add(ocelot, port, ipv6_ev_cookie, 1439 + ocelot_populate_ipv6_ptp_event_trap_key); 1440 + if (err) 1441 + return err; 1442 + 1443 + err = ocelot_trap_add(ocelot, port, ipv6_gen_cookie, 1444 + ocelot_populate_ipv6_ptp_general_trap_key); 1445 + if (err) 1446 + ocelot_trap_del(ocelot, port, ipv6_ev_cookie); 1447 + 1448 + return err; 1449 + } 1450 + 1451 + static int ocelot_ipv6_ptp_trap_del(struct ocelot *ocelot, int port) 1452 + { 1453 + unsigned long ipv6_gen_cookie = ocelot->num_phys_ports + 4; 1454 + unsigned long ipv6_ev_cookie = ocelot->num_phys_ports + 5; 1455 + int err; 1456 + 1457 + err = ocelot_trap_del(ocelot, port, ipv6_ev_cookie); 1458 + err |= ocelot_trap_del(ocelot, port, ipv6_gen_cookie); 1459 + return err; 1460 + } 1461 + 1462 + static int ocelot_setup_ptp_traps(struct ocelot *ocelot, int port, 1463 + bool l2, bool l4) 1464 + { 1465 + int err; 1466 + 1467 + if (l2) 1468 + err = ocelot_l2_ptp_trap_add(ocelot, port); 1469 + else 1470 + err = ocelot_l2_ptp_trap_del(ocelot, port); 1471 + if (err) 1472 + return err; 1473 + 1474 + if (l4) { 1475 + err = ocelot_ipv4_ptp_trap_add(ocelot, port); 1476 + if (err) 1477 + goto err_ipv4; 1478 + 1479 + err = ocelot_ipv6_ptp_trap_add(ocelot, port); 1480 + if (err) 1481 + goto err_ipv6; 1482 + } else { 1483 + err = ocelot_ipv4_ptp_trap_del(ocelot, port); 1484 + 1485 + err |= ocelot_ipv6_ptp_trap_del(ocelot, port); 1486 + } 1487 + if (err) 1488 + return err; 1489 + 1490 + return 0; 1491 + 1492 + err_ipv6: 1493 + ocelot_ipv4_ptp_trap_del(ocelot, port); 1494 + err_ipv4: 1495 + if (l2) 1496 + ocelot_l2_ptp_trap_del(ocelot, port); 1497 + return err; 1498 + } 1499 + 1281 1500 int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr) 1282 1501 { 1283 1502 return copy_to_user(ifr->ifr_data, &ocelot->hwtstamp_config, ··· 1507 1288 int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr) 1508 1289 { 1509 1290 struct ocelot_port *ocelot_port = ocelot->ports[port]; 1291 + bool l2 = false, l4 = false; 1510 1292 struct hwtstamp_config cfg; 1293 + int err; 1511 1294 1512 1295 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) 1513 1296 return -EFAULT; ··· 1541 1320 switch (cfg.rx_filter) { 1542 1321 case HWTSTAMP_FILTER_NONE: 1543 1322 break; 1544 - case HWTSTAMP_FILTER_ALL: 1545 - case HWTSTAMP_FILTER_SOME: 1546 - case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: 1547 - case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: 1548 - case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: 1549 - case HWTSTAMP_FILTER_NTP_ALL: 1550 1323 case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: 1551 1324 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: 1552 1325 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: 1326 + l4 = true; 1327 + break; 1553 1328 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: 1554 1329 case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: 1555 1330 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: 1331 + l2 = true; 1332 + break; 1556 1333 case HWTSTAMP_FILTER_PTP_V2_EVENT: 1557 1334 case HWTSTAMP_FILTER_PTP_V2_SYNC: 1558 1335 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 1559 - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; 1336 + l2 = true; 1337 + l4 = true; 1560 1338 break; 1561 1339 default: 1562 1340 mutex_unlock(&ocelot->ptp_lock); 1563 1341 return -ERANGE; 1564 1342 } 1343 + 1344 + err = ocelot_setup_ptp_traps(ocelot, port, l2, l4); 1345 + if (err) 1346 + return err; 1347 + 1348 + if (l2 && l4) 1349 + cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; 1350 + else if (l2) 1351 + cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; 1352 + else if (l4) 1353 + cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; 1354 + else 1355 + cfg.rx_filter = HWTSTAMP_FILTER_NONE; 1565 1356 1566 1357 /* Commit back the result & save it */ 1567 1358 memcpy(&ocelot->hwtstamp_config, &cfg, sizeof(cfg)); ··· 1677 1444 SOF_TIMESTAMPING_RAW_HARDWARE; 1678 1445 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON) | 1679 1446 BIT(HWTSTAMP_TX_ONESTEP_SYNC); 1680 - info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL); 1447 + info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | 1448 + BIT(HWTSTAMP_FILTER_PTP_V2_EVENT) | 1449 + BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | 1450 + BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT); 1681 1451 1682 1452 return 0; 1683 1453 }
+16
drivers/net/ethernet/mscc/ocelot_vcap.c
··· 1217 1217 } 1218 1218 EXPORT_SYMBOL(ocelot_vcap_filter_del); 1219 1219 1220 + int ocelot_vcap_filter_replace(struct ocelot *ocelot, 1221 + struct ocelot_vcap_filter *filter) 1222 + { 1223 + struct ocelot_vcap_block *block = &ocelot->block[filter->block_id]; 1224 + int index; 1225 + 1226 + index = ocelot_vcap_block_get_filter_index(block, filter); 1227 + if (index < 0) 1228 + return index; 1229 + 1230 + vcap_entry_set(ocelot, index, filter); 1231 + 1232 + return 0; 1233 + } 1234 + EXPORT_SYMBOL(ocelot_vcap_filter_replace); 1235 + 1220 1236 int ocelot_vcap_filter_stats_update(struct ocelot *ocelot, 1221 1237 struct ocelot_vcap_filter *filter) 1222 1238 {
-3
drivers/net/ethernet/netronome/nfp/nfp_net.h
··· 565 565 * @exn_name: Name for Exception interrupt 566 566 * @shared_handler: Handler for shared interrupts 567 567 * @shared_name: Name for shared interrupt 568 - * @me_freq_mhz: ME clock_freq (MHz) 569 568 * @reconfig_lock: Protects @reconfig_posted, @reconfig_timer_active, 570 569 * @reconfig_sync_present and HW reconfiguration request 571 570 * regs/machinery from async requests (sync must take ··· 648 649 649 650 irq_handler_t shared_handler; 650 651 char shared_name[IFNAMSIZ + 8]; 651 - 652 - u32 me_freq_mhz; 653 652 654 653 bool link_up; 655 654 spinlock_t link_status_lock;
+1 -1
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
··· 1344 1344 * ME timestamp ticks. There are 16 ME clock cycles for each timestamp 1345 1345 * count. 1346 1346 */ 1347 - factor = nn->me_freq_mhz / 16; 1347 + factor = nn->tlv_caps.me_freq_mhz / 16; 1348 1348 1349 1349 /* Each pair of (usecs, max_frames) fields specifies that interrupts 1350 1350 * should be coalesced until
+2 -2
drivers/net/ethernet/ni/nixge.c
··· 1209 1209 1210 1210 cell = nvmem_cell_get(dev, "address"); 1211 1211 if (IS_ERR(cell)) 1212 - return NULL; 1212 + return cell; 1213 1213 1214 1214 mac = nvmem_cell_read(cell, &cell_size); 1215 1215 nvmem_cell_put(cell); ··· 1282 1282 ndev->max_mtu = NIXGE_JUMBO_MTU; 1283 1283 1284 1284 mac_addr = nixge_get_nvmem_address(&pdev->dev); 1285 - if (mac_addr && is_valid_ether_addr(mac_addr)) { 1285 + if (!IS_ERR(mac_addr) && is_valid_ether_addr(mac_addr)) { 1286 1286 eth_hw_addr_set(ndev, mac_addr); 1287 1287 kfree(mac_addr); 1288 1288 } else {
+3 -3
drivers/net/ethernet/qlogic/qed/qed_int.c
··· 1045 1045 if (!parities) 1046 1046 continue; 1047 1047 1048 - for (j = 0, bit_idx = 0; bit_idx < 32; j++) { 1048 + for (j = 0, bit_idx = 0; bit_idx < 32 && j < 32; j++) { 1049 1049 struct aeu_invert_reg_bit *p_bit = &p_aeu->bits[j]; 1050 1050 1051 1051 if (qed_int_is_parity_flag(p_hwfn, p_bit) && ··· 1083 1083 * to current group, making them responsible for the 1084 1084 * previous assertion. 1085 1085 */ 1086 - for (j = 0, bit_idx = 0; bit_idx < 32; j++) { 1086 + for (j = 0, bit_idx = 0; bit_idx < 32 && j < 32; j++) { 1087 1087 long unsigned int bitmask; 1088 1088 u8 bit, bit_len; 1089 1089 ··· 1382 1382 memset(sb_info->parity_mask, 0, sizeof(u32) * NUM_ATTN_REGS); 1383 1383 for (i = 0; i < NUM_ATTN_REGS; i++) { 1384 1384 /* j is array index, k is bit index */ 1385 - for (j = 0, k = 0; k < 32; j++) { 1385 + for (j = 0, k = 0; k < 32 && j < 32; j++) { 1386 1386 struct aeu_invert_reg_bit *p_aeu; 1387 1387 1388 1388 p_aeu = &aeu_descs[i].bits[j];
+3 -2
drivers/net/ethernet/realtek/r8169_main.c
··· 5217 5217 5218 5218 static void rtl_init_mac_address(struct rtl8169_private *tp) 5219 5219 { 5220 + u8 mac_addr[ETH_ALEN] __aligned(2) = {}; 5220 5221 struct net_device *dev = tp->dev; 5221 - u8 mac_addr[ETH_ALEN]; 5222 5222 int rc; 5223 5223 5224 5224 rc = eth_platform_get_mac_address(tp_to_dev(tp), mac_addr); ··· 5233 5233 if (is_valid_ether_addr(mac_addr)) 5234 5234 goto done; 5235 5235 5236 - eth_hw_addr_random(dev); 5236 + eth_random_addr(mac_addr); 5237 + dev->addr_assign_type = NET_ADDR_RANDOM; 5237 5238 dev_warn(tp_to_dev(tp), "can't read MAC address, setting random one\n"); 5238 5239 done: 5239 5240 eth_hw_addr_set(dev, mac_addr);
+1
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 314 314 int stmmac_xpcs_setup(struct mii_bus *mii); 315 315 void stmmac_set_ethtool_ops(struct net_device *netdev); 316 316 317 + int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); 317 318 void stmmac_ptp_register(struct stmmac_priv *priv); 318 319 void stmmac_ptp_unregister(struct stmmac_priv *priv); 319 320 int stmmac_open(struct net_device *dev);
+86 -50
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 50 50 #include "dwxgmac2.h" 51 51 #include "hwif.h" 52 52 53 + /* As long as the interface is active, we keep the timestamping counter enabled 54 + * with fine resolution and binary rollover. This avoid non-monotonic behavior 55 + * (clock jumps) when changing timestamping settings at runtime. 56 + */ 57 + #define STMMAC_HWTS_ACTIVE (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | \ 58 + PTP_TCR_TSCTRLSSR) 59 + 53 60 #define STMMAC_ALIGN(x) ALIGN(ALIGN(x, SMP_CACHE_BYTES), 16) 54 61 #define TSO_MAX_BUFF_SIZE (SZ_16K - 1) 55 62 ··· 620 613 { 621 614 struct stmmac_priv *priv = netdev_priv(dev); 622 615 struct hwtstamp_config config; 623 - struct timespec64 now; 624 - u64 temp = 0; 625 616 u32 ptp_v2 = 0; 626 617 u32 tstamp_all = 0; 627 618 u32 ptp_over_ipv4_udp = 0; ··· 628 623 u32 snap_type_sel = 0; 629 624 u32 ts_master_en = 0; 630 625 u32 ts_event_en = 0; 631 - u32 sec_inc = 0; 632 - u32 value = 0; 633 - bool xmac; 634 - 635 - xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; 636 626 637 627 if (!(priv->dma_cap.time_stamp || priv->adv_ts)) { 638 628 netdev_alert(priv->dev, "No support for HW time stamping\n"); ··· 789 789 priv->hwts_rx_en = ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1); 790 790 priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON; 791 791 792 - if (!priv->hwts_tx_en && !priv->hwts_rx_en) 793 - stmmac_config_hw_tstamping(priv, priv->ptpaddr, 0); 794 - else { 795 - value = (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | PTP_TCR_TSCTRLSSR | 796 - tstamp_all | ptp_v2 | ptp_over_ethernet | 797 - ptp_over_ipv6_udp | ptp_over_ipv4_udp | ts_event_en | 798 - ts_master_en | snap_type_sel); 799 - stmmac_config_hw_tstamping(priv, priv->ptpaddr, value); 792 + priv->systime_flags = STMMAC_HWTS_ACTIVE; 800 793 801 - /* program Sub Second Increment reg */ 802 - stmmac_config_sub_second_increment(priv, 803 - priv->ptpaddr, priv->plat->clk_ptp_rate, 804 - xmac, &sec_inc); 805 - temp = div_u64(1000000000ULL, sec_inc); 806 - 807 - /* Store sub second increment and flags for later use */ 808 - priv->sub_second_inc = sec_inc; 809 - priv->systime_flags = value; 810 - 811 - /* calculate default added value: 812 - * formula is : 813 - * addend = (2^32)/freq_div_ratio; 814 - * where, freq_div_ratio = 1e9ns/sec_inc 815 - */ 816 - temp = (u64)(temp << 32); 817 - priv->default_addend = div_u64(temp, priv->plat->clk_ptp_rate); 818 - stmmac_config_addend(priv, priv->ptpaddr, priv->default_addend); 819 - 820 - /* initialize system time */ 821 - ktime_get_real_ts64(&now); 822 - 823 - /* lower 32 bits of tv_sec are safe until y2106 */ 824 - stmmac_init_systime(priv, priv->ptpaddr, 825 - (u32)now.tv_sec, now.tv_nsec); 794 + if (priv->hwts_tx_en || priv->hwts_rx_en) { 795 + priv->systime_flags |= tstamp_all | ptp_v2 | 796 + ptp_over_ethernet | ptp_over_ipv6_udp | 797 + ptp_over_ipv4_udp | ts_event_en | 798 + ts_master_en | snap_type_sel; 826 799 } 800 + 801 + stmmac_config_hw_tstamping(priv, priv->ptpaddr, priv->systime_flags); 827 802 828 803 memcpy(&priv->tstamp_config, &config, sizeof(config)); 829 804 ··· 828 853 } 829 854 830 855 /** 856 + * stmmac_init_tstamp_counter - init hardware timestamping counter 857 + * @priv: driver private structure 858 + * @systime_flags: timestamping flags 859 + * Description: 860 + * Initialize hardware counter for packet timestamping. 861 + * This is valid as long as the interface is open and not suspended. 862 + * Will be rerun after resuming from suspend, case in which the timestamping 863 + * flags updated by stmmac_hwtstamp_set() also need to be restored. 864 + */ 865 + int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags) 866 + { 867 + bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; 868 + struct timespec64 now; 869 + u32 sec_inc = 0; 870 + u64 temp = 0; 871 + int ret; 872 + 873 + if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) 874 + return -EOPNOTSUPP; 875 + 876 + ret = clk_prepare_enable(priv->plat->clk_ptp_ref); 877 + if (ret < 0) { 878 + netdev_warn(priv->dev, 879 + "failed to enable PTP reference clock: %pe\n", 880 + ERR_PTR(ret)); 881 + return ret; 882 + } 883 + 884 + stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags); 885 + priv->systime_flags = systime_flags; 886 + 887 + /* program Sub Second Increment reg */ 888 + stmmac_config_sub_second_increment(priv, priv->ptpaddr, 889 + priv->plat->clk_ptp_rate, 890 + xmac, &sec_inc); 891 + temp = div_u64(1000000000ULL, sec_inc); 892 + 893 + /* Store sub second increment for later use */ 894 + priv->sub_second_inc = sec_inc; 895 + 896 + /* calculate default added value: 897 + * formula is : 898 + * addend = (2^32)/freq_div_ratio; 899 + * where, freq_div_ratio = 1e9ns/sec_inc 900 + */ 901 + temp = (u64)(temp << 32); 902 + priv->default_addend = div_u64(temp, priv->plat->clk_ptp_rate); 903 + stmmac_config_addend(priv, priv->ptpaddr, priv->default_addend); 904 + 905 + /* initialize system time */ 906 + ktime_get_real_ts64(&now); 907 + 908 + /* lower 32 bits of tv_sec are safe until y2106 */ 909 + stmmac_init_systime(priv, priv->ptpaddr, (u32)now.tv_sec, now.tv_nsec); 910 + 911 + return 0; 912 + } 913 + EXPORT_SYMBOL_GPL(stmmac_init_tstamp_counter); 914 + 915 + /** 831 916 * stmmac_init_ptp - init PTP 832 917 * @priv: driver private structure 833 918 * Description: this is to verify if the HW supports the PTPv1 or PTPv2. ··· 897 862 static int stmmac_init_ptp(struct stmmac_priv *priv) 898 863 { 899 864 bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; 865 + int ret; 900 866 901 - if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) 902 - return -EOPNOTSUPP; 867 + ret = stmmac_init_tstamp_counter(priv, STMMAC_HWTS_ACTIVE); 868 + if (ret) 869 + return ret; 903 870 904 871 priv->adv_ts = 0; 905 872 /* Check if adv_ts can be enabled for dwmac 4.x / xgmac core */ ··· 3309 3272 stmmac_mmc_setup(priv); 3310 3273 3311 3274 if (init_ptp) { 3312 - ret = clk_prepare_enable(priv->plat->clk_ptp_ref); 3313 - if (ret < 0) 3314 - netdev_warn(priv->dev, "failed to enable PTP reference clock: %d\n", ret); 3315 - 3316 3275 ret = stmmac_init_ptp(priv); 3317 3276 if (ret == -EOPNOTSUPP) 3318 3277 netdev_warn(priv->dev, "PTP not supported by HW\n"); ··· 3801 3768 { 3802 3769 struct stmmac_priv *priv = netdev_priv(dev); 3803 3770 u32 chan; 3771 + 3772 + netif_tx_disable(dev); 3804 3773 3805 3774 if (device_may_wakeup(priv->device)) 3806 3775 phylink_speed_down(priv->phylink, false); ··· 5196 5161 if (likely(!(status & rx_not_ls)) && 5197 5162 (likely(priv->synopsys_id >= DWMAC_CORE_4_00) || 5198 5163 unlikely(status != llc_snap))) { 5199 - if (buf2_len) 5164 + if (buf2_len) { 5200 5165 buf2_len -= ETH_FCS_LEN; 5201 - else 5166 + len -= ETH_FCS_LEN; 5167 + } else if (buf1_len) { 5202 5168 buf1_len -= ETH_FCS_LEN; 5203 - 5204 - len -= ETH_FCS_LEN; 5169 + len -= ETH_FCS_LEN; 5170 + } 5205 5171 } 5206 5172 5207 5173 if (!skb) {
+1 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 816 816 if (ret) 817 817 return ret; 818 818 819 - clk_prepare_enable(priv->plat->clk_ptp_ref); 819 + stmmac_init_tstamp_counter(priv, priv->systime_flags); 820 820 } 821 821 822 822 return 0;
+2
drivers/net/hamradio/mkiss.c
··· 31 31 32 32 #define AX_MTU 236 33 33 34 + /* some arch define END as assembly function ending, just undef it */ 35 + #undef END 34 36 /* SLIP/KISS protocol characters. */ 35 37 #define END 0300 /* indicates end of frame */ 36 38 #define ESC 0333 /* indicates byte stuffing */
-16
drivers/net/ipa/ipa_cmd.c
··· 661 661 wait_for_completion(&ipa->completion); 662 662 } 663 663 664 - void ipa_cmd_pipeline_clear(struct ipa *ipa) 665 - { 666 - u32 count = ipa_cmd_pipeline_clear_count(); 667 - struct gsi_trans *trans; 668 - 669 - trans = ipa_cmd_trans_alloc(ipa, count); 670 - if (trans) { 671 - ipa_cmd_pipeline_clear_add(trans); 672 - gsi_trans_commit_wait(trans); 673 - ipa_cmd_pipeline_clear_wait(ipa); 674 - } else { 675 - dev_err(&ipa->pdev->dev, 676 - "error allocating %u entry tag transaction\n", count); 677 - } 678 - } 679 - 680 664 static struct ipa_cmd_info * 681 665 ipa_cmd_info_alloc(struct ipa_endpoint *endpoint, u32 tre_count) 682 666 {
-6
drivers/net/ipa/ipa_cmd.h
··· 164 164 void ipa_cmd_pipeline_clear_wait(struct ipa *ipa); 165 165 166 166 /** 167 - * ipa_cmd_pipeline_clear() - Clear the hardware pipeline 168 - * @ipa: - IPA pointer 169 - */ 170 - void ipa_cmd_pipeline_clear(struct ipa *ipa); 171 - 172 - /** 173 167 * ipa_cmd_trans_alloc() - Allocate a transaction for the command TX endpoint 174 168 * @ipa: IPA pointer 175 169 * @tre_count: Number of elements in the transaction
-2
drivers/net/ipa/ipa_endpoint.c
··· 1636 1636 if (ipa->modem_netdev) 1637 1637 ipa_modem_suspend(ipa->modem_netdev); 1638 1638 1639 - ipa_cmd_pipeline_clear(ipa); 1640 - 1641 1639 ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_LAN_RX]); 1642 1640 ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]); 1643 1641 }
+6
drivers/net/ipa/ipa_main.c
··· 28 28 #include "ipa_reg.h" 29 29 #include "ipa_mem.h" 30 30 #include "ipa_table.h" 31 + #include "ipa_smp2p.h" 31 32 #include "ipa_modem.h" 32 33 #include "ipa_uc.h" 33 34 #include "ipa_interrupt.h" ··· 801 800 struct ipa_power *power = ipa->power; 802 801 struct device *dev = &pdev->dev; 803 802 int ret; 803 + 804 + /* Prevent the modem from triggering a call to ipa_setup(). This 805 + * also ensures a modem-initiated setup that's underway completes. 806 + */ 807 + ipa_smp2p_irq_disable_setup(ipa); 804 808 805 809 ret = pm_runtime_get_sync(dev); 806 810 if (WARN_ON(ret < 0))
+3 -3
drivers/net/ipa/ipa_modem.c
··· 339 339 if (state != IPA_MODEM_STATE_RUNNING) 340 340 return -EBUSY; 341 341 342 - /* Prevent the modem from triggering a call to ipa_setup() */ 343 - ipa_smp2p_disable(ipa); 344 - 345 342 /* Clean up the netdev and endpoints if it was started */ 346 343 if (netdev) { 347 344 struct ipa_priv *priv = netdev_priv(netdev); ··· 365 368 { 366 369 struct device *dev = &ipa->pdev->dev; 367 370 int ret; 371 + 372 + /* Prevent the modem from triggering a call to ipa_setup() */ 373 + ipa_smp2p_irq_disable_setup(ipa); 368 374 369 375 ret = pm_runtime_get_sync(dev); 370 376 if (ret < 0) {
+10 -11
drivers/net/ipa/ipa_smp2p.c
··· 53 53 * @setup_ready_irq: IPA interrupt triggered by modem to signal GSI ready 54 54 * @power_on: Whether IPA power is on 55 55 * @notified: Whether modem has been notified of power state 56 - * @disabled: Whether setup ready interrupt handling is disabled 56 + * @setup_disabled: Whether setup ready interrupt handler is disabled 57 57 * @mutex: Mutex protecting ready-interrupt/shutdown interlock 58 58 * @panic_notifier: Panic notifier structure 59 59 */ ··· 67 67 u32 setup_ready_irq; 68 68 bool power_on; 69 69 bool notified; 70 - bool disabled; 70 + bool setup_disabled; 71 71 struct mutex mutex; 72 72 struct notifier_block panic_notifier; 73 73 }; ··· 155 155 struct device *dev; 156 156 int ret; 157 157 158 - mutex_lock(&smp2p->mutex); 159 - 160 - if (smp2p->disabled) 161 - goto out_mutex_unlock; 162 - smp2p->disabled = true; /* If any others arrive, ignore them */ 158 + /* Ignore any (spurious) interrupts received after the first */ 159 + if (smp2p->ipa->setup_complete) 160 + return IRQ_HANDLED; 163 161 164 162 /* Power needs to be active for setup */ 165 163 dev = &smp2p->ipa->pdev->dev; ··· 174 176 out_power_put: 175 177 pm_runtime_mark_last_busy(dev); 176 178 (void)pm_runtime_put_autosuspend(dev); 177 - out_mutex_unlock: 178 - mutex_unlock(&smp2p->mutex); 179 179 180 180 return IRQ_HANDLED; 181 181 } ··· 309 313 kfree(smp2p); 310 314 } 311 315 312 - void ipa_smp2p_disable(struct ipa *ipa) 316 + void ipa_smp2p_irq_disable_setup(struct ipa *ipa) 313 317 { 314 318 struct ipa_smp2p *smp2p = ipa->smp2p; 315 319 ··· 318 322 319 323 mutex_lock(&smp2p->mutex); 320 324 321 - smp2p->disabled = true; 325 + if (!smp2p->setup_disabled) { 326 + disable_irq(smp2p->setup_ready_irq); 327 + smp2p->setup_disabled = true; 328 + } 322 329 323 330 mutex_unlock(&smp2p->mutex); 324 331 }
+3 -4
drivers/net/ipa/ipa_smp2p.h
··· 27 27 void ipa_smp2p_exit(struct ipa *ipa); 28 28 29 29 /** 30 - * ipa_smp2p_disable() - Prevent "ipa-setup-ready" interrupt handling 30 + * ipa_smp2p_irq_disable_setup() - Disable the "setup ready" interrupt 31 31 * @ipa: IPA pointer 32 32 * 33 - * Prevent handling of the "setup ready" interrupt from the modem. 34 - * This is used before initiating shutdown of the driver. 33 + * Disable the "ipa-setup-ready" interrupt from the modem. 35 34 */ 36 - void ipa_smp2p_disable(struct ipa *ipa); 35 + void ipa_smp2p_irq_disable_setup(struct ipa *ipa); 37 36 38 37 /** 39 38 * ipa_smp2p_notify_reset() - Reset modem notification state
+7
drivers/net/mdio/mdio-aspeed.c
··· 61 61 62 62 iowrite32(ctrl, ctx->base + ASPEED_MDIO_CTRL); 63 63 64 + rc = readl_poll_timeout(ctx->base + ASPEED_MDIO_CTRL, ctrl, 65 + !(ctrl & ASPEED_MDIO_CTRL_FIRE), 66 + ASPEED_MDIO_INTERVAL_US, 67 + ASPEED_MDIO_TIMEOUT_US); 68 + if (rc < 0) 69 + return rc; 70 + 64 71 rc = readl_poll_timeout(ctx->base + ASPEED_MDIO_DATA, data, 65 72 data & ASPEED_MDIO_DATA_IDLE, 66 73 ASPEED_MDIO_INTERVAL_US,
+25 -1
drivers/net/phy/phylink.c
··· 710 710 struct phylink_link_state link_state; 711 711 struct net_device *ndev = pl->netdev; 712 712 bool mac_config = false; 713 + bool retrigger = false; 713 714 bool cur_link_state; 714 715 715 716 mutex_lock(&pl->state_mutex); ··· 724 723 link_state.link = false; 725 724 } else if (pl->mac_link_dropped) { 726 725 link_state.link = false; 726 + retrigger = true; 727 727 } else { 728 728 switch (pl->cur_link_an_mode) { 729 729 case MLO_AN_PHY: ··· 741 739 case MLO_AN_INBAND: 742 740 phylink_mac_pcs_get_state(pl, &link_state); 743 741 742 + /* The PCS may have a latching link-fail indicator. 743 + * If the link was up, bring the link down and 744 + * re-trigger the resolve. Otherwise, re-read the 745 + * PCS state to get the current status of the link. 746 + */ 747 + if (!link_state.link) { 748 + if (cur_link_state) 749 + retrigger = true; 750 + else 751 + phylink_mac_pcs_get_state(pl, 752 + &link_state); 753 + } 754 + 744 755 /* If we have a phy, the "up" state is the union of 745 756 * both the PHY and the MAC 746 757 */ ··· 762 747 763 748 /* Only update if the PHY link is up */ 764 749 if (pl->phydev && pl->phy_state.link) { 750 + /* If the interface has changed, force a 751 + * link down event if the link isn't already 752 + * down, and re-resolve. 753 + */ 754 + if (link_state.interface != 755 + pl->phy_state.interface) { 756 + retrigger = true; 757 + link_state.link = false; 758 + } 765 759 link_state.interface = pl->phy_state.interface; 766 760 767 761 /* If we have a PHY, we need to update with ··· 813 789 else 814 790 phylink_link_up(pl, link_state); 815 791 } 816 - if (!link_state.link && pl->mac_link_dropped) { 792 + if (!link_state.link && retrigger) { 817 793 pl->mac_link_dropped = false; 818 794 queue_work(system_power_efficient_wq, &pl->resolve); 819 795 }
+2
drivers/net/slip/slip.h
··· 40 40 insmod -oslip_maxdev=nnn */ 41 41 #define SL_MTU 296 /* 296; I am used to 600- FvK */ 42 42 43 + /* some arch define END as assembly function ending, just undef it */ 44 + #undef END 43 45 /* SLIP protocol characters. */ 44 46 #define END 0300 /* indicates end of frame */ 45 47 #define ESC 0333 /* indicates byte stuffing */
+26 -29
drivers/net/usb/smsc95xx.c
··· 1050 1050 .ndo_set_features = smsc95xx_set_features, 1051 1051 }; 1052 1052 1053 + static void smsc95xx_handle_link_change(struct net_device *net) 1054 + { 1055 + struct usbnet *dev = netdev_priv(net); 1056 + 1057 + phy_print_status(net->phydev); 1058 + usbnet_defer_kevent(dev, EVENT_LINK_CHANGE); 1059 + } 1060 + 1053 1061 static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) 1054 1062 { 1055 1063 struct smsc95xx_priv *pdata; ··· 1162 1154 dev->net->min_mtu = ETH_MIN_MTU; 1163 1155 dev->net->max_mtu = ETH_DATA_LEN; 1164 1156 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; 1157 + 1158 + ret = phy_connect_direct(dev->net, pdata->phydev, 1159 + &smsc95xx_handle_link_change, 1160 + PHY_INTERFACE_MODE_MII); 1161 + if (ret) { 1162 + netdev_err(dev->net, "can't attach PHY to %s\n", pdata->mdiobus->id); 1163 + goto unregister_mdio; 1164 + } 1165 + 1166 + phy_attached_info(dev->net->phydev); 1167 + 1165 1168 return 0; 1166 1169 1167 1170 unregister_mdio: ··· 1190 1171 { 1191 1172 struct smsc95xx_priv *pdata = dev->driver_priv; 1192 1173 1174 + phy_disconnect(dev->net->phydev); 1193 1175 mdiobus_unregister(pdata->mdiobus); 1194 1176 mdiobus_free(pdata->mdiobus); 1195 1177 netif_dbg(dev, ifdown, dev->net, "free pdata\n"); 1196 1178 kfree(pdata); 1197 1179 } 1198 1180 1199 - static void smsc95xx_handle_link_change(struct net_device *net) 1200 - { 1201 - struct usbnet *dev = netdev_priv(net); 1202 - 1203 - phy_print_status(net->phydev); 1204 - usbnet_defer_kevent(dev, EVENT_LINK_CHANGE); 1205 - } 1206 - 1207 1181 static int smsc95xx_start_phy(struct usbnet *dev) 1208 1182 { 1209 - struct smsc95xx_priv *pdata = dev->driver_priv; 1210 - struct net_device *net = dev->net; 1211 - int ret; 1183 + phy_start(dev->net->phydev); 1212 1184 1213 - ret = smsc95xx_reset(dev); 1214 - if (ret < 0) 1215 - return ret; 1216 - 1217 - ret = phy_connect_direct(net, pdata->phydev, 1218 - &smsc95xx_handle_link_change, 1219 - PHY_INTERFACE_MODE_MII); 1220 - if (ret) { 1221 - netdev_err(net, "can't attach PHY to %s\n", pdata->mdiobus->id); 1222 - return ret; 1223 - } 1224 - 1225 - phy_attached_info(net->phydev); 1226 - phy_start(net->phydev); 1227 1185 return 0; 1228 1186 } 1229 1187 1230 - static int smsc95xx_disconnect_phy(struct usbnet *dev) 1188 + static int smsc95xx_stop(struct usbnet *dev) 1231 1189 { 1232 - phy_stop(dev->net->phydev); 1233 - phy_disconnect(dev->net->phydev); 1190 + if (dev->net->phydev) 1191 + phy_stop(dev->net->phydev); 1192 + 1234 1193 return 0; 1235 1194 } 1236 1195 ··· 1963 1966 .unbind = smsc95xx_unbind, 1964 1967 .link_reset = smsc95xx_link_reset, 1965 1968 .reset = smsc95xx_start_phy, 1966 - .stop = smsc95xx_disconnect_phy, 1969 + .stop = smsc95xx_stop, 1967 1970 .rx_fixup = smsc95xx_rx_fixup, 1968 1971 .tx_fixup = smsc95xx_tx_fixup, 1969 1972 .status = smsc95xx_status,
+1 -1
drivers/nfc/virtual_ncidev.c
··· 202 202 miscdev.minor = MISC_DYNAMIC_MINOR; 203 203 miscdev.name = "virtual_nci"; 204 204 miscdev.fops = &virtual_ncidev_fops; 205 - miscdev.mode = S_IALLUGO; 205 + miscdev.mode = 0600; 206 206 207 207 return misc_register(&miscdev); 208 208 }
+1
include/linux/ptp_classify.h
··· 37 37 #define PTP_MSGTYPE_PDELAY_RESP 0x3 38 38 39 39 #define PTP_EV_PORT 319 40 + #define PTP_GEN_PORT 320 40 41 #define PTP_GEN_BIT 0x08 /* indicates general message, if set in message type */ 41 42 42 43 #define OFF_PTP_SOURCE_UUID 22 /* PTPv1 only */
+1
include/net/ip6_fib.h
··· 485 485 struct fib6_config *cfg, gfp_t gfp_flags, 486 486 struct netlink_ext_ack *extack); 487 487 void fib6_nh_release(struct fib6_nh *fib6_nh); 488 + void fib6_nh_release_dsts(struct fib6_nh *fib6_nh); 488 489 489 490 int call_fib6_entry_notifiers(struct net *net, 490 491 enum fib_event_type event_type,
+1
include/net/ipv6_stubs.h
··· 47 47 struct fib6_config *cfg, gfp_t gfp_flags, 48 48 struct netlink_ext_ack *extack); 49 49 void (*fib6_nh_release)(struct fib6_nh *fib6_nh); 50 + void (*fib6_nh_release_dsts)(struct fib6_nh *fib6_nh); 50 51 void (*fib6_update_sernum)(struct net *net, struct fib6_info *rt); 51 52 int (*ip6_del_rt)(struct net *net, struct fib6_info *rt, bool skip_notify); 52 53 void (*fib6_rt_update)(struct net *net, struct fib6_info *rt,
+4 -3
include/net/nl802154.h
··· 19 19 * 20 20 */ 21 21 22 + #include <linux/types.h> 23 + 22 24 #define NL802154_GENL_NAME "nl802154" 23 25 24 26 enum nl802154_commands { ··· 152 150 }; 153 151 154 152 enum nl802154_iftype { 155 - /* for backwards compatibility TODO */ 156 - NL802154_IFTYPE_UNSPEC = -1, 153 + NL802154_IFTYPE_UNSPEC = (~(__u32)0), 157 154 158 - NL802154_IFTYPE_NODE, 155 + NL802154_IFTYPE_NODE = 0, 159 156 NL802154_IFTYPE_MONITOR, 160 157 NL802154_IFTYPE_COORD, 161 158
+2
include/soc/mscc/ocelot_vcap.h
··· 703 703 struct netlink_ext_ack *extack); 704 704 int ocelot_vcap_filter_del(struct ocelot *ocelot, 705 705 struct ocelot_vcap_filter *rule); 706 + int ocelot_vcap_filter_replace(struct ocelot *ocelot, 707 + struct ocelot_vcap_filter *filter); 706 708 struct ocelot_vcap_filter * 707 709 ocelot_vcap_block_find_filter_by_id(struct ocelot_vcap_block *block, 708 710 unsigned long cookie, bool tc_offload);
-3
net/8021q/vlan.c
··· 184 184 if (err) 185 185 goto out_unregister_netdev; 186 186 187 - /* Account for reference in struct vlan_dev_priv */ 188 - dev_hold(real_dev); 189 - 190 187 vlan_stacked_transfer_operstate(real_dev, dev, vlan); 191 188 linkwatch_fire_event(dev); /* _MUST_ call rfc2863_policy() */ 192 189
+3
net/8021q/vlan_dev.c
··· 615 615 if (!vlan->vlan_pcpu_stats) 616 616 return -ENOMEM; 617 617 618 + /* Get vlan's reference to real_dev */ 619 + dev_hold(real_dev); 620 + 618 621 return 0; 619 622 } 620 623
+1
net/core/neighbour.c
··· 1779 1779 { 1780 1780 neigh_tables[index] = NULL; 1781 1781 /* It is not clean... Fix it to unload IPv6 module safely */ 1782 + cancel_delayed_work_sync(&tbl->managed_work); 1782 1783 cancel_delayed_work_sync(&tbl->gc_work); 1783 1784 del_timer_sync(&tbl->proxy_timer); 1784 1785 pneigh_queue_purge(&tbl->proxy_queue);
+1 -1
net/ethtool/ioctl.c
··· 1719 1719 struct ethtool_coalesce coalesce; 1720 1720 int ret; 1721 1721 1722 - if (!dev->ethtool_ops->set_coalesce && !dev->ethtool_ops->get_coalesce) 1722 + if (!dev->ethtool_ops->set_coalesce || !dev->ethtool_ops->get_coalesce) 1723 1723 return -EOPNOTSUPP; 1724 1724 1725 1725 ret = dev->ethtool_ops->get_coalesce(dev, &coalesce, &kernel_coalesce,
+30 -5
net/ipv4/nexthop.c
··· 1899 1899 /* if any FIB entries reference this nexthop, any dst entries 1900 1900 * need to be regenerated 1901 1901 */ 1902 - static void nh_rt_cache_flush(struct net *net, struct nexthop *nh) 1902 + static void nh_rt_cache_flush(struct net *net, struct nexthop *nh, 1903 + struct nexthop *replaced_nh) 1903 1904 { 1904 1905 struct fib6_info *f6i; 1906 + struct nh_group *nhg; 1907 + int i; 1905 1908 1906 1909 if (!list_empty(&nh->fi_list)) 1907 1910 rt_cache_flush(net); 1908 1911 1909 1912 list_for_each_entry(f6i, &nh->f6i_list, nh_list) 1910 1913 ipv6_stub->fib6_update_sernum(net, f6i); 1914 + 1915 + /* if an IPv6 group was replaced, we have to release all old 1916 + * dsts to make sure all refcounts are released 1917 + */ 1918 + if (!replaced_nh->is_group) 1919 + return; 1920 + 1921 + /* new dsts must use only the new nexthop group */ 1922 + synchronize_net(); 1923 + 1924 + nhg = rtnl_dereference(replaced_nh->nh_grp); 1925 + for (i = 0; i < nhg->num_nh; i++) { 1926 + struct nh_grp_entry *nhge = &nhg->nh_entries[i]; 1927 + struct nh_info *nhi = rtnl_dereference(nhge->nh->nh_info); 1928 + 1929 + if (nhi->family == AF_INET6) 1930 + ipv6_stub->fib6_nh_release_dsts(&nhi->fib6_nh); 1931 + } 1911 1932 } 1912 1933 1913 1934 static int replace_nexthop_grp(struct net *net, struct nexthop *old, ··· 2268 2247 err = replace_nexthop_single(net, old, new, extack); 2269 2248 2270 2249 if (!err) { 2271 - nh_rt_cache_flush(net, old); 2250 + nh_rt_cache_flush(net, old, new); 2272 2251 2273 2252 __remove_nexthop(net, new, NULL); 2274 2253 nexthop_put(new); ··· 2565 2544 /* sets nh_dev if successful */ 2566 2545 err = ipv6_stub->fib6_nh_init(net, fib6_nh, &fib6_cfg, GFP_KERNEL, 2567 2546 extack); 2568 - if (err) 2547 + if (err) { 2548 + /* IPv6 is not enabled, don't call fib6_nh_release */ 2549 + if (err == -EAFNOSUPPORT) 2550 + goto out; 2569 2551 ipv6_stub->fib6_nh_release(fib6_nh); 2570 - else 2552 + } else { 2571 2553 nh->nh_flags = fib6_nh->fib_nh_flags; 2572 - 2554 + } 2555 + out: 2573 2556 return err; 2574 2557 } 2575 2558
+3 -2
net/ipv4/tcp_cubic.c
··· 330 330 return; 331 331 332 332 if (tcp_in_slow_start(tp)) { 333 - if (hystart && after(ack, ca->end_seq)) 334 - bictcp_hystart_reset(sk); 335 333 acked = tcp_slow_start(tp, acked); 336 334 if (!acked) 337 335 return; ··· 388 390 struct tcp_sock *tp = tcp_sk(sk); 389 391 struct bictcp *ca = inet_csk_ca(sk); 390 392 u32 threshold; 393 + 394 + if (after(tp->snd_una, ca->end_seq)) 395 + bictcp_hystart_reset(sk); 391 396 392 397 if (hystart_detect & HYSTART_ACK_TRAIN) { 393 398 u32 now = bictcp_clock_us(sk);
+1
net/ipv6/af_inet6.c
··· 1026 1026 .ip6_mtu_from_fib6 = ip6_mtu_from_fib6, 1027 1027 .fib6_nh_init = fib6_nh_init, 1028 1028 .fib6_nh_release = fib6_nh_release, 1029 + .fib6_nh_release_dsts = fib6_nh_release_dsts, 1029 1030 .fib6_update_sernum = fib6_update_sernum_stub, 1030 1031 .fib6_rt_update = fib6_rt_update, 1031 1032 .ip6_del_rt = ip6_del_rt,
+1 -1
net/ipv6/ip6_output.c
··· 174 174 #if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM) 175 175 /* Policy lookup after SNAT yielded a new policy */ 176 176 if (skb_dst(skb)->xfrm) { 177 - IPCB(skb)->flags |= IPSKB_REROUTED; 177 + IP6CB(skb)->flags |= IP6SKB_REROUTED; 178 178 return dst_output(net, sk, skb); 179 179 } 180 180 #endif
+19
net/ipv6/route.c
··· 3680 3680 fib_nh_common_release(&fib6_nh->nh_common); 3681 3681 } 3682 3682 3683 + void fib6_nh_release_dsts(struct fib6_nh *fib6_nh) 3684 + { 3685 + int cpu; 3686 + 3687 + if (!fib6_nh->rt6i_pcpu) 3688 + return; 3689 + 3690 + for_each_possible_cpu(cpu) { 3691 + struct rt6_info *pcpu_rt, **ppcpu_rt; 3692 + 3693 + ppcpu_rt = per_cpu_ptr(fib6_nh->rt6i_pcpu, cpu); 3694 + pcpu_rt = xchg(ppcpu_rt, NULL); 3695 + if (pcpu_rt) { 3696 + dst_dev_put(&pcpu_rt->dst); 3697 + dst_release(&pcpu_rt->dst); 3698 + } 3699 + } 3700 + } 3701 + 3683 3702 static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, 3684 3703 gfp_t gfp_flags, 3685 3704 struct netlink_ext_ack *extack)
+9 -23
net/mptcp/options.c
··· 422 422 return false; 423 423 } 424 424 425 - /* MP_JOIN client subflow must wait for 4th ack before sending any data: 426 - * TCP can't schedule delack timer before the subflow is fully established. 427 - * MPTCP uses the delack timer to do 3rd ack retransmissions 428 - */ 429 - static void schedule_3rdack_retransmission(struct sock *sk) 430 - { 431 - struct inet_connection_sock *icsk = inet_csk(sk); 432 - struct tcp_sock *tp = tcp_sk(sk); 433 - unsigned long timeout; 434 - 435 - /* reschedule with a timeout above RTT, as we must look only for drop */ 436 - if (tp->srtt_us) 437 - timeout = tp->srtt_us << 1; 438 - else 439 - timeout = TCP_TIMEOUT_INIT; 440 - 441 - WARN_ON_ONCE(icsk->icsk_ack.pending & ICSK_ACK_TIMER); 442 - icsk->icsk_ack.pending |= ICSK_ACK_SCHED | ICSK_ACK_TIMER; 443 - icsk->icsk_ack.timeout = timeout; 444 - sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout); 445 - } 446 - 447 425 static void clear_3rdack_retransmission(struct sock *sk) 448 426 { 449 427 struct inet_connection_sock *icsk = inet_csk(sk); ··· 504 526 *size = TCPOLEN_MPTCP_MPJ_ACK; 505 527 pr_debug("subflow=%p", subflow); 506 528 507 - schedule_3rdack_retransmission(sk); 529 + /* we can use the full delegate action helper only from BH context 530 + * If we are in process context - sk is flushing the backlog at 531 + * socket lock release time - just set the appropriate flag, will 532 + * be handled by the release callback 533 + */ 534 + if (sock_owned_by_user(sk)) 535 + set_bit(MPTCP_DELEGATE_ACK, &subflow->delegated_status); 536 + else 537 + mptcp_subflow_delegate(subflow, MPTCP_DELEGATE_ACK); 508 538 return true; 509 539 } 510 540 return false;
+42 -9
net/mptcp/protocol.c
··· 1596 1596 if (!xmit_ssk) 1597 1597 goto out; 1598 1598 if (xmit_ssk != ssk) { 1599 - mptcp_subflow_delegate(mptcp_subflow_ctx(xmit_ssk)); 1599 + mptcp_subflow_delegate(mptcp_subflow_ctx(xmit_ssk), 1600 + MPTCP_DELEGATE_SEND); 1600 1601 goto out; 1601 1602 } 1602 1603 ··· 2944 2943 if (xmit_ssk == ssk) 2945 2944 __mptcp_subflow_push_pending(sk, ssk); 2946 2945 else if (xmit_ssk) 2947 - mptcp_subflow_delegate(mptcp_subflow_ctx(xmit_ssk)); 2946 + mptcp_subflow_delegate(mptcp_subflow_ctx(xmit_ssk), MPTCP_DELEGATE_SEND); 2948 2947 } else { 2949 2948 set_bit(MPTCP_PUSH_PENDING, &mptcp_sk(sk)->flags); 2950 2949 } ··· 2994 2993 __mptcp_update_rmem(sk); 2995 2994 } 2996 2995 2996 + /* MP_JOIN client subflow must wait for 4th ack before sending any data: 2997 + * TCP can't schedule delack timer before the subflow is fully established. 2998 + * MPTCP uses the delack timer to do 3rd ack retransmissions 2999 + */ 3000 + static void schedule_3rdack_retransmission(struct sock *ssk) 3001 + { 3002 + struct inet_connection_sock *icsk = inet_csk(ssk); 3003 + struct tcp_sock *tp = tcp_sk(ssk); 3004 + unsigned long timeout; 3005 + 3006 + if (mptcp_subflow_ctx(ssk)->fully_established) 3007 + return; 3008 + 3009 + /* reschedule with a timeout above RTT, as we must look only for drop */ 3010 + if (tp->srtt_us) 3011 + timeout = usecs_to_jiffies(tp->srtt_us >> (3 - 1)); 3012 + else 3013 + timeout = TCP_TIMEOUT_INIT; 3014 + timeout += jiffies; 3015 + 3016 + WARN_ON_ONCE(icsk->icsk_ack.pending & ICSK_ACK_TIMER); 3017 + icsk->icsk_ack.pending |= ICSK_ACK_SCHED | ICSK_ACK_TIMER; 3018 + icsk->icsk_ack.timeout = timeout; 3019 + sk_reset_timer(ssk, &icsk->icsk_delack_timer, timeout); 3020 + } 3021 + 2997 3022 void mptcp_subflow_process_delegated(struct sock *ssk) 2998 3023 { 2999 3024 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); 3000 3025 struct sock *sk = subflow->conn; 3001 3026 3002 - mptcp_data_lock(sk); 3003 - if (!sock_owned_by_user(sk)) 3004 - __mptcp_subflow_push_pending(sk, ssk); 3005 - else 3006 - set_bit(MPTCP_PUSH_PENDING, &mptcp_sk(sk)->flags); 3007 - mptcp_data_unlock(sk); 3008 - mptcp_subflow_delegated_done(subflow); 3027 + if (test_bit(MPTCP_DELEGATE_SEND, &subflow->delegated_status)) { 3028 + mptcp_data_lock(sk); 3029 + if (!sock_owned_by_user(sk)) 3030 + __mptcp_subflow_push_pending(sk, ssk); 3031 + else 3032 + set_bit(MPTCP_PUSH_PENDING, &mptcp_sk(sk)->flags); 3033 + mptcp_data_unlock(sk); 3034 + mptcp_subflow_delegated_done(subflow, MPTCP_DELEGATE_SEND); 3035 + } 3036 + if (test_bit(MPTCP_DELEGATE_ACK, &subflow->delegated_status)) { 3037 + schedule_3rdack_retransmission(ssk); 3038 + mptcp_subflow_delegated_done(subflow, MPTCP_DELEGATE_ACK); 3039 + } 3009 3040 } 3010 3041 3011 3042 static int mptcp_hash(struct sock *sk)
+9 -8
net/mptcp/protocol.h
··· 387 387 DECLARE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions); 388 388 389 389 #define MPTCP_DELEGATE_SEND 0 390 + #define MPTCP_DELEGATE_ACK 1 390 391 391 392 /* MPTCP subflow context */ 392 393 struct mptcp_subflow_context { ··· 493 492 494 493 void mptcp_subflow_process_delegated(struct sock *ssk); 495 494 496 - static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow) 495 + static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow, int action) 497 496 { 498 497 struct mptcp_delegated_action *delegated; 499 498 bool schedule; 499 + 500 + /* the caller held the subflow bh socket lock */ 501 + lockdep_assert_in_softirq(); 500 502 501 503 /* The implied barrier pairs with mptcp_subflow_delegated_done(), and 502 504 * ensures the below list check sees list updates done prior to status 503 505 * bit changes 504 506 */ 505 - if (!test_and_set_bit(MPTCP_DELEGATE_SEND, &subflow->delegated_status)) { 507 + if (!test_and_set_bit(action, &subflow->delegated_status)) { 506 508 /* still on delegated list from previous scheduling */ 507 509 if (!list_empty(&subflow->delegated_node)) 508 510 return; 509 - 510 - /* the caller held the subflow bh socket lock */ 511 - lockdep_assert_in_softirq(); 512 511 513 512 delegated = this_cpu_ptr(&mptcp_delegated_actions); 514 513 schedule = list_empty(&delegated->head); ··· 534 533 535 534 static inline bool mptcp_subflow_has_delegated_action(const struct mptcp_subflow_context *subflow) 536 535 { 537 - return test_bit(MPTCP_DELEGATE_SEND, &subflow->delegated_status); 536 + return !!READ_ONCE(subflow->delegated_status); 538 537 } 539 538 540 - static inline void mptcp_subflow_delegated_done(struct mptcp_subflow_context *subflow) 539 + static inline void mptcp_subflow_delegated_done(struct mptcp_subflow_context *subflow, int action) 541 540 { 542 541 /* pairs with mptcp_subflow_delegate, ensures delegate_node is updated before 543 542 * touching the status bit 544 543 */ 545 544 smp_wmb(); 546 - clear_bit(MPTCP_DELEGATE_SEND, &subflow->delegated_status); 545 + clear_bit(action, &subflow->delegated_status); 547 546 } 548 547 549 548 int mptcp_is_enabled(const struct net *net);
+16 -8
net/ncsi/ncsi-cmd.c
··· 18 18 #include "internal.h" 19 19 #include "ncsi-pkt.h" 20 20 21 + static const int padding_bytes = 26; 22 + 21 23 u32 ncsi_calculate_checksum(unsigned char *data, int len) 22 24 { 23 25 u32 checksum = 0; ··· 215 213 { 216 214 struct ncsi_cmd_oem_pkt *cmd; 217 215 unsigned int len; 216 + int payload; 217 + /* NC-SI spec DSP_0222_1.2.0, section 8.2.2.2 218 + * requires payload to be padded with 0 to 219 + * 32-bit boundary before the checksum field. 220 + * Ensure the padding bytes are accounted for in 221 + * skb allocation 222 + */ 218 223 224 + payload = ALIGN(nca->payload, 4); 219 225 len = sizeof(struct ncsi_cmd_pkt_hdr) + 4; 220 - if (nca->payload < 26) 221 - len += 26; 222 - else 223 - len += nca->payload; 226 + len += max(payload, padding_bytes); 224 227 225 228 cmd = skb_put_zero(skb, len); 226 229 memcpy(&cmd->mfr_id, nca->data, nca->payload); ··· 279 272 struct net_device *dev = nd->dev; 280 273 int hlen = LL_RESERVED_SPACE(dev); 281 274 int tlen = dev->needed_tailroom; 275 + int payload; 282 276 int len = hlen + tlen; 283 277 struct sk_buff *skb; 284 278 struct ncsi_request *nr; ··· 289 281 return NULL; 290 282 291 283 /* NCSI command packet has 16-bytes header, payload, 4 bytes checksum. 284 + * Payload needs padding so that the checksum field following payload is 285 + * aligned to 32-bit boundary. 292 286 * The packet needs padding if its payload is less than 26 bytes to 293 287 * meet 64 bytes minimal ethernet frame length. 294 288 */ 295 289 len += sizeof(struct ncsi_cmd_pkt_hdr) + 4; 296 - if (nca->payload < 26) 297 - len += 26; 298 - else 299 - len += nca->payload; 290 + payload = ALIGN(nca->payload, 4); 291 + len += max(payload, padding_bytes); 300 292 301 293 /* Allocate skb */ 302 294 skb = alloc_skb(len, GFP_ATOMIC);
+4 -4
net/netfilter/ipvs/ip_vs_core.c
··· 1919 1919 struct ip_vs_proto_data *pd; 1920 1920 struct ip_vs_conn *cp; 1921 1921 int ret, pkts; 1922 - int conn_reuse_mode; 1923 1922 struct sock *sk; 1924 1923 int af = state->pf; 1925 1924 ··· 1996 1997 cp = INDIRECT_CALL_1(pp->conn_in_get, ip_vs_conn_in_get_proto, 1997 1998 ipvs, af, skb, &iph); 1998 1999 1999 - conn_reuse_mode = sysctl_conn_reuse_mode(ipvs); 2000 - if (conn_reuse_mode && !iph.fragoffs && is_new_conn(skb, &iph) && cp) { 2000 + if (!iph.fragoffs && is_new_conn(skb, &iph) && cp) { 2001 + int conn_reuse_mode = sysctl_conn_reuse_mode(ipvs); 2001 2002 bool old_ct = false, resched = false; 2002 2003 2003 2004 if (unlikely(sysctl_expire_nodest_conn(ipvs)) && cp->dest && 2004 2005 unlikely(!atomic_read(&cp->dest->weight))) { 2005 2006 resched = true; 2006 2007 old_ct = ip_vs_conn_uses_old_conntrack(cp, skb); 2007 - } else if (is_new_conn_expected(cp, conn_reuse_mode)) { 2008 + } else if (conn_reuse_mode && 2009 + is_new_conn_expected(cp, conn_reuse_mode)) { 2008 2010 old_ct = ip_vs_conn_uses_old_conntrack(cp, skb); 2009 2011 if (!atomic_read(&cp->n_control)) { 2010 2012 resched = true;
+2 -4
net/netfilter/nf_conntrack_netlink.c
··· 1011 1011 CTA_TUPLE_REPLY, 1012 1012 filter->family, 1013 1013 &filter->zone, 1014 - filter->orig_flags); 1015 - if (err < 0) { 1016 - err = -EINVAL; 1014 + filter->reply_flags); 1015 + if (err < 0) 1017 1016 goto err_filter; 1018 - } 1019 1017 } 1020 1018 1021 1019 return filter;
+2 -2
net/netfilter/nf_flow_table_offload.c
··· 65 65 sizeof(struct in6_addr)); 66 66 if (memcmp(&key->enc_ipv6.src, &in6addr_any, 67 67 sizeof(struct in6_addr))) 68 - memset(&key->enc_ipv6.src, 0xff, 68 + memset(&mask->enc_ipv6.src, 0xff, 69 69 sizeof(struct in6_addr)); 70 70 if (memcmp(&key->enc_ipv6.dst, &in6addr_any, 71 71 sizeof(struct in6_addr))) 72 - memset(&key->enc_ipv6.dst, 0xff, 72 + memset(&mask->enc_ipv6.dst, 0xff, 73 73 sizeof(struct in6_addr)); 74 74 enc_keys |= BIT(FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS); 75 75 key->enc_control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
-1
net/netfilter/nft_payload.c
··· 22 22 #include <linux/icmpv6.h> 23 23 #include <linux/ip.h> 24 24 #include <linux/ipv6.h> 25 - #include <linux/ip.h> 26 25 #include <net/sctp/checksum.h> 27 26 28 27 static bool nft_payload_rebuild_vlan_hdr(const struct sk_buff *skb, int mac_off,
+2 -2
net/netfilter/xt_IDLETIMER.c
··· 85 85 mutex_unlock(&list_mutex); 86 86 87 87 if (time_after(expires, jiffies) || ktimespec.tv_sec > 0) 88 - return snprintf(buf, PAGE_SIZE, "%ld\n", time_diff); 88 + return sysfs_emit(buf, "%ld\n", time_diff); 89 89 90 - return snprintf(buf, PAGE_SIZE, "0\n"); 90 + return sysfs_emit(buf, "0\n"); 91 91 } 92 92 93 93 static void idletimer_tg_work(struct work_struct *work)
+5 -3
net/sched/sch_ets.c
··· 665 665 q->classes[i].deficit = quanta[i]; 666 666 } 667 667 } 668 + for (i = q->nbands; i < oldbands; i++) { 669 + qdisc_tree_flush_backlog(q->classes[i].qdisc); 670 + if (i >= q->nstrict) 671 + list_del(&q->classes[i].alist); 672 + } 668 673 q->nstrict = nstrict; 669 674 memcpy(q->prio2band, priomap, sizeof(priomap)); 670 - 671 - for (i = q->nbands; i < oldbands; i++) 672 - qdisc_tree_flush_backlog(q->classes[i].qdisc); 673 675 674 676 for (i = 0; i < q->nbands; i++) 675 677 q->classes[i].quantum = quanta[i];
+11 -3
net/smc/af_smc.c
··· 585 585 * to clcsocket->wq during the fallback. 586 586 */ 587 587 spin_lock_irqsave(&smc_wait->lock, flags); 588 - spin_lock(&clc_wait->lock); 588 + spin_lock_nested(&clc_wait->lock, SINGLE_DEPTH_NESTING); 589 589 list_splice_init(&smc_wait->head, &clc_wait->head); 590 590 spin_unlock(&clc_wait->lock); 591 591 spin_unlock_irqrestore(&smc_wait->lock, flags); ··· 2134 2134 smc->clcsock->sk->sk_user_data = 2135 2135 (void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY); 2136 2136 rc = kernel_listen(smc->clcsock, backlog); 2137 - if (rc) 2137 + if (rc) { 2138 + smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready; 2138 2139 goto out; 2140 + } 2139 2141 sk->sk_max_ack_backlog = backlog; 2140 2142 sk->sk_ack_backlog = 0; 2141 2143 sk->sk_state = SMC_LISTEN; ··· 2370 2368 static int smc_shutdown(struct socket *sock, int how) 2371 2369 { 2372 2370 struct sock *sk = sock->sk; 2371 + bool do_shutdown = true; 2373 2372 struct smc_sock *smc; 2374 2373 int rc = -EINVAL; 2374 + int old_state; 2375 2375 int rc1 = 0; 2376 2376 2377 2377 smc = smc_sk(sk); ··· 2400 2396 } 2401 2397 switch (how) { 2402 2398 case SHUT_RDWR: /* shutdown in both directions */ 2399 + old_state = sk->sk_state; 2403 2400 rc = smc_close_active(smc); 2401 + if (old_state == SMC_ACTIVE && 2402 + sk->sk_state == SMC_PEERCLOSEWAIT1) 2403 + do_shutdown = false; 2404 2404 break; 2405 2405 case SHUT_WR: 2406 2406 rc = smc_close_shutdown_write(smc); ··· 2414 2406 /* nothing more to do because peer is not involved */ 2415 2407 break; 2416 2408 } 2417 - if (smc->clcsock) 2409 + if (do_shutdown && smc->clcsock) 2418 2410 rc1 = kernel_sock_shutdown(smc->clcsock, how); 2419 2411 /* map sock_shutdown_cmd constants to sk_shutdown value range */ 2420 2412 sk->sk_shutdown |= how + 1;
+8 -2
net/smc/smc_close.c
··· 228 228 /* send close request */ 229 229 rc = smc_close_final(conn); 230 230 sk->sk_state = SMC_PEERCLOSEWAIT1; 231 + 232 + /* actively shutdown clcsock before peer close it, 233 + * prevent peer from entering TIME_WAIT state. 234 + */ 235 + if (smc->clcsock && smc->clcsock->sk) 236 + rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR); 231 237 } else { 232 238 /* peer event has changed the state */ 233 239 goto again; ··· 360 354 if (rxflags->peer_conn_abort) { 361 355 /* peer has not received all data */ 362 356 smc_close_passive_abort_received(smc); 363 - release_sock(&smc->sk); 357 + release_sock(sk); 364 358 cancel_delayed_work_sync(&conn->tx_work); 365 - lock_sock(&smc->sk); 359 + lock_sock(sk); 366 360 goto wakeup; 367 361 } 368 362
+18 -17
net/smc/smc_core.c
··· 1672 1672 mutex_unlock(&lgr->llc_conf_mutex); 1673 1673 } 1674 1674 1675 - /* Determine vlan of internal TCP socket. 1676 - * @vlan_id: address to store the determined vlan id into 1677 - */ 1675 + static int smc_vlan_by_tcpsk_walk(struct net_device *lower_dev, 1676 + struct netdev_nested_priv *priv) 1677 + { 1678 + unsigned short *vlan_id = (unsigned short *)priv->data; 1679 + 1680 + if (is_vlan_dev(lower_dev)) { 1681 + *vlan_id = vlan_dev_vlan_id(lower_dev); 1682 + return 1; 1683 + } 1684 + 1685 + return 0; 1686 + } 1687 + 1688 + /* Determine vlan of internal TCP socket. */ 1678 1689 int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini) 1679 1690 { 1680 1691 struct dst_entry *dst = sk_dst_get(clcsock->sk); 1692 + struct netdev_nested_priv priv; 1681 1693 struct net_device *ndev; 1682 - int i, nest_lvl, rc = 0; 1694 + int rc = 0; 1683 1695 1684 1696 ini->vlan_id = 0; 1685 1697 if (!dst) { ··· 1709 1697 goto out_rel; 1710 1698 } 1711 1699 1700 + priv.data = (void *)&ini->vlan_id; 1712 1701 rtnl_lock(); 1713 - nest_lvl = ndev->lower_level; 1714 - for (i = 0; i < nest_lvl; i++) { 1715 - struct list_head *lower = &ndev->adj_list.lower; 1716 - 1717 - if (list_empty(lower)) 1718 - break; 1719 - lower = lower->next; 1720 - ndev = (struct net_device *)netdev_lower_get_next(ndev, &lower); 1721 - if (is_vlan_dev(ndev)) { 1722 - ini->vlan_id = vlan_dev_vlan_id(ndev); 1723 - break; 1724 - } 1725 - } 1702 + netdev_walk_all_lower_dev(ndev, smc_vlan_by_tcpsk_walk, &priv); 1726 1703 rtnl_unlock(); 1727 1704 1728 1705 out_rel:
+40 -7
net/tls/tls_main.c
··· 61 61 static const struct proto *saved_tcpv4_prot; 62 62 static DEFINE_MUTEX(tcpv4_prot_mutex); 63 63 static struct proto tls_prots[TLS_NUM_PROTS][TLS_NUM_CONFIG][TLS_NUM_CONFIG]; 64 - static struct proto_ops tls_sw_proto_ops; 64 + static struct proto_ops tls_proto_ops[TLS_NUM_PROTS][TLS_NUM_CONFIG][TLS_NUM_CONFIG]; 65 65 static void build_protos(struct proto prot[TLS_NUM_CONFIG][TLS_NUM_CONFIG], 66 66 const struct proto *base); 67 67 ··· 71 71 72 72 WRITE_ONCE(sk->sk_prot, 73 73 &tls_prots[ip_ver][ctx->tx_conf][ctx->rx_conf]); 74 + WRITE_ONCE(sk->sk_socket->ops, 75 + &tls_proto_ops[ip_ver][ctx->tx_conf][ctx->rx_conf]); 74 76 } 75 77 76 78 int wait_on_pending_writer(struct sock *sk, long *timeo) ··· 671 669 if (tx) { 672 670 ctx->sk_write_space = sk->sk_write_space; 673 671 sk->sk_write_space = tls_write_space; 674 - } else { 675 - sk->sk_socket->ops = &tls_sw_proto_ops; 676 672 } 677 673 goto out; 678 674 ··· 728 728 return ctx; 729 729 } 730 730 731 + static void build_proto_ops(struct proto_ops ops[TLS_NUM_CONFIG][TLS_NUM_CONFIG], 732 + const struct proto_ops *base) 733 + { 734 + ops[TLS_BASE][TLS_BASE] = *base; 735 + 736 + ops[TLS_SW ][TLS_BASE] = ops[TLS_BASE][TLS_BASE]; 737 + ops[TLS_SW ][TLS_BASE].sendpage_locked = tls_sw_sendpage_locked; 738 + 739 + ops[TLS_BASE][TLS_SW ] = ops[TLS_BASE][TLS_BASE]; 740 + ops[TLS_BASE][TLS_SW ].splice_read = tls_sw_splice_read; 741 + 742 + ops[TLS_SW ][TLS_SW ] = ops[TLS_SW ][TLS_BASE]; 743 + ops[TLS_SW ][TLS_SW ].splice_read = tls_sw_splice_read; 744 + 745 + #ifdef CONFIG_TLS_DEVICE 746 + ops[TLS_HW ][TLS_BASE] = ops[TLS_BASE][TLS_BASE]; 747 + ops[TLS_HW ][TLS_BASE].sendpage_locked = NULL; 748 + 749 + ops[TLS_HW ][TLS_SW ] = ops[TLS_BASE][TLS_SW ]; 750 + ops[TLS_HW ][TLS_SW ].sendpage_locked = NULL; 751 + 752 + ops[TLS_BASE][TLS_HW ] = ops[TLS_BASE][TLS_SW ]; 753 + 754 + ops[TLS_SW ][TLS_HW ] = ops[TLS_SW ][TLS_SW ]; 755 + 756 + ops[TLS_HW ][TLS_HW ] = ops[TLS_HW ][TLS_SW ]; 757 + ops[TLS_HW ][TLS_HW ].sendpage_locked = NULL; 758 + #endif 759 + #ifdef CONFIG_TLS_TOE 760 + ops[TLS_HW_RECORD][TLS_HW_RECORD] = *base; 761 + #endif 762 + } 763 + 731 764 static void tls_build_proto(struct sock *sk) 732 765 { 733 766 int ip_ver = sk->sk_family == AF_INET6 ? TLSV6 : TLSV4; ··· 772 739 mutex_lock(&tcpv6_prot_mutex); 773 740 if (likely(prot != saved_tcpv6_prot)) { 774 741 build_protos(tls_prots[TLSV6], prot); 742 + build_proto_ops(tls_proto_ops[TLSV6], 743 + sk->sk_socket->ops); 775 744 smp_store_release(&saved_tcpv6_prot, prot); 776 745 } 777 746 mutex_unlock(&tcpv6_prot_mutex); ··· 784 749 mutex_lock(&tcpv4_prot_mutex); 785 750 if (likely(prot != saved_tcpv4_prot)) { 786 751 build_protos(tls_prots[TLSV4], prot); 752 + build_proto_ops(tls_proto_ops[TLSV4], 753 + sk->sk_socket->ops); 787 754 smp_store_release(&saved_tcpv4_prot, prot); 788 755 } 789 756 mutex_unlock(&tcpv4_prot_mutex); ··· 995 958 err = register_pernet_subsys(&tls_proc_ops); 996 959 if (err) 997 960 return err; 998 - 999 - tls_sw_proto_ops = inet_stream_ops; 1000 - tls_sw_proto_ops.splice_read = tls_sw_splice_read; 1001 - tls_sw_proto_ops.sendpage_locked = tls_sw_sendpage_locked; 1002 961 1003 962 tls_device_init(); 1004 963 tcp_register_ulp(&tcp_tls_ulp_ops);
+27 -13
net/tls/tls_sw.c
··· 2005 2005 struct sock *sk = sock->sk; 2006 2006 struct sk_buff *skb; 2007 2007 ssize_t copied = 0; 2008 + bool from_queue; 2008 2009 int err = 0; 2009 2010 long timeo; 2010 2011 int chunk; ··· 2015 2014 2016 2015 timeo = sock_rcvtimeo(sk, flags & SPLICE_F_NONBLOCK); 2017 2016 2018 - skb = tls_wait_data(sk, NULL, flags & SPLICE_F_NONBLOCK, timeo, &err); 2019 - if (!skb) 2020 - goto splice_read_end; 2021 - 2022 - if (!ctx->decrypted) { 2023 - err = decrypt_skb_update(sk, skb, NULL, &chunk, &zc, false); 2024 - 2025 - /* splice does not support reading control messages */ 2026 - if (ctx->control != TLS_RECORD_TYPE_DATA) { 2027 - err = -EINVAL; 2017 + from_queue = !skb_queue_empty(&ctx->rx_list); 2018 + if (from_queue) { 2019 + skb = __skb_dequeue(&ctx->rx_list); 2020 + } else { 2021 + skb = tls_wait_data(sk, NULL, flags & SPLICE_F_NONBLOCK, timeo, 2022 + &err); 2023 + if (!skb) 2028 2024 goto splice_read_end; 2029 - } 2030 2025 2026 + err = decrypt_skb_update(sk, skb, NULL, &chunk, &zc, false); 2031 2027 if (err < 0) { 2032 2028 tls_err_abort(sk, -EBADMSG); 2033 2029 goto splice_read_end; 2034 2030 } 2035 - ctx->decrypted = 1; 2036 2031 } 2032 + 2033 + /* splice does not support reading control messages */ 2034 + if (ctx->control != TLS_RECORD_TYPE_DATA) { 2035 + err = -EINVAL; 2036 + goto splice_read_end; 2037 + } 2038 + 2037 2039 rxm = strp_msg(skb); 2038 2040 2039 2041 chunk = min_t(unsigned int, rxm->full_len, len); ··· 2044 2040 if (copied < 0) 2045 2041 goto splice_read_end; 2046 2042 2047 - tls_sw_advance_skb(sk, skb, copied); 2043 + if (!from_queue) { 2044 + ctx->recv_pkt = NULL; 2045 + __strp_unpause(&ctx->strp); 2046 + } 2047 + if (chunk < rxm->full_len) { 2048 + __skb_queue_head(&ctx->rx_list, skb); 2049 + rxm->offset += len; 2050 + rxm->full_len -= len; 2051 + } else { 2052 + consume_skb(skb); 2053 + } 2048 2054 2049 2055 splice_read_end: 2050 2056 release_sock(sk);
-3
net/unix/af_unix.c
··· 2882 2882 2883 2883 unix_state_lock(sk); 2884 2884 sk->sk_shutdown |= mode; 2885 - if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) && 2886 - mode == SHUTDOWN_MASK) 2887 - sk->sk_state = TCP_CLOSE; 2888 2885 other = unix_peer(sk); 2889 2886 if (other) 2890 2887 sock_hold(other);
+1
net/vmw_vsock/virtio_transport.c
··· 731 731 static struct virtio_driver virtio_vsock_driver = { 732 732 .feature_table = features, 733 733 .feature_table_size = ARRAY_SIZE(features), 734 + .suppress_used_validation = true, 734 735 .driver.name = KBUILD_MODNAME, 735 736 .driver.owner = THIS_MODULE, 736 737 .id_table = id_table,
+259 -34
tools/include/uapi/linux/if_link.h
··· 7 7 8 8 /* This struct should be in sync with struct rtnl_link_stats64 */ 9 9 struct rtnl_link_stats { 10 - __u32 rx_packets; /* total packets received */ 11 - __u32 tx_packets; /* total packets transmitted */ 12 - __u32 rx_bytes; /* total bytes received */ 13 - __u32 tx_bytes; /* total bytes transmitted */ 14 - __u32 rx_errors; /* bad packets received */ 15 - __u32 tx_errors; /* packet transmit problems */ 16 - __u32 rx_dropped; /* no space in linux buffers */ 17 - __u32 tx_dropped; /* no space available in linux */ 18 - __u32 multicast; /* multicast packets received */ 10 + __u32 rx_packets; 11 + __u32 tx_packets; 12 + __u32 rx_bytes; 13 + __u32 tx_bytes; 14 + __u32 rx_errors; 15 + __u32 tx_errors; 16 + __u32 rx_dropped; 17 + __u32 tx_dropped; 18 + __u32 multicast; 19 19 __u32 collisions; 20 - 21 20 /* detailed rx_errors: */ 22 21 __u32 rx_length_errors; 23 - __u32 rx_over_errors; /* receiver ring buff overflow */ 24 - __u32 rx_crc_errors; /* recved pkt with crc error */ 25 - __u32 rx_frame_errors; /* recv'd frame alignment error */ 26 - __u32 rx_fifo_errors; /* recv'r fifo overrun */ 27 - __u32 rx_missed_errors; /* receiver missed packet */ 22 + __u32 rx_over_errors; 23 + __u32 rx_crc_errors; 24 + __u32 rx_frame_errors; 25 + __u32 rx_fifo_errors; 26 + __u32 rx_missed_errors; 28 27 29 28 /* detailed tx_errors */ 30 29 __u32 tx_aborted_errors; ··· 36 37 __u32 rx_compressed; 37 38 __u32 tx_compressed; 38 39 39 - __u32 rx_nohandler; /* dropped, no handler found */ 40 + __u32 rx_nohandler; 40 41 }; 41 42 42 - /* The main device statistics structure */ 43 + /** 44 + * struct rtnl_link_stats64 - The main device statistics structure. 45 + * 46 + * @rx_packets: Number of good packets received by the interface. 47 + * For hardware interfaces counts all good packets received from the device 48 + * by the host, including packets which host had to drop at various stages 49 + * of processing (even in the driver). 50 + * 51 + * @tx_packets: Number of packets successfully transmitted. 52 + * For hardware interfaces counts packets which host was able to successfully 53 + * hand over to the device, which does not necessarily mean that packets 54 + * had been successfully transmitted out of the device, only that device 55 + * acknowledged it copied them out of host memory. 56 + * 57 + * @rx_bytes: Number of good received bytes, corresponding to @rx_packets. 58 + * 59 + * For IEEE 802.3 devices should count the length of Ethernet Frames 60 + * excluding the FCS. 61 + * 62 + * @tx_bytes: Number of good transmitted bytes, corresponding to @tx_packets. 63 + * 64 + * For IEEE 802.3 devices should count the length of Ethernet Frames 65 + * excluding the FCS. 66 + * 67 + * @rx_errors: Total number of bad packets received on this network device. 68 + * This counter must include events counted by @rx_length_errors, 69 + * @rx_crc_errors, @rx_frame_errors and other errors not otherwise 70 + * counted. 71 + * 72 + * @tx_errors: Total number of transmit problems. 73 + * This counter must include events counter by @tx_aborted_errors, 74 + * @tx_carrier_errors, @tx_fifo_errors, @tx_heartbeat_errors, 75 + * @tx_window_errors and other errors not otherwise counted. 76 + * 77 + * @rx_dropped: Number of packets received but not processed, 78 + * e.g. due to lack of resources or unsupported protocol. 79 + * For hardware interfaces this counter may include packets discarded 80 + * due to L2 address filtering but should not include packets dropped 81 + * by the device due to buffer exhaustion which are counted separately in 82 + * @rx_missed_errors (since procfs folds those two counters together). 83 + * 84 + * @tx_dropped: Number of packets dropped on their way to transmission, 85 + * e.g. due to lack of resources. 86 + * 87 + * @multicast: Multicast packets received. 88 + * For hardware interfaces this statistic is commonly calculated 89 + * at the device level (unlike @rx_packets) and therefore may include 90 + * packets which did not reach the host. 91 + * 92 + * For IEEE 802.3 devices this counter may be equivalent to: 93 + * 94 + * - 30.3.1.1.21 aMulticastFramesReceivedOK 95 + * 96 + * @collisions: Number of collisions during packet transmissions. 97 + * 98 + * @rx_length_errors: Number of packets dropped due to invalid length. 99 + * Part of aggregate "frame" errors in `/proc/net/dev`. 100 + * 101 + * For IEEE 802.3 devices this counter should be equivalent to a sum 102 + * of the following attributes: 103 + * 104 + * - 30.3.1.1.23 aInRangeLengthErrors 105 + * - 30.3.1.1.24 aOutOfRangeLengthField 106 + * - 30.3.1.1.25 aFrameTooLongErrors 107 + * 108 + * @rx_over_errors: Receiver FIFO overflow event counter. 109 + * 110 + * Historically the count of overflow events. Such events may be 111 + * reported in the receive descriptors or via interrupts, and may 112 + * not correspond one-to-one with dropped packets. 113 + * 114 + * The recommended interpretation for high speed interfaces is - 115 + * number of packets dropped because they did not fit into buffers 116 + * provided by the host, e.g. packets larger than MTU or next buffer 117 + * in the ring was not available for a scatter transfer. 118 + * 119 + * Part of aggregate "frame" errors in `/proc/net/dev`. 120 + * 121 + * This statistics was historically used interchangeably with 122 + * @rx_fifo_errors. 123 + * 124 + * This statistic corresponds to hardware events and is not commonly used 125 + * on software devices. 126 + * 127 + * @rx_crc_errors: Number of packets received with a CRC error. 128 + * Part of aggregate "frame" errors in `/proc/net/dev`. 129 + * 130 + * For IEEE 802.3 devices this counter must be equivalent to: 131 + * 132 + * - 30.3.1.1.6 aFrameCheckSequenceErrors 133 + * 134 + * @rx_frame_errors: Receiver frame alignment errors. 135 + * Part of aggregate "frame" errors in `/proc/net/dev`. 136 + * 137 + * For IEEE 802.3 devices this counter should be equivalent to: 138 + * 139 + * - 30.3.1.1.7 aAlignmentErrors 140 + * 141 + * @rx_fifo_errors: Receiver FIFO error counter. 142 + * 143 + * Historically the count of overflow events. Those events may be 144 + * reported in the receive descriptors or via interrupts, and may 145 + * not correspond one-to-one with dropped packets. 146 + * 147 + * This statistics was used interchangeably with @rx_over_errors. 148 + * Not recommended for use in drivers for high speed interfaces. 149 + * 150 + * This statistic is used on software devices, e.g. to count software 151 + * packet queue overflow (can) or sequencing errors (GRE). 152 + * 153 + * @rx_missed_errors: Count of packets missed by the host. 154 + * Folded into the "drop" counter in `/proc/net/dev`. 155 + * 156 + * Counts number of packets dropped by the device due to lack 157 + * of buffer space. This usually indicates that the host interface 158 + * is slower than the network interface, or host is not keeping up 159 + * with the receive packet rate. 160 + * 161 + * This statistic corresponds to hardware events and is not used 162 + * on software devices. 163 + * 164 + * @tx_aborted_errors: 165 + * Part of aggregate "carrier" errors in `/proc/net/dev`. 166 + * For IEEE 802.3 devices capable of half-duplex operation this counter 167 + * must be equivalent to: 168 + * 169 + * - 30.3.1.1.11 aFramesAbortedDueToXSColls 170 + * 171 + * High speed interfaces may use this counter as a general device 172 + * discard counter. 173 + * 174 + * @tx_carrier_errors: Number of frame transmission errors due to loss 175 + * of carrier during transmission. 176 + * Part of aggregate "carrier" errors in `/proc/net/dev`. 177 + * 178 + * For IEEE 802.3 devices this counter must be equivalent to: 179 + * 180 + * - 30.3.1.1.13 aCarrierSenseErrors 181 + * 182 + * @tx_fifo_errors: Number of frame transmission errors due to device 183 + * FIFO underrun / underflow. This condition occurs when the device 184 + * begins transmission of a frame but is unable to deliver the 185 + * entire frame to the transmitter in time for transmission. 186 + * Part of aggregate "carrier" errors in `/proc/net/dev`. 187 + * 188 + * @tx_heartbeat_errors: Number of Heartbeat / SQE Test errors for 189 + * old half-duplex Ethernet. 190 + * Part of aggregate "carrier" errors in `/proc/net/dev`. 191 + * 192 + * For IEEE 802.3 devices possibly equivalent to: 193 + * 194 + * - 30.3.2.1.4 aSQETestErrors 195 + * 196 + * @tx_window_errors: Number of frame transmission errors due 197 + * to late collisions (for Ethernet - after the first 64B of transmission). 198 + * Part of aggregate "carrier" errors in `/proc/net/dev`. 199 + * 200 + * For IEEE 802.3 devices this counter must be equivalent to: 201 + * 202 + * - 30.3.1.1.10 aLateCollisions 203 + * 204 + * @rx_compressed: Number of correctly received compressed packets. 205 + * This counters is only meaningful for interfaces which support 206 + * packet compression (e.g. CSLIP, PPP). 207 + * 208 + * @tx_compressed: Number of transmitted compressed packets. 209 + * This counters is only meaningful for interfaces which support 210 + * packet compression (e.g. CSLIP, PPP). 211 + * 212 + * @rx_nohandler: Number of packets received on the interface 213 + * but dropped by the networking stack because the device is 214 + * not designated to receive packets (e.g. backup link in a bond). 215 + */ 43 216 struct rtnl_link_stats64 { 44 - __u64 rx_packets; /* total packets received */ 45 - __u64 tx_packets; /* total packets transmitted */ 46 - __u64 rx_bytes; /* total bytes received */ 47 - __u64 tx_bytes; /* total bytes transmitted */ 48 - __u64 rx_errors; /* bad packets received */ 49 - __u64 tx_errors; /* packet transmit problems */ 50 - __u64 rx_dropped; /* no space in linux buffers */ 51 - __u64 tx_dropped; /* no space available in linux */ 52 - __u64 multicast; /* multicast packets received */ 217 + __u64 rx_packets; 218 + __u64 tx_packets; 219 + __u64 rx_bytes; 220 + __u64 tx_bytes; 221 + __u64 rx_errors; 222 + __u64 tx_errors; 223 + __u64 rx_dropped; 224 + __u64 tx_dropped; 225 + __u64 multicast; 53 226 __u64 collisions; 54 227 55 228 /* detailed rx_errors: */ 56 229 __u64 rx_length_errors; 57 - __u64 rx_over_errors; /* receiver ring buff overflow */ 58 - __u64 rx_crc_errors; /* recved pkt with crc error */ 59 - __u64 rx_frame_errors; /* recv'd frame alignment error */ 60 - __u64 rx_fifo_errors; /* recv'r fifo overrun */ 61 - __u64 rx_missed_errors; /* receiver missed packet */ 230 + __u64 rx_over_errors; 231 + __u64 rx_crc_errors; 232 + __u64 rx_frame_errors; 233 + __u64 rx_fifo_errors; 234 + __u64 rx_missed_errors; 62 235 63 236 /* detailed tx_errors */ 64 237 __u64 tx_aborted_errors; ··· 242 71 /* for cslip etc */ 243 72 __u64 rx_compressed; 244 73 __u64 tx_compressed; 245 - 246 - __u64 rx_nohandler; /* dropped, no handler found */ 74 + __u64 rx_nohandler; 247 75 }; 248 76 249 77 /* The struct should be in sync with struct ifmap */ ··· 340 170 IFLA_PROP_LIST, 341 171 IFLA_ALT_IFNAME, /* Alternative ifname */ 342 172 IFLA_PERM_ADDRESS, 173 + IFLA_PROTO_DOWN_REASON, 174 + 175 + /* device (sysfs) name as parent, used instead 176 + * of IFLA_LINK where there's no parent netdev 177 + */ 178 + IFLA_PARENT_DEV_NAME, 179 + IFLA_PARENT_DEV_BUS_NAME, 180 + 343 181 __IFLA_MAX 344 182 }; 345 183 346 184 347 185 #define IFLA_MAX (__IFLA_MAX - 1) 186 + 187 + enum { 188 + IFLA_PROTO_DOWN_REASON_UNSPEC, 189 + IFLA_PROTO_DOWN_REASON_MASK, /* u32, mask for reason bits */ 190 + IFLA_PROTO_DOWN_REASON_VALUE, /* u32, reason bit value */ 191 + 192 + __IFLA_PROTO_DOWN_REASON_CNT, 193 + IFLA_PROTO_DOWN_REASON_MAX = __IFLA_PROTO_DOWN_REASON_CNT - 1 194 + }; 348 195 349 196 /* backwards compatibility for userspace */ 350 197 #ifndef __KERNEL__ ··· 480 293 IFLA_BR_MCAST_MLD_VERSION, 481 294 IFLA_BR_VLAN_STATS_PER_PORT, 482 295 IFLA_BR_MULTI_BOOLOPT, 296 + IFLA_BR_MCAST_QUERIER_STATE, 483 297 __IFLA_BR_MAX, 484 298 }; 485 299 ··· 534 346 IFLA_BRPORT_BACKUP_PORT, 535 347 IFLA_BRPORT_MRP_RING_OPEN, 536 348 IFLA_BRPORT_MRP_IN_OPEN, 349 + IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT, 350 + IFLA_BRPORT_MCAST_EHT_HOSTS_CNT, 537 351 __IFLA_BRPORT_MAX 538 352 }; 539 353 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) ··· 623 433 }; 624 434 625 435 #define MACVLAN_FLAG_NOPROMISC 1 436 + #define MACVLAN_FLAG_NODST 2 /* skip dst macvlan if matching src macvlan */ 626 437 627 438 /* VRF section */ 628 439 enum { ··· 787 596 __GENEVE_DF_END, 788 597 GENEVE_DF_MAX = __GENEVE_DF_END - 1, 789 598 }; 599 + 600 + /* Bareudp section */ 601 + enum { 602 + IFLA_BAREUDP_UNSPEC, 603 + IFLA_BAREUDP_PORT, 604 + IFLA_BAREUDP_ETHERTYPE, 605 + IFLA_BAREUDP_SRCPORT_MIN, 606 + IFLA_BAREUDP_MULTIPROTO_MODE, 607 + __IFLA_BAREUDP_MAX 608 + }; 609 + 610 + #define IFLA_BAREUDP_MAX (__IFLA_BAREUDP_MAX - 1) 790 611 791 612 /* PPP section */ 792 613 enum { ··· 1102 899 #define IFLA_IPOIB_MAX (__IFLA_IPOIB_MAX - 1) 1103 900 1104 901 1105 - /* HSR section */ 902 + /* HSR/PRP section, both uses same interface */ 903 + 904 + /* Different redundancy protocols for hsr device */ 905 + enum { 906 + HSR_PROTOCOL_HSR, 907 + HSR_PROTOCOL_PRP, 908 + HSR_PROTOCOL_MAX, 909 + }; 1106 910 1107 911 enum { 1108 912 IFLA_HSR_UNSPEC, ··· 1119 909 IFLA_HSR_SUPERVISION_ADDR, /* Supervision frame multicast addr */ 1120 910 IFLA_HSR_SEQ_NR, 1121 911 IFLA_HSR_VERSION, /* HSR version */ 912 + IFLA_HSR_PROTOCOL, /* Indicate different protocol than 913 + * HSR. For example PRP. 914 + */ 1122 915 __IFLA_HSR_MAX, 1123 916 }; 1124 917 ··· 1246 1033 #define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) 1247 1034 #define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) 1248 1035 #define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) 1036 + #define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 4) 1037 + #define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 5) 1249 1038 1250 1039 enum { 1251 1040 IFLA_RMNET_UNSPEC, ··· 1262 1047 __u32 flags; 1263 1048 __u32 mask; 1264 1049 }; 1050 + 1051 + /* MCTP section */ 1052 + 1053 + enum { 1054 + IFLA_MCTP_UNSPEC, 1055 + IFLA_MCTP_NET, 1056 + __IFLA_MCTP_MAX, 1057 + }; 1058 + 1059 + #define IFLA_MCTP_MAX (__IFLA_MCTP_MAX - 1) 1265 1060 1266 1061 #endif /* _UAPI_LINUX_IF_LINK_H */
+1
tools/testing/selftests/net/Makefile
··· 34 34 TEST_PROGS += srv6_end_dt4_l3vpn_test.sh 35 35 TEST_PROGS += srv6_end_dt6_l3vpn_test.sh 36 36 TEST_PROGS += vrf_strict_mode_test.sh 37 + TEST_PROGS += arp_ndisc_evict_nocarrier.sh 37 38 TEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh 38 39 TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh 39 40 TEST_GEN_FILES = socket nettest
+63
tools/testing/selftests/net/fib_nexthops.sh
··· 629 629 log_test $? 0 "Nexthops removed on admin down" 630 630 } 631 631 632 + ipv6_grp_refs() 633 + { 634 + if [ ! -x "$(command -v mausezahn)" ]; then 635 + echo "SKIP: Could not run test; need mausezahn tool" 636 + return 637 + fi 638 + 639 + run_cmd "$IP link set dev veth1 up" 640 + run_cmd "$IP link add veth1.10 link veth1 up type vlan id 10" 641 + run_cmd "$IP link add veth1.20 link veth1 up type vlan id 20" 642 + run_cmd "$IP -6 addr add 2001:db8:91::1/64 dev veth1.10" 643 + run_cmd "$IP -6 addr add 2001:db8:92::1/64 dev veth1.20" 644 + run_cmd "$IP -6 neigh add 2001:db8:91::2 lladdr 00:11:22:33:44:55 dev veth1.10" 645 + run_cmd "$IP -6 neigh add 2001:db8:92::2 lladdr 00:11:22:33:44:55 dev veth1.20" 646 + run_cmd "$IP nexthop add id 100 via 2001:db8:91::2 dev veth1.10" 647 + run_cmd "$IP nexthop add id 101 via 2001:db8:92::2 dev veth1.20" 648 + run_cmd "$IP nexthop add id 102 group 100" 649 + run_cmd "$IP route add 2001:db8:101::1/128 nhid 102" 650 + 651 + # create per-cpu dsts through nh 100 652 + run_cmd "ip netns exec me mausezahn -6 veth1.10 -B 2001:db8:101::1 -A 2001:db8:91::1 -c 5 -t tcp "dp=1-1023, flags=syn" >/dev/null 2>&1" 653 + 654 + # remove nh 100 from the group to delete the route potentially leaving 655 + # a stale per-cpu dst which holds a reference to the nexthop's net 656 + # device and to the IPv6 route 657 + run_cmd "$IP nexthop replace id 102 group 101" 658 + run_cmd "$IP route del 2001:db8:101::1/128" 659 + 660 + # add both nexthops to the group so a reference is taken on them 661 + run_cmd "$IP nexthop replace id 102 group 100/101" 662 + 663 + # if the bug described in commit "net: nexthop: release IPv6 per-cpu 664 + # dsts when replacing a nexthop group" exists at this point we have 665 + # an unlinked IPv6 route (but not freed due to stale dst) with a 666 + # reference over the group so we delete the group which will again 667 + # only unlink it due to the route reference 668 + run_cmd "$IP nexthop del id 102" 669 + 670 + # delete the nexthop with stale dst, since we have an unlinked 671 + # group with a ref to it and an unlinked IPv6 route with ref to the 672 + # group, the nh will only be unlinked and not freed so the stale dst 673 + # remains forever and we get a net device refcount imbalance 674 + run_cmd "$IP nexthop del id 100" 675 + 676 + # if a reference was lost this command will hang because the net device 677 + # cannot be removed 678 + timeout -s KILL 5 ip netns exec me ip link del veth1.10 >/dev/null 2>&1 679 + 680 + # we can't cleanup if the command is hung trying to delete the netdev 681 + if [ $? -eq 137 ]; then 682 + return 1 683 + fi 684 + 685 + # cleanup 686 + run_cmd "$IP link del veth1.20" 687 + run_cmd "$IP nexthop flush" 688 + 689 + return 0 690 + } 691 + 632 692 ipv6_grp_fcnal() 633 693 { 634 694 local rc ··· 794 734 795 735 run_cmd "$IP nexthop add id 108 group 31/24" 796 736 log_test $? 2 "Nexthop group can not have a blackhole and another nexthop" 737 + 738 + ipv6_grp_refs 739 + log_test $? 0 "Nexthop group replace refcounts" 797 740 } 798 741 799 742 ipv6_res_grp_fcnal()
+397 -140
tools/testing/selftests/net/tls.c
··· 78 78 *byte++ = rand(); 79 79 } 80 80 81 - FIXTURE(tls_basic) 82 - { 83 - int fd, cfd; 84 - bool notls; 85 - }; 86 - 87 - FIXTURE_SETUP(tls_basic) 81 + static void ulp_sock_pair(struct __test_metadata *_metadata, 82 + int *fd, int *cfd, bool *notls) 88 83 { 89 84 struct sockaddr_in addr; 90 85 socklen_t len; 91 86 int sfd, ret; 92 87 93 - self->notls = false; 88 + *notls = false; 94 89 len = sizeof(addr); 95 90 96 91 addr.sin_family = AF_INET; 97 92 addr.sin_addr.s_addr = htonl(INADDR_ANY); 98 93 addr.sin_port = 0; 99 94 100 - self->fd = socket(AF_INET, SOCK_STREAM, 0); 95 + *fd = socket(AF_INET, SOCK_STREAM, 0); 101 96 sfd = socket(AF_INET, SOCK_STREAM, 0); 102 97 103 98 ret = bind(sfd, &addr, sizeof(addr)); ··· 103 108 ret = getsockname(sfd, &addr, &len); 104 109 ASSERT_EQ(ret, 0); 105 110 106 - ret = connect(self->fd, &addr, sizeof(addr)); 111 + ret = connect(*fd, &addr, sizeof(addr)); 107 112 ASSERT_EQ(ret, 0); 108 113 109 - self->cfd = accept(sfd, &addr, &len); 110 - ASSERT_GE(self->cfd, 0); 114 + *cfd = accept(sfd, &addr, &len); 115 + ASSERT_GE(*cfd, 0); 111 116 112 117 close(sfd); 113 118 114 - ret = setsockopt(self->fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")); 119 + ret = setsockopt(*fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")); 115 120 if (ret != 0) { 116 121 ASSERT_EQ(errno, ENOENT); 117 - self->notls = true; 122 + *notls = true; 118 123 printf("Failure setting TCP_ULP, testing without tls\n"); 119 124 return; 120 125 } 121 126 122 - ret = setsockopt(self->cfd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")); 127 + ret = setsockopt(*cfd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")); 123 128 ASSERT_EQ(ret, 0); 129 + } 130 + 131 + /* Produce a basic cmsg */ 132 + static int tls_send_cmsg(int fd, unsigned char record_type, 133 + void *data, size_t len, int flags) 134 + { 135 + char cbuf[CMSG_SPACE(sizeof(char))]; 136 + int cmsg_len = sizeof(char); 137 + struct cmsghdr *cmsg; 138 + struct msghdr msg; 139 + struct iovec vec; 140 + 141 + vec.iov_base = data; 142 + vec.iov_len = len; 143 + memset(&msg, 0, sizeof(struct msghdr)); 144 + msg.msg_iov = &vec; 145 + msg.msg_iovlen = 1; 146 + msg.msg_control = cbuf; 147 + msg.msg_controllen = sizeof(cbuf); 148 + cmsg = CMSG_FIRSTHDR(&msg); 149 + cmsg->cmsg_level = SOL_TLS; 150 + /* test sending non-record types. */ 151 + cmsg->cmsg_type = TLS_SET_RECORD_TYPE; 152 + cmsg->cmsg_len = CMSG_LEN(cmsg_len); 153 + *CMSG_DATA(cmsg) = record_type; 154 + msg.msg_controllen = cmsg->cmsg_len; 155 + 156 + return sendmsg(fd, &msg, flags); 157 + } 158 + 159 + static int tls_recv_cmsg(struct __test_metadata *_metadata, 160 + int fd, unsigned char record_type, 161 + void *data, size_t len, int flags) 162 + { 163 + char cbuf[CMSG_SPACE(sizeof(char))]; 164 + struct cmsghdr *cmsg; 165 + unsigned char ctype; 166 + struct msghdr msg; 167 + struct iovec vec; 168 + int n; 169 + 170 + vec.iov_base = data; 171 + vec.iov_len = len; 172 + memset(&msg, 0, sizeof(struct msghdr)); 173 + msg.msg_iov = &vec; 174 + msg.msg_iovlen = 1; 175 + msg.msg_control = cbuf; 176 + msg.msg_controllen = sizeof(cbuf); 177 + 178 + n = recvmsg(fd, &msg, flags); 179 + 180 + cmsg = CMSG_FIRSTHDR(&msg); 181 + EXPECT_NE(cmsg, NULL); 182 + EXPECT_EQ(cmsg->cmsg_level, SOL_TLS); 183 + EXPECT_EQ(cmsg->cmsg_type, TLS_GET_RECORD_TYPE); 184 + ctype = *((unsigned char *)CMSG_DATA(cmsg)); 185 + EXPECT_EQ(ctype, record_type); 186 + 187 + return n; 188 + } 189 + 190 + FIXTURE(tls_basic) 191 + { 192 + int fd, cfd; 193 + bool notls; 194 + }; 195 + 196 + FIXTURE_SETUP(tls_basic) 197 + { 198 + ulp_sock_pair(_metadata, &self->fd, &self->cfd, &self->notls); 124 199 } 125 200 126 201 FIXTURE_TEARDOWN(tls_basic) ··· 264 199 FIXTURE_SETUP(tls) 265 200 { 266 201 struct tls_crypto_info_keys tls12; 267 - struct sockaddr_in addr; 268 - socklen_t len; 269 - int sfd, ret; 270 - 271 - self->notls = false; 272 - len = sizeof(addr); 202 + int ret; 273 203 274 204 tls_crypto_info_init(variant->tls_version, variant->cipher_type, 275 205 &tls12); 276 206 277 - addr.sin_family = AF_INET; 278 - addr.sin_addr.s_addr = htonl(INADDR_ANY); 279 - addr.sin_port = 0; 207 + ulp_sock_pair(_metadata, &self->fd, &self->cfd, &self->notls); 280 208 281 - self->fd = socket(AF_INET, SOCK_STREAM, 0); 282 - sfd = socket(AF_INET, SOCK_STREAM, 0); 209 + if (self->notls) 210 + return; 283 211 284 - ret = bind(sfd, &addr, sizeof(addr)); 285 - ASSERT_EQ(ret, 0); 286 - ret = listen(sfd, 10); 212 + ret = setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, tls12.len); 287 213 ASSERT_EQ(ret, 0); 288 214 289 - ret = getsockname(sfd, &addr, &len); 215 + ret = setsockopt(self->cfd, SOL_TLS, TLS_RX, &tls12, tls12.len); 290 216 ASSERT_EQ(ret, 0); 291 - 292 - ret = connect(self->fd, &addr, sizeof(addr)); 293 - ASSERT_EQ(ret, 0); 294 - 295 - ret = setsockopt(self->fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")); 296 - if (ret != 0) { 297 - self->notls = true; 298 - printf("Failure setting TCP_ULP, testing without tls\n"); 299 - } 300 - 301 - if (!self->notls) { 302 - ret = setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, 303 - tls12.len); 304 - ASSERT_EQ(ret, 0); 305 - } 306 - 307 - self->cfd = accept(sfd, &addr, &len); 308 - ASSERT_GE(self->cfd, 0); 309 - 310 - if (!self->notls) { 311 - ret = setsockopt(self->cfd, IPPROTO_TCP, TCP_ULP, "tls", 312 - sizeof("tls")); 313 - ASSERT_EQ(ret, 0); 314 - 315 - ret = setsockopt(self->cfd, SOL_TLS, TLS_RX, &tls12, 316 - tls12.len); 317 - ASSERT_EQ(ret, 0); 318 - } 319 - 320 - close(sfd); 321 217 } 322 218 323 219 FIXTURE_TEARDOWN(tls) ··· 636 610 EXPECT_GE(send(self->fd, mem_send, send_len, 0), 0); 637 611 EXPECT_GE(splice(self->cfd, NULL, p[1], NULL, send_len, 0), 0); 638 612 EXPECT_GE(read(p[0], mem_recv, send_len), 0); 613 + EXPECT_EQ(memcmp(mem_send, mem_recv, send_len), 0); 614 + } 615 + 616 + TEST_F(tls, splice_cmsg_to_pipe) 617 + { 618 + char *test_str = "test_read"; 619 + char record_type = 100; 620 + int send_len = 10; 621 + char buf[10]; 622 + int p[2]; 623 + 624 + ASSERT_GE(pipe(p), 0); 625 + EXPECT_EQ(tls_send_cmsg(self->fd, 100, test_str, send_len, 0), 10); 626 + EXPECT_EQ(splice(self->cfd, NULL, p[1], NULL, send_len, 0), -1); 627 + EXPECT_EQ(errno, EINVAL); 628 + EXPECT_EQ(recv(self->cfd, buf, send_len, 0), -1); 629 + EXPECT_EQ(errno, EIO); 630 + EXPECT_EQ(tls_recv_cmsg(_metadata, self->cfd, record_type, 631 + buf, sizeof(buf), MSG_WAITALL), 632 + send_len); 633 + EXPECT_EQ(memcmp(test_str, buf, send_len), 0); 634 + } 635 + 636 + TEST_F(tls, splice_dec_cmsg_to_pipe) 637 + { 638 + char *test_str = "test_read"; 639 + char record_type = 100; 640 + int send_len = 10; 641 + char buf[10]; 642 + int p[2]; 643 + 644 + ASSERT_GE(pipe(p), 0); 645 + EXPECT_EQ(tls_send_cmsg(self->fd, 100, test_str, send_len, 0), 10); 646 + EXPECT_EQ(recv(self->cfd, buf, send_len, 0), -1); 647 + EXPECT_EQ(errno, EIO); 648 + EXPECT_EQ(splice(self->cfd, NULL, p[1], NULL, send_len, 0), -1); 649 + EXPECT_EQ(errno, EINVAL); 650 + EXPECT_EQ(tls_recv_cmsg(_metadata, self->cfd, record_type, 651 + buf, sizeof(buf), MSG_WAITALL), 652 + send_len); 653 + EXPECT_EQ(memcmp(test_str, buf, send_len), 0); 654 + } 655 + 656 + TEST_F(tls, recv_and_splice) 657 + { 658 + int send_len = TLS_PAYLOAD_MAX_LEN; 659 + char mem_send[TLS_PAYLOAD_MAX_LEN]; 660 + char mem_recv[TLS_PAYLOAD_MAX_LEN]; 661 + int half = send_len / 2; 662 + int p[2]; 663 + 664 + ASSERT_GE(pipe(p), 0); 665 + EXPECT_EQ(send(self->fd, mem_send, send_len, 0), send_len); 666 + /* Recv hald of the record, splice the other half */ 667 + EXPECT_EQ(recv(self->cfd, mem_recv, half, MSG_WAITALL), half); 668 + EXPECT_EQ(splice(self->cfd, NULL, p[1], NULL, half, SPLICE_F_NONBLOCK), 669 + half); 670 + EXPECT_EQ(read(p[0], &mem_recv[half], half), half); 671 + EXPECT_EQ(memcmp(mem_send, mem_recv, send_len), 0); 672 + } 673 + 674 + TEST_F(tls, peek_and_splice) 675 + { 676 + int send_len = TLS_PAYLOAD_MAX_LEN; 677 + char mem_send[TLS_PAYLOAD_MAX_LEN]; 678 + char mem_recv[TLS_PAYLOAD_MAX_LEN]; 679 + int chunk = TLS_PAYLOAD_MAX_LEN / 4; 680 + int n, i, p[2]; 681 + 682 + memrnd(mem_send, sizeof(mem_send)); 683 + 684 + ASSERT_GE(pipe(p), 0); 685 + for (i = 0; i < 4; i++) 686 + EXPECT_EQ(send(self->fd, &mem_send[chunk * i], chunk, 0), 687 + chunk); 688 + 689 + EXPECT_EQ(recv(self->cfd, mem_recv, chunk * 5 / 2, 690 + MSG_WAITALL | MSG_PEEK), 691 + chunk * 5 / 2); 692 + EXPECT_EQ(memcmp(mem_send, mem_recv, chunk * 5 / 2), 0); 693 + 694 + n = 0; 695 + while (n < send_len) { 696 + i = splice(self->cfd, NULL, p[1], NULL, send_len - n, 0); 697 + EXPECT_GT(i, 0); 698 + n += i; 699 + } 700 + EXPECT_EQ(n, send_len); 701 + EXPECT_EQ(read(p[0], mem_recv, send_len), send_len); 639 702 EXPECT_EQ(memcmp(mem_send, mem_recv, send_len), 0); 640 703 } 641 704 ··· 1308 1193 1309 1194 TEST_F(tls, control_msg) 1310 1195 { 1311 - if (self->notls) 1312 - return; 1313 - 1314 - char cbuf[CMSG_SPACE(sizeof(char))]; 1315 - char const *test_str = "test_read"; 1316 - int cmsg_len = sizeof(char); 1196 + char *test_str = "test_read"; 1317 1197 char record_type = 100; 1318 - struct cmsghdr *cmsg; 1319 - struct msghdr msg; 1320 1198 int send_len = 10; 1321 - struct iovec vec; 1322 1199 char buf[10]; 1323 1200 1324 - vec.iov_base = (char *)test_str; 1325 - vec.iov_len = 10; 1326 - memset(&msg, 0, sizeof(struct msghdr)); 1327 - msg.msg_iov = &vec; 1328 - msg.msg_iovlen = 1; 1329 - msg.msg_control = cbuf; 1330 - msg.msg_controllen = sizeof(cbuf); 1331 - cmsg = CMSG_FIRSTHDR(&msg); 1332 - cmsg->cmsg_level = SOL_TLS; 1333 - /* test sending non-record types. */ 1334 - cmsg->cmsg_type = TLS_SET_RECORD_TYPE; 1335 - cmsg->cmsg_len = CMSG_LEN(cmsg_len); 1336 - *CMSG_DATA(cmsg) = record_type; 1337 - msg.msg_controllen = cmsg->cmsg_len; 1201 + if (self->notls) 1202 + SKIP(return, "no TLS support"); 1338 1203 1339 - EXPECT_EQ(sendmsg(self->fd, &msg, 0), send_len); 1204 + EXPECT_EQ(tls_send_cmsg(self->fd, record_type, test_str, send_len, 0), 1205 + send_len); 1340 1206 /* Should fail because we didn't provide a control message */ 1341 1207 EXPECT_EQ(recv(self->cfd, buf, send_len, 0), -1); 1342 1208 1343 - vec.iov_base = buf; 1344 - EXPECT_EQ(recvmsg(self->cfd, &msg, MSG_WAITALL | MSG_PEEK), send_len); 1345 - 1346 - cmsg = CMSG_FIRSTHDR(&msg); 1347 - EXPECT_NE(cmsg, NULL); 1348 - EXPECT_EQ(cmsg->cmsg_level, SOL_TLS); 1349 - EXPECT_EQ(cmsg->cmsg_type, TLS_GET_RECORD_TYPE); 1350 - record_type = *((unsigned char *)CMSG_DATA(cmsg)); 1351 - EXPECT_EQ(record_type, 100); 1209 + EXPECT_EQ(tls_recv_cmsg(_metadata, self->cfd, record_type, 1210 + buf, sizeof(buf), MSG_WAITALL | MSG_PEEK), 1211 + send_len); 1352 1212 EXPECT_EQ(memcmp(buf, test_str, send_len), 0); 1353 1213 1354 1214 /* Recv the message again without MSG_PEEK */ 1355 - record_type = 0; 1356 1215 memset(buf, 0, sizeof(buf)); 1357 1216 1358 - EXPECT_EQ(recvmsg(self->cfd, &msg, MSG_WAITALL), send_len); 1359 - cmsg = CMSG_FIRSTHDR(&msg); 1360 - EXPECT_NE(cmsg, NULL); 1361 - EXPECT_EQ(cmsg->cmsg_level, SOL_TLS); 1362 - EXPECT_EQ(cmsg->cmsg_type, TLS_GET_RECORD_TYPE); 1363 - record_type = *((unsigned char *)CMSG_DATA(cmsg)); 1364 - EXPECT_EQ(record_type, 100); 1217 + EXPECT_EQ(tls_recv_cmsg(_metadata, self->cfd, record_type, 1218 + buf, sizeof(buf), MSG_WAITALL), 1219 + send_len); 1365 1220 EXPECT_EQ(memcmp(buf, test_str, send_len), 0); 1366 1221 } 1367 1222 ··· 1384 1299 ret = connect(self->fd, &addr, sizeof(addr)); 1385 1300 EXPECT_EQ(ret, -1); 1386 1301 EXPECT_EQ(errno, EISCONN); 1302 + } 1303 + 1304 + FIXTURE(tls_err) 1305 + { 1306 + int fd, cfd; 1307 + int fd2, cfd2; 1308 + bool notls; 1309 + }; 1310 + 1311 + FIXTURE_VARIANT(tls_err) 1312 + { 1313 + uint16_t tls_version; 1314 + }; 1315 + 1316 + FIXTURE_VARIANT_ADD(tls_err, 12_aes_gcm) 1317 + { 1318 + .tls_version = TLS_1_2_VERSION, 1319 + }; 1320 + 1321 + FIXTURE_VARIANT_ADD(tls_err, 13_aes_gcm) 1322 + { 1323 + .tls_version = TLS_1_3_VERSION, 1324 + }; 1325 + 1326 + FIXTURE_SETUP(tls_err) 1327 + { 1328 + struct tls_crypto_info_keys tls12; 1329 + int ret; 1330 + 1331 + tls_crypto_info_init(variant->tls_version, TLS_CIPHER_AES_GCM_128, 1332 + &tls12); 1333 + 1334 + ulp_sock_pair(_metadata, &self->fd, &self->cfd, &self->notls); 1335 + ulp_sock_pair(_metadata, &self->fd2, &self->cfd2, &self->notls); 1336 + if (self->notls) 1337 + return; 1338 + 1339 + ret = setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, tls12.len); 1340 + ASSERT_EQ(ret, 0); 1341 + 1342 + ret = setsockopt(self->cfd2, SOL_TLS, TLS_RX, &tls12, tls12.len); 1343 + ASSERT_EQ(ret, 0); 1344 + } 1345 + 1346 + FIXTURE_TEARDOWN(tls_err) 1347 + { 1348 + close(self->fd); 1349 + close(self->cfd); 1350 + close(self->fd2); 1351 + close(self->cfd2); 1352 + } 1353 + 1354 + TEST_F(tls_err, bad_rec) 1355 + { 1356 + char buf[64]; 1357 + 1358 + if (self->notls) 1359 + SKIP(return, "no TLS support"); 1360 + 1361 + memset(buf, 0x55, sizeof(buf)); 1362 + EXPECT_EQ(send(self->fd2, buf, sizeof(buf), 0), sizeof(buf)); 1363 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), -1); 1364 + EXPECT_EQ(errno, EMSGSIZE); 1365 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), MSG_DONTWAIT), -1); 1366 + EXPECT_EQ(errno, EAGAIN); 1367 + } 1368 + 1369 + TEST_F(tls_err, bad_auth) 1370 + { 1371 + char buf[128]; 1372 + int n; 1373 + 1374 + if (self->notls) 1375 + SKIP(return, "no TLS support"); 1376 + 1377 + memrnd(buf, sizeof(buf) / 2); 1378 + EXPECT_EQ(send(self->fd, buf, sizeof(buf) / 2, 0), sizeof(buf) / 2); 1379 + n = recv(self->cfd, buf, sizeof(buf), 0); 1380 + EXPECT_GT(n, sizeof(buf) / 2); 1381 + 1382 + buf[n - 1]++; 1383 + 1384 + EXPECT_EQ(send(self->fd2, buf, n, 0), n); 1385 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), -1); 1386 + EXPECT_EQ(errno, EBADMSG); 1387 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), -1); 1388 + EXPECT_EQ(errno, EBADMSG); 1389 + } 1390 + 1391 + TEST_F(tls_err, bad_in_large_read) 1392 + { 1393 + char txt[3][64]; 1394 + char cip[3][128]; 1395 + char buf[3 * 128]; 1396 + int i, n; 1397 + 1398 + if (self->notls) 1399 + SKIP(return, "no TLS support"); 1400 + 1401 + /* Put 3 records in the sockets */ 1402 + for (i = 0; i < 3; i++) { 1403 + memrnd(txt[i], sizeof(txt[i])); 1404 + EXPECT_EQ(send(self->fd, txt[i], sizeof(txt[i]), 0), 1405 + sizeof(txt[i])); 1406 + n = recv(self->cfd, cip[i], sizeof(cip[i]), 0); 1407 + EXPECT_GT(n, sizeof(txt[i])); 1408 + /* Break the third message */ 1409 + if (i == 2) 1410 + cip[2][n - 1]++; 1411 + EXPECT_EQ(send(self->fd2, cip[i], n, 0), n); 1412 + } 1413 + 1414 + /* We should be able to receive the first two messages */ 1415 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), sizeof(txt[0]) * 2); 1416 + EXPECT_EQ(memcmp(buf, txt[0], sizeof(txt[0])), 0); 1417 + EXPECT_EQ(memcmp(buf + sizeof(txt[0]), txt[1], sizeof(txt[1])), 0); 1418 + /* Third mesasge is bad */ 1419 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), -1); 1420 + EXPECT_EQ(errno, EBADMSG); 1421 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), -1); 1422 + EXPECT_EQ(errno, EBADMSG); 1423 + } 1424 + 1425 + TEST_F(tls_err, bad_cmsg) 1426 + { 1427 + char *test_str = "test_read"; 1428 + int send_len = 10; 1429 + char cip[128]; 1430 + char buf[128]; 1431 + char txt[64]; 1432 + int n; 1433 + 1434 + if (self->notls) 1435 + SKIP(return, "no TLS support"); 1436 + 1437 + /* Queue up one data record */ 1438 + memrnd(txt, sizeof(txt)); 1439 + EXPECT_EQ(send(self->fd, txt, sizeof(txt), 0), sizeof(txt)); 1440 + n = recv(self->cfd, cip, sizeof(cip), 0); 1441 + EXPECT_GT(n, sizeof(txt)); 1442 + EXPECT_EQ(send(self->fd2, cip, n, 0), n); 1443 + 1444 + EXPECT_EQ(tls_send_cmsg(self->fd, 100, test_str, send_len, 0), 10); 1445 + n = recv(self->cfd, cip, sizeof(cip), 0); 1446 + cip[n - 1]++; /* Break it */ 1447 + EXPECT_GT(n, send_len); 1448 + EXPECT_EQ(send(self->fd2, cip, n, 0), n); 1449 + 1450 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), sizeof(txt)); 1451 + EXPECT_EQ(memcmp(buf, txt, sizeof(txt)), 0); 1452 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), -1); 1453 + EXPECT_EQ(errno, EBADMSG); 1454 + EXPECT_EQ(recv(self->cfd2, buf, sizeof(buf), 0), -1); 1455 + EXPECT_EQ(errno, EBADMSG); 1387 1456 } 1388 1457 1389 1458 TEST(non_established) { ··· 1594 1355 1595 1356 TEST(keysizes) { 1596 1357 struct tls12_crypto_info_aes_gcm_256 tls12; 1597 - struct sockaddr_in addr; 1598 - int sfd, ret, fd, cfd; 1599 - socklen_t len; 1358 + int ret, fd, cfd; 1600 1359 bool notls; 1601 - 1602 - notls = false; 1603 - len = sizeof(addr); 1604 1360 1605 1361 memset(&tls12, 0, sizeof(tls12)); 1606 1362 tls12.info.version = TLS_1_2_VERSION; 1607 1363 tls12.info.cipher_type = TLS_CIPHER_AES_GCM_256; 1608 1364 1609 - addr.sin_family = AF_INET; 1610 - addr.sin_addr.s_addr = htonl(INADDR_ANY); 1611 - addr.sin_port = 0; 1612 - 1613 - fd = socket(AF_INET, SOCK_STREAM, 0); 1614 - sfd = socket(AF_INET, SOCK_STREAM, 0); 1615 - 1616 - ret = bind(sfd, &addr, sizeof(addr)); 1617 - ASSERT_EQ(ret, 0); 1618 - ret = listen(sfd, 10); 1619 - ASSERT_EQ(ret, 0); 1620 - 1621 - ret = getsockname(sfd, &addr, &len); 1622 - ASSERT_EQ(ret, 0); 1623 - 1624 - ret = connect(fd, &addr, sizeof(addr)); 1625 - ASSERT_EQ(ret, 0); 1626 - 1627 - ret = setsockopt(fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")); 1628 - if (ret != 0) { 1629 - notls = true; 1630 - printf("Failure setting TCP_ULP, testing without tls\n"); 1631 - } 1365 + ulp_sock_pair(_metadata, &fd, &cfd, &notls); 1632 1366 1633 1367 if (!notls) { 1634 1368 ret = setsockopt(fd, SOL_TLS, TLS_TX, &tls12, 1635 1369 sizeof(tls12)); 1636 - EXPECT_EQ(ret, 0); 1637 - } 1638 - 1639 - cfd = accept(sfd, &addr, &len); 1640 - ASSERT_GE(cfd, 0); 1641 - 1642 - if (!notls) { 1643 - ret = setsockopt(cfd, IPPROTO_TCP, TCP_ULP, "tls", 1644 - sizeof("tls")); 1645 1370 EXPECT_EQ(ret, 0); 1646 1371 1647 1372 ret = setsockopt(cfd, SOL_TLS, TLS_RX, &tls12, ··· 1613 1410 EXPECT_EQ(ret, 0); 1614 1411 } 1615 1412 1616 - close(sfd); 1617 1413 close(fd); 1618 1414 close(cfd); 1415 + } 1416 + 1417 + TEST(tls_v6ops) { 1418 + struct tls_crypto_info_keys tls12; 1419 + struct sockaddr_in6 addr, addr2; 1420 + int sfd, ret, fd; 1421 + socklen_t len, len2; 1422 + 1423 + tls_crypto_info_init(TLS_1_2_VERSION, TLS_CIPHER_AES_GCM_128, &tls12); 1424 + 1425 + addr.sin6_family = AF_INET6; 1426 + addr.sin6_addr = in6addr_any; 1427 + addr.sin6_port = 0; 1428 + 1429 + fd = socket(AF_INET6, SOCK_STREAM, 0); 1430 + sfd = socket(AF_INET6, SOCK_STREAM, 0); 1431 + 1432 + ret = bind(sfd, &addr, sizeof(addr)); 1433 + ASSERT_EQ(ret, 0); 1434 + ret = listen(sfd, 10); 1435 + ASSERT_EQ(ret, 0); 1436 + 1437 + len = sizeof(addr); 1438 + ret = getsockname(sfd, &addr, &len); 1439 + ASSERT_EQ(ret, 0); 1440 + 1441 + ret = connect(fd, &addr, sizeof(addr)); 1442 + ASSERT_EQ(ret, 0); 1443 + 1444 + len = sizeof(addr); 1445 + ret = getsockname(fd, &addr, &len); 1446 + ASSERT_EQ(ret, 0); 1447 + 1448 + ret = setsockopt(fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")); 1449 + if (ret) { 1450 + ASSERT_EQ(errno, ENOENT); 1451 + SKIP(return, "no TLS support"); 1452 + } 1453 + ASSERT_EQ(ret, 0); 1454 + 1455 + ret = setsockopt(fd, SOL_TLS, TLS_TX, &tls12, tls12.len); 1456 + ASSERT_EQ(ret, 0); 1457 + 1458 + ret = setsockopt(fd, SOL_TLS, TLS_RX, &tls12, tls12.len); 1459 + ASSERT_EQ(ret, 0); 1460 + 1461 + len2 = sizeof(addr2); 1462 + ret = getsockname(fd, &addr2, &len2); 1463 + ASSERT_EQ(ret, 0); 1464 + 1465 + EXPECT_EQ(len2, len); 1466 + EXPECT_EQ(memcmp(&addr, &addr2, len), 0); 1467 + 1468 + close(fd); 1469 + close(sfd); 1619 1470 } 1620 1471 1621 1472 TEST_HARNESS_MAIN
+2 -1
tools/testing/selftests/netfilter/Makefile
··· 5 5 conntrack_icmp_related.sh nft_flowtable.sh ipvs.sh \ 6 6 nft_concat_range.sh nft_conntrack_helper.sh \ 7 7 nft_queue.sh nft_meta.sh nf_nat_edemux.sh \ 8 - ipip-conntrack-mtu.sh conntrack_tcp_unreplied.sh 8 + ipip-conntrack-mtu.sh conntrack_tcp_unreplied.sh \ 9 + conntrack_vrf.sh 9 10 10 11 LDLIBS = -lmnl 11 12 TEST_GEN_FILES = nf-queue
+219
tools/testing/selftests/netfilter/conntrack_vrf.sh
··· 1 + #!/bin/sh 2 + 3 + # This script demonstrates interaction of conntrack and vrf. 4 + # The vrf driver calls the netfilter hooks again, with oif/iif 5 + # pointing at the VRF device. 6 + # 7 + # For ingress, this means first iteration has iifname of lower/real 8 + # device. In this script, thats veth0. 9 + # Second iteration is iifname set to vrf device, tvrf in this script. 10 + # 11 + # For egress, this is reversed: first iteration has the vrf device, 12 + # second iteration is done with the lower/real/veth0 device. 13 + # 14 + # test_ct_zone_in demonstrates unexpected change of nftables 15 + # behavior # caused by commit 09e856d54bda5f28 "vrf: Reset skb conntrack 16 + # connection on VRF rcv" 17 + # 18 + # It was possible to assign conntrack zone to a packet (or mark it for 19 + # `notracking`) in the prerouting chain before conntrack, based on real iif. 20 + # 21 + # After the change, the zone assignment is lost and the zone is assigned based 22 + # on the VRF master interface (in case such a rule exists). 23 + # assignment is lost. Instead, assignment based on the `iif` matching 24 + # Thus it is impossible to distinguish packets based on the original 25 + # interface. 26 + # 27 + # test_masquerade_vrf and test_masquerade_veth0 demonstrate the problem 28 + # that was supposed to be fixed by the commit mentioned above to make sure 29 + # that any fix to test case 1 won't break masquerade again. 30 + 31 + ksft_skip=4 32 + 33 + IP0=172.30.30.1 34 + IP1=172.30.30.2 35 + PFXL=30 36 + ret=0 37 + 38 + sfx=$(mktemp -u "XXXXXXXX") 39 + ns0="ns0-$sfx" 40 + ns1="ns1-$sfx" 41 + 42 + cleanup() 43 + { 44 + ip netns pids $ns0 | xargs kill 2>/dev/null 45 + ip netns pids $ns1 | xargs kill 2>/dev/null 46 + 47 + ip netns del $ns0 $ns1 48 + } 49 + 50 + nft --version > /dev/null 2>&1 51 + if [ $? -ne 0 ];then 52 + echo "SKIP: Could not run test without nft tool" 53 + exit $ksft_skip 54 + fi 55 + 56 + ip -Version > /dev/null 2>&1 57 + if [ $? -ne 0 ];then 58 + echo "SKIP: Could not run test without ip tool" 59 + exit $ksft_skip 60 + fi 61 + 62 + ip netns add "$ns0" 63 + if [ $? -ne 0 ];then 64 + echo "SKIP: Could not create net namespace $ns0" 65 + exit $ksft_skip 66 + fi 67 + ip netns add "$ns1" 68 + 69 + trap cleanup EXIT 70 + 71 + ip netns exec $ns0 sysctl -q -w net.ipv4.conf.default.rp_filter=0 72 + ip netns exec $ns0 sysctl -q -w net.ipv4.conf.all.rp_filter=0 73 + ip netns exec $ns0 sysctl -q -w net.ipv4.conf.all.rp_filter=0 74 + 75 + ip link add veth0 netns "$ns0" type veth peer name veth0 netns "$ns1" > /dev/null 2>&1 76 + if [ $? -ne 0 ];then 77 + echo "SKIP: Could not add veth device" 78 + exit $ksft_skip 79 + fi 80 + 81 + ip -net $ns0 li add tvrf type vrf table 9876 82 + if [ $? -ne 0 ];then 83 + echo "SKIP: Could not add vrf device" 84 + exit $ksft_skip 85 + fi 86 + 87 + ip -net $ns0 li set lo up 88 + 89 + ip -net $ns0 li set veth0 master tvrf 90 + ip -net $ns0 li set tvrf up 91 + ip -net $ns0 li set veth0 up 92 + ip -net $ns1 li set veth0 up 93 + 94 + ip -net $ns0 addr add $IP0/$PFXL dev veth0 95 + ip -net $ns1 addr add $IP1/$PFXL dev veth0 96 + 97 + ip netns exec $ns1 iperf3 -s > /dev/null 2>&1& 98 + if [ $? -ne 0 ];then 99 + echo "SKIP: Could not start iperf3" 100 + exit $ksft_skip 101 + fi 102 + 103 + # test vrf ingress handling. 104 + # The incoming connection should be placed in conntrack zone 1, 105 + # as decided by the first iteration of the ruleset. 106 + test_ct_zone_in() 107 + { 108 + ip netns exec $ns0 nft -f - <<EOF 109 + table testct { 110 + chain rawpre { 111 + type filter hook prerouting priority raw; 112 + 113 + iif { veth0, tvrf } counter meta nftrace set 1 114 + iif veth0 counter ct zone set 1 counter return 115 + iif tvrf counter ct zone set 2 counter return 116 + ip protocol icmp counter 117 + notrack counter 118 + } 119 + 120 + chain rawout { 121 + type filter hook output priority raw; 122 + 123 + oif veth0 counter ct zone set 1 counter return 124 + oif tvrf counter ct zone set 2 counter return 125 + notrack counter 126 + } 127 + } 128 + EOF 129 + ip netns exec $ns1 ping -W 1 -c 1 -I veth0 $IP0 > /dev/null 130 + 131 + # should be in zone 1, not zone 2 132 + count=$(ip netns exec $ns0 conntrack -L -s $IP1 -d $IP0 -p icmp --zone 1 2>/dev/null | wc -l) 133 + if [ $count -eq 1 ]; then 134 + echo "PASS: entry found in conntrack zone 1" 135 + else 136 + echo "FAIL: entry not found in conntrack zone 1" 137 + count=$(ip netns exec $ns0 conntrack -L -s $IP1 -d $IP0 -p icmp --zone 2 2> /dev/null | wc -l) 138 + if [ $count -eq 1 ]; then 139 + echo "FAIL: entry found in zone 2 instead" 140 + else 141 + echo "FAIL: entry not in zone 1 or 2, dumping table" 142 + ip netns exec $ns0 conntrack -L 143 + ip netns exec $ns0 nft list ruleset 144 + fi 145 + fi 146 + } 147 + 148 + # add masq rule that gets evaluated w. outif set to vrf device. 149 + # This tests the first iteration of the packet through conntrack, 150 + # oifname is the vrf device. 151 + test_masquerade_vrf() 152 + { 153 + ip netns exec $ns0 conntrack -F 2>/dev/null 154 + 155 + ip netns exec $ns0 nft -f - <<EOF 156 + flush ruleset 157 + table ip nat { 158 + chain postrouting { 159 + type nat hook postrouting priority 0; 160 + # NB: masquerade should always be combined with 'oif(name) bla', 161 + # lack of this is intentional here, we want to exercise double-snat. 162 + ip saddr 172.30.30.0/30 counter masquerade random 163 + } 164 + } 165 + EOF 166 + ip netns exec $ns0 ip vrf exec tvrf iperf3 -t 1 -c $IP1 >/dev/null 167 + if [ $? -ne 0 ]; then 168 + echo "FAIL: iperf3 connect failure with masquerade + sport rewrite on vrf device" 169 + ret=1 170 + return 171 + fi 172 + 173 + # must also check that nat table was evaluated on second (lower device) iteration. 174 + ip netns exec $ns0 nft list table ip nat |grep -q 'counter packets 2' 175 + if [ $? -eq 0 ]; then 176 + echo "PASS: iperf3 connect with masquerade + sport rewrite on vrf device" 177 + else 178 + echo "FAIL: vrf masq rule has unexpected counter value" 179 + ret=1 180 + fi 181 + } 182 + 183 + # add masq rule that gets evaluated w. outif set to veth device. 184 + # This tests the 2nd iteration of the packet through conntrack, 185 + # oifname is the lower device (veth0 in this case). 186 + test_masquerade_veth() 187 + { 188 + ip netns exec $ns0 conntrack -F 2>/dev/null 189 + ip netns exec $ns0 nft -f - <<EOF 190 + flush ruleset 191 + table ip nat { 192 + chain postrouting { 193 + type nat hook postrouting priority 0; 194 + meta oif veth0 ip saddr 172.30.30.0/30 counter masquerade random 195 + } 196 + } 197 + EOF 198 + ip netns exec $ns0 ip vrf exec tvrf iperf3 -t 1 -c $IP1 > /dev/null 199 + if [ $? -ne 0 ]; then 200 + echo "FAIL: iperf3 connect failure with masquerade + sport rewrite on veth device" 201 + ret=1 202 + return 203 + fi 204 + 205 + # must also check that nat table was evaluated on second (lower device) iteration. 206 + ip netns exec $ns0 nft list table ip nat |grep -q 'counter packets 2' 207 + if [ $? -eq 0 ]; then 208 + echo "PASS: iperf3 connect with masquerade + sport rewrite on veth device" 209 + else 210 + echo "FAIL: vrf masq rule has unexpected counter value" 211 + ret=1 212 + fi 213 + } 214 + 215 + test_ct_zone_in 216 + test_masquerade_vrf 217 + test_masquerade_veth 218 + 219 + exit $ret
+24 -11
tools/testing/selftests/netfilter/nft_nat.sh
··· 759 759 local result="" 760 760 local logmsg="" 761 761 762 - echo ROUTER | ip netns exec "$ns0" nc -w 5 -u -l -p 1405 >/dev/null 2>&1 & 763 - nc_r=$! 764 - 765 - echo CLIENT | ip netns exec "$ns2" nc -w 5 -u -l -p 1405 >/dev/null 2>&1 & 766 - nc_c=$! 767 - 768 762 # make shadow entry, from client (ns2), going to (ns1), port 41404, sport 1405. 769 - echo "fake-entry" | ip netns exec "$ns2" nc -w 1 -p 1405 -u "$daddrc" 41404 > /dev/null 763 + echo "fake-entry" | ip netns exec "$ns2" timeout 1 socat -u STDIN UDP:"$daddrc":41404,sourceport=1405 764 + 765 + echo ROUTER | ip netns exec "$ns0" timeout 5 socat -u STDIN UDP4-LISTEN:1405 & 766 + sc_r=$! 767 + 768 + echo CLIENT | ip netns exec "$ns2" timeout 5 socat -u STDIN UDP4-LISTEN:1405,reuseport & 769 + sc_c=$! 770 + 771 + sleep 0.3 770 772 771 773 # ns1 tries to connect to ns0:1405. With default settings this should connect 772 774 # to client, it matches the conntrack entry created above. 773 775 774 - result=$(echo "" | ip netns exec "$ns1" nc -w 1 -p 41404 -u "$daddrs" 1405) 776 + result=$(echo "data" | ip netns exec "$ns1" timeout 1 socat - UDP:"$daddrs":1405,sourceport=41404) 775 777 776 778 if [ "$result" = "$expect" ] ;then 777 779 echo "PASS: portshadow test $test: got reply from ${expect}${logmsg}" ··· 782 780 ret=1 783 781 fi 784 782 785 - kill $nc_r $nc_c 2>/dev/null 783 + kill $sc_r $sc_c 2>/dev/null 786 784 787 785 # flush udp entries for next test round, if any 788 786 ip netns exec "$ns0" conntrack -F >/dev/null 2>&1 ··· 818 816 chain prerouting { 819 817 type filter hook prerouting priority -300; policy accept; 820 818 meta iif veth0 udp dport 1405 notrack 821 - udp dport 1405 notrack 822 819 } 823 820 chain output { 824 821 type filter hook output priority -300; policy accept; 825 - udp sport 1405 notrack 822 + meta oif veth0 udp sport 1405 notrack 826 823 } 827 824 } 828 825 EOF ··· 851 850 test_port_shadowing() 852 851 { 853 852 local family="ip" 853 + 854 + conntrack -h >/dev/null 2>&1 855 + if [ $? -ne 0 ];then 856 + echo "SKIP: Could not run nat port shadowing test without conntrack tool" 857 + return 858 + fi 859 + 860 + socat -h > /dev/null 2>&1 861 + if [ $? -ne 0 ];then 862 + echo "SKIP: Could not run nat port shadowing test without socat tool" 863 + return 864 + fi 854 865 855 866 ip netns exec "$ns0" sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null 856 867 ip netns exec "$ns0" sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
+54
tools/testing/selftests/netfilter/nft_queue.sh
··· 16 16 17 17 cleanup() 18 18 { 19 + ip netns pids ${ns1} | xargs kill 2>/dev/null 20 + ip netns pids ${ns2} | xargs kill 2>/dev/null 21 + ip netns pids ${nsrouter} | xargs kill 2>/dev/null 22 + 19 23 ip netns del ${ns1} 20 24 ip netns del ${ns2} 21 25 ip netns del ${nsrouter} ··· 336 332 echo "PASS: tcp via loopback and re-queueing" 337 333 } 338 334 335 + test_icmp_vrf() { 336 + ip -net $ns1 link add tvrf type vrf table 9876 337 + if [ $? -ne 0 ];then 338 + echo "SKIP: Could not add vrf device" 339 + return 340 + fi 341 + 342 + ip -net $ns1 li set eth0 master tvrf 343 + ip -net $ns1 li set tvrf up 344 + 345 + ip -net $ns1 route add 10.0.2.0/24 via 10.0.1.1 dev eth0 table 9876 346 + ip netns exec ${ns1} nft -f /dev/stdin <<EOF 347 + flush ruleset 348 + table inet filter { 349 + chain output { 350 + type filter hook output priority 0; policy accept; 351 + meta oifname "tvrf" icmp type echo-request counter queue num 1 352 + meta oifname "eth0" icmp type echo-request counter queue num 1 353 + } 354 + chain post { 355 + type filter hook postrouting priority 0; policy accept; 356 + meta oifname "tvrf" icmp type echo-request counter queue num 1 357 + meta oifname "eth0" icmp type echo-request counter queue num 1 358 + } 359 + } 360 + EOF 361 + ip netns exec ${ns1} ./nf-queue -q 1 -t $timeout & 362 + local nfqpid=$! 363 + 364 + sleep 1 365 + ip netns exec ${ns1} ip vrf exec tvrf ping -c 1 10.0.2.99 > /dev/null 366 + 367 + for n in output post; do 368 + for d in tvrf eth0; do 369 + ip netns exec ${ns1} nft list chain inet filter $n | grep -q "oifname \"$d\" icmp type echo-request counter packets 1" 370 + if [ $? -ne 0 ] ; then 371 + echo "FAIL: chain $n: icmp packet counter mismatch for device $d" 1>&2 372 + ip netns exec ${ns1} nft list ruleset 373 + ret=1 374 + return 375 + fi 376 + done 377 + done 378 + 379 + wait $nfqpid 380 + [ $? -eq 0 ] && echo "PASS: icmp+nfqueue via vrf" 381 + wait 2>/dev/null 382 + } 383 + 339 384 ip netns exec ${nsrouter} sysctl net.ipv6.conf.all.forwarding=1 > /dev/null 340 385 ip netns exec ${nsrouter} sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null 341 386 ip netns exec ${nsrouter} sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null ··· 425 372 test_tcp_forward 426 373 test_tcp_localhost 427 374 test_tcp_localhost_requeue 375 + test_icmp_vrf 428 376 429 377 exit $ret
+1 -1
tools/testing/selftests/tc-testing/tc-tests/actions/bpf.json
··· 68 68 "cmdUnderTest": "$TC action add action bpf object-file $EBPFDIR/action.o section action-ok index 667", 69 69 "expExitCode": "0", 70 70 "verifyCmd": "$TC action get action bpf index 667", 71 - "matchPattern": "action order [0-9]*: bpf action.o:\\[action-ok\\] id [0-9]* tag [0-9a-f]{16}( jited)? default-action pipe.*index 667 ref", 71 + "matchPattern": "action order [0-9]*: bpf action.o:\\[action-ok\\] id [0-9].* tag [0-9a-f]{16}( jited)? default-action pipe.*index 667 ref", 72 72 "matchCount": "1", 73 73 "teardown": [ 74 74 "$TC action flush action bpf"
+6 -6
tools/testing/selftests/tc-testing/tc-tests/qdiscs/mq.json
··· 15 15 "cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: mq", 16 16 "expExitCode": "0", 17 17 "verifyCmd": "$TC qdisc show dev $ETH", 18 - "matchPattern": "qdisc pfifo_fast 0: parent 1:[1-4] bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1", 18 + "matchPattern": "qdisc [a-zA-Z0-9_]+ 0: parent 1:[1-4]", 19 19 "matchCount": "4", 20 20 "teardown": [ 21 21 "echo \"1\" > /sys/bus/netdevsim/del_device" ··· 37 37 "cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: mq", 38 38 "expExitCode": "0", 39 39 "verifyCmd": "$TC qdisc show dev $ETH", 40 - "matchPattern": "qdisc pfifo_fast 0: parent 1:[1-9,a-f][0-9,a-f]{0,2} bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1", 40 + "matchPattern": "qdisc [a-zA-Z0-9_]+ 0: parent 1:[1-9,a-f][0-9,a-f]{0,2}", 41 41 "matchCount": "256", 42 42 "teardown": [ 43 43 "echo \"1\" > /sys/bus/netdevsim/del_device" ··· 60 60 "cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: mq", 61 61 "expExitCode": "2", 62 62 "verifyCmd": "$TC qdisc show dev $ETH", 63 - "matchPattern": "qdisc pfifo_fast 0: parent 1:[1-4] bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1", 63 + "matchPattern": "qdisc [a-zA-Z0-9_]+ 0: parent 1:[1-4]", 64 64 "matchCount": "4", 65 65 "teardown": [ 66 66 "echo \"1\" > /sys/bus/netdevsim/del_device" ··· 82 82 "cmdUnderTest": "$TC qdisc del dev $ETH root handle 1: mq", 83 83 "expExitCode": "2", 84 84 "verifyCmd": "$TC qdisc show dev $ETH", 85 - "matchPattern": "qdisc pfifo_fast 0: parent 1:[1-4] bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1", 85 + "matchPattern": "qdisc [a-zA-Z0-9_]+ 0: parent 1:[1-4]", 86 86 "matchCount": "0", 87 87 "teardown": [ 88 88 "echo \"1\" > /sys/bus/netdevsim/del_device" ··· 106 106 "cmdUnderTest": "$TC qdisc del dev $ETH root handle 1: mq", 107 107 "expExitCode": "2", 108 108 "verifyCmd": "$TC qdisc show dev $ETH", 109 - "matchPattern": "qdisc pfifo_fast 0: parent 1:[1-4] bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1", 109 + "matchPattern": "qdisc [a-zA-Z0-9_]+ 0: parent 1:[1-4]", 110 110 "matchCount": "0", 111 111 "teardown": [ 112 112 "echo \"1\" > /sys/bus/netdevsim/del_device" ··· 128 128 "cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: mq", 129 129 "expExitCode": "2", 130 130 "verifyCmd": "$TC qdisc show dev $ETH", 131 - "matchPattern": "qdisc pfifo_fast 0: parent 1:[1-4] bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1", 131 + "matchPattern": "qdisc [a-zA-Z0-9_]+ 0: parent 1:[1-4]", 132 132 "matchCount": "0", 133 133 "teardown": [ 134 134 "echo \"1\" > /sys/bus/netdevsim/del_device"