1 #ifndef __NET_UDP_TUNNEL_WRAPPER_H
2 #define __NET_UDP_TUNNEL_WRAPPER_H
4 #include <linux/version.h>
5 #include <linux/kconfig.h>
7 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,20,0)
8 #include_next <net/udp_tunnel.h>
10 static inline struct sk_buff *
11 rpl_udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum,
14 if (skb_is_gso(skb) && skb_is_encapsulated(skb)) {
16 return ERR_PTR(-ENOSYS);
18 return udp_tunnel_handle_offloads(skb, udp_csum);
20 #define udp_tunnel_handle_offloads rpl_udp_tunnel_handle_offloads
24 #include <net/ip_tunnels.h>
30 /* Used only for kernel-created sockets */
32 struct in_addr local_ip;
33 #if IS_ENABLED(CONFIG_IPV6)
34 struct in6_addr local_ip6;
39 struct in_addr peer_ip;
40 #if IS_ENABLED(CONFIG_IPV6)
41 struct in6_addr peer_ip6;
45 __be16 local_udp_port;
47 unsigned int use_udp_checksums:1,
48 use_udp6_tx_checksums:1,
49 use_udp6_rx_checksums:1;
52 #define udp_sock_create rpl_udp_sock_create
53 int udp_sock_create(struct net *net, struct udp_port_cfg *cfg,
54 struct socket **sockp);
56 typedef int (*udp_tunnel_encap_rcv_t)(struct sock *sk, struct sk_buff *skb);
57 typedef void (*udp_tunnel_encap_destroy_t)(struct sock *sk);
59 struct udp_tunnel_sock_cfg {
60 void *sk_user_data; /* user data used by encap_rcv call back */
61 /* Used for setting up udp_sock fields, see udp.h for details */
63 udp_tunnel_encap_rcv_t encap_rcv;
64 udp_tunnel_encap_destroy_t encap_destroy;
67 /* Setup the given (UDP) sock to receive UDP encapsulated packets */
68 void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
69 struct udp_tunnel_sock_cfg *sock_cfg);
71 /* Transmit the skb using UDP encapsulation. */
72 int udp_tunnel_xmit_skb(struct rtable *rt, struct sk_buff *skb,
73 __be32 src, __be32 dst, __u8 tos, __u8 ttl,
74 __be16 df, __be16 src_port, __be16 dst_port,
75 bool xnet, bool nocheck);
78 void udp_tunnel_sock_release(struct socket *sock);
80 void ovs_udp_gso(struct sk_buff *skb);
81 void ovs_udp_csum_gso(struct sk_buff *skb);
83 static inline struct sk_buff *udp_tunnel_handle_offloads(struct sk_buff *skb,
87 int type = udp_csum ? SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;
88 void (*fix_segment)(struct sk_buff *);
91 fix_segment = ovs_udp_gso;
93 fix_segment = ovs_udp_csum_gso;
95 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
100 return ovs_iptunnel_handle_offloads(skb, udp_csum, type, fix_segment);
103 #define udp_tunnel_encap_enable(sock) udp_encap_enable()
105 #endif /* Linux version < 3.20 */