diff mbox

[net-next,v21,4/4] openvswitch: report error on VLAN nlattr in ovs_key_from_nlattrs()

Message ID 1472762727-25844-5-git-send-email-e@erig.me
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Garver Sept. 1, 2016, 8:45 p.m. UTC
With 802.1ad support these are parsed and set upfront by
parse_vlan_from_nlattrs() before ovs_key_from_nlattrs() is ever called.
As such we should never see a VLAN attribute in ovs_key_from_nlattrs().

Signed-off-by: Eric Garver <e@erig.me>
---
 net/openvswitch/flow_netlink.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

Comments

Pravin Shelar Sept. 2, 2016, 9:42 p.m. UTC | #1
On Thu, Sep 1, 2016 at 1:45 PM, Eric Garver <e@erig.me> wrote:
> With 802.1ad support these are parsed and set upfront by
> parse_vlan_from_nlattrs() before ovs_key_from_nlattrs() is ever called.
> As such we should never see a VLAN attribute in ovs_key_from_nlattrs().
>
> Signed-off-by: Eric Garver <e@erig.me>
> ---
>  net/openvswitch/flow_netlink.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
>
> diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
> index fbe9e0e4792d..0f36aead744b 100644
> --- a/net/openvswitch/flow_netlink.c
> +++ b/net/openvswitch/flow_netlink.c
> @@ -923,20 +923,11 @@ static int ovs_key_from_nlattrs(struct net *net, struct sw_flow_match *match,
>         }
>
>         if (attrs & (1 << OVS_KEY_ATTR_VLAN)) {
> -               __be16 tci;
> -
> -               tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
> -               if (!(tci & htons(VLAN_TAG_PRESENT))) {
> -                       if (is_mask)
> -                               OVS_NLERR(log, "VLAN TCI mask does not have exact match for VLAN_TAG_PRESENT bit.");
> -                       else
> -                               OVS_NLERR(log, "VLAN TCI does not have VLAN_TAG_PRESENT bit set.");
> -
> -                       return -EINVAL;
> -               }
> -
> -               SW_FLOW_KEY_PUT(match, eth.vlan.tci, tci, is_mask);
> -               attrs &= ~(1 << OVS_KEY_ATTR_VLAN);
> +               /* VLAN attribute is always parsed before getting here since it may
> +                * occur multiple times.
> +                */
> +               OVS_NLERR(log, "VLAN attribute unexpected.");
> +               return -EINVAL;
>         }
>
Is there reason for not merging this patch with earlier patch?
Eric Garver Sept. 3, 2016, 3:59 p.m. UTC | #2
On Fri, Sep 02, 2016 at 02:42:41PM -0700, pravin shelar wrote:
> On Thu, Sep 1, 2016 at 1:45 PM, Eric Garver <e@erig.me> wrote:
> > With 802.1ad support these are parsed and set upfront by
> > parse_vlan_from_nlattrs() before ovs_key_from_nlattrs() is ever called.
> > As such we should never see a VLAN attribute in ovs_key_from_nlattrs().
> >
> > Signed-off-by: Eric Garver <e@erig.me>
> > ---
> >  net/openvswitch/flow_netlink.c | 19 +++++--------------
> >  1 file changed, 5 insertions(+), 14 deletions(-)
> >
> > diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
> > index fbe9e0e4792d..0f36aead744b 100644
> > --- a/net/openvswitch/flow_netlink.c
> > +++ b/net/openvswitch/flow_netlink.c
> > @@ -923,20 +923,11 @@ static int ovs_key_from_nlattrs(struct net *net, struct sw_flow_match *match,
> >         }
> >
> >         if (attrs & (1 << OVS_KEY_ATTR_VLAN)) {
> > -               __be16 tci;
> > -
> > -               tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
> > -               if (!(tci & htons(VLAN_TAG_PRESENT))) {
> > -                       if (is_mask)
> > -                               OVS_NLERR(log, "VLAN TCI mask does not have exact match for VLAN_TAG_PRESENT bit.");
> > -                       else
> > -                               OVS_NLERR(log, "VLAN TCI does not have VLAN_TAG_PRESENT bit set.");
> > -
> > -                       return -EINVAL;
> > -               }
> > -
> > -               SW_FLOW_KEY_PUT(match, eth.vlan.tci, tci, is_mask);
> > -               attrs &= ~(1 << OVS_KEY_ATTR_VLAN);
> > +               /* VLAN attribute is always parsed before getting here since it may
> > +                * occur multiple times.
> > +                */
> > +               OVS_NLERR(log, "VLAN attribute unexpected.");
> > +               return -EINVAL;
> >         }
> >
> Is there reason for not merging this patch with earlier patch?

Not a particularly good one. I'll merge it into patch 3.
diff mbox

Patch

diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index fbe9e0e4792d..0f36aead744b 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -923,20 +923,11 @@  static int ovs_key_from_nlattrs(struct net *net, struct sw_flow_match *match,
 	}
 
 	if (attrs & (1 << OVS_KEY_ATTR_VLAN)) {
-		__be16 tci;
-
-		tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
-		if (!(tci & htons(VLAN_TAG_PRESENT))) {
-			if (is_mask)
-				OVS_NLERR(log, "VLAN TCI mask does not have exact match for VLAN_TAG_PRESENT bit.");
-			else
-				OVS_NLERR(log, "VLAN TCI does not have VLAN_TAG_PRESENT bit set.");
-
-			return -EINVAL;
-		}
-
-		SW_FLOW_KEY_PUT(match, eth.vlan.tci, tci, is_mask);
-		attrs &= ~(1 << OVS_KEY_ATTR_VLAN);
+		/* VLAN attribute is always parsed before getting here since it may
+		 * occur multiple times.
+		 */
+		OVS_NLERR(log, "VLAN attribute unexpected.");
+		return -EINVAL;
 	}
 
 	if (attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) {