History

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

Pull networking fixes from David Miller: 1) Limit xt_hashlimit hash table size to avoid OOM or hung tasks, from Cong Wang. 2) Fix deadlock in xsk by publishing global consumer pointers when NAPI is finished, from Magnus Karlsson. 3) Set table field properly to RT_TABLE_COMPAT when necessary, from Jethro Beekman. 4) NLA_STRING attributes are not necessary NULL terminated, deal wiht that in IFLA_ALT_IFNAME. From Eric Dumazet. 5) Fix checksum handling in atlantic driver, from Dmitry Bezrukov. 6) Handle mtu==0 devices properly in wireguard, from Jason A. Donenfeld. 7) Fix several lockdep warnings in bonding, from Taehee Yoo. 8) Fix cls_flower port blocking, from Jason Baron. 9) Sanitize internal map names in libbpf, from Toke Høiland-Jørgensen. 10) Fix RDMA race in qede driver, from Michal Kalderon. 11) Fix several false lockdep warnings by adding conditions to list_for_each_entry_rcu(), from Madhuparna Bhowmik. 12) Fix sleep in atomic in mlx5 driver, from Huy Nguyen. 13) Fix potential deadlock in bpf_map_do_batch(), from Yonghong Song. 14) Hey, variables declared in switch statement before any case statements are not initialized. I learn something every day. Get rids of this stuff in several parts of the networking, from Kees Cook. * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (99 commits) bnxt_en: Issue PCIe FLR in kdump kernel to cleanup pending DMAs. bnxt_en: Improve device shutdown method. net: netlink: cap max groups which will be considered in netlink_bind() net: thunderx: workaround BGX TX Underflow issue ionic: fix fw_status read net: disable BRIDGE_NETFILTER by default net: macb: Properly handle phylink on at91rm9200 s390/qeth: fix off-by-one in RX copybreak check s390/qeth: don't warn for napi with 0 budget s390/qeth: vnicc Fix EOPNOTSUPP precedence openvswitch: Distribute switch variables for initialization net: ip6_gre: Distribute switch variables for initialization net: core: Distribute switch variables for initialization udp: rehash on disconnect net/tls: Fix to avoid gettig invalid tls record bpf: Fix a potential deadlock with bpf_map_do_batch bpf: Do not grab the bucket spinlock by default on htab batch ops ice: Wait for VF to be reset/ready before configuration ice: Don't tell the OS that link is going down ice: Don't reject odd values of usecs set by user ...

Linus Torvalds committed 6 years ago

Commit 3dc55db2 parents b0dd1eb 36a44bc104 files · +1132 −506Browse files

Unified · Split

104 files
  1. drivers/net/bonding/bond_main.c +52 −3
  2. drivers/net/bonding/bond_options.c +2 −0
  3. drivers/net/dsa/b53/b53_common.c +3 −0
  4. drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +5 −0
  5. drivers/net/ethernet/aquantia/atlantic/aq_filters.c +1 −1
  6. drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2 −0
  7. drivers/net/ethernet/aquantia/atlantic/aq_nic.c +3 −5
  8. drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +8 −5
  9. drivers/net/ethernet/aquantia/atlantic/aq_ring.c +7 −3
  10. drivers/net/ethernet/aquantia/atlantic/aq_ring.h +2 −1
  11. drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +14 −8
  12. drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +17 −2
  13. drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c +12 −0
  14. drivers/net/ethernet/broadcom/bnxt/bnxt.c +10 −2
  15. drivers/net/ethernet/broadcom/cnic_defs.h +2 −2
  16. drivers/net/ethernet/cadence/macb.h +1 −0
  17. drivers/net/ethernet/cadence/macb_main.c +37 −29
  18. drivers/net/ethernet/cavium/thunder/thunder_bgx.c +59 −3
  19. drivers/net/ethernet/cavium/thunder/thunder_bgx.h +9 −0
  20. drivers/net/ethernet/davicom/dm9000.c +2 −0
  21. drivers/net/ethernet/intel/ice/ice_ethtool.c +38 −18
  22. drivers/net/ethernet/intel/ice/ice_txrx.h +1 −1
  23. drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +74 −60
  24. drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +2 −1
  25. drivers/net/ethernet/mellanox/mlx5/core/en/health.c +1 −1
  26. drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +8 −0
  27. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 −0
  28. drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +8 −12
  29. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 −2
  30. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c +1 −1
  31. drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c +4 −1
  32. drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +7 −2
  33. drivers/net/ethernet/mellanox/mlx5/core/wq.c +30 −9
  34. drivers/net/ethernet/mellanox/mlx5/core/wq.h +2 −0
  35. drivers/net/ethernet/micrel/ks8851_mll.c +9 −44
  36. drivers/net/ethernet/mscc/ocelot_board.c +8 −0
  37. drivers/net/ethernet/pensando/ionic/ionic_dev.c +7 −4
  38. drivers/net/ethernet/pensando/ionic/ionic_if.h +1 −0
  39. drivers/net/ethernet/qlogic/qede/qede.h +2 −0
  40. drivers/net/ethernet/qlogic/qede/qede_rdma.c +28 −1
  41. drivers/net/phy/broadcom.c +2 −2
  42. drivers/net/phy/mdio-bcm-iproc.c +20 −0
  43. drivers/net/wireguard/device.c +4 −3
  44. drivers/net/wireguard/receive.c +5 −2
  45. drivers/net/wireguard/send.c +11 −5
  46. drivers/net/wireguard/socket.c +0 −1
  47. drivers/nfc/pn544/i2c.c +1 −0
  48. drivers/nfc/pn544/pn544.c +1 −1
  49. drivers/s390/net/qeth_core_main.c +1 −2
  50. drivers/s390/net/qeth_l2_main.c +13 −16
  51. include/linux/mlx5/mlx5_ifc.h +4 −1
  52. include/linux/netdevice.h +3 −4
  53. include/linux/rculist_nulls.h +7 −0
  54. include/linux/skbuff.h +30 −0
  55. include/net/flow_dissector.h +9 −0
  56. include/net/sock.h +33 −5
  57. include/uapi/linux/bpf.h +7 −9
  58. include/uapi/linux/netfilter/nf_conntrack_common.h +11 −1
  59. kernel/bpf/btf.c +3 −3
  60. kernel/bpf/hashtab.c +53 −5
  61. kernel/bpf/offload.c +1 −1
  62. net/Kconfig +0 −1
  63. net/bridge/br_stp.c +2 −1
  64. net/core/dev.c +11 −23
  65. net/core/fib_rules.c +1 −1
  66. net/core/rtnetlink.c +12 −14
  67. net/core/skbuff.c +2 −4
  68. net/ethtool/bitset.c +3 −0
  69. net/hsr/hsr_framereg.c +2 −1
  70. net/ipv4/udp.c +5 −1
  71. net/ipv6/ip6_fib.c +4 −3
  72. net/ipv6/ip6_gre.c +5 −3
  73. net/ipv6/ip6_tunnel.c +9 −4
  74. net/ipv6/route.c +1 −0
  75. net/mptcp/Kconfig +1 −0
  76. net/mptcp/protocol.c +19 −29
  77. net/mptcp/protocol.h +2 −2
  78. net/netfilter/nf_conntrack_core.c +164 −28
  79. net/netfilter/nf_conntrack_proto_udp.c +16 −4
  80. net/netfilter/nf_flow_table_offload.c +3 −3
  81. net/netfilter/nft_set_pipapo.c +3 −3
  82. net/netfilter/xt_hashlimit.c +16 −6
  83. net/netlabel/netlabel_domainhash.c +2 −1
  84. net/netlabel/netlabel_unlabeled.c +2 −1
  85. net/netlink/af_netlink.c +3 −2
  86. net/openvswitch/datapath.c +6 −3
  87. net/openvswitch/flow_netlink.c +10 −8
  88. net/openvswitch/flow_table.c +4 −2
  89. net/openvswitch/meter.c +2 −1
  90. net/openvswitch/vport.c +2 −1
  91. net/rds/rdma.c +12 −12
  92. net/sched/cls_flower.c +1 −0
  93. net/sctp/sm_statefuns.c +20 −9
  94. net/tls/tls_device.c +19 −1
  95. net/xdp/xsk.c +2 −0
  96. net/xdp/xsk_queue.h +2 −1
  97. tools/include/uapi/linux/bpf.h +7 −9
  98. tools/lib/bpf/libbpf.c +7 −1
  99. tools/testing/selftests/bpf/prog_tests/select_reuseport.c +6 −2
  100. tools/testing/selftests/bpf/prog_tests/sockmap_basic.c +5 −0
  101. tools/testing/selftests/net/fib_tests.sh +6 −0
  102. tools/testing/selftests/net/forwarding/mirror_gre.sh +13 −12
  103. tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +3 −3
  104. tools/testing/selftests/wireguard/qemu/Makefile +14 −24
drivers/net/bonding/bond_main.c+52−3
@@ -3526,6 +3526,47 @@ static void bond_fold_stats(struct rtnl_link_stats64 *_res, · 3525 unmodified lines
3526 }3526 }
3527}3527}
3528 3528
3529#ifdef CONFIG_LOCKDEP
3530static int bond_get_lowest_level_rcu(struct net_device *dev)
3531{
3532 struct net_device *ldev, *next, *now, *dev_stack[MAX_NEST_DEV + 1];
3533 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1];
3534 int cur = 0, max = 0;
3535
3536 now = dev;
3537 iter = &dev->adj_list.lower;
3538
3539 while (1) {
3540 next = NULL;
3541 while (1) {
3542 ldev = netdev_next_lower_dev_rcu(now, &iter);
3543 if (!ldev)
3544 break;
3545
3546 next = ldev;
3547 niter = &ldev->adj_list.lower;
3548 dev_stack[cur] = now;
3549 iter_stack[cur++] = iter;
3550 if (max <= cur)
3551 max = cur;
3552 break;
3553 }
3554
3555 if (!next) {
3556 if (!cur)
3557 return max;
3558 next = dev_stack[--cur];
3559 niter = iter_stack[cur];
3560 }
3561
3562 now = next;
3563 iter = niter;
3564 }
3565
3566 return max;
3567}
3568#endif
3569
3529static void bond_get_stats(struct net_device *bond_dev,3570static void bond_get_stats(struct net_device *bond_dev,
3530 struct rtnl_link_stats64 *stats)3571 struct rtnl_link_stats64 *stats)
3531{3572{
@@ -3533,11 +3574,17 @@ static void bond_get_stats(struct net_device *bond_dev, · 1 unmodified line
3533 struct rtnl_link_stats64 temp;3574 struct rtnl_link_stats64 temp;
3534 struct list_head *iter;3575 struct list_head *iter;
3535 struct slave *slave;3576 struct slave *slave;
3577 int nest_level = 0;
3536 3578
3537 spin_lock(&bond->stats_lock);
3538 memcpy(stats, &bond->bond_stats, sizeof(*stats));
3539 3579
3540 rcu_read_lock();3580 rcu_read_lock();
3581#ifdef CONFIG_LOCKDEP
3582 nest_level = bond_get_lowest_level_rcu(bond_dev);
3583#endif
3584
3585 spin_lock_nested(&bond->stats_lock, nest_level);
3586 memcpy(stats, &bond->bond_stats, sizeof(*stats));
3587
3541 bond_for_each_slave_rcu(bond, slave, iter) {3588 bond_for_each_slave_rcu(bond, slave, iter) {
3542 const struct rtnl_link_stats64 *new =3589 const struct rtnl_link_stats64 *new =
3543 dev_get_stats(slave->dev, &temp);3590 dev_get_stats(slave->dev, &temp);
@@ -3547,10 +3594,10 @@ static void bond_get_stats(struct net_device *bond_dev, · 3 unmodified lines
3547 /* save off the slave stats for the next run */3594 /* save off the slave stats for the next run */
3548 memcpy(&slave->slave_stats, new, sizeof(*new));3595 memcpy(&slave->slave_stats, new, sizeof(*new));
3549 }3596 }
3550 rcu_read_unlock();
3551 3597
3552 memcpy(&bond->bond_stats, stats, sizeof(*stats));3598 memcpy(&bond->bond_stats, stats, sizeof(*stats));
3553 spin_unlock(&bond->stats_lock);3599 spin_unlock(&bond->stats_lock);
3600 rcu_read_unlock();
3554}3601}
3555 3602
3556static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd)3603static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd)
@@ -3640,6 +3687,8 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd · 83 unmodified lines
3640 case BOND_RELEASE_OLD:3687 case BOND_RELEASE_OLD:
3641 case SIOCBONDRELEASE:3688 case SIOCBONDRELEASE:
3642 res = bond_release(bond_dev, slave_dev);3689 res = bond_release(bond_dev, slave_dev);
3690 if (!res)
3691 netdev_update_lockdep_key(slave_dev);
3643 break;3692 break;
3644 case BOND_SETHWADDR_OLD:3693 case BOND_SETHWADDR_OLD:
3645 case SIOCBONDSETHWADDR:3694 case SIOCBONDSETHWADDR:
drivers/net/bonding/bond_options.c+2−0
@@ -1398,6 +1398,8 @@ static int bond_option_slaves_set(struct bonding *bond, · 1397 unmodified lines
1398 case '-':1398 case '-':
1399 slave_dbg(bond->dev, dev, "Releasing interface\n");1399 slave_dbg(bond->dev, dev, "Releasing interface\n");
1400 ret = bond_release(bond->dev, dev);1400 ret = bond_release(bond->dev, dev);
1401 if (!ret)
1402 netdev_update_lockdep_key(dev);
1401 break;1403 break;
1402 1404
1403 default:1405 default:
drivers/net/dsa/b53/b53_common.c+3−0
@@ -1366,6 +1366,9 @@ void b53_vlan_add(struct dsa_switch *ds, int port, · 1365 unmodified lines
1366 1366
1367 b53_get_vlan_entry(dev, vid, vl);1367 b53_get_vlan_entry(dev, vid, vl);
1368 1368
1369 if (vid == 0 && vid == b53_default_pvid(dev))
1370 untagged = true;
1371
1369 vl->members |= BIT(port);1372 vl->members |= BIT(port);
1370 if (untagged && !dsa_is_cpu_port(ds, port))1373 if (untagged && !dsa_is_cpu_port(ds, port))
1371 vl->untag |= BIT(port);1374 vl->untag |= BIT(port);
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c+5−0
@@ -722,6 +722,11 @@ static int aq_ethtool_set_priv_flags(struct net_device *ndev, u32 flags) · 721 unmodified lines
722 if (flags & ~AQ_PRIV_FLAGS_MASK)722 if (flags & ~AQ_PRIV_FLAGS_MASK)
723 return -EOPNOTSUPP;723 return -EOPNOTSUPP;
724 724
725 if (hweight32((flags | priv_flags) & AQ_HW_LOOPBACK_MASK) > 1) {
726 netdev_info(ndev, "Can't enable more than one loopback simultaneously\n");
727 return -EINVAL;
728 }
729
725 cfg->priv_flags = flags;730 cfg->priv_flags = flags;
726 731
727 if ((priv_flags ^ flags) & BIT(AQ_HW_LOOPBACK_DMA_NET)) {732 if ((priv_flags ^ flags) & BIT(AQ_HW_LOOPBACK_DMA_NET)) {
drivers/net/ethernet/aquantia/atlantic/aq_filters.c+1−1
@@ -163,7 +163,7 @@ aq_check_approve_fvlan(struct aq_nic_s *aq_nic, · 162 unmodified lines
163 }163 }
164 164
165 if ((aq_nic->ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) &&165 if ((aq_nic->ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) &&
166 (!test_bit(be16_to_cpu(fsp->h_ext.vlan_tci),166 (!test_bit(be16_to_cpu(fsp->h_ext.vlan_tci) & VLAN_VID_MASK,
167 aq_nic->active_vlans))) {167 aq_nic->active_vlans))) {
168 netdev_err(aq_nic->ndev,168 netdev_err(aq_nic->ndev,
169 "ethtool: unknown vlan-id specified");169 "ethtool: unknown vlan-id specified");
drivers/net/ethernet/aquantia/atlantic/aq_hw.h+2−0
@@ -337,6 +337,8 @@ struct aq_fw_ops { · 336 unmodified lines
337 337
338 void (*enable_ptp)(struct aq_hw_s *self, int enable);338 void (*enable_ptp)(struct aq_hw_s *self, int enable);
339 339
340 void (*adjust_ptp)(struct aq_hw_s *self, uint64_t adj);
341
340 int (*set_eee_rate)(struct aq_hw_s *self, u32 speed);342 int (*set_eee_rate)(struct aq_hw_s *self, u32 speed);
341 343
342 int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,344 int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
drivers/net/ethernet/aquantia/atlantic/aq_nic.c+3−5
@@ -533,8 +533,10 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb, · 532 unmodified lines
533 dx_buff->len,533 dx_buff->len,
534 DMA_TO_DEVICE);534 DMA_TO_DEVICE);
535 535
536 if (unlikely(dma_mapping_error(aq_nic_get_dev(self), dx_buff->pa)))536 if (unlikely(dma_mapping_error(aq_nic_get_dev(self), dx_buff->pa))) {
537 ret = 0;
537 goto exit;538 goto exit;
539 }
538 540
539 first = dx_buff;541 first = dx_buff;
540 dx_buff->len_pkt = skb->len;542 dx_buff->len_pkt = skb->len;
@@ -655,10 +657,6 @@ int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb) · 114 unmodified lines
655 if (likely(frags)) {657 if (likely(frags)) {
656 err = self->aq_hw_ops->hw_ring_tx_xmit(self->aq_hw,658 err = self->aq_hw_ops->hw_ring_tx_xmit(self->aq_hw,
657 ring, frags);659 ring, frags);
658 if (err >= 0) {
659 ++ring->stats.tx.packets;
660 ring->stats.tx.bytes += skb->len;
661 }
662 } else {660 } else {
663 err = NETDEV_TX_BUSY;661 err = NETDEV_TX_BUSY;
664 }662 }
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c+8−5
@@ -359,7 +359,8 @@ static int aq_suspend_common(struct device *dev, bool deep) · 358 unmodified lines
359 netif_device_detach(nic->ndev);359 netif_device_detach(nic->ndev);
360 netif_tx_stop_all_queues(nic->ndev);360 netif_tx_stop_all_queues(nic->ndev);
361 361
362 aq_nic_stop(nic);362 if (netif_running(nic->ndev))
363 aq_nic_stop(nic);
363 364
364 if (deep) {365 if (deep) {
365 aq_nic_deinit(nic, !nic->aq_hw->aq_nic_cfg->wol);366 aq_nic_deinit(nic, !nic->aq_hw->aq_nic_cfg->wol);
@@ -375,7 +376,7 @@ static int atl_resume_common(struct device *dev, bool deep) · 9 unmodified lines
375{376{
376 struct pci_dev *pdev = to_pci_dev(dev);377 struct pci_dev *pdev = to_pci_dev(dev);
377 struct aq_nic_s *nic;378 struct aq_nic_s *nic;
378 int ret;379 int ret = 0;
379 380
380 nic = pci_get_drvdata(pdev);381 nic = pci_get_drvdata(pdev);
381 382
@@ -390,9 +391,11 @@ static int atl_resume_common(struct device *dev, bool deep) · 8 unmodified lines
390 goto err_exit;391 goto err_exit;
391 }392 }
392 393
393 ret = aq_nic_start(nic);394 if (netif_running(nic->ndev)) {
394 if (ret)395 ret = aq_nic_start(nic);
395 goto err_exit;396 if (ret)
397 goto err_exit;
398 }
396 399
397 netif_device_attach(nic->ndev);400 netif_device_attach(nic->ndev);
398 netif_tx_start_all_queues(nic->ndev);401 netif_tx_start_all_queues(nic->ndev);
drivers/net/ethernet/aquantia/atlantic/aq_ring.c+7−3
@@ -272,9 +272,12 @@ bool aq_ring_tx_clean(struct aq_ring_s *self) · 271 unmodified lines
272 }272 }
273 }273 }
274 274
275 if (unlikely(buff->is_eop))275 if (unlikely(buff->is_eop)) {
276 dev_kfree_skb_any(buff->skb);276 ++self->stats.rx.packets;
277 self->stats.tx.bytes += buff->skb->len;
277 278
279 dev_kfree_skb_any(buff->skb);
280 }
278 buff->pa = 0U;281 buff->pa = 0U;
279 buff->eop_index = 0xffffU;282 buff->eop_index = 0xffffU;
280 self->sw_head = aq_ring_next_dx(self, self->sw_head);283 self->sw_head = aq_ring_next_dx(self, self->sw_head);
@@ -351,7 +354,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self, · 70 unmodified lines
351 err = 0;354 err = 0;
352 goto err_exit;355 goto err_exit;
353 }356 }
354 if (buff->is_error || buff->is_cso_err) {357 if (buff->is_error ||
358 (buff->is_lro && buff->is_cso_err)) {
355 buff_ = buff;359 buff_ = buff;
356 do {360 do {
357 next_ = buff_->next,361 next_ = buff_->next,
drivers/net/ethernet/aquantia/atlantic/aq_ring.h+2−1
@@ -78,7 +78,8 @@ struct __packed aq_ring_buff_s { · 77 unmodified lines
78 u32 is_cleaned:1;78 u32 is_cleaned:1;
79 u32 is_error:1;79 u32 is_error:1;
80 u32 is_vlan:1;80 u32 is_vlan:1;
81 u32 rsvd3:4;81 u32 is_lro:1;
82 u32 rsvd3:3;
82 u16 eop_index;83 u16 eop_index;
83 u16 rsvd4;84 u16 rsvd4;
84 };85 };
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c+14−8
@@ -823,6 +823,8 @@ static int hw_atl_b0_hw_ring_rx_receive(struct aq_hw_s *self, · 822 unmodified lines
823 }823 }
824 }824 }
825 825
826 buff->is_lro = !!(HW_ATL_B0_RXD_WB_STAT2_RSCCNT &
827 rxd_wb->status);
826 if (HW_ATL_B0_RXD_WB_STAT2_EOP & rxd_wb->status) {828 if (HW_ATL_B0_RXD_WB_STAT2_EOP & rxd_wb->status) {
827 buff->len = rxd_wb->pkt_len %829 buff->len = rxd_wb->pkt_len %
828 AQ_CFG_RX_FRAME_MAX;830 AQ_CFG_RX_FRAME_MAX;
@@ -835,8 +837,7 @@ static int hw_atl_b0_hw_ring_rx_receive(struct aq_hw_s *self, · 6 unmodified lines
835 rxd_wb->pkt_len > AQ_CFG_RX_FRAME_MAX ?837 rxd_wb->pkt_len > AQ_CFG_RX_FRAME_MAX ?
836 AQ_CFG_RX_FRAME_MAX : rxd_wb->pkt_len;838 AQ_CFG_RX_FRAME_MAX : rxd_wb->pkt_len;
837 839
838 if (HW_ATL_B0_RXD_WB_STAT2_RSCCNT &840 if (buff->is_lro) {
839 rxd_wb->status) {
840 /* LRO */841 /* LRO */
841 buff->next = rxd_wb->next_desc_ptr;842 buff->next = rxd_wb->next_desc_ptr;
842 ++ring->stats.rx.lro_packets;843 ++ring->stats.rx.lro_packets;
@@ -884,13 +885,16 @@ static int hw_atl_b0_hw_packet_filter_set(struct aq_hw_s *self, · 41 unmodified lines
884{885{
885 struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;886 struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;
886 unsigned int i = 0U;887 unsigned int i = 0U;
888 u32 vlan_promisc;
889 u32 l2_promisc;
887 890
888 hw_atl_rpfl2promiscuous_mode_en_set(self,891 l2_promisc = IS_FILTER_ENABLED(IFF_PROMISC) ||
889 IS_FILTER_ENABLED(IFF_PROMISC));892 !!(cfg->priv_flags & BIT(AQ_HW_LOOPBACK_DMA_NET));
893 vlan_promisc = l2_promisc || cfg->is_vlan_force_promisc;
890 894
891 hw_atl_rpf_vlan_prom_mode_en_set(self,895 hw_atl_rpfl2promiscuous_mode_en_set(self, l2_promisc);
892 IS_FILTER_ENABLED(IFF_PROMISC) ||896
893 cfg->is_vlan_force_promisc);897 hw_atl_rpf_vlan_prom_mode_en_set(self, vlan_promisc);
894 898
895 hw_atl_rpfl2multicast_flr_en_set(self,899 hw_atl_rpfl2multicast_flr_en_set(self,
896 IS_FILTER_ENABLED(IFF_ALLMULTI) &&900 IS_FILTER_ENABLED(IFF_ALLMULTI) &&
@@ -1161,6 +1165,8 @@ static int hw_atl_b0_adj_sys_clock(struct aq_hw_s *self, s64 delta) · 264 unmodified lines
1161{1165{
1162 self->ptp_clk_offset += delta;1166 self->ptp_clk_offset += delta;
1163 1167
1168 self->aq_fw_ops->adjust_ptp(self, self->ptp_clk_offset);
1169
1164 return 0;1170 return 0;
1165}1171}
1166 1172
@@ -1211,7 +1217,7 @@ static int hw_atl_b0_gpio_pulse(struct aq_hw_s *self, u32 index, · 44 unmodified lines
1211 fwreq.ptp_gpio_ctrl.index = index;1217 fwreq.ptp_gpio_ctrl.index = index;
1212 fwreq.ptp_gpio_ctrl.period = period;1218 fwreq.ptp_gpio_ctrl.period = period;
1213 /* Apply time offset */1219 /* Apply time offset */
1214 fwreq.ptp_gpio_ctrl.start = start - self->ptp_clk_offset;1220 fwreq.ptp_gpio_ctrl.start = start;
1215 1221
1216 size = sizeof(fwreq.msg_id) + sizeof(fwreq.ptp_gpio_ctrl);1222 size = sizeof(fwreq.msg_id) + sizeof(fwreq.ptp_gpio_ctrl);
1217 return self->aq_fw_ops->send_fw_request(self, &fwreq, size);1223 return self->aq_fw_ops->send_fw_request(self, &fwreq, size);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c+17−2
@@ -22,6 +22,7 @@ · 21 unmodified lines
22#define HW_ATL_MIF_ADDR 0x0208U22#define HW_ATL_MIF_ADDR 0x0208U
23#define HW_ATL_MIF_VAL 0x020CU23#define HW_ATL_MIF_VAL 0x020CU
24 24
25#define HW_ATL_MPI_RPC_ADDR 0x0334U
25#define HW_ATL_RPC_CONTROL_ADR 0x0338U26#define HW_ATL_RPC_CONTROL_ADR 0x0338U
26#define HW_ATL_RPC_STATE_ADR 0x033CU27#define HW_ATL_RPC_STATE_ADR 0x033CU
27 28
@@ -53,15 +54,14 @@ enum mcp_area { · 25 unmodified lines
53};54};
54 55
55static int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);56static int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);
56
57static int hw_atl_utils_mpi_set_state(struct aq_hw_s *self,57static int hw_atl_utils_mpi_set_state(struct aq_hw_s *self,
58 enum hal_atl_utils_fw_state_e state);58 enum hal_atl_utils_fw_state_e state);
59
60static u32 hw_atl_utils_get_mpi_mbox_tid(struct aq_hw_s *self);59static u32 hw_atl_utils_get_mpi_mbox_tid(struct aq_hw_s *self);
61static u32 hw_atl_utils_mpi_get_state(struct aq_hw_s *self);60static u32 hw_atl_utils_mpi_get_state(struct aq_hw_s *self);
62static u32 hw_atl_utils_mif_cmd_get(struct aq_hw_s *self);61static u32 hw_atl_utils_mif_cmd_get(struct aq_hw_s *self);
63static u32 hw_atl_utils_mif_addr_get(struct aq_hw_s *self);62static u32 hw_atl_utils_mif_addr_get(struct aq_hw_s *self);
64static u32 hw_atl_utils_rpc_state_get(struct aq_hw_s *self);63static u32 hw_atl_utils_rpc_state_get(struct aq_hw_s *self);
64static u32 aq_fw1x_rpc_get(struct aq_hw_s *self);
65 65
66int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)66int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)
67{67{
@@ -476,6 +476,10 @@ static int hw_atl_utils_init_ucp(struct aq_hw_s *self, · 408 unmodified lines
476 self, self->mbox_addr,476 self, self->mbox_addr,
477 self->mbox_addr != 0U,477 self->mbox_addr != 0U,
478 1000U, 10000U);478 1000U, 10000U);
479 err = readx_poll_timeout_atomic(aq_fw1x_rpc_get, self,
480 self->rpc_addr,
481 self->rpc_addr != 0U,
482 1000U, 100000U);
479 483
480 return err;484 return err;
481}485}
@@ -531,6 +535,12 @@ int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self, · 49 unmodified lines
531 self, fw.val,535 self, fw.val,
532 sw.tid == fw.tid,536 sw.tid == fw.tid,
533 1000U, 100000U);537 1000U, 100000U);
538 if (err < 0)
539 goto err_exit;
540
541 err = aq_hw_err_from_flags(self);
542 if (err < 0)
543 goto err_exit;
534 544
535 if (fw.len == 0xFFFFU) {545 if (fw.len == 0xFFFFU) {
536 err = hw_atl_utils_fw_rpc_call(self, sw.len);546 err = hw_atl_utils_fw_rpc_call(self, sw.len);
@@ -1025,6 +1035,11 @@ static u32 hw_atl_utils_rpc_state_get(struct aq_hw_s *self) · 488 unmodified lines
1025 return aq_hw_read_reg(self, HW_ATL_RPC_STATE_ADR);1035 return aq_hw_read_reg(self, HW_ATL_RPC_STATE_ADR);
1026}1036}
1027 1037
1038static u32 aq_fw1x_rpc_get(struct aq_hw_s *self)
1039{
1040 return aq_hw_read_reg(self, HW_ATL_MPI_RPC_ADDR);
1041}
1042
1028const struct aq_fw_ops aq_fw_1x_ops = {1043const struct aq_fw_ops aq_fw_1x_ops = {
1029 .init = hw_atl_utils_mpi_create,1044 .init = hw_atl_utils_mpi_create,
1030 .deinit = hw_atl_fw1x_deinit,1045 .deinit = hw_atl_fw1x_deinit,
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c+12−0
@@ -30,6 +30,9 @@ · 29 unmodified lines
30#define HW_ATL_FW3X_EXT_CONTROL_ADDR 0x37830#define HW_ATL_FW3X_EXT_CONTROL_ADDR 0x378
31#define HW_ATL_FW3X_EXT_STATE_ADDR 0x37c31#define HW_ATL_FW3X_EXT_STATE_ADDR 0x37c
32 32
33#define HW_ATL_FW3X_PTP_ADJ_LSW_ADDR 0x50a0
34#define HW_ATL_FW3X_PTP_ADJ_MSW_ADDR 0x50a4
35
33#define HW_ATL_FW2X_CAP_PAUSE BIT(CAPS_HI_PAUSE)36#define HW_ATL_FW2X_CAP_PAUSE BIT(CAPS_HI_PAUSE)
34#define HW_ATL_FW2X_CAP_ASYM_PAUSE BIT(CAPS_HI_ASYMMETRIC_PAUSE)37#define HW_ATL_FW2X_CAP_ASYM_PAUSE BIT(CAPS_HI_ASYMMETRIC_PAUSE)
35#define HW_ATL_FW2X_CAP_SLEEP_PROXY BIT(CAPS_HI_SLEEP_PROXY)38#define HW_ATL_FW2X_CAP_SLEEP_PROXY BIT(CAPS_HI_SLEEP_PROXY)
@@ -475,6 +478,14 @@ static void aq_fw3x_enable_ptp(struct aq_hw_s *self, int enable) · 439 unmodified lines
475 aq_hw_write_reg(self, HW_ATL_FW3X_EXT_CONTROL_ADDR, ptp_opts);478 aq_hw_write_reg(self, HW_ATL_FW3X_EXT_CONTROL_ADDR, ptp_opts);
476}479}
477 480
481static void aq_fw3x_adjust_ptp(struct aq_hw_s *self, uint64_t adj)
482{
483 aq_hw_write_reg(self, HW_ATL_FW3X_PTP_ADJ_LSW_ADDR,
484 (adj >> 0) & 0xffffffff);
485 aq_hw_write_reg(self, HW_ATL_FW3X_PTP_ADJ_MSW_ADDR,
486 (adj >> 32) & 0xffffffff);
487}
488
478static int aq_fw2x_led_control(struct aq_hw_s *self, u32 mode)489static int aq_fw2x_led_control(struct aq_hw_s *self, u32 mode)
479{490{
480 if (self->fw_ver_actual < HW_ATL_FW_VER_LED)491 if (self->fw_ver_actual < HW_ATL_FW_VER_LED)
@@ -633,4 +644,5 @@ const struct aq_fw_ops aq_fw_2x_ops = { · 152 unmodified lines
633 .enable_ptp = aq_fw3x_enable_ptp,644 .enable_ptp = aq_fw3x_enable_ptp,
634 .led_control = aq_fw2x_led_control,645 .led_control = aq_fw2x_led_control,
635 .set_phyloopback = aq_fw2x_set_phyloopback,646 .set_phyloopback = aq_fw2x_set_phyloopback,
647 .adjust_ptp = aq_fw3x_adjust_ptp,
636};648};
drivers/net/ethernet/broadcom/bnxt/bnxt.c+10−2
@@ -11786,6 +11786,14 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 11785 unmodified lines
11786 if (version_printed++ == 0)11786 if (version_printed++ == 0)
11787 pr_info("%s", version);11787 pr_info("%s", version);
11788 11788
11789 /* Clear any pending DMA transactions from crash kernel
11790 * while loading driver in capture kernel.
11791 */
11792 if (is_kdump_kernel()) {
11793 pci_clear_master(pdev);
11794 pcie_flr(pdev);
11795 }
11796
11789 max_irqs = bnxt_get_max_irq(pdev);11797 max_irqs = bnxt_get_max_irq(pdev);
11790 dev = alloc_etherdev_mq(sizeof(*bp), max_irqs);11798 dev = alloc_etherdev_mq(sizeof(*bp), max_irqs);
11791 if (!dev)11799 if (!dev)
@@ -11983,10 +11991,10 @@ static void bnxt_shutdown(struct pci_dev *pdev) · 191 unmodified lines
11983 dev_close(dev);11991 dev_close(dev);
11984 11992
11985 bnxt_ulp_shutdown(bp);11993 bnxt_ulp_shutdown(bp);
11994 bnxt_clear_int_mode(bp);
11995 pci_disable_device(pdev);
11986 11996
11987 if (system_state == SYSTEM_POWER_OFF) {11997 if (system_state == SYSTEM_POWER_OFF) {
11988 bnxt_clear_int_mode(bp);
11989 pci_disable_device(pdev);
11990 pci_wake_from_d3(pdev, bp->wol);11998 pci_wake_from_d3(pdev, bp->wol);
11991 pci_set_power_state(pdev, PCI_D3hot);11999 pci_set_power_state(pdev, PCI_D3hot);
11992 }12000 }
drivers/net/ethernet/broadcom/cnic_defs.h+2−2
@@ -543,13 +543,13 @@ struct l4_kwq_update_pg { · 542 unmodified lines
543#define L4_KWQ_UPDATE_PG_RESERVERD2_SHIFT 2543#define L4_KWQ_UPDATE_PG_RESERVERD2_SHIFT 2
544#endif544#endif
545#if defined(__BIG_ENDIAN)545#if defined(__BIG_ENDIAN)
546 u16 reserverd3;546 u16 reserved3;
547 u8 da0;547 u8 da0;
548 u8 da1;548 u8 da1;
549#elif defined(__LITTLE_ENDIAN)549#elif defined(__LITTLE_ENDIAN)
550 u8 da1;550 u8 da1;
551 u8 da0;551 u8 da0;
552 u16 reserverd3;552 u16 reserved3;
553#endif553#endif
554#if defined(__BIG_ENDIAN)554#if defined(__BIG_ENDIAN)
555 u8 da2;555 u8 da2;
drivers/net/ethernet/cadence/macb.h+1−0
@@ -652,6 +652,7 @@ · 651 unmodified lines
652#define MACB_CAPS_GEM_HAS_PTP 0x00000040652#define MACB_CAPS_GEM_HAS_PTP 0x00000040
653#define MACB_CAPS_BD_RD_PREFETCH 0x00000080653#define MACB_CAPS_BD_RD_PREFETCH 0x00000080
654#define MACB_CAPS_NEEDS_RSTONUBR 0x00000100654#define MACB_CAPS_NEEDS_RSTONUBR 0x00000100
655#define MACB_CAPS_MACB_IS_EMAC 0x08000000
655#define MACB_CAPS_FIFO_MODE 0x10000000656#define MACB_CAPS_FIFO_MODE 0x10000000
656#define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000657#define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000
657#define MACB_CAPS_SG_DISABLED 0x40000000658#define MACB_CAPS_SG_DISABLED 0x40000000
drivers/net/ethernet/cadence/macb_main.c+37−29
@@ -572,8 +572,21 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode, · 571 unmodified lines
572 old_ctrl = ctrl = macb_or_gem_readl(bp, NCFGR);572 old_ctrl = ctrl = macb_or_gem_readl(bp, NCFGR);
573 573
574 /* Clear all the bits we might set later */574 /* Clear all the bits we might set later */
575 ctrl &= ~(GEM_BIT(GBE) | MACB_BIT(SPD) | MACB_BIT(FD) | MACB_BIT(PAE) |575 ctrl &= ~(MACB_BIT(SPD) | MACB_BIT(FD) | MACB_BIT(PAE));
576 GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL));576
577 if (bp->caps & MACB_CAPS_MACB_IS_EMAC) {
578 if (state->interface == PHY_INTERFACE_MODE_RMII)
579 ctrl |= MACB_BIT(RM9200_RMII);
580 } else {
581 ctrl &= ~(GEM_BIT(GBE) | GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL));
582
583 /* We do not support MLO_PAUSE_RX yet */
584 if (state->pause & MLO_PAUSE_TX)
585 ctrl |= MACB_BIT(PAE);
586
587 if (state->interface == PHY_INTERFACE_MODE_SGMII)
588 ctrl |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL);
589 }
577 590
578 if (state->speed == SPEED_1000)591 if (state->speed == SPEED_1000)
579 ctrl |= GEM_BIT(GBE);592 ctrl |= GEM_BIT(GBE);
@@ -583,13 +596,6 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode, · 3 unmodified lines
583 if (state->duplex)596 if (state->duplex)
584 ctrl |= MACB_BIT(FD);597 ctrl |= MACB_BIT(FD);
585 598
586 /* We do not support MLO_PAUSE_RX yet */
587 if (state->pause & MLO_PAUSE_TX)
588 ctrl |= MACB_BIT(PAE);
589
590 if (state->interface == PHY_INTERFACE_MODE_SGMII)
591 ctrl |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL);
592
593 /* Apply the new configuration, if any */599 /* Apply the new configuration, if any */
594 if (old_ctrl ^ ctrl)600 if (old_ctrl ^ ctrl)
595 macb_or_gem_writel(bp, NCFGR, ctrl);601 macb_or_gem_writel(bp, NCFGR, ctrl);
@@ -608,9 +614,10 @@ static void macb_mac_link_down(struct phylink_config *config, unsigned int mode, · 12 unmodified lines
608 unsigned int q;614 unsigned int q;
609 u32 ctrl;615 u32 ctrl;
610 616
611 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)617 if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC))
612 queue_writel(queue, IDR,618 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
613 bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));619 queue_writel(queue, IDR,
620 bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));
614 621
615 /* Disable Rx and Tx */622 /* Disable Rx and Tx */
616 ctrl = macb_readl(bp, NCR) & ~(MACB_BIT(RE) | MACB_BIT(TE));623 ctrl = macb_readl(bp, NCR) & ~(MACB_BIT(RE) | MACB_BIT(TE));
@@ -627,17 +634,19 @@ static void macb_mac_link_up(struct phylink_config *config, unsigned int mode, · 10 unmodified lines
627 struct macb_queue *queue;634 struct macb_queue *queue;
628 unsigned int q;635 unsigned int q;
629 636
630 macb_set_tx_clk(bp->tx_clk, bp->speed, ndev);637 if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC)) {
638 macb_set_tx_clk(bp->tx_clk, bp->speed, ndev);
631 639
632 /* Initialize rings & buffers as clearing MACB_BIT(TE) in link down640 /* Initialize rings & buffers as clearing MACB_BIT(TE) in link down
633 * cleared the pipeline and control registers.641 * cleared the pipeline and control registers.
634 */642 */
635 bp->macbgem_ops.mog_init_rings(bp);643 bp->macbgem_ops.mog_init_rings(bp);
636 macb_init_buffers(bp);644 macb_init_buffers(bp);
637 645
638 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)646 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
639 queue_writel(queue, IER,647 queue_writel(queue, IER,
640 bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));648 bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));
649 }
641 650
642 /* Enable Rx and Tx */651 /* Enable Rx and Tx */
643 macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE) | MACB_BIT(TE));652 macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE) | MACB_BIT(TE));
@@ -3790,6 +3799,10 @@ static int at91ether_open(struct net_device *dev) · 3146 unmodified lines
3790 u32 ctl;3799 u32 ctl;
3791 int ret;3800 int ret;
3792 3801
3802 ret = pm_runtime_get_sync(&lp->pdev->dev);
3803 if (ret < 0)
3804 return ret;
3805
3793 /* Clear internal statistics */3806 /* Clear internal statistics */
3794 ctl = macb_readl(lp, NCR);3807 ctl = macb_readl(lp, NCR);
3795 macb_writel(lp, NCR, ctl | MACB_BIT(CLRSTAT));3808 macb_writel(lp, NCR, ctl | MACB_BIT(CLRSTAT));
@@ -3854,7 +3867,7 @@ static int at91ether_close(struct net_device *dev) · 58 unmodified lines
3854 q->rx_buffers, q->rx_buffers_dma);3867 q->rx_buffers, q->rx_buffers_dma);
3855 q->rx_buffers = NULL;3868 q->rx_buffers = NULL;
3856 3869
3857 return 0;3870 return pm_runtime_put(&lp->pdev->dev);
3858}3871}
3859 3872
3860/* Transmit packet */3873/* Transmit packet */
@@ -4037,7 +4050,6 @@ static int at91ether_init(struct platform_device *pdev) · 176 unmodified lines
4037 struct net_device *dev = platform_get_drvdata(pdev);4050 struct net_device *dev = platform_get_drvdata(pdev);
4038 struct macb *bp = netdev_priv(dev);4051 struct macb *bp = netdev_priv(dev);
4039 int err;4052 int err;
4040 u32 reg;
4041 4053
4042 bp->queues[0].bp = bp;4054 bp->queues[0].bp = bp;
4043 4055
@@ -4051,11 +4063,7 @@ static int at91ether_init(struct platform_device *pdev) · 7 unmodified lines
4051 4063
4052 macb_writel(bp, NCR, 0);4064 macb_writel(bp, NCR, 0);
4053 4065
4054 reg = MACB_BF(CLK, MACB_CLK_DIV32) | MACB_BIT(BIG);4066 macb_writel(bp, NCFGR, MACB_BF(CLK, MACB_CLK_DIV32) | MACB_BIT(BIG));
4055 if (bp->phy_interface == PHY_INTERFACE_MODE_RMII)
4056 reg |= MACB_BIT(RM9200_RMII);
4057
4058 macb_writel(bp, NCFGR, reg);
4059 4067
4060 return 0;4068 return 0;
4061}4069}
@@ -4214,7 +4222,7 @@ static const struct macb_config sama5d4_config = { · 152 unmodified lines
4214};4222};
4215 4223
4216static const struct macb_config emac_config = {4224static const struct macb_config emac_config = {
4217 .caps = MACB_CAPS_NEEDS_RSTONUBR,4225 .caps = MACB_CAPS_NEEDS_RSTONUBR | MACB_CAPS_MACB_IS_EMAC,
4218 .clk_init = at91ether_clk_init,4226 .clk_init = at91ether_clk_init,
4219 .init = at91ether_init,4227 .init = at91ether_init,
4220};4228};
drivers/net/ethernet/cavium/thunder/thunder_bgx.c+59−3
@@ -410,10 +410,19 @@ void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable) · 409 unmodified lines
410 lmac = &bgx->lmac[lmacid];410 lmac = &bgx->lmac[lmacid];
411 411
412 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);412 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
413 if (enable)413 if (enable) {
414 cfg |= CMR_PKT_RX_EN | CMR_PKT_TX_EN;414 cfg |= CMR_PKT_RX_EN | CMR_PKT_TX_EN;
415 else415
416 /* enable TX FIFO Underflow interrupt */
417 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_INT_ENA_W1S,
418 GMI_TXX_INT_UNDFLW);
419 } else {
416 cfg &= ~(CMR_PKT_RX_EN | CMR_PKT_TX_EN);420 cfg &= ~(CMR_PKT_RX_EN | CMR_PKT_TX_EN);
421
422 /* Disable TX FIFO Underflow interrupt */
423 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_INT_ENA_W1C,
424 GMI_TXX_INT_UNDFLW);
425 }
417 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);426 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
418 427
419 if (bgx->is_rgx)428 if (bgx->is_rgx)
@@ -1535,6 +1544,48 @@ static int bgx_init_phy(struct bgx *bgx) · 1115 unmodified lines
1535 return bgx_init_of_phy(bgx);1544 return bgx_init_of_phy(bgx);
1536}1545}
1537 1546
1547static irqreturn_t bgx_intr_handler(int irq, void *data)
1548{
1549 struct bgx *bgx = (struct bgx *)data;
1550 u64 status, val;
1551 int lmac;
1552
1553 for (lmac = 0; lmac < bgx->lmac_count; lmac++) {
1554 status = bgx_reg_read(bgx, lmac, BGX_GMP_GMI_TXX_INT);
1555 if (status & GMI_TXX_INT_UNDFLW) {
1556 pci_err(bgx->pdev, "BGX%d lmac%d UNDFLW\n",
1557 bgx->bgx_id, lmac);
1558 val = bgx_reg_read(bgx, lmac, BGX_CMRX_CFG);
1559 val &= ~CMR_EN;
1560 bgx_reg_write(bgx, lmac, BGX_CMRX_CFG, val);
1561 val |= CMR_EN;
1562 bgx_reg_write(bgx, lmac, BGX_CMRX_CFG, val);
1563 }
1564 /* clear interrupts */
1565 bgx_reg_write(bgx, lmac, BGX_GMP_GMI_TXX_INT, status);
1566 }
1567
1568 return IRQ_HANDLED;
1569}
1570
1571static void bgx_register_intr(struct pci_dev *pdev)
1572{
1573 struct bgx *bgx = pci_get_drvdata(pdev);
1574 int ret;
1575
1576 ret = pci_alloc_irq_vectors(pdev, BGX_LMAC_VEC_OFFSET,
1577 BGX_LMAC_VEC_OFFSET, PCI_IRQ_ALL_TYPES);
1578 if (ret < 0) {
1579 pci_err(pdev, "Req for #%d msix vectors failed\n",
1580 BGX_LMAC_VEC_OFFSET);
1581 return;
1582 }
1583 ret = pci_request_irq(pdev, GMPX_GMI_TX_INT, bgx_intr_handler, NULL,
1584 bgx, "BGX%d", bgx->bgx_id);
1585 if (ret)
1586 pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx);
1587}
1588
1538static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)1589static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1539{1590{
1540 int err;1591 int err;
@@ -1550,7 +1601,7 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 9 unmodified lines
1550 1601
1551 pci_set_drvdata(pdev, bgx);1602 pci_set_drvdata(pdev, bgx);
1552 1603
1553 err = pci_enable_device(pdev);1604 err = pcim_enable_device(pdev);
1554 if (err) {1605 if (err) {
1555 dev_err(dev, "Failed to enable PCI device\n");1606 dev_err(dev, "Failed to enable PCI device\n");
1556 pci_set_drvdata(pdev, NULL);1607 pci_set_drvdata(pdev, NULL);
@@ -1604,6 +1655,8 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 47 unmodified lines
1604 1655
1605 bgx_init_hw(bgx);1656 bgx_init_hw(bgx);
1606 1657
1658 bgx_register_intr(pdev);
1659
1607 /* Enable all LMACs */1660 /* Enable all LMACs */
1608 for (lmac = 0; lmac < bgx->lmac_count; lmac++) {1661 for (lmac = 0; lmac < bgx->lmac_count; lmac++) {
1609 err = bgx_lmac_enable(bgx, lmac);1662 err = bgx_lmac_enable(bgx, lmac);
@@ -1620,6 +1673,7 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 10 unmodified lines
1620 1673
1621err_enable:1674err_enable:
1622 bgx_vnic[bgx->bgx_id] = NULL;1675 bgx_vnic[bgx->bgx_id] = NULL;
1676 pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx);
1623err_release_regions:1677err_release_regions:
1624 pci_release_regions(pdev);1678 pci_release_regions(pdev);
1625err_disable_device:1679err_disable_device:
@@ -1637,6 +1691,8 @@ static void bgx_remove(struct pci_dev *pdev) · 11 unmodified lines
1637 for (lmac = 0; lmac < bgx->lmac_count; lmac++)1691 for (lmac = 0; lmac < bgx->lmac_count; lmac++)
1638 bgx_lmac_disable(bgx, lmac);1692 bgx_lmac_disable(bgx, lmac);
1639 1693
1694 pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx);
1695
1640 bgx_vnic[bgx->bgx_id] = NULL;1696 bgx_vnic[bgx->bgx_id] = NULL;
1641 pci_release_regions(pdev);1697 pci_release_regions(pdev);
1642 pci_disable_device(pdev);1698 pci_disable_device(pdev);
drivers/net/ethernet/cavium/thunder/thunder_bgx.h+9−0
@@ -180,6 +180,15 @@ · 179 unmodified lines
180#define BGX_GMP_GMI_TXX_BURST 0x38228180#define BGX_GMP_GMI_TXX_BURST 0x38228
181#define BGX_GMP_GMI_TXX_MIN_PKT 0x38240181#define BGX_GMP_GMI_TXX_MIN_PKT 0x38240
182#define BGX_GMP_GMI_TXX_SGMII_CTL 0x38300182#define BGX_GMP_GMI_TXX_SGMII_CTL 0x38300
183#define BGX_GMP_GMI_TXX_INT 0x38500
184#define BGX_GMP_GMI_TXX_INT_W1S 0x38508
185#define BGX_GMP_GMI_TXX_INT_ENA_W1C 0x38510
186#define BGX_GMP_GMI_TXX_INT_ENA_W1S 0x38518
187#define GMI_TXX_INT_PTP_LOST BIT_ULL(4)
188#define GMI_TXX_INT_LATE_COL BIT_ULL(3)
189#define GMI_TXX_INT_XSDEF BIT_ULL(2)
190#define GMI_TXX_INT_XSCOL BIT_ULL(1)
191#define GMI_TXX_INT_UNDFLW BIT_ULL(0)
183 192
184#define BGX_MSIX_VEC_0_29_ADDR 0x400000 /* +(0..29) << 4 */193#define BGX_MSIX_VEC_0_29_ADDR 0x400000 /* +(0..29) << 4 */
185#define BGX_MSIX_VEC_0_29_CTL 0x400008194#define BGX_MSIX_VEC_0_29_CTL 0x400008
drivers/net/ethernet/davicom/dm9000.c+2−0
@@ -1405,6 +1405,8 @@ static struct dm9000_plat_data *dm9000_parse_dt(struct device *dev) · 1404 unmodified lines
1405 mac_addr = of_get_mac_address(np);1405 mac_addr = of_get_mac_address(np);
1406 if (!IS_ERR(mac_addr))1406 if (!IS_ERR(mac_addr))
1407 ether_addr_copy(pdata->dev_addr, mac_addr);1407 ether_addr_copy(pdata->dev_addr, mac_addr);
1408 else if (PTR_ERR(mac_addr) == -EPROBE_DEFER)
1409 return ERR_CAST(mac_addr);
1408 1410
1409 return pdata;1411 return pdata;
1410}1412}
drivers/net/ethernet/intel/ice/ice_ethtool.c+38−18
@@ -2936,13 +2936,6 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) · 2935 unmodified lines
2936 else2936 else
2937 return -EINVAL;2937 return -EINVAL;
2938 2938
2939 /* Tell the OS link is going down, the link will go back up when fw
2940 * says it is ready asynchronously
2941 */
2942 ice_print_link_msg(vsi, false);
2943 netif_carrier_off(netdev);
2944 netif_tx_stop_all_queues(netdev);
2945
2946 /* Set the FC mode and only restart AN if link is up */2939 /* Set the FC mode and only restart AN if link is up */
2947 status = ice_set_fc(pi, &aq_failures, link_up);2940 status = ice_set_fc(pi, &aq_failures, link_up);
2948 2941
@@ -3489,21 +3482,13 @@ ice_set_rc_coalesce(enum ice_container_type c_type, struct ethtool_coalesce *ec, · 540 unmodified lines
3489 return -EINVAL;3482 return -EINVAL;
3490 }3483 }
3491 3484
3492 /* hardware only supports an ITR granularity of 2us */
3493 if (coalesce_usecs % 2 != 0) {
3494 netdev_info(vsi->netdev, "Invalid value, %s-usecs must be even\n",
3495 c_type_str);
3496 return -EINVAL;
3497 }
3498
3499 if (use_adaptive_coalesce) {3485 if (use_adaptive_coalesce) {
3500 rc->itr_setting |= ICE_ITR_DYNAMIC;3486 rc->itr_setting |= ICE_ITR_DYNAMIC;
3501 } else {3487 } else {
3502 /* store user facing value how it was set */3488 /* save the user set usecs */
3503 rc->itr_setting = coalesce_usecs;3489 rc->itr_setting = coalesce_usecs;
3504 /* set to static and convert to value HW understands */3490 /* device ITR granularity is in 2 usec increments */
3505 rc->target_itr =3491 rc->target_itr = ITR_REG_ALIGN(rc->itr_setting);
3506 ITR_TO_REG(ITR_REG_ALIGN(rc->itr_setting));
3507 }3492 }
3508 3493
3509 return 0;3494 return 0;
@@ -3596,6 +3581,30 @@ ice_is_coalesce_param_invalid(struct net_device *netdev, · 86 unmodified lines
3596 return 0;3581 return 0;
3597}3582}
3598 3583
3584/**
3585 * ice_print_if_odd_usecs - print message if user tries to set odd [tx|rx]-usecs
3586 * @netdev: netdev used for print
3587 * @itr_setting: previous user setting
3588 * @use_adaptive_coalesce: if adaptive coalesce is enabled or being enabled
3589 * @coalesce_usecs: requested value of [tx|rx]-usecs
3590 * @c_type_str: either "rx" or "tx" to match user set field of [tx|rx]-usecs
3591 */
3592static void
3593ice_print_if_odd_usecs(struct net_device *netdev, u16 itr_setting,
3594 u32 use_adaptive_coalesce, u32 coalesce_usecs,
3595 const char *c_type_str)
3596{
3597 if (use_adaptive_coalesce)
3598 return;
3599
3600 itr_setting = ITR_TO_REG(itr_setting);
3601
3602 if (itr_setting != coalesce_usecs && (coalesce_usecs % 2))
3603 netdev_info(netdev, "User set %s-usecs to %d, device only supports even values. Rounding down and attempting to set %s-usecs to %d\n",
3604 c_type_str, coalesce_usecs, c_type_str,
3605 ITR_REG_ALIGN(coalesce_usecs));
3606}
3607
3599/**3608/**
3600 * __ice_set_coalesce - set ITR/INTRL values for the device3609 * __ice_set_coalesce - set ITR/INTRL values for the device
3601 * @netdev: pointer to the netdev associated with this query3610 * @netdev: pointer to the netdev associated with this query
@@ -3616,8 +3625,19 @@ __ice_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec, · 14 unmodified lines
3616 return -EINVAL;3625 return -EINVAL;
3617 3626
3618 if (q_num < 0) {3627 if (q_num < 0) {
3628 struct ice_q_vector *q_vector = vsi->q_vectors[0];
3619 int v_idx;3629 int v_idx;
3620 3630
3631 if (q_vector) {
3632 ice_print_if_odd_usecs(netdev, q_vector->rx.itr_setting,
3633 ec->use_adaptive_rx_coalesce,
3634 ec->rx_coalesce_usecs, "rx");
3635
3636 ice_print_if_odd_usecs(netdev, q_vector->tx.itr_setting,
3637 ec->use_adaptive_tx_coalesce,
3638 ec->tx_coalesce_usecs, "tx");
3639 }
3640
3621 ice_for_each_q_vector(vsi, v_idx) {3641 ice_for_each_q_vector(vsi, v_idx) {
3622 /* In some cases if DCB is configured the num_[rx|tx]q3642 /* In some cases if DCB is configured the num_[rx|tx]q
3623 * can be less than vsi->num_q_vectors. This check3643 * can be less than vsi->num_q_vectors. This check
drivers/net/ethernet/intel/ice/ice_txrx.h+1−1
@@ -222,7 +222,7 @@ enum ice_rx_dtype { · 221 unmodified lines
222#define ICE_ITR_GRAN_S 1 /* ITR granularity is always 2us */222#define ICE_ITR_GRAN_S 1 /* ITR granularity is always 2us */
223#define ICE_ITR_GRAN_US BIT(ICE_ITR_GRAN_S)223#define ICE_ITR_GRAN_US BIT(ICE_ITR_GRAN_S)
224#define ICE_ITR_MASK 0x1FFE /* ITR register value alignment mask */224#define ICE_ITR_MASK 0x1FFE /* ITR register value alignment mask */
225#define ITR_REG_ALIGN(setting) __ALIGN_MASK(setting, ~ICE_ITR_MASK)225#define ITR_REG_ALIGN(setting) ((setting) & ICE_ITR_MASK)
226 226
227#define ICE_ITR_ADAPTIVE_MIN_INC 0x0002227#define ICE_ITR_ADAPTIVE_MIN_INC 0x0002
228#define ICE_ITR_ADAPTIVE_MIN_USECS 0x0002228#define ICE_ITR_ADAPTIVE_MIN_USECS 0x0002
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c+74−60
@@ -1873,6 +1873,48 @@ error_param: · 1872 unmodified lines
1873 NULL, 0);1873 NULL, 0);
1874}1874}
1875 1875
1876/**
1877 * ice_wait_on_vf_reset - poll to make sure a given VF is ready after reset
1878 * @vf: The VF being resseting
1879 *
1880 * The max poll time is about ~800ms, which is about the maximum time it takes
1881 * for a VF to be reset and/or a VF driver to be removed.
1882 */
1883static void ice_wait_on_vf_reset(struct ice_vf *vf)
1884{
1885 int i;
1886
1887 for (i = 0; i < ICE_MAX_VF_RESET_TRIES; i++) {
1888 if (test_bit(ICE_VF_STATE_INIT, vf->vf_states))
1889 break;
1890 msleep(ICE_MAX_VF_RESET_SLEEP_MS);
1891 }
1892}
1893
1894/**
1895 * ice_check_vf_ready_for_cfg - check if VF is ready to be configured/queried
1896 * @vf: VF to check if it's ready to be configured/queried
1897 *
1898 * The purpose of this function is to make sure the VF is not in reset, not
1899 * disabled, and initialized so it can be configured and/or queried by a host
1900 * administrator.
1901 */
1902static int ice_check_vf_ready_for_cfg(struct ice_vf *vf)
1903{
1904 struct ice_pf *pf;
1905
1906 ice_wait_on_vf_reset(vf);
1907
1908 if (ice_is_vf_disabled(vf))
1909 return -EINVAL;
1910
1911 pf = vf->pf;
1912 if (ice_check_vf_init(pf, vf))
1913 return -EBUSY;
1914
1915 return 0;
1916}
1917
1876/**1918/**
1877 * ice_set_vf_spoofchk1919 * ice_set_vf_spoofchk
1878 * @netdev: network interface device structure1920 * @netdev: network interface device structure
@@ -1890,16 +1932,16 @@ int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena) · 11 unmodified lines
1890 enum ice_status status;1932 enum ice_status status;
1891 struct device *dev;1933 struct device *dev;
1892 struct ice_vf *vf;1934 struct ice_vf *vf;
1893 int ret = 0;1935 int ret;
1894 1936
1895 dev = ice_pf_to_dev(pf);1937 dev = ice_pf_to_dev(pf);
1896 if (ice_validate_vf_id(pf, vf_id))1938 if (ice_validate_vf_id(pf, vf_id))
1897 return -EINVAL;1939 return -EINVAL;
1898 1940
1899 vf = &pf->vf[vf_id];1941 vf = &pf->vf[vf_id];
1900 1942 ret = ice_check_vf_ready_for_cfg(vf);
1901 if (ice_check_vf_init(pf, vf))1943 if (ret)
1902 return -EBUSY;1944 return ret;
1903 1945
1904 vf_vsi = pf->vsi[vf->lan_vsi_idx];1946 vf_vsi = pf->vsi[vf->lan_vsi_idx];
1905 if (!vf_vsi) {1947 if (!vf_vsi) {
@@ -2696,7 +2738,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 790 unmodified lines
2696 struct ice_vsi *vsi;2738 struct ice_vsi *vsi;
2697 struct device *dev;2739 struct device *dev;
2698 struct ice_vf *vf;2740 struct ice_vf *vf;
2699 int ret = 0;2741 int ret;
2700 2742
2701 dev = ice_pf_to_dev(pf);2743 dev = ice_pf_to_dev(pf);
2702 if (ice_validate_vf_id(pf, vf_id))2744 if (ice_validate_vf_id(pf, vf_id))
@@ -2714,13 +2756,15 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 11 unmodified lines
2714 2756
2715 vf = &pf->vf[vf_id];2757 vf = &pf->vf[vf_id];
2716 vsi = pf->vsi[vf->lan_vsi_idx];2758 vsi = pf->vsi[vf->lan_vsi_idx];
2717 if (ice_check_vf_init(pf, vf))2759
2718 return -EBUSY;2760 ret = ice_check_vf_ready_for_cfg(vf);
2761 if (ret)
2762 return ret;
2719 2763
2720 if (le16_to_cpu(vsi->info.pvid) == vlanprio) {2764 if (le16_to_cpu(vsi->info.pvid) == vlanprio) {
2721 /* duplicate request, so just return success */2765 /* duplicate request, so just return success */
2722 dev_dbg(dev, "Duplicate pvid %d request\n", vlanprio);2766 dev_dbg(dev, "Duplicate pvid %d request\n", vlanprio);
2723 return ret;2767 return 0;
2724 }2768 }
2725 2769
2726 /* If PVID, then remove all filters on the old VLAN */2770 /* If PVID, then remove all filters on the old VLAN */
@@ -2731,7 +2775,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 4 unmodified lines
2731 if (vlan_id || qos) {2775 if (vlan_id || qos) {
2732 ret = ice_vsi_manage_pvid(vsi, vlanprio, true);2776 ret = ice_vsi_manage_pvid(vsi, vlanprio, true);
2733 if (ret)2777 if (ret)
2734 goto error_set_pvid;2778 return ret;
2735 } else {2779 } else {
2736 ice_vsi_manage_pvid(vsi, 0, false);2780 ice_vsi_manage_pvid(vsi, 0, false);
2737 vsi->info.pvid = 0;2781 vsi->info.pvid = 0;
@@ -2744,7 +2788,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 6 unmodified lines
2744 /* add new VLAN filter for each MAC */2788 /* add new VLAN filter for each MAC */
2745 ret = ice_vsi_add_vlan(vsi, vlan_id);2789 ret = ice_vsi_add_vlan(vsi, vlan_id);
2746 if (ret)2790 if (ret)
2747 goto error_set_pvid;2791 return ret;
2748 }2792 }
2749 2793
2750 /* The Port VLAN needs to be saved across resets the same as the2794 /* The Port VLAN needs to be saved across resets the same as the
@@ -2752,8 +2796,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 1 unmodified line
2752 */2796 */
2753 vf->port_vlan_id = le16_to_cpu(vsi->info.pvid);2797 vf->port_vlan_id = le16_to_cpu(vsi->info.pvid);
2754 2798
2755error_set_pvid:2799 return 0;
2756 return ret;
2757}2800}
2758 2801
2759/**2802/**
@@ -3236,23 +3279,6 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi) · 476 unmodified lines
3236 return 0;3279 return 0;
3237}3280}
3238 3281
3239/**
3240 * ice_wait_on_vf_reset
3241 * @vf: The VF being resseting
3242 *
3243 * Poll to make sure a given VF is ready after reset
3244 */
3245static void ice_wait_on_vf_reset(struct ice_vf *vf)
3246{
3247 int i;
3248
3249 for (i = 0; i < ICE_MAX_VF_RESET_WAIT; i++) {
3250 if (test_bit(ICE_VF_STATE_INIT, vf->vf_states))
3251 break;
3252 msleep(20);
3253 }
3254}
3255
3256/**3282/**
3257 * ice_set_vf_mac3283 * ice_set_vf_mac
3258 * @netdev: network interface device structure3284 * @netdev: network interface device structure
@@ -3265,29 +3291,21 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) · 6 unmodified lines
3265{3291{
3266 struct ice_pf *pf = ice_netdev_to_pf(netdev);3292 struct ice_pf *pf = ice_netdev_to_pf(netdev);
3267 struct ice_vf *vf;3293 struct ice_vf *vf;
3268 int ret = 0;3294 int ret;
3269 3295
3270 if (ice_validate_vf_id(pf, vf_id))3296 if (ice_validate_vf_id(pf, vf_id))
3271 return -EINVAL;3297 return -EINVAL;
3272 3298
3273 vf = &pf->vf[vf_id];
3274 /* Don't set MAC on disabled VF */
3275 if (ice_is_vf_disabled(vf))
3276 return -EINVAL;
3277
3278 /* In case VF is in reset mode, wait until it is completed. Depending
3279 * on factors like queue disabling routine, this could take ~250ms
3280 */
3281 ice_wait_on_vf_reset(vf);
3282
3283 if (ice_check_vf_init(pf, vf))
3284 return -EBUSY;
3285
3286 if (is_zero_ether_addr(mac) || is_multicast_ether_addr(mac)) {3299 if (is_zero_ether_addr(mac) || is_multicast_ether_addr(mac)) {
3287 netdev_err(netdev, "%pM not a valid unicast address\n", mac);3300 netdev_err(netdev, "%pM not a valid unicast address\n", mac);
3288 return -EINVAL;3301 return -EINVAL;
3289 }3302 }
3290 3303
3304 vf = &pf->vf[vf_id];
3305 ret = ice_check_vf_ready_for_cfg(vf);
3306 if (ret)
3307 return ret;
3308
3291 /* copy MAC into dflt_lan_addr and trigger a VF reset. The reset3309 /* copy MAC into dflt_lan_addr and trigger a VF reset. The reset
3292 * flow will use the updated dflt_lan_addr and add a MAC filter3310 * flow will use the updated dflt_lan_addr and add a MAC filter
3293 * using ice_add_mac. Also set pf_set_mac to indicate that the PF has3311 * using ice_add_mac. Also set pf_set_mac to indicate that the PF has
@@ -3299,7 +3317,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) · 5 unmodified lines
3299 vf_id, mac);3317 vf_id, mac);
3300 3318
3301 ice_vc_reset_vf(vf);3319 ice_vc_reset_vf(vf);
3302 return ret;3320 return 0;
3303}3321}
3304 3322
3305/**3323/**
@@ -3314,22 +3332,15 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted) · 8 unmodified lines
3314{3332{
3315 struct ice_pf *pf = ice_netdev_to_pf(netdev);3333 struct ice_pf *pf = ice_netdev_to_pf(netdev);
3316 struct ice_vf *vf;3334 struct ice_vf *vf;
3335 int ret;
3317 3336
3318 if (ice_validate_vf_id(pf, vf_id))3337 if (ice_validate_vf_id(pf, vf_id))
3319 return -EINVAL;3338 return -EINVAL;
3320 3339
3321 vf = &pf->vf[vf_id];3340 vf = &pf->vf[vf_id];
3322 /* Don't set Trusted Mode on disabled VF */3341 ret = ice_check_vf_ready_for_cfg(vf);
3323 if (ice_is_vf_disabled(vf))3342 if (ret)
3324 return -EINVAL;3343 return ret;
3325
3326 /* In case VF is in reset mode, wait until it is completed. Depending
3327 * on factors like queue disabling routine, this could take ~250ms
3328 */
3329 ice_wait_on_vf_reset(vf);
3330
3331 if (ice_check_vf_init(pf, vf))
3332 return -EBUSY;
3333 3344
3334 /* Check if already trusted */3345 /* Check if already trusted */
3335 if (trusted == vf->trusted)3346 if (trusted == vf->trusted)
@@ -3355,13 +3366,15 @@ int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state) · 19 unmodified lines
3355{3366{
3356 struct ice_pf *pf = ice_netdev_to_pf(netdev);3367 struct ice_pf *pf = ice_netdev_to_pf(netdev);
3357 struct ice_vf *vf;3368 struct ice_vf *vf;
3369 int ret;
3358 3370
3359 if (ice_validate_vf_id(pf, vf_id))3371 if (ice_validate_vf_id(pf, vf_id))
3360 return -EINVAL;3372 return -EINVAL;
3361 3373
3362 vf = &pf->vf[vf_id];3374 vf = &pf->vf[vf_id];
3363 if (ice_check_vf_init(pf, vf))3375 ret = ice_check_vf_ready_for_cfg(vf);
3364 return -EBUSY;3376 if (ret)
3377 return ret;
3365 3378
3366 switch (link_state) {3379 switch (link_state) {
3367 case IFLA_VF_LINK_STATE_AUTO:3380 case IFLA_VF_LINK_STATE_AUTO:
@@ -3397,14 +3410,15 @@ int ice_get_vf_stats(struct net_device *netdev, int vf_id, · 29 unmodified lines
3397 struct ice_eth_stats *stats;3410 struct ice_eth_stats *stats;
3398 struct ice_vsi *vsi;3411 struct ice_vsi *vsi;
3399 struct ice_vf *vf;3412 struct ice_vf *vf;
3413 int ret;
3400 3414
3401 if (ice_validate_vf_id(pf, vf_id))3415 if (ice_validate_vf_id(pf, vf_id))
3402 return -EINVAL;3416 return -EINVAL;
3403 3417
3404 vf = &pf->vf[vf_id];3418 vf = &pf->vf[vf_id];
3405 3419 ret = ice_check_vf_ready_for_cfg(vf);
3406 if (ice_check_vf_init(pf, vf))3420 if (ret)
3407 return -EBUSY;3421 return ret;
3408 3422
3409 vsi = pf->vsi[vf->lan_vsi_idx];3423 vsi = pf->vsi[vf->lan_vsi_idx];
3410 if (!vsi)3424 if (!vsi)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h+2−1
@@ -38,7 +38,8 @@ · 37 unmodified lines
38#define ICE_MAX_POLICY_INTR_PER_VF 3338#define ICE_MAX_POLICY_INTR_PER_VF 33
39#define ICE_MIN_INTR_PER_VF (ICE_MIN_QS_PER_VF + 1)39#define ICE_MIN_INTR_PER_VF (ICE_MIN_QS_PER_VF + 1)
40#define ICE_DFLT_INTR_PER_VF (ICE_DFLT_QS_PER_VF + 1)40#define ICE_DFLT_INTR_PER_VF (ICE_DFLT_QS_PER_VF + 1)
41#define ICE_MAX_VF_RESET_WAIT 1541#define ICE_MAX_VF_RESET_TRIES 40
42#define ICE_MAX_VF_RESET_SLEEP_MS 20
42 43
43#define ice_for_each_vf(pf, i) \44#define ice_for_each_vf(pf, i) \
44 for ((i) = 0; (i) < (pf)->num_alloc_vfs; (i)++)45 for ((i) = 0; (i) < (pf)->num_alloc_vfs; (i)++)
drivers/net/ethernet/mellanox/mlx5/core/en/health.c+1−1
@@ -200,7 +200,7 @@ int mlx5e_health_report(struct mlx5e_priv *priv, · 199 unmodified lines
200 netdev_err(priv->netdev, err_str);200 netdev_err(priv->netdev, err_str);
201 201
202 if (!reporter)202 if (!reporter)
203 return err_ctx->recover(&err_ctx->ctx);203 return err_ctx->recover(err_ctx->ctx);
204 204
205 return devlink_health_report(reporter, err_str, err_ctx);205 return devlink_health_report(reporter, err_str, err_ctx);
206}206}
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h+8−0
@@ -179,6 +179,14 @@ mlx5e_tx_dma_unmap(struct device *pdev, struct mlx5e_sq_dma *dma) · 178 unmodified lines
179 }179 }
180}180}
181 181
182static inline void mlx5e_rqwq_reset(struct mlx5e_rq *rq)
183{
184 if (rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
185 mlx5_wq_ll_reset(&rq->mpwqe.wq);
186 else
187 mlx5_wq_cyc_reset(&rq->wqe.wq);
188}
189
182/* SW parser related functions */190/* SW parser related functions */
183 191
184struct mlx5e_swp_spec {192struct mlx5e_swp_spec {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+3−0
@@ -712,6 +712,9 @@ int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state, int next_state) · 711 unmodified lines
712 if (!in)712 if (!in)
713 return -ENOMEM;713 return -ENOMEM;
714 714
715 if (curr_state == MLX5_RQC_STATE_RST && next_state == MLX5_RQC_STATE_RDY)
716 mlx5e_rqwq_reset(rq);
717
715 rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);718 rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
716 719
717 MLX5_SET(modify_rq_in, in, rq_state, curr_state);720 MLX5_SET(modify_rq_in, in, rq_state, curr_state);
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c+8−12
@@ -459,12 +459,16 @@ static void esw_destroy_legacy_table(struct mlx5_eswitch *esw) · 458 unmodified lines
459 459
460static int esw_legacy_enable(struct mlx5_eswitch *esw)460static int esw_legacy_enable(struct mlx5_eswitch *esw)
461{461{
462 int ret;462 struct mlx5_vport *vport;
463 int ret, i;
463 464
464 ret = esw_create_legacy_table(esw);465 ret = esw_create_legacy_table(esw);
465 if (ret)466 if (ret)
466 return ret;467 return ret;
467 468
469 mlx5_esw_for_each_vf_vport(esw, i, vport, esw->esw_funcs.num_vfs)
470 vport->info.link_state = MLX5_VPORT_ADMIN_STATE_AUTO;
471
468 ret = mlx5_eswitch_enable_pf_vf_vports(esw, MLX5_LEGACY_SRIOV_VPORT_EVENTS);472 ret = mlx5_eswitch_enable_pf_vf_vports(esw, MLX5_LEGACY_SRIOV_VPORT_EVENTS);
469 if (ret)473 if (ret)
470 esw_destroy_legacy_table(esw);474 esw_destroy_legacy_table(esw);
@@ -2452,25 +2456,17 @@ out: · 1981 unmodified lines
2452 2456
2453int mlx5_eswitch_get_vepa(struct mlx5_eswitch *esw, u8 *setting)2457int mlx5_eswitch_get_vepa(struct mlx5_eswitch *esw, u8 *setting)
2454{2458{
2455 int err = 0;
2456
2457 if (!esw)2459 if (!esw)
2458 return -EOPNOTSUPP;2460 return -EOPNOTSUPP;
2459 2461
2460 if (!ESW_ALLOWED(esw))2462 if (!ESW_ALLOWED(esw))
2461 return -EPERM;2463 return -EPERM;
2462 2464
2463 mutex_lock(&esw->state_lock);2465 if (esw->mode != MLX5_ESWITCH_LEGACY)
2464 if (esw->mode != MLX5_ESWITCH_LEGACY) {2466 return -EOPNOTSUPP;
2465 err = -EOPNOTSUPP;
2466 goto out;
2467 }
2468 2467
2469 *setting = esw->fdb_table.legacy.vepa_uplink_rule ? 1 : 0;2468 *setting = esw->fdb_table.legacy.vepa_uplink_rule ? 1 : 0;
2470 2469 return 0;
2471out:
2472 mutex_unlock(&esw->state_lock);
2473 return err;
2474}2470}
2475 2471
2476int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,2472int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+2−2
@@ -1172,7 +1172,7 @@ static int esw_offloads_start(struct mlx5_eswitch *esw, · 1171 unmodified lines
1172 return -EINVAL;1172 return -EINVAL;
1173 }1173 }
1174 1174
1175 mlx5_eswitch_disable(esw, true);1175 mlx5_eswitch_disable(esw, false);
1176 mlx5_eswitch_update_num_of_vfs(esw, esw->dev->priv.sriov.num_vfs);1176 mlx5_eswitch_update_num_of_vfs(esw, esw->dev->priv.sriov.num_vfs);
1177 err = mlx5_eswitch_enable(esw, MLX5_ESWITCH_OFFLOADS);1177 err = mlx5_eswitch_enable(esw, MLX5_ESWITCH_OFFLOADS);
1178 if (err) {1178 if (err) {
@@ -2065,7 +2065,7 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw, · 886 unmodified lines
2065{2065{
2066 int err, err1;2066 int err, err1;
2067 2067
2068 mlx5_eswitch_disable(esw, true);2068 mlx5_eswitch_disable(esw, false);
2069 err = mlx5_eswitch_enable(esw, MLX5_ESWITCH_LEGACY);2069 err = mlx5_eswitch_enable(esw, MLX5_ESWITCH_LEGACY);
2070 if (err) {2070 if (err) {
2071 NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy");2071 NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy");
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c+1−1
@@ -35,7 +35,7 @@ · 34 unmodified lines
35static const unsigned int ESW_POOLS[] = { 4 * 1024 * 1024,35static const unsigned int ESW_POOLS[] = { 4 * 1024 * 1024,
36 1 * 1024 * 1024,36 1 * 1024 * 1024,
37 64 * 1024,37 64 * 1024,
38 4 * 1024, };38 128 };
39 39
40struct mlx5_esw_chains_priv {40struct mlx5_esw_chains_priv {
41 struct rhashtable chains_ht;41 struct rhashtable chains_ht;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c+4−1
@@ -2307,7 +2307,9 @@ static int dr_ste_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value, · 2306 unmodified lines
2307 struct mlx5dr_cmd_vport_cap *vport_cap;2307 struct mlx5dr_cmd_vport_cap *vport_cap;
2308 struct mlx5dr_domain *dmn = sb->dmn;2308 struct mlx5dr_domain *dmn = sb->dmn;
2309 struct mlx5dr_cmd_caps *caps;2309 struct mlx5dr_cmd_caps *caps;
2310 u8 *bit_mask = sb->bit_mask;
2310 u8 *tag = hw_ste->tag;2311 u8 *tag = hw_ste->tag;
2312 bool source_gvmi_set;
2311 2313
2312 DR_STE_SET_TAG(src_gvmi_qp, tag, source_qp, misc, source_sqn);2314 DR_STE_SET_TAG(src_gvmi_qp, tag, source_qp, misc, source_sqn);
2313 2315
@@ -2328,7 +2330,8 @@ static int dr_ste_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value, · 14 unmodified lines
2328 if (!vport_cap)2330 if (!vport_cap)
2329 return -EINVAL;2331 return -EINVAL;
2330 2332
2331 if (vport_cap->vport_gvmi)2333 source_gvmi_set = MLX5_GET(ste_src_gvmi_qp, bit_mask, source_gvmi);
2334 if (vport_cap->vport_gvmi && source_gvmi_set)
2332 MLX5_SET(ste_src_gvmi_qp, tag, source_gvmi, vport_cap->vport_gvmi);2335 MLX5_SET(ste_src_gvmi_qp, tag, source_gvmi, vport_cap->vport_gvmi);
2333 2336
2334 misc->source_eswitch_owner_vhca_id = 0;2337 misc->source_eswitch_owner_vhca_id = 0;
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c+7−2
@@ -66,15 +66,20 @@ static int mlx5_cmd_dr_create_flow_table(struct mlx5_flow_root_namespace *ns, · 65 unmodified lines
66 struct mlx5_flow_table *next_ft)66 struct mlx5_flow_table *next_ft)
67{67{
68 struct mlx5dr_table *tbl;68 struct mlx5dr_table *tbl;
69 u32 flags;
69 int err;70 int err;
70 71
71 if (mlx5_dr_is_fw_table(ft->flags))72 if (mlx5_dr_is_fw_table(ft->flags))
72 return mlx5_fs_cmd_get_fw_cmds()->create_flow_table(ns, ft,73 return mlx5_fs_cmd_get_fw_cmds()->create_flow_table(ns, ft,
73 log_size,74 log_size,
74 next_ft);75 next_ft);
76 flags = ft->flags;
77 /* turn off encap/decap if not supported for sw-str by fw */
78 if (!MLX5_CAP_FLOWTABLE(ns->dev, sw_owner_reformat_supported))
79 flags = ft->flags & ~(MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT |
80 MLX5_FLOW_TABLE_TUNNEL_EN_DECAP);
75 81
76 tbl = mlx5dr_table_create(ns->fs_dr_domain.dr_domain,82 tbl = mlx5dr_table_create(ns->fs_dr_domain.dr_domain, ft->level, flags);
77 ft->level, ft->flags);
78 if (!tbl) {83 if (!tbl) {
79 mlx5_core_err(ns->dev, "Failed creating dr flow_table\n");84 mlx5_core_err(ns->dev, "Failed creating dr flow_table\n");
80 return -EINVAL;85 return -EINVAL;
drivers/net/ethernet/mellanox/mlx5/core/wq.c+30−9
@@ -94,6 +94,13 @@ void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides) · 93 unmodified lines
94 print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, wqe, len, false);94 print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, wqe, len, false);
95}95}
96 96
97void mlx5_wq_cyc_reset(struct mlx5_wq_cyc *wq)
98{
99 wq->wqe_ctr = 0;
100 wq->cur_sz = 0;
101 mlx5_wq_cyc_update_db_record(wq);
102}
103
97int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,104int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
98 void *qpc, struct mlx5_wq_qp *wq,105 void *qpc, struct mlx5_wq_qp *wq,
99 struct mlx5_wq_ctrl *wq_ctrl)106 struct mlx5_wq_ctrl *wq_ctrl)
@@ -192,6 +199,19 @@ err_db_free: · 92 unmodified lines
192 return err;199 return err;
193}200}
194 201
202static void mlx5_wq_ll_init_list(struct mlx5_wq_ll *wq)
203{
204 struct mlx5_wqe_srq_next_seg *next_seg;
205 int i;
206
207 for (i = 0; i < wq->fbc.sz_m1; i++) {
208 next_seg = mlx5_wq_ll_get_wqe(wq, i);
209 next_seg->next_wqe_index = cpu_to_be16(i + 1);
210 }
211 next_seg = mlx5_wq_ll_get_wqe(wq, i);
212 wq->tail_next = &next_seg->next_wqe_index;
213}
214
195int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,215int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
196 void *wqc, struct mlx5_wq_ll *wq,216 void *wqc, struct mlx5_wq_ll *wq,
197 struct mlx5_wq_ctrl *wq_ctrl)217 struct mlx5_wq_ctrl *wq_ctrl)
@@ -199,9 +219,7 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, · 1 unmodified line
199 u8 log_wq_stride = MLX5_GET(wq, wqc, log_wq_stride);219 u8 log_wq_stride = MLX5_GET(wq, wqc, log_wq_stride);
200 u8 log_wq_sz = MLX5_GET(wq, wqc, log_wq_sz);220 u8 log_wq_sz = MLX5_GET(wq, wqc, log_wq_sz);
201 struct mlx5_frag_buf_ctrl *fbc = &wq->fbc;221 struct mlx5_frag_buf_ctrl *fbc = &wq->fbc;
202 struct mlx5_wqe_srq_next_seg *next_seg;
203 int err;222 int err;
204 int i;
205 223
206 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node);224 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node);
207 if (err) {225 if (err) {
@@ -220,13 +238,7 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, · 12 unmodified lines
220 238
221 mlx5_init_fbc(wq_ctrl->buf.frags, log_wq_stride, log_wq_sz, fbc);239 mlx5_init_fbc(wq_ctrl->buf.frags, log_wq_stride, log_wq_sz, fbc);
222 240
223 for (i = 0; i < fbc->sz_m1; i++) {241 mlx5_wq_ll_init_list(wq);
224 next_seg = mlx5_wq_ll_get_wqe(wq, i);
225 next_seg->next_wqe_index = cpu_to_be16(i + 1);
226 }
227 next_seg = mlx5_wq_ll_get_wqe(wq, i);
228 wq->tail_next = &next_seg->next_wqe_index;
229
230 wq_ctrl->mdev = mdev;242 wq_ctrl->mdev = mdev;
231 243
232 return 0;244 return 0;
@@ -237,6 +249,15 @@ err_db_free: · 4 unmodified lines
237 return err;249 return err;
238}250}
239 251
252void mlx5_wq_ll_reset(struct mlx5_wq_ll *wq)
253{
254 wq->head = 0;
255 wq->wqe_ctr = 0;
256 wq->cur_sz = 0;
257 mlx5_wq_ll_init_list(wq);
258 mlx5_wq_ll_update_db_record(wq);
259}
260
240void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl)261void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl)
241{262{
242 mlx5_frag_buf_free(wq_ctrl->mdev, &wq_ctrl->buf);263 mlx5_frag_buf_free(wq_ctrl->mdev, &wq_ctrl->buf);
drivers/net/ethernet/mellanox/mlx5/core/wq.h+2−0
@@ -80,6 +80,7 @@ int mlx5_wq_cyc_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, · 79 unmodified lines
80 void *wqc, struct mlx5_wq_cyc *wq,80 void *wqc, struct mlx5_wq_cyc *wq,
81 struct mlx5_wq_ctrl *wq_ctrl);81 struct mlx5_wq_ctrl *wq_ctrl);
82void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides);82void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides);
83void mlx5_wq_cyc_reset(struct mlx5_wq_cyc *wq);
83 84
84int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,85int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
85 void *qpc, struct mlx5_wq_qp *wq,86 void *qpc, struct mlx5_wq_qp *wq,
@@ -92,6 +93,7 @@ int mlx5_cqwq_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, · 6 unmodified lines
92int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,93int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
93 void *wqc, struct mlx5_wq_ll *wq,94 void *wqc, struct mlx5_wq_ll *wq,
94 struct mlx5_wq_ctrl *wq_ctrl);95 struct mlx5_wq_ctrl *wq_ctrl);
96void mlx5_wq_ll_reset(struct mlx5_wq_ll *wq);
95 97
96void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl);98void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl);
97 99
drivers/net/ethernet/micrel/ks8851_mll.c+9−44
@@ -156,24 +156,6 @@ static int msg_enable; · 155 unmodified lines
156 * chip is busy transferring packet data (RX/TX FIFO accesses).156 * chip is busy transferring packet data (RX/TX FIFO accesses).
157 */157 */
158 158
159/**
160 * ks_rdreg8 - read 8 bit register from device
161 * @ks : The chip information
162 * @offset: The register address
163 *
164 * Read a 8bit register from the chip, returning the result
165 */
166static u8 ks_rdreg8(struct ks_net *ks, int offset)
167{
168 u16 data;
169 u8 shift_bit = offset & 0x03;
170 u8 shift_data = (offset & 1) << 3;
171 ks->cmd_reg_cache = (u16) offset | (u16)(BE0 << shift_bit);
172 iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
173 data = ioread16(ks->hw_addr);
174 return (u8)(data >> shift_data);
175}
176
177/**159/**
178 * ks_rdreg16 - read 16 bit register from device160 * ks_rdreg16 - read 16 bit register from device
179 * @ks : The chip information161 * @ks : The chip information
@@ -184,27 +166,11 @@ static u8 ks_rdreg8(struct ks_net *ks, int offset) · 4 unmodified lines
184 166
185static u16 ks_rdreg16(struct ks_net *ks, int offset)167static u16 ks_rdreg16(struct ks_net *ks, int offset)
186{168{
187 ks->cmd_reg_cache = (u16)offset | ((BE1 | BE0) << (offset & 0x02));169 ks->cmd_reg_cache = (u16)offset | ((BE3 | BE2) >> (offset & 0x02));
188 iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);170 iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
189 return ioread16(ks->hw_addr);171 return ioread16(ks->hw_addr);
190}172}
191 173
192/**
193 * ks_wrreg8 - write 8bit register value to chip
194 * @ks: The chip information
195 * @offset: The register address
196 * @value: The value to write
197 *
198 */
199static void ks_wrreg8(struct ks_net *ks, int offset, u8 value)
200{
201 u8 shift_bit = (offset & 0x03);
202 u16 value_write = (u16)(value << ((offset & 1) << 3));
203 ks->cmd_reg_cache = (u16)offset | (BE0 << shift_bit);
204 iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
205 iowrite16(value_write, ks->hw_addr);
206}
207
208/**174/**
209 * ks_wrreg16 - write 16bit register value to chip175 * ks_wrreg16 - write 16bit register value to chip
210 * @ks: The chip information176 * @ks: The chip information
@@ -215,7 +181,7 @@ static void ks_wrreg8(struct ks_net *ks, int offset, u8 value) · 4 unmodified lines
215 181
216static void ks_wrreg16(struct ks_net *ks, int offset, u16 value)182static void ks_wrreg16(struct ks_net *ks, int offset, u16 value)
217{183{
218 ks->cmd_reg_cache = (u16)offset | ((BE1 | BE0) << (offset & 0x02));184 ks->cmd_reg_cache = (u16)offset | ((BE3 | BE2) >> (offset & 0x02));
219 iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);185 iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
220 iowrite16(value, ks->hw_addr);186 iowrite16(value, ks->hw_addr);
221}187}
@@ -231,7 +197,7 @@ static inline void ks_inblk(struct ks_net *ks, u16 *wptr, u32 len) · 9 unmodified lines
231{197{
232 len >>= 1;198 len >>= 1;
233 while (len--)199 while (len--)
234 *wptr++ = (u16)ioread16(ks->hw_addr);200 *wptr++ = be16_to_cpu(ioread16(ks->hw_addr));
235}201}
236 202
237/**203/**
@@ -245,7 +211,7 @@ static inline void ks_outblk(struct ks_net *ks, u16 *wptr, u32 len) · 7 unmodified lines
245{211{
246 len >>= 1;212 len >>= 1;
247 while (len--)213 while (len--)
248 iowrite16(*wptr++, ks->hw_addr);214 iowrite16(cpu_to_be16(*wptr++), ks->hw_addr);
249}215}
250 216
251static void ks_disable_int(struct ks_net *ks)217static void ks_disable_int(struct ks_net *ks)
@@ -324,8 +290,7 @@ static void ks_read_config(struct ks_net *ks) · 72 unmodified lines
324 u16 reg_data = 0;290 u16 reg_data = 0;
325 291
326 /* Regardless of bus width, 8 bit read should always work.*/292 /* Regardless of bus width, 8 bit read should always work.*/
327 reg_data = ks_rdreg8(ks, KS_CCR) & 0x00FF;293 reg_data = ks_rdreg16(ks, KS_CCR);
328 reg_data |= ks_rdreg8(ks, KS_CCR+1) << 8;
329 294
330 /* addr/data bus are multiplexed */295 /* addr/data bus are multiplexed */
331 ks->sharedbus = (reg_data & CCR_SHARED) == CCR_SHARED;296 ks->sharedbus = (reg_data & CCR_SHARED) == CCR_SHARED;
@@ -429,7 +394,7 @@ static inline void ks_read_qmu(struct ks_net *ks, u16 *buf, u32 len) · 97 unmodified lines
429 394
430 /* 1. set sudo DMA mode */395 /* 1. set sudo DMA mode */
431 ks_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI);396 ks_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI);
432 ks_wrreg8(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_SDA) & 0xff);397 ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
433 398
434 /* 2. read prepend data */399 /* 2. read prepend data */
435 /**400 /**
@@ -446,7 +411,7 @@ static inline void ks_read_qmu(struct ks_net *ks, u16 *buf, u32 len) · 10 unmodified lines
446 ks_inblk(ks, buf, ALIGN(len, 4));411 ks_inblk(ks, buf, ALIGN(len, 4));
447 412
448 /* 4. reset sudo DMA Mode */413 /* 4. reset sudo DMA Mode */
449 ks_wrreg8(ks, KS_RXQCR, ks->rc_rxqcr);414 ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
450}415}
451 416
452/**417/**
@@ -679,13 +644,13 @@ static void ks_write_qmu(struct ks_net *ks, u8 *pdata, u16 len) · 226 unmodified lines
679 ks->txh.txw[1] = cpu_to_le16(len);644 ks->txh.txw[1] = cpu_to_le16(len);
680 645
681 /* 1. set sudo-DMA mode */646 /* 1. set sudo-DMA mode */
682 ks_wrreg8(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_SDA) & 0xff);647 ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
683 /* 2. write status/lenth info */648 /* 2. write status/lenth info */
684 ks_outblk(ks, ks->txh.txw, 4);649 ks_outblk(ks, ks->txh.txw, 4);
685 /* 3. write pkt data */650 /* 3. write pkt data */
686 ks_outblk(ks, (u16 *)pdata, ALIGN(len, 4));651 ks_outblk(ks, (u16 *)pdata, ALIGN(len, 4));
687 /* 4. reset sudo-DMA mode */652 /* 4. reset sudo-DMA mode */
688 ks_wrreg8(ks, KS_RXQCR, ks->rc_rxqcr);653 ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
689 /* 5. Enqueue Tx(move the pkt from TX buffer into TXQ) */654 /* 5. Enqueue Tx(move the pkt from TX buffer into TXQ) */
690 ks_wrreg16(ks, KS_TXQCR, TXQCR_METFE);655 ks_wrreg16(ks, KS_TXQCR, TXQCR_METFE);
691 /* 6. wait until TXQCR_METFE is auto-cleared */656 /* 6. wait until TXQCR_METFE is auto-cleared */
drivers/net/ethernet/mscc/ocelot_board.c+8−0
@@ -114,6 +114,14 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) · 113 unmodified lines
114 if (err != 4)114 if (err != 4)
115 break;115 break;
116 116
117 /* At this point the IFH was read correctly, so it is safe to
118 * presume that there is no error. The err needs to be reset
119 * otherwise a frame could come in CPU queue between the while
120 * condition and the check for error later on. And in that case
121 * the new frame is just removed and not processed.
122 */
123 err = 0;
124
117 ocelot_parse_ifh(ifh, &info);125 ocelot_parse_ifh(ifh, &info);
118 126
119 ocelot_port = ocelot->ports[info.port];127 ocelot_port = ocelot->ports[info.port];
drivers/net/ethernet/pensando/ionic/ionic_dev.c+7−4
@@ -103,7 +103,7 @@ int ionic_heartbeat_check(struct ionic *ionic) · 102 unmodified lines
103{103{
104 struct ionic_dev *idev = &ionic->idev;104 struct ionic_dev *idev = &ionic->idev;
105 unsigned long hb_time;105 unsigned long hb_time;
106 u32 fw_status;106 u8 fw_status;
107 u32 hb;107 u32 hb;
108 108
109 /* wait a little more than one second before testing again */109 /* wait a little more than one second before testing again */
@@ -111,9 +111,12 @@ int ionic_heartbeat_check(struct ionic *ionic) · 1 unmodified line
111 if (time_before(hb_time, (idev->last_hb_time + ionic->watchdog_period)))111 if (time_before(hb_time, (idev->last_hb_time + ionic->watchdog_period)))
112 return 0;112 return 0;
113 113
114 /* firmware is useful only if fw_status is non-zero */114 /* firmware is useful only if the running bit is set and
115 fw_status = ioread32(&idev->dev_info_regs->fw_status);115 * fw_status != 0xff (bad PCI read)
116 if (!fw_status)116 */
117 fw_status = ioread8(&idev->dev_info_regs->fw_status);
118 if (fw_status == 0xff ||
119 !(fw_status & IONIC_FW_STS_F_RUNNING))
117 return -ENXIO;120 return -ENXIO;
118 121
119 /* early FW has no heartbeat, else FW will return non-zero */122 /* early FW has no heartbeat, else FW will return non-zero */
drivers/net/ethernet/pensando/ionic/ionic_if.h+1−0
@@ -2445,6 +2445,7 @@ union ionic_dev_info_regs { · 2444 unmodified lines
2445 u8 version;2445 u8 version;
2446 u8 asic_type;2446 u8 asic_type;
2447 u8 asic_rev;2447 u8 asic_rev;
2448#define IONIC_FW_STS_F_RUNNING 0x1
2448 u8 fw_status;2449 u8 fw_status;
2449 u32 fw_heartbeat;2450 u32 fw_heartbeat;
2450 char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN];2451 char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN];
drivers/net/ethernet/qlogic/qede/qede.h+2−0
@@ -163,6 +163,8 @@ struct qede_rdma_dev { · 162 unmodified lines
163 struct list_head entry;163 struct list_head entry;
164 struct list_head rdma_event_list;164 struct list_head rdma_event_list;
165 struct workqueue_struct *rdma_wq;165 struct workqueue_struct *rdma_wq;
166 struct kref refcnt;
167 struct completion event_comp;
166 bool exp_recovery;168 bool exp_recovery;
167};169};
168 170
drivers/net/ethernet/qlogic/qede/qede_rdma.c+28−1
@@ -59,6 +59,9 @@ static void _qede_rdma_dev_add(struct qede_dev *edev) · 58 unmodified lines
59static int qede_rdma_create_wq(struct qede_dev *edev)59static int qede_rdma_create_wq(struct qede_dev *edev)
60{60{
61 INIT_LIST_HEAD(&edev->rdma_info.rdma_event_list);61 INIT_LIST_HEAD(&edev->rdma_info.rdma_event_list);
62 kref_init(&edev->rdma_info.refcnt);
63 init_completion(&edev->rdma_info.event_comp);
64
62 edev->rdma_info.rdma_wq = create_singlethread_workqueue("rdma_wq");65 edev->rdma_info.rdma_wq = create_singlethread_workqueue("rdma_wq");
63 if (!edev->rdma_info.rdma_wq) {66 if (!edev->rdma_info.rdma_wq) {
64 DP_NOTICE(edev, "qedr: Could not create workqueue\n");67 DP_NOTICE(edev, "qedr: Could not create workqueue\n");
@@ -83,8 +86,23 @@ static void qede_rdma_cleanup_event(struct qede_dev *edev) · 18 unmodified lines
83 }86 }
84}87}
85 88
89static void qede_rdma_complete_event(struct kref *ref)
90{
91 struct qede_rdma_dev *rdma_dev =
92 container_of(ref, struct qede_rdma_dev, refcnt);
93
94 /* no more events will be added after this */
95 complete(&rdma_dev->event_comp);
96}
97
86static void qede_rdma_destroy_wq(struct qede_dev *edev)98static void qede_rdma_destroy_wq(struct qede_dev *edev)
87{99{
100 /* Avoid race with add_event flow, make sure it finishes before
101 * we start accessing the list and cleaning up the work
102 */
103 kref_put(&edev->rdma_info.refcnt, qede_rdma_complete_event);
104 wait_for_completion(&edev->rdma_info.event_comp);
105
88 qede_rdma_cleanup_event(edev);106 qede_rdma_cleanup_event(edev);
89 destroy_workqueue(edev->rdma_info.rdma_wq);107 destroy_workqueue(edev->rdma_info.rdma_wq);
90}108}
@@ -310,15 +328,24 @@ static void qede_rdma_add_event(struct qede_dev *edev, · 219 unmodified lines
310 if (!edev->rdma_info.qedr_dev)328 if (!edev->rdma_info.qedr_dev)
311 return;329 return;
312 330
331 /* We don't want the cleanup flow to start while we're allocating and
332 * scheduling the work
333 */
334 if (!kref_get_unless_zero(&edev->rdma_info.refcnt))
335 return; /* already being destroyed */
336
313 event_node = qede_rdma_get_free_event_node(edev);337 event_node = qede_rdma_get_free_event_node(edev);
314 if (!event_node)338 if (!event_node)
315 return;339 goto out;
316 340
317 event_node->event = event;341 event_node->event = event;
318 event_node->ptr = edev;342 event_node->ptr = edev;
319 343
320 INIT_WORK(&event_node->work, qede_rdma_handle_event);344 INIT_WORK(&event_node->work, qede_rdma_handle_event);
321 queue_work(edev->rdma_info.rdma_wq, &event_node->work);345 queue_work(edev->rdma_info.rdma_wq, &event_node->work);
346
347out:
348 kref_put(&edev->rdma_info.refcnt, qede_rdma_complete_event);
322}349}
323 350
324void qede_rdma_dev_event_open(struct qede_dev *edev)351void qede_rdma_dev_event_open(struct qede_dev *edev)
drivers/net/phy/broadcom.c+2−2
@@ -410,7 +410,7 @@ static int bcm5481_config_aneg(struct phy_device *phydev) · 409 unmodified lines
410 struct device_node *np = phydev->mdio.dev.of_node;410 struct device_node *np = phydev->mdio.dev.of_node;
411 int ret;411 int ret;
412 412
413 /* Aneg firsly. */413 /* Aneg firstly. */
414 ret = genphy_config_aneg(phydev);414 ret = genphy_config_aneg(phydev);
415 415
416 /* Then we can set up the delay. */416 /* Then we can set up the delay. */
@@ -463,7 +463,7 @@ static int bcm54616s_config_aneg(struct phy_device *phydev) · 46 unmodified lines
463{463{
464 int ret;464 int ret;
465 465
466 /* Aneg firsly. */466 /* Aneg firstly. */
467 if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX)467 if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX)
468 ret = genphy_c37_config_aneg(phydev);468 ret = genphy_c37_config_aneg(phydev);
469 else469 else
drivers/net/phy/mdio-bcm-iproc.c+20−0
@@ -178,6 +178,23 @@ static int iproc_mdio_remove(struct platform_device *pdev) · 177 unmodified lines
178 return 0;178 return 0;
179}179}
180 180
181#ifdef CONFIG_PM_SLEEP
182int iproc_mdio_resume(struct device *dev)
183{
184 struct platform_device *pdev = to_platform_device(dev);
185 struct iproc_mdio_priv *priv = platform_get_drvdata(pdev);
186
187 /* restore the mii clock configuration */
188 iproc_mdio_config_clk(priv->base);
189
190 return 0;
191}
192
193static const struct dev_pm_ops iproc_mdio_pm_ops = {
194 .resume = iproc_mdio_resume
195};
196#endif /* CONFIG_PM_SLEEP */
197
181static const struct of_device_id iproc_mdio_of_match[] = {198static const struct of_device_id iproc_mdio_of_match[] = {
182 { .compatible = "brcm,iproc-mdio", },199 { .compatible = "brcm,iproc-mdio", },
183 { /* sentinel */ },200 { /* sentinel */ },
@@ -188,6 +205,9 @@ static struct platform_driver iproc_mdio_driver = { · 4 unmodified lines
188 .driver = {205 .driver = {
189 .name = "iproc-mdio",206 .name = "iproc-mdio",
190 .of_match_table = iproc_mdio_of_match,207 .of_match_table = iproc_mdio_of_match,
208#ifdef CONFIG_PM_SLEEP
209 .pm = &iproc_mdio_pm_ops,
210#endif
191 },211 },
192 .probe = iproc_mdio_probe,212 .probe = iproc_mdio_probe,
193 .remove = iproc_mdio_remove,213 .remove = iproc_mdio_remove,
drivers/net/wireguard/device.c+4−3
@@ -258,6 +258,8 @@ static void wg_setup(struct net_device *dev) · 257 unmodified lines
258 enum { WG_NETDEV_FEATURES = NETIF_F_HW_CSUM | NETIF_F_RXCSUM |258 enum { WG_NETDEV_FEATURES = NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
259 NETIF_F_SG | NETIF_F_GSO |259 NETIF_F_SG | NETIF_F_GSO |
260 NETIF_F_GSO_SOFTWARE | NETIF_F_HIGHDMA };260 NETIF_F_GSO_SOFTWARE | NETIF_F_HIGHDMA };
261 const int overhead = MESSAGE_MINIMUM_LENGTH + sizeof(struct udphdr) +
262 max(sizeof(struct ipv6hdr), sizeof(struct iphdr));
261 263
262 dev->netdev_ops = &netdev_ops;264 dev->netdev_ops = &netdev_ops;
263 dev->hard_header_len = 0;265 dev->hard_header_len = 0;
@@ -271,9 +273,8 @@ static void wg_setup(struct net_device *dev) · 7 unmodified lines
271 dev->features |= WG_NETDEV_FEATURES;273 dev->features |= WG_NETDEV_FEATURES;
272 dev->hw_features |= WG_NETDEV_FEATURES;274 dev->hw_features |= WG_NETDEV_FEATURES;
273 dev->hw_enc_features |= WG_NETDEV_FEATURES;275 dev->hw_enc_features |= WG_NETDEV_FEATURES;
274 dev->mtu = ETH_DATA_LEN - MESSAGE_MINIMUM_LENGTH -276 dev->mtu = ETH_DATA_LEN - overhead;
275 sizeof(struct udphdr) -277 dev->max_mtu = round_down(INT_MAX, MESSAGE_PADDING_MULTIPLE) - overhead;
276 max(sizeof(struct ipv6hdr), sizeof(struct iphdr));
277 278
278 SET_NETDEV_DEVTYPE(dev, &device_type);279 SET_NETDEV_DEVTYPE(dev, &device_type);
279 280
drivers/net/wireguard/receive.c+5−2
@@ -118,10 +118,13 @@ static void wg_receive_handshake_packet(struct wg_device *wg, · 117 unmodified lines
118 118
119 under_load = skb_queue_len(&wg->incoming_handshakes) >=119 under_load = skb_queue_len(&wg->incoming_handshakes) >=
120 MAX_QUEUED_INCOMING_HANDSHAKES / 8;120 MAX_QUEUED_INCOMING_HANDSHAKES / 8;
121 if (under_load)121 if (under_load) {
122 last_under_load = ktime_get_coarse_boottime_ns();122 last_under_load = ktime_get_coarse_boottime_ns();
123 else if (last_under_load)123 } else if (last_under_load) {
124 under_load = !wg_birthdate_has_expired(last_under_load, 1);124 under_load = !wg_birthdate_has_expired(last_under_load, 1);
125 if (!under_load)
126 last_under_load = 0;
127 }
125 mac_state = wg_cookie_validate_packet(&wg->cookie_checker, skb,128 mac_state = wg_cookie_validate_packet(&wg->cookie_checker, skb,
126 under_load);129 under_load);
127 if ((under_load && mac_state == VALID_MAC_WITH_COOKIE) ||130 if ((under_load && mac_state == VALID_MAC_WITH_COOKIE) ||
drivers/net/wireguard/send.c+11−5
@@ -143,16 +143,22 @@ static void keep_key_fresh(struct wg_peer *peer) · 142 unmodified lines
143 143
144static unsigned int calculate_skb_padding(struct sk_buff *skb)144static unsigned int calculate_skb_padding(struct sk_buff *skb)
145{145{
146 unsigned int padded_size, last_unit = skb->len;
147
148 if (unlikely(!PACKET_CB(skb)->mtu))
149 return ALIGN(last_unit, MESSAGE_PADDING_MULTIPLE) - last_unit;
150
146 /* We do this modulo business with the MTU, just in case the networking151 /* We do this modulo business with the MTU, just in case the networking
147 * layer gives us a packet that's bigger than the MTU. In that case, we152 * layer gives us a packet that's bigger than the MTU. In that case, we
148 * wouldn't want the final subtraction to overflow in the case of the153 * wouldn't want the final subtraction to overflow in the case of the
149 * padded_size being clamped.154 * padded_size being clamped. Fortunately, that's very rarely the case,
155 * so we optimize for that not happening.
150 */156 */
151 unsigned int last_unit = skb->len % PACKET_CB(skb)->mtu;157 if (unlikely(last_unit > PACKET_CB(skb)->mtu))
152 unsigned int padded_size = ALIGN(last_unit, MESSAGE_PADDING_MULTIPLE);158 last_unit %= PACKET_CB(skb)->mtu;
153 159
154 if (padded_size > PACKET_CB(skb)->mtu)160 padded_size = min(PACKET_CB(skb)->mtu,
155 padded_size = PACKET_CB(skb)->mtu;161 ALIGN(last_unit, MESSAGE_PADDING_MULTIPLE));
156 return padded_size - last_unit;162 return padded_size - last_unit;
157}163}
158 164
drivers/net/wireguard/socket.c+0−1
@@ -432,7 +432,6 @@ void wg_socket_reinit(struct wg_device *wg, struct sock *new4, · 431 unmodified lines
432 wg->incoming_port = ntohs(inet_sk(new4)->inet_sport);432 wg->incoming_port = ntohs(inet_sk(new4)->inet_sport);
433 mutex_unlock(&wg->socket_update_lock);433 mutex_unlock(&wg->socket_update_lock);
434 synchronize_rcu();434 synchronize_rcu();
435 synchronize_net();
436 sock_free(old4);435 sock_free(old4);
437 sock_free(old6);436 sock_free(old6);
438}437}
drivers/nfc/pn544/i2c.c+1−0
@@ -225,6 +225,7 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy) · 224 unmodified lines
225 225
226out:226out:
227 gpiod_set_value_cansleep(phy->gpiod_en, !phy->en_polarity);227 gpiod_set_value_cansleep(phy->gpiod_en, !phy->en_polarity);
228 usleep_range(10000, 15000);
228}229}
229 230
230static void pn544_hci_i2c_enable_mode(struct pn544_i2c_phy *phy, int run_mode)231static void pn544_hci_i2c_enable_mode(struct pn544_i2c_phy *phy, int run_mode)
drivers/nfc/pn544/pn544.c+1−1
@@ -682,7 +682,7 @@ static int pn544_hci_tm_send(struct nfc_hci_dev *hdev, struct sk_buff *skb) · 681 unmodified lines
682static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,682static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,
683 struct nfc_target *target)683 struct nfc_target *target)
684{684{
685 pr_debug("supported protocol %d\b", target->supported_protocols);685 pr_debug("supported protocol %d\n", target->supported_protocols);
686 if (target->supported_protocols & (NFC_PROTO_ISO14443_MASK |686 if (target->supported_protocols & (NFC_PROTO_ISO14443_MASK |
687 NFC_PROTO_ISO14443_B_MASK)) {687 NFC_PROTO_ISO14443_B_MASK)) {
688 return nfc_hci_send_cmd(hdev, target->hci_reader_gate,688 return nfc_hci_send_cmd(hdev, target->hci_reader_gate,
drivers/s390/net/qeth_core_main.c+1−2
@@ -5344,7 +5344,7 @@ next_packet: · 5343 unmodified lines
5344 }5344 }
5345 5345
5346 use_rx_sg = (card->options.cq == QETH_CQ_ENABLED) ||5346 use_rx_sg = (card->options.cq == QETH_CQ_ENABLED) ||
5347 ((skb_len >= card->options.rx_sg_cb) &&5347 (skb_len > card->options.rx_sg_cb &&
5348 !atomic_read(&card->force_alloc_skb) &&5348 !atomic_read(&card->force_alloc_skb) &&
5349 !IS_OSN(card));5349 !IS_OSN(card));
5350 5350
@@ -5447,7 +5447,6 @@ static int qeth_extract_skbs(struct qeth_card *card, int budget, · 96 unmodified lines
5447{5447{
5448 int work_done = 0;5448 int work_done = 0;
5449 5449
5450 WARN_ON_ONCE(!budget);
5451 *done = false;5450 *done = false;
5452 5451
5453 while (budget) {5452 while (budget) {
drivers/s390/net/qeth_l2_main.c+13−16
@@ -1707,15 +1707,14 @@ int qeth_l2_vnicc_set_state(struct qeth_card *card, u32 vnicc, bool state) · 1706 unmodified lines
1707 1707
1708 QETH_CARD_TEXT(card, 2, "vniccsch");1708 QETH_CARD_TEXT(card, 2, "vniccsch");
1709 1709
1710 /* do not change anything if BridgePort is enabled */
1711 if (qeth_bridgeport_is_in_use(card))
1712 return -EBUSY;
1713
1714 /* check if characteristic and enable/disable are supported */1710 /* check if characteristic and enable/disable are supported */
1715 if (!(card->options.vnicc.sup_chars & vnicc) ||1711 if (!(card->options.vnicc.sup_chars & vnicc) ||
1716 !(card->options.vnicc.set_char_sup & vnicc))1712 !(card->options.vnicc.set_char_sup & vnicc))
1717 return -EOPNOTSUPP;1713 return -EOPNOTSUPP;
1718 1714
1715 if (qeth_bridgeport_is_in_use(card))
1716 return -EBUSY;
1717
1719 /* set enable/disable command and store wanted characteristic */1718 /* set enable/disable command and store wanted characteristic */
1720 if (state) {1719 if (state) {
1721 cmd = IPA_VNICC_ENABLE;1720 cmd = IPA_VNICC_ENABLE;
@@ -1761,14 +1760,13 @@ int qeth_l2_vnicc_get_state(struct qeth_card *card, u32 vnicc, bool *state) · 39 unmodified lines
1761 1760
1762 QETH_CARD_TEXT(card, 2, "vniccgch");1761 QETH_CARD_TEXT(card, 2, "vniccgch");
1763 1762
1764 /* do not get anything if BridgePort is enabled */
1765 if (qeth_bridgeport_is_in_use(card))
1766 return -EBUSY;
1767
1768 /* check if characteristic is supported */1763 /* check if characteristic is supported */
1769 if (!(card->options.vnicc.sup_chars & vnicc))1764 if (!(card->options.vnicc.sup_chars & vnicc))
1770 return -EOPNOTSUPP;1765 return -EOPNOTSUPP;
1771 1766
1767 if (qeth_bridgeport_is_in_use(card))
1768 return -EBUSY;
1769
1772 /* if card is ready, query current VNICC state */1770 /* if card is ready, query current VNICC state */
1773 if (qeth_card_hw_is_reachable(card))1771 if (qeth_card_hw_is_reachable(card))
1774 rc = qeth_l2_vnicc_query_chars(card);1772 rc = qeth_l2_vnicc_query_chars(card);
@@ -1786,15 +1784,14 @@ int qeth_l2_vnicc_set_timeout(struct qeth_card *card, u32 timeout) · 11 unmodified lines
1786 1784
1787 QETH_CARD_TEXT(card, 2, "vniccsto");1785 QETH_CARD_TEXT(card, 2, "vniccsto");
1788 1786
1789 /* do not change anything if BridgePort is enabled */
1790 if (qeth_bridgeport_is_in_use(card))
1791 return -EBUSY;
1792
1793 /* check if characteristic and set_timeout are supported */1787 /* check if characteristic and set_timeout are supported */
1794 if (!(card->options.vnicc.sup_chars & QETH_VNICC_LEARNING) ||1788 if (!(card->options.vnicc.sup_chars & QETH_VNICC_LEARNING) ||
1795 !(card->options.vnicc.getset_timeout_sup & QETH_VNICC_LEARNING))1789 !(card->options.vnicc.getset_timeout_sup & QETH_VNICC_LEARNING))
1796 return -EOPNOTSUPP;1790 return -EOPNOTSUPP;
1797 1791
1792 if (qeth_bridgeport_is_in_use(card))
1793 return -EBUSY;
1794
1798 /* do we need to do anything? */1795 /* do we need to do anything? */
1799 if (card->options.vnicc.learning_timeout == timeout)1796 if (card->options.vnicc.learning_timeout == timeout)
1800 return rc;1797 return rc;
@@ -1823,14 +1820,14 @@ int qeth_l2_vnicc_get_timeout(struct qeth_card *card, u32 *timeout) · 22 unmodified lines
1823 1820
1824 QETH_CARD_TEXT(card, 2, "vniccgto");1821 QETH_CARD_TEXT(card, 2, "vniccgto");
1825 1822
1826 /* do not get anything if BridgePort is enabled */
1827 if (qeth_bridgeport_is_in_use(card))
1828 return -EBUSY;
1829
1830 /* check if characteristic and get_timeout are supported */1823 /* check if characteristic and get_timeout are supported */
1831 if (!(card->options.vnicc.sup_chars & QETH_VNICC_LEARNING) ||1824 if (!(card->options.vnicc.sup_chars & QETH_VNICC_LEARNING) ||
1832 !(card->options.vnicc.getset_timeout_sup & QETH_VNICC_LEARNING))1825 !(card->options.vnicc.getset_timeout_sup & QETH_VNICC_LEARNING))
1833 return -EOPNOTSUPP;1826 return -EOPNOTSUPP;
1827
1828 if (qeth_bridgeport_is_in_use(card))
1829 return -EBUSY;
1830
1834 /* if card is ready, get timeout. Otherwise, just return stored value */1831 /* if card is ready, get timeout. Otherwise, just return stored value */
1835 *timeout = card->options.vnicc.learning_timeout;1832 *timeout = card->options.vnicc.learning_timeout;
1836 if (qeth_card_hw_is_reachable(card))1833 if (qeth_card_hw_is_reachable(card))
include/linux/mlx5/mlx5_ifc.h+4−1
@@ -688,7 +688,10 @@ struct mlx5_ifc_flow_table_nic_cap_bits { · 687 unmodified lines
688 u8 nic_rx_multi_path_tirs[0x1];688 u8 nic_rx_multi_path_tirs[0x1];
689 u8 nic_rx_multi_path_tirs_fts[0x1];689 u8 nic_rx_multi_path_tirs_fts[0x1];
690 u8 allow_sniffer_and_nic_rx_shared_tir[0x1];690 u8 allow_sniffer_and_nic_rx_shared_tir[0x1];
691 u8 reserved_at_3[0x1d];691 u8 reserved_at_3[0x4];
692 u8 sw_owner_reformat_supported[0x1];
693 u8 reserved_at_8[0x18];
694
692 u8 encap_general_header[0x1];695 u8 encap_general_header[0x1];
693 u8 reserved_at_21[0xa];696 u8 reserved_at_21[0xa];
694 u8 log_max_packet_reformat_context[0x5];697 u8 log_max_packet_reformat_context[0x5];
include/linux/netdevice.h+3−4
@@ -72,6 +72,8 @@ void netdev_set_default_ethtool_ops(struct net_device *dev, · 71 unmodified lines
72#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */72#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
73#define NET_RX_DROP 1 /* packet dropped */73#define NET_RX_DROP 1 /* packet dropped */
74 74
75#define MAX_NEST_DEV 8
76
75/*77/*
76 * Transmit return codes: transmit return codes originate from three different78 * Transmit return codes: transmit return codes originate from three different
77 * namespaces:79 * namespaces:
@@ -4389,11 +4391,8 @@ void *netdev_lower_get_next(struct net_device *dev, · 4311 unmodified lines
4389 ldev; \4391 ldev; \
4390 ldev = netdev_lower_get_next(dev, &(iter)))4392 ldev = netdev_lower_get_next(dev, &(iter)))
4391 4393
4392struct net_device *netdev_all_lower_get_next(struct net_device *dev,4394struct net_device *netdev_next_lower_dev_rcu(struct net_device *dev,
4393 struct list_head **iter);4395 struct list_head **iter);
4394struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev,
4395 struct list_head **iter);
4396
4397int netdev_walk_all_lower_dev(struct net_device *dev,4396int netdev_walk_all_lower_dev(struct net_device *dev,
4398 int (*fn)(struct net_device *lower_dev,4397 int (*fn)(struct net_device *lower_dev,
4399 void *data),4398 void *data),
include/linux/rculist_nulls.h+7−0
@@ -145,6 +145,13 @@ static inline void hlist_nulls_add_tail_rcu(struct hlist_nulls_node *n, · 144 unmodified lines
145 }145 }
146}146}
147 147
148/* after that hlist_nulls_del will work */
149static inline void hlist_nulls_add_fake(struct hlist_nulls_node *n)
150{
151 n->pprev = &n->next;
152 n->next = (struct hlist_nulls_node *)NULLS_MARKER(NULL);
153}
154
148/**155/**
149 * hlist_nulls_for_each_entry_rcu - iterate over rcu list of given type156 * hlist_nulls_for_each_entry_rcu - iterate over rcu list of given type
150 * @tpos: the type * to use as a loop cursor.157 * @tpos: the type * to use as a loop cursor.
include/linux/skbuff.h+30−0
@@ -611,9 +611,15 @@ typedef unsigned char *sk_buff_data_t; · 610 unmodified lines
611 * @next: Next buffer in list611 * @next: Next buffer in list
612 * @prev: Previous buffer in list612 * @prev: Previous buffer in list
613 * @tstamp: Time we arrived/left613 * @tstamp: Time we arrived/left
614 * @skb_mstamp_ns: (aka @tstamp) earliest departure time; start point
615 * for retransmit timer
614 * @rbnode: RB tree node, alternative to next/prev for netem/tcp616 * @rbnode: RB tree node, alternative to next/prev for netem/tcp
617 * @list: queue head
615 * @sk: Socket we are owned by618 * @sk: Socket we are owned by
619 * @ip_defrag_offset: (aka @sk) alternate use of @sk, used in
620 * fragmentation management
616 * @dev: Device we arrived on/are leaving by621 * @dev: Device we arrived on/are leaving by
622 * @dev_scratch: (aka @dev) alternate use of @dev when @dev would be %NULL
617 * @cb: Control buffer. Free for use by every layer. Put private vars here623 * @cb: Control buffer. Free for use by every layer. Put private vars here
618 * @_skb_refdst: destination entry (with norefcount bit)624 * @_skb_refdst: destination entry (with norefcount bit)
619 * @sp: the security path, used for xfrm625 * @sp: the security path, used for xfrm
@@ -632,6 +638,9 @@ typedef unsigned char *sk_buff_data_t; · 12 unmodified lines
632 * @pkt_type: Packet class638 * @pkt_type: Packet class
633 * @fclone: skbuff clone status639 * @fclone: skbuff clone status
634 * @ipvs_property: skbuff is owned by ipvs640 * @ipvs_property: skbuff is owned by ipvs
641 * @inner_protocol_type: whether the inner protocol is
642 * ENCAP_TYPE_ETHER or ENCAP_TYPE_IPPROTO
643 * @remcsum_offload: remote checksum offload is enabled
635 * @offload_fwd_mark: Packet was L2-forwarded in hardware644 * @offload_fwd_mark: Packet was L2-forwarded in hardware
636 * @offload_l3_fwd_mark: Packet was L3-forwarded in hardware645 * @offload_l3_fwd_mark: Packet was L3-forwarded in hardware
637 * @tc_skip_classify: do not classify packet. set by IFB device646 * @tc_skip_classify: do not classify packet. set by IFB device
@@ -650,6 +659,8 @@ typedef unsigned char *sk_buff_data_t; · 12 unmodified lines
650 * @tc_index: Traffic control index659 * @tc_index: Traffic control index
651 * @hash: the packet hash660 * @hash: the packet hash
652 * @queue_mapping: Queue mapping for multiqueue devices661 * @queue_mapping: Queue mapping for multiqueue devices
662 * @head_frag: skb was allocated from page fragments,
663 * not allocated by kmalloc() or vmalloc().
653 * @pfmemalloc: skbuff was allocated from PFMEMALLOC reserves664 * @pfmemalloc: skbuff was allocated from PFMEMALLOC reserves
654 * @active_extensions: active extensions (skb_ext_id types)665 * @active_extensions: active extensions (skb_ext_id types)
655 * @ndisc_nodetype: router type (from link layer)666 * @ndisc_nodetype: router type (from link layer)
@@ -660,15 +671,28 @@ typedef unsigned char *sk_buff_data_t; · 4 unmodified lines
660 * @wifi_acked_valid: wifi_acked was set671 * @wifi_acked_valid: wifi_acked was set
661 * @wifi_acked: whether frame was acked on wifi or not672 * @wifi_acked: whether frame was acked on wifi or not
662 * @no_fcs: Request NIC to treat last 4 bytes as Ethernet FCS673 * @no_fcs: Request NIC to treat last 4 bytes as Ethernet FCS
674 * @encapsulation: indicates the inner headers in the skbuff are valid
675 * @encap_hdr_csum: software checksum is needed
676 * @csum_valid: checksum is already valid
663 * @csum_not_inet: use CRC32c to resolve CHECKSUM_PARTIAL677 * @csum_not_inet: use CRC32c to resolve CHECKSUM_PARTIAL
678 * @csum_complete_sw: checksum was completed by software
679 * @csum_level: indicates the number of consecutive checksums found in
680 * the packet minus one that have been verified as
681 * CHECKSUM_UNNECESSARY (max 3)
664 * @dst_pending_confirm: need to confirm neighbour682 * @dst_pending_confirm: need to confirm neighbour
665 * @decrypted: Decrypted SKB683 * @decrypted: Decrypted SKB
666 * @napi_id: id of the NAPI struct this skb came from684 * @napi_id: id of the NAPI struct this skb came from
685 * @sender_cpu: (aka @napi_id) source CPU in XPS
667 * @secmark: security marking686 * @secmark: security marking
668 * @mark: Generic packet mark687 * @mark: Generic packet mark
688 * @reserved_tailroom: (aka @mark) number of bytes of free space available
689 * at the tail of an sk_buff
690 * @vlan_present: VLAN tag is present
669 * @vlan_proto: vlan encapsulation protocol691 * @vlan_proto: vlan encapsulation protocol
670 * @vlan_tci: vlan tag control information692 * @vlan_tci: vlan tag control information
671 * @inner_protocol: Protocol (encapsulation)693 * @inner_protocol: Protocol (encapsulation)
694 * @inner_ipproto: (aka @inner_protocol) stores ipproto when
695 * skb->inner_protocol_type == ENCAP_TYPE_IPPROTO;
672 * @inner_transport_header: Inner transport layer header (encapsulation)696 * @inner_transport_header: Inner transport layer header (encapsulation)
673 * @inner_network_header: Network layer header (encapsulation)697 * @inner_network_header: Network layer header (encapsulation)
674 * @inner_mac_header: Link layer header (encapsulation)698 * @inner_mac_header: Link layer header (encapsulation)
@@ -750,7 +774,9 @@ struct sk_buff { · 75 unmodified lines
750#endif774#endif
751#define CLONED_OFFSET() offsetof(struct sk_buff, __cloned_offset)775#define CLONED_OFFSET() offsetof(struct sk_buff, __cloned_offset)
752 776
777 /* private: */
753 __u8 __cloned_offset[0];778 __u8 __cloned_offset[0];
779 /* public: */
754 __u8 cloned:1,780 __u8 cloned:1,
755 nohdr:1,781 nohdr:1,
756 fclone:2,782 fclone:2,
@@ -775,7 +801,9 @@ struct sk_buff { · 18 unmodified lines
775#endif801#endif
776#define PKT_TYPE_OFFSET() offsetof(struct sk_buff, __pkt_type_offset)802#define PKT_TYPE_OFFSET() offsetof(struct sk_buff, __pkt_type_offset)
777 803
804 /* private: */
778 __u8 __pkt_type_offset[0];805 __u8 __pkt_type_offset[0];
806 /* public: */
779 __u8 pkt_type:3;807 __u8 pkt_type:3;
780 __u8 ignore_df:1;808 __u8 ignore_df:1;
781 __u8 nf_trace:1;809 __u8 nf_trace:1;
@@ -798,7 +826,9 @@ struct sk_buff { · 16 unmodified lines
798#define PKT_VLAN_PRESENT_BIT 0826#define PKT_VLAN_PRESENT_BIT 0
799#endif827#endif
800#define PKT_VLAN_PRESENT_OFFSET() offsetof(struct sk_buff, __pkt_vlan_present_offset)828#define PKT_VLAN_PRESENT_OFFSET() offsetof(struct sk_buff, __pkt_vlan_present_offset)
829 /* private: */
801 __u8 __pkt_vlan_present_offset[0];830 __u8 __pkt_vlan_present_offset[0];
831 /* public: */
802 __u8 vlan_present:1;832 __u8 vlan_present:1;
803 __u8 csum_complete_sw:1;833 __u8 csum_complete_sw:1;
804 __u8 csum_level:2;834 __u8 csum_level:2;
include/net/flow_dissector.h+9−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
5#include <linux/types.h>5#include <linux/types.h>
6#include <linux/in6.h>6#include <linux/in6.h>
7#include <linux/siphash.h>7#include <linux/siphash.h>
8#include <linux/string.h>
8#include <uapi/linux/if_ether.h>9#include <uapi/linux/if_ether.h>
9 10
10struct sk_buff;11struct sk_buff;
@@ -348,4 +349,12 @@ struct bpf_flow_dissector { · 337 unmodified lines
348 void *data_end;349 void *data_end;
349};350};
350 351
352static inline void
353flow_dissector_init_keys(struct flow_dissector_key_control *key_control,
354 struct flow_dissector_key_basic *key_basic)
355{
356 memset(key_control, 0, sizeof(*key_control));
357 memset(key_basic, 0, sizeof(*key_basic));
358}
359
351#endif360#endif
include/net/sock.h+33−5
@@ -117,19 +117,26 @@ typedef __u64 __bitwise __addrpair; · 116 unmodified lines
117 * struct sock_common - minimal network layer representation of sockets117 * struct sock_common - minimal network layer representation of sockets
118 * @skc_daddr: Foreign IPv4 addr118 * @skc_daddr: Foreign IPv4 addr
119 * @skc_rcv_saddr: Bound local IPv4 addr119 * @skc_rcv_saddr: Bound local IPv4 addr
120 * @skc_addrpair: 8-byte-aligned __u64 union of @skc_daddr & @skc_rcv_saddr
120 * @skc_hash: hash value used with various protocol lookup tables121 * @skc_hash: hash value used with various protocol lookup tables
121 * @skc_u16hashes: two u16 hash values used by UDP lookup tables122 * @skc_u16hashes: two u16 hash values used by UDP lookup tables
122 * @skc_dport: placeholder for inet_dport/tw_dport123 * @skc_dport: placeholder for inet_dport/tw_dport
123 * @skc_num: placeholder for inet_num/tw_num124 * @skc_num: placeholder for inet_num/tw_num
125 * @skc_portpair: __u32 union of @skc_dport & @skc_num
124 * @skc_family: network address family126 * @skc_family: network address family
125 * @skc_state: Connection state127 * @skc_state: Connection state
126 * @skc_reuse: %SO_REUSEADDR setting128 * @skc_reuse: %SO_REUSEADDR setting
127 * @skc_reuseport: %SO_REUSEPORT setting129 * @skc_reuseport: %SO_REUSEPORT setting
130 * @skc_ipv6only: socket is IPV6 only
131 * @skc_net_refcnt: socket is using net ref counting
128 * @skc_bound_dev_if: bound device index if != 0132 * @skc_bound_dev_if: bound device index if != 0
129 * @skc_bind_node: bind hash linkage for various protocol lookup tables133 * @skc_bind_node: bind hash linkage for various protocol lookup tables
130 * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol134 * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol
131 * @skc_prot: protocol handlers inside a network family135 * @skc_prot: protocol handlers inside a network family
132 * @skc_net: reference to the network namespace of this socket136 * @skc_net: reference to the network namespace of this socket
137 * @skc_v6_daddr: IPV6 destination address
138 * @skc_v6_rcv_saddr: IPV6 source address
139 * @skc_cookie: socket's cookie value
133 * @skc_node: main hash linkage for various protocol lookup tables140 * @skc_node: main hash linkage for various protocol lookup tables
134 * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol141 * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol
135 * @skc_tx_queue_mapping: tx queue number for this connection142 * @skc_tx_queue_mapping: tx queue number for this connection
@@ -137,7 +144,15 @@ typedef __u64 __bitwise __addrpair; · 1 unmodified line
137 * @skc_flags: place holder for sk_flags144 * @skc_flags: place holder for sk_flags
138 * %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE,145 * %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE,
139 * %SO_OOBINLINE settings, %SO_TIMESTAMPING settings146 * %SO_OOBINLINE settings, %SO_TIMESTAMPING settings
147 * @skc_listener: connection request listener socket (aka rsk_listener)
148 * [union with @skc_flags]
149 * @skc_tw_dr: (aka tw_dr) ptr to &struct inet_timewait_death_row
150 * [union with @skc_flags]
140 * @skc_incoming_cpu: record/match cpu processing incoming packets151 * @skc_incoming_cpu: record/match cpu processing incoming packets
152 * @skc_rcv_wnd: (aka rsk_rcv_wnd) TCP receive window size (possibly scaled)
153 * [union with @skc_incoming_cpu]
154 * @skc_tw_rcv_nxt: (aka tw_rcv_nxt) TCP window next expected seq number
155 * [union with @skc_incoming_cpu]
141 * @skc_refcnt: reference count156 * @skc_refcnt: reference count
142 *157 *
143 * This is the minimal network layer representation of sockets, the header158 * This is the minimal network layer representation of sockets, the header
@@ -245,6 +260,7 @@ struct bpf_sk_storage; · 101 unmodified lines
245 * @sk_dst_cache: destination cache260 * @sk_dst_cache: destination cache
246 * @sk_dst_pending_confirm: need to confirm neighbour261 * @sk_dst_pending_confirm: need to confirm neighbour
247 * @sk_policy: flow policy262 * @sk_policy: flow policy
263 * @sk_rx_skb_cache: cache copy of recently accessed RX skb
248 * @sk_receive_queue: incoming packets264 * @sk_receive_queue: incoming packets
249 * @sk_wmem_alloc: transmit queue bytes committed265 * @sk_wmem_alloc: transmit queue bytes committed
250 * @sk_tsq_flags: TCP Small Queues flags266 * @sk_tsq_flags: TCP Small Queues flags
@@ -265,6 +281,8 @@ struct bpf_sk_storage; · 14 unmodified lines
265 * @sk_no_check_rx: allow zero checksum in RX packets281 * @sk_no_check_rx: allow zero checksum in RX packets
266 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)282 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
267 * @sk_route_nocaps: forbidden route capabilities (e.g NETIF_F_GSO_MASK)283 * @sk_route_nocaps: forbidden route capabilities (e.g NETIF_F_GSO_MASK)
284 * @sk_route_forced_caps: static, forced route capabilities
285 * (set in tcp_init_sock())
268 * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)286 * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
269 * @sk_gso_max_size: Maximum GSO segment size to build287 * @sk_gso_max_size: Maximum GSO segment size to build
270 * @sk_gso_max_segs: Maximum number of GSO segments288 * @sk_gso_max_segs: Maximum number of GSO segments
@@ -303,6 +321,8 @@ struct bpf_sk_storage; · 32 unmodified lines
303 * @sk_frag: cached page frag321 * @sk_frag: cached page frag
304 * @sk_peek_off: current peek_offset value322 * @sk_peek_off: current peek_offset value
305 * @sk_send_head: front of stuff to transmit323 * @sk_send_head: front of stuff to transmit
324 * @tcp_rtx_queue: TCP re-transmit queue [union with @sk_send_head]
325 * @sk_tx_skb_cache: cache copy of recently accessed TX skb
306 * @sk_security: used by security modules326 * @sk_security: used by security modules
307 * @sk_mark: generic packet mark327 * @sk_mark: generic packet mark
308 * @sk_cgrp_data: cgroup data for this cgroup328 * @sk_cgrp_data: cgroup data for this cgroup
@@ -313,11 +333,14 @@ struct bpf_sk_storage; · 4 unmodified lines
313 * @sk_write_space: callback to indicate there is bf sending space available333 * @sk_write_space: callback to indicate there is bf sending space available
314 * @sk_error_report: callback to indicate errors (e.g. %MSG_ERRQUEUE)334 * @sk_error_report: callback to indicate errors (e.g. %MSG_ERRQUEUE)
315 * @sk_backlog_rcv: callback to process the backlog335 * @sk_backlog_rcv: callback to process the backlog
336 * @sk_validate_xmit_skb: ptr to an optional validate function
316 * @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0337 * @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0
317 * @sk_reuseport_cb: reuseport group container338 * @sk_reuseport_cb: reuseport group container
339 * @sk_bpf_storage: ptr to cache and control for bpf_sk_storage
318 * @sk_rcu: used during RCU grace period340 * @sk_rcu: used during RCU grace period
319 * @sk_clockid: clockid used by time-based scheduling (SO_TXTIME)341 * @sk_clockid: clockid used by time-based scheduling (SO_TXTIME)
320 * @sk_txtime_deadline_mode: set deadline mode for SO_TXTIME342 * @sk_txtime_deadline_mode: set deadline mode for SO_TXTIME
343 * @sk_txtime_report_errors: set report errors mode for SO_TXTIME
321 * @sk_txtime_unused: unused txtime flags344 * @sk_txtime_unused: unused txtime flags
322 */345 */
323struct sock {346struct sock {
@@ -393,7 +416,9 @@ struct sock { · 69 unmodified lines
393 struct sk_filter __rcu *sk_filter;416 struct sk_filter __rcu *sk_filter;
394 union {417 union {
395 struct socket_wq __rcu *sk_wq;418 struct socket_wq __rcu *sk_wq;
419 /* private: */
396 struct socket_wq *sk_wq_raw;420 struct socket_wq *sk_wq_raw;
421 /* public: */
397 };422 };
398#ifdef CONFIG_XFRM423#ifdef CONFIG_XFRM
399 struct xfrm_policy __rcu *sk_policy[2];424 struct xfrm_policy __rcu *sk_policy[2];
@@ -2017,7 +2042,7 @@ static inline int skb_copy_to_page_nocache(struct sock *sk, struct iov_iter *fro · 1617 unmodified lines
2017 * sk_wmem_alloc_get - returns write allocations2042 * sk_wmem_alloc_get - returns write allocations
2018 * @sk: socket2043 * @sk: socket
2019 *2044 *
2020 * Returns sk_wmem_alloc minus initial offset of one2045 * Return: sk_wmem_alloc minus initial offset of one
2021 */2046 */
2022static inline int sk_wmem_alloc_get(const struct sock *sk)2047static inline int sk_wmem_alloc_get(const struct sock *sk)
2023{2048{
@@ -2028,7 +2053,7 @@ static inline int sk_wmem_alloc_get(const struct sock *sk) · 4 unmodified lines
2028 * sk_rmem_alloc_get - returns read allocations2053 * sk_rmem_alloc_get - returns read allocations
2029 * @sk: socket2054 * @sk: socket
2030 *2055 *
2031 * Returns sk_rmem_alloc2056 * Return: sk_rmem_alloc
2032 */2057 */
2033static inline int sk_rmem_alloc_get(const struct sock *sk)2058static inline int sk_rmem_alloc_get(const struct sock *sk)
2034{2059{
@@ -2039,7 +2064,7 @@ static inline int sk_rmem_alloc_get(const struct sock *sk) · 4 unmodified lines
2039 * sk_has_allocations - check if allocations are outstanding2064 * sk_has_allocations - check if allocations are outstanding
2040 * @sk: socket2065 * @sk: socket
2041 *2066 *
2042 * Returns true if socket has write or read allocations2067 * Return: true if socket has write or read allocations
2043 */2068 */
2044static inline bool sk_has_allocations(const struct sock *sk)2069static inline bool sk_has_allocations(const struct sock *sk)
2045{2070{
@@ -2050,7 +2075,7 @@ static inline bool sk_has_allocations(const struct sock *sk) · 4 unmodified lines
2050 * skwq_has_sleeper - check if there are any waiting processes2075 * skwq_has_sleeper - check if there are any waiting processes
2051 * @wq: struct socket_wq2076 * @wq: struct socket_wq
2052 *2077 *
2053 * Returns true if socket_wq has waiting processes2078 * Return: true if socket_wq has waiting processes
2054 *2079 *
2055 * The purpose of the skwq_has_sleeper and sock_poll_wait is to wrap the memory2080 * The purpose of the skwq_has_sleeper and sock_poll_wait is to wrap the memory
2056 * barrier call. They were added due to the race found within the tcp code.2081 * barrier call. They were added due to the race found within the tcp code.
@@ -2238,6 +2263,9 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, · 181 unmodified lines
2238 * gfpflags_allow_blocking() isn't enough here as direct reclaim may nest2263 * gfpflags_allow_blocking() isn't enough here as direct reclaim may nest
2239 * inside other socket operations and end up recursing into sk_page_frag()2264 * inside other socket operations and end up recursing into sk_page_frag()
2240 * while it's already in use.2265 * while it's already in use.
2266 *
2267 * Return: a per task page_frag if context allows that,
2268 * otherwise a per socket one.
2241 */2269 */
2242static inline struct page_frag *sk_page_frag(struct sock *sk)2270static inline struct page_frag *sk_page_frag(struct sock *sk)
2243{2271{
@@ -2432,6 +2460,7 @@ static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags) · 188 unmodified lines
2432 &skb_shinfo(skb)->tskey);2460 &skb_shinfo(skb)->tskey);
2433}2461}
2434 2462
2463DECLARE_STATIC_KEY_FALSE(tcp_rx_skb_cache_key);
2435/**2464/**
2436 * sk_eat_skb - Release a skb if it is no longer needed2465 * sk_eat_skb - Release a skb if it is no longer needed
2437 * @sk: socket to eat this skb from2466 * @sk: socket to eat this skb from
@@ -2440,7 +2469,6 @@ static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags) · 2 unmodified lines
2440 * This routine must be called with interrupts disabled or with the socket2469 * This routine must be called with interrupts disabled or with the socket
2441 * locked so that the sk_buff queue operation is ok.2470 * locked so that the sk_buff queue operation is ok.
2442*/2471*/
2443DECLARE_STATIC_KEY_FALSE(tcp_rx_skb_cache_key);
2444static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb)2472static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb)
2445{2473{
2446 __skb_unlink(skb, &sk->sk_receive_queue);2474 __skb_unlink(skb, &sk->sk_receive_queue);
include/uapi/linux/bpf.h+7−9
@@ -1045,9 +1045,9 @@ union bpf_attr { · 1044 unmodified lines
1045 * supports redirection to the egress interface, and accepts no1045 * supports redirection to the egress interface, and accepts no
1046 * flag at all.1046 * flag at all.
1047 *1047 *
1048 * The same effect can be attained with the more generic1048 * The same effect can also be attained with the more generic
1049 * **bpf_redirect_map**\ (), which requires specific maps to be1049 * **bpf_redirect_map**\ (), which uses a BPF map to store the
1050 * used but offers better performance.1050 * redirect target instead of providing it directly to the helper.
1051 * Return1051 * Return
1052 * For XDP, the helper returns **XDP_REDIRECT** on success or1052 * For XDP, the helper returns **XDP_REDIRECT** on success or
1053 * **XDP_ABORTED** on error. For other program types, the values1053 * **XDP_ABORTED** on error. For other program types, the values
@@ -1611,13 +1611,11 @@ union bpf_attr { · 557 unmodified lines
1611 * the caller. Any higher bits in the *flags* argument must be1611 * the caller. Any higher bits in the *flags* argument must be
1612 * unset.1612 * unset.
1613 *1613 *
1614 * When used to redirect packets to net devices, this helper1614 * See also bpf_redirect(), which only supports redirecting to an
1615 * provides a high performance increase over **bpf_redirect**\ ().1615 * ifindex, but doesn't require a map to do so.
1616 * This is due to various implementation details of the underlying
1617 * mechanisms, one of which is the fact that **bpf_redirect_map**\
1618 * () tries to send packet as a "bulk" to the device.
1619 * Return1616 * Return
1620 * **XDP_REDIRECT** on success, or **XDP_ABORTED** on error.1617 * **XDP_REDIRECT** on success, or the value of the two lower bits
1618 * of the **flags* argument on error.
1621 *1619 *
1622 * int bpf_sk_redirect_map(struct sk_buff *skb, struct bpf_map *map, u32 key, u64 flags)1620 * int bpf_sk_redirect_map(struct sk_buff *skb, struct bpf_map *map, u32 key, u64 flags)
1623 * Description1621 * Description
include/uapi/linux/netfilter/nf_conntrack_common.h+11−1
@@ -97,6 +97,15 @@ enum ip_conntrack_status { · 96 unmodified lines
97 IPS_UNTRACKED_BIT = 12,97 IPS_UNTRACKED_BIT = 12,
98 IPS_UNTRACKED = (1 << IPS_UNTRACKED_BIT),98 IPS_UNTRACKED = (1 << IPS_UNTRACKED_BIT),
99 99
100#ifdef __KERNEL__
101 /* Re-purposed for in-kernel use:
102 * Tags a conntrack entry that clashed with an existing entry
103 * on insert.
104 */
105 IPS_NAT_CLASH_BIT = IPS_UNTRACKED_BIT,
106 IPS_NAT_CLASH = IPS_UNTRACKED,
107#endif
108
100 /* Conntrack got a helper explicitly attached via CT target. */109 /* Conntrack got a helper explicitly attached via CT target. */
101 IPS_HELPER_BIT = 13,110 IPS_HELPER_BIT = 13,
102 IPS_HELPER = (1 << IPS_HELPER_BIT),111 IPS_HELPER = (1 << IPS_HELPER_BIT),
@@ -110,7 +119,8 @@ enum ip_conntrack_status { · 7 unmodified lines
110 */119 */
111 IPS_UNCHANGEABLE_MASK = (IPS_NAT_DONE_MASK | IPS_NAT_MASK |120 IPS_UNCHANGEABLE_MASK = (IPS_NAT_DONE_MASK | IPS_NAT_MASK |
112 IPS_EXPECTED | IPS_CONFIRMED | IPS_DYING |121 IPS_EXPECTED | IPS_CONFIRMED | IPS_DYING |
113 IPS_SEQ_ADJUST | IPS_TEMPLATE | IPS_OFFLOAD),122 IPS_SEQ_ADJUST | IPS_TEMPLATE | IPS_UNTRACKED |
123 IPS_OFFLOAD),
114 124
115 __IPS_MAX_BIT = 15,125 __IPS_MAX_BIT = 15,
116};126};
kernel/bpf/btf.c+3−3
@@ -4142,9 +4142,9 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, · 4141 unmodified lines
4142 * EFAULT - verifier bug4142 * EFAULT - verifier bug
4143 * 0 - 99% match. The last 1% is validated by the verifier.4143 * 0 - 99% match. The last 1% is validated by the verifier.
4144 */4144 */
4145int btf_check_func_type_match(struct bpf_verifier_log *log,4145static int btf_check_func_type_match(struct bpf_verifier_log *log,
4146 struct btf *btf1, const struct btf_type *t1,4146 struct btf *btf1, const struct btf_type *t1,
4147 struct btf *btf2, const struct btf_type *t2)4147 struct btf *btf2, const struct btf_type *t2)
4148{4148{
4149 const struct btf_param *args1, *args2;4149 const struct btf_param *args1, *args2;
4150 const char *fn1, *fn2, *s1, *s2;4150 const char *fn1, *fn2, *s1, *s2;
kernel/bpf/hashtab.c+53−5
@@ -56,6 +56,7 @@ struct htab_elem { · 55 unmodified lines
56 union {56 union {
57 struct bpf_htab *htab;57 struct bpf_htab *htab;
58 struct pcpu_freelist_node fnode;58 struct pcpu_freelist_node fnode;
59 struct htab_elem *batch_flink;
59 };60 };
60 };61 };
61 };62 };
@@ -126,6 +127,17 @@ free_elems: · 64 unmodified lines
126 bpf_map_area_free(htab->elems);127 bpf_map_area_free(htab->elems);
127}128}
128 129
130/* The LRU list has a lock (lru_lock). Each htab bucket has a lock
131 * (bucket_lock). If both locks need to be acquired together, the lock
132 * order is always lru_lock -> bucket_lock and this only happens in
133 * bpf_lru_list.c logic. For example, certain code path of
134 * bpf_lru_pop_free(), which is called by function prealloc_lru_pop(),
135 * will acquire lru_lock first followed by acquiring bucket_lock.
136 *
137 * In hashtab.c, to avoid deadlock, lock acquisition of
138 * bucket_lock followed by lru_lock is not allowed. In such cases,
139 * bucket_lock needs to be released first before acquiring lru_lock.
140 */
129static struct htab_elem *prealloc_lru_pop(struct bpf_htab *htab, void *key,141static struct htab_elem *prealloc_lru_pop(struct bpf_htab *htab, void *key,
130 u32 hash)142 u32 hash)
131{143{
@@ -1256,10 +1268,12 @@ __htab_map_lookup_and_delete_batch(struct bpf_map *map, · 1124 unmodified lines
1256 void __user *ukeys = u64_to_user_ptr(attr->batch.keys);1268 void __user *ukeys = u64_to_user_ptr(attr->batch.keys);
1257 void *ubatch = u64_to_user_ptr(attr->batch.in_batch);1269 void *ubatch = u64_to_user_ptr(attr->batch.in_batch);
1258 u32 batch, max_count, size, bucket_size;1270 u32 batch, max_count, size, bucket_size;
1271 struct htab_elem *node_to_free = NULL;
1259 u64 elem_map_flags, map_flags;1272 u64 elem_map_flags, map_flags;
1260 struct hlist_nulls_head *head;1273 struct hlist_nulls_head *head;
1261 struct hlist_nulls_node *n;1274 struct hlist_nulls_node *n;
1262 unsigned long flags;1275 unsigned long flags = 0;
1276 bool locked = false;
1263 struct htab_elem *l;1277 struct htab_elem *l;
1264 struct bucket *b;1278 struct bucket *b;
1265 int ret = 0;1279 int ret = 0;
@@ -1319,15 +1333,25 @@ again_nocopy: · 53 unmodified lines
1319 dst_val = values;1333 dst_val = values;
1320 b = &htab->buckets[batch];1334 b = &htab->buckets[batch];
1321 head = &b->head;1335 head = &b->head;
1322 raw_spin_lock_irqsave(&b->lock, flags);1336 /* do not grab the lock unless need it (bucket_cnt > 0). */
1337 if (locked)
1338 raw_spin_lock_irqsave(&b->lock, flags);
1323 1339
1324 bucket_cnt = 0;1340 bucket_cnt = 0;
1325 hlist_nulls_for_each_entry_rcu(l, n, head, hash_node)1341 hlist_nulls_for_each_entry_rcu(l, n, head, hash_node)
1326 bucket_cnt++;1342 bucket_cnt++;
1327 1343
1344 if (bucket_cnt && !locked) {
1345 locked = true;
1346 goto again_nocopy;
1347 }
1348
1328 if (bucket_cnt > (max_count - total)) {1349 if (bucket_cnt > (max_count - total)) {
1329 if (total == 0)1350 if (total == 0)
1330 ret = -ENOSPC;1351 ret = -ENOSPC;
1352 /* Note that since bucket_cnt > 0 here, it is implicit
1353 * that the locked was grabbed, so release it.
1354 */
1331 raw_spin_unlock_irqrestore(&b->lock, flags);1355 raw_spin_unlock_irqrestore(&b->lock, flags);
1332 rcu_read_unlock();1356 rcu_read_unlock();
1333 this_cpu_dec(bpf_prog_active);1357 this_cpu_dec(bpf_prog_active);
@@ -1337,6 +1361,9 @@ again_nocopy: · 3 unmodified lines
1337 1361
1338 if (bucket_cnt > bucket_size) {1362 if (bucket_cnt > bucket_size) {
1339 bucket_size = bucket_cnt;1363 bucket_size = bucket_cnt;
1364 /* Note that since bucket_cnt > 0 here, it is implicit
1365 * that the locked was grabbed, so release it.
1366 */
1340 raw_spin_unlock_irqrestore(&b->lock, flags);1367 raw_spin_unlock_irqrestore(&b->lock, flags);
1341 rcu_read_unlock();1368 rcu_read_unlock();
1342 this_cpu_dec(bpf_prog_active);1369 this_cpu_dec(bpf_prog_active);
@@ -1346,6 +1373,10 @@ again_nocopy: · 3 unmodified lines
1346 goto alloc;1373 goto alloc;
1347 }1374 }
1348 1375
1376 /* Next block is only safe to run if you have grabbed the lock */
1377 if (!locked)
1378 goto next_batch;
1379
1349 hlist_nulls_for_each_entry_safe(l, n, head, hash_node) {1380 hlist_nulls_for_each_entry_safe(l, n, head, hash_node) {
1350 memcpy(dst_key, l->key, key_size);1381 memcpy(dst_key, l->key, key_size);
1351 1382
@@ -1370,16 +1401,33 @@ again_nocopy: · 18 unmodified lines
1370 }1401 }
1371 if (do_delete) {1402 if (do_delete) {
1372 hlist_nulls_del_rcu(&l->hash_node);1403 hlist_nulls_del_rcu(&l->hash_node);
1373 if (is_lru_map)1404
1374 bpf_lru_push_free(&htab->lru, &l->lru_node);1405 /* bpf_lru_push_free() will acquire lru_lock, which
1375 else1406 * may cause deadlock. See comments in function
1407 * prealloc_lru_pop(). Let us do bpf_lru_push_free()
1408 * after releasing the bucket lock.
1409 */
1410 if (is_lru_map) {
1411 l->batch_flink = node_to_free;
1412 node_to_free = l;
1413 } else {
1376 free_htab_elem(htab, l);1414 free_htab_elem(htab, l);
1415 }
1377 }1416 }
1378 dst_key += key_size;1417 dst_key += key_size;
1379 dst_val += value_size;1418 dst_val += value_size;
1380 }1419 }
1381 1420
1382 raw_spin_unlock_irqrestore(&b->lock, flags);1421 raw_spin_unlock_irqrestore(&b->lock, flags);
1422 locked = false;
1423
1424 while (node_to_free) {
1425 l = node_to_free;
1426 node_to_free = node_to_free->batch_flink;
1427 bpf_lru_push_free(&htab->lru, &l->lru_node);
1428 }
1429
1430next_batch:
1383 /* If we are not copying data, we can go to next bucket and avoid1431 /* If we are not copying data, we can go to next bucket and avoid
1384 * unlocking the rcu.1432 * unlocking the rcu.
1385 */1433 */
kernel/bpf/offload.c+1−1
@@ -321,7 +321,7 @@ int bpf_prog_offload_info_fill(struct bpf_prog_info *info, · 320 unmodified lines
321 321
322 ulen = info->jited_prog_len;322 ulen = info->jited_prog_len;
323 info->jited_prog_len = aux->offload->jited_len;323 info->jited_prog_len = aux->offload->jited_len;
324 if (info->jited_prog_len & ulen) {324 if (info->jited_prog_len && ulen) {
325 uinsns = u64_to_user_ptr(info->jited_prog_insns);325 uinsns = u64_to_user_ptr(info->jited_prog_insns);
326 ulen = min_t(u32, info->jited_prog_len, ulen);326 ulen = min_t(u32, info->jited_prog_len, ulen);
327 if (copy_to_user(uinsns, aux->offload->jited_image, ulen)) {327 if (copy_to_user(uinsns, aux->offload->jited_image, ulen)) {
net/Kconfig+0−1
@@ -189,7 +189,6 @@ config BRIDGE_NETFILTER · 188 unmodified lines
189 depends on NETFILTER_ADVANCED189 depends on NETFILTER_ADVANCED
190 select NETFILTER_FAMILY_BRIDGE190 select NETFILTER_FAMILY_BRIDGE
191 select SKB_EXTENSIONS191 select SKB_EXTENSIONS
192 default m
193 ---help---192 ---help---
194 Enabling this option will let arptables resp. iptables see bridged193 Enabling this option will let arptables resp. iptables see bridged
195 ARP resp. IP traffic. If you want a bridging firewall, you probably194 ARP resp. IP traffic. If you want a bridging firewall, you probably
net/bridge/br_stp.c+2−1
@@ -63,7 +63,8 @@ struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) · 62 unmodified lines
63{63{
64 struct net_bridge_port *p;64 struct net_bridge_port *p;
65 65
66 list_for_each_entry_rcu(p, &br->port_list, list) {66 list_for_each_entry_rcu(p, &br->port_list, list,
67 lockdep_is_held(&br->lock)) {
67 if (p->port_no == port_no)68 if (p->port_no == port_no)
68 return p;69 return p;
69 }70 }
net/core/dev.c+11−23
@@ -146,7 +146,6 @@ · 145 unmodified lines
146#include "net-sysfs.h"146#include "net-sysfs.h"
147 147
148#define MAX_GRO_SKBS 8148#define MAX_GRO_SKBS 8
149#define MAX_NEST_DEV 8
150 149
151/* This should be increased if a protocol with a bigger head is added. */150/* This should be increased if a protocol with a bigger head is added. */
152#define GRO_MAX_HEAD (MAX_HEADER + 128)151#define GRO_MAX_HEAD (MAX_HEADER + 128)
@@ -331,6 +330,12 @@ int netdev_name_node_alt_destroy(struct net_device *dev, const char *name) · 178 unmodified lines
331 name_node = netdev_name_node_lookup(net, name);330 name_node = netdev_name_node_lookup(net, name);
332 if (!name_node)331 if (!name_node)
333 return -ENOENT;332 return -ENOENT;
333 /* lookup might have found our primary name or a name belonging
334 * to another device.
335 */
336 if (name_node == dev->name_node || name_node->dev != dev)
337 return -EINVAL;
338
334 __netdev_name_node_alt_destroy(name_node);339 __netdev_name_node_alt_destroy(name_node);
335 340
336 return 0;341 return 0;
@@ -3657,26 +3662,8 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q, · 3320 unmodified lines
3657 qdisc_calculate_pkt_len(skb, q);3662 qdisc_calculate_pkt_len(skb, q);
3658 3663
3659 if (q->flags & TCQ_F_NOLOCK) {3664 if (q->flags & TCQ_F_NOLOCK) {
3660 if ((q->flags & TCQ_F_CAN_BYPASS) && READ_ONCE(q->empty) &&3665 rc = q->enqueue(skb, q, &to_free) & NET_XMIT_MASK;
3661 qdisc_run_begin(q)) {3666 qdisc_run(q);
3662 if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED,
3663 &q->state))) {
3664 __qdisc_drop(skb, &to_free);
3665 rc = NET_XMIT_DROP;
3666 goto end_run;
3667 }
3668 qdisc_bstats_cpu_update(q, skb);
3669
3670 rc = NET_XMIT_SUCCESS;
3671 if (sch_direct_xmit(skb, q, dev, txq, NULL, true))
3672 __qdisc_run(q);
3673
3674end_run:
3675 qdisc_run_end(q);
3676 } else {
3677 rc = q->enqueue(skb, q, &to_free) & NET_XMIT_MASK;
3678 qdisc_run(q);
3679 }
3680 3667
3681 if (unlikely(to_free))3668 if (unlikely(to_free))
3682 kfree_skb_list(to_free);3669 kfree_skb_list(to_free);
@@ -7201,8 +7188,8 @@ static int __netdev_walk_all_lower_dev(struct net_device *dev, · 3518 unmodified lines
7201 return 0;7188 return 0;
7202}7189}
7203 7190
7204static struct net_device *netdev_next_lower_dev_rcu(struct net_device *dev,7191struct net_device *netdev_next_lower_dev_rcu(struct net_device *dev,
7205 struct list_head **iter)7192 struct list_head **iter)
7206{7193{
7207 struct netdev_adjacent *lower;7194 struct netdev_adjacent *lower;
7208 7195
@@ -7214,6 +7201,7 @@ static struct net_device *netdev_next_lower_dev_rcu(struct net_device *dev, · 5 unmodified lines
7214 7201
7215 return lower->dev;7202 return lower->dev;
7216}7203}
7204EXPORT_SYMBOL(netdev_next_lower_dev_rcu);
7217 7205
7218static u8 __netdev_upper_depth(struct net_device *dev)7206static u8 __netdev_upper_depth(struct net_device *dev)
7219{7207{
net/core/fib_rules.c+1−1
@@ -974,7 +974,7 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule, · 973 unmodified lines
974 974
975 frh = nlmsg_data(nlh);975 frh = nlmsg_data(nlh);
976 frh->family = ops->family;976 frh->family = ops->family;
977 frh->table = rule->table;977 frh->table = rule->table < 256 ? rule->table : RT_TABLE_COMPAT;
978 if (nla_put_u32(skb, FRA_TABLE, rule->table))978 if (nla_put_u32(skb, FRA_TABLE, rule->table))
979 goto nla_put_failure;979 goto nla_put_failure;
980 if (nla_put_u32(skb, FRA_SUPPRESS_PREFIXLEN, rule->suppress_prefixlen))980 if (nla_put_u32(skb, FRA_SUPPRESS_PREFIXLEN, rule->suppress_prefixlen))
net/core/rtnetlink.c+12−14
@@ -3504,27 +3504,25 @@ static int rtnl_alt_ifname(int cmd, struct net_device *dev, struct nlattr *attr, · 3503 unmodified lines
3504 if (err)3504 if (err)
3505 return err;3505 return err;
3506 3506
3507 alt_ifname = nla_data(attr);3507 alt_ifname = nla_strdup(attr, GFP_KERNEL);
3508 if (!alt_ifname)
3509 return -ENOMEM;
3510
3508 if (cmd == RTM_NEWLINKPROP) {3511 if (cmd == RTM_NEWLINKPROP) {
3509 alt_ifname = kstrdup(alt_ifname, GFP_KERNEL);
3510 if (!alt_ifname)
3511 return -ENOMEM;
3512 err = netdev_name_node_alt_create(dev, alt_ifname);3512 err = netdev_name_node_alt_create(dev, alt_ifname);
3513 if (err) {3513 if (!err)
3514 kfree(alt_ifname);3514 alt_ifname = NULL;
3515 return err;
3516 }
3517 } else if (cmd == RTM_DELLINKPROP) {3515 } else if (cmd == RTM_DELLINKPROP) {
3518 err = netdev_name_node_alt_destroy(dev, alt_ifname);3516 err = netdev_name_node_alt_destroy(dev, alt_ifname);
3519 if (err)
3520 return err;
3521 } else {3517 } else {
3522 WARN_ON(1);3518 WARN_ON_ONCE(1);
3523 return 0;3519 err = -EINVAL;
3524 }3520 }
3525 3521
3526 *changed = true;3522 kfree(alt_ifname);
3527 return 0;3523 if (!err)
3524 *changed = true;
3525 return err;
3528}3526}
3529 3527
3530static int rtnl_linkprop(int cmd, struct sk_buff *skb, struct nlmsghdr *nlh,3528static int rtnl_linkprop(int cmd, struct sk_buff *skb, struct nlmsghdr *nlh,
net/core/skbuff.c+2−4
@@ -467,7 +467,6 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len, · 466 unmodified lines
467 return NULL;467 return NULL;
468 }468 }
469 469
470 /* use OR instead of assignment to avoid clearing of bits in mask */
471 if (pfmemalloc)470 if (pfmemalloc)
472 skb->pfmemalloc = 1;471 skb->pfmemalloc = 1;
473 skb->head_frag = 1;472 skb->head_frag = 1;
@@ -527,7 +526,6 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len, · 53 unmodified lines
527 return NULL;526 return NULL;
528 }527 }
529 528
530 /* use OR instead of assignment to avoid clearing of bits in mask */
531 if (nc->page.pfmemalloc)529 if (nc->page.pfmemalloc)
532 skb->pfmemalloc = 1;530 skb->pfmemalloc = 1;
533 skb->head_frag = 1;531 skb->head_frag = 1;
@@ -4805,9 +4803,9 @@ static __sum16 *skb_checksum_setup_ip(struct sk_buff *skb, · 4271 unmodified lines
4805 typeof(IPPROTO_IP) proto,4803 typeof(IPPROTO_IP) proto,
4806 unsigned int off)4804 unsigned int off)
4807{4805{
4808 switch (proto) {4806 int err;
4809 int err;
4810 4807
4808 switch (proto) {
4811 case IPPROTO_TCP:4809 case IPPROTO_TCP:
4812 err = skb_maybe_pull_tail(skb, off + sizeof(struct tcphdr),4810 err = skb_maybe_pull_tail(skb, off + sizeof(struct tcphdr),
4813 off + MAX_TCP_HDR_LEN);4811 off + MAX_TCP_HDR_LEN);
net/ethtool/bitset.c+3−0
@@ -447,7 +447,10 @@ ethnl_update_bitset32_verbose(u32 *bitmap, unsigned int nbits, · 446 unmodified lines
447 "mask only allowed in compact bitset");447 "mask only allowed in compact bitset");
448 return -EINVAL;448 return -EINVAL;
449 }449 }
450
450 no_mask = tb[ETHTOOL_A_BITSET_NOMASK];451 no_mask = tb[ETHTOOL_A_BITSET_NOMASK];
452 if (no_mask)
453 ethnl_bitmap32_clear(bitmap, 0, nbits, mod);
451 454
452 nla_for_each_nested(bit_attr, tb[ETHTOOL_A_BITSET_BITS], rem) {455 nla_for_each_nested(bit_attr, tb[ETHTOOL_A_BITSET_BITS], rem) {
453 bool old_val, new_val;456 bool old_val, new_val;
net/hsr/hsr_framereg.c+2−1
@@ -155,7 +155,8 @@ static struct hsr_node *hsr_add_node(struct hsr_priv *hsr, · 154 unmodified lines
155 new_node->seq_out[i] = seq_out;155 new_node->seq_out[i] = seq_out;
156 156
157 spin_lock_bh(&hsr->list_lock);157 spin_lock_bh(&hsr->list_lock);
158 list_for_each_entry_rcu(node, node_db, mac_list) {158 list_for_each_entry_rcu(node, node_db, mac_list,
159 lockdep_is_held(&hsr->list_lock)) {
159 if (ether_addr_equal(node->macaddress_A, addr))160 if (ether_addr_equal(node->macaddress_A, addr))
160 goto out;161 goto out;
161 if (ether_addr_equal(node->macaddress_B, addr))162 if (ether_addr_equal(node->macaddress_B, addr))
net/ipv4/udp.c+5−1
@@ -1857,8 +1857,12 @@ int __udp_disconnect(struct sock *sk, int flags) · 1856 unmodified lines
1857 inet->inet_dport = 0;1857 inet->inet_dport = 0;
1858 sock_rps_reset_rxhash(sk);1858 sock_rps_reset_rxhash(sk);
1859 sk->sk_bound_dev_if = 0;1859 sk->sk_bound_dev_if = 0;
1860 if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))1860 if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) {
1861 inet_reset_saddr(sk);1861 inet_reset_saddr(sk);
1862 if (sk->sk_prot->rehash &&
1863 (sk->sk_userlocks & SOCK_BINDPORT_LOCK))
1864 sk->sk_prot->rehash(sk);
1865 }
1862 1866
1863 if (!(sk->sk_userlocks & SOCK_BINDPORT_LOCK)) {1867 if (!(sk->sk_userlocks & SOCK_BINDPORT_LOCK)) {
1864 sk->sk_prot->unhash(sk);1868 sk->sk_prot->unhash(sk);
net/ipv6/ip6_fib.c+4−3
@@ -1102,8 +1102,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt, · 1101 unmodified lines
1102 found++;1102 found++;
1103 break;1103 break;
1104 }1104 }
1105 if (rt_can_ecmp)1105 fallback_ins = fallback_ins ?: ins;
1106 fallback_ins = fallback_ins ?: ins;
1107 goto next_iter;1106 goto next_iter;
1108 }1107 }
1109 1108
@@ -1146,7 +1145,9 @@ next_iter: · 36 unmodified lines
1146 }1145 }
1147 1146
1148 if (fallback_ins && !found) {1147 if (fallback_ins && !found) {
1149 /* No ECMP-able route found, replace first non-ECMP one */1148 /* No matching route with same ecmp-able-ness found, replace
1149 * first matching route
1150 */
1150 ins = fallback_ins;1151 ins = fallback_ins;
1151 iter = rcu_dereference_protected(*ins,1152 iter = rcu_dereference_protected(*ins,
1152 lockdep_is_held(&rt->fib6_table->tb6_lock));1153 lockdep_is_held(&rt->fib6_table->tb6_lock));
net/ipv6/ip6_gre.c+5−3
@@ -437,8 +437,6 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · 436 unmodified lines
437 return -ENOENT;437 return -ENOENT;
438 438
439 switch (type) {439 switch (type) {
440 struct ipv6_tlv_tnl_enc_lim *tel;
441 __u32 teli;
442 case ICMPV6_DEST_UNREACH:440 case ICMPV6_DEST_UNREACH:
443 net_dbg_ratelimited("%s: Path to destination invalid or inactive!\n",441 net_dbg_ratelimited("%s: Path to destination invalid or inactive!\n",
444 t->parms.name);442 t->parms.name);
@@ -452,7 +450,10 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · 7 unmodified lines
452 break;450 break;
453 }451 }
454 return 0;452 return 0;
455 case ICMPV6_PARAMPROB:453 case ICMPV6_PARAMPROB: {
454 struct ipv6_tlv_tnl_enc_lim *tel;
455 __u32 teli;
456
456 teli = 0;457 teli = 0;
457 if (code == ICMPV6_HDR_FIELD)458 if (code == ICMPV6_HDR_FIELD)
458 teli = ip6_tnl_parse_tlv_enc_lim(skb, skb->data);459 teli = ip6_tnl_parse_tlv_enc_lim(skb, skb->data);
@@ -468,6 +469,7 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · 9 unmodified lines
468 t->parms.name);469 t->parms.name);
469 }470 }
470 return 0;471 return 0;
472 }
471 case ICMPV6_PKT_TOOBIG:473 case ICMPV6_PKT_TOOBIG:
472 ip6_update_pmtu(skb, net, info, 0, 0, sock_net_uid(net, NULL));474 ip6_update_pmtu(skb, net, info, 0, 0, sock_net_uid(net, NULL));
473 return 0;475 return 0;
net/ipv6/ip6_tunnel.c+9−4
@@ -517,8 +517,6 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt, · 516 unmodified lines
517 err = 0;517 err = 0;
518 518
519 switch (*type) {519 switch (*type) {
520 struct ipv6_tlv_tnl_enc_lim *tel;
521 __u32 mtu, teli;
522 case ICMPV6_DEST_UNREACH:520 case ICMPV6_DEST_UNREACH:
523 net_dbg_ratelimited("%s: Path to destination invalid or inactive!\n",521 net_dbg_ratelimited("%s: Path to destination invalid or inactive!\n",
524 t->parms.name);522 t->parms.name);
@@ -531,7 +529,10 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt, · 6 unmodified lines
531 rel_msg = 1;529 rel_msg = 1;
532 }530 }
533 break;531 break;
534 case ICMPV6_PARAMPROB:532 case ICMPV6_PARAMPROB: {
533 struct ipv6_tlv_tnl_enc_lim *tel;
534 __u32 teli;
535
535 teli = 0;536 teli = 0;
536 if ((*code) == ICMPV6_HDR_FIELD)537 if ((*code) == ICMPV6_HDR_FIELD)
537 teli = ip6_tnl_parse_tlv_enc_lim(skb, skb->data);538 teli = ip6_tnl_parse_tlv_enc_lim(skb, skb->data);
@@ -548,7 +549,10 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt, · 10 unmodified lines
548 t->parms.name);549 t->parms.name);
549 }550 }
550 break;551 break;
551 case ICMPV6_PKT_TOOBIG:552 }
553 case ICMPV6_PKT_TOOBIG: {
554 __u32 mtu;
555
552 ip6_update_pmtu(skb, net, htonl(*info), 0, 0,556 ip6_update_pmtu(skb, net, htonl(*info), 0, 0,
553 sock_net_uid(net, NULL));557 sock_net_uid(net, NULL));
554 mtu = *info - offset;558 mtu = *info - offset;
@@ -562,6 +566,7 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt, · 7 unmodified lines
562 rel_msg = 1;566 rel_msg = 1;
563 }567 }
564 break;568 break;
569 }
565 case NDISC_REDIRECT:570 case NDISC_REDIRECT:
566 ip6_redirect(skb, net, skb->dev->ifindex, 0,571 ip6_redirect(skb, net, skb->dev->ifindex, 0,
567 sock_net_uid(net, NULL));572 sock_net_uid(net, NULL));
net/ipv6/route.c+1−0
@@ -5198,6 +5198,7 @@ static int ip6_route_multipath_add(struct fib6_config *cfg, · 5197 unmodified lines
5198 */5198 */
5199 cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |5199 cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
5200 NLM_F_REPLACE);5200 NLM_F_REPLACE);
5201 cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE;
5201 nhn++;5202 nhn++;
5202 }5203 }
5203 5204
net/mptcp/Kconfig+1−0
@@ -4,6 +4,7 @@ config MPTCP · 3 unmodified lines
4 depends on INET4 depends on INET
5 select SKB_EXTENSIONS5 select SKB_EXTENSIONS
6 select CRYPTO_LIB_SHA2566 select CRYPTO_LIB_SHA256
7 select CRYPTO
7 help8 help
8 Multipath TCP (MPTCP) connections send and receive data over multiple9 Multipath TCP (MPTCP) connections send and receive data over multiple
9 subflows in order to utilize multiple network paths. Each subflow10 subflows in order to utilize multiple network paths. Each subflow
net/mptcp/protocol.c+19−29
@@ -755,60 +755,50 @@ static int mptcp_setsockopt(struct sock *sk, int level, int optname, · 754 unmodified lines
755 char __user *optval, unsigned int optlen)755 char __user *optval, unsigned int optlen)
756{756{
757 struct mptcp_sock *msk = mptcp_sk(sk);757 struct mptcp_sock *msk = mptcp_sk(sk);
758 int ret = -EOPNOTSUPP;
759 struct socket *ssock;758 struct socket *ssock;
760 struct sock *ssk;
761 759
762 pr_debug("msk=%p", msk);760 pr_debug("msk=%p", msk);
763 761
764 /* @@ the meaning of setsockopt() when the socket is connected and762 /* @@ the meaning of setsockopt() when the socket is connected and
765 * there are multiple subflows is not defined.763 * there are multiple subflows is not yet defined. It is up to the
764 * MPTCP-level socket to configure the subflows until the subflow
765 * is in TCP fallback, when TCP socket options are passed through
766 * to the one remaining subflow.
766 */767 */
767 lock_sock(sk);768 lock_sock(sk);
768 ssock = __mptcp_socket_create(msk, MPTCP_SAME_STATE);769 ssock = __mptcp_tcp_fallback(msk);
769 if (IS_ERR(ssock)) {770 if (ssock)
770 release_sock(sk);771 return tcp_setsockopt(ssock->sk, level, optname, optval,
771 return ret;772 optlen);
772 }
773 773
774 ssk = ssock->sk;
775 sock_hold(ssk);
776 release_sock(sk);774 release_sock(sk);
777 775
778 ret = tcp_setsockopt(ssk, level, optname, optval, optlen);776 return -EOPNOTSUPP;
779 sock_put(ssk);
780
781 return ret;
782}777}
783 778
784static int mptcp_getsockopt(struct sock *sk, int level, int optname,779static int mptcp_getsockopt(struct sock *sk, int level, int optname,
785 char __user *optval, int __user *option)780 char __user *optval, int __user *option)
786{781{
787 struct mptcp_sock *msk = mptcp_sk(sk);782 struct mptcp_sock *msk = mptcp_sk(sk);
788 int ret = -EOPNOTSUPP;
789 struct socket *ssock;783 struct socket *ssock;
790 struct sock *ssk;
791 784
792 pr_debug("msk=%p", msk);785 pr_debug("msk=%p", msk);
793 786
794 /* @@ the meaning of getsockopt() when the socket is connected and787 /* @@ the meaning of setsockopt() when the socket is connected and
795 * there are multiple subflows is not defined.788 * there are multiple subflows is not yet defined. It is up to the
789 * MPTCP-level socket to configure the subflows until the subflow
790 * is in TCP fallback, when socket options are passed through
791 * to the one remaining subflow.
796 */792 */
797 lock_sock(sk);793 lock_sock(sk);
798 ssock = __mptcp_socket_create(msk, MPTCP_SAME_STATE);794 ssock = __mptcp_tcp_fallback(msk);
799 if (IS_ERR(ssock)) {795 if (ssock)
800 release_sock(sk);796 return tcp_getsockopt(ssock->sk, level, optname, optval,
801 return ret;797 option);
802 }
803 798
804 ssk = ssock->sk;
805 sock_hold(ssk);
806 release_sock(sk);799 release_sock(sk);
807 800
808 ret = tcp_getsockopt(ssk, level, optname, optval, option);801 return -EOPNOTSUPP;
809 sock_put(ssk);
810
811 return ret;
812}802}
813 803
814static int mptcp_get_port(struct sock *sk, unsigned short snum)804static int mptcp_get_port(struct sock *sk, unsigned short snum)
net/mptcp/protocol.h+2−2
@@ -56,8 +56,8 @@ · 55 unmodified lines
56#define MPTCP_DSS_FLAG_MASK (0x1F)56#define MPTCP_DSS_FLAG_MASK (0x1F)
57 57
58/* MPTCP socket flags */58/* MPTCP socket flags */
59#define MPTCP_DATA_READY BIT(0)59#define MPTCP_DATA_READY 0
60#define MPTCP_SEND_SPACE BIT(1)60#define MPTCP_SEND_SPACE 1
61 61
62/* MPTCP connection sock */62/* MPTCP connection sock */
63struct mptcp_sock {63struct mptcp_sock {
net/netfilter/nf_conntrack_core.c+164−28
@@ -894,32 +894,175 @@ static void nf_ct_acct_merge(struct nf_conn *ct, enum ip_conntrack_info ctinfo, · 893 unmodified lines
894 }894 }
895}895}
896 896
897/* Resolve race on insertion if this protocol allows this. */897static void __nf_conntrack_insert_prepare(struct nf_conn *ct)
898{
899 struct nf_conn_tstamp *tstamp;
900
901 atomic_inc(&ct->ct_general.use);
902 ct->status |= IPS_CONFIRMED;
903
904 /* set conntrack timestamp, if enabled. */
905 tstamp = nf_conn_tstamp_find(ct);
906 if (tstamp)
907 tstamp->start = ktime_get_real_ns();
908}
909
910static int __nf_ct_resolve_clash(struct sk_buff *skb,
911 struct nf_conntrack_tuple_hash *h)
912{
913 /* This is the conntrack entry already in hashes that won race. */
914 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h);
915 enum ip_conntrack_info ctinfo;
916 struct nf_conn *loser_ct;
917
918 loser_ct = nf_ct_get(skb, &ctinfo);
919
920 if (nf_ct_is_dying(ct))
921 return NF_DROP;
922
923 if (!atomic_inc_not_zero(&ct->ct_general.use))
924 return NF_DROP;
925
926 if (((ct->status & IPS_NAT_DONE_MASK) == 0) ||
927 nf_ct_match(ct, loser_ct)) {
928 struct net *net = nf_ct_net(ct);
929
930 nf_ct_acct_merge(ct, ctinfo, loser_ct);
931 nf_ct_add_to_dying_list(loser_ct);
932 nf_conntrack_put(&loser_ct->ct_general);
933 nf_ct_set(skb, ct, ctinfo);
934
935 NF_CT_STAT_INC(net, insert_failed);
936 return NF_ACCEPT;
937 }
938
939 nf_ct_put(ct);
940 return NF_DROP;
941}
942
943/**
944 * nf_ct_resolve_clash_harder - attempt to insert clashing conntrack entry
945 *
946 * @skb: skb that causes the collision
947 * @repl_idx: hash slot for reply direction
948 *
949 * Called when origin or reply direction had a clash.
950 * The skb can be handled without packet drop provided the reply direction
951 * is unique or there the existing entry has the identical tuple in both
952 * directions.
953 *
954 * Caller must hold conntrack table locks to prevent concurrent updates.
955 *
956 * Returns NF_DROP if the clash could not be handled.
957 */
958static int nf_ct_resolve_clash_harder(struct sk_buff *skb, u32 repl_idx)
959{
960 struct nf_conn *loser_ct = (struct nf_conn *)skb_nfct(skb);
961 const struct nf_conntrack_zone *zone;
962 struct nf_conntrack_tuple_hash *h;
963 struct hlist_nulls_node *n;
964 struct net *net;
965
966 zone = nf_ct_zone(loser_ct);
967 net = nf_ct_net(loser_ct);
968
969 /* Reply direction must never result in a clash, unless both origin
970 * and reply tuples are identical.
971 */
972 hlist_nulls_for_each_entry(h, n, &nf_conntrack_hash[repl_idx], hnnode) {
973 if (nf_ct_key_equal(h,
974 &loser_ct->tuplehash[IP_CT_DIR_REPLY].tuple,
975 zone, net))
976 return __nf_ct_resolve_clash(skb, h);
977 }
978
979 /* We want the clashing entry to go away real soon: 1 second timeout. */
980 loser_ct->timeout = nfct_time_stamp + HZ;
981
982 /* IPS_NAT_CLASH removes the entry automatically on the first
983 * reply. Also prevents UDP tracker from moving the entry to
984 * ASSURED state, i.e. the entry can always be evicted under
985 * pressure.
986 */
987 loser_ct->status |= IPS_FIXED_TIMEOUT | IPS_NAT_CLASH;
988
989 __nf_conntrack_insert_prepare(loser_ct);
990
991 /* fake add for ORIGINAL dir: we want lookups to only find the entry
992 * already in the table. This also hides the clashing entry from
993 * ctnetlink iteration, i.e. conntrack -L won't show them.
994 */
995 hlist_nulls_add_fake(&loser_ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode);
996
997 hlist_nulls_add_head_rcu(&loser_ct->tuplehash[IP_CT_DIR_REPLY].hnnode,
998 &nf_conntrack_hash[repl_idx]);
999 return NF_ACCEPT;
1000}
1001
1002/**
1003 * nf_ct_resolve_clash - attempt to handle clash without packet drop
1004 *
1005 * @skb: skb that causes the clash
1006 * @h: tuplehash of the clashing entry already in table
1007 * @hash_reply: hash slot for reply direction
1008 *
1009 * A conntrack entry can be inserted to the connection tracking table
1010 * if there is no existing entry with an identical tuple.
1011 *
1012 * If there is one, @skb (and the assocated, unconfirmed conntrack) has
1013 * to be dropped. In case @skb is retransmitted, next conntrack lookup
1014 * will find the already-existing entry.
1015 *
1016 * The major problem with such packet drop is the extra delay added by
1017 * the packet loss -- it will take some time for a retransmit to occur
1018 * (or the sender to time out when waiting for a reply).
1019 *
1020 * This function attempts to handle the situation without packet drop.
1021 *
1022 * If @skb has no NAT transformation or if the colliding entries are
1023 * exactly the same, only the to-be-confirmed conntrack entry is discarded
1024 * and @skb is associated with the conntrack entry already in the table.
1025 *
1026 * Failing that, the new, unconfirmed conntrack is still added to the table
1027 * provided that the collision only occurs in the ORIGINAL direction.
1028 * The new entry will be added after the existing one in the hash list,
1029 * so packets in the ORIGINAL direction will continue to match the existing
1030 * entry. The new entry will also have a fixed timeout so it expires --
1031 * due to the collision, it will not see bidirectional traffic.
1032 *
1033 * Returns NF_DROP if the clash could not be resolved.
1034 */
898static __cold noinline int1035static __cold noinline int
899nf_ct_resolve_clash(struct net *net, struct sk_buff *skb,1036nf_ct_resolve_clash(struct sk_buff *skb, struct nf_conntrack_tuple_hash *h,
900 enum ip_conntrack_info ctinfo,1037 u32 reply_hash)
901 struct nf_conntrack_tuple_hash *h)
902{1038{
903 /* This is the conntrack entry already in hashes that won race. */1039 /* This is the conntrack entry already in hashes that won race. */
904 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h);1040 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h);
905 const struct nf_conntrack_l4proto *l4proto;1041 const struct nf_conntrack_l4proto *l4proto;
906 enum ip_conntrack_info oldinfo;1042 enum ip_conntrack_info ctinfo;
907 struct nf_conn *loser_ct = nf_ct_get(skb, &oldinfo);1043 struct nf_conn *loser_ct;
1044 struct net *net;
1045 int ret;
1046
1047 loser_ct = nf_ct_get(skb, &ctinfo);
1048 net = nf_ct_net(loser_ct);
908 1049
909 l4proto = nf_ct_l4proto_find(nf_ct_protonum(ct));1050 l4proto = nf_ct_l4proto_find(nf_ct_protonum(ct));
910 if (l4proto->allow_clash &&1051 if (!l4proto->allow_clash)
911 !nf_ct_is_dying(ct) &&1052 goto drop;
912 atomic_inc_not_zero(&ct->ct_general.use)) {1053
913 if (((ct->status & IPS_NAT_DONE_MASK) == 0) ||1054 ret = __nf_ct_resolve_clash(skb, h);
914 nf_ct_match(ct, loser_ct)) {1055 if (ret == NF_ACCEPT)
915 nf_ct_acct_merge(ct, ctinfo, loser_ct);1056 return ret;
916 nf_conntrack_put(&loser_ct->ct_general);1057
917 nf_ct_set(skb, ct, oldinfo);1058 ret = nf_ct_resolve_clash_harder(skb, reply_hash);
918 return NF_ACCEPT;1059 if (ret == NF_ACCEPT)
919 }1060 return ret;
920 nf_ct_put(ct);1061
921 }1062drop:
1063 nf_ct_add_to_dying_list(loser_ct);
922 NF_CT_STAT_INC(net, drop);1064 NF_CT_STAT_INC(net, drop);
1065 NF_CT_STAT_INC(net, insert_failed);
923 return NF_DROP;1066 return NF_DROP;
924}1067}
925 1068
@@ -932,7 +1075,6 @@ __nf_conntrack_confirm(struct sk_buff *skb) · 6 unmodified lines
932 struct nf_conntrack_tuple_hash *h;1075 struct nf_conntrack_tuple_hash *h;
933 struct nf_conn *ct;1076 struct nf_conn *ct;
934 struct nf_conn_help *help;1077 struct nf_conn_help *help;
935 struct nf_conn_tstamp *tstamp;
936 struct hlist_nulls_node *n;1078 struct hlist_nulls_node *n;
937 enum ip_conntrack_info ctinfo;1079 enum ip_conntrack_info ctinfo;
938 struct net *net;1080 struct net *net;
@@ -989,6 +1131,7 @@ __nf_conntrack_confirm(struct sk_buff *skb) · 50 unmodified lines
989 1131
990 if (unlikely(nf_ct_is_dying(ct))) {1132 if (unlikely(nf_ct_is_dying(ct))) {
991 nf_ct_add_to_dying_list(ct);1133 nf_ct_add_to_dying_list(ct);
1134 NF_CT_STAT_INC(net, insert_failed);
992 goto dying;1135 goto dying;
993 }1136 }
994 1137
@@ -1009,13 +1152,8 @@ __nf_conntrack_confirm(struct sk_buff *skb) · 14 unmodified lines
1009 setting time, otherwise we'd get timer wrap in1152 setting time, otherwise we'd get timer wrap in
1010 weird delay cases. */1153 weird delay cases. */
1011 ct->timeout += nfct_time_stamp;1154 ct->timeout += nfct_time_stamp;
1012 atomic_inc(&ct->ct_general.use);
1013 ct->status |= IPS_CONFIRMED;
1014 1155
1015 /* set conntrack timestamp, if enabled. */1156 __nf_conntrack_insert_prepare(ct);
1016 tstamp = nf_conn_tstamp_find(ct);
1017 if (tstamp)
1018 tstamp->start = ktime_get_real_ns();
1019 1157
1020 /* Since the lookup is lockless, hash insertion must be done after1158 /* Since the lookup is lockless, hash insertion must be done after
1021 * starting the timer and setting the CONFIRMED bit. The RCU barriers1159 * starting the timer and setting the CONFIRMED bit. The RCU barriers
@@ -1035,11 +1173,9 @@ __nf_conntrack_confirm(struct sk_buff *skb) · 13 unmodified lines
1035 return NF_ACCEPT;1173 return NF_ACCEPT;
1036 1174
1037out:1175out:
1038 nf_ct_add_to_dying_list(ct);1176 ret = nf_ct_resolve_clash(skb, h, reply_hash);
1039 ret = nf_ct_resolve_clash(net, skb, ctinfo, h);
1040dying:1177dying:
1041 nf_conntrack_double_unlock(hash, reply_hash);1178 nf_conntrack_double_unlock(hash, reply_hash);
1042 NF_CT_STAT_INC(net, insert_failed);
1043 local_bh_enable();1179 local_bh_enable();
1044 return ret;1180 return ret;
1045}1181}
net/netfilter/nf_conntrack_proto_udp.c+16−4
@@ -81,6 +81,18 @@ static bool udp_error(struct sk_buff *skb, · 80 unmodified lines
81 return false;81 return false;
82}82}
83 83
84static void nf_conntrack_udp_refresh_unreplied(struct nf_conn *ct,
85 struct sk_buff *skb,
86 enum ip_conntrack_info ctinfo,
87 u32 extra_jiffies)
88{
89 if (unlikely(ctinfo == IP_CT_ESTABLISHED_REPLY &&
90 ct->status & IPS_NAT_CLASH))
91 nf_ct_kill(ct);
92 else
93 nf_ct_refresh_acct(ct, ctinfo, skb, extra_jiffies);
94}
95
84/* Returns verdict for packet, and may modify conntracktype */96/* Returns verdict for packet, and may modify conntracktype */
85int nf_conntrack_udp_packet(struct nf_conn *ct,97int nf_conntrack_udp_packet(struct nf_conn *ct,
86 struct sk_buff *skb,98 struct sk_buff *skb,
@@ -116,8 +128,8 @@ int nf_conntrack_udp_packet(struct nf_conn *ct, · 29 unmodified lines
116 if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))128 if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
117 nf_conntrack_event_cache(IPCT_ASSURED, ct);129 nf_conntrack_event_cache(IPCT_ASSURED, ct);
118 } else {130 } else {
119 nf_ct_refresh_acct(ct, ctinfo, skb,131 nf_conntrack_udp_refresh_unreplied(ct, skb, ctinfo,
120 timeouts[UDP_CT_UNREPLIED]);132 timeouts[UDP_CT_UNREPLIED]);
121 }133 }
122 return NF_ACCEPT;134 return NF_ACCEPT;
123}135}
@@ -198,8 +210,8 @@ int nf_conntrack_udplite_packet(struct nf_conn *ct, · 74 unmodified lines
198 if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))210 if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
199 nf_conntrack_event_cache(IPCT_ASSURED, ct);211 nf_conntrack_event_cache(IPCT_ASSURED, ct);
200 } else {212 } else {
201 nf_ct_refresh_acct(ct, ctinfo, skb,213 nf_conntrack_udp_refresh_unreplied(ct, skb, ctinfo,
202 timeouts[UDP_CT_UNREPLIED]);214 timeouts[UDP_CT_UNREPLIED]);
203 }215 }
204 return NF_ACCEPT;216 return NF_ACCEPT;
205}217}
net/netfilter/nf_flow_table_offload.c+3−3
@@ -847,9 +847,6 @@ static int nf_flow_table_offload_cmd(struct flow_block_offload *bo, · 846 unmodified lines
847{847{
848 int err;848 int err;
849 849
850 if (!nf_flowtable_hw_offload(flowtable))
851 return 0;
852
853 if (!dev->netdev_ops->ndo_setup_tc)850 if (!dev->netdev_ops->ndo_setup_tc)
854 return -EOPNOTSUPP;851 return -EOPNOTSUPP;
855 852
@@ -876,6 +873,9 @@ int nf_flow_table_offload_setup(struct nf_flowtable *flowtable, · 20 unmodified lines
876 struct flow_block_offload bo;873 struct flow_block_offload bo;
877 int err;874 int err;
878 875
876 if (!nf_flowtable_hw_offload(flowtable))
877 return 0;
878
879 err = nf_flow_table_offload_cmd(&bo, flowtable, dev, cmd, &extack);879 err = nf_flow_table_offload_cmd(&bo, flowtable, dev, cmd, &extack);
880 if (err < 0)880 if (err < 0)
881 return err;881 return err;
net/netfilter/nft_set_pipapo.c+3−3
@@ -203,7 +203,7 @@ · 202 unmodified lines
203 * ::203 * ::
204 *204 *
205 * rule indices in last field: 0 1205 * rule indices in last field: 0 1
206 * map to elements: 0x42 0x66206 * map to elements: 0x66 0x42
207 *207 *
208 *208 *
209 * Matching209 * Matching
@@ -298,7 +298,7 @@ · 88 unmodified lines
298 * ::298 * ::
299 *299 *
300 * rule indices in last field: 0 1300 * rule indices in last field: 0 1
301 * map to elements: 0x42 0x66301 * map to elements: 0x66 0x42
302 *302 *
303 * the matching element is at 0x42.303 * the matching element is at 0x42.
304 *304 *
@@ -503,7 +503,7 @@ static int pipapo_refill(unsigned long *map, int len, int rules, · 198 unmodified lines
503 return -1;503 return -1;
504 }504 }
505 505
506 if (unlikely(match_only)) {506 if (match_only) {
507 bitmap_clear(map, i, 1);507 bitmap_clear(map, i, 1);
508 return i;508 return i;
509 }509 }
net/netfilter/xt_hashlimit.c+16−6
@@ -36,6 +36,7 @@ · 35 unmodified lines
36#include <linux/netfilter_ipv6/ip6_tables.h>36#include <linux/netfilter_ipv6/ip6_tables.h>
37#include <linux/mutex.h>37#include <linux/mutex.h>
38#include <linux/kernel.h>38#include <linux/kernel.h>
39#include <linux/refcount.h>
39#include <uapi/linux/netfilter/xt_hashlimit.h>40#include <uapi/linux/netfilter/xt_hashlimit.h>
40 41
41#define XT_HASHLIMIT_ALL (XT_HASHLIMIT_HASH_DIP | XT_HASHLIMIT_HASH_DPT | \42#define XT_HASHLIMIT_ALL (XT_HASHLIMIT_HASH_DIP | XT_HASHLIMIT_HASH_DPT | \
@@ -114,7 +115,7 @@ struct dsthash_ent { · 72 unmodified lines
114 115
115struct xt_hashlimit_htable {116struct xt_hashlimit_htable {
116 struct hlist_node node; /* global list of all htables */117 struct hlist_node node; /* global list of all htables */
117 int use;118 refcount_t use;
118 u_int8_t family;119 u_int8_t family;
119 bool rnd_initialized;120 bool rnd_initialized;
120 121
@@ -315,7 +316,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg, · 194 unmodified lines
315 for (i = 0; i < hinfo->cfg.size; i++)316 for (i = 0; i < hinfo->cfg.size; i++)
316 INIT_HLIST_HEAD(&hinfo->hash[i]);317 INIT_HLIST_HEAD(&hinfo->hash[i]);
317 318
318 hinfo->use = 1;319 refcount_set(&hinfo->use, 1);
319 hinfo->count = 0;320 hinfo->count = 0;
320 hinfo->family = family;321 hinfo->family = family;
321 hinfo->rnd_initialized = false;322 hinfo->rnd_initialized = false;
@@ -420,7 +421,7 @@ static struct xt_hashlimit_htable *htable_find_get(struct net *net, · 98 unmodified lines
420 hlist_for_each_entry(hinfo, &hashlimit_net->htables, node) {421 hlist_for_each_entry(hinfo, &hashlimit_net->htables, node) {
421 if (!strcmp(name, hinfo->name) &&422 if (!strcmp(name, hinfo->name) &&
422 hinfo->family == family) {423 hinfo->family == family) {
423 hinfo->use++;424 refcount_inc(&hinfo->use);
424 return hinfo;425 return hinfo;
425 }426 }
426 }427 }
@@ -429,12 +430,11 @@ static struct xt_hashlimit_htable *htable_find_get(struct net *net, · 2 unmodified lines
429 430
430static void htable_put(struct xt_hashlimit_htable *hinfo)431static void htable_put(struct xt_hashlimit_htable *hinfo)
431{432{
432 mutex_lock(&hashlimit_mutex);433 if (refcount_dec_and_mutex_lock(&hinfo->use, &hashlimit_mutex)) {
433 if (--hinfo->use == 0) {
434 hlist_del(&hinfo->node);434 hlist_del(&hinfo->node);
435 mutex_unlock(&hashlimit_mutex);
435 htable_destroy(hinfo);436 htable_destroy(hinfo);
436 }437 }
437 mutex_unlock(&hashlimit_mutex);
438}438}
439 439
440/* The algorithm used is the Simple Token Bucket Filter (TBF)440/* The algorithm used is the Simple Token Bucket Filter (TBF)
@@ -837,6 +837,8 @@ hashlimit_mt(const struct sk_buff *skb, struct xt_action_param *par) · 396 unmodified lines
837 return hashlimit_mt_common(skb, par, hinfo, &info->cfg, 3);837 return hashlimit_mt_common(skb, par, hinfo, &info->cfg, 3);
838}838}
839 839
840#define HASHLIMIT_MAX_SIZE 1048576
841
840static int hashlimit_mt_check_common(const struct xt_mtchk_param *par,842static int hashlimit_mt_check_common(const struct xt_mtchk_param *par,
841 struct xt_hashlimit_htable **hinfo,843 struct xt_hashlimit_htable **hinfo,
842 struct hashlimit_cfg3 *cfg,844 struct hashlimit_cfg3 *cfg,
@@ -847,6 +849,14 @@ static int hashlimit_mt_check_common(const struct xt_mtchk_param *par, · 4 unmodified lines
847 849
848 if (cfg->gc_interval == 0 || cfg->expire == 0)850 if (cfg->gc_interval == 0 || cfg->expire == 0)
849 return -EINVAL;851 return -EINVAL;
852 if (cfg->size > HASHLIMIT_MAX_SIZE) {
853 cfg->size = HASHLIMIT_MAX_SIZE;
854 pr_info_ratelimited("size too large, truncated to %u\n", cfg->size);
855 }
856 if (cfg->max > HASHLIMIT_MAX_SIZE) {
857 cfg->max = HASHLIMIT_MAX_SIZE;
858 pr_info_ratelimited("max too large, truncated to %u\n", cfg->max);
859 }
850 if (par->family == NFPROTO_IPV4) {860 if (par->family == NFPROTO_IPV4) {
851 if (cfg->srcmask > 32 || cfg->dstmask > 32)861 if (cfg->srcmask > 32 || cfg->dstmask > 32)
852 return -EINVAL;862 return -EINVAL;
net/netlabel/netlabel_domainhash.c+2−1
@@ -143,7 +143,8 @@ static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain, · 142 unmodified lines
143 if (domain != NULL) {143 if (domain != NULL) {
144 bkt = netlbl_domhsh_hash(domain);144 bkt = netlbl_domhsh_hash(domain);
145 bkt_list = &netlbl_domhsh_rcu_deref(netlbl_domhsh)->tbl[bkt];145 bkt_list = &netlbl_domhsh_rcu_deref(netlbl_domhsh)->tbl[bkt];
146 list_for_each_entry_rcu(iter, bkt_list, list)146 list_for_each_entry_rcu(iter, bkt_list, list,
147 lockdep_is_held(&netlbl_domhsh_lock))
147 if (iter->valid &&148 if (iter->valid &&
148 netlbl_family_match(iter->family, family) &&149 netlbl_family_match(iter->family, family) &&
149 strcmp(iter->domain, domain) == 0)150 strcmp(iter->domain, domain) == 0)
net/netlabel/netlabel_unlabeled.c+2−1
@@ -207,7 +207,8 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex) · 206 unmodified lines
207 207
208 bkt = netlbl_unlhsh_hash(ifindex);208 bkt = netlbl_unlhsh_hash(ifindex);
209 bkt_list = &netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->tbl[bkt];209 bkt_list = &netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->tbl[bkt];
210 list_for_each_entry_rcu(iter, bkt_list, list)210 list_for_each_entry_rcu(iter, bkt_list, list,
211 lockdep_is_held(&netlbl_unlhsh_lock))
211 if (iter->valid && iter->ifindex == ifindex)212 if (iter->valid && iter->ifindex == ifindex)
212 return iter;213 return iter;
213 214
net/netlink/af_netlink.c+3−2
@@ -1014,7 +1014,8 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, · 1013 unmodified lines
1014 if (nlk->netlink_bind && groups) {1014 if (nlk->netlink_bind && groups) {
1015 int group;1015 int group;
1016 1016
1017 for (group = 0; group < nlk->ngroups; group++) {1017 /* nl_groups is a u32, so cap the maximum groups we can bind */
1018 for (group = 0; group < BITS_PER_TYPE(u32); group++) {
1018 if (!test_bit(group, &groups))1019 if (!test_bit(group, &groups))
1019 continue;1020 continue;
1020 err = nlk->netlink_bind(net, group + 1);1021 err = nlk->netlink_bind(net, group + 1);
@@ -1033,7 +1034,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, · 12 unmodified lines
1033 netlink_insert(sk, nladdr->nl_pid) :1034 netlink_insert(sk, nladdr->nl_pid) :
1034 netlink_autobind(sock);1035 netlink_autobind(sock);
1035 if (err) {1036 if (err) {
1036 netlink_undo_bind(nlk->ngroups, groups, sk);1037 netlink_undo_bind(BITS_PER_TYPE(u32), groups, sk);
1037 goto unlock;1038 goto unlock;
1038 }1039 }
1039 }1040 }
net/openvswitch/datapath.c+6−3
@@ -179,7 +179,8 @@ struct vport *ovs_lookup_vport(const struct datapath *dp, u16 port_no) · 178 unmodified lines
179 struct hlist_head *head;179 struct hlist_head *head;
180 180
181 head = vport_hash_bucket(dp, port_no);181 head = vport_hash_bucket(dp, port_no);
182 hlist_for_each_entry_rcu(vport, head, dp_hash_node) {182 hlist_for_each_entry_rcu(vport, head, dp_hash_node,
183 lockdep_ovsl_is_held()) {
183 if (vport->port_no == port_no)184 if (vport->port_no == port_no)
184 return vport;185 return vport;
185 }186 }
@@ -2042,7 +2043,8 @@ static unsigned int ovs_get_max_headroom(struct datapath *dp) · 1856 unmodified lines
2042 int i;2043 int i;
2043 2044
2044 for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {2045 for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {
2045 hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) {2046 hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node,
2047 lockdep_ovsl_is_held()) {
2046 dev = vport->dev;2048 dev = vport->dev;
2047 dev_headroom = netdev_get_fwd_headroom(dev);2049 dev_headroom = netdev_get_fwd_headroom(dev);
2048 if (dev_headroom > max_headroom)2050 if (dev_headroom > max_headroom)
@@ -2061,7 +2063,8 @@ static void ovs_update_headroom(struct datapath *dp, unsigned int new_headroom) · 12 unmodified lines
2061 2063
2062 dp->max_headroom = new_headroom;2064 dp->max_headroom = new_headroom;
2063 for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++)2065 for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++)
2064 hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node)2066 hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node,
2067 lockdep_ovsl_is_held())
2065 netdev_set_rx_headroom(vport->dev, new_headroom);2068 netdev_set_rx_headroom(vport->dev, new_headroom);
2066}2069}
2067 2070
net/openvswitch/flow_netlink.c+10−8
@@ -2708,10 +2708,6 @@ static int validate_set(const struct nlattr *a, · 2707 unmodified lines
2708 return -EINVAL;2708 return -EINVAL;
2709 2709
2710 switch (key_type) {2710 switch (key_type) {
2711 const struct ovs_key_ipv4 *ipv4_key;
2712 const struct ovs_key_ipv6 *ipv6_key;
2713 int err;
2714
2715 case OVS_KEY_ATTR_PRIORITY:2711 case OVS_KEY_ATTR_PRIORITY:
2716 case OVS_KEY_ATTR_SKB_MARK:2712 case OVS_KEY_ATTR_SKB_MARK:
2717 case OVS_KEY_ATTR_CT_MARK:2713 case OVS_KEY_ATTR_CT_MARK:
@@ -2723,7 +2719,9 @@ static int validate_set(const struct nlattr *a, · 5 unmodified lines
2723 return -EINVAL;2719 return -EINVAL;
2724 break;2720 break;
2725 2721
2726 case OVS_KEY_ATTR_TUNNEL:2722 case OVS_KEY_ATTR_TUNNEL: {
2723 int err;
2724
2727 if (masked)2725 if (masked)
2728 return -EINVAL; /* Masked tunnel set not supported. */2726 return -EINVAL; /* Masked tunnel set not supported. */
2729 2727
@@ -2732,8 +2730,10 @@ static int validate_set(const struct nlattr *a, · 2 unmodified lines
2732 if (err)2730 if (err)
2733 return err;2731 return err;
2734 break;2732 break;
2733 }
2734 case OVS_KEY_ATTR_IPV4: {
2735 const struct ovs_key_ipv4 *ipv4_key;
2735 2736
2736 case OVS_KEY_ATTR_IPV4:
2737 if (eth_type != htons(ETH_P_IP))2737 if (eth_type != htons(ETH_P_IP))
2738 return -EINVAL;2738 return -EINVAL;
2739 2739
@@ -2753,8 +2753,10 @@ static int validate_set(const struct nlattr *a, · 13 unmodified lines
2753 return -EINVAL;2753 return -EINVAL;
2754 }2754 }
2755 break;2755 break;
2756 }
2757 case OVS_KEY_ATTR_IPV6: {
2758 const struct ovs_key_ipv6 *ipv6_key;
2756 2759
2757 case OVS_KEY_ATTR_IPV6:
2758 if (eth_type != htons(ETH_P_IPV6))2760 if (eth_type != htons(ETH_P_IPV6))
2759 return -EINVAL;2761 return -EINVAL;
2760 2762
@@ -2781,7 +2783,7 @@ static int validate_set(const struct nlattr *a, · 20 unmodified lines
2781 return -EINVAL;2783 return -EINVAL;
2782 2784
2783 break;2785 break;
2784 2786 }
2785 case OVS_KEY_ATTR_TCP:2787 case OVS_KEY_ATTR_TCP:
2786 if ((eth_type != htons(ETH_P_IP) &&2788 if ((eth_type != htons(ETH_P_IP) &&
2787 eth_type != htons(ETH_P_IPV6)) ||2789 eth_type != htons(ETH_P_IPV6)) ||
net/openvswitch/flow_table.c+4−2
@@ -585,7 +585,8 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti, · 584 unmodified lines
585 head = find_bucket(ti, hash);585 head = find_bucket(ti, hash);
586 (*n_mask_hit)++;586 (*n_mask_hit)++;
587 587
588 hlist_for_each_entry_rcu(flow, head, flow_table.node[ti->node_ver]) {588 hlist_for_each_entry_rcu(flow, head, flow_table.node[ti->node_ver],
589 lockdep_ovsl_is_held()) {
589 if (flow->mask == mask && flow->flow_table.hash == hash &&590 if (flow->mask == mask && flow->flow_table.hash == hash &&
590 flow_cmp_masked_key(flow, &masked_key, &mask->range))591 flow_cmp_masked_key(flow, &masked_key, &mask->range))
591 return flow;592 return flow;
@@ -769,7 +770,8 @@ struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *tbl, · 177 unmodified lines
769 770
770 hash = ufid_hash(ufid);771 hash = ufid_hash(ufid);
771 head = find_bucket(ti, hash);772 head = find_bucket(ti, hash);
772 hlist_for_each_entry_rcu(flow, head, ufid_table.node[ti->node_ver]) {773 hlist_for_each_entry_rcu(flow, head, ufid_table.node[ti->node_ver],
774 lockdep_ovsl_is_held()) {
773 if (flow->ufid_table.hash == hash &&775 if (flow->ufid_table.hash == hash &&
774 ovs_flow_cmp_ufid(flow, ufid))776 ovs_flow_cmp_ufid(flow, ufid))
775 return flow;777 return flow;
net/openvswitch/meter.c+2−1
@@ -61,7 +61,8 @@ static struct dp_meter *lookup_meter(const struct datapath *dp, · 60 unmodified lines
61 struct hlist_head *head;61 struct hlist_head *head;
62 62
63 head = meter_hash_bucket(dp, meter_id);63 head = meter_hash_bucket(dp, meter_id);
64 hlist_for_each_entry_rcu(meter, head, dp_hash_node) {64 hlist_for_each_entry_rcu(meter, head, dp_hash_node,
65 lockdep_ovsl_is_held()) {
65 if (meter->id == meter_id)66 if (meter->id == meter_id)
66 return meter;67 return meter;
67 }68 }
net/openvswitch/vport.c+2−1
@@ -96,7 +96,8 @@ struct vport *ovs_vport_locate(const struct net *net, const char *name) · 95 unmodified lines
96 struct hlist_head *bucket = hash_bucket(net, name);96 struct hlist_head *bucket = hash_bucket(net, name);
97 struct vport *vport;97 struct vport *vport;
98 98
99 hlist_for_each_entry_rcu(vport, bucket, hash_node)99 hlist_for_each_entry_rcu(vport, bucket, hash_node,
100 lockdep_ovsl_is_held())
100 if (!strcmp(name, ovs_vport_name(vport)) &&101 if (!strcmp(name, ovs_vport_name(vport)) &&
101 net_eq(ovs_dp_get_net(vport->dp), net))102 net_eq(ovs_dp_get_net(vport->dp), net))
102 return vport;103 return vport;
net/rds/rdma.c+12−12
@@ -162,10 +162,9 @@ static int rds_pin_pages(unsigned long user_addr, unsigned int nr_pages, · 161 unmodified lines
162 if (write)162 if (write)
163 gup_flags |= FOLL_WRITE;163 gup_flags |= FOLL_WRITE;
164 164
165 ret = get_user_pages_fast(user_addr, nr_pages, gup_flags, pages);165 ret = pin_user_pages_fast(user_addr, nr_pages, gup_flags, pages);
166 if (ret >= 0 && ret < nr_pages) {166 if (ret >= 0 && ret < nr_pages) {
167 while (ret--)167 unpin_user_pages(pages, ret);
168 put_page(pages[ret]);
169 ret = -EFAULT;168 ret = -EFAULT;
170 }169 }
171 170
@@ -300,8 +299,7 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args, · 128 unmodified lines
300 * to release anything.299 * to release anything.
301 */300 */
302 if (!need_odp) {301 if (!need_odp) {
303 for (i = 0 ; i < nents; i++)302 unpin_user_pages(pages, nr_pages);
304 put_page(sg_page(&sg[i]));
305 kfree(sg);303 kfree(sg);
306 }304 }
307 ret = PTR_ERR(trans_private);305 ret = PTR_ERR(trans_private);
@@ -325,7 +323,12 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args, · 17 unmodified lines
325 if (cookie_ret)323 if (cookie_ret)
326 *cookie_ret = cookie;324 *cookie_ret = cookie;
327 325
328 if (args->cookie_addr && put_user(cookie, (u64 __user *)(unsigned long) args->cookie_addr)) {326 if (args->cookie_addr &&
327 put_user(cookie, (u64 __user *)(unsigned long)args->cookie_addr)) {
328 if (!need_odp) {
329 unpin_user_pages(pages, nr_pages);
330 kfree(sg);
331 }
329 ret = -EFAULT;332 ret = -EFAULT;
330 goto out;333 goto out;
331 }334 }
@@ -496,9 +499,7 @@ void rds_rdma_free_op(struct rm_rdma_op *ro) · 164 unmodified lines
496 * is the case for a RDMA_READ which copies from remote499 * is the case for a RDMA_READ which copies from remote
497 * to local memory500 * to local memory
498 */501 */
499 if (!ro->op_write)502 unpin_user_pages_dirty_lock(&page, 1, !ro->op_write);
500 set_page_dirty(page);
501 put_page(page);
502 }503 }
503 }504 }
504 505
@@ -515,8 +516,7 @@ void rds_atomic_free_op(struct rm_atomic_op *ao) · 10 unmodified lines
515 /* Mark page dirty if it was possibly modified, which516 /* Mark page dirty if it was possibly modified, which
516 * is the case for a RDMA_READ which copies from remote517 * is the case for a RDMA_READ which copies from remote
517 * to local memory */518 * to local memory */
518 set_page_dirty(page);519 unpin_user_pages_dirty_lock(&page, 1, true);
519 put_page(page);
520 520
521 kfree(ao->op_notifier);521 kfree(ao->op_notifier);
522 ao->op_notifier = NULL;522 ao->op_notifier = NULL;
@@ -944,7 +944,7 @@ int rds_cmsg_atomic(struct rds_sock *rs, struct rds_message *rm, · 421 unmodified lines
944 return ret;944 return ret;
945err:945err:
946 if (page)946 if (page)
947 put_page(page);947 unpin_user_page(page);
948 rm->atomic.op_active = 0;948 rm->atomic.op_active = 0;
949 kfree(rm->atomic.op_notifier);949 kfree(rm->atomic.op_notifier);
950 950
net/sched/cls_flower.c+1−0
@@ -305,6 +305,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, · 304 unmodified lines
305 struct cls_fl_filter *f;305 struct cls_fl_filter *f;
306 306
307 list_for_each_entry_rcu(mask, &head->masks, list) {307 list_for_each_entry_rcu(mask, &head->masks, list) {
308 flow_dissector_init_keys(&skb_key.control, &skb_key.basic);
308 fl_clear_masked_range(&skb_key, mask);309 fl_clear_masked_range(&skb_key, mask);
309 310
310 skb_flow_dissect_meta(skb, &mask->dissector, &skb_key);311 skb_flow_dissect_meta(skb, &mask->dissector, &skb_key);
net/sctp/sm_statefuns.c+20−9
@@ -170,6 +170,16 @@ static inline bool sctp_chunk_length_valid(struct sctp_chunk *chunk, · 169 unmodified lines
170 return true;170 return true;
171}171}
172 172
173/* Check for format error in an ABORT chunk */
174static inline bool sctp_err_chunk_valid(struct sctp_chunk *chunk)
175{
176 struct sctp_errhdr *err;
177
178 sctp_walk_errors(err, chunk->chunk_hdr);
179
180 return (void *)err == (void *)chunk->chunk_end;
181}
182
173/**********************************************************183/**********************************************************
174 * These are the state functions for handling chunk events.184 * These are the state functions for handling chunk events.
175 **********************************************************/185 **********************************************************/
@@ -2255,6 +2265,9 @@ enum sctp_disposition sctp_sf_shutdown_pending_abort( · 2079 unmodified lines
2255 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))2265 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
2256 return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);2266 return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
2257 2267
2268 if (!sctp_err_chunk_valid(chunk))
2269 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2270
2258 return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands);2271 return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands);
2259}2272}
2260 2273
@@ -2298,6 +2311,9 @@ enum sctp_disposition sctp_sf_shutdown_sent_abort( · 37 unmodified lines
2298 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))2311 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
2299 return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);2312 return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
2300 2313
2314 if (!sctp_err_chunk_valid(chunk))
2315 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2316
2301 /* Stop the T2-shutdown timer. */2317 /* Stop the T2-shutdown timer. */
2302 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,2318 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
2303 SCTP_TO(SCTP_EVENT_TIMEOUT_T2_SHUTDOWN));2319 SCTP_TO(SCTP_EVENT_TIMEOUT_T2_SHUTDOWN));
@@ -2565,6 +2581,9 @@ enum sctp_disposition sctp_sf_do_9_1_abort( · 261 unmodified lines
2565 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))2581 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
2566 return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);2582 return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
2567 2583
2584 if (!sctp_err_chunk_valid(chunk))
2585 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2586
2568 return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands);2587 return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands);
2569}2588}
2570 2589
@@ -2582,16 +2601,8 @@ static enum sctp_disposition __sctp_sf_do_9_1_abort( · 11 unmodified lines
2582 2601
2583 /* See if we have an error cause code in the chunk. */2602 /* See if we have an error cause code in the chunk. */
2584 len = ntohs(chunk->chunk_hdr->length);2603 len = ntohs(chunk->chunk_hdr->length);
2585 if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) {2604 if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr))
2586 struct sctp_errhdr *err;
2587
2588 sctp_walk_errors(err, chunk->chunk_hdr);
2589 if ((void *)err != (void *)chunk->chunk_end)
2590 return sctp_sf_pdiscard(net, ep, asoc, type, arg,
2591 commands);
2592
2593 error = ((struct sctp_errhdr *)chunk->skb->data)->cause;2605 error = ((struct sctp_errhdr *)chunk->skb->data)->cause;
2594 }
2595 2606
2596 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET));2607 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET));
2597 /* ASSOC_FAILED will DELETE_TCB. */2608 /* ASSOC_FAILED will DELETE_TCB. */
net/tls/tls_device.c+19−1
@@ -593,7 +593,7 @@ struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context, · 592 unmodified lines
593 u32 seq, u64 *p_record_sn)593 u32 seq, u64 *p_record_sn)
594{594{
595 u64 record_sn = context->hint_record_sn;595 u64 record_sn = context->hint_record_sn;
596 struct tls_record_info *info;596 struct tls_record_info *info, *last;
597 597
598 info = context->retransmit_hint;598 info = context->retransmit_hint;
599 if (!info ||599 if (!info ||
@@ -605,6 +605,24 @@ struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context, · 5 unmodified lines
605 struct tls_record_info, list);605 struct tls_record_info, list);
606 if (!info)606 if (!info)
607 return NULL;607 return NULL;
608 /* send the start_marker record if seq number is before the
609 * tls offload start marker sequence number. This record is
610 * required to handle TCP packets which are before TLS offload
611 * started.
612 * And if it's not start marker, look if this seq number
613 * belongs to the list.
614 */
615 if (likely(!tls_record_is_start_marker(info))) {
616 /* we have the first record, get the last record to see
617 * if this seq number belongs to the list.
618 */
619 last = list_last_entry(&context->records_list,
620 struct tls_record_info, list);
621
622 if (!between(seq, tls_record_start_seq(info),
623 last->end_seq))
624 return NULL;
625 }
608 record_sn = context->unacked_record_sn;626 record_sn = context->unacked_record_sn;
609 }627 }
610 628
net/xdp/xsk.c+2−0
@@ -217,6 +217,7 @@ static int xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp) · 216 unmodified lines
217static void xsk_flush(struct xdp_sock *xs)217static void xsk_flush(struct xdp_sock *xs)
218{218{
219 xskq_prod_submit(xs->rx);219 xskq_prod_submit(xs->rx);
220 __xskq_cons_release(xs->umem->fq);
220 sock_def_readable(&xs->sk);221 sock_def_readable(&xs->sk);
221}222}
222 223
@@ -304,6 +305,7 @@ void xsk_umem_consume_tx_done(struct xdp_umem *umem) · 81 unmodified lines
304 305
305 rcu_read_lock();306 rcu_read_lock();
306 list_for_each_entry_rcu(xs, &umem->xsk_list, list) {307 list_for_each_entry_rcu(xs, &umem->xsk_list, list) {
308 __xskq_cons_release(xs->tx);
307 xs->sk.sk_write_space(&xs->sk);309 xs->sk.sk_write_space(&xs->sk);
308 }310 }
309 rcu_read_unlock();311 rcu_read_unlock();
net/xdp/xsk_queue.h+2−1
@@ -271,7 +271,8 @@ static inline void xskq_cons_release(struct xsk_queue *q) · 270 unmodified lines
271{271{
272 /* To improve performance, only update local state here.272 /* To improve performance, only update local state here.
273 * Reflect this to global state when we get new entries273 * Reflect this to global state when we get new entries
274 * from the ring in xskq_cons_get_entries().274 * from the ring in xskq_cons_get_entries() and whenever
275 * Rx or Tx processing are completed in the NAPI loop.
275 */276 */
276 q->cached_cons++;277 q->cached_cons++;
277}278}
tools/include/uapi/linux/bpf.h+7−9
@@ -1045,9 +1045,9 @@ union bpf_attr { · 1044 unmodified lines
1045 * supports redirection to the egress interface, and accepts no1045 * supports redirection to the egress interface, and accepts no
1046 * flag at all.1046 * flag at all.
1047 *1047 *
1048 * The same effect can be attained with the more generic1048 * The same effect can also be attained with the more generic
1049 * **bpf_redirect_map**\ (), which requires specific maps to be1049 * **bpf_redirect_map**\ (), which uses a BPF map to store the
1050 * used but offers better performance.1050 * redirect target instead of providing it directly to the helper.
1051 * Return1051 * Return
1052 * For XDP, the helper returns **XDP_REDIRECT** on success or1052 * For XDP, the helper returns **XDP_REDIRECT** on success or
1053 * **XDP_ABORTED** on error. For other program types, the values1053 * **XDP_ABORTED** on error. For other program types, the values
@@ -1611,13 +1611,11 @@ union bpf_attr { · 557 unmodified lines
1611 * the caller. Any higher bits in the *flags* argument must be1611 * the caller. Any higher bits in the *flags* argument must be
1612 * unset.1612 * unset.
1613 *1613 *
1614 * When used to redirect packets to net devices, this helper1614 * See also bpf_redirect(), which only supports redirecting to an
1615 * provides a high performance increase over **bpf_redirect**\ ().1615 * ifindex, but doesn't require a map to do so.
1616 * This is due to various implementation details of the underlying
1617 * mechanisms, one of which is the fact that **bpf_redirect_map**\
1618 * () tries to send packet as a "bulk" to the device.
1619 * Return1616 * Return
1620 * **XDP_REDIRECT** on success, or **XDP_ABORTED** on error.1617 * **XDP_REDIRECT** on success, or the value of the two lower bits
1618 * of the **flags* argument on error.
1621 *1619 *
1622 * int bpf_sk_redirect_map(struct sk_buff *skb, struct bpf_map *map, u32 key, u64 flags)1620 * int bpf_sk_redirect_map(struct sk_buff *skb, struct bpf_map *map, u32 key, u64 flags)
1623 * Description1621 * Description
tools/lib/bpf/libbpf.c+7−1
@@ -24,6 +24,7 @@ · 23 unmodified lines
24#include <endian.h>24#include <endian.h>
25#include <fcntl.h>25#include <fcntl.h>
26#include <errno.h>26#include <errno.h>
27#include <ctype.h>
27#include <asm/unistd.h>28#include <asm/unistd.h>
28#include <linux/err.h>29#include <linux/err.h>
29#include <linux/kernel.h>30#include <linux/kernel.h>
@@ -1283,7 +1284,7 @@ static size_t bpf_map_mmap_sz(const struct bpf_map *map) · 1253 unmodified lines
1283static char *internal_map_name(struct bpf_object *obj,1284static char *internal_map_name(struct bpf_object *obj,
1284 enum libbpf_map_type type)1285 enum libbpf_map_type type)
1285{1286{
1286 char map_name[BPF_OBJ_NAME_LEN];1287 char map_name[BPF_OBJ_NAME_LEN], *p;
1287 const char *sfx = libbpf_type_to_btf_name[type];1288 const char *sfx = libbpf_type_to_btf_name[type];
1288 int sfx_len = max((size_t)7, strlen(sfx));1289 int sfx_len = max((size_t)7, strlen(sfx));
1289 int pfx_len = min((size_t)BPF_OBJ_NAME_LEN - sfx_len - 1,1290 int pfx_len = min((size_t)BPF_OBJ_NAME_LEN - sfx_len - 1,
@@ -1292,6 +1293,11 @@ static char *internal_map_name(struct bpf_object *obj, · 2 unmodified lines
1292 snprintf(map_name, sizeof(map_name), "%.*s%.*s", pfx_len, obj->name,1293 snprintf(map_name, sizeof(map_name), "%.*s%.*s", pfx_len, obj->name,
1293 sfx_len, libbpf_type_to_btf_name[type]);1294 sfx_len, libbpf_type_to_btf_name[type]);
1294 1295
1296 /* sanitise map name to characters allowed by kernel */
1297 for (p = map_name; *p && p < map_name + sizeof(map_name); p++)
1298 if (!isalnum(*p) && *p != '_' && *p != '.')
1299 *p = '_';
1300
1295 return strdup(map_name);1301 return strdup(map_name);
1296}1302}
1297 1303
tools/testing/selftests/bpf/prog_tests/select_reuseport.c+6−2
@@ -506,8 +506,10 @@ static void test_syncookie(int type, sa_family_t family) · 505 unmodified lines
506 .pass_on_failure = 0,506 .pass_on_failure = 0,
507 };507 };
508 508
509 if (type != SOCK_STREAM)509 if (type != SOCK_STREAM) {
510 test__skip();
510 return;511 return;
512 }
511 513
512 /*514 /*
513 * +1 for TCP-SYN and515 * +1 for TCP-SYN and
@@ -822,8 +824,10 @@ void test_select_reuseport(void) · 308 unmodified lines
822 goto out;824 goto out;
823 825
824 saved_tcp_fo = read_int_sysctl(TCP_FO_SYSCTL);826 saved_tcp_fo = read_int_sysctl(TCP_FO_SYSCTL);
827 if (saved_tcp_fo < 0)
828 goto out;
825 saved_tcp_syncookie = read_int_sysctl(TCP_SYNCOOKIE_SYSCTL);829 saved_tcp_syncookie = read_int_sysctl(TCP_SYNCOOKIE_SYSCTL);
826 if (saved_tcp_syncookie < 0 || saved_tcp_syncookie < 0)830 if (saved_tcp_syncookie < 0)
827 goto out;831 goto out;
828 832
829 if (enable_fastopen())833 if (enable_fastopen())
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c+5−0
@@ -3,6 +3,11 @@ · 2 unmodified lines
3 3
4#include "test_progs.h"4#include "test_progs.h"
5 5
6#define TCP_REPAIR 19 /* TCP sock is under repair right now */
7
8#define TCP_REPAIR_ON 1
9#define TCP_REPAIR_OFF_NO_WP -1 /* Turn off without window probes */
10
6static int connected_socket_v4(void)11static int connected_socket_v4(void)
7{12{
8 struct sockaddr_in addr = {13 struct sockaddr_in addr = {
tools/testing/selftests/net/fib_tests.sh+6−0
@@ -910,6 +910,12 @@ ipv6_rt_replace_mpath() · 909 unmodified lines
910 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"910 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
911 log_test $? 0 "Multipath with single path via multipath attribute"911 log_test $? 0 "Multipath with single path via multipath attribute"
912 912
913 # multipath with dev-only
914 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
915 run_cmd "$IP -6 ro replace 2001:db8:104::/64 dev veth1"
916 check_route6 "2001:db8:104::/64 dev veth1 metric 1024"
917 log_test $? 0 "Multipath with dev-only"
918
913 # route replace fails - invalid nexthop 1919 # route replace fails - invalid nexthop 1
914 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"920 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
915 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103::3"921 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103::3"
tools/testing/selftests/net/forwarding/mirror_gre.sh+13−12
@@ -63,22 +63,23 @@ test_span_gre_mac() · 62 unmodified lines
63{63{
64 local tundev=$1; shift64 local tundev=$1; shift
65 local direction=$1; shift65 local direction=$1; shift
66 local prot=$1; shift
67 local what=$1; shift66 local what=$1; shift
68 67
69 local swp3mac=$(mac_get $swp3)68 case "$direction" in
70 local h3mac=$(mac_get $h3)69 ingress) local src_mac=$(mac_get $h1); local dst_mac=$(mac_get $h2)
70 ;;
71 egress) local src_mac=$(mac_get $h2); local dst_mac=$(mac_get $h1)
72 ;;
73 esac
71 74
72 RET=075 RET=0
73 76
74 mirror_install $swp1 $direction $tundev "matchall $tcflags"77 mirror_install $swp1 $direction $tundev "matchall $tcflags"
75 tc filter add dev $h3 ingress pref 77 prot $prot \78 icmp_capture_install h3-${tundev} "src_mac $src_mac dst_mac $dst_mac"
76 flower ip_proto 0x2f src_mac $swp3mac dst_mac $h3mac \
77 action pass
78 79
79 mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 1080 mirror_test v$h1 192.0.2.1 192.0.2.2 h3-${tundev} 100 10
80 81
81 tc filter del dev $h3 ingress pref 7782 icmp_capture_uninstall h3-${tundev}
82 mirror_uninstall $swp1 $direction83 mirror_uninstall $swp1 $direction
83 84
84 log_test "$direction $what: envelope MAC ($tcflags)"85 log_test "$direction $what: envelope MAC ($tcflags)"
@@ -120,14 +121,14 @@ test_ip6gretap() · 35 unmodified lines
120 121
121test_gretap_mac()122test_gretap_mac()
122{123{
123 test_span_gre_mac gt4 ingress ip "mirror to gretap"124 test_span_gre_mac gt4 ingress "mirror to gretap"
124 test_span_gre_mac gt4 egress ip "mirror to gretap"125 test_span_gre_mac gt4 egress "mirror to gretap"
125}126}
126 127
127test_ip6gretap_mac()128test_ip6gretap_mac()
128{129{
129 test_span_gre_mac gt6 ingress ipv6 "mirror to ip6gretap"130 test_span_gre_mac gt6 ingress "mirror to ip6gretap"
130 test_span_gre_mac gt6 egress ipv6 "mirror to ip6gretap"131 test_span_gre_mac gt6 egress "mirror to ip6gretap"
131}132}
132 133
133test_all()134test_all()
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh+3−3
@@ -516,9 +516,9 @@ test_tos() · 515 unmodified lines
516 RET=0516 RET=0
517 517
518 tc filter add dev v1 egress pref 77 prot ip \518 tc filter add dev v1 egress pref 77 prot ip \
519 flower ip_tos 0x40 action pass519 flower ip_tos 0x14 action pass
520 vxlan_ping_test $h1 192.0.2.3 "-Q 0x40" v1 egress 77 10520 vxlan_ping_test $h1 192.0.2.3 "-Q 0x14" v1 egress 77 10
521 vxlan_ping_test $h1 192.0.2.3 "-Q 0x30" v1 egress 77 0521 vxlan_ping_test $h1 192.0.2.3 "-Q 0x18" v1 egress 77 0
522 tc filter del dev v1 egress pref 77 prot ip522 tc filter del dev v1 egress pref 77 prot ip
523 523
524 log_test "VXLAN: envelope TOS inheritance"524 log_test "VXLAN: envelope TOS inheritance"
tools/testing/selftests/wireguard/qemu/Makefile+14−24
@@ -38,19 +38,17 @@ endef · 37 unmodified lines
38define file_download =38define file_download =
39$(DISTFILES_PATH)/$(1):39$(DISTFILES_PATH)/$(1):
40 mkdir -p $(DISTFILES_PATH)40 mkdir -p $(DISTFILES_PATH)
41 flock -x $$@.lock -c '[ -f $$@ ] && exit 0; wget -O $$@.tmp $(MIRROR)$(1) || wget -O $$@.tmp $(2)$(1) || rm -f $$@.tmp'41 flock -x $$@.lock -c '[ -f $$@ ] && exit 0; wget -O $$@.tmp $(MIRROR)$(1) || wget -O $$@.tmp $(2)$(1) || rm -f $$@.tmp; [ -f $$@.tmp ] || exit 1; if echo "$(3) $$@.tmp" | sha256sum -c -; then mv $$@.tmp $$@; else rm -f $$@.tmp; exit 71; fi'
42 if echo "$(3) $$@.tmp" | sha256sum -c -; then mv $$@.tmp $$@; else rm -f $$@.tmp; exit 71; fi
43endef42endef
44 43
45$(eval $(call tar_download,MUSL,musl,1.1.24,.tar.gz,https://www.musl-libc.org/releases/,1370c9a812b2cf2a7d92802510cca0058cc37e66a7bedd70051f0a34015022a3))44$(eval $(call tar_download,MUSL,musl,1.1.24,.tar.gz,https://www.musl-libc.org/releases/,1370c9a812b2cf2a7d92802510cca0058cc37e66a7bedd70051f0a34015022a3))
46$(eval $(call tar_download,LIBMNL,libmnl,1.0.4,.tar.bz2,https://www.netfilter.org/projects/libmnl/files/,171f89699f286a5854b72b91d06e8f8e3683064c5901fb09d954a9ab6f551f81))
47$(eval $(call tar_download,IPERF,iperf,3.7,.tar.gz,https://downloads.es.net/pub/iperf/,d846040224317caf2f75c843d309a950a7db23f9b44b94688ccbe557d6d1710c))45$(eval $(call tar_download,IPERF,iperf,3.7,.tar.gz,https://downloads.es.net/pub/iperf/,d846040224317caf2f75c843d309a950a7db23f9b44b94688ccbe557d6d1710c))
48$(eval $(call tar_download,BASH,bash,5.0,.tar.gz,https://ftp.gnu.org/gnu/bash/,b4a80f2ac66170b2913efbfb9f2594f1f76c7b1afd11f799e22035d63077fb4d))46$(eval $(call tar_download,BASH,bash,5.0,.tar.gz,https://ftp.gnu.org/gnu/bash/,b4a80f2ac66170b2913efbfb9f2594f1f76c7b1afd11f799e22035d63077fb4d))
49$(eval $(call tar_download,IPROUTE2,iproute2,5.4.0,.tar.xz,https://www.kernel.org/pub/linux/utils/net/iproute2/,fe97aa60a0d4c5ac830be18937e18dc3400ca713a33a89ad896ff1e3d46086ae))47$(eval $(call tar_download,IPROUTE2,iproute2,5.4.0,.tar.xz,https://www.kernel.org/pub/linux/utils/net/iproute2/,fe97aa60a0d4c5ac830be18937e18dc3400ca713a33a89ad896ff1e3d46086ae))
50$(eval $(call tar_download,IPTABLES,iptables,1.8.4,.tar.bz2,https://www.netfilter.org/projects/iptables/files/,993a3a5490a544c2cbf2ef15cf7e7ed21af1845baf228318d5c36ef8827e157c))48$(eval $(call tar_download,IPTABLES,iptables,1.8.4,.tar.bz2,https://www.netfilter.org/projects/iptables/files/,993a3a5490a544c2cbf2ef15cf7e7ed21af1845baf228318d5c36ef8827e157c))
51$(eval $(call tar_download,NMAP,nmap,7.80,.tar.bz2,https://nmap.org/dist/,fcfa5a0e42099e12e4bf7a68ebe6fde05553383a682e816a7ec9256ab4773faa))49$(eval $(call tar_download,NMAP,nmap,7.80,.tar.bz2,https://nmap.org/dist/,fcfa5a0e42099e12e4bf7a68ebe6fde05553383a682e816a7ec9256ab4773faa))
52$(eval $(call tar_download,IPUTILS,iputils,s20190709,.tar.gz,https://github.com/iputils/iputils/archive/s20190709.tar.gz/#,a15720dd741d7538dd2645f9f516d193636ae4300ff7dbc8bfca757bf166490a))50$(eval $(call tar_download,IPUTILS,iputils,s20190709,.tar.gz,https://github.com/iputils/iputils/archive/s20190709.tar.gz/#,a15720dd741d7538dd2645f9f516d193636ae4300ff7dbc8bfca757bf166490a))
53$(eval $(call tar_download,WIREGUARD_TOOLS,wireguard-tools,1.0.20191226,.tar.xz,https://git.zx2c4.com/wireguard-tools/snapshot/,aa8af0fdc9872d369d8c890a84dbc2a2466b55795dccd5b47721b2d97644b04f))51$(eval $(call tar_download,WIREGUARD_TOOLS,wireguard-tools,1.0.20200206,.tar.xz,https://git.zx2c4.com/wireguard-tools/snapshot/,f5207248c6a3c3e3bfc9ab30b91c1897b00802ed861e1f9faaed873366078c64))
54 52
55KERNEL_BUILD_PATH := $(BUILD_PATH)/kernel$(if $(findstring yes,$(DEBUG_KERNEL)),-debug)53KERNEL_BUILD_PATH := $(BUILD_PATH)/kernel$(if $(findstring yes,$(DEBUG_KERNEL)),-debug)
56rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))54rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
@@ -295,21 +293,13 @@ $(IPERF_PATH)/src/iperf3: | $(IPERF_PATH)/.installed $(USERSPACE_DEPS) · 238 unmodified lines
295 $(MAKE) -C $(IPERF_PATH)293 $(MAKE) -C $(IPERF_PATH)
296 $(STRIP) -s $@294 $(STRIP) -s $@
297 295
298$(LIBMNL_PATH)/.installed: $(LIBMNL_TAR)
299 flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
300 touch $@
301
302$(LIBMNL_PATH)/src/.libs/libmnl.a: | $(LIBMNL_PATH)/.installed $(USERSPACE_DEPS)
303 cd $(LIBMNL_PATH) && ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared
304 $(MAKE) -C $(LIBMNL_PATH)
305 sed -i 's:prefix=.*:prefix=$(LIBMNL_PATH):' $(LIBMNL_PATH)/libmnl.pc
306
307$(WIREGUARD_TOOLS_PATH)/.installed: $(WIREGUARD_TOOLS_TAR)296$(WIREGUARD_TOOLS_PATH)/.installed: $(WIREGUARD_TOOLS_TAR)
297 mkdir -p $(BUILD_PATH)
308 flock -s $<.lock tar -C $(BUILD_PATH) -xf $<298 flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
309 touch $@299 touch $@
310 300
311$(WIREGUARD_TOOLS_PATH)/src/wg: | $(WIREGUARD_TOOLS_PATH)/.installed $(LIBMNL_PATH)/src/.libs/libmnl.a $(USERSPACE_DEPS)301$(WIREGUARD_TOOLS_PATH)/src/wg: | $(WIREGUARD_TOOLS_PATH)/.installed $(USERSPACE_DEPS)
312 LDFLAGS="$(LDFLAGS) -L$(LIBMNL_PATH)/src/.libs" $(MAKE) -C $(WIREGUARD_TOOLS_PATH)/src LIBMNL_CFLAGS="-I$(LIBMNL_PATH)/include" LIBMNL_LDLIBS="-lmnl" wg302 $(MAKE) -C $(WIREGUARD_TOOLS_PATH)/src wg
313 $(STRIP) -s $@303 $(STRIP) -s $@
314 304
315$(BUILD_PATH)/init: init.c | $(USERSPACE_DEPS)305$(BUILD_PATH)/init: init.c | $(USERSPACE_DEPS)
@@ -340,17 +330,17 @@ $(BASH_PATH)/bash: | $(BASH_PATH)/.installed $(USERSPACE_DEPS) · 24 unmodified lines
340$(IPROUTE2_PATH)/.installed: $(IPROUTE2_TAR)330$(IPROUTE2_PATH)/.installed: $(IPROUTE2_TAR)
341 mkdir -p $(BUILD_PATH)331 mkdir -p $(BUILD_PATH)
342 flock -s $<.lock tar -C $(BUILD_PATH) -xf $<332 flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
343 printf 'CC:=$(CC)\nPKG_CONFIG:=pkg-config\nTC_CONFIG_XT:=n\nTC_CONFIG_ATM:=n\nTC_CONFIG_IPSET:=n\nIP_CONFIG_SETNS:=y\nHAVE_ELF:=n\nHAVE_MNL:=y\nHAVE_BERKELEY_DB:=n\nHAVE_LATEX:=n\nHAVE_PDFLATEX:=n\nCFLAGS+=-DHAVE_SETNS -DHAVE_LIBMNL -I$(LIBMNL_PATH)/include\nLDLIBS+=-lmnl' > $(IPROUTE2_PATH)/config.mk333 printf 'CC:=$(CC)\nPKG_CONFIG:=pkg-config\nTC_CONFIG_XT:=n\nTC_CONFIG_ATM:=n\nTC_CONFIG_IPSET:=n\nIP_CONFIG_SETNS:=y\nHAVE_ELF:=n\nHAVE_MNL:=n\nHAVE_BERKELEY_DB:=n\nHAVE_LATEX:=n\nHAVE_PDFLATEX:=n\nCFLAGS+=-DHAVE_SETNS\n' > $(IPROUTE2_PATH)/config.mk
344 printf 'lib: snapshot\n\t$$(MAKE) -C lib\nip/ip: lib\n\t$$(MAKE) -C ip ip\nmisc/ss: lib\n\t$$(MAKE) -C misc ss\n' >> $(IPROUTE2_PATH)/Makefile334 printf 'lib: snapshot\n\t$$(MAKE) -C lib\nip/ip: lib\n\t$$(MAKE) -C ip ip\nmisc/ss: lib\n\t$$(MAKE) -C misc ss\n' >> $(IPROUTE2_PATH)/Makefile
345 touch $@335 touch $@
346 336
347$(IPROUTE2_PATH)/ip/ip: | $(IPROUTE2_PATH)/.installed $(LIBMNL_PATH)/src/.libs/libmnl.a $(USERSPACE_DEPS)337$(IPROUTE2_PATH)/ip/ip: | $(IPROUTE2_PATH)/.installed $(USERSPACE_DEPS)
348 LDFLAGS="$(LDFLAGS) -L$(LIBMNL_PATH)/src/.libs" PKG_CONFIG_LIBDIR="$(LIBMNL_PATH)" $(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ ip/ip338 $(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ ip/ip
349 $(STRIP) -s $(IPROUTE2_PATH)/ip/ip339 $(STRIP) -s $@
350 340
351$(IPROUTE2_PATH)/misc/ss: | $(IPROUTE2_PATH)/.installed $(LIBMNL_PATH)/src/.libs/libmnl.a $(USERSPACE_DEPS)341$(IPROUTE2_PATH)/misc/ss: | $(IPROUTE2_PATH)/.installed $(USERSPACE_DEPS)
352 LDFLAGS="$(LDFLAGS) -L$(LIBMNL_PATH)/src/.libs" PKG_CONFIG_LIBDIR="$(LIBMNL_PATH)" $(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ misc/ss342 $(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ misc/ss
353 $(STRIP) -s $(IPROUTE2_PATH)/misc/ss343 $(STRIP) -s $@
354 344
355$(IPTABLES_PATH)/.installed: $(IPTABLES_TAR)345$(IPTABLES_PATH)/.installed: $(IPTABLES_TAR)
356 mkdir -p $(BUILD_PATH)346 mkdir -p $(BUILD_PATH)
@@ -358,8 +348,8 @@ $(IPTABLES_PATH)/.installed: $(IPTABLES_TAR) · 1 unmodified line
358 sed -i -e "/nfnetlink=[01]/s:=[01]:=0:" -e "/nfconntrack=[01]/s:=[01]:=0:" $(IPTABLES_PATH)/configure348 sed -i -e "/nfnetlink=[01]/s:=[01]:=0:" -e "/nfconntrack=[01]/s:=[01]:=0:" $(IPTABLES_PATH)/configure
359 touch $@349 touch $@
360 350
361$(IPTABLES_PATH)/iptables/xtables-legacy-multi: | $(IPTABLES_PATH)/.installed $(LIBMNL_PATH)/src/.libs/libmnl.a $(USERSPACE_DEPS)351$(IPTABLES_PATH)/iptables/xtables-legacy-multi: | $(IPTABLES_PATH)/.installed $(USERSPACE_DEPS)
362 cd $(IPTABLES_PATH) && PKG_CONFIG_LIBDIR="$(LIBMNL_PATH)" ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --disable-nftables --disable-bpf-compiler --disable-nfsynproxy --disable-libipq --with-kernel=$(BUILD_PATH)/include352 cd $(IPTABLES_PATH) && ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --disable-nftables --disable-bpf-compiler --disable-nfsynproxy --disable-libipq --disable-connlabel --with-kernel=$(BUILD_PATH)/include
363 $(MAKE) -C $(IPTABLES_PATH)353 $(MAKE) -C $(IPTABLES_PATH)
364 $(STRIP) -s $@354 $(STRIP) -s $@
365 355