diff mbox series

[ovs-dev,02/10] netdev-offload-tc: Set the correct VLAN_VID and VLAN_PCP masks

Message ID 164329038934.2583748.1063789923479682271.stgit@ebuild
State Superseded
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. 27, 2022, 1:33 p.m. UTC
This change will set the correct VID and PCP masks, as well as the
ethernet type mask.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/tc.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Eelco Chaudron Jan. 27, 2022, 1:59 p.m. UTC | #1
On 27 Jan 2022, at 14:33, Eelco Chaudron wrote:

> This change will set the correct VID and PCP masks, as well as the
> ethernet type mask.
>
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
> ---
>  lib/tc.c |   10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/lib/tc.c b/lib/tc.c
> index 77305a105..5e6aa638e 100644
> --- a/lib/tc.c
> +++ b/lib/tc.c
> @@ -568,16 +568,17 @@ nl_parse_flower_vlan(struct nlattr **attrs, struct tc_flower *flower)
>
>      flower->key.encap_eth_type[0] =
>          nl_attr_get_be16(attrs[TCA_FLOWER_KEY_ETH_TYPE]);
> +    flower->mask.encap_eth_type[0] = 0xffff;
>

This needs fixing to avoid sparse to nag about it.

  +    flower->mask.encap_eth_type[0] = CONSTANT_HTONS(0xffff);

>      if (attrs[TCA_FLOWER_KEY_VLAN_ID]) {
>          flower->key.vlan_id[0] =
>              nl_attr_get_u16(attrs[TCA_FLOWER_KEY_VLAN_ID]);
> -        flower->mask.vlan_id[0] = 0xffff;
> +        flower->mask.vlan_id[0] = VLAN_VID_MASK >> VLAN_VID_SHIFT;
>      }
>      if (attrs[TCA_FLOWER_KEY_VLAN_PRIO]) {
>          flower->key.vlan_prio[0] =
>              nl_attr_get_u8(attrs[TCA_FLOWER_KEY_VLAN_PRIO]);
> -        flower->mask.vlan_prio[0] = 0xff;
> +        flower->mask.vlan_prio[0] = VLAN_PCP_MASK >> VLAN_PCP_SHIFT;
>      }
>
>      if (!attrs[TCA_FLOWER_KEY_VLAN_ETH_TYPE]) {
> @@ -590,17 +591,18 @@ nl_parse_flower_vlan(struct nlattr **attrs, struct tc_flower *flower)
>      }
>
>      flower->key.encap_eth_type[1] = flower->key.encap_eth_type[0];
> +    flower->mask.encap_eth_type[1] = 0xffff;

  +    flower->mask.encap_eth_type[1] = CONSTANT_HTONS(0xffff);

>      flower->key.encap_eth_type[0] = encap_ethtype;
>
>      if (attrs[TCA_FLOWER_KEY_CVLAN_ID]) {
>          flower->key.vlan_id[1] =
>              nl_attr_get_u16(attrs[TCA_FLOWER_KEY_CVLAN_ID]);
> -        flower->mask.vlan_id[1] = 0xffff;
> +        flower->mask.vlan_id[1] = VLAN_VID_MASK >> VLAN_VID_SHIFT;
>      }
>      if (attrs[TCA_FLOWER_KEY_CVLAN_PRIO]) {
>          flower->key.vlan_prio[1] =
>              nl_attr_get_u8(attrs[TCA_FLOWER_KEY_CVLAN_PRIO]);
> -        flower->mask.vlan_prio[1] = 0xff;
> +        flower->mask.vlan_prio[1] = VLAN_PCP_MASK >> VLAN_PCP_SHIFT;
>      }
>  }
>
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

diff --git a/lib/tc.c b/lib/tc.c
index 77305a105..5e6aa638e 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -568,16 +568,17 @@  nl_parse_flower_vlan(struct nlattr **attrs, struct tc_flower *flower)
 
     flower->key.encap_eth_type[0] =
         nl_attr_get_be16(attrs[TCA_FLOWER_KEY_ETH_TYPE]);
+    flower->mask.encap_eth_type[0] = 0xffff;
 
     if (attrs[TCA_FLOWER_KEY_VLAN_ID]) {
         flower->key.vlan_id[0] =
             nl_attr_get_u16(attrs[TCA_FLOWER_KEY_VLAN_ID]);
-        flower->mask.vlan_id[0] = 0xffff;
+        flower->mask.vlan_id[0] = VLAN_VID_MASK >> VLAN_VID_SHIFT;
     }
     if (attrs[TCA_FLOWER_KEY_VLAN_PRIO]) {
         flower->key.vlan_prio[0] =
             nl_attr_get_u8(attrs[TCA_FLOWER_KEY_VLAN_PRIO]);
-        flower->mask.vlan_prio[0] = 0xff;
+        flower->mask.vlan_prio[0] = VLAN_PCP_MASK >> VLAN_PCP_SHIFT;
     }
 
     if (!attrs[TCA_FLOWER_KEY_VLAN_ETH_TYPE]) {
@@ -590,17 +591,18 @@  nl_parse_flower_vlan(struct nlattr **attrs, struct tc_flower *flower)
     }
 
     flower->key.encap_eth_type[1] = flower->key.encap_eth_type[0];
+    flower->mask.encap_eth_type[1] = 0xffff;
     flower->key.encap_eth_type[0] = encap_ethtype;
 
     if (attrs[TCA_FLOWER_KEY_CVLAN_ID]) {
         flower->key.vlan_id[1] =
             nl_attr_get_u16(attrs[TCA_FLOWER_KEY_CVLAN_ID]);
-        flower->mask.vlan_id[1] = 0xffff;
+        flower->mask.vlan_id[1] = VLAN_VID_MASK >> VLAN_VID_SHIFT;
     }
     if (attrs[TCA_FLOWER_KEY_CVLAN_PRIO]) {
         flower->key.vlan_prio[1] =
             nl_attr_get_u8(attrs[TCA_FLOWER_KEY_CVLAN_PRIO]);
-        flower->mask.vlan_prio[1] = 0xff;
+        flower->mask.vlan_prio[1] = VLAN_PCP_MASK >> VLAN_PCP_SHIFT;
     }
 }