net/bonding: fix socket id check

Message ID 20200616094637.31620-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/bonding: fix socket id check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

David Marchand June 16, 2020, 9:46 a.m. UTC
  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")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Chas Williams June 16, 2020, 10:09 a.m. UTC | #1
Acked-by: Chas Williams <chas3@att.com>

On 6/16/20 5:46 AM, David Marchand wrote:
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>   drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index b77a37ddb3..b7ffa2f2cf 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -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.

>   		socket_id = rte_socket_id();
>   
>   	element_size = sizeof(struct slow_protocol_frame) +
>
  
Ferruh Yigit July 9, 2020, 10:36 a.m. UTC | #2
On 6/16/2020 11:09 AM, Chas Williams wrote:

> On 6/16/20 5:46 AM, David Marchand wrote:
>> 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")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: David Marchand <david.marchand@redhat.com>
>
> Acked-by: Chas Williams <chas3@att.com>
>

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

>> ---
>>   drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
>> index b77a37ddb3..b7ffa2f2cf 100644
>> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
>> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
>> @@ -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.
> 
>>   		socket_id = rte_socket_id();
>>   
>>   	element_size = sizeof(struct slow_protocol_frame) +
>>
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index b77a37ddb3..b7ffa2f2cf 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -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) +