summaryrefslogtreecommitdiff
path: root/include/net/gtp.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2024-05-07 01:11:47 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2024-05-07 01:35:55 +0200
commitb6fc0956ac532d1b35f6f517c083603b5e150b0d (patch)
treed12fb58ece454decaee6637a6a1a62166db9510a /include/net/gtp.h
parent353f5ffbc63b532aa0c92a7635e84bd53d04644e (diff)
gtp: properly parse extension headers
Currently GTP packets are dropped if the next extension field is set to non-zero value, but this are valid GTP packets. TS 29.281 provides a longer header format, which is defined as struct gtp1_header_long. Such long header format is used if any of the S, PN, E flags is set. This long header is 4 bytes longer than struct gtp1_header, plus variable length (optional) extension headers. The next extension header field is zero is no extension header is provided. The extension header is composed of a length field which includes total number of 4 byte words including the extension header itself (1 byte), payload (variable length) and next type (1 byte). The extension header size and its payload is aligned to 4 bytes. A GTP packet might come with a chain extensions headers, which makes it slightly cumbersome to parse because the extension next header field comes at the end of the extension header, and there is a need to check if this field becomes zero to stop the extension header parser. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/net/gtp.h')
-rw-r--r--include/net/gtp.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/net/gtp.h b/include/net/gtp.h
index 2a503f035d18..c0253c8702d0 100644
--- a/include/net/gtp.h
+++ b/include/net/gtp.h
@@ -78,4 +78,9 @@ static inline bool netif_is_gtp(const struct net_device *dev)
#define GTP1_F_EXTHDR 0x04
#define GTP1_F_MASK 0x07
+struct gtp_ext_hdr {
+ __u8 len;
+ __u8 data[];
+};
+
#endif