batman-adv; branch, master, updated. v2011.4.0-59-gd2c993d
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit d2c993d1532362a5c6e14e4bc9f0b2dfad64ed24
Author: Simon Wunderlich <simon.wunderlich(a)s2003.tu-chemnitz.de>
Date: Tue Dec 27 17:24:07 2011 +0100
batman-adv: convert all times to miliseconds
has_timed_out() takes the second argument in miliseconds. The commit
"batman-adv: convert time_after instances to has_timed_out" introduced
some bugs by confusing seconds and miliseconds.
This patch converts all timeouts to miliseconds to be consistent, and
also fixes the previously introduced bugs.
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
diff --git a/gateway_client.c b/gateway_client.c
index 24403a7..df5631e 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -396,7 +396,7 @@ void gw_node_purge(struct bat_priv *bat_priv)
{
struct gw_node *gw_node, *curr_gw;
struct hlist_node *node, *node_tmp;
- unsigned long timeout = 2 * PURGE_TIMEOUT * HZ;
+ unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT);
int do_deselect = 0;
curr_gw = gw_get_selected_gw_node(bat_priv);
diff --git a/main.h b/main.h
index 222c120..d124c28 100644
--- a/main.h
+++ b/main.h
@@ -41,13 +41,14 @@
/* purge originators after time in seconds if no valid packet comes in
* -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */
-#define PURGE_TIMEOUT 200
-#define TT_LOCAL_TIMEOUT 3600 /* in seconds */
-#define TT_CLIENT_ROAM_TIMEOUT 600
+#define PURGE_TIMEOUT 200000 /* 200 seconds */
+#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */
+#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */
/* sliding packet range of received originator messages in sequence numbers
* (should be a multiple of our word size) */
#define TQ_LOCAL_WINDOW_SIZE 64
-#define TT_REQUEST_TIMEOUT 3 /* seconds we have to keep pending tt_req */
+#define TT_REQUEST_TIMEOUT 3000 /* miliseconds we have to keep
+ * pending tt_req */
#define TQ_GLOBAL_WINDOW_SIZE 5
#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
@@ -56,8 +57,8 @@
#define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */
-#define ROAMING_MAX_TIME 20 /* Time in which a client can roam at most
- * ROAMING_MAX_COUNT times */
+#define ROAMING_MAX_TIME 20000 /* Time in which a client can roam at most
+ * ROAMING_MAX_COUNT times in miliseconds*/
#define ROAMING_MAX_COUNT 5
#define NO_FLAGS 0
diff --git a/translation-table.c b/translation-table.c
index a1be7ef..9fe38c1 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -413,7 +413,7 @@ static void tt_local_purge(struct bat_priv *bat_priv)
continue;
if (!has_timed_out(tt_local_entry->last_seen,
- TT_LOCAL_TIMEOUT * 1000))
+ TT_LOCAL_TIMEOUT))
continue;
tt_local_set_pending(bat_priv, tt_local_entry,
@@ -753,7 +753,7 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv)
if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM))
continue;
if (!has_timed_out(tt_global_entry->roam_at,
- TT_CLIENT_ROAM_TIMEOUT * 1000))
+ TT_CLIENT_ROAM_TIMEOUT))
continue;
bat_dbg(DBG_TT, bat_priv, "Deleting global "
@@ -972,8 +972,7 @@ static void tt_req_purge(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->tt_req_list_lock);
list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) {
- if (has_timed_out(node->issued_at,
- TT_REQUEST_TIMEOUT * 1000)) {
+ if (has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) {
list_del(&node->list);
kfree(node);
}
@@ -992,7 +991,7 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv,
list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) {
if (compare_eth(tt_req_node_tmp, orig_node) &&
!has_timed_out(tt_req_node_tmp->issued_at,
- TT_REQUEST_TIMEOUT * 1000))
+ TT_REQUEST_TIMEOUT))
goto unlock;
}
@@ -1585,8 +1584,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->tt_roam_list_lock);
list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) {
- if (!has_timed_out(node->first_time,
- ROAMING_MAX_TIME * 1000))
+ if (!has_timed_out(node->first_time, ROAMING_MAX_TIME))
continue;
list_del(&node->list);
@@ -1613,8 +1611,7 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
if (!compare_eth(tt_roam_node->addr, client))
continue;
- if (has_timed_out(tt_roam_node->first_time,
- ROAMING_MAX_TIME * 1000))
+ if (has_timed_out(tt_roam_node->first_time, ROAMING_MAX_TIME))
continue;
if (!atomic_dec_not_zero(&tt_roam_node->counter))
diff --git a/vis.h b/vis.h
index 31b820d..851bc4f 100644
--- a/vis.h
+++ b/vis.h
@@ -22,7 +22,8 @@
#ifndef _NET_BATMAN_ADV_VIS_H_
#define _NET_BATMAN_ADV_VIS_H_
-#define VIS_TIMEOUT 200 /* timeout of vis packets in seconds */
+#define VIS_TIMEOUT 200000 /* timeout of vis packets
+ * in miliseconds */
int vis_seq_print_text(struct seq_file *seq, void *offset);
void receive_server_sync_packet(struct bat_priv *bat_priv,
--
batman-adv
11 years, 1 month
linux integration; annotated tag, v3.2-rc7, created. v3.2-rc7
by postmaster@open-mesh.org
The annotated tag, v3.2-rc7 has been created
at e33abea7c57a228c8fdf77c892c230cb840425ac (tag)
tagging 5f0a6e2d503896062f641639dacfe5055c2f593b (commit)
replaces v3.2-rc6
tagged by Linus Torvalds
on Fri Dec 23 21:51:14 2011 -0800
- Shortlog ------------------------------------------------------------
Linux 3.2-rc7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
iQEcBAABAgAGBQJO9WhiAAoJEHm+PkMAQRiGCJoH/iA/MUwHqVUdRTA3NeXzeu6A
xBhCslh0J7sn+2LN26JSt4WnWKiOqytsH0DySBC6AtC4e04O1exen8kpBYuaFIJf
sUQ2LYpZX+GpMdDm8gfHjz5i+4PGNyRa9bUOA79nv35K+KKSgoVRavqtPPobOLSu
sFeHs1F4jXlrAspp0XgcX3iiOqZcvjgpRBQF9CmTBPSFcuaJEId9FbOpkKIpiVfW
feOMyy1oTil4Lzsery/H51jP2M95R69bhK2fCTwAh30BQAyg9KM73sRMDPUyT2iE
HQi/J1la94aA3Nyb5h6yqk2g91/JVa3Daig/UbcjFtNDtDcbZkQVdgMliDYe6b4=
=lDKL
-----END PGP SIGNATURE-----
-----------------------------------------------------------------------
--
linux integration
11 years, 1 month
batman-adv; branch, master, updated. v2011.4.0-58-gf379f93
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit f379f93aef18d6f2cfc0342e3ee77ef630e6e346
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Fri Dec 23 22:38:01 2011 +0100
batman-adv: Fix compilation with linux 2.6.29 and 2.6.30
Linux v2.6.30-2332-gfddd520 introduced a seventh parameter to
__module_param_call. It is used to give a slightly different user experience
for bool parameters. Older kernels can just drop this information using a
special compat wrapper for __module_param_call.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
diff --git a/compat.h b/compat.h
index 3733f68..c71d928 100644
--- a/compat.h
+++ b/compat.h
@@ -42,6 +42,7 @@
#endif /* < KERNEL_VERSION(2, 6, 33) */
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
#define hlist_first_rcu(head) (*((struct hlist_node **)(&(head)->first)))
@@ -56,6 +57,20 @@
#endif /* < KERNEL_VERSION(2, 6, 34) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
+
+#define __compat__module_param_call(p1, p2, p3, p4, p5, p6, p7) \
+ __module_param_call(p1, p2, p3, p4, p5, p7)
+
+#else
+
+#define __compat__module_param_call(p1, p2, p3, p4, p5, p6, p7) \
+ __module_param_call(p1, p2, p3, p4, p5, p6, p7)
+
+#endif /* < KERNEL_VERSION(2, 6, 31) */
+
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
#define __rcu
@@ -77,10 +92,10 @@ struct kernel_param_ops {
static int __compat_get_param_##name(char *buffer, \
struct kernel_param *kp) \
{ return (ops)->get(buffer, kp); } \
- __module_param_call(MODULE_PARAM_PREFIX, name, \
- __compat_set_param_##name, \
- __compat_get_param_##name, arg, \
- __same_type((arg), bool *), perm)
+ __compat__module_param_call(MODULE_PARAM_PREFIX, name, \
+ __compat_set_param_##name, \
+ __compat_get_param_##name, arg, \
+ __same_type((arg), bool *), perm)
static inline int __param_set_copystring(const char *val,
const struct kernel_param *kp)
@@ -91,6 +106,7 @@ static inline int __param_set_copystring(const char *val,
#endif /* < KERNEL_VERSION(2, 6, 36) */
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
#define kstrtoul strict_strtoul
@@ -98,6 +114,7 @@ static inline int __param_set_copystring(const char *val,
#endif /* < KERNEL_VERSION(2, 6, 39) */
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)
#define kfree_rcu(ptr, rcu_head) call_rcu(&ptr->rcu_head, free_rcu_##ptr)
--
batman-adv
11 years, 1 month
batman-adv; branch, master, updated. v2011.4.0-57-ge745802
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit e745802096d9e9d02752682b80d1efa3d41f5855
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Fri Dec 23 21:53:27 2011 +0100
batman-adv: Split README in kernel and external part
The README is shipped in a stripped down version as part of the kernel under
Documentation/networking/batman-adv.txt. The readme has to be manually merged
each time it gets prepared for submission to the networking subsystem
maintainer after the README was modified.
This extra work is reduced by splitting it in a README which contains the same
data as available in the kernel and README.external which contains the
information that only affect the external module.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
diff --git a/README b/README
index 58d3473..01db663 100644
--- a/README
+++ b/README
@@ -15,26 +15,7 @@ are: IPv4, IPv6, DHCP, IPX.
Batman advanced was implemented as a Linux kernel driver to re-
duce the overhead to a minimum. It does not depend on any (other)
network driver, and can be used on wifi as well as ethernet lan,
-vpn, etc ... (anything with ethernet-style layer 2). It compiles
-against and should work with Linux 2.6.29 - 3.2. Supporting
-older versions is not planned, but it's probably easy to backport
-it. If you work on a backport, feel free to contact us. :-)
-
-
-COMPILE
--------
-
-To compile against your currently installed kernel, just type:
-
-# make
-
-if you want to compile against some other kernel, use:
-
-# make KERNELPATH=/path/to/kernel
-
-if you wont to install this module:
-
-# sudo make install
+vpn, etc ... (anything with ethernet-style layer 2).
CONFIGURATION
@@ -89,6 +70,7 @@ folder:
# ap_isolation gw_bandwidth hop_penalty
# bonding gw_mode orig_interval
+
There is a special folder for debugging information:
# ls /sys/kernel/debug/batman_adv/bat0/
@@ -204,11 +186,7 @@ When investigating problems with your mesh network it is some-
times necessary to see more detail debug messages. This must be
enabled when compiling the batman-adv module. When building bat-
man-adv as part of kernel, use "make menuconfig" and enable the
-option "B.A.T.M.A.N. debugging". When compiling outside of the
-kernel tree it is necessary to enable it using the make option
-CONFIG_BATMAN_ADV_DEBUG=y
-
-# make CONFIG_BATMAN_ADV_DEBUG=y
+option "B.A.T.M.A.N. debugging".
Those additional debug messages can be accessed using a special
file in debugfs
diff --git a/README.external b/README.external
new file mode 100644
index 0000000..4aa4763
--- /dev/null
+++ b/README.external
@@ -0,0 +1,45 @@
+BATMAN-ADV external module
+--------------------------
+
+The batman-adv module is shipped as part of the Linux kernel
+and as external module. The external module allows to get
+new features without upgrading to a newer kernel version
+and to get batman-adv specific bugfixes for kernels that are
+not supported anymore. It compiles against and should work
+with Linux 2.6.29 - 3.2. Supporting older versions is not
+planned, but it's probably easy to backport it. If you work on a
+backport, feel free to contact us. :-)
+
+COMPILE
+-------
+
+To compile against your currently installed kernel, just type:
+
+# make
+
+if you want to compile against some other kernel, use:
+
+# make KERNELPATH=/path/to/kernel
+
+if you wont to install this module:
+
+# sudo make install
+
+CONFIGURATION
+-------------
+
+The in-kernel module can be configured through
+menuconfig. When compiling outside of the kernel, tree it is
+necessary to configure it using the make options. Each
+option can be set to to y (enabled), n (disabled) or m (build as
+module). Available options and their possible values are
+(default marked with an "*")
+
+ * CONFIG_BATMAN_ADV_DEBUG=[y|n*] (B.A.T.M.A.N. debugging)
+
+e.g., debugging can be enabled by
+
+# make CONFIG_BATMAN_ADV_DEBUG=y
+
+Keep in mind that all options must also be added to "make
+install" call.
--
batman-adv
11 years, 1 month
batman-adv; branch, master, updated. v2011.4.0-56-g58cd303
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit 58cd303f3db1db34bd913e4d4b83e6c7065f9741
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Fri Dec 23 21:53:26 2011 +0100
batman-adv: Remove date from README
The date has to be updated when a patch touches the README. Therefore, nearly
every feature will modify this date. It can happens quite often that not only
one feature is currently in development or waiting on the mailinglist. This
creates merge conflicts when applying a patchset.
The date itself doesn't provide any additional information when this file is
only available in a release tarball or as part of a SCM repository.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
diff --git a/README b/README
index ddc9569..58d3473 100644
--- a/README
+++ b/README
@@ -1,5 +1,3 @@
-[state: 13-11-2011]
-
BATMAN-ADV
----------
--
batman-adv
11 years, 1 month
batman-adv; branch, master, updated. v2011.4.0-55-ge2b9917
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit e2b9917bb63b44deb41b2a2bdb4033dc6929d730
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Thu Dec 22 20:31:12 2011 +0800
batman-adv: refactor tt_global_del() to avoid misalignment
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Acked-by: Antonio Quartulli <ordex(a)autistici.org>
diff --git a/translation-table.c b/translation-table.c
index d542b9d..a1be7ef 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -657,29 +657,31 @@ void tt_global_del(struct bat_priv *bat_priv,
struct tt_local_entry *tt_local_entry = NULL;
tt_global_entry = tt_global_hash_find(bat_priv, addr);
- if (!tt_global_entry)
+ if (!tt_global_entry || tt_global_entry->orig_node != orig_node)
goto out;
- if (tt_global_entry->orig_node == orig_node) {
- if (roaming) {
- /* if we are deleting a global entry due to a roam
- * event, there are two possibilities:
- * 1) the client roamed from node A to node B => we mark
- * it with TT_CLIENT_ROAM, we start a timer and we
- * wait for node B to claim it. In case of timeout
- * the entry is purged.
- * 2) the client roamed to us => we can directly delete
- * the global entry, since it is useless now. */
- tt_local_entry = tt_local_hash_find(bat_priv,
- tt_global_entry->common.addr);
- if (!tt_local_entry) {
- tt_global_entry->common.flags |= TT_CLIENT_ROAM;
- tt_global_entry->roam_at = jiffies;
- goto out;
- }
- }
- _tt_global_del(bat_priv, tt_global_entry, message);
+ if (!roaming)
+ goto out_del;
+
+ /* if we are deleting a global entry due to a roam
+ * event, there are two possibilities:
+ * 1) the client roamed from node A to node B => we mark
+ * it with TT_CLIENT_ROAM, we start a timer and we
+ * wait for node B to claim it. In case of timeout
+ * the entry is purged.
+ * 2) the client roamed to us => we can directly delete
+ * the global entry, since it is useless now. */
+ tt_local_entry = tt_local_hash_find(bat_priv,
+ tt_global_entry->common.addr);
+ if (!tt_local_entry) {
+ tt_global_entry->common.flags |= TT_CLIENT_ROAM;
+ tt_global_entry->roam_at = jiffies;
+ goto out;
}
+
+out_del:
+ _tt_global_del(bat_priv, tt_global_entry, message);
+
out:
if (tt_global_entry)
tt_global_entry_free_ref(tt_global_entry);
--
batman-adv
11 years, 1 month
batman-adv; branch, master, updated. v2011.4.0-54-ga7fdb84
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit a7fdb8432768341e0cf4530e80895e516706cd2c
Author: Marek Lindner <lindner_marek(a)yahoo.de>
Date: Tue Dec 20 19:30:40 2011 +0800
batman-adv: convert time_after instances to has_timed_out
To increase readability the has_timed_out() functions has been introduced.
This patch converts existing time_after() calls to use this wrapper
function (if applicable).
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
diff --git a/originator.c b/originator.c
index 847ff7e..1161f27 100644
--- a/originator.c
+++ b/originator.c
@@ -282,8 +282,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
hlist_for_each_entry_safe(neigh_node, node, node_tmp,
&orig_node->neigh_list, list) {
- if ((time_after(jiffies,
- neigh_node->last_valid + PURGE_TIMEOUT * HZ)) ||
+ if ((has_timed_out(neigh_node->last_valid, PURGE_TIMEOUT)) ||
(neigh_node->if_incoming->if_status == IF_INACTIVE) ||
(neigh_node->if_incoming->if_status == IF_NOT_IN_USE) ||
(neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) {
@@ -327,9 +326,7 @@ static bool purge_orig_node(struct bat_priv *bat_priv,
{
struct neigh_node *best_neigh_node;
- if (time_after(jiffies,
- orig_node->last_valid + 2 * PURGE_TIMEOUT * HZ)) {
-
+ if (has_timed_out(orig_node->last_valid, 2 * PURGE_TIMEOUT)) {
bat_dbg(DBG_BATMAN, bat_priv,
"Originator timeout: originator %pM, last_valid %lu\n",
orig_node->orig, (orig_node->last_valid / HZ));
@@ -372,8 +369,8 @@ static void _purge_orig(struct bat_priv *bat_priv)
continue;
}
- if (time_after(jiffies, orig_node->last_frag_packet +
- msecs_to_jiffies(FRAG_TIMEOUT)))
+ if (has_timed_out(orig_node->last_frag_packet,
+ FRAG_TIMEOUT))
frag_list_free(&orig_node->frag_list);
}
spin_unlock_bh(list_lock);
diff --git a/routing.c b/routing.c
index b72d7f3..c1e45c0 100644
--- a/routing.c
+++ b/routing.c
@@ -231,8 +231,7 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
{
if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE)
|| (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
- if (time_after(jiffies, *last_reset +
- msecs_to_jiffies(RESET_PROTECTION_MS))) {
+ if (has_timed_out(*last_reset, RESET_PROTECTION_MS)) {
*last_reset = jiffies;
bat_dbg(DBG_BATMAN, bat_priv,
diff --git a/soft-interface.c b/soft-interface.c
index b5aecd5..c41dac3 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -396,8 +396,8 @@ void softif_neigh_purge(struct bat_priv *bat_priv)
hlist_for_each_entry_safe(softif_neigh, node_tmp, node_tmp2,
&softif_neigh_vid->softif_neigh_list,
list) {
- if ((!time_after(jiffies, softif_neigh->last_seen +
- msecs_to_jiffies(SOFTIF_NEIGH_TIMEOUT))) &&
+ if ((!has_timed_out(softif_neigh->last_seen,
+ SOFTIF_NEIGH_TIMEOUT)) &&
(atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE))
continue;
diff --git a/vis.c b/vis.c
index ac7e661..4f4b2a0 100644
--- a/vis.c
+++ b/vis.c
@@ -714,8 +714,7 @@ static void purge_vis_packets(struct bat_priv *bat_priv)
if (info == bat_priv->my_vis_info)
continue;
- if (time_after(jiffies,
- info->first_seen + VIS_TIMEOUT * HZ)) {
+ if (has_timed_out(info->first_seen, VIS_TIMEOUT)) {
hlist_del(node);
send_list_del(info);
kref_put(&info->refcount, free_info);
--
batman-adv
11 years, 1 month
batman-adv; branch, master, updated. v2011.4.0-53-g84975ac
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit 84975acd7fa5f3b35dcae20cdc14e19c8f719b9c
Author: Marek Lindner <lindner_marek(a)yahoo.de>
Date: Tue Nov 29 00:15:37 2011 +0800
batman-adv: export used routing algorithm via sysfs
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
diff --git a/bat_sysfs.c b/bat_sysfs.c
index c25492f..480ae0a 100644
--- a/bat_sysfs.c
+++ b/bat_sysfs.c
@@ -272,6 +272,13 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
return count;
}
+static ssize_t show_bat_algo(struct kobject *kobj, struct attribute *attr,
+ char *buff)
+{
+ struct bat_priv *bat_priv = kobj_to_batpriv(kobj);
+ return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name);
+}
+
static void post_gw_deselect(struct net_device *net_dev)
{
struct bat_priv *bat_priv = netdev_priv(net_dev);
@@ -382,6 +389,7 @@ BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
BAT_ATTR_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu);
BAT_ATTR_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
+static BAT_ATTR(routing_algo, S_IRUGO, show_bat_algo, NULL);
static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode);
BAT_ATTR_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL);
BAT_ATTR_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL);
@@ -399,6 +407,7 @@ static struct bat_attribute *mesh_attrs[] = {
&bat_attr_fragmentation,
&bat_attr_ap_isolation,
&bat_attr_vis_mode,
+ &bat_attr_routing_algo,
&bat_attr_gw_mode,
&bat_attr_orig_interval,
&bat_attr_hop_penalty,
diff --git a/sysfs-class-net-mesh b/sysfs-class-net-mesh
index b020014..b218e0f 100644
--- a/sysfs-class-net-mesh
+++ b/sysfs-class-net-mesh
@@ -65,6 +65,13 @@ Description:
Defines the penalty which will be applied to an
originator message's tq-field on every hop.
+What: /sys/class/net/<mesh_iface>/mesh/routing_algo
+Date: Dec 2011
+Contact: Marek Lindner <lindner_marek(a)yahoo.de>
+Description:
+ Defines the routing procotol this mesh instance
+ uses to find the optimal paths through the mesh.
+
What: /sys/class/net/<mesh_iface>/mesh/vis_mode
Date: May 2010
Contact: Marek Lindner <lindner_marek(a)yahoo.de>
--
batman-adv
11 years, 1 month
batman-adv; branch, master, updated. v2011.4.0-52-g3b94747
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit 3b94747c96c7b78f01f34d090344aa446a5f56f7
Author: Marek Lindner <lindner_marek(a)yahoo.de>
Date: Sat Dec 10 19:45:53 2011 +0800
batman-adv: allowing changing the routing algorithm via module parameter
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
diff --git a/compat.h b/compat.h
index 194e70e..3733f68 100644
--- a/compat.h
+++ b/compat.h
@@ -61,6 +61,34 @@
#define __rcu
#define IFF_BRIDGE_PORT 0 || (hard_iface->net_dev->br_port ? 1 : 0)
+struct kernel_param_ops {
+ /* Returns 0, or -errno. arg is in kp->arg. */
+ int (*set)(const char *val, const struct kernel_param *kp);
+ /* Returns length written or -errno. Buffer is 4k (ie. be short!) */
+ int (*get)(char *buffer, struct kernel_param *kp);
+ /* Optional function to free kp->arg when module unloaded. */
+ void (*free)(void *arg);
+};
+
+#define module_param_cb(name, ops, arg, perm) \
+ static int __compat_set_param_##name(const char *val, \
+ struct kernel_param *kp) \
+ { return (ops)->set(val, kp); } \
+ static int __compat_get_param_##name(char *buffer, \
+ struct kernel_param *kp) \
+ { return (ops)->get(buffer, kp); } \
+ __module_param_call(MODULE_PARAM_PREFIX, name, \
+ __compat_set_param_##name, \
+ __compat_get_param_##name, arg, \
+ __same_type((arg), bool *), perm)
+
+static inline int __param_set_copystring(const char *val,
+ const struct kernel_param *kp)
+{
+ return param_set_copystring(val, (struct kernel_param *)kp);
+}
+#define param_set_copystring __param_set_copystring
+
#endif /* < KERNEL_VERSION(2, 6, 36) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
diff --git a/main.c b/main.c
index bcc2bdd..8ae497b 100644
--- a/main.c
+++ b/main.c
@@ -256,6 +256,30 @@ int bat_algo_seq_print_text(struct seq_file *seq, void *offset)
return 0;
}
+static int param_set_ra(const char *val, const struct kernel_param *kp)
+{
+ struct bat_algo_ops *bat_algo_ops;
+
+ bat_algo_ops = bat_algo_get((char *)val);
+ if (!bat_algo_ops) {
+ pr_err("Routing algorithm '%s' is not supported\n", val);
+ return -EINVAL;
+ }
+
+ return param_set_copystring(val, kp);
+}
+
+static const struct kernel_param_ops param_ops_ra = {
+ .set = param_set_ra,
+ .get = param_get_string,
+};
+
+static struct kparam_string __param_string_ra = {
+ .maxlen = sizeof(bat_routing_algo),
+ .string = bat_routing_algo,
+};
+
+module_param_cb(routing_algo, ¶m_ops_ra, &__param_string_ra, 0644);
module_init(batman_init);
module_exit(batman_exit);
--
batman-adv
11 years, 1 month
batman-adv; branch, master, updated. v2011.4.0-51-g4fa5609
by postmaster@open-mesh.org
The following commit has been merged in the master branch:
commit 4fa5609a4ce79b8f1316dbe9beca3b1d67014f53
Author: Marek Lindner <lindner_marek(a)yahoo.de>
Date: Mon Nov 28 21:31:55 2011 +0800
batman-adv: convert batman iv algorithm to use dynamic infrastructure
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 1847efa..1c483a5 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -20,7 +20,6 @@
*/
#include "main.h"
-#include "bat_ogm.h"
#include "translation-table.h"
#include "ring_buffer.h"
#include "originator.h"
@@ -31,7 +30,7 @@
#include "send.h"
#include "bat_algo.h"
-void bat_ogm_init(struct hard_iface *hard_iface)
+static void bat_iv_ogm_init(struct hard_iface *hard_iface)
{
struct batman_ogm_packet *batman_ogm_packet;
@@ -48,7 +47,7 @@ void bat_ogm_init(struct hard_iface *hard_iface)
batman_ogm_packet->ttvn = 0;
}
-void bat_ogm_init_primary(struct hard_iface *hard_iface)
+static void bat_iv_ogm_init_primary(struct hard_iface *hard_iface)
{
struct batman_ogm_packet *batman_ogm_packet;
@@ -57,7 +56,7 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface)
batman_ogm_packet->header.ttl = TTL;
}
-void bat_ogm_update_mac(struct hard_iface *hard_iface)
+static void bat_iv_ogm_update_mac(struct hard_iface *hard_iface)
{
struct batman_ogm_packet *batman_ogm_packet;
@@ -69,7 +68,7 @@ void bat_ogm_update_mac(struct hard_iface *hard_iface)
}
/* when do we schedule our own ogm to be sent */
-static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv)
+static unsigned long bat_iv_ogm_emit_send_time(const struct bat_priv *bat_priv)
{
return jiffies + msecs_to_jiffies(
atomic_read(&bat_priv->orig_interval) -
@@ -77,7 +76,7 @@ static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv)
}
/* when do we schedule a ogm packet to be sent */
-static unsigned long bat_ogm_fwd_send_time(void)
+static unsigned long bat_iv_ogm_fwd_send_time(void)
{
return jiffies + msecs_to_jiffies(random32() % (JITTER/2));
}
@@ -90,8 +89,8 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
}
/* is there another aggregated packet here? */
-static int bat_ogm_aggr_packet(int buff_pos, int packet_len,
- int tt_num_changes)
+static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len,
+ int tt_num_changes)
{
int next_buff_pos = buff_pos + BATMAN_OGM_LEN + tt_len(tt_num_changes);
@@ -100,8 +99,8 @@ static int bat_ogm_aggr_packet(int buff_pos, int packet_len,
}
/* send a batman ogm to a given interface */
-static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
- struct hard_iface *hard_iface)
+static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
+ struct hard_iface *hard_iface)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
char *fwd_str;
@@ -118,8 +117,8 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data;
/* adjust all flags and log packets */
- while (bat_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
- batman_ogm_packet->tt_num_changes)) {
+ while (bat_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
+ batman_ogm_packet->tt_num_changes)) {
/* we might have aggregated direct link packets with an
* ordinary base packet */
@@ -158,7 +157,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
}
/* send a batman ogm packet */
-void bat_ogm_emit(struct forw_packet *forw_packet)
+static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
{
struct hard_iface *hard_iface;
struct net_device *soft_iface;
@@ -217,7 +216,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
if (hard_iface->soft_iface != soft_iface)
continue;
- bat_ogm_send_to_if(forw_packet, hard_iface);
+ bat_iv_ogm_send_to_if(forw_packet, hard_iface);
}
rcu_read_unlock();
@@ -227,13 +226,13 @@ out:
}
/* return true if new_packet can be aggregated with forw_packet */
-static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
+static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
*new_batman_ogm_packet,
- struct bat_priv *bat_priv,
- int packet_len, unsigned long send_time,
- bool directlink,
- const struct hard_iface *if_incoming,
- const struct forw_packet *forw_packet)
+ struct bat_priv *bat_priv,
+ int packet_len, unsigned long send_time,
+ bool directlink,
+ const struct hard_iface *if_incoming,
+ const struct forw_packet *forw_packet)
{
struct batman_ogm_packet *batman_ogm_packet;
int aggregated_bytes = forw_packet->packet_len + packet_len;
@@ -307,11 +306,11 @@ out:
}
/* create a new aggregated packet and add this packet to it */
-static void bat_ogm_aggregate_new(const unsigned char *packet_buff,
- int packet_len, unsigned long send_time,
- bool direct_link,
- struct hard_iface *if_incoming,
- int own_packet)
+static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
+ int packet_len, unsigned long send_time,
+ bool direct_link,
+ struct hard_iface *if_incoming,
+ int own_packet)
{
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
struct forw_packet *forw_packet_aggr;
@@ -386,9 +385,9 @@ out:
}
/* aggregate a new packet into the existing ogm packet */
-static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr,
- const unsigned char *packet_buff,
- int packet_len, bool direct_link)
+static void bat_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr,
+ const unsigned char *packet_buff,
+ int packet_len, bool direct_link)
{
unsigned char *skb_buff;
@@ -403,10 +402,10 @@ static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr,
(1 << forw_packet_aggr->num_packets);
}
-static void bat_ogm_queue_add(struct bat_priv *bat_priv,
- unsigned char *packet_buff,
- int packet_len, struct hard_iface *if_incoming,
- int own_packet, unsigned long send_time)
+static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
+ unsigned char *packet_buff,
+ int packet_len, struct hard_iface *if_incoming,
+ int own_packet, unsigned long send_time)
{
/**
* _aggr -> pointer to the packet we want to aggregate with
@@ -426,11 +425,11 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
hlist_for_each_entry(forw_packet_pos, tmp_node,
&bat_priv->forw_bat_list, list) {
- if (bat_ogm_can_aggregate(batman_ogm_packet,
- bat_priv, packet_len,
- send_time, direct_link,
- if_incoming,
- forw_packet_pos)) {
+ if (bat_iv_ogm_can_aggregate(batman_ogm_packet,
+ bat_priv, packet_len,
+ send_time, direct_link,
+ if_incoming,
+ forw_packet_pos)) {
forw_packet_aggr = forw_packet_pos;
break;
}
@@ -452,20 +451,20 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
(atomic_read(&bat_priv->aggregated_ogms)))
send_time += msecs_to_jiffies(MAX_AGGREGATION_MS);
- bat_ogm_aggregate_new(packet_buff, packet_len,
- send_time, direct_link,
- if_incoming, own_packet);
+ bat_iv_ogm_aggregate_new(packet_buff, packet_len,
+ send_time, direct_link,
+ if_incoming, own_packet);
} else {
- bat_ogm_aggregate(forw_packet_aggr, packet_buff, packet_len,
- direct_link);
+ bat_iv_ogm_aggregate(forw_packet_aggr, packet_buff,
+ packet_len, direct_link);
spin_unlock_bh(&bat_priv->forw_bat_list_lock);
}
}
-static void bat_ogm_forward(struct orig_node *orig_node,
- const struct ethhdr *ethhdr,
- struct batman_ogm_packet *batman_ogm_packet,
- int directlink, struct hard_iface *if_incoming)
+static void bat_iv_ogm_forward(struct orig_node *orig_node,
+ const struct ethhdr *ethhdr,
+ struct batman_ogm_packet *batman_ogm_packet,
+ int directlink, struct hard_iface *if_incoming)
{
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
struct neigh_node *router;
@@ -524,12 +523,13 @@ static void bat_ogm_forward(struct orig_node *orig_node,
else
batman_ogm_packet->flags &= ~DIRECTLINK;
- bat_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
- BATMAN_OGM_LEN + tt_len(tt_num_changes),
- if_incoming, 0, bat_ogm_fwd_send_time());
+ bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
+ BATMAN_OGM_LEN + tt_len(tt_num_changes),
+ if_incoming, 0, bat_iv_ogm_fwd_send_time());
}
-void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
+static void bat_iv_ogm_schedule(struct hard_iface *hard_iface,
+ int tt_num_changes)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct batman_ogm_packet *batman_ogm_packet;
@@ -566,21 +566,22 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
atomic_inc(&hard_iface->seqno);
slide_own_bcast_window(hard_iface);
- bat_ogm_queue_add(bat_priv, hard_iface->packet_buff,
- hard_iface->packet_len, hard_iface, 1,
- bat_ogm_emit_send_time(bat_priv));
+ bat_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
+ hard_iface->packet_len, hard_iface, 1,
+ bat_iv_ogm_emit_send_time(bat_priv));
if (primary_if)
hardif_free_ref(primary_if);
}
-static void bat_ogm_orig_update(struct bat_priv *bat_priv,
- struct orig_node *orig_node,
- const struct ethhdr *ethhdr,
- const struct batman_ogm_packet
+static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
+ struct orig_node *orig_node,
+ const struct ethhdr *ethhdr,
+ const struct batman_ogm_packet
*batman_ogm_packet,
- struct hard_iface *if_incoming,
- const unsigned char *tt_buff, int is_duplicate)
+ struct hard_iface *if_incoming,
+ const unsigned char *tt_buff,
+ int is_duplicate)
{
struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
struct neigh_node *router = NULL;
@@ -715,10 +716,10 @@ out:
neigh_node_free_ref(router);
}
-static int bat_ogm_calc_tq(struct orig_node *orig_node,
- struct orig_node *orig_neigh_node,
- struct batman_ogm_packet *batman_ogm_packet,
- struct hard_iface *if_incoming)
+static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
+ struct orig_node *orig_neigh_node,
+ struct batman_ogm_packet *batman_ogm_packet,
+ struct hard_iface *if_incoming)
{
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
struct neigh_node *neigh_node = NULL, *tmp_neigh_node;
@@ -827,10 +828,10 @@ out:
* -1 the packet is old and has been received while the seqno window
* was protected. Caller should drop it.
*/
-static int bat_ogm_update_seqnos(const struct ethhdr *ethhdr,
- const struct batman_ogm_packet
+static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+ const struct batman_ogm_packet
*batman_ogm_packet,
- const struct hard_iface *if_incoming)
+ const struct hard_iface *if_incoming)
{
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
struct orig_node *orig_node;
@@ -892,10 +893,10 @@ out:
return ret;
}
-static void bat_ogm_process(const struct ethhdr *ethhdr,
- struct batman_ogm_packet *batman_ogm_packet,
- const unsigned char *tt_buff,
- struct hard_iface *if_incoming)
+static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
+ struct batman_ogm_packet *batman_ogm_packet,
+ const unsigned char *tt_buff,
+ struct hard_iface *if_incoming)
{
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
struct hard_iface *hard_iface;
@@ -1033,8 +1034,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
if (!orig_node)
return;
- is_duplicate = bat_ogm_update_seqnos(ethhdr, batman_ogm_packet,
- if_incoming);
+ is_duplicate = bat_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet,
+ if_incoming);
if (is_duplicate == -1) {
bat_dbg(DBG_BATMAN, bat_priv,
@@ -1083,8 +1084,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
goto out_neigh;
}
- is_bidirectional = bat_ogm_calc_tq(orig_node, orig_neigh_node,
- batman_ogm_packet, if_incoming);
+ is_bidirectional = bat_iv_ogm_calc_tq(orig_node, orig_neigh_node,
+ batman_ogm_packet, if_incoming);
bonding_save_primary(orig_node, orig_neigh_node, batman_ogm_packet);
@@ -1094,16 +1095,16 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
(!is_duplicate ||
((orig_node->last_real_seqno == batman_ogm_packet->seqno) &&
(orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl))))
- bat_ogm_orig_update(bat_priv, orig_node, ethhdr,
- batman_ogm_packet, if_incoming,
- tt_buff, is_duplicate);
+ bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
+ batman_ogm_packet, if_incoming,
+ tt_buff, is_duplicate);
/* is single hop (direct) neighbor */
if (is_single_hop_neigh) {
/* mark direct link on incoming interface */
- bat_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
- 1, if_incoming);
+ bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
+ 1, if_incoming);
bat_dbg(DBG_BATMAN, bat_priv, "Forwarding packet: "
"rebroadcast neighbor packet with direct link flag\n");
@@ -1125,7 +1126,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
bat_dbg(DBG_BATMAN, bat_priv,
"Forwarding packet: rebroadcast originator packet\n");
- bat_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 0, if_incoming);
+ bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
+ 0, if_incoming);
out_neigh:
if ((orig_neigh_node) && (!is_single_hop_neigh))
@@ -1141,7 +1143,8 @@ out:
orig_node_free_ref(orig_node);
}
-void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb)
+static void bat_iv_ogm_receive(struct hard_iface *if_incoming,
+ struct sk_buff *skb)
{
struct batman_ogm_packet *batman_ogm_packet;
struct ethhdr *ethhdr;
@@ -1162,20 +1165,26 @@ void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb)
tt_buff = packet_buff + buff_pos + BATMAN_OGM_LEN;
- bat_ogm_process(ethhdr, batman_ogm_packet,
- tt_buff, if_incoming);
+ bat_iv_ogm_process(ethhdr, batman_ogm_packet,
+ tt_buff, if_incoming);
buff_pos += BATMAN_OGM_LEN +
tt_len(batman_ogm_packet->tt_num_changes);
batman_ogm_packet = (struct batman_ogm_packet *)
(packet_buff + buff_pos);
- } while (bat_ogm_aggr_packet(buff_pos, packet_len,
- batman_ogm_packet->tt_num_changes));
+ } while (bat_iv_ogm_aggr_packet(buff_pos, packet_len,
+ batman_ogm_packet->tt_num_changes));
}
static struct bat_algo_ops batman_iv __read_mostly = {
.name = "BATMAN IV",
+ .bat_ogm_init = bat_iv_ogm_init,
+ .bat_ogm_init_primary = bat_iv_ogm_init_primary,
+ .bat_ogm_update_mac = bat_iv_ogm_update_mac,
+ .bat_ogm_schedule = bat_iv_ogm_schedule,
+ .bat_ogm_emit = bat_iv_ogm_emit,
+ .bat_ogm_receive = bat_iv_ogm_receive,
};
int __init bat_iv_init(void)
diff --git a/bat_ogm.h b/bat_ogm.h
deleted file mode 100644
index 47edfde..0000000
--- a/bat_ogm.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
- *
- * Marek Lindner, Simon Wunderlich
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- *
- */
-
-#ifndef _NET_BATMAN_ADV_OGM_H_
-#define _NET_BATMAN_ADV_OGM_H_
-
-#include "main.h"
-
-void bat_ogm_init(struct hard_iface *hard_iface);
-void bat_ogm_init_primary(struct hard_iface *hard_iface);
-void bat_ogm_update_mac(struct hard_iface *hard_iface);
-void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes);
-void bat_ogm_emit(struct forw_packet *forw_packet);
-void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb);
-
-#endif /* _NET_BATMAN_ADV_OGM_H_ */
diff --git a/hard-interface.c b/hard-interface.c
index 68b667c..ff5ba40 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -28,7 +28,6 @@
#include "bat_sysfs.h"
#include "originator.h"
#include "hash.h"
-#include "bat_ogm.h"
#include <linux/if_arp.h>
@@ -147,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
if (!new_hard_iface)
return;
- bat_ogm_init_primary(new_hard_iface);
+ bat_priv->bat_algo_ops->bat_ogm_init_primary(new_hard_iface);
primary_if_update_addr(bat_priv);
}
@@ -233,7 +232,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
bat_priv = netdev_priv(hard_iface->soft_iface);
- bat_ogm_update_mac(hard_iface);
+ bat_priv->bat_algo_ops->bat_ogm_update_mac(hard_iface);
hard_iface->if_status = IF_TO_BE_ACTIVATED;
/**
@@ -315,7 +314,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
hard_iface->soft_iface = soft_iface;
bat_priv = netdev_priv(hard_iface->soft_iface);
- bat_ogm_init(hard_iface);
+ bat_priv->bat_algo_ops->bat_ogm_init(hard_iface);
if (!hard_iface->packet_buff) {
bat_err(hard_iface->soft_iface, "Can't add interface packet "
@@ -535,9 +534,10 @@ static int hard_if_event(struct notifier_block *this,
goto hardif_put;
check_known_mac_addr(hard_iface->net_dev);
- bat_ogm_update_mac(hard_iface);
bat_priv = netdev_priv(hard_iface->soft_iface);
+ bat_priv->bat_algo_ops->bat_ogm_update_mac(hard_iface);
+
primary_if = primary_if_get_selected(bat_priv);
if (!primary_if)
goto hardif_put;
diff --git a/main.c b/main.c
index 7c87a34..bcc2bdd 100644
--- a/main.c
+++ b/main.c
@@ -206,6 +206,18 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
goto out;
}
+ /* all algorithms must implement all ops (for now) */
+ if (!bat_algo_ops->bat_ogm_init ||
+ !bat_algo_ops->bat_ogm_init_primary ||
+ !bat_algo_ops->bat_ogm_update_mac ||
+ !bat_algo_ops->bat_ogm_schedule ||
+ !bat_algo_ops->bat_ogm_emit ||
+ !bat_algo_ops->bat_ogm_receive) {
+ pr_info("Routing algo '%s' does not implement required ops\n",
+ bat_algo_ops->name);
+ goto out;
+ }
+
INIT_HLIST_NODE(&bat_algo_ops->list);
hlist_add_head(&bat_algo_ops->list, &bat_algo_list);
ret = 0;
diff --git a/routing.c b/routing.c
index 5bc41c8..b72d7f3 100644
--- a/routing.c
+++ b/routing.c
@@ -29,7 +29,6 @@
#include "originator.h"
#include "vis.h"
#include "unicast.h"
-#include "bat_ogm.h"
void slide_own_bcast_window(struct hard_iface *hard_iface)
{
@@ -248,6 +247,7 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
{
+ struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct ethhdr *ethhdr;
/* drop packet if it has not necessary minimum size */
@@ -272,7 +272,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
if (skb_linearize(skb) < 0)
return NET_RX_DROP;
- bat_ogm_receive(hard_iface, skb);
+ bat_priv->bat_algo_ops->bat_ogm_receive(hard_iface, skb);
kfree_skb(skb);
return NET_RX_SUCCESS;
diff --git a/send.c b/send.c
index b00a0f5..019337e 100644
--- a/send.c
+++ b/send.c
@@ -28,7 +28,6 @@
#include "vis.h"
#include "gateway_common.h"
#include "originator.h"
-#include "bat_ogm.h"
static void send_outstanding_bcast_packet(struct work_struct *work);
@@ -168,7 +167,7 @@ void schedule_bat_ogm(struct hard_iface *hard_iface)
if (primary_if)
hardif_free_ref(primary_if);
- bat_ogm_schedule(hard_iface, tt_num_changes);
+ bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface, tt_num_changes);
}
static void forw_packet_free(struct forw_packet *forw_packet)
@@ -318,7 +317,7 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work)
if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING)
goto out;
- bat_ogm_emit(forw_packet);
+ bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet);
/**
* we have to have at least one packet in the queue
diff --git a/types.h b/types.h
index d21ff2c..650ce5f 100644
--- a/types.h
+++ b/types.h
@@ -348,6 +348,20 @@ struct softif_neigh {
struct bat_algo_ops {
struct hlist_node list;
char *name;
+ /* init OGM when hard-interface is enabled */
+ void (*bat_ogm_init)(struct hard_iface *hard_iface);
+ /* init primary OGM when primary interface is selected */
+ void (*bat_ogm_init_primary)(struct hard_iface *hard_iface);
+ /* init mac addresses of the OGM belonging to this hard-interface */
+ void (*bat_ogm_update_mac)(struct hard_iface *hard_iface);
+ /* prepare a new outgoing OGM for the send queue */
+ void (*bat_ogm_schedule)(struct hard_iface *hard_iface,
+ int tt_num_changes);
+ /* send scheduled OGM */
+ void (*bat_ogm_emit)(struct forw_packet *forw_packet);
+ /* receive incoming OGM */
+ void (*bat_ogm_receive)(struct hard_iface *if_incoming,
+ struct sk_buff *skb);
};
#endif /* _NET_BATMAN_ADV_TYPES_H_ */
--
batman-adv
11 years, 1 month