Re: Using B.A.T.M.A.N.-Adv and scanning for neighbours
On Monday, 29 April 2024 16:16:21 CEST Furmans Hannes wrote: > Hello everyone! > > We have a setup with four Raspberry Pi, all in IBSS mode and connected via > B.A.T.M.A.N.. That all works fine. However we now have troubles scanning on > the Pis for the neighbours. [...] > Which is not what we expected. We hope to see the RSSI of our neighbours and > that should be possible, at least as I understand it. Why do you want to scan here? If you want to have the RSSI of your "connected" neighbors then just run: iw dev wlan0 station dump Btw. this is not really a batman-adv topic. If you want more information about the linux wireless stack then you should try the linux-wireless mailing list [1] or IRC channel [2] Kind regards, Sven [1] https://wireless.wiki.kernel.org/en/developers/mailinglists [2] https://wireless.wiki.kernel.org/en/users/support signature.asc Description: This is a digitally signed message part.
Re: [PATCH] batman-adv: Add flex array to struct batadv_tvlv_tt_data
On Tuesday, 2 April 2024 19:23:01 CEST Erick Archer wrote: > The "struct batadv_tvlv_tt_data" uses a dynamically sized set of > trailing elements. Specifically, it uses an array of structures of type > "batadv_tvlv_tt_vlan_data". So, use the preferred way in the kernel > declaring a flexible array [1]. > > The order in which the structure batadv_tvlv_tt_data and the structure > batadv_tvlv_tt_vlan_data are defined must be swap to avoid an incomplete > type error. > > Also, avoid the open-coded arithmetic in memory allocator functions [2] > using the "struct_size" macro and use the "flex_array_size" helper to > clarify some calculations, when possible. > > Moreover, the new structure member also allow us to avoid the open-coded > arithmetic on pointers in some situations. Take advantage of this. > > This code was detected with the help of Coccinelle, and audited and > modified manually. > > Link: > https://www.kernel.org/doc/html/next/process/deprecated.html#zero-length-and-one-element-arrays > [1] > Link: > https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments > [2] > Signed-off-by: Erick Archer > --- > Hi, > > I would like to add the "__counted_by(num_vlan)" tag to the new flex member > but I don't know if this line can affect it. > > ntohs(tt_data->num_vlan) Yes, num_vlan is a __be16. I could only identify the kernel-doc related scripts as consumer. But maybe they are more - so I would defer this question to kernel-hardening. And with this change, I get a lot of additional warnings (-Wsparse-all) cfg: BLA=n DAT=y DEBUG=y TRACING=n NC=y MCAST=n BATMAN_V=n net/batman-adv/translation-table.c:574:21: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:859:25: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:859:25: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:938:25: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:938:25: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:2932:16: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:2932:16: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:3378:21: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:3378:21: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:3982:30: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:3986:27: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:4026:30: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:4030:27: warning: using sizeof on a flexible structure net/batman-adv/translation-table.c:4032:23: warning: cast from restricted __be16 net/batman-adv/translation-table.c:4032:23: warning: restricted __be16 degrades to integer net/batman-adv/translation-table.c:4032:23: warning: incorrect type in argument 1 (different base types) net/batman-adv/translation-table.c:4032:23:expected unsigned long [usertype] factor1 net/batman-adv/translation-table.c:4032:23:got restricted __be16 [usertype] num_vlan [...] > num_vlan = ntohs(tt_data->num_vlan); > > - if (tvlv_value_len < sizeof(*tt_vlan) * num_vlan) > + flex_size = flex_array_size(tt_data, vlan_data, num_vlan); > + if (tvlv_value_len < flex_size) > return; This helper would need an #include of in net/batman-adv/translation-table.c [] > /** > @@ -4039,8 +4029,7 @@ static int batadv_tt_tvlv_unicast_handler_v1(struct > batadv_priv *bat_priv, > tt_data = tvlv_value; > tvlv_value_len -= sizeof(*tt_data); > > - tt_vlan_len = sizeof(struct batadv_tvlv_tt_vlan_data); > - tt_vlan_len *= ntohs(tt_data->num_vlan); > + tt_vlan_len = flex_array_size(tt_data, vlan_data, tt_data->num_vlan); This is definitely wrong on little endian systems. You first need to convert num_vlan from network (big endian) to host order. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [syzbot] [batman?] [bpf?] possible deadlock in lock_timer_base
On Tuesday, 19 March 2024 11:33:17 CET syzbot wrote: > syzbot has found a reproducer for the following issue on: > > HEAD commit:35c3e2791756 Revert "net: Re-use and set mono_delivery_tim.. > git tree: net > console output: https://syzkaller.appspot.com/x/log.txt?x=1056918118 > kernel config: https://syzkaller.appspot.com/x/.config?x=6fb1be60a193d440 > dashboard link: https://syzkaller.appspot.com/bug?extid=8983d6d4f7df556be565 > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) > 2.40 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13d9fa4e18 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=137afac918 > > Downloadable assets: > disk image: > https://storage.googleapis.com/syzbot-assets/26b55a26fc12/disk-35c3e279.raw.xz > vmlinux: > https://storage.googleapis.com/syzbot-assets/6f39fa55c828/vmlinux-35c3e279.xz > kernel image: > https://storage.googleapis.com/syzbot-assets/e1e0501539e6/bzImage-35c3e279.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+8983d6d4f7df556be...@syzkaller.appspotmail.com Sorry, this is a little bit off-topic. But how does sysbot figure out the subsystems (like "[batman?]"). Because neither the reproducer nor the backtrace nor the console output mention anything batman-adv related. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH] batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks
On Tuesday, 12 March 2024 19:16:28 CET Dmitry Antipov wrote: > Drop 'batadv_tt_local_entry_free_rcu()', 'batadv_tt_global_entry_free_rcu()' > and 'batadv_tt_orig_list_entry_free_rcu()' in favor of 'kfree_rcu()' in > 'batadv_tt_local_entry_release()', 'batadv_tt_global_entry_release()' and > 'batadv_tt_orig_list_entry_release()', respectively. > > Signed-off-by: Dmitry Antipov Ah, SLOB is gone and now this is possible. Acked-by: Sven Eckelmann Thanks, Sven signature.asc Description: This is a digitally signed message part.
[PATCH] batman-adv: Avoid infinite loop trying to resize local TT
If the MTU of one of an attached interface becomes too small to transmit the local translation table then it must be resized to fit inside all fragments (when enabled) or a single packet. But if the MTU becomes too low to transmit even the header + the VLAN specific part then the resizing of the local TT will never succeed. This can for example happen when the usable space is 110 bytes and 11 VLANs are on top of batman-adv. In this case, at least 116 byte would be needed. There will just be an endless spam of batman_adv: batadv0: Forced to purge local tt entries to fit new maximum fragment MTU (110) in the log but the function will never finish. Problem here is that the timeout will be halved all the time and will then stagnate at 0 and therefore never be able to reduce the table even more. There are other scenarios possible with a similar result. The number of BATADV_TT_CLIENT_NOPURGE entries in the local TT can for example be too high to fit inside a packet. Such a scenario can therefore happen also with only a single VLAN + 7 non-purgable addresses - requiring at least 120 bytes. While this should be handled proactively when: * interface with too low MTU is added * VLAN is added * non-purgeable local mac is added * MTU of an attached interface is reduced * fragmentation setting gets disabled (which most likely requires dropping attached interfaces) not all of these scenarios can be prevented because batman-adv is only consuming events without the the possibility to prevent these actions (non-purgable MAC address added, MTU of an attached interface is reduced). It is therefore necessary to also make sure that the code is able to handle also the situations when there were already incompatible system configuration are present. Cc: Fixes: f7f2fe494388 ("batman-adv: limit local translation table max size") Reported-by: Signed-off-by: Sven Eckelmann --- net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index b95c3676..2243cec1 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -3948,7 +3948,7 @@ void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface) spin_lock_bh(_priv->tt.commit_lock); - while (true) { + while (timeout) { table_size = batadv_tt_local_table_transmit_size(bat_priv); if (packet_size_max >= table_size) break; --- base-commit: 7d30b5a06020e8c4e53968e4086a0fa6e9fdd947 change-id: 20240212-infinite-tt-resize-285a0d33fff8 Best regards, -- Sven Eckelmann
Re: [syzbot] [batman?] BUG: soft lockup in sys_sendmsg
On Monday, 12 February 2024 11:26:24 CET syzbot wrote: > syzbot found the following issue on: > > HEAD commit:41bccc98fb79 Linux 6.8-rc2 > git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git > for-kernelci > console output: https://syzkaller.appspot.com/x/log.txt?x=1420011818 > kernel config: https://syzkaller.appspot.com/x/.config?x=451a1e62b11ea4a6 > dashboard link: https://syzkaller.appspot.com/bug?extid=a6a4b5bb3da165594cff > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) > 2.40 > userspace arch: arm64 > > Unfortunately, I don't have any reproducer for this issue yet. > > Downloadable assets: > disk image: > https://storage.googleapis.com/syzbot-assets/0772069e29cf/disk-41bccc98.raw.xz > vmlinux: > https://storage.googleapis.com/syzbot-assets/659d3f0755b7/vmlinux-41bccc98.xz > kernel image: > https://storage.googleapis.com/syzbot-assets/7780a45c3e51/Image-41bccc98.gz.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+a6a4b5bb3da165594...@syzkaller.appspotmail.com > #syz test >From 5984ace8f8df7cf8d6f98ded0eebe7d962028992 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Mon, 12 Feb 2024 13:10:33 +0100 Subject: [PATCH] batman-adv: Avoid infinite loop trying to resize local TT If the MTU of one of an attached interface becomes too small to transmit the local translation table then it must be resized to fit inside all fragments (when enabled) or a single packet. But if the MTU becomes too low to transmit even the header + the VLAN specific part then the resizing of the local TT will never succeed. This can for example happen when the usable space is 110 bytes and 11 VLANs are on top of batman-adv. In this case, at least 116 byte would be needed. There will just be an endless spam of batman_adv: batadv0: Forced to purge local tt entries to fit new maximum fragment MTU (110) in the log but the function will never finish. Problem here is that the timeout will be halved in each step and will then stagnate at 0 and therefore never be able to reduce the table even more. There are other scenarios possible with a similar result. The number of BATADV_TT_CLIENT_NOPURGE entries in the local TT can for example be too high to fit inside a packet. Such a scenario can therefore happen also with only a single VLAN + 7 non-purgable addresses - requiring at least 120 bytes. While this should be handled proactively when: * interface with too low MTU is added * VLAN is added * non-purgeable local mac is added * MTU of an attached interface is reduced * fragmentation setting gets disabled (which most likely requires dropping attached interfaces) not all of these scenarios can be prevented because batman-adv is only consuming events without the the possibility to prevent these actions (non-purgable MAC address added, MTU of an attached interface is reduced). It is therefore necessary to also make sure that the code is able to handle also the situations when there were already incompatible system configurations present. Cc: sta...@vger.kernel.org Fixes: a19d3d85e1b8 ("batman-adv: limit local translation table max size") Reported-by: syzbot+a6a4b5bb3da165594...@syzkaller.appspotmail.com Signed-off-by: Sven Eckelmann --- net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index b95c36765d04..2243cec18ecc 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -3948,7 +3948,7 @@ void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface) spin_lock_bh(_priv->tt.commit_lock); - while (true) { + while (timeout) { table_size = batadv_tt_local_table_transmit_size(bat_priv); if (packet_size_max >= table_size) break; -- 2.39.2 signature.asc Description: This is a digitally signed message part.
Re: [syzbot] [batman?] BUG: soft lockup in sys_sendmsg
On Monday, 12 February 2024 11:41:38 CET Eric Dumazet wrote: > This patch [1] looks suspicious Shouldn't be caused by this - but this might be another way to trigger the problem. The problem would be visible even without it when a mtu is explicitly set. But the reproducer is not available so I can't actually check what is going on. > I think batman-adv should reject too small MTU values. You are refering to the size calculated by batadv_tt_local_table_transmit_size(), right? And yes, I would agree that it looks suspicious and might not have been correctly integrated in batadv_max_header_len() when commit a19d3d85e1b8 ("batman-adv: limit local translation table max size") introduced the code. But I think we also need to remove interfaces again when receiving NETDEV_CHANGEMTU and an interface is not having the correctly sized anymore. So have to check how to do this the best way. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH 0/6] batctl: tcpdump: Fix problems detected during fuzzing
On Saturday, 27 January 2024 13:48:58 CET Sven Eckelmann wrote: > While many parts of batctl are rather simple, tcpdump is one of the most > complex parts - which unfortunately is also dealing all the time > with potentially harmful input. It is therefore a good idea to perform > some tests to figure out how bad the current state of the code is. The > findings will be presented here - including some information how other > people can reproduce these problems. Attached are also the actual reproducers. Kind regards, Sven 0001-parse_eth_hdr-missing-bat_hdr_len-check Description: Binary data 0002-dump_batman_icmp-tp_len_check Description: Binary data 0003-dump_ip-missing-ihl-validation Description: Binary data 0004-dump_ipv6-neigh-advert-len_check Description: Binary data 0005-dump_ipv6-neigh-solicit-len_check Description: Binary data 0006-dump_ip-unreachable-len_check Description: Binary data signature.asc Description: This is a digitally signed message part.
[PATCH 6/6] batctl: tcpdump: Fix ICMPv4 inner IPv4 header length check
dump_ip() is doing a length check for the inner (inside ICMP) IPv4 header length. But it is just assuming that the inner ICMPv4 header has ihl set to 5 - without actually checking for this. The more complex IPv4 header length check for the outer IPv4 header is missing before it tries to access the UDP header using the inner ihl IPv4 header length information. So it is possible that it tries to read outside of the received data. Fixes: 75d68356f3fa ("[batctl] tcpdump - add basic IPv4 support") Signed-off-by: Sven Eckelmann --- tcpdump.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tcpdump.c b/tcpdump.c index c253755..c6aca27 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -730,12 +730,20 @@ static void dump_ip(unsigned char *packet_buff, ssize_t buff_len, (size_t)buff_len - (iphdr->ihl * 4)); break; case ICMP_DEST_UNREACH: - LEN_CHECK((size_t)buff_len - (iphdr->ihl * 4) - sizeof(struct icmphdr), - sizeof(struct iphdr) + 8, "ICMP DEST_UNREACH"); - switch (icmphdr->code) { case ICMP_PORT_UNREACH: + LEN_CHECK((size_t)buff_len - (iphdr->ihl * 4) - sizeof(struct icmphdr), + sizeof(struct iphdr), "ICMP DEST_UNREACH"); + + /* validate inner IP header information */ tmp_iphdr = (struct iphdr *)(((char *)icmphdr) + sizeof(struct icmphdr)); + LEN_CHECK((size_t)buff_len - (iphdr->ihl * 4) - sizeof(struct icmphdr), + (size_t)(tmp_iphdr->ihl * 4), "ICMP DEST_UNREACH"); + LEN_CHECK((size_t)(tmp_iphdr->ihl * 4), sizeof(*iphdr), "ICMP DEST_UNREACH"); + + LEN_CHECK((size_t)buff_len - (iphdr->ihl * 4) - sizeof(struct icmphdr) - (tmp_iphdr->ihl * 4), + sizeof(*tmp_udphdr), "ICMP DEST_UNREACH"); + tmp_udphdr = (struct udphdr *)(((char *)tmp_iphdr) + (tmp_iphdr->ihl * 4)); printf("%s: ICMP ", ipdst); -- 2.39.2
[PATCH 5/6] batctl: tcpdump: Add missing ICMPv6 Neighbor Solicit length check
dump_ipv6() is doing a length check for the original ICMPv6 header length. But the neighbor solicitation (which is also handled by this function) is accessed without doing an additional length check. So it is possible that it tries to read outside of the received data. Fixes: 35b37756f4a3 ("add IPv6 support to tcpdump parser") Cc: Marco Dalla Torre Signed-off-by: Sven Eckelmann --- tcpdump.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tcpdump.c b/tcpdump.c index 2ae3909..c253755 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -652,6 +652,8 @@ static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len, (size_t)buff_len - sizeof(struct icmp6_hdr)); break; case ND_NEIGHBOR_SOLICIT: + LEN_CHECK((size_t)buff_len - (size_t)(sizeof(struct ip6_hdr)), + sizeof(*nd_neigh_sol), "ICMPv6 Neighbor Solicitation"); nd_neigh_sol = (struct nd_neighbor_solicit *)icmphdr; inet_ntop(AF_INET6, &(nd_neigh_sol->nd_ns_target), nd_nas_target, 40); -- 2.39.2
[PATCH 4/6] batctl: tcpdump: Add missing ICMPv6 Neighbor Advert length check
dump_ipv6() is doing a length check for the original ICMPv6 header length. But the neighbor advertisement (which is also handled by this function) is accessed without doing an additional length check. So it is possible that it tries to read outside of the received data. Fixes: 35b37756f4a3 ("add IPv6 support to tcpdump parser") Cc: Marco Dalla Torre Signed-off-by: Sven Eckelmann --- tcpdump.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tcpdump.c b/tcpdump.c index 3fdd7c3..2ae3909 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -659,6 +659,8 @@ static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len, nd_nas_target, buff_len); break; case ND_NEIGHBOR_ADVERT: + LEN_CHECK((size_t)buff_len - (size_t)(sizeof(struct ip6_hdr)), + sizeof(*nd_advert), "ICMPv6 Neighbor Advertisement"); nd_advert = (struct nd_neighbor_advert *)icmphdr; inet_ntop(AF_INET6, &(nd_advert->nd_na_target), nd_nas_target, 40); -- 2.39.2
[PATCH 3/6] batctl: tcpdump: Fix IPv4 header length check
dump_ip() is directly accessing the header in the header length check and assumes that ihl can be trusted. But when when ihl is set to something less than 5 then it would not even be possible to store the basic IPv4 header in it. But dump_ip would have still accepted it because it didn't check if there are at least enough bytes available to read the basic IPv4 header. So it is possible that it tries to read outside of the received data. Fixes: 75d68356f3fa ("[batctl] tcpdump - add basic IPv4 support") Signed-off-by: Sven Eckelmann --- tcpdump.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tcpdump.c b/tcpdump.c index 9bb4b9e..3fdd7c3 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -694,7 +694,9 @@ static void dump_ip(unsigned char *packet_buff, ssize_t buff_len, struct icmphdr *icmphdr; iphdr = (struct iphdr *)packet_buff; + LEN_CHECK((size_t)buff_len, sizeof(*iphdr), ip_string); LEN_CHECK((size_t)buff_len, (size_t)(iphdr->ihl * 4), ip_string); + LEN_CHECK((size_t)(iphdr->ihl * 4), sizeof(*iphdr), ip_string); if (!time_printed) print_time(); -- 2.39.2
[PATCH 2/6] batctl: tcpdump: Add missing throughput header length check
dump_batman_icmp() is only doing a length check for the original ICMP packet length. But the throughput packet (which is also handled by this function) is accessed without doing an additional length check. So it is possible that it tries to read outside of the received data. Fixes: f109b3473f86 ("batctl: introduce throughput meter support") Signed-off-by: Sven Eckelmann --- tcpdump.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tcpdump.c b/tcpdump.c index d15c32e..9bb4b9e 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -911,7 +911,6 @@ static void dump_batman_icmp(unsigned char *packet_buff, ssize_t buff_len, int r LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_icmp_packet), "BAT ICMP"); icmp_packet = (struct batadv_icmp_packet *)(packet_buff + sizeof(struct ether_header)); - tp = (struct batadv_icmp_tp_packet *)icmp_packet; if (!time_printed) print_time(); @@ -942,6 +941,10 @@ static void dump_batman_icmp(unsigned char *packet_buff, ssize_t buff_len, int r (size_t)buff_len - sizeof(struct ether_header)); break; case BATADV_TP: + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(*tp), "BAT TP"); + + tp = (struct batadv_icmp_tp_packet *)icmp_packet; + printf("%s: ICMP TP type %s (%hhu), id %hhu, seq %u, ttl %2d, v %d, length %zu\n", name, tp->subtype == BATADV_TP_MSG ? "MSG" : tp->subtype == BATADV_TP_ACK ? "ACK" : "N/A", -- 2.39.2
[PATCH 1/6] batctl: tcpdump: Fix missing sanity check for batman-adv header
parse_eth_hdr() is assuming that every ETH_P_BATMAN ethernet packet has a valid, minimal batman-adv header (packet_type, version, ttl) attached. But it doesn't actually check if the received buffer has enough bytes to access the two bytes packet_type + version. So it is possible that it tries to read outside of the received data. Fixes: 3bdfc388e74b ("implement simple tcpdump, first only batman packets") Signed-off-by: Sven Eckelmann --- tcpdump.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tcpdump.c b/tcpdump.c index d340af9..d15c32e 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -1167,6 +1167,9 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read dump_vlan(packet_buff, buff_len, read_opt, time_printed); break; case ETH_P_BATMAN: + /* check for batman-adv packet_type + version */ + LEN_CHECK(buff_len, sizeof(*eth_hdr) + 2, "BAT HEADER") + batman_ogm_packet = (struct batadv_ogm_packet *)(packet_buff + ETH_HLEN); if ((read_opt & COMPAT_FILTER) && -- 2.39.2
[PATCH 0/6] batctl: tcpdump: Fix problems detected during fuzzing
While many parts of batctl are rather simple, tcpdump is one of the most complex parts - which unfortunately is also dealing all the time with potentially harmful input. It is therefore a good idea to perform some tests to figure out how bad the current state of the code is. The findings will be presented here - including some information how other people can reproduce these problems. With afl++, it is possible to fuzz batctl tcpdump and find parsing errors (easier). But it needs an entry point to actually send data to. So for simplicity, a fuzzme subcommand was added which just gets new data from afl++ and then runs the main ethernet parsing function. diff --git a/split_pcap.py b/split_pcap.py new file mode 100755 index ..11a1f5ce8ec60fac141693b0449d5c3955f9ad28 --- /dev/null +++ b/split_pcap.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import sys + +from hashlib import sha256 +from scapy.utils import rdpcap + + +def main(): +for pcap in sys.argv[1:]: +packets = rdpcap(pcap) +for packet in packets: +m = sha256() +m.update(packet.load) +fname = m.hexdigest() +with open(fname, "wb") as f: +f.write(packet.load) + + +if __name__ == "__main__": +main() diff --git a/tcpdump.c b/tcpdump.c index 5e7c76c69bd192d7485958aafabc0e9264b41b90..d340af986f99bdf2e8e6dae0d91a641bc80e82a2 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -1556,3 +1556,41 @@ static int tcpdump(struct state *state __maybe_unused, int argc, char **argv) COMMAND(SUBCOMMAND, tcpdump, "td", 0, NULL, " \ttcpdump layer 2 traffic on the given interface"); + +__AFL_FUZZ_INIT(); + +static int fuzzme(struct state *state __maybe_unused, int argc, char **argv) +{ + dump_level = dump_level_all; + +#ifdef __AFL_HAVE_MANUAL_CONTROL + __AFL_INIT(); +#endif + + unsigned char *buf = __AFL_FUZZ_TESTCASE_BUF; + while (__AFL_LOOP(1)) { + int len = __AFL_FUZZ_TESTCASE_LEN; + + /* safety check from tcpdump */ + if ((size_t)len < sizeof(struct ether_header)) + continue; + + /* move into new buffer to allow ASAN to detect invalid memory access */ + unsigned char *p = malloc(len); + if (!p) + continue; + + memcpy(p, buf, len); + + /* function under test */ + parse_eth_hdr(p, len, 0, 0); + + /* drop buffer from asan */ + free(p); + } + + return 0; +} + +COMMAND(SUBCOMMAND, fuzzme, "fz", 0, NULL, To build the fuzzing test, it is necessary to build batctl slightly differently: make clean export AFL_USE_ASAN=1; CC=afl-clang-fast make V=s And the some input files (containing raw ethernet fames have to be generated from existing pcaps): mkdir in cd in ../split_pcap.py ~/wireshark-batman-adv/tests/* cd .. And then multiple afl++ fuzzer instances can be started. if [ -z "${STY}" ]; then echo "must be started inside a screen session" >&2 exit 1 fi for i in $(seq 1 $(nproc)); do start_mode=-M [ "${i}" = "1" ] || start_mode=-S screen afl-fuzz "${start_mode}" "fuzzer${i}" -i in -o out ./batctl fuzzme done The crashes can then be analyzed further by sending them to the fuzzme subcommand: ./batctl fuzzme < out/fuzzer1/crashes/id:00,sig:06,src:000528,time:12,execs:23992,op:havoc,rep:8 Signed-off-by: Sven Eckelmann --- Sven Eckelmann (6): batctl: tcpdump: Fix missing sanity check for batman-adv header batctl: tcpdump: Add missing throughput header length check batctl: tcpdump: Fix IPv4 header length check batctl: tcpdump: Add missing ICMPv6 Neighbor Advert length check batctl: tcpdump: Add missing ICMPv6 Neighbor Solicit length check batctl: tcpdump: Fix ICMPv4 inner IPv4 header length check tcpdump.c | 28 1 file changed, 24 insertions(+), 4 deletions(-) --- base-commit: a57de3183e67ec27cf96f1761e69d542e6dfac03 change-id: 20240127-tcpdump_fuzzing-736774906f60 Best regards, -- Sven Eckelmann
[PATCH] batman-adv: Drop usage of export.h
The linux/export.h include was introduced in commit f6977d91a992 ("batman-adv: Introduce missing headers for genetlink restructure") to have access to THIS_MODULE. But with commit 5b20755b7780 ("init: move THIS_MODULE from to "), it was moved and the include for export.h is no longer needed. Signed-off-by: Sven Eckelmann --- net/batman-adv/netlink.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index cda99753..6aff7cc1 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include --- base-commit: ecdc425a87d40eba44c9c094293d50d3e9a38b45 change-id: 20240122-no-export-header-0293ee4ccd11 Best regards, -- Sven Eckelmann
Re: [syzbot] [btrfs?] memory leak in corrupted
On Tuesday, 16 January 2024 10:27:20 CET syzbot wrote: > Hello, > > syzbot found the following issue on: > > HEAD commit:052d534373b7 Merge tag 'exfat-for-6.8-rc1' of git://git.ke.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=14620debe8 > kernel config: https://syzkaller.appspot.com/x/.config?x=a7031f9e71583b4a > dashboard link: https://syzkaller.appspot.com/bug?extid=ebe64cc5950868e77358 > compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for > Debian) 2.40 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16a344c1e8 > > Downloadable assets: > disk image: > https://storage.googleapis.com/syzbot-assets/82a7201eef4c/disk-052d5343.raw.xz > vmlinux: > https://storage.googleapis.com/syzbot-assets/ca12b4c31826/vmlinux-052d5343.xz > kernel image: > https://storage.googleapis.com/syzbot-assets/3f07360ba5a8/bzImage-052d5343.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+ebe64cc5950868e77...@syzkaller.appspotmail.com #syz test git://git.open-mesh.org/linux-merge.git a67d6793286ffab46b72b1afff5fb1f0ca55f2e1 Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [syzbot] [btrfs?] memory leak in corrupted
@Linus, this looks like something for you. On Tuesday, 16 January 2024 10:27:20 CET syzbot wrote: > syzbot found the following issue on: > > HEAD commit:052d534373b7 Merge tag 'exfat-for-6.8-rc1' of git://git.ke.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=14620debe8 > kernel config: https://syzkaller.appspot.com/x/.config?x=a7031f9e71583b4a > dashboard link: https://syzkaller.appspot.com/bug?extid=ebe64cc5950868e77358 > compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for > Debian) 2.40 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16a344c1e8 > > Downloadable assets: > disk image: > https://storage.googleapis.com/syzbot-assets/82a7201eef4c/disk-052d5343.raw.xz > vmlinux: > https://storage.googleapis.com/syzbot-assets/ca12b4c31826/vmlinux-052d5343.xz > kernel image: > https://storage.googleapis.com/syzbot-assets/3f07360ba5a8/bzImage-052d5343.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+ebe64cc5950868e77...@syzkaller.appspotmail.com The relevant line is the batadv_mcast_forw_tracker_tvlv_handler registration in batadv_mcast_init() which was introduced in commit 07afe1ba288c ("batman-adv: mcast: implement multicast packet reception and forwarding") And I can't find the batadv_tvlv_handler_unregister for BATADV_TVLV_MCAST_TRACKER in batadv_mcast_free() Kind regards, Sven > > BUG: memory leak > unreferenced object 0x88811c71a980 (size 64): > comm "syz-executor.7", pid 5063, jiffies 4294953937 > hex dump (first 32 bytes): > 00 00 00 00 00 00 00 00 20 8e 7e 1c 81 88 ff ff .~. > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > backtrace (crc 9f8721dd): > [] kmemleak_alloc_recursive include/linux/kmemleak.h:42 > [inline] > [] slab_post_alloc_hook mm/slub.c:3817 [inline] > [] slab_alloc_node mm/slub.c:3860 [inline] > [] kmalloc_trace+0x283/0x330 mm/slub.c:4007 > [] kmalloc include/linux/slab.h:590 [inline] > [] kzalloc include/linux/slab.h:711 [inline] > [] batadv_tvlv_handler_register+0xf7/0x2a0 > net/batman-adv/tvlv.c:560 > [] batadv_mcast_init+0x4f/0xc0 > net/batman-adv/multicast.c:1926 > [] batadv_mesh_init+0x209/0x2f0 > net/batman-adv/main.c:231 > [] batadv_softif_init_late+0x1f8/0x280 > net/batman-adv/soft-interface.c:812 > [] register_netdevice+0x189/0xca0 net/core/dev.c:10188 > [] batadv_softif_newlink+0x55/0x70 > net/batman-adv/soft-interface.c:1088 > [] rtnl_newlink_create net/core/rtnetlink.c:3515 > [inline] > [] __rtnl_newlink+0xb10/0xec0 net/core/rtnetlink.c:3735 > [] rtnl_newlink+0x4c/0x70 net/core/rtnetlink.c:3748 > [] rtnetlink_rcv_msg+0x22f/0x5b0 > net/core/rtnetlink.c:6615 > [] netlink_rcv_skb+0x91/0x1d0 > net/netlink/af_netlink.c:2543 > [] netlink_unicast_kernel net/netlink/af_netlink.c:1341 > [inline] > [] netlink_unicast+0x2c2/0x440 > net/netlink/af_netlink.c:1367 > [] netlink_sendmsg+0x341/0x690 > net/netlink/af_netlink.c:1908 > [] sock_sendmsg_nosec net/socket.c:730 [inline] > [] __sock_sendmsg+0x52/0xa0 net/socket.c:745 > [] __sys_sendto+0x164/0x1e0 net/socket.c:2191 > [] __do_sys_sendto net/socket.c:2203 [inline] > [] __se_sys_sendto net/socket.c:2199 [inline] > [] __x64_sys_sendto+0x28/0x30 net/socket.c:2199 signature.asc Description: This is a digitally signed message part.
[PATCH v2] batman-adv: Drop support for Linux < 4.19
The Linux Kernel 4.14 reached its end of life [1] after 6 years. Instead it is recommended to use at least kernel 4.19. It is also over 5 years old but still maintained by the stable kernel team. All older kernels (4.14 - v4.18) will be dropped to reduce the support overhead. [1] https://lore.kernel.org/r/2024011046-ecology-tiptoeing-ce50@gregkh/ Signed-off-by: Sven Eckelmann --- Changes in v2: - Add EOL announcement URL to commit message - Fix conflict in README.external.rst - Link to v1: https://lore.kernel.org/r/20231104-drop-compat-4-14-v1-1-d2453b1cf...@narfation.org --- README.external.rst | 2 +- compat-include/linux/netdevice.h | 8 compat-include/linux/stddef.h| 24 compat-include/net/cfg80211.h| 40 compat-include/net/genetlink.h | 18 -- compat.h | 7 --- 6 files changed, 1 insertion(+), 98 deletions(-) diff --git a/README.external.rst b/README.external.rst index 3b014af8..4e1de973 100644 --- a/README.external.rst +++ b/README.external.rst @@ -12,7 +12,7 @@ and as an external module. The external module allows to get newfeatures without upgrading to a newer kernel version and to get batman-adv specific bug fixes for kernels that are not supported anymore. It compiles against and should work -with Linux 4.14 - 6.7. Supporting older versions is not +with Linux 4.19 - 6.7. 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. :-) diff --git a/compat-include/linux/netdevice.h b/compat-include/linux/netdevice.h index 3188ad3d..a489ac9b 100644 --- a/compat-include/linux/netdevice.h +++ b/compat-include/linux/netdevice.h @@ -13,14 +13,6 @@ #include #include_next -#if LINUX_VERSION_IS_LESS(4, 15, 0) - -#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info, extack) \ - netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) - -#endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */ - - #if LINUX_VERSION_IS_LESS(5, 15, 0) static inline void batadv_dev_put(struct net_device *dev) diff --git a/compat-include/linux/stddef.h b/compat-include/linux/stddef.h deleted file mode 100644 index c4558f81.. --- a/compat-include/linux/stddef.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_STDDEF_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_STDDEF_H_ - -#include -#include_next - -#if LINUX_VERSION_IS_LESS(4, 16, 0) - -#ifndef sizeof_field -#define sizeof_field(TYPE, MEMBER) sizeofTYPE *)0)->MEMBER)) -#endif - -#endif /* LINUX_VERSION_IS_LESS(4, 16, 0) */ - -#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_STDDEF_H_ */ diff --git a/compat-include/net/cfg80211.h b/compat-include/net/cfg80211.h deleted file mode 100644 index 4bfcd5a3.. --- a/compat-include/net/cfg80211.h +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#ifndef _NET_BATMAN_ADV_COMPAT_NET_CFG80211_H_ -#define _NET_BATMAN_ADV_COMPAT_NET_CFG80211_H_ - -#include -#include_next - - -#if LINUX_VERSION_IS_LESS(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211) - -/* cfg80211 fix: https://patchwork.kernel.org/patch/10449857/ */ -static inline int batadv_cfg80211_get_station(struct net_device *dev, - const u8 *mac_addr, - struct station_info *sinfo) -{ - memset(sinfo, 0, sizeof(*sinfo)); - return cfg80211_get_station(dev, mac_addr, sinfo); -} - -#define cfg80211_get_station(dev, mac_addr, sinfo) \ - batadv_cfg80211_get_station(dev, mac_addr, sinfo) - -#endif /* LINUX_VERSION_IS_LESS(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211) */ - - -#if LINUX_VERSION_IS_LESS(4, 18, 0) - -#define cfg80211_sinfo_release_content(sinfo) - -#endif /* LINUX_VERSION_IS_LESS(4, 18, 0) */ - -#endif /* _NET_BATMAN_ADV_COMPAT_NET_CFG80211_H_ */ diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h index 05c57ce0..85376044 100644 --- a/compat-include/net/genetlink.h +++ b/compat-include/net/genetlink.h @@ -13,24 +13,6 @@ #include #include_next -#if LINUX_VERSION_IS_LESS(4, 15, 0) - -static inline -void batadv_genl_dump_check_consistent(struct netlink_callback *cb, - void *user_hdr) -{ - struct genl_family genl_family = { - .hdrsize = 0, - }; - - genl_dump_check_consistent(cb
Re: [PATCH 2/2] batman-adv: Improve exception handling in batadv_throw_uevent()
On Tuesday, 2 January 2024 08:12:56 CET Markus Elfring wrote: > From: Markus Elfring > Date: Tue, 2 Jan 2024 07:52:21 +0100 > > The kfree() function was called in up to three cases by > the batadv_throw_uevent() function during error handling > even if the passed variable contained a null pointer. > This issue was detected by using the Coccinelle software. > > * Thus adjust jump targets. > > * Reorder kfree() calls at the end. > > Signed-off-by: Markus Elfring Acked-by: Sven Eckelmann > --- > net/batman-adv/main.c | 14 -- > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c > index 5fc754b0b3f7..75119f1ffccc 100644 > --- a/net/batman-adv/main.c > +++ b/net/batman-adv/main.c > @@ -691,29 +691,31 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, > enum batadv_uev_type type, > "%s%s", BATADV_UEV_TYPE_VAR, > batadv_uev_type_str[type]); > if (!uevent_env[0]) > - goto out; > + goto report_error; > > uevent_env[1] = kasprintf(GFP_ATOMIC, > "%s%s", BATADV_UEV_ACTION_VAR, > batadv_uev_action_str[action]); > if (!uevent_env[1]) > - goto out; > + goto free_first_env; > > /* If the event is DEL, ignore the data field */ > if (action != BATADV_UEV_DEL) { > uevent_env[2] = kasprintf(GFP_ATOMIC, > "%s%s", BATADV_UEV_DATA_VAR, data); > if (!uevent_env[2]) > - goto out; > + goto free_second_env; > } > > ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env); > -out: > - kfree(uevent_env[0]); > - kfree(uevent_env[1]); > kfree(uevent_env[2]); > +free_second_env: > + kfree(uevent_env[1]); > +free_first_env: > + kfree(uevent_env[0]); > > if (ret) > +report_error: > batadv_dbg(BATADV_DBG_BATMAN, bat_priv, > "Impossible to send uevent for (%s,%s,%s) event > (err: %d)\n", > batadv_uev_type_str[type], > -- > 2.43.0 > > signature.asc Description: This is a digitally signed message part.
Re: [PATCH 1/2] batman-adv: Return directly after a failed batadv_dat_select_candidates() in batadv_dat_forward_data()
On Tuesday, 2 January 2024 08:11:47 CET Markus Elfring wrote: > From: Markus Elfring > Date: Tue, 2 Jan 2024 07:27:45 +0100 > > The kfree() function was called in one case by > the batadv_dat_forward_data() function during error handling > even if the passed variable contained a null pointer. > This issue was detected by using the Coccinelle software. > > * Thus return directly after a batadv_dat_select_candidates() call failed > at the beginning. > > * Delete the label “out” which became unnecessary with this refactoring. > > Signed-off-by: Markus Elfring Acked-by: Sven Eckelmann > --- > net/batman-adv/distributed-arp-table.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/net/batman-adv/distributed-arp-table.c > b/net/batman-adv/distributed-arp-table.c > index 28a939d56090..4c7e85534324 100644 > --- a/net/batman-adv/distributed-arp-table.c > +++ b/net/batman-adv/distributed-arp-table.c > @@ -684,7 +684,7 @@ static bool batadv_dat_forward_data(struct batadv_priv > *bat_priv, > > cand = batadv_dat_select_candidates(bat_priv, ip, vid); > if (!cand) > - goto out; > + return ret; > > batadv_dbg(BATADV_DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", ); > > @@ -728,7 +728,6 @@ static bool batadv_dat_forward_data(struct batadv_priv > *bat_priv, > batadv_orig_node_put(cand[i].orig_node); > } > > -out: > kfree(cand); > return ret; > } > -- > 2.43.0 > > signature.asc Description: This is a digitally signed message part.
[PATCH] batman-adv: compat: Fix skb_vlan_eth_hdr conflict in stable kernels
The newest Linux stable kernel releases: * v5.10.205 * v5.15.144 * v6.1.69 received a backported version of commit 1f5020acb33f ("net: vlan: introduce skb_vlan_eth_hdr()"). batman-adv must therefore not provide this function any longer for these kernel versions. Signed-off-by: Sven Eckelmann --- compat-include/linux/if_vlan.h | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compat-include/linux/if_vlan.h b/compat-include/linux/if_vlan.h index eb15e060..f19674b5 100644 --- a/compat-include/linux/if_vlan.h +++ b/compat-include/linux/if_vlan.h @@ -13,7 +13,10 @@ #include #include_next -#if LINUX_VERSION_IS_LESS(6, 4, 0) +#if LINUX_VERSION_IS_LESS(6, 4, 0) && \ +!(LINUX_VERSION_IS_GEQ(5, 10, 205) && LINUX_VERSION_IS_LESS(5, 11, 0)) && \ +!(LINUX_VERSION_IS_GEQ(5, 15, 144) && LINUX_VERSION_IS_LESS(5, 16, 0)) && \ +!(LINUX_VERSION_IS_GEQ(6, 1, 69) && LINUX_VERSION_IS_LESS(6, 2, 0)) /* Prefer this version in TX path, instead of * skb_reset_mac_header() + vlan_eth_hdr() --- base-commit: f33d7f724675544a36b24c77f8d4b95d41252ae2 change-id: 20231223-compat-skb_vlan_eth_hdr-deabef2d774c Best regards, -- Sven Eckelmann
Re: Fwd: Fwd: memory leak in batadv_iv_ogm_aggregate_new
On Thursday, 21 December 2023 06:52:01 CET Jinho Ju wrote: > Resending to everyone on the mailing list as per previous mail, adding some > things that were missing. > > Regarding the cause of the L2-related crash being detected by syzkaller, What crash? I can't see it in your mail [1] > I > can't say for sure - what I can say for sure at this point is that a > memleak occurring in L2 was detected by my personal syzkaller. Nothing tells you that the actual leak happened in layer 2. You only know that packets were generated in batman-adv and mac80211_hwsim. But nothing tells you what actually lost track of the skbuff (if that even happens). > Moving away from syzkaller for a moment and shifting the focus to memleak, > we have to assume that the conditions for this to occur are that they > reference the same network stack and are found in modules in L2, What do you mean with "reference the same network stack"? And no, nothing tells you that the culprit is actually something related to network layer 2. > but it > seems that when batman-adv is freed and returned while accessing and > processing a skb in veth (L3), veth is layer 2. > memleak occurs because it is trying to > reference the same skb, the veth freed skb. This doesn't make a lot of sense. batman-adv is not referencing the skb anymore after it was submitted to the underlying device. And if it would reference anything then it would not be a memleak. There are a lot of possibilities: * kmemleak cannot not handling transient queue state correctly while the namespace is destroyed (because it doesn't have a consistent memory state while it scans) * removing of the network namespace (used by the reproducers) might leak skbs which are currently passed around between the queues * there is an actual memory leak somewhere while the queued packets are processed * ... The first two option seem plausible to me because you can see "memory leaks" in for other things which regularly (and often) transmit packets in this namespace. In you log, this would hwsim which transmits beacons regularly (and often). I would guess that you see something similar when you use pktgen. It would now be interesting if you still see the memory leak if you mark all unfreed objects as grey and redo the scan: echo clear > /sys/kernel/debug/kmemleak echo scan > /sys/kernel/debug/kmemleak If you would still see it then we could rule out the first option. If not, then it is a false positive. Kind regards, Sven [1] https://lists.open-mesh.org/mailman3/hyperkitty/list/b.a.t.m.a.n@lists.open-mesh.org/thread/GLS6TCIPHIMWF2G6PVDEEK6UDVFB6UD2/ signature.asc Description: This is a digitally signed message part.
Re: bat0 not capable of MTU > 1500
On Tuesday, 12 December 2023 20:30:24 CET Rich Chase wrote: > For my life I can't see anything I'm doing wrong. Why can't bat0 > have MTU greater than 1500? > > I don't have any other devices mastered by bat0, other than my .1s wifi mesh > link. > > Throwing myself at your mercy. Help? https://lore.kernel.org/all/20230727-jumbo-mtu-v1-3-036ce1a6e...@narfation.org/ https://www.open-mesh.org/issues/365 Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v7 0/3] Implementation of a Stateless Multicast Packet Type
On Thursday, 7 September 2023 03:09:07 CET Linus Lüssing wrote: [...] > Changelog v7: > * PATCH 1/3: > * rebased to current main/master branch (resolved net/multicast/routing.h) > * renamed batadv_mcast_forw_orig_to_neigh() to > batadv_orig_to_router() and moved it to originator.c, for > reuse in fragmentation.c > * added a SKB_LINEAR_ASSERT() to batadv_mcast_forw_packet() > * adjusted batadv_mcast_forw_scrub_dests(): > added a new macro that updates two dest pointers > to avoid confusion due to two different updating methods, > removed goto's and a little reordering > * PATCH 2/3: > * added SKB_LINEAR_ASSERT() to batadv_mcast_forw_scrape() > * PATCH 3/3: > * simplified batadv_mcast_forw_shrink_pack_dests(): > moved parts to new sub function batadv_mcast_forw_shrink_fill(), > removed keeping track of filler over the whole function > (might be slower, as we might check+skip the same zero > MAC entry multiple times, for each slot, but a lot easier > to read - and we don't prioritize performance with this > patchset yet) Merged. But I think the wireshark implementation is still missing. Kind regards, Sven
[PATCH] batman-adv: Switch to linux/array_size.h
The commit 3cd39bc3b11b ("kernel.h: Move ARRAY_SIZE() to a separate header") introduced a new header for the ARRAY_SIZE macro which was previously exposed via linux/kernel.h. Signed-off-by: Sven Eckelmann --- compat-include/linux/array_size.h | 20 net/batman-adv/main.c | 2 +- net/batman-adv/netlink.c | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/compat-include/linux/array_size.h b/compat-include/linux/array_size.h new file mode 100644 index ..824ad011 --- /dev/null +++ b/compat-include/linux/array_size.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_ + +#include +#if LINUX_VERSION_IS_GEQ(6, 7, 0) +#include_next +#else +#include +#endif + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_ */ diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index e8a44991..357b3a6a 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -6,6 +6,7 @@ #include "main.h" +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index 2b3da616..cda99753 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -7,6 +7,7 @@ #include "netlink.h" #include "main.h" +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include #include #include --- base-commit: 5fecd4a389cea1b9719e9ec480d7257887e0dfdf change-id: 20231113-new-6-7-headers-2ac8803d5292 Best regards, -- Sven Eckelmann
[PATCH RFC] batman-adv: Drop support for Linux < 4.19
The Linux Kernel 4.14 reached its end of life [1] after 6 years. Instead it is recommended to use at least kernel 4.19. It is also over 5 years old but still maintained by the stable kernel team. All older kernels (4.14 - v4.18) will be dropped to reduce the support overhead. [1] TODO: https://lore.kernel.org/r/ Signed-off-by: Sven Eckelmann --- The last 4.14 version was not yet released but is announced to be in Jan, 2024: https://kernel.org/category/releases.html --- README.external.rst | 2 +- compat-include/linux/netdevice.h | 8 compat-include/linux/stddef.h| 24 compat-include/net/cfg80211.h| 40 compat-include/net/genetlink.h | 18 -- compat.h | 7 --- 6 files changed, 1 insertion(+), 98 deletions(-) diff --git a/README.external.rst b/README.external.rst index 58e8fc7a..62a8cf06 100644 --- a/README.external.rst +++ b/README.external.rst @@ -12,7 +12,7 @@ and as an external module. The external module allows to get newfeatures without upgrading to a newer kernel version and to get batman-adv specific bug fixes for kernels that are not supported anymore. It compiles against and should work -with Linux 4.14 - 6.5. Supporting older versions is not +with Linux 4.19 - 6.5. 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. :-) diff --git a/compat-include/linux/netdevice.h b/compat-include/linux/netdevice.h index 3188ad3d..a489ac9b 100644 --- a/compat-include/linux/netdevice.h +++ b/compat-include/linux/netdevice.h @@ -13,14 +13,6 @@ #include #include_next -#if LINUX_VERSION_IS_LESS(4, 15, 0) - -#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info, extack) \ - netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) - -#endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */ - - #if LINUX_VERSION_IS_LESS(5, 15, 0) static inline void batadv_dev_put(struct net_device *dev) diff --git a/compat-include/linux/stddef.h b/compat-include/linux/stddef.h deleted file mode 100644 index c4558f81.. --- a/compat-include/linux/stddef.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_STDDEF_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_STDDEF_H_ - -#include -#include_next - -#if LINUX_VERSION_IS_LESS(4, 16, 0) - -#ifndef sizeof_field -#define sizeof_field(TYPE, MEMBER) sizeofTYPE *)0)->MEMBER)) -#endif - -#endif /* LINUX_VERSION_IS_LESS(4, 16, 0) */ - -#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_STDDEF_H_ */ diff --git a/compat-include/net/cfg80211.h b/compat-include/net/cfg80211.h deleted file mode 100644 index 4bfcd5a3.. --- a/compat-include/net/cfg80211.h +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#ifndef _NET_BATMAN_ADV_COMPAT_NET_CFG80211_H_ -#define _NET_BATMAN_ADV_COMPAT_NET_CFG80211_H_ - -#include -#include_next - - -#if LINUX_VERSION_IS_LESS(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211) - -/* cfg80211 fix: https://patchwork.kernel.org/patch/10449857/ */ -static inline int batadv_cfg80211_get_station(struct net_device *dev, - const u8 *mac_addr, - struct station_info *sinfo) -{ - memset(sinfo, 0, sizeof(*sinfo)); - return cfg80211_get_station(dev, mac_addr, sinfo); -} - -#define cfg80211_get_station(dev, mac_addr, sinfo) \ - batadv_cfg80211_get_station(dev, mac_addr, sinfo) - -#endif /* LINUX_VERSION_IS_LESS(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211) */ - - -#if LINUX_VERSION_IS_LESS(4, 18, 0) - -#define cfg80211_sinfo_release_content(sinfo) - -#endif /* LINUX_VERSION_IS_LESS(4, 18, 0) */ - -#endif /* _NET_BATMAN_ADV_COMPAT_NET_CFG80211_H_ */ diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h index 05c57ce0..85376044 100644 --- a/compat-include/net/genetlink.h +++ b/compat-include/net/genetlink.h @@ -13,24 +13,6 @@ #include #include_next -#if LINUX_VERSION_IS_LESS(4, 15, 0) - -static inline -void batadv_genl_dump_check_consistent(struct netlink_callback *cb, - void *user_hdr) -{ - struct genl_family genl_family = { - .hdrsize = 0, - }; - - genl_dump_check_consistent(cb, user_hdr, _family); -} - -#define genl_dump_check_consistent batadv_genl_dump_check_consistent - -#endif /* LINU
[PATCH v2] batman-adv: Switch to linux/sprintf.h
The commit 39ced19b9e60 ("lib/vsprintf: split out sprintf() and friends") introduced a new header for the sprintf related functions which were previously exposed via linux/kernel.h. Signed-off-by: Sven Eckelmann --- Changes in v2: - version for out-of-tree kernel with compat header - Link to v1: https://lore.kernel.org/r/20231030-sprintf_header-v1-1-2730d6395...@narfation.org --- compat-include/linux/sprintf.h | 20 net/batman-adv/bridge_loop_avoidance.c | 2 +- net/batman-adv/gateway_client.c| 2 +- net/batman-adv/main.c | 1 + net/batman-adv/multicast.c | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/compat-include/linux/sprintf.h b/compat-include/linux/sprintf.h new file mode 100644 index ..d3823277 --- /dev/null +++ b/compat-include/linux/sprintf.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_SPRINTF_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_SPRINTF_H_ + +#include +#if LINUX_VERSION_IS_GEQ(6, 6, 0) +#include_next +#else +#include +#endif + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SPRINTF_H_ */ diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 37ce6cfb..5f46ca3d 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index d26124bc..0ddd8b4b 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index e8a44991..928c78a5 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 27511a06..7686caef 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include #include #include --- base-commit: 5fecd4a389cea1b9719e9ec480d7257887e0dfdf change-id: 20231030-sprintf_header-47d656369468 Best regards, -- Sven Eckelmann
[PATCH] batman-adv: Switch to linux/sprintf.h
The commit 39ced19b9e60 ("lib/vsprintf: split out sprintf() and friends") introduced a new header for the sprintf related functions which were previously exposed via linux/kernel.h. Signed-off-by: Sven Eckelmann --- net/batman-adv/bridge_loop_avoidance.c | 2 +- net/batman-adv/gateway_client.c| 2 +- net/batman-adv/main.c | 1 + net/batman-adv/multicast.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 37ce6cfb..5f46ca3d 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index d26124bc..0ddd8b4b 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index e8a44991..928c78a5 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 27511a06..7686caef 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include #include #include --- base-commit: 5fecd4a389cea1b9719e9ec480d7257887e0dfdf change-id: 20231030-sprintf_header-47d656369468 Best regards, -- Sven Eckelmann
Re: [PATCH v7 0/3] Implementation of a Stateless Multicast Packet Type
On Thursday, 7 September 2023 03:09:07 CEST Linus Lüssing wrote: [...] > Changelog v7: > * PATCH 1/3: > * rebased to current main/master branch (resolved net/multicast/routing.h) Are you trying to take over batman-adv and make it the *multicast* mesh protocol? :D > * renamed batadv_mcast_forw_orig_to_neigh() to > batadv_orig_to_router() and moved it to originator.c, for > reuse in fragmentation.c For this, you should also remove routing.h from fragmentation.c in patch 1. Same for multicast_forw.c I have already queued it up in linux-merge with these changes > * PATCH 3/3: @Simon, can you please also check the remaining code changes? To quickly identify modifications, you can use pipx install b4 # in you batman-adv repo b4 diff -- 20230907010910.22427-2-linus.luess...@c0d3.blue > * simplified batadv_mcast_forw_shrink_pack_dests(): > moved parts to new sub function batadv_mcast_forw_shrink_fill(), > removed keeping track of filler over the whole function > (might be slower, as we might check+skip the same zero > MAC entry multiple times, for each slot, but a lot easier > to read - and we don't prioritize performance with this > patchset yet) Independent of the outcome for this patchset, something like this would often be implemented by starting the search on one side of an array and get the replacement from the other side of the array - and when start and end overlap then the algorithm stops. At least for me, it is easier to comprehend than some filler which needs to be pushed forward and is influenced by a variable which is (unexpectedly) modified inside a macro: #! /usr/bin/env python3 from random import randint # initialize test array def random_array(): slots = [] for i in range(100): slots.append(randint(0, 5)) return slots # searches from the end towards the empty slot for fillers (non-zero) # # returns a non-zero entry if return value > empty_slot def find_filler(slots, empty_slot, end): while end > empty_slot: if slots[end] != 0: break end -= 1 return end # searches from the front for empty entries and replaces them with # non-empty entries from the end # # returns number of non-empty entries def move_empty_to_end(slots): non_empty = 0 start = 0 length = len(slots) end = length - 1 # replace empty entries at the beginning with non-empty from end while start < end: # ignore non-empty entries at the start if slots[start] != 0: start += 1 non_empty += 1 continue # find replacement at end new_end = find_filler(slots, start, end) if new_end <= start: # no replacement found break # move non-empty entry from end to start slots[start] = slots[new_end] end = new_end - 1 slots[new_end] = 0 # count remaining non-empty for i in range(start, length): if slots[i] == 0: break non_empty += 1 return non_empty slots = random_array() count_non_empty = move_empty_to_end(slots) # just to make sure that everything is empty print(slots[count_non_empty:]) # memmove simulator :) slots = slots[:count_non_empty] # just to see the non-empty entries print(slots) While the natural way would actually be to move non-empty entries to the end (and then only move the header), your implementation needs them at the start. So I did it similar in this PoC. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: Fwd: Possibility of dual-licensing to ease bringing into FreeBSD
On Friday, 15 September 2023 16:11:44 CEST obiwac wrote: > Would it be possible to > dual-license batman-adv to GPL/BSD This is not really likely. There is not a single entity which can re-license the code - instead there are nearly 120 authors recorded in the repository which have some saying over their contribution. There can be even more copyright holders which weren't recorded correctly (especially in the early days). Akinobu Mita Al Viro Alexey Dobriyan Alexey Fisher Anders Roxell Andrea Gelmini Andrea Ghittino Andreas Langer Andreas Pape Andrew Lunn André Gaul Andy Shevchenko Antonio Quartulli Arnd Bergmann Ben Hutchings Chris Lang Christophe JAILLET Colin Ian King Cong Wang Dan Carpenter Daniel Seither Daniele Furlan Danny Kukawka David Ahern David Decotigny David Howells David S. Miller Def Denys Vlasenko Ding Tianhong Eric Dumazet Eric W. Biederman Felix Fietkau Fengguang Wu Florian Westphal Gao Feng Geliang Tang George Spelvin Greg Kroah-Hartman Gustavo A. R. Silva Himangi Saraogi Jakub Kicinski Jason A. Donenfeld Javier Martinez Canillas Jean Delvare Jean Sacren Jeremy Sowden Jesper Juhl Jiri Pirko Joe Perches Johannes Berg Jonathan Corbet Julia Lawall Jussi Kivilinna Kees Cook Ken Helias Kirill Smelkov Krzysztof Kozlowski Kyungrok Chung Leon Romanovsky Linus Lüssing Linus Torvalds Luc Van Oostenryck Lucas De Marchi Luis de Bethencourt Marek Lindner Markus Elfring Markus Pargmann Martin Hundebøll Martin Weinelt Masahiro Yamada Mathieu Desnoyers Matthias Schiffer Michał Mirosław Minghao Chi Nicolas Dichtel Nikolay Aleksandrov Octavian Purdila Pankaj Bharadiya Patrick McHardy Pau Koning Paul E. McKenney Paul Kot Pavel Skripkin Phil Sutter Randy Dunlap Rasmus Villemoes Remi Pommarel René Treffer Ruben Wisniewski Sasha Levin Scott Raynel Sebastian Andrzej Siewior Shan Wei Shaokun Zhang Shigeru Yoshida Simon Wunderlich Stephen Hemminger Steven Rostedt (Google) Sven Eckelmann Sven-Thorsten Dietrich Sylvestre Ledru Taehee Yoo Tejun Heo Tetsuo Handa Tobias Klauser Tom Gundersen Tracey Dent Vasiliy Kulikov Vladimir Oltean Vladislav Efanov Wilfried Klaebe Xiyu Yang Yajun Deng Ying Xue Yu Zhe YueHaibing Zheng Yongjun And I don't want to start now any discussion about per country rules regarding copyright and copyrightable work. Just wanted to point out that it is not as simple. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: batman 2023.1 fails to compile with implicit func kstrtou64 on debian 5.10.0
On Wednesday, 6 September 2023 17:50:26 CEST MK wrote: [...] > batman-adv/gateway_common.c:55:8: error: implicit declaration of > function ‘kstrtou64’ [-Werror=implicit-function-declaration] > 55 | ret = kstrtou64(buff, 10, ); > cc1: some warnings being treated as errors > > Tried make CFLAGS="-Wno-error=implicit-function-declaration" but that > doesn't help. Successfully compiled on 5.15.0 (ubuntu LTS). Please use 2023.2 or get following commit: https://git.open-mesh.org/batman-adv.git/patch/8924adbdf993cd0521f9d0024b43e3b23af5114f Kind regards, Sven signature.asc Description: This is a digitally signed message part.
[PATCH net] batman-adv: Hold rtnl lock during MTU update via netlink
The automatic recalculation of the maximum allowed MTU is usually triggered by code sections which are already rtnl lock protected by callers outside of batman-adv. But when the fragmentation setting is changed via batman-adv's own batadv genl family, then the rtnl lock is not yet taken. But dev_set_mtu requires that the caller holds the rtnl lock because it uses netdevice notifiers. And this code will then fail the check for this lock: RTNL: assertion failed at net/core/dev.c (1953) Cc: sta...@vger.kernel.org Reported-by: syzbot+f8812454d9b3ac00d...@syzkaller.appspotmail.com Fixes: c6a953cce8d0 ("batman-adv: Trigger events for auto adjusted MTU") Signed-off-by: Sven Eckelmann --- This problem was just identified by syzbot [1]. I hope it is ok to directly send this patch to netdev instead of creating a single-patch PR from the batadv/net branch. If you still prefer a PR then we can also prepare it. [1] https://lore.kernel.org/r/9bbb4b0603717...@google.com --- net/batman-adv/netlink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index ad5714f737be..6efbc9275aec 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -495,7 +495,10 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) attr = info->attrs[BATADV_ATTR_FRAGMENTATION_ENABLED]; atomic_set(_priv->fragmentation, !!nla_get_u8(attr)); + + rtnl_lock(); batadv_update_min_mtu(bat_priv->soft_iface); + rtnl_unlock(); } if (info->attrs[BATADV_ATTR_GW_BANDWIDTH_DOWN]) { --- base-commit: 421d467dc2d483175bad4fb76a31b9e5a3d744cf change-id: 20230821-batadv-missing-mtu-rtnl-lock-bc4cee67731d Best regards, -- Sven Eckelmann
Re: [PATCH v6 0/3] Implementation of a Stateless Multicast Packet Type
On Saturday, 29 July 2023 13:11:28 CEST Sven Eckelmann wrote: > I have now acked the various patches and have queued them up for submission > to > net-next. But it would be good when Simon also checks them. Just discussed with Simon, and he had some good points regarding the readability of some functions (not so much actual functionality problems) Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH net] batman-adv: Fix batadv_v_ogm_aggr_send memory leak
On Wed, 09 Aug 2023 17:29:13 +0200, Remi Pommarel wrote: > When batadv_v_ogm_aggr_send is called for an inactive interface, the skb > is silently dropped by batadv_v_ogm_send_to_if() but never freed causing > the following memory leak: > > unreferenced object 0x0c164800 (size 512): > comm "kworker/u8:1", pid 2648, jiffies 4295122303 (age 97.656s) > hex dump (first 32 bytes): > 00 80 af 09 00 00 ff ff e1 09 00 00 75 01 60 83 u.`. > 1f 00 00 00 b8 00 00 00 15 00 05 00 da e3 d3 64 ...d > backtrace: > [<07ad20f6>] __kmalloc_track_caller+0x1a8/0x310 > [<d1029e55>] kmalloc_reserve.constprop.0+0x70/0x13c > [<8b9d4183>] __alloc_skb+0xec/0x1fc > [<c7af5051>] __netdev_alloc_skb+0x48/0x23c > [<642ee5f5>] batadv_v_ogm_aggr_send+0x50/0x36c > [<88660bd7>] batadv_v_ogm_aggr_work+0x24/0x40 > [<42fc2606>] process_one_work+0x3b0/0x610 > [<2f2a0b1c>] worker_thread+0xa0/0x690 > [<59fae5d4>] kthread+0x1fc/0x210 > [<0c587d3a>] ret_from_fork+0x10/0x20 > > [...] Applied, thanks! [1/1] batman-adv: Fix batadv_v_ogm_aggr_send memory leak commit: 421d467dc2d483175bad4fb76a31b9e5a3d744cf Best regards, -- Sven Eckelmann signature.asc Description: This is a digitally signed message part.
Re: [PATCH net] batman-adv: Fix TT global entry leak when client roamed back
On Fri, 04 Aug 2023 11:39:36 +0200, Remi Pommarel wrote: > When a client roamed back to a node before it got time to destroy the > pending local entry (i.e. within the same originator interval) the old > global one is directly removed from hash table and left as such. > > But because this entry had an extra reference taken at lookup (i.e using > batadv_tt_global_hash_find) there is no way its memory will be reclaimed > at any time causing the following memory leak: > > [...] Applied, thanks! [1/1] batman-adv: Fix TT global entry leak when client roamed back commit: d25ddb7e788d34cf27ff1738d11a87cb4b67d446 Kind regards, Sven signature.asc Description: This is a digitally signed message part.
[PATCH 3/3] batman-adv: Drop per algo GW section class code
This code was only used in the past for the sysfs interface. But since this was replace with netlink, it was never executed. The function pointer was only checked to figure out whether the limit 255 (B.A.T.M.A.N. IV) or 2**32-1 (B.A.T.M.A.N. V) should be used as limit. So instead of keeping the function pointer, just store the limits directly in struct batadv_algo_gw_ops. Signed-off-by: Sven Eckelmann --- net/batman-adv/bat_iv_ogm.c | 1 + net/batman-adv/bat_v.c | 23 ++--- net/batman-adv/gateway_common.c | 74 + net/batman-adv/gateway_common.h | 5 --- net/batman-adv/netlink.c| 5 +-- net/batman-adv/types.h | 7 ++-- 6 files changed, 8 insertions(+), 107 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 828fb393..74b49c35 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -2516,6 +2516,7 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = { }, .gw = { .init_sel_class = batadv_iv_init_sel_class, + .sel_class_max = BATADV_TQ_MAX_VALUE, .get_best_gw_node = batadv_iv_gw_get_best_gw_node, .is_eligible = batadv_iv_gw_is_eligible, .dump = batadv_iv_gw_dump, diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index 54e41fc7..ac11f1f0 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,6 @@ #include "bat_v_elp.h" #include "bat_v_ogm.h" #include "gateway_client.h" -#include "gateway_common.h" #include "hard-interface.h" #include "hash.h" #include "log.h" @@ -512,25 +512,6 @@ static void batadv_v_init_sel_class(struct batadv_priv *bat_priv) atomic_set(_priv->gw.sel_class, 50); } -static ssize_t batadv_v_store_sel_class(struct batadv_priv *bat_priv, - char *buff, size_t count) -{ - u32 old_class, class; - - if (!batadv_parse_throughput(bat_priv->soft_iface, buff, -"B.A.T.M.A.N. V GW selection class", -)) - return -EINVAL; - - old_class = atomic_read(_priv->gw.sel_class); - atomic_set(_priv->gw.sel_class, class); - - if (old_class != class) - batadv_gw_reselect(bat_priv); - - return count; -} - /** * batadv_v_gw_throughput_get() - retrieve the GW-bandwidth for a given GW * @gw_node: the GW to retrieve the metric for @@ -818,7 +799,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { }, .gw = { .init_sel_class = batadv_v_init_sel_class, - .store_sel_class = batadv_v_store_sel_class, + .sel_class_max = U32_MAX, .get_best_gw_node = batadv_v_gw_get_best_gw_node, .is_eligible = batadv_v_gw_is_eligible, .dump = batadv_v_gw_dump, diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index d9632607..2dd36ef0 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -9,86 +9,14 @@ #include #include -#include -#include -#include -#include #include -#include +#include #include #include #include "gateway_client.h" -#include "log.h" #include "tvlv.h" -/** - * batadv_parse_throughput() - parse supplied string buffer to extract - * throughput information - * @net_dev: the soft interface net device - * @buff: string buffer to parse - * @description: text shown when throughput string cannot be parsed - * @throughput: pointer holding the returned throughput information - * - * Return: false on parse error and true otherwise. - */ -bool batadv_parse_throughput(struct net_device *net_dev, char *buff, -const char *description, u32 *throughput) -{ - enum batadv_bandwidth_units bw_unit_type = BATADV_BW_UNIT_KBIT; - u64 lthroughput; - char *tmp_ptr; - int ret; - - if (strlen(buff) > 4) { - tmp_ptr = buff + strlen(buff) - 4; - - if (strncasecmp(tmp_ptr, "mbit", 4) == 0) - bw_unit_type = BATADV_BW_UNIT_MBIT; - - if (strncasecmp(tmp_ptr, "kbit", 4) == 0 || - bw_unit_type == BATADV_BW_UNIT_MBIT) - *tmp_ptr = '\0'; - } - - ret = kstrtou64(buff, 10, ); - if (ret) { - batadv_err(net_dev, - "Invalid throughput speed for %s: %s\n", - description, buff); - return false; - } - - switch (bw_unit_type) { - ca
[PATCH 2/3] batman-adv: Keep batadv_netlink_notify_* static
The batadv_netlink_notify_*() functions are not used by any other source file. Just keep them local to netlink.c to get informed by the compiler when they are not used anymore. Signed-off-by: Sven Eckelmann --- net/batman-adv/netlink.c | 10 +- net/batman-adv/netlink.h | 6 -- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index 07f21cdb..09b76b0f 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -377,7 +377,7 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, * * Return: 0 on success, < 0 on error */ -int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv) +static int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv) { struct sk_buff *msg; int ret; @@ -858,8 +858,8 @@ static int batadv_netlink_hardif_fill(struct sk_buff *msg, * * Return: 0 on success, < 0 on error */ -int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv, -struct batadv_hard_iface *hard_iface) +static int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv, + struct batadv_hard_iface *hard_iface) { struct sk_buff *msg; int ret; @@ -1073,8 +1073,8 @@ static int batadv_netlink_vlan_fill(struct sk_buff *msg, * * Return: 0 on success, < 0 on error */ -int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv, - struct batadv_softif_vlan *vlan) +static int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv, + struct batadv_softif_vlan *vlan) { struct sk_buff *msg; int ret; diff --git a/net/batman-adv/netlink.h b/net/batman-adv/netlink.h index 48102cc7..876d2806 100644 --- a/net/batman-adv/netlink.h +++ b/net/batman-adv/netlink.h @@ -21,12 +21,6 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, u8 result, u32 test_time, u64 total_bytes, u32 cookie); -int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv); -int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv, -struct batadv_hard_iface *hard_iface); -int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv, - struct batadv_softif_vlan *vlan); - extern struct genl_family batadv_netlink_family; #endif /* _NET_BATMAN_ADV_NETLINK_H_ */ -- 2.39.2
[PATCH 1/3] batman-adv: Drop unused function batadv_gw_bandwidth_set
This function is no longer used since the sysfs support was removed from batman-adv. Signed-off-by: Sven Eckelmann --- net/batman-adv/gateway_common.c | 88 - net/batman-adv/gateway_common.h | 2 - 2 files changed, 90 deletions(-) diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index 6a964a77..d9632607 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -90,42 +89,6 @@ bool batadv_parse_throughput(struct net_device *net_dev, char *buff, return true; } -/** - * batadv_parse_gw_bandwidth() - parse supplied string buffer to extract - * download and upload bandwidth information - * @net_dev: the soft interface net device - * @buff: string buffer to parse - * @down: pointer holding the returned download bandwidth information - * @up: pointer holding the returned upload bandwidth information - * - * Return: false on parse error and true otherwise. - */ -static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, - u32 *down, u32 *up) -{ - char *slash_ptr; - bool ret; - - slash_ptr = strchr(buff, '/'); - if (slash_ptr) - *slash_ptr = 0; - - ret = batadv_parse_throughput(net_dev, buff, "download gateway speed", - down); - if (!ret) - return false; - - /* we also got some upload info */ - if (slash_ptr) { - ret = batadv_parse_throughput(net_dev, slash_ptr + 1, - "upload gateway speed", up); - if (!ret) - return false; - } - - return true; -} - /** * batadv_gw_tvlv_container_update() - update the gw tvlv container after * gateway setting change @@ -155,57 +118,6 @@ void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv) } } -/** - * batadv_gw_bandwidth_set() - Parse and set download/upload gateway bandwidth - * from supplied string buffer - * @net_dev: netdev struct of the soft interface - * @buff: the buffer containing the user data - * @count: number of bytes in the buffer - * - * Return: 'count' on success or a negative error code in case of failure - */ -ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, - size_t count) -{ - struct batadv_priv *bat_priv = netdev_priv(net_dev); - u32 down_curr; - u32 up_curr; - u32 down_new = 0; - u32 up_new = 0; - bool ret; - - down_curr = (unsigned int)atomic_read(_priv->gw.bandwidth_down); - up_curr = (unsigned int)atomic_read(_priv->gw.bandwidth_up); - - ret = batadv_parse_gw_bandwidth(net_dev, buff, _new, _new); - if (!ret) - return -EINVAL; - - if (!down_new) - down_new = 1; - - if (!up_new) - up_new = down_new / 5; - - if (!up_new) - up_new = 1; - - if (down_curr == down_new && up_curr == up_new) - return count; - - batadv_gw_reselect(bat_priv); - batadv_info(net_dev, - "Changing gateway bandwidth from: '%u.%u/%u.%u MBit' to: '%u.%u/%u.%u MBit'\n", - down_curr / 10, down_curr % 10, up_curr / 10, up_curr % 10, - down_new / 10, down_new % 10, up_new / 10, up_new % 10); - - atomic_set(_priv->gw.bandwidth_down, down_new); - atomic_set(_priv->gw.bandwidth_up, up_new); - batadv_gw_tvlv_container_update(bat_priv); - - return count; -} - /** * batadv_gw_tvlv_ogm_handler_v1() - process incoming gateway tvlv container * @bat_priv: the bat priv with all the soft interface information diff --git a/net/batman-adv/gateway_common.h b/net/batman-adv/gateway_common.h index 87c37f90..cb2e72d7 100644 --- a/net/batman-adv/gateway_common.h +++ b/net/batman-adv/gateway_common.h @@ -27,8 +27,6 @@ enum batadv_bandwidth_units { #define BATADV_GW_MODE_CLIENT_NAME "client" #define BATADV_GW_MODE_SERVER_NAME "server" -ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, - size_t count); void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv); void batadv_gw_init(struct batadv_priv *bat_priv); void batadv_gw_free(struct batadv_priv *bat_priv); -- 2.39.2
[PATCH 0/3] batman-adv: Drop ununused functions and localize when possible
There were a couple of functions which were still compiled but not used anymore since a while. Just drop them and make sure that other ones are local only (to make it easier to spot them in the future). Signed-off-by: Sven Eckelmann --- Sven Eckelmann (3): batman-adv: Drop unused function batadv_gw_bandwidth_set batman-adv: Keep batadv_netlink_notify_* static batman-adv: Drop per algo GW section class code net/batman-adv/bat_iv_ogm.c | 1 + net/batman-adv/bat_v.c | 23 +- net/batman-adv/gateway_common.c | 162 +--- net/batman-adv/gateway_common.h | 7 -- net/batman-adv/netlink.c| 15 ++-- net/batman-adv/netlink.h| 6 -- net/batman-adv/types.h | 7 +- 7 files changed, 13 insertions(+), 208 deletions(-) --- base-commit: ed12d0c16556942c4fd52af122030182c11e60ef change-id: 20230802-cleanup_functions-2946498ebebc Best regards, -- Sven Eckelmann
Re: [PATCH v6 0/3] Implementation of a Stateless Multicast Packet Type
On Thursday, 20 July 2023 06:35:52 CEST Linus Lüssing wrote: [...] > The purpose of this new packet type is to allow to forward an IP > multicast packet with less transmissions / overhead than the > multicast-via-multiple-unicasts approach. Or to reach a lot more > destinations (currently up to 196, depending on the payload size, see > Wiki documentation for details) than with the default multicast fanout > for the via-unicasts approach. Please don't forget that batctl's tcpdump+wireshark also requires support for parsing it. Most likely, this was not added yet to not confuse third parties in case the packet format changes. I have now acked the various patches and have queued them up for submission to net-next. But it would be good when Simon also checks them. And we must also first release 2023.2 (including submission for net + net-next) before these patches can be added to the batman-adv repository. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v6 3/3] batman-adv: mcast: shrink tracker packet after scrubbing
On Thursday, 20 July 2023 06:35:55 CEST Linus Lüssing wrote: > Remove all zero MAC address entries (00:00:00:00:00:00) from a multicast > packet's tracker TVLV before transmitting it and update all headers > accordingly. This way, instead of keeping the multicast packet at a > constant size throughout its journey through the mesh, it will become > more lightweight, smaller with every interested receiver on the way and > on each splitting intersection. Which can save some valuable bandwidth. > > Signed-off-by: Linus Lüssing > --- > net/batman-adv/multicast_forw.c | 195 > 1 file changed, 195 insertions(+) Acked-by: Sven Eckelmann Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v6 2/3] batman-adv: mcast: implement multicast packet generation
On Thursday, 20 July 2023 06:35:54 CEST Linus Lüssing wrote: > Implement the preparation of a batman-adv multicast packet and use this > under certain conditions. > > For one thing this implements the capability to push a complete > batman-adv multicast packet header, including a tracker TVLV with all > originator destinations that have signaled interest in it, onto a given > ethernet frame with an IP multicast packet inside. > > For another checks are implemented to determine if encapsulating a > multicast packet in this new batman-adv multicast packet type and using > it is feasible. Those checks are: > > 1) Have all nodes signaled that they are capable of handling the new >batman-adv multicast packet type? > 2) Do all active hard interfaces of all nodes, including us, have an MTU >of at least 1280 bytes? > 3) Does a complete multicast packet header with all its destination >addresses fit onto the given multicast packet / ethernet frame and >does not exceed 1280 bytes? > > If all checks passed then the new batman-adv multicast packet type will > be used for transmission and distribution. Otherwise we fall back to one or > more batman-adv unicast packet transmissions, if possible. Or if not > possible we will fall back to classic flooding through a batman-adv > broadcast packet. > > Signed-off-by: Linus Lüssing > --- > net/batman-adv/multicast.c | 79 +++- > net/batman-adv/multicast.h | 25 +- > net/batman-adv/multicast_forw.c | 727 > net/batman-adv/soft-interface.c | 6 +- > net/batman-adv/types.h | 6 + > 5 files changed, 835 insertions(+), 8 deletions(-) Acked-by: Sven Eckelmann > +/** > + * batadv_mcast_forw_scrape() - remove bytes within skb data > + * @skb: the skb to remove bytes from > + * @offset: the offset from the skb data from which to scrape > + * @len: the amount of bytes to scrape starting from the offset > + * > + * Scrapes/removes len bytes from the given skb at the given offset from the > + * skb data. > + * > + * Caller needs to ensure that the region from the skb data's start up > + * to/including the to be removed bytes are linearized. > + */ > +static void batadv_mcast_forw_scrape(struct sk_buff *skb, > + unsigned short offset, > + unsigned short len) > +{ > + char *to = skb_pull(skb, len), *from = to - len; > + > + memmove(to, from, offset); > +} Just because I remembered it when reading a comment: SKB_LINEAR_ASSERT(skb) might be a good idea in places like this. Not all over the place but actually in the code which operates on the buffer and assumes the skbuff to be linearized. skb_put would do such a check (because it is a put at the end of the skb) but not an skb_pull. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v6 1/3] batman-adv: mcast: implement multicast packet reception and forwarding
On Thursday, 20 July 2023 06:35:53 CEST Linus Lüssing wrote: > Implement functionality to receive and forward a new TVLV capable > multicast packet type. > > The new batman-adv multicast packet type allows to contain several > originator destination addresses within a TVLV. Routers on the way will > potentially split the batman-adv multicast packet and adjust its tracker > TVLV contents. > > Routing decisions are still based on the selected BATMAN IV or BATMAN V > routing algorithm. So this new batman-adv multicast packet type retains > the same loop-free properties. > > Also a new OGM multicast TVLV flag is introduced to signal to other > nodes that we are capable of handling a batman-adv multicast packet and > multicast tracker TVLV. And that all of our hard interfaces have an MTU > of at least 1280 bytes (IPv6 minimum MTU), as a simple solution for now > to avoid MTU issues while forwarding. > > Signed-off-by: Linus Lüssing > --- > include/uapi/linux/batadv_packet.h | 45 - > net/batman-adv/Makefile| 1 + > net/batman-adv/main.c | 2 + > net/batman-adv/multicast.c | 48 +- > net/batman-adv/multicast.h | 5 + > net/batman-adv/multicast_forw.c| 256 + > net/batman-adv/originator.c| 1 + > net/batman-adv/routing.c | 70 > net/batman-adv/routing.h | 11 ++ > net/batman-adv/soft-interface.c| 12 ++ > net/batman-adv/types.h | 64 > 11 files changed, 504 insertions(+), 11 deletions(-) > create mode 100644 net/batman-adv/multicast_forw.c Acked-by: Sven Eckelmann signature.asc Description: This is a digitally signed message part.
Re: [PATCH net] batman-adv: Do not get eth header before batadv_check_management_packet
On Fri, 28 Jul 2023 15:38:50 +0200, Remi Pommarel wrote: > If received skb in batadv_v_elp_packet_recv or batadv_v_ogm_packet_recv > is either cloned or non linearized then its data buffer will be > reallocated by batadv_check_management_packet when skb_cow or > skb_linearize get called. Thus geting ethernet header address inside > skb data buffer before batadv_check_management_packet had any chance to > reallocate it could lead to the following kernel panic: > > [...] Applied, thanks! [1/1] batman-adv: Do not get eth header before batadv_check_management_packet commit: eac27a41ab641de074655d2932fc7f8cdb446881 Kind regards, Sven signature.asc Description: This is a digitally signed message part.
[PATCH RFC 3/3] batman-adv: Add support for jumbo frames
Since batman-adv is not actually depending on hardware capabilities, it has no limit on the MTU. Only the lower hard interfaces can limit it. In case these have an high enough MTU or fragmentation is enabled, a higher MTU than 1500 can be enabled. Signed-off-by: Sven Eckelmann --- net/batman-adv/hard-interface.c | 4 +--- net/batman-adv/main.h | 2 ++ net/batman-adv/soft-interface.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 5a4ff9a8..4fbb6339 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -618,10 +618,8 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface) /* the real soft-interface MTU is computed by removing the payload * overhead from the maximum amount of bytes that was just computed. -* -* However batman-adv does not support MTUs bigger than ETH_DATA_LEN */ - return min_t(int, min_mtu - batadv_max_header_len(), ETH_DATA_LEN); + return min_t(int, min_mtu - batadv_max_header_len(), BATADV_MAX_MTU); } /** diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index e0d53273..4dc81ddb 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -22,6 +22,8 @@ #define BATADV_THROUGHPUT_MAX_VALUE 0x #define BATADV_JITTER 20 +#define BATADV_MAX_MTU (ETH_MAX_MTU - batadv_max_header_len()) + /* Time To Live of broadcast messages */ #define BATADV_TTL 50 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index f7947fad..13d5f993 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -769,7 +769,7 @@ static int batadv_softif_init_late(struct net_device *dev) atomic_set(_priv->log_level, 0); #endif atomic_set(_priv->fragmentation, 1); - atomic_set(_priv->packet_size_max, ETH_DATA_LEN); + atomic_set(_priv->packet_size_max, BATADV_MAX_MTU); atomic_set(_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN); atomic_set(_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN); @@ -1009,6 +1009,7 @@ static void batadv_softif_init_early(struct net_device *dev) * have not been initialized yet */ dev->mtu = ETH_DATA_LEN; + dev->max_mtu = BATADV_MAX_MTU; /* generate random address */ eth_hw_addr_random(dev); -- 2.39.2
[PATCH RFC 2/3] batman-adv: Check hardif MTU against runtime MTU
If the MTU of the soft/mesh interface was already reduced (enough), it is not necessary to print a warning about a hard interface not having a MTU to transport ethernet payloads of 1500 bytes. Signed-off-by: Sven Eckelmann --- net/batman-adv/hard-interface.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 41c1ad33..5a4ff9a8 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -699,9 +700,14 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, struct batadv_priv *bat_priv; __be16 ethertype = htons(ETH_P_BATMAN); int max_header_len = batadv_max_header_len(); + unsigned int required_mtu; + unsigned int hardif_mtu; int ret; - if (hard_iface->net_dev->mtu < ETH_MIN_MTU + max_header_len) + hardif_mtu = READ_ONCE(hard_iface->net_dev->mtu); + required_mtu = READ_ONCE(soft_iface->mtu) + max_header_len; + + if (hardif_mtu < ETH_MIN_MTU + max_header_len) return -EINVAL; if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) @@ -734,18 +740,18 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, hard_iface->net_dev->name); if (atomic_read(_priv->fragmentation) && - hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len) + hardif_mtu < required_mtu) batadv_info(hard_iface->soft_iface, "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %i would solve the problem.\n", - hard_iface->net_dev->name, hard_iface->net_dev->mtu, - ETH_DATA_LEN + max_header_len); + hard_iface->net_dev->name, hardif_mtu, + required_mtu); if (!atomic_read(_priv->fragmentation) && - hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len) + hardif_mtu < required_mtu) batadv_info(hard_iface->soft_iface, "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %i.\n", - hard_iface->net_dev->name, hard_iface->net_dev->mtu, - ETH_DATA_LEN + max_header_len); + hard_iface->net_dev->name, hardif_mtu, + required_mtu); if (batadv_hardif_is_iface_up(hard_iface)) batadv_hardif_activate_interface(hard_iface); -- 2.39.2
[PATCH RFC 1/3] batman-adv: Avoid magic value for minimum MTU
The header linux/if_ether.h already defines a constant for the minimum MTU. So simply use it instead of having a magic constant in the code. Signed-off-by: Sven Eckelmann --- net/batman-adv/soft-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index d3fdf822..f7947fad 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -154,7 +154,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu) { /* check ranges */ - if (new_mtu < 68 || new_mtu > batadv_hardif_min_mtu(dev)) + if (new_mtu < ETH_MIN_MTU || new_mtu > batadv_hardif_min_mtu(dev)) return -EINVAL; dev->mtu = new_mtu; -- 2.39.2
[PATCH RFC 0/3] batman-adv: Enable support for jumbo frames
There are from time to time discussions about supporting jumbo frames with batman-adv. While the changes were known since a longe time [1], no actual tests were performed and no actual reviews were gathered. Maybe some more interest can be stirred up by this RFC and some Tested-by/Reviewed-by [2] can be collected - or some fixes. [1] https://www.open-mesh.org/issues/365 [2] https://www.kernel.org/doc/html/v6.4/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes Signed-off-by: Sven Eckelmann --- Sven Eckelmann (3): batman-adv: Avoid magic value for minimum MTU batman-adv: Check hardif MTU against runtime MTU batman-adv: Add support for jumbo frames net/batman-adv/hard-interface.c | 24 ++-- net/batman-adv/main.h | 2 ++ net/batman-adv/soft-interface.c | 5 +++-- 3 files changed, 19 insertions(+), 12 deletions(-) --- base-commit: f779cdaf7782ee765dbddd31f6d9a89abf0c52f9 change-id: 20230727-jumbo-mtu-13d736059c84 Best regards, -- Sven Eckelmann
Re: [PATCH net-next] batman-adv: Remove unused declarations
On Wed, 26 Jul 2023 22:25:25 +0800, YueHaibing wrote: > Since commit 335fbe0f5d25 ("batman-adv: tvlv - convert tt query packet to use > tvlv unicast packets") > batadv_recv_tt_query() is not used. > And commit 122edaa05940 ("batman-adv: tvlv - convert roaming adv packet to > use tvlv unicast packets") > left behind batadv_recv_roam_adv(). > > Applied, thanks! [1/1] batman-adv: Remove unused declarations commit: 5af81b30fd8fc8dcaf2c20e91c9f1f053bf2b4f5 signature.asc Description: This is a digitally signed message part.
Re: [PATCH v5 0/3] Implementation of a Stateless Multicast Packet Type
On Saturday, 8 July 2023 23:51:10 CEST Linus Lüssing wrote: [...] > Changelog v5: > * removed patches 1/5 + 2/5, as they were already applied > * rebased to current main branch > * changed padding behaviour: > * now 2 bytes padding on the end of the multicast > tracker TVLV, if number of destination nodes is > even > * as number of destination nodes might change between > initial check until after pushing them, functions > to post-adjust padding after pushing were added > * added/fixed TTL handling > * removed skb_pull() bailing from sub-functions of > batadv_mcast_forw_push(), to only have a single > skb_pull() to keep track of in batadv_mcast_forw_push() > to revert the changes to the skb; instead a > "unsigned short *tvlv_len" is passsed along in > batadv_mcast_.*push.*() functions to keep track of > how many bytes were pushed > * moved + verified skb->ip_summed invalidation > * batadv_mcast_forw_shrink_tracker() xmas tree ordering > * reword batadv_mcast_forw_push_dest() "Return:" kerneldoc > * fixed spelling: outter -> outer Didn't perform any actual review. But here are the buildbot complaints. The compiler.h is missing since patch 2 (for the "likely()"). Output of different failed tests ecsv/multicast: headers --- diff --git a/net/batman-adv/multicast_forw.c b/net/batman-adv/multicast_forw.c index a90e9057..96ec3f06 100644 --- a/net/batman-adv/multicast_forw.c +++ b/net/batman-adv/multicast_forw.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include ecsv/multicast: kerneldoc ./net/batman-adv/multicast_forw.c --- ./net/batman-adv/multicast_forw.c:433: warning: Function parameter or member 'num_dests_pushed' not described in 'batadv_mcast_forw_push_adjust_padding' ecsv/multicast: sparse linux-5.1 cfg: BLA=y DAT=n DEBUG=n TRACING=y NC=y MCAST=y BATMAN_V=y --- /home/build_test/build_env/tmp.SpMnhX4MAz/net/batman-adv/multicast_forw.c:783:7: warning: symbol 'batadv_mcast_forw_shrink_align_offset' was not declared. Should it be static? ecsv/multicast: unused_symbols linux-5.1 cfg: BLA=y DAT=n DEBUG=n TRACING=y NC=y MCAST=y BATMAN_V=y --- batadv_mcast_forw_shrink_align_offset Kind regards, Sven signature.asc Description: This is a digitally signed message part.
[PATCH 2/2] batman-adv: Don't increase MTU when set by user
If the user set an MTU value, it usually means that there are special requirements for the MTU. But if an interface gots activated, the MTU was always recalculated and then the user set value was overwritten. The only reason why this user set value has to be overwritten, is when the MTU has to be decreased because batman-adv is not able to transfer packets with the user specified size. Fixes: 88861ea9acb7 ("[batman-adv] replacing if up/down timer with kernel notifications") Signed-off-by: Sven Eckelmann --- net/batman-adv/hard-interface.c | 14 +- net/batman-adv/soft-interface.c | 3 +++ net/batman-adv/types.h | 6 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index ae5762af..24c9c0c3 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -630,7 +630,19 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface) */ void batadv_update_min_mtu(struct net_device *soft_iface) { - dev_set_mtu(soft_iface, batadv_hardif_min_mtu(soft_iface)); + struct batadv_priv *bat_priv = netdev_priv(soft_iface); + int limit_mtu; + int mtu; + + mtu = batadv_hardif_min_mtu(soft_iface); + + if (bat_priv->mtu_set_by_user) + limit_mtu = bat_priv->mtu_set_by_user; + else + limit_mtu = ETH_DATA_LEN; + + mtu = min(mtu, limit_mtu); + dev_set_mtu(soft_iface, mtu); /* Check if the local translate table should be cleaned up to match a * new (and smaller) MTU. diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index d3fdf822..85d00dc9 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -153,11 +153,14 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu) { + struct batadv_priv *bat_priv = netdev_priv(dev); + /* check ranges */ if (new_mtu < 68 || new_mtu > batadv_hardif_min_mtu(dev)) return -EINVAL; dev->mtu = new_mtu; + bat_priv->mtu_set_by_user = new_mtu; return 0; } diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index ca9449ec..cf1a0eaf 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -1546,6 +1546,12 @@ struct batadv_priv { /** @soft_iface: net device which holds this struct as private data */ struct net_device *soft_iface; + /** +* @mtu_set_by_user: MTU was set once by user +* protected by rtnl_lock +*/ + int mtu_set_by_user; + /** * @bat_counters: mesh internal traffic statistic counters (see * batadv_counters) -- 2.39.2
[PATCH 1/2] batman-adv: Trigger events for auto adjusted MTU
If an interface changes the MTU, it is expected that an NETDEV_PRECHANGEMTU and NETDEV_CHANGEMTU notification events is triggered. This worked fine for .ndo_change_mtu based changes because core networking code took care of it. But for auto-adjustments after hard-interfaces changes, these events were simply missing. Due to this problem, non-batman-adv components weren't aware of MTU changes and thus couldn't perform their own tasks correctly. Fixes: 8009e9f7ac4f ("set bat0 MTU according to the MTUs of the hard interfaces") Signed-off-by: Sven Eckelmann --- net/batman-adv/hard-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 41c1ad33..ae5762af 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -630,7 +630,7 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface) */ void batadv_update_min_mtu(struct net_device *soft_iface) { - soft_iface->mtu = batadv_hardif_min_mtu(soft_iface); + dev_set_mtu(soft_iface, batadv_hardif_min_mtu(soft_iface)); /* Check if the local translate table should be cleaned up to match a * new (and smaller) MTU. -- 2.39.2
[PATCH 0/2] batman-adv: Fix MTU handling
It was noticed (while proposing a starting point/patch for https://www.open-mesh.org/issues/365 ) that the auto-adjusting MTU handling in batman-adv looks rather odd. * events for pre-MTU change and (post) MTU change were not triggered for an auto-adjust * user set (lower) MTUs were always overwritten when a hard-interface became active Signed-off-by: Sven Eckelmann --- Sven Eckelmann (2): batman-adv: Trigger events for auto adjusted MTU batman-adv: Don't increase MTU when set by user net/batman-adv/hard-interface.c | 14 +- net/batman-adv/soft-interface.c | 3 +++ net/batman-adv/types.h | 6 ++ 3 files changed, 22 insertions(+), 1 deletion(-) --- base-commit: 8924adbdf993cd0521f9d0024b43e3b23af5114f change-id: 20230719-mtu-e5ff71c6dd77 Best regards, -- Sven Eckelmann
Re: Yocto meta-batman
On Tuesday, 11 July 2023 15:03:25 CEST anders.berndts...@idptech.se wrote: > Is there anyone supporting Yocto layer meta-batman ? > > https://github.com/jhaws1982/meta-batman Why aren't you asking the maintainer [1]? But he already wrote [2] on the mailinglist [3] that he will only accept PRs but not maintain it actively. Kind regards, Sven [1] https://github.com/jhaws1982/meta-batman#patches [2] https://lore.kernel.org/batman/dfcf0d4b-8a76-4cb8-9577-620452e7f...@sdl.usu.edu/ [3] https://www.open-mesh.org/projects/open-mesh/wiki/MailingList signature.asc Description: This is a digitally signed message part.
Re: Error - mac address of the ping destination could not be resolved and is not a bat-host name
On Friday, 9 June 2023 20:55:24 CEST Mark Mundy wrote: > I think I understand this to mean that I should remove the ipaddress, netmask > configuration items from the bat0 interface, and create a bridge with bat0 > and eth1. Nearly correct - the eth1 IP configuration must also be removed because you configured two conflicting IP addresses (with the same subnet and metric) and in this process broke the routing table. > Something more like this for 10.1.1.1, and similar changes for 10.2.1.1 where > it is actually the bridge interface that contains holds the IP address info [...] > allow hotplug eth1 > auto eth1 > iface eth1 inet static > address 10.1.1.1 > netmask 255.0.0.0 > gateway 10.0.0.1 > #dns-nameservers 1.1.1.1 8.8.8.8 8.8.4.4 Why do you configure an IP address on eth1? It is part of a bridge and the IP configuration must be on top of the bridge. But you already have an IP address in the same subnet configured on br0. There are ways to still work around this configuration problem but it would be weird to not simply fix the configuration. Btw. this has nothing to do with batman-adv but is just about basic (Linux) networking. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: Error - mac address of the ping destination could not be resolved and is not a bat-host name
On Thursday, 8 June 2023 22:38:23 CEST mark.mu...@draeger.com wrote: > What is the best way to figure out why 2 nodes that are connected on a WMN > can see each other through 'batctl n', but 'batman ping' fails with the > message "Error - mac address of the ping destination could not be resolved > and is not a bat-host name"? Please use either the actual mac address of the remote or the IP which is configured on the bat0 (which is also reachable directly by your host). batman-adv is not the IP subsystem and will therefore not be able to resolve any non-direct neighbors (over bat0). > Node at eth1 - 10.1.1.1, wlan0 mac ether 04:f0:21:59:38:c9 > root@jammy-newport:~# batctl n > [B.A.T.M.A.N. adv 2021.3, MainIF/MAC: wlan0/04:f0:21:59:38:c9 > (bat0/72:85:90:2a:95:06 BATMAN_IV)] > IF Neighbor last-seen > wlan0 c4:4b:d1:90:02:900.500s > root@jammy-newport:~# batctl ping 10.2.1.1 > Error - mac address of the ping destination could not be resolved and is not > a bat-host name: 10.2.1.1 > > > Node at eth1 - 10.2.1.1, wlan0 mac ether c4:4b:d1:90:02:90 > root@focal-newport:~# batctl n > [B.A.T.M.A.N. adv 2021.3, MainIF/MAC: wlan0/c4:4b:d1:90:02:90 > (bat0/6e:87:15:7e:f3:14 BATMAN_IV)] > IF Neighbor last-seen > wlan0 04:f0:21:59:38:c90.708s > root@focal-newport:~# batctl ping 10.1.1.1 > Error - mac address of the ping destination could not be resolved and is not > a bat-host name: 10.1.1.1 > > My intention is to be able to reach a computer on the far side of the WMN > connected to eth1 10.2.1.1 from my host computer connected to the same > network on eth1 10.1.1.1. It should look something like this. > network -> eth1 10.1.1.1 -> wlan0 -> bat0 (inet 10.1.1.4) -> BATMAN -> bat0 > (inet 10.2.1.4) -> wlan0 -> eth1 10.2.1.1 -> non-BATMAN computer > > My intention is to have eth1 10.1.1.1 connected to the main network as an > interface for bat0 able to communicate over bat0. On the other end, eth1 > 10.2.1.1 The interfaces for eth1 and wlan0 show as active for both computers. Reach how? With IP routing? It is not the task of batman-adv to perform IP routing (it is on the wrong layer). On Thursday, 8 June 2023 22:38:23 CEST mark.mu...@draeger.com wrote: > allow hotplug eth1 > auto eth1 > iface eth1 inet static > address 10.1.1.1 > netmask 255.0.0.0 > gateway 10.0.0.1 > #dns-nameservers 1.1.1.1 8.8.8.8 8.8.4.4 > > allow hotplug bat0 > auto bat0 > iface bat0 inet static > address 10.1.1.4 > netmask 255.0.0.0 The IP configuration is weird. You have two IP addresses (bat0+ethX) which are overlapping (10.0.0.0/8). This cannot work. If it should be a transparent bridge between mesh without IP routing then please add bat0+eth1 in the same bridge. And then configure the IP address on top of the bridge. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH 1/1] batman-adv: Broken sync while rescheduling delayed work
On Thursday, 8 June 2023 11:27:31 CEST Paolo Abeni wrote: [...] > > We're still not preventing the timer / work from getting scheduled > > and staying alive after the netdev has been freed, right? > > I *think* this specific use case does not expose such problem, as the > delayed work is (AFAICS) scheduled only at device creation time and by > the work itself, it should never be re-scheduled after > cancel_delayed_work_sync() Correct. * batadv_dat_start_timer is the only thing scheduling it * batadv_dat_start_timer is called by: - batadv_dat_purge (the worker rearming itself) - batadv_dat_init (when the interface is created) Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH] batman-adv: Broken sync while rescheduling delayed work
On Friday, 26 May 2023 18:16:32 CEST Vladislav Efanov wrote: > Syzkaller got a lot of crashes like: > KASAN: use-after-free Write in *_timers* > > All of these crashes point to the same memory area: > > The buggy address belongs to the object at 88801f87 > which belongs to the cache kmalloc-8k of size 8192 > The buggy address is located 5320 bytes inside of > 8192-byte region [88801f87, 88801f872000) > > This area belongs to : > batadv_priv->batadv_priv_dat->delayed_work->timer_list > > The reason for these issues is the lack of synchronization. Delayed > work (batadv_dat_purge) schedules new timer/work while the device > is being deleted. As the result new timer/delayed work is set after > cancel_delayed_work_sync() was called. So after the device is freed > the timer list contains pointer to already freed memory. > > Found by Linux Verification Center (linuxtesting.org) with syzkaller. > > Fixes: 2f1dfbe18507 ("batman-adv: Distributed ARP Table - implement local > storage") > Signed-off-by: Vladislav Efanov > --- Acked-by: Sven Eckelmann Thanks, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH] batman-adv: Broken sync while rescheduling delayed work
On Friday, 26 May 2023 18:16:32 CEST Vladislav Efanov wrote: > The reason for these issues is the lack of synchronization. Delayed > work (batadv_dat_purge) schedules new timer/work while the device > is being deleted. As the result new timer/delayed work is set after > cancel_delayed_work_sync() was called. So after the device is freed > the timer list contains pointer to already freed memory. You are most likely right but could you please point out what in the worker is checked by the workqueue code that prevents it from being scheduled again? (and which seems to be overwritten as your patch seems to suggest) I think __cancel_work_timer marked the work as canceling but batadv_dat_start_timer reinitialized the worked (thus removing this important state). Would be nice if you could either correct me or confirm what I think to remember. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH 1/5] batman-adv: Start new development cycle
On Tuesday, 7 February 2023 11:41:53 CET Leon Romanovsky wrote: > Once you stop to update version, you will push users to look on the real > version (kernel) which really matters. I would have understood if you say "let us use a magic value like 'in-tree' or 'linux'" but setting it to an old (existing) version number - I don't want to live with the headaches it creates. Because this is what users often don't (want) to understand: if it looks like a valid version number, why isn't it the valid version number? So I have to do a lot of pushing - without any rewards because it is necessary to push every new "user". Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH 1/5] batman-adv: Start new development cycle
On Tuesday, 7 February 2023 10:02:58 CET Leon Romanovsky wrote: > In cases where you can prove real userspace breakage, we simply stop to > update module versions. That would be the worst option. Then the kernel shows bogus values and no one is helped. And how should I prove it to you? Is that enough? $ lsmod|grep '^batman_adv' batman_adv266240 0 $ sudo batctl -v batctl debian-2022.3-2 [batman-adv: module not loaded] $ sudo batctl if add enp70s0 Error - batman-adv module has not been loaded $ sudo ip link show dev bat0 8: bat0: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 7a:8b:21:b7:13:b8 brd ff:ff:ff:ff:ff:ff $ sudo ip link set master bat0 dev enp70s0 $ sudo ip link set up dev bat0 $ sudo batctl n Missing attributes from kernel $ sudo batctl o Missing attributes from kernel Expected was following output: $ sudo batctl -v batctl debian-2022.3-2 [batman-adv: 2022.3] $ sudo batctl if add enp70s0 $ sudo ip link show dev bat0 $ sudo ip link set up dev bat0 $ sudo batctl n [B.A.T.M.A.N. adv 2022.3, MainIF/MAC: enp70s0/2c:f0:5d:04:70:39 (bat0/7a:8b:21:b7:13:b8 BATMAN_IV)] IF Neighbor last-seen enp70s0 50:7b:9d:ce:26:830.708s $ sudo batctl o [B.A.T.M.A.N. adv 2022.3, MainIF/MAC: enp70s0/2c:f0:5d:04:70:39 (bat0/7a:8b:21:b7:13:b8 BATMAN_IV)] Originatorlast-seen (#/255) Nexthop [outgoingIF] * 50:7b:9d:ce:26:830.684s (255) 50:7b:9d:ce:26:83 [ enp70s0] Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH 1/5] batman-adv: Start new development cycle
On Friday, 3 February 2023 09:29:50 CET Jiri Pirko wrote: [...] > Why kernel version is not enough for you? My point is, why to maintain > internal driver version alongside with the kernel version? [...] > >Also note that we can't do a simple kernel version to year > >notation mapping in userspace in batctl. OpenWrt uses the most > >recent Linux LTS release. But might feature a backport of a more > >recent batman-adv which is newer than the one this stable kernel > >would provide. Or people also often use Debian stable but compile > >and use the latest batman-adv version with it. > > Yeah, for out of tree driver, have whatever. A while back, my personal opinion changed after there were various Linux developers/maintainers were trying to either remove it or wondering about this bump. The idea which I've proposed was to: * still ship the "backports" like out-of-tree tarball with a module version - but directly in its "compat" code * continue to use in projects (which for whatever reason cannot use the in- kernel implementation) a version which represents their upstream backports tarball + their (patch) revision: Something like "2022.0-openwrt-7" * for the in-kernel module, just return either - remove the version information completely from the kernel module MODULE_VERSION + drop BATADV_ATTR_VERSION + modifying batctl to fetch that from uname(). But of course, that would break old batctl versions [1] - or by setting BATADV_SOURCE_VERSION to UTS_RELEASE (+suffix?) or UTS_VERSION But this wasn't well received when mentioning it to Simon+Linus (but I could misremember the persons involved here). Kind regards, Sven [1] https://lore.kernel.org/r/20201205085604.1e3fc...@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com signature.asc Description: This is a digitally signed message part.
Re: [PATCH v4 0/5] Implementation of a Stateless Multicast Packet Type
On Tuesday, 27 December 2022 20:34:04 CET Linus Lüssing wrote: [...] > The purpose of this new packet type is to allow to forward an IP > multicast packet with less transmissions / overhead than the > multicast-via-multiple-unicasts approach. Or to reach a lot more > destinations (currently up to 196, depending on the payload size, see > Wiki documentation for details) than with the default multicast fanout > for the via-unicasts approach. Please don't forget that batctl's tcpdump also requires support for parsing it. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
[PATCH] batman-adv: Fix mailing list address
Fixes: d83571147325 ("add some README to describe the usage") Signed-off-by: Sven Eckelmann --- Documentation/networking/batman-adv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/networking/batman-adv.rst b/Documentation/networking/batman-adv.rst index b85563ea..8a0dcb18 100644 --- a/Documentation/networking/batman-adv.rst +++ b/Documentation/networking/batman-adv.rst @@ -159,7 +159,7 @@ Please send us comments, experiences, questions, anything :) IRC: #batadv on ircs://irc.hackint.org/ Mailing-list: - b.a.t.m@open-mesh.org (optional subscription at + b.a.t.m.a.n@lists.open-mesh.org (optional subscription at https://lists.open-mesh.org/mailman3/postorius/lists/b.a.t.m.a.n.lists.open-mesh.org/) You can also contact the Authors: --- base-commit: d364e8168b28b345f39c3f77526a2d71a28c282e change-id: 20230121-mailinglist-5f3588e088c6 Best regards, -- Sven Eckelmann
[PATCH] alfred: gpsd: Fix build against gpsd 3.25
gpsd moved in commit 35fe48835da0 ("include/gps.h: Move fixsource_t into gps.h, add into gps_data_t.") the function gpsd_source_spec + its data structures from the private gpsdclient.h to the public API header gps.h. But the actual API major or minor version was not increased in this process. It is therefore not easily possible to figure out whether the libgps API will provide this functionality or not. To avoid a conflict during the build, just rename fixsource_t and gpsd_source_spec. Reported-by: Bjørn Forsman Signed-off-by: Sven Eckelmann --- gpsd/alfred-gpsd.c | 11 +++ gpsd/alfred-gpsd.h | 8 +--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gpsd/alfred-gpsd.c b/gpsd/alfred-gpsd.c index 20b3d98..d0bd47c 100644 --- a/gpsd/alfred-gpsd.c +++ b/gpsd/alfred-gpsd.c @@ -217,8 +217,11 @@ static int gpsd_read_answer(struct globals *globals) return 0; } -/* Standard parsing of a GPS data source spec. Taken from gpsdclient.c */ -static void gpsd_source_spec(const char *arg, struct fixsource_t *source) +/* Standard parsing of a GPS data source spec. Taken from gpsdclient.c + * remove when gpsd 3.25 is minimum supported version + */ +static void alfred_gpsd_source_spec(const char *arg, + struct alfred_gpsd_fixsource_t *source) { /* the casts attempt to head off a -Wwrite-strings warning */ source->server = (char *)"localhost"; @@ -425,7 +428,7 @@ static struct globals *gpsd_init(int argc, char *argv[]) gpsd_parse_location(globals, optarg); break; case 'g': - gpsd_source_spec(optarg, >gpsdsource); + alfred_gpsd_source_spec(optarg, >gpsdsource); have_source = true; break; case 'u': @@ -443,7 +446,7 @@ static struct globals *gpsd_init(int argc, char *argv[]) } if (globals->source == SOURCE_GPSD && !have_source) - gpsd_source_spec(NULL, >gpsdsource); + alfred_gpsd_source_spec(NULL, >gpsdsource); if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) perror("could not register SIGPIPE handler"); diff --git a/gpsd/alfred-gpsd.h b/gpsd/alfred-gpsd.h index 38588ad..174ca14 100644 --- a/gpsd/alfred-gpsd.h +++ b/gpsd/alfred-gpsd.h @@ -60,8 +60,10 @@ struct gpsd_v1 { #define GPSD_DATA_SIZE(gpsd_data) \ (sizeof(*gpsd_data) + (ntohl(gpsd_data->tpv_len))) -/* struct taken from gpsdclient.h */ -struct fixsource_t +/* struct taken from gpsdclient.h + * remove when gpsd 3.25 is minimum supported version + */ +struct alfred_gpsd_fixsource_t { char *spec; /* pointer to actual storage */ char *server; @@ -84,7 +86,7 @@ struct globals { int unix_sock; const char *unix_path; - struct fixsource_t gpsdsource; + struct alfred_gpsd_fixsource_t gpsdsource; struct gps_data_t gpsdata; char * tpv; }; --- base-commit: 1ff43b3ea32b0f6cdea2440c4beaf001090370ff change-id: 20230121-gpsd_3-25-34e854104d05 Best regards, -- Sven Eckelmann
Re: [PATCH v4 5/5] batman-adv: mcast: shrink tracker packet after scrubbing
On Tuesday, 27 December 2022 20:34:09 CET Linus Lüssing wrote: > +/** > + * batadv_mcast_forw_shrink_move_headers() - move multicast headers by offset > + * @skb: the batman-adv multicast packet to move headers for > + * @offset: a non-negative offset to move headers by, towards the skb tail > + * > + * Moves the batman-adv multicast packet header, its multicast tracker TVLV > and > + * any TVLVs in between by the given offset in direction towards the tail. > + * > + * It also invalidates the skb checksum. > + */ > +static void > +batadv_mcast_forw_shrink_move_headers(struct sk_buff *skb, unsigned int > offset) > +{ > + struct batadv_tvlv_mcast_tracker *mcast_tracker; > + unsigned int tracker_hdrlen, len; > + unsigned char *skb_net_hdr; > + u16 num_dests; > + > + skb_net_hdr = skb_network_header(skb); > + mcast_tracker = (struct batadv_tvlv_mcast_tracker *)skb_net_hdr; > + num_dests = ntohs(mcast_tracker->num_dests); > + tracker_hdrlen = batadv_mcast_forw_tracker_hdrlen(num_dests); > + len = skb_network_offset(skb) + tracker_hdrlen; > + > + memmove(skb->data + offset, skb->data, len); > + skb_pull(skb, offset); > + > + /* invalidate checksum: */ > + skb->ip_summed = CHECKSUM_NONE; Shouldn't the invalidation be that already part of the patch 3? At least it includes receive path processing and modification on the tvlv with the destination originator addresses. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v4 4/5] batman-adv: mcast: implement multicast packet generation
On Tuesday, 27 December 2022 20:34:08 CET Linus Lüssing wrote: > Implement the preparation of a batman-adv multicast packet and use this > under certain conditions. > > For one thing this implements the capability to push a complete > batman-adv multicast packet header, including a tracker TVLV with all > originator destinations that have signaled interest in it, onto a given > ethernet frame with an IP multicast packet inside. > > For another checks are implemented to determine if encapsulating a > multicast packet in this new batman-adv multicast packet type and using > it is feasible. Those checks are: > > 1) Have all nodes signaled that they are capable of handling the new >batman-adv multicast packet type? > 2) Do all active hard interfaces of all nodes, including us, have an MTU >of at least 1280 bytes? > 3) Does a complete multicast packet header with all its destination >addresses fit onto the given multicast packet / ethernet frame and >does not exceed 1280 bytes? > > If all checks passed then the new batman-adv multicast packet type will > be used for transmission and distribution. Otherwise we fall back to one or > more batman-adv unicast packet transmissions, if possible. Or if not > possible we will fall back to classic flooding through a batman-adv > broadcast packet. > > Signed-off-by: Linus Lüssing > --- > net/batman-adv/multicast.c | 79 - > net/batman-adv/multicast.h | 25 +- > net/batman-adv/multicast_forw.c | 513 > net/batman-adv/soft-interface.c | 6 +- > net/batman-adv/types.h | 6 + > 5 files changed, 621 insertions(+), 8 deletions(-) Acked-by: Sven Eckelmann Btw. it is spelled "outer" and not "outter" [...] > +/** > + * batadv_mcast_forw_expand_head() - expand headroom for an mcast packet > + * @bat_priv: the bat priv with all the soft interface information > + * @skb: the multicast packet to send > + * > + * Tries to expand an skb's headroom so that its head to tail is 1298 > + * bytes (minimum IPv6 MTU + vlan ethernet header size) large. > + * > + * Return: -EINVAL if the given skb's length is too large or -ENOMEM on > memory > + * allocation failure. Otherwise, on success, zero is returned. > + */ > +static int batadv_mcast_forw_expand_head(struct batadv_priv *bat_priv, > + struct sk_buff *skb) > +{ > + int hdr_size = VLAN_ETH_HLEN + IPV6_MIN_MTU - skb->len; > + > + /* TODO: Could be tightened to actual number of destination nodes? > + * But it's tricky, number of destinations might have increased since > + * we last checked. > + */ But it might at least be a good start. So basically a "we can at least guarantee that there is enough room for what we've seen in our precheck" And you could make sure that we still have enough headroom for our lower devices. Not that we steal from the headroom which they need - because your headroom is not part of the needed_headroom which we report. But of course, we don't know the outgoing device (yet) - so this makes it harder to figure out how large we need to allocate it. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v4 3/5] batman-adv: mcast: implement multicast packet reception and forwarding
On Tuesday, 27 December 2022 20:34:07 CET Linus Lüssing wrote: > Implement functionality to receive and forward a new TVLV capable > multicast packet type. > > The new batman-adv multicast packet type allows to contain several > originator destination addresses within a TVLV. Routers on the way will > potentially split the batman-adv multicast packet and adjust its tracker > TVLV contents. > > Routing decisions are still based on the selected BATMAN IV or BATMAN V > routing algorithm. So this new batman-adv multicast packet type retains > the same loop-free properties. > > Also a new OGM multicast TVLV flag is introduced to signal to other > nodes that we are capable of handling a batman-adv multicast packet and > multicast tracker TVLV. And that all of our hard interfaces have an MTU > of at least 1280 bytes (IPv6 minimum MTU), as a simple solution for now > to avoid MTU issues while forwarding. > > Signed-off-by: Linus Lüssing > --- > include/uapi/linux/batadv_packet.h | 48 - > net/batman-adv/Makefile| 1 + > net/batman-adv/main.c | 2 + > net/batman-adv/multicast.c | 48 - > net/batman-adv/multicast.h | 5 + > net/batman-adv/multicast_forw.c| 274 + > net/batman-adv/originator.c| 1 + > net/batman-adv/routing.c | 68 +++ > net/batman-adv/routing.h | 11 ++ > net/batman-adv/soft-interface.c| 12 ++ > net/batman-adv/types.h | 64 +++ > 11 files changed, 523 insertions(+), 11 deletions(-) > create mode 100644 net/batman-adv/multicast_forw.c Acked-by: Sven Eckelmann But I want to have at least another maintainer checking the new packet format and acking it. Kind regards, Sven [...] > +static void > +batadv_mcast_forw_scrub_dests(struct batadv_priv *bat_priv, > + struct batadv_neigh_node *comp_neigh, u8 *dest, > + u8 *next_dest, u16 num_dests) > +{ > + struct batadv_neigh_node *next_neigh; > + > + /* skip first entry, this is what we are comparing with */ > + eth_zero_addr(dest); > + dest += ETH_ALEN; > + next_dest += ETH_ALEN; > + num_dests--; > + > + batadv_mcast_forw_tracker_for_each_dest(next_dest, num_dests) { > + if (is_zero_ether_addr(next_dest)) > + goto scrub_next; > + > + if (is_multicast_ether_addr(next_dest)) { > + eth_zero_addr(dest); > + eth_zero_addr(next_dest); > + goto scrub_next; > + } > + > + next_neigh = batadv_mcast_forw_orig_to_neigh(bat_priv, > + next_dest); > + if (!next_neigh) { > + eth_zero_addr(next_dest); Why is the original skb not touched in this case? It might not be a problem because you are also doing the batadv_mcast_forw_orig_to_neigh check in batadv_mcast_forw_packet. But I was just wondering about it Btw. it could happen that you send out a packet with zero destinations in the TVLV because the neighbor disappeared between the batadv_mcast_forw_orig_to_neigh in batadv_mcast_forw_packet and in batadv_mcast_forw_scrub_dests Kind regards, Sven signature.asc Description: This is a digitally signed message part.
[PATCH v2] batman-adv: Drop prandom.h includes
The commit a15d3f3c1c2a ("batman-adv: use get_random_u32_below() instead of deprecated function") replaced the prandom.h function prandom_u32_max with the random.h function get_random_u32_below. There is no need to still include prandom.h. Signed-off-by: Sven Eckelmann --- v2: - Fix conflicts with the Linux < 4.14 compat code removal - directly integrate "batman-adv: Include random.h for get_random_u32_below" into the first patch --- compat-include/linux/prandom.h | 24 net/batman-adv/bat_iv_ogm.c | 1 - net/batman-adv/bat_v_elp.c | 1 - net/batman-adv/bat_v_ogm.c | 1 - net/batman-adv/network-coding.c | 2 +- 5 files changed, 1 insertion(+), 28 deletions(-) diff --git a/compat-include/linux/prandom.h b/compat-include/linux/prandom.h deleted file mode 100644 index ec2f5244.. --- a/compat-include/linux/prandom.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_PRANDOM_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_PRANDOM_H_ - -#include -#if LINUX_VERSION_IS_GEQ(5, 8, 1) || \ -(LINUX_VERSION_IS_GEQ(4, 14, 193) && LINUX_VERSION_IS_LESS(4, 15, 0)) || \ -(LINUX_VERSION_IS_GEQ(4, 19, 138) && LINUX_VERSION_IS_LESS(4, 20, 0)) || \ -(LINUX_VERSION_IS_GEQ(5, 4, 57) && LINUX_VERSION_IS_LESS(5, 5, 0)) || \ -(LINUX_VERSION_IS_GEQ(5, 7, 14) && LINUX_VERSION_IS_LESS(5, 8, 0)) -#include_next -#else -#include -#endif - -#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_PRANDOM_H_ */ diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 114ee5da..828fb393 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index f9a58fb5..acff5658 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index addfd8c4..96e02736 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index bf29fba4..ecd871ab 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include #include #include --- base-commit: d364e8168b28b345f39c3f77526a2d71a28c282e change-id: 20230107-headers-055722c77349 Best regards, -- Sven Eckelmann
[PATCH] batman-adv: Drop support for Linux < 4.14
The Linux Kernel 4.9 reached its end of life [1] after 6 years. Instead it is recommended to use at least kernel 4.14. It is also over 5 years old but still maintained by the stable kernel team. All older kernels (4.9 - v4.13) will be dropped to reduce the support overhead. [1] https://lore.kernel.org/r/y7lbu6%2f0p7q%2fp...@kroah.com Signed-off-by: Sven Eckelmann --- README.external.rst | 2 +- compat-include/linux/build_bug.h | 31 - compat-include/linux/netdevice.h | 19 compat-include/linux/prandom.h | 1 - compat-include/linux/skbuff.h| 29 compat-include/linux/timer.h | 34 compat-include/uapi/linux/if_ether.h | 25 compat.h | 10 8 files changed, 1 insertion(+), 150 deletions(-) delete mode 100644 compat-include/linux/build_bug.h delete mode 100644 compat-include/linux/timer.h delete mode 100644 compat-include/uapi/linux/if_ether.h diff --git a/README.external.rst b/README.external.rst index 34f3a8d4..e9f00ee0 100644 --- a/README.external.rst +++ b/README.external.rst @@ -12,7 +12,7 @@ and as an external module. The external module allows to get newfeatures without upgrading to a newer kernel version and to get batman-adv specific bug fixes for kernels that are not supported anymore. It compiles against and should work -with Linux 4.9 - 6.1. Supporting older versions is not +with Linux 4.14 - 6.1. 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. :-) diff --git a/compat-include/linux/build_bug.h b/compat-include/linux/build_bug.h deleted file mode 100644 index 8ec79069.. --- a/compat-include/linux/build_bug.h +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ - -#include -#if LINUX_VERSION_IS_GEQ(4, 13, 0) -#include_next -#else -#include - -/* Linux 4.9.297 doesn't provide BUILD_BUG_ON anymore in linux/bug.h - * also identified itself with the version number 4.9.255 when decoding the - * LINUX_VERSION_CODE. So we have to try to guess now if we need to include - * linux/build_bug.h based on whether BUILD_BUG_ON is defined or not after - * including linux/bug.h - */ -#ifndef BUILD_BUG_ON -#include_next -#endif - -#endif - -#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ */ diff --git a/compat-include/linux/netdevice.h b/compat-include/linux/netdevice.h index eeb31bed..3188ad3d 100644 --- a/compat-include/linux/netdevice.h +++ b/compat-include/linux/netdevice.h @@ -20,25 +20,6 @@ #endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */ -#if LINUX_VERSION_IS_LESS(4, 11, 9) - -/* work around missing attribute needs_free_netdev and priv_destructor in - * net_device - */ -#define ether_setup(dev) \ - void batadv_softif_free2(struct net_device *dev) \ - { \ - batadv_softif_free(dev); \ - free_netdev(dev); \ - } \ - void (*t1)(struct net_device *dev) __attribute__((unused)); \ - bool t2 __attribute__((unused)); \ - ether_setup(dev) -#define needs_free_netdev destructor = batadv_softif_free2; t2 -#define priv_destructor destructor = batadv_softif_free2; t1 - -#endif /* LINUX_VERSION_IS_LESS(4, 11, 9) */ - #if LINUX_VERSION_IS_LESS(5, 15, 0) diff --git a/compat-include/linux/prandom.h b/compat-include/linux/prandom.h index dc227e61..ec2f5244 100644 --- a/compat-include/linux/prandom.h +++ b/compat-include/linux/prandom.h @@ -12,7 +12,6 @@ #include #if LINUX_VERSION_IS_GEQ(5, 8, 1) || \ -(LINUX_VERSION_IS_GEQ(4, 9, 233) && LINUX_VERSION_IS_LESS(4, 10, 0)) || \ (LINUX_VERSION_IS_GEQ(4, 14, 193) && LINUX_VERSION_IS_LESS(4, 15, 0)) || \ (LINUX_VERSION_IS_GEQ(4, 19, 138) && LINUX_VERSION_IS_LESS(4, 20, 0)) || \ (LINUX_VERSION_IS_GEQ(5, 4, 57) && LINUX_VERSION_IS_LESS(5, 5, 0)) || \ diff --git a/compat-include/linux/skbuff.h b/compat-include/linux/skbuff.h index 77c4e99f..eda2d181 100644 --- a/compat-include/linux/skbuff.h +++ b/compat-include/linux/skbuff.h @@ -13,35 +13,6 @@ #include #include_next -#if LINUX_VERSION_IS_LESS(4, 13, 0) - -static inline void *batadv_skb_put(struct sk_buff *skb, unsigned int len) -{ - return (void *)skb_put(skb, len); -} -#define skb_put batadv_skb_put - -static inline void *skb_put_zero(struct sk_buff *skb, unsigned int len) -{ - void *tmp = skb_put(skb, len); - - memset(tmp, 0, len); - - return tmp; -} - -static inline void *skb_put_data(struc
Mailing list mirror on lore.kernel.org
Hi, maybe some of you remember the time when the archive of this mailing list was also mirrored to Gmane - providing services like web ui, nntp or raw (unmangled) mail downloads. But the original Gmane is gone since a long time. And the other public mirror (mail-archive.com) is a lot more web centric and not integrated in the kernel.org infrastructure. So I spend my time between the years to fix the situation and create an sanitized archive of all the old mails form this mailing list. This was then submitted to the kernel.org's helpdesk for inclusion in their public-inbox [1] infrastructure [2]. To make a long story short: you can now find the mails also under https://lore.kernel.org/batman/ Some features are: * NNTP/Atom feed support * being able to follow threads spanning multiple (kernel) mailing lists * handle your patch queues with b4 For example when you want to apply the new multicast patches from Linus: $ b4 am 20221227193409.13461-1-linus.luess...@c0d3.blue $ git am ./v4_20221227_linus_luessing_implementation_of_a_stateless_multicast_packet_type.mbx Similar things can also be done to prepare the patches for submission. See - https://people.kernel.org/monsieuricon/introducing-b4-and-patch-attestation - https://people.kernel.org/monsieuricon/sending-a-kernel-patch-with-b4-part-1 * whole mailinglist archive available as git repository At the moment, our single epoch can be mirrored using: $ git clone --mirror https://lore.kernel.org/batman/0 batman/git/0.git # but you should use public-inbox/ or otherwise you might miss some # archives in case it is split into multiple epochs See - https://lore.kernel.org/batman/_/text/mirror/ - https://people.kernel.org/monsieuricon/subscribing-to-lore-lists-with-grokmirror * Subscribe^W Pull mailing list with filters via (lore)lei See - https://people.kernel.org/monsieuricon/lore-lei-part-1-getting-started - https://people.kernel.org/monsieuricon/lore-lei-part-2-now-with-imap The hyperkitty mailing archives on lists.open-mesh.org will continue to be supported. But their archives are not perfectly suited for working with patch(sets) - so this should be a nice addition for some people. And I will also continue to use patchwork for keeping track of patches. lore.kernel.org and its tooling just adds a cherry on top. Kind regards, Sven [1] https://public-inbox.org/README.html [2] https://www.kernel.org/lore.html signature.asc Description: This is a digitally signed message part.
Re: [PATCH v4 2/5] batman-adv: tvlv: prepare for tvlv enabled multicast packet type
On Tuesday, 27 December 2022 20:34:06 CET Linus Lüssing wrote: > Prepare TVLV infrastructure for more packet types, in particular the > upcoming batman-adv multicast packet type. > > For that swap the OGM vs. unicast-tvlv packet boolean indicator to an > explicit unsigned integer packet type variable. And provide the skb > to a call to batadv_tvlv_containers_process(), as later the multicast > packet's TVLV handler will need to have access not only to the TVLV but > the full skb for forwarding. Forwarding will be invoked from the > multicast packet's TVLVs' contents later. > > Signed-off-by: Linus Lüssing > --- > include/uapi/linux/batadv_packet.h | 2 + > net/batman-adv/bat_v_ogm.c | 4 +- > net/batman-adv/distributed-arp-table.c | 2 +- > net/batman-adv/gateway_common.c| 2 +- > net/batman-adv/multicast.c | 2 +- > net/batman-adv/network-coding.c| 2 +- > net/batman-adv/routing.c | 7 ++- > net/batman-adv/translation-table.c | 4 +- > net/batman-adv/tvlv.c | 71 ++ > net/batman-adv/tvlv.h | 9 ++-- > net/batman-adv/types.h | 6 +++ > 11 files changed, 74 insertions(+), 37 deletions(-) I am rather unhappy that the TVLV handlers parts are not static, constant, global objects which are just presented to batadv_tvlv_handler_register. The batadv_tvlv_containers_process parameters start to become a mess. Anyway, this has not really anything to do with your patch. Acked-by: Sven Eckelmann Just wondering if it is a good idea to use the network/transport header offsets/pointers like this. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v4 1/5] batman-adv: mcast: remove now redundant single ucast forwarding
On Tuesday, 27 December 2022 20:34:05 CET Linus Lüssing wrote: > The multicast code to send a multicast packet via multiple batman-adv > unicast packets is not only capable of sending to multiple but also to a > single node. Therefore we can safely remove the old, specialized, now > redundant multicast-to-single-unicast code. > > The only functional change of this simplification is that the edge case > of allowing a multicast packet with an unsnoopable destination address > (224.0.0.0/24 or ff02::1) where only a single node has signaled interest > in it via the batman-adv want-all-unsnoopables multicast flag is now > transmitted via a batman-adv broadcast instead of a batman-adv unicast > packet. Maintaining this edge case feature does not seem worth the extra > lines of code and people should just not expect to be able to snoop and > optimize such unsnoopable multicast addresses when bridges are involved. > > While at it also renaming a few items in the batadv_forw_mode enum to > prepare for the new batman-adv multicast packet type. > > Signed-off-by: Linus Lüssing > --- > net/batman-adv/multicast.c | 249 ++-- > net/batman-adv/multicast.h | 38 + > net/batman-adv/soft-interface.c | 26 ++-- > 3 files changed, 33 insertions(+), 280 deletions(-) Acked-by: Sven Eckelmann Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v3 3/5] batman-adv: mcast: implement multicast packet reception and forwarding
On Tuesday, 27 December 2022 12:58:41 CET Linus Lüssing wrote: > On Tue, Dec 27, 2022 at 10:07:36AM +0100, Sven Eckelmann wrote: > > ecsv/pu: checkpatch ./net/batman-adv/multicast_forw.c > > - > > > > CHECK: Macro argument reuse 'num_dests' - possible side-effects? > > #25: FILE: ./net/batman-adv/multicast_forw.c:25: > > +#define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ > > + for (; num_dests; num_dests--, (dest) += ETH_ALEN) > > > > total: 0 errors, 0 warnings, 1 checks, 274 lines checked > > > > For this I'm not quite sure how to best silence this. I tried > the workaround of passing num_dests as a pointer and dereferencing > it inside the macro: > > #define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ > for (; (*(num_dests)); (*(num_dests))--, (dest) += ETH_ALEN) This doesn't make a lot of sense. The checkpatch output is about using the same argument multiple times. It is explicitly talking about following situation. #define asd(b) \ do { if (b) printk("Foobar %d\n", b); while (1) asd(x++); Which would then be transformed to following by the preprocessor: do { if (x++) printk("Foobar %d\n", x++); while (1) So your x after the "call" of asd() would (sometimes) not be x+1 but x+2. > So just like you'd do if you would want intentional side-effects with > a normal function. But seems like checkpatch does not recoginze it. > > Also all the other for_each macros in the kernel code have > side-effects, as far as I know? > > Or would you have another idea? Provide a patch for checkpatch or build_test.git (which would otherwise send this output every day). Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v3 5/5] batman-adv: mcast: shrink tracker packet after scrubbing
On Monday, 26 December 2022 21:42:37 CET Linus Lüssing wrote: > Remove all zero MAC address entries (00:00:00:00:00:00) from a multicast > packet's tracker TVLV before transmitting it and update all headers > accordingly. This way, instead of keeping the multicast packet at a > constant size throughout its journey through the mesh, it will become > more lightweight, smaller with every interested receiver on the way and > on each splitting intersection. Which can save some valuable bandwidth. > > Signed-off-by: Linus Lüssing > --- > net/batman-adv/multicast_forw.c | 212 > 1 file changed, 212 insertions(+) ecsv/pu: checkpatch ./net/batman-adv/multicast_forw.c - CHECK: Macro argument reuse 'num_dests' - possible side-effects? #35: FILE: ./net/batman-adv/multicast_forw.c:35: +#define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ + for (; num_dests; num_dests--, (dest) += ETH_ALEN) CHECK: Macro argument reuse 'num_dests' - possible side-effects? #38: FILE: ./net/batman-adv/multicast_forw.c:38: +#define batadv_mcast_forw_tracker_for_each_dest_rev(dest, num_dests) \ + for (; num_dests; num_dests--, (dest) -= ETH_ALEN) total: 0 errors, 0 warnings, 2 checks, 997 lines checked ecsv/pu: headers diff --git a/net/batman-adv/multicast.h b/net/batman-adv/multicast.h index 0f0d79c8..4393c3a2 100644 --- a/net/batman-adv/multicast.h +++ b/net/batman-adv/multicast.h @@ -11,6 +11,7 @@ #include #include +#include /** * enum batadv_forw_mode - the way a packet should be forwarded as ecsv/pu: kerneldoc ./net/batman-adv/multicast_forw.c ./net/batman-adv/multicast_forw.c:86: warning: Function parameter or member 'bat_priv' not described in 'batadv_mcast_forw_push_dest' ./net/batman-adv/multicast_forw.c:401: warning: Function parameter or member 'bat_priv' not described in 'batadv_mcast_forw_push_tvlvs' ./net/batman-adv/multicast_forw.c:553: warning: Function parameter or member 'num_dests_remove' not described in 'batadv_mcast_forw_shrink_align_offset' ./net/batman-adv/multicast_forw.c:553: warning: Excess function parameter 'num_dests_reduce' description in 'batadv_mcast_forw_shrink_align_offset' ./net/batman-adv/multicast_forw.c:657: warning: Function parameter or member 'num_dests_reduce' not described in 'batadv_mcast_forw_shrink_update_headers' ./net/batman-adv/multicast_forw.c:657: warning: Excess function parameter 'num_dest_reduce' description in 'batadv_mcast_forw_shrink_update_headers' > +static int batadv_mcast_forw_shrink_align_offset(unsigned int num_dests_old, > + unsigned int num_dests_remove) > +{ > + int ret = sizeof(((struct batadv_tvlv_mcast_tracker *)0)->align); sizeof_field from linux/stddef.h. Available there since v4.16. So you need to have a compat code commit which introduces it for older kernels. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v3 4/5] batman-adv: mcast: implement multicast packet generation
On Monday, 26 December 2022 21:42:36 CET Linus Lüssing wrote: > Implement the preparation of a batman-adv multicast packet and use this > under certain conditions. > > For one thing this implements the capability to push a complete > batman-adv multicast packet header, including a tracker TVLV with all > originator destinations that have signaled interest in it, onto a given > ethernet frame with an IP multicast packet inside. > > For another checks are implemented to determine if encapsulating a > multicast packet in this new batman-adv multicast packet type and using > it is feasible. Those checks are: > > 1) Have all nodes signaled that they are capable of handling the new >batman-adv multicast packet type? > 2) Do all active hard interfaces of all nodes, including us, have an MTU >of at least 1280 bytes? > 3) Does a complete multicast packet header with all its destination >addresses fit onto the given multicast packet / ethernet frame and >does not exceed 1280 bytes? > > If all checks passed then the new batman-adv multicast packet type will > be used for transmission and distribution. Otherwise we fall back to one or > more batman-adv unicast packet transmissions, if possible. Or if not > possible we will fall back to classic flooding through a batman-adv > broadcast packet. > > Signed-off-by: Linus Lüssing > --- > net/batman-adv/multicast.c | 79 - > net/batman-adv/multicast.h | 24 +- > net/batman-adv/multicast_forw.c | 511 > net/batman-adv/soft-interface.c | 6 +- > net/batman-adv/types.h | 6 + > 5 files changed, 618 insertions(+), 8 deletions(-) ecsv/pu: checkpatch ./net/batman-adv/multicast_forw.c - CHECK: Macro argument reuse 'num_dests' - possible side-effects? #35: FILE: ./net/batman-adv/multicast_forw.c:35: +#define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ + for (; num_dests; num_dests--, (dest) += ETH_ALEN) total: 0 errors, 0 warnings, 1 checks, 785 lines checked ecsv/pu: headers diff --git a/net/batman-adv/multicast.h b/net/batman-adv/multicast.h index 0f0d79c8..4393c3a2 100644 --- a/net/batman-adv/multicast.h +++ b/net/batman-adv/multicast.h @@ -11,6 +11,7 @@ #include #include +#include /** * enum batadv_forw_mode - the way a packet should be forwarded as ecsv/pu: kerneldoc ./net/batman-adv/multicast_forw.c ./net/batman-adv/multicast_forw.c:83: warning: Function parameter or member 'bat_priv' not described in 'batadv_mcast_forw_push_dest' ./net/batman-adv/multicast_forw.c:398: warning: Function parameter or member 'bat_priv' not described in 'batadv_mcast_forw_push_tvlvs' signature.asc Description: This is a digitally signed message part.
Re: [PATCH v3 3/5] batman-adv: mcast: implement multicast packet reception and forwarding
On Monday, 26 December 2022 21:42:35 CET Linus Lüssing wrote: > Implement functionality to receive and forward a new TVLV capable > multicast packet type. > > The new batman-adv multicast packet type allows to contain several > originator destination addresses within a TVLV. Routers on the way will > potentially split the batman-adv multicast packet and adjust its tracker > TVLV contents. > > Routing decisions are still based on the selected BATMAN IV or BATMAN V > routing algorithm. So this new batman-adv multicast packet type retains > the same loop-free properties. > > Also a new OGM multicast TVLV flag is introduced to signal to other > nodes that we are capable of handling a batman-adv multicast packet and > multicast tracker TVLV. And that all of our hard interfaces have an MTU > of at least 1280 bytes (IPv6 minimum MTU), as a simple solution for now > to avoid MTU issues while forwarding. > > Signed-off-by: Linus Lüssing > --- > include/uapi/linux/batadv_packet.h | 48 - > net/batman-adv/Makefile| 1 + > net/batman-adv/main.c | 2 + > net/batman-adv/multicast.c | 48 - > net/batman-adv/multicast.h | 5 + > net/batman-adv/multicast_forw.c| 274 + > net/batman-adv/originator.c| 1 + > net/batman-adv/routing.c | 68 +++ > net/batman-adv/routing.h | 11 ++ > net/batman-adv/soft-interface.c| 12 ++ > net/batman-adv/types.h | 64 +++ > 11 files changed, 523 insertions(+), 11 deletions(-) > create mode 100644 net/batman-adv/multicast_forw.c ecsv/pu: checkpatch ./net/batman-adv/multicast_forw.c - CHECK: Macro argument reuse 'num_dests' - possible side-effects? #25: FILE: ./net/batman-adv/multicast_forw.c:25: +#define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ + for (; num_dests; num_dests--, (dest) += ETH_ALEN) total: 0 errors, 0 warnings, 1 checks, 274 lines checked signature.asc Description: This is a digitally signed message part.
batman-adv: Drop prandom.h includes
The commit a15d3f3c1c2a ("batman-adv: use get_random_u32_below() instead of deprecated function") replaced the prandom.h function prandom_u32_max with the random.h function get_random_u32_below. There is no need to still include prandom.h. Signed-off-by: Sven Eckelmann diff --git a/compat-include/linux/prandom.h b/compat-include/linux/prandom.h deleted file mode 100644 index dc227e61f95167a86432e862796db7905f7034c2.. --- a/compat-include/linux/prandom.h +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_PRANDOM_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_PRANDOM_H_ - -#include -#if LINUX_VERSION_IS_GEQ(5, 8, 1) || \ -(LINUX_VERSION_IS_GEQ(4, 9, 233) && LINUX_VERSION_IS_LESS(4, 10, 0)) || \ -(LINUX_VERSION_IS_GEQ(4, 14, 193) && LINUX_VERSION_IS_LESS(4, 15, 0)) || \ -(LINUX_VERSION_IS_GEQ(4, 19, 138) && LINUX_VERSION_IS_LESS(4, 20, 0)) || \ -(LINUX_VERSION_IS_GEQ(5, 4, 57) && LINUX_VERSION_IS_LESS(5, 5, 0)) || \ -(LINUX_VERSION_IS_GEQ(5, 7, 14) && LINUX_VERSION_IS_LESS(5, 8, 0)) -#include_next -#else -#include -#endif - -#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_PRANDOM_H_ */ diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 114ee5da261f4410d207a76a357163aad6d1783f..828fb393ee94a31e8715b0b157b4c39b6337b19d 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index f9a58fb5442efc051e6f1bad6814f269752b7de7..acff565849ae91f4c0cf54d7299ed76ecb2c6ced 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index addfd8c4fe959e269b16e2f35b1299354ff4aea2..96e02736430472fed8fe7e0a3aaa5cc8cda1 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index bf29fba4dde5940ad03b6ed925257cdd825f57e4..5e1f422b3a94b119746a6b3b5cf64182951e8eb3 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include
batman-adv: Include random.h for get_random_u32_below
The commit a15d3f3c1c2a ("batman-adv: use get_random_u32_below() instead of deprecated function") replaced the prandom.h function prandom_u32_max with the random.h function get_random_u32_below. Signed-off-by: Sven Eckelmann diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 5e1f422b3a94b119746a6b3b5cf64182951e8eb3..ecd871abda34284cd01ae7863f8852e479ccc23d 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include
Re: [PATCH v2 1/5] batman-adv: mcast: remove now redundant single ucast forwarding
On Monday, 26 December 2022 17:15:50 CET Linus Lüssing wrote: > The multicast code to send a multicast packet via multiple batman-adv > unicast packets is not only capable of sending to multiple but also to a > single node. Therefore we can safely remove the old, specialized, now > redundant multicast-to-single-unicast code. > > The only functional change of this simplification is that the edge case > of allowing a multicast packet with an unsnoopable destination address > (224.0.0.0/24 or ff02::1) where only a single node has signaled interest > in it via the batman-adv want-all-unsnoopables multicast flag is now > transmitted via a batman-adv broadcast instead of a batman-adv unicast > packet. Maintaining this edge case feature does not seem worth the extra > lines of code and people should just not expect to be able to snoop and > optimize such unsnoopable multicast addresses when bridges are involved. > > While at it also renaming a few items in the batadv_forw_mode enum to > prepare for the new batman-adv multicast packet type. > > Signed-off-by: Linus Lüssing > --- > net/batman-adv/multicast.c | 248 ++-- > net/batman-adv/multicast.h | 38 + > net/batman-adv/soft-interface.c | 25 ++-- > 3 files changed, 33 insertions(+), 278 deletions(-) Output of different failed tests ecsv/pu: headers diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 89ba1093..6f387e61 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index c2fa0ef5..cd04ab27 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -48,7 +48,6 @@ #include "hard-interface.h" #include "multicast.h" #include "network-coding.h" -#include "originator.h" #include "send.h" #include "translation-table.h" signature.asc Description: This is a digitally signed message part.
Re: [PATCH] batman-adv: Check return value
Subject is missing something like ..." after calling rtnl_link_register()" or ..."s during module initialization". On Sunday, 25 December 2022 00:33:11 CET Artem Chernyshev wrote: [...] > diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c > index e8a449915566..04cd9682bd29 100644kwin > @@ -113,7 +113,11 @@ static int __init batadv_init(void) > goto err_create_wq; > > register_netdevice_notifier(_hard_if_notifier); > - rtnl_link_register(_link_ops); > + ret = rtnl_link_register(_link_ops); > + if (ret) { > + pr_err("Can't register link_ops\n"); > + goto err_create_wq; > + } > batadv_netlink_register(); > > pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n", > This looks wrong to me. You missed to destroy the batadv_hard_if_notifier in this case. And if you want to start adding the checks, you should also have added it for batadv_v_init, batadv_iv_init, batadv_nc_init, batadv_tp_meter_init and register_netdevice_notifier. You can use the unfinished patch from Markus Pargmann as starting point. Kind regards, Sven [1] https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/1419594103-10928-6-git-send-email-...@pengutronix.de/ https://lists.open-mesh.org/mailman3/hyperkitty/list/b.a.t.m.a.n@lists.open-mesh.org/thread/QDX46YARWUC4R7OBFHR5OJKWQIXDQWRR/#QDX46YARWUC4R7OBFHR5OJKWQIXDQWRR signature.asc Description: This is a digitally signed message part.
[RFC PATCH] batman-adv: Drop support for Linux < 4.14
The Linux Kernel 4.9 reached its end of life [1] after 6 years. Instead it is recommended to use at least kernel 4.14. It is also over 5 years old but still maintained by the stable kernel team. All older kernels (4.9 - v4.13) will be dropped to reduce the support overhead. [1] TODO: https://lore.kernel.org/r/ Signed-off-by: Sven Eckelmann --- README.external.rst | 2 +- compat-include/linux/build_bug.h | 31 - compat-include/linux/netdevice.h | 19 compat-include/linux/prandom.h | 1 - compat-include/linux/skbuff.h| 29 compat-include/linux/timer.h | 34 compat-include/uapi/linux/if_ether.h | 25 compat.h | 10 8 files changed, 1 insertion(+), 150 deletions(-) delete mode 100644 compat-include/linux/build_bug.h delete mode 100644 compat-include/linux/timer.h delete mode 100644 compat-include/uapi/linux/if_ether.h diff --git a/README.external.rst b/README.external.rst index 34f3a8d4..e9f00ee0 100644 --- a/README.external.rst +++ b/README.external.rst @@ -12,7 +12,7 @@ and as an external module. The external module allows to get newfeatures without upgrading to a newer kernel version and to get batman-adv specific bug fixes for kernels that are not supported anymore. It compiles against and should work -with Linux 4.9 - 6.1. Supporting older versions is not +with Linux 4.14 - 6.1. 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. :-) diff --git a/compat-include/linux/build_bug.h b/compat-include/linux/build_bug.h deleted file mode 100644 index 8ec79069.. --- a/compat-include/linux/build_bug.h +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ - -#include -#if LINUX_VERSION_IS_GEQ(4, 13, 0) -#include_next -#else -#include - -/* Linux 4.9.297 doesn't provide BUILD_BUG_ON anymore in linux/bug.h - * also identified itself with the version number 4.9.255 when decoding the - * LINUX_VERSION_CODE. So we have to try to guess now if we need to include - * linux/build_bug.h based on whether BUILD_BUG_ON is defined or not after - * including linux/bug.h - */ -#ifndef BUILD_BUG_ON -#include_next -#endif - -#endif - -#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ */ diff --git a/compat-include/linux/netdevice.h b/compat-include/linux/netdevice.h index eeb31bed..3188ad3d 100644 --- a/compat-include/linux/netdevice.h +++ b/compat-include/linux/netdevice.h @@ -20,25 +20,6 @@ #endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */ -#if LINUX_VERSION_IS_LESS(4, 11, 9) - -/* work around missing attribute needs_free_netdev and priv_destructor in - * net_device - */ -#define ether_setup(dev) \ - void batadv_softif_free2(struct net_device *dev) \ - { \ - batadv_softif_free(dev); \ - free_netdev(dev); \ - } \ - void (*t1)(struct net_device *dev) __attribute__((unused)); \ - bool t2 __attribute__((unused)); \ - ether_setup(dev) -#define needs_free_netdev destructor = batadv_softif_free2; t2 -#define priv_destructor destructor = batadv_softif_free2; t1 - -#endif /* LINUX_VERSION_IS_LESS(4, 11, 9) */ - #if LINUX_VERSION_IS_LESS(5, 15, 0) diff --git a/compat-include/linux/prandom.h b/compat-include/linux/prandom.h index dc227e61..ec2f5244 100644 --- a/compat-include/linux/prandom.h +++ b/compat-include/linux/prandom.h @@ -12,7 +12,6 @@ #include #if LINUX_VERSION_IS_GEQ(5, 8, 1) || \ -(LINUX_VERSION_IS_GEQ(4, 9, 233) && LINUX_VERSION_IS_LESS(4, 10, 0)) || \ (LINUX_VERSION_IS_GEQ(4, 14, 193) && LINUX_VERSION_IS_LESS(4, 15, 0)) || \ (LINUX_VERSION_IS_GEQ(4, 19, 138) && LINUX_VERSION_IS_LESS(4, 20, 0)) || \ (LINUX_VERSION_IS_GEQ(5, 4, 57) && LINUX_VERSION_IS_LESS(5, 5, 0)) || \ diff --git a/compat-include/linux/skbuff.h b/compat-include/linux/skbuff.h index 77c4e99f..eda2d181 100644 --- a/compat-include/linux/skbuff.h +++ b/compat-include/linux/skbuff.h @@ -13,35 +13,6 @@ #include #include_next -#if LINUX_VERSION_IS_LESS(4, 13, 0) - -static inline void *batadv_skb_put(struct sk_buff *skb, unsigned int len) -{ - return (void *)skb_put(skb, len); -} -#define skb_put batadv_skb_put - -static inline void *skb_put_zero(struct sk_buff *skb, unsigned int len) -{ - void *tmp = skb_put(skb, len); - - memset(tmp, 0, len); - - return tmp; -} - -static inline void *skb_put_data(struc
Re: Question about batman for ARM
On Tuesday, 1 November 2022 19:49:54 CET cch...@creonexsystems.com wrote: > We are now looking into getting BATMAN working on a Zynq-7000 Xilinx FPGA. > This FPGA hosts dual-arm A9 cores. We have successfully loaded up Ubuntu on > this platform and it is running > Linux version 4.19.0-xilinx-v2019.2 (oe-user@oe-host) (gcc version 8.2.0 > (GCC)) I don't know what this should be. It is not an ubuntu kernel (more like an openembedded kernel). So you might have to get in contact with whoever provided you with this kernel and ask them how to build externel kernel modules against this kernel. They hopefully have some linux-headers package which you can install and then build some kernel modules against it. And if it is openembedded (with yocto) then you can either try to update these recipes (which are using ancient batman-adv versions): https://github.com/jhaws1982/meta-batman Or simply enable CONFIG_BATMAN_ADV (and related symbols) in your kernel configuration which you are using to build this kernel. It will not be the most recent batman-adv version but better than nothing. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH] batman-adv: Fix hang up with small MTU hard-interface
On Wednesday, 7 September 2022 18:00:37 CEST Shigeru Yoshida wrote: > ping? This was applied a while ago: https://git.open-mesh.org/linux-merge.git/commit/b1cb8a71f1eaec4eb77051590f7f561f25b15e32 Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v2] batman-adv: tracing: Use the new __vstring() helper
On Monday, 25 July 2022 01:16:50 CEST Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > Instead of open coding a __dynamic_array() with a fixed length (which > defeats the purpose of the dynamic array in the first place). Use the new > __vstring() helper that will use a va_list and only write enough of the > string into the ring buffer that is needed. Acked-by: Sven Eckelmann (and sorry for taking such a long time to respond to the v1 version of the patch). > --- > Changes since v1: > https://lkml.kernel.org/r/20220705224751.080390...@goodmis.org > > - Removed no longer used BATADV_MAX_MSG_LEN > > net/batman-adv/trace.h | 9 ++--- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/net/batman-adv/trace.h b/net/batman-adv/trace.h > index d673ebdd0426..31c8f922651d 100644 > --- a/net/batman-adv/trace.h > +++ b/net/batman-adv/trace.h > @@ -28,8 +28,6 @@ > > #endif /* CONFIG_BATMAN_ADV_TRACING */ > > -#define BATADV_MAX_MSG_LEN 256 > - > TRACE_EVENT(batadv_dbg, > > TP_PROTO(struct batadv_priv *bat_priv, > @@ -40,16 +38,13 @@ TRACE_EVENT(batadv_dbg, > TP_STRUCT__entry( > __string(device, bat_priv->soft_iface->name) > __string(driver, KBUILD_MODNAME) > - __dynamic_array(char, msg, BATADV_MAX_MSG_LEN) > + __vstring(msg, vaf->fmt, vaf->va) > ), > > TP_fast_assign( > __assign_str(device, bat_priv->soft_iface->name); > __assign_str(driver, KBUILD_MODNAME); > - WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), > -BATADV_MAX_MSG_LEN, > -vaf->fmt, > -*vaf->va) >= BATADV_MAX_MSG_LEN); > + __assign_vstr(msg, vaf->fmt, vaf->va); > ), > > TP_printk( > signature.asc Description: This is a digitally signed message part.
Re: [for-next][PATCH 17/23] batman-adv: tracing: Use the new __vstring() helper
On Thursday, 14 July 2022 18:43:13 CEST Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > Instead of open coding a __dynamic_array() with a fixed length (which > defeats the purpose of the dynamic array in the first place). Please also make sure to remove the define of BATADV_MAX_MSG_LEN Kind regards, Sven [...] > --- a/net/batman-adv/trace.h > +++ b/net/batman-adv/trace.h > @@ -40,16 +40,13 @@ TRACE_EVENT(batadv_dbg, > TP_STRUCT__entry( > __string(device, bat_priv->soft_iface->name) > __string(driver, KBUILD_MODNAME) > - __dynamic_array(char, msg, BATADV_MAX_MSG_LEN) > + __vstring(msg, vaf->fmt, vaf->va) > ), > > TP_fast_assign( > __assign_str(device, bat_priv->soft_iface->name); > __assign_str(driver, KBUILD_MODNAME); > - WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), > -BATADV_MAX_MSG_LEN, > -vaf->fmt, > -*vaf->va) >= BATADV_MAX_MSG_LEN); > + __assign_vstr(msg, vaf->fmt, vaf->va); > ), > > TP_printk( > signature.asc Description: This is a digitally signed message part.
[PATCH] batman-adv: tracing: Use the new __vstring() helper
From: "Steven Rostedt (Google)" Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed. Link: https://lkml.kernel.org/r/20220705224751.080390...@goodmis.org Signed-off-by: Steven Rostedt (Google) [s...@narfation.org: add compat code] Signed-off-by: Sven Eckelmann --- Already added to https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git/commit/?h=for-next=013cfbccb0cb3bbac478666aed78e4f5f7e39dd6 compat-include/linux/tracepoint.h | 24 net/batman-adv/trace.h| 7 ++- 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 compat-include/linux/tracepoint.h diff --git a/compat-include/linux/tracepoint.h b/compat-include/linux/tracepoint.h new file mode 100644 index ..61df01a3 --- /dev/null +++ b/compat-include/linux/tracepoint.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_TRACEPOINT_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_TRACEPOINT_H_ + +#include +#include_next + +#if LINUX_VERSION_IS_LESS(5, 19, 0) + +#define __vstring(item, fmt, ap) __dynamic_array(char, item, 256) +#define __assign_vstr(dst, fmt, va) \ + WARN_ON_ONCE(vsnprintf(__get_dynamic_array(dst), 256, fmt, *va) >= 256) + +#endif /* LINUX_VERSION_IS_LESS(5, 19, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_TRACEPOINT_H_ */ diff --git a/net/batman-adv/trace.h b/net/batman-adv/trace.h index d673ebdd..67d2a8a0 100644 --- a/net/batman-adv/trace.h +++ b/net/batman-adv/trace.h @@ -40,16 +40,13 @@ TRACE_EVENT(batadv_dbg, TP_STRUCT__entry( __string(device, bat_priv->soft_iface->name) __string(driver, KBUILD_MODNAME) - __dynamic_array(char, msg, BATADV_MAX_MSG_LEN) + __vstring(msg, vaf->fmt, vaf->va) ), TP_fast_assign( __assign_str(device, bat_priv->soft_iface->name); __assign_str(driver, KBUILD_MODNAME); - WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), - BATADV_MAX_MSG_LEN, - vaf->fmt, - *vaf->va) >= BATADV_MAX_MSG_LEN); + __assign_vstr(msg, vaf->fmt, vaf->va); ), TP_printk( -- 2.30.2
Re: Question about batman for ARM
On Monday, 20 June 2022 12:20:19 CEST cch...@creonexsystems.com wrote: > Does BATMAN ADV interfaces with the radio via the network driver or does > BATMAN include the network driver? As said before, it is interfacing with the generic ethernet netdev layer of the kernel. For example in: * https://git.open-mesh.org/batman-adv.git/blob/caa1eb0cf7bf8ebfe43bba06b890252a865efa91:/net/batman-adv/hard-interface.c#l727 * https://git.open-mesh.org/batman-adv.git/blob/caa1eb0cf7bf8ebfe43bba06b890252a865efa91:/net/batman-adv/send.c#l108 * https://git.open-mesh.org/batman-adv.git/blob/caa1eb0cf7bf8ebfe43bba06b890252a865efa91:/net/batman-adv/hard-interface.c#l185 There are a lot of other places when it uses the abstraction interfaces of the kernels for ethernet related communication. For B.A.T.M.A.N. V, it is also trying to get throughput information via various generic kernel functionality: * https://git.open-mesh.org/batman-adv.git/blob/caa1eb0cf7bf8ebfe43bba06b890252a865efa91:/net/batman-adv/bat_v_elp.c#l67 There is also one detection for wifi interfaces to decide whether broadcast messages should be repeated or not: * https://git.open-mesh.org/batman-adv.git/blob/caa1eb0cf7bf8ebfe43bba06b890252a865efa91:/net/batman-adv/hard-interface.c#l877 > Can you provide some guidance on where the network driver or interface to > network driver is located within BATMAN? It is not talking directly to the driver. It is always using abstraction layers. Either the normal network core, ethernet or cfg80211 abstraction interfaces. But these don't abstract the requirement for ethernet compatibility away - the underlying device must provide this either directly or via a wrapper. Just perform a `git grep -e ETH_ -e eth_ -e ethhdr` to see that it is build around the concept of ethernet packets. Also things like originators and the complete translation table only works with ethernet addresses. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: Question about batman for ARM
On Friday, 17 June 2022 10:41:46 CEST cch...@creonexsystems.com wrote: [...] > We would like to use batman with a custom radio and are trying to figure out > what part of the source code we may need to modify to allow batman to work > with a custom radio. > Custom radio means that the radio is not a commercial radio, such as wi-fi or > Bluetooth. batman-adv (especially with the B.A.T.M.A.N. IV algo) only requires that the device itself can transport ethernet frames (with proper unicast and broadcast behavior). If you need something else then you either need a virtual interface which does the translation from $whatever to ethernet (and back) - or you need to reimplement the B.A.T.M.A.N. IV/V algorithms yourself. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: Question about batman for ARM
On Friday, 20 May 2022 08:18:45 CEST Charles Chien wrote: > We’re currently trying to install batman-adv on an ARM platform but we > ran into some issues and we would appreciate your help to answer our > questions below: > > Is the batman-adv module compatible with an ARM processor (Raspberry PI 4)? There is not just an "ARM" processor. It is a family of various processors. Anyway, it can be used easily on Raspberry Pi - just make sure that you use a good wifi device + driver (+firmware) which actually can communicate over IBSS/802.11s (without forwarding enabled) and has no (extreme low) peer limit. Unfortunately, you cannot take this for granted. > I’m trying to install batman-adv onto an ARM Raspberry PI 4 with a > Debian based Linux distribution (Pop OS). However, when I run > “modprobe batman-adv”, it returns a FATAL error complaining that the > module is not found in the “/lib/modules” directory. Where can I > find/download the “.ko” for batman-adv for the ARM platform? Ehrm, this is not how this works. You cannot just use a kernel module and hope that it works on all kernel (builds) available in the universe. This is also why we write following in each batman-adv release news entry: "As the kernel module always depends on the Linux kernel it is compiled against, it does not make sense to provide binaries on our website. As usual, you will find the signed tarballs in our download section:" Either your distribution has to enable this module in their kernel build or you have to get their kernel headers (and build scripts) and then build it from scratch. And at least on the default Debian kernel, batman-adv is enabled since ages - so no idea why PopOS doesn't ship it > And if I need to recompile the .ko file for ARM, is there an online > repository where I can find the original source code for the > batman-adv driver? This is mentioned in multiple places on the website. Just to mention a few interesting pages: * https://www.open-mesh.org/projects/open-mesh/wiki * https://www.open-mesh.org/news/108 * https://www.open-mesh.org/projects/open-mesh/wiki/Download * https://www.open-mesh.org/projects/open-mesh/wiki/UsingBatmanGit * https://git.open-mesh.org/ https://git.open-mesh.org/batman-adv.git * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH v2] alfred: notify event listener via unix socket
On Tuesday, 17 May 2022 09:44:07 CEST Marek Lindner wrote: [...] > Thanks for preparing the rebase & code change patches. Wouldn't you say that > EPOLL_CTL_DEL somewhere near unix_sock_event_listener_free() could be helpful? > > Something like: > -static void unix_sock_event_listener_free(struct event_listener *listener) > +static void unix_sock_event_listener_free(struct globals *globals, > + struct event_listener *listener) > { > list_del(>list); > + epoll_ctl(globals->epollfd, EPOLL_CTL_DEL, listener->fd, NULL); > close(listener->fd); > free(listener); > } No, alfred doesn't share file descriptors and thus close of the fd will do this for us [1]. Kind regards, Sven [1] https://man7.org/linux/man-pages/man7/epoll.7.html "Will closing a file descriptor cause it to be removed from all epoll interest lists?" signature.asc Description: This is a digitally signed message part.
Re: [PATCH net 11/12] batman-adv: fix iflink detection in batadv_is_on_batman_iface
On Thursday, 1 October 2020 09:59:35 CEST Sabrina Dubroca wrote: > device has the same ifindex as its link. Let's use the presence of a > ndo_get_iflink operation, rather than the value it returns, to detect > a device without a link. There wasn't any activity in this patchset since a while, it doesn't apply anymore and the assumptions made here doesn't seem to be reflect the current situation in the kernel. See commit 6c1f41afc1db ("batman-adv: Don't expect inter-netns unique iflink indices"): > But only checking for dev->netdev_ops->ndo_get_iflink is also not an option > because ipoib_get_iflink implements it even when it sometimes returns an > iflink != ifindex and sometimes iflink == ifindex. The caller must > therefore make sure itself to check both netns and iflink + ifindex for > equality. Only when they are equal, a "physical" interface was detected > which should stop the traversal. On the other hand, vxcan_get_iflink can > also return 0 in case there was currently no valid peer. In this case, it > is still necessary to stop. It would would be nice when the situation would be better but the proposed patches don't solve it. So I will mark the two patches as "Rejected" (from "Changes requested") in batadv's patchwork. It is not meant as sign of disapproval of someone working in this area to improve the situation - I just don't want to wait for the v2 [1] anymore. Kind regards, Sven [1] https://lore.kernel.org/all/20201002090703.GD3565727@bistromath.localdomain/ signature.asc Description: This is a digitally signed message part.
Re: [PATCH v2] alfred: notify event listener via unix socket
On Monday, 2 May 2022 13:46:51 CEST Marek Lindner wrote: > The alfred server instance accepts event notification registration > via the unix socket. These notification sockets only inform > registered parties of the availability of an alfred datatype change. > The actual data itself needs to be retrieved via the existing data > retrieval mechanisms. > > Unlike the update-command this event monitor allows: > > - multiple parallel listeners > - programmatic access to changes without requiring multiple processes > > The alfred client allows to monitor events via the newly added '-E' > (event monitor) command line option. Serving as debugging tool and > example code at the same time. > > Signed-off-by: Marek Lindner > --- > > v2: > - fix typ0s > - replace list_del_init() with list_del() > - remove unnecessary INIT_LIST_HEAD() > - change --event-monitor to not require an argument This version cannot be applied on top of the current master. I have attached the diff for the things which (afaik) need to be changed when you rebase the patch. I have also attached the change to support the reporting of the source mac for the changed dataset. Kind regards, Svendiff --git a/alfred.h b/alfred.h index 668e856..f00346d 100644 --- a/alfred.h +++ b/alfred.h @@ -121,6 +121,7 @@ struct interface { struct event_listener { int fd; + struct epoll_handle epoll; struct list_head list; }; @@ -208,10 +209,6 @@ int unix_sock_open_client(struct globals *globals); int unix_sock_close(struct globals *globals); int unix_sock_req_data_finish(struct globals *globals, struct transaction_head *head); -int unix_sock_events_select_prepare(struct globals *globals, fd_set *fds, -fd_set *errfds, int maxsock); -void unix_sock_events_select_handle(struct globals *globals, -fd_set *fds, fd_set *errfds); void unix_sock_events_close_all(struct globals *globals); void unix_sock_event_notify(struct globals *globals, uint8_t type); /* vis.c */ diff --git a/main.c b/main.c index 885b950..3fe7b42 100644 --- a/main.c +++ b/main.c @@ -164,12 +164,8 @@ static struct globals *alfred_init(int argc, char *argv[]) {"modeswitch", required_argument, NULL, 'M'}, {"change-interface", required_argument, NULL, 'I'}, {"change-bat-iface", required_argument, NULL, 'B'}, -<<< HEAD {"server-status", no_argument, NULL, 'S'}, -=== - {"server-status", required_argument, NULL, 'S'}, {"event-monitor", no_argument, NULL, 'E'}, ->>> 08415c9 (alfred: notify event listener via unix socket) {"unix-path", required_argument, NULL, 'u'}, {"update-command", required_argument, NULL, 'c'}, {"version", no_argument, NULL, 'v'}, diff --git a/server.c b/server.c index 15b4d77..0d792b0 100644 --- a/server.c +++ b/server.c @@ -513,54 +513,7 @@ int alfred_server(struct globals *globals) while (1) { netsock_reopen(globals); -<<< HEAD process_events(globals); -=== - - FD_ZERO(); - FD_ZERO(); - FD_SET(globals->unix_sock, ); - maxsock = globals->unix_sock; - - maxsock = netsock_prepare_select(globals, , maxsock); - maxsock = netsock_prepare_select(globals, , maxsock); - maxsock = unix_sock_events_select_prepare(globals, , - , maxsock); - - ret = pselect(maxsock + 1, , NULL, , , NULL); - - if (ret == -1) { - perror("main loop select failed ..."); - } else if (ret) { - netsock_check_error(globals, ); - - unix_sock_events_select_handle(globals, , ); - - if (FD_ISSET(globals->unix_sock, )) { -unix_sock_read(globals); -continue; - } else { -recvs = netsock_receive_packet(globals, ); -if (recvs > 0) - continue; - } - } - clock_gettime(CLOCK_MONOTONIC, _check); - - if (globals->opmode == OPMODE_PRIMARY) { - /* we are a primary */ - printf("[%ld.%09ld] announce primary ...\n", last_check.tv_sec, last_check.tv_nsec); - announce_primary(globals); - sync_data(globals); - } else { - /* send local data to server */ - update_server_info(globals); - push_local_data(globals); - } - purge_data(globals); - check_if_sockets(globals); - execute_update_command(globals); ->>> 08415c9 (alfred: notify event listener via unix socket) } netsock_close_all(globals); diff --git a/unix_sock.c b/unix_sock.c index 2d7fc2e..14d63dd 100644 --- a/unix_sock.c +++ b/unix_sock.c @@ -27,6 +27,9 @@ static void unix_sock_read(struct globals *globals, struct epoll_handle *handle __unused, struct epoll_event *ev __unused); +static void unix_sock_event_listener_handle(struct globals *globals __unused, + struct epoll_handle *handle, + struct epoll_event *ev); int unix_sock_open_daemon(struct globals *globals) { @@ -496,14 +499,10 @@ err: return ret; } -<<< HEAD -static void unix_sock_read(struct globals *globals, - struct epoll_handle *handle __unused, - struct epoll_event *ev __unused) -=== static int unix_sock_register_listener(struct globals *globals, int client_sock) { struct
[PATCH] alfred: Drop argument requirement from --server-status
The short form -S doesn't require a parameter but the --server-status requires one (which no one reads). If none is supplied, following is printed: ./alfred: option '--server-status' requires an argument and the execution stops. Just drop this requirement because it is not used and no where documented. Fixes: 5a7d28b1866d ("alfred: introduce 'server status' IPC call") Signed-off-by: Sven Eckelmann --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 68d6efd..30e18a5 100644 --- a/main.c +++ b/main.c @@ -163,7 +163,7 @@ static struct globals *alfred_init(int argc, char *argv[]) {"modeswitch", required_argument, NULL, 'M'}, {"change-interface",required_argument, NULL, 'I'}, {"change-bat-iface",required_argument, NULL, 'B'}, - {"server-status", required_argument, NULL, 'S'}, + {"server-status", no_argument,NULL, 'S'}, {"unix-path", required_argument, NULL, 'u'}, {"update-command", required_argument, NULL, 'c'}, {"version", no_argument,NULL, 'v'}, -- 2.34.1
[PATCH 2/2] alfred: Switch to epoll for socket handling
The select syscall has various problems when working with many sockets: * only a fd less than FD_SETSIZE (usually 1024) is supported * it is necessary to register all relevant fds manually before each select call * when events are received, all the fds must be checked again the returned data This can be solved by using epoll. File descriptors are only registered once and only the relevant file descriptors are returned. And epoll will also take care of walking in a round-robin fashion through all relevant file descriptors in case a lot of file descriptors could be returned by the kernel. Signed-off-by: Sven Eckelmann --- alfred.h | 20 -- batadv_querynl.c | 4 -- epoll_handle.h | 25 +++ netsock.c| 171 ++- server.c | 127 --- unix_sock.c | 59 ++-- 6 files changed, 243 insertions(+), 163 deletions(-) create mode 100644 epoll_handle.h diff --git a/alfred.h b/alfred.h index 2679515..4839c85 100644 --- a/alfred.h +++ b/alfred.h @@ -16,9 +16,10 @@ #include #include #include -#include +#include #include #include "bitops.h" +#include "epoll_handle.h" #include "list.h" #include "packet.h" @@ -30,6 +31,10 @@ #define ALFRED_SOCK_PATH_DEFAULT "/var/run/alfred.sock" #define NO_FILTER -1 +#ifndef __unused +#define __unused __attribute__((unused)) +#endif + #define FIXED_TLV_LEN(__tlv_type) \ htons(sizeof(__tlv_type) - sizeof((__tlv_type).header)) @@ -101,9 +106,12 @@ struct interface { alfred_addr address; uint32_t scope_id; char *interface; + int netsock; int netsock_mcast; - int netsock_arp; + + struct epoll_handle netsock_epoll; + struct epoll_handle netsock_mcast_epoll; struct hashtable_t *server_hash; @@ -124,9 +132,13 @@ struct globals { uint8_t ipv4mode:1; uint8_t force:1; + int epollfd; + int check_timerfd; + struct epoll_handle check_epoll; int unix_sock; + struct epoll_handle unix_epoll; const char *unix_path; const char *update_command; @@ -182,7 +194,6 @@ int sync_data(struct globals *globals); ssize_t send_alfred_packet(struct globals *globals, struct interface *interface, const alfred_addr *dest, void *buf, int length); /* unix_sock.c */ -int unix_sock_read(struct globals *globals); int unix_sock_open_daemon(struct globals *globals); int unix_sock_open_client(struct globals *globals); int unix_sock_close(struct globals *globals); @@ -197,9 +208,6 @@ void netsock_close_all(struct globals *globals); int netsock_set_interfaces(struct globals *globals, char *interfaces); struct interface *netsock_first_interface(struct globals *globals); void netsock_reopen(struct globals *globals); -int netsock_prepare_select(struct globals *globals, fd_set *fds, int maxsock); -void netsock_check_error(struct globals *globals, fd_set *errfds); -int netsock_receive_packet(struct globals *globals, fd_set *fds); int netsock_own_address(const struct globals *globals, const alfred_addr *address); /* util.c */ diff --git a/batadv_querynl.c b/batadv_querynl.c index 872cb85..7c1b115 100644 --- a/batadv_querynl.c +++ b/batadv_querynl.c @@ -26,10 +26,6 @@ #include "batadv_query.h" #include "netlink.h" -#ifndef __unused -#define __unused __attribute__((unused)) -#endif - static const int translate_mac_netlink_mandatory[] = { BATADV_ATTR_TT_ADDRESS, BATADV_ATTR_ORIG_ADDRESS, diff --git a/epoll_handle.h b/epoll_handle.h new file mode 100644 index 000..4ec69b9 --- /dev/null +++ b/epoll_handle.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) B.A.T.M.A.N. contributors: + * + * Sven Eckelmann + * + * License-Filename: LICENSES/preferred/GPL-2.0 + */ + +#ifndef _ALFRED_EPOLL_HANDLE_H +#define _ALFRED_EPOLL_HANDLE_H + +#include + +struct globals; +struct epoll_handle; + +typedef void (*epoll_handler)(struct globals *globals, + struct epoll_handle *handle, + struct epoll_event *ev); + +struct epoll_handle { + epoll_handler handler; +}; + +#endif /* _ALFRED_EPOLL_HANDLE_H */ diff --git a/netsock.c b/netsock.c index 128e768..feed21d 100644 --- a/netsock.c +++ b/netsock.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #ifdef CONFIG_ALFRED_CAPABILITIES #include #endif @@ -203,12 +203,59 @@ out: return ret; } -static int netsock_open(struct interface *interface) +static void netsock_close_error(struct interface *interface) +{ + fprintf(stderr, "Error on netsock detected\n"); + + if (interface->netsock >= 0) + close(interface->netsock); + + if (interface->netsock_mc
[PATCH 1/2] alfred: Stabilize synchronization period using timerfd
The current way of scheduling the synchronization related events tends to cause drift from a perfect periodic timer. This happens because it doesn't calculate the next event based on a fixed start time + period * the number of past synchronization periods. Instead, the next event was scheduled based on the time before the last select() - ignoring that non-zero time was spend processing events. For a 10 second period, this usually looks somthing like: [24.043904208] announce primary ... [34.044216187] announce primary ... [44.053485658] announce primary ... [54.063562062] announce primary ... [64.073517069] announce primary ... To avoid this drift, just use timerfd as rather stable periodic timer event sources. It also has the benefit of making it easier to use multiple periodic timers with different periods. Only some small jitter can be seen with this external timer implementation: [12.673756426] announce primary ... [22.673779811] announce primary ... [32.673778362] announce primary ... [42.673775216] announce primary ... Signed-off-by: Sven Eckelmann --- alfred.h | 2 ++ server.c | 89 +++- 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/alfred.h b/alfred.h index 2d98a30..2679515 100644 --- a/alfred.h +++ b/alfred.h @@ -124,6 +124,8 @@ struct globals { uint8_t ipv4mode:1; uint8_t force:1; + int check_timerfd; + int unix_sock; const char *unix_path; diff --git a/server.c b/server.c index bfc37bc..b5ec7b2 100644 --- a/server.c +++ b/server.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -366,17 +367,44 @@ static void execute_update_command(struct globals *globals) free(command); } +static int create_sync_period_timer(struct globals *globals) +{ + struct itimerspec sync_timer; + int ret; + + globals->check_timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); + if (globals->check_timerfd < 0) { + perror("Failed to create periodic timer"); + return -1; + } + + sync_timer.it_value = globals->sync_period; + sync_timer.it_interval = globals->sync_period; + + ret = timerfd_settime(globals->check_timerfd, 0, _timer, NULL); + if (ret < 0) { + perror("Failed to arm synchronization timer"); + return -1; + } + + return 0; +} + int alfred_server(struct globals *globals) { int maxsock, ret, recvs; - struct timespec last_check, now, tv; + struct timespec now; fd_set fds, errfds; size_t num_interfaces; + uint64_t timer_exp; int num_socks; if (create_hashes(globals)) return -1; + if (create_sync_period_timer(globals)) + return -1; + if (unix_sock_open_daemon(globals)) return -1; @@ -414,25 +442,10 @@ int alfred_server(struct globals *globals) return -1; } - clock_gettime(CLOCK_MONOTONIC, _check); - globals->if_check = last_check; + clock_gettime(CLOCK_MONOTONIC, ); + globals->if_check = now; while (1) { - clock_gettime(CLOCK_MONOTONIC, ); - - /* subtract the synchronization period from the current time -* NOTE: this is an atypical usage of time_diff as it ignores the return -* value and store the result back into now, essentially performing the -* operation: -* now -= globals->sync_period; -*/ - time_diff(, >sync_period, ); - - if (!time_diff(_check, , )) { - tv.tv_sec = 0; - tv.tv_nsec = 0; - } - netsock_reopen(globals); FD_ZERO(); @@ -440,10 +453,14 @@ int alfred_server(struct globals *globals) FD_SET(globals->unix_sock, ); maxsock = globals->unix_sock; + FD_SET(globals->check_timerfd, ); + if (maxsock < globals->check_timerfd) + maxsock = globals->check_timerfd; + maxsock = netsock_prepare_select(globals, , maxsock); maxsock = netsock_prepare_select(globals, , maxsock); - ret = pselect(maxsock + 1, , NULL, , , NULL); + ret = pselect(maxsock + 1, , NULL, , NULL, NULL); if (ret == -1) { perror("main loop select failed ..."); @@ -459,21 +476,27 @@ int alfred_server(struct globals *globals) continue; } } - clock_gettime(CLOCK_MONOTONIC, _check); - - if (globals->opmode == OPMODE_PRIMARY) { - /* we
Re: [PATCH] alfred: notify event listener via unix socket
On Sunday, 1 May 2022 11:10:13 CEST Marek Lindner wrote: > > > +static void unix_sock_event_listener_free(struct event_listener > > > *listener) > > > +{ > > > + list_del_init(>list); > > > + close(listener->fd); > > > + free(listener); > > > > list_del_init has no benefit (only downsides) when you free the memory > > anyway at the end of the function > > What are those downsides you are referring to ? Additional writes for something which is dropped anyway. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH] alfred: notify event listener via unix socket
On Saturday, 30 April 2022 12:56:47 CEST Marek Lindner wrote: > The alfred server instance accepts event notification registration > via the unix socket. These notification sockets only inform > registered parties of the availibility of an alfred datatype change. availability > +int alfred_client_event_monitor(struct globals *globals) > +{ [...] > + fprintf(stdout, "Event: type = %d\n", event_notify.type); event_notify.type is unsigned and not signed. > diff --git a/main.c b/main.c > index 68d6efd..98bf64d 100644 > --- a/main.c > +++ b/main.c > @@ -39,6 +39,7 @@ static void alfred_usage(void) > printf(" -I, --change-interface [interface] change to the specified > interface(s)\n"); > printf(" -B, --change-bat-iface [interface] change to the specified > batman-adv interface\n"); > printf(" -S, --server-status request server status > info such as mode & interfaces\n"); > + printf(" -E, --event-monitor monitor alfred data > record update eventss\n"); events > printf("\n"); > printf("server mode options:\n"); > printf(" -i, --interface specify the interface (or > comma separated list of interfaces) to listen on\n"); > @@ -164,6 +165,7 @@ static struct globals *alfred_init(int argc, char *argv[]) > {"change-interface",required_argument, NULL, 'I'}, > {"change-bat-iface",required_argument, NULL, 'B'}, > {"server-status", required_argument, NULL, 'S'}, > + {"event-monitor", required_argument, NULL, 'E'}, Why does it require an argument but the usage doesn't describe the argument? See also getopt_long which also doesn't expect an argument > @@ -138,10 +140,17 @@ static int unix_sock_add_data(struct globals *globals, > free(dataset); > goto err; > } > + new_entry_created = true; > } > dataset->data_source = SOURCE_LOCAL; > clock_gettime(CLOCK_MONOTONIC, >last_seen); > > + /* check that data was changed */ > + if (new_entry_created || > + dataset->data.header.length != data_len || > + memcmp(dataset->buf, data->data, data_len) != 0) > + unix_sock_event_notify(globals, data->header.type); > + I am wondering now if it could be interesting for the listener whether the data is from us or some remote (for example via the source mac). Does anyone else have an opinion about that? > +static int unix_sock_register_listener(struct globals *globals, int > client_sock) > +{ > + struct event_listener *listener; > + int ret; > + > + ret = fcntl(client_sock, F_GETFL, 0); > + if (ret < 0) { > + perror("failed to get file status flags"); > + goto err; > + } > + > + ret = fcntl(client_sock, F_SETFL, ret | O_NONBLOCK); > + if (ret < 0) { > + perror("failed to set file status flags"); > + goto err; > + } > + > + listener = malloc(sizeof(*listener)); > + if (!listener) > + goto err; > + > + listener->fd = client_sock; > + INIT_LIST_HEAD(>list); > + list_add_tail(>list, >event_listeners); INIT_LIST_HEAD (of the prev/next pointer) is not necessary when you just overwrite the next/prev pointer in the next line via list_add_tail > + > +static void unix_sock_event_listener_free(struct event_listener *listener) > +{ > + list_del_init(>list); > + close(listener->fd); > + free(listener); list_del_init has no benefit (only downsides) when you free the memory anyway at the end of the function > +int unix_sock_events_select_prepare(struct globals *globals, fd_set *fds, > + fd_set *errfds, int maxsock) > +{ > + struct event_listener *listener; > + > + list_for_each_entry(listener, >event_listeners, list) { > + if (listener->fd < 0) > + continue; > + > + FD_SET(listener->fd, fds); > + FD_SET(listener->fd, errfds); > + > + if (maxsock < listener->fd) > + maxsock = listener->fd; > + } > + > + return maxsock; > +} I should really rewrite the socket mainloop using epoll but this is just a side note and not a problem in your patch. Kind regards, Sven signature.asc Description: This is a digitally signed message part.
Re: [PATCH] batman-adv: remove unnecessary type castings
On Monday, 25 April 2022 13:36:35 CEST Yu Zhe wrote: > remove unnecessary void* type castings. > > Signed-off-by: Yu Zhe > --- > net/batman-adv/translation-table.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) If you send a second version then please use `git format-patch -v2 ...` to format the patch. Now it looks in patchworks like you've resent the first version again. And please also add a little changelog after "---" which explains what you've changed. It is trivial in this little patch but still might be useful. Regarding the patch: Now you've removed bridge_loop_avoidance.c + batadv_choose_tt instead of fixing your patch. I would really prefer this patch version: https://git.open-mesh.org/linux-merge.git/commitdiff/8864d2fcf04385cabb8c8bb159f1f2ba5790cf71 Kind regards, Sven signature.asc Description: This is a digitally signed message part.