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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller:

1) Fix crash on bpf_prog_load() errors, from Daniel Borkmann.

2) Fix ATM VCC memory accounting, from David Woodhouse.

3) fib6_info objects need RCU freeing, from Eric Dumazet.

4) Fix SO_BINDTODEVICE handling for TCP sockets, from David Ahern.

5) Fix clobbered error code in enic_open() failure path, from
Govindarajulu Varadarajan.

6) Propagate dev_get_valid_name() error returns properly, from Li
RongQing.

7) Fix suspend/resume in davinci_emac driver, from Bartosz Golaszewski.

8) Various act_ife fixes (recursive locking, IDR leaks, etc.) from
Davide Caratti.

9) Fix buggy checksum handling in sungem driver, from Eric Dumazet.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (40 commits)
ip: limit use of gso_size to udp
stmmac: fix DMA channel hang in half-duplex mode
net: stmmac: socfpga: add additional ocp reset line for Stratix10
net: sungem: fix rx checksum support
bpfilter: ignore binary files
bpfilter: fix build error
net/usb/drivers: Remove useless hrtimer_active check
net/sched: act_ife: preserve the action control in case of error
net/sched: act_ife: fix recursive lock and idr leak
net: ethernet: fix suspend/resume in davinci_emac
net: propagate dev_get_valid_name return code
enic: do not overwrite error code
net/tcp: Fix socket lookups with SO_BINDTODEVICE
ptp: replace getnstimeofday64() with ktime_get_real_ts64()
net/ipv6: respect rcu grace period before freeing fib6_info
net: net_failover: fix typo in net_failover_slave_register()
ipvlan: use ETH_MAX_MTU as max mtu
net: hamradio: use eth_broadcast_addr
enic: initialize enic->rfs_h.lock in enic_probe
MAINTAINERS: Add Sam as the maintainer for NCSI
...

+370 -194
+5
MAINTAINERS
··· 9751 9751 S: Maintained 9752 9752 F: drivers/scsi/NCR_D700.* 9753 9753 9754 + NCSI LIBRARY: 9755 + M: Samuel Mendoza-Jonas <sam@mendozajonas.com> 9756 + S: Maintained 9757 + F: net/ncsi/ 9758 + 9754 9759 NCT6775 HARDWARE MONITOR DRIVER 9755 9760 M: Guenter Roeck <linux@roeck-us.net> 9756 9761 L: linux-hwmon@vger.kernel.org
+1 -1
drivers/bluetooth/hci_nokia.c
··· 29 29 #include <linux/slab.h> 30 30 #include <linux/string.h> 31 31 #include <linux/types.h> 32 - #include <linux/unaligned/le_struct.h> 32 + #include <asm/unaligned.h> 33 33 #include <net/bluetooth/bluetooth.h> 34 34 #include <net/bluetooth/hci_core.h> 35 35
+1 -2
drivers/net/ethernet/cisco/enic/enic_clsf.c
··· 79 79 enic->rfs_h.max = enic->config.num_arfs; 80 80 enic->rfs_h.free = enic->rfs_h.max; 81 81 enic->rfs_h.toclean = 0; 82 - enic_rfs_timer_start(enic); 83 82 } 84 83 85 84 void enic_rfs_flw_tbl_free(struct enic *enic) ··· 87 88 88 89 enic_rfs_timer_stop(enic); 89 90 spin_lock_bh(&enic->rfs_h.lock); 90 - enic->rfs_h.free = 0; 91 91 for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) { 92 92 struct hlist_head *hhead; 93 93 struct hlist_node *tmp; ··· 97 99 enic_delfltr(enic, n->fltr_id); 98 100 hlist_del(&n->node); 99 101 kfree(n); 102 + enic->rfs_h.free++; 100 103 } 101 104 } 102 105 spin_unlock_bh(&enic->rfs_h.lock);
+6 -6
drivers/net/ethernet/cisco/enic/enic_main.c
··· 1920 1920 { 1921 1921 struct enic *enic = netdev_priv(netdev); 1922 1922 unsigned int i; 1923 - int err; 1923 + int err, ret; 1924 1924 1925 1925 err = enic_request_intr(enic); 1926 1926 if (err) { ··· 1971 1971 vnic_intr_unmask(&enic->intr[i]); 1972 1972 1973 1973 enic_notify_timer_start(enic); 1974 - enic_rfs_flw_tbl_init(enic); 1974 + enic_rfs_timer_start(enic); 1975 1975 1976 1976 return 0; 1977 1977 1978 1978 err_out_free_rq: 1979 1979 for (i = 0; i < enic->rq_count; i++) { 1980 - err = vnic_rq_disable(&enic->rq[i]); 1981 - if (err) 1982 - return err; 1983 - vnic_rq_clean(&enic->rq[i], enic_free_rq_buf); 1980 + ret = vnic_rq_disable(&enic->rq[i]); 1981 + if (!ret) 1982 + vnic_rq_clean(&enic->rq[i], enic_free_rq_buf); 1984 1983 } 1985 1984 enic_dev_notify_unset(enic); 1986 1985 err_out_free_intr: ··· 2903 2904 2904 2905 timer_setup(&enic->notify_timer, enic_notify_timer, 0); 2905 2906 2907 + enic_rfs_flw_tbl_init(enic); 2906 2908 enic_set_rx_coal_setting(enic); 2907 2909 INIT_WORK(&enic->reset, enic_reset); 2908 2910 INIT_WORK(&enic->tx_hang_reset, enic_tx_hang_reset);
+2 -2
drivers/net/ethernet/faraday/ftgmac100.c
··· 1735 1735 if (unlikely(nd->state != ncsi_dev_state_functional)) 1736 1736 return; 1737 1737 1738 - netdev_info(nd->dev, "NCSI interface %s\n", 1739 - nd->link_up ? "up" : "down"); 1738 + netdev_dbg(nd->dev, "NCSI interface %s\n", 1739 + nd->link_up ? "up" : "down"); 1740 1740 } 1741 1741 1742 1742 static void ftgmac100_setup_clk(struct ftgmac100 *priv)
+3 -4
drivers/net/ethernet/intel/i40e/i40e_txrx.c
··· 2103 2103 unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2; 2104 2104 #else 2105 2105 unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + 2106 - SKB_DATA_ALIGN(I40E_SKB_PAD + 2107 - (xdp->data_end - 2108 - xdp->data_hard_start)); 2106 + SKB_DATA_ALIGN(xdp->data_end - 2107 + xdp->data_hard_start); 2109 2108 #endif 2110 2109 struct sk_buff *skb; 2111 2110 ··· 2123 2124 return NULL; 2124 2125 2125 2126 /* update pointers within the skb to store the data */ 2126 - skb_reserve(skb, I40E_SKB_PAD + (xdp->data - xdp->data_hard_start)); 2127 + skb_reserve(skb, xdp->data - xdp->data_hard_start); 2127 2128 __skb_put(skb, xdp->data_end - xdp->data); 2128 2129 if (metasize) 2129 2130 skb_metadata_set(skb, metasize);
+4 -7
drivers/net/ethernet/qlogic/qed/qed_dcbx.c
··· 255 255 *type = DCBX_PROTOCOL_ROCE_V2; 256 256 } else { 257 257 *type = DCBX_MAX_PROTOCOL_TYPE; 258 - DP_ERR(p_hwfn, 259 - "No action required, App TLV id = 0x%x app_prio_bitmap = 0x%x\n", 260 - id, app_prio_bitmap); 258 + DP_ERR(p_hwfn, "No action required, App TLV entry = 0x%x\n", 259 + app_prio_bitmap); 261 260 return false; 262 261 } 263 262 ··· 1478 1479 *cap = 0x80; 1479 1480 break; 1480 1481 case DCB_CAP_ATTR_DCBX: 1481 - *cap = (DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_CEE | 1482 - DCB_CAP_DCBX_VER_IEEE | DCB_CAP_DCBX_STATIC); 1482 + *cap = (DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_VER_IEEE | 1483 + DCB_CAP_DCBX_STATIC); 1483 1484 break; 1484 1485 default: 1485 1486 *cap = false; ··· 1547 1548 if (!dcbx_info) 1548 1549 return 0; 1549 1550 1550 - if (dcbx_info->operational.enabled) 1551 - mode |= DCB_CAP_DCBX_LLD_MANAGED; 1552 1551 if (dcbx_info->operational.ieee) 1553 1552 mode |= DCB_CAP_DCBX_VER_IEEE; 1554 1553 if (dcbx_info->operational.cee)
+9 -2
drivers/net/ethernet/qlogic/qed/qed_ll2.c
··· 201 201 202 202 skb = build_skb(buffer->data, 0); 203 203 if (!skb) { 204 - rc = -ENOMEM; 205 - goto out_post; 204 + DP_INFO(cdev, "Failed to build SKB\n"); 205 + kfree(buffer->data); 206 + goto out_post1; 206 207 } 207 208 208 209 data->u.placement_offset += NET_SKB_PAD; ··· 225 224 cdev->ll2->cbs->rx_cb(cdev->ll2->cb_cookie, skb, 226 225 data->opaque_data_0, 227 226 data->opaque_data_1); 227 + } else { 228 + DP_VERBOSE(p_hwfn, (NETIF_MSG_RX_STATUS | NETIF_MSG_PKTDATA | 229 + QED_MSG_LL2 | QED_MSG_STORAGE), 230 + "Dropping the packet\n"); 231 + kfree(buffer->data); 228 232 } 229 233 234 + out_post1: 230 235 /* Update Buffer information and update FW producer */ 231 236 buffer->data = new_data; 232 237 buffer->phys_addr = new_phys_addr;
+10 -2
drivers/net/ethernet/qlogic/qed/qed_main.c
··· 567 567 /* Fastpath interrupts */ 568 568 for (j = 0; j < 64; j++) { 569 569 if ((0x2ULL << j) & status) { 570 - hwfn->simd_proto_handler[j].func( 571 - hwfn->simd_proto_handler[j].token); 570 + struct qed_simd_fp_handler *p_handler = 571 + &hwfn->simd_proto_handler[j]; 572 + 573 + if (p_handler->func) 574 + p_handler->func(p_handler->token); 575 + else 576 + DP_NOTICE(hwfn, 577 + "Not calling fastpath handler as it is NULL [handler #%d, status 0x%llx]\n", 578 + j, status); 579 + 572 580 status &= ~(0x2ULL << j); 573 581 rc = IRQ_HANDLED; 574 582 }
+1 -1
drivers/net/ethernet/stmicro/stmmac/Kconfig
··· 111 111 config DWMAC_SOCFPGA 112 112 tristate "SOCFPGA dwmac support" 113 113 default ARCH_SOCFPGA 114 - depends on OF && (ARCH_SOCFPGA || COMPILE_TEST) 114 + depends on OF && (ARCH_SOCFPGA || ARCH_STRATIX10 || COMPILE_TEST) 115 115 select MFD_SYSCON 116 116 help 117 117 Support for ethernet controller on Altera SOCFPGA
+14 -4
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
··· 55 55 struct device *dev; 56 56 struct regmap *sys_mgr_base_addr; 57 57 struct reset_control *stmmac_rst; 58 + struct reset_control *stmmac_ocp_rst; 58 59 void __iomem *splitter_base; 59 60 bool f2h_ptp_ref_clk; 60 61 struct tse_pcs pcs; ··· 263 262 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII; 264 263 265 264 /* Assert reset to the enet controller before changing the phy mode */ 266 - if (dwmac->stmmac_rst) 267 - reset_control_assert(dwmac->stmmac_rst); 265 + reset_control_assert(dwmac->stmmac_ocp_rst); 266 + reset_control_assert(dwmac->stmmac_rst); 268 267 269 268 regmap_read(sys_mgr_base_addr, reg_offset, &ctrl); 270 269 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift); ··· 289 288 /* Deassert reset for the phy configuration to be sampled by 290 289 * the enet controller, and operation to start in requested mode 291 290 */ 292 - if (dwmac->stmmac_rst) 293 - reset_control_deassert(dwmac->stmmac_rst); 291 + reset_control_deassert(dwmac->stmmac_ocp_rst); 292 + reset_control_deassert(dwmac->stmmac_rst); 294 293 if (phymode == PHY_INTERFACE_MODE_SGMII) { 295 294 if (tse_pcs_init(dwmac->pcs.tse_pcs_base, &dwmac->pcs) != 0) { 296 295 dev_err(dwmac->dev, "Unable to initialize TSE PCS"); ··· 324 323 ret = -ENOMEM; 325 324 goto err_remove_config_dt; 326 325 } 326 + 327 + dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp"); 328 + if (IS_ERR(dwmac->stmmac_ocp_rst)) { 329 + ret = PTR_ERR(dwmac->stmmac_ocp_rst); 330 + dev_err(dev, "error getting reset control of ocp %d\n", ret); 331 + goto err_remove_config_dt; 332 + } 333 + 334 + reset_control_deassert(dwmac->stmmac_ocp_rst); 327 335 328 336 ret = socfpga_dwmac_parse_data(dwmac, dev); 329 337 if (ret) {
+10
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 928 928 static int stmmac_init_phy(struct net_device *dev) 929 929 { 930 930 struct stmmac_priv *priv = netdev_priv(dev); 931 + u32 tx_cnt = priv->plat->tx_queues_to_use; 931 932 struct phy_device *phydev; 932 933 char phy_id_fmt[MII_BUS_ID_SIZE + 3]; 933 934 char bus_id[MII_BUS_ID_SIZE]; ··· 968 967 (max_speed < 1000 && max_speed > 0)) 969 968 phydev->advertising &= ~(SUPPORTED_1000baseT_Half | 970 969 SUPPORTED_1000baseT_Full); 970 + 971 + /* 972 + * Half-duplex mode not supported with multiqueue 973 + * half-duplex can only works with single queue 974 + */ 975 + if (tx_cnt > 1) 976 + phydev->supported &= ~(SUPPORTED_1000baseT_Half | 977 + SUPPORTED_100baseT_Half | 978 + SUPPORTED_10baseT_Half); 971 979 972 980 /* 973 981 * Broken HW is sometimes missing the pull-up resistor on the
+12 -10
drivers/net/ethernet/sun/sungem.c
··· 60 60 #include <linux/sungem_phy.h> 61 61 #include "sungem.h" 62 62 63 - /* Stripping FCS is causing problems, disabled for now */ 64 - #undef STRIP_FCS 63 + #define STRIP_FCS 65 64 66 65 #define DEFAULT_MSG (NETIF_MSG_DRV | \ 67 66 NETIF_MSG_PROBE | \ ··· 434 435 writel(desc_dma & 0xffffffff, gp->regs + RXDMA_DBLOW); 435 436 writel(RX_RING_SIZE - 4, gp->regs + RXDMA_KICK); 436 437 val = (RXDMA_CFG_BASE | (RX_OFFSET << 10) | 437 - ((14 / 2) << 13) | RXDMA_CFG_FTHRESH_128); 438 + (ETH_HLEN << 13) | RXDMA_CFG_FTHRESH_128); 438 439 writel(val, gp->regs + RXDMA_CFG); 439 440 if (readl(gp->regs + GREG_BIFCFG) & GREG_BIFCFG_M66EN) 440 441 writel(((5 & RXDMA_BLANK_IPKTS) | ··· 759 760 struct net_device *dev = gp->dev; 760 761 int entry, drops, work_done = 0; 761 762 u32 done; 762 - __sum16 csum; 763 763 764 764 if (netif_msg_rx_status(gp)) 765 765 printk(KERN_DEBUG "%s: rx interrupt, done: %d, rx_new: %d\n", ··· 853 855 skb = copy_skb; 854 856 } 855 857 856 - csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 0xffff); 857 - skb->csum = csum_unfold(csum); 858 - skb->ip_summed = CHECKSUM_COMPLETE; 858 + if (likely(dev->features & NETIF_F_RXCSUM)) { 859 + __sum16 csum; 860 + 861 + csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 0xffff); 862 + skb->csum = csum_unfold(csum); 863 + skb->ip_summed = CHECKSUM_COMPLETE; 864 + } 859 865 skb->protocol = eth_type_trans(skb, gp->dev); 860 866 861 867 napi_gro_receive(&gp->napi, skb); ··· 1763 1761 writel(0, gp->regs + TXDMA_KICK); 1764 1762 1765 1763 val = (RXDMA_CFG_BASE | (RX_OFFSET << 10) | 1766 - ((14 / 2) << 13) | RXDMA_CFG_FTHRESH_128); 1764 + (ETH_HLEN << 13) | RXDMA_CFG_FTHRESH_128); 1767 1765 writel(val, gp->regs + RXDMA_CFG); 1768 1766 1769 1767 writel(desc_dma >> 32, gp->regs + RXDMA_DBHI); ··· 2987 2985 pci_set_drvdata(pdev, dev); 2988 2986 2989 2987 /* We can do scatter/gather and HW checksum */ 2990 - dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM; 2991 - dev->features |= dev->hw_features | NETIF_F_RXCSUM; 2988 + dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM; 2989 + dev->features = dev->hw_features; 2992 2990 if (pci_using_dac) 2993 2991 dev->features |= NETIF_F_HIGHDMA; 2994 2992
+13 -2
drivers/net/ethernet/ti/davinci_emac.c
··· 1385 1385 return -EOPNOTSUPP; 1386 1386 } 1387 1387 1388 + static int match_first_device(struct device *dev, void *data) 1389 + { 1390 + return !strncmp(dev_name(dev), "davinci_mdio", 12); 1391 + } 1392 + 1388 1393 /** 1389 1394 * emac_dev_open - EMAC device open 1390 1395 * @ndev: The DaVinci EMAC network adapter ··· 1489 1484 1490 1485 /* use the first phy on the bus if pdata did not give us a phy id */ 1491 1486 if (!phydev && !priv->phy_id) { 1492 - phy = bus_find_device_by_name(&mdio_bus_type, NULL, 1493 - "davinci_mdio"); 1487 + /* NOTE: we can't use bus_find_device_by_name() here because 1488 + * the device name is not guaranteed to be 'davinci_mdio'. On 1489 + * some systems it can be 'davinci_mdio.0' so we need to use 1490 + * strncmp() against the first part of the string to correctly 1491 + * match it. 1492 + */ 1493 + phy = bus_find_device(&mdio_bus_type, NULL, NULL, 1494 + match_first_device); 1494 1495 if (phy) { 1495 1496 priv->phy_id = dev_name(phy); 1496 1497 if (!priv->phy_id || !*priv->phy_id)
+2 -6
drivers/net/hamradio/bpqether.c
··· 89 89 static const char banner[] __initconst = KERN_INFO \ 90 90 "AX.25: bpqether driver version 004\n"; 91 91 92 - static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; 93 - 94 - static char bpq_eth_addr[6]; 95 - 96 92 static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); 97 93 static int bpq_device_event(struct notifier_block *, unsigned long, void *); 98 94 ··· 497 501 bpq->ethdev = edev; 498 502 bpq->axdev = ndev; 499 503 500 - memcpy(bpq->dest_addr, bcast_addr, sizeof(bpq_eth_addr)); 501 - memcpy(bpq->acpt_addr, bcast_addr, sizeof(bpq_eth_addr)); 504 + eth_broadcast_addr(bpq->dest_addr); 505 + eth_broadcast_addr(bpq->acpt_addr); 502 506 503 507 err = register_netdevice(ndev); 504 508 if (err)
+1
drivers/net/ipvlan/ipvlan_main.c
··· 693 693 { 694 694 ether_setup(dev); 695 695 696 + dev->max_mtu = ETH_MAX_MTU; 696 697 dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); 697 698 dev->priv_flags |= IFF_UNICAST_FLT | IFF_NO_QUEUE; 698 699 dev->netdev_ops = &ipvlan_netdev_ops;
+1 -1
drivers/net/net_failover.c
··· 527 527 528 528 netif_addr_lock_bh(failover_dev); 529 529 dev_uc_sync_multiple(slave_dev, failover_dev); 530 - dev_uc_sync_multiple(slave_dev, failover_dev); 530 + dev_mc_sync_multiple(slave_dev, failover_dev); 531 531 netif_addr_unlock_bh(failover_dev); 532 532 533 533 err = vlan_vids_add_by_dev(slave_dev, failover_dev);
+1 -2
drivers/net/usb/cdc_ncm.c
··· 967 967 968 968 atomic_set(&ctx->stop, 1); 969 969 970 - if (hrtimer_active(&ctx->tx_timer)) 971 - hrtimer_cancel(&ctx->tx_timer); 970 + hrtimer_cancel(&ctx->tx_timer); 972 971 973 972 tasklet_kill(&ctx->bh); 974 973
+2 -2
drivers/ptp/ptp_chardev.c
··· 221 221 } 222 222 pct = &sysoff->ts[0]; 223 223 for (i = 0; i < sysoff->n_samples; i++) { 224 - getnstimeofday64(&ts); 224 + ktime_get_real_ts64(&ts); 225 225 pct->sec = ts.tv_sec; 226 226 pct->nsec = ts.tv_nsec; 227 227 pct++; ··· 230 230 pct->nsec = ts.tv_nsec; 231 231 pct++; 232 232 } 233 - getnstimeofday64(&ts); 233 + ktime_get_real_ts64(&ts); 234 234 pct->sec = ts.tv_sec; 235 235 pct->nsec = ts.tv_nsec; 236 236 if (copy_to_user((void __user *)arg, sysoff, sizeof(*sysoff)))
+1 -1
drivers/ptp/ptp_qoriq.c
··· 374 374 pr_err("ioremap ptp registers failed\n"); 375 375 goto no_ioremap; 376 376 } 377 - getnstimeofday64(&now); 377 + ktime_get_real_ts64(&now); 378 378 ptp_qoriq_settime(&qoriq_ptp->caps, &now); 379 379 380 380 tmr_ctrl =
+15
include/linux/atmdev.h
··· 214 214 struct atm_skb_data { 215 215 struct atm_vcc *vcc; /* ATM VCC */ 216 216 unsigned long atm_options; /* ATM layer options */ 217 + unsigned int acct_truesize; /* truesize accounted to vcc */ 217 218 }; 218 219 219 220 #define VCC_HTABLE_SIZE 32 ··· 242 241 243 242 void atm_dev_release_vccs(struct atm_dev *dev); 244 243 244 + static inline void atm_account_tx(struct atm_vcc *vcc, struct sk_buff *skb) 245 + { 246 + /* 247 + * Because ATM skbs may not belong to a sock (and we don't 248 + * necessarily want to), skb->truesize may be adjusted, 249 + * escaping the hack in pskb_expand_head() which avoids 250 + * doing so for some cases. So stash the value of truesize 251 + * at the time we accounted it, and atm_pop_raw() can use 252 + * that value later, in case it changes. 253 + */ 254 + refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); 255 + ATM_SKB(skb)->acct_truesize = skb->truesize; 256 + ATM_SKB(skb)->atm_options = vcc->atm_options; 257 + } 245 258 246 259 static inline void atm_force_charge(struct atm_vcc *vcc,int truesize) 247 260 {
+12
include/linux/bpf.h
··· 488 488 489 489 /* Map specifics */ 490 490 struct xdp_buff; 491 + struct sk_buff; 491 492 492 493 struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key); 493 494 void __dev_map_insert_ctx(struct bpf_map *map, u32 index); 494 495 void __dev_map_flush(struct bpf_map *map); 495 496 int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp, 496 497 struct net_device *dev_rx); 498 + int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb, 499 + struct bpf_prog *xdp_prog); 497 500 498 501 struct bpf_cpu_map_entry *__cpu_map_lookup_elem(struct bpf_map *map, u32 key); 499 502 void __cpu_map_insert_ctx(struct bpf_map *map, u32 index); ··· 585 582 static inline 586 583 int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp, 587 584 struct net_device *dev_rx) 585 + { 586 + return 0; 587 + } 588 + 589 + struct sk_buff; 590 + 591 + static inline int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, 592 + struct sk_buff *skb, 593 + struct bpf_prog *xdp_prog) 588 594 { 589 595 return 0; 590 596 }
+57 -22
include/linux/filter.h
··· 19 19 #include <linux/cryptohash.h> 20 20 #include <linux/set_memory.h> 21 21 #include <linux/kallsyms.h> 22 + #include <linux/if_vlan.h> 22 23 23 24 #include <net/sch_generic.h> 24 25 ··· 470 469 }; 471 470 472 471 struct bpf_binary_header { 473 - unsigned int pages; 472 + u16 pages; 473 + u16 locked:1; 474 474 u8 image[]; 475 475 }; 476 476 ··· 673 671 674 672 #define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0])) 675 673 676 - #ifdef CONFIG_ARCH_HAS_SET_MEMORY 677 674 static inline void bpf_prog_lock_ro(struct bpf_prog *fp) 678 675 { 676 + #ifdef CONFIG_ARCH_HAS_SET_MEMORY 679 677 fp->locked = 1; 680 - WARN_ON_ONCE(set_memory_ro((unsigned long)fp, fp->pages)); 678 + if (set_memory_ro((unsigned long)fp, fp->pages)) 679 + fp->locked = 0; 680 + #endif 681 681 } 682 682 683 683 static inline void bpf_prog_unlock_ro(struct bpf_prog *fp) 684 684 { 685 + #ifdef CONFIG_ARCH_HAS_SET_MEMORY 685 686 if (fp->locked) { 686 687 WARN_ON_ONCE(set_memory_rw((unsigned long)fp, fp->pages)); 687 688 /* In case set_memory_rw() fails, we want to be the first ··· 692 687 */ 693 688 fp->locked = 0; 694 689 } 690 + #endif 695 691 } 696 692 697 693 static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr) 698 694 { 699 - WARN_ON_ONCE(set_memory_ro((unsigned long)hdr, hdr->pages)); 695 + #ifdef CONFIG_ARCH_HAS_SET_MEMORY 696 + hdr->locked = 1; 697 + if (set_memory_ro((unsigned long)hdr, hdr->pages)) 698 + hdr->locked = 0; 699 + #endif 700 700 } 701 701 702 702 static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr) 703 703 { 704 - WARN_ON_ONCE(set_memory_rw((unsigned long)hdr, hdr->pages)); 704 + #ifdef CONFIG_ARCH_HAS_SET_MEMORY 705 + if (hdr->locked) { 706 + WARN_ON_ONCE(set_memory_rw((unsigned long)hdr, hdr->pages)); 707 + /* In case set_memory_rw() fails, we want to be the first 708 + * to crash here instead of some random place later on. 709 + */ 710 + hdr->locked = 0; 711 + } 712 + #endif 705 713 } 706 - #else 707 - static inline void bpf_prog_lock_ro(struct bpf_prog *fp) 708 - { 709 - } 710 - 711 - static inline void bpf_prog_unlock_ro(struct bpf_prog *fp) 712 - { 713 - } 714 - 715 - static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr) 716 - { 717 - } 718 - 719 - static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr) 720 - { 721 - } 722 - #endif /* CONFIG_ARCH_HAS_SET_MEMORY */ 723 714 724 715 static inline struct bpf_binary_header * 725 716 bpf_jit_binary_hdr(const struct bpf_prog *fp) ··· 725 724 726 725 return (void *)addr; 727 726 } 727 + 728 + #ifdef CONFIG_ARCH_HAS_SET_MEMORY 729 + static inline int bpf_prog_check_pages_ro_single(const struct bpf_prog *fp) 730 + { 731 + if (!fp->locked) 732 + return -ENOLCK; 733 + if (fp->jited) { 734 + const struct bpf_binary_header *hdr = bpf_jit_binary_hdr(fp); 735 + 736 + if (!hdr->locked) 737 + return -ENOLCK; 738 + } 739 + 740 + return 0; 741 + } 742 + #endif 728 743 729 744 int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, unsigned int cap); 730 745 static inline int sk_filter(struct sock *sk, struct sk_buff *skb) ··· 802 785 803 786 struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off, 804 787 const struct bpf_insn *patch, u32 len); 788 + 789 + static inline int __xdp_generic_ok_fwd_dev(struct sk_buff *skb, 790 + struct net_device *fwd) 791 + { 792 + unsigned int len; 793 + 794 + if (unlikely(!(fwd->flags & IFF_UP))) 795 + return -ENETDOWN; 796 + 797 + len = fwd->mtu + fwd->hard_header_len + VLAN_HLEN; 798 + if (skb->len > len) 799 + return -EMSGSIZE; 800 + 801 + return 0; 802 + } 805 803 806 804 /* The pair of xdp_do_redirect and xdp_do_flush_map MUST be called in the 807 805 * same cpu context. Further for best results no more than a single map ··· 992 960 { 993 961 } 994 962 #endif /* CONFIG_BPF_JIT */ 963 + 964 + void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp); 965 + void bpf_prog_kallsyms_del_all(struct bpf_prog *fp); 995 966 996 967 #define BPF_ANC BIT(15) 997 968
+3 -2
include/net/ip6_fib.h
··· 170 170 unused:3; 171 171 172 172 struct fib6_nh fib6_nh; 173 + struct rcu_head rcu; 173 174 }; 174 175 175 176 struct rt6_info { ··· 274 273 } 275 274 276 275 struct fib6_info *fib6_info_alloc(gfp_t gfp_flags); 277 - void fib6_info_destroy(struct fib6_info *f6i); 276 + void fib6_info_destroy_rcu(struct rcu_head *head); 278 277 279 278 static inline void fib6_info_hold(struct fib6_info *f6i) 280 279 { ··· 284 283 static inline void fib6_info_release(struct fib6_info *f6i) 285 284 { 286 285 if (f6i && atomic_dec_and_test(&f6i->fib6_ref)) 287 - fib6_info_destroy(f6i); 286 + call_rcu(&f6i->rcu, fib6_info_destroy_rcu); 288 287 } 289 288 290 289 enum fib6_walk_state {
+61 -6
kernel/bpf/core.c
··· 350 350 return prog_adj; 351 351 } 352 352 353 + void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp) 354 + { 355 + int i; 356 + 357 + for (i = 0; i < fp->aux->func_cnt; i++) 358 + bpf_prog_kallsyms_del(fp->aux->func[i]); 359 + } 360 + 361 + void bpf_prog_kallsyms_del_all(struct bpf_prog *fp) 362 + { 363 + bpf_prog_kallsyms_del_subprogs(fp); 364 + bpf_prog_kallsyms_del(fp); 365 + } 366 + 353 367 #ifdef CONFIG_BPF_JIT 354 368 /* All BPF JIT sysctl knobs here. */ 355 369 int bpf_jit_enable __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_ALWAYS_ON); ··· 598 584 bpf_fill_ill_insns(hdr, size); 599 585 600 586 hdr->pages = size / PAGE_SIZE; 587 + hdr->locked = 0; 588 + 601 589 hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)), 602 590 PAGE_SIZE - sizeof(*hdr)); 603 591 start = (get_random_int() % hole) & ~(alignment - 1); ··· 1450 1434 return 0; 1451 1435 } 1452 1436 1437 + static int bpf_prog_check_pages_ro_locked(const struct bpf_prog *fp) 1438 + { 1439 + #ifdef CONFIG_ARCH_HAS_SET_MEMORY 1440 + int i, err; 1441 + 1442 + for (i = 0; i < fp->aux->func_cnt; i++) { 1443 + err = bpf_prog_check_pages_ro_single(fp->aux->func[i]); 1444 + if (err) 1445 + return err; 1446 + } 1447 + 1448 + return bpf_prog_check_pages_ro_single(fp); 1449 + #endif 1450 + return 0; 1451 + } 1452 + 1453 + static void bpf_prog_select_func(struct bpf_prog *fp) 1454 + { 1455 + #ifndef CONFIG_BPF_JIT_ALWAYS_ON 1456 + u32 stack_depth = max_t(u32, fp->aux->stack_depth, 1); 1457 + 1458 + fp->bpf_func = interpreters[(round_up(stack_depth, 32) / 32) - 1]; 1459 + #else 1460 + fp->bpf_func = __bpf_prog_ret0_warn; 1461 + #endif 1462 + } 1463 + 1453 1464 /** 1454 1465 * bpf_prog_select_runtime - select exec runtime for BPF program 1455 1466 * @fp: bpf_prog populated with internal BPF program ··· 1487 1444 */ 1488 1445 struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err) 1489 1446 { 1490 - #ifndef CONFIG_BPF_JIT_ALWAYS_ON 1491 - u32 stack_depth = max_t(u32, fp->aux->stack_depth, 1); 1447 + /* In case of BPF to BPF calls, verifier did all the prep 1448 + * work with regards to JITing, etc. 1449 + */ 1450 + if (fp->bpf_func) 1451 + goto finalize; 1492 1452 1493 - fp->bpf_func = interpreters[(round_up(stack_depth, 32) / 32) - 1]; 1494 - #else 1495 - fp->bpf_func = __bpf_prog_ret0_warn; 1496 - #endif 1453 + bpf_prog_select_func(fp); 1497 1454 1498 1455 /* eBPF JITs can rewrite the program in case constant 1499 1456 * blinding is active. However, in case of error during ··· 1514 1471 if (*err) 1515 1472 return fp; 1516 1473 } 1474 + 1475 + finalize: 1517 1476 bpf_prog_lock_ro(fp); 1518 1477 1519 1478 /* The tail call compatibility check can only be done at ··· 1524 1479 * all eBPF JITs might immediately support all features. 1525 1480 */ 1526 1481 *err = bpf_check_tail_call(fp); 1482 + if (*err) 1483 + return fp; 1527 1484 1485 + /* Checkpoint: at this point onwards any cBPF -> eBPF or 1486 + * native eBPF program is read-only. If we failed to change 1487 + * the page attributes (e.g. allocation failure from 1488 + * splitting large pages), then reject the whole program 1489 + * in order to guarantee not ending up with any W+X pages 1490 + * from BPF side in kernel. 1491 + */ 1492 + *err = bpf_prog_check_pages_ro_locked(fp); 1528 1493 return fp; 1529 1494 } 1530 1495 EXPORT_SYMBOL_GPL(bpf_prog_select_runtime);
+14
kernel/bpf/devmap.c
··· 345 345 return bq_enqueue(dst, xdpf, dev_rx); 346 346 } 347 347 348 + int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb, 349 + struct bpf_prog *xdp_prog) 350 + { 351 + int err; 352 + 353 + err = __xdp_generic_ok_fwd_dev(skb, dst->dev); 354 + if (unlikely(err)) 355 + return err; 356 + skb->dev = dst->dev; 357 + generic_xdp_tx(skb, xdp_prog); 358 + 359 + return 0; 360 + } 361 + 348 362 static void *dev_map_lookup_elem(struct bpf_map *map, void *key) 349 363 { 350 364 struct bpf_dtab_netdev *obj = __dev_map_lookup_elem(map, *(u32 *)key);
+3 -9
kernel/bpf/syscall.c
··· 1034 1034 static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock) 1035 1035 { 1036 1036 if (atomic_dec_and_test(&prog->aux->refcnt)) { 1037 - int i; 1038 - 1039 1037 /* bpf_prog_free_id() must be called first */ 1040 1038 bpf_prog_free_id(prog, do_idr_lock); 1041 - 1042 - for (i = 0; i < prog->aux->func_cnt; i++) 1043 - bpf_prog_kallsyms_del(prog->aux->func[i]); 1044 - bpf_prog_kallsyms_del(prog); 1039 + bpf_prog_kallsyms_del_all(prog); 1045 1040 1046 1041 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); 1047 1042 } ··· 1353 1358 if (err < 0) 1354 1359 goto free_used_maps; 1355 1360 1356 - /* eBPF program is ready to be JITed */ 1357 - if (!prog->bpf_func) 1358 - prog = bpf_prog_select_runtime(prog, &err); 1361 + prog = bpf_prog_select_runtime(prog, &err); 1359 1362 if (err < 0) 1360 1363 goto free_used_maps; 1361 1364 ··· 1377 1384 return err; 1378 1385 1379 1386 free_used_maps: 1387 + bpf_prog_kallsyms_del_subprogs(prog); 1380 1388 free_used_maps(prog->aux); 1381 1389 free_prog: 1382 1390 bpf_prog_uncharge_memlock(prog);
+1 -2
net/atm/br2684.c
··· 252 252 253 253 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc; 254 254 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev); 255 - refcount_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); 256 - ATM_SKB(skb)->atm_options = atmvcc->atm_options; 255 + atm_account_tx(atmvcc, skb); 257 256 dev->stats.tx_packets++; 258 257 dev->stats.tx_bytes += skb->len; 259 258
+1 -2
net/atm/clip.c
··· 381 381 memcpy(here, llc_oui, sizeof(llc_oui)); 382 382 ((__be16 *) here)[3] = skb->protocol; 383 383 } 384 - refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); 385 - ATM_SKB(skb)->atm_options = vcc->atm_options; 384 + atm_account_tx(vcc, skb); 386 385 entry->vccs->last_use = jiffies; 387 386 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev); 388 387 old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */
+1 -2
net/atm/common.c
··· 630 630 goto out; 631 631 } 632 632 pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize); 633 - refcount_add(skb->truesize, &sk->sk_wmem_alloc); 633 + atm_account_tx(vcc, skb); 634 634 635 635 skb->dev = NULL; /* for paths shared with net_device interfaces */ 636 - ATM_SKB(skb)->atm_options = vcc->atm_options; 637 636 if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) { 638 637 kfree_skb(skb); 639 638 error = -EFAULT;
+1 -2
net/atm/lec.c
··· 182 182 struct net_device *dev = skb->dev; 183 183 184 184 ATM_SKB(skb)->vcc = vcc; 185 - ATM_SKB(skb)->atm_options = vcc->atm_options; 185 + atm_account_tx(vcc, skb); 186 186 187 - refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); 188 187 if (vcc->send(vcc, skb) < 0) { 189 188 dev->stats.tx_dropped++; 190 189 return;
+1 -2
net/atm/mpc.c
··· 555 555 sizeof(struct llc_snap_hdr)); 556 556 } 557 557 558 - refcount_add(skb->truesize, &sk_atm(entry->shortcut)->sk_wmem_alloc); 559 - ATM_SKB(skb)->atm_options = entry->shortcut->atm_options; 558 + atm_account_tx(entry->shortcut, skb); 560 559 entry->shortcut->send(entry->shortcut, skb); 561 560 entry->packets_fwded++; 562 561 mpc->in_ops->put(entry);
+1 -2
net/atm/pppoatm.c
··· 350 350 return 1; 351 351 } 352 352 353 - refcount_add(skb->truesize, &sk_atm(ATM_SKB(skb)->vcc)->sk_wmem_alloc); 354 - ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options; 353 + atm_account_tx(vcc, skb); 355 354 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", 356 355 skb, ATM_SKB(skb)->vcc, ATM_SKB(skb)->vcc->dev); 357 356 ret = ATM_SKB(skb)->vcc->send(ATM_SKB(skb)->vcc, skb)
+2 -2
net/atm/raw.c
··· 35 35 struct sock *sk = sk_atm(vcc); 36 36 37 37 pr_debug("(%d) %d -= %d\n", 38 - vcc->vci, sk_wmem_alloc_get(sk), skb->truesize); 39 - WARN_ON(refcount_sub_and_test(skb->truesize, &sk->sk_wmem_alloc)); 38 + vcc->vci, sk_wmem_alloc_get(sk), ATM_SKB(skb)->acct_truesize); 39 + WARN_ON(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize, &sk->sk_wmem_alloc)); 40 40 dev_kfree_skb_any(skb); 41 41 sk->sk_write_space(sk); 42 42 }
+1
net/bpfilter/.gitignore
··· 1 + bpfilter_umh
+4 -2
net/bpfilter/Makefile
··· 21 21 # which bpfilter_kern.c passes further into umh blob loader at run-time 22 22 quiet_cmd_copy_umh = GEN $@ 23 23 cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \ 24 - $(OBJCOPY) -I binary -O `$(OBJDUMP) -f $<|grep format|cut -d' ' -f8` \ 25 - -B `$(OBJDUMP) -f $<|grep architecture|cut -d, -f1|cut -d' ' -f2` \ 24 + $(OBJCOPY) -I binary \ 25 + `LC_ALL=C objdump -f net/bpfilter/bpfilter_umh \ 26 + |awk -F' |,' '/file format/{print "-O",$$NF} \ 27 + /^architecture:/{print "-B",$$2}'` \ 26 28 --rename-section .data=.init.rodata $< $@ 27 29 28 30 $(obj)/bpfilter_umh.o: $(obj)/bpfilter_umh
+2 -2
net/core/dev.c
··· 8643 8643 /* We get here if we can't use the current device name */ 8644 8644 if (!pat) 8645 8645 goto out; 8646 - if (dev_get_valid_name(net, dev, pat) < 0) 8646 + err = dev_get_valid_name(net, dev, pat); 8647 + if (err < 0) 8647 8648 goto out; 8648 8649 } 8649 8650 ··· 8656 8655 dev_close(dev); 8657 8656 8658 8657 /* And unlink it from device chain */ 8659 - err = -ENODEV; 8660 8658 unlist_netdevice(dev); 8661 8659 8662 8660 synchronize_net();
+4 -17
net/core/filter.c
··· 3214 3214 } 3215 3215 EXPORT_SYMBOL_GPL(xdp_do_redirect); 3216 3216 3217 - static int __xdp_generic_ok_fwd_dev(struct sk_buff *skb, struct net_device *fwd) 3218 - { 3219 - unsigned int len; 3220 - 3221 - if (unlikely(!(fwd->flags & IFF_UP))) 3222 - return -ENETDOWN; 3223 - 3224 - len = fwd->mtu + fwd->hard_header_len + VLAN_HLEN; 3225 - if (skb->len > len) 3226 - return -EMSGSIZE; 3227 - 3228 - return 0; 3229 - } 3230 - 3231 3217 static int xdp_do_generic_redirect_map(struct net_device *dev, 3232 3218 struct sk_buff *skb, 3233 3219 struct xdp_buff *xdp, ··· 3242 3256 } 3243 3257 3244 3258 if (map->map_type == BPF_MAP_TYPE_DEVMAP) { 3245 - if (unlikely((err = __xdp_generic_ok_fwd_dev(skb, fwd)))) 3259 + struct bpf_dtab_netdev *dst = fwd; 3260 + 3261 + err = dev_map_generic_redirect(dst, skb, xdp_prog); 3262 + if (unlikely(err)) 3246 3263 goto err; 3247 - skb->dev = fwd; 3248 - generic_xdp_tx(skb, xdp_prog); 3249 3264 } else if (map->map_type == BPF_MAP_TYPE_XSKMAP) { 3250 3265 struct xdp_sock *xs = fwd; 3251 3266
+2 -2
net/ipv4/inet_hashtables.c
··· 243 243 bool dev_match = (sk->sk_bound_dev_if == dif || 244 244 sk->sk_bound_dev_if == sdif); 245 245 246 - if (exact_dif && !dev_match) 246 + if (!dev_match) 247 247 return -1; 248 - if (sk->sk_bound_dev_if && dev_match) 248 + if (sk->sk_bound_dev_if) 249 249 score += 4; 250 250 } 251 251 if (sk->sk_incoming_cpu == raw_smp_processor_id())
+2 -1
net/ipv4/ip_output.c
··· 1145 1145 cork->fragsize = ip_sk_use_pmtu(sk) ? 1146 1146 dst_mtu(&rt->dst) : rt->dst.dev->mtu; 1147 1147 1148 - cork->gso_size = sk->sk_type == SOCK_DGRAM ? ipc->gso_size : 0; 1148 + cork->gso_size = sk->sk_type == SOCK_DGRAM && 1149 + sk->sk_protocol == IPPROTO_UDP ? ipc->gso_size : 0; 1149 1150 cork->dst = &rt->dst; 1150 1151 cork->length = 0; 1151 1152 cork->ttl = ipc->ttl;
+2 -2
net/ipv6/inet6_hashtables.c
··· 113 113 bool dev_match = (sk->sk_bound_dev_if == dif || 114 114 sk->sk_bound_dev_if == sdif); 115 115 116 - if (exact_dif && !dev_match) 116 + if (!dev_match) 117 117 return -1; 118 - if (sk->sk_bound_dev_if && dev_match) 118 + if (sk->sk_bound_dev_if) 119 119 score++; 120 120 } 121 121 if (sk->sk_incoming_cpu == raw_smp_processor_id())
+3 -2
net/ipv6/ip6_fib.c
··· 167 167 return f6i; 168 168 } 169 169 170 - void fib6_info_destroy(struct fib6_info *f6i) 170 + void fib6_info_destroy_rcu(struct rcu_head *head) 171 171 { 172 + struct fib6_info *f6i = container_of(head, struct fib6_info, rcu); 172 173 struct rt6_exception_bucket *bucket; 173 174 struct dst_metrics *m; 174 175 ··· 207 206 208 207 kfree(f6i); 209 208 } 210 - EXPORT_SYMBOL_GPL(fib6_info_destroy); 209 + EXPORT_SYMBOL_GPL(fib6_info_destroy_rcu); 211 210 212 211 static struct fib6_node *node_alloc(struct net *net) 213 212 {
+2 -1
net/ipv6/ip6_output.c
··· 1219 1219 if (mtu < IPV6_MIN_MTU) 1220 1220 return -EINVAL; 1221 1221 cork->base.fragsize = mtu; 1222 - cork->base.gso_size = sk->sk_type == SOCK_DGRAM ? ipc6->gso_size : 0; 1222 + cork->base.gso_size = sk->sk_type == SOCK_DGRAM && 1223 + sk->sk_protocol == IPPROTO_UDP ? ipc6->gso_size : 0; 1223 1224 1224 1225 if (dst_allfrag(xfrm_dst_path(&rt->dst))) 1225 1226 cork->base.flags |= IPCORK_ALLFRAG;
+5 -5
net/ncsi/ncsi-aen.c
··· 73 73 ncm->data[2] = data; 74 74 ncm->data[4] = ntohl(lsc->oem_status); 75 75 76 - netdev_info(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n", 77 - nc->id, data & 0x1 ? "up" : "down"); 76 + netdev_dbg(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n", 77 + nc->id, data & 0x1 ? "up" : "down"); 78 78 79 79 chained = !list_empty(&nc->link); 80 80 state = nc->state; ··· 148 148 hncdsc = (struct ncsi_aen_hncdsc_pkt *)h; 149 149 ncm->data[3] = ntohl(hncdsc->status); 150 150 spin_unlock_irqrestore(&nc->lock, flags); 151 - netdev_printk(KERN_DEBUG, ndp->ndev.dev, 152 - "NCSI: host driver %srunning on channel %u\n", 153 - ncm->data[3] & 0x1 ? "" : "not ", nc->id); 151 + netdev_dbg(ndp->ndev.dev, 152 + "NCSI: host driver %srunning on channel %u\n", 153 + ncm->data[3] & 0x1 ? "" : "not ", nc->id); 154 154 155 155 return 0; 156 156 }
+22 -27
net/ncsi/ncsi-manage.c
··· 788 788 } 789 789 break; 790 790 case ncsi_dev_state_config_done: 791 - netdev_printk(KERN_DEBUG, ndp->ndev.dev, 792 - "NCSI: channel %u config done\n", nc->id); 791 + netdev_dbg(ndp->ndev.dev, "NCSI: channel %u config done\n", 792 + nc->id); 793 793 spin_lock_irqsave(&nc->lock, flags); 794 794 if (nc->reconfigure_needed) { 795 795 /* This channel's configuration has been updated ··· 804 804 list_add_tail_rcu(&nc->link, &ndp->channel_queue); 805 805 spin_unlock_irqrestore(&ndp->lock, flags); 806 806 807 - netdev_printk(KERN_DEBUG, dev, 808 - "Dirty NCSI channel state reset\n"); 807 + netdev_dbg(dev, "Dirty NCSI channel state reset\n"); 809 808 ncsi_process_next_channel(ndp); 810 809 break; 811 810 } ··· 815 816 } else { 816 817 hot_nc = NULL; 817 818 nc->state = NCSI_CHANNEL_INACTIVE; 818 - netdev_warn(ndp->ndev.dev, 819 - "NCSI: channel %u link down after config\n", 820 - nc->id); 819 + netdev_dbg(ndp->ndev.dev, 820 + "NCSI: channel %u link down after config\n", 821 + nc->id); 821 822 } 822 823 spin_unlock_irqrestore(&nc->lock, flags); 823 824 ··· 907 908 } 908 909 909 910 ncm = &found->modes[NCSI_MODE_LINK]; 910 - netdev_printk(KERN_DEBUG, ndp->ndev.dev, 911 - "NCSI: Channel %u added to queue (link %s)\n", 912 - found->id, ncm->data[2] & 0x1 ? "up" : "down"); 911 + netdev_dbg(ndp->ndev.dev, 912 + "NCSI: Channel %u added to queue (link %s)\n", 913 + found->id, ncm->data[2] & 0x1 ? "up" : "down"); 913 914 914 915 out: 915 916 spin_lock_irqsave(&ndp->lock, flags); ··· 1198 1199 switch (old_state) { 1199 1200 case NCSI_CHANNEL_INACTIVE: 1200 1201 ndp->ndev.state = ncsi_dev_state_config; 1201 - netdev_info(ndp->ndev.dev, "NCSI: configuring channel %u\n", 1202 - nc->id); 1202 + netdev_dbg(ndp->ndev.dev, "NCSI: configuring channel %u\n", 1203 + nc->id); 1203 1204 ncsi_configure_channel(ndp); 1204 1205 break; 1205 1206 case NCSI_CHANNEL_ACTIVE: 1206 1207 ndp->ndev.state = ncsi_dev_state_suspend; 1207 - netdev_info(ndp->ndev.dev, "NCSI: suspending channel %u\n", 1208 - nc->id); 1208 + netdev_dbg(ndp->ndev.dev, "NCSI: suspending channel %u\n", 1209 + nc->id); 1209 1210 ncsi_suspend_channel(ndp); 1210 1211 break; 1211 1212 default: ··· 1225 1226 return ncsi_choose_active_channel(ndp); 1226 1227 } 1227 1228 1228 - netdev_printk(KERN_DEBUG, ndp->ndev.dev, 1229 - "NCSI: No more channels to process\n"); 1230 1229 ncsi_report_link(ndp, false); 1231 1230 return -ENODEV; 1232 1231 } ··· 1315 1318 if ((ndp->ndev.state & 0xff00) == 1316 1319 ncsi_dev_state_config || 1317 1320 !list_empty(&nc->link)) { 1318 - netdev_printk(KERN_DEBUG, nd->dev, 1319 - "NCSI: channel %p marked dirty\n", 1320 - nc); 1321 + netdev_dbg(nd->dev, 1322 + "NCSI: channel %p marked dirty\n", 1323 + nc); 1321 1324 nc->reconfigure_needed = true; 1322 1325 } 1323 1326 spin_unlock_irqrestore(&nc->lock, flags); ··· 1335 1338 list_add_tail_rcu(&nc->link, &ndp->channel_queue); 1336 1339 spin_unlock_irqrestore(&ndp->lock, flags); 1337 1340 1338 - netdev_printk(KERN_DEBUG, nd->dev, 1339 - "NCSI: kicked channel %p\n", nc); 1341 + netdev_dbg(nd->dev, "NCSI: kicked channel %p\n", nc); 1340 1342 n++; 1341 1343 } 1342 1344 } ··· 1366 1370 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) { 1367 1371 n_vids++; 1368 1372 if (vlan->vid == vid) { 1369 - netdev_printk(KERN_DEBUG, dev, 1370 - "NCSI: vid %u already registered\n", vid); 1373 + netdev_dbg(dev, "NCSI: vid %u already registered\n", 1374 + vid); 1371 1375 return 0; 1372 1376 } 1373 1377 } ··· 1386 1390 vlan->vid = vid; 1387 1391 list_add_rcu(&vlan->list, &ndp->vlan_vids); 1388 1392 1389 - netdev_printk(KERN_DEBUG, dev, "NCSI: Added new vid %u\n", vid); 1393 + netdev_dbg(dev, "NCSI: Added new vid %u\n", vid); 1390 1394 1391 1395 found = ncsi_kick_channels(ndp) != 0; 1392 1396 ··· 1415 1419 /* Remove the VLAN id from our internal list */ 1416 1420 list_for_each_entry_safe(vlan, tmp, &ndp->vlan_vids, list) 1417 1421 if (vlan->vid == vid) { 1418 - netdev_printk(KERN_DEBUG, dev, 1419 - "NCSI: vid %u found, removing\n", vid); 1422 + netdev_dbg(dev, "NCSI: vid %u found, removing\n", vid); 1420 1423 list_del_rcu(&vlan->list); 1421 1424 found = true; 1422 1425 kfree(vlan); ··· 1542 1547 } 1543 1548 } 1544 1549 1545 - netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: Stopping device\n"); 1550 + netdev_dbg(ndp->ndev.dev, "NCSI: Stopping device\n"); 1546 1551 ncsi_report_link(ndp, true); 1547 1552 } 1548 1553 EXPORT_SYMBOL_GPL(ncsi_stop_dev);
+5 -7
net/sched/act_ife.c
··· 415 415 spin_unlock_bh(&ife->tcf_lock); 416 416 417 417 p = rcu_dereference_protected(ife->params, 1); 418 - kfree_rcu(p, rcu); 418 + if (p) 419 + kfree_rcu(p, rcu); 419 420 } 420 421 421 422 /* under ife->tcf_lock for existing action */ ··· 517 516 saddr = nla_data(tb[TCA_IFE_SMAC]); 518 517 } 519 518 520 - ife->tcf_action = parm->action; 521 - 522 519 if (parm->flags & IFE_ENCODE) { 523 520 if (daddr) 524 521 ether_addr_copy(p->eth_dst, daddr); ··· 542 543 NULL, NULL); 543 544 if (err) { 544 545 metadata_parse_err: 545 - if (exists) 546 - tcf_idr_release(*a, bind); 547 546 if (ret == ACT_P_CREATED) 548 - _tcf_ife_cleanup(*a); 547 + tcf_idr_release(*a, bind); 549 548 550 549 if (exists) 551 550 spin_unlock_bh(&ife->tcf_lock); ··· 564 567 err = use_all_metadata(ife); 565 568 if (err) { 566 569 if (ret == ACT_P_CREATED) 567 - _tcf_ife_cleanup(*a); 570 + tcf_idr_release(*a, bind); 568 571 569 572 if (exists) 570 573 spin_unlock_bh(&ife->tcf_lock); ··· 573 576 } 574 577 } 575 578 579 + ife->tcf_action = parm->action; 576 580 if (exists) 577 581 spin_unlock_bh(&ife->tcf_lock); 578 582
+1 -1
net/sched/sch_blackhole.c
··· 21 21 struct sk_buff **to_free) 22 22 { 23 23 qdisc_drop(skb, sch, to_free); 24 - return NET_XMIT_SUCCESS; 24 + return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; 25 25 } 26 26 27 27 static struct sk_buff *blackhole_dequeue(struct Qdisc *sch)
+3
net/xdp/xsk.c
··· 118 118 u64 addr; 119 119 int err; 120 120 121 + if (xs->dev != xdp->rxq->dev || xs->queue_id != xdp->rxq->queue_index) 122 + return -EINVAL; 123 + 121 124 if (!xskq_peek_addr(xs->umem->fq, &addr) || 122 125 len > xs->umem->chunk_size_nohr) { 123 126 xs->rx_dropped++;
+3 -2
tools/bpf/bpftool/perf.c
··· 29 29 if (perf_query_supported) 30 30 goto out; 31 31 32 - fd = open(bin_name, O_RDONLY); 32 + fd = open("/", O_RDONLY); 33 33 if (fd < 0) { 34 - p_err("perf_query_support: %s", strerror(errno)); 34 + p_err("perf_query_support: cannot open directory \"/\" (%s)", 35 + strerror(errno)); 35 36 goto out; 36 37 } 37 38
+3 -1
tools/bpf/bpftool/prog.c
··· 90 90 } 91 91 92 92 wallclock_secs = (real_time_ts.tv_sec - boot_time_ts.tv_sec) + 93 - nsecs / 1000000000; 93 + (real_time_ts.tv_nsec - boot_time_ts.tv_nsec + nsecs) / 94 + 1000000000; 95 + 94 96 95 97 if (!localtime_r(&wallclock_secs, &load_tm)) { 96 98 snprintf(buf, size, "%llu", nsecs / 1000000000);
+10
tools/testing/selftests/bpf/config
··· 7 7 CONFIG_NETDEVSIM=m 8 8 CONFIG_NET_CLS_ACT=y 9 9 CONFIG_NET_SCH_INGRESS=y 10 + CONFIG_NET_IPIP=y 11 + CONFIG_IPV6=y 12 + CONFIG_NET_IPGRE_DEMUX=y 13 + CONFIG_NET_IPGRE=y 14 + CONFIG_IPV6_GRE=y 15 + CONFIG_CRYPTO_USER_API_HASH=m 16 + CONFIG_CRYPTO_HMAC=m 17 + CONFIG_CRYPTO_SHA256=m 18 + CONFIG_VXLAN=y 19 + CONFIG_GENEVE=y
+10 -2
tools/testing/selftests/bpf/test_offload.py
··· 163 163 164 164 def bpftool_prog_list(expected=None, ns=""): 165 165 _, progs = bpftool("prog show", JSON=True, ns=ns, fail=True) 166 + # Remove the base progs 167 + for p in base_progs: 168 + if p in progs: 169 + progs.remove(p) 166 170 if expected is not None: 167 171 if len(progs) != expected: 168 172 fail(True, "%d BPF programs loaded, expected %d" % ··· 175 171 176 172 def bpftool_map_list(expected=None, ns=""): 177 173 _, maps = bpftool("map show", JSON=True, ns=ns, fail=True) 174 + # Remove the base maps 175 + for m in base_maps: 176 + if m in maps: 177 + maps.remove(m) 178 178 if expected is not None: 179 179 if len(maps) != expected: 180 180 fail(True, "%d BPF maps loaded, expected %d" % ··· 593 585 # Check tools 594 586 ret, progs = bpftool("prog", fail=False) 595 587 skip(ret != 0, "bpftool not installed") 596 - # Check no BPF programs are loaded 597 - skip(len(progs) != 0, "BPF programs already loaded on the system") 588 + base_progs = progs 589 + _, base_maps = bpftool("map") 598 590 599 591 # Check netdevsim 600 592 ret, out = cmd("modprobe netdevsim", fail=False)
+14 -12
tools/testing/selftests/bpf/test_tunnel.sh
··· 608 608 test_xfrm_tunnel() 609 609 { 610 610 config_device 611 - #tcpdump -nei veth1 ip & 612 - output=$(mktemp) 613 - cat /sys/kernel/debug/tracing/trace_pipe | tee $output & 614 - setup_xfrm_tunnel 611 + > /sys/kernel/debug/tracing/trace 612 + setup_xfrm_tunnel 615 613 tc qdisc add dev veth1 clsact 616 614 tc filter add dev veth1 proto ip ingress bpf da obj test_tunnel_kern.o \ 617 615 sec xfrm_get_state 618 616 ip netns exec at_ns0 ping $PING_ARG 10.1.1.200 619 617 sleep 1 620 - grep "reqid 1" $output 618 + grep "reqid 1" /sys/kernel/debug/tracing/trace 621 619 check_err $? 622 - grep "spi 0x1" $output 620 + grep "spi 0x1" /sys/kernel/debug/tracing/trace 623 621 check_err $? 624 - grep "remote ip 0xac100164" $output 622 + grep "remote ip 0xac100164" /sys/kernel/debug/tracing/trace 625 623 check_err $? 626 624 cleanup 627 625 628 626 if [ $ret -ne 0 ]; then 629 - echo -e ${RED}"FAIL: xfrm tunnel"${NC} 630 - return 1 631 - fi 632 - echo -e ${GREEN}"PASS: xfrm tunnel"${NC} 627 + echo -e ${RED}"FAIL: xfrm tunnel"${NC} 628 + return 1 629 + fi 630 + echo -e ${GREEN}"PASS: xfrm tunnel"${NC} 633 631 } 634 632 635 633 attach_bpf() ··· 655 657 ip link del ip6geneve11 2> /dev/null 656 658 ip link del erspan11 2> /dev/null 657 659 ip link del ip6erspan11 2> /dev/null 660 + ip xfrm policy delete dir out src 10.1.1.200/32 dst 10.1.1.100/32 2> /dev/null 661 + ip xfrm policy delete dir in src 10.1.1.100/32 dst 10.1.1.200/32 2> /dev/null 662 + ip xfrm state delete src 172.16.1.100 dst 172.16.1.200 proto esp spi 0x1 2> /dev/null 663 + ip xfrm state delete src 172.16.1.200 dst 172.16.1.100 proto esp spi 0x2 2> /dev/null 658 664 } 659 665 660 666 cleanup_exit() ··· 670 668 671 669 check() 672 670 { 673 - ip link help $1 2>&1 | grep -q "^Usage:" 671 + ip link help 2>&1 | grep -q "\s$1\s" 674 672 if [ $? -ne 0 ];then 675 673 echo "SKIP $1: iproute2 not support" 676 674 cleanup