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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull networking fixes from Paolo Abeni:
"Including fixes from can, bluetooth and ipsec.

This contains a last minute revert of a recent GRE patch, mostly to
allow me stating there are no known regressions outstanding.

Current release - regressions:

- revert "gre: Fix IPv6 link-local address generation."

- eth: ti: am65-cpsw: fix NAPI registration sequence

Previous releases - regressions:

- ipv6: fix memleak of nhc_pcpu_rth_output in fib_check_nh_v6_gw().

- mptcp: fix data stream corruption in the address announcement

- bluetooth: fix connection regression between LE and non-LE adapters

- can:
- flexcan: only change CAN state when link up in system PM
- ucan: fix out of bound read in strscpy() source

Previous releases - always broken:

- lwtunnel: fix reentry loops

- ipv6: fix TCP GSO segmentation with NAT

- xfrm: force software GSO only in tunnel mode

- eth: ti: icssg-prueth: add lock to stats

Misc:

- add Andrea Mayer as a maintainer of SRv6"

* tag 'net-6.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (33 commits)
MAINTAINERS: Add Andrea Mayer as a maintainer of SRv6
Revert "gre: Fix IPv6 link-local address generation."
Revert "selftests: Add IPv6 link-local address generation tests for GRE devices."
net/neighbor: add missing policy for NDTPA_QUEUE_LENBYTES
tools headers: Sync uapi/asm-generic/socket.h with the kernel sources
mptcp: Fix data stream corruption in the address announcement
selftests: net: test for lwtunnel dst ref loops
net: ipv6: ioam6: fix lwtunnel_output() loop
net: lwtunnel: fix recursion loops
net: ti: icssg-prueth: Add lock to stats
net: atm: fix use after free in lec_send()
xsk: fix an integer overflow in xp_create_and_assign_umem()
net: stmmac: dwc-qos-eth: use devm_kzalloc() for AXI data
selftests: drv-net: use defer in the ping test
phy: fix xa_alloc_cyclic() error handling
dpll: fix xa_alloc_cyclic() error handling
devlink: fix xa_alloc_cyclic() error handling
ipv6: Set errno after ip_fib_metrics_init() in ip6_route_info_create().
ipv6: Fix memleak of nhc_pcpu_rth_output in fib_check_nh_v6_gw().
net: ipv6: fix TCP GSO segmentation with NAT
...

+560 -334
+1 -1
Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
··· 170 170 const: renesas,r8a779h0-canfd 171 171 then: 172 172 patternProperties: 173 - "^channel[5-7]$": false 173 + "^channel[4-7]$": false 174 174 else: 175 175 if: 176 176 not:
+11
MAINTAINERS
··· 16660 16660 F: tools/testing/selftests/bpf/*/*mptcp*.[ch] 16661 16661 F: tools/testing/selftests/net/mptcp/ 16662 16662 16663 + NETWORKING [SRv6] 16664 + M: Andrea Mayer <andrea.mayer@uniroma2.it> 16665 + L: netdev@vger.kernel.org 16666 + S: Maintained 16667 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git 16668 + F: include/linux/seg6* 16669 + F: include/net/seg6* 16670 + F: include/uapi/linux/seg6* 16671 + F: net/ipv6/seg6* 16672 + F: tools/testing/selftests/net/srv6* 16673 + 16663 16674 NETWORKING [TCP] 16664 16675 M: Eric Dumazet <edumazet@google.com> 16665 16676 M: Neal Cardwell <ncardwell@google.com>
+1 -1
drivers/dpll/dpll_core.c
··· 505 505 xa_init_flags(&pin->parent_refs, XA_FLAGS_ALLOC); 506 506 ret = xa_alloc_cyclic(&dpll_pin_xa, &pin->id, pin, xa_limit_32b, 507 507 &dpll_pin_xa_id, GFP_KERNEL); 508 - if (ret) 508 + if (ret < 0) 509 509 goto err_xa_alloc; 510 510 return pin; 511 511 err_xa_alloc:
+15 -3
drivers/net/can/flexcan/flexcan-core.c
··· 2260 2260 2261 2261 flexcan_chip_interrupts_disable(dev); 2262 2262 2263 + err = flexcan_transceiver_disable(priv); 2264 + if (err) 2265 + return err; 2266 + 2263 2267 err = pinctrl_pm_select_sleep_state(device); 2264 2268 if (err) 2265 2269 return err; 2266 2270 } 2267 2271 netif_stop_queue(dev); 2268 2272 netif_device_detach(dev); 2273 + 2274 + priv->can.state = CAN_STATE_SLEEPING; 2269 2275 } 2270 - priv->can.state = CAN_STATE_SLEEPING; 2271 2276 2272 2277 return 0; 2273 2278 } ··· 2283 2278 struct flexcan_priv *priv = netdev_priv(dev); 2284 2279 int err; 2285 2280 2286 - priv->can.state = CAN_STATE_ERROR_ACTIVE; 2287 2281 if (netif_running(dev)) { 2288 2282 netif_device_attach(dev); 2289 2283 netif_start_queue(dev); ··· 2296 2292 if (err) 2297 2293 return err; 2298 2294 2299 - err = flexcan_chip_start(dev); 2295 + err = flexcan_transceiver_enable(priv); 2300 2296 if (err) 2301 2297 return err; 2302 2298 2299 + err = flexcan_chip_start(dev); 2300 + if (err) { 2301 + flexcan_transceiver_disable(priv); 2302 + return err; 2303 + } 2304 + 2303 2305 flexcan_chip_interrupts_enable(dev); 2304 2306 } 2307 + 2308 + priv->can.state = CAN_STATE_ERROR_ACTIVE; 2305 2309 } 2306 2310 2307 2311 return 0;
+11 -17
drivers/net/can/rcar/rcar_canfd.c
··· 787 787 } 788 788 789 789 static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv, 790 - u32 ch) 790 + u32 ch, u32 rule_entry) 791 791 { 792 - u32 cfg; 793 - int offset, start, page, num_rules = RCANFD_CHANNEL_NUMRULES; 792 + int offset, page, num_rules = RCANFD_CHANNEL_NUMRULES; 793 + u32 rule_entry_index = rule_entry % 16; 794 794 u32 ridx = ch + RCANFD_RFFIFO_IDX; 795 795 796 - if (ch == 0) { 797 - start = 0; /* Channel 0 always starts from 0th rule */ 798 - } else { 799 - /* Get number of Channel 0 rules and adjust */ 800 - cfg = rcar_canfd_read(gpriv->base, RCANFD_GAFLCFG(ch)); 801 - start = RCANFD_GAFLCFG_GETRNC(gpriv, 0, cfg); 802 - } 803 - 804 796 /* Enable write access to entry */ 805 - page = RCANFD_GAFL_PAGENUM(start); 797 + page = RCANFD_GAFL_PAGENUM(rule_entry); 806 798 rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLECTR, 807 799 (RCANFD_GAFLECTR_AFLPN(gpriv, page) | 808 800 RCANFD_GAFLECTR_AFLDAE)); ··· 810 818 offset = RCANFD_C_GAFL_OFFSET; 811 819 812 820 /* Accept all IDs */ 813 - rcar_canfd_write(gpriv->base, RCANFD_GAFLID(offset, start), 0); 821 + rcar_canfd_write(gpriv->base, RCANFD_GAFLID(offset, rule_entry_index), 0); 814 822 /* IDE or RTR is not considered for matching */ 815 - rcar_canfd_write(gpriv->base, RCANFD_GAFLM(offset, start), 0); 823 + rcar_canfd_write(gpriv->base, RCANFD_GAFLM(offset, rule_entry_index), 0); 816 824 /* Any data length accepted */ 817 - rcar_canfd_write(gpriv->base, RCANFD_GAFLP0(offset, start), 0); 825 + rcar_canfd_write(gpriv->base, RCANFD_GAFLP0(offset, rule_entry_index), 0); 818 826 /* Place the msg in corresponding Rx FIFO entry */ 819 - rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLP1(offset, start), 827 + rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLP1(offset, rule_entry_index), 820 828 RCANFD_GAFLP1_GAFLFDP(ridx)); 821 829 822 830 /* Disable write access to page */ ··· 1843 1851 unsigned long channels_mask = 0; 1844 1852 int err, ch_irq, g_irq; 1845 1853 int g_err_irq, g_recc_irq; 1854 + u32 rule_entry = 0; 1846 1855 bool fdmode = true; /* CAN FD only mode - default */ 1847 1856 char name[9] = "channelX"; 1848 1857 int i; ··· 2016 2023 rcar_canfd_configure_tx(gpriv, ch); 2017 2024 2018 2025 /* Configure receive rules */ 2019 - rcar_canfd_configure_afl_rules(gpriv, ch); 2026 + rcar_canfd_configure_afl_rules(gpriv, ch, rule_entry); 2027 + rule_entry += RCANFD_CHANNEL_NUMRULES; 2020 2028 } 2021 2029 2022 2030 /* Configure common interrupts */
+18 -25
drivers/net/can/usb/ucan.c
··· 186 186 */ 187 187 struct ucan_ctl_cmd_get_protocol_version cmd_get_protocol_version; 188 188 189 - u8 raw[128]; 189 + u8 fw_str[128]; 190 190 } __packed; 191 191 192 192 enum { ··· 424 424 UCAN_USB_CTL_PIPE_TIMEOUT); 425 425 } 426 426 427 - static int ucan_device_request_in(struct ucan_priv *up, 428 - u8 cmd, u16 subcmd, u16 datalen) 427 + static void ucan_get_fw_str(struct ucan_priv *up, char *fw_str, size_t size) 429 428 { 430 - return usb_control_msg(up->udev, 431 - usb_rcvctrlpipe(up->udev, 0), 432 - cmd, 433 - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 434 - subcmd, 435 - 0, 436 - up->ctl_msg_buffer, 437 - datalen, 438 - UCAN_USB_CTL_PIPE_TIMEOUT); 429 + int ret; 430 + 431 + ret = usb_control_msg(up->udev, usb_rcvctrlpipe(up->udev, 0), 432 + UCAN_DEVICE_GET_FW_STRING, 433 + USB_DIR_IN | USB_TYPE_VENDOR | 434 + USB_RECIP_DEVICE, 435 + 0, 0, fw_str, size - 1, 436 + UCAN_USB_CTL_PIPE_TIMEOUT); 437 + if (ret > 0) 438 + fw_str[ret] = '\0'; 439 + else 440 + strscpy(fw_str, "unknown", size); 439 441 } 440 442 441 443 /* Parse the device information structure reported by the device and ··· 1316 1314 u8 in_ep_addr; 1317 1315 u8 out_ep_addr; 1318 1316 union ucan_ctl_payload *ctl_msg_buffer; 1319 - char firmware_str[sizeof(union ucan_ctl_payload) + 1]; 1320 1317 1321 1318 udev = interface_to_usbdev(intf); 1322 1319 ··· 1528 1527 */ 1529 1528 ucan_parse_device_info(up, &ctl_msg_buffer->cmd_get_device_info); 1530 1529 1531 - /* just print some device information - if available */ 1532 - ret = ucan_device_request_in(up, UCAN_DEVICE_GET_FW_STRING, 0, 1533 - sizeof(union ucan_ctl_payload)); 1534 - if (ret > 0) { 1535 - /* copy string while ensuring zero termination */ 1536 - strscpy(firmware_str, up->ctl_msg_buffer->raw, 1537 - sizeof(union ucan_ctl_payload) + 1); 1538 - } else { 1539 - strcpy(firmware_str, "unknown"); 1540 - } 1541 - 1542 1530 /* device is compatible, reset it */ 1543 1531 ret = ucan_ctrl_command_out(up, UCAN_COMMAND_RESET, 0, 0); 1544 1532 if (ret < 0) ··· 1545 1555 1546 1556 /* initialisation complete, log device info */ 1547 1557 netdev_info(up->netdev, "registered device\n"); 1548 - netdev_info(up->netdev, "firmware string: %s\n", firmware_str); 1558 + ucan_get_fw_str(up, up->ctl_msg_buffer->fw_str, 1559 + sizeof(up->ctl_msg_buffer->fw_str)); 1560 + netdev_info(up->netdev, "firmware string: %s\n", 1561 + up->ctl_msg_buffer->fw_str); 1549 1562 1550 1563 /* success */ 1551 1564 return 0;
+10 -4
drivers/net/ethernet/microsoft/mana/gdma_main.c
··· 134 134 struct gdma_list_devices_resp resp = {}; 135 135 struct gdma_general_req req = {}; 136 136 struct gdma_dev_id dev; 137 - u32 i, max_num_devs; 137 + int found_dev = 0; 138 138 u16 dev_type; 139 139 int err; 140 + u32 i; 140 141 141 142 mana_gd_init_req_hdr(&req.hdr, GDMA_LIST_DEVICES, sizeof(req), 142 143 sizeof(resp)); ··· 149 148 return err ? err : -EPROTO; 150 149 } 151 150 152 - max_num_devs = min_t(u32, MAX_NUM_GDMA_DEVICES, resp.num_of_devs); 153 - 154 - for (i = 0; i < max_num_devs; i++) { 151 + for (i = 0; i < GDMA_DEV_LIST_SIZE && 152 + found_dev < resp.num_of_devs; i++) { 155 153 dev = resp.devs[i]; 156 154 dev_type = dev.type; 155 + 156 + /* Skip empty devices */ 157 + if (dev.as_uint32 == 0) 158 + continue; 159 + 160 + found_dev++; 157 161 158 162 /* HWC is already detected in mana_hwc_create_channel(). */ 159 163 if (dev_type == GDMA_DEVICE_HWC)
+3 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
··· 46 46 u32 a_index = 0; 47 47 48 48 if (!plat_dat->axi) { 49 - plat_dat->axi = kzalloc(sizeof(struct stmmac_axi), GFP_KERNEL); 49 + plat_dat->axi = devm_kzalloc(&pdev->dev, 50 + sizeof(struct stmmac_axi), 51 + GFP_KERNEL); 50 52 51 53 if (!plat_dat->axi) 52 54 return -ENOMEM;
+18 -14
drivers/net/ethernet/ti/am65-cpsw-nuss.c
··· 2306 2306 static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common) 2307 2307 { 2308 2308 struct device *dev = common->dev; 2309 + struct am65_cpsw_tx_chn *tx_chn; 2309 2310 int i, ret = 0; 2310 2311 2311 2312 for (i = 0; i < common->tx_ch_num; i++) { 2312 - struct am65_cpsw_tx_chn *tx_chn = &common->tx_chns[i]; 2313 + tx_chn = &common->tx_chns[i]; 2313 2314 2314 2315 hrtimer_init(&tx_chn->tx_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); 2315 2316 tx_chn->tx_hrtimer.function = &am65_cpsw_nuss_tx_timer_callback; 2317 + 2318 + netif_napi_add_tx(common->dma_ndev, &tx_chn->napi_tx, 2319 + am65_cpsw_nuss_tx_poll); 2316 2320 2317 2321 ret = devm_request_irq(dev, tx_chn->irq, 2318 2322 am65_cpsw_nuss_tx_irq, ··· 2327 2323 tx_chn->id, tx_chn->irq, ret); 2328 2324 goto err; 2329 2325 } 2330 - 2331 - netif_napi_add_tx(common->dma_ndev, &tx_chn->napi_tx, 2332 - am65_cpsw_nuss_tx_poll); 2333 2326 } 2334 2327 2335 2328 return 0; 2336 2329 2337 2330 err: 2338 - for (--i ; i >= 0 ; i--) { 2339 - struct am65_cpsw_tx_chn *tx_chn = &common->tx_chns[i]; 2340 - 2341 - netif_napi_del(&tx_chn->napi_tx); 2331 + netif_napi_del(&tx_chn->napi_tx); 2332 + for (--i; i >= 0; i--) { 2333 + tx_chn = &common->tx_chns[i]; 2342 2334 devm_free_irq(dev, tx_chn->irq, tx_chn); 2335 + netif_napi_del(&tx_chn->napi_tx); 2343 2336 } 2344 2337 2345 2338 return ret; ··· 2570 2569 HRTIMER_MODE_REL_PINNED); 2571 2570 flow->rx_hrtimer.function = &am65_cpsw_nuss_rx_timer_callback; 2572 2571 2572 + netif_napi_add(common->dma_ndev, &flow->napi_rx, 2573 + am65_cpsw_nuss_rx_poll); 2574 + 2573 2575 ret = devm_request_irq(dev, flow->irq, 2574 2576 am65_cpsw_nuss_rx_irq, 2575 2577 IRQF_TRIGGER_HIGH, ··· 2581 2577 dev_err(dev, "failure requesting rx %d irq %u, %d\n", 2582 2578 i, flow->irq, ret); 2583 2579 flow->irq = -EINVAL; 2584 - goto err_flow; 2580 + goto err_request_irq; 2585 2581 } 2586 - 2587 - netif_napi_add(common->dma_ndev, &flow->napi_rx, 2588 - am65_cpsw_nuss_rx_poll); 2589 2582 } 2590 2583 2591 2584 /* setup classifier to route priorities to flows */ ··· 2590 2589 2591 2590 return 0; 2592 2591 2592 + err_request_irq: 2593 + netif_napi_del(&flow->napi_rx); 2594 + 2593 2595 err_flow: 2594 - for (--i; i >= 0 ; i--) { 2596 + for (--i; i >= 0; i--) { 2595 2597 flow = &rx_chn->flows[i]; 2596 - netif_napi_del(&flow->napi_rx); 2597 2598 devm_free_irq(dev, flow->irq, flow); 2599 + netif_napi_del(&flow->napi_rx); 2598 2600 } 2599 2601 2600 2602 err:
+1
drivers/net/ethernet/ti/icssg/icssg_prueth.c
··· 1679 1679 } 1680 1680 1681 1681 spin_lock_init(&prueth->vtbl_lock); 1682 + spin_lock_init(&prueth->stats_lock); 1682 1683 /* setup netdev interfaces */ 1683 1684 if (eth0_node) { 1684 1685 ret = prueth_netdev_init(prueth, eth0_node);
+2
drivers/net/ethernet/ti/icssg/icssg_prueth.h
··· 305 305 int default_vlan; 306 306 /** @vtbl_lock: Lock for vtbl in shared memory */ 307 307 spinlock_t vtbl_lock; 308 + /** @stats_lock: Lock for reading icssg stats */ 309 + spinlock_t stats_lock; 308 310 }; 309 311 310 312 struct emac_tx_ts_response {
+4
drivers/net/ethernet/ti/icssg/icssg_stats.c
··· 26 26 u32 val, reg; 27 27 int i; 28 28 29 + spin_lock(&prueth->stats_lock); 30 + 29 31 for (i = 0; i < ARRAY_SIZE(icssg_all_miig_stats); i++) { 30 32 regmap_read(prueth->miig_rt, 31 33 base + icssg_all_miig_stats[i].offset, ··· 53 51 emac->pa_stats[i] += val; 54 52 } 55 53 } 54 + 55 + spin_unlock(&prueth->stats_lock); 56 56 } 57 57 58 58 void icssg_stats_work_handler(struct work_struct *work)
+1 -1
include/net/bluetooth/hci.h
··· 683 683 #define HCI_ERROR_REMOTE_POWER_OFF 0x15 684 684 #define HCI_ERROR_LOCAL_HOST_TERM 0x16 685 685 #define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 686 - #define HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE 0x1e 686 + #define HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE 0x1a 687 687 #define HCI_ERROR_INVALID_LL_PARAMS 0x1e 688 688 #define HCI_ERROR_UNSPECIFIED 0x1f 689 689 #define HCI_ERROR_ADVERTISING_TIMEOUT 0x3c
+7 -4
include/net/mana/gdma.h
··· 408 408 struct gdma_dev mana_ib; 409 409 }; 410 410 411 - #define MAX_NUM_GDMA_DEVICES 4 412 - 413 411 static inline bool mana_gd_is_mana(struct gdma_dev *gd) 414 412 { 415 413 return gd->dev_id.type == GDMA_DEVICE_MANA; ··· 554 556 #define GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG BIT(3) 555 557 #define GDMA_DRV_CAP_FLAG_1_VARIABLE_INDIRECTION_TABLE_SUPPORT BIT(5) 556 558 559 + /* Driver can handle holes (zeros) in the device list */ 560 + #define GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP BIT(11) 561 + 557 562 #define GDMA_DRV_CAP_FLAGS1 \ 558 563 (GDMA_DRV_CAP_FLAG_1_EQ_SHARING_MULTI_VPORT | \ 559 564 GDMA_DRV_CAP_FLAG_1_NAPI_WKDONE_FIX | \ 560 565 GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG | \ 561 - GDMA_DRV_CAP_FLAG_1_VARIABLE_INDIRECTION_TABLE_SUPPORT) 566 + GDMA_DRV_CAP_FLAG_1_VARIABLE_INDIRECTION_TABLE_SUPPORT | \ 567 + GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP) 562 568 563 569 #define GDMA_DRV_CAP_FLAGS2 0 564 570 ··· 623 621 }; /* HW DATA */ 624 622 625 623 /* GDMA_LIST_DEVICES */ 624 + #define GDMA_DEV_LIST_SIZE 64 626 625 struct gdma_list_devices_resp { 627 626 struct gdma_resp_hdr hdr; 628 627 u32 num_of_devs; 629 628 u32 reserved; 630 - struct gdma_dev_id devs[64]; 629 + struct gdma_dev_id devs[GDMA_DEV_LIST_SIZE]; 631 630 }; /* HW DATA */ 632 631 633 632 /* GDMA_REGISTER_DEVICE */
+2 -1
net/atm/lec.c
··· 181 181 lec_send(struct atm_vcc *vcc, struct sk_buff *skb) 182 182 { 183 183 struct net_device *dev = skb->dev; 184 + unsigned int len = skb->len; 184 185 185 186 ATM_SKB(skb)->vcc = vcc; 186 187 atm_account_tx(vcc, skb); ··· 192 191 } 193 192 194 193 dev->stats.tx_packets++; 195 - dev->stats.tx_bytes += skb->len; 194 + dev->stats.tx_bytes += len; 196 195 } 197 196 198 197 static void lec_tx_timeout(struct net_device *dev, unsigned int txqueue)
+1 -2
net/batman-adv/bat_iv_ogm.c
··· 325 325 /* check if there is enough space for the optional TVLV */ 326 326 next_buff_pos += ntohs(ogm_packet->tvlv_len); 327 327 328 - return (next_buff_pos <= packet_len) && 329 - (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES); 328 + return next_buff_pos <= packet_len; 330 329 } 331 330 332 331 /* send a batman ogm to a given interface */
+1 -2
net/batman-adv/bat_v_ogm.c
··· 839 839 /* check if there is enough space for the optional TVLV */ 840 840 next_buff_pos += ntohs(ogm2_packet->tvlv_len); 841 841 842 - return (next_buff_pos <= packet_len) && 843 - (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES); 842 + return next_buff_pos <= packet_len; 844 843 } 845 844 846 845 /**
+6 -1
net/bluetooth/6lowpan.c
··· 825 825 unsigned long hdr_len, 826 826 unsigned long len, int nb) 827 827 { 828 + struct sk_buff *skb; 829 + 828 830 /* Note that we must allocate using GFP_ATOMIC here as 829 831 * this function is called originally from netdev hard xmit 830 832 * function in atomic context. 831 833 */ 832 - return bt_skb_alloc(hdr_len + len, GFP_ATOMIC); 834 + skb = bt_skb_alloc(hdr_len + len, GFP_ATOMIC); 835 + if (!skb) 836 + return ERR_PTR(-ENOMEM); 837 + return skb; 833 838 } 834 839 835 840 static void chan_suspend_cb(struct l2cap_chan *chan)
+6 -6
net/can/af_can.c
··· 287 287 netif_rx(newskb); 288 288 289 289 /* update statistics */ 290 - pkg_stats->tx_frames++; 291 - pkg_stats->tx_frames_delta++; 290 + atomic_long_inc(&pkg_stats->tx_frames); 291 + atomic_long_inc(&pkg_stats->tx_frames_delta); 292 292 293 293 return 0; 294 294 ··· 647 647 int matches; 648 648 649 649 /* update statistics */ 650 - pkg_stats->rx_frames++; 651 - pkg_stats->rx_frames_delta++; 650 + atomic_long_inc(&pkg_stats->rx_frames); 651 + atomic_long_inc(&pkg_stats->rx_frames_delta); 652 652 653 653 /* create non-zero unique skb identifier together with *skb */ 654 654 while (!(can_skb_prv(skb)->skbcnt)) ··· 669 669 consume_skb(skb); 670 670 671 671 if (matches > 0) { 672 - pkg_stats->matches++; 673 - pkg_stats->matches_delta++; 672 + atomic_long_inc(&pkg_stats->matches); 673 + atomic_long_inc(&pkg_stats->matches_delta); 674 674 } 675 675 } 676 676
+6 -6
net/can/af_can.h
··· 66 66 struct can_pkg_stats { 67 67 unsigned long jiffies_init; 68 68 69 - unsigned long rx_frames; 70 - unsigned long tx_frames; 71 - unsigned long matches; 69 + atomic_long_t rx_frames; 70 + atomic_long_t tx_frames; 71 + atomic_long_t matches; 72 72 73 73 unsigned long total_rx_rate; 74 74 unsigned long total_tx_rate; ··· 82 82 unsigned long max_tx_rate; 83 83 unsigned long max_rx_match_ratio; 84 84 85 - unsigned long rx_frames_delta; 86 - unsigned long tx_frames_delta; 87 - unsigned long matches_delta; 85 + atomic_long_t rx_frames_delta; 86 + atomic_long_t tx_frames_delta; 87 + atomic_long_t matches_delta; 88 88 }; 89 89 90 90 /* persistent statistics */
+27 -19
net/can/proc.c
··· 118 118 struct can_pkg_stats *pkg_stats = net->can.pkg_stats; 119 119 unsigned long j = jiffies; /* snapshot */ 120 120 121 + long rx_frames = atomic_long_read(&pkg_stats->rx_frames); 122 + long tx_frames = atomic_long_read(&pkg_stats->tx_frames); 123 + long matches = atomic_long_read(&pkg_stats->matches); 124 + long rx_frames_delta = atomic_long_read(&pkg_stats->rx_frames_delta); 125 + long tx_frames_delta = atomic_long_read(&pkg_stats->tx_frames_delta); 126 + long matches_delta = atomic_long_read(&pkg_stats->matches_delta); 127 + 121 128 /* restart counting in timer context on user request */ 122 129 if (user_reset) 123 130 can_init_stats(net); ··· 134 127 can_init_stats(net); 135 128 136 129 /* prevent overflow in calc_rate() */ 137 - if (pkg_stats->rx_frames > (ULONG_MAX / HZ)) 130 + if (rx_frames > (LONG_MAX / HZ)) 138 131 can_init_stats(net); 139 132 140 133 /* prevent overflow in calc_rate() */ 141 - if (pkg_stats->tx_frames > (ULONG_MAX / HZ)) 134 + if (tx_frames > (LONG_MAX / HZ)) 142 135 can_init_stats(net); 143 136 144 137 /* matches overflow - very improbable */ 145 - if (pkg_stats->matches > (ULONG_MAX / 100)) 138 + if (matches > (LONG_MAX / 100)) 146 139 can_init_stats(net); 147 140 148 141 /* calc total values */ 149 - if (pkg_stats->rx_frames) 150 - pkg_stats->total_rx_match_ratio = (pkg_stats->matches * 100) / 151 - pkg_stats->rx_frames; 142 + if (rx_frames) 143 + pkg_stats->total_rx_match_ratio = (matches * 100) / rx_frames; 152 144 153 145 pkg_stats->total_tx_rate = calc_rate(pkg_stats->jiffies_init, j, 154 - pkg_stats->tx_frames); 146 + tx_frames); 155 147 pkg_stats->total_rx_rate = calc_rate(pkg_stats->jiffies_init, j, 156 - pkg_stats->rx_frames); 148 + rx_frames); 157 149 158 150 /* calc current values */ 159 - if (pkg_stats->rx_frames_delta) 151 + if (rx_frames_delta) 160 152 pkg_stats->current_rx_match_ratio = 161 - (pkg_stats->matches_delta * 100) / 162 - pkg_stats->rx_frames_delta; 153 + (matches_delta * 100) / rx_frames_delta; 163 154 164 - pkg_stats->current_tx_rate = calc_rate(0, HZ, pkg_stats->tx_frames_delta); 165 - pkg_stats->current_rx_rate = calc_rate(0, HZ, pkg_stats->rx_frames_delta); 155 + pkg_stats->current_tx_rate = calc_rate(0, HZ, tx_frames_delta); 156 + pkg_stats->current_rx_rate = calc_rate(0, HZ, rx_frames_delta); 166 157 167 158 /* check / update maximum values */ 168 159 if (pkg_stats->max_tx_rate < pkg_stats->current_tx_rate) ··· 173 168 pkg_stats->max_rx_match_ratio = pkg_stats->current_rx_match_ratio; 174 169 175 170 /* clear values for 'current rate' calculation */ 176 - pkg_stats->tx_frames_delta = 0; 177 - pkg_stats->rx_frames_delta = 0; 178 - pkg_stats->matches_delta = 0; 171 + atomic_long_set(&pkg_stats->tx_frames_delta, 0); 172 + atomic_long_set(&pkg_stats->rx_frames_delta, 0); 173 + atomic_long_set(&pkg_stats->matches_delta, 0); 179 174 180 175 /* restart timer (one second) */ 181 176 mod_timer(&net->can.stattimer, round_jiffies(jiffies + HZ)); ··· 219 214 struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; 220 215 221 216 seq_putc(m, '\n'); 222 - seq_printf(m, " %8ld transmitted frames (TXF)\n", pkg_stats->tx_frames); 223 - seq_printf(m, " %8ld received frames (RXF)\n", pkg_stats->rx_frames); 224 - seq_printf(m, " %8ld matched frames (RXMF)\n", pkg_stats->matches); 217 + seq_printf(m, " %8ld transmitted frames (TXF)\n", 218 + atomic_long_read(&pkg_stats->tx_frames)); 219 + seq_printf(m, " %8ld received frames (RXF)\n", 220 + atomic_long_read(&pkg_stats->rx_frames)); 221 + seq_printf(m, " %8ld matched frames (RXMF)\n", 222 + atomic_long_read(&pkg_stats->matches)); 225 223 226 224 seq_putc(m, '\n'); 227 225
+53 -12
net/core/lwtunnel.c
··· 23 23 #include <net/ip6_fib.h> 24 24 #include <net/rtnh.h> 25 25 26 + #include "dev.h" 27 + 26 28 DEFINE_STATIC_KEY_FALSE(nf_hooks_lwtunnel_enabled); 27 29 EXPORT_SYMBOL_GPL(nf_hooks_lwtunnel_enabled); 28 30 ··· 327 325 328 326 int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb) 329 327 { 330 - struct dst_entry *dst = skb_dst(skb); 331 328 const struct lwtunnel_encap_ops *ops; 332 329 struct lwtunnel_state *lwtstate; 333 - int ret = -EINVAL; 330 + struct dst_entry *dst; 331 + int ret; 334 332 335 - if (!dst) 333 + if (dev_xmit_recursion()) { 334 + net_crit_ratelimited("%s(): recursion limit reached on datapath\n", 335 + __func__); 336 + ret = -ENETDOWN; 336 337 goto drop; 338 + } 339 + 340 + dst = skb_dst(skb); 341 + if (!dst) { 342 + ret = -EINVAL; 343 + goto drop; 344 + } 337 345 lwtstate = dst->lwtstate; 338 346 339 347 if (lwtstate->type == LWTUNNEL_ENCAP_NONE || ··· 353 341 ret = -EOPNOTSUPP; 354 342 rcu_read_lock(); 355 343 ops = rcu_dereference(lwtun_encaps[lwtstate->type]); 356 - if (likely(ops && ops->output)) 344 + if (likely(ops && ops->output)) { 345 + dev_xmit_recursion_inc(); 357 346 ret = ops->output(net, sk, skb); 347 + dev_xmit_recursion_dec(); 348 + } 358 349 rcu_read_unlock(); 359 350 360 351 if (ret == -EOPNOTSUPP) ··· 374 359 375 360 int lwtunnel_xmit(struct sk_buff *skb) 376 361 { 377 - struct dst_entry *dst = skb_dst(skb); 378 362 const struct lwtunnel_encap_ops *ops; 379 363 struct lwtunnel_state *lwtstate; 380 - int ret = -EINVAL; 364 + struct dst_entry *dst; 365 + int ret; 381 366 382 - if (!dst) 367 + if (dev_xmit_recursion()) { 368 + net_crit_ratelimited("%s(): recursion limit reached on datapath\n", 369 + __func__); 370 + ret = -ENETDOWN; 383 371 goto drop; 372 + } 373 + 374 + dst = skb_dst(skb); 375 + if (!dst) { 376 + ret = -EINVAL; 377 + goto drop; 378 + } 384 379 385 380 lwtstate = dst->lwtstate; 386 381 ··· 401 376 ret = -EOPNOTSUPP; 402 377 rcu_read_lock(); 403 378 ops = rcu_dereference(lwtun_encaps[lwtstate->type]); 404 - if (likely(ops && ops->xmit)) 379 + if (likely(ops && ops->xmit)) { 380 + dev_xmit_recursion_inc(); 405 381 ret = ops->xmit(skb); 382 + dev_xmit_recursion_dec(); 383 + } 406 384 rcu_read_unlock(); 407 385 408 386 if (ret == -EOPNOTSUPP) ··· 422 394 423 395 int lwtunnel_input(struct sk_buff *skb) 424 396 { 425 - struct dst_entry *dst = skb_dst(skb); 426 397 const struct lwtunnel_encap_ops *ops; 427 398 struct lwtunnel_state *lwtstate; 428 - int ret = -EINVAL; 399 + struct dst_entry *dst; 400 + int ret; 429 401 430 - if (!dst) 402 + if (dev_xmit_recursion()) { 403 + net_crit_ratelimited("%s(): recursion limit reached on datapath\n", 404 + __func__); 405 + ret = -ENETDOWN; 431 406 goto drop; 407 + } 408 + 409 + dst = skb_dst(skb); 410 + if (!dst) { 411 + ret = -EINVAL; 412 + goto drop; 413 + } 432 414 lwtstate = dst->lwtstate; 433 415 434 416 if (lwtstate->type == LWTUNNEL_ENCAP_NONE || ··· 448 410 ret = -EOPNOTSUPP; 449 411 rcu_read_lock(); 450 412 ops = rcu_dereference(lwtun_encaps[lwtstate->type]); 451 - if (likely(ops && ops->input)) 413 + if (likely(ops && ops->input)) { 414 + dev_xmit_recursion_inc(); 452 415 ret = ops->input(skb); 416 + dev_xmit_recursion_dec(); 417 + } 453 418 rcu_read_unlock(); 454 419 455 420 if (ret == -EOPNOTSUPP)
+1
net/core/neighbour.c
··· 2250 2250 static const struct nla_policy nl_ntbl_parm_policy[NDTPA_MAX+1] = { 2251 2251 [NDTPA_IFINDEX] = { .type = NLA_U32 }, 2252 2252 [NDTPA_QUEUE_LEN] = { .type = NLA_U32 }, 2253 + [NDTPA_QUEUE_LENBYTES] = { .type = NLA_U32 }, 2253 2254 [NDTPA_PROXY_QLEN] = { .type = NLA_U32 }, 2254 2255 [NDTPA_APP_PROBES] = { .type = NLA_U32 }, 2255 2256 [NDTPA_UCAST_PROBES] = { .type = NLA_U32 },
+1 -1
net/devlink/core.c
··· 117 117 118 118 err = xa_alloc_cyclic(&devlink_rels, &rel->index, rel, 119 119 xa_limit_32b, &next, GFP_KERNEL); 120 - if (err) { 120 + if (err < 0) { 121 121 kfree(rel); 122 122 return ERR_PTR(err); 123 123 }
+6 -9
net/ipv6/addrconf.c
··· 3209 3209 struct in6_addr addr; 3210 3210 struct net_device *dev; 3211 3211 struct net *net = dev_net(idev->dev); 3212 - int scope, plen; 3212 + int scope, plen, offset = 0; 3213 3213 u32 pflags = 0; 3214 3214 3215 3215 ASSERT_RTNL(); 3216 3216 3217 3217 memset(&addr, 0, sizeof(struct in6_addr)); 3218 - memcpy(&addr.s6_addr32[3], idev->dev->dev_addr, 4); 3218 + /* in case of IP6GRE the dev_addr is an IPv6 and therefore we use only the last 4 bytes */ 3219 + if (idev->dev->addr_len == sizeof(struct in6_addr)) 3220 + offset = sizeof(struct in6_addr) - 4; 3221 + memcpy(&addr.s6_addr32[3], idev->dev->dev_addr + offset, 4); 3219 3222 3220 3223 if (!(idev->dev->flags & IFF_POINTOPOINT) && idev->dev->type == ARPHRD_SIT) { 3221 3224 scope = IPV6_ADDR_COMPATv4; ··· 3529 3526 return; 3530 3527 } 3531 3528 3532 - /* Generate the IPv6 link-local address using addrconf_addr_gen(), 3533 - * unless we have an IPv4 GRE device not bound to an IP address and 3534 - * which is in EUI64 mode (as __ipv6_isatap_ifid() would fail in this 3535 - * case). Such devices fall back to add_v4_addrs() instead. 3536 - */ 3537 - if (!(dev->type == ARPHRD_IPGRE && *(__be32 *)dev->dev_addr == 0 && 3538 - idev->cnf.addr_gen_mode == IN6_ADDR_GEN_MODE_EUI64)) { 3529 + if (dev->type == ARPHRD_ETHER) { 3539 3530 addrconf_addr_gen(idev, true); 3540 3531 return; 3541 3532 }
+4 -4
net/ipv6/ioam6_iptunnel.c
··· 337 337 static int ioam6_output(struct net *net, struct sock *sk, struct sk_buff *skb) 338 338 { 339 339 struct dst_entry *dst = skb_dst(skb), *cache_dst = NULL; 340 - struct in6_addr orig_daddr; 341 340 struct ioam6_lwt *ilwt; 342 341 int err = -EINVAL; 343 342 u32 pkt_cnt; ··· 350 351 pkt_cnt = atomic_fetch_inc(&ilwt->pkt_cnt); 351 352 if (pkt_cnt % ilwt->freq.n >= ilwt->freq.k) 352 353 goto out; 353 - 354 - orig_daddr = ipv6_hdr(skb)->daddr; 355 354 356 355 local_bh_disable(); 357 356 cache_dst = dst_cache_get(&ilwt->cache); ··· 419 422 goto drop; 420 423 } 421 424 422 - if (!ipv6_addr_equal(&orig_daddr, &ipv6_hdr(skb)->daddr)) { 425 + /* avoid lwtunnel_output() reentry loop when destination is the same 426 + * after transformation (e.g., with the inline mode) 427 + */ 428 + if (dst->lwtstate != cache_dst->lwtstate) { 423 429 skb_dst_drop(skb); 424 430 skb_dst_set(skb, cache_dst); 425 431 return dst_output(net, sk, skb);
+4 -1
net/ipv6/route.c
··· 3644 3644 in6_dev_put(idev); 3645 3645 3646 3646 if (err) { 3647 - lwtstate_put(fib6_nh->fib_nh_lws); 3647 + fib_nh_common_release(&fib6_nh->nh_common); 3648 + fib6_nh->nh_common.nhc_pcpu_rth_output = NULL; 3648 3649 fib6_nh->fib_nh_lws = NULL; 3649 3650 netdev_put(dev, dev_tracker); 3650 3651 } ··· 3803 3802 if (nh) { 3804 3803 if (rt->fib6_src.plen) { 3805 3804 NL_SET_ERR_MSG(extack, "Nexthops can not be used with source routing"); 3805 + err = -EINVAL; 3806 3806 goto out_free; 3807 3807 } 3808 3808 if (!nexthop_get(nh)) { 3809 3809 NL_SET_ERR_MSG(extack, "Nexthop has been deleted"); 3810 + err = -ENOENT; 3810 3811 goto out_free; 3811 3812 } 3812 3813 rt->nh = nh;
+15 -6
net/ipv6/tcpv6_offload.c
··· 94 94 } 95 95 96 96 static void __tcpv6_gso_segment_csum(struct sk_buff *seg, 97 + struct in6_addr *oldip, 98 + const struct in6_addr *newip, 97 99 __be16 *oldport, __be16 newport) 98 100 { 99 - struct tcphdr *th; 101 + struct tcphdr *th = tcp_hdr(seg); 102 + 103 + if (!ipv6_addr_equal(oldip, newip)) { 104 + inet_proto_csum_replace16(&th->check, seg, 105 + oldip->s6_addr32, 106 + newip->s6_addr32, 107 + true); 108 + *oldip = *newip; 109 + } 100 110 101 111 if (*oldport == newport) 102 112 return; 103 113 104 - th = tcp_hdr(seg); 105 114 inet_proto_csum_replace2(&th->check, seg, *oldport, newport, false); 106 115 *oldport = newport; 107 116 } ··· 138 129 th2 = tcp_hdr(seg); 139 130 iph2 = ipv6_hdr(seg); 140 131 141 - iph2->saddr = iph->saddr; 142 - iph2->daddr = iph->daddr; 143 - __tcpv6_gso_segment_csum(seg, &th2->source, th->source); 144 - __tcpv6_gso_segment_csum(seg, &th2->dest, th->dest); 132 + __tcpv6_gso_segment_csum(seg, &iph2->saddr, &iph->saddr, 133 + &th2->source, th->source); 134 + __tcpv6_gso_segment_csum(seg, &iph2->daddr, &iph->daddr, 135 + &th2->dest, th->dest); 145 136 } 146 137 147 138 return segs;
+4 -2
net/mptcp/options.c
··· 651 651 struct mptcp_sock *msk = mptcp_sk(subflow->conn); 652 652 bool drop_other_suboptions = false; 653 653 unsigned int opt_size = *size; 654 + struct mptcp_addr_info addr; 654 655 bool echo; 655 656 int len; 656 657 ··· 660 659 */ 661 660 if (!mptcp_pm_should_add_signal(msk) || 662 661 (opts->suboptions & (OPTION_MPTCP_MPJ_ACK | OPTION_MPTCP_MPC_ACK)) || 663 - !mptcp_pm_add_addr_signal(msk, skb, opt_size, remaining, &opts->addr, 662 + !mptcp_pm_add_addr_signal(msk, skb, opt_size, remaining, &addr, 664 663 &echo, &drop_other_suboptions)) 665 664 return false; 666 665 ··· 673 672 else if (opts->suboptions & OPTION_MPTCP_DSS) 674 673 return false; 675 674 676 - len = mptcp_add_addr_len(opts->addr.family, echo, !!opts->addr.port); 675 + len = mptcp_add_addr_len(addr.family, echo, !!addr.port); 677 676 if (remaining < len) 678 677 return false; 679 678 ··· 690 689 opts->ahmac = 0; 691 690 *size -= opt_size; 692 691 } 692 + opts->addr = addr; 693 693 opts->suboptions |= OPTION_MPTCP_ADD_ADDR; 694 694 if (!echo) { 695 695 MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDRTX);
+1 -1
net/xdp/xsk_buff_pool.c
··· 105 105 if (pool->unaligned) 106 106 pool->free_heads[i] = xskb; 107 107 else 108 - xp_init_xskb_addr(xskb, pool, i * pool->chunk_size); 108 + xp_init_xskb_addr(xskb, pool, (u64)i * pool->chunk_size); 109 109 } 110 110 111 111 return pool;
+42 -1
net/xfrm/xfrm_output.c
··· 612 612 } 613 613 EXPORT_SYMBOL_GPL(xfrm_output_resume); 614 614 615 + static int xfrm_dev_direct_output(struct sock *sk, struct xfrm_state *x, 616 + struct sk_buff *skb) 617 + { 618 + struct dst_entry *dst = skb_dst(skb); 619 + struct net *net = xs_net(x); 620 + int err; 621 + 622 + dst = skb_dst_pop(skb); 623 + if (!dst) { 624 + XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); 625 + kfree_skb(skb); 626 + return -EHOSTUNREACH; 627 + } 628 + skb_dst_set(skb, dst); 629 + nf_reset_ct(skb); 630 + 631 + err = skb_dst(skb)->ops->local_out(net, sk, skb); 632 + if (unlikely(err != 1)) { 633 + kfree_skb(skb); 634 + return err; 635 + } 636 + 637 + /* In transport mode, network destination is 638 + * directly reachable, while in tunnel mode, 639 + * inner packet network may not be. In packet 640 + * offload type, HW is responsible for hard 641 + * header packet mangling so directly xmit skb 642 + * to netdevice. 643 + */ 644 + skb->dev = x->xso.dev; 645 + __skb_push(skb, skb->dev->hard_header_len); 646 + return dev_queue_xmit(skb); 647 + } 648 + 615 649 static int xfrm_output2(struct net *net, struct sock *sk, struct sk_buff *skb) 616 650 { 617 651 return xfrm_output_resume(sk, skb, 1); ··· 769 735 return -EHOSTUNREACH; 770 736 } 771 737 738 + /* Exclusive direct xmit for tunnel mode, as 739 + * some filtering or matching rules may apply 740 + * in transport mode. 741 + */ 742 + if (x->props.mode == XFRM_MODE_TUNNEL) 743 + return xfrm_dev_direct_output(sk, x, skb); 744 + 772 745 return xfrm_output_resume(sk, skb, 0); 773 746 } 774 747 ··· 799 758 skb->encapsulation = 1; 800 759 801 760 if (skb_is_gso(skb)) { 802 - if (skb->inner_protocol) 761 + if (skb->inner_protocol && x->props.mode == XFRM_MODE_TUNNEL) 803 762 return xfrm_output_gso(net, sk, skb); 804 763 805 764 skb_shinfo(skb)->gso_type |= SKB_GSO_ESP;
+19 -2
tools/include/uapi/asm-generic/socket.h
··· 119 119 120 120 #define SO_DETACH_REUSEPORT_BPF 68 121 121 122 + #define SO_PREFER_BUSY_POLL 69 123 + #define SO_BUSY_POLL_BUDGET 70 124 + 125 + #define SO_NETNS_COOKIE 71 126 + 127 + #define SO_BUF_LOCK 72 128 + 129 + #define SO_RESERVE_MEM 73 130 + 131 + #define SO_TXREHASH 74 132 + 122 133 #define SO_RCVMARK 75 123 134 124 135 #define SO_PASSPIDFD 76 125 136 #define SO_PEERPIDFD 77 126 137 127 - #define SCM_TS_OPT_ID 78 138 + #define SO_DEVMEM_LINEAR 78 139 + #define SCM_DEVMEM_LINEAR SO_DEVMEM_LINEAR 140 + #define SO_DEVMEM_DMABUF 79 141 + #define SCM_DEVMEM_DMABUF SO_DEVMEM_DMABUF 142 + #define SO_DEVMEM_DONTNEED 80 128 143 129 - #define SO_RCVPRIORITY 79 144 + #define SCM_TS_OPT_ID 81 145 + 146 + #define SO_RCVPRIORITY 82 130 147 131 148 #if !defined(__KERNEL__) 132 149
+8 -8
tools/testing/selftests/drivers/net/ping.py
··· 7 7 from lib.py import ksft_eq, KsftSkipEx, KsftFailEx 8 8 from lib.py import EthtoolFamily, NetDrvEpEnv 9 9 from lib.py import bkg, cmd, wait_port_listen, rand_port 10 - from lib.py import ethtool, ip 10 + from lib.py import defer, ethtool, ip 11 11 12 12 remote_ifname="" 13 13 no_sleep=False ··· 60 60 prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o" 61 61 cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote) 62 62 cmd(f"ip link set dev {cfg.ifname} mtu 1500 xdpgeneric obj {prog} sec xdp", shell=True) 63 + defer(cmd, f"ip link set dev {cfg.ifname} xdpgeneric off") 63 64 64 65 if no_sleep != True: 65 66 time.sleep(10) ··· 69 68 test_dir = os.path.dirname(os.path.realpath(__file__)) 70 69 prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o" 71 70 cmd(f"ip link set dev {remote_ifname} mtu 9000", shell=True, host=cfg.remote) 71 + defer(ip, f"link set dev {remote_ifname} mtu 1500", host=cfg.remote) 72 72 ip("link set dev %s mtu 9000 xdpgeneric obj %s sec xdp.frags" % (cfg.ifname, prog)) 73 + defer(ip, f"link set dev {cfg.ifname} mtu 1500 xdpgeneric off") 73 74 74 75 if no_sleep != True: 75 76 time.sleep(10) ··· 81 78 prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o" 82 79 cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote) 83 80 cmd(f"ip -j link set dev {cfg.ifname} mtu 1500 xdp obj {prog} sec xdp", shell=True) 81 + defer(ip, f"link set dev {cfg.ifname} mtu 1500 xdp off") 84 82 xdp_info = ip("-d link show %s" % (cfg.ifname), json=True)[0] 85 83 if xdp_info['xdp']['mode'] != 1: 86 84 """ ··· 98 94 test_dir = os.path.dirname(os.path.realpath(__file__)) 99 95 prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o" 100 96 cmd(f"ip link set dev {remote_ifname} mtu 9000", shell=True, host=cfg.remote) 97 + defer(ip, f"link set dev {remote_ifname} mtu 1500", host=cfg.remote) 101 98 try: 102 99 cmd(f"ip link set dev {cfg.ifname} mtu 9000 xdp obj {prog} sec xdp.frags", shell=True) 100 + defer(ip, f"link set dev {cfg.ifname} mtu 1500 xdp off") 103 101 except Exception as e: 104 - cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote) 105 102 raise KsftSkipEx('device does not support native-multi-buffer XDP') 106 103 107 104 if no_sleep != True: ··· 116 111 cmd(f"ip link set dev {cfg.ifname} xdpoffload obj {prog} sec xdp", shell=True) 117 112 except Exception as e: 118 113 raise KsftSkipEx('device does not support offloaded XDP') 114 + defer(ip, f"link set dev {cfg.ifname} xdpoffload off") 119 115 cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote) 120 116 121 117 if no_sleep != True: ··· 163 157 _test_v4(cfg) 164 158 _test_v6(cfg) 165 159 _test_tcp(cfg) 166 - ip("link set dev %s xdpgeneric off" % cfg.ifname) 167 160 168 161 def test_xdp_generic_mb(cfg, netnl) -> None: 169 162 _set_xdp_generic_mb_on(cfg) ··· 174 169 _test_v4(cfg) 175 170 _test_v6(cfg) 176 171 _test_tcp(cfg) 177 - ip("link set dev %s xdpgeneric off" % cfg.ifname) 178 172 179 173 def test_xdp_native_sb(cfg, netnl) -> None: 180 174 _set_xdp_native_sb_on(cfg) ··· 185 181 _test_v4(cfg) 186 182 _test_v6(cfg) 187 183 _test_tcp(cfg) 188 - ip("link set dev %s xdp off" % cfg.ifname) 189 184 190 185 def test_xdp_native_mb(cfg, netnl) -> None: 191 186 _set_xdp_native_mb_on(cfg) ··· 196 193 _test_v4(cfg) 197 194 _test_v6(cfg) 198 195 _test_tcp(cfg) 199 - ip("link set dev %s xdp off" % cfg.ifname) 200 196 201 197 def test_xdp_offload(cfg, netnl) -> None: 202 198 _set_xdp_offload_on(cfg) 203 199 _test_v4(cfg) 204 200 _test_v6(cfg) 205 201 _test_tcp(cfg) 206 - ip("link set dev %s xdpoffload off" % cfg.ifname) 207 202 208 203 def main() -> None: 209 204 with NetDrvEpEnv(__file__) as cfg: ··· 214 213 test_xdp_native_mb, 215 214 test_xdp_offload], 216 215 args=(cfg, EthtoolFamily())) 217 - set_interface_init(cfg) 218 216 ksft_exit() 219 217 220 218
+1 -1
tools/testing/selftests/net/Makefile
··· 31 31 TEST_PROGS += ioam6.sh 32 32 TEST_PROGS += gro.sh 33 33 TEST_PROGS += gre_gso.sh 34 - TEST_PROGS += gre_ipv6_lladdr.sh 35 34 TEST_PROGS += cmsg_so_mark.sh 36 35 TEST_PROGS += cmsg_so_priority.sh 37 36 TEST_PROGS += cmsg_time.sh cmsg_ipv6.sh ··· 100 101 TEST_PROGS += bpf_offload.py 101 102 TEST_PROGS += ipv6_route_update_soft_lockup.sh 102 103 TEST_PROGS += busy_poll_test.sh 104 + TEST_PROGS += lwt_dst_cache_ref_loop.sh 103 105 104 106 # YNL files, must be before "include ..lib.mk" 105 107 YNL_GEN_FILES := busy_poller netlink-dumps
+2
tools/testing/selftests/net/config
··· 107 107 CONFIG_XFRM_USER=m 108 108 CONFIG_IP_NF_MATCH_RPFILTER=m 109 109 CONFIG_IP6_NF_MATCH_RPFILTER=m 110 + CONFIG_IPV6_ILA=m 111 + CONFIG_IPV6_RPL_LWTUNNEL=y
-177
tools/testing/selftests/net/gre_ipv6_lladdr.sh
··· 1 - #!/bin/bash 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - source ./lib.sh 5 - 6 - PAUSE_ON_FAIL="no" 7 - 8 - # The trap function handler 9 - # 10 - exit_cleanup_all() 11 - { 12 - cleanup_all_ns 13 - 14 - exit "${EXIT_STATUS}" 15 - } 16 - 17 - # Add fake IPv4 and IPv6 networks on the loopback device, to be used as 18 - # underlay by future GRE devices. 19 - # 20 - setup_basenet() 21 - { 22 - ip -netns "${NS0}" link set dev lo up 23 - ip -netns "${NS0}" address add dev lo 192.0.2.10/24 24 - ip -netns "${NS0}" address add dev lo 2001:db8::10/64 nodad 25 - } 26 - 27 - # Check if network device has an IPv6 link-local address assigned. 28 - # 29 - # Parameters: 30 - # 31 - # * $1: The network device to test 32 - # * $2: An extra regular expression that should be matched (to verify the 33 - # presence of extra attributes) 34 - # * $3: The expected return code from grep (to allow checking the absence of 35 - # a link-local address) 36 - # * $4: The user visible name for the scenario being tested 37 - # 38 - check_ipv6_ll_addr() 39 - { 40 - local DEV="$1" 41 - local EXTRA_MATCH="$2" 42 - local XRET="$3" 43 - local MSG="$4" 44 - 45 - RET=0 46 - set +e 47 - ip -netns "${NS0}" -6 address show dev "${DEV}" scope link | grep "fe80::" | grep -q "${EXTRA_MATCH}" 48 - check_err_fail "${XRET}" $? "" 49 - log_test "${MSG}" 50 - set -e 51 - } 52 - 53 - # Create a GRE device and verify that it gets an IPv6 link-local address as 54 - # expected. 55 - # 56 - # Parameters: 57 - # 58 - # * $1: The device type (gre, ip6gre, gretap or ip6gretap) 59 - # * $2: The local underlay IP address (can be an IPv4, an IPv6 or "any") 60 - # * $3: The remote underlay IP address (can be an IPv4, an IPv6 or "any") 61 - # * $4: The IPv6 interface identifier generation mode to use for the GRE 62 - # device (eui64, none, stable-privacy or random). 63 - # 64 - test_gre_device() 65 - { 66 - local GRE_TYPE="$1" 67 - local LOCAL_IP="$2" 68 - local REMOTE_IP="$3" 69 - local MODE="$4" 70 - local ADDR_GEN_MODE 71 - local MATCH_REGEXP 72 - local MSG 73 - 74 - ip link add netns "${NS0}" name gretest type "${GRE_TYPE}" local "${LOCAL_IP}" remote "${REMOTE_IP}" 75 - 76 - case "${MODE}" in 77 - "eui64") 78 - ADDR_GEN_MODE=0 79 - MATCH_REGEXP="" 80 - MSG="${GRE_TYPE}, mode: 0 (EUI64), ${LOCAL_IP} -> ${REMOTE_IP}" 81 - XRET=0 82 - ;; 83 - "none") 84 - ADDR_GEN_MODE=1 85 - MATCH_REGEXP="" 86 - MSG="${GRE_TYPE}, mode: 1 (none), ${LOCAL_IP} -> ${REMOTE_IP}" 87 - XRET=1 # No link-local address should be generated 88 - ;; 89 - "stable-privacy") 90 - ADDR_GEN_MODE=2 91 - MATCH_REGEXP="stable-privacy" 92 - MSG="${GRE_TYPE}, mode: 2 (stable privacy), ${LOCAL_IP} -> ${REMOTE_IP}" 93 - XRET=0 94 - # Initialise stable_secret (required for stable-privacy mode) 95 - ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.stable_secret="2001:db8::abcd" 96 - ;; 97 - "random") 98 - ADDR_GEN_MODE=3 99 - MATCH_REGEXP="stable-privacy" 100 - MSG="${GRE_TYPE}, mode: 3 (random), ${LOCAL_IP} -> ${REMOTE_IP}" 101 - XRET=0 102 - ;; 103 - esac 104 - 105 - # Check that IPv6 link-local address is generated when device goes up 106 - ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode="${ADDR_GEN_MODE}" 107 - ip -netns "${NS0}" link set dev gretest up 108 - check_ipv6_ll_addr gretest "${MATCH_REGEXP}" "${XRET}" "config: ${MSG}" 109 - 110 - # Now disable link-local address generation 111 - ip -netns "${NS0}" link set dev gretest down 112 - ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode=1 113 - ip -netns "${NS0}" link set dev gretest up 114 - 115 - # Check that link-local address generation works when re-enabled while 116 - # the device is already up 117 - ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode="${ADDR_GEN_MODE}" 118 - check_ipv6_ll_addr gretest "${MATCH_REGEXP}" "${XRET}" "update: ${MSG}" 119 - 120 - ip -netns "${NS0}" link del dev gretest 121 - } 122 - 123 - test_gre4() 124 - { 125 - local GRE_TYPE 126 - local MODE 127 - 128 - for GRE_TYPE in "gre" "gretap"; do 129 - printf "\n####\nTesting IPv6 link-local address generation on ${GRE_TYPE} devices\n####\n\n" 130 - 131 - for MODE in "eui64" "none" "stable-privacy" "random"; do 132 - test_gre_device "${GRE_TYPE}" 192.0.2.10 192.0.2.11 "${MODE}" 133 - test_gre_device "${GRE_TYPE}" any 192.0.2.11 "${MODE}" 134 - test_gre_device "${GRE_TYPE}" 192.0.2.10 any "${MODE}" 135 - done 136 - done 137 - } 138 - 139 - test_gre6() 140 - { 141 - local GRE_TYPE 142 - local MODE 143 - 144 - for GRE_TYPE in "ip6gre" "ip6gretap"; do 145 - printf "\n####\nTesting IPv6 link-local address generation on ${GRE_TYPE} devices\n####\n\n" 146 - 147 - for MODE in "eui64" "none" "stable-privacy" "random"; do 148 - test_gre_device "${GRE_TYPE}" 2001:db8::10 2001:db8::11 "${MODE}" 149 - test_gre_device "${GRE_TYPE}" any 2001:db8::11 "${MODE}" 150 - test_gre_device "${GRE_TYPE}" 2001:db8::10 any "${MODE}" 151 - done 152 - done 153 - } 154 - 155 - usage() 156 - { 157 - echo "Usage: $0 [-p]" 158 - exit 1 159 - } 160 - 161 - while getopts :p o 162 - do 163 - case $o in 164 - p) PAUSE_ON_FAIL="yes";; 165 - *) usage;; 166 - esac 167 - done 168 - 169 - setup_ns NS0 170 - 171 - set -e 172 - trap exit_cleanup_all EXIT 173 - 174 - setup_basenet 175 - 176 - test_gre4 177 - test_gre6
+246
tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0+ 3 + # 4 + # Author: Justin Iurman <justin.iurman@uliege.be> 5 + # 6 + # WARNING 7 + # ------- 8 + # This is just a dummy script that triggers encap cases with possible dst cache 9 + # reference loops in affected lwt users (see list below). Some cases are 10 + # pathological configurations for simplicity, others are valid. Overall, we 11 + # don't want this issue to happen, no matter what. In order to catch any 12 + # reference loops, kmemleak MUST be used. The results alone are always blindly 13 + # successful, don't rely on them. Note that the following tests may crash the 14 + # kernel if the fix to prevent lwtunnel_{input|output|xmit}() reentry loops is 15 + # not present. 16 + # 17 + # Affected lwt users so far (please update accordingly if needed): 18 + # - ila_lwt (output only) 19 + # - ioam6_iptunnel (output only) 20 + # - rpl_iptunnel (both input and output) 21 + # - seg6_iptunnel (both input and output) 22 + 23 + source lib.sh 24 + 25 + check_compatibility() 26 + { 27 + setup_ns tmp_node &>/dev/null 28 + if [ $? != 0 ]; then 29 + echo "SKIP: Cannot create netns." 30 + exit $ksft_skip 31 + fi 32 + 33 + ip link add name veth0 netns $tmp_node type veth \ 34 + peer name veth1 netns $tmp_node &>/dev/null 35 + local ret=$? 36 + 37 + ip -netns $tmp_node link set veth0 up &>/dev/null 38 + ret=$((ret + $?)) 39 + 40 + ip -netns $tmp_node link set veth1 up &>/dev/null 41 + ret=$((ret + $?)) 42 + 43 + if [ $ret != 0 ]; then 44 + echo "SKIP: Cannot configure links." 45 + cleanup_ns $tmp_node 46 + exit $ksft_skip 47 + fi 48 + 49 + lsmod 2>/dev/null | grep -q "ila" 50 + ila_lsmod=$? 51 + [ $ila_lsmod != 0 ] && modprobe ila &>/dev/null 52 + 53 + ip -netns $tmp_node route add 2001:db8:1::/64 \ 54 + encap ila 1:2:3:4 csum-mode no-action ident-type luid \ 55 + hook-type output \ 56 + dev veth0 &>/dev/null 57 + 58 + ip -netns $tmp_node route add 2001:db8:2::/64 \ 59 + encap ioam6 trace prealloc type 0x800000 ns 0 size 4 \ 60 + dev veth0 &>/dev/null 61 + 62 + ip -netns $tmp_node route add 2001:db8:3::/64 \ 63 + encap rpl segs 2001:db8:3::1 dev veth0 &>/dev/null 64 + 65 + ip -netns $tmp_node route add 2001:db8:4::/64 \ 66 + encap seg6 mode inline segs 2001:db8:4::1 dev veth0 &>/dev/null 67 + 68 + ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap ila" 69 + skip_ila=$? 70 + 71 + ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap ioam6" 72 + skip_ioam6=$? 73 + 74 + ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap rpl" 75 + skip_rpl=$? 76 + 77 + ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap seg6" 78 + skip_seg6=$? 79 + 80 + cleanup_ns $tmp_node 81 + } 82 + 83 + setup() 84 + { 85 + setup_ns alpha beta gamma &>/dev/null 86 + 87 + ip link add name veth-alpha netns $alpha type veth \ 88 + peer name veth-betaL netns $beta &>/dev/null 89 + 90 + ip link add name veth-betaR netns $beta type veth \ 91 + peer name veth-gamma netns $gamma &>/dev/null 92 + 93 + ip -netns $alpha link set veth-alpha name veth0 &>/dev/null 94 + ip -netns $beta link set veth-betaL name veth0 &>/dev/null 95 + ip -netns $beta link set veth-betaR name veth1 &>/dev/null 96 + ip -netns $gamma link set veth-gamma name veth0 &>/dev/null 97 + 98 + ip -netns $alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null 99 + ip -netns $alpha link set veth0 up &>/dev/null 100 + ip -netns $alpha link set lo up &>/dev/null 101 + ip -netns $alpha route add 2001:db8:2::/64 \ 102 + via 2001:db8:1::1 dev veth0 &>/dev/null 103 + 104 + ip -netns $beta addr add 2001:db8:1::1/64 dev veth0 &>/dev/null 105 + ip -netns $beta addr add 2001:db8:2::1/64 dev veth1 &>/dev/null 106 + ip -netns $beta link set veth0 up &>/dev/null 107 + ip -netns $beta link set veth1 up &>/dev/null 108 + ip -netns $beta link set lo up &>/dev/null 109 + ip -netns $beta route del 2001:db8:2::/64 110 + ip -netns $beta route add 2001:db8:2::/64 dev veth1 111 + ip netns exec $beta \ 112 + sysctl -wq net.ipv6.conf.all.forwarding=1 &>/dev/null 113 + 114 + ip -netns $gamma addr add 2001:db8:2::2/64 dev veth0 &>/dev/null 115 + ip -netns $gamma link set veth0 up &>/dev/null 116 + ip -netns $gamma link set lo up &>/dev/null 117 + ip -netns $gamma route add 2001:db8:1::/64 \ 118 + via 2001:db8:2::1 dev veth0 &>/dev/null 119 + 120 + sleep 1 121 + 122 + ip netns exec $alpha ping6 -c 5 -W 1 2001:db8:2::2 &>/dev/null 123 + if [ $? != 0 ]; then 124 + echo "SKIP: Setup failed." 125 + exit $ksft_skip 126 + fi 127 + 128 + sleep 1 129 + } 130 + 131 + cleanup() 132 + { 133 + cleanup_ns $alpha $beta $gamma 134 + [ $ila_lsmod != 0 ] && modprobe -r ila &>/dev/null 135 + } 136 + 137 + run_ila() 138 + { 139 + if [ $skip_ila != 0 ]; then 140 + echo "SKIP: ila (output)" 141 + return 142 + fi 143 + 144 + ip -netns $beta route del 2001:db8:2::/64 145 + ip -netns $beta route add 2001:db8:2:0:0:0:0:2/128 \ 146 + encap ila 2001:db8:2:0 csum-mode no-action ident-type luid \ 147 + hook-type output \ 148 + dev veth1 &>/dev/null 149 + sleep 1 150 + 151 + echo "TEST: ila (output)" 152 + ip netns exec $beta ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null 153 + sleep 1 154 + 155 + ip -netns $beta route del 2001:db8:2:0:0:0:0:2/128 156 + ip -netns $beta route add 2001:db8:2::/64 dev veth1 157 + sleep 1 158 + } 159 + 160 + run_ioam6() 161 + { 162 + if [ $skip_ioam6 != 0 ]; then 163 + echo "SKIP: ioam6 (output)" 164 + return 165 + fi 166 + 167 + ip -netns $beta route change 2001:db8:2::/64 \ 168 + encap ioam6 trace prealloc type 0x800000 ns 1 size 4 \ 169 + dev veth1 &>/dev/null 170 + sleep 1 171 + 172 + echo "TEST: ioam6 (output)" 173 + ip netns exec $beta ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null 174 + sleep 1 175 + } 176 + 177 + run_rpl() 178 + { 179 + if [ $skip_rpl != 0 ]; then 180 + echo "SKIP: rpl (input)" 181 + echo "SKIP: rpl (output)" 182 + return 183 + fi 184 + 185 + ip -netns $beta route change 2001:db8:2::/64 \ 186 + encap rpl segs 2001:db8:2::2 \ 187 + dev veth1 &>/dev/null 188 + sleep 1 189 + 190 + echo "TEST: rpl (input)" 191 + ip netns exec $alpha ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null 192 + sleep 1 193 + 194 + echo "TEST: rpl (output)" 195 + ip netns exec $beta ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null 196 + sleep 1 197 + } 198 + 199 + run_seg6() 200 + { 201 + if [ $skip_seg6 != 0 ]; then 202 + echo "SKIP: seg6 (input)" 203 + echo "SKIP: seg6 (output)" 204 + return 205 + fi 206 + 207 + ip -netns $beta route change 2001:db8:2::/64 \ 208 + encap seg6 mode inline segs 2001:db8:2::2 \ 209 + dev veth1 &>/dev/null 210 + sleep 1 211 + 212 + echo "TEST: seg6 (input)" 213 + ip netns exec $alpha ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null 214 + sleep 1 215 + 216 + echo "TEST: seg6 (output)" 217 + ip netns exec $beta ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null 218 + sleep 1 219 + } 220 + 221 + run() 222 + { 223 + run_ila 224 + run_ioam6 225 + run_rpl 226 + run_seg6 227 + } 228 + 229 + if [ "$(id -u)" -ne 0 ]; then 230 + echo "SKIP: Need root privileges." 231 + exit $ksft_skip 232 + fi 233 + 234 + if [ ! -x "$(command -v ip)" ]; then 235 + echo "SKIP: Could not run test without ip tool." 236 + exit $ksft_skip 237 + fi 238 + 239 + check_compatibility 240 + 241 + trap cleanup EXIT 242 + 243 + setup 244 + run 245 + 246 + exit $ksft_pass