summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorJamal Hadi Salim <jhs@mojatatu.com>2016-07-02 06:43:14 -0400
committerMichael Bestas <mkbestas@lineageos.org>2022-04-19 00:51:36 +0300
commit86c651d631b89084f7bc5925c73091f8fbb0e630 (patch)
treea69bb7e0491408ef8a975391aead1e1f5d6ae3e6 /include/linux
parent7c2ad1220f8fb6b6c77a5324979e4756d202f995 (diff)
net: simplify and make pkt_type_ok() available for other users
Suggested-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/skbuff.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 172c2d3fd654..4f2933707b13 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -37,6 +37,7 @@
#include <net/flow_dissector.h>
#include <linux/splice.h>
#include <linux/in6.h>
+#include <linux/if_packet.h>
#include <net/flow.h>
/* A. Checksumming of received packets by device.
@@ -809,6 +810,15 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb)
return (struct rtable *)skb_dst(skb);
}
+/* For mangling skb->pkt_type from user space side from applications
+ * such as nft, tc, etc, we only allow a conservative subset of
+ * possible pkt_types to be set.
+*/
+static inline bool skb_pkt_type_ok(u32 ptype)
+{
+ return ptype <= PACKET_OTHERHOST;
+}
+
void kfree_skb(struct sk_buff *skb);
void kfree_skb_list(struct sk_buff *segs);
void skb_tx_error(struct sk_buff *skb);