nodewatcher: only add direct batman originators

This is a normal scenario:
-- %< --
originator last-seen (quality) nexthop [interface]: .. possible nexthops ..
A    0.270s   (134) A [    w2mesh]: C ( 79) A (134)
B    0.170s   (245) B [    w2mesh]: B (245)
C    1.850s   (152) C [    w2mesh]: A ( 83) C (152)
-- >% --
Nodewatcher will send only the originator, last-seen, quality, nexthop
and the interface. Nothing about the possible nexthops. Because Netmon
can't show every Originator (to bad performance), we need some filtering,
to only see direct neighbors. At the moment Netmon stores only
originator == nexthop entries. And there is no other way to filter,
because Netmon has only this information.

But this may fail. The problem occurs, if A has a better connection
(e.g. via eth0) with leads to an quality of 255:
-- %< --
A    0.270s   (255) A [    eth0]: C ( 79) A (255)
B    0.170s   (245) B [    w2mesh]: B (245)
C    1.850s   (204) A [    eth0]: A (204) C (152)
-- >% --
In this example, Netmon wouldn't show the connection to C.

This patch doesn't use the originator == nexthop filter. Instead a
filter like "originator is anywhere in the possible nexthops" is used.
With this, we can disable the filtering in Netmon and show at least that
there is directly connection. With the "batctl o" command it is not
possible to show the correct interface for this direct connection.

Signed-off-by: Tim Niemeyer <tim.niemeyer@mastersword.de>
Reviewed-by: Tobias Klaus <tk+ff@meskal.net>
This commit is contained in:
Tim Niemeyer 2015-10-10 16:46:39 +02:00
parent 368241ec28
commit d9dbaf7d97
1 changed files with 12 additions and 7 deletions

View File

@ -2,7 +2,7 @@
# Netmon Nodewatcher (C) 2010-2012 Freifunk Oldenburg
# License; GPL v3
SCRIPT_VERSION="31"
SCRIPT_VERSION="32"
test -f /tmp/started || exit
@ -168,17 +168,22 @@ crawl() {
BATMAN_ADV_INTERFACES=$BATMAN_ADV_INTERFACES"<$iface><name>$iface</name><status>$status</status></$iface>"
done
# Build a list of direct neighbors
batman_adv_originators=$(awk \
'BEGIN { FS=" "; i=0 }
/O/ { next }
/B/ { next }
{ sub("\\(", "", $0)
'BEGIN { FS=" "; i=0 } # set the delimiter to " "
/O/ { next } # ignore lines with O (will remove second line)
/B/ { next } # ignore line with B (will remove first line)
{ sub("\\(", "", $0) # remove parentheses
sub("\\)", "", $0)
sub("\\[", "", $0)
sub("\\]:", "", $0)
sub(" ", " ", $0)
printf "<originator_"i"><originator>"$1"</originator><link_quality>"$3"</link_quality><nexthop>"$4"</nexthop><last_seen>"$2"</last_seen><outgoing_interface>"$5"</outgoing_interface></originator_"i">"
i++
o=$1".*"$1 # build a regex to find lines that contains the $1 (=originator) twice
if ($0 ~ o) # filter for this regex (will remove entries without direct neighbor)
{
printf "<originator_"i"><originator>"$1"</originator><link_quality>"$3"</link_quality><nexthop>"$4"</nexthop><last_seen>"$2"</last_seen><outgoing_interface>"$5"</outgoing_interface></originator_"i">"
i++
}
}' /sys/kernel/debug/batman_adv/bat0/originators)
batman_adv_gateway_mode=$(batctl gw)