pull request for net-next: batman-adv 2023-01-27
Subsystems (4)
Simon Wunderlich
maintainercover pull request for net-next: batman-adv 2023-01-27
Hi Jakub, hi David,
here is a feature/cleanup pull request of batman-adv to go into net-next.
Please pull or let me know of any problem!
Thank you,
Simon
The following changes since commit 88603b6dc419445847923fcb7fe5080067a30f98:
Linux 6.2-rc2 (2023-01-01 13:53:16 -0800)
are available in the Git repository at:
git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20230127
for you to fetch changes up to 0c4061c0d0e2c381ffe4d8b7c62ea69ad8132071:
batman-adv: tvlv: prepare for tvlv enabled multicast packet type (2023-01-21 19:01:59 +0100)
----------------------------------------------------------------
This feature/cleanup patchset includes the following patches:
- bump version strings, by Simon Wunderlich
- drop prandom.h includes, by Sven Eckelmann
- fix mailing list address, by Sven Eckelmann
- multicast feature preparation, by Linus Lüssing (2 patches)
----------------------------------------------------------------
Linus Lüssing (2):
batman-adv: mcast: remove now redundant single ucast forwarding
batman-adv: tvlv: prepare for tvlv enabled multicast packet type
Simon Wunderlich (1):
batman-adv: Start new development cycle
Sven Eckelmann (2):
batman-adv: Drop prandom.h includes
batman-adv: Fix mailing list address
Documentation/networking/batman-adv.rst | 2 +- include/uapi/linux/batadv_packet.h | 2 + net/batman-adv/bat_iv_ogm.c | 1 - net/batman-adv/bat_v_elp.c | 1 - net/batman-adv/bat_v_ogm.c | 5 +- net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/gateway_common.c | 2 +- net/batman-adv/main.h | 2 +- net/batman-adv/multicast.c | 251 ++------------------------------ net/batman-adv/multicast.h | 38 +---- net/batman-adv/network-coding.c | 4 +- net/batman-adv/routing.c | 7 +- net/batman-adv/soft-interface.c | 26 ++-- 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 + 17 files changed, 110 insertions(+), 323 deletions(-)
Simon Wunderlich
maintainerPATCH 1/5 batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 6.3.
The version number isn't a semantic version number with major and minor information. It is just encoding the year of the expected publishing as Linux -rc1 and the number of published versions this year (starting at 0).
--- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/main.h +1 -1
@@ -13,7 +13,7 @@#define BATADV_DRIVER_DEVICE "batman-adv"#ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2022.3" +#define BATADV_SOURCE_VERSION "2023.1"#endif /* B.A.T.M.A.N. parameters */
Signature · 1 line
2.30.2
Re: [PATCH 1/5] batman-adv: Start new development cycle
This series was applied to netdev/net-next.git (master) by Simon Wunderlich <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Simon Wunderlich <[email protected]>:
Quoted 8 lines · On Fri, 27 Jan 2023 11:21:29 +0100 you wrote:
This version will contain all the (major or even only minor) changes for Linux 6.3.
The version number isn't a semantic version number with major and minor information. It is just encoding the year of the expected publishing as Linux -rc1 and the number of published versions this year (starting at 0).
[...]
Here is the summary with links:
- [1/5] batman-adv: Start new development cycle
https://git.kernel.org/netdev/net-next/c/55307f51f48e - [2/5] batman-adv: Drop prandom.h includes https://git.kernel.org/netdev/net-next/c/c4b40f80585c - [3/5] batman-adv: Fix mailing list address https://git.kernel.org/netdev/net-next/c/8f6bc4583713 - [4/5] batman-adv: mcast: remove now redundant single ucast forwarding https://git.kernel.org/netdev/net-next/c/e7d6127b89a9 - [5/5] batman-adv: tvlv: prepare for tvlv enabled multicast packet type https://git.kernel.org/netdev/net-next/c/0c4061c0d0e2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH 1/5] batman-adv: Start new development cycle
In reply to Simon WunderlichQuoted 6 lines · Fri, Jan 27, 2023 at 11:21:29AM CET, [email protected] wrote:
This version will contain all the (major or even only minor) changes for Linux 6.3.
The version number isn't a semantic version number with major and minor information. It is just encoding the year of the expected publishing as Linux -rc1 and the number of published versions this year (starting at 0).
I wonder, what is this versioning good for?
Re: [PATCH 1/5] batman-adv: Start new development cycle
Quoted 9 lines · Jiri Pirko
Quoted 6 lines · Fri, Jan 27, 2023 at 11:21:29AM CET, [email protected] wrote:
This version will contain all the (major or even only minor) changes for Linux 6.3.
The version number isn't a semantic version number with major and minor information. It is just encoding the year of the expected publishing as Linux -rc1 and the number of published versions this year (starting at 0).
I wonder, what is this versioning good for?
The best reason in my opinion is that it's useful to convince ordinary people that they should update :-).
Usually when debugging reported issues one of the first things we ask users is to provide the output of "batctl -v":
``` $ batctl -v batctl debian-2023.0-1 [batman-adv: 2022.3] ```
If there is a very old year in there I think it's easier to tell and convince people to try again with newer versions and to update.
And also as a developer I find it easier to (roughly) memorize when a feature was added by year than by kernel version number. So I know by heart that TVLVs were added in 2014 and multicast snooping patches and new multicast handling was added around 2019 for instance. But don't ask me which kernel version that was :D. I'd have to look that up. So if "batctl -v" displayed a kernel version number that would be less helpful for me.
Also makes it easier for ordinary users to look up and compare their version with our news archive:
https://www.open-mesh.org/projects/open-mesh/wiki/News-archive
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.
Does that make sense?
Re: [PATCH 1/5] batman-adv: Start new development cycle
Quoted 14 lines · Thu, Feb 02, 2023 at 07:44:06PM CET, [email protected] wrote:
Quoted 9 lines · Jiri Pirko
Quoted 6 lines · Fri, Jan 27, 2023 at 11:21:29AM CET, [email protected] wrote:
This version will contain all the (major or even only minor) changes for Linux 6.3.
The version number isn't a semantic version number with major and minor information. It is just encoding the year of the expected publishing as Linux -rc1 and the number of published versions this year (starting at 0).
I wonder, what is this versioning good for?
The best reason in my opinion is that it's useful to convince ordinary people that they should update :-).
Quoted 6 lines
Usually when debugging reported issues one of the first things we ask users is to provide the output of "batctl -v":
```
$ batctl -v batctl debian-2023.0-1 [batman-adv: 2022.3]
Why kernel version is not enough for you? My point is, why to maintain internal driver version alongside with the kernel version?
I just don't see any point of having these parallel driver versions. Looks like a historical relict. IDK.
I'w just wondering, that's all.
Quoted 18 lines
```
If there is a very old year in there I think it's easier to tell and convince people to try again with newer versions and to update.
And also as a developer I find it easier to (roughly) memorize when a feature was added by year than by kernel version number. So I know by heart that TVLVs were added in 2014 and multicast snooping patches and new multicast handling was added around 2019 for instance. But don't ask me which kernel version that was :D. I'd have to look that up. So if "batctl -v" displayed a kernel version number that would be less helpful for me.
Also makes it easier for ordinary users to look up and compare their version with our news archive:
https://www.open-mesh.org/projects/open-mesh/wiki/News-archive
Quoted 6 lines
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.
Quoted 2 lines
Does that make sense?
Sven Eckelmann
maintainerRe: [PATCH 1/5] batman-adv: Start new development cycle
On Friday, 3 February 2023 09:29:50 CET Jiri Pirko wrote:
[...]
Quoted 2 lines
Why kernel version is not enough for you? My point is, why to maintain internal driver version alongside with the kernel version?
[...]
Quoted 8 lines
Quoted 6 lines
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.1e3fcaee@kicinski-fedora-pc1c0hjn.DHCP.thefacebook.com
Re: [PATCH 1/5] batman-adv: Start new development cycle
Quoted 32 lines · Sven Eckelmann
On Friday, 3 February 2023 09:29:50 CET Jiri Pirko wrote:
[...]Quoted 2 lines
Why kernel version is not enough for you? My point is, why to maintain internal driver version alongside with the kernel version?
[...]
Quoted 8 lines
Quoted 6 lines
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+ dropBATADV_ATTR_VERSION+ modifying batctl to fetch that fromuname(). But of course, that would break old batctl versions [1]
- or by settingBATADV_SOURCE_VERSIONtoUTS_RELEASE(+suffix?) orUTS_VERSION
Quoted 2 lines
But this wasn't well received when mentioning it to Simon+Linus (but I could misremember the persons involved here).
In cases where you can prove real userspace breakage, we simply stop to update module versions.
Thanks
Quoted 5 lines
Kind regards,
Sven[1] https://lore.kernel.org/r/20201205085604.1e3fcaee@kicinski-fedora-pc1c0hjn.DHCP.thefacebook.com
Sven Eckelmann
maintainerRe: [PATCH 1/5] batman-adv: Start new development cycle
Quoted 2 lines · 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_adv 266240 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: <BROADCAST,MULTICAST> 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 kernelExpected 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:83 0.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)]
Originator last-seen (#/255) Nexthop [outgoingIF]
* 50:7b:9d:ce:26:83 0.684s (255) 50:7b:9d:ce:26:83 [ enp70s0]Kind regards,
Sven
Re: [PATCH 1/5] batman-adv: Start new development cycle
Quoted 6 lines · Sven Eckelmann
Quoted 2 lines · 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.
The thing is that you already show bogus values.
Most users don't compile their kernel, but use distro-based one. The latter is a mix of base kernel, fixes and sometimes backports.
For example, on my system:
➜ kernel git:(wip/leon-for-next) modinfo batman_adv
filename: /lib/modules/6.1.9-200.fc37.x86_64/kernel/net/batman-adv/batman-adv.ko.xz
....
version: 2022.3 description: B.A.T.M.A.N. advanced ... name: batman_adv vermagic: 6.1.9-200.fc37.x86_64 SMP preempt mod_unload
As you can see both of us have 2022.3 in version string, but are we running same code?
The answer is no as you run debian and I'm running latest Fedora with different kernel version, which means different batman_adv feature set.
Once you stop to update version, you will push users to look on the real version (kernel) which really matters.
Thanks
Quoted 39 lines
And how should I prove it to you? Is that enough?
$ lsmod|grep '^batman_adv' batman_adv 266240 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: <BROADCAST,MULTICAST> 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 kernelExpected 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:83 0.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)] Originator last-seen (#/255) Nexthop [outgoingIF] * 50:7b:9d:ce:26:83 0.684s (255) 50:7b:9d:ce:26:83 [ enp70s0]Kind regards,
Sven
Sven Eckelmann
maintainerRe: [PATCH 1/5] batman-adv: Start new development cycle
Quoted 2 lines · 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
Re: [PATCH 1/5] batman-adv: Start new development cycle
Quoted 10 lines · Sven Eckelmann
Quoted 2 lines · 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".
I'm not sharing your view about users and think they need to be educated, even it is hard and non-rewarding job.
Thanks
Quoted 3 lines
Kind regards,
Sven
Simon Wunderlich
maintainerPATCH 2/5 batman-adv: Drop prandom.h includes
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The commit 8032bf1233a7 ("treewide: 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.
--- 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 +- 4 files changed, 1 insertion(+), 4 deletions(-)
net/batman-adv/bat_iv_ogm.c +0 -1
@@ -27,7 +27,6 @@#include <linux/netdevice.h> #include <linux/netlink.h> #include <linux/pkt_sched.h> -#include <linux/prandom.h> #include <linux/printk.h> #include <linux/random.h> #include <linux/rculist.h>
net/batman-adv/bat_v_elp.c +0 -1
@@ -21,7 +21,6 @@#include <linux/minmax.h> #include <linux/netdevice.h> #include <linux/nl80211.h> -#include <linux/prandom.h> #include <linux/random.h> #include <linux/rculist.h> #include <linux/rcupdate.h>
net/batman-adv/bat_v_ogm.c +0 -1
@@ -21,7 +21,6 @@#include <linux/minmax.h> #include <linux/mutex.h> #include <linux/netdevice.h> -#include <linux/prandom.h> #include <linux/random.h> #include <linux/rculist.h> #include <linux/rcupdate.h>
net/batman-adv/network-coding.c +1 -1
@@ -25,8 +25,8 @@#include <linux/lockdep.h> #include <linux/net.h> #include <linux/netdevice.h> -#include <linux/prandom.h> #include <linux/printk.h> +#include <linux/random.h> #include <linux/rculist.h> #include <linux/rcupdate.h> #include <linux/skbuff.h>
Signature · 1 line
2.30.2
Simon Wunderlich
maintainerPATCH 3/5 batman-adv: Fix mailing list address
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
--- Documentation/networking/batman-adv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/networking/batman-adv.rst +1 -1
@@ -159,7 +159,7 @@ Please send us comments, experiences, questions, anything :) IRC: #batadv on ircs://irc.hackint.org/ Mailing-list: - [email protected] (optional subscription at + [email protected] (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:
Signature · 1 line
2.30.2
Simon Wunderlich
maintainerPATCH 4/5 batman-adv: mcast: remove now redundant single ucast forwarding
In reply to Simon WunderlichFrom: Linus Lüssing <[email protected]>
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.
--- 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(-)
net/batman-adv/multicast.c +14 -235
@@ -26,7 +26,6 @@#include <linux/ipv6.h> #include <linux/jiffies.h> #include <linux/kernel.h> -#include <linux/kref.h> #include <linux/list.h> #include <linux/lockdep.h> #include <linux/netdevice.h>
@@ -1136,223 +1135,20 @@ static int batadv_mcast_forw_rtr_count(struct batadv_priv *bat_priv, } } -/** -* batadv_mcast_forw_tt_node_get() - get a multicast tt node -* @bat_priv: the bat priv with all the soft interface information -* @ethhdr: the ether header containing the multicast destination -* -* Return: an orig_node matching the multicast address provided by ethhdr -* via a translation table lookup. This increases the returned nodes refcount. -*/ -static struct batadv_orig_node * -batadv_mcast_forw_tt_node_get (struct batadv_priv *bat_priv, -struct ethhdr *ethhdr) -{ -return batadv_transtable_search (bat_priv,NULL , ethhdr->h_dest, -BATADV_NO_FLAGS ); -} - -/** -* batadv_mcast_forw_ipv4_node_get() - get a node with an ipv4 flag -* @bat_priv: the bat priv with all the soft interface information -* -* Return: an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 flag set and -* increases its refcount. -*/ -static struct batadv_orig_node * -batadv_mcast_forw_ipv4_node_get (struct batadv_priv *bat_priv) -{ -struct batadv_orig_node *tmp_orig_node, *orig_node =NULL ; - -rcu_read_lock (); -hlist_for_each_entry_rcu (tmp_orig_node, - &bat_priv->mcast.want_all_ipv4_list, - mcast_want_all_ipv4_node) { -if (!kref_get_unless_zero (&tmp_orig_node->refcount)) -continue ; - - orig_node = tmp_orig_node; -break ; - } -rcu_read_unlock (); - -return orig_node; -} - -/** -* batadv_mcast_forw_ipv6_node_get() - get a node with an ipv6 flag -* @bat_priv: the bat priv with all the soft interface information -* -* Return: an orig_node which has the BATADV_MCAST_WANT_ALL_IPV6 flag set -* and increases its refcount. -*/ -static struct batadv_orig_node * -batadv_mcast_forw_ipv6_node_get (struct batadv_priv *bat_priv) -{ -struct batadv_orig_node *tmp_orig_node, *orig_node =NULL ; - -rcu_read_lock (); -hlist_for_each_entry_rcu (tmp_orig_node, - &bat_priv->mcast.want_all_ipv6_list, - mcast_want_all_ipv6_node) { -if (!kref_get_unless_zero (&tmp_orig_node->refcount)) -continue ; - - orig_node = tmp_orig_node; -break ; - } -rcu_read_unlock (); - -return orig_node; -} - -/** -* batadv_mcast_forw_ip_node_get() - get a node with an ipv4/ipv6 flag -* @bat_priv: the bat priv with all the soft interface information -* @ethhdr: an ethernet header to determine the protocol family from -* -* Return: an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 or -* BATADV_MCAST_WANT_ALL_IPV6 flag, depending on the provided ethhdr, sets and -* increases its refcount. -*/ -static struct batadv_orig_node * -batadv_mcast_forw_ip_node_get (struct batadv_priv *bat_priv, -struct ethhdr *ethhdr) -{ -switch (ntohs (ethhdr->h_proto)) { -case ETH_P_IP : -return batadv_mcast_forw_ipv4_node_get (bat_priv); -case ETH_P_IPV6 : -return batadv_mcast_forw_ipv6_node_get (bat_priv); -default : -/* we shouldn't be here... */ -return NULL ; - } -} - -/** -* batadv_mcast_forw_unsnoop_node_get() - get a node with an unsnoopable flag -* @bat_priv: the bat priv with all the soft interface information -* -* Return: an orig_node which has the BATADV_MCAST_WANT_ALL_UNSNOOPABLES flag -* set and increases its refcount. -*/ -static struct batadv_orig_node * -batadv_mcast_forw_unsnoop_node_get (struct batadv_priv *bat_priv) -{ -struct batadv_orig_node *tmp_orig_node, *orig_node =NULL ; - -rcu_read_lock (); -hlist_for_each_entry_rcu (tmp_orig_node, - &bat_priv->mcast.want_all_unsnoopables_list, - mcast_want_all_unsnoopables_node) { -if (!kref_get_unless_zero (&tmp_orig_node->refcount)) -continue ; - - orig_node = tmp_orig_node; -break ; - } -rcu_read_unlock (); - -return orig_node; -} - -/** -* batadv_mcast_forw_rtr4_node_get() - get a node with an ipv4 mcast router flag -* @bat_priv: the bat priv with all the soft interface information -* -* Return: an orig_node which has the BATADV_MCAST_WANT_NO_RTR4 flag unset and -* increases its refcount. -*/ -static struct batadv_orig_node * -batadv_mcast_forw_rtr4_node_get (struct batadv_priv *bat_priv) -{ -struct batadv_orig_node *tmp_orig_node, *orig_node =NULL ; - -rcu_read_lock (); -hlist_for_each_entry_rcu (tmp_orig_node, - &bat_priv->mcast.want_all_rtr4_list, - mcast_want_all_rtr4_node) { -if (!kref_get_unless_zero (&tmp_orig_node->refcount)) -continue ; - - orig_node = tmp_orig_node; -break ; - } -rcu_read_unlock (); - -return orig_node; -} - -/** -* batadv_mcast_forw_rtr6_node_get() - get a node with an ipv6 mcast router flag -* @bat_priv: the bat priv with all the soft interface information -* -* Return: an orig_node which has the BATADV_MCAST_WANT_NO_RTR6 flag unset -* and increases its refcount. -*/ -static struct batadv_orig_node * -batadv_mcast_forw_rtr6_node_get (struct batadv_priv *bat_priv) -{ -struct batadv_orig_node *tmp_orig_node, *orig_node =NULL ; - -rcu_read_lock (); -hlist_for_each_entry_rcu (tmp_orig_node, - &bat_priv->mcast.want_all_rtr6_list, - mcast_want_all_rtr6_node) { -if (!kref_get_unless_zero (&tmp_orig_node->refcount)) -continue ; - - orig_node = tmp_orig_node; -break ; - } -rcu_read_unlock (); - -return orig_node; -} - -/** -* batadv_mcast_forw_rtr_node_get() - get a node with an ipv4/ipv6 router flag -* @bat_priv: the bat priv with all the soft interface information -* @ethhdr: an ethernet header to determine the protocol family from -* -* Return: an orig_node which has no BATADV_MCAST_WANT_NO_RTR4 or -* BATADV_MCAST_WANT_NO_RTR6 flag, depending on the provided ethhdr, set and -* increases its refcount. -*/ -static struct batadv_orig_node * -batadv_mcast_forw_rtr_node_get (struct batadv_priv *bat_priv, -struct ethhdr *ethhdr) -{ -switch (ntohs (ethhdr->h_proto)) { -case ETH_P_IP : -return batadv_mcast_forw_rtr4_node_get (bat_priv); -case ETH_P_IPV6 : -return batadv_mcast_forw_rtr6_node_get (bat_priv); -default : -/* we shouldn't be here... */ -return NULL ; - } -} -/** * batadv_mcast_forw_mode() - check on how to forward a multicast packet * @bat_priv: the bat priv with all the soft interface information -* @skb: The multicast packet to check -* @orig: an originator to be set to forward the skb to +* @skb: the multicast packet to check * @is_routable: stores whether the destination is routable * -* Return: the forwarding mode as enum batadv_forw_mode and in case of -* BATADV_FORW_SINGLE set the orig to the single originator the skb -* should be forwarded to. +* Return: The forwarding mode as enum batadv_forw_mode. */ enum batadv_forw_mode batadv_mcast_forw_mode (struct batadv_priv *bat_priv,struct sk_buff *skb, -struct batadv_orig_node **orig,int *is_routable) +int *is_routable) {int ret, tt_count, ip_count, unsnoop_count, total_count;bool is_unsnoopable = false; -unsigned int mcast_fanout;struct ethhdr *ethhdr;int rtr_count =0 ;
@@ -1361,7 +1157,7 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,if (ret == -ENOMEM )return BATADV_FORW_NONE ;else if (ret <0 ) -return BATADV_FORW_ALL ; +return BATADV_FORW_BCAST ; ethhdr =eth_hdr (skb);
@@ -1374,32 +1170,15 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, total_count = tt_count + ip_count + unsnoop_count + rtr_count; -switch (total_count) { -case 1 : -if (tt_count) - *orig =batadv_mcast_forw_tt_node_get (bat_priv, ethhdr); -else if (ip_count) - *orig =batadv_mcast_forw_ip_node_get (bat_priv, ethhdr); -else if (unsnoop_count) - *orig =batadv_mcast_forw_unsnoop_node_get (bat_priv); -else if (rtr_count) - *orig =batadv_mcast_forw_rtr_node_get (bat_priv, - ethhdr); - -if (*orig) -return BATADV_FORW_SINGLE ; - - fallthrough; -case 0 : +if (!total_count)return BATADV_FORW_NONE ; -default : - mcast_fanout =atomic_read (&bat_priv->multicast_fanout); +else if (unsnoop_count) +return BATADV_FORW_BCAST ; -if (!unsnoop_count && total_count <= mcast_fanout) -return BATADV_FORW_SOME ; - } +if (total_count <=atomic_read (&bat_priv->multicast_fanout)) +return BATADV_FORW_UCASTS ; -return BATADV_FORW_ALL ; +return BATADV_FORW_BCAST ; }/**
@@ -1411,10 +1190,10 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,* * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise. */ -int batadv_mcast_forw_send_orig (struct batadv_priv *bat_priv, -struct sk_buff *skb, -unsigned short vid, -struct batadv_orig_node *orig_node) +static int batadv_mcast_forw_send_orig (struct batadv_priv *bat_priv, +struct sk_buff *skb, +unsigned short vid, +struct batadv_orig_node *orig_node) {/* Avoid sending multicast-in-unicast packets to other BLA * gateways - they already got the frame from the LAN side
net/batman-adv/multicast.h +7 -31
@@ -17,23 +17,16 @@*/ enum batadv_forw_mode {/** -* @BATADV_FORW_ALL: forward the packet to all nodes (currently via -* classic flooding) +* @BATADV_FORW_BCAST: forward the packet to all nodes via a batman-adv +* broadcast packet */ -BATADV_FORW_ALL , +BATADV_FORW_BCAST ,/** -* @BATADV_FORW_SOME: forward the packet to some nodes (currently via -* a multicast-to-unicast conversion and the BATMAN unicast routing -* protocol) +* @BATADV_FORW_UCASTS: forward the packet to some nodes via one +* or more batman-adv unicast packets */ -BATADV_FORW_SOME , - -/** -* @BATADV_FORW_SINGLE: forward the packet to a single node (currently -* via the BATMAN unicast routing protocol) -*/ -BATADV_FORW_SINGLE , +BATADV_FORW_UCASTS ,/** @BATADV_FORW_NONE: don't forward, drop it */ BATADV_FORW_NONE ,
@@ -43,14 +36,8 @@ enum batadv_forw_mode {enum batadv_forw_mode batadv_mcast_forw_mode (struct batadv_priv *bat_priv,struct sk_buff *skb, -struct batadv_orig_node **mcast_single_orig,int *is_routable); -int batadv_mcast_forw_send_orig (struct batadv_priv *bat_priv, -struct sk_buff *skb, -unsigned short vid, -struct batadv_orig_node *orig_node); -int batadv_mcast_forw_send (struct batadv_priv *bat_priv,struct sk_buff *skb,unsigned short vid,int is_routable);
@@ -69,20 +56,9 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node);static inline enum batadv_forw_mode batadv_mcast_forw_mode (struct batadv_priv *bat_priv,struct sk_buff *skb, -struct batadv_orig_node **mcast_single_orig,int *is_routable) { -return BATADV_FORW_ALL ; -} - -static inline int -batadv_mcast_forw_send_orig (struct batadv_priv *bat_priv, -struct sk_buff *skb, -unsigned short vid, -struct batadv_orig_node *orig_node) -{ -kfree_skb (skb); -return NET_XMIT_DROP ; +return BATADV_FORW_BCAST ; } static inline int
net/batman-adv/soft-interface.c +12 -14
@@ -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"
@@ -196,8 +195,7 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,unsigned short vid;u32 seqno;int gw_mode; -enum batadv_forw_mode forw_mode =BATADV_FORW_SINGLE ; -struct batadv_orig_node *mcast_single_orig =NULL ; +enum batadv_forw_mode forw_mode =BATADV_FORW_BCAST ;int mcast_is_routable =0 ;int network_offset =ETH_HLEN ;__be16 proto;
@@ -301,14 +299,18 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb, send:if (do_bcast && !is_broadcast_ether_addr (ethhdr->h_dest)) { forw_mode =batadv_mcast_forw_mode (bat_priv, skb, - &mcast_single_orig, &mcast_is_routable); -if (forw_mode ==BATADV_FORW_NONE ) - goto dropped; - -if (forw_mode ==BATADV_FORW_SINGLE || - forw_mode ==BATADV_FORW_SOME ) +switch (forw_mode) { +case BATADV_FORW_BCAST : +break ; +case BATADV_FORW_UCASTS : do_bcast = false; +break ; +case BATADV_FORW_NONE : + fallthrough; +default : + goto dropped; + } } }
@@ -357,10 +359,7 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,if (ret) goto dropped; ret =batadv_send_skb_via_gw (bat_priv, skb, vid); - }else if (mcast_single_orig) { - ret =batadv_mcast_forw_send_orig (bat_priv, skb, vid, - mcast_single_orig); - }else if (forw_mode ==BATADV_FORW_SOME ) { + }else if (forw_mode ==BATADV_FORW_UCASTS ) { ret =batadv_mcast_forw_send (bat_priv, skb, vid, mcast_is_routable); }else {
@@ -386,7 +385,6 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb, dropped_freed:batadv_inc_counter (bat_priv,BATADV_CNT_TX_DROPPED ); end: -batadv_orig_node_put (mcast_single_orig);batadv_hardif_put (primary_if);return NETDEV_TX_OK ; }
Signature · 1 line
2.30.2
Simon Wunderlich
maintainerPATCH 5/5 batman-adv: tvlv: prepare for tvlv enabled multicast packet type
In reply to Simon WunderlichFrom: Linus Lüssing <[email protected]>
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.
--- 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(-)
include/uapi/linux/batadv_packet.h +2 -0
@@ -26,6 +26,7 @@* @BATADV_CODED: network coded packets * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V +* @BATADV_MCAST: multicast packet with multiple destination addresses * * @BATADV_UNICAST: unicast packets carrying unicast payload traffic * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
@@ -42,6 +43,7 @@ enum batadv_packettype {BATADV_CODED =0x02 ,BATADV_ELP =0x03 ,BATADV_OGM2 =0x04 , +BATADV_MCAST =0x05 ,/* 0x40 - 0x7f: unicast */ #define BATADV_UNICAST_MIN 0x40 BATADV_UNICAST = 0x40,
net/batman-adv/bat_v_ogm.c +2 -2
@@ -799,8 +799,8 @@ batadv_v_ogm_process_per_outif(struct batadv_priv *bat_priv,/* only unknown & newer OGMs contain TVLVs we are interested in */ if (seqno_age >0 && if_outgoing ==BATADV_IF_DEFAULT ) -batadv_tvlv_containers_process (bat_priv, true, orig_node, -NULL ,NULL , +batadv_tvlv_containers_process (bat_priv,BATADV_OGM2 , orig_node, +NULL , (unsigned char *)(ogm2 +1 ),ntohs (ogm2->tvlv_len));
net/batman-adv/distributed-arp-table.c +1 -1
@@ -822,7 +822,7 @@ int batadv_dat_init(struct batadv_priv *bat_priv)batadv_dat_start_timer (bat_priv);batadv_tvlv_handler_register (bat_priv, batadv_dat_tvlv_ogm_handler_v1, -NULL ,BATADV_TVLV_DAT ,1 , +NULL ,NULL ,BATADV_TVLV_DAT ,1 ,BATADV_TVLV_HANDLER_OGM_CIFNOTFND );batadv_dat_tvlv_container_update (bat_priv);return 0 ;
net/batman-adv/gateway_common.c +1 -1
@@ -259,7 +259,7 @@ void batadv_gw_init(struct batadv_priv *bat_priv)atomic_set (&bat_priv->gw.sel_class,1 );batadv_tvlv_handler_register (bat_priv, batadv_gw_tvlv_ogm_handler_v1, -NULL ,BATADV_TVLV_GW ,1 , +NULL ,NULL ,BATADV_TVLV_GW ,1 ,BATADV_TVLV_HANDLER_OGM_CIFNOTFND ); }
net/batman-adv/multicast.c +1 -1
@@ -1818,7 +1818,7 @@ static void batadv_mcast_tvlv_ogm_handler(struct batadv_priv *bat_priv,void batadv_mcast_init (struct batadv_priv *bat_priv) {batadv_tvlv_handler_register (bat_priv, batadv_mcast_tvlv_ogm_handler, -NULL ,BATADV_TVLV_MCAST ,2 , +NULL ,NULL ,BATADV_TVLV_MCAST ,2 ,BATADV_TVLV_HANDLER_OGM_CIFNOTFND );INIT_DELAYED_WORK (&bat_priv->mcast.work, batadv_mcast_mla_update);
net/batman-adv/network-coding.c +1 -1
@@ -160,7 +160,7 @@ int batadv_nc_mesh_init(struct batadv_priv *bat_priv)batadv_nc_start_timer (bat_priv);batadv_tvlv_handler_register (bat_priv, batadv_nc_tvlv_ogm_handler_v1, -NULL ,BATADV_TVLV_NC ,1 , +NULL ,NULL ,BATADV_TVLV_NC ,1 ,BATADV_TVLV_HANDLER_OGM_CIFNOTFND );batadv_nc_tvlv_container_update (bat_priv);return 0 ;
net/batman-adv/routing.c +3 -4
@@ -1073,10 +1073,9 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb,if (tvlv_buff_len > skb->len - hdr_size) goto free_skb; - ret =batadv_tvlv_containers_process (bat_priv, false,NULL , - unicast_tvlv_packet->src, - unicast_tvlv_packet->dst, - tvlv_buff, tvlv_buff_len); + ret =batadv_tvlv_containers_process (bat_priv,BATADV_UNICAST_TVLV , +NULL , skb, tvlv_buff, + tvlv_buff_len);if (ret !=NET_RX_SUCCESS ) { ret =batadv_route_unicast_packet (skb, recv_if);
net/batman-adv/translation-table.c +2 -2
@@ -4168,11 +4168,11 @@ int batadv_tt_init(struct batadv_priv *bat_priv) }batadv_tvlv_handler_register (bat_priv, batadv_tt_tvlv_ogm_handler_v1, - batadv_tt_tvlv_unicast_handler_v1, + batadv_tt_tvlv_unicast_handler_v1,NULL ,BATADV_TVLV_TT ,1 ,BATADV_NO_FLAGS );batadv_tvlv_handler_register (bat_priv,NULL , - batadv_roam_tvlv_unicast_handler_v1, + batadv_roam_tvlv_unicast_handler_v1,NULL ,BATADV_TVLV_ROAM ,1 ,BATADV_NO_FLAGS );INIT_DELAYED_WORK (&bat_priv->tt.work, batadv_tt_purge);
net/batman-adv/tvlv.c +49 -22
158 lines not on this page · raw message
net/batman-adv/tvlv.h +6 -3
@@ -9,6 +9,7 @@#include "main.h" +#include <linux/skbuff.h> #include <linux/types.h> #include <uapi/linux/batadv_packet.h>
@@ -34,14 +35,16 @@ void batadv_tvlv_handler_register(struct batadv_priv *bat_priv, u8 *src, u8 *dst, void *tvlv_value, u16 tvlv_value_len), + int (*mptr)(struct batadv_priv *bat_priv, + struct sk_buff *skb), u8 type, u8 version, u8 flags);void batadv_tvlv_handler_unregister (struct batadv_priv *bat_priv,u8 type,u8 version);int batadv_tvlv_containers_process (struct batadv_priv *bat_priv, -bool ogm_source, +u8 packet_type,struct batadv_orig_node *orig_node, -u8 *src,u8 *dst, -void *tvlv_buff,u16 tvlv_buff_len); +struct sk_buff *skb,void *tvlv_buff, +u16 tvlv_buff_len);void batadv_tvlv_unicast_send (struct batadv_priv *bat_priv,const u8 *src,const u8 *dst,u8 type,u8 version,void *tvlv_value,u16 tvlv_value_len);
net/batman-adv/types.h +6 -0
@@ -2335,6 +2335,12 @@ struct batadv_tvlv_handler { u8 *src, u8 *dst, void *tvlv_value, u16 tvlv_value_len); +/** +* @mcast_handler: handler callback which is given the tvlv payload to +* process on incoming mcast packet +*/ +int (*mcast_handler)(struct batadv_priv *bat_priv,struct sk_buff *skb); +/** @type: tvlv type this handler feels responsible for */ u8 type;
Signature · 1 line
2.30.2