[git] batman-adv branch, master, updated. 15c3c06c1ce2d55af8e519764ac9af7f492b9d58
by postmaster@open-mesh.net
The following commit has been merged in the master branch:
commit 15c3c06c1ce2d55af8e519764ac9af7f492b9d58
Author: marek <marek@45894c77-fb22-0410-b583-ff6e7d5dbf6c>
Date: Sun Oct 25 00:13:47 2009 +0000
[batman-adv] Start to send originator messages when interface gets active
The module gets in a inactive state when all interfaces are down. This
stops the sending of new packets. When a interface gets activated again
it must reactivate the module and then start the sending of new
originator messages.
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
git-svn-id: http://downloads.open-mesh.net/svn/batman/trunk/batman-adv-kernelland@1455 45894c77-fb22-0410-b583-ff6e7d5dbf6c
diff --git a/hard-interface.c b/hard-interface.c
index f04d2db..960e86c 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -425,6 +425,10 @@ static int hard_if_event(struct notifier_block *this,
break;
case NETDEV_UP:
hardif_activate_interface(batman_if);
+ if ((atomic_read(&module_state) == MODULE_INACTIVE) &&
+ (hardif_get_active_if_num() > 0)) {
+ activate_module();
+ }
break;
/* NETDEV_CHANGEADDR - mac address change - what are we doing here ? */
default:
diff --git a/main.c b/main.c
index 8fbefc2..4e70c95 100644
--- a/main.c
+++ b/main.c
@@ -173,7 +173,7 @@ end:
/* shuts down the whole module.*/
void shutdown_module(void)
{
- atomic_set(&module_state, MODULE_INACTIVE);
+ atomic_set(&module_state, MODULE_DEACTIVATING);
purge_outstanding_packets();
flush_workqueue(bat_event_workqueue);
@@ -199,6 +199,7 @@ void shutdown_module(void)
hardif_remove_interfaces();
synchronize_rcu();
+ atomic_set(&module_state, MODULE_INACTIVE);
}
void inc_module_count(void)
diff --git a/main.h b/main.h
index 21d3919..9493f96 100644
--- a/main.h
+++ b/main.h
@@ -63,7 +63,7 @@
#define MODULE_INACTIVE 0
#define MODULE_ACTIVE 1
-/* #define MODULE_WAITING 2 -- not needed anymore */
+#define MODULE_DEACTIVATING 2
/*
diff --git a/send.c b/send.c
index 73fe371..01396b4 100644
--- a/send.c
+++ b/send.c
@@ -399,7 +399,7 @@ void send_outstanding_bcast_packet(struct work_struct *work)
/* if we still have some more bcasts to send and we are not shutting
* down */
if ((forw_packet->num_packets < 3) &&
- (atomic_read(&module_state) != MODULE_INACTIVE))
+ (atomic_read(&module_state) != MODULE_DEACTIVATING))
_add_bcast_packet_to_list(forw_packet, ((5 * HZ) / 1000));
else
forw_packet_free(forw_packet);
@@ -424,7 +424,7 @@ void send_outstanding_bat_packet(struct work_struct *work)
* shutting down
*/
if ((forw_packet->own) &&
- (atomic_read(&module_state) != MODULE_INACTIVE))
+ (atomic_read(&module_state) != MODULE_DEACTIVATING))
schedule_own_packet(forw_packet->if_incoming);
forw_packet_free(forw_packet);
--
batman-adv
12 years, 8 months
r1459 - in trunk/batctl: . man
by postmaster@open-mesh.net
Author: marek
Date: 2009-10-26 20:48:30 +0000 (Mon, 26 Oct 2009)
New Revision: 1459
Modified:
trunk/batctl/bisect.c
trunk/batctl/bisect.h
trunk/batctl/man/batctl.8
Log:
[batctl] bisect - add orig event filter
Modified: trunk/batctl/bisect.c
===================================================================
--- trunk/batctl/bisect.c 2009-10-26 19:17:52 UTC (rev 1458)
+++ trunk/batctl/bisect.c 2009-10-26 20:48:30 UTC (rev 1459)
@@ -40,6 +40,7 @@
printf(" \t -h print this help\n");
printf(" \t -l run a loop detection of given mac address or bat-host (default)\n");
printf(" \t -n don't convert addresses to bat-host names\n");
+ printf(" \t -o only display orig events that affect given mac address or bat-host\n");
printf(" \t -r print routing tables of given mac address or bat-host\n");
printf(" \t -s seqno range to limit the output\n");
printf(" \t -t trace seqnos of given mac address or bat-host\n");
@@ -777,7 +778,7 @@
return -1;
}
-static void loop_detection(char *loop_orig, int seqno_min, int seqno_max, int read_opt)
+static void loop_detection(char *loop_orig, int seqno_min, int seqno_max, char *filter_orig, int read_opt)
{
struct bat_node *bat_node;
struct orig_event *orig_event;
@@ -795,12 +796,18 @@
get_name_by_macstr(loop_orig, read_opt));
if ((seqno_min == -1) && (seqno_max == -1))
- printf("[all sequence numbers]\n");
+ printf("[all sequence numbers]");
else if (seqno_min == seqno_max)
- printf("[sequence number: %i]\n", seqno_min);
+ printf("[sequence number: %i]", seqno_min);
else
- printf("[sequence number range: %i-%i]\n", seqno_min, seqno_max);
+ printf("[sequence number range: %i-%i]", seqno_min, seqno_max);
+ if (!compare_name(filter_orig, check_orig))
+ printf(" [filter originator: %s]",
+ get_name_by_macstr(filter_orig, read_opt));
+
+ printf("\n");
+
while (NULL != (hashit = hash_iterate(node_hash, hashit))) {
bat_node = hashit->bucket->data;
@@ -815,6 +822,10 @@
if (bat_node == orig_event->orig_node)
continue;
+ if (!compare_name(filter_orig, check_orig) &&
+ !compare_name(filter_orig, orig_event->orig_node->name))
+ continue;
+
/* we might have no log file from this node */
if (list_empty(&orig_event->event_list)) {
fprintf(stderr, "No seqno data of originator '%s' - skipping\n",
@@ -926,23 +937,35 @@
}
static void seqno_trace_print(struct list_head_first *trace_list, char *trace_orig,
- int seqno_min, int seqno_max, int read_opt)
+ int seqno_min, int seqno_max, char *filter_orig, int read_opt)
{
struct seqno_trace *seqno_trace;
- char head[MAX_LINE];
+ char head[MAX_LINE], check_orig[NAME_LEN];
int i;
+ /* if no option was given filter_orig is empty */
+ memset(check_orig, 0, NAME_LEN);
+
printf("Sequence number flow of originator: %s ",
get_name_by_macstr(trace_orig, read_opt));
if ((seqno_min == -1) && (seqno_max == -1))
- printf("[all sequence numbers]\n");
+ printf("[all sequence numbers]");
else if (seqno_min == seqno_max)
- printf("[sequence number: %i]\n", seqno_min);
+ printf("[sequence number: %i]", seqno_min);
else
- printf("[sequence number range: %i-%i]\n", seqno_min, seqno_max);
+ printf("[sequence number range: %i-%i]", seqno_min, seqno_max);
+ if (!compare_name(filter_orig, check_orig))
+ printf(" [filter originator: %s]",
+ get_name_by_macstr(filter_orig, read_opt));
+
+ printf("\n");
+
list_for_each_entry(seqno_trace, trace_list, list) {
+ if (!seqno_trace->print)
+ continue;
+
printf("+=> %s (seqno %i)\n",
get_name_by_macstr(trace_orig, read_opt),
seqno_trace->seqno);
@@ -1109,6 +1132,7 @@
INIT_LIST_HEAD(&seqno_trace->list);
seqno_trace->seqno = seqno_event->seqno;
+ seqno_trace->print = 0;
seqno_trace->seqno_trace_neigh.num_neighbors = 0;
@@ -1126,7 +1150,7 @@
}
static int seqno_trace_add(struct list_head_first *trace_list, struct bat_node *bat_node,
- struct seqno_event *seqno_event)
+ struct seqno_event *seqno_event, char print_trace)
{
struct seqno_trace *seqno_trace = NULL, *seqno_trace_tmp = NULL, *seqno_trace_prev = NULL;
struct seqno_trace_neigh *seqno_trace_neigh;
@@ -1157,6 +1181,9 @@
list_add_before(&seqno_trace_prev->list, &seqno_trace_tmp->list, &seqno_trace->list);
}
+ if (print_trace)
+ seqno_trace->print = print_trace;
+
seqno_trace_neigh = seqno_trace_find_neigh(seqno_event->neigh,
seqno_event->prev_sender,
&seqno_trace->seqno_trace_neigh);
@@ -1177,7 +1204,7 @@
return 0;
}
-static void trace_seqnos(char *trace_orig, int seqno_min, int seqno_max, int read_opt)
+static void trace_seqnos(char *trace_orig, int seqno_min, int seqno_max, char *filter_orig, int read_opt)
{
struct bat_node *bat_node;
struct orig_event *orig_event;
@@ -1185,8 +1212,11 @@
struct hash_it_t *hashit = NULL;
struct list_head_first trace_list;
struct seqno_trace *seqno_trace, *seqno_trace_tmp;
+ char check_orig[NAME_LEN], print_trace;
int res;
+ /* if no option was given filter_orig is empty */
+ memset(check_orig, 0, NAME_LEN);
INIT_LIST_HEAD_FIRST(trace_list);
while (NULL != (hashit = hash_iterate(node_hash, hashit))) {
@@ -1212,15 +1242,22 @@
if ((seqno_max != -1) && (seqno_event->seqno > seqno_max))
continue;
- res = seqno_trace_add(&trace_list, bat_node, seqno_event);
+ /* if no filter option was given all seqno traces are to be printed */
+ print_trace = compare_name(filter_orig, check_orig);
+ if (!compare_name(filter_orig, check_orig) &&
+ compare_name(filter_orig, bat_node->name))
+ print_trace = 1;
+
+ res = seqno_trace_add(&trace_list, bat_node, seqno_event, print_trace);
+
if (res < 1)
goto out;
}
}
}
- seqno_trace_print(&trace_list, trace_orig, seqno_min, seqno_max, read_opt);
+ seqno_trace_print(&trace_list, trace_orig, seqno_min, seqno_max, filter_orig, read_opt);
out:
list_for_each_entry_safe(seqno_trace, seqno_trace_tmp, &trace_list, list) {
@@ -1231,23 +1268,33 @@
return;
}
-static void print_rt_tables(char *rt_orig, int seqno_min, int seqno_max, int read_opt)
+static void print_rt_tables(char *rt_orig, int seqno_min, int seqno_max, char *filter_orig, int read_opt)
{
struct bat_node *bat_node;
struct rt_table *rt_table;
struct seqno_event *seqno_event;
+ char check_orig[NAME_LEN];
int i;
+ /* if no option was given filter_orig is empty */
+ memset(check_orig, 0, NAME_LEN);
+
printf("Routing tables of originator: %s ",
get_name_by_macstr(rt_orig, read_opt));
if ((seqno_min == -1) && (seqno_max == -1))
- printf("[all sequence numbers]\n");
+ printf("[all sequence numbers]");
else if (seqno_min == seqno_max)
- printf("[sequence number: %i]\n", seqno_min);
+ printf("[sequence number: %i]", seqno_min);
else
- printf("[sequence number range: %i-%i]\n", seqno_min, seqno_max);
+ printf("[sequence number range: %i-%i]", seqno_min, seqno_max);
+ if (!compare_name(filter_orig, check_orig))
+ printf(" [filter originator: %s]",
+ get_name_by_macstr(filter_orig, read_opt));
+
+ printf("\n");
+
bat_node = node_get(rt_orig);
if (!bat_node)
goto out;
@@ -1259,6 +1306,10 @@
list_for_each_entry(rt_table, &bat_node->rt_table_list, list) {
seqno_event = rt_table->rt_hist->seqno_event;
+ if (!compare_name(filter_orig, check_orig) &&
+ !compare_name(filter_orig, seqno_event->orig->name))
+ continue;
+
if ((seqno_min != -1) && (seqno_event->seqno < seqno_min))
continue;
@@ -1347,11 +1398,12 @@
int read_opt = USE_BAT_HOSTS, num_parsed_files;
int tmp_seqno, seqno_max = -1, seqno_min = -1;
char *trace_orig_ptr = NULL, *rt_orig_ptr = NULL, *loop_orig_ptr = NULL;
- char orig[NAME_LEN], *dash_ptr;
+ char orig[NAME_LEN], filter_orig[NAME_LEN], *dash_ptr, *filter_orig_ptr = NULL;
memset(orig, 0, NAME_LEN);
+ memset(filter_orig, 0, NAME_LEN);
- while ((optchar = getopt(argc, argv, "hl:nr:s:t:")) != -1) {
+ while ((optchar = getopt(argc, argv, "hl:no:r:s:t:")) != -1) {
switch (optchar) {
case 'h':
bisect_usage();
@@ -1364,6 +1416,10 @@
read_opt &= ~USE_BAT_HOSTS;
found_args += 1;
break;
+ case 'o':
+ filter_orig_ptr = optarg;
+ found_args += ((*((char*)(optarg - 1)) == optchar ) ? 1 : 2);
+ break;
case 'r':
rt_orig_ptr = optarg;
found_args += ((*((char*)(optarg - 1)) == optchar ) ? 1 : 2);
@@ -1453,6 +1509,13 @@
goto err;
}
+ if (filter_orig_ptr) {
+ res = get_orig_addr(filter_orig_ptr, filter_orig);
+
+ if (res < 1)
+ goto err;
+ }
+
while (argc > found_args) {
res = parse_log_file(argv[found_args]);
@@ -1468,11 +1531,11 @@
}
if (trace_orig_ptr)
- trace_seqnos(orig, seqno_min, seqno_max, read_opt);
+ trace_seqnos(orig, seqno_min, seqno_max, filter_orig, read_opt);
else if (rt_orig_ptr)
- print_rt_tables(orig, seqno_min, seqno_max, read_opt);
+ print_rt_tables(orig, seqno_min, seqno_max, filter_orig, read_opt);
else
- loop_detection(orig, seqno_min, seqno_max, read_opt);
+ loop_detection(orig, seqno_min, seqno_max, filter_orig, read_opt);
ret = EXIT_SUCCESS;
Modified: trunk/batctl/bisect.h
===================================================================
--- trunk/batctl/bisect.h 2009-10-26 19:17:52 UTC (rev 1458)
+++ trunk/batctl/bisect.h 2009-10-26 20:48:30 UTC (rev 1459)
@@ -89,5 +89,6 @@
struct seqno_trace {
struct list_head list;
int seqno;
+ char print;
struct seqno_trace_neigh seqno_trace_neigh;
};
Modified: trunk/batctl/man/batctl.8
===================================================================
--- trunk/batctl/man/batctl.8 2009-10-26 19:17:52 UTC (rev 1458)
+++ trunk/batctl/man/batctl.8 2009-10-26 20:48:30 UTC (rev 1459)
@@ -78,7 +78,7 @@
Per default batctl will display all packets that were seen on the given interface(s). The "\-p" options allows to filter certain packet types: 1 displays batman ogm packets only, 2 displays batman icmp packets only, etc. These numbers can be added to filter more than one packet type, e.g. use "\-p 3" to display batman ogm packets and batman icmp packets only. If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output.
.br
.IP "\fBbisect logfile1 logfile2 .. logfileN\fP"
-Analyzes the logfiles to build a small internal database of all sent sequence numbers and routing table changes. This database can be used to search for routing loops (default action), to trace OGMs of a host (use "-t" to specify the mac address or bat\-host name) throughout the network or to display routing tables of the nodes (use "-r" to specify the mac address or bat\-host name). You can name a specific sequence number or a range using the "-s" option to reduce the trace output. If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output.
+Analyzes the logfiles to build a small internal database of all sent sequence numbers and routing table changes. This database can be used to search for routing loops (default action), to trace OGMs of a host (use "-t" to specify the mac address or bat\-host name) throughout the network or to display routing tables of the nodes (use "-r" to specify the mac address or bat\-host name). You can name a specific sequence number or a range using the "-s" option to limit the output's range. Furthermore you can filter the output by specifying an originator (use "-o" to specify the mac address or bat\-host name) to only see data connected to this originator. If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output.
.br
.SH FILES
.TP
12 years, 8 months
r1458 - trunk/batctl
by postmaster@open-mesh.net
Author: marek
Date: 2009-10-26 19:17:52 +0000 (Mon, 26 Oct 2009)
New Revision: 1458
Modified:
trunk/batctl/bisect.c
Log:
[batctl] fix endless loop in bisect
Modified: trunk/batctl/bisect.c
===================================================================
--- trunk/batctl/bisect.c 2009-10-25 00:28:45 UTC (rev 1457)
+++ trunk/batctl/bisect.c 2009-10-26 19:17:52 UTC (rev 1458)
@@ -665,7 +665,7 @@
/* same here */
if (list_empty(&orig_event->rt_hist_list))
- continue;
+ goto out;
/* we are running in a loop */
if (memcmp(curr_loop_magic, next_hop_tmp->loop_magic, LOOP_MAGIC_LEN) == 0) {
12 years, 8 months
r1457 - in trunk/batctl: . man
by postmaster@open-mesh.net
Author: marek
Date: 2009-10-25 00:28:45 +0000 (Sun, 25 Oct 2009)
New Revision: 1457
Modified:
trunk/batctl/main.c
trunk/batctl/man/batctl.8
Log:
[batctl] a little more documentation for batctl
Modified: trunk/batctl/main.c
===================================================================
--- trunk/batctl/main.c 2009-10-25 00:13:51 UTC (rev 1456)
+++ trunk/batctl/main.c 2009-10-25 00:28:45 UTC (rev 1457)
@@ -53,7 +53,7 @@
printf(" \ttcpdump|td <interface> \ttcpdump layer 2 traffic on the given interface\n");
printf(" \tbisect <file1> .. <fileN>\tanalyze given log files for routing stability\n");
printf("options:\n");
- printf(" \t-h print this help\n");
+ printf(" \t-h print this help (or 'batctl <command> -h' for the command specific help)\n");
printf(" \t-v print version\n");
}
Modified: trunk/batctl/man/batctl.8
===================================================================
--- trunk/batctl/man/batctl.8 2009-10-25 00:13:51 UTC (rev 1456)
+++ trunk/batctl/man/batctl.8 2009-10-25 00:28:45 UTC (rev 1457)
@@ -78,7 +78,7 @@
Per default batctl will display all packets that were seen on the given interface(s). The "\-p" options allows to filter certain packet types: 1 displays batman ogm packets only, 2 displays batman icmp packets only, etc. These numbers can be added to filter more than one packet type, e.g. use "\-p 3" to display batman ogm packets and batman icmp packets only. If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output.
.br
.IP "\fBbisect logfile1 logfile2 .. logfileN\fP"
-Analyzes the logfiles to build a small internal database of all sent sequence numbers and routing table changes. This database can be used to search for routing loops (default action) or to trace OGMs of a host (use "-t" to specify the mac address or bat\-host name) throughout the network. You can name a specific sequence number or a range using the "-s" option to reduce the trace output. If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output.
+Analyzes the logfiles to build a small internal database of all sent sequence numbers and routing table changes. This database can be used to search for routing loops (default action), to trace OGMs of a host (use "-t" to specify the mac address or bat\-host name) throughout the network or to display routing tables of the nodes (use "-r" to specify the mac address or bat\-host name). You can name a specific sequence number or a range using the "-s" option to reduce the trace output. If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output.
.br
.SH FILES
.TP
12 years, 8 months
r1456 - trunk/batctl
by postmaster@open-mesh.net
Author: marek
Date: 2009-10-25 00:13:51 +0000 (Sun, 25 Oct 2009)
New Revision: 1456
Modified:
trunk/batctl/Makefile
trunk/batctl/bisect.c
trunk/batctl/bisect.h
Log:
[batctl] add recursive check for routing loops
Modified: trunk/batctl/Makefile
===================================================================
--- trunk/batctl/Makefile 2009-10-25 00:13:47 UTC (rev 1455)
+++ trunk/batctl/Makefile 2009-10-25 00:13:51 UTC (rev 1456)
@@ -26,7 +26,7 @@
endif
CC = gcc
-CFLAGS += -pedantic -Wall -W -O1 -g3 -std=gnu99
+CFLAGS += -pedantic -Wall -W -g3 -std=gnu99
EXTRA_CFLAGS = -DREVISION_VERSION=$(REVISION_VERSION)
LDFLAGS +=
Modified: trunk/batctl/bisect.c
===================================================================
--- trunk/batctl/bisect.c 2009-10-25 00:13:47 UTC (rev 1455)
+++ trunk/batctl/bisect.c 2009-10-25 00:13:51 UTC (rev 1456)
@@ -87,24 +87,91 @@
}
strncpy(bat_node->name, name, NAME_LEN);
- INIT_LIST_HEAD_FIRST(bat_node->event_list);
+ INIT_LIST_HEAD_FIRST(bat_node->orig_event_list);
INIT_LIST_HEAD_FIRST(bat_node->rt_table_list);
memset(bat_node->loop_magic, 0, sizeof(bat_node->loop_magic));
+ memset(bat_node->loop_magic2, 0, sizeof(bat_node->loop_magic2));
hash_add(node_hash, bat_node);
out:
return bat_node;
}
+static struct orig_event *orig_event_new(struct bat_node *bat_node, struct bat_node *orig_node)
+{
+ struct orig_event *orig_event;
+
+ orig_event = malloc(sizeof(struct orig_event));
+ if (!orig_event) {
+ fprintf(stderr, "Could not allocate memory for orig event structure (out of mem?) - skipping");
+ return NULL;
+ }
+
+ INIT_LIST_HEAD(&orig_event->list);
+ INIT_LIST_HEAD_FIRST(orig_event->event_list);
+ INIT_LIST_HEAD_FIRST(orig_event->rt_hist_list);
+ orig_event->orig_node = orig_node;
+ list_add_tail(&orig_event->list, &bat_node->orig_event_list);
+
+ return orig_event;
+}
+
+static struct orig_event *orig_event_get_by_name(struct bat_node *bat_node, char *orig)
+{
+ struct bat_node *orig_node;
+ struct orig_event *orig_event;
+
+ if (!bat_node)
+ return NULL;
+
+ list_for_each_entry(orig_event, &bat_node->orig_event_list, list) {
+ if (compare_name(orig_event->orig_node->name, orig))
+ return orig_event;
+ }
+
+ orig_node = node_get(orig);
+ if (!orig_node)
+ return NULL;
+
+ return orig_event_new(bat_node, orig_node);
+}
+
+static struct orig_event *orig_event_get_by_ptr(struct bat_node *bat_node, struct bat_node *orig_node)
+{
+ struct orig_event *orig_event;
+
+ if (!bat_node)
+ return NULL;
+
+ list_for_each_entry(orig_event, &bat_node->orig_event_list, list) {
+ if (orig_event->orig_node == orig_node)
+ return orig_event;
+ }
+
+ return orig_event_new(bat_node, orig_node);
+}
+
static void node_free(void *data)
{
+ struct orig_event *orig_event, *orig_event_tmp;
struct seqno_event *seqno_event, *seqno_event_tmp;
struct rt_table *rt_table, *rt_table_tmp;
+ struct rt_hist *rt_hist, *rt_hist_tmp;
struct bat_node *bat_node = (struct bat_node *)data;
- list_for_each_entry_safe(seqno_event, seqno_event_tmp, &bat_node->event_list, list) {
- list_del((struct list_head *)&bat_node->event_list, &seqno_event->list, &bat_node->event_list);
- free(seqno_event);
+ list_for_each_entry_safe(orig_event, orig_event_tmp, &bat_node->orig_event_list, list) {
+ list_for_each_entry_safe(seqno_event, seqno_event_tmp, &orig_event->event_list, list) {
+ list_del((struct list_head *)&orig_event->event_list, &seqno_event->list, &orig_event->event_list);
+ free(seqno_event);
+ }
+
+ list_for_each_entry_safe(rt_hist, rt_hist_tmp, &orig_event->rt_hist_list, list) {
+ list_del((struct list_head *)&orig_event->rt_hist_list, &rt_hist->list, &orig_event->rt_hist_list);
+ free(rt_hist);
+ }
+
+ list_del((struct list_head *)&bat_node->orig_event_list, &orig_event->list, &bat_node->orig_event_list);
+ free(orig_event);
}
list_for_each_entry_safe(rt_table, rt_table_tmp, &bat_node->rt_table_list, list) {
@@ -120,8 +187,10 @@
static int routing_table_new(char *orig, char *next_hop, char *old_next_hop, char rt_flag)
{
struct bat_node *next_hop_node;
+ struct orig_event *orig_event;
struct seqno_event *seqno_event;
struct rt_table *rt_table, *prev_rt_table = NULL;
+ struct rt_hist *rt_hist;
int i, j;
if (!curr_bat_node) {
@@ -148,19 +217,46 @@
if ((rt_flag != RT_FLAG_DELETE) && (!next_hop_node))
goto err;
+ orig_event = orig_event_get_by_name(curr_bat_node, orig);
+ if (!orig_event)
+ goto err;
+
+ if (list_empty(&orig_event->event_list)) {
+ fprintf(stderr, "Routing table change without any preceeding OGM of that originator - skipping");
+ goto err;
+ }
+
+ if (!compare_name(((struct seqno_event *)(orig_event->event_list.prev))->orig->name, orig)) {
+ fprintf(stderr, "Routing table change does not match with last received OGM - skipping");
+ goto err;
+ }
+
rt_table = malloc(sizeof(struct rt_table));
if (!rt_table) {
fprintf(stderr, "Could not allocate memory for routing table (out of mem?) - skipping");
goto err;
}
+ rt_hist = malloc(sizeof(struct rt_hist));
+ if (!rt_hist) {
+ fprintf(stderr, "Could not allocate memory for routing history (out of mem?) - skipping");
+ goto table_free;
+ }
+
INIT_LIST_HEAD(&rt_table->list);
+ rt_table->num_entries = 1;
+ INIT_LIST_HEAD(&rt_hist->list);
+ rt_hist->prev_rt_hist = NULL;
+ rt_hist->next_hop = next_hop_node;
+ rt_hist->flags = rt_flag;
+
+ if (!(list_empty(&orig_event->rt_hist_list)))
+ rt_hist->prev_rt_hist = (struct rt_hist *)(orig_event->rt_hist_list.prev);
+
if (!(list_empty(&curr_bat_node->rt_table_list)))
prev_rt_table = (struct rt_table *)(curr_bat_node->rt_table_list.prev);
- rt_table->num_entries = 1;
-
switch (rt_flag) {
case RT_FLAG_ADD:
if (prev_rt_table)
@@ -193,9 +289,9 @@
if (rt_table->num_entries != prev_rt_table->num_entries) {
fprintf(stderr,
- "Found a delete entry of orig '%s' but no previous existing record - skipping",
+ "Found a delete entry of orig '%s' but no existing record - skipping",
orig);
- goto table_free;
+ goto rt_hist_free;
}
/**
@@ -205,29 +301,29 @@
seqno_event = malloc(sizeof(struct seqno_event));
if (!seqno_event) {
fprintf(stderr, "Could not allocate memory for delete seqno event (out of mem?) - skipping");
- goto table_free;
+ goto rt_hist_free;
}
INIT_LIST_HEAD(&seqno_event->list);
- seqno_event->orig = NULL;
+ seqno_event->orig = node_get(orig);
seqno_event->neigh = NULL;
seqno_event->prev_sender = NULL;
seqno_event->seqno = -1;
seqno_event->tq = -1;
seqno_event->ttl = -1;
- seqno_event->rt_table = NULL;
- list_add_tail(&seqno_event->list, &curr_bat_node->event_list);
+ seqno_event->rt_hist = NULL;
+ list_add_tail(&seqno_event->list, &orig_event->event_list);
}
break;
default:
fprintf(stderr, "Unknown rt_flag received: %i - skipping", rt_flag);
- goto table_free;
+ goto rt_hist_free;
}
rt_table->entries = malloc(sizeof(struct rt_entry) * rt_table->num_entries);
if (!rt_table->entries) {
fprintf(stderr, "Could not allocate memory for routing table entries (out of mem?) - skipping");
- goto table_free;
+ goto rt_hist_free;
}
if (prev_rt_table) {
@@ -246,7 +342,9 @@
*/
j++;
- memcpy((char *)&rt_table->entries[j], (char *)&prev_rt_table->entries[i], sizeof(struct rt_entry));
+ memcpy((char *)&rt_table->entries[j],
+ (char *)&prev_rt_table->entries[i],
+ sizeof(struct rt_entry));
if (compare_name(orig, rt_table->entries[j].orig)) {
if (rt_flag != RT_FLAG_DELETE)
@@ -266,11 +364,17 @@
rt_table->entries[i - 1].flags = rt_flag;
}
+ rt_table->rt_hist = rt_hist;
+ rt_hist->seqno_event = (struct seqno_event *)(orig_event->event_list.prev);
+ rt_hist->seqno_event->rt_hist = rt_hist;
+ rt_hist->rt_table = rt_table;
list_add_tail(&rt_table->list, &curr_bat_node->rt_table_list);
- ((struct seqno_event *)(curr_bat_node->event_list.prev))->rt_table = rt_table;
+ list_add_tail(&rt_hist->list, &orig_event->rt_hist_list);
return 1;
+rt_hist_free:
+ free(rt_hist);
table_free:
free(rt_table);
err:
@@ -280,6 +384,7 @@
static int seqno_event_new(char *iface_addr, char *orig, char *prev_sender, char *neigh, int seqno, int tq, int ttl)
{
struct bat_node *orig_node, *neigh_node, *prev_sender_node;
+ struct orig_event *orig_event;
struct seqno_event *seqno_event;
if (!iface_addr) {
@@ -328,6 +433,10 @@
if (!prev_sender_node)
goto err;
+ orig_event = orig_event_get_by_ptr(curr_bat_node, orig_node);
+ if (!orig_event)
+ goto err;
+
seqno_event = malloc(sizeof(struct seqno_event));
if (!seqno_event) {
fprintf(stderr, "Could not allocate memory for seqno event (out of mem?) - skipping");
@@ -341,8 +450,8 @@
seqno_event->seqno = seqno;
seqno_event->tq = tq;
seqno_event->ttl = ttl;
- seqno_event->rt_table = NULL;
- list_add_tail(&seqno_event->list, &curr_bat_node->event_list);
+ seqno_event->rt_hist = NULL;
+ list_add_tail(&seqno_event->list, &orig_event->event_list);
return 1;
@@ -464,8 +573,8 @@
}
}
-// printf("route (line %i): orig: '%s', neigh: '%s', prev_sender: '%s'\n",
-// line_count, orig, neigh, prev_sender);
+// printf("route (file: %s, line %i): orig: '%s', neigh: '%s', prev_sender: '%s'\n",
+// file_path, line_count, orig, neigh, prev_sender);
if (((rt_flag == RT_FLAG_ADD) && (!neigh)) ||
((rt_flag == RT_FLAG_UPDATE) && (!prev_sender)) ||
@@ -485,102 +594,203 @@
// printf("File '%s' parsed (lines: %i)\n", file_path, line_count);
fclose(fd);
+ curr_bat_node = NULL;
return 1;
}
-static int validate_path(struct bat_node *bat_node, struct seqno_event *seqno_event,
- struct rt_entry *rt_entry, int seqno_count, int read_opt)
+static struct rt_hist *get_rt_hist_by_seqno(struct orig_event *orig_event, int seqno)
{
- struct bat_node *next_hop_node;
- struct seqno_event *seqno_event_tmp;
- struct rt_table *rt_table_tmp;
- struct rt_entry *rt_entry_tmp = rt_entry;
+ struct seqno_event *seqno_event;
+ struct rt_hist *rt_hist = NULL;
+
+ list_for_each_entry(seqno_event, &orig_event->event_list, list) {
+ if (seqno_event->seqno > seqno)
+
+ break;
+ if (seqno_event->rt_hist)
+ rt_hist = seqno_event->rt_hist;
+ }
+
+ return rt_hist;
+}
+
+static struct rt_hist *get_rt_hist_by_node_seqno(struct bat_node *bat_node, struct bat_node *orig_node, int seqno)
+{
+ struct orig_event *orig_event;
+ struct rt_hist *rt_hist;
+
+ orig_event = orig_event_get_by_ptr(bat_node, orig_node);
+ if (!orig_event)
+ return NULL;
+
+ rt_hist = get_rt_hist_by_seqno(orig_event, seqno);
+ return rt_hist;
+}
+
+static int print_rt_path_at_seqno(struct bat_node *src_node, struct bat_node *dst_node,
+ struct bat_node *next_hop, int seqno, int seqno_rand, int read_opt)
+{
+ struct bat_node *next_hop_tmp;
+ struct orig_event *orig_event;
+ struct rt_hist *rt_hist;
char curr_loop_magic[LOOP_MAGIC_LEN];
- int i;
- snprintf(curr_loop_magic, LOOP_MAGIC_LEN, "%s%s%i%i",
- bat_node->name, rt_entry->orig,
- seqno_event->seqno, seqno_count);
+ memset(curr_loop_magic, 0, LOOP_MAGIC_LEN);
+ snprintf(curr_loop_magic, LOOP_MAGIC_LEN, "%s%s%i%i", src_node->name,
+ dst_node->name, seqno, seqno_rand);
- printf("Path towards %s (seqno %i):",
- get_name_by_macstr(rt_entry->orig, read_opt),
- seqno_event->seqno);
+ printf("Path towards %s (seqno %i ",
+ get_name_by_macstr(dst_node->name, read_opt), seqno);
+ printf("via neigh %s):", get_name_by_macstr(next_hop->name, read_opt));
+
+ next_hop_tmp = next_hop;
+
while (1) {
- next_hop_node = rt_entry_tmp->next_hop;
+ printf(" -> %s%s",
+ get_name_by_macstr(next_hop_tmp->name, read_opt),
+ (dst_node == next_hop_tmp ? "." : ""));
- printf(" -> %s",
- get_name_by_macstr(next_hop_node->name, read_opt));
+ /* destination reached */
+ if (dst_node == next_hop_tmp)
+ break;
+ orig_event = orig_event_get_by_ptr(next_hop_tmp, dst_node);
+ if (!orig_event)
+ goto out;
+
/* no more data - path seems[tm] fine */
- if (list_empty(&next_hop_node->event_list))
+ if (list_empty(&orig_event->event_list))
goto out;
/* same here */
- if (list_empty(&next_hop_node->rt_table_list))
+ if (list_empty(&orig_event->rt_hist_list))
continue;
- rt_table_tmp = NULL;
- rt_entry_tmp = NULL;
-
/* we are running in a loop */
- if (memcmp(curr_loop_magic, next_hop_node->loop_magic, LOOP_MAGIC_LEN) == 0) {
+ if (memcmp(curr_loop_magic, next_hop_tmp->loop_magic, LOOP_MAGIC_LEN) == 0) {
printf(" aborted due to loop!");
goto out;
}
- memcpy(next_hop_node->loop_magic, curr_loop_magic, sizeof(next_hop_node->loop_magic));
+ memcpy(next_hop_tmp->loop_magic, curr_loop_magic, sizeof(next_hop_tmp->loop_magic));
- list_for_each_entry(seqno_event_tmp, &next_hop_node->event_list, list) {
- if (seqno_event_tmp->rt_table)
- rt_table_tmp = seqno_event_tmp->rt_table;
+ rt_hist = get_rt_hist_by_seqno(orig_event, seqno);
- if ((seqno_event_tmp->seqno == seqno_event->seqno) &&
- (seqno_event_tmp->orig == seqno_event->orig))
- break;
- }
+ /* no more routing data - what can we do ? */
+ if (!rt_hist)
+ break;
- /* no routing data so far - what can we do ? */
- if (!rt_table_tmp)
- goto out;
+ next_hop_tmp = rt_hist->next_hop;
+ }
- /* search the following next hop */
- for (i = 0; i < rt_table_tmp->num_entries; i++) {
- if (compare_name(rt_table_tmp->entries[i].orig, rt_entry->orig)) {
- rt_entry_tmp = (struct rt_entry *)&rt_table_tmp->entries[i];
- break;
- }
+out:
+ printf("\n");
+ return 1;
+}
+
+static int find_rt_table_change(struct bat_node *src_node, struct bat_node *dst_node,
+ struct bat_node *curr_node, int seqno_min, int seqno_max,
+ int seqno_rand, int read_opt)
+{
+ struct orig_event *orig_event;
+ struct rt_hist *rt_hist, *rt_hist_tmp;
+ char curr_loop_magic[LOOP_MAGIC_LEN];
+ int res;
+
+ /* recursion ends here */
+ if (curr_node == dst_node) {
+ rt_hist = get_rt_hist_by_node_seqno(src_node, dst_node, seqno_max);
+
+ if (rt_hist)
+ print_rt_path_at_seqno(src_node, dst_node, rt_hist->next_hop,
+ seqno_max, seqno_rand, read_opt);
+ return 0;
+ }
+
+ memset(curr_loop_magic, 0, LOOP_MAGIC_LEN);
+ snprintf(curr_loop_magic, LOOP_MAGIC_LEN, "%s%s%i%i",
+ src_node->name, dst_node->name,
+ seqno_min, seqno_rand);
+
+ /* we are running in a loop */
+ if (memcmp(curr_loop_magic, curr_node->loop_magic2, LOOP_MAGIC_LEN) == 0) {
+ rt_hist = get_rt_hist_by_node_seqno(src_node, dst_node, seqno_max);
+
+ if (rt_hist)
+ print_rt_path_at_seqno(src_node, dst_node, rt_hist->next_hop,
+ seqno_max, seqno_rand, read_opt);
+ goto out;
+ }
+
+ memcpy(curr_node->loop_magic2, curr_loop_magic, sizeof(curr_node->loop_magic));
+
+ orig_event = orig_event_get_by_ptr(curr_node, dst_node);
+ if (!orig_event)
+ goto out;
+
+ list_for_each_entry(rt_hist, &orig_event->rt_hist_list, list) {
+ /* special seqno that indicates an originator timeout */
+ if (rt_hist->seqno_event->seqno == -1) {
+ printf("Woot - originator timeout ??\n");
+ continue;
}
- /* no routing entry of orig ?? */
- if (!rt_entry_tmp)
- goto out;
+ if ((seqno_min != -1) && (rt_hist->seqno_event->seqno < seqno_min))
+ continue;
- if (compare_name(rt_entry->orig, rt_entry_tmp->next_hop->name)) {
- printf(" -> %s.",
- get_name_by_macstr(rt_entry_tmp->next_hop->name, read_opt));
- break;
- }
+ if ((seqno_max != -1) && (rt_hist->seqno_event->seqno >= seqno_max))
+ continue;
+
+ /* printf("validate route after change (seqno %i) of next hop: %s\n",
+ rt_hist->seqno_event->seqno,
+ get_name_by_macstr(rt_hist->next_hop->name, read_opt));*/
+
+ res = find_rt_table_change(src_node, dst_node, rt_hist->next_hop,
+ seqno_min, rt_hist->seqno_event->seqno,
+ seqno_rand, read_opt);
+
+ /* find_rt_table_change() did not run into a loop and printed the path */
+ if (res == 0)
+ continue;
+
+ /**
+ * retrieve routing table towards dst at that point and
+ * print the routing path
+ **/
+ rt_hist_tmp = get_rt_hist_by_node_seqno(src_node, dst_node, rt_hist->seqno_event->seqno);
+
+ if (!rt_hist_tmp)
+ continue;
+
+ print_rt_path_at_seqno(src_node, dst_node, rt_hist_tmp->next_hop,
+ rt_hist->seqno_event->seqno, seqno_rand, read_opt);
}
+ rt_hist = get_rt_hist_by_seqno(orig_event, seqno_max - 1);
+
+ if (rt_hist)
+ return find_rt_table_change(src_node, dst_node, rt_hist->next_hop,
+ seqno_min, seqno_max, seqno_rand, read_opt);
+
out:
- printf("\n");
- return 1;
+ return -1;
}
static void loop_detection(char *loop_orig, int seqno_min, int seqno_max, int read_opt)
{
struct bat_node *bat_node;
- struct seqno_event *seqno_event;
+ struct orig_event *orig_event;
struct hash_it_t *hashit = NULL;
- int i, last_seqno = -1, seqno_count = 0;
+ struct rt_hist *rt_hist, *prev_rt_hist;
+ int last_seqno = -1, seqno_count = 0;
char check_orig[NAME_LEN];
printf("\nAnalyzing routing tables ");
/* if no option was given loop_orig is empty */
memset(check_orig, 0, NAME_LEN);
- if (memcmp(loop_orig, check_orig, NAME_LEN))
+ if (!compare_name(loop_orig, check_orig))
printf("of originator: %s ",
get_name_by_macstr(loop_orig, read_opt));
@@ -594,60 +804,89 @@
while (NULL != (hashit = hash_iterate(node_hash, hashit))) {
bat_node = hashit->bucket->data;
- if (memcmp(loop_orig, check_orig, NAME_LEN) &&
- memcmp(loop_orig, bat_node->name, NAME_LEN) != 0)
+ if (!compare_name(loop_orig, check_orig) &&
+ !compare_name(loop_orig, bat_node->name))
continue;
- /* we might have no log file from this node */
- if (list_empty(&bat_node->event_list)) {
- fprintf(stderr, "\nNo seqno data from node '%s' - skipping\n",
- get_name_by_macstr(bat_node->name, read_opt));
- continue;
- }
-
- /* or routing tables */
- if (list_empty(&bat_node->rt_table_list)) {
- fprintf(stderr, "\nNo routing tables from node '%s' - skipping\n",
- get_name_by_macstr(bat_node->name, read_opt));
- continue;
- }
-
printf("\nChecking host: %s\n",
get_name_by_macstr(bat_node->name, read_opt));
- list_for_each_entry(seqno_event, &bat_node->event_list, list) {
- /**
- * this received packet did not trigger a routing
- * table change and is considered harmless
- */
- if (!seqno_event->rt_table)
+ list_for_each_entry(orig_event, &bat_node->orig_event_list, list) {
+ if (bat_node == orig_event->orig_node)
continue;
- if ((seqno_min != -1) && (seqno_event->seqno < seqno_min))
+ /* we might have no log file from this node */
+ if (list_empty(&orig_event->event_list)) {
+ fprintf(stderr, "No seqno data of originator '%s' - skipping\n",
+ get_name_by_macstr(orig_event->orig_node->name, read_opt));
continue;
+ }
- if ((seqno_max != -1) && (seqno_event->seqno > seqno_max))
+ /* or routing tables */
+ if (list_empty(&orig_event->rt_hist_list)) {
+ fprintf(stderr, "No routing history of originator '%s' - skipping\n",
+ get_name_by_macstr(orig_event->orig_node->name, read_opt));
continue;
+ }
- /* special seqno that indicates an originator timeout */
- if (seqno_event->seqno == -1)
- continue;
+ list_for_each_entry(rt_hist, &orig_event->rt_hist_list, list) {
+ /* special seqno that indicates an originator timeout */
+ if (rt_hist->seqno_event->seqno == -1)
+ continue;
- /**
- * sometime we change the routing table more than once
- * with the same seqno
- */
- if (last_seqno == seqno_event->seqno)
- seqno_count++;
- else
- seqno_count = 0;
+ if ((seqno_min != -1) && (rt_hist->seqno_event->seqno < seqno_min))
+ continue;
- last_seqno = seqno_event->seqno;
+ if ((seqno_max != -1) && (rt_hist->seqno_event->seqno > seqno_max))
+ continue;
- for (i = 0; i < seqno_event->rt_table->num_entries; i++) {
- validate_path(bat_node, seqno_event,
- (struct rt_entry *)&seqno_event->rt_table->entries[i],
- seqno_count, read_opt);
+ /**
+ * sometime we change the routing table more than once
+ * with the same seqno
+ */
+ if (last_seqno == rt_hist->seqno_event->seqno)
+ seqno_count++;
+ else
+ seqno_count = 0;
+
+ last_seqno = rt_hist->seqno_event->seqno;
+
+ if (rt_hist->flags == RT_FLAG_DELETE) {
+ printf("Path towards %s deleted (originator timeout)\n",
+ get_name_by_macstr(rt_hist->seqno_event->orig->name, read_opt));
+ continue;
+ }
+
+ prev_rt_hist = rt_hist->prev_rt_hist;
+
+ if ((prev_rt_hist) &&
+ (rt_hist->seqno_event->seqno != prev_rt_hist->seqno_event->seqno)) {
+ if (rt_hist->seqno_event->seqno < prev_rt_hist->seqno_event->seqno) {
+ fprintf(stderr,
+ "Smaller seqno (%i) than previously received seqno (%i) of orig %s triggered routing table change - skipping recursive check\n",
+ rt_hist->seqno_event->seqno, prev_rt_hist->seqno_event->seqno,
+ get_name_by_macstr(rt_hist->seqno_event->orig->name, read_opt));
+ goto validate_path;
+ }
+
+ /*printf("\n=> checking orig %s in seqno range of: %i - %i ",
+ get_name_by_macstr(rt_hist->seqno_event->orig->name, read_opt),
+ prev_rt_hist->seqno_event->seqno + 1,
+ rt_hist->seqno_event->seqno);
+
+ printf("(prev nexthop: %s)\n",
+ get_name_by_macstr(prev_rt_hist->next_hop->name, read_opt));*/
+
+ find_rt_table_change(bat_node, rt_hist->seqno_event->orig, prev_rt_hist->next_hop,
+ prev_rt_hist->seqno_event->seqno + 1, rt_hist->seqno_event->seqno,
+ seqno_count, read_opt);
+
+ continue;
+ }
+
+validate_path:
+ print_rt_path_at_seqno(bat_node, rt_hist->seqno_event->orig, rt_hist->next_hop,
+ rt_hist->seqno_event->seqno, seqno_count, read_opt);
}
}
}
@@ -677,9 +916,9 @@
for (i = 0; i < seqno_trace_neigh->num_neighbors; i++) {
snprintf(new_head, sizeof(new_head), "%s%s",
- (strlen(head) > 1 ? head : num_sisters == 0 ? " " : head),
- (strlen(head) == 1 ? " " :
- num_sisters == 0 ? " " : "| "));
+ (strlen(head) > 1 ? head : num_sisters == 0 ? " " : head),
+ (strlen(head) == 1 ? " " :
+ num_sisters == 0 ? " " : "| "));
seqno_trace_print_neigh(seqno_trace_neigh->seqno_trace_neigh[i], seqno_trace_neigh->seqno_event,
seqno_trace_neigh->num_neighbors - i - 1, new_head, read_opt);
@@ -941,6 +1180,7 @@
static void trace_seqnos(char *trace_orig, int seqno_min, int seqno_max, int read_opt)
{
struct bat_node *bat_node;
+ struct orig_event *orig_event;
struct seqno_event *seqno_event;
struct hash_it_t *hashit = NULL;
struct list_head_first trace_list;
@@ -952,28 +1192,31 @@
while (NULL != (hashit = hash_iterate(node_hash, hashit))) {
bat_node = hashit->bucket->data;
- /* we might have no log file from this node */
- if (list_empty(&bat_node->event_list))
- continue;
+ list_for_each_entry(orig_event, &bat_node->orig_event_list, list) {
- list_for_each_entry(seqno_event, &bat_node->event_list, list) {
- /* special seqno that indicates an originator timeout */
- if (seqno_event->seqno == -1)
+ /* we might have no log file from this node */
+ if (list_empty(&orig_event->event_list))
continue;
- if (!compare_name(trace_orig, seqno_event->orig->name))
- continue;
+ list_for_each_entry(seqno_event, &orig_event->event_list, list) {
+ /* special seqno that indicates an originator timeout */
+ if (seqno_event->seqno == -1)
+ continue;
- if ((seqno_min != -1) && (seqno_event->seqno < seqno_min))
- continue;
+ if (!compare_name(trace_orig, seqno_event->orig->name))
+ continue;
- if ((seqno_max != -1) && (seqno_event->seqno > seqno_max))
- continue;
+ if ((seqno_min != -1) && (seqno_event->seqno < seqno_min))
+ continue;
- res = seqno_trace_add(&trace_list, bat_node, seqno_event);
+ if ((seqno_max != -1) && (seqno_event->seqno > seqno_max))
+ continue;
- if (res < 1)
- goto out;
+ res = seqno_trace_add(&trace_list, bat_node, seqno_event);
+
+ if (res < 1)
+ goto out;
+ }
}
}
@@ -991,6 +1234,7 @@
static void print_rt_tables(char *rt_orig, int seqno_min, int seqno_max, int read_opt)
{
struct bat_node *bat_node;
+ struct rt_table *rt_table;
struct seqno_event *seqno_event;
int i;
@@ -1009,16 +1253,11 @@
goto out;
/* we might have no log file from this node */
- if (list_empty(&bat_node->event_list))
- goto out;
-
- /* or routing tables */
if (list_empty(&bat_node->rt_table_list))
goto out;
- list_for_each_entry(seqno_event, &bat_node->event_list, list) {
- if (!seqno_event->rt_table)
- continue;
+ list_for_each_entry(rt_table, &bat_node->rt_table_list, list) {
+ seqno_event = rt_table->rt_hist->seqno_event;
if ((seqno_min != -1) && (seqno_event->seqno < seqno_min))
continue;
@@ -1026,7 +1265,7 @@
if ((seqno_max != -1) && (seqno_event->seqno > seqno_max))
continue;
- if (seqno_event->orig) {
+ if (seqno_event->seqno > -1) {
printf("rt change triggered by OGM from: %s (tq: %i, ttl: %i, seqno %i",
get_name_by_macstr(seqno_event->orig->name, read_opt),
seqno_event->tq, seqno_event->ttl, seqno_event->seqno);
@@ -1038,14 +1277,14 @@
printf("rt change triggered by originator timeout: \n");
}
- for (i = 0; i < seqno_event->rt_table->num_entries; i++) {
+ for (i = 0; i < rt_table->num_entries; i++) {
printf("%s %s via next hop",
- (seqno_event->rt_table->entries[i].flags ? " *" : " "),
- get_name_by_macstr(seqno_event->rt_table->entries[i].orig, read_opt));
+ (rt_table->entries[i].flags ? " *" : " "),
+ get_name_by_macstr(rt_table->entries[i].orig, read_opt));
printf(" %s",
- get_name_by_macstr(seqno_event->rt_table->entries[i].next_hop->name, read_opt));
+ get_name_by_macstr(rt_table->entries[i].next_hop->name, read_opt));
- switch (seqno_event->rt_table->entries[i].flags) {
+ switch (rt_table->entries[i].flags) {
case RT_FLAG_ADD:
printf(" (route added)\n");
break;
Modified: trunk/batctl/bisect.h
===================================================================
--- trunk/batctl/bisect.h 2009-10-25 00:13:47 UTC (rev 1455)
+++ trunk/batctl/bisect.h 2009-10-25 00:13:51 UTC (rev 1456)
@@ -29,19 +29,39 @@
int bisect(int argc, char **argv);
+
+
struct bat_node {
char name[NAME_LEN];
- struct list_head_first event_list;
+ struct list_head_first orig_event_list;
struct list_head_first rt_table_list;
char loop_magic[LOOP_MAGIC_LEN];
+ char loop_magic2[LOOP_MAGIC_LEN];
};
+struct orig_event {
+ struct list_head list;
+ struct bat_node *orig_node;
+ struct list_head_first event_list;
+ struct list_head_first rt_hist_list;
+};
+
struct rt_table {
struct list_head list;
int num_entries;
struct rt_entry *entries;
+ struct rt_hist *rt_hist;
};
+struct rt_hist {
+ struct list_head list;
+ struct rt_table *rt_table;
+ struct rt_hist *prev_rt_hist;
+ struct seqno_event *seqno_event;
+ struct bat_node *next_hop;
+ char flags;
+};
+
struct rt_entry {
char orig[NAME_LEN];
struct bat_node *next_hop;
@@ -56,7 +76,7 @@
int seqno;
int tq;
int ttl;
- struct rt_table *rt_table;
+ struct rt_hist *rt_hist;
};
struct seqno_trace_neigh {
12 years, 8 months
r1455 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2009-10-25 00:13:47 +0000 (Sun, 25 Oct 2009)
New Revision: 1455
Modified:
trunk/batman-adv-kernelland/hard-interface.c
trunk/batman-adv-kernelland/main.c
trunk/batman-adv-kernelland/main.h
trunk/batman-adv-kernelland/send.c
Log:
[batman-adv] Start to send originator messages when interface gets active
The module gets in a inactive state when all interfaces are down. This
stops the sending of new packets. When a interface gets activated again
it must reactivate the module and then start the sending of new
originator messages.
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batman-adv-kernelland/hard-interface.c
===================================================================
--- trunk/batman-adv-kernelland/hard-interface.c 2009-10-25 00:13:44 UTC (rev 1454)
+++ trunk/batman-adv-kernelland/hard-interface.c 2009-10-25 00:13:47 UTC (rev 1455)
@@ -425,6 +425,10 @@
break;
case NETDEV_UP:
hardif_activate_interface(batman_if);
+ if ((atomic_read(&module_state) == MODULE_INACTIVE) &&
+ (hardif_get_active_if_num() > 0)) {
+ activate_module();
+ }
break;
/* NETDEV_CHANGEADDR - mac address change - what are we doing here ? */
default:
Modified: trunk/batman-adv-kernelland/main.c
===================================================================
--- trunk/batman-adv-kernelland/main.c 2009-10-25 00:13:44 UTC (rev 1454)
+++ trunk/batman-adv-kernelland/main.c 2009-10-25 00:13:47 UTC (rev 1455)
@@ -173,7 +173,7 @@
/* shuts down the whole module.*/
void shutdown_module(void)
{
- atomic_set(&module_state, MODULE_INACTIVE);
+ atomic_set(&module_state, MODULE_DEACTIVATING);
purge_outstanding_packets();
flush_workqueue(bat_event_workqueue);
@@ -199,6 +199,7 @@
hardif_remove_interfaces();
synchronize_rcu();
+ atomic_set(&module_state, MODULE_INACTIVE);
}
void inc_module_count(void)
Modified: trunk/batman-adv-kernelland/main.h
===================================================================
--- trunk/batman-adv-kernelland/main.h 2009-10-25 00:13:44 UTC (rev 1454)
+++ trunk/batman-adv-kernelland/main.h 2009-10-25 00:13:47 UTC (rev 1455)
@@ -63,7 +63,7 @@
#define MODULE_INACTIVE 0
#define MODULE_ACTIVE 1
-/* #define MODULE_WAITING 2 -- not needed anymore */
+#define MODULE_DEACTIVATING 2
/*
Modified: trunk/batman-adv-kernelland/send.c
===================================================================
--- trunk/batman-adv-kernelland/send.c 2009-10-25 00:13:44 UTC (rev 1454)
+++ trunk/batman-adv-kernelland/send.c 2009-10-25 00:13:47 UTC (rev 1455)
@@ -399,7 +399,7 @@
/* if we still have some more bcasts to send and we are not shutting
* down */
if ((forw_packet->num_packets < 3) &&
- (atomic_read(&module_state) != MODULE_INACTIVE))
+ (atomic_read(&module_state) != MODULE_DEACTIVATING))
_add_bcast_packet_to_list(forw_packet, ((5 * HZ) / 1000));
else
forw_packet_free(forw_packet);
@@ -424,7 +424,7 @@
* shutting down
*/
if ((forw_packet->own) &&
- (atomic_read(&module_state) != MODULE_INACTIVE))
+ (atomic_read(&module_state) != MODULE_DEACTIVATING))
schedule_own_packet(forw_packet->if_incoming);
forw_packet_free(forw_packet);
12 years, 8 months
r1454 - trunk/batctl
by postmaster@open-mesh.net
Author: marek
Date: 2009-10-25 00:13:44 +0000 (Sun, 25 Oct 2009)
New Revision: 1454
Modified:
trunk/batctl/bisect.c
trunk/batctl/bisect.h
Log:
[batctl] bisect - better routing table handling due to add/update/delete detection
Modified: trunk/batctl/bisect.c
===================================================================
--- trunk/batctl/bisect.c 2009-10-18 11:47:08 UTC (rev 1453)
+++ trunk/batctl/bisect.c 2009-10-25 00:13:44 UTC (rev 1454)
@@ -73,6 +73,9 @@
{
struct bat_node *bat_node;
+ if (!name)
+ return NULL;
+
bat_node = (struct bat_node *)hash_find(node_hash, name);
if (bat_node)
goto out;
@@ -114,11 +117,12 @@
free(bat_node);
}
-static int routing_table_new(char *orig, char *next_hop, char *old_next_hop)
+static int routing_table_new(char *orig, char *next_hop, char *old_next_hop, char rt_flag)
{
struct bat_node *next_hop_node;
- struct rt_table *rt_table, *prev_rt_table;
- int i;
+ struct seqno_event *seqno_event;
+ struct rt_table *rt_table, *prev_rt_table = NULL;
+ int i, j;
if (!curr_bat_node) {
fprintf(stderr, "Routing table change without preceeding OGM - skipping");
@@ -130,18 +134,18 @@
goto err;
}
- if (!next_hop) {
+ if ((rt_flag != RT_FLAG_DELETE) && (!next_hop)) {
fprintf(stderr, "Invalid next hop found - skipping");
goto err;
}
- if (!old_next_hop) {
+ if ((rt_flag == RT_FLAG_UPDATE) && (!old_next_hop)) {
fprintf(stderr, "Invalid old next hop found - skipping");
goto err;
}
next_hop_node = node_get(next_hop);
- if (!next_hop_node)
+ if ((rt_flag != RT_FLAG_DELETE) && (!next_hop_node))
goto err;
rt_table = malloc(sizeof(struct rt_table));
@@ -151,19 +155,73 @@
}
INIT_LIST_HEAD(&rt_table->list);
- rt_table->num_entries = 1;
- if (!(list_empty(&curr_bat_node->rt_table_list))) {
+ if (!(list_empty(&curr_bat_node->rt_table_list)))
prev_rt_table = (struct rt_table *)(curr_bat_node->rt_table_list.prev);
- rt_table->num_entries = prev_rt_table->num_entries + 1;
- /* if we had a route already we just change the entry */
- for (i = 0; i < prev_rt_table->num_entries; i++) {
- if (compare_name(orig, prev_rt_table->entries[i].orig)) {
- rt_table->num_entries--;
- break;
+ rt_table->num_entries = 1;
+
+ switch (rt_flag) {
+ case RT_FLAG_ADD:
+ if (prev_rt_table)
+ rt_table->num_entries = prev_rt_table->num_entries + 1;
+ break;
+ case RT_FLAG_UPDATE:
+ if (prev_rt_table) {
+ rt_table->num_entries = prev_rt_table->num_entries + 1;
+
+ /* if we had that route already we just change the entry */
+ for (i = 0; i < prev_rt_table->num_entries; i++) {
+ if (compare_name(orig, prev_rt_table->entries[i].orig)) {
+ rt_table->num_entries = prev_rt_table->num_entries;
+ break;
+ }
}
}
+ break;
+ case RT_FLAG_DELETE:
+ if (prev_rt_table) {
+ rt_table->num_entries = prev_rt_table->num_entries + 1;
+
+ /* if we had that route already we just change the entry */
+ for (i = 0; i < prev_rt_table->num_entries; i++) {
+ if (compare_name(orig, prev_rt_table->entries[i].orig)) {
+ rt_table->num_entries = prev_rt_table->num_entries;
+ break;
+ }
+ }
+
+ if (rt_table->num_entries != prev_rt_table->num_entries) {
+ fprintf(stderr,
+ "Found a delete entry of orig '%s' but no previous existing record - skipping",
+ orig);
+ goto table_free;
+ }
+
+ /**
+ * we need to create a special seqno event as a timer instead
+ * of an OGM triggered that event
+ */
+ seqno_event = malloc(sizeof(struct seqno_event));
+ if (!seqno_event) {
+ fprintf(stderr, "Could not allocate memory for delete seqno event (out of mem?) - skipping");
+ goto table_free;
+ }
+
+ INIT_LIST_HEAD(&seqno_event->list);
+ seqno_event->orig = NULL;
+ seqno_event->neigh = NULL;
+ seqno_event->prev_sender = NULL;
+ seqno_event->seqno = -1;
+ seqno_event->tq = -1;
+ seqno_event->ttl = -1;
+ seqno_event->rt_table = NULL;
+ list_add_tail(&seqno_event->list, &curr_bat_node->event_list);
+ }
+ break;
+ default:
+ fprintf(stderr, "Unknown rt_flag received: %i - skipping", rt_flag);
+ goto table_free;
}
rt_table->entries = malloc(sizeof(struct rt_entry) * rt_table->num_entries);
@@ -172,18 +230,40 @@
goto table_free;
}
- if (!(list_empty(&curr_bat_node->rt_table_list)))
- memcpy(rt_table->entries, prev_rt_table->entries, prev_rt_table->num_entries * sizeof(struct rt_entry));
+ if (prev_rt_table) {
+ j = -1;
+ for (i = 0; i < prev_rt_table->num_entries; i++) {
+ /* if we have a previously deleted item don't copy it over */
+ if (prev_rt_table->entries[i].flags == RT_FLAG_DELETE) {
+ rt_table->num_entries--;
+ continue;
+ }
- if ((rt_table->num_entries == 1) ||
- (rt_table->num_entries != prev_rt_table->num_entries)) {
+ /**
+ * if we delete one item the entries are not in sync anymore,
+ * therefore we need to counters: one for the old and one for
+ * the new routing table
+ */
+ j++;
+
+ memcpy((char *)&rt_table->entries[j], (char *)&prev_rt_table->entries[i], sizeof(struct rt_entry));
+
+ if (compare_name(orig, rt_table->entries[j].orig)) {
+ if (rt_flag != RT_FLAG_DELETE)
+ rt_table->entries[j].next_hop = next_hop_node;
+ rt_table->entries[j].flags = rt_flag;
+ continue;
+ }
+
+ rt_table->entries[j].flags = 0;
+ }
+ }
+
+ if ((rt_table->num_entries == 1) || (rt_table->num_entries != j + 1)) {
i = rt_table->num_entries;
strncpy(rt_table->entries[i - 1].orig, orig, NAME_LEN);
rt_table->entries[i - 1].next_hop = next_hop_node;
- } else {
-
- rt_table->entries[i].next_hop = next_hop_node;
-
+ rt_table->entries[i - 1].flags = rt_flag;
}
list_add_tail(&rt_table->list, &curr_bat_node->rt_table_list);
@@ -274,8 +354,8 @@
{
FILE *fd;
char line_buff[MAX_LINE], *start_ptr, *tok_ptr;
- char *neigh, *iface_addr, *orig, *prev_sender;
- int line_count = 0, tq, ttl, seqno, i, res;
+ char *neigh, *iface_addr, *orig, *prev_sender, rt_flag;
+ int line_count = 0, tq, ttl, seqno, i, res, max;
fd = fopen(file_path, "r");
@@ -339,11 +419,25 @@
if (res < 1)
fprintf(stderr, " [file: %s, line: %i]\n", file_path, line_count);
- } else if (strstr(start_ptr, "Changing route towards")) {
+ } else if (strstr(start_ptr, "Adding route towards") ||
+ strstr(start_ptr, "Changing route towards") ||
+ strstr(start_ptr, "Deleting route towards")) {
+
+ rt_flag = RT_FLAG_UPDATE;
+ max = 12;
+
+ if (strstr(start_ptr, "Adding route towards")) {
+ rt_flag = RT_FLAG_ADD;
+ max = 5;
+ } else if (strstr(start_ptr, "Deleting route towards")) {
+ rt_flag = RT_FLAG_DELETE;
+ max = 3;
+ }
+
tok_ptr = strtok(start_ptr, " ");
orig = neigh = prev_sender = NULL;
- for (i = 0; i < 12; i++) {
+ for (i = 0; i < max; i++) {
tok_ptr = strtok(NULL, " ");
if (!tok_ptr)
break;
@@ -351,7 +445,15 @@
switch (i) {
case 2:
orig = tok_ptr;
+ if (rt_flag == RT_FLAG_DELETE)
+ orig[strlen(orig) - 1] = 0;
break;
+ case 4:
+ if (rt_flag == RT_FLAG_ADD) {
+ neigh = tok_ptr;
+ neigh[strlen(neigh) - 2] = 0;
+ }
+ break;
case 5:
neigh = tok_ptr;
break;
@@ -362,14 +464,20 @@
}
}
- if (!prev_sender) {
- fprintf(stderr, "Broken 'changing route' line found - skipping [file: %s, line: %i]\n", file_path, line_count);
+// printf("route (line %i): orig: '%s', neigh: '%s', prev_sender: '%s'\n",
+// line_count, orig, neigh, prev_sender);
+
+ if (((rt_flag == RT_FLAG_ADD) && (!neigh)) ||
+ ((rt_flag == RT_FLAG_UPDATE) && (!prev_sender)) ||
+ ((rt_flag == RT_FLAG_DELETE) && (!orig))) {
+ fprintf(stderr, "Broken '%s route' line found - skipping [file: %s, line: %i]\n",
+ (rt_flag == RT_FLAG_UPDATE ? "changing" :
+ (rt_flag == RT_FLAG_ADD ? "adding" : "deleting")),
+ file_path, line_count);
continue;
}
-// printf("changing route (line %i): orig: '%s', neigh: '%s', prev_sender: '%s'\n", line_count, orig, neigh, prev_sender);
-
- res = routing_table_new(orig, neigh, prev_sender);
+ res = routing_table_new(orig, neigh, prev_sender, rt_flag);
if (res < 1)
fprintf(stderr, " [file: %s, line: %i]\n", file_path, line_count);
}
@@ -506,6 +614,7 @@
printf("\nChecking host: %s\n",
get_name_by_macstr(bat_node->name, read_opt));
+
list_for_each_entry(seqno_event, &bat_node->event_list, list) {
/**
* this received packet did not trigger a routing
@@ -520,6 +629,10 @@
if ((seqno_max != -1) && (seqno_event->seqno > seqno_max))
continue;
+ /* special seqno that indicates an originator timeout */
+ if (seqno_event->seqno == -1)
+ continue;
+
/**
* sometime we change the routing table more than once
* with the same seqno
@@ -844,6 +957,10 @@
continue;
list_for_each_entry(seqno_event, &bat_node->event_list, list) {
+ /* special seqno that indicates an originator timeout */
+ if (seqno_event->seqno == -1)
+ continue;
+
if (!compare_name(trace_orig, seqno_event->orig->name))
continue;
@@ -875,8 +992,7 @@
{
struct bat_node *bat_node;
struct seqno_event *seqno_event;
- struct rt_table *prev_rt_table = NULL;
- int i, j, changed_entry;
+ int i;
printf("Routing tables of originator: %s ",
get_name_by_macstr(rt_orig, read_opt));
@@ -910,39 +1026,42 @@
if ((seqno_max != -1) && (seqno_event->seqno > seqno_max))
continue;
- printf("rt change triggered by OGM from: %s (tq: %i, ttl: %i, seqno %i",
- get_name_by_macstr(seqno_event->orig->name, read_opt),
- seqno_event->tq, seqno_event->ttl, seqno_event->seqno);
- printf(", neigh: %s",
- get_name_by_macstr(seqno_event->neigh->name, read_opt));
- printf(", prev_sender: %s)\n",
- get_name_by_macstr(seqno_event->prev_sender->name, read_opt));
+ if (seqno_event->orig) {
+ printf("rt change triggered by OGM from: %s (tq: %i, ttl: %i, seqno %i",
+ get_name_by_macstr(seqno_event->orig->name, read_opt),
+ seqno_event->tq, seqno_event->ttl, seqno_event->seqno);
+ printf(", neigh: %s",
+ get_name_by_macstr(seqno_event->neigh->name, read_opt));
+ printf(", prev_sender: %s)\n",
+ get_name_by_macstr(seqno_event->prev_sender->name, read_opt));
+ } else {
+ printf("rt change triggered by originator timeout: \n");
+ }
for (i = 0; i < seqno_event->rt_table->num_entries; i++) {
- changed_entry = 1;
+ printf("%s %s via next hop",
+ (seqno_event->rt_table->entries[i].flags ? " *" : " "),
+ get_name_by_macstr(seqno_event->rt_table->entries[i].orig, read_opt));
+ printf(" %s",
+ get_name_by_macstr(seqno_event->rt_table->entries[i].next_hop->name, read_opt));
- if (prev_rt_table) {
- for (j = 0; j < prev_rt_table->num_entries; j++) {
- if (!compare_name(seqno_event->rt_table->entries[i].orig, prev_rt_table->entries[j].orig))
- continue;
-
- if (seqno_event->rt_table->entries[i].next_hop != prev_rt_table->entries[j].next_hop)
- continue;
-
- changed_entry = 0;
- break;
- }
+ switch (seqno_event->rt_table->entries[i].flags) {
+ case RT_FLAG_ADD:
+ printf(" (route added)\n");
+ break;
+ case RT_FLAG_UPDATE:
+ printf(" (next hop changed)\n");
+ break;
+ case RT_FLAG_DELETE:
+ printf(" (route deleted)\n");
+ break;
+ default:
+ printf("\n");
+ break;
}
-
- printf("%s %s via next hop", (changed_entry ? " *" : " "),
- get_name_by_macstr(seqno_event->rt_table->entries[i].orig, read_opt));
- printf(" %s\n",
- get_name_by_macstr(seqno_event->rt_table->entries[i].next_hop->name, read_opt));
}
printf("\n");
-
- prev_rt_table = seqno_event->rt_table;
}
out:
Modified: trunk/batctl/bisect.h
===================================================================
--- trunk/batctl/bisect.h 2009-10-18 11:47:08 UTC (rev 1453)
+++ trunk/batctl/bisect.h 2009-10-25 00:13:44 UTC (rev 1454)
@@ -23,6 +23,10 @@
#define MAX_LINE 256
#define LOOP_MAGIC_LEN ((2 * NAME_LEN) + (2 * sizeof(int)) - 2)
+#define RT_FLAG_ADD 1
+#define RT_FLAG_UPDATE 2
+#define RT_FLAG_DELETE 3
+
int bisect(int argc, char **argv);
struct bat_node {
@@ -41,6 +45,7 @@
struct rt_entry {
char orig[NAME_LEN];
struct bat_node *next_hop;
+ char flags;
};
struct seqno_event {
12 years, 8 months
[git] batman-adv branch, master, updated. f01af72e428717f15f2f612c07fd8ed57da19b7c
by postmaster@open-mesh.net
The following commit has been merged in the master branch:
commit f01af72e428717f15f2f612c07fd8ed57da19b7c
Author: marek <marek@45894c77-fb22-0410-b583-ff6e7d5dbf6c>
Date: Sun Oct 18 11:47:08 2009 +0000
[batman-adv] remove last LINUX_VERSION_CODE check outside of compat.h
git-svn-id: http://downloads.open-mesh.net/svn/batman/trunk/batman-adv-kernelland@1453 45894c77-fb22-0410-b583-ff6e7d5dbf6c
diff --git a/soft-interface.c b/soft-interface.c
index 08a16e3..fa5289e 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -83,7 +83,7 @@ int my_skb_push(struct sk_buff *skb, unsigned int len)
return 0;
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
+#ifdef HAVE_NET_DEVICE_OPS
static const struct net_device_ops bat_netdev_ops = {
.ndo_open = interface_open,
.ndo_stop = interface_release,
@@ -93,7 +93,7 @@ static const struct net_device_ops bat_netdev_ops = {
.ndo_start_xmit = interface_tx,
.ndo_validate_addr = eth_validate_addr
};
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
+#endif
void interface_setup(struct net_device *dev)
{
@@ -102,16 +102,16 @@ void interface_setup(struct net_device *dev)
ether_setup(dev);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
+#ifdef HAVE_NET_DEVICE_OPS
+ dev->netdev_ops = &bat_netdev_ops;
+#else
dev->open = interface_open;
dev->stop = interface_release;
dev->get_stats = interface_stats;
dev->set_mac_address = interface_set_mac_addr;
dev->change_mtu = interface_change_mtu;
dev->hard_start_xmit = interface_tx;
-#else
- dev->netdev_ops = &bat_netdev_ops;
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
+#endif
dev->destructor = free_netdev;
dev->mtu = hardif_min_mtu();
--
batman-adv
12 years, 8 months
[git] batman-adv branch, master, updated. f01af72e428717f15f2f612c07fd8ed57da19b7c
by postmaster@open-mesh.net
The following commit has been merged in the master branch:
commit 60b750e5ad69e7a06b9db09561e89f4b7456ec93
Author: marek <marek@45894c77-fb22-0410-b583-ff6e7d5dbf6c>
Date: Sat Oct 17 22:11:17 2009 +0000
[batman-adv] print a warning when an existing mac address is added again
git-svn-id: http://downloads.open-mesh.net/svn/batman/trunk/batman-adv-kernelland@1452 45894c77-fb22-0410-b583-ff6e7d5dbf6c
diff --git a/hard-interface.c b/hard-interface.c
index dd5e784..f04d2db 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -70,6 +70,28 @@ int hardif_min_mtu(void)
return min_mtu;
}
+void check_known_mac_addr(uint8_t *addr)
+{
+ struct batman_if *batman_if;
+ char mac_string[ETH_STR_LEN];
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(batman_if, &if_list, list) {
+ if ((batman_if->if_active != IF_ACTIVE) &&
+ (batman_if->if_active != IF_TO_BE_ACTIVATED))
+ continue;
+
+ if (!compare_orig(batman_if->net_dev->dev_addr, addr))
+ continue;
+
+ addr_to_string(mac_string, addr);
+ debug_log(LOG_TYPE_WARN, "The newly added mac address (%s) already exists on: %s\n",
+ mac_string, batman_if->dev);
+ debug_log(LOG_TYPE_WARN, "It is strongly recommended to keep mac addresses unique to avoid problems!\n");
+ }
+ rcu_read_unlock();
+}
+
/* adjusts the MTU if a new interface with a smaller MTU appeared. */
void update_min_mtu(void)
{
@@ -191,6 +213,8 @@ void hardif_activate_interface(struct batman_if *batman_if)
goto bind_err;
}
+ check_known_mac_addr(batman_if->net_dev->dev_addr);
+
batman_if->raw_sock->sk->sk_user_data =
batman_if->raw_sock->sk->sk_data_ready;
batman_if->raw_sock->sk->sk_data_ready = batman_data_ready;
--
batman-adv
12 years, 8 months
[git] batman-adv branch, master, updated. f01af72e428717f15f2f612c07fd8ed57da19b7c
by postmaster@open-mesh.net
The following commit has been merged in the master branch:
commit fb0d487a472d0d7d45d032c3fda7c9fe21ca5e42
Author: simon <simon@45894c77-fb22-0410-b583-ff6e7d5dbf6c>
Date: Sat Oct 17 19:28:57 2009 +0000
announce compile-compatibility for tested kernels in the README
git-svn-id: http://downloads.open-mesh.net/svn/batman/trunk/batman-adv-kernelland@1450 45894c77-fb22-0410-b583-ff6e7d5dbf6c
diff --git a/README b/README
index b97a78b..63465c2 100644
--- a/README
+++ b/README
@@ -6,7 +6,7 @@ BATMAN-ADV
The kernel implementation of batman-advanced. It does not depend on any network
driver, and can be used on wifi as well as ethernet, vpn, etc ... (anything
with ethernet-style layer 2).
-It compiles against and should work with Linux 2.6.20 - 2.6.28. Supporting older
+It compiles against and should work with Linux 2.6.20 - 2.6.31. Supporting older
versions is not planned, but it's probably easy to backport it. If you work on a
backport, feel free to contact us. :-)
--
batman-adv
12 years, 8 months