diff mbox series

[ovs-dev,v2,10/10] odp-util: Fix output for tc to be equal to kernel

Message ID 164362650513.2824752.3415995944135755088.stgit@ebuild
State Changes Requested
Headers show
Series netdev-offload-tc: Fix various tc-offload related problems | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed

Commit Message

Eelco Chaudron Jan. 31, 2022, 10:55 a.m. UTC
When the same flow is programmed in the kernel and tc, they
look different due to the way they are translated. They take
the userspace approach by always including the packet type
attribute. To make the outputs the same, show the ethernet
header when the packet type is wildcarded, and not printed.

So without the fix the kernel would show (ovs-appctl dpctl/dump-flows):

  in_port(3),eth(),eth_type(0x0800),ipv4(frag=no), packets:19, bytes:11614, used:0.001s, actions:output

Where as TC would show:

  in_port(3),eth_type(0x0800),ipv4(frag=no), packets:19, bytes:11614, used:0.001s, actions:output

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/odp-util.c  |    5 +++++
 tests/tunnel.at |    2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Roi Dayan Jan. 31, 2022, 1:34 p.m. UTC | #1
On 2022-01-31 12:55 PM, Eelco Chaudron wrote:
> When the same flow is programmed in the kernel and tc, they
> look different due to the way they are translated. They take
> the userspace approach by always including the packet type
> attribute. To make the outputs the same, show the ethernet
> header when the packet type is wildcarded, and not printed.
> 
> So without the fix the kernel would show (ovs-appctl dpctl/dump-flows):
> 
>    in_port(3),eth(),eth_type(0x0800),ipv4(frag=no), packets:19, bytes:11614, used:0.001s, actions:output
> 
> Where as TC would show:
> 
>    in_port(3),eth_type(0x0800),ipv4(frag=no), packets:19, bytes:11614, used:0.001s, actions:output
> 
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
> ---
>   lib/odp-util.c  |    5 +++++
>   tests/tunnel.at |    2 +-
>   2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index 99dd55807..cd7063046 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -4630,6 +4630,11 @@ odp_flow_format(const struct nlattr *key, size_t key_len,
>                       ds_put_char(ds, ',');
>                   }
>                   ds_put_cstr(ds, "eth()");
> +            } else if (attr_type == OVS_KEY_ATTR_PACKET_TYPE && is_wildcard) {
> +                /* See the above help text, however in the case where the
> +                 * packet type is not shown, we still need to display the
> +                 * eth() header if the packets type is wildcarded. */
> +                has_packet_type_key = false;
>               }
>               ofpbuf_clear(&ofp);
>           }
> diff --git a/tests/tunnel.at b/tests/tunnel.at
> index b8ae7caa9..fd482aa87 100644
> --- a/tests/tunnel.at
> +++ b/tests/tunnel.at
> @@ -126,7 +126,7 @@ AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
>   AT_CHECK([ovs-appctl dpctl/add-flow "tunnel(dst=1.1.1.1,src=3.3.3.200/255.255.255.0,tp_dst=123,tp_src=1,ttl=64),recirc_id(0),in_port(1),eth(),eth_type(0x0800),ipv4()" "2"])
>   
>   AT_CHECK([ovs-appctl dpctl/dump-flows | tail -1], [0], [dnl
> -tunnel(src=3.3.3.200/255.255.255.0,dst=1.1.1.1,ttl=64,tp_src=1,tp_dst=123),recirc_id(0),in_port(1),eth_type(0x0800), packets:0, bytes:0, used:never, actions:2
> +tunnel(src=3.3.3.200/255.255.255.0,dst=1.1.1.1,ttl=64,tp_src=1,tp_dst=123),recirc_id(0),in_port(1),eth(),eth_type(0x0800), packets:0, bytes:0, used:never, actions:2
>   ])
>   
>   OVS_VSWITCHD_STOP
> 

Acked-by: Roi Dayan <roid@nvidia.com>
diff mbox series

Patch

diff --git a/lib/odp-util.c b/lib/odp-util.c
index 99dd55807..cd7063046 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -4630,6 +4630,11 @@  odp_flow_format(const struct nlattr *key, size_t key_len,
                     ds_put_char(ds, ',');
                 }
                 ds_put_cstr(ds, "eth()");
+            } else if (attr_type == OVS_KEY_ATTR_PACKET_TYPE && is_wildcard) {
+                /* See the above help text, however in the case where the
+                 * packet type is not shown, we still need to display the
+                 * eth() header if the packets type is wildcarded. */
+                has_packet_type_key = false;
             }
             ofpbuf_clear(&ofp);
         }
diff --git a/tests/tunnel.at b/tests/tunnel.at
index b8ae7caa9..fd482aa87 100644
--- a/tests/tunnel.at
+++ b/tests/tunnel.at
@@ -126,7 +126,7 @@  AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
 AT_CHECK([ovs-appctl dpctl/add-flow "tunnel(dst=1.1.1.1,src=3.3.3.200/255.255.255.0,tp_dst=123,tp_src=1,ttl=64),recirc_id(0),in_port(1),eth(),eth_type(0x0800),ipv4()" "2"])
 
 AT_CHECK([ovs-appctl dpctl/dump-flows | tail -1], [0], [dnl
-tunnel(src=3.3.3.200/255.255.255.0,dst=1.1.1.1,ttl=64,tp_src=1,tp_dst=123),recirc_id(0),in_port(1),eth_type(0x0800), packets:0, bytes:0, used:never, actions:2
+tunnel(src=3.3.3.200/255.255.255.0,dst=1.1.1.1,ttl=64,tp_src=1,tp_dst=123),recirc_id(0),in_port(1),eth(),eth_type(0x0800), packets:0, bytes:0, used:never, actions:2
 ])
 
 OVS_VSWITCHD_STOP