datapath: Provide compatibility for kernels up to 3.17
[cascardo/ovs.git] / datapath / linux / compat / include / net / vxlan.h
index 102bc0c..2e56a9b 100644 (file)
@@ -5,39 +5,57 @@
 #include <linux/netdevice.h>
 #include <linux/udp.h>
 
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+#include_next <net/vxlan.h>
+
+static inline int rpl_vxlan_xmit_skb(struct vxlan_sock *vs,
+                   struct rtable *rt, struct sk_buff *skb,
+                   __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
+                   __be16 src_port, __be16 dst_port, __be32 vni)
+{
+       if (skb->encapsulation && skb_is_gso(skb)) {
+               kfree_skb(skb);
+               return -ENOSYS;
+       }
+
+#ifdef HAVE_VXLAN_XMIT_SKB_XNET_ARG
+       return vxlan_xmit_skb(vs, rt, skb, src, dst, tos, ttl, df,
+                             src_port, dst_port, vni, false);
+#else
+       return vxlan_xmit_skb(vs, rt, skb, src, dst, tos, ttl, df,
+                             src_port, dst_port, vni);
+#endif
+}
+
+#define vxlan_xmit_skb rpl_vxlan_xmit_skb
+#else
+
+struct vxlan_sock;
+typedef void (vxlan_rcv_t)(struct vxlan_sock *vs, struct sk_buff *skb, __be32 key);
+
 /* per UDP socket information */
 struct vxlan_sock {
        struct hlist_node hlist;
-       struct rcu_head   rcu;
-       struct socket     *sock;
-       struct list_head  handler_list;
-};
-
-struct vxlan_handler;
-typedef int (vxlan_rcv_t)(struct vxlan_handler *vh, struct sk_buff *skb, __be32 key);
-
-struct vxlan_handler {
-       vxlan_rcv_t       *rcv;
-       struct list_head   node;
-       void              *data;
-       struct vxlan_sock *vs;
-       atomic_t           refcnt;
-       struct rcu_head    rcu;
+       vxlan_rcv_t      *rcv;
+       void             *data;
        struct work_struct del_work;
-       int                priority;
+       struct socket    *sock;
+       struct rcu_head   rcu;
 };
 
-void vxlan_handler_put(struct vxlan_handler *vh);
+struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,
+                                 vxlan_rcv_t *rcv, void *data,
+                                 bool no_share, bool ipv6);
 
-struct vxlan_handler *vxlan_handler_add(struct net *net,
-                                       __be16 portno, vxlan_rcv_t *rcv,
-                                       void *data, int priority, bool create);
+void vxlan_sock_release(struct vxlan_sock *vs);
 
-int vxlan_xmit_skb(struct net *net, struct vxlan_handler *vh,
+int vxlan_xmit_skb(struct vxlan_sock *vs,
                   struct rtable *rt, struct sk_buff *skb,
                   __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
                   __be16 src_port, __be16 dst_port, __be32 vni);
 
 __be16 vxlan_src_port(__u16 port_min, __u16 port_max, struct sk_buff *skb);
 
+#endif /* 3.12 */
 #endif