Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp813360ybi; Thu, 30 May 2019 07:10:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlhKGsxLbSeiEv5IHWWJfGDxvSTfnLQMg2JnkcH+1rjt7Nr3/Orhemdz34/tOU7VpQtwE2 X-Received: by 2002:a17:90a:e393:: with SMTP id b19mr3683704pjz.119.1559225459048; Thu, 30 May 2019 07:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559225459; cv=none; d=google.com; s=arc-20160816; b=Xq9yWhmdXoTWizsJAbvMf0YeSSltNYC8kLpE829iV8B5nameLojYvDhrrXtdB2Oqu0 oAbg38PJyIrKNY0J2lPzAKjMPwiaEbtVsKTeJf1qx06EfN9orUeq0fQ6TxQ+V981yWs5 IdroXeJNCeu+NvCxCJ9TBM6Tx8GtF6plhktmj+2d2BbFwM1dv9H+Od74N0yg1238J/WE XD7d57OcpBmvQ34sCwr8+pPNDhsusOZQmzTIvE9GEP+DvfYvg3ZGAVacYdfRfgozY3c6 EBZ07tfJ1iRsnlCFYsYKsK4SemKMlGyJALny+j03OhqN49LZRgr/Cm+5VENWNxs+Fma2 OMsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=aWRuucJLJgIU4GcG2aojEyaHY16Y2R9Nj1LFsZBAlHs=; b=iqxNQ7MczqAmVn2TL5atWixdDB3ieBLr6/iRNaPJiup+Dj6OXLemWC2xlRr8xF5jz1 dB8tG8H7UxysZkDWP2b+vKiPesHWgOJVYpcPYSKHh4hGvHpD5vmKZvqH20FH2GOJVqSG Y8ty9EvIAJ4BXKA6F9W1fgKSkc/x9DgYbtq8o2FYIiGJ3BUjHbYGkKS8mjjAbVjUVSeG jEXTX55XMi+3rkCq6se7XWbdATxVp8/SnRCIq9NWost5yzpLQwQP1ZDDbttfed+E+C7E hyUNBqCHhe0CCpTUJDsB63xN1MFxdTfjQwYM0xYrbIpFK3Wav+T7nJXDQUttIbL96/qQ tAZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f20si3371882pfn.207.2019.05.30.07.10.31; Thu, 30 May 2019 07:10:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbfE3OI7 (ORCPT + 99 others); Thu, 30 May 2019 10:08:59 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:44261 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbfE3OI7 (ORCPT ); Thu, 30 May 2019 10:08:59 -0400 X-Originating-IP: 86.206.242.253 Received: from mc-bl-xps13.lan (lfbn-tou-1-417-253.w86-206.abo.wanadoo.fr [86.206.242.253]) (Authenticated sender: maxime.chevallier@bootlin.com) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 383D21BF209; Thu, 30 May 2019 14:08:50 +0000 (UTC) From: Maxime Chevallier To: davem@davemloft.net, Pablo Neira Ayuso , Florian Fainelli , Jiri Pirko , Jakub Kicinski Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Antoine Tenart , thomas.petazzoni@bootlin.com Subject: [PATCH net] ethtool: Check for vlan etype or vlan tci when parsing flow_rule Date: Thu, 30 May 2019 16:08:40 +0200 Message-Id: <20190530140840.741-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When parsing an ethtool flow spec to build a flow_rule, the code checks if both the vlan etype and the vlan tci are specified by the user to add a FLOW_DISSECTOR_KEY_VLAN match. However, when the user only specified a vlan etype or a vlan tci, this check silently ignores these parameters. For example, the following rule : ethtool -N eth0 flow-type udp4 vlan 0x0010 action -1 loc 0 will result in no error being issued, but the equivalent rule will be created and passed to the NIC driver : ethtool -N eth0 flow-type udp4 action -1 loc 0 In the end, neither the NIC driver using the rule nor the end user have a way to know that these keys were dropped along the way, or that incorrect parameters were entered. This kind of check should be left to either the driver, or the ethtool flow spec layer. This commit makes so that ethtool parameters are forwarded as-is to the NIC driver. Since none of the users of ethtool_rx_flow_rule_create are using the VLAN dissector, I don't think this qualifies as a regression. Fixes: eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator") Signed-off-by: Maxime Chevallier --- This patch was previously sent as : "ethtool: Drop check for vlan etype and vlan tci when parsing flow_rule" Following Pablo's review, we don't drop the check anymore, hence the more fitting subject. net/core/ethtool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 4a593853cbf2..43e9add58340 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -3010,11 +3010,12 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input) const struct ethtool_flow_ext *ext_h_spec = &fs->h_ext; const struct ethtool_flow_ext *ext_m_spec = &fs->m_ext; - if (ext_m_spec->vlan_etype && - ext_m_spec->vlan_tci) { + if (ext_m_spec->vlan_etype) { match->key.vlan.vlan_tpid = ext_h_spec->vlan_etype; match->mask.vlan.vlan_tpid = ext_m_spec->vlan_etype; + } + if (ext_m_spec->vlan_tci) { match->key.vlan.vlan_id = ntohs(ext_h_spec->vlan_tci) & 0x0fff; match->mask.vlan.vlan_id = @@ -3024,7 +3025,10 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input) (ntohs(ext_h_spec->vlan_tci) & 0xe000) >> 13; match->mask.vlan.vlan_priority = (ntohs(ext_m_spec->vlan_tci) & 0xe000) >> 13; + } + if (ext_m_spec->vlan_etype || + ext_m_spec->vlan_tci) { match->dissector.used_keys |= BIT(FLOW_DISSECTOR_KEY_VLAN); match->dissector.offset[FLOW_DISSECTOR_KEY_VLAN] = -- 2.20.1