[linux-merge]linux integration; annotated tag, v5.2-rc7, created. v5.2-rc7
by postmaster@open-mesh.org
The annotated tag, v5.2-rc7 has been created
at dde2fa21d081aa5152511f1b70d53dfa0bdc0556 (tag)
tagging 6fbc7275c7a9ba97877050335f290341a1fd8dbf (commit)
replaces v5.2-rc6
tagged by Linus Torvalds
on Sun Jun 30 11:25:43 2019 +0800
- Shortlog ------------------------------------------------------------
Linux 5.2-rc7
-----BEGIN PGP SIGNATURE-----
iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAl0YK7ceHHRvcnZhbGRz
QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiGWfcH/36ep8GZHY9H1ARV
RJJoGoMnwENoq2o4eKhH3iZgUIGPq2uonazequhePwnIsrOdFGT7AeMHWSW7W0o4
wNlNFdUrTe0bvU00m+YtDwNIqgNCnFEoUbqn9H+VhAAWpSydKvhh2mlebTFO50KN
hb9+jh59Q8tbxrQdCuNF6yJATdf4hcj1V/ZZMGgF34kx+dFY4wOooSfu/eaIxXIl
fBDKN9K4Mmw8HWJvebV+ocOMZ7Zqknt1lbjx69OxpJmgxhb2Ks7heqSZanLTBPBB
oZxOlEdNPSyOjBQUlsDC2S8VJ7g5gINZk1JcFjByzE7cIPOQ2UXE72R++wwANngm
SR054NQ=
=WlA8
-----END PGP SIGNATURE-----
-----------------------------------------------------------------------
--
linux integration
3 years, 7 months
[linux-merge]linux integration; annotated tag, batadv-next-for-davem-20190627v2, created. batadv-next-for-davem-20190627v2
by postmaster@open-mesh.org
The annotated tag, batadv-next-for-davem-20190627v2 has been created
at f76a1f25ec91ba00209a702b1c37d1d132c462a3 (tag)
tagging 11d458c1cb9b24ac899b1ec6284676f6b1914305 (commit)
replaces v5.2-rc1
tagged by Simon Wunderlich
on Fri Jun 28 15:53:09 2019 +0200
- Shortlog ------------------------------------------------------------
This feature/cleanup patchset includes the following patches:
- bump version strings, by Simon Wunderlich
- fix includes for _MAX constants, atomic functions and fwdecls,
by Sven Eckelmann (3 patches)
- shorten multicast tt/tvlv worker spinlock section, by Linus Luessing
- routeable multicast preparations: implement MAC multicast filtering,
by Linus Luessing (2 patches, David Millers comments integrated)
- remove return value checks for debugfs_create, by Greg Kroah-Hartman
- add routable multicast optimizations, by Linus Luessing (2 patches)
-----BEGIN PGP SIGNATURE-----
iQJKBAABCgA0FiEE1ilQI7G+y+fdhnrfoSvjmEKSnqEFAl0WG8UWHHN3QHNpbW9u
d3VuZGVybGljaC5kZQAKCRChK+OYQpKeoWU9D/9bzRACAW/jwDqVw9NVk6kpjzXa
fRj+4raXjDCug67XLdWd50KW+gen5HkkkOonu96Iew6ZGceTvqOciPKdVXnjH30n
2Bi/+K56LYWomaUMWD+aVhjgEKOIjDYd1ueqZCGsMrIFuhA5MonFWrigpSiQv0Gr
s0cbxbKOl5EO+lGFgySYznVdJ/K+9RlHyGB+hkthg9CAFaJX92wvwcFW37+cLgOS
3B6T1PylyWn72uPfac2Jd0M8yQkPaNtZqwJBj8Y0wJ7cVfj29p/VZdlCn/g5oRKT
VtRnuukOWNGn942+C88pl4YhC9rTipFb4qd9sgj5oDlj5d6B9+ZHy8vyhFQEByzJ
2l4rjkNIjwfEkw3QIxZT9/HFnyymrT08sGUtGzKAhIUcwXAe0Zm83EazGzig0UQ3
hjXZRloPldQ93CnboychqX7erDz3qGBTb+v+T+JDXzV0bR5UD4VWs/X2K6tls0nB
bacin9O7VZgo2uaxkrzNKxzRKYPFn8LbpSitINZEYbNllncdCFfhEQ3depdc//SL
WachCKPkwLRXSJCIXjnhGQSmLR4SvTP6xucr9ImwpE12Px4DWRGv8jux289q3flu
ZdX2xAUsLMLsbKjELwAJrgH1HaKNZhsw16UxCc4QSNqe9RhwD/Qc/O6Gj11ONhGn
6ury81y2zFpBu4Acrg==
=nP3L
-----END PGP SIGNATURE-----
Greg Kroah-Hartman (1):
batman-adv: no need to check return value of debugfs_create functions
Linus Lüssing (5):
batman-adv: mcast: shorten multicast tt/tvlv worker spinlock section
batman-adv: mcast: collect softif listeners from IP lists instead
batman-adv: mcast: avoid redundant multicast TT entries with bridges
batman-adv: mcast: detect, distribute and maintain multicast router presence
batman-adv: mcast: apply optimizations for routable packets, too
Simon Wunderlich (1):
batman-adv: Start new development cycle
Sven Eckelmann (3):
batman-adv: Fix includes for *_MAX constants
batman-adv: Add missing include for atomic functions
batman-adv: Use includes instead of fwdecls
-----------------------------------------------------------------------
--
linux integration
3 years, 7 months
[batman-adv] master: batman-adv: Get inet(6) device inside RCU protected region (e2b064ff)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit e2b064ff5cf53e75fb8176b1c749474366a20ab9
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Thu Jun 27 19:22:06 2019 +0200
batman-adv: Get inet(6) device inside RCU protected region
It is not necessary to get the inet(6)_dev outside of the rcu protected
region by using reference counting. Instead, the in(6)_dev_get can be
replaced by the non-refcnt function and everything can be moved inside the
rcu protected region.
Fixes: 2b0f11124aad ("batman-adv: mcast: collect softif listeners from IP lists instead")
Reported-by: David Miller <davem(a)davemloft.net>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
e2b064ff5cf53e75fb8176b1c749474366a20ab9
net/batman-adv/multicast.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 40ceab95..67d7f830 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -379,11 +379,14 @@ batadv_mcast_mla_softif_get_ipv4(struct net_device *dev,
if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV4)
return 0;
- in_dev = in_dev_get(dev);
- if (!in_dev)
+ rcu_read_lock();
+
+ in_dev = __in_dev_get_rcu(dev);
+ if (!in_dev) {
+ rcu_read_unlock();
return 0;
+ }
- rcu_read_lock();
for (pmc = rcu_dereference(in_dev->mc_list); pmc;
pmc = rcu_dereference(pmc->next_rcu)) {
if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
@@ -410,7 +413,6 @@ batadv_mcast_mla_softif_get_ipv4(struct net_device *dev,
ret++;
}
rcu_read_unlock();
- in_dev_put(in_dev);
return ret;
}
@@ -444,9 +446,13 @@ batadv_mcast_mla_softif_get_ipv6(struct net_device *dev,
if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6)
return 0;
- in6_dev = in6_dev_get(dev);
- if (!in6_dev)
+ rcu_read_lock();
+
+ in6_dev = __in6_dev_get(dev);
+ if (!in6_dev) {
+ rcu_read_unlock();
return 0;
+ }
read_lock_bh(&in6_dev->lock);
for (pmc6 = in6_dev->mc_list; pmc6; pmc6 = pmc6->next) {
@@ -479,7 +485,7 @@ batadv_mcast_mla_softif_get_ipv6(struct net_device *dev,
ret++;
}
read_unlock_bh(&in6_dev->lock);
- in6_dev_put(in6_dev);
+ rcu_read_unlock();
return ret;
}
3 years, 7 months
[linux-merge]linux integration; branch, batadv/net-next-v1, created. v5.2-rc1-10-g8a8a79f53b42
by postmaster@open-mesh.org
The branch, batadv/net-next-v1 has been created
at 8a8a79f53b4210c55557d1148e925b0f385c1bf7 (commit)
- Shortlog ------------------------------------------------------------
commit 8a8a79f53b4210c55557d1148e925b0f385c1bf7
Author: Linus Lüssing <linus.luessing(a)c0d3.blue>
Date: Tue Jun 11 22:58:41 2019 +0200
batman-adv: mcast: apply optimizations for routable packets, too
Now that we not only track the presence of multicast listeners but also
multicast routers we can safely apply group-aware multicast-to-unicast
forwarding to packets with a destination address of scope greater than
link-local as well.
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit cd0c2051ddd5274db345352070b3799d70672de6
Author: Linus Lüssing <linus.luessing(a)c0d3.blue>
Date: Tue Jun 11 22:58:40 2019 +0200
batman-adv: mcast: detect, distribute and maintain multicast router presence
To be able to apply our group aware multicast optimizations to packets
with a scope greater than link-local we need to not only keep track of
multicast listeners but also multicast routers.
With this patch a node detects the presence of multicast routers on
its segment by checking if
/proc/sys/net/ipv{4,6}/conf/<bat0|br0(bat)>/mc_forwarding is set for one
thing. This option is enabled by multicast routing daemons and needed
for the kernel's multicast routing tables to receive and route packets.
For another thing if a bridge is configured on top of bat0 then the
presence of an IPv6 multicast router behind this bridge is currently
detected by checking for an IPv6 multicast "All Routers Address"
(ff02::2). This should later be replaced by querying the bridge, which
performs proper, RFC4286 compliant Multicast Router Discovery (our
simplified approach includes more hosts than necessary, most notably
not just multicast routers but also unicast ones and is not applicable
for IPv4).
If no multicast router is detected then this is signalized via the new
BATADV_MCAST_WANT_NO_RTR4 and BATADV_MCAST_WANT_NO_RTR6
multicast tvlv flags.
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit b5f7d55f4ee7128af75366e3ae2272cc7e1bda6c
Author: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Date: Fri Jun 14 09:11:23 2019 +0200
batman-adv: no need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the
return value. The function can work or not, but the code logic should
never do something different based on this.
Because we don't care if debugfs works or not, this trickles back a bit
so we can clean things up by making some functions return void instead
of an error value that is never going to fail.
Cc: Marek Lindner <mareklindner(a)neomailbox.ch>
Cc: Simon Wunderlich <sw(a)simonwunderlich.de>
Cc: Antonio Quartulli <a(a)unstable.cc>
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: b.a.t.m.a.n(a)lists.open-mesh.org
Cc: netdev(a)vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
[sven(a)narfation.org: drop unused variables]
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit 8e1d6c8709b66f00c978531e4d51fc189134a4ef
Author: Linus Lüssing <linus.luessing(a)c0d3.blue>
Date: Sun May 26 18:35:50 2019 +0200
batman-adv: mcast: avoid redundant multicast TT entries with bridges
When a bridge is added on top of bat0 we set the WANT_ALL_UNSNOOPABLES
flag. Which means we sign up for all traffic for ff02::1/128 and
224.0.0.0/24.
When the node itself had IPv6 enabled or joined a group in 224.0.0.0/24
itself then so far this would result in a multicast TT entry which is
redundant to the WANT_ALL_UNSNOOPABLES.
With this patch such redundant TT entries are avoided.
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit 8a13258f379d98f9454d25a6ed9df8c6c5d20098
Author: Linus Lüssing <linus.luessing(a)c0d3.blue>
Date: Sun May 26 18:35:49 2019 +0200
batman-adv: mcast: collect softif listeners from IP lists instead
Instead of collecting multicast MAC addresses from the netdev hw mc
list collect a node's multicast listeners from the IP lists and convert
those to MAC addresses.
This allows to exclude addresses of specific scope later. On a
multicast MAC address the IP destination scope is not visible anymore.
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit 6bc4544021f82283f0949f94494011730ecdd084
Author: Linus Lüssing <linus.luessing(a)c0d3.blue>
Date: Tue May 7 06:08:26 2019 +0200
batman-adv: mcast: shorten multicast tt/tvlv worker spinlock section
It is not necessary to hold the mla_lock spinlock during the whole
multicast tt/tvlv worker callback. Just holding it during the checks and
updates of the bat_priv stored multicast flags and mla_list is enough.
Therefore this patch splits batadv_mcast_mla_tvlv_update() in two:
batadv_mcast_mla_flags_get() at the beginning of the worker to gather
and calculate the new multicast flags, which does not need any locking
as it neither reads from nor writes to bat_priv->mcast.
And batadv_mcast_mla_flags_update() at the end of the worker which
commits the newly calculated flags and lists to bat_priv->mcast and
therefore needs the lock.
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit 68a600de9afc2134aa24d0cce539b98a0acb68b1
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Fri May 24 20:11:17 2019 +0200
batman-adv: Use includes instead of fwdecls
While it can be slightly beneficial for the build performance to use
forward declarations instead of includes, the handling of them together
with changes in the included headers makes it unnecessary complicated and
fragile. Just replace them with actual includes since some parts (hwmon,
..) of the kernel even request avoidance of forward declarations and net/
is mostly not using them in *.c file.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit 47d4522dd5130361d463b47f0e9a687c4b6697c2
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Fri May 24 16:51:29 2019 +0200
batman-adv: Add missing include for atomic functions
main.h is using atomic_add_unless and log.h atomic_read. The main
header linux/atomic.h should be included for these files.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit e1928752988bd95316676fea234475327726e22d
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Fri May 24 16:28:50 2019 +0200
batman-adv: Fix includes for *_MAX constants
The commit 54d50897d544 ("linux/kernel.h: split *_MAX and *_MIN macros into
<linux/limits.h>") moved the U32_MAX/INT_MAX/ULONG_MAX from linux/kernel.h
to linux/limits.h. Adjust the includes accordingly.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
commit eef98918c88eaeb922e6e82b983419cb2acfda5b
Author: Simon Wunderlich <sw(a)simonwunderlich.de>
Date: Sun Apr 7 09:00:57 2019 +0200
batman-adv: Start new development cycle
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
-----------------------------------------------------------------------
--
linux integration
3 years, 7 months
[linux-merge]linux integration; annotated tag, batadv-next-for-davem-20190627, deleted. v5.2-rc1-10-g8a8a79f53b42
by postmaster@open-mesh.org
The annotated tag, batadv-next-for-davem-20190627 has been deleted
was 0613fa4d2dea22b1ae21e6b70b82b24d933429ed
-----------------------------------------------------------------------
tag batadv-next-for-davem-20190627
This feature/cleanup patchset includes the following patches:
- bump version strings, by Simon Wunderlich
- fix includes for _MAX constants, atomic functions and fwdecls,
by Sven Eckelmann (3 patches)
- shorten multicast tt/tvlv worker spinlock section, by Linus Luessing
- routeable multicast preparations: implement MAC multicast filtering,
by Linus Luessing (2 patches)
- remove return value checks for debugfs_create, by Greg Kroah-Hartman
- add routable multicast optimizations, by Linus Luessing (2 patches)
-----BEGIN PGP SIGNATURE-----
iQJKBAABCgA0FiEE1ilQI7G+y+fdhnrfoSvjmEKSnqEFAl0UnH8WHHN3QHNpbW9u
d3VuZGVybGljaC5kZQAKCRChK+OYQpKeoaSDD/9bnC1Ir+6I6pMbXR5cGc24mZ3O
4pz/dM39poO3WEh4W4EFE7G/Lw0705FP+PMRARLDtN5nnOC+QJaNc9jTQoY7VveO
qsnUlFlPX5SV4+Jr2GoOb+k5r6ZgBbkoBmEoryDVGILBxr2wgFqS2zkYN84rH0ta
8O7iThrbA1tW8I0ej+EZC93zvguKQE76OdrJAx6BEdEOzp6JO0/I7yBfoLphj/33
5tUyILNQC1oaFk/dEuigrUJRNDEAJHgP4YLvapdhSogoouJBH9gv+M+lqhxGzG6Z
LAcElBks5FeXFCXkRBknTjUdudK8o+WJMUZEsB2DhJ7CdSQSs6+kiwpxV5hjvuAU
/JNNviIm3iZD5Bi/QHeyZ6IZsH/xYUfQ1qAuJSr8Eits+2PbEa6ql39hfjPCSHND
rx2JjazfJh5HeAglp9sFY9JqWZ/dDxw06IJk7Jdi8OEJULFaoZEV1fRcpRKIKaQ7
yWI00NPyaCq3apHoOxd/2BJovLGLYYRTAiQkWuT1qAm4xrWGW5PIeNGPF7H2/e/k
ORcuIatF7wsIbkMx76FZXS1nwQ3JKYAIA0hN9by5kSHHk18hyi7e5XC/fVUgQuqp
dl+l/7oQEh6YR86TWyKO0zrxqdC/f5s6DBQjIplyDhN6rSaB9EXW8jHO3PWEoWUR
99scR+a/dq4MfdwVYg==
=gTw0
-----END PGP SIGNATURE-----
8a8a79f53b4210c55557d1148e925b0f385c1bf7 batman-adv: mcast: apply optimizations for routable packets, too
-----------------------------------------------------------------------
--
linux integration
3 years, 7 months
[alfred] master: alfred: vis: Use rtnl to query list of hardifs of meshif (a34f044)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/alfred
On branch : master
>---------------------------------------------------------------
commit a34f044de561ce90f67b5760059f818bfb35b449
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Wed Jun 19 21:38:09 2019 +0200
alfred: vis: Use rtnl to query list of hardifs of meshif
The normal way of network related programs to query the state of interfaces
is to use the rtnetlink. Most of these data can also be queried via sysfs
but it is better to use the same way for both retrieving the list of
interfaces and modifying the list of interfaces.
Also the sysfs files are deprecated and cause warnings when access:
batman_adv: [Deprecated]: batadv-vis (pid 832) Use of sysfs file "mesh_iface".
Use batadv genl family instead
In worst case, the file doesn't even exist when batman-adv was compiled
without sysfs support.
Reported-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
a34f044de561ce90f67b5760059f818bfb35b449
vis/vis.c | 170 +++++++++++++++++++++++++++++++++++++++++++++-----------------
vis/vis.h | 1 -
2 files changed, 123 insertions(+), 48 deletions(-)
diff --git a/vis/vis.c b/vis/vis.c
index beaeca1..37956b1 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -372,70 +372,146 @@ static void clear_lists(struct globals *globals)
}
}
-static int register_interfaces(struct globals *globals)
+static int query_rtnl_link(int ifindex, nl_recvmsg_msg_cb_t func, void *arg)
{
- DIR *iface_base_dir;
- struct dirent *iface_dir;
- char *path_buff, *file_content;
- char *content_newline;
+ struct ifinfomsg rt_hdr = {
+ .ifi_family = IFLA_UNSPEC,
+ };
+ struct nl_sock *sock;
+ struct nl_msg *msg;
+ struct nl_cb *cb;
+ int err = 0;
+ int ret;
- path_buff = malloc(PATH_BUFF_LEN);
- if (!path_buff) {
- perror("Error - could not allocate path buffer");
- goto err;
+ sock = nl_socket_alloc();
+ if (!sock)
+ return -ENOMEM;
+
+ ret = nl_connect(sock, NETLINK_ROUTE);
+ if (ret < 0) {
+ err = -ENOMEM;
+ goto err_free_sock;
}
- iface_base_dir = opendir(SYS_IFACE_PATH);
- if (!iface_base_dir) {
- fprintf(stderr, "Error - the directory '%s' could not be read: %s\n",
- SYS_IFACE_PATH, strerror(errno));
- fprintf(stderr, "Is the batman-adv module loaded and sysfs mounted ?\n");
- goto err_buff;
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb) {
+ err = -ENOMEM;
+ goto err_free_sock;
}
- while ((iface_dir = readdir(iface_base_dir)) != NULL) {
- snprintf(path_buff, PATH_BUFF_LEN, SYS_MESH_IFACE_FMT, iface_dir->d_name);
- file_content = read_file(path_buff);
- if (!file_content)
- continue;
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, func, arg);
- if (file_content[strlen(file_content) - 1] == '\n')
- file_content[strlen(file_content) - 1] = '\0';
+ msg = nlmsg_alloc_simple(RTM_GETLINK, NLM_F_REQUEST | NLM_F_DUMP);
+ if (!msg) {
+ err = -ENOMEM;
+ goto err_free_cb;
+ }
- if (strcmp(file_content, "none") == 0)
- goto free_line;
+ ret = nlmsg_append(msg, &rt_hdr, sizeof(rt_hdr), NLMSG_ALIGNTO);
+ if (ret < 0) {
+ err = -ENOMEM;
+ goto err_free_msg;
+ }
- if (strcmp(file_content, globals->interface) != 0)
- goto free_line;
+ ret = nla_put_u32(msg, IFLA_MASTER, ifindex);
+ if (ret < 0) {
+ err = -ENOMEM;
+ goto err_free_msg;
+ }
- free(file_content);
- file_content = NULL;
+ ret = nl_send_auto_complete(sock, msg);
+ if (ret < 0)
+ goto err_free_msg;
- snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, iface_dir->d_name);
- file_content = read_file(path_buff);
- if (!file_content)
- continue;
+ nl_recvmsgs(sock, cb);
- content_newline = strstr(file_content, "\n");
- if (content_newline)
- *content_newline = '\0';
+err_free_msg:
+ nlmsg_free(msg);
+err_free_cb:
+ nl_cb_put(cb);
+err_free_sock:
+ nl_socket_free(sock);
- if (strcmp(file_content, "active") == 0)
- get_if_index_byname(globals, iface_dir->d_name);
+ return err;
+}
-free_line:
- free(file_content);
- file_content = NULL;
- }
+struct register_interfaces_rtnl_arg {
+ struct globals *globals;
+ int ifindex;
+};
- free(path_buff);
- closedir(iface_base_dir);
- return EXIT_SUCCESS;
+static struct nla_policy link_policy[IFLA_MAX + 1] = {
+ [IFLA_IFNAME] = { .type = NLA_STRING, .maxlen = IFNAMSIZ },
+ [IFLA_MASTER] = { .type = NLA_U32 },
+};
+
+static int register_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
+{
+ struct register_interfaces_rtnl_arg *register_arg = arg;
+ struct nlattr *attrs[IFLA_MAX + 1];
+ char path_buff[PATH_BUFF_LEN];
+ struct ifinfomsg *ifm;
+ char *content_newline;
+ char *file_content;
+ char *ifname;
+ int master;
+ int ret;
+
+ ifm = nlmsg_data(nlmsg_hdr(msg));
+ ret = nlmsg_parse(nlmsg_hdr(msg), sizeof(*ifm), attrs, IFLA_MAX,
+ link_policy);
+ if (ret < 0)
+ goto err;
+
+ if (!attrs[IFLA_IFNAME])
+ goto err;
+
+ if (!attrs[IFLA_MASTER])
+ goto err;
+
+ ifname = nla_get_string(attrs[IFLA_IFNAME]);
+ master = nla_get_u32(attrs[IFLA_MASTER]);
+
+ /* required on older kernels which don't prefilter the results */
+ if (master != register_arg->ifindex)
+ goto err;
+
+ snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, ifname);
+ file_content = read_file(path_buff);
+ if (!file_content)
+ goto free_file;
+
+ content_newline = strstr(file_content, "\n");
+ if (content_newline)
+ *content_newline = '\0';
+
+ if (strcmp(file_content, "active") != 0)
+ goto err;
+
+ get_if_index_byname(register_arg->globals, ifname);
-err_buff:
- free(path_buff);
+free_file:
+ free(file_content);
+ file_content = NULL;
err:
- return EXIT_FAILURE;
+ return NL_OK;
+}
+
+static int register_interfaces(struct globals *globals)
+{
+ struct register_interfaces_rtnl_arg register_arg = {
+ .globals = globals,
+ };
+
+ register_arg.ifindex = if_nametoindex(globals->interface);
+ if (!globals->interface)
+ return EXIT_FAILURE;
+
+
+ query_rtnl_link(register_arg.ifindex, register_interfaces_rtnl_parse,
+ ®ister_arg);
+
+ return EXIT_SUCCESS;
}
static const int parse_orig_list_mandatory[] = {
diff --git a/vis/vis.h b/vis/vis.h
index 178406c..36bdecc 100644
--- a/vis/vis.h
+++ b/vis/vis.h
@@ -25,7 +25,6 @@
#define SYS_IFACE_PATH "/sys/class/net"
#define DEBUG_BATIF_PATH_FMT "%s/batman_adv/%s"
-#define SYS_MESH_IFACE_FMT SYS_IFACE_PATH"/%s/batman_adv/mesh_iface"
#define SYS_IFACE_STATUS_FMT SYS_IFACE_PATH"/%s/batman_adv/iface_status"
3 years, 7 months
[alfred] master: alfred: vis: Retrieve hardif status via generic netlink (0fc6e66)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/alfred
On branch : master
>---------------------------------------------------------------
commit 0fc6e6674428ce7085b07645895ef837604e18b5
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Wed Jun 19 21:38:10 2019 +0200
alfred: vis: Retrieve hardif status via generic netlink
The batman-adv kernel module can now be compiled without support for sysfs.
But the batadv-vis interface retriever can only get the status via the per
hardif sysfs file iface_status. To still have some information, use
BATADV_CMD_GET_HARDIF to retrieve the status and fall back to sysfs when
the status could not retrieved via generic netlink.
This also solved the warning about deprecated sysfs file access
batman_adv: [Deprecated]: batadv-vis (pid 1365) Use of sysfs file "iface_status".
Use batadv genl family instead
Reported-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
0fc6e6674428ce7085b07645895ef837604e18b5
vis/vis.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 128 insertions(+), 16 deletions(-)
diff --git a/vis/vis.c b/vis/vis.c
index 37956b1..9474563 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -27,6 +27,8 @@
#include "netlink.h"
#include "debugfs.h"
+#define IFACE_STATUS_LEN 256
+
static struct globals vis_globals;
struct vis_netlink_opts {
@@ -435,6 +437,131 @@ err_free_sock:
return err;
}
+static int get_iface_status_netlink_parse(struct nl_msg *msg, void *arg)
+{
+ struct nlattr *attrs[NUM_BATADV_ATTR];
+ struct nlmsghdr *nlh = nlmsg_hdr(msg);
+ char *iface_status = arg;
+ struct genlmsghdr *ghdr;
+
+ if (!genlmsg_valid_hdr(nlh, 0))
+ return NL_OK;
+
+ ghdr = nlmsg_data(nlh);
+ if (ghdr->cmd != BATADV_CMD_GET_HARDIF)
+ return NL_OK;
+
+ if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
+ genlmsg_len(ghdr), batadv_netlink_policy))
+ return NL_OK;
+
+ if (attrs[BATADV_ATTR_ACTIVE])
+ strncpy(iface_status, "active\n", IFACE_STATUS_LEN);
+ else
+ strncpy(iface_status, "inactive\n", IFACE_STATUS_LEN);
+
+ iface_status[IFACE_STATUS_LEN - 1] = '\0';
+
+ return NL_STOP;
+}
+
+static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
+ char *iface_status)
+{
+ char *ret_status = NULL;
+ struct nl_sock *sock;
+ struct nl_msg *msg;
+ int batadv_family;
+ struct nl_cb *cb;
+ int ret;
+
+ iface_status[0] = '\0';
+
+ sock = nl_socket_alloc();
+ if (!sock)
+ return NULL;
+
+ ret = genl_connect(sock);
+ if (ret < 0)
+ goto err_free_sock;
+
+ batadv_family = genl_ctrl_resolve(sock, BATADV_NL_NAME);
+ if (batadv_family < 0)
+ goto err_free_sock;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ goto err_free_sock;
+
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, get_iface_status_netlink_parse,
+ iface_status);
+
+ msg = nlmsg_alloc();
+ if (!msg)
+ goto err_free_cb;
+
+ genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, batadv_family,
+ 0, 0, BATADV_CMD_GET_HARDIF, 1);
+
+ nla_put_u32(msg, BATADV_ATTR_MESH_IFINDEX, meshif);
+ nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX, hardif);
+
+ ret = nl_send_auto_complete(sock, msg);
+ if (ret < 0)
+ goto err_free_msg;
+
+ nl_recvmsgs(sock, cb);
+
+ if (strlen(iface_status) > 0)
+ ret_status = iface_status;
+
+err_free_msg:
+ nlmsg_free(msg);
+err_free_cb:
+ nl_cb_put(cb);
+err_free_sock:
+ nl_socket_free(sock);
+
+ return ret_status;
+}
+
+static bool interface_active(unsigned int meshif, unsigned int hardif,
+ const char *ifname)
+{
+ char iface_status[IFACE_STATUS_LEN];
+ char path_buff[PATH_BUFF_LEN];
+ char *file_content = NULL;
+ char *content_newline;
+ bool active = false;
+ char *status;
+
+ status = get_iface_status_netlink(meshif, hardif, iface_status);
+ if (!status) {
+ snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT,
+ ifname);
+ file_content = read_file(path_buff);
+ if (!file_content)
+ return false;
+
+ status = file_content;
+ }
+
+ content_newline = strstr(status, "\n");
+ if (content_newline)
+ *content_newline = '\0';
+
+ if (strcmp(status, "active") != 0)
+ goto free_file;
+
+ active = true;
+
+free_file:
+ free(file_content);
+ file_content = NULL;
+
+ return active;
+}
+
struct register_interfaces_rtnl_arg {
struct globals *globals;
int ifindex;
@@ -449,10 +576,7 @@ static int register_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
{
struct register_interfaces_rtnl_arg *register_arg = arg;
struct nlattr *attrs[IFLA_MAX + 1];
- char path_buff[PATH_BUFF_LEN];
struct ifinfomsg *ifm;
- char *content_newline;
- char *file_content;
char *ifname;
int master;
int ret;
@@ -476,23 +600,11 @@ static int register_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
if (master != register_arg->ifindex)
goto err;
- snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, ifname);
- file_content = read_file(path_buff);
- if (!file_content)
- goto free_file;
-
- content_newline = strstr(file_content, "\n");
- if (content_newline)
- *content_newline = '\0';
-
- if (strcmp(file_content, "active") != 0)
+ if (!interface_active(master, ifm->ifi_index, ifname))
goto err;
get_if_index_byname(register_arg->globals, ifname);
-free_file:
- free(file_content);
- file_content = NULL;
err:
return NL_OK;
}
3 years, 7 months
[batctl] master: Merge branch 'maint' (a153758)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : master
>---------------------------------------------------------------
commit a15375802e6a38074d7e36ad5eab49273b332069
Merge: b382c0a ce5f0ef
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Thu Jun 27 17:22:43 2019 +0200
Merge branch 'maint'
>---------------------------------------------------------------
a15375802e6a38074d7e36ad5eab49273b332069
interface.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
3 years, 7 months
[batctl] maint: batctl: Prefer netlink hardif status retrieval over sysfs (ce5f0ef)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : maint
>---------------------------------------------------------------
commit ce5f0efb35bff8a80992df63876bcac1d4a94867
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Wed Jun 19 09:37:50 2019 +0200
batctl: Prefer netlink hardif status retrieval over sysfs
The sysfs code in batman-adv was changed to print a deprecated warning when
sysfs files are accessed. The `batctl if` call would therefore cause
warnings like this in the kernel log:
batman_adv: [Deprecated]: batctl (pid 18540) Use of sysfs file "iface_status".
Use batadv genl family instead
It is now appropriate to try the generic netlink BATADV_CMD_GET_HARDIF
request first to get the status of the interface before falling back to
sysfs.
Reported-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
ce5f0efb35bff8a80992df63876bcac1d4a94867
interface.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/interface.c b/interface.c
index 5ff25a7..0a694c9 100644
--- a/interface.c
+++ b/interface.c
@@ -67,18 +67,18 @@ static int get_iface_status_netlink_parse(struct nl_msg *msg, void *arg)
static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
char *iface_status)
{
+ char *ret_status = NULL;
struct nl_sock *sock;
struct nl_msg *msg;
int batadv_family;
struct nl_cb *cb;
int ret;
- strncpy(iface_status, "<error reading status>\n", IFACE_STATUS_LEN);
- iface_status[IFACE_STATUS_LEN - 1] = '\0';
+ iface_status[0] = '\0';
sock = nl_socket_alloc();
if (!sock)
- return iface_status;
+ return NULL;
ret = genl_connect(sock);
if (ret < 0)
@@ -111,6 +111,9 @@ static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
nl_recvmsgs(sock, cb);
+ if (strlen(iface_status) > 0)
+ ret_status = iface_status;
+
err_free_msg:
nlmsg_free(msg);
err_free_cb:
@@ -118,7 +121,7 @@ err_free_cb:
err_free_sock:
nl_socket_free(sock);
- return iface_status;
+ return ret_status;
}
static struct nla_policy link_policy[IFLA_MAX + 1] = {
@@ -161,13 +164,17 @@ static int print_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
if (master != print_arg->ifindex)
goto err;
- snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT, ifname);
- ret = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS, 0, 0, 0);
- if (ret != EXIT_SUCCESS)
- status = get_iface_status_netlink(master, ifm->ifi_index,
- iface_status);
- else
- status = line_ptr;
+ status = get_iface_status_netlink(master, ifm->ifi_index, iface_status);
+ if (!status) {
+ snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT,
+ ifname);
+ ret = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS,
+ 0, 0, 0);
+ if (ret != EXIT_SUCCESS)
+ status = "<error reading status>\n";
+ else
+ status = line_ptr;
+ }
printf("%s: %s", ifname, status);
3 years, 7 months