History

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

Pull networking fixes from Jakub Kicinski: "Mostly driver fixes. Current release - regressions: - Revert "net: Add a second bind table hashed by port and address", needs more work - amd-xgbe: use platform_irq_count(), static setup of IRQ resources had been removed from DT core - dts: at91: ksz9477_evb: add phy-mode to fix port/phy validation Current release - new code bugs: - hns3: modify the ring param print info Previous releases - always broken: - axienet: make the 64b addressable DMA depends on 64b architectures - iavf: fix issue with MAC address of VF shown as zero - ice: fix PTP TX timestamp offset calculation - usb: ax88179_178a needs FLAG_SEND_ZLP Misc: - document some net.sctp.* sysctls" * tag 'net-5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (31 commits) net: axienet: add missing error return code in axienet_probe() Revert "net: Add a second bind table hashed by port and address" net: ax25: Fix deadlock caused by skb_recv_datagram in ax25_recvmsg net: usb: ax88179_178a needs FLAG_SEND_ZLP MAINTAINERS: add include/dt-bindings/net to NETWORKING DRIVERS ARM: dts: at91: ksz9477_evb: fix port/phy validation net: bgmac: Fix an erroneous kfree() in bgmac_remove() ice: Fix memory corruption in VF driver ice: Fix queue config fail handling ice: Sync VLAN filtering features for DVM ice: Fix PTP TX timestamp offset calculation mlxsw: spectrum_cnt: Reorder counter pools docs: networking: phy: Fix a typo amd-xgbe: Use platform_irq_count() octeontx2-vf: Add support for adaptive interrupt coalescing xilinx: Fix build on x86. net: axienet: Use iowrite64 to write all 64b descriptor pointers net: axienet: make the 64b addresable DMA depends on 64b archectures net: hns3: fix tm port shapping of fibre port is incorrect after driver initialization net: hns3: fix PF rss size initialization bug ...

Linus Torvalds committed 4 years ago

Commit 48a23ec2 parents 30306f6 2e7bf4a36 files · +433 −752Browse files

Unified · Split

36 files
  1. Documentation/networking/ip-sysctl.rst +37 −0
  2. Documentation/networking/phy.rst +1 −1
  3. MAINTAINERS +1 −0
  4. arch/arm/boot/dts/at91-sama5d3_ksz9477_evb.dts +5 −0
  5. drivers/net/ethernet/amd/xgbe/xgbe-platform.c +2 −2
  6. drivers/net/ethernet/broadcom/bgmac-bcma.c +0 −1
  7. drivers/net/ethernet/hisilicon/hns3/hnae3.h +1 −0
  8. drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +1 −1
  9. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +15 −3
  10. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +68 −33
  11. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +1 −0
  12. drivers/net/ethernet/intel/i40e/i40e_ethtool.c +17 −8
  13. drivers/net/ethernet/intel/i40e/i40e_main.c +5 −0
  14. drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1 −1
  15. drivers/net/ethernet/intel/iavf/iavf_main.c +1 −1
  16. drivers/net/ethernet/intel/ice/ice_main.c +31 −18
  17. drivers/net/ethernet/intel/ice/ice_ptp.c +1 −1
  18. drivers/net/ethernet/intel/ice/ice_ptp.h +31 −0
  19. drivers/net/ethernet/intel/ice/ice_vf_lib.c +5 −0
  20. drivers/net/ethernet/intel/ice/ice_virtchnl.c +26 −27
  21. drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +2 −1
  22. drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.h +1 −1
  23. drivers/net/ethernet/xilinx/xilinx_axienet.h +51 −0
  24. drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5 −24
  25. drivers/net/usb/ax88179_178a.c +13 −13
  26. include/net/inet_connection_sock.h +0 −3
  27. include/net/inet_hashtables.h +1 −67
  28. include/net/sock.h +0 −14
  29. net/ax25/af_ax25.c +28 −5
  30. net/dccp/proto.c +5 −28
  31. net/ipv4/inet_connection_sock.c +64 −183
  32. net/ipv4/inet_hashtables.c +11 −182
  33. net/ipv4/tcp.c +2 −12
  34. tools/testing/selftests/net/.gitignore +0 −1
  35. tools/testing/selftests/net/Makefile +0 −2
  36. tools/testing/selftests/net/bind_bhash_test.c +0 −119
Documentation/networking/ip-sysctl.rst+37−0
@@ -2925,6 +2925,43 @@ plpmtud_probe_interval - INTEGER · 2924 unmodified lines
29252925
29262926 Default: 0
29272927
2928+reconf_enable - BOOLEAN
2929+ Enable or disable extension of Stream Reconfiguration functionality
2930+ specified in RFC6525. This extension provides the ability to "reset"
2931+ a stream, and it includes the Parameters of "Outgoing/Incoming SSN
2932+ Reset", "SSN/TSN Reset" and "Add Outgoing/Incoming Streams".
2933+
2934+ - 1: Enable extension.
2935+ - 0: Disable extension.
2936+
2937+ Default: 0
2938+
2939+intl_enable - BOOLEAN
2940+ Enable or disable extension of User Message Interleaving functionality
2941+ specified in RFC8260. This extension allows the interleaving of user
2942+ messages sent on different streams. With this feature enabled, I-DATA
2943+ chunk will replace DATA chunk to carry user messages if also supported
2944+ by the peer. Note that to use this feature, one needs to set this option
2945+ to 1 and also needs to set socket options SCTP_FRAGMENT_INTERLEAVE to 2
2946+ and SCTP_INTERLEAVING_SUPPORTED to 1.
2947+
2948+ - 1: Enable extension.
2949+ - 0: Disable extension.
2950+
2951+ Default: 0
2952+
2953+ecn_enable - BOOLEAN
2954+ Control use of Explicit Congestion Notification (ECN) by SCTP.
2955+ Like in TCP, ECN is used only when both ends of the SCTP connection
2956+ indicate support for it. This feature is useful in avoiding losses
2957+ due to congestion by allowing supporting routers to signal congestion
2958+ before having to drop packets.
2959+
2960+ 1: Enable ecn.
2961+ 0: Disable ecn.
2962+
2963+ Default: 1
2964+
29282965
29292966 ``/proc/sys/net/core/*``
29302967 ========================
Documentation/networking/phy.rst+1−1
@@ -104,7 +104,7 @@ Whenever possible, use the PHY side RGMII delay for these reasons: · 103 unmodified lines
104104
105105 * PHY device drivers in PHYLIB being reusable by nature, being able to
106106 configure correctly a specified delay enables more designs with similar delay
107− requirements to be operate correctly
107+ requirements to be operated correctly
108108
109109 For cases where the PHY is not capable of providing this delay, but the
110110 Ethernet MAC driver is capable of doing so, the correct phy_interface_t value
MAINTAINERS+1−0
@@ -13800,6 +13800,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git · 13799 unmodified lines
1380013800 F: Documentation/devicetree/bindings/net/
1380113801 F: drivers/connector/
1380213802 F: drivers/net/
13803+F: include/dt-bindings/net/
1380313804 F: include/linux/etherdevice.h
1380413805 F: include/linux/fcdevice.h
1380513806 F: include/linux/fddidevice.h
arch/arm/boot/dts/at91-sama5d3_ksz9477_evb.dts+5−0
@@ -120,26 +120,31 @@ · 119 unmodified lines
120120 port@0 {
121121 reg = <0>;
122122 label = "lan1";
123+ phy-mode = "internal";
123124 };
124125
125126 port@1 {
126127 reg = <1>;
127128 label = "lan2";
129+ phy-mode = "internal";
128130 };
129131
130132 port@2 {
131133 reg = <2>;
132134 label = "lan3";
135+ phy-mode = "internal";
133136 };
134137
135138 port@3 {
136139 reg = <3>;
137140 label = "lan4";
141+ phy-mode = "internal";
138142 };
139143
140144 port@4 {
141145 reg = <4>;
142146 label = "lan5";
147+ phy-mode = "internal";
143148 };
144149
145150 port@5 {
drivers/net/ethernet/amd/xgbe/xgbe-platform.c+2−2
@@ -338,7 +338,7 @@ static int xgbe_platform_probe(struct platform_device *pdev) · 337 unmodified lines
338338 * the PHY resources listed last
339339 */
340340 phy_memnum = xgbe_resource_count(pdev, IORESOURCE_MEM) - 3;
341− phy_irqnum = xgbe_resource_count(pdev, IORESOURCE_IRQ) - 1;
341+ phy_irqnum = platform_irq_count(pdev) - 1;
342342 dma_irqnum = 1;
343343 dma_irqend = phy_irqnum;
344344 } else {
@@ -348,7 +348,7 @@ static int xgbe_platform_probe(struct platform_device *pdev) · 3 unmodified lines
348348 phy_memnum = 0;
349349 phy_irqnum = 0;
350350 dma_irqnum = 1;
351− dma_irqend = xgbe_resource_count(pdev, IORESOURCE_IRQ);
351+ dma_irqend = platform_irq_count(pdev);
352352 }
353353
354354 /* Obtain the mmio areas for the device */
drivers/net/ethernet/broadcom/bgmac-bcma.c+0−1
@@ -332,7 +332,6 @@ static void bgmac_remove(struct bcma_device *core) · 331 unmodified lines
332332 bcma_mdio_mii_unregister(bgmac->mii_bus);
333333 bgmac_enet_remove(bgmac);
334334 bcma_set_drvdata(core, NULL);
335− kfree(bgmac);
336335 }
337336
338337 static struct bcma_driver bgmac_bcma_driver = {
drivers/net/ethernet/hisilicon/hns3/hnae3.h+1−0
@@ -769,6 +769,7 @@ struct hnae3_tc_info { · 768 unmodified lines
769769 u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */
770770 u16 tqp_count[HNAE3_MAX_TC];
771771 u16 tqp_offset[HNAE3_MAX_TC];
772+ u8 max_tc; /* Total number of TCs */
772773 u8 num_tc; /* Total number of enabled TCs */
773774 bool mqprio_active;
774775 };
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c+1−1
@@ -1129,7 +1129,7 @@ hns3_is_ringparam_changed(struct net_device *ndev, · 1128 unmodified lines
11291129 if (old_ringparam->tx_desc_num == new_ringparam->tx_desc_num &&
11301130 old_ringparam->rx_desc_num == new_ringparam->rx_desc_num &&
11311131 old_ringparam->rx_buf_len == new_ringparam->rx_buf_len) {
1132− netdev_info(ndev, "ringparam not changed\n");
1132+ netdev_info(ndev, "descriptor number and rx buffer length not changed\n");
11331133 return false;
11341134 }
11351135
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c+15−3
@@ -3268,7 +3268,7 @@ static int hclge_tp_port_init(struct hclge_dev *hdev) · 3267 unmodified lines
32683268 static int hclge_update_port_info(struct hclge_dev *hdev)
32693269 {
32703270 struct hclge_mac *mac = &hdev->hw.mac;
3271− int speed = HCLGE_MAC_SPEED_UNKNOWN;
3271+ int speed;
32723272 int ret;
32733273
32743274 /* get the port info from SFP cmd if not copper port */
@@ -3279,10 +3279,13 @@ static int hclge_update_port_info(struct hclge_dev *hdev) · 4 unmodified lines
32793279 if (!hdev->support_sfp_query)
32803280 return 0;
32813281
3282− if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2)
3282+ if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) {
3283+ speed = mac->speed;
32833284 ret = hclge_get_sfp_info(hdev, mac);
3284− else
3285+ } else {
3286+ speed = HCLGE_MAC_SPEED_UNKNOWN;
32853287 ret = hclge_get_sfp_speed(hdev, &speed);
3288+ }
32863289
32873290 if (ret == -EOPNOTSUPP) {
32883291 hdev->support_sfp_query = false;
@@ -3294,6 +3297,8 @@ static int hclge_update_port_info(struct hclge_dev *hdev) · 5 unmodified lines
32943297 if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) {
32953298 if (mac->speed_type == QUERY_ACTIVE_SPEED) {
32963299 hclge_update_port_capability(hdev, mac);
3300+ if (mac->speed != speed)
3301+ (void)hclge_tm_port_shaper_cfg(hdev);
32973302 return 0;
32983303 }
32993304 return hclge_cfg_mac_speed_dup(hdev, mac->speed,
@@ -3376,6 +3381,12 @@ static int hclge_set_vf_link_state(struct hnae3_handle *handle, int vf, · 76 unmodified lines
33763381 link_state_old = vport->vf_info.link_state;
33773382 vport->vf_info.link_state = link_state;
33783383
3384+ /* return success directly if the VF is unalive, VF will
3385+ * query link state itself when it starts work.
3386+ */
3387+ if (!test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state))
3388+ return 0;
3389+
33793390 ret = hclge_push_vf_link_status(vport);
33803391 if (ret) {
33813392 vport->vf_info.link_state = link_state_old;
@@ -10117,6 +10128,7 @@ static int hclge_modify_port_base_vlan_tag(struct hclge_vport *vport, · 6735 unmodified lines
1011710128 if (ret)
1011810129 return ret;
1011910130
10131+ vport->port_base_vlan_cfg.tbl_sta = false;
1012010132 /* remove old VLAN tag */
1012110133 if (old_info->vlan_tag == 0)
1012210134 ret = hclge_set_vf_vlan_common(hdev, vport->vport_id,
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c+68−33
@@ -282,8 +282,8 @@ static int hclge_tm_pg_to_pri_map_cfg(struct hclge_dev *hdev, · 281 unmodified lines
282282 return hclge_cmd_send(&hdev->hw, &desc, 1);
283283 }
284284
285−static int hclge_tm_qs_to_pri_map_cfg(struct hclge_dev *hdev,
286− u16 qs_id, u8 pri)
285+static int hclge_tm_qs_to_pri_map_cfg(struct hclge_dev *hdev, u16 qs_id, u8 pri,
286+ bool link_vld)
287287 {
288288 struct hclge_qs_to_pri_link_cmd *map;
289289 struct hclge_desc desc;
@@ -294,7 +294,7 @@ static int hclge_tm_qs_to_pri_map_cfg(struct hclge_dev *hdev, · 4 unmodified lines
294294
295295 map->qs_id = cpu_to_le16(qs_id);
296296 map->priority = pri;
297− map->link_vld = HCLGE_TM_QS_PRI_LINK_VLD_MSK;
297+ map->link_vld = link_vld ? HCLGE_TM_QS_PRI_LINK_VLD_MSK : 0;
298298
299299 return hclge_cmd_send(&hdev->hw, &desc, 1);
300300 }
@@ -420,7 +420,7 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev, · 119 unmodified lines
420420 return hclge_cmd_send(&hdev->hw, &desc, 1);
421421 }
422422
423−static int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev)
423+int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev)
424424 {
425425 struct hclge_port_shapping_cmd *shap_cfg_cmd;
426426 struct hclge_shaper_ir_para ir_para;
@@ -642,11 +642,13 @@ static void hclge_tm_update_kinfo_rss_size(struct hclge_vport *vport) · 215 unmodified lines
642642 * one tc for VF for simplicity. VF's vport_id is non zero.
643643 */
644644 if (vport->vport_id) {
645+ kinfo->tc_info.max_tc = 1;
645646 kinfo->tc_info.num_tc = 1;
646647 vport->qs_offset = HNAE3_MAX_TC +
647648 vport->vport_id - HCLGE_VF_VPORT_START_NUM;
648649 vport_max_rss_size = hdev->vf_rss_size_max;
649650 } else {
651+ kinfo->tc_info.max_tc = hdev->tc_max;
650652 kinfo->tc_info.num_tc =
651653 min_t(u16, vport->alloc_tqps, hdev->tm_info.num_tc);
652654 vport->qs_offset = 0;
@@ -679,7 +681,9 @@ static void hclge_tm_vport_tc_info_update(struct hclge_vport *vport) · 26 unmodified lines
679681 kinfo->num_tqps = hclge_vport_get_tqp_num(vport);
680682 vport->dwrr = 100; /* 100 percent as init */
681683 vport->bw_limit = hdev->tm_info.pg_info[0].bw_limit;
682− hdev->rss_cfg.rss_size = kinfo->rss_size;
684+
685+ if (vport->vport_id == PF_VPORT_ID)
686+ hdev->rss_cfg.rss_size = kinfo->rss_size;
683687
684688 /* when enable mqprio, the tc_info has been updated. */
685689 if (kinfo->tc_info.mqprio_active)
@@ -714,14 +718,22 @@ static void hclge_tm_vport_info_update(struct hclge_dev *hdev) · 28 unmodified lines
714718
715719 static void hclge_tm_tc_info_init(struct hclge_dev *hdev)
716720 {
717− u8 i;
721+ u8 i, tc_sch_mode;
722+ u32 bw_limit;
723+
724+ for (i = 0; i < hdev->tc_max; i++) {
725+ if (i < hdev->tm_info.num_tc) {
726+ tc_sch_mode = HCLGE_SCH_MODE_DWRR;
727+ bw_limit = hdev->tm_info.pg_info[0].bw_limit;
728+ } else {
729+ tc_sch_mode = HCLGE_SCH_MODE_SP;
730+ bw_limit = 0;
731+ }
718732
719− for (i = 0; i < hdev->tm_info.num_tc; i++) {
720733 hdev->tm_info.tc_info[i].tc_id = i;
721− hdev->tm_info.tc_info[i].tc_sch_mode = HCLGE_SCH_MODE_DWRR;
734+ hdev->tm_info.tc_info[i].tc_sch_mode = tc_sch_mode;
722735 hdev->tm_info.tc_info[i].pgid = 0;
723− hdev->tm_info.tc_info[i].bw_limit =
724− hdev->tm_info.pg_info[0].bw_limit;
736+ hdev->tm_info.tc_info[i].bw_limit = bw_limit;
725737 }
726738
727739 for (i = 0; i < HNAE3_MAX_USER_PRIO; i++)
@@ -926,10 +938,13 @@ static int hclge_tm_pri_q_qs_cfg_tc_base(struct hclge_dev *hdev) · 198 unmodified lines
926938 for (k = 0; k < hdev->num_alloc_vport; k++) {
927939 struct hnae3_knic_private_info *kinfo = &vport[k].nic.kinfo;
928940
929− for (i = 0; i < kinfo->tc_info.num_tc; i++) {
941+ for (i = 0; i < kinfo->tc_info.max_tc; i++) {
942+ u8 pri = i < kinfo->tc_info.num_tc ? i : 0;
943+ bool link_vld = i < kinfo->tc_info.num_tc;
944+
930945 ret = hclge_tm_qs_to_pri_map_cfg(hdev,
931946 vport[k].qs_offset + i,
932− i);
947+ pri, link_vld);
933948 if (ret)
934949 return ret;
935950 }
@@ -949,7 +964,7 @@ static int hclge_tm_pri_q_qs_cfg_vnet_base(struct hclge_dev *hdev) · 13 unmodified lines
949964 for (i = 0; i < HNAE3_MAX_TC; i++) {
950965 ret = hclge_tm_qs_to_pri_map_cfg(hdev,
951966 vport[k].qs_offset + i,
952− k);
967+ k, true);
953968 if (ret)
954969 return ret;
955970 }
@@ -989,33 +1004,39 @@ static int hclge_tm_pri_tc_base_shaper_cfg(struct hclge_dev *hdev) · 33 unmodified lines
9891004 {
9901005 u32 max_tm_rate = hdev->ae_dev->dev_specs.max_tm_rate;
9911006 struct hclge_shaper_ir_para ir_para;
992− u32 shaper_para;
1007+ u32 shaper_para_c, shaper_para_p;
9931008 int ret;
9941009 u32 i;
9951010
996− for (i = 0; i < hdev->tm_info.num_tc; i++) {
1011+ for (i = 0; i < hdev->tc_max; i++) {
9971012 u32 rate = hdev->tm_info.tc_info[i].bw_limit;
9981013
999− ret = hclge_shaper_para_calc(rate, HCLGE_SHAPER_LVL_PRI,
1000− &ir_para, max_tm_rate);
1001− if (ret)
1002− return ret;
1014+ if (rate) {
1015+ ret = hclge_shaper_para_calc(rate, HCLGE_SHAPER_LVL_PRI,
1016+ &ir_para, max_tm_rate);
1017+ if (ret)
1018+ return ret;
1019+
1020+ shaper_para_c = hclge_tm_get_shapping_para(0, 0, 0,
1021+ HCLGE_SHAPER_BS_U_DEF,
1022+ HCLGE_SHAPER_BS_S_DEF);
1023+ shaper_para_p = hclge_tm_get_shapping_para(ir_para.ir_b,
1024+ ir_para.ir_u,
1025+ ir_para.ir_s,
1026+ HCLGE_SHAPER_BS_U_DEF,
1027+ HCLGE_SHAPER_BS_S_DEF);
1028+ } else {
1029+ shaper_para_c = 0;
1030+ shaper_para_p = 0;
1031+ }
10031032
1004− shaper_para = hclge_tm_get_shapping_para(0, 0, 0,
1005− HCLGE_SHAPER_BS_U_DEF,
1006− HCLGE_SHAPER_BS_S_DEF);
10071033 ret = hclge_tm_pri_shapping_cfg(hdev, HCLGE_TM_SHAP_C_BUCKET, i,
1008− shaper_para, rate);
1034+ shaper_para_c, rate);
10091035 if (ret)
10101036 return ret;
10111037
1012− shaper_para = hclge_tm_get_shapping_para(ir_para.ir_b,
1013− ir_para.ir_u,
1014− ir_para.ir_s,
1015− HCLGE_SHAPER_BS_U_DEF,
1016− HCLGE_SHAPER_BS_S_DEF);
10171038 ret = hclge_tm_pri_shapping_cfg(hdev, HCLGE_TM_SHAP_P_BUCKET, i,
1018− shaper_para, rate);
1039+ shaper_para_p, rate);
10191040 if (ret)
10201041 return ret;
10211042 }
@@ -1125,7 +1146,7 @@ static int hclge_tm_pri_tc_base_dwrr_cfg(struct hclge_dev *hdev) · 103 unmodified lines
11251146 int ret;
11261147 u32 i, k;
11271148
1128− for (i = 0; i < hdev->tm_info.num_tc; i++) {
1149+ for (i = 0; i < hdev->tc_max; i++) {
11291150 pg_info =
11301151 &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid];
11311152 dwrr = pg_info->tc_dwrr[i];
@@ -1135,9 +1156,15 @@ static int hclge_tm_pri_tc_base_dwrr_cfg(struct hclge_dev *hdev) · 3 unmodified lines
11351156 return ret;
11361157
11371158 for (k = 0; k < hdev->num_alloc_vport; k++) {
1159+ struct hnae3_knic_private_info *kinfo = &vport[k].nic.kinfo;
1160+
1161+ if (i >= kinfo->tc_info.max_tc)
1162+ continue;
1163+
1164+ dwrr = i < kinfo->tc_info.num_tc ? vport[k].dwrr : 0;
11381165 ret = hclge_tm_qs_weight_cfg(
11391166 hdev, vport[k].qs_offset + i,
1140− vport[k].dwrr);
1167+ dwrr);
11411168 if (ret)
11421169 return ret;
11431170 }
@@ -1303,6 +1330,7 @@ static int hclge_tm_schd_mode_tc_base_cfg(struct hclge_dev *hdev, u8 pri_id) · 159 unmodified lines
13031330 {
13041331 struct hclge_vport *vport = hdev->vport;
13051332 int ret;
1333+ u8 mode;
13061334 u16 i;
13071335
13081336 ret = hclge_tm_pri_schd_mode_cfg(hdev, pri_id);
@@ -1310,9 +1338,16 @@ static int hclge_tm_schd_mode_tc_base_cfg(struct hclge_dev *hdev, u8 pri_id) · 1 unmodified line
13101338 return ret;
13111339
13121340 for (i = 0; i < hdev->num_alloc_vport; i++) {
1341+ struct hnae3_knic_private_info *kinfo = &vport[i].nic.kinfo;
1342+
1343+ if (pri_id >= kinfo->tc_info.max_tc)
1344+ continue;
1345+
1346+ mode = pri_id < kinfo->tc_info.num_tc ? HCLGE_SCH_MODE_DWRR :
1347+ HCLGE_SCH_MODE_SP;
13131348 ret = hclge_tm_qs_schd_mode_cfg(hdev,
13141349 vport[i].qs_offset + pri_id,
1315− HCLGE_SCH_MODE_DWRR);
1350+ mode);
13161351 if (ret)
13171352 return ret;
13181353 }
@@ -1353,7 +1388,7 @@ static int hclge_tm_lvl34_schd_mode_cfg(struct hclge_dev *hdev) · 34 unmodified lines
13531388 u8 i;
13541389
13551390 if (hdev->tx_sch_mode == HCLGE_FLAG_TC_BASE_SCH_MODE) {
1356− for (i = 0; i < hdev->tm_info.num_tc; i++) {
1391+ for (i = 0; i < hdev->tc_max; i++) {
13571392 ret = hclge_tm_schd_mode_tc_base_cfg(hdev, i);
13581393 if (ret)
13591394 return ret;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h+1−0
@@ -237,6 +237,7 @@ int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr); · 236 unmodified lines
237237 void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats);
238238 void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats);
239239 int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate);
240+int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev);
240241 int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num);
241242 int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num);
242243 int hclge_tm_get_qset_map_pri(struct hclge_dev *hdev, u16 qset_id, u8 *priority,
drivers/net/ethernet/intel/i40e/i40e_ethtool.c+17−8
@@ -2586,15 +2586,16 @@ static void i40e_diag_test(struct net_device *netdev, · 2585 unmodified lines
25862586
25872587 set_bit(__I40E_TESTING, pf->state);
25882588
2589+ if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
2590+ test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) {
2591+ dev_warn(&pf->pdev->dev,
2592+ "Cannot start offline testing when PF is in reset state.\n");
2593+ goto skip_ol_tests;
2594+ }
2595+
25892596 if (i40e_active_vfs(pf) || i40e_active_vmdqs(pf)) {
25902597 dev_warn(&pf->pdev->dev,
25912598 "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n");
2592− data[I40E_ETH_TEST_REG] = 1;
2593− data[I40E_ETH_TEST_EEPROM] = 1;
2594− data[I40E_ETH_TEST_INTR] = 1;
2595− data[I40E_ETH_TEST_LINK] = 1;
2596− eth_test->flags |= ETH_TEST_FL_FAILED;
2597− clear_bit(__I40E_TESTING, pf->state);
25982599 goto skip_ol_tests;
25992600 }
26002601
@@ -2641,9 +2642,17 @@ static void i40e_diag_test(struct net_device *netdev, · 40 unmodified lines
26412642 data[I40E_ETH_TEST_INTR] = 0;
26422643 }
26432644
2644−skip_ol_tests:
2645−
26462645 netif_info(pf, drv, netdev, "testing finished\n");
2646+ return;
2647+
2648+skip_ol_tests:
2649+ data[I40E_ETH_TEST_REG] = 1;
2650+ data[I40E_ETH_TEST_EEPROM] = 1;
2651+ data[I40E_ETH_TEST_INTR] = 1;
2652+ data[I40E_ETH_TEST_LINK] = 1;
2653+ eth_test->flags |= ETH_TEST_FL_FAILED;
2654+ clear_bit(__I40E_TESTING, pf->state);
2655+ netif_info(pf, drv, netdev, "testing failed\n");
26472656 }
26482657
26492658 static void i40e_get_wol(struct net_device *netdev,
drivers/net/ethernet/intel/i40e/i40e_main.c+5−0
@@ -8542,6 +8542,11 @@ static int i40e_configure_clsflower(struct i40e_vsi *vsi, · 8541 unmodified lines
85428542 return -EOPNOTSUPP;
85438543 }
85448544
8545+ if (!tc) {
8546+ dev_err(&pf->pdev->dev, "Unable to add filter because of invalid destination");
8547+ return -EINVAL;
8548+ }
8549+
85458550 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
85468551 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
85478552 return -EBUSY;
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c+1−1
@@ -2282,7 +2282,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg) · 2281 unmodified lines
22822282 }
22832283
22842284 if (vf->adq_enabled) {
2285− for (i = 0; i < I40E_MAX_VF_VSI; i++)
2285+ for (i = 0; i < vf->num_tc; i++)
22862286 num_qps_all += vf->ch[i].num_qps;
22872287 if (num_qps_all != qci->num_queue_pairs) {
22882288 aq_ret = I40E_ERR_PARAM;
drivers/net/ethernet/intel/iavf/iavf_main.c+1−1
@@ -984,7 +984,7 @@ struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter, · 983 unmodified lines
984984 list_add_tail(&f->list, &adapter->mac_filter_list);
985985 f->add = true;
986986 f->is_new_mac = true;
987− f->is_primary = false;
987+ f->is_primary = ether_addr_equal(macaddr, adapter->hw.mac.addr);
988988 adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER;
989989 } else {
990990 f->remove = false;
drivers/net/ethernet/intel/ice/ice_main.c+31−18
@@ -5763,25 +5763,38 @@ static netdev_features_t · 5762 unmodified lines
57635763 ice_fix_features(struct net_device *netdev, netdev_features_t features)
57645764 {
57655765 struct ice_netdev_priv *np = netdev_priv(netdev);
5766− netdev_features_t supported_vlan_filtering;
5767− netdev_features_t requested_vlan_filtering;
5768− struct ice_vsi *vsi = np->vsi;
5769−
5770− requested_vlan_filtering = features & NETIF_VLAN_FILTERING_FEATURES;
5771−
5772− /* make sure supported_vlan_filtering works for both SVM and DVM */
5773− supported_vlan_filtering = NETIF_F_HW_VLAN_CTAG_FILTER;
5774− if (ice_is_dvm_ena(&vsi->back->hw))
5775− supported_vlan_filtering |= NETIF_F_HW_VLAN_STAG_FILTER;
5776−
5777− if (requested_vlan_filtering &&
5778− requested_vlan_filtering != supported_vlan_filtering) {
5779− if (requested_vlan_filtering & NETIF_F_HW_VLAN_CTAG_FILTER) {
5780− netdev_warn(netdev, "cannot support requested VLAN filtering settings, enabling all supported VLAN filtering settings\n");
5781− features |= supported_vlan_filtering;
5766+ netdev_features_t req_vlan_fltr, cur_vlan_fltr;
5767+ bool cur_ctag, cur_stag, req_ctag, req_stag;
5768+
5769+ cur_vlan_fltr = netdev->features & NETIF_VLAN_FILTERING_FEATURES;
5770+ cur_ctag = cur_vlan_fltr & NETIF_F_HW_VLAN_CTAG_FILTER;
5771+ cur_stag = cur_vlan_fltr & NETIF_F_HW_VLAN_STAG_FILTER;
5772+
5773+ req_vlan_fltr = features & NETIF_VLAN_FILTERING_FEATURES;
5774+ req_ctag = req_vlan_fltr & NETIF_F_HW_VLAN_CTAG_FILTER;
5775+ req_stag = req_vlan_fltr & NETIF_F_HW_VLAN_STAG_FILTER;
5776+
5777+ if (req_vlan_fltr != cur_vlan_fltr) {
5778+ if (ice_is_dvm_ena(&np->vsi->back->hw)) {
5779+ if (req_ctag && req_stag) {
5780+ features |= NETIF_VLAN_FILTERING_FEATURES;
5781+ } else if (!req_ctag && !req_stag) {
5782+ features &= ~NETIF_VLAN_FILTERING_FEATURES;
5783+ } else if ((!cur_ctag && req_ctag && !cur_stag) ||
5784+ (!cur_stag && req_stag && !cur_ctag)) {
5785+ features |= NETIF_VLAN_FILTERING_FEATURES;
5786+ netdev_warn(netdev, "802.1Q and 802.1ad VLAN filtering must be either both on or both off. VLAN filtering has been enabled for both types.\n");
5787+ } else if ((cur_ctag && !req_ctag && cur_stag) ||
5788+ (cur_stag && !req_stag && cur_ctag)) {
5789+ features &= ~NETIF_VLAN_FILTERING_FEATURES;
5790+ netdev_warn(netdev, "802.1Q and 802.1ad VLAN filtering must be either both on or both off. VLAN filtering has been disabled for both types.\n");
5791+ }
57825792 } else {
5783− netdev_warn(netdev, "cannot support requested VLAN filtering settings, clearing all supported VLAN filtering settings\n");
5784− features &= ~supported_vlan_filtering;
5793+ if (req_vlan_fltr & NETIF_F_HW_VLAN_STAG_FILTER)
5794+ netdev_warn(netdev, "cannot support requested 802.1ad filtering setting in SVM mode\n");
5795+
5796+ if (req_vlan_fltr & NETIF_F_HW_VLAN_CTAG_FILTER)
5797+ features |= NETIF_F_HW_VLAN_CTAG_FILTER;
57855798 }
57865799 }
57875800
drivers/net/ethernet/intel/ice/ice_ptp.c+1−1
@@ -2271,7 +2271,7 @@ static int · 2270 unmodified lines
22712271 ice_ptp_init_tx_e822(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port)
22722272 {
22732273 tx->quad = port / ICE_PORTS_PER_QUAD;
2274− tx->quad_offset = tx->quad * INDEX_PER_PORT;
2274+ tx->quad_offset = (port % ICE_PORTS_PER_QUAD) * INDEX_PER_PORT;
22752275 tx->len = INDEX_PER_PORT;
22762276
22772277 return ice_ptp_alloc_tx_tracker(tx);
drivers/net/ethernet/intel/ice/ice_ptp.h+31−0
@@ -49,6 +49,37 @@ struct ice_perout_channel { · 48 unmodified lines
4949 * To allow multiple ports to access the shared register block independently,
5050 * the blocks are split up so that indexes are assigned to each port based on
5151 * hardware logical port number.
52+ *
53+ * The timestamp blocks are handled differently for E810- and E822-based
54+ * devices. In E810 devices, each port has its own block of timestamps, while in
55+ * E822 there is a need to logically break the block of registers into smaller
56+ * chunks based on the port number to avoid collisions.
57+ *
58+ * Example for port 5 in E810:
59+ * +--------+--------+--------+--------+--------+--------+--------+--------+
60+ * |register|register|register|register|register|register|register|register|
61+ * | block | block | block | block | block | block | block | block |
62+ * | for | for | for | for | for | for | for | for |
63+ * | port 0 | port 1 | port 2 | port 3 | port 4 | port 5 | port 6 | port 7 |
64+ * +--------+--------+--------+--------+--------+--------+--------+--------+
65+ * ^^
66+ * ||
67+ * |--- quad offset is always 0
68+ * ---- quad number
69+ *
70+ * Example for port 5 in E822:
71+ * +-----------------------------+-----------------------------+
72+ * | register block for quad 0 | register block for quad 1 |
73+ * |+------+------+------+------+|+------+------+------+------+|
74+ * ||port 0|port 1|port 2|port 3|||port 0|port 1|port 2|port 3||
75+ * |+------+------+------+------+|+------+------+------+------+|
76+ * +-----------------------------+-------^---------------------+
77+ * ^ |
78+ * | --- quad offset*
79+ * ---- quad number
80+ *
81+ * * PHY port 5 is port 1 in quad 1
82+ *
5283 */
5384
5485 /**
drivers/net/ethernet/intel/ice/ice_vf_lib.c+5−0
@@ -504,6 +504,11 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags) · 503 unmodified lines
504504 }
505505
506506 if (ice_is_vf_disabled(vf)) {
507+ vsi = ice_get_vf_vsi(vf);
508+ if (WARN_ON(!vsi))
509+ return -EINVAL;
510+ ice_vsi_stop_lan_tx_rings(vsi, ICE_NO_RESET, vf->vf_id);
511+ ice_vsi_stop_all_rx_rings(vsi);
507512 dev_dbg(dev, "VF is already disabled, there is no need for resetting it, telling VM, all is fine %d\n",
508513 vf->vf_id);
509514 return 0;
drivers/net/ethernet/intel/ice/ice_virtchnl.c+26−27
@@ -1569,35 +1569,27 @@ error_param: · 1568 unmodified lines
15691569 */
15701570 static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
15711571 {
1572− enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
15731572 struct virtchnl_vsi_queue_config_info *qci =
15741573 (struct virtchnl_vsi_queue_config_info *)msg;
15751574 struct virtchnl_queue_pair_info *qpi;
15761575 struct ice_pf *pf = vf->pf;
15771576 struct ice_vsi *vsi;
1578− int i, q_idx;
1577+ int i = -1, q_idx;
15791578
1580− if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
1581− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1579+ if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
15821580 goto error_param;
1583− }
15841581
1585− if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id)) {
1586− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1582+ if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id))
15871583 goto error_param;
1588− }
15891584
15901585 vsi = ice_get_vf_vsi(vf);
1591− if (!vsi) {
1592− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1586+ if (!vsi)
15931587 goto error_param;
1594− }
15951588
15961589 if (qci->num_queue_pairs > ICE_MAX_RSS_QS_PER_VF ||
15971590 qci->num_queue_pairs > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
15981591 dev_err(ice_pf_to_dev(pf), "VF-%d requesting more than supported number of queues: %d\n",
15991592 vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
1600− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
16011593 goto error_param;
16021594 }
16031595
@@ -1610,7 +1602,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 6 unmodified lines
16101602 !ice_vc_isvalid_ring_len(qpi->txq.ring_len) ||
16111603 !ice_vc_isvalid_ring_len(qpi->rxq.ring_len) ||
16121604 !ice_vc_isvalid_q_id(vf, qci->vsi_id, qpi->txq.queue_id)) {
1613− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
16141605 goto error_param;
16151606 }
16161607
@@ -1620,7 +1611,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 3 unmodified lines
16201611 * for selected "vsi"
16211612 */
16221613 if (q_idx >= vsi->alloc_txq || q_idx >= vsi->alloc_rxq) {
1623− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
16241614 goto error_param;
16251615 }
16261616
@@ -1630,14 +1620,13 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 3 unmodified lines
16301620 vsi->tx_rings[i]->count = qpi->txq.ring_len;
16311621
16321622 /* Disable any existing queue first */
1633− if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx)) {
1634− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1623+ if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx))
16351624 goto error_param;
1636− }
16371625
16381626 /* Configure a queue with the requested settings */
16391627 if (ice_vsi_cfg_single_txq(vsi, vsi->tx_rings, q_idx)) {
1640− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1628+ dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure TX queue %d\n",
1629+ vf->vf_id, i);
16411630 goto error_param;
16421631 }
16431632 }
@@ -1651,17 +1640,13 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 7 unmodified lines
16511640
16521641 if (qpi->rxq.databuffer_size != 0 &&
16531642 (qpi->rxq.databuffer_size > ((16 * 1024) - 128) ||
1654− qpi->rxq.databuffer_size < 1024)) {
1655− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1643+ qpi->rxq.databuffer_size < 1024))
16561644 goto error_param;
1657− }
16581645 vsi->rx_buf_len = qpi->rxq.databuffer_size;
16591646 vsi->rx_rings[i]->rx_buf_len = vsi->rx_buf_len;
16601647 if (qpi->rxq.max_pkt_size > max_frame_size ||
1661− qpi->rxq.max_pkt_size < 64) {
1662− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1648+ qpi->rxq.max_pkt_size < 64)
16631649 goto error_param;
1664− }
16651650
16661651 vsi->max_frame = qpi->rxq.max_pkt_size;
16671652 /* add space for the port VLAN since the VF driver is
@@ -1672,16 +1657,30 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 4 unmodified lines
16721657 vsi->max_frame += VLAN_HLEN;
16731658
16741659 if (ice_vsi_cfg_single_rxq(vsi, q_idx)) {
1675− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1660+ dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure RX queue %d\n",
1661+ vf->vf_id, i);
16761662 goto error_param;
16771663 }
16781664 }
16791665 }
16801666
1667+ /* send the response to the VF */
1668+ return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
1669+ VIRTCHNL_STATUS_SUCCESS, NULL, 0);
16811670 error_param:
1671+ /* disable whatever we can */
1672+ for (; i >= 0; i--) {
1673+ if (ice_vsi_ctrl_one_rx_ring(vsi, false, i, true))
1674+ dev_err(ice_pf_to_dev(pf), "VF-%d could not disable RX queue %d\n",
1675+ vf->vf_id, i);
1676+ if (ice_vf_vsi_dis_single_txq(vf, vsi, i))
1677+ dev_err(ice_pf_to_dev(pf), "VF-%d could not disable TX queue %d\n",
1678+ vf->vf_id, i);
1679+ }
1680+
16821681 /* send the response to the VF */
1683− return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES, v_ret,
1684− NULL, 0);
1682+ return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
1683+ VIRTCHNL_STATUS_ERR_PARAM, NULL, 0);
16851684 }
16861685
16871686 /**
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c+2−1
@@ -1390,7 +1390,8 @@ static int otx2vf_get_link_ksettings(struct net_device *netdev, · 1389 unmodified lines
13901390
13911391 static const struct ethtool_ops otx2vf_ethtool_ops = {
13921392 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
1393− ETHTOOL_COALESCE_MAX_FRAMES,
1393+ ETHTOOL_COALESCE_MAX_FRAMES |
1394+ ETHTOOL_COALESCE_USE_ADAPTIVE,
13941395 .supported_ring_params = ETHTOOL_RING_USE_RX_BUF_LEN |
13951396 ETHTOOL_RING_USE_CQE_SIZE,
13961397 .get_link = otx2_get_link,
drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.h+1−1
@@ -8,8 +8,8 @@ · 7 unmodified lines
88 #include "spectrum.h"
99
1010 enum mlxsw_sp_counter_sub_pool_id {
11− MLXSW_SP_COUNTER_SUB_POOL_FLOW,
1211 MLXSW_SP_COUNTER_SUB_POOL_RIF,
12+ MLXSW_SP_COUNTER_SUB_POOL_FLOW,
1313 };
1414
1515 int mlxsw_sp_counter_alloc(struct mlxsw_sp *mlxsw_sp,
drivers/net/ethernet/xilinx/xilinx_axienet.h+51−0
@@ -547,6 +547,57 @@ static inline void axienet_iow(struct axienet_local *lp, off_t offset, · 546 unmodified lines
547547 iowrite32(value, lp->regs + offset);
548548 }
549549
550+/**
551+ * axienet_dma_out32 - Memory mapped Axi DMA register write.
552+ * @lp: Pointer to axienet local structure
553+ * @reg: Address offset from the base address of the Axi DMA core
554+ * @value: Value to be written into the Axi DMA register
555+ *
556+ * This function writes the desired value into the corresponding Axi DMA
557+ * register.
558+ */
559+
560+static inline void axienet_dma_out32(struct axienet_local *lp,
561+ off_t reg, u32 value)
562+{
563+ iowrite32(value, lp->dma_regs + reg);
564+}
565+
566+#if defined(CONFIG_64BIT) && defined(iowrite64)
567+/**
568+ * axienet_dma_out64 - Memory mapped Axi DMA register write.
569+ * @lp: Pointer to axienet local structure
570+ * @reg: Address offset from the base address of the Axi DMA core
571+ * @value: Value to be written into the Axi DMA register
572+ *
573+ * This function writes the desired value into the corresponding Axi DMA
574+ * register.
575+ */
576+static inline void axienet_dma_out64(struct axienet_local *lp,
577+ off_t reg, u64 value)
578+{
579+ iowrite64(value, lp->dma_regs + reg);
580+}
581+
582+static inline void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
583+ dma_addr_t addr)
584+{
585+ if (lp->features & XAE_FEATURE_DMA_64BIT)
586+ axienet_dma_out64(lp, reg, addr);
587+ else
588+ axienet_dma_out32(lp, reg, lower_32_bits(addr));
589+}
590+
591+#else /* CONFIG_64BIT */
592+
593+static inline void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
594+ dma_addr_t addr)
595+{
596+ axienet_dma_out32(lp, reg, lower_32_bits(addr));
597+}
598+
599+#endif /* CONFIG_64BIT */
600+
550601 /* Function prototypes visible in xilinx_axienet_mdio.c for other files */
551602 int axienet_mdio_enable(struct axienet_local *lp);
552603 void axienet_mdio_disable(struct axienet_local *lp);
drivers/net/ethernet/xilinx/xilinx_axienet_main.c+5−24
@@ -133,30 +133,6 @@ static inline u32 axienet_dma_in32(struct axienet_local *lp, off_t reg) · 132 unmodified lines
133133 return ioread32(lp->dma_regs + reg);
134134 }
135135
136−/**
137− * axienet_dma_out32 - Memory mapped Axi DMA register write.
138− * @lp: Pointer to axienet local structure
139− * @reg: Address offset from the base address of the Axi DMA core
140− * @value: Value to be written into the Axi DMA register
141− *
142− * This function writes the desired value into the corresponding Axi DMA
143− * register.
144− */
145−static inline void axienet_dma_out32(struct axienet_local *lp,
146− off_t reg, u32 value)
147−{
148− iowrite32(value, lp->dma_regs + reg);
149−}
150−
151−static void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
152− dma_addr_t addr)
153−{
154− axienet_dma_out32(lp, reg, lower_32_bits(addr));
155−
156− if (lp->features & XAE_FEATURE_DMA_64BIT)
157− axienet_dma_out32(lp, reg + 4, upper_32_bits(addr));
158−}
159−
160136 static void desc_set_phys_addr(struct axienet_local *lp, dma_addr_t addr,
161137 struct axidma_bd *desc)
162138 {
@@ -2061,6 +2037,11 @@ static int axienet_probe(struct platform_device *pdev) · 1898 unmodified lines
20612037 iowrite32(0x0, desc);
20622038 }
20632039 }
2040+ if (!IS_ENABLED(CONFIG_64BIT) && lp->features & XAE_FEATURE_DMA_64BIT) {
2041+ dev_err(&pdev->dev, "64-bit addressable DMA is not compatible with 32-bit archecture\n");
2042+ ret = -EINVAL;
2043+ goto cleanup_clk;
2044+ }
20642045
20652046 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(addr_width));
20662047 if (ret) {
drivers/net/usb/ax88179_178a.c+13−13
@@ -1750,7 +1750,7 @@ static const struct driver_info ax88179_info = { · 1749 unmodified lines
17501750 .link_reset = ax88179_link_reset,
17511751 .reset = ax88179_reset,
17521752 .stop = ax88179_stop,
1753− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1753+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
17541754 .rx_fixup = ax88179_rx_fixup,
17551755 .tx_fixup = ax88179_tx_fixup,
17561756 };
@@ -1763,7 +1763,7 @@ static const struct driver_info ax88178a_info = { · 6 unmodified lines
17631763 .link_reset = ax88179_link_reset,
17641764 .reset = ax88179_reset,
17651765 .stop = ax88179_stop,
1766− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1766+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
17671767 .rx_fixup = ax88179_rx_fixup,
17681768 .tx_fixup = ax88179_tx_fixup,
17691769 };
@@ -1776,7 +1776,7 @@ static const struct driver_info cypress_GX3_info = { · 6 unmodified lines
17761776 .link_reset = ax88179_link_reset,
17771777 .reset = ax88179_reset,
17781778 .stop = ax88179_stop,
1779− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1779+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
17801780 .rx_fixup = ax88179_rx_fixup,
17811781 .tx_fixup = ax88179_tx_fixup,
17821782 };
@@ -1789,7 +1789,7 @@ static const struct driver_info dlink_dub1312_info = { · 6 unmodified lines
17891789 .link_reset = ax88179_link_reset,
17901790 .reset = ax88179_reset,
17911791 .stop = ax88179_stop,
1792− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1792+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
17931793 .rx_fixup = ax88179_rx_fixup,
17941794 .tx_fixup = ax88179_tx_fixup,
17951795 };
@@ -1802,7 +1802,7 @@ static const struct driver_info sitecom_info = { · 6 unmodified lines
18021802 .link_reset = ax88179_link_reset,
18031803 .reset = ax88179_reset,
18041804 .stop = ax88179_stop,
1805− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1805+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
18061806 .rx_fixup = ax88179_rx_fixup,
18071807 .tx_fixup = ax88179_tx_fixup,
18081808 };
@@ -1815,7 +1815,7 @@ static const struct driver_info samsung_info = { · 6 unmodified lines
18151815 .link_reset = ax88179_link_reset,
18161816 .reset = ax88179_reset,
18171817 .stop = ax88179_stop,
1818− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1818+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
18191819 .rx_fixup = ax88179_rx_fixup,
18201820 .tx_fixup = ax88179_tx_fixup,
18211821 };
@@ -1828,7 +1828,7 @@ static const struct driver_info lenovo_info = { · 6 unmodified lines
18281828 .link_reset = ax88179_link_reset,
18291829 .reset = ax88179_reset,
18301830 .stop = ax88179_stop,
1831− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1831+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
18321832 .rx_fixup = ax88179_rx_fixup,
18331833 .tx_fixup = ax88179_tx_fixup,
18341834 };
@@ -1841,7 +1841,7 @@ static const struct driver_info belkin_info = { · 6 unmodified lines
18411841 .link_reset = ax88179_link_reset,
18421842 .reset = ax88179_reset,
18431843 .stop = ax88179_stop,
1844− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1844+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
18451845 .rx_fixup = ax88179_rx_fixup,
18461846 .tx_fixup = ax88179_tx_fixup,
18471847 };
@@ -1854,7 +1854,7 @@ static const struct driver_info toshiba_info = { · 6 unmodified lines
18541854 .link_reset = ax88179_link_reset,
18551855 .reset = ax88179_reset,
18561856 .stop = ax88179_stop,
1857− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1857+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
18581858 .rx_fixup = ax88179_rx_fixup,
18591859 .tx_fixup = ax88179_tx_fixup,
18601860 };
@@ -1867,7 +1867,7 @@ static const struct driver_info mct_info = { · 6 unmodified lines
18671867 .link_reset = ax88179_link_reset,
18681868 .reset = ax88179_reset,
18691869 .stop = ax88179_stop,
1870− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1870+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
18711871 .rx_fixup = ax88179_rx_fixup,
18721872 .tx_fixup = ax88179_tx_fixup,
18731873 };
@@ -1880,7 +1880,7 @@ static const struct driver_info at_umc2000_info = { · 6 unmodified lines
18801880 .link_reset = ax88179_link_reset,
18811881 .reset = ax88179_reset,
18821882 .stop = ax88179_stop,
1883− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1883+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
18841884 .rx_fixup = ax88179_rx_fixup,
18851885 .tx_fixup = ax88179_tx_fixup,
18861886 };
@@ -1893,7 +1893,7 @@ static const struct driver_info at_umc200_info = { · 6 unmodified lines
18931893 .link_reset = ax88179_link_reset,
18941894 .reset = ax88179_reset,
18951895 .stop = ax88179_stop,
1896− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1896+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
18971897 .rx_fixup = ax88179_rx_fixup,
18981898 .tx_fixup = ax88179_tx_fixup,
18991899 };
@@ -1906,7 +1906,7 @@ static const struct driver_info at_umc2000sp_info = { · 6 unmodified lines
19061906 .link_reset = ax88179_link_reset,
19071907 .reset = ax88179_reset,
19081908 .stop = ax88179_stop,
1909− .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1909+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
19101910 .rx_fixup = ax88179_rx_fixup,
19111911 .tx_fixup = ax88179_tx_fixup,
19121912 };
include/net/inet_connection_sock.h+0−3
@@ -25,7 +25,6 @@ · 24 unmodified lines
2525 #undef INET_CSK_CLEAR_TIMERS
2626
2727 struct inet_bind_bucket;
28−struct inet_bind2_bucket;
2928 struct tcp_congestion_ops;
3029
3130 /*
@@ -58,7 +57,6 @@ struct inet_connection_sock_af_ops { · 26 unmodified lines
5857 *
5958 * @icsk_accept_queue: FIFO of established children
6059 * @icsk_bind_hash: Bind node
61− * @icsk_bind2_hash: Bind node in the bhash2 table
6260 * @icsk_timeout: Timeout
6361 * @icsk_retransmit_timer: Resend (no ack)
6462 * @icsk_rto: Retransmit timeout
@@ -85,7 +83,6 @@ struct inet_connection_sock { · 20 unmodified lines
8583 struct inet_sock icsk_inet;
8684 struct request_sock_queue icsk_accept_queue;
8785 struct inet_bind_bucket *icsk_bind_hash;
88− struct inet_bind2_bucket *icsk_bind2_hash;
8986 unsigned long icsk_timeout;
9087 struct timer_list icsk_retransmit_timer;
9188 struct timer_list icsk_delack_timer;
include/net/inet_hashtables.h+1−67
@@ -90,32 +90,11 @@ struct inet_bind_bucket { · 89 unmodified lines
9090 struct hlist_head owners;
9191 };
9292
93−struct inet_bind2_bucket {
94− possible_net_t ib_net;
95− int l3mdev;
96− unsigned short port;
97− union {
98−#if IS_ENABLED(CONFIG_IPV6)
99− struct in6_addr v6_rcv_saddr;
100−#endif
101− __be32 rcv_saddr;
102− };
103− /* Node in the inet2_bind_hashbucket chain */
104− struct hlist_node node;
105− /* List of sockets hashed to this bucket */
106− struct hlist_head owners;
107−};
108−
10993 static inline struct net *ib_net(struct inet_bind_bucket *ib)
11094 {
11195 return read_pnet(&ib->ib_net);
11296 }
11397
114−static inline struct net *ib2_net(struct inet_bind2_bucket *ib)
115−{
116− return read_pnet(&ib->ib_net);
117−}
118−
11998 #define inet_bind_bucket_for_each(tb, head) \
12099 hlist_for_each_entry(tb, head, node)
121100
@@ -124,15 +103,6 @@ struct inet_bind_hashbucket { · 2 unmodified lines
124103 struct hlist_head chain;
125104 };
126105
127−/* This is synchronized using the inet_bind_hashbucket's spinlock.
128− * Instead of having separate spinlocks, the inet_bind2_hashbucket can share
129− * the inet_bind_hashbucket's given that in every case where the bhash2 table
130− * is useful, a lookup in the bhash table also occurs.
131− */
132−struct inet_bind2_hashbucket {
133− struct hlist_head chain;
134−};
135−
136106 /* Sockets can be hashed in established or listening table.
137107 * We must use different 'nulls' end-of-chain value for all hash buckets :
138108 * A socket might transition from ESTABLISH to LISTEN state without
@@ -164,12 +134,6 @@ struct inet_hashinfo { · 25 unmodified lines
164134 */
165135 struct kmem_cache *bind_bucket_cachep;
166136 struct inet_bind_hashbucket *bhash;
167− /* The 2nd binding table hashed by port and address.
168− * This is used primarily for expediting the resolution of bind
169− * conflicts.
170− */
171− struct kmem_cache *bind2_bucket_cachep;
172− struct inet_bind2_hashbucket *bhash2;
173137 unsigned int bhash_size;
174138
175139 /* The 2nd listener table hashed by local port and address */
@@ -229,36 +193,6 @@ inet_bind_bucket_create(struct kmem_cache *cachep, struct net *net, · 53 unmodified lines
229193 void inet_bind_bucket_destroy(struct kmem_cache *cachep,
230194 struct inet_bind_bucket *tb);
231195
232−static inline bool check_bind_bucket_match(struct inet_bind_bucket *tb,
233− struct net *net,
234− const unsigned short port,
235− int l3mdev)
236−{
237− return net_eq(ib_net(tb), net) && tb->port == port &&
238− tb->l3mdev == l3mdev;
239−}
240−
241−struct inet_bind2_bucket *
242−inet_bind2_bucket_create(struct kmem_cache *cachep, struct net *net,
243− struct inet_bind2_hashbucket *head,
244− const unsigned short port, int l3mdev,
245− const struct sock *sk);
246−
247−void inet_bind2_bucket_destroy(struct kmem_cache *cachep,
248− struct inet_bind2_bucket *tb);
249−
250−struct inet_bind2_bucket *
251−inet_bind2_bucket_find(struct inet_hashinfo *hinfo, struct net *net,
252− const unsigned short port, int l3mdev,
253− struct sock *sk,
254− struct inet_bind2_hashbucket **head);
255−
256−bool check_bind2_bucket_match_nulladdr(struct inet_bind2_bucket *tb,
257− struct net *net,
258− const unsigned short port,
259− int l3mdev,
260− const struct sock *sk);
261−
262196 static inline u32 inet_bhashfn(const struct net *net, const __u16 lport,
263197 const u32 bhash_size)
264198 {
@@ -266,7 +200,7 @@ static inline u32 inet_bhashfn(const struct net *net, const __u16 lport, · 1 unmodified line
266200 }
267201
268202 void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb,
269− struct inet_bind2_bucket *tb2, const unsigned short snum);
203+ const unsigned short snum);
270204
271205 /* Caller must disable local BH processing. */
272206 int __inet_inherit_port(const struct sock *sk, struct sock *child);
include/net/sock.h+0−14
@@ -348,7 +348,6 @@ struct sk_filter; · 347 unmodified lines
348348 * @sk_txtime_report_errors: set report errors mode for SO_TXTIME
349349 * @sk_txtime_unused: unused txtime flags
350350 * @ns_tracker: tracker for netns reference
351− * @sk_bind2_node: bind node in the bhash2 table
352351 */
353352 struct sock {
354353 /*
@@ -538,7 +537,6 @@ struct sock { · 183 unmodified lines
538537 #endif
539538 struct rcu_head sk_rcu;
540539 netns_tracker ns_tracker;
541− struct hlist_node sk_bind2_node;
542540 };
543541
544542 enum sk_pacing {
@@ -819,16 +817,6 @@ static inline void sk_add_bind_node(struct sock *sk, · 274 unmodified lines
819817 hlist_add_head(&sk->sk_bind_node, list);
820818 }
821819
822−static inline void __sk_del_bind2_node(struct sock *sk)
823−{
824− __hlist_del(&sk->sk_bind2_node);
825−}
826−
827−static inline void sk_add_bind2_node(struct sock *sk, struct hlist_head *list)
828−{
829− hlist_add_head(&sk->sk_bind2_node, list);
830−}
831−
832820 #define sk_for_each(__sk, list) \
833821 hlist_for_each_entry(__sk, list, sk_node)
834822 #define sk_for_each_rcu(__sk, list) \
@@ -846,8 +834,6 @@ static inline void sk_add_bind2_node(struct sock *sk, struct hlist_head *list) · 11 unmodified lines
846834 hlist_for_each_entry_safe(__sk, tmp, list, sk_node)
847835 #define sk_for_each_bound(__sk, list) \
848836 hlist_for_each_entry(__sk, list, sk_bind_node)
849−#define sk_for_each_bound_bhash2(__sk, list) \
850− hlist_for_each_entry(__sk, list, sk_bind2_node)
851837
852838 /**
853839 * sk_for_each_entry_offset_rcu - iterate over a list at a given struct offset
net/ax25/af_ax25.c+28−5
@@ -1661,9 +1661,12 @@ static int ax25_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, · 1660 unmodified lines
16611661 int flags)
16621662 {
16631663 struct sock *sk = sock->sk;
1664− struct sk_buff *skb;
1664+ struct sk_buff *skb, *last;
1665+ struct sk_buff_head *sk_queue;
16651666 int copied;
16661667 int err = 0;
1668+ int off = 0;
1669+ long timeo;
16671670
16681671 lock_sock(sk);
16691672 /*
@@ -1675,10 +1678,29 @@ static int ax25_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, · 5 unmodified lines
16751678 goto out;
16761679 }
16771680
1678− /* Now we can treat all alike */
1679− skb = skb_recv_datagram(sk, flags, &err);
1680− if (skb == NULL)
1681− goto out;
1681+ /* We need support for non-blocking reads. */
1682+ sk_queue = &sk->sk_receive_queue;
1683+ skb = __skb_try_recv_datagram(sk, sk_queue, flags, &off, &err, &last);
1684+ /* If no packet is available, release_sock(sk) and try again. */
1685+ if (!skb) {
1686+ if (err != -EAGAIN)
1687+ goto out;
1688+ release_sock(sk);
1689+ timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
1690+ while (timeo && !__skb_wait_for_more_packets(sk, sk_queue, &err,
1691+ &timeo, last)) {
1692+ skb = __skb_try_recv_datagram(sk, sk_queue, flags, &off,
1693+ &err, &last);
1694+ if (skb)
1695+ break;
1696+
1697+ if (err != -EAGAIN)
1698+ goto done;
1699+ }
1700+ if (!skb)
1701+ goto done;
1702+ lock_sock(sk);
1703+ }
16821704
16831705 if (!sk_to_ax25(sk)->pidincl)
16841706 skb_pull(skb, 1); /* Remove PID */
@@ -1725,6 +1747,7 @@ static int ax25_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, · 40 unmodified lines
17251747 out:
17261748 release_sock(sk);
17271749
1750+done:
17281751 return err;
17291752 }
17301753
net/dccp/proto.c+5−28
@@ -1120,12 +1120,6 @@ static int __init dccp_init(void) · 1119 unmodified lines
11201120 SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL);
11211121 if (!dccp_hashinfo.bind_bucket_cachep)
11221122 goto out_free_hashinfo2;
1123− dccp_hashinfo.bind2_bucket_cachep =
1124− kmem_cache_create("dccp_bind2_bucket",
1125− sizeof(struct inet_bind2_bucket), 0,
1126− SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL);
1127− if (!dccp_hashinfo.bind2_bucket_cachep)
1128− goto out_free_bind_bucket_cachep;
11291123
11301124 /*
11311125 * Size and allocate the main established and bind bucket
@@ -1156,7 +1150,7 @@ static int __init dccp_init(void) · 24 unmodified lines
11561150
11571151 if (!dccp_hashinfo.ehash) {
11581152 DCCP_CRIT("Failed to allocate DCCP established hash table");
1159− goto out_free_bind2_bucket_cachep;
1153+ goto out_free_bind_bucket_cachep;
11601154 }
11611155
11621156 for (i = 0; i <= dccp_hashinfo.ehash_mask; i++)
@@ -1182,23 +1176,14 @@ static int __init dccp_init(void) · 19 unmodified lines
11821176 goto out_free_dccp_locks;
11831177 }
11841178
1185− dccp_hashinfo.bhash2 = (struct inet_bind2_hashbucket *)
1186− __get_free_pages(GFP_ATOMIC | __GFP_NOWARN, bhash_order);
1187−
1188− if (!dccp_hashinfo.bhash2) {
1189− DCCP_CRIT("Failed to allocate DCCP bind2 hash table");
1190− goto out_free_dccp_bhash;
1191− }
1192−
11931179 for (i = 0; i < dccp_hashinfo.bhash_size; i++) {
11941180 spin_lock_init(&dccp_hashinfo.bhash[i].lock);
11951181 INIT_HLIST_HEAD(&dccp_hashinfo.bhash[i].chain);
1196− INIT_HLIST_HEAD(&dccp_hashinfo.bhash2[i].chain);
11971182 }
11981183
11991184 rc = dccp_mib_init();
12001185 if (rc)
1201− goto out_free_dccp_bhash2;
1186+ goto out_free_dccp_bhash;
12021187
12031188 rc = dccp_ackvec_init();
12041189 if (rc)
@@ -1222,38 +1207,30 @@ out_ackvec_exit: · 17 unmodified lines
12221207 dccp_ackvec_exit();
12231208 out_free_dccp_mib:
12241209 dccp_mib_exit();
1225−out_free_dccp_bhash2:
1226− free_pages((unsigned long)dccp_hashinfo.bhash2, bhash_order);
12271210 out_free_dccp_bhash:
12281211 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
12291212 out_free_dccp_locks:
12301213 inet_ehash_locks_free(&dccp_hashinfo);
12311214 out_free_dccp_ehash:
12321215 free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order);
1233−out_free_bind2_bucket_cachep:
1234− kmem_cache_destroy(dccp_hashinfo.bind2_bucket_cachep);
12351216 out_free_bind_bucket_cachep:
12361217 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
12371218 out_free_hashinfo2:
12381219 inet_hashinfo2_free_mod(&dccp_hashinfo);
12391220 out_fail:
12401221 dccp_hashinfo.bhash = NULL;
1241− dccp_hashinfo.bhash2 = NULL;
12421222 dccp_hashinfo.ehash = NULL;
12431223 dccp_hashinfo.bind_bucket_cachep = NULL;
1244− dccp_hashinfo.bind2_bucket_cachep = NULL;
12451224 return rc;
12461225 }
12471226
12481227 static void __exit dccp_fini(void)
12491228 {
1250− int bhash_order = get_order(dccp_hashinfo.bhash_size *
1251− sizeof(struct inet_bind_hashbucket));
1252−
12531229 ccid_cleanup_builtins();
12541230 dccp_mib_exit();
1255− free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
1256− free_pages((unsigned long)dccp_hashinfo.bhash2, bhash_order);
1231+ free_pages((unsigned long)dccp_hashinfo.bhash,
1232+ get_order(dccp_hashinfo.bhash_size *
1233+ sizeof(struct inet_bind_hashbucket)));
12571234 free_pages((unsigned long)dccp_hashinfo.ehash,
12581235 get_order((dccp_hashinfo.ehash_mask + 1) *
12591236 sizeof(struct inet_ehash_bucket)));
net/ipv4/inet_connection_sock.c+64−183
@@ -117,32 +117,6 @@ bool inet_rcv_saddr_any(const struct sock *sk) · 116 unmodified lines
117117 return !sk->sk_rcv_saddr;
118118 }
119119
120−static bool use_bhash2_on_bind(const struct sock *sk)
121−{
122−#if IS_ENABLED(CONFIG_IPV6)
123− int addr_type;
124−
125− if (sk->sk_family == AF_INET6) {
126− addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
127− return addr_type != IPV6_ADDR_ANY &&
128− addr_type != IPV6_ADDR_MAPPED;
129− }
130−#endif
131− return sk->sk_rcv_saddr != htonl(INADDR_ANY);
132−}
133−
134−static u32 get_bhash2_nulladdr_hash(const struct sock *sk, struct net *net,
135− int port)
136−{
137−#if IS_ENABLED(CONFIG_IPV6)
138− struct in6_addr nulladdr = {};
139−
140− if (sk->sk_family == AF_INET6)
141− return ipv6_portaddr_hash(net, &nulladdr, port);
142−#endif
143− return ipv4_portaddr_hash(net, 0, port);
144−}
145−
146120 void inet_get_local_port_range(struct net *net, int *low, int *high)
147121 {
148122 unsigned int seq;
@@ -156,71 +130,16 @@ void inet_get_local_port_range(struct net *net, int *low, int *high) · 7 unmodified lines
156130 }
157131 EXPORT_SYMBOL(inet_get_local_port_range);
158132
159−static bool bind_conflict_exist(const struct sock *sk, struct sock *sk2,
160− kuid_t sk_uid, bool relax,
161− bool reuseport_cb_ok, bool reuseport_ok)
162−{
163− int bound_dev_if2;
164−
165− if (sk == sk2)
166− return false;
167−
168− bound_dev_if2 = READ_ONCE(sk2->sk_bound_dev_if);
169−
170− if (!sk->sk_bound_dev_if || !bound_dev_if2 ||
171− sk->sk_bound_dev_if == bound_dev_if2) {
172− if (sk->sk_reuse && sk2->sk_reuse &&
173− sk2->sk_state != TCP_LISTEN) {
174− if (!relax || (!reuseport_ok && sk->sk_reuseport &&
175− sk2->sk_reuseport && reuseport_cb_ok &&
176− (sk2->sk_state == TCP_TIME_WAIT ||
177− uid_eq(sk_uid, sock_i_uid(sk2)))))
178− return true;
179− } else if (!reuseport_ok || !sk->sk_reuseport ||
180− !sk2->sk_reuseport || !reuseport_cb_ok ||
181− (sk2->sk_state != TCP_TIME_WAIT &&
182− !uid_eq(sk_uid, sock_i_uid(sk2)))) {
183− return true;
184− }
185− }
186− return false;
187−}
188−
189−static bool check_bhash2_conflict(const struct sock *sk,
190− struct inet_bind2_bucket *tb2, kuid_t sk_uid,
191− bool relax, bool reuseport_cb_ok,
192− bool reuseport_ok)
193−{
194− struct sock *sk2;
195−
196− sk_for_each_bound_bhash2(sk2, &tb2->owners) {
197− if (sk->sk_family == AF_INET && ipv6_only_sock(sk2))
198− continue;
199−
200− if (bind_conflict_exist(sk, sk2, sk_uid, relax,
201− reuseport_cb_ok, reuseport_ok))
202− return true;
203− }
204− return false;
205−}
206−
207−/* This should be called only when the corresponding inet_bind_bucket spinlock
208− * is held
209− */
210−static int inet_csk_bind_conflict(const struct sock *sk, int port,
211− struct inet_bind_bucket *tb,
212− struct inet_bind2_bucket *tb2, /* may be null */
133+static int inet_csk_bind_conflict(const struct sock *sk,
134+ const struct inet_bind_bucket *tb,
213135 bool relax, bool reuseport_ok)
214136 {
215− struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo;
216− kuid_t uid = sock_i_uid((struct sock *)sk);
217− struct sock_reuseport *reuseport_cb;
218− struct inet_bind2_hashbucket *head2;
219− bool reuseport_cb_ok;
220137 struct sock *sk2;
221− struct net *net;
222− int l3mdev;
223− u32 hash;
138+ bool reuseport_cb_ok;
139+ bool reuse = sk->sk_reuse;
140+ bool reuseport = !!sk->sk_reuseport;
141+ struct sock_reuseport *reuseport_cb;
142+ kuid_t uid = sock_i_uid((struct sock *)sk);
224143
225144 rcu_read_lock();
226145 reuseport_cb = rcu_dereference(sk->sk_reuseport_cb);
@@ -231,42 +150,40 @@ static int inet_csk_bind_conflict(const struct sock *sk, int port, · 4 unmodified lines
231150 /*
232151 * Unlike other sk lookup places we do not check
233152 * for sk_net here, since _all_ the socks listed
234− * in tb->owners and tb2->owners list belong
235− * to the same net
153+ * in tb->owners list belong to the same net - the
154+ * one this bucket belongs to.
236155 */
237156
238− if (!use_bhash2_on_bind(sk)) {
239− sk_for_each_bound(sk2, &tb->owners)
240− if (bind_conflict_exist(sk, sk2, uid, relax,
241− reuseport_cb_ok, reuseport_ok) &&
242− inet_rcv_saddr_equal(sk, sk2, true))
243− return true;
157+ sk_for_each_bound(sk2, &tb->owners) {
158+ int bound_dev_if2;
244159
245− return false;
160+ if (sk == sk2)
161+ continue;
162+ bound_dev_if2 = READ_ONCE(sk2->sk_bound_dev_if);
163+ if ((!sk->sk_bound_dev_if ||
164+ !bound_dev_if2 ||
165+ sk->sk_bound_dev_if == bound_dev_if2)) {
166+ if (reuse && sk2->sk_reuse &&
167+ sk2->sk_state != TCP_LISTEN) {
168+ if ((!relax ||
169+ (!reuseport_ok &&
170+ reuseport && sk2->sk_reuseport &&
171+ reuseport_cb_ok &&
172+ (sk2->sk_state == TCP_TIME_WAIT ||
173+ uid_eq(uid, sock_i_uid(sk2))))) &&
174+ inet_rcv_saddr_equal(sk, sk2, true))
175+ break;
176+ } else if (!reuseport_ok ||
177+ !reuseport || !sk2->sk_reuseport ||
178+ !reuseport_cb_ok ||
179+ (sk2->sk_state != TCP_TIME_WAIT &&
180+ !uid_eq(uid, sock_i_uid(sk2)))) {
181+ if (inet_rcv_saddr_equal(sk, sk2, true))
182+ break;
183+ }
184+ }
246185 }
247−
248− if (tb2 && check_bhash2_conflict(sk, tb2, uid, relax, reuseport_cb_ok,
249− reuseport_ok))
250− return true;
251−
252− net = sock_net(sk);
253−
254− /* check there's no conflict with an existing IPV6_ADDR_ANY (if ipv6) or
255− * INADDR_ANY (if ipv4) socket.
256− */
257− hash = get_bhash2_nulladdr_hash(sk, net, port);
258− head2 = &hinfo->bhash2[hash & (hinfo->bhash_size - 1)];
259−
260− l3mdev = inet_sk_bound_l3mdev(sk);
261− inet_bind_bucket_for_each(tb2, &head2->chain)
262− if (check_bind2_bucket_match_nulladdr(tb2, net, port, l3mdev, sk))
263− break;
264−
265− if (tb2 && check_bhash2_conflict(sk, tb2, uid, relax, reuseport_cb_ok,
266− reuseport_ok))
267− return true;
268−
269− return false;
186+ return sk2 != NULL;
270187 }
271188
272189 /*
@@ -274,20 +191,16 @@ static int inet_csk_bind_conflict(const struct sock *sk, int port, · 1 unmodified line
274191 * inet_bind_hashbucket lock held.
275192 */
276193 static struct inet_bind_hashbucket *
277−inet_csk_find_open_port(struct sock *sk, struct inet_bind_bucket **tb_ret,
278− struct inet_bind2_bucket **tb2_ret,
279− struct inet_bind2_hashbucket **head2_ret, int *port_ret)
194+inet_csk_find_open_port(struct sock *sk, struct inet_bind_bucket **tb_ret, int *port_ret)
280195 {
281196 struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo;
282− struct inet_bind2_hashbucket *head2;
197+ int port = 0;
283198 struct inet_bind_hashbucket *head;
284199 struct net *net = sock_net(sk);
200+ bool relax = false;
285201 int i, low, high, attempt_half;
286− struct inet_bind2_bucket *tb2;
287202 struct inet_bind_bucket *tb;
288203 u32 remaining, offset;
289− bool relax = false;
290− int port = 0;
291204 int l3mdev;
292205
293206 l3mdev = inet_sk_bound_l3mdev(sk);
@@ -326,12 +239,10 @@ other_parity_scan: · 32 unmodified lines
326239 head = &hinfo->bhash[inet_bhashfn(net, port,
327240 hinfo->bhash_size)];
328241 spin_lock_bh(&head->lock);
329− tb2 = inet_bind2_bucket_find(hinfo, net, port, l3mdev, sk,
330− &head2);
331242 inet_bind_bucket_for_each(tb, &head->chain)
332− if (check_bind_bucket_match(tb, net, port, l3mdev)) {
333− if (!inet_csk_bind_conflict(sk, port, tb, tb2,
334− relax, false))
243+ if (net_eq(ib_net(tb), net) && tb->l3mdev == l3mdev &&
244+ tb->port == port) {
245+ if (!inet_csk_bind_conflict(sk, tb, relax, false))
335246 goto success;
336247 goto next_port;
337248 }
@@ -361,8 +272,6 @@ next_port: · 23 unmodified lines
361272 success:
362273 *port_ret = port;
363274 *tb_ret = tb;
364− *tb2_ret = tb2;
365− *head2_ret = head2;
366275 return head;
367276 }
368277
@@ -458,81 +367,54 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum) · 89 unmodified lines
458367 {
459368 bool reuse = sk->sk_reuse && sk->sk_state != TCP_LISTEN;
460369 struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo;
461− bool bhash_created = false, bhash2_created = false;
462− struct inet_bind2_bucket *tb2 = NULL;
463− struct inet_bind2_hashbucket *head2;
464− struct inet_bind_bucket *tb = NULL;
370+ int ret = 1, port = snum;
465371 struct inet_bind_hashbucket *head;
466372 struct net *net = sock_net(sk);
467− int ret = 1, port = snum;
468− bool found_port = false;
373+ struct inet_bind_bucket *tb = NULL;
469374 int l3mdev;
470375
471376 l3mdev = inet_sk_bound_l3mdev(sk);
472377
473378 if (!port) {
474− head = inet_csk_find_open_port(sk, &tb, &tb2, &head2, &port);
379+ head = inet_csk_find_open_port(sk, &tb, &port);
475380 if (!head)
476381 return ret;
477− if (tb && tb2)
478− goto success;
479− found_port = true;
480− } else {
481− head = &hinfo->bhash[inet_bhashfn(net, port,
482− hinfo->bhash_size)];
483− spin_lock_bh(&head->lock);
484− inet_bind_bucket_for_each(tb, &head->chain)
485− if (check_bind_bucket_match(tb, net, port, l3mdev))
486− break;
487−
488− tb2 = inet_bind2_bucket_find(hinfo, net, port, l3mdev, sk,
489− &head2);
490− }
491−
492− if (!tb) {
493− tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, net,
494− head, port, l3mdev);
495382 if (!tb)
496− goto fail_unlock;
497− bhash_created = true;
498− }
499−
500− if (!tb2) {
501− tb2 = inet_bind2_bucket_create(hinfo->bind2_bucket_cachep,
502− net, head2, port, l3mdev, sk);
503− if (!tb2)
504− goto fail_unlock;
505− bhash2_created = true;
383+ goto tb_not_found;
384+ goto success;
506385 }
507−
508− /* If we had to find an open port, we already checked for conflicts */
509− if (!found_port && !hlist_empty(&tb->owners)) {
386+ head = &hinfo->bhash[inet_bhashfn(net, port,
387+ hinfo->bhash_size)];
388+ spin_lock_bh(&head->lock);
389+ inet_bind_bucket_for_each(tb, &head->chain)
390+ if (net_eq(ib_net(tb), net) && tb->l3mdev == l3mdev &&
391+ tb->port == port)
392+ goto tb_found;
393+tb_not_found:
394+ tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep,
395+ net, head, port, l3mdev);
396+ if (!tb)
397+ goto fail_unlock;
398+tb_found:
399+ if (!hlist_empty(&tb->owners)) {
510400 if (sk->sk_reuse == SK_FORCE_REUSE)
511401 goto success;
512402
513403 if ((tb->fastreuse > 0 && reuse) ||
514404 sk_reuseport_match(tb, sk))
515405 goto success;
516− if (inet_csk_bind_conflict(sk, port, tb, tb2, true, true))
406+ if (inet_csk_bind_conflict(sk, tb, true, true))
517407 goto fail_unlock;
518408 }
519409 success:
520410 inet_csk_update_fastreuse(tb, sk);
521411
522412 if (!inet_csk(sk)->icsk_bind_hash)
523− inet_bind_hash(sk, tb, tb2, port);
413+ inet_bind_hash(sk, tb, port);
524414 WARN_ON(inet_csk(sk)->icsk_bind_hash != tb);
525− WARN_ON(inet_csk(sk)->icsk_bind2_hash != tb2);
526415 ret = 0;
527416
528417 fail_unlock:
529− if (ret) {
530− if (bhash_created)
531− inet_bind_bucket_destroy(hinfo->bind_bucket_cachep, tb);
532− if (bhash2_created)
533− inet_bind2_bucket_destroy(hinfo->bind2_bucket_cachep,
534− tb2);
535− }
536418 spin_unlock_bh(&head->lock);
537419 return ret;
538420 }
@@ -1079,7 +961,6 @@ struct sock *inet_csk_clone_lock(const struct sock *sk, · 540 unmodified lines
1079961
1080962 inet_sk_set_state(newsk, TCP_SYN_RECV);
1081963 newicsk->icsk_bind_hash = NULL;
1082− newicsk->icsk_bind2_hash = NULL;
1083964
1084965 inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port;
1085966 inet_sk(newsk)->inet_num = inet_rsk(req)->ir_num;
net/ipv4/inet_hashtables.c+11−182
@@ -81,41 +81,6 @@ struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep, · 80 unmodified lines
8181 return tb;
8282 }
8383
84−struct inet_bind2_bucket *inet_bind2_bucket_create(struct kmem_cache *cachep,
85− struct net *net,
86− struct inet_bind2_hashbucket *head,
87− const unsigned short port,
88− int l3mdev,
89− const struct sock *sk)
90−{
91− struct inet_bind2_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC);
92−
93− if (tb) {
94− write_pnet(&tb->ib_net, net);
95− tb->l3mdev = l3mdev;
96− tb->port = port;
97−#if IS_ENABLED(CONFIG_IPV6)
98− if (sk->sk_family == AF_INET6)
99− tb->v6_rcv_saddr = sk->sk_v6_rcv_saddr;
100− else
101−#endif
102− tb->rcv_saddr = sk->sk_rcv_saddr;
103− INIT_HLIST_HEAD(&tb->owners);
104− hlist_add_head(&tb->node, &head->chain);
105− }
106− return tb;
107−}
108−
109−static bool bind2_bucket_addr_match(struct inet_bind2_bucket *tb2, struct sock *sk)
110−{
111−#if IS_ENABLED(CONFIG_IPV6)
112− if (sk->sk_family == AF_INET6)
113− return ipv6_addr_equal(&tb2->v6_rcv_saddr,
114− &sk->sk_v6_rcv_saddr);
115−#endif
116− return tb2->rcv_saddr == sk->sk_rcv_saddr;
117−}
118−
11984 /*
12085 * Caller must hold hashbucket lock for this tb with local BH disabled
12186 */
@@ -127,25 +92,12 @@ void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket · 5 unmodified lines
12792 }
12893 }
12994
130−/* Caller must hold the lock for the corresponding hashbucket in the bhash table
131− * with local BH disabled
132− */
133−void inet_bind2_bucket_destroy(struct kmem_cache *cachep, struct inet_bind2_bucket *tb)
134−{
135− if (hlist_empty(&tb->owners)) {
136− __hlist_del(&tb->node);
137− kmem_cache_free(cachep, tb);
138− }
139−}
140−
14195 void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb,
142− struct inet_bind2_bucket *tb2, const unsigned short snum)
96+ const unsigned short snum)
14397 {
14498 inet_sk(sk)->inet_num = snum;
14599 sk_add_bind_node(sk, &tb->owners);
146100 inet_csk(sk)->icsk_bind_hash = tb;
147− sk_add_bind2_node(sk, &tb2->owners);
148− inet_csk(sk)->icsk_bind2_hash = tb2;
149101 }
150102
151103 /*
@@ -157,7 +109,6 @@ static void __inet_put_port(struct sock *sk) · 5 unmodified lines
157109 const int bhash = inet_bhashfn(sock_net(sk), inet_sk(sk)->inet_num,
158110 hashinfo->bhash_size);
159111 struct inet_bind_hashbucket *head = &hashinfo->bhash[bhash];
160− struct inet_bind2_bucket *tb2;
161112 struct inet_bind_bucket *tb;
162113
163114 spin_lock(&head->lock);
@@ -166,13 +117,6 @@ static void __inet_put_port(struct sock *sk) · 2 unmodified lines
166117 inet_csk(sk)->icsk_bind_hash = NULL;
167118 inet_sk(sk)->inet_num = 0;
168119 inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb);
169−
170− if (inet_csk(sk)->icsk_bind2_hash) {
171− tb2 = inet_csk(sk)->icsk_bind2_hash;
172− __sk_del_bind2_node(sk);
173− inet_csk(sk)->icsk_bind2_hash = NULL;
174− inet_bind2_bucket_destroy(hashinfo->bind2_bucket_cachep, tb2);
175− }
176120 spin_unlock(&head->lock);
177121 }
178122
@@ -189,19 +133,14 @@ int __inet_inherit_port(const struct sock *sk, struct sock *child) · 10 unmodified lines
189133 struct inet_hashinfo *table = sk->sk_prot->h.hashinfo;
190134 unsigned short port = inet_sk(child)->inet_num;
191135 const int bhash = inet_bhashfn(sock_net(sk), port,
192− table->bhash_size);
136+ table->bhash_size);
193137 struct inet_bind_hashbucket *head = &table->bhash[bhash];
194− struct inet_bind2_hashbucket *head_bhash2;
195− bool created_inet_bind_bucket = false;
196− struct net *net = sock_net(sk);
197− struct inet_bind2_bucket *tb2;
198138 struct inet_bind_bucket *tb;
199139 int l3mdev;
200140
201141 spin_lock(&head->lock);
202142 tb = inet_csk(sk)->icsk_bind_hash;
203− tb2 = inet_csk(sk)->icsk_bind2_hash;
204− if (unlikely(!tb || !tb2)) {
143+ if (unlikely(!tb)) {
205144 spin_unlock(&head->lock);
206145 return -ENOENT;
207146 }
@@ -214,45 +153,25 @@ int __inet_inherit_port(const struct sock *sk, struct sock *child) · 6 unmodified lines
214153 * as that of the child socket. We have to look up or
215154 * create a new bind bucket for the child here. */
216155 inet_bind_bucket_for_each(tb, &head->chain) {
217− if (check_bind_bucket_match(tb, net, port, l3mdev))
156+ if (net_eq(ib_net(tb), sock_net(sk)) &&
157+ tb->l3mdev == l3mdev && tb->port == port)
218158 break;
219159 }
220160 if (!tb) {
221161 tb = inet_bind_bucket_create(table->bind_bucket_cachep,
222− net, head, port, l3mdev);
162+ sock_net(sk), head, port,
163+ l3mdev);
223164 if (!tb) {
224165 spin_unlock(&head->lock);
225166 return -ENOMEM;
226167 }
227− created_inet_bind_bucket = true;
228168 }
229169 inet_csk_update_fastreuse(tb, child);
230−
231− goto bhash2_find;
232− } else if (!bind2_bucket_addr_match(tb2, child)) {
233− l3mdev = inet_sk_bound_l3mdev(sk);
234−
235−bhash2_find:
236− tb2 = inet_bind2_bucket_find(table, net, port, l3mdev, child,
237− &head_bhash2);
238− if (!tb2) {
239− tb2 = inet_bind2_bucket_create(table->bind2_bucket_cachep,
240− net, head_bhash2, port,
241− l3mdev, child);
242− if (!tb2)
243− goto error;
244− }
245170 }
246− inet_bind_hash(child, tb, tb2, port);
171+ inet_bind_hash(child, tb, port);
247172 spin_unlock(&head->lock);
248173
249174 return 0;
250−
251−error:
252− if (created_inet_bind_bucket)
253− inet_bind_bucket_destroy(table->bind_bucket_cachep, tb);
254− spin_unlock(&head->lock);
255− return -ENOMEM;
256175 }
257176 EXPORT_SYMBOL_GPL(__inet_inherit_port);
258177
@@ -756,76 +675,6 @@ void inet_unhash(struct sock *sk) · 497 unmodified lines
756675 }
757676 EXPORT_SYMBOL_GPL(inet_unhash);
758677
759−static bool check_bind2_bucket_match(struct inet_bind2_bucket *tb,
760− struct net *net, unsigned short port,
761− int l3mdev, struct sock *sk)
762−{
763−#if IS_ENABLED(CONFIG_IPV6)
764− if (sk->sk_family == AF_INET6)
765− return net_eq(ib2_net(tb), net) && tb->port == port &&
766− tb->l3mdev == l3mdev &&
767− ipv6_addr_equal(&tb->v6_rcv_saddr, &sk->sk_v6_rcv_saddr);
768− else
769−#endif
770− return net_eq(ib2_net(tb), net) && tb->port == port &&
771− tb->l3mdev == l3mdev && tb->rcv_saddr == sk->sk_rcv_saddr;
772−}
773−
774−bool check_bind2_bucket_match_nulladdr(struct inet_bind2_bucket *tb,
775− struct net *net, const unsigned short port,
776− int l3mdev, const struct sock *sk)
777−{
778−#if IS_ENABLED(CONFIG_IPV6)
779− struct in6_addr nulladdr = {};
780−
781− if (sk->sk_family == AF_INET6)
782− return net_eq(ib2_net(tb), net) && tb->port == port &&
783− tb->l3mdev == l3mdev &&
784− ipv6_addr_equal(&tb->v6_rcv_saddr, &nulladdr);
785− else
786−#endif
787− return net_eq(ib2_net(tb), net) && tb->port == port &&
788− tb->l3mdev == l3mdev && tb->rcv_saddr == 0;
789−}
790−
791−static struct inet_bind2_hashbucket *
792−inet_bhashfn_portaddr(struct inet_hashinfo *hinfo, const struct sock *sk,
793− const struct net *net, unsigned short port)
794−{
795− u32 hash;
796−
797−#if IS_ENABLED(CONFIG_IPV6)
798− if (sk->sk_family == AF_INET6)
799− hash = ipv6_portaddr_hash(net, &sk->sk_v6_rcv_saddr, port);
800− else
801−#endif
802− hash = ipv4_portaddr_hash(net, sk->sk_rcv_saddr, port);
803− return &hinfo->bhash2[hash & (hinfo->bhash_size - 1)];
804−}
805−
806−/* This should only be called when the spinlock for the socket's corresponding
807− * bind_hashbucket is held
808− */
809−struct inet_bind2_bucket *
810−inet_bind2_bucket_find(struct inet_hashinfo *hinfo, struct net *net,
811− const unsigned short port, int l3mdev, struct sock *sk,
812− struct inet_bind2_hashbucket **head)
813−{
814− struct inet_bind2_bucket *bhash2 = NULL;
815− struct inet_bind2_hashbucket *h;
816−
817− h = inet_bhashfn_portaddr(hinfo, sk, net, port);
818− inet_bind_bucket_for_each(bhash2, &h->chain) {
819− if (check_bind2_bucket_match(bhash2, net, port, l3mdev, sk))
820− break;
821− }
822−
823− if (head)
824− *head = h;
825−
826− return bhash2;
827−}
828−
829678 /* RFC 6056 3.3.4. Algorithm 4: Double-Hash Port Selection Algorithm
830679 * Note that we use 32bit integers (vs RFC 'short integers')
831680 * because 2^16 is not a multiple of num_ephemeral and this
@@ -846,13 +695,10 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, · 14 unmodified lines
846695 {
847696 struct inet_hashinfo *hinfo = death_row->hashinfo;
848697 struct inet_timewait_sock *tw = NULL;
849− struct inet_bind2_hashbucket *head2;
850698 struct inet_bind_hashbucket *head;
851699 int port = inet_sk(sk)->inet_num;
852700 struct net *net = sock_net(sk);
853− struct inet_bind2_bucket *tb2;
854701 struct inet_bind_bucket *tb;
855− bool tb_created = false;
856702 u32 remaining, offset;
857703 int ret, i, low, high;
858704 int l3mdev;
@@ -909,7 +755,8 @@ other_parity_scan: · 50 unmodified lines
909755 * the established check is already unique enough.
910756 */
911757 inet_bind_bucket_for_each(tb, &head->chain) {
912− if (check_bind_bucket_match(tb, net, port, l3mdev)) {
758+ if (net_eq(ib_net(tb), net) && tb->l3mdev == l3mdev &&
759+ tb->port == port) {
913760 if (tb->fastreuse >= 0 ||
914761 tb->fastreuseport >= 0)
915762 goto next_port;
@@ -927,7 +774,6 @@ other_parity_scan: · 11 unmodified lines
927774 spin_unlock_bh(&head->lock);
928775 return -ENOMEM;
929776 }
930− tb_created = true;
931777 tb->fastreuse = -1;
932778 tb->fastreuseport = -1;
933779 goto ok;
@@ -943,17 +789,6 @@ next_port: · 9 unmodified lines
943789 return -EADDRNOTAVAIL;
944790
945791 ok:
946− /* Find the corresponding tb2 bucket since we need to
947− * add the socket to the bhash2 table as well
948− */
949− tb2 = inet_bind2_bucket_find(hinfo, net, port, l3mdev, sk, &head2);
950− if (!tb2) {
951− tb2 = inet_bind2_bucket_create(hinfo->bind2_bucket_cachep, net,
952− head2, port, l3mdev, sk);
953− if (!tb2)
954− goto error;
955− }
956−
957792 /* Here we want to add a little bit of randomness to the next source
958793 * port that will be chosen. We use a max() with a random here so that
959794 * on low contention the randomness is maximal and on high contention
@@ -963,7 +798,7 @@ ok: · 3 unmodified lines
963798 WRITE_ONCE(table_perturb[index], READ_ONCE(table_perturb[index]) + i + 2);
964799
965800 /* Head lock still held and bh's disabled */
966− inet_bind_hash(sk, tb, tb2, port);
801+ inet_bind_hash(sk, tb, port);
967802 if (sk_unhashed(sk)) {
968803 inet_sk(sk)->inet_sport = htons(port);
969804 inet_ehash_nolisten(sk, (struct sock *)tw, NULL);
@@ -975,12 +810,6 @@ ok: · 5 unmodified lines
975810 inet_twsk_deschedule_put(tw);
976811 local_bh_enable();
977812 return 0;
978−
979−error:
980− if (tb_created)
981− inet_bind_bucket_destroy(hinfo->bind_bucket_cachep, tb);
982− spin_unlock_bh(&head->lock);
983− return -ENOMEM;
984813 }
985814
986815 /*
net/ipv4/tcp.c+2−12
@@ -4604,12 +4604,6 @@ void __init tcp_init(void) · 4603 unmodified lines
46044604 SLAB_HWCACHE_ALIGN | SLAB_PANIC |
46054605 SLAB_ACCOUNT,
46064606 NULL);
4607− tcp_hashinfo.bind2_bucket_cachep =
4608− kmem_cache_create("tcp_bind2_bucket",
4609− sizeof(struct inet_bind2_bucket), 0,
4610− SLAB_HWCACHE_ALIGN | SLAB_PANIC |
4611− SLAB_ACCOUNT,
4612− NULL);
46134607
46144608 /* Size and allocate the main established and bind bucket
46154609 * hash tables.
@@ -4632,9 +4626,8 @@ void __init tcp_init(void) · 16 unmodified lines
46324626 if (inet_ehash_locks_alloc(&tcp_hashinfo))
46334627 panic("TCP: failed to alloc ehash_locks");
46344628 tcp_hashinfo.bhash =
4635− alloc_large_system_hash("TCP bind bhash tables",
4636− sizeof(struct inet_bind_hashbucket) +
4637− sizeof(struct inet_bind2_hashbucket),
4629+ alloc_large_system_hash("TCP bind",
4630+ sizeof(struct inet_bind_hashbucket),
46384631 tcp_hashinfo.ehash_mask + 1,
46394632 17, /* one slot per 128 KB of memory */
46404633 0,
@@ -4643,12 +4636,9 @@ void __init tcp_init(void) · 2 unmodified lines
46434636 0,
46444637 64 * 1024);
46454638 tcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size;
4646− tcp_hashinfo.bhash2 =
4647− (struct inet_bind2_hashbucket *)(tcp_hashinfo.bhash + tcp_hashinfo.bhash_size);
46484639 for (i = 0; i < tcp_hashinfo.bhash_size; i++) {
46494640 spin_lock_init(&tcp_hashinfo.bhash[i].lock);
46504641 INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain);
4651− INIT_HLIST_HEAD(&tcp_hashinfo.bhash2[i].chain);
46524642 }
46534643
46544644
tools/testing/selftests/net/.gitignore+0−1
@@ -37,4 +37,3 @@ gro · 36 unmodified lines
3737 ioam6_parser
3838 toeplitz
3939 cmsg_sender
40−bind_bhash_test
tools/testing/selftests/net/Makefile+0−2
@@ -59,7 +59,6 @@ TEST_GEN_FILES += toeplitz · 58 unmodified lines
5959 TEST_GEN_FILES += cmsg_sender
6060 TEST_GEN_FILES += stress_reuseport_listen
6161 TEST_PROGS += test_vxlan_vnifiltering.sh
62−TEST_GEN_FILES += bind_bhash_test
6362
6463 TEST_FILES := settings
6564
@@ -70,5 +69,4 @@ include bpf/Makefile · 4 unmodified lines
7069
7170 $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
7271 $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread
73−$(OUTPUT)/bind_bhash_test: LDLIBS += -lpthread
7472 $(OUTPUT)/tcp_inq: LDLIBS += -lpthread
tools/testing/selftests/net/bind_bhash_test.c+0−119
@@ -1,119 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0
2−/*
3− * This times how long it takes to bind to a port when the port already
4− * has multiple sockets in its bhash table.
5− *
6− * In the setup(), we populate the port's bhash table with
7− * MAX_THREADS * MAX_CONNECTIONS number of entries.
8− */
9−
10−#include <unistd.h>
11−#include <stdio.h>
12−#include <netdb.h>
13−#include <pthread.h>
14−
15−#define MAX_THREADS 600
16−#define MAX_CONNECTIONS 40
17−
18−static const char *bind_addr = "::1";
19−static const char *port;
20−
21−static int fd_array[MAX_THREADS][MAX_CONNECTIONS];
22−
23−static int bind_socket(int opt, const char *addr)
24−{
25− struct addrinfo *res, hint = {};
26− int sock_fd, reuse = 1, err;
27−
28− sock_fd = socket(AF_INET6, SOCK_STREAM, 0);
29− if (sock_fd < 0) {
30− perror("socket fd err");
31− return -1;
32− }
33−
34− hint.ai_family = AF_INET6;
35− hint.ai_socktype = SOCK_STREAM;
36−
37− err = getaddrinfo(addr, port, &hint, &res);
38− if (err) {
39− perror("getaddrinfo failed");
40− return -1;
41− }
42−
43− if (opt) {
44− err = setsockopt(sock_fd, SOL_SOCKET, opt, &reuse, sizeof(reuse));
45− if (err) {
46− perror("setsockopt failed");
47− return -1;
48− }
49− }
50−
51− err = bind(sock_fd, res->ai_addr, res->ai_addrlen);
52− if (err) {
53− perror("failed to bind to port");
54− return -1;
55− }
56−
57− return sock_fd;
58−}
59−
60−static void *setup(void *arg)
61−{
62− int sock_fd, i;
63− int *array = (int *)arg;
64−
65− for (i = 0; i < MAX_CONNECTIONS; i++) {
66− sock_fd = bind_socket(SO_REUSEADDR | SO_REUSEPORT, bind_addr);
67− if (sock_fd < 0)
68− return NULL;
69− array[i] = sock_fd;
70− }
71−
72− return NULL;
73−}
74−
75−int main(int argc, const char *argv[])
76−{
77− int listener_fd, sock_fd, i, j;
78− pthread_t tid[MAX_THREADS];
79− clock_t begin, end;
80−
81− if (argc != 2) {
82− printf("Usage: listener <port>\n");
83− return -1;
84− }
85−
86− port = argv[1];
87−
88− listener_fd = bind_socket(SO_REUSEADDR | SO_REUSEPORT, bind_addr);
89− if (listen(listener_fd, 100) < 0) {
90− perror("listen failed");
91− return -1;
92− }
93−
94− /* Set up threads to populate the bhash table entry for the port */
95− for (i = 0; i < MAX_THREADS; i++)
96− pthread_create(&tid[i], NULL, setup, fd_array[i]);
97−
98− for (i = 0; i < MAX_THREADS; i++)
99− pthread_join(tid[i], NULL);
100−
101− begin = clock();
102−
103− /* Bind to the same port on a different address */
104− sock_fd = bind_socket(0, "2001:0db8:0:f101::1");
105−
106− end = clock();
107−
108− printf("time spent = %f\n", (double)(end - begin) / CLOCKS_PER_SEC);
109−
110− /* clean up */
111− close(sock_fd);
112− close(listener_fd);
113− for (i = 0; i < MAX_THREADS; i++) {
114− for (j = 0; i < MAX_THREADS; i++)
115− close(fd_array[i][j]);
116− }
117−
118− return 0;
119−}