From patchwork Wed Jul 31 17:23:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749002 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.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 0ABEC1BDC8 for ; Wed, 31 Jul 2024 17:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446633; cv=none; b=MBLjhU/9avJOgdxRwsMmRrCUd1C0Npq7o/KnSTGfsFUlD/sk9Nh1kr/IBEzBj2lUwszgjz3OWyIv6JBfj14pBBWG/hFLLyhsP7KkVJYD6d6jGejiXMojfB2nnWBLdnz19e07xg69CFqBXD3SHG4Y/L4v6bXffwpgk67aXdrM6rs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446633; c=relaxed/simple; bh=GcVtObMKZKvCumwXVrLokDsxMWPVUBDmwxpMG8r26L0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NtPm7TQkNwVO7fyTkyNYVTkqL5Keo4OB/S1rTk6rX9ym+o6NiIdlt8mwBzZVtYgt/6Q11uoEQQKsqXggMMwrL+VfV9G+BZpG7f5jgQeCyEfpGZ4Q/6XMADxpdi4eY2sCYo85SEBkCxrpp6fSOE94NpycImxulNCVgYXzsTxR1NU= 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=UYeopeyK; arc=none smtp.client-ip=209.85.167.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="UYeopeyK" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3db145c8010so3800889b6e.3 for ; Wed, 31 Jul 2024 10:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446631; x=1723051431; 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=H6uStiK3aDF1mC90JSWDLW9NK1b0vERakNh1bTcVzv0=; b=UYeopeyKMgJquXqBHDkIeozqzcA84GYUbXf8umrTrJzvOxSlKDBTW1NgE2y6VZbY9D qHos5/Hetd0mDLxukRy3SFwevZtPybV3Up8mrpuFPnVuP5kctJl/fH7wg2Llw3jNK/nO lRrxQ+0eEuf2C5omsALOEx07FzlTFF22n7oXGXoN6j5fEjh4J/lMj1NTanAju1EAF2tp C2Ca7Kj86Xt/5MUICronlbhwtgAJ/Lgsue1T1mD0ronxQozCJ9Qr5oo+En4Kl9ptdG9v 3NXbttN5hesB2+qjVM4uT7N8AdFWW+yGQ8yzkrpDnusb7gHPqdVHX1iIQTAHYuc2I6kx ZPKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446631; x=1723051431; 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=H6uStiK3aDF1mC90JSWDLW9NK1b0vERakNh1bTcVzv0=; b=MIIPNsxuSAgcrK8Msz6C/sNcYH6oO6vsY5fEBix8D5wC7vAD6V2YDWi5sZ2zqhttdu 6tz2V7wN9hOezEdV8NHLV7RSGgJt5hXB6fkpQ4Zlzm74SuYhHpVs5UdMQlV1ra82yL1c /l7jo/UARfEVjDOSp9GLIk1qMQL9+VVKVTmhL93Ers4nXQonbm2V6qFUTJmYZQ7hlHTz c84nfxSC0wK48BKOPtPGBzDB9BP5V9siTJ11r91ma6d9qnThSXQqoBjJ+al3tiB2gEzs XzoLydFXJm5bTKlmcwq4fdG5O6Tlq3mWVwfYcHUO4Idw6uzFjt+PjgOBKzOXxTatA2ts Mrmw== X-Forwarded-Encrypted: i=1; AJvYcCVCNBD1xMoA5ht48/0BD8BV7UdcQFYzzOHm2+9TBwlgtKzqOFeMgLebqx3IwJGxonwLzwel/4xVICtKElJpYHJtKL5msckG X-Gm-Message-State: AOJu0Yy5yhWlxpG/k/UGDPNNwAEPHCIUf0uIWRDoRdRJNuUlYARyuoSz wQgmsQj+6aDyIMVs04Suy5kL78JEbocd3pi+1rb+s7gVn1pk1a1xZzgn32MWTQ== X-Google-Smtp-Source: AGHT+IH8TWPfAHmhwJZe+It6bVRS3JDs8ZkNw5U4+kXV2m3jd9sqcYs5EZTSzRidqzKISy3y80DARA== X-Received: by 2002:a05:6871:4006:b0:261:2c4:f7a0 with SMTP id 586e51a60fabf-267d4f80cf9mr15117956fac.51.1722446631116; Wed, 31 Jul 2024 10:23:51 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:23:50 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 01/12] skbuff: Unconstantify struct net argument in flowdis functions Date: Wed, 31 Jul 2024 10:23:21 -0700 Message-Id: <20240731172332.683815-2-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 We want __skb_flow_dissect to be able to call functions that take a non-constant struct net argument (UDP socket lookup functions for instance). Change the net argument of flow dissector functions to not be const Signed-off-by: Tom Herbert Reviewed-by: Willem de Bruijn --- include/linux/skbuff.h | 10 +++++----- net/core/flow_dissector.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 29c3ea5b6e93..a0b5687fa49c 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1504,14 +1504,14 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4) __skb_set_hash(skb, hash, true, is_l4); } -u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb); +u32 __skb_get_hash_symmetric_net(struct net *net, const struct sk_buff *skb); static inline u32 __skb_get_hash_symmetric(const struct sk_buff *skb) { return __skb_get_hash_symmetric_net(NULL, skb); } -void __skb_get_hash_net(const struct net *net, struct sk_buff *skb); +void __skb_get_hash_net(struct net *net, struct sk_buff *skb); u32 skb_get_poff(const struct sk_buff *skb); u32 __skb_get_poff(const struct sk_buff *skb, const void *data, const struct flow_keys_basic *keys, int hlen); @@ -1532,7 +1532,7 @@ struct bpf_flow_dissector; u32 bpf_flow_dissect(struct bpf_prog *prog, struct bpf_flow_dissector *ctx, __be16 proto, int nhoff, int hlen, unsigned int flags); -bool __skb_flow_dissect(const struct net *net, +bool __skb_flow_dissect(struct net *net, const struct sk_buff *skb, struct flow_dissector *flow_dissector, void *target_container, const void *data, @@ -1556,7 +1556,7 @@ static inline bool skb_flow_dissect_flow_keys(const struct sk_buff *skb, } static inline bool -skb_flow_dissect_flow_keys_basic(const struct net *net, +skb_flow_dissect_flow_keys_basic(struct net *net, const struct sk_buff *skb, struct flow_keys_basic *flow, const void *data, __be16 proto, @@ -1590,7 +1590,7 @@ void skb_flow_dissect_hash(const struct sk_buff *skb, struct flow_dissector *flow_dissector, void *target_container); -static inline __u32 skb_get_hash_net(const struct net *net, struct sk_buff *skb) +static inline __u32 skb_get_hash_net(struct net *net, struct sk_buff *skb) { if (!skb->l4_hash && !skb->sw_hash) __skb_get_hash_net(net, skb); diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 0e638a37aa09..e034e502ab49 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1045,7 +1045,7 @@ static bool is_pppoe_ses_hdr_valid(const struct pppoe_hdr *hdr) * * Caller must take care of zeroing target container memory. */ -bool __skb_flow_dissect(const struct net *net, +bool __skb_flow_dissect(struct net *net, const struct sk_buff *skb, struct flow_dissector *flow_dissector, void *target_container, const void *data, @@ -1854,7 +1854,7 @@ EXPORT_SYMBOL(make_flow_keys_digest); static struct flow_dissector flow_keys_dissector_symmetric __read_mostly; -u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb) +u32 __skb_get_hash_symmetric_net(struct net *net, const struct sk_buff *skb) { struct flow_keys keys; @@ -1878,7 +1878,7 @@ EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric_net); * on success, zero indicates no valid hash. Also, sets l4_hash in skb * if hash is a canonical 4-tuple hash over transport ports. */ -void __skb_get_hash_net(const struct net *net, struct sk_buff *skb) +void __skb_get_hash_net(struct net *net, struct sk_buff *skb) { struct flow_keys keys; u32 hash; From patchwork Wed Jul 31 17:23:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749003 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 551E61BD004 for ; Wed, 31 Jul 2024 17:23:53 +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=1722446635; cv=none; b=h2y9B/HneX4LbWc/FwANy550gUx/1h8RVBEYOn0U8vrW9thjNr8/By5bjZqtKfUt19pD700xcVXj796cOJg3biTOTP5jruv7AM9XCgfjmLfR0DZmMxF/DyEk4QsXRC8UUbeuaYKBY6bqC4//eYil88zngaWEYVlDjHNWGRUf8K0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446635; c=relaxed/simple; bh=UjjMjEIjZ/P6a7VI25jpnfNez4v3VskRw73WlLvw1/A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GlhPnbobwws3FXgWb4Yj1YCvrjr5rUHwGJ2aKVbUfibFuIZb463wtCCkArl3GOGei10UZsFKxxCRYyAX5PoQFTpodnyW74ywSygOeAAdK6GWS6eUrWKtFUdkDYla58O4tUFgnqLb8tnHcsjj4Q8llPbesrrNofZJSkHlkgBsMkw= 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=AMiAmgjc; 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="AMiAmgjc" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-70f5ef740b7so2074627b3a.2 for ; Wed, 31 Jul 2024 10:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446633; x=1723051433; 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=tN7sl7gkDooNZGfuikETnahqgb0UIgEa7LSKuUv2JSU=; b=AMiAmgjcY2Fr+n1cvV4Qv+VXlEepxBk65aImQc6+JcHlEJtQt016SGc0pF77Ok3YQi SI2AsJ6YJhsVNhLkZCOE40WulN/eifpQHHus6wLLiLyMxlI03icK5WOiDADx/Izeig2i cJfihaIzkj/MtEQuMN6cbDL+VrMS+HMc8ze4AyOkbFvadaw+pE47CgPr9Hj9WNc0ekPk Z1BEpVrX2bWEIIwb5jVSgbP124FAOkA973NjqCKzJ8PofEFMFebj8iVzdMokJngsOSSR xTTYjqiBwAAXOlwrifj0mXf3/Ua70PS9WDENBdCNMdT6w+iyM3ZWFfbsZZp1DJQ4s9X9 JU+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446633; x=1723051433; 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=tN7sl7gkDooNZGfuikETnahqgb0UIgEa7LSKuUv2JSU=; b=OUjw7KhbdFHdeTif4U6mXzLCf8q8U5Q4OzqO7+/9tS1kFNuRHFgeWbeLbLHq6qisCL C/2jC3sfyJXP0qihf29MyfN3p37t3z+OtCbU6TPfFf89SXZlXIXZme7Dv7X2TJWdz+WI q1LunRlRJCoGnldokbcM3dIRGkVDF8aOPQxEkXMDq97SDqxZadEqzc4TQn0DgEpzUqMi ncTU7pmXi8FdvyPZ1dXTUJ2SbQlIySjaPvLWBhkioCrkFdJaxiYLcTfFU1fh2RpNaB9v 0dwRGrIYt+WbPTyhoyl46QOj6dixEXlpJni74ZuP+O7bqCsXOjwjXfy9NybD83Yoh1Yj N0Jg== X-Forwarded-Encrypted: i=1; AJvYcCUGn8Z1RsYYoAGqgRYwrv+fTu0NTNb+rIq1ggsDCQwxMHL2QuPIlOQFvS0RIjcC6qCK2scTZYwKARldvo/p/gH3ALHDN9VL X-Gm-Message-State: AOJu0YyJo8VjKhPg0x5hcFhFJw7rPKqBTOmHLOC0APWuAaOtVxaUwQwP i7Tg68MH79kfAmSUeG36aB+Whn5uEbQUX75rZxbGgakRfEb/07BjqItA9D+x93o9MNNCJ3yu/GA E/g== X-Google-Smtp-Source: AGHT+IG9CfRkfNVSAWk3X0bJWt6HSxadCd6xnLbz82/cOSwK//+l7whXEvmhGjwWO5dofUHTm9Zrxw== X-Received: by 2002:a05:6a00:6f67:b0:70e:8dfd:412e with SMTP id d2e1a72fcca58-70ecea32edbmr17064609b3a.18.1722446632460; Wed, 31 Jul 2024 10:23:52 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:23:52 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 02/12] flow_dissector: Parse ETH_P_TEB Date: Wed, 31 Jul 2024 10:23:22 -0700 Message-Id: <20240731172332.683815-3-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 Signed-off-by: Tom Herbert Reviewed-by: Willem de Bruijn --- net/core/flow_dissector.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index e034e502ab49..d9abb4ae021b 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1284,6 +1284,27 @@ bool __skb_flow_dissect(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. + */ + if (NET_IP_ALIGN) + hlen = nhoff; + + goto proto_again; + } case htons(ETH_P_8021AD): case htons(ETH_P_8021Q): { const struct vlan_hdr *vlan = NULL; From patchwork Wed Jul 31 17:23:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749004 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 0376B1BD4E4 for ; Wed, 31 Jul 2024 17:23:54 +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=1722446636; cv=none; b=eI7SoF/xqMo3iXVtFSf3wUGbF7eakikzLh653Ej6CSjSoBjViGR3hzw+OkY7rSMJDyI8r1hm5ExNbY7GxdJZTgpNQfMfa2t39JOn90ZnRQx/Sjb5xTYhiOXmYEyE93kmryJJ4Cq9OeyICPwtWvC1O8K9BAltvfkmYr3hA9fHRtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446636; c=relaxed/simple; bh=a4ri8INzPBz1jyyv/MtslRAqOROZxxSvtl1l+/lq2k4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BBwZP4YfJT9ecFldRg3A2hSKrwd5iBdLYb9XA45r9jgjxvu7qXmjqqz+iUeO8FLSc7r6x33NT7cNE2iI7qHFBsVwDO3i5yhtsLD8rMKId4iEN0pAMM7k4BHqhnUMvtoAqayg+IkgOo5wz+F7PSf+KIwt2dSHC2zdZUlWiNOBx2k= 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=KAxrMta1; 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="KAxrMta1" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-70d18112b60so981313b3a.1 for ; Wed, 31 Jul 2024 10:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446634; x=1723051434; 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=1trD5mstAM6ko/ALjqsiVF8KtF9GGGc+lYxrqdY4URE=; b=KAxrMta1OSquvFabP3rG8WufTFA7wIlRAjr3GnQqnacgekAVqRwAdiXKqgS1yDVFw+ tD8bnYyGxruUGCsy4MN6c1T7C38xEJCGYfONu71nSNzg3Fhq49Zs28EpIUfmNlOOnf9Y PhVrek4WP2Wy4D/gqHQhoArN1xff/TQlMINIlzHBlhCORTCDD75R2gpfpMciePA8KMqm m3B1Y5iNiz/r34QxHhWXU+G7FNVKa+MtuFAP69e7Nzr20gF/xe4ZkefOB13e1KgxyQLg culXwlYxwvVVYwkP7CQ08jEb2V96ThSp9rD6pEU/7KlWejcbTlNx3ay/9AFp8FlIx5yq ppdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446634; x=1723051434; 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=1trD5mstAM6ko/ALjqsiVF8KtF9GGGc+lYxrqdY4URE=; b=caO0B/GQADQywxp8As20/wDnKnb+4EXDrEhPsvyhsC+FHzOUGTET+gbWjzGNBw3TXN P4RkVuhBhMMEuZ7PWWNtutubx3RjAKV4TmzSApdgTis3F3Qe2QT3+1ChpFls/M2gANIZ bSjDEnbek6lby+To6yl0XTR10BVdAlgYsApX9Z0qeYz3gTuGIT+QfNZ/pkDAGWZiogvj 0OpFJnDwF36bG8MA+vRJ3WYBNxQLpc6RD2I/n8ul6+d68tKdXXoq3nndspTajG9Mpz2w K8pV3RPI8hnP9mKDIfeLiXPLKgasO+CMnSwRYROw2lhoJGUyAJeJVR+BNVBPkFme4gEY /6CQ== X-Forwarded-Encrypted: i=1; AJvYcCXSovvT/TCzi74sOuHuSjcI29oj/fzvL4xUPSUDa3ui+rS5h8EuLL0shJYyab+cJiAee5IOOkhpvnbIsMHyv1RtlX+fEz5s X-Gm-Message-State: AOJu0YxwOzRRkO5HTDI2TwZOcWx6uzQuSIkJT7XR7RcGfTq8WRki4PhU 19lPxyd3KCD8ajEutEHM4tgjKod+ylDscjWo7h47199AaC2ANHzfm7Psqd6R9g== X-Google-Smtp-Source: AGHT+IFU+olFYWB5AcQ3eeA+UzxIphxkBQTmbjoGYQAqYgQJWHR5lPitJWbOyAoBTOkK+cdd3NjZCw== X-Received: by 2002:a05:6a21:39a:b0:1c3:f4b6:f83c with SMTP id adf61e73a8af0-1c4e4848649mr6704011637.26.1722446634242; Wed, 31 Jul 2024 10:23:54 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:23:53 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 03/12] flow_dissector: Move ETH_P_TEB out of GRE Date: Wed, 31 Jul 2024 10:23:23 -0700 Message-Id: <20240731172332.683815-4-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 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 Signed-off-by: Tom Herbert Reviewed-by: Willem de Bruijn --- net/core/flow_dissector.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index d9abb4ae021b..416f889c623c 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; @@ -1552,7 +1536,7 @@ bool __skb_flow_dissect(struct net *net, fdret = __skb_flow_dissect_gre(skb, key_control, flow_dissector, target_container, data, - &proto, &nhoff, &hlen, flags); + &proto, &nhoff, hlen, flags); break; case NEXTHDR_HOP: From patchwork Wed Jul 31 17:23:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749005 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 B08E21BD004 for ; Wed, 31 Jul 2024 17:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446638; cv=none; b=MQDIy47rjb4FX2m4m2pRGrDmbnC7XMbMojGPi9CG0CrsnxmATG843ND5mdtTz++++471/iD1GXc3ubWyl4ibp0bpaPjpQ1V5+nujThY7p0glUKlaYxiLOLUp+jgGYHJMEqtPVXocMypCMSyALGG0zYZILtqlxzZhIZgqmVkdXmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446638; c=relaxed/simple; bh=UBnlbylDQiGGFqb824hJ8LOfBeF2it/cgHiViI1JVBU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iGCJ7jxDD5xCXaqKvr8o0yGfMHL7dfKNaXmrvt6GebTN2K6SbdUHiZ9Eqxj5PeH5QVAvQYVggWryOJNYExwFBLshdw7yNq7x136zRqfh/IiFpK1GC2z1huVh1Ir+ihvcaYG6kXkSs7u/k/hzMiOksf4sLuCahDHGGN6paQT8oZ4= 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=aSD0huch; arc=none smtp.client-ip=209.85.160.43 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="aSD0huch" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-25dfb580d1fso2693656fac.2 for ; Wed, 31 Jul 2024 10:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446636; x=1723051436; 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=8f2VEr48rqS/xVUGYX/zdpL28CXVAGtsS1olIt5KoRY=; b=aSD0huchpLYp9lMTDyidEQSA/AtfKHi+qwc5n01mVi0vKTDC/uLYxh/N1TbxIr5o0J 3zfjz/aguzi1rV6DVvgRK/OUkK80KISmNCF/hHi3Aj+N3UYV1VBh+f8+KVSx0c87sx1d KFyHZnhlDbEfWm9tCPPGd1m+aMC0gpcUjTY3BT3CXWtA8WyabEUsYWs44diQnj6c5W4f 0jjIpILnjK/nKtIyG3mMjC1g3bCDo+W+pa6pgAKS5wpPHRkS8m9FtQgRd/XcvCf+K+kC o+aOJE9O9taR3IMnTU58YjFi1XAQr0NDtVPq92HaeSr6U3hTKMEyDl2TYSRZO7BWGWHT +aZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446636; x=1723051436; 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=8f2VEr48rqS/xVUGYX/zdpL28CXVAGtsS1olIt5KoRY=; b=m9oC697UZLCc4kfuqvXdzIzakW2cObfX5laIzecOxwnAVsZmXUyfTUlN55v7cuomlu z9AMd3iAMzVi37MGHASiMqJqGeOGOwpjEbYVDIV2Jv1GOz3qq5YHim5H10IF44p7JfX0 awkrzWYzh2K9wfowGiLytaW4n5a5RC+AYwGi01l9K8B23L2LvG1jHjz7/6eT4Lfb4w1n ytOtEwKVsDq+9vnpUouL0eDgnihA0cQ+TpV6EMVT0iffshxXTIjLT1E7aSk6zJcNpBE8 KZM7yE4znnAjQf+uzOsqaqWEugpYGc/dkhShjZSWKjpAcQqQGp7tbE1abaS3ATX2IOWL SAjA== X-Forwarded-Encrypted: i=1; AJvYcCVj7cFXH3cli6p3ASgrdxTl5I5IushSYIfyv8SC89gmcHv6D6AW28OxrtD++6sfcLwLGiV+tXYundbibUPwMz0WnptUmUgY X-Gm-Message-State: AOJu0YwpDtdCvJjYl/NIyviVsbHu/Eq4agJNzhG7BFLyjHJhK9fU7qH4 tJMTxGe8lPsa0xtwhZvvbPR+gdgFSZPi4EBrG5Uxfgbs/Oia9r51uV5xsbbYhJIE5PES2MtoGch pdw== X-Google-Smtp-Source: AGHT+IGwBSHi1BId3E48H2h8nNpnR8g3goMlcdHaj6q6+v1C/nYhws4c5z860rXgGddcCGnHXzmepg== X-Received: by 2002:a05:6870:8a24:b0:259:8cb3:db2e with SMTP id 586e51a60fabf-267d4f01dafmr17784968fac.39.1722446635701; Wed, 31 Jul 2024 10:23:55 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:23:55 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 04/12] udp_encaps: Add new UDP_ENCAP constants Date: Wed, 31 Jul 2024 10:23:24 -0700 Message-Id: <20240731172332.683815-5-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-1-tom@herbertland.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add constants for various UDP encapsulations that are supported Signed-off-by: Tom Herbert --- include/uapi/linux/udp.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/uapi/linux/udp.h b/include/uapi/linux/udp.h index 1a0fe8b151fb..0432a9a6536d 100644 --- a/include/uapi/linux/udp.h +++ b/include/uapi/linux/udp.h @@ -36,6 +36,7 @@ struct udphdr { #define UDP_GRO 104 /* This socket can receive UDP GRO packets */ /* UDP encapsulation types */ +#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 +44,17 @@ struct udphdr { #define UDP_ENCAP_GTP1U 5 /* 3GPP TS 29.060 */ #define UDP_ENCAP_RXRPC 6 #define TCP_ENCAP_ESPINTCP 7 /* Yikes, this is really xfrm encap types. */ +#define UDP_ENCAP_TIPC 8 +#define UDP_ENCAP_FOU 9 +#define UDP_ENCAP_GUE 10 +#define UDP_ENCAP_SCTP 11 +#define UDP_ENCAP_RXE 12 +#define UDP_ENCAP_PFCP 13 +#define UDP_ENCAP_WIREGUARD 14 +#define UDP_ENCAP_BAREUDP 15 +#define UDP_ENCAP_VXLAN 16 +#define UDP_ENCAP_VXLAN_GPE 17 +#define UDP_ENCAP_GENEVE 18 +#define UDP_ENCAP_AMT 19 #endif /* _UAPI_LINUX_UDP_H */ From patchwork Wed Jul 31 17:23:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749006 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 E87A01BD512 for ; Wed, 31 Jul 2024 17:23:57 +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=1722446639; cv=none; b=mTSjsgkESGMARei6qfMCVERXCaNJwYP6t0RJ1Bzu3VwPOpZOVNF4pNmthBro4E6Nu2TQKmbcnmd1Yt5aZu/8AkTcRcFTbHYNqPB1B8JsIc3yyTreAgaTzU49FhfAtfkoib5EMUGXhLKsbRNXY5QzOq85G9bYYhjtEELoMEyxfNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446639; c=relaxed/simple; bh=Q5ncU6hUSIyMrne9XD2fwUyOxTXcwg4oUbu/75rT4dA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p64Q94Fx0YnLk6CatfX7o2sXfuXajZPD7RTVDTJxldSKpOxV+OsOYbRkxoflzpQC50N3C9OtYxFKu9lyYhSzkp++Ai8V2fVzPnxAI48q4MHaIvle7xAk1F6mx6muugYxQv67xmV4fk8tRHOK8S/LL51gDnOv7zRzNZF7eUb8BV4= 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=DmlD6Ov8; 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="DmlD6Ov8" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-70d1c655141so4472114b3a.1 for ; Wed, 31 Jul 2024 10:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446637; x=1723051437; 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=Vvijrc2anlLTYbTObgYbhL3tX3ZzyqYSkVQtZLVf5Sc=; b=DmlD6Ov8moEUdftCL/KyAnLEjSZLI+MHFAmoFOE/VZY4tMWFDjOuSNz91ZwvaotR7X 0GL7guvdH3VdEWfxyuBqtpiV4UGRgW2dTGUtxKrKlYVoOtMNvG725ZxOcVcpNjbL+v6s +VvOCiSyApG2Xr7FgX1DlcSo3L/WEkj7n0r1+qnOPkYeCn68C/Pj6V4AYuPBeDmOGlXm oWcOjI6Hk4BlAVAECkXYcSabe4J8NcmosBYinuZLUSeObqy2Lx/NdA60ItyXS6tXV1HM FCGjAQ/CgDotqgRhn6cmSnR53antDPBTKfDlYNRhsDy7A7YDVjmCp+U22fhLNC1oprBz 0khA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446637; x=1723051437; 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=Vvijrc2anlLTYbTObgYbhL3tX3ZzyqYSkVQtZLVf5Sc=; b=N6v41+fSRRmshdH7RtUfOE6krCMPn937wnVpvsEsVE+j7/ScdM1oagvUC99Mr9aZ9H gFXwrzc5ov9U3QIwXXih3pOuW7z08gBkSgO5Rtlqbw7UrweY50E/D6Y8hxuOCWcuE5g0 DZKAq2PQITWFKFDXzgQYxTHF+/ZXTz6kk1Ca9m2FECiR65yEwzy7FnIQx7Gc2gY9lu+0 E4rLlB/sEZkNnJOqPPRzWgoSYSWa9O+7Jtr0Y6RJMM65gm4YnTUAW0R9y6WzC3HdAXRO gdF5Veaf3rVe372VDhcYNnxfX9e1C0jingiPVaIzY9aE8SKmx3I2ByMImbe0gnWgw4JL 06BQ== X-Forwarded-Encrypted: i=1; AJvYcCXg+EfeiKbP/+8Q4u7ebThfpiaLcwjE11RR1flXUMXtvlu7KHWzL3r7YEw6e8cs2h7ardgdYxuXzSYjyNElVDBDv6Bngp2w X-Gm-Message-State: AOJu0Yx4/A+ysP2gdohj48S0Wd2BdjPA5+D8VG4n8IfvAwaFVDWNVODV 0mBws5oPEWNYQQixHN6S7lYkIP98pX5LL0S7X4seZVZHGN0j8iD4kzvYjOCBUg== X-Google-Smtp-Source: AGHT+IFDMhY+KljIj829Sikt3jtl0TmFPDmgiz8ZEtNhjz5Vs9Lv6h1m1XlcvuMuv+D8Bdni0f8KQA== X-Received: by 2002:a05:6a00:845:b0:70d:3777:da8e with SMTP id d2e1a72fcca58-70ecea3f2bdmr13342488b3a.18.1722446637103; Wed, 31 Jul 2024 10:23:57 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:23:56 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 05/12] udp_encaps: Set proper UDP_ENCAP types in tunnel setup Date: Wed, 31 Jul 2024 10:23:25 -0700 Message-Id: <20240731172332.683815-6-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 Signed-off-by: Tom Herbert Reviewed-by: Willem de Bruijn --- 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 ba59e92ab941..38715186aac4 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3572,7 +3572,8 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6, /* Mark socket as an encapsulation socket. */ memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); tunnel_cfg.sk_user_data = vs; - tunnel_cfg.encap_type = 1; + tunnel_cfg.encap_type = vs->flags & VXLAN_F_GPE ? + UDP_ENCAP_VXLAN_GPE : UDP_ENCAP_VXLAN; tunnel_cfg.encap_rcv = vxlan_rcv; tunnel_cfg.encap_err_lookup = vxlan_err_lookup; tunnel_cfg.encap_destroy = NULL; diff --git a/drivers/net/wireguard/socket.c b/drivers/net/wireguard/socket.c index 0414d7a6ce74..f4b5bd14fd56 100644 --- a/drivers/net/wireguard/socket.c +++ b/drivers/net/wireguard/socket.c @@ -352,7 +352,7 @@ int wg_socket_init(struct wg_device *wg, u16 port) int ret; struct udp_tunnel_sock_cfg cfg = { .sk_user_data = wg, - .encap_type = 1, + .encap_type = UDP_ENCAP_WIREGUARD, .encap_rcv = wg_receive }; struct socket *new4 = NULL, *new6 = NULL; diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c index 0abbc413e0fe..8241f762e45b 100644 --- a/net/ipv4/fou_core.c +++ b/net/ipv4/fou_core.c @@ -578,19 +578,20 @@ static int fou_create(struct net *net, struct fou_cfg *cfg, fou->sock = sock; memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); - tunnel_cfg.encap_type = 1; tunnel_cfg.sk_user_data = fou; tunnel_cfg.encap_destroy = NULL; /* Initial for fou type */ switch (cfg->type) { case FOU_ENCAP_DIRECT: + tunnel_cfg.encap_type = UDP_ENCAP_FOU; tunnel_cfg.encap_rcv = fou_udp_recv; tunnel_cfg.gro_receive = fou_gro_receive; tunnel_cfg.gro_complete = fou_gro_complete; fou->protocol = cfg->protocol; break; case FOU_ENCAP_GUE: + tunnel_cfg.encap_type = UDP_ENCAP_GUE; tunnel_cfg.encap_rcv = gue_udp_recv; tunnel_cfg.gro_receive = gue_gro_receive; tunnel_cfg.gro_complete = gue_gro_complete; diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 5a7436a13b74..290ebcf17a48 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -876,7 +876,7 @@ int sctp_udp_sock_start(struct net *net) return err; } - tuncfg.encap_type = 1; + tuncfg.encap_type = UDP_ENCAP_SCTP; tuncfg.encap_rcv = sctp_udp_rcv; tuncfg.encap_err_lookup = sctp_udp_v4_err; setup_udp_tunnel_sock(net, sock, &tuncfg); diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 439f75539977..3c081b7b9d67 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -771,7 +771,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, if (err) goto err; tuncfg.sk_user_data = ub; - tuncfg.encap_type = 1; + tuncfg.encap_type = UDP_ENCAP_TIPC; tuncfg.encap_rcv = tipc_udp_recv; tuncfg.encap_destroy = NULL; setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg); From patchwork Wed Jul 31 17:23:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749007 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 34D1E1BE228 for ; Wed, 31 Jul 2024 17:24:00 +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=1722446642; cv=none; b=iAkrIr+b+wiOo23APF62Qjo2L2Q0ZyMwh9Mf5R5bf5gpmNrWqRAC+DhJRv/wl/7Vd3L0USIMZhwcImRjOFE/zRD2GQqkFfiBcqnaULkv7ECphj3++Sdgrr0DxxjjN8K+kCqxd4/gJj567jSoDv94SFu81aQ7DXkEcWSaPEnC9gQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446642; c=relaxed/simple; bh=H1iQKMvlgsc1lvyQRC947XpooBlR1eb8C6Ifq/YKLM8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CDWUoisyI72AURHNNZV8xp1cMT2ohK31HAhw+qvmKbX5LMLy3MoxBk7FxcaZHAlDieFWuN2I0o+zjCDXtf2uQC/JOIxj7pKSiipWTpIOp5LPugrnfBf4GXNKp/CwR7h2+3R9QPu0pyAhKLozdUsdpH10dVlcItyhvnkpeVlXSrE= 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=WLqMsX3p; 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="WLqMsX3p" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-7104f939aaaso734704b3a.1 for ; Wed, 31 Jul 2024 10:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446639; x=1723051439; 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=imZmMFLAIJG5OavDJqtWshHLP2CLhvH70mtX5RPUROs=; b=WLqMsX3pOJjdG4NVyB/5h1+8cuxJMk/nlgQygHeJ3R1Sr4wJjPrJQlKNAZ75Nk8Bg4 ICcet83SMIb0LYYuB77HI0amwK1ylTFtHeCm1sYRvN5hlbzYDRIIhWZe1KXivaRDA3ml QYC0vEQ+F9tx6bA2/wat5aP+ybiLIE1Z3rzNhB1Bx5FlnoJotThLWQMRgUaKOYQ8yNpX y6bnYc6OrKn++z7CEiNfDUdkbRmpSFLKBuFCrDNV0qYEenp1eae2MnCNZE9ZWBLKQx3O AgM2JididyzXGuizXIBc6oTLzGZwXuE4RBge9T2a7xitRWypCACT0bQVqa9ULYKzmKsV 3I5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446639; x=1723051439; 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=imZmMFLAIJG5OavDJqtWshHLP2CLhvH70mtX5RPUROs=; b=rUFVTVyZTnexecFUxjUWJtgzU2BLZz1hB+siOCQqNX1VpnHW5DiTm8hYJnD/ODjg8f MzNZS4OgwRsDiDA1DbDDb+pq1wEPNEChSkXlZxF8ZsYgNnHY/fKYJzhFgHrg6FDXrFq0 g7eIkg1/p446J/Vw5x5mP0JWazNLdWD2kg/kKVZh8GROk6qjUNpg/qU2GiBOQxscnKnU PvKb5PIn1yy7ew0bdJIBGO+ls1dvEf4IZ85KJU8L6zsgIdjZmspssNb36FBOi4DTdqJf HZCyDf2RsmDCqr3Lhq5ctFcci3IOcx+c6MiYGhjOlEQDKBjcZ3sae+XAfFcIhgVv22IM 3vtQ== X-Forwarded-Encrypted: i=1; AJvYcCUEYSRPklOUMRbA24KjsWtaRJ6DyZzK2NAamkKgdjaTTQlynKf6BE+a8f6dIXLhvupXvMyTJmr/nB+X6ScHMINeylikIDWZ X-Gm-Message-State: AOJu0Yxe1ToDdxxR6xa7K6jaUbcVC+PDb4l3eR0L6DGLNb6Jfmk+VGAI MDfZJBJvyYIStcGKs+Xmzh9PUNBdCspFG7H8D7XvX5eH9G7QYctyFMjlmgxUPA== X-Google-Smtp-Source: AGHT+IEIWdXCuSRPBBXj5FEbh5Nct8SxXIXTuwJsPaPagjbFC2qFU+PTgeietc+QnjKy/y+DPrSK4g== X-Received: by 2002:a05:6a00:1910:b0:70d:2af7:849d with SMTP id d2e1a72fcca58-70eceda313bmr12644931b3a.23.1722446639425; Wed, 31 Jul 2024 10:23:59 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:23:58 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 06/12] flow_dissector: UDP encap infrastructure Date: Wed, 31 Jul 2024 10:23:26 -0700 Message-Id: <20240731172332.683815-7-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 | 114 +++++++++++++++++++++++++++++++++++ 2 files changed, 115 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 416f889c623c..006db3b893d0 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,110 @@ __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, 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 bpoff, unsigned int flags) +{ + enum flow_dissect_ret ret; + const struct udphdr *udph; + struct udphdr _udph; + struct sock *sk; + __u8 encap_type; + int nhoff; + + if (!(flags & FLOW_DISSECTOR_F_PARSE_UDP_ENCAPS)) + return FLOW_DISSECT_RET_OUT_GOOD; + + switch (*p_proto) { + case htons(ETH_P_IP): { + const struct iphdr *iph; + struct iphdr _iph; + + iph = __skb_header_pointer(skb, bpoff, 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; + } + case htons(ETH_P_IPV6): { + const struct ipv6hdr *iph; + struct ipv6hdr _iph; + + iph = __skb_header_pointer(skb, bpoff, 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 = __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; + } + default: + return FLOW_DISSECT_RET_OUT_GOOD; + } + + nhoff = *p_nhoff + sizeof(struct udphdr); + 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 +1151,7 @@ bool __skb_flow_dissect(struct net *net, int mpls_lse = 0; int num_hdrs = 0; u8 ip_proto = 0; + int bpoff; bool ret; if (!data) { @@ -1168,6 +1274,7 @@ bool __skb_flow_dissect(struct net *net, proto_again: fdret = FLOW_DISSECT_RET_CONTINUE; + bpoff = nhoff; switch (proto) { case htons(ETH_P_IP): { @@ -1635,6 +1742,13 @@ bool __skb_flow_dissect(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, + bpoff, flags); + break; + case IPPROTO_ICMP: case IPPROTO_ICMPV6: __skb_flow_dissect_icmp(skb, flow_dissector, target_container, From patchwork Wed Jul 31 17:23:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749008 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 829891DFE4 for ; Wed, 31 Jul 2024 17:24:01 +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=1722446643; cv=none; b=rHvykBqhFtetR4EGifF6fvGjc+VHLbcoE7/3GuP1Stxp3VRrhXMShpplMUqpfiOtxVfIRPDh7SlILOsGBZqlPQrtZt+AXRLGsXqs9VgLStbBo1cMWZ27KRFYsw7c4ZhvbG5dpPsJEMOfVOlQFnHZZxflnHJ6hNKb9jDgYze2f/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446643; c=relaxed/simple; bh=n51CI8cK5wiEvOfTCSLy5pPWmLpsIxNMT5nP6x2nZO0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iBuP9WNXubpWxTrLkxil/XWi7SXLVVXC2pexPjv0RDT8eguGfIkZoKNVOSIP3km2LLONqelCylXwGWnrDQdatUsZ8PzgRYbDn9iEpfnpjYoB0uD8AY+w9Y6Zzio/fxYfToZBN/kHPzvBjBZafJ248IT/Pq9p4ZFCZ6f1CbJiAPQ= 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=avsmUrIc; 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="avsmUrIc" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-70d1cbbeeaeso4401626b3a.0 for ; Wed, 31 Jul 2024 10:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446641; x=1723051441; 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=i0SX612ERSBxho7BUn2WEmD8uBOhjYomrMitKQTE+JU=; b=avsmUrIcAjdknyz5NgIqwc4f2/+wxOoI9aMQcvHmLuosSeIO+fg7Ud7KxESjcYnuOC /pAI0SjEYeQeFraSBffNBgyIb9ShyY61GjELggkvanM/Er0MpEdNsZbiRENt//cXUwLv z+x25lZhCOpwif7bHnLfVc7QD8HuiZ6WXvLoL9KuYwcvEOBX6zimrzp7/lSHhpJ77Umc Tk2eRXLSSNKZrFJESw308qMHm62rNADkVZjwW8zFbXNA+8410CLylRSbGUrvEJINbkqa iy4RN0tqfVB/FicUZxCw6ipBBsheTRZeq5JfkWwh9wgW6JXZ5plWDbwV3dSEoZ3xCOgN lZsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446641; x=1723051441; 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=i0SX612ERSBxho7BUn2WEmD8uBOhjYomrMitKQTE+JU=; b=m9XDFacKVtMOWcYloHz0kUEk0RfmUU10GA2ZaQwtSCUUcDvsM7LDfG3U6eaVICAWGr yBs9YTvnY7vBQsP52n7a4Jp/oJ83Ni7dCJNf4DLH/UIz6sAEaGEUvyb8FZqoI/jTZCXT 6UrJ6nQkaED9ajJP+GtI3piRjKGR47mhZwqM2cN3zSGwATL6PXUGOVwI5nbDhtqPbTcA Rh9+ioK7ksWCKP/0D8B4Zlu5n366iNtJPpNzUuTf3+pz/772XrIjzGMfeBvMlXRRUJVv 4iXh20t+Qh0PgFJc4J2ClIbfhbH9E7PZ1iNnoxgQ6KMw0kLE/Nsx1O3b+WVEGGYCsgGW D4Iw== X-Forwarded-Encrypted: i=1; AJvYcCVzMdLAw1Eb+v2nWo9i+lawn+QmQczxSmtTsSn0Kdz784wskzZ0O54rUzQVS4Z2nKKQ19xGk2yZoH/1OJuDog4MZS8g61Yh X-Gm-Message-State: AOJu0YxJv98xB6HU1mwfFmV1ahNoo9b2+UTbRGpXoLsMGMPvsWqJphIk striG6CzubiahAcIKhut4PpH024ygsRUArFJfj/A9yLfzKFcyDDs/cjCuu2Tcg== X-Google-Smtp-Source: AGHT+IFiW3hw86EkTuRM/PR9zTUoY0DhF03AmrMzsNEIVGvkZovEzhGfAQR0AdCxxEAgbWASmQ9jNA== X-Received: by 2002:a05:6a00:94a2:b0:706:b10c:548a with SMTP id d2e1a72fcca58-70eced8bad2mr13785947b3a.22.1722446640730; Wed, 31 Jul 2024 10:24:00 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:24:00 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 07/12] flow_dissector: Parse vxlan in UDP Date: Wed, 31 Jul 2024 10:23:27 -0700 Message-Id: <20240731172332.683815-8-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 006db3b893d0..6ad45b09dda4 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,55 @@ __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) +{ + 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 (hdr->vx_flags & VXLAN_F_GPE) { + struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)hdr; + + /* Need to have Next Protocol set for interfaces in GPE mode. */ + if (!gpe->np_applied) + return FLOW_DISSECT_RET_OUT_BAD; + + /* The initial version is 0 */ + if (gpe->version != 0) + return FLOW_DISSECT_RET_OUT_GOOD; + + /* "When the O bit is set to 1, the packet is an OAM packet and + * OAM so ignore + */ + if (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 @@ -893,6 +944,12 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, 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); + break; default: break; } From patchwork Wed Jul 31 17:23:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749009 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 C50441BBBC8 for ; Wed, 31 Jul 2024 17:24:02 +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=1722446644; cv=none; b=hYrEXnlxD5ZyLDx8U/zhumAsB6e8yf67zGNFG29hMKvppo2evESSL1qRCJciK/wRpaM/odDgp4x9C6sOuLVD6qWSohqYmZIArcdY+idv/+/iPfSi5+q37G81M4Yd0Xnk3jx/FGwd6OKeu/DmVDU9G6J1cVa3A9YeXRiKAXtg+es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446644; c=relaxed/simple; bh=5oMCYIU9XJTq0+hsLqOXoAjN+GZqSaq42fdG5HmWJPI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ncBaXUW9veQYV+JZp52jOxXLNxjJMvPnWIF1kuT8qzKDYMpfxZnQCUxvJnG7fnTAXBfZm6cESQ6vBZqdolGv99WlRvEVQyjpWeDvdFRiZuxG0A1J7sDdJx08bgueJmmtsYdPWkqSt1E4tWomD3dI9JSqji96pn17WM1snmfdqis= 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=a9dUDKZU; 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="a9dUDKZU" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-70eae5896bcso5257013b3a.2 for ; Wed, 31 Jul 2024 10:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446642; x=1723051442; 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=m8FUT5Xp4+XwB5Y+5gBGNeICx/92cKno6YcckxURgOM=; b=a9dUDKZUiAmhS3MMdyMpua9TZgi64ebFzIxnubOAWuSDicJS9QLoZk2E8wH11iY5Wu me+zNXAYGIEFhVNwZlRFZpPn3cAXHfq6XbpluXdgCV3bM6v/YtsI72uMRo+twaV72BDC RM4QF0jfjKj/krVyngjBti1WwTbi7mTktQqEQRSJOjQ7bQevd2Kfd9V3Fn1HVc9FhkeT pYDftX73/iuoyrzN63NiLBvLHejDc4sHkBmyBD9ldWyi8D+xGsmYZ65z8DCcEN2Nk/7Z 4qIOghOuTst7p5xhRehagc5x32fOufqwLbr4Gp5MvqH7sfwaI8SmhDR/gIkBUN+MddP6 ukvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446642; x=1723051442; 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=m8FUT5Xp4+XwB5Y+5gBGNeICx/92cKno6YcckxURgOM=; b=AKqTyvP4ALbg0oDr2SBqUc0QAQgccEuwZRZg+1QHF6eyxzlXvMXg7nKG90to/wNFMc ZFkdiltkJjeM5gwyu8cHng5826Rnb4O7VCHvcoRWYqeO1XxJaq1IK4wqpzPvSD+KyUfM AVOlRkV9XLdmOXLY6CrVgFDJAzigrW6IvLLGfvq7jewwnicBMn2BoUfwy1gKHvws3VWZ cyP+R/olgx5ewC9Ua02n2l0Bo2+xTwjvXObg61s391gxM5z+wJkK5TpUduPQZBukyqFt 4IvvjISS647d0pQGudzphDYN1j2Qd4UoC5pESFFxm5lEP0b9QnVljlEHg4RRctK3Do+E FyNA== X-Forwarded-Encrypted: i=1; AJvYcCXSjh/ZwTGuYo5kXYpXuiE21rJh3WLmgiJpXn2CGbPW3FSLsjbZRLVKcfreR5vnLdHzEax1eSRIZ+XWcOTL/hsJAXDLyEz2 X-Gm-Message-State: AOJu0Yx8iFP/VWVYc1klQHr1q2FQFga84BQdLsibBZAfZFVQwkGBT5Fj wDxvt5g1B4stdPsPaaS9jVP/Pm4mH8GzHdk0fXLuJiVJGs4GqYd+pdKR5AuoEg== X-Google-Smtp-Source: AGHT+IGNBQ1halh5m9PUDBr7sefo5cIqvF4C7P67NCrvbkftDM7cGyMZyg+AkfQD3y9noOa6+qn7hA== X-Received: by 2002:a05:6a20:394d:b0:1c4:c795:ee6a with SMTP id adf61e73a8af0-1c68cf8d06emr159626637.28.1722446642090; Wed, 31 Jul 2024 10:24:02 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.24.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:24:01 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 08/12] flow_dissector: Parse foo-over-udp (FOU) Date: Wed, 31 Jul 2024 10:23:28 -0700 Message-Id: <20240731172332.683815-9-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 Signed-off-by: Tom Herbert Reviewed-by: Willem de Bruijn --- include/net/fou.h | 16 ++++++++++++++++ net/core/flow_dissector.c | 13 ++++++++++++- net/ipv4/fou_core.c | 16 ---------------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/include/net/fou.h b/include/net/fou.h index 824eb4b231fd..8574767b91b6 100644 --- a/include/net/fou.h +++ b/include/net/fou.h @@ -17,6 +17,22 @@ int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, u8 *protocol, __be16 *sport, int type); +struct fou { + struct socket *sock; + u8 protocol; + u8 flags; + __be16 port; + u8 family; + u16 type; + struct list_head list; + struct rcu_head rcu; +}; + +static inline struct fou *fou_from_sock(struct sock *sk) +{ + return sk->sk_user_data; +} + int register_fou_bpf(void); #endif diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 6ad45b09dda4..68906c4bb474 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -865,11 +866,11 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, struct net *net, int *p_nhoff, int hlen, __be16 *p_proto, u8 *p_ip_proto, int bpoff, unsigned int flags) { + __u8 encap_type, fou_protocol; enum flow_dissect_ret ret; const struct udphdr *udph; struct udphdr _udph; struct sock *sk; - __u8 encap_type; int nhoff; if (!(flags & FLOW_DISSECTOR_F_PARSE_UDP_ENCAPS)) @@ -902,6 +903,9 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, 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; @@ -932,6 +936,9 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, 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; @@ -944,6 +951,10 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, struct net *net, ret = FLOW_DISSECT_RET_OUT_GOOD; switch (encap_type) { + case UDP_ENCAP_FOU: + *p_ip_proto = fou_protocol; + ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; + break; case UDP_ENCAP_VXLAN: case UDP_ENCAP_VXLAN_GPE: ret = __skb_flow_dissect_vxlan(skb, flow_dissector, diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c index 8241f762e45b..137eb80c56a2 100644 --- a/net/ipv4/fou_core.c +++ b/net/ipv4/fou_core.c @@ -21,17 +21,6 @@ #include "fou_nl.h" -struct fou { - struct socket *sock; - u8 protocol; - u8 flags; - __be16 port; - u8 family; - u16 type; - struct list_head list; - struct rcu_head rcu; -}; - #define FOU_F_REMCSUM_NOPARTIAL BIT(0) struct fou_cfg { @@ -48,11 +37,6 @@ struct fou_net { struct mutex fou_lock; }; -static inline struct fou *fou_from_sock(struct sock *sk) -{ - return sk->sk_user_data; -} - static int fou_recv_pull(struct sk_buff *skb, struct fou *fou, size_t len) { /* Remove 'len' bytes from the packet (UDP header and From patchwork Wed Jul 31 17:23:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749010 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 518721BE24B for ; Wed, 31 Jul 2024 17:24:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446645; cv=none; b=dnbb+U0iR7hnhdcsSV+Gh6/Ek1Jgaez3g0er1QIiLnMUoemHcIJ2iG7ziqqg82vck0W77dMWoUOs6DESru/hHsGu+/rx+tDMMMZ6B4DQFrQWMFYpx3OknDWxTRhl0wFNYJF7Ppvc+heGoJu2THGTE9b0nMxyopO69nC/ZhYF5OY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446645; c=relaxed/simple; bh=296isLAADgrxQrxtxkq4pUsuyUhJiENDHC0DxsFqIBI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bnmR7gxoVG+422EuCLJFMDNGljz+LjwnReHBmnz16PgldZ6+IAI788FMA94CZkrM0jUZnCnP+RZtNeOvNwuLLGLfCp4paqBjv5kAhTHrlds4D6aV8wLXNLPUNquVWHWmTVapc1q08LbfIdmklLxzRu2mX0/q30etficFfInGK5M= 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=hC84F03a; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="hC84F03a" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-70d333d57cdso4299287b3a.3 for ; Wed, 31 Jul 2024 10:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446643; x=1723051443; 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=WvQhfDiwAzUjEhxoZFVKQ1onbUQ2OV+Y2W79oOVwrwk=; b=hC84F03au82rcC60RVoJ4BirbwYHp53EpNa5LtRyImRw5I6gaDp9UmjdjFVuV3dcaW Vs0hGCdkLmWFrE5GqtWHnIO994pS7YzQvEvSHctUFFADIwyz56obZm7DIsaDlXbEAE/E /kHHpBzmQNJnYkFvdgwS2LSyaWFWNolilBksn2LVGB1Z/l3P9oz5Tu1SKFsQmOoPuZYj TPCswSgcclJHocp4iXxgB+Z/wStgChVIH/NJwC3irT78yf5+5wabVLi6RIfM7tcNRdk4 yMVExAzVGk64J1dal+omA6MuH6xKkJXV4e4L2vqseBpYOaFWdZs+Gh4PQctwvmQoFTZJ F1gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446643; x=1723051443; 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=WvQhfDiwAzUjEhxoZFVKQ1onbUQ2OV+Y2W79oOVwrwk=; b=Eib10zvYHThEHCdIdjeBTpN/N6WMFh/L/XmM7kpVErcHo/F7SoKQbc3QF2HMQvGszN k8QO3mXr6lEHOjxgTZlvidZ1MWnOMXa200IoIK0q7bHH/+u4ybcwDdbd5JBMJXjasMAY ppTaCMI1ajWDC8249GuV/LujlYaF1Ht6Z44jV/sllDFE9FGWimcN62fxUny5N2irJqwR vTlbiG6aCENwhOnaxhM7IYQ4MkT4ZJneTl78kUzhdUCkduvOEJigi/BsrsX5wAp45R/2 WEXLbZUZuReazmLvSFNLrImZURdDR0Skrt/gP1+ZGooKVxVb8WBvYzSyTOW6alxnFLD0 4CQQ== X-Forwarded-Encrypted: i=1; AJvYcCWb3e8Wxqq2HKFoD0hIK5pDD1uQb1/q7epGseC/MyUFKW9gv8WTSvU9SglTI46S6CkGil027rqV9bObb+fj7WRgeVAtNCGw X-Gm-Message-State: AOJu0YzdQiFSqLIIU2g+i0EbT1QqUSFlnvFnS7YfLHY/zc0UJiCsy3ic JM2oIm1nmnkfVG+xb4Ih1AxL15iIvET0oNDnupM97Y1fsbEXVMQvlHFqtMIXBw== X-Google-Smtp-Source: AGHT+IHhTCBtjF5lXf+QshaFRGe8EGUEplT/BmYOb/uv71kOHuIHex4ULAjafDirSVgtgULWxoSP+g== X-Received: by 2002:a05:6a20:4303:b0:1c4:c305:121d with SMTP id adf61e73a8af0-1c68d2607cdmr98249637.39.1722446643516; Wed, 31 Jul 2024 10:24:03 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:24:03 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 09/12] flow_dissector: Parse ESP, L2TP, and SCTP in UDP Date: Wed, 31 Jul 2024 10:23:29 -0700 Message-Id: <20240731172332.683815-10-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 68906c4bb474..3766dc4d5b23 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -951,10 +951,23 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, struct net *net, ret = FLOW_DISSECT_RET_OUT_GOOD; switch (encap_type) { + case UDP_ENCAP_ESPINUDP_NON_IKE: + case UDP_ENCAP_ESPINUDP: + *p_ip_proto = IPPROTO_ESP; + ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; + break; + case UDP_ENCAP_L2TPINUDP: + *p_ip_proto = IPPROTO_L2TP; + ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; + break; case UDP_ENCAP_FOU: *p_ip_proto = fou_protocol; ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; break; + case UDP_ENCAP_SCTP: + *p_ip_proto = IPPROTO_SCTP; + ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; + break; case UDP_ENCAP_VXLAN: case UDP_ENCAP_VXLAN_GPE: ret = __skb_flow_dissect_vxlan(skb, flow_dissector, From patchwork Wed Jul 31 17:23:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749011 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB9F61BE258 for ; Wed, 31 Jul 2024 17:24:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446647; cv=none; b=NpbuVaw2ArhADqbG5rfOkFU9sRFGcdmtVfJo+v6BIzt2uZHiCBFmuYxTYPE/Xo1tlD+pRkpx08H67PJJXdHwB1ikVCoXby+aYM+BJ5uZcQS/AYGqlJYdOM8gtmtSs4A3ZmMeYVue1HcYniVHI9CHlpWBKyyarxlkyvw4iL9trkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446647; c=relaxed/simple; bh=WqE54iqgsL7Gq5r/FGZzatFq3v1Ubfb/TsjD/HB0MWo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iJ7kH80MfjbRRjvHLGSka0Io0811aIlEy6XgKAA/+FJvCuiQB5/1MZ7A6UbWTqKIN83WzBiIgfY1hwJgxnrQUBJe8dBxojGXeAg+2HMRocmAAQX24mHvSxa0GZGWFis1oN3IozWCVP2VkagLV+a2NI9X/w42TifAXELg68Z5CJw= 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=KIY4ZiIq; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="KIY4ZiIq" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-70cec4aa1e4so4120089b3a.1 for ; Wed, 31 Jul 2024 10:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446645; x=1723051445; 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=wMX0tr1XqQIXXYv8t8puiyUaD8WbuWDFc/Hh6oAxUxs=; b=KIY4ZiIqgFO3UD9N1n98ar2uZTVuV16lUydIcejn4wJO7n0V82oM0rKwGBQkg9VuGW o+Hi57S/Xh9eGXadx1DRn1kKZI6Aw6c2cKhvQQZsTUw6Q8gpQw0NjVBTAuFUiNlWUJ55 n15Ois+pw4EVZwcyje3ykuVsx+BZs2OgST9a9h5kZb8amwhy7ZEdE1PMFjeMW1zq5WnW cwRZodFHQef+cZ1iSTMW2phd1+49CDGxNxOBR/+hkIuRdSSL18tG5vmfKWZyhbahFwIS PNkG43ob5liy94vQQCewJ1BuWhvuBbqiBG19goBiky/S1YWhzh1ADpbnwEiX251uvJhe VizQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446645; x=1723051445; 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=wMX0tr1XqQIXXYv8t8puiyUaD8WbuWDFc/Hh6oAxUxs=; b=Ehl9GT93G9ejJLrHpL1yaGtDQtWTEpSgRywg3SqoSMh0VLirVQqDfX9S9MOLzOmS3x j6f34KvPqV3XbvkvCtyamIuOMWWII0RtjYEJupprh37c9ijSSkkYraUA8gQLQUqgbieK f5843aLIFdhzIMNxcKk0t4yHNmlcQsPVxNKGrELuBTJMSUQKLpbiEdGrMqhvVfQ3F9oK XX1/4cpHrHL+R9RAxj2Rmy5ZMakjkivWiUkcnq+z8V7+itGQtciBYvDjRbHdoT9nsW8P RDUu6MROwxIzZ47K8Ls4VeK49HlxAsdOANyG8m/BW7OTvNdDnPgbXCJgxFpXrEDkX0fK iAbg== X-Forwarded-Encrypted: i=1; AJvYcCX0ERSplkaVCVO5u+Oacub6tXGAq6sBkFooj+mYDUP/9lfMYTvcZXk/rsGC3t29GCCqb3nJb9M43TBo7s4v1tUNbRTh0JOc X-Gm-Message-State: AOJu0Yx/sv4b/+pyRs3VeJxWzRSMUWZOegt/pdyadi9ttnQgFminU16t tXgN1LUvT/jazyf2tQ3BgCoQSOQFTgaa4XUIX1eSHJ9tZNahrC8iBSCD0MikkaGWBcJiYO6FDDq lwg== X-Google-Smtp-Source: AGHT+IE/wgjjpDpaouCZpQnlB9N9HP12Y0QRdbb5N2mjjfhMMS5fNqgmYVEXLId2Cv4kDNe/8lohEw== X-Received: by 2002:a05:6a00:178e:b0:706:8a67:c395 with SMTP id d2e1a72fcca58-70ece9ebb3amr18997465b3a.6.1722446644859; Wed, 31 Jul 2024 10:24:04 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:24:04 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 10/12] flow_dissector: Parse Geneve in UDP Date: Wed, 31 Jul 2024 10:23:30 -0700 Message-Id: <20240731172332.683815-11-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 3766dc4d5b23..4fff60233992 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -808,6 +809,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 @@ -974,6 +998,11 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, struct net *net, target_container, data, p_proto, &nhoff, hlen, flags); break; + case UDP_ENCAP_GENEVE: + ret = __skb_flow_dissect_geneve(skb, flow_dissector, + target_container, data, + p_proto, &nhoff, hlen, flags); + break; default: break; } From patchwork Wed Jul 31 17:23:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749012 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F32CC1BE849 for ; Wed, 31 Jul 2024 17:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446648; cv=none; b=GCo9rjPyetpAGse4o9H/qEFYyq2VjsuUBaCq8+ueRZS7YMOgaPpr1lOCOaYSUO6BkLBqtlI3v8Runpin40DyEgBlqi7FIiaDvTwTjIk+Gz2ih7b2Z+VaC2k63+nBLsidVuNxDgjfSy6vd+iAf3F5jm9nFDXniIfsXp5ehoTdnjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446648; c=relaxed/simple; bh=uCrzGnflXBB/wO7tIWXlW2Kk1gddFbDJri8RoliGZIo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ClvMF9EVrOKVniUj/KuQG2fkIe9okM/iCtxGjP0suO/NZ4SkLC5NVUC2Q+YAUsJVGITv9o62IkrY/dU1Iq46YUy4aETlzy9irM+Y4W7LZ3AHWuNPT1VO5EeB+xFx+B76IkZMAAjeeaalWPbaE9tVmFkSQi5q3xc6PhVIWrl7cio= 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=XfOLmJGl; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="XfOLmJGl" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-70eb73a9f14so4526678b3a.2 for ; Wed, 31 Jul 2024 10:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446646; x=1723051446; 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=2VAIcPmR4c/mUmwEAsZgDFV7MJlQirW9DYXFb4pZbSk=; b=XfOLmJGlib0OmnqszaMjiZP3LJxAzYNr7rIpeJ/vEbpUekK7vd6NTPMB42Jp+Owzgw AwYh6ywxj9rYgtdVA01tLvSuhZ6u0Vsy5nclz6sxnuqW2CX/OvC8Xgstc5c3Lg1EqyKf /GauV+HRpJ2xbm4NCSqii9DfrL/vyH/I5f/oB56Li/71Rl8+/rXsGpeDA8Yox4GDN5iu x9gwJfqRSLXAgaMGFSRxNj7OF6mTu+swa9OivzwD5t3nxOldfxqcydaTPxnBoQd0o9C7 +x5UxUffjfq2BYUu4ksK2BFcePazeOWdFNHENRSeLuTSAHMcw8DcRruWzBxsXNZHDPJZ 22mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446646; x=1723051446; 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=2VAIcPmR4c/mUmwEAsZgDFV7MJlQirW9DYXFb4pZbSk=; b=bHq39W35EIdMTPfBVVJi8O6W72LgfmH9zK6aQs/pAEIOeSqFrp4RLauoW4rbvXt4GU oBVYuEBGdYuo7yp/7nPRaIsYcdh+nIdy6NUQ9GTw9dDZNKvkDozGJAZUiYmi2EbKF4Wg CzcjcDfyLi4fh4RIhdfm4KQILJPINxfucrYDSp8uv90wZ5y1raEMKYE8hCVmftM8I+h/ 1Hl8EzKa9r8wbg/Y6gHQx694f+eI8YFwURNSJH1ltrf+NeY6zVTVwJQizrE581Rj4VJM AAz8l+7CQnyMwMAtX5PAb1tgYVbhPWjT1UBn3XUiI4DO1ukGE1edQ+i+YkILmorZg/eZ xi4g== X-Forwarded-Encrypted: i=1; AJvYcCXrLfg1ZwVbiphPGnYo+s3z0jijIyb5bjWrLjp0MWMm3vuG4+Orv4kVHbrBtksfndy1GtWoTlhfzrycMEa+AHrA3oo5wlk3 X-Gm-Message-State: AOJu0Yw5RYAfpw/EQMGhyL7kmeIPYF8En/URJRrA8Yl1UHnCYyYiih4j CyHG61FfsdP2g9KbtJSnduU6poOweul3Pdvs1PYCIVgYrTSOuM6CCuqw/qb/BfoSuvHVef3RniR QSw== X-Google-Smtp-Source: AGHT+IEWst+YGDsEisZO52gN7YdaR80YMovtazfFNrY9HVXqIh2Dt0YnB1ROB8bpMAy+M8t8Xeni0Q== X-Received: by 2002:a05:6a21:114d:b0:1be:e6d8:756e with SMTP id adf61e73a8af0-1c68d265253mr72285637.53.1722446646236; Wed, 31 Jul 2024 10:24:06 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:24:05 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 11/12] flow_dissector: Parse GUE in UDP Date: Wed, 31 Jul 2024 10:23:31 -0700 Message-Id: <20240731172332.683815-12-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 4fff60233992..7f0bf737c3db 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -832,6 +832,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 @@ -988,6 +1043,11 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, struct net *net, *p_ip_proto = fou_protocol; ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; break; + case UDP_ENCAP_GUE: + ret = __skb_flow_dissect_gue(skb, flow_dissector, + target_container, data, + p_ip_proto, p_nhoff, hlen, flags); + break; case UDP_ENCAP_SCTP: *p_ip_proto = IPPROTO_SCTP; ret = FLOW_DISSECT_RET_IPPROTO_AGAIN; From patchwork Wed Jul 31 17:23:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 13749013 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 207F81BD4E3 for ; Wed, 31 Jul 2024 17:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446649; cv=none; b=Vi0cBB5T/1gqRn+tGfZRB6tYDVzjdkBIgVSahHlt/1JW4bm/WEg3+V541mXUJQD5+FIIiXj9QPq0diUgXZ9lhfQQq2s4wmZj4j8g+/q7rGzMbaiWRi+2EdnFgcciMvr6Zm6Y3ib+Nzl9RDpDh1WkNmXbNg6DLIOjgLzZ6CumhHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722446649; c=relaxed/simple; bh=Uaz0+6BevwyEXT/uG3eV6RgaEzEZq57aPBCVyG9WuNE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M6ebgX8xoxVFRJlKihmXf74Sq4ndkBgydsWhoQ3f5/ZJzmcz+Z96J/3+sMeVZ5RJ5zqn8S9vMZHlA8lMiUkzpOKfqtSu0NQYVFx3WvhwJBfMiNuk4sTrEUiORfI7XxDTqpwdIhihCuflWojQ9BrJUaeAPKb2mBVjgNeT77rbChg= 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=UfWM2NpS; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=herbertland.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herbertland.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herbertland.com header.i=@herbertland.com header.b="UfWM2NpS" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-710439ad77dso1572228b3a.2 for ; Wed, 31 Jul 2024 10:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland.com; s=google; t=1722446647; x=1723051447; 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=FTJAEyJOqHchmjcd+P/9wLzF9JPDrStciBj2jppQ1sU=; b=UfWM2NpShUE+jzgJm8cuqHLmK5ZD14TX21ZLUrAi/MQyPlkiMN1/w92rhFkCUaudkk Dz1zcHy+e4eCO4udeE6WMGjYMz3jTxDA7XWGNfB2T5qcbT7KyYH84ZQgPeR1EhQnRwuu s8UatHcvv2HBkP0eo18DXgXCEW2AnyA7eXwC8v41rSAaZDAatLqpX3a2ef7kWnatYn5g PTew06gXla2giUMo3W+fRrPDaKHl0mHUtIRU4srWP/WchEOJuujpsW2W2e7qFvGrZ+g9 U26TJZctqV0mhYPNIOQKteRpodAspkFTsBJMBz3S/cAlSHCObbk84RwhOekP22rjMxOH +VvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446647; x=1723051447; 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=FTJAEyJOqHchmjcd+P/9wLzF9JPDrStciBj2jppQ1sU=; b=CDJAH2k8uYvh75aEH8yWDVI+TYST9N1LMdbotot5vynI68YC7c+w4mG+hkcTZkpApx 2fZ8cZax2SsiNHed3vsZ9W2dvkRWj4olx5YemIKbFFk/VygyUX+lAlokYda3huJhJL9B Npr51Q3/aS3+KXtkYKaFXvcS+JI5VpATpN6vL26lA88Z9pC9XZw0Jyaft4smIWXGnP+3 GDnsJuyrTiRf6qoCCi9Nxx5530780dn03jcIX3L1wnDMZGjPD/HBJBEQ6MSexFagDFwa 3ohh3QY+xiPlWIckwdW54FOZZzGac169eOVOP15sb6dVpAjuBx5H1HKCx2Bd3AVksGPO psxA== X-Forwarded-Encrypted: i=1; AJvYcCVdVKNpdHmjE3QuCkgw0/qoAflWtBd5hK5jVxUrvLePAuLkZtcZVxkuSR5RilTZDfWHuWY8H3WzbsEwIG7drcuPVDJOz29z X-Gm-Message-State: AOJu0YwOmczJbNW2pd8APEcGZhXVV1dkeOKvlu1jbSSvP8Z5Zd61ah8F spO5jmwy3iP9/zj14LKcLQQkpna8UQ09zR8mQ+xgggn+jIXUzq5IYy/urH8Qyg== X-Google-Smtp-Source: AGHT+IEiKUQazBv53K2DGK3kpSwuO9lOEkL2727kNBNa81juQ8UzfIPmwo1cYq8f/5QIdYEuULMBNQ== X-Received: by 2002:a05:6a20:4309:b0:1c4:9e32:b26f with SMTP id adf61e73a8af0-1c68cef30c3mr102133637.8.1722446647480; Wed, 31 Jul 2024 10:24:07 -0700 (PDT) Received: from TomsPC.home ([2601:646:8300:55f0:be07:e41f:5184:de2f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72ab97sm10487203b3a.92.2024.07.31.10.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:24:07 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, netdev@vger.kernel.org, felipe@sipanda.io Cc: Tom Herbert Subject: [PATCH 12/12] flow_dissector: Parse gtp in UDP Date: Wed, 31 Jul 2024 10:23:32 -0700 Message-Id: <20240731172332.683815-13-tom@herbertland.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731172332.683815-1-tom@herbertland.com> References: <20240731172332.683815-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 | 87 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 7f0bf737c3db..af197ed560b8 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 @@ -887,6 +889,81 @@ __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; + + 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 @@ -1039,6 +1116,16 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, 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;