2022-07-28 16:33:00

by Mike Pattrick

[permalink] [raw]
Subject: [PATCH net-next 1/2] openvswitch: Fix double reporting of drops in dropwatch

Frames sent to userspace can be reported as dropped in
ovs_dp_process_packet, however, if they are dropped in the netlink code
then netlink_attachskb will report the same frame as dropped.

This patch checks for error codes which indicate that the frame has
already been freed.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2109946
Signed-off-by: Mike Pattrick <[email protected]>
---
net/openvswitch/datapath.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 7e8a39a35627..029f9c3e1c28 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -252,10 +252,20 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)

upcall.mru = OVS_CB(skb)->mru;
error = ovs_dp_upcall(dp, skb, key, &upcall, 0);
- if (unlikely(error))
- kfree_skb(skb);
- else
+ switch (error) {
+ case 0:
+ fallthrough;
+ case -EAGAIN:
+ fallthrough;
+ case -ERESTARTSYS:
+ fallthrough;
+ case -EINTR:
consume_skb(skb);
+ break;
+ default:
+ kfree_skb(skb);
+ break;
+ }
stats_counter = &stats->n_missed;
goto out;
}
--
2.31.1


2022-07-30 03:35:47

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH net-next 1/2] openvswitch: Fix double reporting of drops in dropwatch

On Thu, 28 Jul 2022 12:12:58 -0400 Mike Pattrick wrote:
> Frames sent to userspace can be reported as dropped in
> ovs_dp_process_packet, however, if they are dropped in the netlink code
> then netlink_attachskb will report the same frame as dropped.
>
> This patch checks for error codes which indicate that the frame has
> already been freed.
>
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2109946

Please remove the Bugzilla link, it doesn't seem to be public.
If it is then it should be a Link: tag, not a custom tag for bz.

> Signed-off-by: Mike Pattrick <[email protected]>
> ---
> net/openvswitch/datapath.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index 7e8a39a35627..029f9c3e1c28 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -252,10 +252,20 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
>
> upcall.mru = OVS_CB(skb)->mru;
> error = ovs_dp_upcall(dp, skb, key, &upcall, 0);
> - if (unlikely(error))
> - kfree_skb(skb);
> - else
> + switch (error) {
> + case 0:
> + fallthrough;
> + case -EAGAIN:
> + fallthrough;
> + case -ERESTARTSYS:
> + fallthrough;

No need to add the fallthrough;s between two case statements.

> + case -EINTR:
> consume_skb(skb);
> + break;
> + default:
> + kfree_skb(skb);
> + break;
> + }
> stats_counter = &stats->n_missed;
> goto out;
> }