[B.A.T.M.A.N.] batman-adv: added uevent support for gw and gw propagation for clients
by Antonio Quartulli
Three new features have been added:
1) generic uevent support
2) uevent triggering for gw state changes
3) gw propagation for clients
Patch summary:
- 1/3: a wrapper function that permits to trigger uevents has been added.
The function takes a "type", an "action" and a "data" as parameters which
will be used as uevent attributes. In particular they will respectively be
BATTYPE, BATACTION and BATDATA in the uevent environment.
The "type" and the "action" field are managed using two enum definitions and
two char arrais. Currently the supported "type" is 'gw' only and the supported
"actions" are 'add', 'change' and 'del'. The "data" parameter is a free field
which can be filled by the programmer to send any useful data to the userspace.
Uevents can be seen in userspace with the following command:
"$ udevadm monitor --property"
- 2/3: on a gateway add/change/del event a corresponding uevent of type 'gw' is
triggered. In particular, in case of setting up a gw for the first time a
uevent with action 'add' is triggered. In case of changing the best gateway a
uevent with action 'change' is triggered. In case of deselection of any gateway
a uevent with action DEL is triggered.
- 3/3: a gw propagation feature for clients has been provided. The main target
of this patch is to make clients able to change L3 gateway as soon as the mesh
node currently serving them changes its default one at the batman layer.
For this target a passive approach has been followed: whenever a unicast
DHCPREQUEST for renewal is sent from a client, the node will inspect it and
check if it is directed to the current default gateway or not. If it is not
the case then the packet is dropped. In this way the client will get a
timeout and a new DHCPREQUEST for discover will be sent giving the possibility
to the node to select the best gw to forward this packet to (current gw
selection mode).
11 years, 8 months
[B.A.T.M.A.N.] [PATCH] batman-adv: modify TT_RESPONSE-full-table format
by Antonio Quartulli
In case of TT_REQUEST for a full table, the related TT_RESPONSE now
carries a set of tt_change structures instead of pure MACs.
This helps to keep the TT_RESPONSE format extensible. In particular, the
flag field can be used for later purposes.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
translation-table.c | 99 +++++++++++++++++++++++++--------------------------
1 files changed, 49 insertions(+), 50 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index f04ab9b..3f30460 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -1012,6 +1012,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
struct neigh_node *neigh_node = NULL;
struct hard_iface *primary_if = NULL;
struct tt_global_entry *tt_global_entry;
+ struct tt_change *tt_change;
struct hlist_node *node;
struct hlist_head *head;
struct hashtable_t *hash;
@@ -1086,14 +1087,14 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
spin_unlock_bh(&req_dst_orig_node->tt_buff_lock);
} else {
tt_len = (uint16_t)atomic_read(&req_dst_orig_node->tt_size) *
- ETH_ALEN;
+ sizeof(struct tt_change);
if (sizeof(struct tt_query_packet) + tt_len >
primary_if->soft_iface->mtu) {
tt_len = primary_if->soft_iface->mtu -
sizeof(struct tt_query_packet);
- tt_len -= tt_len % ETH_ALEN;
+ tt_len -= tt_len % sizeof(struct tt_change);
}
- tt_tot = tt_len / ETH_ALEN;
+ tt_tot = tt_len / sizeof(struct tt_change);
skb = dev_alloc_skb(sizeof(struct tt_query_packet) +
tt_len + ETH_HLEN);
@@ -1106,7 +1107,8 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
tt_response->ttvn = (uint8_t)
atomic_read(&req_dst_orig_node->last_ttvn);
- tt_buff = skb->data + sizeof(struct tt_query_packet);
+ tt_change = (struct tt_change *)(skb->data +
+ sizeof(struct tt_query_packet));
/* Fill the packet with the orig_node's local table */
hash = bat_priv->tt_global_hash;
tt_count = 0;
@@ -1120,10 +1122,13 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
break;
if (tt_global_entry->orig_node ==
req_dst_orig_node) {
- memcpy(tt_buff + tt_count * ETH_ALEN,
+ memcpy(tt_change->addr,
tt_global_entry->addr,
ETH_ALEN);
+ tt_change->flags = TT_CHANGE_ADD;
+
tt_count++;
+ tt_change++;
}
}
}
@@ -1173,6 +1178,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
struct orig_node *orig_node = NULL;
struct neigh_node *neigh_node = NULL;
struct tt_local_entry *tt_local_entry;
+ struct tt_change *tt_change;
struct hard_iface *primary_if = NULL;
struct hlist_node *node;
struct hlist_head *head;
@@ -1238,14 +1244,14 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
spin_unlock_bh(&bat_priv->tt_buff_lock);
} else {
tt_len = (uint16_t)atomic_read(&bat_priv->num_local_tt) *
- ETH_ALEN;
+ sizeof(struct tt_change);
if (sizeof(struct tt_query_packet) + tt_len >
primary_if->soft_iface->mtu) {
tt_len = primary_if->soft_iface->mtu -
sizeof(struct tt_query_packet);
- tt_len -= tt_len % ETH_ALEN;
+ tt_len -= tt_len % sizeof(struct tt_change);
}
- tt_tot = tt_len / ETH_ALEN;
+ tt_tot = tt_len / sizeof(struct tt_change);
skb = dev_alloc_skb(sizeof(struct tt_query_packet) +
tt_len + ETH_HLEN);
@@ -1255,7 +1261,8 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
skb_reserve(skb, ETH_HLEN);
tt_response = (struct tt_query_packet *)skb_put(skb,
sizeof(struct tt_query_packet) + tt_len);
- tt_buff = skb->data + sizeof(struct tt_query_packet);
+ tt_change = (struct tt_change *)(skb->data +
+ sizeof(struct tt_query_packet));
/* Fill the packet with the local table */
tt_response->ttvn =
(uint8_t)atomic_read(&bat_priv->ttvn);
@@ -1270,10 +1277,12 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
head, hash_entry) {
if (tt_count == tt_tot)
break;
- memcpy(tt_buff + tt_count * ETH_ALEN,
- tt_local_entry->addr,
- ETH_ALEN);
+ memcpy(tt_change->addr, tt_local_entry->addr,
+ ETH_ALEN);
+ tt_change->flags = TT_CHANGE_ADD;
+
tt_count++;
+ tt_change++;
}
}
rcu_read_unlock();
@@ -1323,23 +1332,30 @@ bool send_tt_response(struct bat_priv *bat_priv,
return send_other_tt_response(bat_priv, tt_request);
}
-/* Substitute the TT response source's table with the newone carried by the
- * packet */
-static void _tt_fill_gtable(struct bat_priv *bat_priv,
- struct orig_node *orig_node, unsigned char *tt_buff,
- uint16_t table_size, uint8_t ttvn)
+static void _tt_update_changes(struct bat_priv *bat_priv,
+ struct orig_node *orig_node,
+ struct tt_change *tt_change,
+ uint16_t tt_num_changes, uint8_t ttvn)
{
- int count;
- unsigned char *tt_ptr;
-
- for (count = 0; count < table_size; count++) {
- tt_ptr = tt_buff + (count * ETH_ALEN);
+ int i;
- /* If we fail to allocate a new entry we return immediatly */
- if (!tt_global_add(bat_priv, orig_node, tt_ptr, ttvn, false))
- return;
+ for (i = 0; i < tt_num_changes; i++) {
+ if ((tt_change + i)->flags & TT_CHANGE_DEL)
+ tt_global_del(bat_priv, orig_node,
+ (tt_change + i)->addr,
+ "tt removed by changes",
+ (tt_change + i)->flags & TT_CHANGE_ROAM);
+ else
+ if (!tt_global_add(bat_priv, orig_node,
+ (tt_change + i)->addr, ttvn, false))
+ /* In case of problem while storing a
+ * global_entry, we stop the updating
+ * procedure without committing the
+ * ttvn change. This will avoid to send
+ * corrupted data on tt_request
+ */
+ return;
}
- atomic_set(&orig_node->last_ttvn, ttvn);
}
static void tt_fill_gtable(struct bat_priv *bat_priv,
@@ -1354,11 +1370,9 @@ static void tt_fill_gtable(struct bat_priv *bat_priv,
/* Purge the old table first.. */
tt_global_del_orig(bat_priv, orig_node, "Received full table");
- _tt_fill_gtable(bat_priv, orig_node,
- ((unsigned char *)tt_response) +
- sizeof(struct tt_query_packet),
- tt_response->tt_data,
- tt_response->ttvn);
+ _tt_update_changes(bat_priv, orig_node,
+ (struct tt_change *)(tt_response + 1),
+ tt_response->tt_data, tt_response->ttvn);
spin_lock_bh(&orig_node->tt_buff_lock);
kfree(orig_node->tt_buff);
@@ -1366,6 +1380,8 @@ static void tt_fill_gtable(struct bat_priv *bat_priv,
orig_node->tt_buff = NULL;
spin_unlock_bh(&orig_node->tt_buff_lock);
+ atomic_set(&orig_node->last_ttvn, tt_response->ttvn);
+
out:
if (orig_node)
orig_node_free_ref(orig_node);
@@ -1375,25 +1391,8 @@ void tt_update_changes(struct bat_priv *bat_priv, struct orig_node *orig_node,
uint16_t tt_num_changes, uint8_t ttvn,
struct tt_change *tt_change)
{
- int i;
-
- for (i = 0; i < tt_num_changes; i++) {
- if ((tt_change + i)->flags & TT_CHANGE_DEL)
- tt_global_del(bat_priv, orig_node,
- (tt_change + i)->addr,
- "tt removed by changes",
- (tt_change + i)->flags & TT_CHANGE_ROAM);
- else
- if (!tt_global_add(bat_priv, orig_node,
- (tt_change + i)->addr, ttvn, false))
- /* In case of problem while storing a
- * global_entry, we stop the updating
- * procedure without committing the
- * ttvn change. This will avoid to send
- * corrupted data on tt_request
- */
- return;
- }
+ _tt_update_changes(bat_priv, orig_node, tt_change, tt_num_changes,
+ ttvn);
tt_save_orig_buffer(bat_priv, orig_node, (unsigned char *)tt_change,
tt_num_changes);
--
1.7.3.4
11 years, 8 months
[B.A.T.M.A.N.] batman-adv 2011-05-30
by Sven Eckelmann
Hi,
I would like to propose following patches for net-next-2.6/3.1 [1]. It
is not really based on your net-next-2.6 tree, but directly on v3.0-rc1.
I hope that this is ok - thought that you will merge that version
anyway. Just wanted to get these patches out before doing the really
work (reducing the amount of patches you get in a single pull request).
Most patches are only cleanup patches - nothing really interesting.
Antonio also moved the protocol specific seq_before/seq_after function
to main.h like you told us [2]. Now he can use it in his translation
table query patches (they are still moving, so he needs to hunt them
down before I can submit them).
thanks,
Sven
[1] wow, that sounds creepy
[2] https://lkml.org/lkml/2011/5/19/88
The following changes since commit 55922c9d1b84b89cb946c777fddccb3247e7df2c:
Linux 3.0-rc1 (2011-05-29 17:43:36 -0700)
are available in the git repository at:
git://git.open-mesh.org/ecsv/linux-merge.git batman-adv/next
Antonio Quartulli (4):
batman-adv: move neigh_node->if_incoming->if_status check in find_router()
batman-adv: move smallest_signed_int(), seq_before() and seq_after() into main.h
batman-adv: use is_broadcast_ether_addr() instead of compare_eth(.., brd_addr)
batman-adv: a multiline comment should precede the variable it is describing
Sven Eckelmann (13):
batman-adv: Use kzalloc rather than kmalloc followed by memset with 0
batman-adv: Annotate functions with format strings
batman-adv: Print jiffies as unsigned long
batman-adv: Remove comparising < 0 for unsigned type
batman-adv: Don't do pointer arithmetic with void*
batman-adv: Add const type qualifier for pointers
batman-adv: Only use int up and down gw representation
batman-adv: Remove explicit casts cast from void* for store
batman-adv: Remove casts from type x to type x
batman-adv: Calculate sizeof using variable insead of types
batman-adv: Use rcu_dereference_protected by update-side
batman-adv: Check type of x and y in seq_(before|after)
batman-adv: Ensure that we really have route changes in update_route
net/batman-adv/aggregation.c | 23 +++++----
net/batman-adv/aggregation.h | 5 +-
net/batman-adv/bat_debugfs.c | 11 ++--
net/batman-adv/bat_sysfs.c | 15 +++---
net/batman-adv/bitarray.c | 6 +-
net/batman-adv/bitarray.h | 6 +-
net/batman-adv/gateway_client.c | 19 ++++----
net/batman-adv/gateway_common.c | 19 ++++----
net/batman-adv/hard-interface.c | 25 +++++-----
net/batman-adv/hard-interface.h | 6 ++-
net/batman-adv/hash.c | 7 ++-
net/batman-adv/hash.h | 6 +-
net/batman-adv/icmp_socket.c | 4 +-
net/batman-adv/main.c | 4 +-
net/batman-adv/main.h | 30 ++++++++++--
net/batman-adv/originator.c | 12 ++--
net/batman-adv/originator.h | 14 +++---
net/batman-adv/ring_buffer.c | 4 +-
net/batman-adv/ring_buffer.h | 2 +-
net/batman-adv/routing.c | 54 +++++++++++-----------
net/batman-adv/routing.h | 12 ++--
net/batman-adv/send.c | 44 +++++++++---------
net/batman-adv/send.h | 12 ++--
net/batman-adv/soft-interface.c | 22 ++++-----
net/batman-adv/soft-interface.h | 4 +-
net/batman-adv/translation-table.c | 44 +++++++++--------
net/batman-adv/translation-table.h | 13 +++--
net/batman-adv/types.h | 8 ++--
net/batman-adv/unicast.c | 30 +++++-------
net/batman-adv/unicast.h | 8 ++--
net/batman-adv/vis.c | 91 +++++++++++++++---------------------
31 files changed, 284 insertions(+), 276 deletions(-)
11 years, 8 months
[B.A.T.M.A.N.] [PATCH] batctl: added loglevel support for DBG_TT
by Antonio Quartulli
DBG_TT log level has been added to batman-adv to collect all the
messages related to Translation Table operations. This patch makes batctl
able to select such level.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
Patch "batman-adv: improved client announcement mechanism" introduces a new log
"channel" called DBG_TT. This patch makes batctl able to correctly handle it
sys.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/sys.c b/sys.c
index f8fa1f2..dbf5383 100644
--- a/sys.c
+++ b/sys.c
@@ -182,6 +182,7 @@ static void log_level_usage(void)
int handle_loglevel(char *mesh_iface, int argc, char **argv)
{
int optchar, res;
+ int log_level;
char *path_buff;
while ((optchar = getopt(argc, argv, "h")) != -1) {
@@ -208,14 +209,16 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv)
if (res != EXIT_SUCCESS)
goto out;
- printf("[%c] %s (%d)\n", (line_ptr[0] == '0') ? 'x' : ' ',
+ log_level = strtol(line_ptr, (char **) NULL, 10);
+
+ printf("[%c] %s (%d)\n", (!log_level) ? 'x' : ' ',
"all debug output disabled", 0);
- printf("[%c] %s (%d)\n", (line_ptr[0] == '1') ? 'x' : ' ',
+ printf("[%c] %s (%d)\n", (log_level & 1) ? 'x' : ' ',
"messages related to routing / flooding / broadcasting", 1);
- printf("[%c] %s (%d)\n", (line_ptr[0] == '2') ? 'x' : ' ',
- "messages related to route or tt entry added / changed / deleted", 2);
- printf("[%c] %s (%d)\n", (line_ptr[0] == '3') ? 'x' : ' ',
- "all debug messages", 3);
+ printf("[%c] %s (%d)\n", (log_level & 2) ? 'x' : ' ',
+ "messages related to route added / changed / deleted", 2);
+ printf("[%c] %s (%d)\n", (log_level & 4) ? 'x' : ' ',
+ "messages related to translation table operations", 4);
out:
if (errno == ENOENT)
--
1.7.3.4
11 years, 8 months
[B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - add support for tt request / roaming advertisement packets
by Marek Lindner
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
---
tcpdump.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
tcpdump.h | 3 +-
2 files changed, 78 insertions(+), 16 deletions(-)
diff --git a/tcpdump.c b/tcpdump.c
index a715e27..6f1adc1 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -52,7 +52,7 @@ if ((size_t)(buff_len) < (check_len)) { \
}
static unsigned short dump_level = DUMP_TYPE_BATOGM | DUMP_TYPE_BATICMP | DUMP_TYPE_BATUCAST |
- DUMP_TYPE_BATBCAST | DUMP_TYPE_BATVIS | DUMP_TYPE_BATFRAG | DUMP_TYPE_NONBAT;
+ DUMP_TYPE_BATBCAST | DUMP_TYPE_BATVIS | DUMP_TYPE_BATFRAG | DUMP_TYPE_BATTT | DUMP_TYPE_NONBAT;
static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed);
@@ -63,14 +63,15 @@ static void tcpdump_usage(void)
printf(" \t -h print this help\n");
printf(" \t -n don't convert addresses to bat-host names\n");
printf(" \t -p dump specific packet type\n");
- printf(" \t\t%d - batman ogm packets\n", DUMP_TYPE_BATOGM);
- printf(" \t\t%d - batman icmp packets\n", DUMP_TYPE_BATICMP);
- printf(" \t\t%d - batman unicast packets\n", DUMP_TYPE_BATUCAST);
- printf(" \t\t%d - batman broadcast packets\n", DUMP_TYPE_BATBCAST);
- printf(" \t\t%d - batman vis packets\n", DUMP_TYPE_BATVIS);
- printf(" \t\t%d - batman fragmented packets\n", DUMP_TYPE_BATFRAG);
- printf(" \t\t%d - non batman packets\n", DUMP_TYPE_NONBAT);
- printf(" \t\t%d - batman ogm & non batman packets\n", DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
+ printf(" \t\t%3d - batman ogm packets\n", DUMP_TYPE_BATOGM);
+ printf(" \t\t%3d - batman icmp packets\n", DUMP_TYPE_BATICMP);
+ printf(" \t\t%3d - batman unicast packets\n", DUMP_TYPE_BATUCAST);
+ printf(" \t\t%3d - batman broadcast packets\n", DUMP_TYPE_BATBCAST);
+ printf(" \t\t%3d - batman vis packets\n", DUMP_TYPE_BATVIS);
+ printf(" \t\t%3d - batman fragmented packets\n", DUMP_TYPE_BATFRAG);
+ printf(" \t\t%3d - batman tt / roaming packets\n", DUMP_TYPE_BATTT);
+ printf(" \t\t%3d - non batman packets\n", DUMP_TYPE_NONBAT);
+ printf(" \t\t%3d - batman ogm & non batman packets\n", DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
}
static int print_time(void)
@@ -247,6 +248,58 @@ static void dump_vlan(unsigned char *packet_buff, ssize_t buff_len, int read_opt
parse_eth_hdr(packet_buff + 4, buff_len - 4, read_opt, time_printed);
}
+static void dump_batman_tt(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
+{
+ struct ether_header *ether_header;
+ struct tt_query_packet *tt_query_packet;
+
+ LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct tt_query_packet), "BAT TT");
+
+ ether_header = (struct ether_header *)packet_buff;
+ tt_query_packet = (struct tt_query_packet *)(packet_buff + sizeof(struct ether_header));
+
+ if (!time_printed)
+ print_time();
+
+ printf("BAT %s > ",
+ get_name_by_macaddr((struct ether_addr *)tt_query_packet->src, read_opt));
+
+ printf("%s: TT %s, ttvn %d, %s %d, ttl %2d, v %d, flags [%c%c%c], length %zu\n",
+ get_name_by_macaddr((struct ether_addr *)tt_query_packet->dst, read_opt),
+ tt_query_packet->flags & TT_RESPONSE ? "response" : "request",
+ tt_query_packet->ttvn, tt_query_packet->flags & TT_RESPONSE ? "entries" : "crc",
+ ntohs(tt_query_packet->tt_data), tt_query_packet->ttl, tt_query_packet->version,
+ (tt_query_packet->flags & TT_REQUEST ? 'Q' : '.'),
+ (tt_query_packet->flags & TT_RESPONSE ? 'P' : '.'),
+ (tt_query_packet->flags & TT_FULL_TABLE ? 'F' : '.'),
+ (size_t)buff_len - sizeof(struct ether_header));
+}
+
+static void dump_batman_roam(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
+{
+ struct ether_header *ether_header;
+ struct roam_adv_packet *roam_adv_packet;
+
+ LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct roam_adv_packet), "BAT ROAM");
+
+ ether_header = (struct ether_header *)packet_buff;
+ roam_adv_packet = (struct roam_adv_packet *)(packet_buff + sizeof(struct ether_header));
+
+ if (!time_printed)
+ print_time();
+
+ printf("BAT %s > ",
+ get_name_by_macaddr((struct ether_addr *)roam_adv_packet->src, read_opt));
+
+ printf("%s: ROAM, ",
+ get_name_by_macaddr((struct ether_addr *)roam_adv_packet->dst, read_opt));
+
+ printf("client %s, ttl %2d, v %d, length %zu\n",
+ get_name_by_macaddr((struct ether_addr *)roam_adv_packet->client, read_opt),
+ roam_adv_packet->ttl, roam_adv_packet->version,
+ (size_t)buff_len - sizeof(struct ether_header));
+}
+
static void dump_batman_ogm(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
{
struct ether_header *ether_header;
@@ -263,9 +316,9 @@ static void dump_batman_ogm(unsigned char *packet_buff, ssize_t buff_len, int re
printf("BAT %s: ",
get_name_by_macaddr((struct ether_addr *)batman_packet->orig, read_opt));
- printf("OGM via neigh %s, seq %u, tq %3d, ttl %2d, v %d, flags [%c%c%c%c], length %zu\n",
+ printf("OGM via neigh %s, seq %u, tq %3d, ttvn %d, ttl %2d, v %d, flags [%c%c%c%c], length %zu\n",
get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt),
- ntohl(batman_packet->seqno), batman_packet->tq,
+ ntohl(batman_packet->seqno), batman_packet->tq, batman_packet->ttvn,
batman_packet->ttl, batman_packet->version,
(batman_packet->flags & DIRECTLINK ? 'D' : '.'),
(batman_packet->flags & VIS_SERVER ? 'V' : '.'),
@@ -334,9 +387,9 @@ static void dump_batman_ucast(unsigned char *packet_buff, ssize_t buff_len, int
printf("BAT %s > ",
get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt));
- printf("%s: UCAST, ttl %hhu, ",
+ printf("%s: UCAST, ttvn %d, ttl %hhu, ",
get_name_by_macaddr((struct ether_addr *)unicast_packet->dest, read_opt),
- unicast_packet->ttl);
+ unicast_packet->ttvn, unicast_packet->ttl);
parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct unicast_packet),
buff_len - ETH_HLEN - sizeof(struct unicast_packet),
@@ -385,9 +438,9 @@ static void dump_batman_frag(unsigned char *packet_buff, ssize_t buff_len, int r
printf("BAT %s > ",
get_name_by_macaddr((struct ether_addr *)unicast_frag_packet->orig, read_opt));
- printf("%s: FRAG, seq %hu, ttl %hhu, flags [%c%c], ",
+ printf("%s: FRAG, seq %hu, ttvn %d, ttl %hhu, flags [%c%c], ",
get_name_by_macaddr((struct ether_addr *)unicast_frag_packet->dest, read_opt),
- ntohs(unicast_frag_packet->seqno), unicast_frag_packet->ttl,
+ ntohs(unicast_frag_packet->seqno), unicast_frag_packet->ttvn, unicast_frag_packet->ttl,
(unicast_frag_packet->flags & UNI_FRAG_HEAD ? 'H' : '.'),
(unicast_frag_packet->flags & UNI_FRAG_LARGETAIL ? 'L' : '.'));
@@ -447,6 +500,14 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read
if (dump_level & DUMP_TYPE_BATFRAG)
dump_batman_frag(packet_buff, buff_len, read_opt, time_printed);
break;
+ case BAT_TT_QUERY:
+ if (dump_level & DUMP_TYPE_BATTT)
+ dump_batman_tt(packet_buff, buff_len, read_opt, time_printed);
+ break;
+ case BAT_ROAM_ADV:
+ if (dump_level & DUMP_TYPE_BATTT)
+ 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_packet->packet_type);
break;
diff --git a/tcpdump.h b/tcpdump.h
index 4364be1..925b116 100644
--- a/tcpdump.h
+++ b/tcpdump.h
@@ -37,7 +37,8 @@
#define DUMP_TYPE_BATBCAST 8
#define DUMP_TYPE_BATVIS 16
#define DUMP_TYPE_BATFRAG 32
-#define DUMP_TYPE_NONBAT 64
+#define DUMP_TYPE_BATTT 64
+#define DUMP_TYPE_NONBAT 128
#define IEEE80211_FCTL_FTYPE 0x0c00
#define IEEE80211_FCTL_TODS 0x0001
--
1.7.2.3
11 years, 8 months
[B.A.T.M.A.N.] [PATCH] batman-adv: send_*_tt_response() has to initialise the ttl field
by Antonio Quartulli
send_*_tt_response() didn't properly initialise the ttl field of the
tt_response message.
This error was introduced with: cea194d90b11aff7fc289149e4c7f305fad3535a
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
translation-table.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index f0d8857..f04ab9b 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -1132,6 +1132,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
tt_response->packet_type = BAT_TT_QUERY;
tt_response->version = COMPAT_VERSION;
+ tt_response->ttl = TTL;
memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN);
memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
tt_response->tt_data = htons(tt_tot);
@@ -1280,6 +1281,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
tt_response->packet_type = BAT_TT_QUERY;
tt_response->version = COMPAT_VERSION;
+ tt_response->ttl = TTL;
memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN);
memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
tt_response->tt_data = htons(tt_tot);
--
1.7.3.4
11 years, 8 months
[B.A.T.M.A.N.] [PATCH] batman-adv: correct kobject_set_name() arguments
by Antonio Quartulli
Compiling against kernel version <2.6.25 was failing due to wrong
parameters.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
compat.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/compat.h b/compat.h
index 6842a26..0f0e66e 100644
--- a/compat.h
+++ b/compat.h
@@ -131,7 +131,7 @@ static inline struct kobject *kobject_create_and_add(const char *name,
if (!kobj)
return NULL;
- kobject_set_name(kobj, name);
+ kobject_set_name(kobj, "%s", name);
kobj->ktype = &ktype_bat_wrapper;
kobj->kset = NULL;
kobj->parent = parent;
--
1.7.3.4
11 years, 8 months
[B.A.T.M.A.N.] [PATCH] batman-adv: correct !x & y in !(x & y)
by Antonio Quartulli
This error was introduced with: 4dea0274b8edeab50bfeb6685ef33362e3ec9299
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
This error has been found using sparse
translation-table.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index 464569e..f0d8857 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -724,7 +724,7 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv)
spin_lock_bh(list_lock);
hlist_for_each_entry_safe(tt_global_entry, node, node_tmp,
head, hash_entry) {
- if (!tt_global_entry->flags & TT_GLOBAL_ROAM)
+ if (!(tt_global_entry->flags & TT_GLOBAL_ROAM))
continue;
if (!is_out_of_time(tt_global_entry->roam_at,
TT_GLOBAL_ROAM_TIMEOUT * 1000))
--
1.7.3.4
11 years, 8 months
[B.A.T.M.A.N.] [PATCH] New translation table announcement mechanism patchset
by Antonio Quartulli
This patchset wants to introduce a new client announcement mechanism (previously
called HNA) which totally revises the old one.
B.A.T.M.A.N.-advanced manages clients by the means of two translation tables:
a local table and a global table. The first one stores all the clients directly
connected to the node itself while the second one stores all the clients which
are announced by other nodes in the mesh network.
In the current implementation the whole local table is sent within each OGM
causing a big protocol overhead.
The core of the new implementation, instead, consists in avoiding this part
and replace this procedure by sending only the local table _changes_ which
happened in the last OGM interval. In this way, every node will update its
global table applying the changes it finds in the OGM.
A roaming improvement is also provided exploiting the newly implemented
announcement mechanism.
Moreover the global and local translation table are now lock free and rcu
protected :-)
Patchset description:
1) Rename all the variables/functions/constants from *hna* to *tt*
2) Implement the new announcement mechanism
3) Implement the roaming optimisation
4) Protect by RCU the local and global table
** Patch 2/4 also introduces a dependency on the crc16 module since the new
mechanism uses the crc16 computation function provided by this module. **
For more details, please refer to the commit message of each patch.
Regards,
Antonio Quartulli
11 years, 8 months
[B.A.T.M.A.N.] [PATCH] batman-adv: move the ttl field to the third position of unicast_* packets
by Antonio Quartulli
Move the ttl field to the third position of unicast_packet and
unicast_frag_packet. In this way it possible to give them a better shape for
later usage
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
packet.h | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/packet.h b/packet.h
index eda9965..e464ceb 100644
--- a/packet.h
+++ b/packet.h
@@ -32,7 +32,7 @@
#define BAT_UNICAST_FRAG 0x06
/* this file is included by batctl which needs these defines */
-#define COMPAT_VERSION 12
+#define COMPAT_VERSION 14
#define DIRECTLINK 0x40
#define VIS_SERVER 0x20
#define PRIMARIES_FIRST_HOP 0x10
@@ -99,16 +99,19 @@ struct icmp_packet_rr {
struct unicast_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
- uint8_t dest[6];
uint8_t ttl;
+ uint8_t align;
+ uint8_t dest[6];
} __packed;
struct unicast_frag_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
- uint8_t dest[6];
uint8_t ttl;
+ uint8_t align;
+ uint8_t dest[6];
uint8_t flags;
+ uint8_t align;
uint8_t orig[6];
uint16_t seqno;
} __packed;
--
1.7.3.4
11 years, 8 months