From patchwork Thu Sep 1 20:45:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Garver X-Patchwork-Id: 665014 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sQFKg59CPz9sC4 for ; Fri, 2 Sep 2016 07:11:03 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757278AbcIAVKV (ORCPT ); Thu, 1 Sep 2016 17:10:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51642 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754448AbcIAUyb (ORCPT ); Thu, 1 Sep 2016 16:54:31 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F40B98122E; Thu, 1 Sep 2016 20:45:30 +0000 (UTC) Received: from egarver.redhat.com (vpn-49-112.rdu2.redhat.com [10.10.49.112]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u81KjRMA027198; Thu, 1 Sep 2016 16:45:30 -0400 From: Eric Garver To: netdev@vger.kernel.org Cc: dev@openvswitch.org, Thomas F Herbert , Xiao Liang Subject: [PATCH net-next v21 4/4] openvswitch: report error on VLAN nlattr in ovs_key_from_nlattrs() Date: Thu, 1 Sep 2016 16:45:27 -0400 Message-Id: <1472762727-25844-5-git-send-email-e@erig.me> In-Reply-To: <1472762727-25844-1-git-send-email-e@erig.me> References: <1472762727-25844-1-git-send-email-e@erig.me> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 01 Sep 2016 20:45:31 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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; } if (attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) {