From patchwork Fri Sep 8 12:06:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 13377387 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A8365381 for ; Fri, 8 Sep 2023 12:06:44 +0000 (UTC) Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A381BC5 for ; Fri, 8 Sep 2023 05:06:43 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qeaG2-00062a-2D; Fri, 08 Sep 2023 14:06:42 +0200 From: Florian Westphal To: Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au, Florian Westphal Subject: [RFC ipsec-next 2/3] flow_dissector: add ipv6 mobility header support Date: Fri, 8 Sep 2023 14:06:19 +0200 Message-ID: <20230908120628.26164-3-fw@strlen.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908120628.26164-1-fw@strlen.de> References: <20230908120628.26164-1-fw@strlen.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Needed to replace xfrm home-grown decoder with the flow dissector if we don't want to lose functionality. Alternative is to drop mobility header support and see if anyone complains. Signed-off-by: Florian Westphal --- include/net/flow_dissector.h | 5 +++++ net/core/flow_dissector.c | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h index 1a7131d6cb0e..a82b7039d755 100644 --- a/include/net/flow_dissector.h +++ b/include/net/flow_dissector.h @@ -329,6 +329,10 @@ struct flow_dissector_key_cfm { #define FLOW_DIS_CFM_MDL_MASK GENMASK(7, 5) #define FLOW_DIS_CFM_MDL_MAX 7 +struct flow_dissector_ipv6_mh { + u8 mh_type; +}; + enum flow_dissector_key_id { FLOW_DISSECTOR_KEY_CONTROL, /* struct flow_dissector_key_control */ FLOW_DISSECTOR_KEY_BASIC, /* struct flow_dissector_key_basic */ @@ -363,6 +367,7 @@ enum flow_dissector_key_id { FLOW_DISSECTOR_KEY_L2TPV3, /* struct flow_dissector_key_l2tpv3 */ FLOW_DISSECTOR_KEY_CFM, /* struct flow_dissector_key_cfm */ FLOW_DISSECTOR_KEY_IPSEC, /* struct flow_dissector_key_ipsec */ + FLOW_DISSECTOR_KEY_IPV6MH, /* struct flow_dissector_ipv6_mh */ FLOW_DISSECTOR_KEY_MAX, }; diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 89d15ceaf9af..6dcd608f8da6 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1531,6 +1531,33 @@ bool __skb_flow_dissect(const struct net *net, fdret = FLOW_DISSECT_RET_IPPROTO_AGAIN; break; } + case NEXTHDR_MOBILITY: { + struct flow_dissector_ipv6_mh *key_ipv6mh; + u8 _opthdr[3], *opthdr; + + if (proto != htons(ETH_P_IPV6)) + break; + + opthdr = __skb_header_pointer(skb, nhoff, sizeof(_opthdr), + data, hlen, &_opthdr); + if (!opthdr) { + fdret = FLOW_DISSECT_RET_OUT_BAD; + break; + } + + if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_IPV6MH)) + break; + + key_ipv6mh = skb_flow_dissector_target(flow_dissector, + FLOW_DISSECTOR_KEY_IPV6MH, + target_container); + ip_proto = opthdr[0]; + nhoff += (opthdr[1] + 1) << 3; + key_ipv6mh->mh_type = opthdr[2]; + + fdret = FLOW_DISSECT_RET_OUT_GOOD; + break; + } case NEXTHDR_FRAGMENT: { struct frag_hdr _fh, *fh;