From patchwork Fri Aug 23 20:15:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775987 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.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 DBB57194147 for ; Fri, 23 Aug 2024 20:16:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444170; cv=none; b=TSI0ZeLjtny0CUu+3/SxYezH0LBH9hHc31LDUYaG2bKYcuLs5Bp+/sfUFKlQG/6LHL0pE5WZVXMZVnyYdU5eGJc3yYZsnVWgG5lMqFhDZWWZ7DEzhK+REXzms6TXiKcv6OmtM8E5wlXKbEcyP7VGhGZY/MS1lSoaVI/N6P9+A2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444170; c=relaxed/simple; bh=eU0j3/8rJg2aPvh4RwRcGS6M4omz/kWqfL82UJkQcUI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EpUijhuBzGT6ImqQcBMnibNmqnTtFt325U1xoMrxwefqjTBD9kNi6uW1zIRnQrKi2HflnJbil5B/qrbE5JkQxaWS8ZYfBqae2PAHFhwVg4XTWlNVh+rWJTzYQcLI3P8yR/NvYadt0hPvfW1Zq3y3A2ZZ2GGKn5IR1xbTe1et7GQ= 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=bVgPThgc; arc=none smtp.client-ip=209.85.210.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="bVgPThgc" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-713edc53429so1953516b3a.2 for ; Fri, 23 Aug 2024 13:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444168; x=1725048968; 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=bVgPThgc2NRHZyeLkBsv55D/WY8a6h7uGTGL4SKhxH3Jvf1RtddQtMopTHZKcCOdur wucxP05gwyXKFaRCs5VX4oLERivCy0FE8hy3aK7dK5HCLENe3l1nbMmHPYQG+nVlyxyC 6H1OUXMH6urIjLtjx7xKuAefPTFELfg5YDIRNhFRnehq6HPVvk8GWVV2yPx4Y/aAhONO u3LCqY3/u/1yYl4AY0P/8FMT5B/tTcrbyQZfLSS57q2eDt7YGz+3VBeGVv8LXuZd/Uxd gtZNBRCDOBDTkpFuW0drFEcrq5Fb8nPQkdXLGdXC1rYRKqltc3x3whrVxIr7XFVS44dD BM2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444168; x=1725048968; 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=bpnKFKXIqbrGBYF39mF69gOZBK8S2jjc8/75Ewf6VwRLlBNZgVfwz5ynIe/4M94NsZ 2VYtlrtlxisOPInBTfAYA6nMV6oNnrDjEwZrgWoR+FPLyffN/86rXbcCJCRtt7oA+Pct NVMjtIAvVbJuIed0B6Xp6I4cQb44PXPeGbPeHK2GWR37aQ2NXhauUHF/3CpDqsSJlSkm EI3vXcPl0514EarSXZhFcDuVucYztyU9DCAgtyh6mDWQz9uaBnDrFqZTU+P+xWCQef+D hbBtb0EE6Q2ruWB73E/8tsk09JNu15a00r8sEjdtjME6YC2WKIN7RTnjzgIkV9M3tM0J ZFsg== X-Forwarded-Encrypted: i=1; AJvYcCW22mx3rm1GEzAbSdvfg87aUDK6XHa/zX744syIQs6sFzguZ9pNlfGv+vHxZgA793UNMkK4T7A=@vger.kernel.org X-Gm-Message-State: AOJu0Yw11uTGN0Lh5Nc+ZYUpA55POArKkF04bdjs1ajCUPuWEajakdgD H9xWzwoUcMd4Z3doZebrQ5oNaFc7w/Ktg7LO9v61ahGlJQ32cFPOk9RBPS8xfg== X-Google-Smtp-Source: AGHT+IGikXl2xCudNl0p/N806W2b5LcalpbKN7512RPrrAy+lWYw/SeeRngQWhHDV1nL754nOQY59w== X-Received: by 2002:a05:6a00:2383:b0:706:3329:5533 with SMTP id d2e1a72fcca58-7144587f44fmr4665115b3a.24.1724444167996; Fri, 23 Aug 2024 13:16:07 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:06 -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 v4 01/13] ipv6: Add udp6_lib_lookup to IPv6 stubs Date: Fri, 23 Aug 2024 13:15:45 -0700 Message-Id: <20240823201557.1794985-2-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 Fri Aug 23 20:15:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775988 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 73B27194A49 for ; Fri, 23 Aug 2024 20:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444173; cv=none; b=Y+GjkmGxO5d9b103s99PJnbQ/CbfqoIYv7g9ObxqS44T1/LO87m72s3/VGUuRG/WlF8yRxC3IPSsG0gVkhGuvEnUP2hf62NZf9upt6TJIUi8w+sHXvhlG6+iMiQGIOXHkudMh0YhqUbeA4oiopwpjY1mB69EhSXppfP0HqZZbAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444173; c=relaxed/simple; bh=CCZmy3roTcoldWMY3Np2LMkMsQ2dOSmXCqOYrD/u33c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mqCIcWUMatMFc3IVNTJrIhVTjX+nLcsa486Y4gaTAOv7NY+0WGsgRmKL0gtjanNxQ5WMPotkEwiLd7fMu5sZkr3Ofm9ejjkOKi8DlLIW5TC8GsUG5BzF5G8/ls3iakHh3wC7NRXsDVzwgD0dnw/7FGtOpQlXUi9DWDvsnIyVXg0= 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=WYVBuoBb; arc=none smtp.client-ip=209.85.210.178 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="WYVBuoBb" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71439adca73so1824398b3a.0 for ; Fri, 23 Aug 2024 13:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444170; x=1725048970; 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=WYVBuoBbZzSfyOiruH+SQRtGBoOApbraD2F9i1RitSP1N5tIMYng9WptH+KfGppb5J +WIB4dOr/X8gExlyfbUmCQAdjKedn6y6pSfB8O+lqId9JapCz/YlMy+PFRJoH5UP8dfG A+C3O8Fe5THFrLYKTHIHpLA4Bbd6fnJvuIDSdhpHJTE81UGprx0NKYK3GbPCqdNcQuHO e0ByWvpNodEN5ab6/UPbPU99851lF5e+yoj7AbjeK1VS4MM8iKO3FNHfia4VvCSbERNJ yj6PhiQ2FTBewxVyWkfgMG4L32uApYTYv4N7kkW9UAxeX3oJVuNuCG9OP02eUssbYYgy NxhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444170; x=1725048970; 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=eZTZVCzWJS46iBTEolRTkEjn11oRqP1+riGTWyyDZkm6CfEKdF2w71FNDkbe8T3BWx m4hAZoKahiOO8fn1ICbC0Mn3b3F3yOlRqBoOQ37GhBxq6Jxa2mCgDGdqt9EtdDal8ANk jmV7CiA7/w4wlzb1ev/jxpB8QTPGXSsF5f/bzmTBF1+eVYMl1AVNARMkjfyet7yCr1kh PkSA+bR6fgYzsvaDHpSaxo929MUX0uc+v3eMdbEnKuDa2fAnJNYfb0lBPi4COWFElohE H+eYKRLR7dsEO+4+LXxsfisvjQEKiFg9apSDqIw0L/+OYMmDJUL7MZXPhTDtVu8Ci58A y1nQ== X-Forwarded-Encrypted: i=1; AJvYcCUioYOtjnWw8yJxQ1kDncyQmr5ys7TBsVPppMtO/n+YbjvgrDzKsJiZC0/bqsbukbnB3gXlIek=@vger.kernel.org X-Gm-Message-State: AOJu0Yxxq/zT7S0LYgOAJIffesjDRgB+gK49Al5Bd1VTOdFqMq4ht85S lgHDbV9LjLzF2vFrL+OyOgE83i5Qdyf1Gan3f5ux1Rqejg/YisG/s5gNwSi3s4+JsZld/Dvd+9w = X-Google-Smtp-Source: AGHT+IEwpSNa8jZ4oZu0FAZzUZAVdglotwRbJWzNRi7TDjGNRdqHyZ8eKNeURjkByM3iNp4+7RqDUQ== X-Received: by 2002:a05:6a00:944f:b0:714:2198:26b9 with SMTP id d2e1a72fcca58-714457d6995mr3959260b3a.13.1724444169524; Fri, 23 Aug 2024 13:16:09 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:09 -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 v4 02/13] flow_dissector: Parse ETH_P_TEB and move out of GRE Date: Fri, 23 Aug 2024 13:15:46 -0700 Message-Id: <20240823201557.1794985-3-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 Fri Aug 23 20:15:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775989 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 EAB95194147 for ; Fri, 23 Aug 2024 20:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444173; cv=none; b=WObu546yO6eOlAJz2mRmlPM06PQXKToaAk2f0LxO/UW9sGDhjy+Io5nIZJoy/BTG8ATcJs8yDEfSU0UCQ7Wf+fiq9znjA6/J6PDjikXsOx+vWoLXuBQOK68xLJ7NLYh4dWOIUYKt40rsLMsZ8RjI7UTsScwWUYeedczhiINY7cQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444173; c=relaxed/simple; bh=YyZztFICIyC3NZU6IESwORkmV0LZE0KdGN1JMoaO8nw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=USxr+POm+4r/wWIUN3hOcIbEfxP/9ZJTmQuxSt60IouJZAJeMkPDvC/oUJaZkAVJBPJVeP2dnvfHSe1YvU2ZqGqjzlMWShgltqp1ruNQ18Oj03v1vZEumgktL1ZUSmxwEryQ7pevaTOU48YJo5t9meQ24XmIEqvvFlxxD19s6QA= 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=LB+5OwfW; arc=none smtp.client-ip=209.85.210.178 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="LB+5OwfW" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-7141285db14so2176268b3a.1 for ; Fri, 23 Aug 2024 13:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444171; x=1725048971; 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=LB+5OwfWbuX+fSMgNmAgqiqONrwjdcTsP8+YDD0uMqmIr4qxXA4nNaTA0eZ98Ibb3b Sy0fNCuBjit01I/DsjD8VmLIh/XAXuNjixvYepy6rt8WbEvUufsX6MHTAQh4NgLButw7 /1ov+ALWmTT35d4EbOFcukRkTPGyKe0UsuCQbHEI8ubOBNqHzuRMeleRxRap4RrgJl9/ ew5p6VKzRuG5b5Etskvw6NHO6jY+I0omK13UNvE4zREjkSEIh9tj4X9pmJhvHPkaHFqs 0alOQl8xjuHJLcl/Z7Xzgj3nfISL6EunsD0GjPNPuvxLkzsgnbFJUCQqTtNKk1jPkVvM Sxfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444171; x=1725048971; 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=DI2V6t8UnkkGwoBBRpYdHErfKSbjk7apxcpkU5MSgKmJoGGZ5GOFf4Jmx1wf2gspaV qB5LbPaJN2xzb9cWst7sIXdOyrd2srJTYMlULkl+X+F3KGzqdB4R/9XMum/EqWfxjXhs R88wEud5jdpc0DsMNuPU1jfjFnAuTghWiHmFXqAkR+AarkgeySo9Jfy11cRPror8/mq1 EgfIYPyPyKJLe97fG3gMNzYuQRswfxRmKh/9FEVS44Oe7KY9jLhGhW4CX/j9XBYPcxPR PQAuWJU4tyVbubXeQIMCpelqZ/e5PaUwW2AALV3d1YQJcuBgjI7oSOMvO/tPeFHXkd36 QRfw== X-Forwarded-Encrypted: i=1; AJvYcCXiXeNYeOjbR1VmwylJwANdGbWdbGoB2otLWTFhP+JX3pRzA2ISk5On8jolD8DhLnvny7e5AqQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzLcaL3Au/DyHNr4/sGYS+cvtZifpvW95JpFQYG0m1St6Y6FVhc oqMgNtbBj/k0ji0VEzFhSImezfs/Pu5TOMsymoxfrrlD2A1fvC54dcWfbl+ZxA== X-Google-Smtp-Source: AGHT+IFpdEBxZYkyTsBV3dhEjE1uuP4JaCzJT+eNqeHnK5vx3bQT1Y6VxZXRElD59737tCcmEKDppQ== X-Received: by 2002:a05:6a21:339a:b0:1cc:961f:33c6 with SMTP id adf61e73a8af0-1cc961f36e0mr2268260637.19.1724444171029; Fri, 23 Aug 2024 13:16:11 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:10 -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 v4 03/13] udp_encaps: Add new UDP_ENCAP constants Date: Fri, 23 Aug 2024 13:15:47 -0700 Message-Id: <20240823201557.1794985-4-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 Fri Aug 23 20:15:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775990 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 740D5194A4B for ; Fri, 23 Aug 2024 20:16:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444175; cv=none; b=PVPD6ukn9VzD9TpSN4GdgvlwKJS/JcXsjmkmuikyOn0vLtqich6hbOLeU8FfDS0lfFs4qYcwZ5rb1iZrpnYEbNxlNDHM1+4Nxt1wWr7sIKFKUXyxFWwv324uGUfLW4wOUaNwgrTtKdOMgM6X7r7+csAnl1W42d2RIAyp8P30j7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444175; c=relaxed/simple; bh=nYu8yZ/VN1Dg7+BXBxyOnOybgHomc2LXxWLVKv9ctjk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qaPJ3mgPuFc+8bm1TU55sA/eymNzZRfgLl8A5gwJGlU2intH3xP40rSMmJxc5UPdhGHvJwLWJZxoD0JMIJn/pQV05i5lHmJolDKIikDmQz///hje7bdb2yPX1lvcwCYLyvSXzUsIQTpIwHUK82MBCVml0YGP5BjhG7Hnaxv9WRo= 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=SPzXxcn3; arc=none smtp.client-ip=209.85.215.178 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="SPzXxcn3" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7c3d9a5e050so1692083a12.2 for ; Fri, 23 Aug 2024 13:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444173; x=1725048973; 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=SPzXxcn3xLnF3ZX1zSZbfz/0nqvpuvBP734pWn/qz++YXDtloPjOpUkAqdBAVDQTIg 9KuFdmWJ4Buzf4fcsZ3A1sZoHRPzsUSyLoeOgP6dQX/2T857w8ltOyjdNdDRgkjegyur TVPaAX2asyL90a/pqUYfZwBnYse3JMBL15pMfCTaopYt+o4pefbz6WoXAxqGc0DGiDTn 6sODSa1CI5JQG/Sx+Do99vcCNM5zpXBwZ+JbKL++FbiF2ngwD3IHIDAbVNIgKbZZnu0Q pwqJuKUEaurTjjl8hqQ/pV9343/N3WODNsnmi2J22zjIdqyVIaYzVRjBHgTeNNamwuUX IUrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444173; x=1725048973; 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=aTO5UejOFFwhHf2+oXLSZQfaxW9pvWikVsxsLcdCDfN69Ir/O6i/nW+NHd0yw0DU9l vmTz97TDUInvwlpItFy7N6p3qdRbYVTKvU7WkYd4NcH3IJlz88hMX7is+5doteBnwvlM tl/0RsbFuG/D27GeHZ4uIPyRfXAFBdOYlPynWlQ9mjGrx5+ydRAwJ3WYQQ2DbMSSxAgN QjT28cX9irm7Qi2H6+3DDNYsb6eQcv7owgLeO7ojGhCd4ixSoZKRgEO02JLZrMB7vI1Q 0PIUiudZ/B4QOgLu3+QG2KAa6sulbuZYv4+nFs6I10+qAPrC8YRjxgyvAz90FG4g6TdB hbnQ== X-Forwarded-Encrypted: i=1; AJvYcCXz/MNwKKgPKUkPYwZPiXIXmhTNlM/VgqePcvwze5yyVkqU1uNJUn0phf1iBdGeFMS3jABQxZs=@vger.kernel.org X-Gm-Message-State: AOJu0YzleFbnGAagV1yetVd44D2S85rJQ+Q17CEnQnDg7qWPyNclSFLs i31mjRWOJKeZYo6ePuRvrK49B+YMV5xbahwbuHHOvzNBrByKxrsXGoE+Jll2Gg== X-Google-Smtp-Source: AGHT+IGHSkqxYcDFAOOvjm88ZooDqYYtfq407lxNHMIeEh+vrN5XsgnEkmZ6LyfL67baGL3uOVQihw== X-Received: by 2002:a05:6a20:9d90:b0:1ca:ccfc:eddb with SMTP id adf61e73a8af0-1cc8a2679demr3916513637.49.1724444172566; Fri, 23 Aug 2024 13:16:12 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:12 -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 v4 04/13] udp_encaps: Set proper UDP_ENCAP types in tunnel setup Date: Fri, 23 Aug 2024 13:15:48 -0700 Message-Id: <20240823201557.1794985-5-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 Fri Aug 23 20:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775991 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.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 EDA4B1940B5 for ; Fri, 23 Aug 2024 20:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444176; cv=none; b=PNAcrc7i+eLw8kkX4fjnX/WijG9OgBvoE/yYEy7DJCfg58Y1WmzzESjDfFuBdTKstifgzuXxJ7gys9QNbVhzXaRrqOM1ZtAywJlhoXZ38oOEqTiUHqy+gwHMwpkiRktChV8PXEf3xF4U2/6iMZk7F9AJy00UKZqkR3MvjJCy9P8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444176; c=relaxed/simple; bh=op1twAxSHU3hRk6SpGinbT6uqFzUumefX7loJ2CE2y8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CHZ4vnsdoYxEbUXydmKqpvB9sHiAbomZHBE5YKNXAwiQGxpdW09LtaLtBG/2LEJRitUHd4AfI2z6VPXYjkoDa7o6n8NN9BPdPMzhbLDuwOHvIYhgCD+uo5EPmQUYUrCDvauGVsPFSbR18oLOkqQTbfC0erzxztjtO4paaem9NLw= 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=H/iz6p9w; arc=none smtp.client-ip=209.85.210.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="H/iz6p9w" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-714287e4083so2142799b3a.2 for ; Fri, 23 Aug 2024 13:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444174; x=1725048974; 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=nv0jy74cDRROYRqyx5fpkhp9fmqxEfPxq11gk0t/z6Q=; b=H/iz6p9wlP1gdGbC/3T/4NMMkdhN8THyYdvUyUksf/NNEcwE4gfpCXjTQOBzNu44yx Ik4IYVu0gpfBxKJsQyTz7eJ93LyKxPCsmN6JWzeHbj5rbJZRwklQVGq3J1bW4wAhtVyx LFVwY9adoWALeUXT2UERm9zQhKFB9HbwbFV2ET492P1ei+/3fRxfqO+IXeeNW+otPWtr hPjWOySPOnEsdT5W0JK3KB/Uhc2l73LLx3MZIc36mW3OO6PekIBMwdQuMCf9FvkxDHkf 612HuA2BUTiQy54YtB5wCeJKKH/+lHgtQt3RhO5mCmwn9TtpvIi4zzqv5LD1cWPPui8u sdHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444174; x=1725048974; 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=nv0jy74cDRROYRqyx5fpkhp9fmqxEfPxq11gk0t/z6Q=; b=sY7vDypyFO3F4V1xGCYhVZY8t+0A9A/g5R/qNBhiyC3HO+kmBmN3lbYFxOAhuqPgI4 57UOxBqV2fH3x1KQGrAS/t8o7DPrl76zyvsmLmXl+jy7FROjyE+0nhRezPXkc+Z+OXtI UK7fUkIvea7I/UbN8oJgqcyYk1Eq791fOQBVs7AjQAyXb5jAkNRCiCllhO1aLOe4CV8u 1m+jRhUHgBWreba4qpPQC6O3AEDcI4cM/H5tzSEVEIQ/VsUbaw4lgHn9HV2RIlbXLzvy 8yKWxMqI9KtJrpjHtXMzU326E2/YqZ0mhQ38JXBJVusJ0/9DYVDtHiOd9IG4399IW74f 15xQ== X-Forwarded-Encrypted: i=1; AJvYcCXCNa+Izyvnp6uTlxb2Z5EyK+2FQSZDRF7Jd2dTg2mO8ZDnpdGEn+3qpSbbL6KgAnmIVEO0Jqg=@vger.kernel.org X-Gm-Message-State: AOJu0Yxnp10eCYtc9IYtjVtf5skfvq3953+Qqh6O1y9XFgNRH/np0atI y1ASEfLgMgfn8GDVE6NYEXrb7w4x6UMlHCibo6pjyJ569Tf9AuYaRdrXwGW+xA== X-Google-Smtp-Source: AGHT+IHOoibAEa0IvBwdYWnlq6KnZD6zWRJfAlagjFiipdD1/ynzgnielHQrvxFCf9vMfEG6mZHhNA== X-Received: by 2002:a05:6a21:e89:b0:1ca:cccd:4a1c with SMTP id adf61e73a8af0-1cc8b5d898amr3002156637.43.1724444174052; Fri, 23 Aug 2024 13:16:14 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:13 -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 v4 05/13] flow_dissector: UDP encap infrastructure Date: Fri, 23 Aug 2024 13:15:49 -0700 Message-Id: <20240823201557.1794985-6-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 | 138 +++++++++++++++++++++++++++++++++++ 2 files changed, 139 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..f3134804a1db 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,134 @@ __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; + struct udphdr _udph; + 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 udphdr *udph; + const struct iphdr *iph; + struct iphdr _iph; + struct sock *sk; + + 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; + const struct udphdr *udph; + struct ipv6hdr _iph; + struct sock *sk; + + 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 +1175,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 +1298,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 +1780,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 Fri Aug 23 20:15:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775992 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.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 B16B1194A75 for ; Fri, 23 Aug 2024 20:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444178; cv=none; b=ftqEl4tlQK7NmrzaEqbiadfTMDgALYgvnavaeSMDsv397wZyyBL0Qg6Sw16aft8HK7ZeVfZSK64Sl2xycudI3r3wKu+nbMp6X4/VHQ1BMfBMs0RFtsZCa6JuXIETB6ac+3n5IAF8HYgDDNlqie1e9jlio8bo38526+DAEG4kBlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444178; c=relaxed/simple; bh=3zXqjd6T7OAkkVyPtynFctJzHiviWc01ugeuIPQDJlc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P3yaHXlUowfTMPL5Sfh7d8T7P6ajbz/F4WtD+899jdki2BRU4RmbiiHoUQr3UAnZlo968DidUUiEFcuIFEXWabVuOMzSgowA5LZokruMbaMdB3Y2GfjB7gCvKznUHQ2kT5OTMIr/m411JkNZWs1Xg7Ia+s84DrwpCy9wyGDU1RQ= 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=Nrk1wkZI; arc=none smtp.client-ip=209.85.210.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="Nrk1wkZI" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-7141b04e7b5so1513663b3a.2 for ; Fri, 23 Aug 2024 13:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444176; x=1725048976; 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=PmN31OVcMhNWNVNEtEZ2hIEFQuF/DCs+aqdarr054Cw=; b=Nrk1wkZIQ4qcuk4UzFJ+AVHJkhTl3CXzESQtANlscHN1k72glqpOyiK5q5G76AB+Rd cnEcxzR5Tq5IcCTCayxLu17Nu8Kq1aJZsySiArglhT2bMoAO0qFlnapnxY4MMOro70bg oXMvGFOJ/ZX4hrThqZwzZEDPPy0VKYB3S4oInTP+JsrkN/RkykW8dRk7foMSNNSsDpPB Tj+k3R34UkXi+JuWi8Il8Ztqds7vCevl0G+vzhS+pROMyiE3lzP52yk8J9b8GbDycyEz 6dWhBk5o/OANsDEZMWQLevBP+NgUABdP2ps3XrBlBzejbA35RPAlTaF48BnqHHFZVPC6 dIJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444176; x=1725048976; 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=PmN31OVcMhNWNVNEtEZ2hIEFQuF/DCs+aqdarr054Cw=; b=sX+7kx8EbnQ1Ja7ChwMapa8wXPu+IbAfz0j96VA/CCYNYWJ8g4+/MLa4pLk73WBe8h F/2u5IiYkG+WQXNAoUnPpeUhSQxcEPQtUZwhqCQm//WJ9Nr5UyC4iG00cNkPdxyQ8i0K nPtuUGt42nRRbVX0w66uxa+LYSeGR+sefTKWfM4hkUh48YWiJC/qCQi4ux69tbRg8kXy BJwWJwE7JJUhrK8/r7BqCdO9slZCOZYLE4d6P77c9R4DG/KaFeHGXewRKZ3+G0dvV4yH gGvEpTTAy7/tAn7v9+KwrqNuwGbiOVSopF9NZ97lPMbTqkky88JECMrfYM5n+Lvej4wG NVpQ== X-Forwarded-Encrypted: i=1; AJvYcCUDPgRqbHWKPpg/U1TROatnarQn1MAAFpvtj1JvafxSe50ZL6nbRIk2Z+h3X55+d2EC2OWx8s0=@vger.kernel.org X-Gm-Message-State: AOJu0YxUolIvFMt2L9BC1qFUPym2cyGb2fredTnTf6sQ2fOGavnfGss2 xq9AMJBy5my6JSPz6smlDjf/43fUsZMkK+U5HCzelS+lAs2AVTrVbi8BLEd+Bn5saDb2DDfl9Mk = X-Google-Smtp-Source: AGHT+IGOEWssWAXO+yM7Zxlb93fs4cQ4LccBhzcvbs5Q7JEljk2cc0twnRKmmSXUwzYwwMXppZxcGQ== X-Received: by 2002:a05:6a00:847:b0:706:6b29:9cf0 with SMTP id d2e1a72fcca58-714458e02f5mr3685026b3a.30.1724444175777; Fri, 23 Aug 2024 13:16:15 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:15 -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 v4 06/13] flow_dissector: Parse vxlan in UDP Date: Fri, 23 Aug 2024 13:15:50 -0700 Message-Id: <20240823201557.1794985-7-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 f3134804a1db..49feea3fec56 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 @@ -917,6 +957,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 Fri Aug 23 20:15:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775993 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.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 0C4B01940B5 for ; Fri, 23 Aug 2024 20:16:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444179; cv=none; b=mDFaLQrV3al5KkWe5VyglNmYt71F/4+Kywp4CnuRUUNueltvcG0TrU1/PzmChBFCfc+RSntCrEVM3BuaMv9JZhCPbwandqSoqUjb/y84+KCcKBUqdcAxsIrRTYWqmtKvMxKfzmhZt1B65486QNTkEtLtBTTjrcM4Ab0cj9+fj2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444179; c=relaxed/simple; bh=F6OllGcU6yuYlZOEbg/dfHvFSpbltkoo+4zTmYf1kRA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aqqyCGrhGtvtAuG7Dyo4EORNCvSLWeE92sERx1Hsc+lYHQ4oYONC6yc+sOppXlbhs/gix/rE7QQIbVrD5uIBA7rUSx04oGV25tfA9OW8/dpkaqEvau03V7UnWj+3dYZ1v0fsWjG7IZephMVS1Xq7SP9nHqu0hY7BT/QZ7Jfgk00= 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=O5+/ug4e; arc=none smtp.client-ip=209.85.210.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="O5+/ug4e" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7141feed424so2183020b3a.2 for ; Fri, 23 Aug 2024 13:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444177; x=1725048977; 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=HWXbPxeYHeGajvaLgNvKzNYOpsN47QGTGqJHcAwu8Dk=; b=O5+/ug4eCBzK8qBaC6rfhdDjAxE0S17MXmqtiV4t5mTdhqj2Zjhdeyv+NG80Ogar/a Xx8LjuhL9nkC39jZoQk5yoVjoEPzbqawV6t6TbBQ7WTXO1S8bow4lT7x7j+thVw/66w1 3S86E2Uvv2p+onCgrxX+feOVNMY+4S33dNhBKIN11j4F2sGLtNWGqacwOIJQeJnRqr2h HoUOvsS/uSqJk8NE/e3CFsSAe16YzQtapMEMkySLl41oiuKUMiNAnvWnUAvhRL35UFoQ wq74LbKk1EIBVGDwlWsS0a2B83mRqxHMDq1Mx7aC8TqOeTZRX1QGE6tj2mO+PciNpXFx dnvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444177; x=1725048977; 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=HWXbPxeYHeGajvaLgNvKzNYOpsN47QGTGqJHcAwu8Dk=; b=nV1mItjcYeK3Af0qay8ItmbrNOTolVXP14kUP0kjje+Yi24UvC8pN2GDUL/BpXHmUd aTG5qBt0ge31bs3YxdioG0PP4Rfhp0F4pvgg7F44H/yIxabxvE2/Ja2+Er4RE2loy+qb QNqPMlM7AQy5WNphnhxM5ceUJ7QCvdbKFfmM5ZQ32PLAJLZnF0P90TBPjqgRsdHTikEl BW0N/U1yMHHQWJOUiUKRgt51C8PfGl0bUOrXNxwiRpujjx2PcyKq1Dg8O5wOeNQ0Imul gsw1kJfxJ0Il6Cp0U6lNaDx5cl2xUEvD8xuKScKcbHoo1ViF9OcwuytOnr5Sz7LUqn/T EXwQ== X-Forwarded-Encrypted: i=1; AJvYcCU6yxQzkyUW1m6TWlZvlYJ6hGmH3MEYXDLoE3PvVfl4h25RyshNF9/F+FfaUIrXQ0O7fYSrAzs=@vger.kernel.org X-Gm-Message-State: AOJu0YxTCa8TSRFdv/tYwSLZX4ZhImVsXogBzL236/wY+AHaRLVyjTvB 41Y7uPKItS8dBNqeM7ElfXCFVrtMv7N2ia/q1D7HOICIbHAdOUmmaNYgDQCg/w== X-Google-Smtp-Source: AGHT+IGpc/wS9dPsrNyYf8JqoIj76FyNgWP2n1I8Tj+k0jz7XGj54fPdDoeOGNqVHUZJD46bStyn2Q== X-Received: by 2002:a05:6a00:3ccc:b0:714:1bd8:35f7 with SMTP id d2e1a72fcca58-71445d5a9a7mr3459014b3a.15.1724444177253; Fri, 23 Aug 2024 13:16:17 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:16 -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 v4 07/13] flow_dissector: Parse foo-over-udp (FOU) Date: Fri, 23 Aug 2024 13:15:51 -0700 Message-Id: <20240823201557.1794985-8-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 | 12 ++++++++++++ net/ipv4/fou_core.c | 16 ---------------- 3 files changed, 28 insertions(+), 16 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 49feea3fec56..e8760c1182b1 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,6 +856,7 @@ __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; struct udphdr _udph; int nhoff; @@ -905,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; @@ -943,6 +948,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; @@ -957,6 +965,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 Fri Aug 23 20:15:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775994 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.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 A9EBB194C9D for ; Fri, 23 Aug 2024 20:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444181; cv=none; b=VuTLP8VzMVLaF3PBF6TAYyD1Dp0RR39hh4FRfSX9gMPocD86IaC8YuXeoPitRr9z5OFWhcV/oqFTtWyc5I3I9aUUlvgSd75cAYPS9P6k6q+XaZ6nhiYitIT4Tz3BkNK8Aw5+tR2RqWoaAMtRI9kmqiacv6nDnPVXkWgCbu05ihw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444181; c=relaxed/simple; bh=VOdMMqBJT5gfV//2Em8zA2+MB+y0Dz6omzqKA4vn7kY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tvbrdNgt68pZIUQmlR3gyK7dARbMcxNf7VbkLohcfuee7u7Wh2igao87RBiHs/FOSR10RHKnMomi1i6/tz8L2bGRT+8KSD845u5kAyyLbM0TA7nFn9kHsKUEbZ5OvDas+fPfgu14ycg5jGO879dgVohr/kXBZEJf77yrpLrhaM4= 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=JjKmibSu; arc=none smtp.client-ip=209.85.210.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="JjKmibSu" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-714186ce2f2so2057810b3a.0 for ; Fri, 23 Aug 2024 13:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444179; x=1725048979; 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=yY8Ll53JZEM5OHYIrpL5YbN30bPKt3HuE+whQGMJljk=; b=JjKmibSuDJ+v+mS+zIVPxlxsWdd2t/ohdA0nz/HHNPVTH1uJUL8iL4dHNme37vOhbL LAMUquEvl9MEquHowUZW4z0wvVdK47kubGf1TvQx7nEFzLlpdoR25cffXD1QHArhBF7y 0PcbLL+QDl4M5iv3vt4ERcefxPpmyX//1YogaP5WbKV9vYu02tbNpXlLZ5tMUr3vxax4 W8twhFsGUEf6drPQ1IdBpbwgiU6oqQvyFYwgXtLG8XmdUYLg16n8+qLXTQOB+L5DaJ5U dPGy9rT0iCPeNpD7Y2cY/sQcib81KqvGXMUG23uL8DCiyQFN7sfUveHA4UF+z6n9rJI8 +f0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444179; x=1725048979; 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=yY8Ll53JZEM5OHYIrpL5YbN30bPKt3HuE+whQGMJljk=; b=Lt1tMX9OeAAul82bKiP/JTgCnsMm/PGpsHZYa2EYujlKRxajeIApC4oxm59OzvnBuR 28n5nTPW5D9eddfkn+OIVIXuXzaMUqBL6IgpKVeytpMNTYqJl2iL5MyPgyiJg+PmorVk wwVmsW6Y81W6tXcmmT6D3FOOGg+Jjq2RpVZWLanL3Ur6KAQET6Sc0RHDT9ehuJ1bfppt bg8NRkXJcAA5Jo162fqptckJ2j59Jma7ecl0GZYjGUoQKWX1J3aj3ejuXlkNnFRr2u31 mdDKmRBOe7QwjIBOdIzVBDKLPkska98f76ACKifQ1Y4pCnegScxKFGT8kxI2TwYa60VA pLAw== X-Forwarded-Encrypted: i=1; AJvYcCXNqiSLJwS7y2MozFZQAyMkarwuygHlfsWJRMwHgDuqZn9HRUBRqJRCTwb9Togi+hNqteR7dOk=@vger.kernel.org X-Gm-Message-State: AOJu0YyJKwvqWiu7XgUOZZxpRZU+qTbkQNcMp7MgYo/IEG5vo+CR7XBV Zj2ZQcM+1hygCEjbPrHYldVKRNXX8B3f6AfC1cIzGGONthWCg2kO8AiEsNSQTg== X-Google-Smtp-Source: AGHT+IG2J15abxunlLT7l/suTZjDnmu9e+evc6hS5JzKfeAVBLH6qu9rI2SvmLtMUjk5xAHZRwL+Dw== X-Received: by 2002:aa7:88c2:0:b0:714:340c:b9ee with SMTP id d2e1a72fcca58-7144573659dmr4377631b3a.1.1724444178728; Fri, 23 Aug 2024 13:16:18 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:18 -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 v4 08/13] flow_dissector: Parse ESP, L2TP, and SCTP in UDP Date: Fri, 23 Aug 2024 13:15:52 -0700 Message-Id: <20240823201557.1794985-9-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 e8760c1182b1..dd126e72f880 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -965,10 +965,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 Fri Aug 23 20:15:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775995 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 3F5351953BD for ; Fri, 23 Aug 2024 20:16:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444182; cv=none; b=cCI5xI69pFpI27japtmBxN4fMtMQ75oHkTf5SsF6cgwNz6wCOQHM1KgJHsy+mhnbXTggz1uruTXc6lAhf9idvi6VkIFScQKoE9GZzR6ogqJ2/7Oa6U8OD9cbfifhyMOegFx03/QY42I2IQNRdlrcgzeQo/zx9721LPDLNFCibhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444182; c=relaxed/simple; bh=VTXkwMEyBGBbqcXgjhNII4kl2hwTBqwNmhUpw2+QMfE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tcu2Fo+6LPb6cvyfekiwSK9ngVrs7jGzNScKFvDZTL8J0/wbUguCkqfT7MXQvOExlPg5X2BmeDhmmPH3sN5s2x5PHN1kKQzrQ2hb4T0oHJRqR/fC2EMLDMv+PQU3EuHCSp8pSuRaWxpDngBdso5pFPg0EJWGCial3GoOL3RJ+uw= 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=HpBBrliA; arc=none smtp.client-ip=209.85.210.180 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="HpBBrliA" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7141feed424so2183069b3a.2 for ; Fri, 23 Aug 2024 13:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444180; x=1725048980; 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=Vm7+d4JJAYctB22ym4m4D39UpYANdtXQAcOqQ/0hocU=; b=HpBBrliAJKIJ4KHyKhOBqkNp1tiUhpj5a8PsW3IBho4ndwDR1TD4O7OcmUhXAdEp1w NmrSfEwjrxVpLj0EeFl1pV2wYpHhrtaNa9Wfh/FiQ9ITMtnJgF9p7pYHrsXC2wTwUWqu howhfA4o61cty8DeYC/CVO1AJpNc66/FxBL9prmBG4mKZxkI0y8zDxzdcgv2XBQ7m2eM hsU8ZLn9UQ2cHY/hR78ByylX1lvzA5Y55POkuOaI0UBBKnTHjlddypAliKKo2j4K4oQj xHpk+w44eNVTGu6Gicc2n2V/6+nIRrWztwmfekL38ijbOrC/VfOhZ2GgDCv9Gt8dI4m1 3vXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444180; x=1725048980; 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=Vm7+d4JJAYctB22ym4m4D39UpYANdtXQAcOqQ/0hocU=; b=Qk9o494EQWh48BugjyGP8x+7FUWryI6lda5rsQfGZDwmAv02h120BFOn0jClAlbpKg USvhpExSTL238mWUJVL2c/H9AqsVdqmRdfqQimbtzsAgZhP6KWmEUlhFuRTLSxbhmU+0 ID/ujcSWs9kwKS5Vft+8P1ybEHst2QMngwN4lZHV4Bs27AkYSiEBwz6bHknFMRyxxl10 wz2Jl2PvTmI0W2TQJ2RhbsOpzW9vSRIzTPL8l10oY0xYzIl4WQ7bNunKk3ZlXlRGN4/d zGkLUYpq3vISkXpQPISNwBJiSna8aNRLfr5QriRv+YNQDMf1sZshOkqOgStkvEyYg+G8 Xnnw== X-Forwarded-Encrypted: i=1; AJvYcCWJsSUiQaAKeLmZDYnU8NcMafwniMfrxZ4Botp6h93VcL6q5dJC/OBZo840ZUx3fBhw0ob37iU=@vger.kernel.org X-Gm-Message-State: AOJu0Ywrv24QRkX4a8dzvnmYfL3sHDP4Ue79vKjIbDutlCiDzZgaT+X/ cj2GG8Tj8CODossFx4lW/eqgbzFqjXxq4a1ij/3JGgWWc2GtG2GEsGtNVP/fTg== X-Google-Smtp-Source: AGHT+IF7owriLrYMdFjfQDYLMH/t7kgGcA9P5zP5Slyj2tYEDsvigyoDHLugUgi60oHAYEpZaD4fFw== X-Received: by 2002:a05:6a00:3e02:b0:714:1d96:e6bd with SMTP id d2e1a72fcca58-71445d5a51fmr4664170b3a.13.1724444180443; Fri, 23 Aug 2024 13:16:20 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:19 -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 v4 09/13] flow_dissector: Parse Geneve in UDP Date: Fri, 23 Aug 2024 13:15:53 -0700 Message-Id: <20240823201557.1794985-10-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 dd126e72f880..1deb9c3a75aa 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 @@ -989,6 +1013,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 Fri Aug 23 20:15:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775996 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.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 DCF21195B18 for ; Fri, 23 Aug 2024 20:16:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444185; cv=none; b=h542sNqq6pDKddr+hufT3PcggbdOBH3vivc8d+dBmx6rVmFT3FJn937GFSfLux3v9wgpeQeCnJr8lWH/6WI1LqduhMayWXGGqKwB5JWHvBsf+d/hypf8eug3IZA1nsWfEGMNlOWrngrEFzKdroNMO/Vrmp+uqPVB9PUlUtajmZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444185; c=relaxed/simple; bh=6JYdaM/A69YpsXWisJPTYRJ+hdU6tbac4E9JIlFlgg0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZwoXOegJhZiNr1lJP23z+8kCzJnZcxKAFBzQXDP5kSer9Ke2Y8sLIbsm+udYaCz/ULhWOhQxfy/J11h88YWflBGdWqX1IIPr0z9xTfXsrcA8JqFrA3wP21Y9E42qmjoaP/qcY9nhb/XujkLnQ+e7HzLVEZVczhvIoWMkDZlcQ9o= 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=Rsrd9QZ8; arc=none smtp.client-ip=209.85.210.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="Rsrd9QZ8" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-7106cf5771bso2103457b3a.2 for ; Fri, 23 Aug 2024 13:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444183; x=1725048983; 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=FsvEhGAimRsV6DWolEHWd/q0y3eSkl7ku9bx5TLRyN4=; b=Rsrd9QZ8/AnJaiOqOqkVytrOtMXK/mGjPEMm6ym57f4O5vs7qNjAaGH8RKCZ/P7xoH UNWte3SIpwvzxhcDpCOq3PlTDKgEt2/qfhkRZk33w36aU89ONIBzEM8vZP+cTNQZxpp1 bOV/7goCm8vKXQaGlivbejJR6c8X9S7/3MVWukBn3+s4+xPbn/JxievGIytCfw8WApUV IiuJCgem4yzuUfx5jxoUeDDfS28DD5LRd2eTNanIgmvOo/W9ER6D/ssN6NiFR4s6qJR5 REpSBR5fivx+fgX2JnstoqCVmK+3o5gVODKL3cWuh+Jdy/9lKT9A8QGicGIP0FyryFCu sBvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444183; x=1725048983; 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=FsvEhGAimRsV6DWolEHWd/q0y3eSkl7ku9bx5TLRyN4=; b=Pn1Xiv9Fl1KFFaCzIpiMAAy2kpr7DW6GLLLrbe8ca6dh3rtGbrdwS1XWBlq+f/0ebN iSun4Csuq64cUTCsJOQP23N/+++QJswW75ypRpsZyU0YqeQwU1ilYsVJP6YOAd0DvkhB +GNQXgxPuZXHG8Op0XEafyPO3MzmwAfAZeL2pA9uhuBX1O/jHasnWuhCDj7so3XuzhAq Z/mmFQ0wB5SpOz3MGmuN998k3jH8Z+E2lQOzkbMY14Yv+O4fhUWTH3hJZvObdSZleMYA YJP9AgSb5CtLG4HxPeFr17cOYDBUKqto8uJnBdNRA+pKr9lvhp72Lb7fg9evOFyfjQ34 cnPA== X-Forwarded-Encrypted: i=1; AJvYcCWglKKyLkcRmwXAB6yajRHnh0OqVMGzAam/Nh2RMxeNE3+H139BUvCLxdU+e++qpjBWLr9sZ9E=@vger.kernel.org X-Gm-Message-State: AOJu0YwVjUPLj/DDBwuITdOvJx87YRcElkagq1i1vbVBb7qHLC2QoEQ7 Jk6KABfNlfMfzMHiIDdEsO7Tyco67deQvnw4pdiKPlY8babSo38UgNFVttJOJw== X-Google-Smtp-Source: AGHT+IGJoBGUi3+PypMTvPRfYTlUwgxq3qHbJRDlZXUHLTlqW7/NMRSYK1OB/ZEqW144KpeAH1xKdA== X-Received: by 2002:a05:6a00:9187:b0:70d:2cf6:5e6 with SMTP id d2e1a72fcca58-714457c1845mr3352941b3a.15.1724444182955; Fri, 23 Aug 2024 13:16:22 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:21 -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 v4 10/13] flow_dissector: Parse GUE in UDP Date: Fri, 23 Aug 2024 13:15:54 -0700 Message-Id: <20240823201557.1794985-11-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 1deb9c3a75aa..b59a9e896a31 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 @@ -1002,6 +1057,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 Fri Aug 23 20:15:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775997 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.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 6A2FF196C7B for ; Fri, 23 Aug 2024 20:16:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444187; cv=none; b=K6lnjSEdOePaAYzmnoe9tqQqQ63b9CZ26k+aCpw5lWM6ZBT2CAWoU/WYeAhdtv5U+v6z5X95Ma9YwF+3hPv3z//UtWvto6fQOMy0agEtMMmgRlf1Ku2NvFH6FTU3zIn5WyIoNglunRS0yJoSPO9on2oF9/FWrr6Ki8fFHKOFFj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444187; c=relaxed/simple; bh=0dAjiSIzgpkWEbT6ZjWDA//wTx8HCHscYHZ/Jdych2c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pAqlY6tYjyR9uT10/pzS/GQ/n2q0T0UgiqQbHUzn0m/eeSKEDr8ud6OAE/CickTC6mg2wvEqmf3a0HWcC6S1Wz3wNGz6yuwMoPrVNSZdbcVDzwN790xdsk6EZQsGC6mpvdO1PbuU0er08vOz0GDtW1W1Bg2R5m8u1zoEUZa11LA= 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=Veoa2R31; arc=none smtp.client-ip=209.85.210.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="Veoa2R31" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-714187df604so2178020b3a.1 for ; Fri, 23 Aug 2024 13:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444185; x=1725048985; 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=Veoa2R31+6lQjP96blTeW4y3eQ8SHHI6QGBO5kKszw5Ud1qZGOYBdJQMvZqkAnQfve GKflufML9O2uIA8Lsa+iVo3n5RXHoizLy9BpTb7vmuKJiRI7vHEbrw7Y5VEEvc4zSn+2 AwGeT8NHjD5z+g7+bm1ECuRzL7DjgEPokD14oMeDlKVel0fwKxZd6nC5CTNpHPC7yVGg gb+HF5gvGUa3Xtnb8QIDJoieaqQKxenaP/GCaATqq3HNc9Bm7+jncgeZLvyHE0CZfYtx HwA4UmF6Fsm8kA8HSqjlQbLYD227YvPsYdD6IW0kIUvu0JYYgAEL6xazp5+JcA+mMtRK gPNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444185; x=1725048985; 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=l370JDVrSNoBJK5xNkEj7/8HTKihLF2Z3yYU6uf1N7s0mfq2emfz4HmwrIgXvYXf+0 OEa/PlIUQMJI+2+sSwv8hTRmZxpxScln0sUjSClTKREcLWdGeYa2DnHW3D6L9m/wSjy7 jm/jQWS2EJ4mpVHvB6BUIZBEBUSHNDDTsFYR/eq2ZjQLiBH08V5Xe0JI2RXROgTFO9at ANn80zdcakILIJlM5Vs7KU+We4hOx/EwQJZjxU8fsRlZiENWhAVEKHPJOlvDGiYjapy+ IFgzM+R9Qyzf+3PYvcwq0GCxjaDiyU0cMDnL0CWFLG/LPIJ+wUGjwXZ5G4UDg27lb3YX ifgg== X-Forwarded-Encrypted: i=1; AJvYcCWazo3NSd0YmVYZIQwQ8qm1rrV3hTlJCYHma1g4BZcQh9r0KzBYhcSUjKNDc8M7hOLW7EZNVYY=@vger.kernel.org X-Gm-Message-State: AOJu0YxIiVpooV38cS20vZ6ySHH/jOqzfTJCevLuR2gC/oSJKVNOxp5N BRtXgZ+UcazIibWBiUvWqeO3Q9WS6GL7zlH/fp2Fp4I+gc6LbMmV3WPNYM94MQ== X-Google-Smtp-Source: AGHT+IF0xFTQ24IPIcZf7eWJJa8UmgfaoXwrWlXW6ZQuIgRdjUUVflP6DljkS6BZ82QLbzrSAdyG7w== X-Received: by 2002:a05:6a21:3996:b0:1c4:6e77:71a3 with SMTP id adf61e73a8af0-1cc89d29f30mr6187317637.3.1724444184508; Fri, 23 Aug 2024 13:16:24 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:23 -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 v4 11/13] gtp: Move gtp_parse_exthdrs into net/gtp.h Date: Fri, 23 Aug 2024 13:15:55 -0700 Message-Id: <20240823201557.1794985-12-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 Fri Aug 23 20:15:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775998 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.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 E8996196D8F for ; Fri, 23 Aug 2024 20:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444188; cv=none; b=LaET3p/IoViL6sVa3wfs1haTwtPSeY4f23SSBdNtku0ZAycu6PKaFH3dOX+bZ6MMSnv4ctu5ZNqNZgecGsLESYE2BXCmIQT2AxEuPDXMD6uWy4dFyoUCHVWzDKWQNYL9XLs3xhao6RjYnTkmUMpnsnVrS9Fd0gxL5GkbUsRMZRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444188; c=relaxed/simple; bh=ZMxygvhK4ELf54fKgyLBVpoBZdpq7p5KbBS864OliTk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t4z3ILINhKB8ddAcSfJtwDD+5SP9pUh/jHWt0eUp4+wtoXqJftg2VLXgqPD6tnRMqkC91gSYRBUAv8GFn7/QS8i1CfV3D1/LBx2hOuZ++cBn64BVK/vqenv+msOYnpJHhRY3n53w4bn8GMxfUDsDaHp8HTd1EiBY46927ryJGx4= 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=OUayUzd0; arc=none smtp.client-ip=209.85.210.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="OUayUzd0" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-714114be925so2027622b3a.2 for ; Fri, 23 Aug 2024 13:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444186; x=1725048986; 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=q/LrkTUGrE5MSnxbjizbz/XGEysura3Y8RvHHfJnANk=; b=OUayUzd0eIJYBs2Bwiza5M0+R7j9Pp27aIcdm6CIQGvcXikitU2SUWAzaGfXRVXSLt MTLfEKL/eYH14lJVw9mpraw99h5mRWtYKWb4GGgWeMOpu4BCOxUzTCdnUKoklxGcjpAY O6qJDsuktPffs01oaAAolbnBlJK/0CMvwVNOIgmjsWWz/OJmBYvwkK73O/27AHjvA4Q0 2PkgKXRFEJ+1I4bXNSXka9AykkfQgRls8MaPuW8QeudzsLqDqGxWcI9OyF6mcm44L4nS Gxl3v/TLTje1/gtoQq7HsIHnVr41+IiBTm1ob0+SoK6q0DzymQeff3TZTxyCkAI55Dea +dLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444186; x=1725048986; 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=q/LrkTUGrE5MSnxbjizbz/XGEysura3Y8RvHHfJnANk=; b=CBaGzn7OMaA4SdDL0yorUISvNytvK1ni6a3XwRwMXttVGfBtiQuhCzqwhgzXFx9Fci U9t0BaGl12+nsdGGyFxAfZRZpHYgbuJ4LaAho7D+IDNxiEcxkpMS5N/nrml8TjZz7Am7 Fnm4Qxmp4VkVyZNyA942iSGHlOlL1imD9AUGwOdDpMVuv4Ufu+7HtF6VeDbbsAPmAbAp bFPhpQcgmOBcVxGcO4pIfTrsuDiO5DDggBcKvdSX5gsO0yhB6gd3kcLiEZWHw+5kO63+ RR3taUOakBqrbxvUdhHC5jzuLXcy8ZyFzUXgN0yaTI/dAA0610hYO94NPT7R436Yn1g6 D09Q== X-Forwarded-Encrypted: i=1; AJvYcCW2AEVjodCgC1O5VSaqJZKWZ9IBG2nDw59PXbY2CZrECZhAQgYAVi0hBOu25C4etBSPSH9BBso=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0MvpdWpeXD4fHkxg+2LfQOg7/EZNYNS1IWvKQEM9W0w2ekhJ4 JF5RXk5sW6T2MaPIgtfqivOx82TUHIaLFPIwX1iW9Io7AQafrdRnHhfbHIKcHg== X-Google-Smtp-Source: AGHT+IEweX7RHzWH2YrKfVWv7U7Qfqzc1wScEKeqHiNeMlyUW9PUIJqNjo75Fh0AMS8q2knrvKHZFQ== X-Received: by 2002:a05:6a21:3417:b0:1c6:9e5e:2ec4 with SMTP id adf61e73a8af0-1cc8a0846c5mr4319323637.50.1724444186172; Fri, 23 Aug 2024 13:16:26 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:25 -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 v4 12/13] flow_dissector: Parse gtp in UDP Date: Fri, 23 Aug 2024 13:15:56 -0700 Message-Id: <20240823201557.1794985-13-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 b59a9e896a31..ae56de7d420a 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 @@ -1053,6 +1140,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 Fri Aug 23 20:15:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13775999 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.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 B27221953BD for ; Fri, 23 Aug 2024 20:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444190; cv=none; b=aQK5qPCR+aKuJl3ELOU3UlAjLY+U9WW4BwYstE+UhavV2mctx6H3zyj0Mua1bGpvBuKSQUDHB3YZYRZ/3jbU84AAgIrAZ5WFRHvdvbiX9OVqFIRg3UZ3xs3wHeGPh+AhWLu6zcbyrzPVHyaOAqE+nlQM4H2Idqrb0mQvWbfNkFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724444190; c=relaxed/simple; bh=iMWvxLg6mk3YOZu2GoOmMymABsgkj70W/qqTIhUzPek=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tie416hvZEAQpQVJJFaKffLrTLEpvOLu1503inl6+XCTr1qXtHtIA+P/BviE6gnAcRIOOmQI7x+w1gSgJ8MkxNWPyjXS1A9h2Lbea3LZbJScBYehX5mkO2jzDX6YnS3Luj1E8CWXuPnAL3dRTqV1m8wHuy/moRX+PV5fRjRZwUI= 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=eEyIs1Cu; arc=none smtp.client-ip=209.85.210.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="eEyIs1Cu" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-71456acebe8so37895b3a.3 for ; Fri, 23 Aug 2024 13:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1724444188; x=1725048988; 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=GC41Q2Yt1vb0S2eoC29cm2dAZ//HWncpeQ3N2y1epA8=; b=eEyIs1CuZI7cr4FjUgzRP7gEIldhNVN+mZ+IWhcdBZNPBcoArHsm/iJGEWjECos4VM Ekj3Jo8z4LRHrpdnpIR4gi1/Wg9bdzLvaw7VO7py2BatcmMOqgKmtYCoTfbeK9IVTYeh xps99qK393MB1zRVhdBZeoKsNSLVry9X5YGI4YPWpo9/WOepGq7gVe9UOvWT8e8mj7zT Q9NTn4wKOLff6G+92d5OW7JcZZr9bgdPd+WmgbmH3SqFogT6mjbg7vkUm49iyP4x9ct/ vSuLTSlvlHqXmOZf0rKi8CShxddQKFfdKsFM+18W2hH1FKYEWRlsEQ1SBABkzJ/eRcxs r10Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724444188; x=1725048988; 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=GC41Q2Yt1vb0S2eoC29cm2dAZ//HWncpeQ3N2y1epA8=; b=pblXjLxRyEkNoDgBDNEHLjkLnNKMcupl+Gc3Sv6JuUcvoucY5WYuxlFaNqoRHxa26l yopS8zyPPqCp5YSGzYtHR9jbe37O0gMAWJz/O+hGiv80rXNyaRf2XTV1Kzzal2Ntr8nS jgWSKLWUwWdN9OP+T+FXsVBuOO5BA6kmmLdM68MwP5NwKpWGDeyPQ2AR4KuzR6Dhjytu WOTU1D0NBT7mYNcK8SLhAs8qHeIV9H62RTJtBsbN0/wTI0A7bKChAUYzgsJiZASgaKv8 BepT7qOESA7Lqyset2QEifTuhC4T33VEjrO4whLwzUsa1g65iSiKK9OLq3YwiCkhr62x rkqQ== X-Forwarded-Encrypted: i=1; AJvYcCVIRympoQCSJASFjMiLYJJK4rBHOPeXvLM/elAiAfyGKMGd42KYWEV1PmgFDAxDl4ydpsNh3F4=@vger.kernel.org X-Gm-Message-State: AOJu0YyXGPuxex/TxaNcMtXDW9xnMfMSFq1k+Y/kjtH5p6ufzXLwRHWL 89YDVtWwj6B2iMPHvmlus0lyfWYwwaYkpdrbBJsCXWtWJgba28TeERUsre17Mw== X-Google-Smtp-Source: AGHT+IEQoeYGtxW4mC2FsUcy/CzXoh29ktEXuGudRD/H1+eF7YnZwyOSOsdHpjVnc1P/UqeeUOl5nA== X-Received: by 2002:a05:6a20:d497:b0:1c8:eb6e:5817 with SMTP id adf61e73a8af0-1cc89d29d31mr4337235637.5.1724444187742; Fri, 23 Aug 2024 13:16:27 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:9169:3766:b678:8be3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143422ec1csm3428525b3a.39.2024.08.23.13.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 13:16:27 -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 v4 13/13] flow_dissector: Add case in ipproto switch for NEXTHDR_NONE Date: Fri, 23 Aug 2024 13:15:57 -0700 Message-Id: <20240823201557.1794985-14-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823201557.1794985-1-tom@herbertland.com> References: <20240823201557.1794985-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 ae56de7d420a..6f50cbb39539 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1993,6 +1993,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;