History

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

Pull networking fixes from Jakub Kicinski: "Cross-tree/merge window issues: - rtl8150: don't incorrectly assign random MAC addresses; fix late in the 5.9 cycle started depending on a return code from a function which changed with the 5.10 PR from the usb subsystem Current release regressions: - Revert "virtio-net: ethtool configurable RXCSUM", it was causing crashes at probe when control vq was not negotiated/available Previous release regressions: - ixgbe: fix probing of multi-port 10 Gigabit Intel NICs with an MDIO bus, only first device would be probed correctly - nexthop: Fix performance regression in nexthop deletion by effectively switching from recently added synchronize_rcu() to synchronize_rcu_expedited() - netsec: ignore 'phy-mode' device property on ACPI systems; the property is not populated correctly by the firmware, but firmware configures the PHY so just keep boot settings Previous releases - always broken: - tcp: fix to update snd_wl1 in bulk receiver fast path, addressing bulk transfers getting "stuck" - icmp: randomize the global rate limiter to prevent attackers from getting useful signal - r8169: fix operation under forced interrupt threading, make the driver always use hard irqs, even on RT, given the handler is light and only wants to schedule napi (and do so through a _irqoff() variant, preferably) - bpf: Enforce pointer id generation for all may-be-null register type to avoid pointers erroneously getting marked as null-checked - tipc: re-configure queue limit for broadcast link - net/sched: act_tunnel_key: fix OOB write in case of IPv6 ERSPAN tunnels - fix various issues in chelsio inline tls driver Misc: - bpf: improve just-added bpf_redirect_neigh() helper api to support supplying nexthop by the caller - in case BPF program has already done a lookup we can avoid doing another one - remove unnecessary break statements - make MCTCP not select IPV6, but rather depend on it" * tag 'net-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (62 commits) tcp: fix to update snd_wl1 in bulk receiver fast path net: Properly typecast int values to set sk_max_pacing_rate netfilter: nf_fwd_netdev: clear timestamp in forwarding path ibmvnic: save changed mac address to adapter->mac_addr selftests: mptcp: depends on built-in IPv6 Revert "virtio-net: ethtool configurable RXCSUM" rtnetlink: fix data overflow in rtnl_calcit() net: ethernet: mtk-star-emac: select REGMAP_MMIO net: hdlc_raw_eth: Clear the IFF_TX_SKB_SHARING flag after calling ether_setup net: hdlc: In hdlc_rcv, check to make sure dev is an HDLC device bpf, libbpf: Guard bpf inline asm from bpf_tail_call_static bpf, selftests: Extend test_tc_redirect to use modified bpf_redirect_neigh() bpf: Fix bpf_redirect_neigh helper api to support supplying nexthop mptcp: depends on IPV6 but not as a module sfc: move initialisation of efx->filter_sem to efx_init_struct() mpls: load mpls_gso after mpls_iptunnel net/sched: act_tunnel_key: fix OOB write in case of IPv6 ERSPAN tunnels net/sched: act_gate: Unlock ->tcfa_lock in tc_setup_flow_action() net: dsa: bcm_sf2: make const array static, makes object smaller mptcp: MPTCP_IPV6 should depend on IPV6 instead of selecting it ...

Linus Torvalds committed 6 years ago

Commit 3cb12d22 parents 0adc313 18ded9179 files · +676 −256Browse files

Unified · Split

79 files
  1. Documentation/devicetree/bindings/net/socionext-netsec.txt +3 −1
  2. Documentation/networking/ip-sysctl.rst +3 −1
  3. Documentation/networking/nf_flowtable.rst +1 −1
  4. MAINTAINERS +2 −1
  5. drivers/net/dsa/bcm_sf2.c +1 −1
  6. drivers/net/dsa/ocelot/seville_vsc9953.c +1 −1
  7. drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0 −1
  8. drivers/net/ethernet/chelsio/inline_crypto/Kconfig +1 −0
  9. drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c +13 −6
  10. drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c +3 −2
  11. drivers/net/ethernet/cisco/enic/enic_ethtool.c +0 −1
  12. drivers/net/ethernet/faraday/ftgmac100.c +5 −0
  13. drivers/net/ethernet/faraday/ftgmac100.h +8 −0
  14. drivers/net/ethernet/ibm/ibmvnic.c +5 −0
  15. drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +14 −9
  16. drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c +0 −1
  17. drivers/net/ethernet/korina.c +2 −2
  18. drivers/net/ethernet/mediatek/Kconfig +1 −0
  19. drivers/net/ethernet/realtek/r8169_main.c +4 −4
  20. drivers/net/ethernet/sfc/efx_common.c +1 −0
  21. drivers/net/ethernet/sfc/rx_common.c +0 −1
  22. drivers/net/ethernet/socionext/netsec.c +17 −7
  23. drivers/net/pcs/Kconfig +1 −2
  24. drivers/net/usb/rtl8150.c +1 −1
  25. drivers/net/virtio_net.c +12 −36
  26. drivers/net/wan/hdlc.c +9 −1
  27. drivers/net/wan/hdlc_raw_eth.c +1 −0
  28. drivers/net/wan/lmc/lmc_proto.c +0 −4
  29. drivers/nfc/st21nfca/core.c +0 −1
  30. drivers/nfc/trf7970a.c +0 −1
  31. include/linux/filter.h +9 −0
  32. include/linux/netlink.h +1 −1
  33. include/net/netfilter/nf_tables.h +6 −0
  34. include/uapi/linux/bpf.h +18 −4
  35. kernel/bpf/syscall.c +0 −1
  36. kernel/bpf/verifier.c +5 −6
  37. net/bridge/netfilter/ebt_dnat.c +1 −1
  38. net/bridge/netfilter/ebt_redirect.c +1 −1
  39. net/bridge/netfilter/ebt_snat.c +1 −1
  40. net/core/dev.c +1 −1
  41. net/core/filter.c +101 −60
  42. net/core/rtnetlink.c +6 −7
  43. net/core/sock.c +1 −1
  44. net/dsa/tag_ksz.c +2 −0
  45. net/ipv4/icmp.c +5 −2
  46. net/ipv4/nexthop.c +1 −1
  47. net/ipv4/tcp_input.c +2 −0
  48. net/ipv6/netfilter/nf_conntrack_reasm.c +1 −0
  49. net/mpls/mpls_iptunnel.c +1 −0
  50. net/mptcp/Kconfig +2 −4
  51. net/mptcp/options.c +2 −1
  52. net/netfilter/ipvs/ip_vs_proto_tcp.c +6 −4
  53. net/netfilter/nf_conntrack_proto_tcp.c +13 −6
  54. net/netfilter/nf_dup_netdev.c +1 −0
  55. net/netfilter/nf_tables_api.c +3 −3
  56. net/netfilter/nf_tables_offload.c +2 −2
  57. net/netfilter/nft_fwd_netdev.c +1 −0
  58. net/nfc/netlink.c +1 −1
  59. net/openvswitch/flow_table.c +35 −23
  60. net/openvswitch/flow_table.h +6 −2
  61. net/sched/act_ct.c +2 −2
  62. net/sched/act_tunnel_key.c +1 −1
  63. net/sched/cls_api.c +1 −1
  64. net/tipc/bcast.c +8 −2
  65. samples/bpf/sockex3_kern.c +4 −4
  66. scripts/bpf_helpers_doc.py +1 −0
  67. tools/include/uapi/linux/bpf.h +18 −4
  68. tools/lib/bpf/bpf_helpers.h +2 −0
  69. tools/testing/selftests/bpf/prog_tests/ksyms_btf.c +39 −18
  70. tools/testing/selftests/bpf/progs/test_ksyms_btf_null_check.c +31 −0
  71. tools/testing/selftests/bpf/progs/test_tc_neigh.c +3 −2
  72. tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c +155 −0
  73. tools/testing/selftests/bpf/test_tc_redirect.sh +15 −3
  74. tools/testing/selftests/bpf/verifier/sock.c +25 −0
  75. tools/testing/selftests/net/config +1 −0
  76. tools/testing/selftests/net/forwarding/vxlan_asymmetric.sh +10 −0
  77. tools/testing/selftests/net/forwarding/vxlan_symmetric.sh +10 −0
  78. tools/testing/selftests/net/mptcp/config +1 −0
  79. tools/testing/selftests/net/rtnetlink.sh +5 −0
Documentation/devicetree/bindings/net/socionext-netsec.txt+3−1
@@ -30,7 +30,9 @@ Optional properties: (See ethernet.txt file in the same directory) · 29 unmodified lines
3030 - max-frame-size: See ethernet.txt in the same directory.
3131
3232 The MAC address will be determined using the optional properties
33−defined in ethernet.txt.
33+defined in ethernet.txt. The 'phy-mode' property is required, but may
34+be set to the empty string if the PHY configuration is programmed by
35+the firmware or set by hardware straps, and needs to be preserved.
3436
3537 Example:
3638 eth0: ethernet@522d0000 {
Documentation/networking/ip-sysctl.rst+3−1
@@ -1142,13 +1142,15 @@ icmp_ratelimit - INTEGER · 1141 unmodified lines
11421142 icmp_msgs_per_sec - INTEGER
11431143 Limit maximal number of ICMP packets sent per second from this host.
11441144 Only messages whose type matches icmp_ratemask (see below) are
1145− controlled by this limit.
1145+ controlled by this limit. For security reasons, the precise count
1146+ of messages per second is randomized.
11461147
11471148 Default: 1000
11481149
11491150 icmp_msgs_burst - INTEGER
11501151 icmp_msgs_per_sec controls number of ICMP packets sent per second,
11511152 while icmp_msgs_burst controls the burst size of these packets.
1153+ For security reasons, the precise burst size is randomized.
11521154
11531155 Default: 50
11541156
Documentation/networking/nf_flowtable.rst+1−1
@@ -109,7 +109,7 @@ More reading · 108 unmodified lines
109109 This documentation is based on the LWN.net articles [1]_\ [2]_. Rafal Milecki
110110 also made a very complete and comprehensive summary called "A state of network
111111 acceleration" that describes how things were before this infrastructure was
112−mailined [3]_ and it also makes a rough summary of this work [4]_.
112+mainlined [3]_ and it also makes a rough summary of this work [4]_.
113113
114114 .. [1] https://lwn.net/Articles/738214/
115115 .. [2] https://lwn.net/Articles/742164/
MAINTAINERS+2−1
@@ -3244,7 +3244,8 @@ R: KP Singh <kpsingh@chromium.org> · 3243 unmodified lines
32443244 L: netdev@vger.kernel.org
32453245 L: bpf@vger.kernel.org
32463246 S: Supported
3247−Q: https://patchwork.ozlabs.org/project/netdev/list/?delegate=77147
3247+W: https://bpf.io/
3248+Q: https://patchwork.kernel.org/project/netdevbpf/list/?delegate=121173
32483249 T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git
32493250 T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
32503251 F: Documentation/bpf/
drivers/net/dsa/bcm_sf2.c+1−1
@@ -54,7 +54,7 @@ static void bcm_sf2_recalc_clock(struct dsa_switch *ds) · 53 unmodified lines
5454 unsigned long new_rate;
5555 unsigned int ports_active;
5656 /* Frequenty in Mhz */
57− const unsigned long rate_table[] = {
57+ static const unsigned long rate_table[] = {
5858 59220000,
5959 60820000,
6060 62500000,
drivers/net/dsa/ocelot/seville_vsc9953.c+1−1
@@ -1181,7 +1181,7 @@ static const struct felix_info seville_info_vsc9953 = { · 1180 unmodified lines
11811181 .stats_layout = vsc9953_stats_layout,
11821182 .num_stats = ARRAY_SIZE(vsc9953_stats_layout),
11831183 .vcap = vsc9953_vcap_props,
1184− .shared_queue_sz = 2048 * 1024,
1184+ .shared_queue_sz = 256 * 1024,
11851185 .num_mact_rows = 2048,
11861186 .num_ports = 10,
11871187 .mdio_bus_alloc = vsc9953_mdio_bus_alloc,
drivers/net/ethernet/aquantia/atlantic/aq_nic.c+0−1
@@ -1163,7 +1163,6 @@ int aq_nic_set_link_ksettings(struct aq_nic_s *self, · 1162 unmodified lines
11631163 default:
11641164 err = -1;
11651165 goto err_exit;
1166− break;
11671166 }
11681167 if (!(self->aq_nic_cfg.aq_hw_caps->link_speed_msk & rate)) {
11691168 err = -1;
drivers/net/ethernet/chelsio/inline_crypto/Kconfig+1−0
@@ -16,6 +16,7 @@ if CHELSIO_INLINE_CRYPTO · 15 unmodified lines
1616 config CRYPTO_DEV_CHELSIO_TLS
1717 tristate "Chelsio Crypto Inline TLS Driver"
1818 depends on CHELSIO_T4
19+ depends on TLS
1920 depends on TLS_TOE
2021 help
2122 Support Chelsio Inline TLS with Chelsio crypto accelerator.
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c+13−6
@@ -92,11 +92,13 @@ static void chtls_sock_release(struct kref *ref) · 91 unmodified lines
9292 static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
9393 struct sock *sk)
9494 {
95+ struct adapter *adap = pci_get_drvdata(cdev->pdev);
9596 struct net_device *ndev = cdev->ports[0];
9697 #if IS_ENABLED(CONFIG_IPV6)
9798 struct net_device *temp;
9899 int addr_type;
99100 #endif
101+ int i;
100102
101103 switch (sk->sk_family) {
102104 case PF_INET:
@@ -127,8 +129,12 @@ static struct net_device *chtls_find_netdev(struct chtls_dev *cdev, · 24 unmodified lines
127129 return NULL;
128130
129131 if (is_vlan_dev(ndev))
130− return vlan_dev_real_dev(ndev);
131− return ndev;
132+ ndev = vlan_dev_real_dev(ndev);
133+
134+ for_each_port(adap, i)
135+ if (cdev->ports[i] == ndev)
136+ return ndev;
137+ return NULL;
132138 }
133139
134140 static void assign_rxopt(struct sock *sk, unsigned int opt)
@@ -477,7 +483,6 @@ void chtls_destroy_sock(struct sock *sk) · 342 unmodified lines
477483 chtls_purge_write_queue(sk);
478484 free_tls_keyid(sk);
479485 kref_put(&csk->kref, chtls_sock_release);
480− csk->cdev = NULL;
481486 if (sk->sk_family == AF_INET)
482487 sk->sk_prot = &tcp_prot;
483488 #if IS_ENABLED(CONFIG_IPV6)
@@ -736,14 +741,13 @@ void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk) · 252 unmodified lines
736741
737742 #if IS_ENABLED(CONFIG_IPV6)
738743 if (sk->sk_family == PF_INET6) {
739− struct chtls_sock *csk;
744+ struct net_device *ndev = chtls_find_netdev(cdev, sk);
740745 int addr_type = 0;
741746
742− csk = rcu_dereference_sk_user_data(sk);
743747 addr_type = ipv6_addr_type((const struct in6_addr *)
744748 &sk->sk_v6_rcv_saddr);
745749 if (addr_type != IPV6_ADDR_ANY)
746− cxgb4_clip_release(csk->egress_dev, (const u32 *)
750+ cxgb4_clip_release(ndev, (const u32 *)
747751 &sk->sk_v6_rcv_saddr, 1);
748752 }
749753 #endif
@@ -1157,6 +1161,9 @@ static struct sock *chtls_recv_sock(struct sock *lsk, · 407 unmodified lines
11571161 ndev = n->dev;
11581162 if (!ndev)
11591163 goto free_dst;
1164+ if (is_vlan_dev(ndev))
1165+ ndev = vlan_dev_real_dev(ndev);
1166+
11601167 port_id = cxgb4_port_idx(ndev);
11611168
11621169 csk = chtls_sock_create(cdev);
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c+3−2
@@ -902,9 +902,9 @@ static int chtls_skb_copy_to_page_nocache(struct sock *sk, · 901 unmodified lines
902902 return 0;
903903 }
904904
905−static int csk_mem_free(struct chtls_dev *cdev, struct sock *sk)
905+static bool csk_mem_free(struct chtls_dev *cdev, struct sock *sk)
906906 {
907− return (cdev->max_host_sndbuf - sk->sk_wmem_queued);
907+ return (cdev->max_host_sndbuf - sk->sk_wmem_queued > 0);
908908 }
909909
910910 static int csk_wait_memory(struct chtls_dev *cdev,
@@ -1240,6 +1240,7 @@ int chtls_sendpage(struct sock *sk, struct page *page, · 329 unmodified lines
12401240 copied = 0;
12411241 csk = rcu_dereference_sk_user_data(sk);
12421242 cdev = csk->cdev;
1243+ lock_sock(sk);
12431244 timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
12441245
12451246 err = sk_stream_wait_connect(sk, &timeo);
drivers/net/ethernet/cisco/enic/enic_ethtool.c+0−1
@@ -434,7 +434,6 @@ static int enic_grxclsrule(struct enic *enic, struct ethtool_rxnfc *cmd) · 433 unmodified lines
434434 break;
435435 default:
436436 return -EINVAL;
437− break;
438437 }
439438
440439 fsp->h_u.tcp_ip4_spec.ip4src = flow_get_u32_src(&n->keys);
drivers/net/ethernet/faraday/ftgmac100.c+5−0
@@ -1817,6 +1817,11 @@ static int ftgmac100_probe(struct platform_device *pdev) · 1816 unmodified lines
18171817 priv->rxdes0_edorr_mask = BIT(30);
18181818 priv->txdes0_edotr_mask = BIT(30);
18191819 priv->is_aspeed = true;
1820+ /* Disable ast2600 problematic HW arbitration */
1821+ if (of_device_is_compatible(np, "aspeed,ast2600-mac")) {
1822+ iowrite32(FTGMAC100_TM_DEFAULT,
1823+ priv->base + FTGMAC100_OFFSET_TM);
1824+ }
18201825 } else {
18211826 priv->rxdes0_edorr_mask = BIT(15);
18221827 priv->txdes0_edotr_mask = BIT(15);
drivers/net/ethernet/faraday/ftgmac100.h+8−0
@@ -169,6 +169,14 @@ · 168 unmodified lines
169169 #define FTGMAC100_MACCR_FAST_MODE (1 << 19)
170170 #define FTGMAC100_MACCR_SW_RST (1 << 31)
171171
172+/*
173+ * test mode control register
174+ */
175+#define FTGMAC100_TM_RQ_TX_VALID_DIS (1 << 28)
176+#define FTGMAC100_TM_RQ_RR_IDLE_PREV (1 << 27)
177+#define FTGMAC100_TM_DEFAULT \
178+ (FTGMAC100_TM_RQ_TX_VALID_DIS | FTGMAC100_TM_RQ_RR_IDLE_PREV)
179+
172180 /*
173181 * PHY control register
174182 */
drivers/net/ethernet/ibm/ibmvnic.c+5−0
@@ -4235,8 +4235,13 @@ static int handle_change_mac_rsp(union ibmvnic_crq *crq, · 4234 unmodified lines
42354235 dev_err(dev, "Error %ld in CHANGE_MAC_ADDR_RSP\n", rc);
42364236 goto out;
42374237 }
4238+ /* crq->change_mac_addr.mac_addr is the requested one
4239+ * crq->change_mac_addr_rsp.mac_addr is the returned valid one.
4240+ */
42384241 ether_addr_copy(netdev->dev_addr,
42394242 &crq->change_mac_addr_rsp.mac_addr[0]);
4243+ ether_addr_copy(adapter->mac_addr,
4244+ &crq->change_mac_addr_rsp.mac_addr[0]);
42404245 out:
42414246 complete(&adapter->fw_done);
42424247 return rc;
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c+14−9
@@ -901,15 +901,13 @@ static bool ixgbe_x550em_a_has_mii(struct ixgbe_hw *hw) · 900 unmodified lines
901901 **/
902902 s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw)
903903 {
904+ s32 (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);
905+ s32 (*read)(struct mii_bus *bus, int addr, int regnum);
904906 struct ixgbe_adapter *adapter = hw->back;
905907 struct pci_dev *pdev = adapter->pdev;
906908 struct device *dev = &adapter->netdev->dev;
907909 struct mii_bus *bus;
908910
909− bus = devm_mdiobus_alloc(dev);
910− if (!bus)
911− return -ENOMEM;
912−
913911 switch (hw->device_id) {
914912 /* C3000 SoCs */
915913 case IXGBE_DEV_ID_X550EM_A_KR:
@@ -922,16 +920,23 @@ s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw) · 6 unmodified lines
922920 case IXGBE_DEV_ID_X550EM_A_1G_T:
923921 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
924922 if (!ixgbe_x550em_a_has_mii(hw))
925− return -ENODEV;
926− bus->read = &ixgbe_x550em_a_mii_bus_read;
927− bus->write = &ixgbe_x550em_a_mii_bus_write;
923+ return 0;
924+ read = &ixgbe_x550em_a_mii_bus_read;
925+ write = &ixgbe_x550em_a_mii_bus_write;
928926 break;
929927 default:
930− bus->read = &ixgbe_mii_bus_read;
931− bus->write = &ixgbe_mii_bus_write;
928+ read = &ixgbe_mii_bus_read;
929+ write = &ixgbe_mii_bus_write;
932930 break;
933931 }
934932
933+ bus = devm_mdiobus_alloc(dev);
934+ if (!bus)
935+ return -ENOMEM;
936+
937+ bus->read = read;
938+ bus->write = write;
939+
935940 /* Use the position of the device in the PCI hierarchy as the id */
936941 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mdio-%s", ixgbe_driver_name,
937942 pci_name(pdev));
drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c+0−1
@@ -350,7 +350,6 @@ static s32 ixgbe_calc_eeprom_checksum_X540(struct ixgbe_hw *hw) · 349 unmodified lines
350350 if (ixgbe_read_eerd_generic(hw, pointer, &length)) {
351351 hw_dbg(hw, "EEPROM read failed\n");
352352 return IXGBE_ERR_EEPROM;
353− break;
354353 }
355354
356355 /* Skip pointer section if length is invalid. */
drivers/net/ethernet/korina.c+2−2
@@ -1113,7 +1113,7 @@ out: · 1112 unmodified lines
11131113 return rc;
11141114
11151115 probe_err_register:
1116− kfree(KSEG0ADDR(lp->td_ring));
1116+ kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
11171117 probe_err_td_ring:
11181118 iounmap(lp->tx_dma_regs);
11191119 probe_err_dma_tx:
@@ -1133,7 +1133,7 @@ static int korina_remove(struct platform_device *pdev) · 13 unmodified lines
11331133 iounmap(lp->eth_regs);
11341134 iounmap(lp->rx_dma_regs);
11351135 iounmap(lp->tx_dma_regs);
1136− kfree(KSEG0ADDR(lp->td_ring));
1136+ kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
11371137
11381138 unregister_netdev(bif->dev);
11391139 free_netdev(bif->dev);
drivers/net/ethernet/mediatek/Kconfig+1−0
@@ -17,6 +17,7 @@ config NET_MEDIATEK_SOC · 16 unmodified lines
1717 config NET_MEDIATEK_STAR_EMAC
1818 tristate "MediaTek STAR Ethernet MAC support"
1919 select PHYLIB
20+ select REGMAP_MMIO
2021 help
2122 This driver supports the ethernet MAC IP first used on
2223 MediaTek MT85** SoCs.
drivers/net/ethernet/realtek/r8169_main.c+4−4
@@ -4694,7 +4694,7 @@ static int rtl8169_close(struct net_device *dev) · 4693 unmodified lines
46944694
46954695 phy_disconnect(tp->phydev);
46964696
4697− pci_free_irq(pdev, 0, tp);
4697+ free_irq(pci_irq_vector(pdev, 0), tp);
46984698
46994699 dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
47004700 tp->RxPhyAddr);
@@ -4745,8 +4745,8 @@ static int rtl_open(struct net_device *dev) · 44 unmodified lines
47454745
47464746 rtl_request_firmware(tp);
47474747
4748− retval = pci_request_irq(pdev, 0, rtl8169_interrupt, NULL, tp,
4749− dev->name);
4748+ retval = request_irq(pci_irq_vector(pdev, 0), rtl8169_interrupt,
4749+ IRQF_NO_THREAD | IRQF_SHARED, dev->name, tp);
47504750 if (retval < 0)
47514751 goto err_release_fw_2;
47524752
@@ -4763,7 +4763,7 @@ out: · 10 unmodified lines
47634763 return retval;
47644764
47654765 err_free_irq:
4766− pci_free_irq(pdev, 0, tp);
4766+ free_irq(pci_irq_vector(pdev, 0), tp);
47674767 err_release_fw_2:
47684768 rtl_release_firmware(tp);
47694769 rtl8169_rx_clear(tp);
drivers/net/ethernet/sfc/efx_common.c+1−0
@@ -1014,6 +1014,7 @@ int efx_init_struct(struct efx_nic *efx, · 1013 unmodified lines
10141014 efx->num_mac_stats = MC_CMD_MAC_NSTATS;
10151015 BUILD_BUG_ON(MC_CMD_MAC_NSTATS - 1 != MC_CMD_MAC_GENERATION_END);
10161016 mutex_init(&efx->mac_lock);
1017+ init_rwsem(&efx->filter_sem);
10171018 #ifdef CONFIG_RFS_ACCEL
10181019 mutex_init(&efx->rps_mutex);
10191020 spin_lock_init(&efx->rps_hash_lock);
drivers/net/ethernet/sfc/rx_common.c+0−1
@@ -797,7 +797,6 @@ int efx_probe_filters(struct efx_nic *efx) · 796 unmodified lines
797797 {
798798 int rc;
799799
800− init_rwsem(&efx->filter_sem);
801800 mutex_lock(&efx->mac_lock);
802801 down_write(&efx->filter_sem);
803802 rc = efx->type->filter_table_probe(efx);
drivers/net/ethernet/socionext/netsec.c+17−7
@@ -6,6 +6,7 @@ · 5 unmodified lines
66 #include <linux/pm_runtime.h>
77 #include <linux/acpi.h>
88 #include <linux/of_mdio.h>
9+#include <linux/of_net.h>
910 #include <linux/etherdevice.h>
1011 #include <linux/interrupt.h>
1112 #include <linux/io.h>
@@ -1833,6 +1834,14 @@ static const struct net_device_ops netsec_netdev_ops = { · 1821 unmodified lines
18331834 static int netsec_of_probe(struct platform_device *pdev,
18341835 struct netsec_priv *priv, u32 *phy_addr)
18351836 {
1837+ int err;
1838+
1839+ err = of_get_phy_mode(pdev->dev.of_node, &priv->phy_interface);
1840+ if (err) {
1841+ dev_err(&pdev->dev, "missing required property 'phy-mode'\n");
1842+ return err;
1843+ }
1844+
18361845 priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
18371846 if (!priv->phy_np) {
18381847 dev_err(&pdev->dev, "missing required property 'phy-handle'\n");
@@ -1859,6 +1868,14 @@ static int netsec_acpi_probe(struct platform_device *pdev, · 20 unmodified lines
18591868 if (!IS_ENABLED(CONFIG_ACPI))
18601869 return -ENODEV;
18611870
1871+ /* ACPI systems are assumed to configure the PHY in firmware, so
1872+ * there is really no need to discover the PHY mode from the DSDT.
1873+ * Since firmware is known to exist in the field that configures the
1874+ * PHY correctly but passes the wrong mode string in the phy-mode
1875+ * device property, we have no choice but to ignore it.
1876+ */
1877+ priv->phy_interface = PHY_INTERFACE_MODE_NA;
1878+
18621879 ret = device_property_read_u32(&pdev->dev, "phy-channel", phy_addr);
18631880 if (ret) {
18641881 dev_err(&pdev->dev,
@@ -1995,13 +2012,6 @@ static int netsec_probe(struct platform_device *pdev) · 130 unmodified lines
19952012 priv->msg_enable = NETIF_MSG_TX_ERR | NETIF_MSG_HW | NETIF_MSG_DRV |
19962013 NETIF_MSG_LINK | NETIF_MSG_PROBE;
19972014
1998− priv->phy_interface = device_get_phy_mode(&pdev->dev);
1999− if ((int)priv->phy_interface < 0) {
2000− dev_err(&pdev->dev, "missing required property 'phy-mode'\n");
2001− ret = -ENODEV;
2002− goto free_ndev;
2003− }
2004−
20052015 priv->ioaddr = devm_ioremap(&pdev->dev, mmio_res->start,
20062016 resource_size(mmio_res));
20072017 if (!priv->ioaddr) {
drivers/net/pcs/Kconfig+1−2
@@ -7,8 +7,7 @@ menu "PCS device drivers" · 6 unmodified lines
77
88 config PCS_XPCS
99 tristate "Synopsys DesignWare XPCS controller"
10− select MDIO_BUS
11− depends on MDIO_DEVICE
10+ depends on MDIO_DEVICE && MDIO_BUS
1211 help
1312 This module provides helper functions for Synopsys DesignWare XPCS
1413 controllers.
drivers/net/usb/rtl8150.c+1−1
@@ -261,7 +261,7 @@ static void set_ethernet_addr(rtl8150_t *dev) · 260 unmodified lines
261261
262262 ret = get_registers(dev, IDR, sizeof(node_id), node_id);
263263
264− if (ret == sizeof(node_id)) {
264+ if (!ret) {
265265 ether_addr_copy(dev->netdev->dev_addr, node_id);
266266 } else {
267267 eth_hw_addr_random(dev->netdev);
drivers/net/virtio_net.c+12−36
@@ -68,8 +68,6 @@ static const unsigned long guest_offloads[] = { · 67 unmodified lines
6868 (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
6969 (1ULL << VIRTIO_NET_F_GUEST_UFO))
7070
71−#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
72−
7371 struct virtnet_stat_desc {
7472 char desc[ETH_GSTRING_LEN];
7573 size_t offset;
@@ -2524,48 +2522,29 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf, · 2448 unmodified lines
25242522 return 0;
25252523 }
25262524
2527−static netdev_features_t virtnet_fix_features(struct net_device *netdev,
2528− netdev_features_t features)
2529−{
2530− /* If Rx checksum is disabled, LRO should also be disabled. */
2531− if (!(features & NETIF_F_RXCSUM))
2532− features &= ~NETIF_F_LRO;
2533−
2534− return features;
2535−}
2536−
25372525 static int virtnet_set_features(struct net_device *dev,
25382526 netdev_features_t features)
25392527 {
25402528 struct virtnet_info *vi = netdev_priv(dev);
2541− u64 offloads = vi->guest_offloads;
2529+ u64 offloads;
25422530 int err;
25432531
2544− /* Don't allow configuration while XDP is active. */
2545− if (vi->xdp_queue_pairs)
2546− return -EBUSY;
2547−
25482532 if ((dev->features ^ features) & NETIF_F_LRO) {
2533+ if (vi->xdp_queue_pairs)
2534+ return -EBUSY;
2535+
25492536 if (features & NETIF_F_LRO)
2550− offloads |= GUEST_OFFLOAD_LRO_MASK &
2551− vi->guest_offloads_capable;
2537+ offloads = vi->guest_offloads_capable;
25522538 else
2553− offloads &= ~GUEST_OFFLOAD_LRO_MASK;
2554− }
2539+ offloads = vi->guest_offloads_capable &
2540+ ~GUEST_OFFLOAD_LRO_MASK;
25552541
2556− if ((dev->features ^ features) & NETIF_F_RXCSUM) {
2557− if (features & NETIF_F_RXCSUM)
2558− offloads |= GUEST_OFFLOAD_CSUM_MASK &
2559− vi->guest_offloads_capable;
2560− else
2561− offloads &= ~GUEST_OFFLOAD_CSUM_MASK;
2542+ err = virtnet_set_guest_offloads(vi, offloads);
2543+ if (err)
2544+ return err;
2545+ vi->guest_offloads = offloads;
25622546 }
25632547
2564− err = virtnet_set_guest_offloads(vi, offloads);
2565− if (err)
2566− return err;
2567−
2568− vi->guest_offloads = offloads;
25692548 return 0;
25702549 }
25712550
@@ -2584,7 +2563,6 @@ static const struct net_device_ops virtnet_netdev = { · 12 unmodified lines
25842563 .ndo_features_check = passthru_features_check,
25852564 .ndo_get_phys_port_name = virtnet_get_phys_port_name,
25862565 .ndo_set_features = virtnet_set_features,
2587− .ndo_fix_features = virtnet_fix_features,
25882566 };
25892567
25902568 static void virtnet_config_changed_work(struct work_struct *work)
@@ -3035,10 +3013,8 @@ static int virtnet_probe(struct virtio_device *vdev) · 444 unmodified lines
30353013 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
30363014 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
30373015 dev->features |= NETIF_F_LRO;
3038− if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
3039− dev->hw_features |= NETIF_F_RXCSUM;
3016+ if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
30403017 dev->hw_features |= NETIF_F_LRO;
3041− }
30423018
30433019 dev->vlan_features = dev->features;
30443020
drivers/net/wan/hdlc.c+9−1
@@ -46,7 +46,15 @@ static struct hdlc_proto *first_proto; · 45 unmodified lines
4646 static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
4747 struct packet_type *p, struct net_device *orig_dev)
4848 {
49− struct hdlc_device *hdlc = dev_to_hdlc(dev);
49+ struct hdlc_device *hdlc;
50+
51+ /* First make sure "dev" is an HDLC device */
52+ if (!(dev->priv_flags & IFF_WAN_HDLC)) {
53+ kfree_skb(skb);
54+ return NET_RX_SUCCESS;
55+ }
56+
57+ hdlc = dev_to_hdlc(dev);
5058
5159 if (!net_eq(dev_net(dev), &init_net)) {
5260 kfree_skb(skb);
drivers/net/wan/hdlc_raw_eth.c+1−0
@@ -99,6 +99,7 @@ static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr) · 98 unmodified lines
9999 old_qlen = dev->tx_queue_len;
100100 ether_setup(dev);
101101 dev->tx_queue_len = old_qlen;
102+ dev->priv_flags &= ~IFF_TX_SKB_SHARING;
102103 eth_hw_addr_random(dev);
103104 call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
104105 netif_dormant_off(dev);
drivers/net/wan/lmc/lmc_proto.c+0−4
@@ -89,17 +89,13 @@ __be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/ · 88 unmodified lines
8989 switch(sc->if_type){
9090 case LMC_PPP:
9191 return hdlc_type_trans(skb, sc->lmc_device);
92− break;
9392 case LMC_NET:
9493 return htons(ETH_P_802_2);
95− break;
9694 case LMC_RAW: /* Packet type for skbuff kind of useless */
9795 return htons(ETH_P_802_2);
98− break;
9996 default:
10097 printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
10198 return htons(ETH_P_802_2);
102− break;
10399 }
104100 }
105101
drivers/nfc/st21nfca/core.c+0−1
@@ -794,7 +794,6 @@ static int st21nfca_hci_im_transceive(struct nfc_hci_dev *hdev, · 793 unmodified lines
794794 skb->len,
795795 st21nfca_hci_data_exchange_cb,
796796 info);
797− break;
798797 default:
799798 return 1;
800799 }
drivers/nfc/trf7970a.c+0−1
@@ -1382,7 +1382,6 @@ static int trf7970a_is_iso15693_write_or_lock(u8 cmd) · 1381 unmodified lines
13821382 case ISO15693_CMD_WRITE_DSFID:
13831383 case ISO15693_CMD_LOCK_DSFID:
13841384 return 1;
1385− break;
13861385 default:
13871386 return 0;
13881387 }
include/linux/filter.h+9−0
@@ -607,12 +607,21 @@ struct bpf_skb_data_end { · 606 unmodified lines
607607 void *data_end;
608608 };
609609
610+struct bpf_nh_params {
611+ u32 nh_family;
612+ union {
613+ u32 ipv4_nh;
614+ struct in6_addr ipv6_nh;
615+ };
616+};
617+
610618 struct bpf_redirect_info {
611619 u32 flags;
612620 u32 tgt_index;
613621 void *tgt_value;
614622 struct bpf_map *map;
615623 u32 kern_flags;
624+ struct bpf_nh_params nh;
616625 };
617626
618627 DECLARE_PER_CPU(struct bpf_redirect_info, bpf_redirect_info);
include/linux/netlink.h+1−1
@@ -240,7 +240,7 @@ struct netlink_dump_control { · 239 unmodified lines
240240 int (*done)(struct netlink_callback *);
241241 void *data;
242242 struct module *module;
243− u16 min_dump_alloc;
243+ u32 min_dump_alloc;
244244 };
245245
246246 int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
include/net/netfilter/nf_tables.h+6−0
@@ -891,6 +891,12 @@ static inline struct nft_expr *nft_expr_last(const struct nft_rule *rule) · 890 unmodified lines
891891 return (struct nft_expr *)&rule->data[rule->dlen];
892892 }
893893
894+static inline bool nft_expr_more(const struct nft_rule *rule,
895+ const struct nft_expr *expr)
896+{
897+ return expr != nft_expr_last(rule) && expr->ops;
898+}
899+
894900 static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule)
895901 {
896902 return (void *)&rule->data[rule->dlen];
include/uapi/linux/bpf.h+18−4
@@ -3677,15 +3677,19 @@ union bpf_attr { · 3676 unmodified lines
36773677 * Return
36783678 * The id is returned or 0 in case the id could not be retrieved.
36793679 *
3680− * long bpf_redirect_neigh(u32 ifindex, u64 flags)
3680+ * long bpf_redirect_neigh(u32 ifindex, struct bpf_redir_neigh *params, int plen, u64 flags)
36813681 * Description
36823682 * Redirect the packet to another net device of index *ifindex*
36833683 * and fill in L2 addresses from neighboring subsystem. This helper
36843684 * is somewhat similar to **bpf_redirect**\ (), except that it
36853685 * populates L2 addresses as well, meaning, internally, the helper
3686− * performs a FIB lookup based on the skb's networking header to
3687− * get the address of the next hop and then relies on the neighbor
3688− * lookup for the L2 address of the nexthop.
3686+ * relies on the neighbor lookup for the L2 address of the nexthop.
3687+ *
3688+ * The helper will perform a FIB lookup based on the skb's
3689+ * networking header to get the address of the next hop, unless
3690+ * this is supplied by the caller in the *params* argument. The
3691+ * *plen* argument indicates the len of *params* and should be set
3692+ * to 0 if *params* is NULL.
36893693 *
36903694 * The *flags* argument is reserved and must be 0. The helper is
36913695 * currently only supported for tc BPF program types, and enabled
@@ -4906,6 +4910,16 @@ struct bpf_fib_lookup { · 1214 unmodified lines
49064910 __u8 dmac[6]; /* ETH_ALEN */
49074911 };
49084912
4913+struct bpf_redir_neigh {
4914+ /* network family for lookup (AF_INET, AF_INET6) */
4915+ __u32 nh_family;
4916+ /* network address of nexthop; skips fib lookup to find gateway */
4917+ union {
4918+ __be32 ipv4_nh;
4919+ __u32 ipv6_nh[4]; /* in6_addr; network order */
4920+ };
4921+};
4922+
49094923 enum bpf_task_fd_type {
49104924 BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */
49114925 BPF_FD_TYPE_TRACEPOINT, /* tp name */
kernel/bpf/syscall.c+0−1
@@ -2913,7 +2913,6 @@ attach_type_to_prog_type(enum bpf_attach_type attach_type) · 2912 unmodified lines
29132913 case BPF_CGROUP_INET_INGRESS:
29142914 case BPF_CGROUP_INET_EGRESS:
29152915 return BPF_PROG_TYPE_CGROUP_SKB;
2916− break;
29172916 case BPF_CGROUP_INET_SOCK_CREATE:
29182917 case BPF_CGROUP_INET_SOCK_RELEASE:
29192918 case BPF_CGROUP_INET4_POST_BIND:
kernel/bpf/verifier.c+5−6
@@ -5133,24 +5133,19 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn · 5132 unmodified lines
51335133 regs[BPF_REG_0].id = ++env->id_gen;
51345134 } else {
51355135 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE_OR_NULL;
5136− regs[BPF_REG_0].id = ++env->id_gen;
51375136 }
51385137 } else if (fn->ret_type == RET_PTR_TO_SOCKET_OR_NULL) {
51395138 mark_reg_known_zero(env, regs, BPF_REG_0);
51405139 regs[BPF_REG_0].type = PTR_TO_SOCKET_OR_NULL;
5141− regs[BPF_REG_0].id = ++env->id_gen;
51425140 } else if (fn->ret_type == RET_PTR_TO_SOCK_COMMON_OR_NULL) {
51435141 mark_reg_known_zero(env, regs, BPF_REG_0);
51445142 regs[BPF_REG_0].type = PTR_TO_SOCK_COMMON_OR_NULL;
5145− regs[BPF_REG_0].id = ++env->id_gen;
51465143 } else if (fn->ret_type == RET_PTR_TO_TCP_SOCK_OR_NULL) {
51475144 mark_reg_known_zero(env, regs, BPF_REG_0);
51485145 regs[BPF_REG_0].type = PTR_TO_TCP_SOCK_OR_NULL;
5149− regs[BPF_REG_0].id = ++env->id_gen;
51505146 } else if (fn->ret_type == RET_PTR_TO_ALLOC_MEM_OR_NULL) {
51515147 mark_reg_known_zero(env, regs, BPF_REG_0);
51525148 regs[BPF_REG_0].type = PTR_TO_MEM_OR_NULL;
5153− regs[BPF_REG_0].id = ++env->id_gen;
51545149 regs[BPF_REG_0].mem_size = meta.mem_size;
51555150 } else if (fn->ret_type == RET_PTR_TO_MEM_OR_BTF_ID_OR_NULL ||
51565151 fn->ret_type == RET_PTR_TO_MEM_OR_BTF_ID) {
@@ -5199,6 +5194,9 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn · 42 unmodified lines
51995194 return -EINVAL;
52005195 }
52015196
5197+ if (reg_type_may_be_null(regs[BPF_REG_0].type))
5198+ regs[BPF_REG_0].id = ++env->id_gen;
5199+
52025200 if (is_ptr_cast_function(func_id)) {
52035201 /* For release_reference() */
52045202 regs[BPF_REG_0].ref_obj_id = meta.ref_obj_id;
@@ -7212,7 +7210,8 @@ static void mark_ptr_or_null_reg(struct bpf_func_state *state, · 2007 unmodified lines
72127210 struct bpf_reg_state *reg, u32 id,
72137211 bool is_null)
72147212 {
7215− if (reg_type_may_be_null(reg->type) && reg->id == id) {
7213+ if (reg_type_may_be_null(reg->type) && reg->id == id &&
7214+ !WARN_ON_ONCE(!reg->id)) {
72167215 /* Old offset (both fixed and variable parts) should
72177216 * have been known-zero, because we don't allow pointer
72187217 * arithmetic on pointers that might be NULL.
net/bridge/netfilter/ebt_dnat.c+1−1
@@ -21,7 +21,7 @@ ebt_dnat_tg(struct sk_buff *skb, const struct xt_action_param *par) · 20 unmodified lines
2121 {
2222 const struct ebt_nat_info *info = par->targinfo;
2323
24− if (skb_ensure_writable(skb, ETH_ALEN))
24+ if (skb_ensure_writable(skb, 0))
2525 return EBT_DROP;
2626
2727 ether_addr_copy(eth_hdr(skb)->h_dest, info->mac);
net/bridge/netfilter/ebt_redirect.c+1−1
@@ -21,7 +21,7 @@ ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par) · 20 unmodified lines
2121 {
2222 const struct ebt_redirect_info *info = par->targinfo;
2323
24− if (skb_ensure_writable(skb, ETH_ALEN))
24+ if (skb_ensure_writable(skb, 0))
2525 return EBT_DROP;
2626
2727 if (xt_hooknum(par) != NF_BR_BROUTING)
net/bridge/netfilter/ebt_snat.c+1−1
@@ -22,7 +22,7 @@ ebt_snat_tg(struct sk_buff *skb, const struct xt_action_param *par) · 21 unmodified lines
2222 {
2323 const struct ebt_nat_info *info = par->targinfo;
2424
25− if (skb_ensure_writable(skb, ETH_ALEN * 2))
25+ if (skb_ensure_writable(skb, 0))
2626 return EBT_DROP;
2727
2828 ether_addr_copy(eth_hdr(skb)->h_source, info->mac);
net/core/dev.c+1−1
@@ -10213,7 +10213,7 @@ void netdev_run_todo(void) · 10212 unmodified lines
1021310213 struct net_device *dev = list_first_entry(&unlink_list,
1021410214 struct net_device,
1021510215 unlink_list);
10216− list_del(&dev->unlink_list);
10216+ list_del_init(&dev->unlink_list);
1021710217 dev->nested_level = dev->lower_level - 1;
1021810218 }
1021910219 #endif
net/core/filter.c+101−60
@@ -2165,12 +2165,12 @@ static int __bpf_redirect(struct sk_buff *skb, struct net_device *dev, · 2164 unmodified lines
21652165 }
21662166
21672167 #if IS_ENABLED(CONFIG_IPV6)
2168−static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb)
2168+static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb,
2169+ struct net_device *dev, struct bpf_nh_params *nh)
21692170 {
2170− struct dst_entry *dst = skb_dst(skb);
2171− struct net_device *dev = dst->dev;
21722171 u32 hh_len = LL_RESERVED_SPACE(dev);
21732172 const struct in6_addr *nexthop;
2173+ struct dst_entry *dst = NULL;
21742174 struct neighbour *neigh;
21752175
21762176 if (dev_xmit_recursion()) {
@@ -2196,8 +2196,13 @@ static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb) · 19 unmodified lines
21962196 }
21972197
21982198 rcu_read_lock_bh();
2199− nexthop = rt6_nexthop(container_of(dst, struct rt6_info, dst),
2200− &ipv6_hdr(skb)->daddr);
2199+ if (!nh) {
2200+ dst = skb_dst(skb);
2201+ nexthop = rt6_nexthop(container_of(dst, struct rt6_info, dst),
2202+ &ipv6_hdr(skb)->daddr);
2203+ } else {
2204+ nexthop = &nh->ipv6_nh;
2205+ }
22012206 neigh = ip_neigh_gw6(dev, nexthop);
22022207 if (likely(!IS_ERR(neigh))) {
22032208 int ret;
@@ -2210,36 +2215,43 @@ static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb) · 6 unmodified lines
22102215 return ret;
22112216 }
22122217 rcu_read_unlock_bh();
2213− IP6_INC_STATS(dev_net(dst->dev),
2214− ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
2218+ if (dst)
2219+ IP6_INC_STATS(dev_net(dst->dev),
2220+ ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
22152221 out_drop:
22162222 kfree_skb(skb);
22172223 return -ENETDOWN;
22182224 }
22192225
2220−static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev)
2226+static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev,
2227+ struct bpf_nh_params *nh)
22212228 {
22222229 const struct ipv6hdr *ip6h = ipv6_hdr(skb);
22232230 struct net *net = dev_net(dev);
22242231 int err, ret = NET_XMIT_DROP;
2225− struct dst_entry *dst;
2226− struct flowi6 fl6 = {
2227− .flowi6_flags = FLOWI_FLAG_ANYSRC,
2228− .flowi6_mark = skb->mark,
2229− .flowlabel = ip6_flowinfo(ip6h),
2230− .flowi6_oif = dev->ifindex,
2231− .flowi6_proto = ip6h->nexthdr,
2232− .daddr = ip6h->daddr,
2233− .saddr = ip6h->saddr,
2234− };
22352232
2236− dst = ipv6_stub->ipv6_dst_lookup_flow(net, NULL, &fl6, NULL);
2237− if (IS_ERR(dst))
2238− goto out_drop;
2233+ if (!nh) {
2234+ struct dst_entry *dst;
2235+ struct flowi6 fl6 = {
2236+ .flowi6_flags = FLOWI_FLAG_ANYSRC,
2237+ .flowi6_mark = skb->mark,
2238+ .flowlabel = ip6_flowinfo(ip6h),
2239+ .flowi6_oif = dev->ifindex,
2240+ .flowi6_proto = ip6h->nexthdr,
2241+ .daddr = ip6h->daddr,
2242+ .saddr = ip6h->saddr,
2243+ };
2244+
2245+ dst = ipv6_stub->ipv6_dst_lookup_flow(net, NULL, &fl6, NULL);
2246+ if (IS_ERR(dst))
2247+ goto out_drop;
22392248
2240− skb_dst_set(skb, dst);
2249+ skb_dst_set(skb, dst);
2250+ } else if (nh->nh_family != AF_INET6) {
2251+ goto out_drop;
2252+ }
22412253
2242− err = bpf_out_neigh_v6(net, skb);
2254+ err = bpf_out_neigh_v6(net, skb, dev, nh);
22432255 if (unlikely(net_xmit_eval(err)))
22442256 dev->stats.tx_errors++;
22452257 else
@@ -2252,7 +2264,8 @@ out_xmit: · 6 unmodified lines
22522264 return ret;
22532265 }
22542266 #else
2255−static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev)
2267+static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev,
2268+ struct bpf_nh_params *nh)
22562269 {
22572270 kfree_skb(skb);
22582271 return NET_XMIT_DROP;
@@ -2260,11 +2273,9 @@ static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev) · 1 unmodified line
22602273 #endif /* CONFIG_IPV6 */
22612274
22622275 #if IS_ENABLED(CONFIG_INET)
2263−static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb)
2276+static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb,
2277+ struct net_device *dev, struct bpf_nh_params *nh)
22642278 {
2265− struct dst_entry *dst = skb_dst(skb);
2266− struct rtable *rt = container_of(dst, struct rtable, dst);
2267− struct net_device *dev = dst->dev;
22682279 u32 hh_len = LL_RESERVED_SPACE(dev);
22692280 struct neighbour *neigh;
22702281 bool is_v6gw = false;
@@ -2292,7 +2303,21 @@ static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb) · 21 unmodified lines
22922303 }
22932304
22942305 rcu_read_lock_bh();
2295− neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
2306+ if (!nh) {
2307+ struct dst_entry *dst = skb_dst(skb);
2308+ struct rtable *rt = container_of(dst, struct rtable, dst);
2309+
2310+ neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
2311+ } else if (nh->nh_family == AF_INET6) {
2312+ neigh = ip_neigh_gw6(dev, &nh->ipv6_nh);
2313+ is_v6gw = true;
2314+ } else if (nh->nh_family == AF_INET) {
2315+ neigh = ip_neigh_gw4(dev, nh->ipv4_nh);
2316+ } else {
2317+ rcu_read_unlock_bh();
2318+ goto out_drop;
2319+ }
2320+
22962321 if (likely(!IS_ERR(neigh))) {
22972322 int ret;
22982323
@@ -2309,33 +2334,37 @@ out_drop: · 10 unmodified lines
23092334 return -ENETDOWN;
23102335 }
23112336
2312−static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev)
2337+static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,
2338+ struct bpf_nh_params *nh)
23132339 {
23142340 const struct iphdr *ip4h = ip_hdr(skb);
23152341 struct net *net = dev_net(dev);
23162342 int err, ret = NET_XMIT_DROP;
2317− struct rtable *rt;
2318− struct flowi4 fl4 = {
2319− .flowi4_flags = FLOWI_FLAG_ANYSRC,
2320− .flowi4_mark = skb->mark,
2321− .flowi4_tos = RT_TOS(ip4h->tos),
2322− .flowi4_oif = dev->ifindex,
2323− .flowi4_proto = ip4h->protocol,
2324− .daddr = ip4h->daddr,
2325− .saddr = ip4h->saddr,
2326− };
23272343
2328− rt = ip_route_output_flow(net, &fl4, NULL);
2329− if (IS_ERR(rt))
2330− goto out_drop;
2331− if (rt->rt_type != RTN_UNICAST && rt->rt_type != RTN_LOCAL) {
2332− ip_rt_put(rt);
2333− goto out_drop;
2334− }
2344+ if (!nh) {
2345+ struct flowi4 fl4 = {
2346+ .flowi4_flags = FLOWI_FLAG_ANYSRC,
2347+ .flowi4_mark = skb->mark,
2348+ .flowi4_tos = RT_TOS(ip4h->tos),
2349+ .flowi4_oif = dev->ifindex,
2350+ .flowi4_proto = ip4h->protocol,
2351+ .daddr = ip4h->daddr,
2352+ .saddr = ip4h->saddr,
2353+ };
2354+ struct rtable *rt;
2355+
2356+ rt = ip_route_output_flow(net, &fl4, NULL);
2357+ if (IS_ERR(rt))
2358+ goto out_drop;
2359+ if (rt->rt_type != RTN_UNICAST && rt->rt_type != RTN_LOCAL) {
2360+ ip_rt_put(rt);
2361+ goto out_drop;
2362+ }
23352363
2336− skb_dst_set(skb, &rt->dst);
2364+ skb_dst_set(skb, &rt->dst);
2365+ }
23372366
2338− err = bpf_out_neigh_v4(net, skb);
2367+ err = bpf_out_neigh_v4(net, skb, dev, nh);
23392368 if (unlikely(net_xmit_eval(err)))
23402369 dev->stats.tx_errors++;
23412370 else
@@ -2348,14 +2377,16 @@ out_xmit: · 6 unmodified lines
23482377 return ret;
23492378 }
23502379 #else
2351−static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev)
2380+static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,
2381+ struct bpf_nh_params *nh)
23522382 {
23532383 kfree_skb(skb);
23542384 return NET_XMIT_DROP;
23552385 }
23562386 #endif /* CONFIG_INET */
23572387
2358−static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev)
2388+static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev,
2389+ struct bpf_nh_params *nh)
23592390 {
23602391 struct ethhdr *ethh = eth_hdr(skb);
23612392
@@ -2370,9 +2401,9 @@ static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev) · 8 unmodified lines
23702401 skb_reset_network_header(skb);
23712402
23722403 if (skb->protocol == htons(ETH_P_IP))
2373− return __bpf_redirect_neigh_v4(skb, dev);
2404+ return __bpf_redirect_neigh_v4(skb, dev, nh);
23742405 else if (skb->protocol == htons(ETH_P_IPV6))
2375− return __bpf_redirect_neigh_v6(skb, dev);
2406+ return __bpf_redirect_neigh_v6(skb, dev, nh);
23762407 out:
23772408 kfree_skb(skb);
23782409 return -ENOTSUPP;
@@ -2382,7 +2413,8 @@ out: · 3 unmodified lines
23822413 enum {
23832414 BPF_F_NEIGH = (1ULL << 1),
23842415 BPF_F_PEER = (1ULL << 2),
2385−#define BPF_F_REDIRECT_INTERNAL (BPF_F_NEIGH | BPF_F_PEER)
2416+ BPF_F_NEXTHOP = (1ULL << 3),
2417+#define BPF_F_REDIRECT_INTERNAL (BPF_F_NEIGH | BPF_F_PEER | BPF_F_NEXTHOP)
23862418 };
23872419
23882420 BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags)
@@ -2455,7 +2487,8 @@ int skb_do_redirect(struct sk_buff *skb) · 66 unmodified lines
24552487 return -EAGAIN;
24562488 }
24572489 return flags & BPF_F_NEIGH ?
2458− __bpf_redirect_neigh(skb, dev) :
2490+ __bpf_redirect_neigh(skb, dev, flags & BPF_F_NEXTHOP ?
2491+ &ri->nh : NULL) :
24592492 __bpf_redirect(skb, dev, flags);
24602493 out_drop:
24612494 kfree_skb(skb);
@@ -2504,16 +2537,21 @@ static const struct bpf_func_proto bpf_redirect_peer_proto = { · 42 unmodified lines
25042537 .arg2_type = ARG_ANYTHING,
25052538 };
25062539
2507−BPF_CALL_2(bpf_redirect_neigh, u32, ifindex, u64, flags)
2540+BPF_CALL_4(bpf_redirect_neigh, u32, ifindex, struct bpf_redir_neigh *, params,
2541+ int, plen, u64, flags)
25082542 {
25092543 struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);
25102544
2511− if (unlikely(flags))
2545+ if (unlikely((plen && plen < sizeof(*params)) || flags))
25122546 return TC_ACT_SHOT;
25132547
2514− ri->flags = BPF_F_NEIGH;
2548+ ri->flags = BPF_F_NEIGH | (plen ? BPF_F_NEXTHOP : 0);
25152549 ri->tgt_index = ifindex;
25162550
2551+ BUILD_BUG_ON(sizeof(struct bpf_redir_neigh) != sizeof(struct bpf_nh_params));
2552+ if (plen)
2553+ memcpy(&ri->nh, params, sizeof(ri->nh));
2554+
25172555 return TC_ACT_REDIRECT;
25182556 }
25192557
@@ -2522,7 +2560,9 @@ static const struct bpf_func_proto bpf_redirect_neigh_proto = { · 2 unmodified lines
25222560 .gpl_only = false,
25232561 .ret_type = RET_INTEGER,
25242562 .arg1_type = ARG_ANYTHING,
2525− .arg2_type = ARG_ANYTHING,
2563+ .arg2_type = ARG_PTR_TO_MEM_OR_NULL,
2564+ .arg3_type = ARG_CONST_SIZE_OR_ZERO,
2565+ .arg4_type = ARG_ANYTHING,
25262566 };
25272567
25282568 BPF_CALL_2(bpf_msg_apply_bytes, struct sk_msg *, msg, u32, bytes)
@@ -4693,7 +4733,8 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname, · 2164 unmodified lines
46934733 cmpxchg(&sk->sk_pacing_status,
46944734 SK_PACING_NONE,
46954735 SK_PACING_NEEDED);
4696− sk->sk_max_pacing_rate = (val == ~0U) ? ~0UL : val;
4736+ sk->sk_max_pacing_rate = (val == ~0U) ?
4737+ ~0UL : (unsigned int)val;
46974738 sk->sk_pacing_rate = min(sk->sk_pacing_rate,
46984739 sk->sk_max_pacing_rate);
46994740 break;
net/core/rtnetlink.c+6−7
@@ -3709,13 +3709,13 @@ static int rtnl_dellinkprop(struct sk_buff *skb, struct nlmsghdr *nlh, · 3708 unmodified lines
37093709 return rtnl_linkprop(RTM_DELLINKPROP, skb, nlh, extack);
37103710 }
37113711
3712−static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
3712+static u32 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
37133713 {
37143714 struct net *net = sock_net(skb->sk);
3715− struct net_device *dev;
3715+ size_t min_ifinfo_dump_size = 0;
37163716 struct nlattr *tb[IFLA_MAX+1];
37173717 u32 ext_filter_mask = 0;
3718− u16 min_ifinfo_dump_size = 0;
3718+ struct net_device *dev;
37193719 int hdrlen;
37203720
37213721 /* Same kernel<->userspace interface hack as in rtnl_dump_ifinfo. */
@@ -3735,9 +3735,8 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh) · 13 unmodified lines
37353735 */
37363736 rcu_read_lock();
37373737 for_each_netdev_rcu(net, dev) {
3738− min_ifinfo_dump_size = max_t(u16, min_ifinfo_dump_size,
3739− if_nlmsg_size(dev,
3740− ext_filter_mask));
3738+ min_ifinfo_dump_size = max(min_ifinfo_dump_size,
3739+ if_nlmsg_size(dev, ext_filter_mask));
37413740 }
37423741 rcu_read_unlock();
37433742
@@ -5494,7 +5493,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, · 1750 unmodified lines
54945493 if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
54955494 struct sock *rtnl;
54965495 rtnl_dumpit_func dumpit;
5497− u16 min_dump_alloc = 0;
5496+ u32 min_dump_alloc = 0;
54985497
54995498 link = rtnl_get_link(family, type);
55005499 if (!link || !link->dumpit) {
net/core/sock.c+1−1
@@ -1163,7 +1163,7 @@ set_sndbuf: · 1162 unmodified lines
11631163
11641164 case SO_MAX_PACING_RATE:
11651165 {
1166− unsigned long ulval = (val == ~0U) ? ~0UL : val;
1166+ unsigned long ulval = (val == ~0U) ? ~0UL : (unsigned int)val;
11671167
11681168 if (sizeof(ulval) != sizeof(val) &&
11691169 optlen >= sizeof(ulval) &&
net/dsa/tag_ksz.c+2−0
@@ -123,6 +123,7 @@ static const struct dsa_device_ops ksz8795_netdev_ops = { · 122 unmodified lines
123123 .xmit = ksz8795_xmit,
124124 .rcv = ksz8795_rcv,
125125 .overhead = KSZ_INGRESS_TAG_LEN,
126+ .tail_tag = true,
126127 };
127128
128129 DSA_TAG_DRIVER(ksz8795_netdev_ops);
@@ -199,6 +200,7 @@ static const struct dsa_device_ops ksz9477_netdev_ops = { · 70 unmodified lines
199200 .xmit = ksz9477_xmit,
200201 .rcv = ksz9477_rcv,
201202 .overhead = KSZ9477_INGRESS_TAG_LEN,
203+ .tail_tag = true,
202204 };
203205
204206 DSA_TAG_DRIVER(ksz9477_netdev_ops);
net/ipv4/icmp.c+5−2
@@ -239,7 +239,7 @@ static struct { · 238 unmodified lines
239239 /**
240240 * icmp_global_allow - Are we allowed to send one more ICMP message ?
241241 *
242− * Uses a token bucket to limit our ICMP messages to sysctl_icmp_msgs_per_sec.
242+ * Uses a token bucket to limit our ICMP messages to ~sysctl_icmp_msgs_per_sec.
243243 * Returns false if we reached the limit and can not send another packet.
244244 * Note: called with BH disabled
245245 */
@@ -267,7 +267,10 @@ bool icmp_global_allow(void) · 21 unmodified lines
267267 }
268268 credit = min_t(u32, icmp_global.credit + incr, sysctl_icmp_msgs_burst);
269269 if (credit) {
270− credit--;
270+ /* We want to use a credit of one in average, but need to randomize
271+ * it for security reasons.
272+ */
273+ credit = max_t(int, credit - prandom_u32_max(3), 0);
271274 rc = true;
272275 }
273276 WRITE_ONCE(icmp_global.credit, credit);
net/ipv4/nexthop.c+1−1
@@ -845,7 +845,7 @@ static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh, · 844 unmodified lines
845845 remove_nh_grp_entry(net, nhge, nlinfo);
846846
847847 /* make sure all see the newly published array before releasing rtnl */
848− synchronize_rcu();
848+ synchronize_net();
849849 }
850850
851851 static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo)
net/ipv4/tcp_input.c+2−0
@@ -5827,6 +5827,8 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) · 5826 unmodified lines
58275827 tcp_data_snd_check(sk);
58285828 if (!inet_csk_ack_scheduled(sk))
58295829 goto no_ack;
5830+ } else {
5831+ tcp_update_wl(tp, TCP_SKB_CB(skb)->seq);
58305832 }
58315833
58325834 __tcp_ack_snd_check(sk, 0);
net/ipv6/netfilter/nf_conntrack_reasm.c+1−0
@@ -355,6 +355,7 @@ static int nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *skb, · 354 unmodified lines
355355 ipv6_hdr(skb)->payload_len = htons(payload_len);
356356 ipv6_change_dsfield(ipv6_hdr(skb), 0xff, ecn);
357357 IP6CB(skb)->frag_max_size = sizeof(struct ipv6hdr) + fq->q.max_size;
358+ IP6CB(skb)->flags |= IP6SKB_FRAGMENTED;
358359
359360 /* Yes, and fold redundant checksum back. 8) */
360361 if (skb->ip_summed == CHECKSUM_COMPLETE)
net/mpls/mpls_iptunnel.c+1−0
@@ -300,5 +300,6 @@ static void __exit mpls_iptunnel_exit(void) · 299 unmodified lines
300300 module_exit(mpls_iptunnel_exit);
301301
302302 MODULE_ALIAS_RTNL_LWT(MPLS);
303+MODULE_SOFTDEP("post: mpls_gso");
303304 MODULE_DESCRIPTION("MultiProtocol Label Switching IP Tunnels");
304305 MODULE_LICENSE("GPL v2");
net/mptcp/Kconfig+2−4
@@ -19,14 +19,11 @@ config INET_MPTCP_DIAG · 18 unmodified lines
1919
2020 config MPTCP_IPV6
2121 bool "MPTCP: IPv6 support for Multipath TCP"
22− select IPV6
22+ depends on IPV6=y
2323 default y
2424
25−endif
26−
2725 config MPTCP_KUNIT_TESTS
2826 tristate "This builds the MPTCP KUnit tests" if !KUNIT_ALL_TESTS
29− select MPTCP
3027 depends on KUNIT
3128 default KUNIT_ALL_TESTS
3229 help
@@ -39,3 +36,4 @@ config MPTCP_KUNIT_TESTS · 6 unmodified lines
3936
4037 If unsure, say N.
4138
39+endif
net/mptcp/options.c+2−1
@@ -241,7 +241,6 @@ static void mptcp_parse_option(const struct sk_buff *skb, · 240 unmodified lines
241241 }
242242
243243 mp_opt->add_addr = 1;
244− mp_opt->port = 0;
245244 mp_opt->addr_id = *ptr++;
246245 pr_debug("ADD_ADDR: id=%d, echo=%d", mp_opt->addr_id, mp_opt->echo);
247246 if (mp_opt->family == MPTCP_ADDR_IPVERSION_4) {
@@ -297,6 +296,8 @@ void mptcp_get_options(const struct sk_buff *skb, · 49 unmodified lines
297296 mp_opt->mp_capable = 0;
298297 mp_opt->mp_join = 0;
299298 mp_opt->add_addr = 0;
299+ mp_opt->ahmac = 0;
300+ mp_opt->port = 0;
300301 mp_opt->rm_addr = 0;
301302 mp_opt->dss = 0;
302303
net/netfilter/ipvs/ip_vs_proto_tcp.c+6−4
@@ -539,8 +539,8 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp, · 538 unmodified lines
539539 if (new_state != cp->state) {
540540 struct ip_vs_dest *dest = cp->dest;
541541
542− IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] %s:%d->"
543− "%s:%d state: %s->%s conn->refcnt:%d\n",
542+ IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] c:%s:%d v:%s:%d "
543+ "d:%s:%d state: %s->%s conn->refcnt:%d\n",
544544 pd->pp->name,
545545 ((state_off == TCP_DIR_OUTPUT) ?
546546 "output " : "input "),
@@ -548,10 +548,12 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp, · 1 unmodified line
548548 th->fin ? 'F' : '.',
549549 th->ack ? 'A' : '.',
550550 th->rst ? 'R' : '.',
551− IP_VS_DBG_ADDR(cp->daf, &cp->daddr),
552− ntohs(cp->dport),
553551 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
554552 ntohs(cp->cport),
553+ IP_VS_DBG_ADDR(cp->af, &cp->vaddr),
554+ ntohs(cp->vport),
555+ IP_VS_DBG_ADDR(cp->daf, &cp->daddr),
556+ ntohs(cp->dport),
555557 tcp_state_name(cp->state),
556558 tcp_state_name(new_state),
557559 refcount_read(&cp->refcnt));
net/netfilter/nf_conntrack_proto_tcp.c+13−6
@@ -541,13 +541,20 @@ static bool tcp_in_window(const struct nf_conn *ct, · 540 unmodified lines
541541 swin = win << sender->td_scale;
542542 sender->td_maxwin = (swin == 0 ? 1 : swin);
543543 sender->td_maxend = end + sender->td_maxwin;
544− /*
545− * We haven't seen traffic in the other direction yet
546− * but we have to tweak window tracking to pass III
547− * and IV until that happens.
548− */
549− if (receiver->td_maxwin == 0)
544+ if (receiver->td_maxwin == 0) {
545+ /* We haven't seen traffic in the other
546+ * direction yet but we have to tweak window
547+ * tracking to pass III and IV until that
548+ * happens.
549+ */
550550 receiver->td_end = receiver->td_maxend = sack;
551+ } else if (sack == receiver->td_end + 1) {
552+ /* Likely a reply to a keepalive.
553+ * Needed for III.
554+ */
555+ receiver->td_end++;
556+ }
557+
551558 }
552559 } else if (((state->state == TCP_CONNTRACK_SYN_SENT
553560 && dir == IP_CT_DIR_ORIGINAL)
net/netfilter/nf_dup_netdev.c+1−0
@@ -19,6 +19,7 @@ static void nf_do_netdev_egress(struct sk_buff *skb, struct net_device *dev) · 18 unmodified lines
1919 skb_push(skb, skb->mac_len);
2020
2121 skb->dev = dev;
22+ skb->tstamp = 0;
2223 dev_queue_xmit(skb);
2324 }
2425
net/netfilter/nf_tables_api.c+3−3
@@ -302,7 +302,7 @@ static void nft_rule_expr_activate(const struct nft_ctx *ctx, · 301 unmodified lines
302302 struct nft_expr *expr;
303303
304304 expr = nft_expr_first(rule);
305− while (expr != nft_expr_last(rule) && expr->ops) {
305+ while (nft_expr_more(rule, expr)) {
306306 if (expr->ops->activate)
307307 expr->ops->activate(ctx, expr);
308308
@@ -317,7 +317,7 @@ static void nft_rule_expr_deactivate(const struct nft_ctx *ctx, · 8 unmodified lines
317317 struct nft_expr *expr;
318318
319319 expr = nft_expr_first(rule);
320− while (expr != nft_expr_last(rule) && expr->ops) {
320+ while (nft_expr_more(rule, expr)) {
321321 if (expr->ops->deactivate)
322322 expr->ops->deactivate(ctx, expr, phase);
323323
@@ -3080,7 +3080,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx, · 2756 unmodified lines
30803080 * is called on error from nf_tables_newrule().
30813081 */
30823082 expr = nft_expr_first(rule);
3083− while (expr != nft_expr_last(rule) && expr->ops) {
3083+ while (nft_expr_more(rule, expr)) {
30843084 next = nft_expr_next(expr);
30853085 nf_tables_expr_destroy(ctx, expr);
30863086 expr = next;
net/netfilter/nf_tables_offload.c+2−2
@@ -37,7 +37,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net, · 36 unmodified lines
3737 struct nft_expr *expr;
3838
3939 expr = nft_expr_first(rule);
40− while (expr->ops && expr != nft_expr_last(rule)) {
40+ while (nft_expr_more(rule, expr)) {
4141 if (expr->ops->offload_flags & NFT_OFFLOAD_F_ACTION)
4242 num_actions++;
4343
@@ -61,7 +61,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net, · 17 unmodified lines
6161 ctx->net = net;
6262 ctx->dep.type = NFT_OFFLOAD_DEP_UNSPEC;
6363
64− while (expr->ops && expr != nft_expr_last(rule)) {
64+ while (nft_expr_more(rule, expr)) {
6565 if (!expr->ops->offload) {
6666 err = -EOPNOTSUPP;
6767 goto err_out;
net/netfilter/nft_fwd_netdev.c+1−0
@@ -138,6 +138,7 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr, · 137 unmodified lines
138138 return;
139139
140140 skb->dev = dev;
141+ skb->tstamp = 0;
141142 neigh_xmit(neigh_table, dev, addr, skb);
142143 out:
143144 regs->verdict.code = verdict;
net/nfc/netlink.c+1−1
@@ -1217,7 +1217,7 @@ static int nfc_genl_fw_download(struct sk_buff *skb, struct genl_info *info) · 1216 unmodified lines
12171217 u32 idx;
12181218 char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
12191219
1220− if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
1220+ if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || !info->attrs[NFC_ATTR_FIRMWARE_NAME])
12211221 return -EINVAL;
12221222
12231223 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
net/openvswitch/flow_table.c+35−23
@@ -175,7 +175,7 @@ static struct table_instance *table_instance_alloc(int new_size) · 174 unmodified lines
175175
176176 static void __mask_array_destroy(struct mask_array *ma)
177177 {
178− free_percpu(ma->masks_usage_cntr);
178+ free_percpu(ma->masks_usage_stats);
179179 kfree(ma);
180180 }
181181
@@ -199,15 +199,15 @@ static void tbl_mask_array_reset_counters(struct mask_array *ma) · 17 unmodified lines
199199 ma->masks_usage_zero_cntr[i] = 0;
200200
201201 for_each_possible_cpu(cpu) {
202− u64 *usage_counters = per_cpu_ptr(ma->masks_usage_cntr,
203− cpu);
202+ struct mask_array_stats *stats;
204203 unsigned int start;
205204 u64 counter;
206205
206+ stats = per_cpu_ptr(ma->masks_usage_stats, cpu);
207207 do {
208− start = u64_stats_fetch_begin_irq(&ma->syncp);
209− counter = usage_counters[i];
210− } while (u64_stats_fetch_retry_irq(&ma->syncp, start));
208+ start = u64_stats_fetch_begin_irq(&stats->syncp);
209+ counter = stats->usage_cntrs[i];
210+ } while (u64_stats_fetch_retry_irq(&stats->syncp, start));
211211
212212 ma->masks_usage_zero_cntr[i] += counter;
213213 }
@@ -230,9 +230,10 @@ static struct mask_array *tbl_mask_array_alloc(int size) · 16 unmodified lines
230230 sizeof(struct sw_flow_mask *) *
231231 size);
232232
233− new->masks_usage_cntr = __alloc_percpu(sizeof(u64) * size,
234− __alignof__(u64));
235− if (!new->masks_usage_cntr) {
233+ new->masks_usage_stats = __alloc_percpu(sizeof(struct mask_array_stats) +
234+ sizeof(u64) * size,
235+ __alignof__(u64));
236+ if (!new->masks_usage_stats) {
236237 kfree(new);
237238 return NULL;
238239 }
@@ -722,6 +723,8 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti, · 483 unmodified lines
722723
723724 /* Flow lookup does full lookup on flow table. It starts with
724725 * mask from index passed in *index.
726+ * This function MUST be called with BH disabled due to the use
727+ * of CPU specific variables.
725728 */
726729 static struct sw_flow *flow_lookup(struct flow_table *tbl,
727730 struct table_instance *ti,
@@ -731,7 +734,7 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl, · 3 unmodified lines
731734 u32 *n_cache_hit,
732735 u32 *index)
733736 {
734− u64 *usage_counters = this_cpu_ptr(ma->masks_usage_cntr);
737+ struct mask_array_stats *stats = this_cpu_ptr(ma->masks_usage_stats);
735738 struct sw_flow *flow;
736739 struct sw_flow_mask *mask;
737740 int i;
@@ -741,9 +744,9 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl, · 3 unmodified lines
741744 if (mask) {
742745 flow = masked_flow_lookup(ti, key, mask, n_mask_hit);
743746 if (flow) {
744− u64_stats_update_begin(&ma->syncp);
745− usage_counters[*index]++;
746− u64_stats_update_end(&ma->syncp);
747+ u64_stats_update_begin(&stats->syncp);
748+ stats->usage_cntrs[*index]++;
749+ u64_stats_update_end(&stats->syncp);
747750 (*n_cache_hit)++;
748751 return flow;
749752 }
@@ -762,9 +765,9 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl, · 12 unmodified lines
762765 flow = masked_flow_lookup(ti, key, mask, n_mask_hit);
763766 if (flow) { /* Found */
764767 *index = i;
765− u64_stats_update_begin(&ma->syncp);
766− usage_counters[*index]++;
767− u64_stats_update_end(&ma->syncp);
768+ u64_stats_update_begin(&stats->syncp);
769+ stats->usage_cntrs[*index]++;
770+ u64_stats_update_end(&stats->syncp);
768771 return flow;
769772 }
770773 }
@@ -850,9 +853,17 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl, · 79 unmodified lines
850853 struct mask_array *ma = rcu_dereference_ovsl(tbl->mask_array);
851854 u32 __always_unused n_mask_hit;
852855 u32 __always_unused n_cache_hit;
856+ struct sw_flow *flow;
853857 u32 index = 0;
854858
855− return flow_lookup(tbl, ti, ma, key, &n_mask_hit, &n_cache_hit, &index);
859+ /* This function gets called trough the netlink interface and therefore
860+ * is preemptible. However, flow_lookup() function needs to be called
861+ * with BH disabled due to CPU specific variables.
862+ */
863+ local_bh_disable();
864+ flow = flow_lookup(tbl, ti, ma, key, &n_mask_hit, &n_cache_hit, &index);
865+ local_bh_enable();
866+ return flow;
856867 }
857868
858869 struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
@@ -1109,7 +1120,6 @@ void ovs_flow_masks_rebalance(struct flow_table *table) · 250 unmodified lines
11091120
11101121 for (i = 0; i < ma->max; i++) {
11111122 struct sw_flow_mask *mask;
1112− unsigned int start;
11131123 int cpu;
11141124
11151125 mask = rcu_dereference_ovsl(ma->masks[i]);
@@ -1120,14 +1130,16 @@ void ovs_flow_masks_rebalance(struct flow_table *table) · 4 unmodified lines
11201130 masks_and_count[i].counter = 0;
11211131
11221132 for_each_possible_cpu(cpu) {
1123− u64 *usage_counters = per_cpu_ptr(ma->masks_usage_cntr,
1124− cpu);
1133+ struct mask_array_stats *stats;
1134+ unsigned int start;
11251135 u64 counter;
11261136
1137+ stats = per_cpu_ptr(ma->masks_usage_stats, cpu);
11271138 do {
1128− start = u64_stats_fetch_begin_irq(&ma->syncp);
1129− counter = usage_counters[i];
1130− } while (u64_stats_fetch_retry_irq(&ma->syncp, start));
1139+ start = u64_stats_fetch_begin_irq(&stats->syncp);
1140+ counter = stats->usage_cntrs[i];
1141+ } while (u64_stats_fetch_retry_irq(&stats->syncp,
1142+ start));
11311143
11321144 masks_and_count[i].counter += counter;
11331145 }
net/openvswitch/flow_table.h+6−2
@@ -38,12 +38,16 @@ struct mask_count { · 37 unmodified lines
3838 u64 counter;
3939 };
4040
41+struct mask_array_stats {
42+ struct u64_stats_sync syncp;
43+ u64 usage_cntrs[];
44+};
45+
4146 struct mask_array {
4247 struct rcu_head rcu;
4348 int count, max;
44− u64 __percpu *masks_usage_cntr;
49+ struct mask_array_stats __percpu *masks_usage_stats;
4550 u64 *masks_usage_zero_cntr;
46− struct u64_stats_sync syncp;
4751 struct sw_flow_mask __rcu *masks[];
4852 };
4953
net/sched/act_ct.c+2−2
@@ -156,11 +156,11 @@ tcf_ct_flow_table_add_action_nat_udp(const struct nf_conntrack_tuple *tuple, · 155 unmodified lines
156156 __be16 target_dst = target.dst.u.udp.port;
157157
158158 if (target_src != tuple->src.u.udp.port)
159− tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_TCP,
159+ tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_UDP,
160160 offsetof(struct udphdr, source),
161161 0xFFFF, be16_to_cpu(target_src));
162162 if (target_dst != tuple->dst.u.udp.port)
163− tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_TCP,
163+ tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_UDP,
164164 offsetof(struct udphdr, dest),
165165 0xFFFF, be16_to_cpu(target_dst));
166166 }
net/sched/act_tunnel_key.c+1−1
@@ -459,7 +459,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, · 458 unmodified lines
459459
460460 metadata = __ipv6_tun_set_dst(&saddr, &daddr, tos, ttl, dst_port,
461461 0, flags,
462− key_id, 0);
462+ key_id, opts_len);
463463 } else {
464464 NL_SET_ERR_MSG(extack, "Missing either ipv4 or ipv6 src and dst");
465465 ret = -EINVAL;
net/sched/cls_api.c+1−1
@@ -3712,7 +3712,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, · 3711 unmodified lines
37123712 entry->gate.num_entries = tcf_gate_num_entries(act);
37133713 err = tcf_gate_get_entries(entry, act);
37143714 if (err)
3715− goto err_out;
3715+ goto err_out_locked;
37163716 } else {
37173717 err = -EOPNOTSUPP;
37183718 goto err_out_locked;
net/tipc/bcast.c+8−2
@@ -108,6 +108,8 @@ static void tipc_bcbase_select_primary(struct net *net) · 107 unmodified lines
108108 {
109109 struct tipc_bc_base *bb = tipc_bc_base(net);
110110 int all_dests = tipc_link_bc_peers(bb->link);
111+ int max_win = tipc_link_max_win(bb->link);
112+ int min_win = tipc_link_min_win(bb->link);
111113 int i, mtu, prim;
112114
113115 bb->primary_bearer = INVALID_BEARER_ID;
@@ -121,8 +123,12 @@ static void tipc_bcbase_select_primary(struct net *net) · 7 unmodified lines
121123 continue;
122124
123125 mtu = tipc_bearer_mtu(net, i);
124− if (mtu < tipc_link_mtu(bb->link))
126+ if (mtu < tipc_link_mtu(bb->link)) {
125127 tipc_link_set_mtu(bb->link, mtu);
128+ tipc_link_set_queue_limits(bb->link,
129+ min_win,
130+ max_win);
131+ }
126132 bb->bcast_support &= tipc_bearer_bcast_support(net, i);
127133 if (bb->dests[i] < all_dests)
128134 continue;
@@ -585,7 +591,7 @@ static int tipc_bc_link_set_queue_limits(struct net *net, u32 max_win) · 456 unmodified lines
585591 if (max_win > TIPC_MAX_LINK_WIN)
586592 return -EINVAL;
587593 tipc_bcast_lock(net);
588− tipc_link_set_queue_limits(l, BCLINK_WIN_MIN, max_win);
594+ tipc_link_set_queue_limits(l, tipc_link_min_win(l), max_win);
589595 tipc_bcast_unlock(net);
590596 return 0;
591597 }
samples/bpf/sockex3_kern.c+4−4
@@ -44,17 +44,17 @@ static inline void parse_eth_proto(struct __sk_buff *skb, u32 proto) · 43 unmodified lines
4444 switch (proto) {
4545 case ETH_P_8021Q:
4646 case ETH_P_8021AD:
47− bpf_tail_call_static(skb, &jmp_table, PARSE_VLAN);
47+ bpf_tail_call(skb, &jmp_table, PARSE_VLAN);
4848 break;
4949 case ETH_P_MPLS_UC:
5050 case ETH_P_MPLS_MC:
51− bpf_tail_call_static(skb, &jmp_table, PARSE_MPLS);
51+ bpf_tail_call(skb, &jmp_table, PARSE_MPLS);
5252 break;
5353 case ETH_P_IP:
54− bpf_tail_call_static(skb, &jmp_table, PARSE_IP);
54+ bpf_tail_call(skb, &jmp_table, PARSE_IP);
5555 break;
5656 case ETH_P_IPV6:
57− bpf_tail_call_static(skb, &jmp_table, PARSE_IPV6);
57+ bpf_tail_call(skb, &jmp_table, PARSE_IPV6);
5858 break;
5959 }
6060 }
scripts/bpf_helpers_doc.py+1−0
@@ -453,6 +453,7 @@ class PrinterHelpers(Printer): · 452 unmodified lines
453453 'struct bpf_perf_event_data',
454454 'struct bpf_perf_event_value',
455455 'struct bpf_pidns_info',
456+ 'struct bpf_redir_neigh',
456457 'struct bpf_sk_lookup',
457458 'struct bpf_sock',
458459 'struct bpf_sock_addr',
tools/include/uapi/linux/bpf.h+18−4
@@ -3677,15 +3677,19 @@ union bpf_attr { · 3676 unmodified lines
36773677 * Return
36783678 * The id is returned or 0 in case the id could not be retrieved.
36793679 *
3680− * long bpf_redirect_neigh(u32 ifindex, u64 flags)
3680+ * long bpf_redirect_neigh(u32 ifindex, struct bpf_redir_neigh *params, int plen, u64 flags)
36813681 * Description
36823682 * Redirect the packet to another net device of index *ifindex*
36833683 * and fill in L2 addresses from neighboring subsystem. This helper
36843684 * is somewhat similar to **bpf_redirect**\ (), except that it
36853685 * populates L2 addresses as well, meaning, internally, the helper
3686− * performs a FIB lookup based on the skb's networking header to
3687− * get the address of the next hop and then relies on the neighbor
3688− * lookup for the L2 address of the nexthop.
3686+ * relies on the neighbor lookup for the L2 address of the nexthop.
3687+ *
3688+ * The helper will perform a FIB lookup based on the skb's
3689+ * networking header to get the address of the next hop, unless
3690+ * this is supplied by the caller in the *params* argument. The
3691+ * *plen* argument indicates the len of *params* and should be set
3692+ * to 0 if *params* is NULL.
36893693 *
36903694 * The *flags* argument is reserved and must be 0. The helper is
36913695 * currently only supported for tc BPF program types, and enabled
@@ -4906,6 +4910,16 @@ struct bpf_fib_lookup { · 1214 unmodified lines
49064910 __u8 dmac[6]; /* ETH_ALEN */
49074911 };
49084912
4913+struct bpf_redir_neigh {
4914+ /* network family for lookup (AF_INET, AF_INET6) */
4915+ __u32 nh_family;
4916+ /* network address of nexthop; skips fib lookup to find gateway */
4917+ union {
4918+ __be32 ipv4_nh;
4919+ __u32 ipv6_nh[4]; /* in6_addr; network order */
4920+ };
4921+};
4922+
49094923 enum bpf_task_fd_type {
49104924 BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */
49114925 BPF_FD_TYPE_TRACEPOINT, /* tp name */
tools/lib/bpf/bpf_helpers.h+2−0
@@ -72,6 +72,7 @@ · 71 unmodified lines
7272 /*
7373 * Helper function to perform a tail call with a constant/immediate map slot.
7474 */
75+#if __clang_major__ >= 8 && defined(__bpf__)
7576 static __always_inline void
7677 bpf_tail_call_static(void *ctx, const void *map, const __u32 slot)
7778 {
@@ -98,6 +99,7 @@ bpf_tail_call_static(void *ctx, const void *map, const __u32 slot) · 20 unmodified lines
9899 :: [ctx]"r"(ctx), [map]"r"(map), [slot]"i"(slot)
99100 : "r0", "r1", "r2", "r3", "r4", "r5");
100101 }
102+#endif
101103
102104 /*
103105 * Helper structure used by eBPF C program
tools/testing/selftests/bpf/prog_tests/ksyms_btf.c+39−18
@@ -5,18 +5,17 @@ · 4 unmodified lines
55 #include <bpf/libbpf.h>
66 #include <bpf/btf.h>
77 #include "test_ksyms_btf.skel.h"
8+#include "test_ksyms_btf_null_check.skel.h"
89
910 static int duration;
1011
11−void test_ksyms_btf(void)
12+static void test_basic(void)
1213 {
1314 __u64 runqueues_addr, bpf_prog_active_addr;
1415 __u32 this_rq_cpu;
1516 int this_bpf_prog_active;
1617 struct test_ksyms_btf *skel = NULL;
1718 struct test_ksyms_btf__data *data;
18− struct btf *btf;
19− int percpu_datasec;
2019 int err;
2120
2221 err = kallsyms_find("runqueues", &runqueues_addr);
@@ -31,20 +30,6 @@ void test_ksyms_btf(void) · 8 unmodified lines
3130 if (CHECK(err == -ENOENT, "ksym_find", "symbol 'bpf_prog_active' not found\n"))
3231 return;
3332
34− btf = libbpf_find_kernel_btf();
35− if (CHECK(IS_ERR(btf), "btf_exists", "failed to load kernel BTF: %ld\n",
36− PTR_ERR(btf)))
37− return;
38−
39− percpu_datasec = btf__find_by_name_kind(btf, ".data..percpu",
40− BTF_KIND_DATASEC);
41− if (percpu_datasec < 0) {
42− printf("%s:SKIP:no PERCPU DATASEC in kernel btf\n",
43− __func__);
44− test__skip();
45− goto cleanup;
46− }
47−
4833 skel = test_ksyms_btf__open_and_load();
4934 if (CHECK(!skel, "skel_open", "failed to open and load skeleton\n"))
5035 goto cleanup;
@@ -83,6 +68,42 @@ void test_ksyms_btf(void) · 32 unmodified lines
8368 data->out__bpf_prog_active);
8469
8570 cleanup:
86− btf__free(btf);
8771 test_ksyms_btf__destroy(skel);
8872 }
73+
74+static void test_null_check(void)
75+{
76+ struct test_ksyms_btf_null_check *skel;
77+
78+ skel = test_ksyms_btf_null_check__open_and_load();
79+ CHECK(skel, "skel_open", "unexpected load of a prog missing null check\n");
80+
81+ test_ksyms_btf_null_check__destroy(skel);
82+}
83+
84+void test_ksyms_btf(void)
85+{
86+ int percpu_datasec;
87+ struct btf *btf;
88+
89+ btf = libbpf_find_kernel_btf();
90+ if (CHECK(IS_ERR(btf), "btf_exists", "failed to load kernel BTF: %ld\n",
91+ PTR_ERR(btf)))
92+ return;
93+
94+ percpu_datasec = btf__find_by_name_kind(btf, ".data..percpu",
95+ BTF_KIND_DATASEC);
96+ btf__free(btf);
97+ if (percpu_datasec < 0) {
98+ printf("%s:SKIP:no PERCPU DATASEC in kernel btf\n",
99+ __func__);
100+ test__skip();
101+ return;
102+ }
103+
104+ if (test__start_subtest("basic"))
105+ test_basic();
106+
107+ if (test__start_subtest("null_check"))
108+ test_null_check();
109+}
tools/testing/selftests/bpf/progs/test_ksyms_btf_null_check.c+31−0
@@ -0,0 +1,31 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/* Copyright (c) 2020 Facebook */
3+
4+#include "vmlinux.h"
5+
6+#include <bpf/bpf_helpers.h>
7+
8+extern const struct rq runqueues __ksym; /* struct type global var. */
9+extern const int bpf_prog_active __ksym; /* int type global var. */
10+
11+SEC("raw_tp/sys_enter")
12+int handler(const void *ctx)
13+{
14+ struct rq *rq;
15+ int *active;
16+ __u32 cpu;
17+
18+ cpu = bpf_get_smp_processor_id();
19+ rq = (struct rq *)bpf_per_cpu_ptr(&runqueues, cpu);
20+ active = (int *)bpf_per_cpu_ptr(&bpf_prog_active, cpu);
21+ if (active) {
22+ /* READ_ONCE */
23+ *(volatile int *)active;
24+ /* !rq has not been tested, so verifier should reject. */
25+ *(volatile int *)(&rq->cpu);
26+ }
27+
28+ return 0;
29+}
30+
31+char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/progs/test_tc_neigh.c+3−2
@@ -1,4 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2+#include <stddef.h>
23 #include <stdint.h>
34 #include <stdbool.h>
45
@@ -118,7 +119,7 @@ SEC("dst_ingress") int tc_dst(struct __sk_buff *skb) · 113 unmodified lines
118119 if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0)
119120 return TC_ACT_SHOT;
120121
121− return bpf_redirect_neigh(get_dev_ifindex(dev_src), 0);
122+ return bpf_redirect_neigh(get_dev_ifindex(dev_src), NULL, 0, 0);
122123 }
123124
124125 SEC("src_ingress") int tc_src(struct __sk_buff *skb)
@@ -142,7 +143,7 @@ SEC("src_ingress") int tc_src(struct __sk_buff *skb) · 17 unmodified lines
142143 if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0)
143144 return TC_ACT_SHOT;
144145
145− return bpf_redirect_neigh(get_dev_ifindex(dev_dst), 0);
146+ return bpf_redirect_neigh(get_dev_ifindex(dev_dst), NULL, 0, 0);
146147 }
147148
148149 char __license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c+155−0
@@ -0,0 +1,155 @@
1+// SPDX-License-Identifier: GPL-2.0
2+#include <stdint.h>
3+#include <stdbool.h>
4+#include <stddef.h>
5+
6+#include <linux/bpf.h>
7+#include <linux/stddef.h>
8+#include <linux/pkt_cls.h>
9+#include <linux/if_ether.h>
10+#include <linux/in.h>
11+#include <linux/ip.h>
12+#include <linux/ipv6.h>
13+
14+#include <bpf/bpf_helpers.h>
15+#include <bpf/bpf_endian.h>
16+
17+#ifndef ctx_ptr
18+# define ctx_ptr(field) (void *)(long)(field)
19+#endif
20+
21+#define AF_INET 2
22+#define AF_INET6 10
23+
24+static __always_inline int fill_fib_params_v4(struct __sk_buff *skb,
25+ struct bpf_fib_lookup *fib_params)
26+{
27+ void *data_end = ctx_ptr(skb->data_end);
28+ void *data = ctx_ptr(skb->data);
29+ struct iphdr *ip4h;
30+
31+ if (data + sizeof(struct ethhdr) > data_end)
32+ return -1;
33+
34+ ip4h = (struct iphdr *)(data + sizeof(struct ethhdr));
35+ if ((void *)(ip4h + 1) > data_end)
36+ return -1;
37+
38+ fib_params->family = AF_INET;
39+ fib_params->tos = ip4h->tos;
40+ fib_params->l4_protocol = ip4h->protocol;
41+ fib_params->sport = 0;
42+ fib_params->dport = 0;
43+ fib_params->tot_len = bpf_ntohs(ip4h->tot_len);
44+ fib_params->ipv4_src = ip4h->saddr;
45+ fib_params->ipv4_dst = ip4h->daddr;
46+
47+ return 0;
48+}
49+
50+static __always_inline int fill_fib_params_v6(struct __sk_buff *skb,
51+ struct bpf_fib_lookup *fib_params)
52+{
53+ struct in6_addr *src = (struct in6_addr *)fib_params->ipv6_src;
54+ struct in6_addr *dst = (struct in6_addr *)fib_params->ipv6_dst;
55+ void *data_end = ctx_ptr(skb->data_end);
56+ void *data = ctx_ptr(skb->data);
57+ struct ipv6hdr *ip6h;
58+
59+ if (data + sizeof(struct ethhdr) > data_end)
60+ return -1;
61+
62+ ip6h = (struct ipv6hdr *)(data + sizeof(struct ethhdr));
63+ if ((void *)(ip6h + 1) > data_end)
64+ return -1;
65+
66+ fib_params->family = AF_INET6;
67+ fib_params->flowinfo = 0;
68+ fib_params->l4_protocol = ip6h->nexthdr;
69+ fib_params->sport = 0;
70+ fib_params->dport = 0;
71+ fib_params->tot_len = bpf_ntohs(ip6h->payload_len);
72+ *src = ip6h->saddr;
73+ *dst = ip6h->daddr;
74+
75+ return 0;
76+}
77+
78+SEC("chk_egress") int tc_chk(struct __sk_buff *skb)
79+{
80+ void *data_end = ctx_ptr(skb->data_end);
81+ void *data = ctx_ptr(skb->data);
82+ __u32 *raw = data;
83+
84+ if (data + sizeof(struct ethhdr) > data_end)
85+ return TC_ACT_SHOT;
86+
87+ return !raw[0] && !raw[1] && !raw[2] ? TC_ACT_SHOT : TC_ACT_OK;
88+}
89+
90+static __always_inline int tc_redir(struct __sk_buff *skb)
91+{
92+ struct bpf_fib_lookup fib_params = { .ifindex = skb->ingress_ifindex };
93+ __u8 zero[ETH_ALEN * 2];
94+ int ret = -1;
95+
96+ switch (skb->protocol) {
97+ case __bpf_constant_htons(ETH_P_IP):
98+ ret = fill_fib_params_v4(skb, &fib_params);
99+ break;
100+ case __bpf_constant_htons(ETH_P_IPV6):
101+ ret = fill_fib_params_v6(skb, &fib_params);
102+ break;
103+ }
104+
105+ if (ret)
106+ return TC_ACT_OK;
107+
108+ ret = bpf_fib_lookup(skb, &fib_params, sizeof(fib_params), 0);
109+ if (ret == BPF_FIB_LKUP_RET_NOT_FWDED || ret < 0)
110+ return TC_ACT_OK;
111+
112+ __builtin_memset(&zero, 0, sizeof(zero));
113+ if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0)
114+ return TC_ACT_SHOT;
115+
116+ if (ret == BPF_FIB_LKUP_RET_NO_NEIGH) {
117+ struct bpf_redir_neigh nh_params = {};
118+
119+ nh_params.nh_family = fib_params.family;
120+ __builtin_memcpy(&nh_params.ipv6_nh, &fib_params.ipv6_dst,
121+ sizeof(nh_params.ipv6_nh));
122+
123+ return bpf_redirect_neigh(fib_params.ifindex, &nh_params,
124+ sizeof(nh_params), 0);
125+
126+ } else if (ret == BPF_FIB_LKUP_RET_SUCCESS) {
127+ void *data_end = ctx_ptr(skb->data_end);
128+ struct ethhdr *eth = ctx_ptr(skb->data);
129+
130+ if (eth + 1 > data_end)
131+ return TC_ACT_SHOT;
132+
133+ __builtin_memcpy(eth->h_dest, fib_params.dmac, ETH_ALEN);
134+ __builtin_memcpy(eth->h_source, fib_params.smac, ETH_ALEN);
135+
136+ return bpf_redirect(fib_params.ifindex, 0);
137+ }
138+
139+ return TC_ACT_SHOT;
140+}
141+
142+/* these are identical, but keep them separate for compatibility with the
143+ * section names expected by test_tc_redirect.sh
144+ */
145+SEC("dst_ingress") int tc_dst(struct __sk_buff *skb)
146+{
147+ return tc_redir(skb);
148+}
149+
150+SEC("src_ingress") int tc_src(struct __sk_buff *skb)
151+{
152+ return tc_redir(skb);
153+}
154+
155+char __license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/test_tc_redirect.sh+15−3
@@ -24,8 +24,7 @@ command -v timeout >/dev/null 2>&1 || \ · 23 unmodified lines
2424 { echo >&2 "timeout is not available"; exit 1; }
2525 command -v ping >/dev/null 2>&1 || \
2626 { echo >&2 "ping is not available"; exit 1; }
27−command -v ping6 >/dev/null 2>&1 || \
28− { echo >&2 "ping6 is not available"; exit 1; }
27+if command -v ping6 >/dev/null 2>&1; then PING6=ping6; else PING6=ping; fi
2928 command -v perl >/dev/null 2>&1 || \
3029 { echo >&2 "perl is not available"; exit 1; }
3130 command -v jq >/dev/null 2>&1 || \
@@ -152,7 +151,7 @@ netns_test_connectivity() · 120 unmodified lines
152151 echo -e "${TEST}: ${GREEN}PASS${NC}"
153152
154153 TEST="ICMPv6 connectivity test"
155− ip netns exec ${NS_SRC} ping6 $PING_ARG ${IP6_DST}
154+ ip netns exec ${NS_SRC} $PING6 $PING_ARG ${IP6_DST}
156155 if [ $? -ne 0 ]; then
157156 echo -e "${TEST}: ${RED}FAIL${NC}"
158157 exit 1
@@ -170,6 +169,7 @@ hex_mem_str() · 11 unmodified lines
170169 netns_setup_bpf()
171170 {
172171 local obj=$1
172+ local use_forwarding=${2:-0}
173173
174174 ip netns exec ${NS_FWD} tc qdisc add dev veth_src_fwd clsact
175175 ip netns exec ${NS_FWD} tc filter add dev veth_src_fwd ingress bpf da obj $obj sec src_ingress
@@ -179,6 +179,14 @@ netns_setup_bpf() · 3 unmodified lines
179179 ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd ingress bpf da obj $obj sec dst_ingress
180180 ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd egress bpf da obj $obj sec chk_egress
181181
182+ if [ "$use_forwarding" -eq "1" ]; then
183+ # bpf_fib_lookup() checks if forwarding is enabled
184+ ip netns exec ${NS_FWD} sysctl -w net.ipv4.ip_forward=1
185+ ip netns exec ${NS_FWD} sysctl -w net.ipv6.conf.veth_dst_fwd.forwarding=1
186+ ip netns exec ${NS_FWD} sysctl -w net.ipv6.conf.veth_src_fwd.forwarding=1
187+ return 0
188+ fi
189+
182190 veth_src=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_src_fwd/ifindex)
183191 veth_dst=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_dst_fwd/ifindex)
184192
@@ -200,5 +208,9 @@ netns_setup_bpf test_tc_neigh.o · 15 unmodified lines
200208 netns_test_connectivity
201209 netns_cleanup
202210 netns_setup
211+netns_setup_bpf test_tc_neigh_fib.o 1
212+netns_test_connectivity
213+netns_cleanup
214+netns_setup
203215 netns_setup_bpf test_tc_peer.o
204216 netns_test_connectivity
tools/testing/selftests/bpf/verifier/sock.c+25−0
@@ -631,3 +631,28 @@ · 630 unmodified lines
631631 .prog_type = BPF_PROG_TYPE_SK_REUSEPORT,
632632 .result = ACCEPT,
633633 },
634+{
635+ "mark null check on return value of bpf_skc_to helpers",
636+ .insns = {
637+ BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)),
638+ BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, 2),
639+ BPF_MOV64_IMM(BPF_REG_0, 0),
640+ BPF_EXIT_INSN(),
641+ BPF_MOV64_REG(BPF_REG_6, BPF_REG_1),
642+ BPF_EMIT_CALL(BPF_FUNC_skc_to_tcp_sock),
643+ BPF_MOV64_REG(BPF_REG_7, BPF_REG_0),
644+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_6),
645+ BPF_EMIT_CALL(BPF_FUNC_skc_to_tcp_request_sock),
646+ BPF_MOV64_REG(BPF_REG_8, BPF_REG_0),
647+ BPF_JMP_IMM(BPF_JNE, BPF_REG_8, 0, 2),
648+ BPF_MOV64_IMM(BPF_REG_0, 0),
649+ BPF_EXIT_INSN(),
650+ BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_7, 0),
651+ BPF_EXIT_INSN(),
652+ },
653+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
654+ .result = REJECT,
655+ .errstr = "invalid mem access",
656+ .result_unpriv = REJECT,
657+ .errstr_unpriv = "unknown func",
658+},
tools/testing/selftests/net/config+1−0
@@ -33,3 +33,4 @@ CONFIG_KALLSYMS=y · 32 unmodified lines
3333 CONFIG_TRACEPOINTS=y
3434 CONFIG_NET_DROP_MONITOR=m
3535 CONFIG_NETDEVSIM=m
36+CONFIG_NET_FOU=m
tools/testing/selftests/net/forwarding/vxlan_asymmetric.sh+10−0
@@ -215,10 +215,16 @@ switch_create() · 214 unmodified lines
215215
216216 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
217217 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20
218+
219+ sysctl_set net.ipv4.conf.all.rp_filter 0
220+ sysctl_set net.ipv4.conf.vlan10-v.rp_filter 0
221+ sysctl_set net.ipv4.conf.vlan20-v.rp_filter 0
218222 }
219223
220224 switch_destroy()
221225 {
226+ sysctl_restore net.ipv4.conf.all.rp_filter
227+
222228 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 20
223229 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 10
224230
@@ -359,6 +365,10 @@ ns_switch_create() · 134 unmodified lines
359365
360366 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
361367 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20
368+
369+ sysctl_set net.ipv4.conf.all.rp_filter 0
370+ sysctl_set net.ipv4.conf.vlan10-v.rp_filter 0
371+ sysctl_set net.ipv4.conf.vlan20-v.rp_filter 0
362372 }
363373 export -f ns_switch_create
364374
tools/testing/selftests/net/forwarding/vxlan_symmetric.sh+10−0
@@ -237,10 +237,16 @@ switch_create() · 236 unmodified lines
237237
238238 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
239239 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20
240+
241+ sysctl_set net.ipv4.conf.all.rp_filter 0
242+ sysctl_set net.ipv4.conf.vlan10-v.rp_filter 0
243+ sysctl_set net.ipv4.conf.vlan20-v.rp_filter 0
240244 }
241245
242246 switch_destroy()
243247 {
248+ sysctl_restore net.ipv4.conf.all.rp_filter
249+
244250 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 20
245251 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 10
246252
@@ -402,6 +408,10 @@ ns_switch_create() · 155 unmodified lines
402408
403409 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
404410 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20
411+
412+ sysctl_set net.ipv4.conf.all.rp_filter 0
413+ sysctl_set net.ipv4.conf.vlan10-v.rp_filter 0
414+ sysctl_set net.ipv4.conf.vlan20-v.rp_filter 0
405415 }
406416 export -f ns_switch_create
407417
tools/testing/selftests/net/mptcp/config+1−0
@@ -1,4 +1,5 @@
11 CONFIG_MPTCP=y
2+CONFIG_IPV6=y
23 CONFIG_MPTCP_IPV6=y
34 CONFIG_INET_DIAG=m
45 CONFIG_INET_MPTCP_DIAG=m
tools/testing/selftests/net/rtnetlink.sh+5−0
@@ -520,6 +520,11 @@ kci_test_encap_fou() · 519 unmodified lines
520520 return $ksft_skip
521521 fi
522522
523+ if ! /sbin/modprobe -q -n fou; then
524+ echo "SKIP: module fou is not found"
525+ return $ksft_skip
526+ fi
527+ /sbin/modprobe -q fou
523528 ip -netns "$testns" fou add port 7777 ipproto 47 2>/dev/null
524529 if [ $? -ne 0 ];then
525530 echo "FAIL: can't add fou port 7777, skipping test"