From patchwork Thu Jan 7 12:38:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eran Ben Elisha X-Patchwork-Id: 358713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D144C433E0 for ; Thu, 7 Jan 2021 12:40:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D93E23358 for ; Thu, 7 Jan 2021 12:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728351AbhAGMjr (ORCPT ); Thu, 7 Jan 2021 07:39:47 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:8689 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728204AbhAGMjq (ORCPT ); Thu, 7 Jan 2021 07:39:46 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 07 Jan 2021 04:39:06 -0800 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 7 Jan 2021 12:39:05 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Thu, 7 Jan 2021 12:39:03 +0000 From: Eran Ben Elisha To: , "David S. Miller" , "Jakub Kicinski" CC: Tariq Toukan , Eran Ben Elisha Subject: [PATCH net-next 1/2] net: vlan: Add parse protocol header ops Date: Thu, 7 Jan 2021 14:38:59 +0200 Message-ID: <1610023140-20256-2-git-send-email-eranbe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1610023140-20256-1-git-send-email-eranbe@nvidia.com> References: <1610023140-20256-1-git-send-email-eranbe@nvidia.com> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1610023146; bh=tCYjgofZgw0uArsqzR5z4wwhD1tZyn0bJ13TuqGapCw=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Type; b=M5cCLNpzBARYfX0ILG8gJyj+wxieH52cGsmqgIhVRQMTDfL9Wwtpwac49wspQLzne q9tC2mESf7KXO1yHaJagU92OSLLf9H5bs5EEQxA5k3M0itLcaDAVkGqKdL+YLJgUJZ TuoTxtl9YCOTD8E2iRDBEo1cexlR7fLiMP+e1ci8wZvl05f5JUYjq3qv3To+t56k7r WJRZv5WZA/ofaylP+9SHowUzpFW1B+KZkbs0DRIvz8iiN/zdlA6OUma24PuHkPi39g +YbExv8ykS8f1BOmwHhvJXl3OI1IuVRanfETbfWcIsVr65w1QpLq+X7Ag7vUSGtDyF wzn1EHypdMTPA== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add parse protocol header ops for vlan device. Before this patch, vlan tagged packet transmitted by af_packet had skb->protocol unset. Some kernel methods (like __skb_flow_dissect()) rely on this missing information for its packet processing. Signed-off-by: Eran Ben Elisha Reviewed-by: Tariq Toukan --- net/8021q/vlan_dev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index ec8408d1638f..dc1a197792e6 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -510,9 +510,17 @@ static void vlan_dev_set_lockdep_class(struct net_device *dev) netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, NULL); } +static __be16 vlan_parse_protocol(const struct sk_buff *skb) +{ + struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data); + + return __vlan_get_protocol(skb, veth->h_vlan_proto, NULL); +} + static const struct header_ops vlan_header_ops = { .create = vlan_dev_hard_header, .parse = eth_header_parse, + .parse_protocol = vlan_parse_protocol, }; static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev, @@ -532,6 +540,7 @@ static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev static const struct header_ops vlan_passthru_header_ops = { .create = vlan_passthru_hard_header, .parse = eth_header_parse, + .parse_protocol = vlan_parse_protocol, }; static struct device_type vlan_type = { From patchwork Thu Jan 7 12:39:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eran Ben Elisha X-Patchwork-Id: 358712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C26F7C433E9 for ; Thu, 7 Jan 2021 12:40:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B2AD23370 for ; Thu, 7 Jan 2021 12:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728356AbhAGMjt (ORCPT ); Thu, 7 Jan 2021 07:39:49 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:14884 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728204AbhAGMjs (ORCPT ); Thu, 7 Jan 2021 07:39:48 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 07 Jan 2021 04:39:08 -0800 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 7 Jan 2021 12:39:08 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Thu, 7 Jan 2021 12:39:06 +0000 From: Eran Ben Elisha To: , "David S. Miller" , "Jakub Kicinski" CC: Tariq Toukan , Eran Ben Elisha Subject: [PATCH net-next 2/2] net: flow_dissector: Parse PTP L2 packet header Date: Thu, 7 Jan 2021 14:39:00 +0200 Message-ID: <1610023140-20256-3-git-send-email-eranbe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1610023140-20256-1-git-send-email-eranbe@nvidia.com> References: <1610023140-20256-1-git-send-email-eranbe@nvidia.com> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1610023148; bh=lObJbASHXKKjOEQYPTDuANV7rlY0GCChQO5bCNMDWcI=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Type; b=qXiIzSfCKaIlVmnOjMQQvlaVwVm7TLX/GiUXlvgz9pIgx/1jocBJJ4P8fTZfV1FCw yUIkNPxKbKgzqNCNrYo+C0lyIw02RROowiFAEfrVpiqO44pPKgV90B/P2ASP/pmbCs Zl5QfmdparxVVO4Mdf03wOBs6ltuEzCLNiCxXtqPh9sBS6vQ8EYyI0q5qCZQfTWueX PqPNz3xBAdk57p/1gzgV3G1LRqdXtr6PM6jYYXYCN5lHWgJ7NbNTh/uI2HOLIJgnMU F56XQPuEFPnXg0hBgXH2DCEbnARRECplweYTS4IaON2l/ZvdmEJez42S+duzCOMp33 6fivd0x5Y/UIA== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add support for parsing PTP L2 packet header. Such packet consists of an L2 header (with ethertype of ETH_P_1588), PTP header, body and an optional suffix. Signed-off-by: Eran Ben Elisha Reviewed-by: Tariq Toukan --- net/core/flow_dissector.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 6f1adba6695f..fcaa223c7cdc 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1251,6 +1252,21 @@ bool __skb_flow_dissect(const struct net *net, &proto, &nhoff, hlen, flags); break; + case htons(ETH_P_1588): { + struct ptp_header *hdr, _hdr; + + hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, + hlen, &_hdr); + if (!hdr || (hlen - nhoff) < sizeof(_hdr)) { + fdret = FLOW_DISSECT_RET_OUT_BAD; + break; + } + + nhoff += ntohs(hdr->message_length); + fdret = FLOW_DISSECT_RET_OUT_GOOD; + break; + } + default: fdret = FLOW_DISSECT_RET_OUT_BAD; break;