Re: [B.A.T.M.A.N.] [PATCHv2] batctl: Use netlink to replace some of debugfs

Sven Eckelmann
2016-05-03T10:30:40Z

[-- Attachment #1: Type: text/plain, Size: 6076 bytes --]

[....]
> +static int originators_callback(struct nl_msg *msg, void *arg)
> +{
[...]
> +
> + if (!genlmsg_valid_hdr(nlh, 0)) {
> + fputs("Received invalid data from kernel.", stderr);
[...]
> +
> + orig = nla_data(attrs[BATADV_ATTR_ORIG_ADDRESS]);
> + neigh = nla_data(attrs[BATADV_ATTR_NEIGH_ADDRESS]);
> +
> + if (!if_indextoname(nla_get_u32(attrs[BATADV_ATTR_HARD_IFINDEX]),
> + ifname))
> + ifname[0] = '\0';
> +
> + if (attrs[BATADV_ATTR_FLAG_BEST])
> + c = '*';
> +
> + last_seen_msecs = nla_get_u32(attrs[BATADV_ATTR_LAST_SEEN_MSECS]);
> + last_seen = (float)last_seen_msecs / 1000.0;
> + last_seen_secs = last_seen_msecs / 1000;
> + last_seen_msecs = last_seen_msecs % 1000;
> +
> + /* skip timed out originators */
> + if (opts->read_opt & NO_OLD_ORIGS)
> + if (last_seen > opts->orig_timeout)
> + return NL_OK;
> +
> + if (attrs[BATADV_ATTR_THROUGHPUT]) {
> + throughput_kbits = nla_get_u32(attrs[BATADV_ATTR_THROUGHPUT]);
> + throughput_mbits = throughput_kbits / 1000;
> + throughput_kbits = throughput_kbits % 1000;
> +
> + if (!(opts->read_opt & USE_BAT_HOSTS)) {
> + printf(" %c %02x:%02x:%02x:%02x:%02x:%02x %4i.%03is (%9u.%1u) %02x:%02x:%02x:%02x:%02x:%02x [%10s]\n",

It looks like the header line is missing here. The debugfs table show
something like:

" Originator last-seen (#/255) Nexthop [outgoingIF]: Potential nexthops ...\n");

or

" Originator last-seen ( throughput) Nexthop [outgoingIF]: Potential nexthops ...\n");

the nexthops are also done differently now (not sure if this is better
but at least something which should be discussed):

originator
==========

netlink
-------

[B.A.T.M.A.N. adv 2016.1-62-g55e9890, MainIF/MAC: eth0/02:ba:de:af:fe:01 (bat0/f2:f2:2d:c3:71:8c BATMAN_IV)]
* 02:ba:de:af:fe:02 0.004s (251) 02:ba:de:af:fe:02 [ eth0]

debugfs
-------

[B.A.T.M.A.N. adv 2016.1-62-g55e9890, MainIF/MAC: eth0/02:ba:de:af:fe:01 (bat0 BATMAN_IV)]
Originator last-seen (#/255) Nexthop [outgoingIF]: Potential nexthops ...
02:ba:de:af:fe:02 0.024s (251) 02:ba:de:af:fe:02 [ eth0]: 02:ba:de:af:fe:02 (251)

The output "No batman nodes in range ...\n" also isn't there anymore
(not that I would miss it).

claimtable
==========

netlink
-------

[B.A.T.M.A.N. adv 2016.1-62-g55e9890, MainIF/MAC: eth0/02:ba:de:af:fe:01 (bat0/f2:f2:2d:c3:71:8c BATMAN_IV)]
Client VID Originator [o] (CRC )

debugfs
-------

Claims announced for the mesh bat0 (orig 02:ba:de:af:fe:01, group id 0x9053)
Client VID Originator [o] (CRC )

gateway
=======

netlink
-------

[B.A.T.M.A.N. adv 2016.1-62-g55e9890, MainIF/MAC: eth0/02:ba:de:af:fe:01 (bat0/f2:f2:2d:c3:71:8c BATMAN_IV)]
Router TQ Next Hop outgoingIf Bandwidth

debugfs
-------
Gateway (#/255) Nexthop [outgoingIF]: advertised uplink bandwidth ... [B.A.T.M.A.N. adv 2016.1-62-g55e9890, MainIF/MAC: eth0/02:ba:de:af:fe:01 (bat0)]
No gateways in range ...

transtable_global
=================

netlink
-------

[B.A.T.M.A.N. adv 2016.1-62-g55e9890, MainIF/MAC: eth0/02:ba:de:af:fe:01 (bat0/f2:f2:2d:c3:71:8c BATMAN_IV)]
Client VID Flags Last ttvn Via ttvn (CRC )
* 1a:fd:d4:3b:b9:06 0 [....] ( 2) 02:ba:de:af:fe:02 ( 2) (0x36e70691)
* 33:33:ff:3b:b9:06 -1 [....] ( 2) 02:ba:de:af:fe:02 ( 2) (0x777c331a)
* 01:00:5e:00:00:01 -1 [....] ( 2) 02:ba:de:af:fe:02 ( 2) (0x777c331a)
* 1a:fd:d4:3b:b9:06 -1 [....] ( 1) 02:ba:de:af:fe:02 ( 2) (0x777c331a)
* 33:33:00:00:00:01 -1 [....] ( 1) 02:ba:de:af:fe:02 ( 2) (0x777c331a)

debugfs
-------

Globally announced TT entries received via the mesh bat0
Client VID (TTVN) Originator (Curr TTVN) (CRC ) Flags
* 1a:fd:d4:3b:b9:06 0 ( 2) via 02:ba:de:af:fe:02 ( 2) (0x36e70691) [....]
* 33:33:ff:3b:b9:06 -1 ( 2) via 02:ba:de:af:fe:02 ( 2) (0x777c331a) [....]
* 01:00:5e:00:00:01 -1 ( 2) via 02:ba:de:af:fe:02 ( 2) (0x777c331a) [....]
* 1a:fd:d4:3b:b9:06 -1 ( 1) via 02:ba:de:af:fe:02 ( 2) (0x777c331a) [....]
* 33:33:00:00:00:01 -1 ( 1) via 02:ba:de:af:fe:02 ( 2) (0x777c331a) [....]

Odd to exchange the order of the flags. @Antonio, do you see some problem in
it? It seems to be nice because now tg and tl look similar.

transtable_local
================

netlink
-------

[B.A.T.M.A.N. adv 2016.1-62-g55e9890, MainIF/MAC: eth0/02:ba:de:af:fe:01 (bat0/f2:f2:2d:c3:71:8c BATMAN_IV)]
Client VID Flags Last seen (CRC )
f2:f2:2d:c3:71:8c 0 [.P....] 0.000 (0xd56fb81f)
f2:f2:2d:c3:71:8c -1 [.P....] 0.000 (0x01d52e50)
01:00:5e:00:00:01 -1 [.P....] 0.000 (0x01d52e50)
33:33:ff:c3:71:8c -1 [.P....] 0.000 (0x01d52e50)
33:33:00:00:00:01 -1 [.P....] 0.000 (0x01d52e50)

debugfs
-------

Locally retrieved addresses (from bat0) announced via TT (TTVN: 2):
Client VID Flags Last seen (CRC )
* f2:f2:2d:c3:71:8c 0 [.P....] 0.000 (0xd56fb81f)
* f2:f2:2d:c3:71:8c -1 [.P....] 0.000 (0x01d52e50)
* 01:00:5e:00:00:01 -1 [.P....] 0.000 (0x01d52e50)
* 33:33:ff:c3:71:8c -1 [.P....] 0.000 (0x01d52e50)
* 33:33:00:00:00:01 -1 [.P....] 0.000 (0x01d52e50)

I personally think that the new common header is nice and should be kept. "No
..." lines could also be be dropped. The header to the originators should be
added again and I am not sure about the new format (but cannot say anything
bad about it because it follows the style used in other debugfs files).

@Simon, could this new originator format be problematic when there is
alternating/bonding?

Kind regards,
Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]