From patchwork Wed Aug 21 21:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772056 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E7DB17108A for ; Wed, 21 Aug 2024 21:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275358; cv=none; b=iPxC//+QnRYwLRyLTfJK7s1n8rl9bnKVAafICaqZyoTxsv0BtTWMp/7NtLD2FjF3fPKg3rhb8aybcSlKzzyl95flGJPmCbKryrvMIVaSmToQCUEIv7ctSUGYASZ8MnN3kwkbelazdyJIjRDnedyxUiWJh6PBW0ovzgvAUAqJITA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275358; c=relaxed/simple; bh=eU0j3/8rJg2aPvh4RwRcGS6M4omz/kWqfL82UJkQcUI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ggep1ScALN8y8sKEdYLSD50huqI97KwtsgVYEZyMoCJECVj3eqrlFLix7BBsK7KqikqPm3SBMlBQQYA9qX7qg5Gh19O9s/Bx0ZILXoGzNWaYWuWUQN/DEGubs4sexgKCEa/2M4pADa32wGTGmavPJ7h6NcTsBcaHIh26ZAUQUv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=FgvpAfBh; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="FgvpAfBh" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-201f7fb09f6so1189935ad.2 for ; Wed, 21 Aug 2024 14:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275356; x=1724880156; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZxoeXzU4BY+HKSmSR4ce1eIiQfaMzrOqErp0TccUqeA=; b=FgvpAfBhZYLUQ1n9NGX1xd2n7KERDF68o9A3JjkJ/LYzlftAz4QIHbUAY3dRr9JQP7 v2+oxng3+0OVuyPc34/Drb9NJeg0OBSOT6dLcpI896Gagj1Bi68QXzJNzkwjzBN45fQC 6yTtXFFzVojHLUScFVsppHrR9sPGb2CPMrmHUCX603RXvnt4AjCt2csUrqF/dZHlLT1y vo2ZjKtaQwDVKzamOU7oaamwqOgC1dtkRmtHnf5NYC3454aSK8rUy+5o4zFcu1rRFzJi gUti2cazXTIzgLVZFuJHVq7b1ilqakkGwDTxtHiHbH9JhmSbThKvbqSRGCoU5MI/mllB V5AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275356; x=1724880156; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZxoeXzU4BY+HKSmSR4ce1eIiQfaMzrOqErp0TccUqeA=; b=e3NOle0CUbrT7rVliW4oUAkec3Lgj6+G+Mj/7aSANQ1E3/DeEYh9QgTTRPSW6048+S NgKXy4oq80lsEyBWd3e+lg3QthjOcNOp4gUxlIm/WernpRRVdoozzqwcm8xRFJfhd6yf 3D4vewn5Hel5yMpgNFDi5nPM4xcr1dP5sy92QqT2nu1Ie4RmNqdZvrjSBZxBBaJVuGte ZPAKB/0SBJbr/xtaehkDUCLGLF2gdRoUcCX3iwroVsBM8+T7Es6kJkKVHZIFIlr2CN00 o7d8QfjvkIEqY226ELkTKVEKyh4Aceia2Z7cqnYPn7EVIsJ2ACPPL11LdRte21ArXi2c +GaQ== X-Forwarded-Encrypted: i=1; AJvYcCWj5F3v0w5MhFlFoPNcPuzePrImEAWNa7X5bB9/qraeLRwg5yK6skMyYWXv2vtKLf1sKtj+sac=@vger.kernel.org X-Gm-Message-State: AOJu0YxgU3d7pdy3nNesGwXJ5e+GlSp18BUDqPKi5DF+xI2UbJ7gQ5Yr rWuCoKxuXjA2pFf+nCN+TfTAAU88O8jidxRyfsr3GY/VaMAlBsK6/wfsEYqEfQ== X-Google-Smtp-Source: AGHT+IGDS2edgR/8k3/nWMtFi47IwCu+9q+GtRX0j5YK581lrnp98VglON02PDAoBfhkDpoK2s5RTg== X-Received: by 2002:a17:902:ea01:b0:1fc:369b:c1dd with SMTP id d9443c01a7336-20367bf7586mr37796465ad.6.1724275356430; Wed, 21 Aug 2024 14:22:36 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:35 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 01/13] ipv6: Add udp6_lib_lookup to IPv6 stubs Date: Wed, 21 Aug 2024 14:22:00 -0700 Message-Id: <20240821212212.1795357-2-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Want to do a UDP socket lookup from flow dissector so create a stub for udp6_lib_lookup Signed-off-by: Tom Herbert --- include/net/ipv6_stubs.h | 5 +++++ net/ipv6/af_inet6.c | 1 + 2 files changed, 6 insertions(+) diff --git a/include/net/ipv6_stubs.h b/include/net/ipv6_stubs.h index 8a3465c8c2c5..fc6111fe820a 100644 --- a/include/net/ipv6_stubs.h +++ b/include/net/ipv6_stubs.h @@ -75,6 +75,11 @@ struct ipv6_stub { struct net_device *dev); int (*ip6_xmit)(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, __u32 mark, struct ipv6_txoptions *opt, int tclass, u32 priority); + struct sock *(*udp6_lib_lookup)(const struct net *net, + const struct in6_addr *saddr, __be16 sport, + const struct in6_addr *daddr, __be16 dport, + int dif, int sdif, struct udp_table *tbl, + struct sk_buff *skb); }; extern const struct ipv6_stub *ipv6_stub __read_mostly; diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 90d2c7e3f5e9..699f1e3efb91 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -1061,6 +1061,7 @@ static const struct ipv6_stub ipv6_stub_impl = { .ipv6_fragment = ip6_fragment, .ipv6_dev_find = ipv6_dev_find, .ip6_xmit = ip6_xmit, + .udp6_lib_lookup = __udp6_lib_lookup, }; static const struct ipv6_bpf_stub ipv6_bpf_stub_impl = { From patchwork Wed Aug 21 21:22:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772057 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD0C6175D4E for ; Wed, 21 Aug 2024 21:22:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275360; cv=none; b=aRG3sHy/2xTQTsiayGvisM6Ep08YOLamTTttRz3H9NYdIlBcM0phJUg9InU12Y5wFE+T3NmteFyfGZnUTOs/VEZ3mSByE5qROd3Krm/vbfgHAhLo2rYG+dLLVTw5Ip4+rquonqtyloLn/k+JQ/GZT/Lb+zvWtG+K7C02C4GKifQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275360; c=relaxed/simple; bh=CCZmy3roTcoldWMY3Np2LMkMsQ2dOSmXCqOYrD/u33c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JB8OjxsyFuewVRabU4fRZeCtXCC6Z+iFHt91CTpBVtq1gbjoy4NImm335mwLe2drkh6/RhemEwP02JhfjXJkgbyjvU1MJTY0dYJwE9msR6m/hXy1EqFS20n5UFIuvdwvs9vbGSHKJkxDTEL8WOgQZR+z10w/01Wt/Wc8qOmKi4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=SOCWuns0; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="SOCWuns0" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2021c08b95cso10080795ad.0 for ; Wed, 21 Aug 2024 14:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275358; x=1724880158; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KDdOXUn/9snQ1wK5LCIPPus5mF2WWgGtaZstma1ySpU=; b=SOCWuns0DOFk6Wrq+v8+wSbocVOpnH2zNlZIzHkPR9UodNGr4QU5DeM7ic0fPVkaQl oAsLI9j25FQjJj71mnjh1a+8LfWQmuUdNc4I/jdXCIi6sPP12BkP8Fq2uQykYudD9eBY lRjevQz06tGLoKv8Q4/iHx4OKh25fq0JWCASaOwL9zj4EVRlnZ3rfacPfMGQAAGRA90r V/a9Zo5EFzDrSqlLye/edCNY19hEwWxHNbmPnI+rHB7p9Ra1zVGHsOYUBy0ph47YxJNN Y05KQefPmEBAJauzFpHvSGNw8yliRLhlsMhmQN25NZhWrwNjUy8HXDrzLeFN7fSSdGXy ujzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275358; x=1724880158; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KDdOXUn/9snQ1wK5LCIPPus5mF2WWgGtaZstma1ySpU=; b=obP339taocvKzDC6e1jgyAKYea/K0PFu7UxcwvWoccqKWFdxuvpn5MGX0EdT/4ouch KKS5EKMEJvHh/FsddRs0VoQZOvr3tdj73TRId1PLmx+lFcycy51rAmtGSDbmEsFywKlA vdpphATUCoe/VcD4Uae1WvQTWVBk3CAOR3Sx1n5/KsM5UfbdslV/v9pEG3rnKgS/+l2K AlqSJ3+/W8+92WXbwjHwAS9/cQa4OGMX5ullFv3EMiC3RweyXsrhwnubYSMsSj2GuMG8 ZTo3xHiXCzepUuyJ6ah/H/U26PAr4F63iJTugyo85hT8ggH7lhvbVaRAi2FTJpLLwRbn AEWA== X-Forwarded-Encrypted: i=1; AJvYcCWYHC0UrSXOMRPzSS0iK8yiVgozJmKtuutzCxCW2oxg3e1xM7/bpHzyzwHvzadMY2+x89PiVS8=@vger.kernel.org X-Gm-Message-State: AOJu0YyvYgv93sL1o/Fu8Qx6dBOiTCzhoyD0NH1SEtW+pIE6QgBoA5tf /z99+50JXAahB0nDYspZxKxX7QVXeD1LXAlnkyhXjIIIodfjOYERrRpbI8Zfyg== X-Google-Smtp-Source: AGHT+IGcNAZPUF0W+hbQrxP07GyQ0jaUGEcBHqIKaRxoDDxLk4+aBXMgV7CZOI4oM6X1qeQRCMmI/Q== X-Received: by 2002:a17:902:e851:b0:1fd:96c7:24f5 with SMTP id d9443c01a7336-2037ee0653amr13333935ad.5.1724275358021; Wed, 21 Aug 2024 14:22:38 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:37 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert , Willem de Bruijn Subject: [PATCH net-next v3 02/13] flow_dissector: Parse ETH_P_TEB and move out of GRE Date: Wed, 21 Aug 2024 14:22:01 -0700 Message-Id: <20240821212212.1795357-3-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org ETH_P_TEB (Trans Ether Bridging) is the EtherType to carry a plain Etherent frame. Add case in skb_flow_dissect to parse packets of this type If the GRE protocol is ETH_P_TEB then just process that as any another EtherType since it's now supported in the main loop Reviewed-by: Willem de Bruijn Signed-off-by: Tom Herbert --- net/core/flow_dissector.c | 71 +++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 0e638a37aa09..5170676a224c 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -654,7 +654,7 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, struct flow_dissector_key_control *key_control, struct flow_dissector *flow_dissector, void *target_container, const void *data, - __be16 *p_proto, int *p_nhoff, int *p_hlen, + __be16 *p_proto, int *p_nhoff, int hlen, unsigned int flags) { struct flow_dissector_key_keyid *key_keyid; @@ -663,7 +663,7 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, u16 gre_ver; hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), - data, *p_hlen, &_hdr); + data, hlen, &_hdr); if (!hdr) return FLOW_DISSECT_RET_OUT_BAD; @@ -695,7 +695,7 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, keyid = __skb_header_pointer(skb, *p_nhoff + offset, sizeof(_keyid), - data, *p_hlen, &_keyid); + data, hlen, &_keyid); if (!keyid) return FLOW_DISSECT_RET_OUT_BAD; @@ -715,27 +715,11 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, if (hdr->flags & GRE_SEQ) offset += sizeof_field(struct pptp_gre_header, seq); - if (gre_ver == 0) { - if (*p_proto == htons(ETH_P_TEB)) { - const struct ethhdr *eth; - struct ethhdr _eth; - - eth = __skb_header_pointer(skb, *p_nhoff + offset, - sizeof(_eth), - data, *p_hlen, &_eth); - if (!eth) - return FLOW_DISSECT_RET_OUT_BAD; - *p_proto = eth->h_proto; - offset += sizeof(*eth); - - /* Cap headers that we access via pointers at the - * end of the Ethernet header as our maximum alignment - * at that point is only 2 bytes. - */ - if (NET_IP_ALIGN) - *p_hlen = *p_nhoff + offset; - } - } else { /* version 1, must be PPTP */ + /* For GRE version 0 p_proto is already correctly set (including if + * it is ETH_P_TEB) + */ + + if (gre_ver == 1) { /* Version 1 is PPP */ u8 _ppp_hdr[PPP_HDRLEN]; u8 *ppp_hdr; @@ -744,7 +728,7 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, ppp_hdr = __skb_header_pointer(skb, *p_nhoff + offset, sizeof(_ppp_hdr), - data, *p_hlen, _ppp_hdr); + data, hlen, _ppp_hdr); if (!ppp_hdr) return FLOW_DISSECT_RET_OUT_BAD; @@ -1284,6 +1268,41 @@ bool __skb_flow_dissect(const struct net *net, break; } + case htons(ETH_P_TEB): { + const struct ethhdr *eth; + struct ethhdr _eth; + + eth = __skb_header_pointer(skb, nhoff, sizeof(_eth), + data, hlen, &_eth); + if (!eth) + goto out_bad; + + proto = eth->h_proto; + nhoff += sizeof(*eth); + + /* Cap headers that we access via pointers at the end of the + * Ethernet header as our maximum alignment at that point is + * only 2 bytes. + * + * For the real Ethernet header the receive skbuf is offset by + * two so that device places the packet such that the Ethernet + * payload, i.e. IP header, is aligned to four bytes (14+2=16 + * which will be offset of IP header). When a packet contains + * an encapsulated Ethernet header, the offset of the header is + * aligned to four bytes which means the payload of that + * Ethernet header, i.e. an encapsulated IP header, is not four + * byte aligned and neither are any subsequent headers (TCP, + * UDP, etc.). On some architectures, performing unaligned + * loads is expensive compared to aligned loads, so hlen is + * being capped here to avoid having flow dissector do unaligned + * loads on unaligned headers after the Ethernet header. + */ + if (NET_IP_ALIGN) + hlen = nhoff; + + fdret = FLOW_DISSECT_RET_PROTO_AGAIN; + break; + } case htons(ETH_P_8021AD): case htons(ETH_P_8021Q): { const struct vlan_hdr *vlan = NULL; @@ -1531,7 +1550,7 @@ bool __skb_flow_dissect(const struct net *net, fdret = __skb_flow_dissect_gre(skb, key_control, flow_dissector, target_container, data, - &proto, &nhoff, &hlen, flags); + &proto, &nhoff, hlen, flags); break; case NEXTHDR_HOP: From patchwork Wed Aug 21 21:22:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772058 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7629817108A for ; Wed, 21 Aug 2024 21:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275361; cv=none; b=tl/L+AWFRYTzP3nijFLyJznpSNLD5bEMIzX+i0Y3xqS8TZ+IQdIcaz8PtcCDVK3zZtDvkPugWtzUHMWBa5bfAQ0f949wThwSLOE9E4Z4Y3Gj/C8mF8qIAL1ZKo1MstYLAscDqzqDHTz87Ox0Z49jyRZ6GDZ7KtwPOQYVQ9N1uAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275361; c=relaxed/simple; bh=YyZztFICIyC3NZU6IESwORkmV0LZE0KdGN1JMoaO8nw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k8h8dxM2VE1jhdAtXIvZtXYPwGBH8OLa2fjtcwWqXV1Ek0O6SQ35hr2p4om3Gzno29vN+ogyUy2+a8MaMOISzV3iQjWKF9HQzs+iHrzFNOx/vcVNab0wJjD0AnnamHPzmQx0DqDPmw1inFHzwsr9WpOFO2jeu65E9XiwI2uF5dY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=AgOe0Yg/; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="AgOe0Yg/" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-202146e9538so1217325ad.3 for ; Wed, 21 Aug 2024 14:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275360; x=1724880160; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=unAO7QbRteOSBlEV71R1L2OjksXxItVIlCBySIstqU4=; b=AgOe0Yg/UQRH9HcPit0Cg55LN2wLZUXsNVnNFxlhjp9LRzdEWtVAjNIFRI3YXSYK03 qtyhKKIsnvYWNlWwgm/o3TXgs8mUysJBdXzY9GOTuHcxp94RBodYMFSnltNsbaLCC7rh cZPeYpzXEnh+vBJ9HLnJbP+3UknlFYK8QQLSlmK8zCA64xRE+BKho1jukPQn5J2N9urg 1b4OyV6DCpsQWeiWE0hjMyjyLQu9pNjltO9JQeb6yupq3Cab6MWgNqE289RDUSClsjZ2 +cx3Q4ld9SqHLcY7Sy/Ky6CchywNT1OFj8wiX/sKjtMYEl9vDxFRmlxZG+KYXn0fnUa4 NQiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275360; x=1724880160; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=unAO7QbRteOSBlEV71R1L2OjksXxItVIlCBySIstqU4=; b=lQzL/kG9RIuYQiTjqz2PLRbs8ULc1mzxZdx8uDug4KtbX/nCb0VpzLg7309rpsZWfr fRt5EtmjGdNxduvivzqtY5wtFerYJDpXN35hoFzcs/3mPj5z2WhE2vxPeoLSbRoSu7Or HgIPYczVVhIRCE+2SISF5DEgvgJnddJMJnYjnGktFTWUGMSojDCClB7ZEuLvNUq6ySSE z/Bs+72IYqBWhThOx1eULof/2+TzNpnIslA51LfTtHq04pqrcXfvAfnvXcQGb31uZZ+z dUSwD+uKcNYr7nRPptdqzaAATahqJuP/uuY8BIXD7OJG420OPxUOz796v2j6OtdzY5S+ mFeQ== X-Forwarded-Encrypted: i=1; AJvYcCVaLo4iej74/70S4b8Pmsqp7tzxBy0pcXdvaP/7shhq4/OsqDtQ+E2QwcEkGrxrEWdyUFBdXZ4=@vger.kernel.org X-Gm-Message-State: AOJu0YykAssoOx8w0FxQ5QiNfLawD18z3oHzJlXn05pcjNv0ByRYYffC UGCzdrNzipAvRS+OoCycbBwspbBP7KonuehJMYMpcpY/kbzyhQoTIAtmMJ3W/g== X-Google-Smtp-Source: AGHT+IF/vo8qcl2Pxv4IXJou7lTgtbtRPWvbCWbRhezEi6DmheA8SlWOzsD3aRS69DdxnDtrZanl9A== X-Received: by 2002:a17:902:ec8e:b0:202:38d8:173 with SMTP id d9443c01a7336-20367d31799mr37659525ad.29.1724275359581; Wed, 21 Aug 2024 14:22:39 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:39 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert , Willem de Bruijn Subject: [PATCH net-next v3 03/13] udp_encaps: Add new UDP_ENCAP constants Date: Wed, 21 Aug 2024 14:22:02 -0700 Message-Id: <20240821212212.1795357-4-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add constants for various UDP encapsulations that are supported Reviewed-by: Willem de Bruijn Signed-off-by: Tom Herbert --- include/uapi/linux/udp.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/udp.h b/include/uapi/linux/udp.h index 1a0fe8b151fb..bf15c4ded3e8 100644 --- a/include/uapi/linux/udp.h +++ b/include/uapi/linux/udp.h @@ -35,7 +35,12 @@ struct udphdr { #define UDP_SEGMENT 103 /* Set GSO segmentation size */ #define UDP_GRO 104 /* This socket can receive UDP GRO packets */ -/* UDP encapsulation types */ +/* UDP encapsulation types + * + * Note that these are defined in UAPI since we may need to use them externally, + * for instance by eBPF + */ +#define UDP_ENCAP_NONE 0 #define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* unused draft-ietf-ipsec-nat-t-ike-00/01 */ #define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */ #define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */ @@ -43,5 +48,17 @@ struct udphdr { #define UDP_ENCAP_GTP1U 5 /* 3GPP TS 29.060 */ #define UDP_ENCAP_RXRPC 6 #define TCP_ENCAP_ESPINTCP 7 /* Yikes, this is really xfrm encap types. */ +#define UDP_ENCAP_TIPC 8 +#define UDP_ENCAP_FOU 9 +#define UDP_ENCAP_GUE 10 +#define UDP_ENCAP_SCTP 11 +#define UDP_ENCAP_RXE 12 +#define UDP_ENCAP_PFCP 13 +#define UDP_ENCAP_WIREGUARD 14 +#define UDP_ENCAP_BAREUDP 15 +#define UDP_ENCAP_VXLAN 16 +#define UDP_ENCAP_VXLAN_GPE 17 +#define UDP_ENCAP_GENEVE 18 +#define UDP_ENCAP_AMT 19 #endif /* _UAPI_LINUX_UDP_H */ From patchwork Wed Aug 21 21:22:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772059 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17FEA177981 for ; Wed, 21 Aug 2024 21:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275363; cv=none; b=VUkq/O9/u7y8JBchLQ7vuyuEdAltmHDMjqIrebUz8Fpwyd+jF7c15QDTvwAM3E8hIXdEgaVWP2RHqqMP38mQfsHhiEsbHaWQqJIJfhB/nMb0w8wVEAxkHy4JJtNupHDTBiZn2Gu0kYGv8JxG5mVpqnRIUcFHiyluk2YZXHNEadM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275363; c=relaxed/simple; bh=nYu8yZ/VN1Dg7+BXBxyOnOybgHomc2LXxWLVKv9ctjk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BjXjDuES31e7yBoGpI6x/It153F8VQoYLudjPQS8EZyq5m8P+poXu2p8yVCdupW79mX7dyNeEAXQMeBulP2gYoRNG9ufsrCNtraRZLNvBctviXcsgmDz2L/T8UJ9JytH0jAGKFhFlyqkwKpF39WTfChxIcA+bIERF4dNQfZ1piI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=KJsB4Iif; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="KJsB4Iif" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20227ba378eso1366165ad.0 for ; Wed, 21 Aug 2024 14:22:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275361; x=1724880161; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e1sb8cWs53jZLxOrCKQjc0PrlsqOnPbedcs+Sjt1xik=; b=KJsB4Iifb5Jf5gaW0cTt1P/jOk2lXdwFzmuUkipGv1PsN0H+1BnhJvKvAois+LI6CV 5PPgDK+oNxrYPLnJQcjJ/SuNPz9JT/ut4oHDRoRUMdQObMQdL/JL5NzOGyF95RVUqoK8 8WN1WD5+BzY4Re5RzOAjY0XoMOiSPzMNwigYBjh++bJs3dzMiAil3cu1bmUPKB8YtrT2 XeLNXc6sYuK4DN/l1C6eJvKtW4CbLy6kEYw6gvAlrx0OY79CfJ6FRN72siT+SJOgeX9L jmsj2COeTAUUi1h1pRJqJlSOzuOkoaCL+pPb+VEL4hDM0EWJEmFYqBA3c5oQr4957fPU aWMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275361; x=1724880161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e1sb8cWs53jZLxOrCKQjc0PrlsqOnPbedcs+Sjt1xik=; b=a2XRUDQhClSaubImuH2mvfcTieTMNUI+tWQognav7E5RmurzUm48UhtfbZq4YzrWSv pIDvXEPE5ud4CX45Q5gCa4f6fd95OtKcnGzGW6u1jCcMJ8ApMU7Du90ZIpq/EyPXytVH bZ9S0zZX6clvMHoqgb8UmwmuvJu971TDYTo1jzNDIHBqw7wz4q4jyiffUi2BxESl3PQP z6ebZ4oHFSEi5maLFxU9oUbwbNd35YB+rQNNJvFdNbwN73BKSONFiOWtDN2T7V8zBtr1 6Xqw/s9Ai+YxKyWYVDCuo4YYtumBIriwUIyd3mVkHbW+GpALeI/WSmSMxjkrMeGSEHSY YxZQ== X-Forwarded-Encrypted: i=1; AJvYcCUE4DLjAN4PjleJnusdAgIOdsvA+XX2cmlvoFT1UjLCevGkYYPIdzQ7WGdj9ye69U/7XlbuIMM=@vger.kernel.org X-Gm-Message-State: AOJu0YzzDtp2YZn792lFGUi/GVLobjShZ5LOiKVUpVPNQLRXikcnao+e dCPfUySXuJcK+TBAPO1t1bWPJCvuyJNGMBVGmYc0fVZLvef3HDpe4YW2KR5DwA== X-Google-Smtp-Source: AGHT+IFXKARSVoeNligjxtsRnyn1JW0zZ/uZYDNRnRpsrSzMqCMhER5LhmYxY9QXrPWHRQNlNocUUg== X-Received: by 2002:a17:902:e544:b0:202:2b3c:9ace with SMTP id d9443c01a7336-20367d31d30mr42397725ad.30.1724275361162; Wed, 21 Aug 2024 14:22:41 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:40 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert , Willem de Bruijn Subject: [PATCH net-next v3 04/13] udp_encaps: Set proper UDP_ENCAP types in tunnel setup Date: Wed, 21 Aug 2024 14:22:03 -0700 Message-Id: <20240821212212.1795357-5-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Instead of just setting UDP tunnel config encap_type to 1, use the appropriate constat for the tunnel type. This value can be used to determine the encapsulated protocol in UDP by looking at the socket Reviewed-by: Willem de Bruijn Signed-off-by: Tom Herbert --- drivers/infiniband/sw/rxe/rxe_net.c | 2 +- drivers/net/amt.c | 2 +- drivers/net/bareudp.c | 2 +- drivers/net/geneve.c | 2 +- drivers/net/pfcp.c | 2 +- drivers/net/vxlan/vxlan_core.c | 3 ++- drivers/net/wireguard/socket.c | 2 +- net/ipv4/fou_core.c | 3 ++- net/sctp/protocol.c | 2 +- net/tipc/udp_media.c | 2 +- 10 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 75d1407db52d..1c2bb88132c5 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -193,7 +193,7 @@ static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port, if (err < 0) return ERR_PTR(err); - tnl_cfg.encap_type = 1; + tnl_cfg.encap_type = UDP_ENCAP_RXE; tnl_cfg.encap_rcv = rxe_udp_encap_recv; /* Setup UDP tunnel */ diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 6d15ab3bfbbc..fc421cf2c032 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -2970,7 +2970,7 @@ static int amt_socket_create(struct amt_dev *amt) /* Mark socket as an encapsulation socket */ memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); tunnel_cfg.sk_user_data = amt; - tunnel_cfg.encap_type = 1; + tunnel_cfg.encap_type = UDP_ENCAP_AMT; tunnel_cfg.encap_rcv = amt_rcv; tunnel_cfg.encap_err_lookup = amt_err_lookup; tunnel_cfg.encap_destroy = NULL; diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index d5c56ca91b77..007fb8c5168b 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -248,7 +248,7 @@ static int bareudp_socket_create(struct bareudp_dev *bareudp, __be16 port) /* Mark socket as an encapsulation socket */ memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); tunnel_cfg.sk_user_data = bareudp; - tunnel_cfg.encap_type = 1; + tunnel_cfg.encap_type = UDP_ENCAP_BAREUDP; tunnel_cfg.encap_rcv = bareudp_udp_encap_recv; tunnel_cfg.encap_err_lookup = bareudp_err_lookup; tunnel_cfg.encap_destroy = NULL; diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 838e85ddec67..923c573b6e5c 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -611,7 +611,7 @@ static struct geneve_sock *geneve_socket_create(struct net *net, __be16 port, /* Mark socket as an encapsulation socket */ memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); tunnel_cfg.sk_user_data = gs; - tunnel_cfg.encap_type = 1; + tunnel_cfg.encap_type = UDP_ENCAP_GENEVE; tunnel_cfg.gro_receive = geneve_gro_receive; tunnel_cfg.gro_complete = geneve_gro_complete; tunnel_cfg.encap_rcv = geneve_udp_encap_recv; diff --git a/drivers/net/pfcp.c b/drivers/net/pfcp.c index 69434fd13f96..c7e4fa606b16 100644 --- a/drivers/net/pfcp.c +++ b/drivers/net/pfcp.c @@ -170,7 +170,7 @@ static struct socket *pfcp_create_sock(struct pfcp_dev *pfcp) tuncfg.sk_user_data = pfcp; tuncfg.encap_rcv = pfcp_encap_recv; - tuncfg.encap_type = 1; + tuncfg.encap_type = UDP_ENCAP_PFCP; setup_udp_tunnel_sock(net, sock, &tuncfg); diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 8983e75e9881..e02cbc018b8c 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3572,7 +3572,8 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6, /* Mark socket as an encapsulation socket. */ memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); tunnel_cfg.sk_user_data = vs; - tunnel_cfg.encap_type = 1; + tunnel_cfg.encap_type = vs->flags & VXLAN_F_GPE ? + UDP_ENCAP_VXLAN_GPE : UDP_ENCAP_VXLAN; tunnel_cfg.encap_rcv = vxlan_rcv; tunnel_cfg.encap_err_lookup = vxlan_err_lookup; tunnel_cfg.encap_destroy = NULL; diff --git a/drivers/net/wireguard/socket.c b/drivers/net/wireguard/socket.c index 0414d7a6ce74..f4b5bd14fd56 100644 --- a/drivers/net/wireguard/socket.c +++ b/drivers/net/wireguard/socket.c @@ -352,7 +352,7 @@ int wg_socket_init(struct wg_device *wg, u16 port) int ret; struct udp_tunnel_sock_cfg cfg = { .sk_user_data = wg, - .encap_type = 1, + .encap_type = UDP_ENCAP_WIREGUARD, .encap_rcv = wg_receive }; struct socket *new4 = NULL, *new6 = NULL; diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c index 0abbc413e0fe..8241f762e45b 100644 --- a/net/ipv4/fou_core.c +++ b/net/ipv4/fou_core.c @@ -578,19 +578,20 @@ static int fou_create(struct net *net, struct fou_cfg *cfg, fou->sock = sock; memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); - tunnel_cfg.encap_type = 1; tunnel_cfg.sk_user_data = fou; tunnel_cfg.encap_destroy = NULL; /* Initial for fou type */ switch (cfg->type) { case FOU_ENCAP_DIRECT: + tunnel_cfg.encap_type = UDP_ENCAP_FOU; tunnel_cfg.encap_rcv = fou_udp_recv; tunnel_cfg.gro_receive = fou_gro_receive; tunnel_cfg.gro_complete = fou_gro_complete; fou->protocol = cfg->protocol; break; case FOU_ENCAP_GUE: + tunnel_cfg.encap_type = UDP_ENCAP_GUE; tunnel_cfg.encap_rcv = gue_udp_recv; tunnel_cfg.gro_receive = gue_gro_receive; tunnel_cfg.gro_complete = gue_gro_complete; diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 5a7436a13b74..290ebcf17a48 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -876,7 +876,7 @@ int sctp_udp_sock_start(struct net *net) return err; } - tuncfg.encap_type = 1; + tuncfg.encap_type = UDP_ENCAP_SCTP; tuncfg.encap_rcv = sctp_udp_rcv; tuncfg.encap_err_lookup = sctp_udp_v4_err; setup_udp_tunnel_sock(net, sock, &tuncfg); diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 439f75539977..3c081b7b9d67 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -771,7 +771,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, if (err) goto err; tuncfg.sk_user_data = ub; - tuncfg.encap_type = 1; + tuncfg.encap_type = UDP_ENCAP_TIPC; tuncfg.encap_rcv = tipc_udp_recv; tuncfg.encap_destroy = NULL; setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg); From patchwork Wed Aug 21 21:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772060 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFDB6178372 for ; Wed, 21 Aug 2024 21:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275365; cv=none; b=U+zTkxZOmdQG0cmIIoU+EnziXpDtXoVoy7KPGT+VOUZ8H/oUwaekucfi7bf0xEEdih2Vi8GkMd1m8ji/yMfwf3hbc//fuVh4iKUHsJYjYgLMnEEoNdzq93kufSipiczGQ+Ra4jN9lON4tijGc/5OGY5vn9VczeIaxt9ngTeyZhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275365; c=relaxed/simple; bh=jB9SApiU0tAER5vbQmJHPWj6fZXj0wdImfazAaQNBCs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JzbozKHf74YBjvWSAjC3CriyYbqJJx3deSfnVvKO84dZBnVKqjL5AH29y+u026r02Ks6Ov7up5kmj3ofyIAZiUo4MpdyCdXWP5vjPVJZ0TXka5fW5TXUihJlHwy5lICbM0ZtlcHm2G2dTWBw2JbrU25Uu4eMlOrJusSiqe83J3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=KYpiWJer; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="KYpiWJer" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20219a0fe4dso1320895ad.2 for ; Wed, 21 Aug 2024 14:22:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275363; x=1724880163; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2ybmEWSVMNWJwoyiaxSSrSx1YuGX6mif+IMJnoCq4og=; b=KYpiWJer7aOxJfjgSYzDoiKzp4tf67N1XYHdwXmTWwqSgzWaHzZ4JZ/iSWzMtNoCxz GgMsvzacwm0NF877t3jovO+mnyYPxbAyGQ0eKxMvk+gQAeHxa9hXDTe2nH589xClYhSW E7Iu+8WS47IzhpT3Sf2o/q2diwnp3zUQD/lkCNx/xYIuCI3RuBDRDeVRuqggh5Z9JoJ3 AqtRTWQ+klsekMX0frrFBtJIV+Nvx3Khln0Y7pXHesqSewi/FN8nWec+nbfsdbuECmLx mTwIDFs8+Qx9X8Yyp9rcDV1LYzn8HU2ifa/cguzuFaxnfuKRk/1m77FACyM6Q1bN1iPB VaAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275363; x=1724880163; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2ybmEWSVMNWJwoyiaxSSrSx1YuGX6mif+IMJnoCq4og=; b=k7OqYP8U5IBSK0yZ3Q+QvKdShQ7xrYgfQ2Dd09SifYimeWtqn9OXpY8tKeItz0Sxxc ZJBLRvJMh5gfdt2hEuVpVWASOlcpKvsADRm70BYH4CflEal5juEUZk+XYCGh+uguXzby PxQjZpnvaxrwkuNYc/H/UJDgKVTKZXJXkHnfdRueiAJXqJYOUX+Q37c49jeJMJv54rT7 zj4qUyds19tZId0xEfaYQS9NLkF7+L0FvxrEF6n+vlSXPJrev0mYAAnoBFOfEk9hEyH9 i7DfPGDJLClVi9/osYUOjZRIg0ydc2yIqVksB16HqV24GFeYhxmqc/EAsPuk1SeT0//L 1euw== X-Forwarded-Encrypted: i=1; AJvYcCUkmeOIAbTpbCtHcEBhDnhRtjWS0riFLNTlwPJ4bHuEkLZ1oUjZCXpkIpKVjQ+Quc9bmalxzaM=@vger.kernel.org X-Gm-Message-State: AOJu0YzKRAjJtOGYwaMtVNsliumOr2cWEmZGvortD47iCAJyUrPL4m9v mo1b2JtI3Q7GWu9fDRvkbyzWCD95gSoa8HQ6ZA0PQuw4QCnmEA5kB+cYmA8WVg== X-Google-Smtp-Source: AGHT+IG9+X14WEqdtQsvr4xCnkYsw7ZtpxYZS16ZtQutl9BAgR8l1Uqave/nQXRbdwG07BLScKaNOA== X-Received: by 2002:a17:902:facc:b0:201:fcd1:e430 with SMTP id d9443c01a7336-20367af1ec9mr32615315ad.11.1724275362601; Wed, 21 Aug 2024 14:22:42 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:42 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 05/13] flow_dissector: UDP encap infrastructure Date: Wed, 21 Aug 2024 14:22:04 -0700 Message-Id: <20240821212212.1795357-6-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add infrastructure for parsing into UDP encapsulations Add function __skb_flow_dissect_udp that is called for IPPROTO_UDP. The flag FLOW_DISSECTOR_F_PARSE_UDP_ENCAPS enables parsing of UDP encapsulations. If the flag is set when parsing a UDP packet then a socket lookup is performed. The offset of the base network header, either an IPv4 or IPv6 header, is tracked and passed to __skb_flow_dissect_udp so that it can perform the socket lookup If a socket is found and it's for a UDP encapsulation (encap_type is set in the UDP socket) then a switch is performed on the encap_type value (cases are UDP_ENCAP_* values) An encapsulated packet in UDP can either be indicated by an EtherType or IP protocol. The processing for dissecting a UDP encap protocol returns a flow dissector return code. If FLOW_DISSECT_RET_PROTO_AGAIN or FLOW_DISSECT_RET_IPPROTO_AGAIN is returned then the corresponding encapsulated protocol is dissected. The nhoff is set to point to the header to process. In the case FLOW_DISSECT_RET_PROTO_AGAIN the EtherType protocol is returned and the IP protocol is set to zero. In the case of FLOW_DISSECT_RET_IPPROTO_AGAIN, the IP protocol is returned and the EtherType protocol is returned unchanged Signed-off-by: Tom Herbert --- include/net/flow_dissector.h | 1 + net/core/flow_dissector.c | 137 +++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h index ced79dc8e856..8a868a88a6f1 100644 --- a/include/net/flow_dissector.h +++ b/include/net/flow_dissector.h @@ -384,6 +384,7 @@ enum flow_dissector_key_id { #define FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL BIT(1) #define FLOW_DISSECTOR_F_STOP_AT_ENCAP BIT(2) #define FLOW_DISSECTOR_F_STOP_BEFORE_ENCAP BIT(3) +#define FLOW_DISSECTOR_F_PARSE_UDP_ENCAPS BIT(4) struct flow_dissector_key { enum flow_dissector_key_id key_id; diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 5170676a224c..a5b1b1badc67 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -806,6 +807,133 @@ __skb_flow_dissect_batadv(const struct sk_buff *skb, return FLOW_DISSECT_RET_PROTO_AGAIN; } +static enum flow_dissect_ret +__skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, + struct flow_dissector *flow_dissector, + void *target_container, const void *data, + int *p_nhoff, int hlen, __be16 *p_proto, + u8 *p_ip_proto, int base_nhoff, unsigned int flags, + unsigned int num_hdrs) +{ + enum flow_dissect_ret ret; + const struct udphdr *udph; + struct udphdr _udph; + struct sock *sk; + __u8 encap_type; + int nhoff; + + if (!(flags & FLOW_DISSECTOR_F_PARSE_UDP_ENCAPS)) + return FLOW_DISSECT_RET_OUT_GOOD; + + /* Check that the netns for the skb device is the same as the caller's, + * and only dissect UDP if we haven't yet encountered any encapsulation. + * The goal is to ensure that the socket lookup is being done in the + * right netns. Encapsulations may push packets into different name + * spaces, so this scheme is restricting UDP dissection to cases where + * they are in the same name spaces or at least the original name space. + * This should capture the majority of use cases for UDP encaps, and + * if we do encounter a UDP encapsulation within a different namespace + * then the only effect is we don't attempt UDP dissection + */ + if (dev_net(skb->dev) != net || num_hdrs > 0) + return FLOW_DISSECT_RET_OUT_GOOD; + + switch (*p_proto) { +#ifdef CONFIG_INET + case htons(ETH_P_IP): { + const struct iphdr *iph; + struct iphdr _iph; + + iph = __skb_header_pointer(skb, base_nhoff, sizeof(_iph), data, + hlen, &_iph); + if (!iph) + return FLOW_DISSECT_RET_OUT_BAD; + + udph = __skb_header_pointer(skb, *p_nhoff, sizeof(_udph), data, + hlen, &_udph); + if (!udph) + return FLOW_DISSECT_RET_OUT_BAD; + + rcu_read_lock(); + /* Look up the UDPv4 socket and get the encap_type */ + sk = __udp4_lib_lookup(net, iph->saddr, udph->source, + iph->daddr, udph->dest, + inet_iif(skb), inet_sdif(skb), + net->ipv4.udp_table, NULL); + if (!sk || !udp_sk(sk)->encap_type) { + rcu_read_unlock(); + return FLOW_DISSECT_RET_OUT_GOOD; + } + + encap_type = udp_sk(sk)->encap_type; + rcu_read_unlock(); + + break; + } +#if IS_ENABLED(CONFIG_IPV6) + case htons(ETH_P_IPV6): { + const struct ipv6hdr *iph; + struct ipv6hdr _iph; + + if (!likely(ipv6_stub)) + return FLOW_DISSECT_RET_OUT_GOOD; + + iph = __skb_header_pointer(skb, base_nhoff, sizeof(_iph), data, + hlen, &_iph); + if (!iph) + return FLOW_DISSECT_RET_OUT_BAD; + + udph = __skb_header_pointer(skb, *p_nhoff, sizeof(_udph), data, + hlen, &_udph); + if (!udph) + return FLOW_DISSECT_RET_OUT_BAD; + + rcu_read_lock(); + /* Look up the UDPv6 socket and get the encap_type */ + sk = ipv6_stub->udp6_lib_lookup(net, + &iph->saddr, udph->source, + &iph->daddr, udph->dest, + inet_iif(skb), inet_sdif(skb), + net->ipv4.udp_table, NULL); + + if (!sk || !udp_sk(sk)->encap_type) { + rcu_read_unlock(); + return FLOW_DISSECT_RET_OUT_GOOD; + } + + encap_type = udp_sk(sk)->encap_type; + rcu_read_unlock(); + + break; + } +#endif /* CONFIG_IPV6 */ +#endif /* CONFIG_INET */ + default: + return FLOW_DISSECT_RET_OUT_GOOD; + } + + nhoff = *p_nhoff + sizeof(_udph); + ret = FLOW_DISSECT_RET_OUT_GOOD; + + switch (encap_type) { + default: + break; + } + + switch (ret) { + case FLOW_DISSECT_RET_PROTO_AGAIN: + *p_ip_proto = 0; + fallthrough; + case FLOW_DISSECT_RET_IPPROTO_AGAIN: + *p_nhoff = nhoff; + break; + default: + break; + } + + return ret; +} + static void __skb_flow_dissect_tcp(const struct sk_buff *skb, struct flow_dissector *flow_dissector, @@ -1046,6 +1174,7 @@ bool __skb_flow_dissect(const struct net *net, int mpls_lse = 0; int num_hdrs = 0; u8 ip_proto = 0; + int base_nhoff; bool ret; if (!data) { @@ -1168,6 +1297,7 @@ bool __skb_flow_dissect(const struct net *net, proto_again: fdret = FLOW_DISSECT_RET_CONTINUE; + base_nhoff = nhoff; switch (proto) { case htons(ETH_P_IP): { @@ -1649,6 +1779,13 @@ bool __skb_flow_dissect(const struct net *net, data, nhoff, hlen); break; + case IPPROTO_UDP: + fdret = __skb_flow_dissect_udp(skb, net, flow_dissector, + target_container, data, &nhoff, + hlen, &proto, &ip_proto, + base_nhoff, flags, num_hdrs); + break; + case IPPROTO_ICMP: case IPPROTO_ICMPV6: __skb_flow_dissect_icmp(skb, flow_dissector, target_container, From patchwork Wed Aug 21 21:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772061 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ABEF175D42 for ; Wed, 21 Aug 2024 21:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275366; cv=none; b=Y6umTNPsBgq83e7EEpTCx+rBPBtOffpfzjxIEtkVTFNQXDzPv1djluJ4ib9uAaGlz+2MH92RZsvpQyxdav+Qpw5kNCuJyyKLyp48Lgju6uVbEKxdzOy5ls3E0FRg+2+5lxlpV4zM51UJnqfGqGafDKj7WoXf/htShhVTMHQ7n6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275366; c=relaxed/simple; bh=3DQ6ma+A0vozs1hkgO1gvkZQH5fte0StjfazO0usrP4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kzD/Q/iZGYlug6kJieUOyOwf92cITcTS8WqaoQWM/ohsR2xGIoKPyn2NBMfrTT6qqfqnLC3Xlau46kghq35kV0RLtwwc1PIcgIAVvg6hiyKuRvVBuYafuNkgmV1sN+Iqmz6pBKz5ZrbCPCqUn52E7oDQ5HjnecvbrKEtZrwZlDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=ZMrt+iOp; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="ZMrt+iOp" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-202318c4f45so1347965ad.0 for ; Wed, 21 Aug 2024 14:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275364; x=1724880164; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CbIFJgKehoO9POmGcrLBdJ/KQY3W1THGNVCwYfkYyqM=; b=ZMrt+iOp5XuoRBMtHFQ9sA5oV46e/szC+1pXUCRkdLiCVO2mM9r0JNxK+grYboJWYp wxBs+uVRUa1evkmgkZOVTQRt9TYXqw/PJAdrpYbd7DgpXRlkqQNu3Yh7B29kF7iMWDqx 7xX6OSIv3nFn+ZcXVmPYTsc8bVG64+Npo0FGE6QAjRJFK58jNhScBnJ/6enpiu86oZjt Le0ioxv5L8Oz/uyDUX6vJ7BfbnT/GRC5VYzabuV6EgCR1zqgwsnmN73x5l6PusPVu62A aqusj/MXxN+mj30uxbr50Qb/CBpbd6P8PkKlyllXaxWMY40vO54CQZcZx55+v2PLwnw/ NPZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275364; x=1724880164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CbIFJgKehoO9POmGcrLBdJ/KQY3W1THGNVCwYfkYyqM=; b=ml53OVtU6NuHdqnQl+SscoL9PH6h9UqOBbHc1N2Cf9zgqVXHqFvS520e1dtnVnbbx0 N2tqUQU7SmBtZ4MMpOniK8xk64ZlUk1tb7WBBjqjMjXmFcjKEkClKgbLhy58tsV1AXep 7vLwBOcSuTEZ/OEYk1gE9LcomDGX60PNYomA/jZF6S55ube5Z4vICTjooqKp4t+ZsD3b DN0j8K0xmj/mBKs2IeZIJekE2I38Z/vaO4B7atSReEI0JlQnQHqSPYlFbTlQFWTpB+7A xj601QxoTDI3hm4erBoRu99n1TyWzeQENPvWVKd/pnHEG1jbXvRfVFiObEZQfUIOiZDp GGXA== X-Forwarded-Encrypted: i=1; AJvYcCUQl8mLocW8ZQEdsO6Xs0YOdADUwaGPYEnh1kyuOLob2woDO9qsHcmJQqJvVIGZ6ZwBPiDy0k8=@vger.kernel.org X-Gm-Message-State: AOJu0YzURkpfyexWlcJgym2W9J6akGvnKpwV92oHyk1LnMUQKpMnykPb 3xLssLxwbRe80WaZ1ExVadiCSRSYSNjazs4K/xBnajVJmqIJGAuBYFgFLSXrLw== X-Google-Smtp-Source: AGHT+IGwSVnK7q6SuO38MSPyha4ii0vvvaQXbLIGY6HjnfJ2m0fAubFdbHN2hqrAUze6yJuOf2sK8Q== X-Received: by 2002:a17:902:ea0f:b0:202:3a49:acec with SMTP id d9443c01a7336-20367bfe058mr46354995ad.11.1724275364344; Wed, 21 Aug 2024 14:22:44 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:43 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 06/13] flow_dissector: Parse vxlan in UDP Date: Wed, 21 Aug 2024 14:22:05 -0700 Message-Id: <20240821212212.1795357-7-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Parse vxlan in a UDP encapsulation Signed-off-by: Tom Herbert --- net/core/flow_dissector.c | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index a5b1b1badc67..452178cf0b59 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -13,7 +13,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -756,6 +758,44 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, return FLOW_DISSECT_RET_PROTO_AGAIN; } +static enum flow_dissect_ret +__skb_flow_dissect_vxlan(const struct sk_buff *skb, + struct flow_dissector *flow_dissector, + void *target_container, const void *data, + __be16 *p_proto, int *p_nhoff, int hlen, + unsigned int flags, bool is_gpe) +{ + struct vxlanhdr *hdr, _hdr; + __be16 protocol; + + hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), data, hlen, + &_hdr); + if (!hdr) + return FLOW_DISSECT_RET_OUT_BAD; + + /* VNI flag always required to be set */ + if (!(hdr->vx_flags & VXLAN_HF_VNI)) + return FLOW_DISSECT_RET_OUT_BAD; + + if (is_gpe) { + struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)hdr; + + if (!gpe->np_applied || gpe->version != 0 || gpe->oam_flag) + return FLOW_DISSECT_RET_OUT_GOOD; + + protocol = tun_p_to_eth_p(gpe->next_protocol); + if (!protocol) + return FLOW_DISSECT_RET_OUT_GOOD; + } else { + protocol = htons(ETH_P_TEB); + } + + *p_nhoff += sizeof(struct vxlanhdr); + *p_proto = protocol; + + return FLOW_DISSECT_RET_PROTO_AGAIN; +} + /** * __skb_flow_dissect_batadv() - dissect batman-adv header * @skb: sk_buff to with the batman-adv header @@ -916,6 +956,13 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, ret = FLOW_DISSECT_RET_OUT_GOOD; switch (encap_type) { + case UDP_ENCAP_VXLAN: + case UDP_ENCAP_VXLAN_GPE: + ret = __skb_flow_dissect_vxlan(skb, flow_dissector, + target_container, data, + p_proto, &nhoff, hlen, flags, + encap_type == UDP_ENCAP_VXLAN_GPE); + break; default: break; } From patchwork Wed Aug 21 21:22:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772062 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E02FB17A582 for ; Wed, 21 Aug 2024 21:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275368; cv=none; b=UXqKEfTipyKoZDK+ZEa8omDm6uQCLC30FSs/cFVdS7h5DI4HRhgtwVPYBD7qa0cyLj58j4HfipxRZTUTAkHZHYMIXMCnN4gvB/5MjuKaSCsx8YzRLglO6yelqpLr9l8X06Dcd81q4e+JlQV9J5yu1qjqeXq8HTFpJjHKMIuXIgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275368; c=relaxed/simple; bh=iy/IjVlTNGIofXJn+fBanD7oMgCF1XdUz+M/FUjwUds=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jkAWFdOilnD4MoXdLfyoLzrlbxeKZ63HG94aNa45mziWT4Q5ar3FCuCTHdfQYl2M0ZY6OMivC3fB73S7rJVtiP0FYBuiLciDTPWkceY8qWJxhG7tgnTfWTRIRCuTwE12XBVnzlNOlONju1oGO428fqTIBIwlCXWz1ueLnNuGpo8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=N55au1ZO; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="N55au1ZO" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2021a99af5eso1215215ad.1 for ; Wed, 21 Aug 2024 14:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275366; x=1724880166; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=94T3lUdDtdwgdQTFptlIHtyUqLExlHZ5i97VvNIbOjU=; b=N55au1ZOOxMMetgtSVbN0nBR01PD8apOgWLfKNXN8WhfEaeNdgI/AR4hWrVa04vzzk mEhry90aU6T5XV8nnCGnOaS/QxNxAlDbWrahis8JzBskttlAMVkeM00FUor8fZ5B57dy ICBUn8eFIetLuDSSt5wlOio/iJJHMYclV57Ur0rALam19CirVprASkEvVDeAWd/EEKDF IHGB1oGAKpzqkBks5a+fT+rXyYVPHMGIMZX7fqBTQMeiTEk5S+pP+G3zu5KXQf40mdWa ovdyEfwPb7n2xva4IEl7YLdlYkXP+jliKAHWZZa48pYYpYhyqgO9SrD8Ih491gTXHn8e S3AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275366; x=1724880166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=94T3lUdDtdwgdQTFptlIHtyUqLExlHZ5i97VvNIbOjU=; b=ih8v+QCOC1sDaPvMJ2d9t6qNU4BcwFn2FC7EoZncWYUT3fP3TZv7aGn7L4FnlX17Js tGUF8EBmBCppmQjHg9Ct18ktRr8ZDIfpuaGxX447pe9i2Ib1Mh+H246AYtrTOGf/OUmX /2id8RxGIM4eOq69fi+Q5KVD/CJp0YVF7KWvmSqRfwtNZi8ZCE0Uuzl0c613OTpokf28 Xi6k0ntqwp6PGwzMt+f42KiDgua4DCNSkGRuDn9pZfLflpQ6sghq0KjPteu2LWboAbNg UdWvE1qV19Iwbpm8bhybup50VXxoJ2xmS/xM0yrNo4h+9Eac4afogVjoJUFJQ1XbP5L6 RKgg== X-Forwarded-Encrypted: i=1; AJvYcCXJ1aDGM+GrV6wvrLyMXeElmaELeoMY69Bp+ejrCs9XNRNjzvyS296zIY13HyyVbNlayNobgKY=@vger.kernel.org X-Gm-Message-State: AOJu0YzMNKKAp6220f0frrd6kIIIVP2kAurBT6E5P6s3z3p18z8lNTk1 5AlwRbG/h34dBp9Xg6uMpcxd5nMZFymglNF1QdAhLUx6UjarWGXNhACg0soUyQ== X-Google-Smtp-Source: AGHT+IEHs5LtiLfbSIneogDIjUwPMc4bZeyIS/QRdHx8u3hzFdb7oh+J2yjCLQxcGgUZjXIS+YA46A== X-Received: by 2002:a17:902:c409:b0:1fb:75b6:a40e with SMTP id d9443c01a7336-20368094748mr45581615ad.45.1724275366022; Wed, 21 Aug 2024 14:22:46 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:45 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert , Willem de Bruijn Subject: [PATCH net-next v3 07/13] flow_dissector: Parse foo-over-udp (FOU) Date: Wed, 21 Aug 2024 14:22:06 -0700 Message-Id: <20240821212212.1795357-8-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Parse FOU by getting the FOU protocol from the matching socket. This includes moving "struct fou" and "fou_from_sock" to fou.h Reviewed-by: Willem de Bruijn Signed-off-by: Tom Herbert --- include/net/fou.h | 16 ++++++++++++++++ net/core/flow_dissector.c | 13 ++++++++++++- net/ipv4/fou_core.c | 16 ---------------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/include/net/fou.h b/include/net/fou.h index 824eb4b231fd..8574767b91b6 100644 --- a/include/net/fou.h +++ b/include/net/fou.h @@ -17,6 +17,22 @@ int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, u8 *protocol, __be16 *sport, int type); +struct fou { + struct socket *sock; + u8 protocol; + u8 flags; + __be16 port; + u8 family; + u16 type; + struct list_head list; + struct rcu_head rcu; +}; + +static inline struct fou *fou_from_sock(struct sock *sk) +{ + return sk->sk_user_data; +} + int register_fou_bpf(void); #endif diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 452178cf0b59..fed1f98358e8 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -855,11 +856,11 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, u8 *p_ip_proto, int base_nhoff, unsigned int flags, unsigned int num_hdrs) { + __u8 encap_type, fou_protocol; enum flow_dissect_ret ret; const struct udphdr *udph; struct udphdr _udph; struct sock *sk; - __u8 encap_type; int nhoff; if (!(flags & FLOW_DISSECTOR_F_PARSE_UDP_ENCAPS)) @@ -906,6 +907,9 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, } encap_type = udp_sk(sk)->encap_type; + if (encap_type == UDP_ENCAP_FOU) + fou_protocol = fou_from_sock(sk)->protocol; + rcu_read_unlock(); break; @@ -942,6 +946,9 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, } encap_type = udp_sk(sk)->encap_type; + if (encap_type == UDP_ENCAP_FOU) + fou_protocol = fou_from_sock(sk)->protocol; + rcu_read_unlock(); break; @@ -956,6 +963,10 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, ret = FLOW_DISSECT_RET_OUT_GOOD; switch (encap_type) { + case UDP_ENCAP_FOU: + *p_ip_proto = fou_protocol; + ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; + break; case UDP_ENCAP_VXLAN: case UDP_ENCAP_VXLAN_GPE: ret = __skb_flow_dissect_vxlan(skb, flow_dissector, diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c index 8241f762e45b..137eb80c56a2 100644 --- a/net/ipv4/fou_core.c +++ b/net/ipv4/fou_core.c @@ -21,17 +21,6 @@ #include "fou_nl.h" -struct fou { - struct socket *sock; - u8 protocol; - u8 flags; - __be16 port; - u8 family; - u16 type; - struct list_head list; - struct rcu_head rcu; -}; - #define FOU_F_REMCSUM_NOPARTIAL BIT(0) struct fou_cfg { @@ -48,11 +37,6 @@ struct fou_net { struct mutex fou_lock; }; -static inline struct fou *fou_from_sock(struct sock *sk) -{ - return sk->sk_user_data; -} - static int fou_recv_pull(struct sk_buff *skb, struct fou *fou, size_t len) { /* Remove 'len' bytes from the packet (UDP header and From patchwork Wed Aug 21 21:22:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772063 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77DCB17A918 for ; Wed, 21 Aug 2024 21:22:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275369; cv=none; b=eeVuoabYVbXQKgKyGMYktcF+uCyo3qN8ZfyWPw+dei2kQaKorijPGt2zhrHb/DUlVbhFKavs8uq4XO0R/8dUyBcWy5Et+X0NB7Re4xl1nWR1ipXzJso2IxSbXNnru/TSXEdnNh2enM7r9hHhMZoT6JVbFB8gJzLeSZ+wEuZ3IS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275369; c=relaxed/simple; bh=davFt26f0OS0c7z4U6yvfVFbReAjZVL2I2xDKhOPIfY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hU85HRUafbTy+tbx52JNBX4rLT5cE2wxy9vFl0eIbkqYvAIuWQ4QZjbjChurBAhuRc2HpGVw8vqq8Jbp1HOjRvP5tXRck5ZbpaMdu/JeOkf3afl83BXNJks29jUPOFp9+CyJLZ6mX89ULqKZmgk5J6xyFDTB4R/TxG/UjrN//Zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=VV/ZsWfG; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="VV/ZsWfG" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-201d5af11a4so1101305ad.3 for ; Wed, 21 Aug 2024 14:22:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275368; x=1724880168; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HccMsd7uTeoExrzsTviCYDr+b+b128oucf8weYhgqhA=; b=VV/ZsWfG8yIZUeMAe/FXRv2vrzprLClnm/B+DtusQMfuPnN6+Vhv4QKM5vPavbYktu Z8/0RSCROJax2yekcVPqYzhi0TLYQVLx94EVhbqZWhpf/5iI4ploLIcx9+MNStiSgP7x Gw+4VtmySOVIjlk92Oxzk9yXVnVZEalTbF3cRiNVeRwml/2rMmOtjlFvpmrUGYbzpL4A BC1tLCMBG9tbXJ/O0DzBZ8xwBkQrhQhjuriV+r96Fw+b/1wpivgzKwEOYa91bmi5ScIS ixg7Mhaygt5FmicO7bM5YJrOKZRKPLncQMTCdl/aVY3mTtCxt7vXXNjDUigDPEBoWKXI p9Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275368; x=1724880168; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HccMsd7uTeoExrzsTviCYDr+b+b128oucf8weYhgqhA=; b=iWLLpQJ5bANv2btqIuytW7LtK2AZVVU54Qk8cfVrt+xV5ojlPZrJrN/WeqzfE2kCJl Fh2NaOfGivwgOjvLhNGVPfZaWtZazfTQjTX6tnktpBmN5e9sMTDvPonjwO0Sw2jhZkMZ nA8KvQt4LpbvBQ+Ty9t8ScKjB/9hJtZT3jDOHMDp2t/uLxytv2hJP9D52/Ot0N0GHw7d vjNX4EB0SwhSIGdD8bmu9OWe2JgafaYVDV6JAg+S91KHVZRIOkFYB3NT6fQ626k9i0mY drW11eI2B5C71GH1leMfIWIfKkIOjHSFNnSPRHkesa0Erq2b8PInDhl8LHQejjMa9i8s l/AQ== X-Forwarded-Encrypted: i=1; AJvYcCVHskLGeSvXyYMb6sUi8R2FouV89MJazWHM01qNlfgxfdzCIpwzt2izA4c65RUB2MNjbAHGZi8=@vger.kernel.org X-Gm-Message-State: AOJu0YxuZSBtW2MDf+VLdjteta2gZnYCMbomVEacclHNQsMdUfaBJHOk +fHYMMIfXsu3DCCaUCK+dN+ZWxNO5pYlZ+nkUnqPvK1WJj/bn6n9ujw63rZHig== X-Google-Smtp-Source: AGHT+IEFiUFE1+QxzlHW5ZYCyKEYPoIYeCSFXG6QfKcIZzjElTWwuTEusuwREe0ttrxr7RqkBV6BzA== X-Received: by 2002:a17:902:db10:b0:1fd:9e6e:7c1f with SMTP id d9443c01a7336-203681ad878mr38599175ad.56.1724275367661; Wed, 21 Aug 2024 14:22:47 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:47 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 08/13] flow_dissector: Parse ESP, L2TP, and SCTP in UDP Date: Wed, 21 Aug 2024 14:22:07 -0700 Message-Id: <20240821212212.1795357-9-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org These don't have an encapsulation header so it's fairly easy to support them Signed-off-by: Tom Herbert --- net/core/flow_dissector.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index fed1f98358e8..331848f90f78 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -963,10 +963,23 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, ret = FLOW_DISSECT_RET_OUT_GOOD; switch (encap_type) { + case UDP_ENCAP_ESPINUDP_NON_IKE: + case UDP_ENCAP_ESPINUDP: + *p_ip_proto = IPPROTO_ESP; + ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; + break; + case UDP_ENCAP_L2TPINUDP: + *p_ip_proto = IPPROTO_L2TP; + ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; + break; case UDP_ENCAP_FOU: *p_ip_proto = fou_protocol; ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; break; + case UDP_ENCAP_SCTP: + *p_ip_proto = IPPROTO_SCTP; + ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; + break; case UDP_ENCAP_VXLAN: case UDP_ENCAP_VXLAN_GPE: ret = __skb_flow_dissect_vxlan(skb, flow_dissector, From patchwork Wed Aug 21 21:22:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772064 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C849B17A582 for ; Wed, 21 Aug 2024 21:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275371; cv=none; b=m3ns3tbqZBoMkdpP5NjxoYTD88/CXbr3gh3nHz4P/q/Rul2Aa6Cmvj7wEGFtsME1r1QtDn7vSy/2qkV63PLRlzrZy40n1MSiTLr+5VB8m5CxdC8gtpUfbqJPxV7zwduFEb+r4CK7K8CFMfsmL1nFMUnBgX7GCSSDvKpeSlaAJuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275371; c=relaxed/simple; bh=Twn1f5dgBXiN3Wmpt1KS7Q+IaWwLHYKUArTze0m9lQM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J51U5sDhR2lnpVwZXdL4UYTiNY/lvjsDau7NKhCV0S6cPLTA5xPDpA7f+5i5Gv9RRfIV/eObBY5k1bmtGwIdHEqo2zWnwmcNBegu6iXZKOKOHlzz0ibDDDuST0Yy06sJ+c7JcnydJOwyq8HFWMMP9qXWKUgpjhaRmEWBzEO6N0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=IexEB5VK; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="IexEB5VK" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-201fae21398so978955ad.1 for ; Wed, 21 Aug 2024 14:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275369; x=1724880169; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k5B0V4ZEdQrdtO9pb5selC4LqFAQxYkVgI02+uDp6NY=; b=IexEB5VKhnMMT3tXIf5s6tIpIBCLvUlY+BSd0DyvKnP3Wm335Sz3oNBUlVpyia0/gu U/Z+XwAZSSLUIY6eXZ8MlQRcBQv3zWHE9qa7Y8FAw5pHcHBcVxwGsJAWD8wknM1FP9ca R/nl7Aw+RRa+L2T7fsjIvkiTbv+9AvCW+RUPsRctIi8rO+r5jn6NtEATarRyaVvSy7W+ F/zEFT2SEhpSexmkcH1QjQ0ixdWahjVgJSS1CsUnnp+O5dOHsWQ28wXRUlFx0bfUzM+T GnSXHnn86I/AxPQbKL1xKBQXeXRbBfQYSsFmXGE5TYNhwWJ6Rsoz4MtpTguTcUS6cDZZ 1V3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275369; x=1724880169; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k5B0V4ZEdQrdtO9pb5selC4LqFAQxYkVgI02+uDp6NY=; b=ahrphlOlje2Gum751uIF6eKlT+791+SuBjbFVwJBpj1mUISdD4qkoTokV9mQGT8VoU cSpx/8qma30mQIiiVumoxwgDjJIXjLNvTdK6oVshodBdo64fGwgwpZr6z/W7A6gr4F+4 U/28WVLD+Bi+HaqYkrfAxz/5bS+OWNSVitdujMvWvtYRaBL3JTwqrMn8+JfyzLEIuOpu ArqviqwlByrV1EIi1nDQII5cv4XJk7xzoQohGUibv23gAKK9ziEHt8SNjvrdEqOTkflo ASD4Vceo4GgnIS2davIhAoDtvqgMKpYJIyjS5y31z+wswrDFVqoHhdU6iwb/bdZel9oU BfCQ== X-Forwarded-Encrypted: i=1; AJvYcCWX7Urlvuhh8bi7AlwVF0m3mEvjrpsMQvoLLcQ+g819Wnb5+n2T9Nzzm2K73RJOs3D8NEcmDBQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxOleGAHUoZ+bzwrKnUK0yI7tJfWM8h70JrySJIR9o1XZCo+uxF MgmbWJ6QqRFw2ghjdfqAioKdhbq3LBdw/sq2AcIGVUOU45Q8JfY8/U9ksb52GH7Bg6jH0rlXHzk = X-Google-Smtp-Source: AGHT+IFJmiPBWsputoEAdkaoZ19DRRR5q9sLVaD1t528UjVcEKQybPEpl50dOZ0W2rkuTHUUj+bkkQ== X-Received: by 2002:a17:902:e747:b0:202:463d:250c with SMTP id d9443c01a7336-20367f6bf9bmr38536435ad.37.1724275369027; Wed, 21 Aug 2024 14:22:49 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:48 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 09/13] flow_dissector: Parse Geneve in UDP Date: Wed, 21 Aug 2024 14:22:08 -0700 Message-Id: <20240821212212.1795357-10-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Parse Geneve in a UDP encapsulation Signed-off-by: Tom Herbert --- net/core/flow_dissector.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 331848f90f78..307d4bb20e99 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -797,6 +798,29 @@ __skb_flow_dissect_vxlan(const struct sk_buff *skb, return FLOW_DISSECT_RET_PROTO_AGAIN; } +static enum flow_dissect_ret +__skb_flow_dissect_geneve(const struct sk_buff *skb, + struct flow_dissector *flow_dissector, + void *target_container, const void *data, + __be16 *p_proto, int *p_nhoff, int hlen, + unsigned int flags) +{ + struct genevehdr *hdr, _hdr; + + hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), data, hlen, + &_hdr); + if (!hdr) + return FLOW_DISSECT_RET_OUT_BAD; + + if (hdr->ver != 0) + return FLOW_DISSECT_RET_OUT_GOOD; + + *p_proto = hdr->proto_type; + *p_nhoff += sizeof(struct genevehdr) + (hdr->opt_len * 4); + + return FLOW_DISSECT_RET_PROTO_AGAIN; +} + /** * __skb_flow_dissect_batadv() - dissect batman-adv header * @skb: sk_buff to with the batman-adv header @@ -987,6 +1011,11 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, p_proto, &nhoff, hlen, flags, encap_type == UDP_ENCAP_VXLAN_GPE); break; + case UDP_ENCAP_GENEVE: + ret = __skb_flow_dissect_geneve(skb, flow_dissector, + target_container, data, + p_proto, &nhoff, hlen, flags); + break; default: break; } From patchwork Wed Aug 21 21:22:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772065 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32BE3178397 for ; Wed, 21 Aug 2024 21:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275372; cv=none; b=fmdy7AG//iLLnPM6hMTGE5M3i5/3kr9nFLvYnAxcSdEvCQbER3Xw1sbNTEDAx7cIpWi/qmck9gcnuQMvhoqLQ6SJIOUBtcEGzTy4+ZQ43qN47OKEgY/V+5I86new4dEpo3H+g9HMQQJtRWQyy0DpQ+Cv9TdsGqDNxPSTj5ZoYrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275372; c=relaxed/simple; bh=16IlvVKdZAjsDfMtf+vKADK8YbecS7XOAKwSjOwZ10U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jFBqAOTtcNtD4TtadVHGmLM8OW4qPzMT8p3I5EAO+QnNB/AMHvYbzcUKtcrlGQ8qP6jLQ/lznE2WIi6QstV42eO3hst44wAhte0Pw1/q6706OwuqpxJYnTey33FrobyKKs64sN2M73zvaD/gIpPY73v8+XAGBXY9VzQDP/WC8pI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=G7he8TZE; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="G7he8TZE" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-201df0b2df4so992545ad.0 for ; Wed, 21 Aug 2024 14:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275370; x=1724880170; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NhwiS23I0RwoQrtwCYtC0yWnRBVOuvRQOlXGuZ9qIvw=; b=G7he8TZELlvvWDZqKm8AZiYMC9P+xtKfZIu59QrRtLcCTUvFYOvHzebL67OadtTiNd XddhWuv8TiLIRX8H5CJ5wdAIkKLBDmo5LkCbOecd0qr6XNR/ykTMRhr5PVIPrFNCH9GR UZ+oUyUaPcS5KRQyA+e/a+BkZ50qpsHJn82X6QP6Ot0tDGBcRzAk/awW93e1SCV+PL2c iD+Lq/VAzCAZZnqWN+FKuFiVrTpOG9AGvII03+B5zSqbojgkd0vGxt1WOecaSwkr8Wkz a/FW8evESf/lYOYgYSfLG9BtrrignIWlbrOEVfwVqAsD2E0cvAP3YloUHLBTxreHzYM4 9R3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275370; x=1724880170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NhwiS23I0RwoQrtwCYtC0yWnRBVOuvRQOlXGuZ9qIvw=; b=BRD0+eZKB/pNa7QcqAsRUwfyRSSoj7xk28eCulyOAEhd4MRzy2LAYtZMGyu0GmGIbo cjg9WLnyqFWc4WGk0o8yaQBMSCr+F6tSP5CBhaUS4rOlYwDQLljBGjydjoXu09x7o1CB TQQk73eUCg7jWRwXc46gT/DpXCjpgImymTfnjJbNj/7mN+7EQcwJ0RdUbAK7ImmvDPlB /x79Tghz12XFYT5ggJl+jum85gcUTj/R6DvCJ5wKr+YViq9bkX9Rn5Ozpl/m5Ugt51NU g4yG9CI8SnTC732PDdJmit1Rdrddpd0t9EnuOEnEy4+i30J2soyFjsSc+nasm1sR6TsH J2rg== X-Forwarded-Encrypted: i=1; AJvYcCVxPkvistuaWHY8o5z8u2jPHNxIqIkDRhqrrOPEXQhjCrM7PRMaxYq6AqPzYwoNdSkV/mIMg9o=@vger.kernel.org X-Gm-Message-State: AOJu0YyuiSXch6+ThzDFq9y3DTysQ6ckfL/taf5f4y6mzKJtytKUfW00 LQYifo6ro0iNmAxhSiS8MxLD6Rl0n9uOfkwC4pWCiubdLONX9nSvVzCC5C7bCw== X-Google-Smtp-Source: AGHT+IGigd48/gWOW8zpTOltpfP0Hf16lKGKliL1Meslv7DbvM2+k9b3SA36hE0kDuSRCQNx4qbi6Q== X-Received: by 2002:a17:902:db05:b0:202:43fa:52f9 with SMTP id d9443c01a7336-2036806f2cemr39493155ad.29.1724275370477; Wed, 21 Aug 2024 14:22:50 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:50 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 10/13] flow_dissector: Parse GUE in UDP Date: Wed, 21 Aug 2024 14:22:09 -0700 Message-Id: <20240821212212.1795357-11-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Parse both version 0 and 1 of GUE encapsulated in UDP. Add helper function __skb_direct_ip_dissect to convert an IP header to IPPROTO_IPIP or IPPROTO_IPV6 (by looking just at the version number) Signed-off-by: Tom Herbert --- net/core/flow_dissector.c | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 307d4bb20e99..0a8398068756 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -821,6 +821,61 @@ __skb_flow_dissect_geneve(const struct sk_buff *skb, return FLOW_DISSECT_RET_PROTO_AGAIN; } +static __u8 +__skb_direct_ip_dissect(void *hdr) +{ + /* Direct encapsulation of IPv4 or IPv6 */ + + switch (((struct iphdr *)hdr)->version) { + case 4: + return IPPROTO_IPIP; + case 6: + return IPPROTO_IPV6; + default: + return 0; + } +} + +static enum flow_dissect_ret +__skb_flow_dissect_gue(const struct sk_buff *skb, + struct flow_dissector *flow_dissector, + void *target_container, const void *data, + __u8 *p_ip_proto, int *p_nhoff, + int hlen, unsigned int flags) +{ + struct guehdr *hdr, _hdr; + __u8 proto; + + hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), data, hlen, + &_hdr); + if (!hdr) + return FLOW_DISSECT_RET_OUT_BAD; + + switch (hdr->version) { + case 0: + if (unlikely(hdr->control)) + return FLOW_DISSECT_RET_OUT_GOOD; + + *p_nhoff += sizeof(struct guehdr) + (hdr->hlen << 2); + *p_ip_proto = hdr->proto_ctype; + + break; + case 1: + /* Direct encapsulation of IPv4 or IPv6 */ + + proto = __skb_direct_ip_dissect(hdr); + if (proto) { + *p_ip_proto = proto; + break; + } + fallthrough; + default: + return FLOW_DISSECT_RET_OUT_GOOD; + } + + return FLOW_DISSECT_RET_IPPROTO_AGAIN; +} + /** * __skb_flow_dissect_batadv() - dissect batman-adv header * @skb: sk_buff to with the batman-adv header @@ -1000,6 +1055,11 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, *p_ip_proto = fou_protocol; ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; break; + case UDP_ENCAP_GUE: + ret = __skb_flow_dissect_gue(skb, flow_dissector, + target_container, data, + p_ip_proto, p_nhoff, hlen, flags); + break; case UDP_ENCAP_SCTP: *p_ip_proto = IPPROTO_SCTP; ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; From patchwork Wed Aug 21 21:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772066 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF559176FA7 for ; Wed, 21 Aug 2024 21:22:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275374; cv=none; b=DOOhTmRikoV76ncnUx5QTjLpBa40WIS+pFyZan6Y9+qtiApiBGvnh3Lqi4cluG/HWRTelmem257/oo2vvpg6JsZ8Fe9CWk2SWBU43obJKOMsvKWICNPGPzi0rOi9DOl4sh5q6APZFx1ZcTqEibi6Ucrs6VCTMAIACS2CVDe/oME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275374; c=relaxed/simple; bh=0dAjiSIzgpkWEbT6ZjWDA//wTx8HCHscYHZ/Jdych2c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DzuQIq7u6QGtWOBuPQ5ToScTRqaS93mA38aUShp4JjenZtzpmqPOjv2e59S/J30+rM/W8IEOnhMmgrEMAMNgeJDAE+j2d5r7o13PSHFRAUTKeyDzMktDb55kZU1kYbTWOVY8U7++fuoTRJJmTy/HKxZxzQv8178nb0ZJ06wQcU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=aqdMvCXt; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="aqdMvCXt" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-201e64607a5so923325ad.2 for ; Wed, 21 Aug 2024 14:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275372; x=1724880172; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FAgVId2zqzrrH8Q5BmxNDksKhXoxgP0QIUZ2Htbs0Hw=; b=aqdMvCXtYTsCkPHKJbaWJ7ZaHAYmBz0RXnONE8WTIW9eJGPI9u/H9PGHFLUU0pXNNG 7eB9JuVKi7ZOFZgM2meUhkZ0LOf6IDitONwnsqCV9IRsG+SiBGyO6hoPKchDIEPxPgGG BbVZhGpgo9z28eOJLJLIChbCpTIxJdw29/fzwWut2lMbb90GtWovSksJQDTtM3BOg/9C xqH/3QrhmQU0HT0c4gc8rL6NWDdAhwnv9x8PEntz5htkFkuFi0+GDxzRdFgWMl87is68 zS2M4ag3WwcGSr9/BpkoRsnEM4fxu2x7wb0CtfSbKaJ64b5xv2ohKm0ArExVWO0HTKs6 VKKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275372; x=1724880172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FAgVId2zqzrrH8Q5BmxNDksKhXoxgP0QIUZ2Htbs0Hw=; b=m8vlLltjjtKuoWP7oIBInvv7Uqvg0r1vsc8LzZBHJbpcWnWyFmIkYOA84rc/XGQ3oQ uJz6V1NPaWc0UxYR28o5f/yx8Py8rcxLysuE3L3ESV/TE6NlqhHNv9V2T0k7w53MJ1G9 lF5usfi8fFHaV+jqYXSTaSbEDc8nNrtTYItmtRhgrccZauY1AXhUF3/S4R/mawBAiChU Ufyn2XQL2hANfdDoHw3hwq7m/CGp7F9860jqwBg4p/paRfMT70hqoM3WRgDak97Jh2ZH Mx/FnmnGILB+WkyFPY4Vu4li7NXzI4Bm/rqmMab38n+HQQcdpPtq6u7O8szfFplWz/Nc jIHA== X-Forwarded-Encrypted: i=1; AJvYcCUupm6XdZbrAtfd3upMyoMBb4qdRuf/gY4ViTvSrmnvpig1gB0eHZHejh2LEs95aTqEgivUe0c=@vger.kernel.org X-Gm-Message-State: AOJu0Yw86q42+UuUf5rDrWRieSdtPRrSMrhPkgpGrPSWdf9Vww9EVoI1 0Jof4Jehsf+KkGW6pxfm5/dLCyNmtLTVrTEPsAAVvUVrAwIif8QwqKGuoBqbxw== X-Google-Smtp-Source: AGHT+IFnmVuZScdusA+0lWWCTqusQ6sHvH/oY4WaXXXqc985alefrTEgPioEYnVR46Tw70tBiR9UuQ== X-Received: by 2002:a17:902:f68e:b0:1fa:2e45:bcb8 with SMTP id d9443c01a7336-20367bfcb3bmr48738025ad.2.1724275371871; Wed, 21 Aug 2024 14:22:51 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:51 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 11/13] gtp: Move gtp_parse_exthdrs into net/gtp.h Date: Wed, 21 Aug 2024 14:22:10 -0700 Message-Id: <20240821212212.1795357-12-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org gtp_parse_exthdrs is a generic function, move into a header file so we can call it outside of the GTP driver (specifically, we can call it from flow dissector) Signed-off-by: Tom Herbert --- drivers/net/gtp.c | 37 ------------------------------------- include/net/gtp.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 0696faf60013..259c7043d20c 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -742,43 +742,6 @@ static int gtp1u_handle_echo_resp(struct gtp_dev *gtp, struct sk_buff *skb) msg, 0, GTP_GENL_MCGRP, GFP_ATOMIC); } -static int gtp_parse_exthdrs(struct sk_buff *skb, unsigned int *hdrlen) -{ - struct gtp_ext_hdr *gtp_exthdr, _gtp_exthdr; - unsigned int offset = *hdrlen; - __u8 *next_type, _next_type; - - /* From 29.060: "The Extension Header Length field specifies the length - * of the particular Extension header in 4 octets units." - * - * This length field includes length field size itself (1 byte), - * payload (variable length) and next type (1 byte). The extension - * header is aligned to to 4 bytes. - */ - - do { - gtp_exthdr = skb_header_pointer(skb, offset, sizeof(*gtp_exthdr), - &_gtp_exthdr); - if (!gtp_exthdr || !gtp_exthdr->len) - return -1; - - offset += gtp_exthdr->len * 4; - - /* From 29.060: "If no such Header follows, then the value of - * the Next Extension Header Type shall be 0." - */ - next_type = skb_header_pointer(skb, offset - 1, - sizeof(_next_type), &_next_type); - if (!next_type) - return -1; - - } while (*next_type != 0); - - *hdrlen = offset; - - return 0; -} - static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) { unsigned int hdrlen = sizeof(struct udphdr) + diff --git a/include/net/gtp.h b/include/net/gtp.h index c0253c8702d0..a513aa1c7394 100644 --- a/include/net/gtp.h +++ b/include/net/gtp.h @@ -83,4 +83,42 @@ struct gtp_ext_hdr { __u8 data[]; }; +static inline int gtp_parse_exthdrs(const struct sk_buff *skb, + unsigned int *hdrlen) +{ + struct gtp_ext_hdr *gtp_exthdr, _gtp_exthdr; + unsigned int offset = *hdrlen; + __u8 *next_type, _next_type; + + /* From 29.060: "The Extension Header Length field specifies the length + * of the particular Extension header in 4 octets units." + * + * This length field includes length field size itself (1 byte), + * payload (variable length) and next type (1 byte). The extension + * header is aligned to 4 bytes. + */ + + do { + gtp_exthdr = skb_header_pointer(skb, offset, sizeof(*gtp_exthdr), + &_gtp_exthdr); + if (!gtp_exthdr || !gtp_exthdr->len) + return -1; + + offset += gtp_exthdr->len * 4; + + /* From 29.060: "If no such Header follows, then the value of + * the Next Extension Header Type shall be 0." + */ + next_type = skb_header_pointer(skb, offset - 1, + sizeof(_next_type), &_next_type); + if (!next_type) + return -1; + + } while (*next_type != 0); + + *hdrlen = offset; + + return 0; +} + #endif From patchwork Wed Aug 21 21:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772067 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 301E7178397 for ; Wed, 21 Aug 2024 21:22:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275375; cv=none; b=FME+iGxkKY9wVVtih2oMAFu7BQFEhymFfY5imlFc/nAn/7JiMhIFWIbZxXyu7XutRcnkb/NMNLxoCefaC66nxSqmG9NeXdVVqYzLEmt+k5qPzm9Q+ykjcA3CXfw9Iebbfsu5yZNtAVOt6MtBDR2CxIB0pYM1sHSDsrWMHoNRPKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275375; c=relaxed/simple; bh=cnD8LFJn8TZDxIa1ysgrwltIkpK9d6Wl+nQo5Q/8h+8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RgcdKouLZXOfhfaObw/PHXd2St4XxP//Vtf0RZRhXXlogtkPJxnuT+EJSoIM7L/0ruk1G5eaWFq0gSqFcMxBQVd+4nw3H22uAEBibcuNSVfdhp4oyRCCelxr2XOjFUJGCKpO2TVNhVep2YIEGWpMdT6VYv+SLRXVWgYLnA8WjVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=S+988jB7; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="S+988jB7" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20203988f37so1259495ad.1 for ; Wed, 21 Aug 2024 14:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275373; x=1724880173; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wqM8G2cuLTbcCpe04KSh789Vdwo3Fc+lpjauFdgQsRk=; b=S+988jB7M+qnYSFzaLfxGbuc4EeRUTWbbA5RiCwlg5S+wHHwMSIWU9j4ZULrlaAr7N /MW0d6OnHeMbN0+SCT40uoroiV4vcc43uGiNvLp+A94AlqFhmuBINp3rr8LdGjqqxYLs J+vmxOFHLa3nHmcod2OCZ7BaT0jqcF63jJCxSynAfYYySz+qWFeDYttCXj9dffQK0+W4 DdEJCeLQZQliJlUp12Y/sv+n5vIdBSCKrUxKdSa1Wf7NpabYkg6dsJy+iZfSK5iP4R4Q 2XYOEwgYI6qq8VRInovLusLGNZp0YegGPLmH3dzHjB3JjBlKZiUZLNQF/7NK2iAJvGb8 es4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275373; x=1724880173; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wqM8G2cuLTbcCpe04KSh789Vdwo3Fc+lpjauFdgQsRk=; b=U2qoXrbJF9sON1bjBO1p9ccmA8wzLrS/sZ07GBJClQ5aILX5rCX+ynmwiCT0ndnkej la68V2ZJ7BUStJyDN7eNNUEioRbzSICZlZhLGpUcBv1+T8tr7qNnypNrI0q26ZBI8ZL2 jkR9xy0BwTGsvwViOerOGF3wmhvTRurYewKFBV5HQlslIZxIwdoG3Cz2jZYc97X+anFR FnaIlVzxpHz1yvYGaAjI1ZUXoz4RYzQRnB7+bGtMj4U71SVKQD0/h2LA6ng1N/AxY8It +OOyFPg1joo5pC8UuGRyrTjcAD/aMOU0TtnU9B7EPabK3jg2o8zKWihO+zygYMsUoeEI 0nUQ== X-Forwarded-Encrypted: i=1; AJvYcCUlUA743MQbycccGQWgh/aauJBSHtxlabhGHcD/D5wUua+Dz/z73S+VK8UfYMv22cBtNblfF+E=@vger.kernel.org X-Gm-Message-State: AOJu0YyRv6cM/cqGEdD4n1TZuLn2QWnRcXbtz86BHUxNXxf6S9XN9xtp iZafsy7F+l8tcx6TXDwk2C/ieqCiOFxPs+WnZIvCTNQa46PXWDsMn181G0308w== X-Google-Smtp-Source: AGHT+IGd0OHwVtUb7Bjl/3ZGSS0VR72/7wzMBNFHhNhglBgtzUGgSWQwgkBa2wkcWZZHwY64V2D6tA== X-Received: by 2002:a17:902:e846:b0:1fb:415d:81ab with SMTP id d9443c01a7336-20367e64085mr39375255ad.20.1724275373294; Wed, 21 Aug 2024 14:22:53 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:52 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 12/13] flow_dissector: Parse gtp in UDP Date: Wed, 21 Aug 2024 14:22:11 -0700 Message-Id: <20240821212212.1795357-13-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Parse both version 0 and 1. Call __skb_direct_ip_dissect to determine IP version of the encapsulated packet Signed-off-by: Tom Herbert --- net/core/flow_dissector.c | 97 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 0a8398068756..ee80c2d2531c 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include #if IS_ENABLED(CONFIG_NF_CONNTRACK) #include @@ -876,6 +878,91 @@ __skb_flow_dissect_gue(const struct sk_buff *skb, return FLOW_DISSECT_RET_IPPROTO_AGAIN; } +static enum flow_dissect_ret +__skb_flow_dissect_gtp0(const struct sk_buff *skb, + struct flow_dissector *flow_dissector, + void *target_container, const void *data, + __u8 *p_ip_proto, int *p_nhoff, int hlen, + unsigned int flags) +{ + __u8 *ip_version, _ip_version, proto; + struct gtp0_header *hdr, _hdr; + + hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), data, hlen, + &_hdr); + if (!hdr) + return FLOW_DISSECT_RET_OUT_BAD; + + if ((hdr->flags >> 5) != GTP_V0) + return FLOW_DISSECT_RET_OUT_GOOD; + + ip_version = skb_header_pointer(skb, *p_nhoff + sizeof(_hdr), + sizeof(*ip_version), + &_ip_version); + if (!ip_version) + return FLOW_DISSECT_RET_OUT_BAD; + + proto = __skb_direct_ip_dissect(ip_version); + if (!proto) + return FLOW_DISSECT_RET_OUT_GOOD; + + *p_ip_proto = proto; + *p_nhoff += sizeof(struct gtp0_header); + + return FLOW_DISSECT_RET_IPPROTO_AGAIN; +} + +static enum flow_dissect_ret +__skb_flow_dissect_gtp1u(const struct sk_buff *skb, + struct flow_dissector *flow_dissector, + void *target_container, const void *data, + __u8 *p_ip_proto, int *p_nhoff, int hlen, + unsigned int flags) +{ + __u8 *ip_version, _ip_version, proto; + struct gtp1_header *hdr, _hdr; + int hdrlen = sizeof(_hdr); + + hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), data, hlen, + &_hdr); + if (!hdr) + return FLOW_DISSECT_RET_OUT_BAD; + + if ((hdr->flags >> 5) != GTP_V1) + return FLOW_DISSECT_RET_OUT_GOOD; + + if (hdr->type != GTP_TPDU) + return FLOW_DISSECT_RET_OUT_GOOD; + + if (hdr->flags & GTP1_F_MASK) + hdrlen += 4; + + /* Skip over GTP extension headers if they are present */ + if (hdr->flags & GTP1_F_EXTHDR && + gtp_parse_exthdrs(skb, &hdrlen) < 0) + return FLOW_DISSECT_RET_OUT_BAD; + + /* Exit if either NPDU or SEQ glags are set */ + if (hdr->flags & GTP1_F_NPDU || + hdr->flags & GTP1_F_SEQ) + return FLOW_DISSECT_RET_OUT_GOOD; + + ip_version = skb_header_pointer(skb, *p_nhoff + hdrlen, + sizeof(*ip_version), + &_ip_version); + if (!ip_version) + return FLOW_DISSECT_RET_OUT_GOOD; + + proto = __skb_direct_ip_dissect(ip_version); + if (!proto) + return FLOW_DISSECT_RET_OUT_GOOD; + + *p_ip_proto = proto; + *p_nhoff += hdrlen; + + return FLOW_DISSECT_RET_IPPROTO_AGAIN; +} + /** * __skb_flow_dissect_batadv() - dissect batman-adv header * @skb: sk_buff to with the batman-adv header @@ -1051,6 +1138,16 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net, *p_ip_proto = IPPROTO_L2TP; ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; break; + case UDP_ENCAP_GTP0: + ret = __skb_flow_dissect_gtp0(skb, flow_dissector, + target_container, data, + p_ip_proto, &nhoff, hlen, flags); + break; + case UDP_ENCAP_GTP1U: + ret = __skb_flow_dissect_gtp1u(skb, flow_dissector, + target_container, data, + p_ip_proto, &nhoff, hlen, flags); + break; case UDP_ENCAP_FOU: *p_ip_proto = fou_protocol; ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; From patchwork Wed Aug 21 21:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13772068 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63BEB17B50A for ; Wed, 21 Aug 2024 21:22:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275376; cv=none; b=gmNM+g+hQlQHH2NQdUiPDmrGJkGHgmaM6X8x3wOYu/qbAf4Cp+mIGKLaPj0bWtKX3twTTL4otaFpbhYci+m+cB+u+P0EX+/04ZI7Dpx/Vgmpqh82adRC8sSSqj1xQPik2c4ewKdegKHdPXTMuViOFNs4w8O9xnnlBAU6lM47NuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724275376; c=relaxed/simple; bh=J4jhXfuZXVsA1fnIFK2aBdNRhCqvs1bcYCs4askDyfE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S2HJSfxTGwnQdM4eSxF3rv2a5yynAEtITbmiJH5E6bs0YEcspKhzSaES4EE6aX0SxCO4EJBMm/o+JUPcqLEtOV4XqnFb0u/MoC9CBjst0Sd57q+1tPYtKIdlxFStTBzjDhDV3ezZ4SB+qlsST64G1rqLbAec0HqdYfTZ3yDWSrE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com; spf=pass smtp.mailfrom=herbertland.com; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b=cE72wCy4; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="cE72wCy4" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20219a0fe4dso1322285ad.2 for ; Wed, 21 Aug 2024 14:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724275375; x=1724880175; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DWlusxC/4B0Tt61cIudea7r7QbRBK/lDmlXELXrJz3M=; b=cE72wCy4ZBc0/+0WNT87HK3J9cAklPodIGlL5+BOF9+3G7b+gj/e+3BO1rGU0L2VFw 5LwejM+SovcjvFSdgXUcJ68wA7oUt0gSgRHATlO2+vX8B84HtxcnN8PORm9LjS8wMRhr VELXamehS74j48oKC0AfqdXSExR9hXXMyRBATlAWSjkZK1ffbisYV89JYfSGtIAOX50u NU/zP0NC+bHgNyGsq76WE+4UpzLd6wnDCP46+aGMnLM0abtvAS5eD5h8sUS1HfkKdENO iWsf3c9O+GX/V5+xRr6rv2IcDwUNwGWbBvrLZkUoW0vi2s2gLGabwEt3iprFR1mbVKUZ Qb0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275375; x=1724880175; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DWlusxC/4B0Tt61cIudea7r7QbRBK/lDmlXELXrJz3M=; b=MmYL0iMKuGi8iKbW0YqC1FGarbooCqUtEyGiwXg6b909WoFspbR9qFwXPgA5TD7lrc GSJq5cOYSYXdfFJZAweCBQoVqpoGUtQXfZ12dc0bQYarFBMYvtxzzAhj41SWxTmMJdIe JOb9rfV5m11gyUoInNmz/NeXAZZhk3DKwA0vuOOq68YwP0tNb7bm6o2TheeLUS16cJx4 roWS43u5hgRGqeqwQnaDjIqFOTvPik2ceHYDl7Ag2Cvq++arGuUTRmD3mJPo8JLYgcJH v6NPQxyLLQLxVTL+knrqzE+x0eTRvoq8c1Yt/5GJIPaoJu5I4CAK2cTWoIno4JtCRAx4 FtKg== X-Forwarded-Encrypted: i=1; AJvYcCV/KbjJfCCSqzFZkLUvqpiWFQBKyC9ld9qN0FRvqWPvT6KckwjiBKHGyBPPgqQO1MVRRYMm6qc=@vger.kernel.org X-Gm-Message-State: AOJu0YyNjb+wKjPSHC/uh8PoNSRjuTH04le8ySlKoOfy+8AhdOzGK3gd xr2ORkpdfJSTbrBXukqfEQeUWxl6FviW5EozmUbr76Xsk8wnBWEL4XMtRcO40g== X-Google-Smtp-Source: AGHT+IESiY6uqwnmtMIbInVxU4n1CDlMMGRMdJ7VdPyUHrT0bhOlkUfkdS5w3apy4szvXnLNBbf02A== X-Received: by 2002:a17:902:e546:b0:1fb:8245:fdeb with SMTP id d9443c01a7336-203681c3183mr39163705ad.64.1724275374698; Wed, 21 Aug 2024 14:22:54 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:7a19:cf52:b518:f0d2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385ae701dsm388265ad.236.2024.08.21.14.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 14:22:54 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io, willemdebruijn.kernel@gmail.com, pablo@netfilter.org, laforge@gnumonks.org, xeb@mail.ru Cc: Tom Herbert Subject: [PATCH net-next v3 13/13] flow_dissector: Add case in ipproto switch for NEXTHDR_NONE Date: Wed, 21 Aug 2024 14:22:12 -0700 Message-Id: <20240821212212.1795357-14-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821212212.1795357-1-tom@herbertland.com> References: <20240821212212.1795357-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Protocol number 59 (no-next-header) means nothing follows the IP header, break out of the flow dissector loop on FLOW_DISSECT_RET_OUT_GOOD when encountered in a packet Signed-off-by: Tom Herbert --- net/core/flow_dissector.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index ee80c2d2531c..e34c1b6c36e3 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1991,6 +1991,9 @@ bool __skb_flow_dissect(const struct net *net, fdret = FLOW_DISSECT_RET_OUT_GOOD; break; } + case NEXTHDR_NONE: + fdret = FLOW_DISSECT_RET_OUT_GOOD; + break; case IPPROTO_IPIP: if (flags & FLOW_DISSECTOR_F_STOP_BEFORE_ENCAP) { fdret = FLOW_DISSECT_RET_OUT_GOOD;