compat: Backport IPv4 reassembly.
[cascardo/ovs.git] / datapath / compat.h
index efad6a0..a6404c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2011 Nicira Networks.
+ * Copyright (c) 2007-2015 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
 #ifndef COMPAT_H
 #define COMPAT_H 1
 
+#include <linux/in.h>
+#include <linux/in_route.h>
 #include <linux/netlink.h>
+#include <net/ip.h>
+#include <net/route.h>
+#include <net/xfrm.h>
 
-#ifndef HAVE_NLA_NUL_STRING
-static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen)
-{
-       char *s;
-       int len;
-       if (!attr)
-               return 0;
+#ifdef HAVE_GENL_MULTICAST_GROUP_WITH_ID
+#define GROUP_ID(grp)  ((grp)->id)
+#else
+#define GROUP_ID(grp)  0
+#endif
 
-       len = nla_len(attr);
-       if (len >= maxlen)
-               return -EINVAL;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+#define rt_dst(rt) (rt->dst)
+#else
+#define rt_dst(rt) (rt->u.dst)
+#endif
 
-       s = nla_data(attr);
-       if (s[len - 1] != '\0')
-               return -EINVAL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+#define inet_sport(sk) (inet_sk(sk)->sport)
+#else
+#define inet_sport(sk) (inet_sk(sk)->inet_sport)
+#endif
 
-       return 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+static inline bool skb_encapsulation(struct sk_buff *skb)
+{
+       return skb->encapsulation;
 }
 #else
-static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen)
+#define skb_encapsulation(skb) false
+#endif
+
+#ifdef OVS_FRAGMENT_BACKPORT
+static inline int __init compat_init(void)
 {
-       return 0;
+       return ipfrag_init();
 }
-#endif  /* !HAVE_NLA_NUL_STRING */
-
-static inline void skb_clear_rxhash(struct sk_buff *skb)
+static inline void compat_exit(void)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
-       skb->rxhash = 0;
-#endif
+       rpl_ipfrag_fini();
 }
+#else
+static inline int __init compat_init(void) { return 0; }
+static inline void compat_exit(void) { }
+#endif
 
 #endif /* compat.h */