batman-adv14: update patches to build with newer kernels

This commit is contained in:
Enno Boland 2016-11-19 10:21:31 +01:00
parent b351dee73d
commit 882fc9c77e
2 changed files with 277 additions and 43 deletions

View file

@ -1,4 +1,4 @@
diff --git Makefile.kbuild Makefile.kbuild
diff --git a/Makefile.kbuild b/Makefile.kbuild
index 489bb36..8ddbfe6 100644
--- Makefile.kbuild
+++ Makefile.kbuild
@ -7,7 +7,66 @@ index 489bb36..8ddbfe6 100644
batman-adv-y += translation-table.o
batman-adv-y += unicast.o
-batman-adv-y += vis.o
diff --git bat_iv_ogm.c bat_iv_ogm.c
diff --git a/README b/README
index c1d8204..4c20e91 100644
--- README
+++ README
@@ -1,3 +1,34 @@
+BATMAN-ADV-LEGACY
+-----------------
+
+This is the batman-adv "legacy" version (compat-level 14). Use it
+if you have a mesh using compat 14 which can't be easily upgraded
+to a newer version of batman-adv. If you are building a new mesh
+network, you should consider the current upstream version, which
+can be found under
+
+http://www.open-mesh.org/projects/batman-adv/wiki
+
+Please don't bother the upstream batman-adv developers with bug
+reports if you are using batman-adv-legacy. The batman-adv-legacy
+maintainers can be found at the bottom of this README.
+
+BRANCHES
+--------
+
+There are currently two branches in this repository:
+
+* master
+* legacy-vis
+
+The in-kernel mesh visualization support ("vis_mode" option) has
+been removed from the master branch, so a userspace tool like
+alfred has to be used. If you still require "vis_mode", you can
+use the legacy-vis branch.
+
+These branches might be merged in the future to allow "vis_mode"
+to be enabled or disabled at runtime.
+
BATMAN-ADV
----------
@@ -237,13 +268,12 @@ batctl is available on http://www.open-mesh.org/
CONTACT
-------
-Please send us comments, experiences, questions, anything :)
+batman-adv-legacy is maintained by the developers of the Gluon
+firmware framework (see https://github.com/freifunk-gluon/gluon).
-IRC: #batman on irc.freenode.org
-Mailing-list: b.a.t.m.a.n@open-mesh.org (optional subscription
- at https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n)
+You can find us on IRC: (channel #gluon on irc.hackint.org, look
+for neoraider)
-You can also contact the Authors:
+Bug reports can also be sent via mail to:
-Marek Lindner <lindner_marek@yahoo.de>
-Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
+Matthias Schiffer <mschiffer@universe-factory.net>
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 2031071..6407369 100644
--- bat_iv_ogm.c
+++ bat_iv_ogm.c
@ -36,11 +95,19 @@ index 2031071..6407369 100644
if (hard_iface == primary_if &&
atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER) {
diff --git compat.h compat.h
index 3e11f89..63feaa9 100644
diff --git a/compat.h b/compat.h
index 3e11f89..0f07edb 100644
--- compat.h
+++ compat.h
@@ -266,7 +266,9 @@ static int __batadv_interface_set_mac_addr(x, y)
@@ -258,7 +258,6 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) \
}\
static int __batadv_interface_set_mac_addr(x, y)
-#define netdev_master_upper_dev_link netdev_set_master
#define netdev_upper_dev_unlink(slave, master) netdev_set_master(slave, NULL)
#define netdev_master_upper_dev_get(dev) \
({\
@@ -266,7 +265,9 @@ static int __batadv_interface_set_mac_addr(x, y)
dev->master;\
})
#define hlist_entry_safe(ptr, type, member) \
@ -51,7 +118,7 @@ index 3e11f89..63feaa9 100644
#undef hlist_for_each_entry
#define hlist_for_each_entry(pos, head, member) \
@@ -318,4 +320,33 @@ static int __batadv_interface_set_mac_addr(x, y)
@@ -318,4 +319,55 @@ static int __batadv_interface_set_mac_addr(x, y)
})
#endif /* < KERNEL_VERSION(3, 11, 0) */
@ -83,9 +150,31 @@ index 3e11f89..63feaa9 100644
+#define dev_get_iflink(_net_dev) ((_net_dev)->iflink)
+
+#endif /* < KERNEL_VERSION(4, 1, 0) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
+
+#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) \
+ netdev_set_master(dev, upper_dev)
+
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
+
+#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) \
+ netdev_master_upper_dev_link(dev, upper_dev)
+
+#endif /* < KERNEL_VERSION(4, 5, 0) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
+
+#define netif_trans_update batadv_netif_trans_update
+static inline void batadv_netif_trans_update(struct net_device *dev)
+{
+ dev->trans_start = jiffies;
+}
+
+#endif /* < KERNEL_VERSION(4, 7, 0) */
+
#endif /* _NET_BATMAN_ADV_COMPAT_H_ */
diff --git debugfs.c debugfs.c
diff --git a/debugfs.c b/debugfs.c
index f186a55..049a7a2 100644
--- debugfs.c
+++ debugfs.c
@ -126,8 +215,8 @@ index f186a55..049a7a2 100644
#ifdef CONFIG_BATMAN_ADV_NC
&batadv_debuginfo_nc_nodes,
#endif
diff --git gateway_client.c gateway_client.c
index 7614af3..04fbfb2 100644
diff --git a/gateway_client.c b/gateway_client.c
index 7614af3..6958356 100644
--- gateway_client.c
+++ gateway_client.c
@@ -115,16 +115,12 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
@ -148,11 +237,13 @@ index 7614af3..04fbfb2 100644
rcu_read_lock();
hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) {
if (gw_node->deleted)
@@ -146,7 +142,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
@@ -145,8 +141,8 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
batadv_gw_bandwidth_to_kbit(orig_node->gw_flags,
&down, &up);
tmp_gw_factor = tq_avg * tq_avg * down * 100 * 100;
- tmp_gw_factor = tq_avg * tq_avg * down * 100 * 100;
- tmp_gw_factor /= gw_divisor;
+ tmp_gw_factor = (uint64_t)tq_avg * tq_avg * down * 100 * 100;
+ tmp_gw_factor >>= 18;
if ((tmp_gw_factor > max_gw_factor) ||
@ -185,7 +276,7 @@ index 7614af3..04fbfb2 100644
batadv_neigh_node_free_ref(router);
if (curr_gw)
diff --git gateway_common.c gateway_common.c
diff --git a/gateway_common.c b/gateway_common.c
index 84bb2b1..bb3f667 100644
--- gateway_common.c
+++ gateway_common.c
@ -215,7 +306,7 @@ index 84bb2b1..bb3f667 100644
(multi > 1))
*tmp_ptr = '\0';
}
diff --git gen-compat-autoconf.sh gen-compat-autoconf.sh
diff --git a/gen-compat-autoconf.sh b/gen-compat-autoconf.sh
index 78573e4..c5a3f5d 100755
--- gen-compat-autoconf.sh
+++ gen-compat-autoconf.sh
@ -229,8 +320,8 @@ index 78573e4..c5a3f5d 100755
gen_config() {
KEY="${1}"
diff --git hard-interface.c hard-interface.c
index c478e6b..01f0a80 100644
diff --git a/hard-interface.c b/hard-interface.c
index c478e6b..5948c80 100644
--- hard-interface.c
+++ hard-interface.c
@@ -83,19 +83,18 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
@ -279,7 +370,17 @@ index c478e6b..01f0a80 100644
batadv_bla_update_orig_address(bat_priv, primary_if, oldif);
out:
if (primary_if)
@@ -600,6 +591,8 @@ batadv_hardif_add_interface(struct net_device *net_dev)
@@ -429,7 +420,8 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
hard_iface->soft_iface = soft_iface;
bat_priv = netdev_priv(hard_iface->soft_iface);
- ret = netdev_master_upper_dev_link(hard_iface->net_dev, soft_iface);
+ ret = netdev_master_upper_dev_link(hard_iface->net_dev,
+ soft_iface, NULL, NULL);
if (ret)
goto err_dev;
@@ -600,6 +592,8 @@ batadv_hardif_add_interface(struct net_device *net_dev)
/* extra reference for return */
atomic_set(&hard_iface->refcount, 2);
@ -288,7 +389,7 @@ index c478e6b..01f0a80 100644
batadv_check_known_mac_addr(hard_iface->net_dev);
list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
diff --git main.c main.c
diff --git a/main.c b/main.c
index c8e0671..a718d07 100644
--- main.c
+++ main.c
@ -329,7 +430,7 @@ index c8e0671..a718d07 100644
batadv_gw_node_purge(bat_priv);
batadv_nc_mesh_free(bat_priv);
batadv_dat_free(bat_priv);
diff --git main.h main.h
diff --git a/main.h b/main.h
index 2c0c14d..06e8971 100644
--- main.h
+++ main.h
@ -376,7 +477,7 @@ index 2c0c14d..06e8971 100644
#define batadv_info(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
diff --git originator.c originator.c
diff --git a/originator.c b/originator.c
index f50553a..af1b427 100644
--- originator.c
+++ originator.c
@ -407,7 +508,7 @@ index f50553a..af1b427 100644
batadv_orig_node_free_ref(orig_node);
continue;
}
diff --git packet.h packet.h
diff --git a/packet.h b/packet.h
index a51ccfc..d12da01 100644
--- packet.h
+++ packet.h
@ -441,8 +542,8 @@ index a51ccfc..d12da01 100644
__be32 seqno;
uint8_t orig[ETH_ALEN];
uint8_t prev_sender[ETH_ALEN];
diff --git routing.c routing.c
index 2f0bd3f..5a11611 100644
diff --git a/routing.c b/routing.c
index 2f0bd3f..f69a32c 100644
--- routing.c
+++ routing.c
@@ -25,7 +25,6 @@
@ -453,6 +554,15 @@ index 2f0bd3f..5a11611 100644
#include "unicast.h"
#include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h"
@@ -845,7 +844,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
skb->len + ETH_HLEN);
ret = NET_RX_SUCCESS;
- } else if (res == NET_XMIT_POLICED) {
+ } else if (res == -EINPROGRESS) {
/* skb was buffered and consumed */
ret = NET_RX_SUCCESS;
}
@@ -940,11 +939,11 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest)) {
if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
@ -583,11 +693,11 @@ index 2f0bd3f..5a11611 100644
+
+ return ret;
}
diff --git send.c send.c
index e9ff8d8..853fcb8 100644
diff --git a/send.c b/send.c
index e9ff8d8..fd42c65 100644
--- send.c
+++ send.c
@@ -24,7 +24,6 @@
@@ -24,11 +24,11 @@
#include "translation-table.h"
#include "soft-interface.h"
#include "hard-interface.h"
@ -595,7 +705,30 @@ index e9ff8d8..853fcb8 100644
#include "gateway_common.h"
#include "originator.h"
#include "network-coding.h"
@@ -272,6 +271,10 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
+#include <linux/errno.h>
#include <linux/if_ether.h>
static void batadv_send_outstanding_bcast_packet(struct work_struct *work);
@@ -97,7 +97,7 @@ send_skb_err:
* attempted.
*
* Returns NET_XMIT_SUCCESS on success, NET_XMIT_DROP on failure, or
- * NET_XMIT_POLICED if the skb is buffered for later transmit.
+ * -EINPROGRESS if the skb is buffered for later transmit.
*/
int batadv_send_skb_to_orig(struct sk_buff *skb,
struct batadv_orig_node *orig_node,
@@ -117,7 +117,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb,
* network coding fails, then send the packet as usual.
*/
if (recv_if && batadv_nc_skb_forward(skb, neigh_node)) {
- ret = NET_XMIT_POLICED;
+ ret = -EINPROGRESS;
} else {
batadv_send_skb_packet(skb, neigh_node->if_incoming,
neigh_node->addr);
@@ -272,6 +272,10 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
if (forw_packet->num_packets >= hard_iface->num_bcasts)
continue;
@ -606,10 +739,19 @@ index e9ff8d8..853fcb8 100644
/* send a copy of the saved skb */
skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC);
if (skb1)
diff --git soft-interface.c soft-interface.c
index 33b6144..c5d4743 100644
diff --git a/soft-interface.c b/soft-interface.c
index 33b6144..3e3f81c 100644
--- soft-interface.c
+++ soft-interface.c
@@ -162,7 +162,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
goto dropped;
- soft_iface->trans_start = jiffies;
+ netif_trans_update(soft_iface);
switch (ntohs(ethhdr->h_proto)) {
case ETH_P_8021Q:
@@ -324,6 +324,11 @@ void batadv_interface_rx(struct net_device *soft_iface,
skb_pull_rcsum(skb, hdr_size);
skb_reset_mac_header(skb);
@ -648,7 +790,7 @@ index 33b6144..c5d4743 100644
if (!soft_iface)
return NULL;
diff --git sysfs-class-net-batman-adv sysfs-class-net-batman-adv
diff --git a/sysfs-class-net-batman-adv b/sysfs-class-net-batman-adv
index bdc0070..88f6f70 100644
--- sysfs-class-net-batman-adv
+++ sysfs-class-net-batman-adv
@ -666,7 +808,7 @@ index bdc0070..88f6f70 100644
+ and symmetric only, for instance point-to-point wifi longshots
+ or wired links. Using this option wrongly is going to
+ break your mesh network, use at your own risk!
diff --git sysfs.c sysfs.c
diff --git a/sysfs.c b/sysfs.c
index 929e304..944209a 100644
--- sysfs.c
+++ sysfs.c
@ -854,8 +996,86 @@ index 929e304..944209a 100644
NULL,
};
diff --git types.h types.h
index b2c94e1..2c5b80e 100644
diff --git a/translation-table.c b/translation-table.c
index 429aeef..9a8aab6 100644
--- translation-table.c
+++ translation-table.c
@@ -1487,6 +1487,19 @@ static uint16_t batadv_tt_local_crc(struct batadv_priv *bat_priv)
return total;
}
+/**
+ * batadv_tt_req_node_release - free tt_req node entry
+ * @ref: kref pointer of the tt req_node entry
+ */
+static void batadv_tt_req_node_release(struct kref *ref)
+{
+ struct batadv_tt_req_node *node;
+
+ node = container_of(ref, struct batadv_tt_req_node, refcount);
+
+ kfree(node);
+}
+
static void batadv_tt_req_list_free(struct batadv_priv *bat_priv)
{
struct batadv_tt_req_node *node, *safe;
@@ -1495,7 +1508,7 @@ static void batadv_tt_req_list_free(struct batadv_priv *bat_priv)
list_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) {
list_del(&node->list);
- kfree(node);
+ kref_put(&node->refcount, batadv_tt_req_node_release);
}
spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -1533,7 +1546,7 @@ static void batadv_tt_req_purge(struct batadv_priv *bat_priv)
if (batadv_has_timed_out(node->issued_at,
BATADV_TT_REQUEST_TIMEOUT)) {
list_del(&node->list);
- kfree(node);
+ kref_put(&node->refcount, batadv_tt_req_node_release);
}
}
spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -1560,9 +1573,11 @@ batadv_new_tt_req_node(struct batadv_priv *bat_priv,
if (!tt_req_node)
goto unlock;
+ kref_init(&tt_req_node->refcount);
memcpy(tt_req_node->addr, orig_node->orig, ETH_ALEN);
tt_req_node->issued_at = jiffies;
+ kref_get(&tt_req_node->refcount);
list_add(&tt_req_node->list, &bat_priv->tt.req_list);
unlock:
spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -1724,9 +1739,13 @@ out:
if (ret && tt_req_node) {
spin_lock_bh(&bat_priv->tt.req_list_lock);
list_del(&tt_req_node->list);
+ kref_put(&tt_req_node->refcount, batadv_tt_req_node_release);
spin_unlock_bh(&bat_priv->tt.req_list_lock);
- kfree(tt_req_node);
}
+
+ if (tt_req_node)
+ kref_put(&tt_req_node->refcount, batadv_tt_req_node_release);
+
return ret;
}
@@ -2111,7 +2130,7 @@ void batadv_handle_tt_response(struct batadv_priv *bat_priv,
if (!batadv_compare_eth(node->addr, tt_response->src))
continue;
list_del(&node->list);
- kfree(node);
+ kref_put(&node->refcount, batadv_tt_req_node_release);
}
spin_unlock_bh(&bat_priv->tt.req_list_lock);
diff --git a/types.h b/types.h
index b2c94e1..b4d38e4 100644
--- types.h
+++ types.h
@@ -85,6 +85,7 @@ struct batadv_hard_iface {
@ -866,10 +1086,11 @@ index b2c94e1..2c5b80e 100644
};
/**
@@ -430,24 +431,6 @@ struct batadv_priv_gw {
@@ -429,24 +430,6 @@ struct batadv_priv_gw {
atomic_t reselect;
};
/**
-/**
- * struct batadv_priv_vis - per mesh interface vis data
- * @send_list: list of batadv_vis_info packets to sent
- * @hash: hash table containing vis data from other nodes in the network
@ -887,10 +1108,9 @@ index b2c94e1..2c5b80e 100644
- struct batadv_vis_info *my_info;
-};
-
-/**
/**
* struct batadv_priv_dat - per mesh interface DAT private data
* @addr: node DAT address
* @hash: hashtable representing the local ARP cache
@@ -504,7 +487,6 @@ struct batadv_priv_nc {
* enabled
* @distributed_arp_table: bool indicating whether distributed ARP table is
@ -923,10 +1143,25 @@ index b2c94e1..2c5b80e 100644
#ifdef CONFIG_BATMAN_ADV_DAT
struct batadv_priv_dat dat;
#endif
@@ -878,66 +857,6 @@ struct batadv_frag_packet_list_entry {
@@ -747,11 +726,13 @@ struct batadv_tt_change_node {
* struct batadv_tt_req_node - data to keep track of the tt requests in flight
* @addr: mac address address of the originator this request was sent to
* @issued_at: timestamp used for purging stale tt requests
+ * @refcount: number of contexts the object is used by
* @list: list node for batadv_priv_tt::req_list
*/
struct batadv_tt_req_node {
uint8_t addr[ETH_ALEN];
unsigned long issued_at;
+ struct kref refcount;
struct list_head list;
};
/**
@@ -877,66 +858,6 @@ struct batadv_frag_packet_list_entry {
struct sk_buff *skb;
};
-/**
- * struct batadv_vis_info - local data for vis information
- * @first_seen: timestamp used for purging stale vis info entries
- * @recv_list: List of server-neighbors we have received this packet from. This
@ -986,11 +1221,10 @@ index b2c94e1..2c5b80e 100644
- struct hlist_node list;
-};
-
-/**
/**
* struct batadv_algo_ops - mesh algorithm callbacks
* @list: list node for the batadv_algo_list
* @name: name of the algorithm
diff --git vis.c vis.c
diff --git a/vis.c b/vis.c
deleted file mode 100644
index 4983340..0000000
--- vis.c
@ -1932,7 +2166,7 @@ index 4983340..0000000
- bat_priv->vis.my_info = NULL;
- spin_unlock_bh(&bat_priv->vis.hash_lock);
-}
diff --git vis.h vis.h
diff --git a/vis.h b/vis.h
deleted file mode 100644
index ad92b0e..0000000
--- vis.h

View file

@ -1,7 +1,7 @@
# Template file for 'batman-adv14'
pkgname=batman-adv14
version=2013.4.0
revision=7
revision=8
short_desc="B.A.T.M.A.N. routing protocol kernel module (protocol version 14)"
maintainer="Enno Boland <gottox@voidlinux.eu>"
license="GPL-2"