Skip to content

Commit

Permalink
net: sched: flower: handle concurrent filter insertion in fl_change
Browse files Browse the repository at this point in the history
Check if user specified a handle and another filter with the same handle
was inserted concurrently. Return EAGAIN to retry filter processing (in
case it is an overwrite request).

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Buslov authored and David S. Miller committed Mar 21, 2019
1 parent 259e60f commit 9a2d938
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net/sched/cls_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,15 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
/* user specifies a handle and it doesn't exist */
err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
handle, GFP_ATOMIC);

/* Filter with specified handle was concurrently
* inserted after initial check in cls_api. This is not
* necessarily an error if NLM_F_EXCL is not set in
* message flags. Returning EAGAIN will cause cls_api to
* try to update concurrently inserted rule.
*/
if (err == -ENOSPC)
err = -EAGAIN;
} else {
handle = 1;
err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
Expand Down

0 comments on commit 9a2d938

Please sign in to comment.