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
30- max-frame-size: See ethernet.txt in the same directory.30- max-frame-size: See ethernet.txt in the same directory.
31 31
32The MAC address will be determined using the optional properties32The MAC address will be determined using the optional properties
33defined in ethernet.txt.33defined in ethernet.txt. The 'phy-mode' property is required, but may
34be set to the empty string if the PHY configuration is programmed by
35the firmware or set by hardware straps, and needs to be preserved.
34 36
35Example:37Example:
36 eth0: ethernet@522d0000 {38 eth0: ethernet@522d0000 {
Documentation/networking/ip-sysctl.rst+3−1
@@ -1142,13 +1142,15 @@ icmp_ratelimit - INTEGER · 1141 unmodified lines
1142icmp_msgs_per_sec - INTEGER1142icmp_msgs_per_sec - INTEGER
1143 Limit maximal number of ICMP packets sent per second from this host.1143 Limit maximal number of ICMP packets sent per second from this host.
1144 Only messages whose type matches icmp_ratemask (see below) are1144 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.
1146 1147
1147 Default: 10001148 Default: 1000
1148 1149
1149icmp_msgs_burst - INTEGER1150icmp_msgs_burst - INTEGER
1150 icmp_msgs_per_sec controls number of ICMP packets sent per second,1151 icmp_msgs_per_sec controls number of ICMP packets sent per second,
1151 while icmp_msgs_burst controls the burst size of these packets.1152 while icmp_msgs_burst controls the burst size of these packets.
1153 For security reasons, the precise burst size is randomized.
1152 1154
1153 Default: 501155 Default: 50
1154 1156
Documentation/networking/nf_flowtable.rst+1−1
@@ -109,7 +109,7 @@ More reading · 108 unmodified lines
109This documentation is based on the LWN.net articles [1]_\ [2]_. Rafal Milecki109This documentation is based on the LWN.net articles [1]_\ [2]_. Rafal Milecki
110also made a very complete and comprehensive summary called "A state of network110also made a very complete and comprehensive summary called "A state of network
111acceleration" that describes how things were before this infrastructure was111acceleration" that describes how things were before this infrastructure was
112mailined [3]_ and it also makes a rough summary of this work [4]_.112mainlined [3]_ and it also makes a rough summary of this work [4]_.
113 113
114.. [1] https://lwn.net/Articles/738214/114.. [1] https://lwn.net/Articles/738214/
115.. [2] https://lwn.net/Articles/742164/115.. [2] https://lwn.net/Articles/742164/
MAINTAINERS+2−1
@@ -3244,7 +3244,8 @@ R: KP Singh <kpsingh@chromium.org> · 3243 unmodified lines
3244L: netdev@vger.kernel.org3244L: netdev@vger.kernel.org
3245L: bpf@vger.kernel.org3245L: bpf@vger.kernel.org
3246S: Supported3246S: Supported
3247Q: https://patchwork.ozlabs.org/project/netdev/list/?delegate=771473247W: https://bpf.io/
3248Q: https://patchwork.kernel.org/project/netdevbpf/list/?delegate=121173
3248T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git3249T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git
3249T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git3250T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
3250F: Documentation/bpf/3251F: 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
54 unsigned long new_rate;54 unsigned long new_rate;
55 unsigned int ports_active;55 unsigned int ports_active;
56 /* Frequenty in Mhz */56 /* Frequenty in Mhz */
57 const unsigned long rate_table[] = {57 static const unsigned long rate_table[] = {
58 59220000,58 59220000,
59 60820000,59 60820000,
60 62500000,60 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
1181 .stats_layout = vsc9953_stats_layout,1181 .stats_layout = vsc9953_stats_layout,
1182 .num_stats = ARRAY_SIZE(vsc9953_stats_layout),1182 .num_stats = ARRAY_SIZE(vsc9953_stats_layout),
1183 .vcap = vsc9953_vcap_props,1183 .vcap = vsc9953_vcap_props,
1184 .shared_queue_sz = 2048 * 1024,1184 .shared_queue_sz = 256 * 1024,
1185 .num_mact_rows = 2048,1185 .num_mact_rows = 2048,
1186 .num_ports = 10,1186 .num_ports = 10,
1187 .mdio_bus_alloc = vsc9953_mdio_bus_alloc,1187 .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
1163 default:1163 default:
1164 err = -1;1164 err = -1;
1165 goto err_exit;1165 goto err_exit;
1166 break;
1167 }1166 }
1168 if (!(self->aq_nic_cfg.aq_hw_caps->link_speed_msk & rate)) {1167 if (!(self->aq_nic_cfg.aq_hw_caps->link_speed_msk & rate)) {
1169 err = -1;1168 err = -1;
drivers/net/ethernet/chelsio/inline_crypto/Kconfig+1−0
@@ -16,6 +16,7 @@ if CHELSIO_INLINE_CRYPTO · 15 unmodified lines
16config CRYPTO_DEV_CHELSIO_TLS16config CRYPTO_DEV_CHELSIO_TLS
17 tristate "Chelsio Crypto Inline TLS Driver"17 tristate "Chelsio Crypto Inline TLS Driver"
18 depends on CHELSIO_T418 depends on CHELSIO_T4
19 depends on TLS
19 depends on TLS_TOE20 depends on TLS_TOE
20 help21 help
21 Support Chelsio Inline TLS with Chelsio crypto accelerator.22 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
92static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,92static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
93 struct sock *sk)93 struct sock *sk)
94{94{
95 struct adapter *adap = pci_get_drvdata(cdev->pdev);
95 struct net_device *ndev = cdev->ports[0];96 struct net_device *ndev = cdev->ports[0];
96#if IS_ENABLED(CONFIG_IPV6)97#if IS_ENABLED(CONFIG_IPV6)
97 struct net_device *temp;98 struct net_device *temp;
98 int addr_type;99 int addr_type;
99#endif100#endif
101 int i;
100 102
101 switch (sk->sk_family) {103 switch (sk->sk_family) {
102 case PF_INET:104 case PF_INET:
@@ -127,8 +129,12 @@ static struct net_device *chtls_find_netdev(struct chtls_dev *cdev, · 24 unmodified lines
127 return NULL;129 return NULL;
128 130
129 if (is_vlan_dev(ndev))131 if (is_vlan_dev(ndev))
130 return vlan_dev_real_dev(ndev);132 ndev = vlan_dev_real_dev(ndev);
131 return ndev;133
134 for_each_port(adap, i)
135 if (cdev->ports[i] == ndev)
136 return ndev;
137 return NULL;
132}138}
133 139
134static void assign_rxopt(struct sock *sk, unsigned int opt)140static void assign_rxopt(struct sock *sk, unsigned int opt)
@@ -477,7 +483,6 @@ void chtls_destroy_sock(struct sock *sk) · 342 unmodified lines
477 chtls_purge_write_queue(sk);483 chtls_purge_write_queue(sk);
478 free_tls_keyid(sk);484 free_tls_keyid(sk);
479 kref_put(&csk->kref, chtls_sock_release);485 kref_put(&csk->kref, chtls_sock_release);
480 csk->cdev = NULL;
481 if (sk->sk_family == AF_INET)486 if (sk->sk_family == AF_INET)
482 sk->sk_prot = &tcp_prot;487 sk->sk_prot = &tcp_prot;
483#if IS_ENABLED(CONFIG_IPV6)488#if IS_ENABLED(CONFIG_IPV6)
@@ -736,14 +741,13 @@ void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk) · 252 unmodified lines
736 741
737#if IS_ENABLED(CONFIG_IPV6)742#if IS_ENABLED(CONFIG_IPV6)
738 if (sk->sk_family == PF_INET6) {743 if (sk->sk_family == PF_INET6) {
739 struct chtls_sock *csk;744 struct net_device *ndev = chtls_find_netdev(cdev, sk);
740 int addr_type = 0;745 int addr_type = 0;
741 746
742 csk = rcu_dereference_sk_user_data(sk);
743 addr_type = ipv6_addr_type((const struct in6_addr *)747 addr_type = ipv6_addr_type((const struct in6_addr *)
744 &sk->sk_v6_rcv_saddr);748 &sk->sk_v6_rcv_saddr);
745 if (addr_type != IPV6_ADDR_ANY)749 if (addr_type != IPV6_ADDR_ANY)
746 cxgb4_clip_release(csk->egress_dev, (const u32 *)750 cxgb4_clip_release(ndev, (const u32 *)
747 &sk->sk_v6_rcv_saddr, 1);751 &sk->sk_v6_rcv_saddr, 1);
748 }752 }
749#endif753#endif
@@ -1157,6 +1161,9 @@ static struct sock *chtls_recv_sock(struct sock *lsk, · 407 unmodified lines
1157 ndev = n->dev;1161 ndev = n->dev;
1158 if (!ndev)1162 if (!ndev)
1159 goto free_dst;1163 goto free_dst;
1164 if (is_vlan_dev(ndev))
1165 ndev = vlan_dev_real_dev(ndev);
1166
1160 port_id = cxgb4_port_idx(ndev);1167 port_id = cxgb4_port_idx(ndev);
1161 1168
1162 csk = chtls_sock_create(cdev);1169 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
902 return 0;902 return 0;
903}903}
904 904
905static int csk_mem_free(struct chtls_dev *cdev, struct sock *sk)905static bool csk_mem_free(struct chtls_dev *cdev, struct sock *sk)
906{906{
907 return (cdev->max_host_sndbuf - sk->sk_wmem_queued);907 return (cdev->max_host_sndbuf - sk->sk_wmem_queued > 0);
908}908}
909 909
910static int csk_wait_memory(struct chtls_dev *cdev,910static int csk_wait_memory(struct chtls_dev *cdev,
@@ -1240,6 +1240,7 @@ int chtls_sendpage(struct sock *sk, struct page *page, · 329 unmodified lines
1240 copied = 0;1240 copied = 0;
1241 csk = rcu_dereference_sk_user_data(sk);1241 csk = rcu_dereference_sk_user_data(sk);
1242 cdev = csk->cdev;1242 cdev = csk->cdev;
1243 lock_sock(sk);
1243 timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);1244 timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
1244 1245
1245 err = sk_stream_wait_connect(sk, &timeo);1246 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
434 break;434 break;
435 default:435 default:
436 return -EINVAL;436 return -EINVAL;
437 break;
438 }437 }
439 438
440 fsp->h_u.tcp_ip4_spec.ip4src = flow_get_u32_src(&n->keys);439 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
1817 priv->rxdes0_edorr_mask = BIT(30);1817 priv->rxdes0_edorr_mask = BIT(30);
1818 priv->txdes0_edotr_mask = BIT(30);1818 priv->txdes0_edotr_mask = BIT(30);
1819 priv->is_aspeed = true;1819 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 }
1820 } else {1825 } else {
1821 priv->rxdes0_edorr_mask = BIT(15);1826 priv->rxdes0_edorr_mask = BIT(15);
1822 priv->txdes0_edotr_mask = BIT(15);1827 priv->txdes0_edotr_mask = BIT(15);
drivers/net/ethernet/faraday/ftgmac100.h+8−0
@@ -169,6 +169,14 @@ · 168 unmodified lines
169#define FTGMAC100_MACCR_FAST_MODE (1 << 19)169#define FTGMAC100_MACCR_FAST_MODE (1 << 19)
170#define FTGMAC100_MACCR_SW_RST (1 << 31)170#define FTGMAC100_MACCR_SW_RST (1 << 31)
171 171
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
172/*180/*
173 * PHY control register181 * PHY control register
174 */182 */
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
4235 dev_err(dev, "Error %ld in CHANGE_MAC_ADDR_RSP\n", rc);4235 dev_err(dev, "Error %ld in CHANGE_MAC_ADDR_RSP\n", rc);
4236 goto out;4236 goto out;
4237 }4237 }
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 */
4238 ether_addr_copy(netdev->dev_addr,4241 ether_addr_copy(netdev->dev_addr,
4239 &crq->change_mac_addr_rsp.mac_addr[0]);4242 &crq->change_mac_addr_rsp.mac_addr[0]);
4243 ether_addr_copy(adapter->mac_addr,
4244 &crq->change_mac_addr_rsp.mac_addr[0]);
4240out:4245out:
4241 complete(&adapter->fw_done);4246 complete(&adapter->fw_done);
4242 return rc;4247 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
901 **/901 **/
902s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw)902s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw)
903{903{
904 s32 (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);
905 s32 (*read)(struct mii_bus *bus, int addr, int regnum);
904 struct ixgbe_adapter *adapter = hw->back;906 struct ixgbe_adapter *adapter = hw->back;
905 struct pci_dev *pdev = adapter->pdev;907 struct pci_dev *pdev = adapter->pdev;
906 struct device *dev = &adapter->netdev->dev;908 struct device *dev = &adapter->netdev->dev;
907 struct mii_bus *bus;909 struct mii_bus *bus;
908 910
909 bus = devm_mdiobus_alloc(dev);
910 if (!bus)
911 return -ENOMEM;
912
913 switch (hw->device_id) {911 switch (hw->device_id) {
914 /* C3000 SoCs */912 /* C3000 SoCs */
915 case IXGBE_DEV_ID_X550EM_A_KR:913 case IXGBE_DEV_ID_X550EM_A_KR:
@@ -922,16 +920,23 @@ s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw) · 6 unmodified lines
922 case IXGBE_DEV_ID_X550EM_A_1G_T:920 case IXGBE_DEV_ID_X550EM_A_1G_T:
923 case IXGBE_DEV_ID_X550EM_A_1G_T_L:921 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
924 if (!ixgbe_x550em_a_has_mii(hw))922 if (!ixgbe_x550em_a_has_mii(hw))
925 return -ENODEV;923 return 0;
926 bus->read = &ixgbe_x550em_a_mii_bus_read;924 read = &ixgbe_x550em_a_mii_bus_read;
927 bus->write = &ixgbe_x550em_a_mii_bus_write;925 write = &ixgbe_x550em_a_mii_bus_write;
928 break;926 break;
929 default:927 default:
930 bus->read = &ixgbe_mii_bus_read;928 read = &ixgbe_mii_bus_read;
931 bus->write = &ixgbe_mii_bus_write;929 write = &ixgbe_mii_bus_write;
932 break;930 break;
933 }931 }
934 932
933 bus = devm_mdiobus_alloc(dev);
934 if (!bus)
935 return -ENOMEM;
936
937 bus->read = read;
938 bus->write = write;
939
935 /* Use the position of the device in the PCI hierarchy as the id */940 /* Use the position of the device in the PCI hierarchy as the id */
936 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mdio-%s", ixgbe_driver_name,941 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mdio-%s", ixgbe_driver_name,
937 pci_name(pdev));942 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
350 if (ixgbe_read_eerd_generic(hw, pointer, &length)) {350 if (ixgbe_read_eerd_generic(hw, pointer, &length)) {
351 hw_dbg(hw, "EEPROM read failed\n");351 hw_dbg(hw, "EEPROM read failed\n");
352 return IXGBE_ERR_EEPROM;352 return IXGBE_ERR_EEPROM;
353 break;
354 }353 }
355 354
356 /* Skip pointer section if length is invalid. */355 /* Skip pointer section if length is invalid. */
drivers/net/ethernet/korina.c+2−2
@@ -1113,7 +1113,7 @@ out: · 1112 unmodified lines
1113 return rc;1113 return rc;
1114 1114
1115probe_err_register:1115probe_err_register:
1116 kfree(KSEG0ADDR(lp->td_ring));1116 kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
1117probe_err_td_ring:1117probe_err_td_ring:
1118 iounmap(lp->tx_dma_regs);1118 iounmap(lp->tx_dma_regs);
1119probe_err_dma_tx:1119probe_err_dma_tx:
@@ -1133,7 +1133,7 @@ static int korina_remove(struct platform_device *pdev) · 13 unmodified lines
1133 iounmap(lp->eth_regs);1133 iounmap(lp->eth_regs);
1134 iounmap(lp->rx_dma_regs);1134 iounmap(lp->rx_dma_regs);
1135 iounmap(lp->tx_dma_regs);1135 iounmap(lp->tx_dma_regs);
1136 kfree(KSEG0ADDR(lp->td_ring));1136 kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
1137 1137
1138 unregister_netdev(bif->dev);1138 unregister_netdev(bif->dev);
1139 free_netdev(bif->dev);1139 free_netdev(bif->dev);
drivers/net/ethernet/mediatek/Kconfig+1−0
@@ -17,6 +17,7 @@ config NET_MEDIATEK_SOC · 16 unmodified lines
17config NET_MEDIATEK_STAR_EMAC17config NET_MEDIATEK_STAR_EMAC
18 tristate "MediaTek STAR Ethernet MAC support"18 tristate "MediaTek STAR Ethernet MAC support"
19 select PHYLIB19 select PHYLIB
20 select REGMAP_MMIO
20 help21 help
21 This driver supports the ethernet MAC IP first used on22 This driver supports the ethernet MAC IP first used on
22 MediaTek MT85** SoCs.23 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
4694 4694
4695 phy_disconnect(tp->phydev);4695 phy_disconnect(tp->phydev);
4696 4696
4697 pci_free_irq(pdev, 0, tp);4697 free_irq(pci_irq_vector(pdev, 0), tp);
4698 4698
4699 dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,4699 dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
4700 tp->RxPhyAddr);4700 tp->RxPhyAddr);
@@ -4745,8 +4745,8 @@ static int rtl_open(struct net_device *dev) · 44 unmodified lines
4745 4745
4746 rtl_request_firmware(tp);4746 rtl_request_firmware(tp);
4747 4747
4748 retval = pci_request_irq(pdev, 0, rtl8169_interrupt, NULL, tp,4748 retval = request_irq(pci_irq_vector(pdev, 0), rtl8169_interrupt,
4749 dev->name);4749 IRQF_NO_THREAD | IRQF_SHARED, dev->name, tp);
4750 if (retval < 0)4750 if (retval < 0)
4751 goto err_release_fw_2;4751 goto err_release_fw_2;
4752 4752
@@ -4763,7 +4763,7 @@ out: · 10 unmodified lines
4763 return retval;4763 return retval;
4764 4764
4765err_free_irq:4765err_free_irq:
4766 pci_free_irq(pdev, 0, tp);4766 free_irq(pci_irq_vector(pdev, 0), tp);
4767err_release_fw_2:4767err_release_fw_2:
4768 rtl_release_firmware(tp);4768 rtl_release_firmware(tp);
4769 rtl8169_rx_clear(tp);4769 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
1014 efx->num_mac_stats = MC_CMD_MAC_NSTATS;1014 efx->num_mac_stats = MC_CMD_MAC_NSTATS;
1015 BUILD_BUG_ON(MC_CMD_MAC_NSTATS - 1 != MC_CMD_MAC_GENERATION_END);1015 BUILD_BUG_ON(MC_CMD_MAC_NSTATS - 1 != MC_CMD_MAC_GENERATION_END);
1016 mutex_init(&efx->mac_lock);1016 mutex_init(&efx->mac_lock);
1017 init_rwsem(&efx->filter_sem);
1017#ifdef CONFIG_RFS_ACCEL1018#ifdef CONFIG_RFS_ACCEL
1018 mutex_init(&efx->rps_mutex);1019 mutex_init(&efx->rps_mutex);
1019 spin_lock_init(&efx->rps_hash_lock);1020 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
797{797{
798 int rc;798 int rc;
799 799
800 init_rwsem(&efx->filter_sem);
801 mutex_lock(&efx->mac_lock);800 mutex_lock(&efx->mac_lock);
802 down_write(&efx->filter_sem);801 down_write(&efx->filter_sem);
803 rc = efx->type->filter_table_probe(efx);802 rc = efx->type->filter_table_probe(efx);
drivers/net/ethernet/socionext/netsec.c+17−7
@@ -6,6 +6,7 @@ · 5 unmodified lines
6#include <linux/pm_runtime.h>6#include <linux/pm_runtime.h>
7#include <linux/acpi.h>7#include <linux/acpi.h>
8#include <linux/of_mdio.h>8#include <linux/of_mdio.h>
9#include <linux/of_net.h>
9#include <linux/etherdevice.h>10#include <linux/etherdevice.h>
10#include <linux/interrupt.h>11#include <linux/interrupt.h>
11#include <linux/io.h>12#include <linux/io.h>
@@ -1833,6 +1834,14 @@ static const struct net_device_ops netsec_netdev_ops = { · 1821 unmodified lines
1833static int netsec_of_probe(struct platform_device *pdev,1834static int netsec_of_probe(struct platform_device *pdev,
1834 struct netsec_priv *priv, u32 *phy_addr)1835 struct netsec_priv *priv, u32 *phy_addr)
1835{1836{
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
1836 priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);1845 priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
1837 if (!priv->phy_np) {1846 if (!priv->phy_np) {
1838 dev_err(&pdev->dev, "missing required property 'phy-handle'\n");1847 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
1859 if (!IS_ENABLED(CONFIG_ACPI))1868 if (!IS_ENABLED(CONFIG_ACPI))
1860 return -ENODEV;1869 return -ENODEV;
1861 1870
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
1862 ret = device_property_read_u32(&pdev->dev, "phy-channel", phy_addr);1879 ret = device_property_read_u32(&pdev->dev, "phy-channel", phy_addr);
1863 if (ret) {1880 if (ret) {
1864 dev_err(&pdev->dev,1881 dev_err(&pdev->dev,
@@ -1995,13 +2012,6 @@ static int netsec_probe(struct platform_device *pdev) · 130 unmodified lines
1995 priv->msg_enable = NETIF_MSG_TX_ERR | NETIF_MSG_HW | NETIF_MSG_DRV |2012 priv->msg_enable = NETIF_MSG_TX_ERR | NETIF_MSG_HW | NETIF_MSG_DRV |
1996 NETIF_MSG_LINK | NETIF_MSG_PROBE;2013 NETIF_MSG_LINK | NETIF_MSG_PROBE;
1997 2014
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
2005 priv->ioaddr = devm_ioremap(&pdev->dev, mmio_res->start,2015 priv->ioaddr = devm_ioremap(&pdev->dev, mmio_res->start,
2006 resource_size(mmio_res));2016 resource_size(mmio_res));
2007 if (!priv->ioaddr) {2017 if (!priv->ioaddr) {
drivers/net/pcs/Kconfig+1−2
@@ -7,8 +7,7 @@ menu "PCS device drivers" · 6 unmodified lines
7 7
8config PCS_XPCS8config PCS_XPCS
9 tristate "Synopsys DesignWare XPCS controller"9 tristate "Synopsys DesignWare XPCS controller"
10 select MDIO_BUS10 depends on MDIO_DEVICE && MDIO_BUS
11 depends on MDIO_DEVICE
12 help11 help
13 This module provides helper functions for Synopsys DesignWare XPCS12 This module provides helper functions for Synopsys DesignWare XPCS
14 controllers.13 controllers.
drivers/net/usb/rtl8150.c+1−1
@@ -261,7 +261,7 @@ static void set_ethernet_addr(rtl8150_t *dev) · 260 unmodified lines
261 261
262 ret = get_registers(dev, IDR, sizeof(node_id), node_id);262 ret = get_registers(dev, IDR, sizeof(node_id), node_id);
263 263
264 if (ret == sizeof(node_id)) {264 if (!ret) {
265 ether_addr_copy(dev->netdev->dev_addr, node_id);265 ether_addr_copy(dev->netdev->dev_addr, node_id);
266 } else {266 } else {
267 eth_hw_addr_random(dev->netdev);267 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
68 (1ULL << VIRTIO_NET_F_GUEST_ECN) | \68 (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
69 (1ULL << VIRTIO_NET_F_GUEST_UFO))69 (1ULL << VIRTIO_NET_F_GUEST_UFO))
70 70
71#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
72
73struct virtnet_stat_desc {71struct virtnet_stat_desc {
74 char desc[ETH_GSTRING_LEN];72 char desc[ETH_GSTRING_LEN];
75 size_t offset;73 size_t offset;
@@ -2524,48 +2522,29 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf, · 2448 unmodified lines
2524 return 0;2522 return 0;
2525}2523}
2526 2524
2527static 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
2537static int virtnet_set_features(struct net_device *dev,2525static int virtnet_set_features(struct net_device *dev,
2538 netdev_features_t features)2526 netdev_features_t features)
2539{2527{
2540 struct virtnet_info *vi = netdev_priv(dev);2528 struct virtnet_info *vi = netdev_priv(dev);
2541 u64 offloads = vi->guest_offloads;2529 u64 offloads;
2542 int err;2530 int err;
2543 2531
2544 /* Don't allow configuration while XDP is active. */
2545 if (vi->xdp_queue_pairs)
2546 return -EBUSY;
2547
2548 if ((dev->features ^ features) & NETIF_F_LRO) {2532 if ((dev->features ^ features) & NETIF_F_LRO) {
2533 if (vi->xdp_queue_pairs)
2534 return -EBUSY;
2535
2549 if (features & NETIF_F_LRO)2536 if (features & NETIF_F_LRO)
2550 offloads |= GUEST_OFFLOAD_LRO_MASK &2537 offloads = vi->guest_offloads_capable;
2551 vi->guest_offloads_capable;
2552 else2538 else
2553 offloads &= ~GUEST_OFFLOAD_LRO_MASK;2539 offloads = vi->guest_offloads_capable &
2554 }2540 ~GUEST_OFFLOAD_LRO_MASK;
2555 2541
2556 if ((dev->features ^ features) & NETIF_F_RXCSUM) {2542 err = virtnet_set_guest_offloads(vi, offloads);
2557 if (features & NETIF_F_RXCSUM)2543 if (err)
2558 offloads |= GUEST_OFFLOAD_CSUM_MASK &2544 return err;
2559 vi->guest_offloads_capable;2545 vi->guest_offloads = offloads;
2560 else
2561 offloads &= ~GUEST_OFFLOAD_CSUM_MASK;
2562 }2546 }
2563 2547
2564 err = virtnet_set_guest_offloads(vi, offloads);
2565 if (err)
2566 return err;
2567
2568 vi->guest_offloads = offloads;
2569 return 0;2548 return 0;
2570}2549}
2571 2550
@@ -2584,7 +2563,6 @@ static const struct net_device_ops virtnet_netdev = { · 12 unmodified lines
2584 .ndo_features_check = passthru_features_check,2563 .ndo_features_check = passthru_features_check,
2585 .ndo_get_phys_port_name = virtnet_get_phys_port_name,2564 .ndo_get_phys_port_name = virtnet_get_phys_port_name,
2586 .ndo_set_features = virtnet_set_features,2565 .ndo_set_features = virtnet_set_features,
2587 .ndo_fix_features = virtnet_fix_features,
2588};2566};
2589 2567
2590static void virtnet_config_changed_work(struct work_struct *work)2568static void virtnet_config_changed_work(struct work_struct *work)
@@ -3035,10 +3013,8 @@ static int virtnet_probe(struct virtio_device *vdev) · 444 unmodified lines
3035 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||3013 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
3036 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))3014 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
3037 dev->features |= NETIF_F_LRO;3015 dev->features |= NETIF_F_LRO;
3038 if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {3016 if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
3039 dev->hw_features |= NETIF_F_RXCSUM;
3040 dev->hw_features |= NETIF_F_LRO;3017 dev->hw_features |= NETIF_F_LRO;
3041 }
3042 3018
3043 dev->vlan_features = dev->features;3019 dev->vlan_features = dev->features;
3044 3020
drivers/net/wan/hdlc.c+9−1
@@ -46,7 +46,15 @@ static struct hdlc_proto *first_proto; · 45 unmodified lines
46static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,46static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
47 struct packet_type *p, struct net_device *orig_dev)47 struct packet_type *p, struct net_device *orig_dev)
48{48{
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);
50 58
51 if (!net_eq(dev_net(dev), &init_net)) {59 if (!net_eq(dev_net(dev), &init_net)) {
52 kfree_skb(skb);60 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
99 old_qlen = dev->tx_queue_len;99 old_qlen = dev->tx_queue_len;
100 ether_setup(dev);100 ether_setup(dev);
101 dev->tx_queue_len = old_qlen;101 dev->tx_queue_len = old_qlen;
102 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
102 eth_hw_addr_random(dev);103 eth_hw_addr_random(dev);
103 call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);104 call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
104 netif_dormant_off(dev);105 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
89 switch(sc->if_type){89 switch(sc->if_type){
90 case LMC_PPP:90 case LMC_PPP:
91 return hdlc_type_trans(skb, sc->lmc_device);91 return hdlc_type_trans(skb, sc->lmc_device);
92 break;
93 case LMC_NET:92 case LMC_NET:
94 return htons(ETH_P_802_2);93 return htons(ETH_P_802_2);
95 break;
96 case LMC_RAW: /* Packet type for skbuff kind of useless */94 case LMC_RAW: /* Packet type for skbuff kind of useless */
97 return htons(ETH_P_802_2);95 return htons(ETH_P_802_2);
98 break;
99 default:96 default:
100 printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);97 printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
101 return htons(ETH_P_802_2);98 return htons(ETH_P_802_2);
102 break;
103 }99 }
104}100}
105 101
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
794 skb->len,794 skb->len,
795 st21nfca_hci_data_exchange_cb,795 st21nfca_hci_data_exchange_cb,
796 info);796 info);
797 break;
798 default:797 default:
799 return 1;798 return 1;
800 }799 }
drivers/nfc/trf7970a.c+0−1
@@ -1382,7 +1382,6 @@ static int trf7970a_is_iso15693_write_or_lock(u8 cmd) · 1381 unmodified lines
1382 case ISO15693_CMD_WRITE_DSFID:1382 case ISO15693_CMD_WRITE_DSFID:
1383 case ISO15693_CMD_LOCK_DSFID:1383 case ISO15693_CMD_LOCK_DSFID:
1384 return 1;1384 return 1;
1385 break;
1386 default:1385 default:
1387 return 0;1386 return 0;
1388 }1387 }
include/linux/filter.h+9−0
@@ -607,12 +607,21 @@ struct bpf_skb_data_end { · 606 unmodified lines
607 void *data_end;607 void *data_end;
608};608};
609 609
610struct bpf_nh_params {
611 u32 nh_family;
612 union {
613 u32 ipv4_nh;
614 struct in6_addr ipv6_nh;
615 };
616};
617
610struct bpf_redirect_info {618struct bpf_redirect_info {
611 u32 flags;619 u32 flags;
612 u32 tgt_index;620 u32 tgt_index;
613 void *tgt_value;621 void *tgt_value;
614 struct bpf_map *map;622 struct bpf_map *map;
615 u32 kern_flags;623 u32 kern_flags;
624 struct bpf_nh_params nh;
616};625};
617 626
618DECLARE_PER_CPU(struct bpf_redirect_info, bpf_redirect_info);627DECLARE_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
240 int (*done)(struct netlink_callback *);240 int (*done)(struct netlink_callback *);
241 void *data;241 void *data;
242 struct module *module;242 struct module *module;
243 u16 min_dump_alloc;243 u32 min_dump_alloc;
244};244};
245 245
246int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,246int __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
891 return (struct nft_expr *)&rule->data[rule->dlen];891 return (struct nft_expr *)&rule->data[rule->dlen];
892}892}
893 893
894static 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
894static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule)900static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule)
895{901{
896 return (void *)&rule->data[rule->dlen];902 return (void *)&rule->data[rule->dlen];
include/uapi/linux/bpf.h+18−4
@@ -3677,15 +3677,19 @@ union bpf_attr { · 3676 unmodified lines
3677 * Return3677 * Return
3678 * The id is returned or 0 in case the id could not be retrieved.3678 * The id is returned or 0 in case the id could not be retrieved.
3679 *3679 *
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)
3681 * Description3681 * Description
3682 * Redirect the packet to another net device of index *ifindex*3682 * Redirect the packet to another net device of index *ifindex*
3683 * and fill in L2 addresses from neighboring subsystem. This helper3683 * and fill in L2 addresses from neighboring subsystem. This helper
3684 * is somewhat similar to **bpf_redirect**\ (), except that it3684 * is somewhat similar to **bpf_redirect**\ (), except that it
3685 * populates L2 addresses as well, meaning, internally, the helper3685 * populates L2 addresses as well, meaning, internally, the helper
3686 * performs a FIB lookup based on the skb's networking header to3686 * relies on the neighbor lookup for the L2 address of the nexthop.
3687 * get the address of the next hop and then relies on the neighbor3687 *
3688 * lookup for the L2 address of the nexthop.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.
3689 *3693 *
3690 * The *flags* argument is reserved and must be 0. The helper is3694 * The *flags* argument is reserved and must be 0. The helper is
3691 * currently only supported for tc BPF program types, and enabled3695 * currently only supported for tc BPF program types, and enabled
@@ -4906,6 +4910,16 @@ struct bpf_fib_lookup { · 1214 unmodified lines
4906 __u8 dmac[6]; /* ETH_ALEN */4910 __u8 dmac[6]; /* ETH_ALEN */
4907};4911};
4908 4912
4913struct 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
4909enum bpf_task_fd_type {4923enum bpf_task_fd_type {
4910 BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */4924 BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */
4911 BPF_FD_TYPE_TRACEPOINT, /* tp name */4925 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
2913 case BPF_CGROUP_INET_INGRESS:2913 case BPF_CGROUP_INET_INGRESS:
2914 case BPF_CGROUP_INET_EGRESS:2914 case BPF_CGROUP_INET_EGRESS:
2915 return BPF_PROG_TYPE_CGROUP_SKB;2915 return BPF_PROG_TYPE_CGROUP_SKB;
2916 break;
2917 case BPF_CGROUP_INET_SOCK_CREATE:2916 case BPF_CGROUP_INET_SOCK_CREATE:
2918 case BPF_CGROUP_INET_SOCK_RELEASE:2917 case BPF_CGROUP_INET_SOCK_RELEASE:
2919 case BPF_CGROUP_INET4_POST_BIND:2918 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
5133 regs[BPF_REG_0].id = ++env->id_gen;5133 regs[BPF_REG_0].id = ++env->id_gen;
5134 } else {5134 } else {
5135 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE_OR_NULL;5135 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE_OR_NULL;
5136 regs[BPF_REG_0].id = ++env->id_gen;
5137 }5136 }
5138 } else if (fn->ret_type == RET_PTR_TO_SOCKET_OR_NULL) {5137 } else if (fn->ret_type == RET_PTR_TO_SOCKET_OR_NULL) {
5139 mark_reg_known_zero(env, regs, BPF_REG_0);5138 mark_reg_known_zero(env, regs, BPF_REG_0);
5140 regs[BPF_REG_0].type = PTR_TO_SOCKET_OR_NULL;5139 regs[BPF_REG_0].type = PTR_TO_SOCKET_OR_NULL;
5141 regs[BPF_REG_0].id = ++env->id_gen;
5142 } else if (fn->ret_type == RET_PTR_TO_SOCK_COMMON_OR_NULL) {5140 } else if (fn->ret_type == RET_PTR_TO_SOCK_COMMON_OR_NULL) {
5143 mark_reg_known_zero(env, regs, BPF_REG_0);5141 mark_reg_known_zero(env, regs, BPF_REG_0);
5144 regs[BPF_REG_0].type = PTR_TO_SOCK_COMMON_OR_NULL;5142 regs[BPF_REG_0].type = PTR_TO_SOCK_COMMON_OR_NULL;
5145 regs[BPF_REG_0].id = ++env->id_gen;
5146 } else if (fn->ret_type == RET_PTR_TO_TCP_SOCK_OR_NULL) {5143 } else if (fn->ret_type == RET_PTR_TO_TCP_SOCK_OR_NULL) {
5147 mark_reg_known_zero(env, regs, BPF_REG_0);5144 mark_reg_known_zero(env, regs, BPF_REG_0);
5148 regs[BPF_REG_0].type = PTR_TO_TCP_SOCK_OR_NULL;5145 regs[BPF_REG_0].type = PTR_TO_TCP_SOCK_OR_NULL;
5149 regs[BPF_REG_0].id = ++env->id_gen;
5150 } else if (fn->ret_type == RET_PTR_TO_ALLOC_MEM_OR_NULL) {5146 } else if (fn->ret_type == RET_PTR_TO_ALLOC_MEM_OR_NULL) {
5151 mark_reg_known_zero(env, regs, BPF_REG_0);5147 mark_reg_known_zero(env, regs, BPF_REG_0);
5152 regs[BPF_REG_0].type = PTR_TO_MEM_OR_NULL;5148 regs[BPF_REG_0].type = PTR_TO_MEM_OR_NULL;
5153 regs[BPF_REG_0].id = ++env->id_gen;
5154 regs[BPF_REG_0].mem_size = meta.mem_size;5149 regs[BPF_REG_0].mem_size = meta.mem_size;
5155 } else if (fn->ret_type == RET_PTR_TO_MEM_OR_BTF_ID_OR_NULL ||5150 } else if (fn->ret_type == RET_PTR_TO_MEM_OR_BTF_ID_OR_NULL ||
5156 fn->ret_type == RET_PTR_TO_MEM_OR_BTF_ID) {5151 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
5199 return -EINVAL;5194 return -EINVAL;
5200 }5195 }
5201 5196
5197 if (reg_type_may_be_null(regs[BPF_REG_0].type))
5198 regs[BPF_REG_0].id = ++env->id_gen;
5199
5202 if (is_ptr_cast_function(func_id)) {5200 if (is_ptr_cast_function(func_id)) {
5203 /* For release_reference() */5201 /* For release_reference() */
5204 regs[BPF_REG_0].ref_obj_id = meta.ref_obj_id;5202 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
7212 struct bpf_reg_state *reg, u32 id,7210 struct bpf_reg_state *reg, u32 id,
7213 bool is_null)7211 bool is_null)
7214{7212{
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)) {
7216 /* Old offset (both fixed and variable parts) should7215 /* Old offset (both fixed and variable parts) should
7217 * have been known-zero, because we don't allow pointer7216 * have been known-zero, because we don't allow pointer
7218 * arithmetic on pointers that might be NULL.7217 * 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
21{21{
22 const struct ebt_nat_info *info = par->targinfo;22 const struct ebt_nat_info *info = par->targinfo;
23 23
24 if (skb_ensure_writable(skb, ETH_ALEN))24 if (skb_ensure_writable(skb, 0))
25 return EBT_DROP;25 return EBT_DROP;
26 26
27 ether_addr_copy(eth_hdr(skb)->h_dest, info->mac);27 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
21{21{
22 const struct ebt_redirect_info *info = par->targinfo;22 const struct ebt_redirect_info *info = par->targinfo;
23 23
24 if (skb_ensure_writable(skb, ETH_ALEN))24 if (skb_ensure_writable(skb, 0))
25 return EBT_DROP;25 return EBT_DROP;
26 26
27 if (xt_hooknum(par) != NF_BR_BROUTING)27 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
22{22{
23 const struct ebt_nat_info *info = par->targinfo;23 const struct ebt_nat_info *info = par->targinfo;
24 24
25 if (skb_ensure_writable(skb, ETH_ALEN * 2))25 if (skb_ensure_writable(skb, 0))
26 return EBT_DROP;26 return EBT_DROP;
27 27
28 ether_addr_copy(eth_hdr(skb)->h_source, info->mac);28 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
10213 struct net_device *dev = list_first_entry(&unlink_list,10213 struct net_device *dev = list_first_entry(&unlink_list,
10214 struct net_device,10214 struct net_device,
10215 unlink_list);10215 unlink_list);
10216 list_del(&dev->unlink_list);10216 list_del_init(&dev->unlink_list);
10217 dev->nested_level = dev->lower_level - 1;10217 dev->nested_level = dev->lower_level - 1;
10218 }10218 }
10219#endif10219#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
2165}2165}
2166 2166
2167#if IS_ENABLED(CONFIG_IPV6)2167#if IS_ENABLED(CONFIG_IPV6)
2168static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb)2168static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb,
2169 struct net_device *dev, struct bpf_nh_params *nh)
2169{2170{
2170 struct dst_entry *dst = skb_dst(skb);
2171 struct net_device *dev = dst->dev;
2172 u32 hh_len = LL_RESERVED_SPACE(dev);2171 u32 hh_len = LL_RESERVED_SPACE(dev);
2173 const struct in6_addr *nexthop;2172 const struct in6_addr *nexthop;
2173 struct dst_entry *dst = NULL;
2174 struct neighbour *neigh;2174 struct neighbour *neigh;
2175 2175
2176 if (dev_xmit_recursion()) {2176 if (dev_xmit_recursion()) {
@@ -2196,8 +2196,13 @@ static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb) · 19 unmodified lines
2196 }2196 }
2197 2197
2198 rcu_read_lock_bh();2198 rcu_read_lock_bh();
2199 nexthop = rt6_nexthop(container_of(dst, struct rt6_info, dst),2199 if (!nh) {
2200 &ipv6_hdr(skb)->daddr);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 }
2201 neigh = ip_neigh_gw6(dev, nexthop);2206 neigh = ip_neigh_gw6(dev, nexthop);
2202 if (likely(!IS_ERR(neigh))) {2207 if (likely(!IS_ERR(neigh))) {
2203 int ret;2208 int ret;
@@ -2210,36 +2215,43 @@ static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb) · 6 unmodified lines
2210 return ret;2215 return ret;
2211 }2216 }
2212 rcu_read_unlock_bh();2217 rcu_read_unlock_bh();
2213 IP6_INC_STATS(dev_net(dst->dev),2218 if (dst)
2214 ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);2219 IP6_INC_STATS(dev_net(dst->dev),
2220 ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
2215out_drop:2221out_drop:
2216 kfree_skb(skb);2222 kfree_skb(skb);
2217 return -ENETDOWN;2223 return -ENETDOWN;
2218}2224}
2219 2225
2220static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev)2226static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev,
2227 struct bpf_nh_params *nh)
2221{2228{
2222 const struct ipv6hdr *ip6h = ipv6_hdr(skb);2229 const struct ipv6hdr *ip6h = ipv6_hdr(skb);
2223 struct net *net = dev_net(dev);2230 struct net *net = dev_net(dev);
2224 int err, ret = NET_XMIT_DROP;2231 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 };
2235 2232
2236 dst = ipv6_stub->ipv6_dst_lookup_flow(net, NULL, &fl6, NULL);2233 if (!nh) {
2237 if (IS_ERR(dst))2234 struct dst_entry *dst;
2238 goto out_drop;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;
2239 2248
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 }
2241 2253
2242 err = bpf_out_neigh_v6(net, skb);2254 err = bpf_out_neigh_v6(net, skb, dev, nh);
2243 if (unlikely(net_xmit_eval(err)))2255 if (unlikely(net_xmit_eval(err)))
2244 dev->stats.tx_errors++;2256 dev->stats.tx_errors++;
2245 else2257 else
@@ -2252,7 +2264,8 @@ out_xmit: · 6 unmodified lines
2252 return ret;2264 return ret;
2253}2265}
2254#else2266#else
2255static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev)2267static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev,
2268 struct bpf_nh_params *nh)
2256{2269{
2257 kfree_skb(skb);2270 kfree_skb(skb);
2258 return NET_XMIT_DROP;2271 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
2260#endif /* CONFIG_IPV6 */2273#endif /* CONFIG_IPV6 */
2261 2274
2262#if IS_ENABLED(CONFIG_INET)2275#if IS_ENABLED(CONFIG_INET)
2263static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb)2276static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb,
2277 struct net_device *dev, struct bpf_nh_params *nh)
2264{2278{
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;
2268 u32 hh_len = LL_RESERVED_SPACE(dev);2279 u32 hh_len = LL_RESERVED_SPACE(dev);
2269 struct neighbour *neigh;2280 struct neighbour *neigh;
2270 bool is_v6gw = false;2281 bool is_v6gw = false;
@@ -2292,7 +2303,21 @@ static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb) · 21 unmodified lines
2292 }2303 }
2293 2304
2294 rcu_read_lock_bh();2305 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
2296 if (likely(!IS_ERR(neigh))) {2321 if (likely(!IS_ERR(neigh))) {
2297 int ret;2322 int ret;
2298 2323
@@ -2309,33 +2334,37 @@ out_drop: · 10 unmodified lines
2309 return -ENETDOWN;2334 return -ENETDOWN;
2310}2335}
2311 2336
2312static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev)2337static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,
2338 struct bpf_nh_params *nh)
2313{2339{
2314 const struct iphdr *ip4h = ip_hdr(skb);2340 const struct iphdr *ip4h = ip_hdr(skb);
2315 struct net *net = dev_net(dev);2341 struct net *net = dev_net(dev);
2316 int err, ret = NET_XMIT_DROP;2342 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 };
2327 2343
2328 rt = ip_route_output_flow(net, &fl4, NULL);2344 if (!nh) {
2329 if (IS_ERR(rt))2345 struct flowi4 fl4 = {
2330 goto out_drop;2346 .flowi4_flags = FLOWI_FLAG_ANYSRC,
2331 if (rt->rt_type != RTN_UNICAST && rt->rt_type != RTN_LOCAL) {2347 .flowi4_mark = skb->mark,
2332 ip_rt_put(rt);2348 .flowi4_tos = RT_TOS(ip4h->tos),
2333 goto out_drop;2349 .flowi4_oif = dev->ifindex,
2334 }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 }
2335 2363
2336 skb_dst_set(skb, &rt->dst);2364 skb_dst_set(skb, &rt->dst);
2365 }
2337 2366
2338 err = bpf_out_neigh_v4(net, skb);2367 err = bpf_out_neigh_v4(net, skb, dev, nh);
2339 if (unlikely(net_xmit_eval(err)))2368 if (unlikely(net_xmit_eval(err)))
2340 dev->stats.tx_errors++;2369 dev->stats.tx_errors++;
2341 else2370 else
@@ -2348,14 +2377,16 @@ out_xmit: · 6 unmodified lines
2348 return ret;2377 return ret;
2349}2378}
2350#else2379#else
2351static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev)2380static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,
2381 struct bpf_nh_params *nh)
2352{2382{
2353 kfree_skb(skb);2383 kfree_skb(skb);
2354 return NET_XMIT_DROP;2384 return NET_XMIT_DROP;
2355}2385}
2356#endif /* CONFIG_INET */2386#endif /* CONFIG_INET */
2357 2387
2358static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev)2388static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev,
2389 struct bpf_nh_params *nh)
2359{2390{
2360 struct ethhdr *ethh = eth_hdr(skb);2391 struct ethhdr *ethh = eth_hdr(skb);
2361 2392
@@ -2370,9 +2401,9 @@ static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev) · 8 unmodified lines
2370 skb_reset_network_header(skb);2401 skb_reset_network_header(skb);
2371 2402
2372 if (skb->protocol == htons(ETH_P_IP))2403 if (skb->protocol == htons(ETH_P_IP))
2373 return __bpf_redirect_neigh_v4(skb, dev);2404 return __bpf_redirect_neigh_v4(skb, dev, nh);
2374 else if (skb->protocol == htons(ETH_P_IPV6))2405 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);
2376out:2407out:
2377 kfree_skb(skb);2408 kfree_skb(skb);
2378 return -ENOTSUPP;2409 return -ENOTSUPP;
@@ -2382,7 +2413,8 @@ out: · 3 unmodified lines
2382enum {2413enum {
2383 BPF_F_NEIGH = (1ULL << 1),2414 BPF_F_NEIGH = (1ULL << 1),
2384 BPF_F_PEER = (1ULL << 2),2415 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)
2386};2418};
2387 2419
2388BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags)2420BPF_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
2455 return -EAGAIN;2487 return -EAGAIN;
2456 }2488 }
2457 return flags & BPF_F_NEIGH ?2489 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) :
2459 __bpf_redirect(skb, dev, flags);2492 __bpf_redirect(skb, dev, flags);
2460out_drop:2493out_drop:
2461 kfree_skb(skb);2494 kfree_skb(skb);
@@ -2504,16 +2537,21 @@ static const struct bpf_func_proto bpf_redirect_peer_proto = { · 42 unmodified lines
2504 .arg2_type = ARG_ANYTHING,2537 .arg2_type = ARG_ANYTHING,
2505};2538};
2506 2539
2507BPF_CALL_2(bpf_redirect_neigh, u32, ifindex, u64, flags)2540BPF_CALL_4(bpf_redirect_neigh, u32, ifindex, struct bpf_redir_neigh *, params,
2541 int, plen, u64, flags)
2508{2542{
2509 struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);2543 struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);
2510 2544
2511 if (unlikely(flags))2545 if (unlikely((plen && plen < sizeof(*params)) || flags))
2512 return TC_ACT_SHOT;2546 return TC_ACT_SHOT;
2513 2547
2514 ri->flags = BPF_F_NEIGH;2548 ri->flags = BPF_F_NEIGH | (plen ? BPF_F_NEXTHOP : 0);
2515 ri->tgt_index = ifindex;2549 ri->tgt_index = ifindex;
2516 2550
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
2517 return TC_ACT_REDIRECT;2555 return TC_ACT_REDIRECT;
2518}2556}
2519 2557
@@ -2522,7 +2560,9 @@ static const struct bpf_func_proto bpf_redirect_neigh_proto = { · 2 unmodified lines
2522 .gpl_only = false,2560 .gpl_only = false,
2523 .ret_type = RET_INTEGER,2561 .ret_type = RET_INTEGER,
2524 .arg1_type = ARG_ANYTHING,2562 .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,
2526};2566};
2527 2567
2528BPF_CALL_2(bpf_msg_apply_bytes, struct sk_msg *, msg, u32, bytes)2568BPF_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
4693 cmpxchg(&sk->sk_pacing_status,4733 cmpxchg(&sk->sk_pacing_status,
4694 SK_PACING_NONE,4734 SK_PACING_NONE,
4695 SK_PACING_NEEDED);4735 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;
4697 sk->sk_pacing_rate = min(sk->sk_pacing_rate,4738 sk->sk_pacing_rate = min(sk->sk_pacing_rate,
4698 sk->sk_max_pacing_rate);4739 sk->sk_max_pacing_rate);
4699 break;4740 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
3709 return rtnl_linkprop(RTM_DELLINKPROP, skb, nlh, extack);3709 return rtnl_linkprop(RTM_DELLINKPROP, skb, nlh, extack);
3710}3710}
3711 3711
3712static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)3712static u32 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
3713{3713{
3714 struct net *net = sock_net(skb->sk);3714 struct net *net = sock_net(skb->sk);
3715 struct net_device *dev;3715 size_t min_ifinfo_dump_size = 0;
3716 struct nlattr *tb[IFLA_MAX+1];3716 struct nlattr *tb[IFLA_MAX+1];
3717 u32 ext_filter_mask = 0;3717 u32 ext_filter_mask = 0;
3718 u16 min_ifinfo_dump_size = 0;3718 struct net_device *dev;
3719 int hdrlen;3719 int hdrlen;
3720 3720
3721 /* Same kernel<->userspace interface hack as in rtnl_dump_ifinfo. */3721 /* 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
3735 */3735 */
3736 rcu_read_lock();3736 rcu_read_lock();
3737 for_each_netdev_rcu(net, dev) {3737 for_each_netdev_rcu(net, dev) {
3738 min_ifinfo_dump_size = max_t(u16, min_ifinfo_dump_size,3738 min_ifinfo_dump_size = max(min_ifinfo_dump_size,
3739 if_nlmsg_size(dev,3739 if_nlmsg_size(dev, ext_filter_mask));
3740 ext_filter_mask));
3741 }3740 }
3742 rcu_read_unlock();3741 rcu_read_unlock();
3743 3742
@@ -5494,7 +5493,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, · 1750 unmodified lines
5494 if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {5493 if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
5495 struct sock *rtnl;5494 struct sock *rtnl;
5496 rtnl_dumpit_func dumpit;5495 rtnl_dumpit_func dumpit;
5497 u16 min_dump_alloc = 0;5496 u32 min_dump_alloc = 0;
5498 5497
5499 link = rtnl_get_link(family, type);5498 link = rtnl_get_link(family, type);
5500 if (!link || !link->dumpit) {5499 if (!link || !link->dumpit) {
net/core/sock.c+1−1
@@ -1163,7 +1163,7 @@ set_sndbuf: · 1162 unmodified lines
1163 1163
1164 case SO_MAX_PACING_RATE:1164 case SO_MAX_PACING_RATE:
1165 {1165 {
1166 unsigned long ulval = (val == ~0U) ? ~0UL : val;1166 unsigned long ulval = (val == ~0U) ? ~0UL : (unsigned int)val;
1167 1167
1168 if (sizeof(ulval) != sizeof(val) &&1168 if (sizeof(ulval) != sizeof(val) &&
1169 optlen >= sizeof(ulval) &&1169 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
123 .xmit = ksz8795_xmit,123 .xmit = ksz8795_xmit,
124 .rcv = ksz8795_rcv,124 .rcv = ksz8795_rcv,
125 .overhead = KSZ_INGRESS_TAG_LEN,125 .overhead = KSZ_INGRESS_TAG_LEN,
126 .tail_tag = true,
126};127};
127 128
128DSA_TAG_DRIVER(ksz8795_netdev_ops);129DSA_TAG_DRIVER(ksz8795_netdev_ops);
@@ -199,6 +200,7 @@ static const struct dsa_device_ops ksz9477_netdev_ops = { · 70 unmodified lines
199 .xmit = ksz9477_xmit,200 .xmit = ksz9477_xmit,
200 .rcv = ksz9477_rcv,201 .rcv = ksz9477_rcv,
201 .overhead = KSZ9477_INGRESS_TAG_LEN,202 .overhead = KSZ9477_INGRESS_TAG_LEN,
203 .tail_tag = true,
202};204};
203 205
204DSA_TAG_DRIVER(ksz9477_netdev_ops);206DSA_TAG_DRIVER(ksz9477_netdev_ops);
net/ipv4/icmp.c+5−2
@@ -239,7 +239,7 @@ static struct { · 238 unmodified lines
239/**239/**
240 * icmp_global_allow - Are we allowed to send one more ICMP message ?240 * icmp_global_allow - Are we allowed to send one more ICMP message ?
241 *241 *
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.
243 * Returns false if we reached the limit and can not send another packet.243 * Returns false if we reached the limit and can not send another packet.
244 * Note: called with BH disabled244 * Note: called with BH disabled
245 */245 */
@@ -267,7 +267,10 @@ bool icmp_global_allow(void) · 21 unmodified lines
267 }267 }
268 credit = min_t(u32, icmp_global.credit + incr, sysctl_icmp_msgs_burst);268 credit = min_t(u32, icmp_global.credit + incr, sysctl_icmp_msgs_burst);
269 if (credit) {269 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);
271 rc = true;274 rc = true;
272 }275 }
273 WRITE_ONCE(icmp_global.credit, credit);276 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
845 remove_nh_grp_entry(net, nhge, nlinfo);845 remove_nh_grp_entry(net, nhge, nlinfo);
846 846
847 /* make sure all see the newly published array before releasing rtnl */847 /* make sure all see the newly published array before releasing rtnl */
848 synchronize_rcu();848 synchronize_net();
849}849}
850 850
851static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo)851static 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
5827 tcp_data_snd_check(sk);5827 tcp_data_snd_check(sk);
5828 if (!inet_csk_ack_scheduled(sk))5828 if (!inet_csk_ack_scheduled(sk))
5829 goto no_ack;5829 goto no_ack;
5830 } else {
5831 tcp_update_wl(tp, TCP_SKB_CB(skb)->seq);
5830 }5832 }
5831 5833
5832 __tcp_ack_snd_check(sk, 0);5834 __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
355 ipv6_hdr(skb)->payload_len = htons(payload_len);355 ipv6_hdr(skb)->payload_len = htons(payload_len);
356 ipv6_change_dsfield(ipv6_hdr(skb), 0xff, ecn);356 ipv6_change_dsfield(ipv6_hdr(skb), 0xff, ecn);
357 IP6CB(skb)->frag_max_size = sizeof(struct ipv6hdr) + fq->q.max_size;357 IP6CB(skb)->frag_max_size = sizeof(struct ipv6hdr) + fq->q.max_size;
358 IP6CB(skb)->flags |= IP6SKB_FRAGMENTED;
358 359
359 /* Yes, and fold redundant checksum back. 8) */360 /* Yes, and fold redundant checksum back. 8) */
360 if (skb->ip_summed == CHECKSUM_COMPLETE)361 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
300module_exit(mpls_iptunnel_exit);300module_exit(mpls_iptunnel_exit);
301 301
302MODULE_ALIAS_RTNL_LWT(MPLS);302MODULE_ALIAS_RTNL_LWT(MPLS);
303MODULE_SOFTDEP("post: mpls_gso");
303MODULE_DESCRIPTION("MultiProtocol Label Switching IP Tunnels");304MODULE_DESCRIPTION("MultiProtocol Label Switching IP Tunnels");
304MODULE_LICENSE("GPL v2");305MODULE_LICENSE("GPL v2");
net/mptcp/Kconfig+2−4
@@ -19,14 +19,11 @@ config INET_MPTCP_DIAG · 18 unmodified lines
19 19
20config MPTCP_IPV620config MPTCP_IPV6
21 bool "MPTCP: IPv6 support for Multipath TCP"21 bool "MPTCP: IPv6 support for Multipath TCP"
22 select IPV622 depends on IPV6=y
23 default y23 default y
24 24
25endif
26
27config MPTCP_KUNIT_TESTS25config MPTCP_KUNIT_TESTS
28 tristate "This builds the MPTCP KUnit tests" if !KUNIT_ALL_TESTS26 tristate "This builds the MPTCP KUnit tests" if !KUNIT_ALL_TESTS
29 select MPTCP
30 depends on KUNIT27 depends on KUNIT
31 default KUNIT_ALL_TESTS28 default KUNIT_ALL_TESTS
32 help29 help
@@ -39,3 +36,4 @@ config MPTCP_KUNIT_TESTS · 6 unmodified lines
39 36
40 If unsure, say N.37 If unsure, say N.
41 38
39endif
net/mptcp/options.c+2−1
@@ -241,7 +241,6 @@ static void mptcp_parse_option(const struct sk_buff *skb, · 240 unmodified lines
241 }241 }
242 242
243 mp_opt->add_addr = 1;243 mp_opt->add_addr = 1;
244 mp_opt->port = 0;
245 mp_opt->addr_id = *ptr++;244 mp_opt->addr_id = *ptr++;
246 pr_debug("ADD_ADDR: id=%d, echo=%d", mp_opt->addr_id, mp_opt->echo);245 pr_debug("ADD_ADDR: id=%d, echo=%d", mp_opt->addr_id, mp_opt->echo);
247 if (mp_opt->family == MPTCP_ADDR_IPVERSION_4) {246 if (mp_opt->family == MPTCP_ADDR_IPVERSION_4) {
@@ -297,6 +296,8 @@ void mptcp_get_options(const struct sk_buff *skb, · 49 unmodified lines
297 mp_opt->mp_capable = 0;296 mp_opt->mp_capable = 0;
298 mp_opt->mp_join = 0;297 mp_opt->mp_join = 0;
299 mp_opt->add_addr = 0;298 mp_opt->add_addr = 0;
299 mp_opt->ahmac = 0;
300 mp_opt->port = 0;
300 mp_opt->rm_addr = 0;301 mp_opt->rm_addr = 0;
301 mp_opt->dss = 0;302 mp_opt->dss = 0;
302 303
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
539 if (new_state != cp->state) {539 if (new_state != cp->state) {
540 struct ip_vs_dest *dest = cp->dest;540 struct ip_vs_dest *dest = cp->dest;
541 541
542 IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] %s:%d->"542 IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] c:%s:%d v:%s:%d "
543 "%s:%d state: %s->%s conn->refcnt:%d\n",543 "d:%s:%d state: %s->%s conn->refcnt:%d\n",
544 pd->pp->name,544 pd->pp->name,
545 ((state_off == TCP_DIR_OUTPUT) ?545 ((state_off == TCP_DIR_OUTPUT) ?
546 "output " : "input "),546 "output " : "input "),
@@ -548,10 +548,12 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp, · 1 unmodified line
548 th->fin ? 'F' : '.',548 th->fin ? 'F' : '.',
549 th->ack ? 'A' : '.',549 th->ack ? 'A' : '.',
550 th->rst ? 'R' : '.',550 th->rst ? 'R' : '.',
551 IP_VS_DBG_ADDR(cp->daf, &cp->daddr),
552 ntohs(cp->dport),
553 IP_VS_DBG_ADDR(cp->af, &cp->caddr),551 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
554 ntohs(cp->cport),552 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),
555 tcp_state_name(cp->state),557 tcp_state_name(cp->state),
556 tcp_state_name(new_state),558 tcp_state_name(new_state),
557 refcount_read(&cp->refcnt));559 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
541 swin = win << sender->td_scale;541 swin = win << sender->td_scale;
542 sender->td_maxwin = (swin == 0 ? 1 : swin);542 sender->td_maxwin = (swin == 0 ? 1 : swin);
543 sender->td_maxend = end + sender->td_maxwin;543 sender->td_maxend = end + sender->td_maxwin;
544 /*544 if (receiver->td_maxwin == 0) {
545 * We haven't seen traffic in the other direction yet545 /* We haven't seen traffic in the other
546 * but we have to tweak window tracking to pass III546 * direction yet but we have to tweak window
547 * and IV until that happens.547 * tracking to pass III and IV until that
548 */548 * happens.
549 if (receiver->td_maxwin == 0)549 */
550 receiver->td_end = receiver->td_maxend = sack;550 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
551 }558 }
552 } else if (((state->state == TCP_CONNTRACK_SYN_SENT559 } else if (((state->state == TCP_CONNTRACK_SYN_SENT
553 && dir == IP_CT_DIR_ORIGINAL)560 && 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
19 skb_push(skb, skb->mac_len);19 skb_push(skb, skb->mac_len);
20 20
21 skb->dev = dev;21 skb->dev = dev;
22 skb->tstamp = 0;
22 dev_queue_xmit(skb);23 dev_queue_xmit(skb);
23}24}
24 25
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
302 struct nft_expr *expr;302 struct nft_expr *expr;
303 303
304 expr = nft_expr_first(rule);304 expr = nft_expr_first(rule);
305 while (expr != nft_expr_last(rule) && expr->ops) {305 while (nft_expr_more(rule, expr)) {
306 if (expr->ops->activate)306 if (expr->ops->activate)
307 expr->ops->activate(ctx, expr);307 expr->ops->activate(ctx, expr);
308 308
@@ -317,7 +317,7 @@ static void nft_rule_expr_deactivate(const struct nft_ctx *ctx, · 8 unmodified lines
317 struct nft_expr *expr;317 struct nft_expr *expr;
318 318
319 expr = nft_expr_first(rule);319 expr = nft_expr_first(rule);
320 while (expr != nft_expr_last(rule) && expr->ops) {320 while (nft_expr_more(rule, expr)) {
321 if (expr->ops->deactivate)321 if (expr->ops->deactivate)
322 expr->ops->deactivate(ctx, expr, phase);322 expr->ops->deactivate(ctx, expr, phase);
323 323
@@ -3080,7 +3080,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx, · 2756 unmodified lines
3080 * is called on error from nf_tables_newrule().3080 * is called on error from nf_tables_newrule().
3081 */3081 */
3082 expr = nft_expr_first(rule);3082 expr = nft_expr_first(rule);
3083 while (expr != nft_expr_last(rule) && expr->ops) {3083 while (nft_expr_more(rule, expr)) {
3084 next = nft_expr_next(expr);3084 next = nft_expr_next(expr);
3085 nf_tables_expr_destroy(ctx, expr);3085 nf_tables_expr_destroy(ctx, expr);
3086 expr = next;3086 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
37 struct nft_expr *expr;37 struct nft_expr *expr;
38 38
39 expr = nft_expr_first(rule);39 expr = nft_expr_first(rule);
40 while (expr->ops && expr != nft_expr_last(rule)) {40 while (nft_expr_more(rule, expr)) {
41 if (expr->ops->offload_flags & NFT_OFFLOAD_F_ACTION)41 if (expr->ops->offload_flags & NFT_OFFLOAD_F_ACTION)
42 num_actions++;42 num_actions++;
43 43
@@ -61,7 +61,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net, · 17 unmodified lines
61 ctx->net = net;61 ctx->net = net;
62 ctx->dep.type = NFT_OFFLOAD_DEP_UNSPEC;62 ctx->dep.type = NFT_OFFLOAD_DEP_UNSPEC;
63 63
64 while (expr->ops && expr != nft_expr_last(rule)) {64 while (nft_expr_more(rule, expr)) {
65 if (!expr->ops->offload) {65 if (!expr->ops->offload) {
66 err = -EOPNOTSUPP;66 err = -EOPNOTSUPP;
67 goto err_out;67 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
138 return;138 return;
139 139
140 skb->dev = dev;140 skb->dev = dev;
141 skb->tstamp = 0;
141 neigh_xmit(neigh_table, dev, addr, skb);142 neigh_xmit(neigh_table, dev, addr, skb);
142out:143out:
143 regs->verdict.code = verdict;144 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
1217 u32 idx;1217 u32 idx;
1218 char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1];1218 char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
1219 1219
1220 if (!info->attrs[NFC_ATTR_DEVICE_INDEX])1220 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || !info->attrs[NFC_ATTR_FIRMWARE_NAME])
1221 return -EINVAL;1221 return -EINVAL;
1222 1222
1223 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);1223 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
175 175
176static void __mask_array_destroy(struct mask_array *ma)176static void __mask_array_destroy(struct mask_array *ma)
177{177{
178 free_percpu(ma->masks_usage_cntr);178 free_percpu(ma->masks_usage_stats);
179 kfree(ma);179 kfree(ma);
180}180}
181 181
@@ -199,15 +199,15 @@ static void tbl_mask_array_reset_counters(struct mask_array *ma) · 17 unmodified lines
199 ma->masks_usage_zero_cntr[i] = 0;199 ma->masks_usage_zero_cntr[i] = 0;
200 200
201 for_each_possible_cpu(cpu) {201 for_each_possible_cpu(cpu) {
202 u64 *usage_counters = per_cpu_ptr(ma->masks_usage_cntr,202 struct mask_array_stats *stats;
203 cpu);
204 unsigned int start;203 unsigned int start;
205 u64 counter;204 u64 counter;
206 205
206 stats = per_cpu_ptr(ma->masks_usage_stats, cpu);
207 do {207 do {
208 start = u64_stats_fetch_begin_irq(&ma->syncp);208 start = u64_stats_fetch_begin_irq(&stats->syncp);
209 counter = usage_counters[i];209 counter = stats->usage_cntrs[i];
210 } while (u64_stats_fetch_retry_irq(&ma->syncp, start));210 } while (u64_stats_fetch_retry_irq(&stats->syncp, start));
211 211
212 ma->masks_usage_zero_cntr[i] += counter;212 ma->masks_usage_zero_cntr[i] += counter;
213 }213 }
@@ -230,9 +230,10 @@ static struct mask_array *tbl_mask_array_alloc(int size) · 16 unmodified lines
230 sizeof(struct sw_flow_mask *) *230 sizeof(struct sw_flow_mask *) *
231 size);231 size);
232 232
233 new->masks_usage_cntr = __alloc_percpu(sizeof(u64) * size,233 new->masks_usage_stats = __alloc_percpu(sizeof(struct mask_array_stats) +
234 __alignof__(u64));234 sizeof(u64) * size,
235 if (!new->masks_usage_cntr) {235 __alignof__(u64));
236 if (!new->masks_usage_stats) {
236 kfree(new);237 kfree(new);
237 return NULL;238 return NULL;
238 }239 }
@@ -722,6 +723,8 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti, · 483 unmodified lines
722 723
723/* Flow lookup does full lookup on flow table. It starts with724/* Flow lookup does full lookup on flow table. It starts with
724 * mask from index passed in *index.725 * mask from index passed in *index.
726 * This function MUST be called with BH disabled due to the use
727 * of CPU specific variables.
725 */728 */
726static struct sw_flow *flow_lookup(struct flow_table *tbl,729static struct sw_flow *flow_lookup(struct flow_table *tbl,
727 struct table_instance *ti,730 struct table_instance *ti,
@@ -731,7 +734,7 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl, · 3 unmodified lines
731 u32 *n_cache_hit,734 u32 *n_cache_hit,
732 u32 *index)735 u32 *index)
733{736{
734 u64 *usage_counters = this_cpu_ptr(ma->masks_usage_cntr);737 struct mask_array_stats *stats = this_cpu_ptr(ma->masks_usage_stats);
735 struct sw_flow *flow;738 struct sw_flow *flow;
736 struct sw_flow_mask *mask;739 struct sw_flow_mask *mask;
737 int i;740 int i;
@@ -741,9 +744,9 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl, · 3 unmodified lines
741 if (mask) {744 if (mask) {
742 flow = masked_flow_lookup(ti, key, mask, n_mask_hit);745 flow = masked_flow_lookup(ti, key, mask, n_mask_hit);
743 if (flow) {746 if (flow) {
744 u64_stats_update_begin(&ma->syncp);747 u64_stats_update_begin(&stats->syncp);
745 usage_counters[*index]++;748 stats->usage_cntrs[*index]++;
746 u64_stats_update_end(&ma->syncp);749 u64_stats_update_end(&stats->syncp);
747 (*n_cache_hit)++;750 (*n_cache_hit)++;
748 return flow;751 return flow;
749 }752 }
@@ -762,9 +765,9 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl, · 12 unmodified lines
762 flow = masked_flow_lookup(ti, key, mask, n_mask_hit);765 flow = masked_flow_lookup(ti, key, mask, n_mask_hit);
763 if (flow) { /* Found */766 if (flow) { /* Found */
764 *index = i;767 *index = i;
765 u64_stats_update_begin(&ma->syncp);768 u64_stats_update_begin(&stats->syncp);
766 usage_counters[*index]++;769 stats->usage_cntrs[*index]++;
767 u64_stats_update_end(&ma->syncp);770 u64_stats_update_end(&stats->syncp);
768 return flow;771 return flow;
769 }772 }
770 }773 }
@@ -850,9 +853,17 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl, · 79 unmodified lines
850 struct mask_array *ma = rcu_dereference_ovsl(tbl->mask_array);853 struct mask_array *ma = rcu_dereference_ovsl(tbl->mask_array);
851 u32 __always_unused n_mask_hit;854 u32 __always_unused n_mask_hit;
852 u32 __always_unused n_cache_hit;855 u32 __always_unused n_cache_hit;
856 struct sw_flow *flow;
853 u32 index = 0;857 u32 index = 0;
854 858
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;
856}867}
857 868
858struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,869struct 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
1109 1120
1110 for (i = 0; i < ma->max; i++) {1121 for (i = 0; i < ma->max; i++) {
1111 struct sw_flow_mask *mask;1122 struct sw_flow_mask *mask;
1112 unsigned int start;
1113 int cpu;1123 int cpu;
1114 1124
1115 mask = rcu_dereference_ovsl(ma->masks[i]);1125 mask = rcu_dereference_ovsl(ma->masks[i]);
@@ -1120,14 +1130,16 @@ void ovs_flow_masks_rebalance(struct flow_table *table) · 4 unmodified lines
1120 masks_and_count[i].counter = 0;1130 masks_and_count[i].counter = 0;
1121 1131
1122 for_each_possible_cpu(cpu) {1132 for_each_possible_cpu(cpu) {
1123 u64 *usage_counters = per_cpu_ptr(ma->masks_usage_cntr,1133 struct mask_array_stats *stats;
1124 cpu);1134 unsigned int start;
1125 u64 counter;1135 u64 counter;
1126 1136
1137 stats = per_cpu_ptr(ma->masks_usage_stats, cpu);
1127 do {1138 do {
1128 start = u64_stats_fetch_begin_irq(&ma->syncp);1139 start = u64_stats_fetch_begin_irq(&stats->syncp);
1129 counter = usage_counters[i];1140 counter = stats->usage_cntrs[i];
1130 } while (u64_stats_fetch_retry_irq(&ma->syncp, start));1141 } while (u64_stats_fetch_retry_irq(&stats->syncp,
1142 start));
1131 1143
1132 masks_and_count[i].counter += counter;1144 masks_and_count[i].counter += counter;
1133 }1145 }
net/openvswitch/flow_table.h+6−2
@@ -38,12 +38,16 @@ struct mask_count { · 37 unmodified lines
38 u64 counter;38 u64 counter;
39};39};
40 40
41struct mask_array_stats {
42 struct u64_stats_sync syncp;
43 u64 usage_cntrs[];
44};
45
41struct mask_array {46struct mask_array {
42 struct rcu_head rcu;47 struct rcu_head rcu;
43 int count, max;48 int count, max;
44 u64 __percpu *masks_usage_cntr;49 struct mask_array_stats __percpu *masks_usage_stats;
45 u64 *masks_usage_zero_cntr;50 u64 *masks_usage_zero_cntr;
46 struct u64_stats_sync syncp;
47 struct sw_flow_mask __rcu *masks[];51 struct sw_flow_mask __rcu *masks[];
48};52};
49 53
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
156 __be16 target_dst = target.dst.u.udp.port;156 __be16 target_dst = target.dst.u.udp.port;
157 157
158 if (target_src != tuple->src.u.udp.port)158 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,
160 offsetof(struct udphdr, source),160 offsetof(struct udphdr, source),
161 0xFFFF, be16_to_cpu(target_src));161 0xFFFF, be16_to_cpu(target_src));
162 if (target_dst != tuple->dst.u.udp.port)162 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,
164 offsetof(struct udphdr, dest),164 offsetof(struct udphdr, dest),
165 0xFFFF, be16_to_cpu(target_dst));165 0xFFFF, be16_to_cpu(target_dst));
166}166}
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
459 459
460 metadata = __ipv6_tun_set_dst(&saddr, &daddr, tos, ttl, dst_port,460 metadata = __ipv6_tun_set_dst(&saddr, &daddr, tos, ttl, dst_port,
461 0, flags,461 0, flags,
462 key_id, 0);462 key_id, opts_len);
463 } else {463 } else {
464 NL_SET_ERR_MSG(extack, "Missing either ipv4 or ipv6 src and dst");464 NL_SET_ERR_MSG(extack, "Missing either ipv4 or ipv6 src and dst");
465 ret = -EINVAL;465 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
3712 entry->gate.num_entries = tcf_gate_num_entries(act);3712 entry->gate.num_entries = tcf_gate_num_entries(act);
3713 err = tcf_gate_get_entries(entry, act);3713 err = tcf_gate_get_entries(entry, act);
3714 if (err)3714 if (err)
3715 goto err_out;3715 goto err_out_locked;
3716 } else {3716 } else {
3717 err = -EOPNOTSUPP;3717 err = -EOPNOTSUPP;
3718 goto err_out_locked;3718 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
108{108{
109 struct tipc_bc_base *bb = tipc_bc_base(net);109 struct tipc_bc_base *bb = tipc_bc_base(net);
110 int all_dests = tipc_link_bc_peers(bb->link);110 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);
111 int i, mtu, prim;113 int i, mtu, prim;
112 114
113 bb->primary_bearer = INVALID_BEARER_ID;115 bb->primary_bearer = INVALID_BEARER_ID;
@@ -121,8 +123,12 @@ static void tipc_bcbase_select_primary(struct net *net) · 7 unmodified lines
121 continue;123 continue;
122 124
123 mtu = tipc_bearer_mtu(net, i);125 mtu = tipc_bearer_mtu(net, i);
124 if (mtu < tipc_link_mtu(bb->link))126 if (mtu < tipc_link_mtu(bb->link)) {
125 tipc_link_set_mtu(bb->link, mtu);127 tipc_link_set_mtu(bb->link, mtu);
128 tipc_link_set_queue_limits(bb->link,
129 min_win,
130 max_win);
131 }
126 bb->bcast_support &= tipc_bearer_bcast_support(net, i);132 bb->bcast_support &= tipc_bearer_bcast_support(net, i);
127 if (bb->dests[i] < all_dests)133 if (bb->dests[i] < all_dests)
128 continue;134 continue;
@@ -585,7 +591,7 @@ static int tipc_bc_link_set_queue_limits(struct net *net, u32 max_win) · 456 unmodified lines
585 if (max_win > TIPC_MAX_LINK_WIN)591 if (max_win > TIPC_MAX_LINK_WIN)
586 return -EINVAL;592 return -EINVAL;
587 tipc_bcast_lock(net);593 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);
589 tipc_bcast_unlock(net);595 tipc_bcast_unlock(net);
590 return 0;596 return 0;
591}597}
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
44 switch (proto) {44 switch (proto) {
45 case ETH_P_8021Q:45 case ETH_P_8021Q:
46 case ETH_P_8021AD:46 case ETH_P_8021AD:
47 bpf_tail_call_static(skb, &jmp_table, PARSE_VLAN);47 bpf_tail_call(skb, &jmp_table, PARSE_VLAN);
48 break;48 break;
49 case ETH_P_MPLS_UC:49 case ETH_P_MPLS_UC:
50 case ETH_P_MPLS_MC:50 case ETH_P_MPLS_MC:
51 bpf_tail_call_static(skb, &jmp_table, PARSE_MPLS);51 bpf_tail_call(skb, &jmp_table, PARSE_MPLS);
52 break;52 break;
53 case ETH_P_IP:53 case ETH_P_IP:
54 bpf_tail_call_static(skb, &jmp_table, PARSE_IP);54 bpf_tail_call(skb, &jmp_table, PARSE_IP);
55 break;55 break;
56 case ETH_P_IPV6:56 case ETH_P_IPV6:
57 bpf_tail_call_static(skb, &jmp_table, PARSE_IPV6);57 bpf_tail_call(skb, &jmp_table, PARSE_IPV6);
58 break;58 break;
59 }59 }
60}60}
scripts/bpf_helpers_doc.py+1−0
@@ -453,6 +453,7 @@ class PrinterHelpers(Printer): · 452 unmodified lines
453 'struct bpf_perf_event_data',453 'struct bpf_perf_event_data',
454 'struct bpf_perf_event_value',454 'struct bpf_perf_event_value',
455 'struct bpf_pidns_info',455 'struct bpf_pidns_info',
456 'struct bpf_redir_neigh',
456 'struct bpf_sk_lookup',457 'struct bpf_sk_lookup',
457 'struct bpf_sock',458 'struct bpf_sock',
458 'struct bpf_sock_addr',459 'struct bpf_sock_addr',
tools/include/uapi/linux/bpf.h+18−4
@@ -3677,15 +3677,19 @@ union bpf_attr { · 3676 unmodified lines
3677 * Return3677 * Return
3678 * The id is returned or 0 in case the id could not be retrieved.3678 * The id is returned or 0 in case the id could not be retrieved.
3679 *3679 *
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)
3681 * Description3681 * Description
3682 * Redirect the packet to another net device of index *ifindex*3682 * Redirect the packet to another net device of index *ifindex*
3683 * and fill in L2 addresses from neighboring subsystem. This helper3683 * and fill in L2 addresses from neighboring subsystem. This helper
3684 * is somewhat similar to **bpf_redirect**\ (), except that it3684 * is somewhat similar to **bpf_redirect**\ (), except that it
3685 * populates L2 addresses as well, meaning, internally, the helper3685 * populates L2 addresses as well, meaning, internally, the helper
3686 * performs a FIB lookup based on the skb's networking header to3686 * relies on the neighbor lookup for the L2 address of the nexthop.
3687 * get the address of the next hop and then relies on the neighbor3687 *
3688 * lookup for the L2 address of the nexthop.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.
3689 *3693 *
3690 * The *flags* argument is reserved and must be 0. The helper is3694 * The *flags* argument is reserved and must be 0. The helper is
3691 * currently only supported for tc BPF program types, and enabled3695 * currently only supported for tc BPF program types, and enabled
@@ -4906,6 +4910,16 @@ struct bpf_fib_lookup { · 1214 unmodified lines
4906 __u8 dmac[6]; /* ETH_ALEN */4910 __u8 dmac[6]; /* ETH_ALEN */
4907};4911};
4908 4912
4913struct 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
4909enum bpf_task_fd_type {4923enum bpf_task_fd_type {
4910 BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */4924 BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */
4911 BPF_FD_TYPE_TRACEPOINT, /* tp name */4925 BPF_FD_TYPE_TRACEPOINT, /* tp name */
tools/lib/bpf/bpf_helpers.h+2−0
@@ -72,6 +72,7 @@ · 71 unmodified lines
72/*72/*
73 * Helper function to perform a tail call with a constant/immediate map slot.73 * Helper function to perform a tail call with a constant/immediate map slot.
74 */74 */
75#if __clang_major__ >= 8 && defined(__bpf__)
75static __always_inline void76static __always_inline void
76bpf_tail_call_static(void *ctx, const void *map, const __u32 slot)77bpf_tail_call_static(void *ctx, const void *map, const __u32 slot)
77{78{
@@ -98,6 +99,7 @@ bpf_tail_call_static(void *ctx, const void *map, const __u32 slot) · 20 unmodified lines
98 :: [ctx]"r"(ctx), [map]"r"(map), [slot]"i"(slot)99 :: [ctx]"r"(ctx), [map]"r"(map), [slot]"i"(slot)
99 : "r0", "r1", "r2", "r3", "r4", "r5");100 : "r0", "r1", "r2", "r3", "r4", "r5");
100}101}
102#endif
101 103
102/*104/*
103 * Helper structure used by eBPF C program105 * 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
5#include <bpf/libbpf.h>5#include <bpf/libbpf.h>
6#include <bpf/btf.h>6#include <bpf/btf.h>
7#include "test_ksyms_btf.skel.h"7#include "test_ksyms_btf.skel.h"
8#include "test_ksyms_btf_null_check.skel.h"
8 9
9static int duration;10static int duration;
10 11
11void test_ksyms_btf(void)12static void test_basic(void)
12{13{
13 __u64 runqueues_addr, bpf_prog_active_addr;14 __u64 runqueues_addr, bpf_prog_active_addr;
14 __u32 this_rq_cpu;15 __u32 this_rq_cpu;
15 int this_bpf_prog_active;16 int this_bpf_prog_active;
16 struct test_ksyms_btf *skel = NULL;17 struct test_ksyms_btf *skel = NULL;
17 struct test_ksyms_btf__data *data;18 struct test_ksyms_btf__data *data;
18 struct btf *btf;
19 int percpu_datasec;
20 int err;19 int err;
21 20
22 err = kallsyms_find("runqueues", &runqueues_addr);21 err = kallsyms_find("runqueues", &runqueues_addr);
@@ -31,20 +30,6 @@ void test_ksyms_btf(void) · 8 unmodified lines
31 if (CHECK(err == -ENOENT, "ksym_find", "symbol 'bpf_prog_active' not found\n"))30 if (CHECK(err == -ENOENT, "ksym_find", "symbol 'bpf_prog_active' not found\n"))
32 return;31 return;
33 32
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
48 skel = test_ksyms_btf__open_and_load();33 skel = test_ksyms_btf__open_and_load();
49 if (CHECK(!skel, "skel_open", "failed to open and load skeleton\n"))34 if (CHECK(!skel, "skel_open", "failed to open and load skeleton\n"))
50 goto cleanup;35 goto cleanup;
@@ -83,6 +68,42 @@ void test_ksyms_btf(void) · 32 unmodified lines
83 data->out__bpf_prog_active);68 data->out__bpf_prog_active);
84 69
85cleanup:70cleanup:
86 btf__free(btf);
87 test_ksyms_btf__destroy(skel);71 test_ksyms_btf__destroy(skel);
88}72}
73
74static 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
84void 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
8extern const struct rq runqueues __ksym; /* struct type global var. */
9extern const int bpf_prog_active __ksym; /* int type global var. */
10
11SEC("raw_tp/sys_enter")
12int 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
31char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/progs/test_tc_neigh.c+3−2
@@ -1,4 +1,5 @@
1// SPDX-License-Identifier: GPL-2.01// SPDX-License-Identifier: GPL-2.0
2#include <stddef.h>
2#include <stdint.h>3#include <stdint.h>
3#include <stdbool.h>4#include <stdbool.h>
4 5
@@ -118,7 +119,7 @@ SEC("dst_ingress") int tc_dst(struct __sk_buff *skb) · 113 unmodified lines
118 if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0)119 if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0)
119 return TC_ACT_SHOT;120 return TC_ACT_SHOT;
120 121
121 return bpf_redirect_neigh(get_dev_ifindex(dev_src), 0);122 return bpf_redirect_neigh(get_dev_ifindex(dev_src), NULL, 0, 0);
122}123}
123 124
124SEC("src_ingress") int tc_src(struct __sk_buff *skb)125SEC("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
142 if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0)143 if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0)
143 return TC_ACT_SHOT;144 return TC_ACT_SHOT;
144 145
145 return bpf_redirect_neigh(get_dev_ifindex(dev_dst), 0);146 return bpf_redirect_neigh(get_dev_ifindex(dev_dst), NULL, 0, 0);
146}147}
147 148
148char __license[] SEC("license") = "GPL";149char __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
24static __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
50static __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
78SEC("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
90static __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 */
145SEC("dst_ingress") int tc_dst(struct __sk_buff *skb)
146{
147 return tc_redir(skb);
148}
149
150SEC("src_ingress") int tc_src(struct __sk_buff *skb)
151{
152 return tc_redir(skb);
153}
154
155char __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
24 { echo >&2 "timeout is not available"; exit 1; }24 { echo >&2 "timeout is not available"; exit 1; }
25command -v ping >/dev/null 2>&1 || \25command -v ping >/dev/null 2>&1 || \
26 { echo >&2 "ping is not available"; exit 1; }26 { echo >&2 "ping is not available"; exit 1; }
27command -v ping6 >/dev/null 2>&1 || \27if command -v ping6 >/dev/null 2>&1; then PING6=ping6; else PING6=ping; fi
28 { echo >&2 "ping6 is not available"; exit 1; }
29command -v perl >/dev/null 2>&1 || \28command -v perl >/dev/null 2>&1 || \
30 { echo >&2 "perl is not available"; exit 1; }29 { echo >&2 "perl is not available"; exit 1; }
31command -v jq >/dev/null 2>&1 || \30command -v jq >/dev/null 2>&1 || \
@@ -152,7 +151,7 @@ netns_test_connectivity() · 120 unmodified lines
152 echo -e "${TEST}: ${GREEN}PASS${NC}"151 echo -e "${TEST}: ${GREEN}PASS${NC}"
153 152
154 TEST="ICMPv6 connectivity test"153 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}
156 if [ $? -ne 0 ]; then155 if [ $? -ne 0 ]; then
157 echo -e "${TEST}: ${RED}FAIL${NC}"156 echo -e "${TEST}: ${RED}FAIL${NC}"
158 exit 1157 exit 1
@@ -170,6 +169,7 @@ hex_mem_str() · 11 unmodified lines
170netns_setup_bpf()169netns_setup_bpf()
171{170{
172 local obj=$1171 local obj=$1
172 local use_forwarding=${2:-0}
173 173
174 ip netns exec ${NS_FWD} tc qdisc add dev veth_src_fwd clsact174 ip netns exec ${NS_FWD} tc qdisc add dev veth_src_fwd clsact
175 ip netns exec ${NS_FWD} tc filter add dev veth_src_fwd ingress bpf da obj $obj sec src_ingress175 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
179 ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd ingress bpf da obj $obj sec dst_ingress179 ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd ingress bpf da obj $obj sec dst_ingress
180 ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd egress bpf da obj $obj sec chk_egress180 ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd egress bpf da obj $obj sec chk_egress
181 181
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
182 veth_src=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_src_fwd/ifindex)190 veth_src=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_src_fwd/ifindex)
183 veth_dst=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_dst_fwd/ifindex)191 veth_dst=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_dst_fwd/ifindex)
184 192
@@ -200,5 +208,9 @@ netns_setup_bpf test_tc_neigh.o · 15 unmodified lines
200netns_test_connectivity208netns_test_connectivity
201netns_cleanup209netns_cleanup
202netns_setup210netns_setup
211netns_setup_bpf test_tc_neigh_fib.o 1
212netns_test_connectivity
213netns_cleanup
214netns_setup
203netns_setup_bpf test_tc_peer.o215netns_setup_bpf test_tc_peer.o
204netns_test_connectivity216netns_test_connectivity
tools/testing/selftests/bpf/verifier/sock.c+25−0
@@ -631,3 +631,28 @@ · 630 unmodified lines
631 .prog_type = BPF_PROG_TYPE_SK_REUSEPORT,631 .prog_type = BPF_PROG_TYPE_SK_REUSEPORT,
632 .result = ACCEPT,632 .result = ACCEPT,
633},633},
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
33CONFIG_TRACEPOINTS=y33CONFIG_TRACEPOINTS=y
34CONFIG_NET_DROP_MONITOR=m34CONFIG_NET_DROP_MONITOR=m
35CONFIG_NETDEVSIM=m35CONFIG_NETDEVSIM=m
36CONFIG_NET_FOU=m
tools/testing/selftests/net/forwarding/vxlan_asymmetric.sh+10−0
@@ -215,10 +215,16 @@ switch_create() · 214 unmodified lines
215 215
216 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10216 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
217 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20217 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
218}222}
219 223
220switch_destroy()224switch_destroy()
221{225{
226 sysctl_restore net.ipv4.conf.all.rp_filter
227
222 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 20228 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 20
223 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 10229 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 10
224 230
@@ -359,6 +365,10 @@ ns_switch_create() · 134 unmodified lines
359 365
360 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10366 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
361 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20367 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
362}372}
363export -f ns_switch_create373export -f ns_switch_create
364 374
tools/testing/selftests/net/forwarding/vxlan_symmetric.sh+10−0
@@ -237,10 +237,16 @@ switch_create() · 236 unmodified lines
237 237
238 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10238 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
239 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20239 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
240}244}
241 245
242switch_destroy()246switch_destroy()
243{247{
248 sysctl_restore net.ipv4.conf.all.rp_filter
249
244 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 20250 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 20
245 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 10251 bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 10
246 252
@@ -402,6 +408,10 @@ ns_switch_create() · 155 unmodified lines
402 408
403 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10409 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
404 bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20410 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
405}415}
406export -f ns_switch_create416export -f ns_switch_create
407 417
tools/testing/selftests/net/mptcp/config+1−0
@@ -1,4 +1,5 @@
1CONFIG_MPTCP=y1CONFIG_MPTCP=y
2CONFIG_IPV6=y
2CONFIG_MPTCP_IPV6=y3CONFIG_MPTCP_IPV6=y
3CONFIG_INET_DIAG=m4CONFIG_INET_DIAG=m
4CONFIG_INET_MPTCP_DIAG=m5CONFIG_INET_MPTCP_DIAG=m
tools/testing/selftests/net/rtnetlink.sh+5−0
@@ -520,6 +520,11 @@ kci_test_encap_fou() · 519 unmodified lines
520 return $ksft_skip520 return $ksft_skip
521 fi521 fi
522 522
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
523 ip -netns "$testns" fou add port 7777 ipproto 47 2>/dev/null528 ip -netns "$testns" fou add port 7777 ipproto 47 2>/dev/null
524 if [ $? -ne 0 ];then529 if [ $? -ne 0 ];then
525 echo "FAIL: can't add fou port 7777, skipping test"530 echo "FAIL: can't add fou port 7777, skipping test"