Repository : ssh://git@open-mesh.org/openwrt-feed-devel
On branches: ecsv/master,master
>---------------------------------------------------------------
commit d944f29acb695c2b6bba9467de90646ddb68d08b
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Feb 11 21:19:11 2017 +0100
batman-adv-devel: Import compat-hacks from openwrt-routing
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
d944f29acb695c2b6bba9467de90646ddb68d08b
batman-adv-devel/files/compat-hacks.h | 111 +++++++++++++++++++++++++++++++++-
1 file changed, 109 insertions(+), 2 deletions(-)
diff --git a/batman-adv-devel/files/compat-hacks.h b/batman-adv-devel/files/compat-hacks.h
index e959ca3..af91f41 100644
--- a/batman-adv-devel/files/compat-hacks.h
+++ b/batman-adv-devel/files/compat-hacks.h
@@ -36,8 +36,8 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
- unsigned int transport_len,
- __sum16(*skb_chkf)(struct sk_buff *skb));
+ unsigned int transport_len,
+ __sum16(*skb_chkf)(struct sk_buff *skb));
int ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed);
@@ -49,6 +49,11 @@ int ipv6_mc_check_mld(struct sk_buff *skb, struct sk_buff **skb_trimmed);
#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
+static inline bool hlist_fake(struct hlist_node *h)
+{
+ return h->pprev == &h->next;
+}
+
#endif /* < KERNEL_VERSION(4, 3, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
@@ -97,3 +102,105 @@ static inline void batadv_netif_trans_update(struct net_device *dev)
}
#endif /* < KERNEL_VERSION(4, 7, 0) */
+
+
+#include_next <linux/netlink.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
+
+#include_next <net/netlink.h>
+
+static inline bool batadv_nla_need_padding_for_64bit(struct sk_buff *skb);
+
+static inline int batadv_nla_align_64bit(struct sk_buff *skb, int padattr)
+{
+ if (batadv_nla_need_padding_for_64bit(skb) &&
+ !nla_reserve(skb, padattr, 0))
+ return -EMSGSIZE;
+
+ return 0;
+}
+
+static inline struct nlattr *batadv__nla_reserve_64bit(struct sk_buff *skb,
+ int attrtype,
+ int attrlen, int padattr)
+{
+ if (batadv_nla_need_padding_for_64bit(skb))
+ batadv_nla_align_64bit(skb, padattr);
+
+ return __nla_reserve(skb, attrtype, attrlen);
+}
+
+static inline void batadv__nla_put_64bit(struct sk_buff *skb, int attrtype,
+ int attrlen, const void *data,
+ int padattr)
+{
+ struct nlattr *nla;
+
+ nla = batadv__nla_reserve_64bit(skb, attrtype, attrlen, padattr);
+ memcpy(nla_data(nla), data, attrlen);
+}
+
+static inline bool batadv_nla_need_padding_for_64bit(struct sk_buff *skb)
+{
+#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+ /* The nlattr header is 4 bytes in size, that's why we test
+ * if the skb->data _is_ aligned. A NOP attribute, plus
+ * nlattr header for next attribute, will make nla_data()
+ * 8-byte aligned.
+ */
+ if (IS_ALIGNED((unsigned long)skb_tail_pointer(skb), 8))
+ return true;
+#endif
+ return false;
+}
+
+static inline int batadv_nla_total_size_64bit(int payload)
+{
+ return NLA_ALIGN(nla_attr_size(payload))
+#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+ + NLA_ALIGN(nla_attr_size(0))
+#endif
+ ;
+}
+
+static inline int batadv_nla_put_64bit(struct sk_buff *skb, int attrtype,
+ int attrlen, const void *data,
+ int padattr)
+{
+ size_t len;
+
+ if (batadv_nla_need_padding_for_64bit(skb))
+ len = batadv_nla_total_size_64bit(attrlen);
+ else
+ len = nla_total_size(attrlen);
+ if (unlikely(skb_tailroom(skb) < len))
+ return -EMSGSIZE;
+
+ batadv__nla_put_64bit(skb, attrtype, attrlen, data, padattr);
+ return 0;
+}
+
+#define nla_put_u64_64bit(_skb, _attrtype, _value, _padattr) \
+ batadv_nla_put_u64_64bit(_skb, _attrtype, _value, _padattr)
+static inline int batadv_nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
+ u64 value, int padattr)
+{
+ return batadv_nla_put_64bit(skb, attrtype, sizeof(u64), &value,
+ padattr);
+}
+
+#endif /* < KERNEL_VERSION(4, 7, 0) */
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
+
+#include_next <linux/cache.h>
+
+/* hack for netlink.c which marked the family ops as ro */
+#ifdef __ro_after_init
+#undef __ro_after_init
+#endif
+#define __ro_after_init
+
+#endif /* < KERNEL_VERSION(4, 10, 0) */