[batctl] master: batctl: add support for the DAT local table (167c37a)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : master
>---------------------------------------------------------------
commit 167c37add861a1f7c1641df078e0cdbf32556945
Author: Antonio Quartulli <ordex(a)autistici.org>
Date: Sun Oct 14 16:54:31 2012 +0200
batctl: add support for the DAT local table
With the introduction of DAT in batman-adv, another table is now exported
through debugfs. This patch adds the possibility to print it
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
>---------------------------------------------------------------
167c37add861a1f7c1641df078e0cdbf32556945
README | 18 ++++++++++++++++++
debug.c | 5 +++++
debug.h | 1 +
functions.c | 1 +
man/batctl.8 | 3 +++
5 files changed, 28 insertions(+)
diff --git a/README b/README
index 03d36c4..5e58452 100644
--- a/README
+++ b/README
@@ -408,6 +408,24 @@ where:
If any of the flags is not enabled, a '.' will substitute its symbol.
+batctl dat_cache
+=================
+
+display the local D.A.T. cache
+
+Usage batctl dat_cache|dc
+
+Example:
+
+Distributed ARP Table (bat0):
+ IPv4 MAC last-seen
+ * 172.100.0.1 b6:9b:d0:ea:b1:13 0:00
+
+where:
+- IPv4 is the IP address of a client in the mesh network
+- MAC is the MAC address associated to that IP
+- last-seen is the amount of time since last refresh of this entry
+
batctl vis_mode
=================
diff --git a/debug.c b/debug.c
index 9b5146f..a230a12 100644
--- a/debug.c
+++ b/debug.c
@@ -64,6 +64,11 @@ const struct debug_table_data batctl_debug_tables[BATCTL_TABLE_NUM] = {
.opt_short = "bbt",
.debugfs_name = "bla_backbone_table",
},
+ {
+ .opt_long = "dat_cache",
+ .opt_short = "dc",
+ .debugfs_name = "dat_cache",
+ },
};
void debug_table_usage(int debug_table)
diff --git a/debug.h b/debug.h
index 6068c2c..4e935cb 100644
--- a/debug.h
+++ b/debug.h
@@ -31,6 +31,7 @@ enum batctl_debug_tables {
BATCTL_TABLE_TRANSGLOBAL,
BATCTL_TABLE_BLA_CLAIMS,
BATCTL_TABLE_BLA_BACKBONES,
+ BATCTL_TABLE_DAT,
BATCTL_TABLE_NUM,
};
diff --git a/functions.c b/functions.c
index e095fd0..0d88137 100644
--- a/functions.c
+++ b/functions.c
@@ -48,6 +48,7 @@ const char *fs_compile_out_param[] = {
batctl_settings[BATCTL_SETTINGS_BLA].sysfs_name,
batctl_debug_tables[BATCTL_TABLE_BLA_CLAIMS].debugfs_name,
batctl_debug_tables[BATCTL_TABLE_BLA_BACKBONES].debugfs_name,
+ batctl_debug_tables[BATCTL_TABLE_DAT].debugfs_name,
NULL,
};
diff --git a/man/batctl.8 b/man/batctl.8
index ab02e9a..310b43f 100644
--- a/man/batctl.8
+++ b/man/batctl.8
@@ -187,6 +187,9 @@ List of debug tables:
.RS 10
\- backbonetable|bbt (compile time option)
.RE
+.RS 10
+\- datcache|dc (compile time option)
+.RE
.RE
.br
.IP "\fBstatistics\fP|\fBs\fP"
8 years, 3 months
[batman-adv] master: batman-adv: fix DAT packet counting (2b105ca)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 2b105ca9d1ec396aa8bbdcc472d89fdc9563ca62
Author: Antonio Quartulli <ordex(a)autistici.org>
Date: Tue Oct 9 15:00:11 2012 +0200
batman-adv: fix DAT packet counting
DAT packets must be counted before any batadv_dat_snoop_incoming_* invocation
otherwise the counters may not be incremented at all
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
>---------------------------------------------------------------
2b105ca9d1ec396aa8bbdcc472d89fdc9563ca62
routing.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/routing.c b/routing.c
index e146370..96375c5 100644
--- a/routing.c
+++ b/routing.c
@@ -1061,6 +1061,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
/* packet for me */
if (batadv_is_my_mac(unicast_packet->dest)) {
+ if (is4addr)
+ batadv_dat_inc_counter(bat_priv,
+ unicast_4addr_packet->subtype);
+
if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb,
hdr_size))
goto rx_success;
@@ -1068,10 +1072,6 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
hdr_size))
goto rx_success;
- if (is4addr)
- batadv_dat_inc_counter(bat_priv,
- unicast_4addr_packet->subtype);
-
batadv_interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size,
NULL);
8 years, 3 months
[batman-adv] master: batman-adv: Mark best gateway in transtable_global debugfs (1421221)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 14212216617f1b00a248b472d8b7d0ea9ff8e2a8
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sun Oct 7 13:34:15 2012 +0200
batman-adv: Mark best gateway in transtable_global debugfs
The transtable_global debug file can show multiple entries for a single client
when multiple gateways exist. The chosen gateway isn't marked in the list and
therefore the user cannot easily debug the situation when there is a problem
with the currently used gateway.
The best gateway is now marked with "*" and secondary gateways are marked with
"+".
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
>---------------------------------------------------------------
14212216617f1b00a248b472d8b7d0ea9ff8e2a8
translation-table.c | 90 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 64 insertions(+), 26 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index 41613b7..d3d6f72 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -912,8 +912,44 @@ out:
return ret;
}
-/* print all orig nodes who announce the address for this global entry.
- * it is assumed that the caller holds rcu_read_lock();
+/* batadv_transtable_best_orig - Get best originator list entry from tt entry
+ * @tt_global_entry: global translation table entry to be analyzed
+ *
+ * This functon assumes the caller holds rcu_read_lock().
+ * Returns best originator list entry or NULL on errors.
+ */
+static struct batadv_tt_orig_list_entry *
+batadv_transtable_best_orig(struct batadv_tt_global_entry *tt_global_entry)
+{
+ struct batadv_neigh_node *router = NULL;
+ struct hlist_head *head;
+ struct hlist_node *node;
+ struct batadv_tt_orig_list_entry *orig_entry, *best_entry = NULL;
+ int best_tq = 0;
+
+ head = &tt_global_entry->orig_list;
+ hlist_for_each_entry_rcu(orig_entry, node, head, list) {
+ router = batadv_orig_node_get_router(orig_entry->orig_node);
+ if (!router)
+ continue;
+
+ if (router->tq_avg > best_tq) {
+ best_entry = orig_entry;
+ best_tq = router->tq_avg;
+ }
+
+ batadv_neigh_node_free_ref(router);
+ }
+
+ return best_entry;
+}
+
+/* batadv_tt_global_print_entry - print all orig nodes who announce the address
+ * for this global entry
+ * @tt_global_entry: global translation table entry to be printed
+ * @seq: debugfs table seq_file struct
+ *
+ * This functon assumes the caller holds rcu_read_lock().
*/
static void
batadv_tt_global_print_entry(struct batadv_tt_global_entry *tt_global_entry,
@@ -921,21 +957,37 @@ batadv_tt_global_print_entry(struct batadv_tt_global_entry *tt_global_entry,
{
struct hlist_head *head;
struct hlist_node *node;
- struct batadv_tt_orig_list_entry *orig_entry;
+ struct batadv_tt_orig_list_entry *orig_entry, *best_entry;
struct batadv_tt_common_entry *tt_common_entry;
uint16_t flags;
uint8_t last_ttvn;
tt_common_entry = &tt_global_entry->common;
+ flags = tt_common_entry->flags;
+
+ best_entry = batadv_transtable_best_orig(tt_global_entry);
+ if (best_entry) {
+ last_ttvn = atomic_read(&best_entry->orig_node->last_ttvn);
+ seq_printf(seq, " %c %pM (%3u) via %pM (%3u) [%c%c%c]\n",
+ '*', tt_global_entry->common.addr,
+ best_entry->ttvn, best_entry->orig_node->orig,
+ last_ttvn,
+ (flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'),
+ (flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.'),
+ (flags & BATADV_TT_CLIENT_TEMP ? 'T' : '.'));
+ }
head = &tt_global_entry->orig_list;
hlist_for_each_entry_rcu(orig_entry, node, head, list) {
- flags = tt_common_entry->flags;
+ if (best_entry == orig_entry)
+ continue;
+
last_ttvn = atomic_read(&orig_entry->orig_node->last_ttvn);
- seq_printf(seq, " * %pM (%3u) via %pM (%3u) [%c%c%c]\n",
- tt_global_entry->common.addr, orig_entry->ttvn,
- orig_entry->orig_node->orig, last_ttvn,
+ seq_printf(seq, " %c %pM (%3u) via %pM (%3u) [%c%c%c]\n",
+ '+', tt_global_entry->common.addr,
+ orig_entry->ttvn, orig_entry->orig_node->orig,
+ last_ttvn,
(flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'),
(flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.'),
(flags & BATADV_TT_CLIENT_TEMP ? 'T' : '.'));
@@ -1281,11 +1333,7 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
struct batadv_tt_local_entry *tt_local_entry = NULL;
struct batadv_tt_global_entry *tt_global_entry = NULL;
struct batadv_orig_node *orig_node = NULL;
- struct batadv_neigh_node *router = NULL;
- struct hlist_head *head;
- struct hlist_node *node;
- struct batadv_tt_orig_list_entry *orig_entry;
- int best_tq;
+ struct batadv_tt_orig_list_entry *best_entry;
if (src && atomic_read(&bat_priv->ap_isolation)) {
tt_local_entry = batadv_tt_local_hash_find(bat_priv, src);
@@ -1305,25 +1353,15 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
goto out;
- best_tq = 0;
-
rcu_read_lock();
- head = &tt_global_entry->orig_list;
- hlist_for_each_entry_rcu(orig_entry, node, head, list) {
- router = batadv_orig_node_get_router(orig_entry->orig_node);
- if (!router)
- continue;
-
- if (router->tq_avg > best_tq) {
- orig_node = orig_entry->orig_node;
- best_tq = router->tq_avg;
- }
- batadv_neigh_node_free_ref(router);
- }
+ best_entry = batadv_transtable_best_orig(tt_global_entry);
/* found anything? */
+ if (best_entry)
+ orig_node = best_entry->orig_node;
if (orig_node && !atomic_inc_not_zero(&orig_node->refcount))
orig_node = NULL;
rcu_read_unlock();
+
out:
if (tt_global_entry)
batadv_tt_global_entry_free_ref(tt_global_entry);
8 years, 3 months
[batman-adv] master: batman-adv: Remove instant overwritten variable initialization (af5ec5c)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit af5ec5cfdd2a09edf596da81f9b7b4003993f910
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sun Oct 7 12:02:22 2012 +0200
batman-adv: Remove instant overwritten variable initialization
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
>---------------------------------------------------------------
af5ec5cfdd2a09edf596da81f9b7b4003993f910
routing.c | 2 +-
sysfs.c | 2 +-
translation-table.c | 20 ++++++++++----------
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/routing.c b/routing.c
index 12af7d3..e146370 100644
--- a/routing.c
+++ b/routing.c
@@ -911,7 +911,7 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
struct batadv_unicast_packet *unicast_packet,
uint8_t *dst_addr)
{
- struct batadv_orig_node *orig_node = NULL;
+ struct batadv_orig_node *orig_node;
bool ret = false;
orig_node = batadv_transtable_search(bat_priv, NULL, dst_addr);
diff --git a/sysfs.c b/sysfs.c
index 7fdc220..cc56ed0 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -739,7 +739,7 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
enum batadv_uev_action action, const char *data)
{
int ret = -ENOMEM;
- struct batadv_hard_iface *primary_if = NULL;
+ struct batadv_hard_iface *primary_if;
struct kobject *bat_kobj;
char *uevent_env[4] = { NULL, NULL, NULL, NULL };
diff --git a/translation-table.c b/translation-table.c
index 1f5ad91..41613b7 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -256,8 +256,8 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
int ifindex)
{
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
- struct batadv_tt_local_entry *tt_local = NULL;
- struct batadv_tt_global_entry *tt_global = NULL;
+ struct batadv_tt_local_entry *tt_local;
+ struct batadv_tt_global_entry *tt_global;
struct hlist_head *head;
struct hlist_node *node;
struct batadv_tt_orig_list_entry *orig_entry;
@@ -543,7 +543,7 @@ uint16_t 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;
+ struct batadv_tt_local_entry *tt_local_entry;
uint16_t flags, curr_flags = BATADV_NO_FLAGS;
tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
@@ -783,8 +783,8 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
const unsigned char *tt_addr, uint8_t flags,
uint8_t ttvn)
{
- struct batadv_tt_global_entry *tt_global_entry = NULL;
- struct batadv_tt_local_entry *tt_local_entry = NULL;
+ struct batadv_tt_global_entry *tt_global_entry;
+ struct batadv_tt_local_entry *tt_local_entry;
int ret = 0;
int hash_added;
struct batadv_tt_common_entry *common;
@@ -1074,7 +1074,7 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv,
const unsigned char *addr,
const char *message, bool roaming)
{
- struct batadv_tt_global_entry *tt_global_entry = NULL;
+ struct batadv_tt_global_entry *tt_global_entry;
struct batadv_tt_local_entry *local_entry = NULL;
tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
@@ -1677,7 +1677,7 @@ static bool
batadv_send_other_tt_response(struct batadv_priv *bat_priv,
struct batadv_tt_query_packet *tt_request)
{
- struct batadv_orig_node *req_dst_orig_node = NULL;
+ struct batadv_orig_node *req_dst_orig_node;
struct batadv_orig_node *res_dst_orig_node = NULL;
struct batadv_neigh_node *neigh_node = NULL;
struct batadv_hard_iface *primary_if = NULL;
@@ -1812,7 +1812,7 @@ static bool
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_orig_node *orig_node;
struct batadv_neigh_node *neigh_node = NULL;
struct batadv_hard_iface *primary_if = NULL;
uint8_t my_ttvn, req_ttvn, ttvn;
@@ -1978,7 +1978,7 @@ static void _batadv_tt_update_changes(struct batadv_priv *bat_priv,
static void batadv_tt_fill_gtable(struct batadv_priv *bat_priv,
struct batadv_tt_query_packet *tt_response)
{
- struct batadv_orig_node *orig_node = NULL;
+ struct batadv_orig_node *orig_node;
orig_node = batadv_orig_hash_find(bat_priv, tt_response->src);
if (!orig_node)
@@ -2020,7 +2020,7 @@ static void batadv_tt_update_changes(struct batadv_priv *bat_priv,
bool batadv_is_my_client(struct batadv_priv *bat_priv, const uint8_t *addr)
{
- struct batadv_tt_local_entry *tt_local_entry = NULL;
+ struct batadv_tt_local_entry *tt_local_entry;
bool ret = false;
tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
8 years, 3 months
[batman-adv] master: batman-adv: fix new line alignment (f0ac944)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit f0ac9442c1120aabfe2a5cc601939df10dc1d9a4
Author: Antonio Quartulli <ordex(a)autistici.org>
Date: Sun Oct 7 09:05:36 2012 +0200
batman-adv: fix new line alignment
Introduced with ("batman-adv: Distributed ARP Table - create DHT helper
functions")
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
>---------------------------------------------------------------
f0ac9442c1120aabfe2a5cc601939df10dc1d9a4
distributed-arp-table.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/distributed-arp-table.h b/distributed-arp-table.h
index 22dd983..63a13a5 100644
--- a/distributed-arp-table.h
+++ b/distributed-arp-table.h
@@ -60,7 +60,7 @@ batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
*/
static inline void
batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
- struct batadv_hard_iface *primary_if)
+ struct batadv_hard_iface *primary_if)
{
uint32_t addr;
8 years, 3 months
[batctl] master: batctl: Add minimal unicast 4addr dissector support (70aefcf)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : master
>---------------------------------------------------------------
commit 70aefcf8abefd509e5721c6ae228d3854d5e8b16
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sun Oct 7 17:43:29 2012 +0200
batctl: Add minimal unicast 4addr dissector support
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
70aefcf8abefd509e5721c6ae228d3854d5e8b16
tcpdump.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/tcpdump.c b/tcpdump.c
index 1a4a9a0..84abd74 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -539,6 +539,33 @@ static void dump_batman_frag(unsigned char *packet_buff, ssize_t buff_len, int r
printf("length %zu\n", (size_t)buff_len - ETH_HLEN - sizeof(struct batadv_unicast_frag_packet));
}
+static void dump_batman_4addr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
+{
+ struct ether_header *ether_header;
+ struct batadv_unicast_packet *unicast_4addr_packet;
+
+ LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_unicast_packet), "BAT 4ADDR");
+ LEN_CHECK((size_t)buff_len - sizeof(struct ether_header) - sizeof(struct batadv_unicast_packet),
+ sizeof(struct ether_header), "BAT 4ADDR (unpacked)");
+
+ ether_header = (struct ether_header *)packet_buff;
+ unicast_4addr_packet = (struct batadv_unicast_packet *)(packet_buff + sizeof(struct ether_header));
+
+ if (!time_printed)
+ time_printed = print_time();
+
+ printf("BAT %s > ",
+ get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt));
+
+ printf("%s: 4ADDR, ttvn %d, ttl %hhu, ",
+ get_name_by_macaddr((struct ether_addr *)unicast_4addr_packet->dest, read_opt),
+ unicast_4addr_packet->ttvn, unicast_4addr_packet->header.ttl);
+
+ parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct batadv_unicast_packet),
+ buff_len - ETH_HLEN - sizeof(struct batadv_unicast_packet),
+ read_opt, time_printed);
+}
+
static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
{
struct batadv_ogm_packet *batman_ogm_packet;
@@ -600,6 +627,10 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read
if (dump_level & DUMP_TYPE_BATTT)
dump_batman_roam(packet_buff, buff_len, read_opt, time_printed);
break;
+ case BATADV_UNICAST_4ADDR:
+ if (dump_level & DUMP_TYPE_BATUCAST)
+ dump_batman_4addr(packet_buff, buff_len, read_opt, time_printed);
+ break;
default:
fprintf(stderr, "Warning - packet contains unknown batman packet type: 0x%02x\n", batman_ogm_packet->header.packet_type);
break;
8 years, 3 months
[batctl] master: batctl: Distributed ARP Table - add ARP parsing functions (0adc79a)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : master
>---------------------------------------------------------------
commit 0adc79a00e710e8689fa32055c8547414b7ec3eb
Author: Antonio Quartulli <ordex(a)autistici.org>
Date: Thu Jun 2 12:29:51 2011 +0200
batctl: Distributed ARP Table - add ARP parsing functions
ARP messages are now parsed to make it possible to trigger special actions
depending on their types (snooping).
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
>---------------------------------------------------------------
0adc79a00e710e8689fa32055c8547414b7ec3eb
packet.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/packet.h b/packet.h
index 72d7331..aa3e63a 100644
--- a/packet.h
+++ b/packet.h
@@ -37,9 +37,15 @@ enum batadv_packettype {
/**
* enum batadv_subtype - packet subtype for unicast4addr
* @BATADV_P_DATA: user payload
+ * @BATADV_P_DAT_DHT_GET: DHT request message
+ * @BATADV_P_DAT_DHT_PUT: DHT store message
+ * @BATADV_P_DAT_CACHE_REPLY: ARP reply generated by DAT
*/
enum batadv_subtype {
- BATADV_P_DATA = 0x01,
+ BATADV_P_DATA = 0x01,
+ BATADV_P_DAT_DHT_GET = 0x02,
+ BATADV_P_DAT_DHT_PUT = 0x03,
+ BATADV_P_DAT_CACHE_REPLY = 0x04,
};
/* this file is included by batctl which needs these defines */
8 years, 3 months
[batctl] master: batman-adv: add UNICAST_4ADDR packet type (a2f7ab6)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : master
>---------------------------------------------------------------
commit a2f7ab6b9d59fcd4c159801f016d0cf52ebb5ded
Author: Antonio Quartulli <ordex(a)autistici.org>
Date: Mon Oct 1 09:57:35 2012 +0200
batman-adv: add UNICAST_4ADDR packet type
The current unicast packet type does not contain the orig source address. This
patches add a new unicast packet (called UNICAST_4ADDR) which provides two new
fields: the originator source address and the subtype (the type of the data
contained in the packet payload). The former is useful to identify the node
which injected the packet into the network and the latter is useful to avoid
creating new unicast packet types in the future: a macro defining a new subtype
will be enough.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
>---------------------------------------------------------------
a2f7ab6b9d59fcd4c159801f016d0cf52ebb5ded
packet.h | 37 +++++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/packet.h b/packet.h
index 2d23a14..72d7331 100644
--- a/packet.h
+++ b/packet.h
@@ -23,14 +23,23 @@
#define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
enum batadv_packettype {
- BATADV_IV_OGM = 0x01,
- BATADV_ICMP = 0x02,
- BATADV_UNICAST = 0x03,
- BATADV_BCAST = 0x04,
- BATADV_VIS = 0x05,
- BATADV_UNICAST_FRAG = 0x06,
- BATADV_TT_QUERY = 0x07,
- BATADV_ROAM_ADV = 0x08,
+ BATADV_IV_OGM = 0x01,
+ BATADV_ICMP = 0x02,
+ BATADV_UNICAST = 0x03,
+ BATADV_BCAST = 0x04,
+ BATADV_VIS = 0x05,
+ BATADV_UNICAST_FRAG = 0x06,
+ BATADV_TT_QUERY = 0x07,
+ BATADV_ROAM_ADV = 0x08,
+ BATADV_UNICAST_4ADDR = 0x09,
+};
+
+/**
+ * enum batadv_subtype - packet subtype for unicast4addr
+ * @BATADV_P_DATA: user payload
+ */
+enum batadv_subtype {
+ BATADV_P_DATA = 0x01,
};
/* this file is included by batctl which needs these defines */
@@ -161,6 +170,18 @@ struct batadv_unicast_packet {
uint8_t dest[ETH_ALEN];
} __packed;
+/**
+ * struct batadv_unicast_4addr_packet - extended unicast packet
+ * @u: common unicast packet header
+ * @src: address of the source
+ * @subtype: packet subtype
+ */
+struct batadv_unicast_4addr_packet {
+ struct batadv_unicast_packet u;
+ uint8_t src[ETH_ALEN];
+ uint8_t subtype;
+} __packed;
+
struct batadv_unicast_frag_packet {
struct batadv_header header;
uint8_t ttvn; /* destination translation table version number */
8 years, 3 months
[batman-adv] master: batman-adv: Add get_ethtool_stats() support for DAT (b996a44)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit b996a44739b3340d9e651c556e434d2524ec145f
Author: Martin Hundebøll <martin(a)hundeboll.net>
Date: Fri Apr 20 17:02:45 2012 +0200
batman-adv: Add get_ethtool_stats() support for DAT
Added additional counters for D.A.T.
Signed-off-by: Martin Hundebøll <martin(a)hundeboll.net>
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
>---------------------------------------------------------------
b996a44739b3340d9e651c556e434d2524ec145f
distributed-arp-table.c | 19 +++++++++++++++++--
distributed-arp-table.h | 27 +++++++++++++++++++++++++++
routing.c | 8 +++++++-
soft-interface.c | 7 +++++++
types.h | 7 +++++++
5 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index d637d62..c933615 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -601,9 +601,22 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
send_status = batadv_send_skb_packet(tmp_skb,
neigh_node->if_incoming,
neigh_node->addr);
- if (send_status == NET_XMIT_SUCCESS)
+ if (send_status == NET_XMIT_SUCCESS) {
+ /* count the sent packet */
+ switch (packet_subtype) {
+ case BATADV_P_DAT_DHT_GET:
+ batadv_inc_counter(bat_priv,
+ BATADV_CNT_DAT_GET_TX);
+ break;
+ case BATADV_P_DAT_DHT_PUT:
+ batadv_inc_counter(bat_priv,
+ BATADV_CNT_DAT_PUT_TX);
+ break;
+ }
+
/* packet sent to a candidate: return true */
ret = true;
+ }
free_neigh:
batadv_neigh_node_free_ref(neigh_node);
free_orig:
@@ -906,8 +919,10 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
else
err = batadv_unicast_send_skb(bat_priv, skb_new);
- if (!err)
+ if (!err) {
+ batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
ret = true;
+ }
out:
if (dat_entry)
batadv_dat_entry_free_ref(dat_entry);
diff --git a/distributed-arp-table.h b/distributed-arp-table.h
index abdae59..22dd983 100644
--- a/distributed-arp-table.h
+++ b/distributed-arp-table.h
@@ -75,6 +75,28 @@ 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
+ * @bat_priv: the bat priv with all the soft interface information
+ * @subtype: the 4addr subtype of the packet to be counted
+ *
+ * Updates the ethtool statistics for the received packet if it is a DAT subtype
+ */
+static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
+ uint8_t subtype)
+{
+ switch (subtype) {
+ case BATADV_P_DAT_DHT_GET:
+ batadv_inc_counter(bat_priv,
+ BATADV_CNT_DAT_GET_RX);
+ break;
+ case BATADV_P_DAT_DHT_PUT:
+ batadv_inc_counter(bat_priv,
+ BATADV_CNT_DAT_PUT_RX);
+ break;
+ }
+}
+
#else
static inline bool
@@ -136,6 +158,11 @@ static inline void batadv_dat_free(struct batadv_priv *bat_priv)
{
}
+static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
+ uint8_t subtype)
+{
+}
+
#endif /* CONFIG_BATMAN_ADV_DAT */
#endif /* _NET_BATMAN_ADV_ARP_H_ */
diff --git a/routing.c b/routing.c
index 74e97eb..12af7d3 100644
--- a/routing.c
+++ b/routing.c
@@ -1041,15 +1041,17 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_unicast_packet *unicast_packet;
+ struct batadv_unicast_4addr_packet *unicast_4addr_packet;
int hdr_size = sizeof(*unicast_packet);
bool is4addr;
unicast_packet = (struct batadv_unicast_packet *)skb->data;
+ unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
is4addr = unicast_packet->header.packet_type == BATADV_UNICAST_4ADDR;
/* the caller function should have already pulled 2 bytes */
if (is4addr)
- hdr_size = sizeof(struct batadv_unicast_4addr_packet);
+ hdr_size = sizeof(*unicast_4addr_packet);
if (batadv_check_unicast_packet(skb, hdr_size) < 0)
return NET_RX_DROP;
@@ -1066,6 +1068,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
hdr_size))
goto rx_success;
+ if (is4addr)
+ batadv_dat_inc_counter(bat_priv,
+ unicast_4addr_packet->subtype);
+
batadv_interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size,
NULL);
diff --git a/soft-interface.c b/soft-interface.c
index c94bccc..2d1f895 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -624,6 +624,13 @@ static const struct {
{ "tt_response_rx" },
{ "tt_roam_adv_tx" },
{ "tt_roam_adv_rx" },
+#ifdef CONFIG_BATMAN_ADV_DAT
+ { "dat_get_tx" },
+ { "dat_get_rx" },
+ { "dat_put_tx" },
+ { "dat_put_rx" },
+ { "dat_cached_reply_tx" },
+#endif
};
static void batadv_get_strings(struct net_device *dev, uint32_t stringset,
diff --git a/types.h b/types.h
index 6e81dcd..b1c261b 100644
--- a/types.h
+++ b/types.h
@@ -179,6 +179,13 @@ enum batadv_counters {
BATADV_CNT_TT_RESPONSE_RX,
BATADV_CNT_TT_ROAM_ADV_TX,
BATADV_CNT_TT_ROAM_ADV_RX,
+#ifdef CONFIG_BATMAN_ADV_DAT
+ BATADV_CNT_DAT_GET_TX,
+ BATADV_CNT_DAT_GET_RX,
+ BATADV_CNT_DAT_PUT_TX,
+ BATADV_CNT_DAT_PUT_RX,
+ BATADV_CNT_DAT_CACHED_REPLY_TX,
+#endif
BATADV_CNT_NUM,
};
8 years, 3 months
[batman-adv] master: batman-adv: Distributed ARP Table - add runtime switch (ad51ff1)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit ad51ff1079aff697c986c65b66f4a7f154128ebc
Author: Antonio Quartulli <ordex(a)autistici.org>
Date: Wed Aug 8 18:50:57 2012 +0200
batman-adv: Distributed ARP Table - add runtime switch
This patch adds a runtime switch that enables the user to turn the DAT feature
on or off at runtime
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
>---------------------------------------------------------------
ad51ff1079aff697c986c65b66f4a7f154128ebc
distributed-arp-table.c | 25 +++++++++++++++++++++++++
distributed-arp-table.h | 1 +
soft-interface.c | 3 +++
sysfs.c | 8 ++++++++
types.h | 3 +++
5 files changed, 40 insertions(+)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index f43bf8e..d637d62 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -790,6 +790,9 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
struct sk_buff *skb_new;
struct batadv_hard_iface *primary_if = NULL;
+ if (!atomic_read(&bat_priv->distributed_arp_table))
+ goto out;
+
type = batadv_arp_get_type(bat_priv, skb, 0);
/* If the node gets an ARP_REQUEST it has to send a DHT_GET unicast
* message to the selected DHT candidates
@@ -861,6 +864,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
bool ret = false;
int err;
+ if (!atomic_read(&bat_priv->distributed_arp_table))
+ goto out;
+
type = batadv_arp_get_type(bat_priv, skb, hdr_size);
if (type != ARPOP_REQUEST)
goto out;
@@ -924,6 +930,9 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
__be32 ip_src, ip_dst;
uint8_t *hw_src, *hw_dst;
+ if (!atomic_read(&bat_priv->distributed_arp_table))
+ return;
+
type = batadv_arp_get_type(bat_priv, skb, 0);
if (type != ARPOP_REPLY)
return;
@@ -959,6 +968,9 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
uint8_t *hw_src, *hw_dst;
bool ret = false;
+ if (!atomic_read(&bat_priv->distributed_arp_table))
+ goto out;
+
type = batadv_arp_get_type(bat_priv, skb, hdr_size);
if (type != ARPOP_REPLY)
goto out;
@@ -1003,6 +1015,9 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
bool ret = false;
const size_t bcast_len = sizeof(struct batadv_bcast_packet);
+ if (!atomic_read(&bat_priv->distributed_arp_table))
+ goto out;
+
/* If this packet is an ARP_REQUEST and the node already has the
* information that it is going to ask, then the packet can be dropped
*/
@@ -1031,3 +1046,13 @@ 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 77814e8..abdae59 100644
--- a/distributed-arp-table.h
+++ b/distributed-arp-table.h
@@ -73,6 +73,7 @@ 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);
#else
diff --git a/soft-interface.c b/soft-interface.c
index 475eae5..c94bccc 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -480,6 +480,9 @@ struct net_device *batadv_softif_create(const char *name)
atomic_set(&bat_priv->aggregated_ogms, 1);
atomic_set(&bat_priv->bonding, 0);
atomic_set(&bat_priv->bridge_loop_avoidance, 0);
+#ifdef CONFIG_BATMAN_ADV_DAT
+ atomic_set(&bat_priv->distributed_arp_table, 1);
+#endif
atomic_set(&bat_priv->ap_isolation, 0);
atomic_set(&bat_priv->vis_mode, BATADV_VIS_TYPE_CLIENT_UPDATE);
atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF);
diff --git a/sysfs.c b/sysfs.c
index fa6c8b1..7fdc220 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -20,6 +20,7 @@
#include "main.h"
#include "sysfs.h"
#include "translation-table.h"
+#include "distributed-arp-table.h"
#include "originator.h"
#include "hard-interface.h"
#include "gateway_common.h"
@@ -470,6 +471,10 @@ BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
#ifdef CONFIG_BATMAN_ADV_BLA
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);
+#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);
static BATADV_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode,
@@ -495,6 +500,9 @@ static struct batadv_attribute *batadv_mesh_attrs[] = {
#ifdef CONFIG_BATMAN_ADV_BLA
&batadv_attr_bridge_loop_avoidance,
#endif
+#ifdef CONFIG_BATMAN_ADV_DAT
+ &batadv_attr_distributed_arp_table,
+#endif
&batadv_attr_fragmentation,
&batadv_attr_ap_isolation,
&batadv_attr_vis_mode,
diff --git a/types.h b/types.h
index 4bc69b5..6e81dcd 100644
--- a/types.h
+++ b/types.h
@@ -265,6 +265,9 @@ struct batadv_priv {
atomic_t fragmentation; /* boolean */
atomic_t ap_isolation; /* boolean */
atomic_t bridge_loop_avoidance; /* boolean */
+#ifdef CONFIG_BATMAN_ADV_DAT
+ atomic_t distributed_arp_table; /* boolean */
+#endif
atomic_t vis_mode; /* VIS_TYPE_* */
atomic_t gw_mode; /* GW_MODE_* */
atomic_t gw_sel_class; /* uint */
8 years, 3 months