From patchwork Mon Jan 11 18:17:48 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: 12011373 X-Patchwork-Delegate: kuba@kernel.org 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 CD39DC433DB for ; Mon, 11 Jan 2021 18:18:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 905EF22473 for ; Mon, 11 Jan 2021 18:18:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390324AbhAKSS5 (ORCPT ); Mon, 11 Jan 2021 13:18:57 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:7207 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390313AbhAKSS4 (ORCPT ); Mon, 11 Jan 2021 13:18:56 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 11 Jan 2021 10:18:15 -0800 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 11 Jan 2021 18:18:13 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Mon, 11 Jan 2021 18:18:10 +0000 From: Eran Ben Elisha To: "David S. Miller" , Jakub Kicinski CC: , Tariq Toukan , Cong Wang , Eric Dumazet , Jiri Pirko , Vladimir Oltean , Jakub Sitnicki , Guillaume Nault , Richard Cochran , Andrew Lunn , Eran Ben Elisha Subject: [PATCH net-next v3 2/2] net: flow_dissector: Parse PTP L2 packet header Date: Mon, 11 Jan 2021 20:17:48 +0200 Message-ID: <1610389068-2133-3-git-send-email-eranbe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1610389068-2133-1-git-send-email-eranbe@nvidia.com> References: <1610389068-2133-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=1610389095; bh=lObJbASHXKKjOEQYPTDuANV7rlY0GCChQO5bCNMDWcI=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Type; b=HrkAm6M03K571ys+9/hUNL3NwLKW9d0BTXTO9ieyitxXy5z2kv7wslZWsxQnUj8Xd uluKfxKnNL6CpCc4NjHrYEyjOFPin2kfg8hVBkzw0YurQQgY2t+2OwHgCrlEjABQvY S0qKG1cElJt+QNuh5znqkIS0lwiO6iptbLVpTRuY3TTXaj7SaejI+8ZdiFnPn7jQOA AkcDNT9FD9bvGyFpbxXiByuN08Xcnd9My09eJE258o/quoOrhDKudmgLs3iMfZgq77 soQWQe9mIpJb8WRn0LZkb3ldti8gEhvPtlsOnmpikUVP9uk8+I1GUrWL4/mLNl2iXh 7jQrcS6NCmU4g== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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;