Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1809352ybd; Thu, 27 Jun 2019 01:54:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrzMLqaZVhe0QkXAn4STvga8f+4THTU9TLWYy6sXI6IeHRRKNOZjRG6BMP9qAQ2mXw+AaT X-Received: by 2002:a17:902:2862:: with SMTP id e89mr3359650plb.258.1561625663099; Thu, 27 Jun 2019 01:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561625663; cv=none; d=google.com; s=arc-20160816; b=w2S2CcNvm+q0vDwCvUo0oe0pipy4VMjg6wkbwUHMfpmqZsIP9/+ObMrwaaIy5DPn+t E+kaPDoZCRgPj27AqNcwjOqc+GLNyQ/Pd+GE6pUg/bCyXoM5kb9CTjVJWztzerjVHfYw S7IrwM1abln7L5rBIQOrsM3tWHBPfUEjvvQwIL/cojsbtPumUPo2sTeMDvFb4L2AugvQ lDuxO7fQ0FZ9eRoZZrq3v6Fs9t6nQ4kzuuL9OXNTg/w5q2NF94pbGYPx2quw/ykDgQJF /zp3Tk12TN6ds6/g85lK1XaOQPlfOf+bGqR3yQkmh2mnfnLSqeOMOaoVS++xDiMi1nAK h2DA== 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=/sqUEkGnaboddYCcOW+6uKPXVTfo/oQsJRlG4ZfWgKw=; b=fGzDjdfIm0dCyXeSQp2X7q1feTgeVLAs1YwfLZbES3G7XF7VKg4rOIinGd1L80XPiR 0t6KuUiGQRgaHRqTODkJ1vlRuxHf9bkZ5jIbD7KPLeZA/hQMFmkA4nmf22JMXdB5NxLP 3YNvNDiLaxai2n/fHhyMhc9uChDhNBu9Gbd5n7ofEkb2RhBdAb9X1+Dco01BzJIo38ug MK2fxScDPjWdrZHkdqJHIkht1sLrudhADWtfhZp7kgNRYQHbR1VJYKtyXqFrTM7BSrCK mPfC0jPTHGbJuI8MUoevdCdp2tRfwfCZHxOnKi/l417u1if5xnNpjZe5XCoqAJVnWVWd 7mqw== 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 m11si4336757pjk.22.2019.06.27.01.54.06; Thu, 27 Jun 2019 01:54:23 -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 S1726595AbfF0Iwb (ORCPT + 99 others); Thu, 27 Jun 2019 04:52:31 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:33327 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbfF0Iwb (ORCPT ); Thu, 27 Jun 2019 04:52:31 -0400 Received: from mc-bl-xps13.lan (lfbn-1-17395-211.w86-250.abo.wanadoo.fr [86.250.200.211]) (Authenticated sender: maxime.chevallier@bootlin.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 7CC8A200003; Thu, 27 Jun 2019 08:52:27 +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-next v2] net: ethtool: Allow parsing ETHER_FLOW types when using flow_rule Date: Thu, 27 Jun 2019 10:52:26 +0200 Message-Id: <20190627085226.7658-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_rx_flow_spec, users can specify an ethernet flow which could contain matches based on the ethernet header, such as the MAC address, the VLAN tag or the ethertype. ETHER_FLOW uses the src and dst ethernet addresses, along with the ethertype as keys. Matches based on the vlan tag are also possible, but they are specified using the special FLOW_EXT flag. Signed-off-by: Maxime Chevallier --- V2 : Add src and dst mac address parsing, as suggested by Pablo. net/core/ethtool.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 4d1011b2e24f..6288e69e94fc 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -2883,6 +2883,30 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input) match->mask.basic.n_proto = htons(0xffff); switch (fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS)) { + case ETHER_FLOW: { + const struct ethhdr *ether_spec, *ether_m_spec; + + ether_spec = &fs->h_u.ether_spec; + ether_m_spec = &fs->m_u.ether_spec; + + if (!is_zero_ether_addr(ether_m_spec->h_source)) { + ether_addr_copy(match->key.eth_addrs.src, + ether_spec->h_source); + ether_addr_copy(match->mask.eth_addrs.src, + ether_m_spec->h_source); + } + if (!is_zero_ether_addr(ether_m_spec->h_dest)) { + ether_addr_copy(match->key.eth_addrs.dst, + ether_spec->h_dest); + ether_addr_copy(match->mask.eth_addrs.dst, + ether_m_spec->h_dest); + } + if (ether_m_spec->h_proto) { + match->key.basic.n_proto = ether_spec->h_proto; + match->mask.basic.n_proto = ether_m_spec->h_proto; + } + } + break; case TCP_V4_FLOW: case UDP_V4_FLOW: { const struct ethtool_tcpip4_spec *v4_spec, *v4_m_spec; -- 2.20.1