xsk: Return -EINVAL instead of -EBUSY after xsk_get_pool_from_qid() fails
Subsystems (4)
PATCH 1/1 xsk: Return -EINVAL instead of -EBUSY after xsk_get_pool_from_qid() fails
xsk_get_pool_from_qid() fails not because the device's queues are busy, but because the queue_id exceeds the current number of queues. So when it fails, it is better to return -EINVAL instead of -EBUSY.
--- net/xdp/xsk_buff_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_buff_pool.c +1 -1
@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,return -EINVAL ;if (xsk_get_pool_from_qid (netdev, queue_id)) -return -EBUSY ; +return -EINVAL ; pool->netdev = netdev; pool->queue_id = queue_id;
Signature · 1 line
2.17.1
Quoted 15 lines · Wang Hai
xsk_get_pool_from_qid()fails not because the device's queues are busy, but because thequeue_idexceeds the current number of queues. So when it fails, it is better to return-EINVALinstead of-EBUSY.Signed-off-by Wang Hai <[email protected]>--- net/xdp/xsk_buff_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/xdp/xsk_buff_pool.c +0
-0
net/xdp/xsk_buff_pool.c int xp_assign_dev(struct xsk_buff_pool *pool, · line 138
Quoted 5 lines
net/xdp/xsk_buff_pool.c +1
-1@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,return -EINVAL ;if (xsk_get_pool_from_qid (netdev, queue_id)) -return -EBUSY ; +return -EINVAL ;
I guess your intent here is to return -EINVAL only when the queue_id is larger than the number of active queues. But this patch also changes the return code when the queue id is already in use and in that case we should continue to return -EBUSY. As this function is used by a number of drivers, the easiest way to accomplish this is to introduce a test for queue_id out of bounds before this if-statement and return -EINVAL there.
Quoted 5 lines
net/xdp/xsk_buff_pool.c +0
-1pool->netdev = netdev; pool->queue_id = queue_id; --2.17.1
Quoted 18 lines · Magnus Karlsson
Quoted 17 lines · Wang Hai
xsk_get_pool_from_qid()fails not because the device's queues are busy, but because thequeue_idexceeds the current number of queues. So when it fails, it is better to return-EINVALinstead of-EBUSY.Signed-off-by Wang Hai <[email protected]>--- net/xdp/xsk_buff_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/xdp/xsk_buff_pool.c +0
-0@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,return -EINVAL ;
Quoted 11 lines
net/xdp/xsk_buff_pool.c int xp_assign_dev(struct xsk_buff_pool *pool, · line 138
Quoted 3 lines
net/xdp/xsk_buff_pool.c +1
-1if (xsk_get_pool_from_qid (netdev, queue_id)) -return -EBUSY ; +return -EINVAL ;I guess your intent here is to return
-EINVALonly when thequeue_idis larger than the number of active queues. But this patch also changes the return code when the queue id is already in use and in that case we should continue to return-EBUSY. As this function is used by a number of drivers, the easiest way to accomplish this is to introduce a test forqueue_idout of bounds before this if-statement and return-EINVALthere.
Isn't the return code ABI by now, though?
-Toke
Quoted 33 lines · Toke Høiland-Jørgensen
Quoted 18 lines · Magnus Karlsson
Quoted 17 lines · Wang Hai
xsk_get_pool_from_qid()fails not because the device's queues are busy, but because thequeue_idexceeds the current number of queues. So when it fails, it is better to return-EINVALinstead of-EBUSY.Signed-off-by Wang Hai <[email protected]>--- net/xdp/xsk_buff_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/xdp/xsk_buff_pool.c +0
-0@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,return -EINVAL ;Quoted 11 lines
net/xdp/xsk_buff_pool.c int xp_assign_dev(struct xsk_buff_pool *pool, · line 138
Quoted 3 lines
net/xdp/xsk_buff_pool.c +1
-1if (xsk_get_pool_from_qid (netdev, queue_id)) -return -EBUSY ; +return -EINVAL ;I guess your intent here is to return
-EINVALonly when thequeue_idis larger than the number of active queues. But this patch also changes the return code when the queue id is already in use and in that case we should continue to return-EBUSY. As this function is used by a number of drivers, the easiest way to accomplish this is to introduce a test forqueue_idout of bounds before this if-statement and return-EINVALthere.
Quoted 1 line
Isn't the return code ABI by now, though?
You are probably right and in that case this should not change at all. It has been returning this for quite a while too as it is nothing new. But I leave the final decision to other people on the list.
Quoted 2 lines
-Toke
Sorry, I misunderstood here, this is a faulty patch and no changes are needed here. Please ignore this patch
Quoted 17 lines · Magnus Karlsson
Quoted 16 lines · Wang Hai
xsk_get_pool_from_qid()fails not because the device's queues are busy, but because thequeue_idexceeds the current number of queues. So when it fails, it is better to return-EINVALinstead of-EBUSY.Signed-off-by Wang Hai <[email protected]>--- net/xdp/xsk_buff_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/xdp/xsk_buff_pool.c +0
-0@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,return -EINVAL ;
Quoted 5 lines
net/xdp/xsk_buff_pool.c int xp_assign_dev(struct xsk_buff_pool *pool, · line 138
Quoted 3 lines
net/xdp/xsk_buff_pool.c +1
-1if (xsk_get_pool_from_qid (netdev, queue_id)) -return -EBUSY ; +return -EINVAL ;I guess your intent here is to return
-EINVALonly when thequeue_idis larger than the number of active queues.
Yes, I just confirmed that this has been implemented in xp_assign_dev().
int xp_assign_dev()
{
...
err = xsk_reg_pool_at_qid(netdev, pool, queue_id);
if (err)
return err; //return -EINVAL;
...
}
Quoted 14 lines
But this patch also
changes the return code when the queue id is already in use and in that case we should continue to return-EBUSY. As this function is used by a number of drivers, the easiest way to accomplish this is to introduce a test forqueue_idout of bounds before this if-statement and return-EINVALthere.Quoted 5 lines
net/xdp/xsk_buff_pool.c +0
-1pool->netdev = netdev; pool->queue_id = queue_id; --2.17.1
.