[B.A.T.M.A.N.] batman-adv on ethernet
by Donald Gordon
Hi
What happens if I add an interface to batman-adv (on which to exchange
mesh frames), and add that same interface to a bridge with bat0? E.g.
on an openwrt, br-lan contains eth0, bat0 and wlan0; batman-adv is
exchanging mesh frames on wlan1 and eth0.
Will I end up with BATMAN-on-BATMAN or will batman-adv filter out the
batman frames it sees on bat0?
thanks
donald
8 years, 2 months
[B.A.T.M.A.N.] [PATCH] batman-adv: Do not add multicast MAC addresses to translation table
by Linus Lüssing
The current translation table mechanism is not suitable for multicast
addresses and we are currently flooding such frames anyway.
Therefore this patch prevents multicast MAC addresses being added to the
translation table.
Signed-off-by: Linus Lüssing <linus.luessing(a)web.de>
---
soft-interface.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/soft-interface.c b/soft-interface.c
index 2d1f895..9955319 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -180,7 +180,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
goto dropped;
/* Register the client MAC in the transtable */
- batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
+ if (!is_multicast_ether_addr(ethhdr->h_source))
+ batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
/* don't accept stp packets. STP does not help in meshes.
* better use the bridge loop avoidance ...
--
1.7.10.4
8 years, 2 months
[B.A.T.M.A.N.] [PATCH] batctl: Guarantee delimiter after snprintf
by Sven Eckelmann
snprintf doesn't add a \0 delimiter when the size of the buffer is not big
enough. The caller has to fix it manually to avoid crashes.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
bisect_iv.c | 10 ++++++----
debugfs.c | 1 +
sys.c | 8 ++++++++
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/bisect_iv.c b/bisect_iv.c
index c4c06c2..09171fb 100644
--- a/bisect_iv.c
+++ b/bisect_iv.c
@@ -639,9 +639,9 @@ static int print_rt_path_at_seqno(struct bat_node *src_node, struct bat_node *ds
struct rt_hist *rt_hist;
char curr_loop_magic[LOOP_MAGIC_LEN];
- memset(curr_loop_magic, 0, LOOP_MAGIC_LEN);
- snprintf(curr_loop_magic, LOOP_MAGIC_LEN, "%s%s%lli%lli", src_node->name,
+ snprintf(curr_loop_magic, sizeof(curr_loop_magic), "%s%s%lli%lli", src_node->name,
dst_node->name, seqno, seqno_rand);
+ curr_loop_magic[sizeof(curr_loop_magic) - 1] = '\0';
printf("Path towards %s (seqno %lli ",
get_name_by_macstr(dst_node->name, read_opt), seqno);
@@ -719,10 +719,10 @@ static int find_rt_table_change(struct bat_node *src_node, struct bat_node *dst_
return 0;
}
- memset(curr_loop_magic, 0, LOOP_MAGIC_LEN);
- snprintf(curr_loop_magic, LOOP_MAGIC_LEN, "%s%s%lli%lli",
+ snprintf(curr_loop_magic, sizeof(curr_loop_magic), "%s%s%lli%lli",
src_node->name, dst_node->name,
seqno_min_tmp, seqno_rand);
+ curr_loop_magic[sizeof(curr_loop_magic) - 1] = '\0';
orig_event = orig_event_get_by_ptr(curr_node, dst_node);
if (!orig_event)
@@ -979,6 +979,7 @@ static void seqno_trace_print_neigh(struct seqno_trace_neigh *seqno_trace_neigh,
(strlen(head) > 1 ? head : num_sisters == 0 ? " " : head),
(strlen(head) == 1 ? " " :
num_sisters == 0 ? " " : "| "));
+ new_head[sizeof(new_head) - 1] = '\0';
seqno_trace_print_neigh(seqno_trace_neigh->seqno_trace_neigh[i], seqno_trace_neigh->seqno_event,
seqno_trace_neigh->num_neighbors - i - 1, new_head, read_opt);
@@ -1024,6 +1025,7 @@ static void seqno_trace_print(struct list_head_first *trace_list, char *trace_or
snprintf(head, sizeof(head), "%c",
(seqno_trace->seqno_trace_neigh.num_neighbors == i + 1 ? '\\' : '|'));
+ head[sizeof(head) - 1] = '\0';
seqno_trace_print_neigh(seqno_trace->seqno_trace_neigh.seqno_trace_neigh[i],
NULL,
diff --git a/debugfs.c b/debugfs.c
index 549546c..9fc6f42 100644
--- a/debugfs.c
+++ b/debugfs.c
@@ -56,6 +56,7 @@ int debugfs_make_path(const char *fmt, char *mesh_iface, char *buffer, int size)
return len+1;
snprintf(buffer, size-1, fmt, debugfs_mountpoint, mesh_iface);
+ buffer[size - 1] = '\0';
return 0;
}
diff --git a/sys.c b/sys.c
index 9591416..e4112b7 100644
--- a/sys.c
+++ b/sys.c
@@ -136,6 +136,7 @@ static int print_interfaces(char *mesh_iface)
while ((iface_dir = readdir(iface_base_dir)) != NULL) {
snprintf(path_buff, PATH_BUFF_LEN, SYS_MESH_IFACE_FMT, iface_dir->d_name);
+ path_buff[PATH_BUFF_LEN - 1] = '\0';
res = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS, 0, 0, 0);
if (res != EXIT_SUCCESS)
continue;
@@ -153,6 +154,7 @@ static int print_interfaces(char *mesh_iface)
line_ptr = NULL;
snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, iface_dir->d_name);
+ path_buff[PATH_BUFF_LEN - 1] = '\0';
res = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS, 0, 0, 0);
if (res != EXIT_SUCCESS) {
printf("<error reading status>\n");
@@ -216,9 +218,11 @@ int interface(char *mesh_iface, int argc, char **argv)
for (i = 2; i < argc; i++) {
snprintf(path_buff, PATH_BUFF_LEN, SYS_MESH_IFACE_FMT, argv[i]);
+ path_buff[PATH_BUFF_LEN - 1] = '\0';
if (!file_exists(path_buff)) {
snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_DIR, argv[i]);
+ path_buff[PATH_BUFF_LEN - 1] = '\0';
if (!file_exists(path_buff)) {
printf("Error - interface does not exist: %s\n", argv[i]);
@@ -288,6 +292,7 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv)
path_buff = malloc(PATH_BUFF_LEN);
snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
+ path_buff[PATH_BUFF_LEN - 1] = '\0';
if (argc != 1) {
for (i = 1; i < argc; i++) {
@@ -314,6 +319,7 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv)
}
snprintf(str, sizeof(str), "%i", log_level);
+ str[sizeof(str) - 1] = '\0';
res = write_file(path_buff, SYS_LOG_LEVEL, str, NULL);
goto out;
}
@@ -379,6 +385,7 @@ int handle_sys_setting(char *mesh_iface, int setting, int argc, char **argv)
path_buff = malloc(PATH_BUFF_LEN);
snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
+ path_buff[PATH_BUFF_LEN - 1] = '\0';
if (argc == 1) {
res = read_file(path_buff, (char *)batctl_settings[setting].sysfs_name,
@@ -443,6 +450,7 @@ int handle_gw_setting(char *mesh_iface, int argc, char **argv)
path_buff = malloc(PATH_BUFF_LEN);
snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
+ path_buff[PATH_BUFF_LEN - 1] = '\0';
if (argc == 1) {
res = read_file(path_buff, SYS_GW_MODE, USE_READ_BUFF, 0, 0, 0);
--
1.7.10.4
8 years, 2 months
[B.A.T.M.A.N.] [PATCH] if_ether.h: add B.A.T.M.A.N.-Advanced Ethertype
by Antonio Quartulli
Add Ethertype 0x4305 (not an officially registered id).
This Ethertype is used by every frame generated by B.A.T.M.A.N.-Advanced. Its
definition is currently batman-adv local only and since it is not officially
registered it is better to make its definition kernel-wide so that we avoid
collisions given by future unofficial uses of the same Ethertype.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
include/uapi/linux/if_ether.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h
index 0343e1f..67fb87c 100644
--- a/include/uapi/linux/if_ether.h
+++ b/include/uapi/linux/if_ether.h
@@ -48,6 +48,7 @@
#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */
+#define ETH_P_BATMAN 0x4305 /* B.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
--
1.7.12.4
8 years, 2 months
[B.A.T.M.A.N.] [PATCH] batman-adv: free the dat hash only if not NULL
by Antonio Quartulli
It could be the case that the user tries to disable DAT when it is already
disabled. To prevent kernel oops, batadv_dat_hash_free() has to check for the
hash table pointer being different from NULL before to try to free it.
This was introduced by ("batman-adv: Distributed ARP Table - add runtime
switch")
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
distributed-arp-table.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index c933615..0fea29a 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -634,6 +634,9 @@ out:
*/
static void batadv_dat_hash_free(struct batadv_priv *bat_priv)
{
+ if (!bat_priv->dat.hash)
+ return;
+
__batadv_dat_purge(bat_priv, NULL);
batadv_hash_destroy(bat_priv->dat.hash);
--
1.7.12.4
8 years, 2 months
[B.A.T.M.A.N.] [PATCHv2] batman-adv: don't free resource when DAT is disabled
by Antonio Quartulli
Freeing all the resources when DAT is disabled need a much more complicated
locking system to prevent concurrent enable/disable operations to destroy the
internal state of the component. For now it is safe to avoid such freeing
operation when DAT is disabled.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
v2:
- removed declaration of batadv_dat_switch() in distributed-arp-table.h
distributed-arp-table.c | 10 ----------
distributed-arp-table.h | 1 -
sysfs.c | 3 +--
3 files changed, 1 insertion(+), 13 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index c933615..7921030 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -1061,13 +1061,3 @@ out:
batadv_dat_entry_free_ref(dat_entry);
return ret;
}
-
-void batadv_dat_switch(struct net_device *net_dev)
-{
- struct batadv_priv *bat_priv = netdev_priv(net_dev);
-
- if (atomic_read(&bat_priv->distributed_arp_table))
- batadv_dat_init(bat_priv);
- else
- batadv_dat_free(bat_priv);
-}
diff --git a/distributed-arp-table.h b/distributed-arp-table.h
index 63a13a5..d060c03 100644
--- a/distributed-arp-table.h
+++ b/distributed-arp-table.h
@@ -73,7 +73,6 @@ batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
int batadv_dat_init(struct batadv_priv *bat_priv);
void batadv_dat_free(struct batadv_priv *bat_priv);
int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset);
-void batadv_dat_switch(struct net_device *net_dev);
/**
* batadv_dat_inc_counter - increment the correct DAT packet counter
diff --git a/sysfs.c b/sysfs.c
index 9dc58b5..84a55cb 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -422,8 +422,7 @@ BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
#endif
#ifdef CONFIG_BATMAN_ADV_DAT
-BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR,
- batadv_dat_switch);
+BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR, NULL);
#endif
BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
--
1.7.12.4
8 years, 2 months
[B.A.T.M.A.N.] pull request: batman-adv 202-10-29
by Antonio Quartulli
Hello David,
this is again our first set of changes intended for net-next/linux-3.8.
With respect to the previous changeset we substituted the patch changing the
BAT_ATTR_HIF_UINT macro with a new one that removes it (we will re-add such
macro together with the user).
The rest is exactly the same as before.
Thank you very much,
Antonio
The following changes since commit a932657f51eadb8280166e82dc7034dfbff3985a:
net: sierra: shut up sparse restricted type warnings (2012-10-28 19:09:02 -0400)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git tags/batman-adv-for-davem
for you to fetch changes up to 0aca86cd92282359d2f7202804bd92e7d092c04e:
batman-adv: add kernel-doc for enum batadv_dbg_level (2012-10-29 09:42:51 +0100)
----------------------------------------------------------------
included changes:
- some code cleanups and minor fixes (3 of them were reported by Coverity)
- 'struct hard_iface' re-shaping to improve multi-protocol support
- ECTP packets silent drop
- transfer the WIFI flag on clients in case of roaming
----------------------------------------------------------------
Antonio Quartulli (8):
batman-adv: use check_unicast_packet() in recv_roam_adv()
batman-adv: return proper value in case of hash_add failure
batman-adv: properly store the roaming time
batman-adv: print packets re-routing on DBG_TT and ratelimit it
batman-adv: check for more space before accessing the skb
batman-adv: properly convert flag into a boolean value
batman-adv: pass the WIFI flag from the local to global entry
batman-adv: add kernel-doc for enum batadv_dbg_level
Marek Lindner (2):
batman-adv: split hard_iface struct for each routing protocol
batman-adv: consolidate duplicated primary_if checking code
Simon Wunderlich (1):
batman-adv: don't allow ECTP traffic on batman-adv
Sven Eckelmann (5):
batman-adv: Remove unused define BAT_ATTR_HIF_UINT
batman-adv: Set special lockdep classes to avoid lockdep warning
batman-adv: Remove extra check in batadv_bit_get_packet
batman-adv: Check return value of try_module_get
batman-adv: Only increase refcounter once for alternate router
net/batman-adv/bat_iv_ogm.c | 43 ++++++++++---------
net/batman-adv/bitarray.c | 23 +++++-----
net/batman-adv/bridge_loop_avoidance.c | 36 +++-------------
net/batman-adv/debugfs.c | 6 ++-
net/batman-adv/gateway_client.c | 19 ++-------
net/batman-adv/hard-interface.c | 4 +-
net/batman-adv/icmp_socket.c | 12 ++++--
net/batman-adv/main.c | 46 +++++++++++++++-----
net/batman-adv/main.h | 19 ++++++---
net/batman-adv/originator.c | 19 ++-------
net/batman-adv/routing.c | 54 +++++++++---------------
net/batman-adv/soft-interface.c | 56 ++++++++++++++++++++++++-
net/batman-adv/sysfs.c | 49 ----------------------
net/batman-adv/translation-table.c | 77 +++++++++++++++++-----------------
net/batman-adv/translation-table.h | 6 +--
net/batman-adv/types.h | 16 +++++--
16 files changed, 238 insertions(+), 247 deletions(-)
8 years, 2 months
[B.A.T.M.A.N.] [PATCH 0/6] TT improvement campaign
by Antonio Quartulli
Hello,
as you may have seen in the last period, TT has been under heavily
re-design/work in order to improve its robustness (and also readability).
However, some more extensive tests and emulated scenarios revealed that it is
possible to hit some situations in which TT behaviour is not optimal.
This set of patches aims to fix some glitches introduces with the last re-design
and to fix some issues discovered by testing complex scenarios.
Cheers,
Antonio Quartulli (6):
batman-adv: fix TT packet rerouting
batman-adv: fix debug message
batman-adv: remove useless goto
batman-adv: send ROAMING_ADV once
batman-adv: remove useless assignment in tt_local_add()
batman-adv: fix local client recognition in is_my_client()
routing.c | 36 ++++++++++++++++++++++++++----------
translation-table.c | 22 +++++++++++-----------
2 files changed, 37 insertions(+), 21 deletions(-)
--
1.7.12.4
8 years, 2 months
[B.A.T.M.A.N.] [PATCH] batman-adv: don't free resources when DAT is disabled
by Antonio Quartulli
Freeing all the resources when DAT is disabled need a much more complicated
locking system to prevent concurrent enable/disable operations to destroy the
internal state of the component. For now it is safe to avoid such freeing
operation at all when DAT gets disabled.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
distributed-arp-table.c | 10 ----------
sysfs.c | 3 +--
2 files changed, 1 insertion(+), 12 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index c933615..7921030 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -1061,13 +1061,3 @@ out:
batadv_dat_entry_free_ref(dat_entry);
return ret;
}
-
-void batadv_dat_switch(struct net_device *net_dev)
-{
- struct batadv_priv *bat_priv = netdev_priv(net_dev);
-
- if (atomic_read(&bat_priv->distributed_arp_table))
- batadv_dat_init(bat_priv);
- else
- batadv_dat_free(bat_priv);
-}
diff --git a/sysfs.c b/sysfs.c
index 9dc58b5..84a55cb 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -422,8 +422,7 @@ BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
#endif
#ifdef CONFIG_BATMAN_ADV_DAT
-BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR,
- batadv_dat_switch);
+BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR, NULL);
#endif
BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
--
1.7.12.4
8 years, 2 months
[B.A.T.M.A.N.] [PATCHv2] batman-adv: Remove unused define BAT_ATTR_HIF_UINT
by Sven Eckelmann
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
v2:
- Rebased this patch from May on top of current master
sysfs.c | 50 --------------------------------------------------
1 file changed, 50 deletions(-)
diff --git a/sysfs.c b/sysfs.c
index cc56ed0..9dc58b5 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -123,56 +123,6 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \
batadv_store_##_name)
-#define BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, _max, _post_func) \
-ssize_t batadv_store_##_name(struct kobject *kobj, \
- struct attribute *attr, char *buff, \
- size_t count) \
-{ \
- struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
- struct batadv_hard_iface *hard_iface; \
- ssize_t length; \
- \
- hard_iface = batadv_hardif_get_by_netdev(net_dev); \
- if (!hard_iface) \
- return 0; \
- \
- length = __batadv_store_uint_attr(buff, count, _min, _max, \
- _post_func, attr, \
- &hard_iface->_var, net_dev); \
- \
- batadv_hardif_free_ref(hard_iface); \
- return length; \
-}
-
-#define BATADV_ATTR_HIF_SHOW_UINT(_name, _var) \
-ssize_t batadv_show_##_name(struct kobject *kobj, \
- struct attribute *attr, char *buff) \
-{ \
- struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
- struct batadv_hard_iface *hard_iface; \
- ssize_t length; \
- \
- hard_iface = batadv_hardif_get_by_netdev(net_dev); \
- if (!hard_iface) \
- return 0; \
- \
- length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_var)); \
- \
- batadv_hardif_free_ref(hard_iface); \
- return length; \
-}
-
-/* Use this, if you are going to set [name] in hard_iface to an
- * unsigned integer value
- */
-#define BATADV_ATTR_HIF_UINT(_name, _var, _mode, _min, _max, _post_func)\
- static BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, \
- _max, _post_func) \
- static BATADV_ATTR_HIF_SHOW_UINT(_name, _var) \
- static BATADV_ATTR(_name, _mode, batadv_show_##_name, \
- batadv_store_##_name)
-
-
static int batadv_store_bool_attr(char *buff, size_t count,
struct net_device *net_dev,
const char *attr_name, atomic_t *attr)
--
1.7.10.4
8 years, 2 months