Skip to contentSkip to conversation

net/bonding: fix socket id check

PATCH Applied David Marchand 3 participants 3 messages Jun 16, 2020 – Jul 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bonding: fix socket id check

Caught by code review, rte_eth_dev_socket_id() returns -1 on error. The code should behave the same, but still, do not use LCORE_ID_ANY for something that is not a lcore id.

Fixes c15c5897340d ("net/bonding: avoid allocating mempool on unknown socket")
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -1
index b77a37ddb3..b7ffa2f2cf 100644
@@ -1043,7 +1043,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev,
 	RTE_ASSERT(port->tx_ring == NULL);
 
 	socket_id = rte_eth_dev_socket_id(slave_id);
-	if (socket_id == (int)LCORE_ID_ANY)
+	if (socket_id == -1)
 		socket_id = rte_socket_id();
 
 	element_size = sizeof(struct slow_protocol_frame) +
Signature · 1 line
2.23.0
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · David Marchand

Caught by code review, rte_eth_dev_socket_id() returns -1 on error. The code should behave the same, but still, do not use LCORE_ID_ANY for something that is not a lcore id.

Fixes c15c5897340d ("net/bonding: avoid allocating mempool on unknown socket")
---
  drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_8023ad.c +0 -0
index b77a37ddb3..b7ffa2f2cf 100644

drivers/net/bonding/rte_eth_bond_8023ad.c bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, · line 1046

Quoted 5 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -1
@@ -1043,7 +1043,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev,
  	RTE_ASSERT(port->tx_ring == NULL);
 
  	socket_id = rte_eth_dev_socket_id(slave_id);
-	if (socket_id == (int)LCORE_ID_ANY)
+	if (socket_id == -1)

Testing against < 0 would probably be more future proof. But if someone decides to update rte_eth_dev_socket_id they will hopefully update callers as well.

Quoted 4 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +0 -0
  		socket_id = rte_socket_id();
 
  	element_size = sizeof(struct slow_protocol_frame) +
Applied
#2 lore raw
Quoted 5 lines · Chas Williams
Quoted 4 lines · David Marchand

Caught by code review, rte_eth_dev_socket_id() returns -1 on error. The code should behave the same, but still, do not use LCORE_ID_ANY for something that is not a lcore id.

Quoted 7 lines
Quoted 4 lines
Fixes c15c5897340d ("net/bonding: avoid allocating mempool on unknown socket")

Applied to dpdk-next-net/master, thanks.

Quoted 23 lines
Quoted 9 lines
---
  drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_8023ad.c +0 -0
index b77a37ddb3..b7ffa2f2cf 100644

drivers/net/bonding/rte_eth_bond_8023ad.c bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, · line 1046

Quoted 5 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -1
@@ -1043,7 +1043,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev,
  	RTE_ASSERT(port->tx_ring == NULL);
 
  	socket_id = rte_eth_dev_socket_id(slave_id);
-	if (socket_id == (int)LCORE_ID_ANY)
+	if (socket_id == -1)

Testing against < 0 would probably be more future proof. But if someone decides to update rte_eth_dev_socket_id they will hopefully update callers as well.

Quoted 4 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +0 -0
  		socket_id = rte_socket_id();
 
  	element_size = sizeof(struct slow_protocol_frame) +