@@ -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
@@ -8,6 +8,7 @@
#include <linux/filter.h>
#include <net/dsa.h>
#include <net/dst_metadata.h>
+#include <net/fou.h>
#include <net/ip.h>
#include <net/ipv6.h>
#include <net/gre.h>
@@ -855,11 +856,11 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net,
u8 *p_ip_proto, int base_nhoff, unsigned int flags,
unsigned int num_hdrs)
{
+ __u8 encap_type, fou_protocol;
enum flow_dissect_ret ret;
const struct udphdr *udph;
struct udphdr _udph;
struct sock *sk;
- __u8 encap_type;
int nhoff;
if (!(flags & FLOW_DISSECTOR_F_PARSE_UDP_ENCAPS))
@@ -906,6 +907,9 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net,
}
encap_type = udp_sk(sk)->encap_type;
+ if (encap_type == UDP_ENCAP_FOU)
+ fou_protocol = fou_from_sock(sk)->protocol;
+
rcu_read_unlock();
break;
@@ -942,6 +946,9 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net,
}
encap_type = udp_sk(sk)->encap_type;
+ if (encap_type == UDP_ENCAP_FOU)
+ fou_protocol = fou_from_sock(sk)->protocol;
+
rcu_read_unlock();
break;
@@ -956,6 +963,10 @@ __skb_flow_dissect_udp(const struct sk_buff *skb, const struct net *net,
ret = FLOW_DISSECT_RET_OUT_GOOD;
switch (encap_type) {
+ case UDP_ENCAP_FOU:
+ *p_ip_proto = fou_protocol;
+ ret = FLOW_DISSECT_RET_IPPROTO_AGAIN;
+ break;
case UDP_ENCAP_VXLAN:
case UDP_ENCAP_VXLAN_GPE:
ret = __skb_flow_dissect_vxlan(skb, flow_dissector,
@@ -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