From: Tom Herbert <tom@herbertland.com>
To: davem@davemloft.net, kuba@kernel.org, edumazet@google.com,
netdev@vger.kernel.org, felipe@sipanda.io,
willemdebruijn.kernel@gmail.com
Cc: Tom Herbert <tom@herbertland.com>
Subject: [PATCH net-next v2 01/12] flow_dissector: Parse ETH_P_TEB and move out of GRE
Date: Thu, 15 Aug 2024 14:45:16 -0700 [thread overview]
Message-ID: <20240815214527.2100137-2-tom@herbertland.com> (raw)
In-Reply-To: <20240815214527.2100137-1-tom@herbertland.com>
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
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
net/core/flow_dissector.c | 57 +++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 26 deletions(-)
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 0e638a37aa09..4b116119086a 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,27 @@ 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.
+ */
+ 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;
@@ -1531,7 +1536,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:
--
2.34.1
next prev parent reply other threads:[~2024-08-15 21:46 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 21:45 [PATCH net-next v2 00/12] flow_dissector: Dissect UDP encapsulation protocols Tom Herbert
2024-08-15 21:45 ` Tom Herbert [this message]
2024-08-16 18:54 ` [PATCH net-next v2 01/12] flow_dissector: Parse ETH_P_TEB and move out of GRE Willem de Bruijn
2024-08-20 16:21 ` Tom Herbert
2024-08-20 16:30 ` Willem de Bruijn
2024-08-20 16:42 ` Tom Herbert
2024-08-20 17:43 ` Willem de Bruijn
2024-08-15 21:45 ` [PATCH net-next v2 02/12] udp_encaps: Add new UDP_ENCAP constants Tom Herbert
2024-08-16 18:56 ` Willem de Bruijn
2024-08-15 21:45 ` [PATCH net-next v2 03/12] udp_encaps: Set proper UDP_ENCAP types in tunnel setup Tom Herbert
2024-08-15 21:45 ` [PATCH net-next v2 04/12] flow_dissector: UDP encap infrastructure Tom Herbert
2024-08-16 19:09 ` Willem de Bruijn
2024-08-17 14:01 ` kernel test robot
2024-08-20 18:52 ` Eric Dumazet
2024-08-20 19:00 ` Tom Herbert
2024-08-15 21:45 ` [PATCH net-next v2 05/12] flow_dissector: Parse vxlan in UDP Tom Herbert
2024-08-16 19:19 ` Willem de Bruijn
2024-08-17 1:09 ` Jakub Kicinski
2024-08-20 18:15 ` Tom Herbert
2024-08-15 21:45 ` [PATCH net-next v2 06/12] flow_dissector: Parse foo-over-udp (FOU) Tom Herbert
2024-08-15 21:45 ` [PATCH net-next v2 07/12] flow_dissector: Parse ESP, L2TP, and SCTP in UDP Tom Herbert
2024-08-16 19:20 ` Willem de Bruijn
2024-08-15 21:45 ` [PATCH net-next v2 08/12] flow_dissector: Parse Geneve " Tom Herbert
2024-08-16 19:21 ` Willem de Bruijn
2024-08-15 21:45 ` [PATCH net-next v2 09/12] flow_dissector: Parse GUE " Tom Herbert
2024-08-16 19:25 ` Willem de Bruijn
2024-08-15 21:45 ` [PATCH net-next v2 10/12] gtp: Move gtp_parse_exthdrs into net/gtp.h Tom Herbert
2024-08-16 19:27 ` Willem de Bruijn
2024-08-15 21:45 ` [PATCH net-next v2 11/12] flow_dissector: Parse gtp in UDP Tom Herbert
2024-08-15 21:45 ` [PATCH net-next v2 12/12] flow_dissector: Add case in ipproto switch for NEXTHDR_NONE Tom Herbert
2024-08-16 19:28 ` Willem de Bruijn
2024-08-16 20:19 ` [PATCH net-next v2 00/12] flow_dissector: Dissect UDP encapsulation protocols Willem de Bruijn
2024-08-20 18:28 ` Tom Herbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240815214527.2100137-2-tom@herbertland.com \
--to=tom@herbertland.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=felipe@sipanda.io \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).