[B.A.T.M.A.N.] [PATCH] batman-adv: Add wrapper to look up neighbor and send skb
by Martin Hundebøll
By adding batadv_send_skb_to_orig() in send.c, we can remove duplicate
code that looks up the next hop and then calls batadv_send_skb_packet().
Furthermore, this prepares the upcoming new implementation of
fragmentation, which requires the next hop to route packets.
Please note that this doesn't entirely remove the next-hop lookup in
routing.c and unicast.c, since it is used by the current fragmentation
code.
Also note that the next-hop info is removed from debug messages in
translation-table.c, since it is looked up elsewhere.
Signed-off-by: Martin Hundebøll <martin(a)hundeboll.net>
---
routing.c | 33 ++++-----------------------
send.c | 20 +++++++++++++++++
send.h | 3 +++
translation-table.c | 65 +++++++++++++----------------------------------------
unicast.c | 9 ++++----
vis.c | 38 +++++++++----------------------
6 files changed, 58 insertions(+), 110 deletions(-)
diff --git a/routing.c b/routing.c
index bc2b88b..5e5d335 100644
--- a/routing.c
+++ b/routing.c
@@ -284,7 +284,6 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
{
struct batadv_hard_iface *primary_if = NULL;
struct batadv_orig_node *orig_node = NULL;
- struct batadv_neigh_node *router = NULL;
struct batadv_icmp_packet_rr *icmp_packet;
int ret = NET_RX_DROP;
@@ -306,10 +305,6 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
if (!orig_node)
goto out;
- router = batadv_orig_node_get_router(orig_node);
- if (!router)
- goto out;
-
/* create a copy of the skb, if needed, to modify it. */
if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
@@ -321,14 +316,11 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
icmp_packet->msg_type = BATADV_ECHO_REPLY;
icmp_packet->header.ttl = BATADV_TTL;
- batadv_send_skb_packet(skb, router->if_incoming, router->addr);
- ret = NET_RX_SUCCESS;
+ ret = batadv_send_skb_to_orig(orig_node, skb, NULL);
out:
if (primary_if)
batadv_hardif_free_ref(primary_if);
- if (router)
- batadv_neigh_node_free_ref(router);
if (orig_node)
batadv_orig_node_free_ref(orig_node);
return ret;
@@ -339,7 +331,6 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
{
struct batadv_hard_iface *primary_if = NULL;
struct batadv_orig_node *orig_node = NULL;
- struct batadv_neigh_node *router = NULL;
struct batadv_icmp_packet *icmp_packet;
int ret = NET_RX_DROP;
@@ -361,10 +352,6 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
if (!orig_node)
goto out;
- router = batadv_orig_node_get_router(orig_node);
- if (!router)
- goto out;
-
/* create a copy of the skb, if needed, to modify it. */
if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
@@ -376,14 +363,11 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
icmp_packet->msg_type = BATADV_TTL_EXCEEDED;
icmp_packet->header.ttl = BATADV_TTL;
- batadv_send_skb_packet(skb, router->if_incoming, router->addr);
- ret = NET_RX_SUCCESS;
+ ret = batadv_send_skb_to_orig(orig_node, skb, NULL);
out:
if (primary_if)
batadv_hardif_free_ref(primary_if);
- if (router)
- batadv_neigh_node_free_ref(router);
if (orig_node)
batadv_orig_node_free_ref(orig_node);
return ret;
@@ -397,7 +381,6 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
struct batadv_icmp_packet_rr *icmp_packet;
struct ethhdr *ethhdr;
struct batadv_orig_node *orig_node = NULL;
- struct batadv_neigh_node *router = NULL;
int hdr_size = sizeof(struct batadv_icmp_packet);
int ret = NET_RX_DROP;
@@ -446,10 +429,6 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
if (!orig_node)
goto out;
- router = batadv_orig_node_get_router(orig_node);
- if (!router)
- goto out;
-
/* create a copy of the skb, if needed, to modify it. */
if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
@@ -460,12 +439,9 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
icmp_packet->header.ttl--;
/* route it */
- batadv_send_skb_packet(skb, router->if_incoming, router->addr);
- ret = NET_RX_SUCCESS;
+ ret = batadv_send_skb_to_orig(orig_node, skb, recv_if);
out:
- if (router)
- batadv_neigh_node_free_ref(router);
if (orig_node)
batadv_orig_node_free_ref(orig_node);
return ret;
@@ -919,8 +895,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
skb->len + ETH_HLEN);
/* route it */
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
- ret = NET_RX_SUCCESS;
+ ret = batadv_send_skb_to_orig(orig_node, skb, recv_if);
out:
if (neigh_node)
diff --git a/send.c b/send.c
index 3b4b2da..c553cfa 100644
--- a/send.c
+++ b/send.c
@@ -77,6 +77,26 @@ send_skb_err:
return NET_XMIT_DROP;
}
+int batadv_send_skb_to_orig(struct batadv_orig_node *orig_node,
+ struct sk_buff *skb,
+ struct batadv_hard_iface *recv_if)
+{
+ struct batadv_priv *bat_priv = orig_node->bat_priv;
+ struct batadv_neigh_node *neigh_node;
+
+ /* batadv_find_router() increases neigh_nodes refcount if found. */
+ neigh_node = batadv_find_router(bat_priv, orig_node, recv_if);
+ if (!neigh_node)
+ return NET_XMIT_DROP;
+
+ /* route it */
+ batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
+
+ batadv_neigh_node_free_ref(neigh_node);
+
+ return NET_XMIT_SUCCESS;
+}
+
void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)
{
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
diff --git a/send.h b/send.h
index 643329b..4f6f5c5 100644
--- a/send.h
+++ b/send.h
@@ -23,6 +23,9 @@
int batadv_send_skb_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface,
const uint8_t *dst_addr);
+int batadv_send_skb_to_orig(struct batadv_orig_node *orig_node,
+ struct sk_buff *skb,
+ struct batadv_hard_iface *recv_if);
void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface);
int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
const struct sk_buff *skb,
diff --git a/translation-table.c b/translation-table.c
index a438f4b..571f8c8 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -1446,10 +1446,9 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv,
{
struct sk_buff *skb = NULL;
struct batadv_tt_query_packet *tt_request;
- struct batadv_neigh_node *neigh_node = NULL;
struct batadv_hard_iface *primary_if;
struct batadv_tt_req_node *tt_req_node = NULL;
- int ret = 1;
+ int ret = NET_RX_DROP;
size_t tt_req_len;
primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -1484,26 +1483,17 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv,
if (full_table)
tt_request->flags |= BATADV_TT_FULL_TABLE;
- neigh_node = batadv_orig_node_get_router(dst_orig_node);
- if (!neigh_node)
- goto out;
-
- batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Sending TT_REQUEST to %pM via %pM [%c]\n",
- dst_orig_node->orig, neigh_node->addr,
- (full_table ? 'F' : '.'));
+ batadv_dbg(BATADV_DBG_TT, bat_priv, "Sending TT_REQUEST to %pM [%c]\n",
+ dst_orig_node->orig, (full_table ? 'F' : '.'));
batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_TX);
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
- ret = 0;
+ ret = batadv_send_skb_to_orig(dst_orig_node, skb, NULL);
out:
- if (neigh_node)
- batadv_neigh_node_free_ref(neigh_node);
if (primary_if)
batadv_hardif_free_ref(primary_if);
- if (ret)
+ if (ret == NET_RX_DROP)
kfree_skb(skb);
if (ret && tt_req_node) {
spin_lock_bh(&bat_priv->tt_req_list_lock);
@@ -1520,7 +1510,6 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv,
{
struct batadv_orig_node *req_dst_orig_node = NULL;
struct batadv_orig_node *res_dst_orig_node = NULL;
- struct batadv_neigh_node *neigh_node = NULL;
struct batadv_hard_iface *primary_if = NULL;
uint8_t orig_ttvn, req_ttvn, ttvn;
int ret = false;
@@ -1545,10 +1534,6 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv,
if (!res_dst_orig_node)
goto out;
- neigh_node = batadv_orig_node_get_router(res_dst_orig_node);
- if (!neigh_node)
- goto out;
-
primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if)
goto out;
@@ -1620,13 +1605,12 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv,
tt_response->flags |= BATADV_TT_FULL_TABLE;
batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n",
- res_dst_orig_node->orig, neigh_node->addr,
- req_dst_orig_node->orig, req_ttvn);
+ "Sending TT_RESPONSE %pM for %pM (ttvn: %u)\n",
+ res_dst_orig_node->orig, req_dst_orig_node->orig, req_ttvn);
batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX);
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
+ batadv_send_skb_to_orig(res_dst_orig_node, skb, NULL);
ret = true;
goto out;
@@ -1638,8 +1622,6 @@ out:
batadv_orig_node_free_ref(res_dst_orig_node);
if (req_dst_orig_node)
batadv_orig_node_free_ref(req_dst_orig_node);
- if (neigh_node)
- batadv_neigh_node_free_ref(neigh_node);
if (primary_if)
batadv_hardif_free_ref(primary_if);
if (!ret)
@@ -1653,7 +1635,6 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv,
struct batadv_tt_query_packet *tt_request)
{
struct batadv_orig_node *orig_node = NULL;
- struct batadv_neigh_node *neigh_node = NULL;
struct batadv_hard_iface *primary_if = NULL;
uint8_t my_ttvn, req_ttvn, ttvn;
int ret = false;
@@ -1677,10 +1658,6 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv,
if (!orig_node)
goto out;
- neigh_node = batadv_orig_node_get_router(orig_node);
- if (!neigh_node)
- goto out;
-
primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if)
goto out;
@@ -1744,13 +1721,13 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv,
tt_response->flags |= BATADV_TT_FULL_TABLE;
batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Sending TT_RESPONSE to %pM via %pM [%c]\n",
- orig_node->orig, neigh_node->addr,
+ "Sending TT_RESPONSE to %pM [%c]\n",
+ orig_node->orig,
(tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX);
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
+ batadv_send_skb_to_orig(orig_node, skb, NULL);
ret = true;
goto out;
@@ -1759,8 +1736,6 @@ unlock:
out:
if (orig_node)
batadv_orig_node_free_ref(orig_node);
- if (neigh_node)
- batadv_neigh_node_free_ref(neigh_node);
if (primary_if)
batadv_hardif_free_ref(primary_if);
if (!ret)
@@ -2028,10 +2003,9 @@ unlock:
static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client,
struct batadv_orig_node *orig_node)
{
- struct batadv_neigh_node *neigh_node = NULL;
struct sk_buff *skb = NULL;
struct batadv_roam_adv_packet *roam_adv_packet;
- int ret = 1;
+ int ret = NET_RX_DROP;
struct batadv_hard_iface *primary_if;
size_t len = sizeof(*roam_adv_packet);
@@ -2061,23 +2035,16 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client,
memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN);
memcpy(roam_adv_packet->client, client, ETH_ALEN);
- neigh_node = batadv_orig_node_get_router(orig_node);
- if (!neigh_node)
- goto out;
-
batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Sending ROAMING_ADV to %pM (client %pM) via %pM\n",
- orig_node->orig, client, neigh_node->addr);
+ "Sending ROAMING_ADV to %pM (client %pM)\n",
+ orig_node->orig, client);
batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX);
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
- ret = 0;
+ ret = batadv_send_skb_to_orig(orig_node, skb, NULL);
out:
- if (neigh_node)
- batadv_neigh_node_free_ref(neigh_node);
- if (ret)
+ if (ret == NET_RX_DROP)
kfree_skb(skb);
return;
}
diff --git a/unicast.c b/unicast.c
index 0016464..5568b69 100644
--- a/unicast.c
+++ b/unicast.c
@@ -295,7 +295,7 @@ int batadv_unicast_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv)
struct batadv_orig_node *orig_node;
struct batadv_neigh_node *neigh_node;
int data_len = skb->len;
- int ret = 1;
+ int ret = NET_RX_DROP;
unsigned int dev_mtu;
/* get routing information */
@@ -356,16 +356,15 @@ find_router:
goto out;
}
- batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
- ret = 0;
- goto out;
+
+ ret = batadv_send_skb_to_orig(orig_node, skb, NULL);
out:
if (neigh_node)
batadv_neigh_node_free_ref(neigh_node);
if (orig_node)
batadv_orig_node_free_ref(orig_node);
- if (ret == 1)
+ if (ret == NET_RX_DROP)
kfree_skb(skb);
return ret;
}
diff --git a/vis.c b/vis.c
index 2a2ea06..a3120e4 100644
--- a/vis.c
+++ b/vis.c
@@ -698,16 +698,13 @@ static void batadv_purge_vis_packets(struct batadv_priv *bat_priv)
static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv,
struct batadv_vis_info *info)
{
- struct batadv_neigh_node *router;
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_node *node;
struct hlist_head *head;
struct batadv_orig_node *orig_node;
struct batadv_vis_packet *packet;
struct sk_buff *skb;
- struct batadv_hard_iface *hard_iface;
- uint8_t dstaddr[ETH_ALEN];
- uint32_t i;
+ uint32_t i, ret;
packet = (struct batadv_vis_packet *)info->skb_packet->data;
@@ -722,30 +719,21 @@ static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv,
if (!(orig_node->flags & BATADV_VIS_SERVER))
continue;
- router = batadv_orig_node_get_router(orig_node);
- if (!router)
- continue;
-
/* don't send it if we already received the packet from
* this node.
*/
if (batadv_recv_list_is_in(bat_priv, &info->recv_list,
- orig_node->orig)) {
- batadv_neigh_node_free_ref(router);
+ orig_node->orig))
continue;
- }
memcpy(packet->target_orig, orig_node->orig, ETH_ALEN);
- hard_iface = router->if_incoming;
- memcpy(dstaddr, router->addr, ETH_ALEN);
-
- batadv_neigh_node_free_ref(router);
-
skb = skb_clone(info->skb_packet, GFP_ATOMIC);
- if (skb)
- batadv_send_skb_packet(skb, hard_iface,
- dstaddr);
+ if (!skb)
+ continue;
+ ret = batadv_send_skb_to_orig(orig_node, skb, NULL);
+ if (ret == NET_RX_DROP)
+ kfree_skb(skb);
}
rcu_read_unlock();
}
@@ -755,7 +743,6 @@ static void batadv_unicast_vis_packet(struct batadv_priv *bat_priv,
struct batadv_vis_info *info)
{
struct batadv_orig_node *orig_node;
- struct batadv_neigh_node *router = NULL;
struct sk_buff *skb;
struct batadv_vis_packet *packet;
@@ -765,17 +752,14 @@ static void batadv_unicast_vis_packet(struct batadv_priv *bat_priv,
if (!orig_node)
goto out;
- router = batadv_orig_node_get_router(orig_node);
- if (!router)
+ skb = skb_clone(info->skb_packet, GFP_ATOMIC);
+ if (!skb)
goto out;
- skb = skb_clone(info->skb_packet, GFP_ATOMIC);
- if (skb)
- batadv_send_skb_packet(skb, router->if_incoming, router->addr);
+ if (batadv_send_skb_to_orig(orig_node, skb, NULL) == NET_RX_DROP)
+ kfree_skb(skb);
out:
- if (router)
- batadv_neigh_node_free_ref(router);
if (orig_node)
batadv_orig_node_free_ref(orig_node);
}
--
1.7.11.1
10 years, 3 months
[B.A.T.M.A.N.] 2012.2 OGMs over ethernet issue?
by Guido Iribarren
Hello again nice folks,
I updated today another segment of the network with just 4 nodes, to
batman-adv 2012.2 (the one i compiled yesterday with simon patches for
blaII, marek stability fixes, and debug log enabled , yikes!)
and i couldn't get batman to work over wired ethernet?? (?)
P -(50mts wlan)- D -----(ubnt transparent bridge) 2km -- C
\----eth-------------------/
Node P and D connected by ethernet on eth0 but close enough that could
also see each other through adhoc wlan, with bla enabled, correctly
preferred ethernet connection to communicate between them (iperf
yielded 92mbps), so far so good.
now, node D and C, too far away from each other to communicate over
wlan, but connected by a "loooong eth cable" (mediated by a wds
transparent bridge) wouldn't find each other batman originator.
C originator table was empty, and D only showed P.
I thought the transparent bridge was misbehaving, so I tried in a
simpler setup using P and D, with the wifi off:
but after disabling wlan0 (batctl if del wlan0-2) and adding eth0
(batctl if add eth0) on both nodes, batman could not see each other
anymore :(
i thought i was doing something wrong, so i tried in different ways,
but could not get it to work.
batctl td eth0 shows both outgoing OGMs from local , and incoming OGMs
from remote,
but batctl l only reported outgoing OGMs.
http://pastebin.com/7DDUaXu1
diego is local node ("D"), palmeras is on the other side of the
ethernet cable ("P") (and jure is further away, connected to palmeras
by adhoc wlan, not illustrated in the previous ascii art)
i hope i'm overlooking something really obvious?
Have a nice weekend!
Gui
10 years, 4 months
[B.A.T.M.A.N.] [PATCH] batman-adv: pass the WIFI flag from the local to global entry
by Antonio Quartulli
in case of client roaming a new global entry is added while a corresponding
local one is still present. In this case the node can safely pass the WIFI flag
from the local to the global entry
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
translation-table.c | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index 37ae4a9..2aacde9 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -500,21 +500,30 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
tt_local_entry->common.addr, message);
}
+static void __batadv_tt_local_remove(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local,
+ const char *message, bool roaming)
+{
+ uint16_t flags;
+
+ flags = BATADV_TT_CLIENT_DEL;
+ if (roaming)
+ flags |= BATADV_TT_CLIENT_ROAM;
+
+ batadv_tt_local_set_pending(bat_priv, tt_local, flags, message);
+}
+
void batadv_tt_local_remove(struct batadv_priv *bat_priv, const uint8_t *addr,
const char *message, bool roaming)
{
struct batadv_tt_local_entry *tt_local_entry = NULL;
- uint16_t flags;
tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
if (!tt_local_entry)
goto out;
- flags = BATADV_TT_CLIENT_DEL;
- if (roaming)
- flags |= BATADV_TT_CLIENT_ROAM;
+ __batadv_tt_local_remove(bat_priv, tt_local_entry, message, roaming);
- batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message);
out:
if (tt_local_entry)
batadv_tt_local_entry_free_ref(tt_local_entry);
@@ -721,9 +730,11 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
uint8_t ttvn)
{
struct batadv_tt_global_entry *tt_global_entry = NULL;
+ struct batadv_tt_local_entry *tt_local_entry = NULL;
int ret = 0;
int hash_added;
struct batadv_tt_common_entry *common;
+ uint16_t wifi_flag;
tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr);
@@ -789,14 +800,23 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
tt_global_entry->common.addr, orig_node->orig);
out_remove:
+ tt_local_entry = batadv_tt_local_hash_find(bat_priv, tt_addr);
+ if (!tt_local_entry)
+ goto out;
+
+ wifi_flag = tt_local_entry->common.flags & BATADV_TT_CLIENT_WIFI;
+ tt_global_entry->common.flags |= wifi_flag;
+
/* remove address from local hash if present */
- batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr,
- "global tt received",
- flags & BATADV_TT_CLIENT_ROAM);
+ __batadv_tt_local_remove(bat_priv, tt_local_entry, "global tt received",
+ flags & BATADV_TT_CLIENT_ROAM);
+
ret = 1;
out:
if (tt_global_entry)
batadv_tt_global_entry_free_ref(tt_global_entry);
+ if (tt_local_entry)
+ batadv_tt_local_entry_free_ref(tt_local_entry);
return ret;
}
--
1.7.9.4
10 years, 5 months
[B.A.T.M.A.N.] [PATCH] batman-adv: use check_unicast_packet() in recv_roam_adv()
by Antonio Quartulli
To avoid code duplication and simplify later changes, check_unicast_packet() is
now used into recv_roam_adv() instead of letting it perform all the checks by
itself
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
routing.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/routing.c b/routing.c
index 939fc01..7ebd922 100644
--- a/routing.c
+++ b/routing.c
@@ -687,21 +687,9 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_roam_adv_packet *roam_adv_packet;
struct batadv_orig_node *orig_node;
- struct ethhdr *ethhdr;
-
- /* drop packet if it has not necessary minimum size */
- if (unlikely(!pskb_may_pull(skb,
- sizeof(struct batadv_roam_adv_packet))))
- goto out;
+ int hdr_size = sizeof(struct batadv_roam_adv_packet);
- ethhdr = (struct ethhdr *)skb_mac_header(skb);
-
- /* packet with unicast indication but broadcast recipient */
- if (is_broadcast_ether_addr(ethhdr->h_dest))
- goto out;
-
- /* packet with broadcast sender address */
- if (is_broadcast_ether_addr(ethhdr->h_source))
+ if (batadv_check_unicast_packet(skb, hdr_size) < 0)
goto out;
batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX);
--
1.7.9.4
10 years, 5 months
[B.A.T.M.A.N.] [PATCH] batctl: tcpdump - print all warnings and errors on stderr
by Marek Lindner
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
---
tcpdump.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/tcpdump.c b/tcpdump.c
index beac2ac..1a4a9a0 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -46,7 +46,7 @@
#define LEN_CHECK(buff_len, check_len, desc) \
if ((size_t)(buff_len) < (check_len)) { \
- printf("Warning - dropping received %s packet as it is smaller than expected (%zu): %zu\n", \
+ fprintf(stderr, "Warning - dropping received %s packet as it is smaller than expected (%zu): %zu\n", \
desc, (check_len), (size_t)(buff_len)); \
return; \
}
@@ -586,7 +586,7 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read
break;
case BATADV_VIS:
if (dump_level & DUMP_TYPE_BATVIS)
- printf("Warning - batman vis packet received: function not implemented yet\n");
+ fprintf(stderr, "Warning - batman vis packet received: function not implemented yet\n");
break;
case BATADV_UNICAST_FRAG:
if (dump_level & DUMP_TYPE_BATFRAG)
@@ -601,14 +601,14 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read
dump_batman_roam(packet_buff, buff_len, read_opt, time_printed);
break;
default:
- printf("Warning - packet contains unknown batman packet type: 0x%02x\n", batman_ogm_packet->header.packet_type);
+ fprintf(stderr, "Warning - packet contains unknown batman packet type: 0x%02x\n", batman_ogm_packet->header.packet_type);
break;
}
break;
default:
- printf("Warning - packet contains unknown ether type: 0x%04x\n", ntohs(eth_hdr->ether_type));
+ fprintf(stderr, "Warning - packet contains unknown ether type: 0x%04x\n", ntohs(eth_hdr->ether_type));
break;
}
}
@@ -747,7 +747,7 @@ int tcpdump(int argc, char **argv)
}
if (argc <= found_args) {
- printf("Error - target interface not specified\n");
+ fprintf(stderr, "Error - target interface not specified\n");
tcpdump_usage();
return EXIT_FAILURE;
}
@@ -767,14 +767,14 @@ int tcpdump(int argc, char **argv)
dump_if->dev = argv[found_args];
if (strlen(dump_if->dev) > IFNAMSIZ - 1) {
- printf("Error - interface name too long: %s\n", dump_if->dev);
+ fprintf(stderr, "Error - interface name too long: %s\n", dump_if->dev);
goto out;
}
dump_if->raw_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (dump_if->raw_sock < 0) {
- printf("Error - can't create raw socket: %s\n", strerror(errno));
+ fprintf(stderr, "Error - can't create raw socket: %s\n", strerror(errno));
goto out;
}
@@ -783,7 +783,7 @@ int tcpdump(int argc, char **argv)
res = ioctl(dump_if->raw_sock, SIOCGIFHWADDR, &req);
if (res < 0) {
- printf("Error - can't create raw socket (SIOCGIFHWADDR): %s\n", strerror(errno));
+ fprintf(stderr, "Error - can't create raw socket (SIOCGIFHWADDR): %s\n", strerror(errno));
close(dump_if->raw_sock);
goto out;
}
@@ -796,7 +796,7 @@ int tcpdump(int argc, char **argv)
case ARPHRD_IEEE80211_RADIOTAP:
break;
default:
- printf("Error - interface '%s' is of unknown type: %i\n", dump_if->dev, dump_if->hw_type);
+ fprintf(stderr, "Error - interface '%s' is of unknown type: %i\n", dump_if->dev, dump_if->hw_type);
goto out;
}
@@ -806,7 +806,7 @@ int tcpdump(int argc, char **argv)
res = ioctl(dump_if->raw_sock, SIOCGIFINDEX, &req);
if (res < 0) {
- printf("Error - can't create raw socket (SIOCGIFINDEX): %s\n", strerror(errno));
+ fprintf(stderr, "Error - can't create raw socket (SIOCGIFINDEX): %s\n", strerror(errno));
close(dump_if->raw_sock);
goto out;
}
@@ -818,7 +818,7 @@ int tcpdump(int argc, char **argv)
res = bind(dump_if->raw_sock, (struct sockaddr *)&dump_if->addr, sizeof(struct sockaddr_ll));
if (res < 0) {
- printf("Error - can't bind raw socket: %s\n", strerror(errno));
+ fprintf(stderr, "Error - can't bind raw socket: %s\n", strerror(errno));
close(dump_if->raw_sock);
goto out;
}
@@ -844,7 +844,7 @@ int tcpdump(int argc, char **argv)
continue;
if (res < 0) {
- printf("Error - can't select on raw socket: %s\n", strerror(errno));
+ fprintf(stderr, "Error - can't select on raw socket: %s\n", strerror(errno));
continue;
}
@@ -855,12 +855,12 @@ int tcpdump(int argc, char **argv)
read_len = read(dump_if->raw_sock, packet_buff, sizeof(packet_buff));
if (read_len < 0) {
- printf("Error - can't read from interface '%s': %s\n", dump_if->dev, strerror(errno));
+ fprintf(stderr, "Error - can't read from interface '%s': %s\n", dump_if->dev, strerror(errno));
continue;
}
if ((size_t)read_len < sizeof(struct ether_header)) {
- printf("Warning - dropping received packet as it is smaller than expected (%zu): %zd\n",
+ fprintf(stderr, "Warning - dropping received packet as it is smaller than expected (%zu): %zd\n",
sizeof(struct ether_header), read_len);
continue;
}
--
1.7.9.1
10 years, 5 months
[B.A.T.M.A.N.] Batman with Ubiquiti SDK
by Mitar
Hi!
Ubiquiti provides OpenWrt based SDK for their firmware. To my
information, it contains some proprietary madwifi-based WiFi drivers
with some older OpenWrt version. My question is how it would be
possible to run Batman on top of their firmware (thus not latest
OpenWrt). As Batman is in kernel, is is enough kernel-backwards
compatible to be able to run also on older (2.6) kernel versions? For
olsrd it is much simpler: you just install olsrd package and this is
it.
Mitar
10 years, 6 months
[B.A.T.M.A.N.] batman majareta? I can batctl ping but not ping
by Guido Iribarren
(which roughly translates as "batman gone nuts?")
Hey great devs!
we've been having a particular issue in deltalibre and quintanalibre
(local WCN) with batman-adv, but so far we haven't found a precise way
to reproduce it.
The symptom is that (after some reboots or physical displacements?)
one batman-adv host becomes unreachable on layer3, although it is seen
on originators table, and can be batctl ping'ed or batctl tracerout'ed
with no problem whatsoever.
Even more, it not unreachable from the whole network, but instead from
just a few other nodes. So, let's say that the nearer nodes can layer3
ping it , but some others farther away cannot (although i can't assure
it depends on the hop distance)
All of them can batctl ping it (layer2)
A hard reboot of all the nodes solves it, connectivity is restored in
all directions.
Thing is, I've just came across it again, and managed to do some tests
to aid in description / debugging
As an aid in understanding network topology,
I'm attaching the wonderful output of "batctl vd dot |grep -v TT" for
your viewing delight
problem node is ana
it can be reached from ruth and hquilla (direct neighbours)
but arping behaves erratically from colmena or charly
and normal ping (v4 or v6) doesn't receive any reply at all when run
from colmena or charly
I used arping, with and without -b , and seemed like i could narrow
the problem down to incoming broadcast packet handling, but further
tests just left me more puzzled!
all nodes are tl-mr3220 running openwrt trunk r31316 with batman-adv
2012.2.0 , driver ath9k
secondary interfaces named _wlan1 are all tl-wn722n which uses driver ath9k_htc
nodes are around 100meters (+/-50mts) apart from each other
this behaviour has been observed (but not reported) in dissimilar
setups, using ubnt bullet2 mixed with mr3220, running r29936 with
batman-adv 2011.4.0 , with nodes 1 or 2km apart from each other.
Tests are the combined crude output of batctl td and arping, so to
make this email ease on the eye, i'm publishing them elsewhere:
http://pastebin.com/6PPwN3PS
The live openwrt configuration can be analysed in detail at
https://bitbucket.org/guidoi/deltalibre-configs/src
(it's a free, open network after all! :D )
in particular:
ana -> https://bitbucket.org/guidoi/deltalibre-configs/src/6de4ce970fe2/mac/54_E...
hquilla -> https://bitbucket.org/guidoi/deltalibre-configs/src/6de4ce970fe2/mac/54_E...
colmena -> https://bitbucket.org/guidoi/deltalibre-configs/src/6de4ce970fe2/mac/54_E...
Thanks a lot for the attention,
Hope that you are having fun, and that I'm not spoiling it :)
Cheers!
Gui
10 years, 6 months
[B.A.T.M.A.N.] Problems to add Batman-adv in wlan0 Nanostation M5
by Esteban Municio
Hi all
I`m working on a academic develop project for improve the networks in
rural areas in Peru. We are doing some test with 6 Nanostation M5 for
create a mesh network.
I tried Commotion software with OLSR and all was Ok. Now, we are
testing BATMAN, with OpenWRT and batman-adv module, but I have some
problems.
I have compiled OpenWrt Backfire r32751 (Load: 0.09 0.10 0.05) and
installed batman-adv with opkg following this
http://wiki.openwrt.org/inbox/mesh.batman
When I put:
lsmod | grep batman
I get
batman_adv 67936 0
and seems to be load in the kernel
But when I try to add the interface wlan0 for activate batman in it,
the Nanostation remains locked and i need to reboot.
I have tried this with:
echo bat0 > /sys/class/net/wlan0/batman_adv/mesh_iface
and
batctl if add wlan0
with the same bad result.
What am i doing wrong?
That are my configuration files:
root@OpenWrt:~# cat /etc/config/network
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option ifname eth0
option type bridge
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0
#config interface wan
# option ifname eth1
# option proto dhcp
config interface wan
option ifname eth1
option proto static
option ipaddr "my ip public for internet access"
option netmask 255.255.255.192
option gateway "my ip public gateway"
option dns 8.8.8.8
----------------------------------------
root@OpenWrt:~# cat /etc/config/wireless
config 'wifi-device' 'radio0'
option 'type' 'mac80211'
option 'macaddr' '00:27:22:52:71:a7'
option 'hwmode' '11na'
option 'htmode' 'HT20'
list 'ht_capab' 'SHORT-GI-40'
list 'ht_capab' 'TX-STBC'
list 'ht_capab' 'RX-STBC1'
list 'ht_capab' 'DSSS_CCK-40'
option 'channel' '161'
option 'txpower' '0'
option 'country' 'US'
config 'wifi-iface'
option 'device' 'radio0'
option 'network' 'lan'
option 'ssid' 'OpenWrt'
option 'encryption' 'none'
option 'mode' 'adhoc'
option 'bssid' '00:27:22:52:71:A7'
---------------------------------------------------
root@OpenWrt:~# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
eth1 no wireless extensions.
br-lan no wireless extensions.
wlan0 IEEE 802.11an ESSID:"OpenWrt"
Mode:Ad-Hoc Frequency:5.805 GHz Cell: 00:27:22:52:71:A7
Tx-Power=3 dBm
RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
-----------------------------------------------------
root@OpenWrt:~# ifconfig
br-lan Link encap:Ethernet HWaddr 00:27:22:53:71:A7
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9489 errors:0 dropped:0 overruns:0 frame:0
TX packets:9584 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:989861 (966.6 KiB) TX bytes:3510637 (3.3 MiB)
eth0 Link encap:Ethernet HWaddr 00:27:22:53:71:A7
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9511 errors:0 dropped:0 overruns:0 frame:0
TX packets:9597 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1124441 (1.0 MiB) TX bytes:3512820 (3.3 MiB)
Interrupt:4
eth1 Link encap:Ethernet HWaddr 00:27:22:53:71:A8
inet addr:"my ip public" Bcast:"my ip broadcast broadcast"
Mask:255.255.255.192
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13086 errors:0 dropped:0 overruns:0 frame:0
TX packets:4552 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4041054 (3.8 MiB) TX bytes:797392 (778.7 KiB)
Interrupt:5
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1556 (1.5 KiB) TX bytes:1556 (1.5 KiB)
wlan0 Link encap:Ethernet HWaddr 00:27:22:52:71:A7
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:0 (0.0 B) TX bytes:1526 (1.4 KiB)
------------------------
I have noticed that i have not the bat0 interface created,is it normal?
Do i need create another aditional interface like ath0?
I have been following that manuals:
http://pizza.hskflashcards.com/index.php?page=B.A.T.M.A.N.+Advanced+on+Op...
http://www.open-mesh.org/projects/batman-adv/wiki/Quick-start-guide
Any help o comment?
Do you recomend me to change to batmand instead?
Do you know if there is any BATMAN implementation for a mesh network
of Nanostation M5, easier to install and manipulate?
Thanks
--
Esteban
10 years, 6 months
[B.A.T.M.A.N.] RFC: Migration to a new git server backend
by Sven Eckelmann
Hi,
maybe some of you have seen that I talked in the channel to Antonio whether we
should migrate to a different solution to serve our git repositories. This is
(in my opinion) a good idea because gitosis [1] (the software that we are
currently using) isn't maintained anymore and will be dropped [2] in the next
version of Debian. My preferred replacement is gitolite [3].
I already talked with Simon and discussed what side effect this could have.
Maybe side effects is not the correct word to describe it... lets call it
options. Gitolite allows to define access rights for refs. For people that are
not familiar with the storage in git: You can for example say that people can
only commit to branches with a specific prefix.
Just to give an example. We want that only the release team can create tags ->
refs/tags/ is only marked for the release team as read-write. Now we have more
interesting features like ordex is only allowed to write in branches starting
with ordex/ -> refs/heads/ordex/ is marked as rw for ordex.
Now the question is: Do we want to use this feature or not. We had following
ideas:
1. 1 repository per project
use only one repo for each project (batman-adv, batctl, batmand, ...) and
use branch namespaces for individual users:
* master, next, maint for the main stuff
* ordex/ (for example ordex/dat), hundeboll/, ... for users
* tags only for release team
2. 2 repositories per project
use one official repo for each project (batman-adv, batctl, batmand, ...)
and one for other people
* master, next, maint in both repos (synced from the main one)
* ordex/ (for example ordex/dat), hundeboll/, ... for users in the second
repo
* tags in both repositories allowed (but in the second repo only with
user prefix)
3. 1+x repositories per project
Keep everything like now
* master, next, maint for the main stuff
* each user has his own copy of the main repo in his user folder
* tags can freely commit in his own repo
Special repositories with big differences like linux-merge are kept in a
special repository.
Any other suggestions? Do you prefer any idea? Please also add other ideas
like "user folder names for idea 3 have to start with a ~ and non-user folder
names have to start with a +".
Kind regards,
Sven
[1] https://github.com/tv42/gitosis
[2] http://packages.qa.debian.org/g/gitosis/news/20110909T215628Z.html
[3] https://github.com/sitaramc/gitolite
10 years, 6 months
[B.A.T.M.A.N.] [PATCH] batman-adv: select an internet gateway if none was chosen
by Marek Lindner
This is a regression introduced by: 6a17ecc4603be7f065c38b288d038a0082bbf21d
Reported-by: Nicolás Echániz <nicoechaniz(a)codigosur.org>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
---
This patch is intended for next and needs to be backported for stable.
gateway_client.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gateway_client.c b/gateway_client.c
index b421cc4..fc866f2 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -200,11 +200,11 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT)
goto out;
- if (!batadv_atomic_dec_not_zero(&bat_priv->gw_reselect))
- goto out;
-
curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
+ if (!batadv_atomic_dec_not_zero(&bat_priv->gw_reselect) && curr_gw)
+ goto out;
+
next_gw = batadv_gw_get_best_gw_node(bat_priv);
if (curr_gw == next_gw)
--
1.7.9.1
10 years, 6 months