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,18,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 int udp_sock_create(struct net *net, struct udp_port_cfg *cfg,
53 struct socket **sockp);
55 typedef int (*udp_tunnel_encap_rcv_t)(struct sock *sk, struct sk_buff *skb);
56 typedef void (*udp_tunnel_encap_destroy_t)(struct sock *sk);
58 struct udp_tunnel_sock_cfg {
59 void *sk_user_data; /* user data used by encap_rcv call back */
60 /* Used for setting up udp_sock fields, see udp.h for details */
62 udp_tunnel_encap_rcv_t encap_rcv;
63 udp_tunnel_encap_destroy_t encap_destroy;
66 /* Setup the given (UDP) sock to receive UDP encapsulated packets */
67 void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
68 struct udp_tunnel_sock_cfg *sock_cfg);
70 /* Transmit the skb using UDP encapsulation. */
71 int udp_tunnel_xmit_skb(struct socket *sock, struct rtable *rt,
72 struct sk_buff *skb, __be32 src, __be32 dst,
73 __u8 tos, __u8 ttl, __be16 df, __be16 src_port,
74 __be16 dst_port, bool xnet);
76 void udp_tunnel_sock_release(struct socket *sock);
78 void ovs_udp_gso(struct sk_buff *skb);
79 void ovs_udp_csum_gso(struct sk_buff *skb);
81 static inline struct sk_buff *udp_tunnel_handle_offloads(struct sk_buff *skb,
85 int type = udp_csum ? SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;
86 void (*fix_segment)(struct sk_buff *);
89 fix_segment = ovs_udp_gso;
91 fix_segment = ovs_udp_csum_gso;
93 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
98 return ovs_iptunnel_handle_offloads(skb, udp_csum, type, fix_segment);
101 #define udp_tunnel_encap_enable(sock) udp_encap_enable()
103 #endif /* Linux version < 3.18 */