Hi David,
this is our first feature pull request for batman-adv (mostly containing code cleanup stuff), there are at least two more to come.
Please pull or let me know of any problem!
Thank you, Simon
The following changes since commit 29fbff8698fc0ac1a1d74584b258e0bf18b469f9:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2016-10-13 21:40:23 -0700)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20161027
for you to fetch changes up to 4c7da0f6dbcde2431d773ce03cde5e7abede54e0:
batman-adv: Avoid precedence issues in macros (2016-10-19 08:37:54 +0200)
---------------------------------------------------------------- This code cleanup patchset includes the following changes (chronological order):
- bump version strings, by Simon Wunderlich
- README updates/clean up, by Sven Eckelmann (4 patches)
- Code clean up and restructuring by Sven Eckelmann (2 patches)
- Kerneldoc fix in forw_packet structure, by Linus Luessing
- Remove unused argument in dbg_arp, by Antonio Quartulli
- Add support to build batman-adv without wireless, by Linus Luessing
- Restructure error handling for is_ap_isolated, by Markus Elfring
- Remove unused initialization in various functions, by Sven Eckelmann
- Use better names for fragment and gateway list heads, by Sven Eckelmann (2 patches)
- Convert to octal permissions for files, by Sven Eckelmann
- Avoid precedence issues for some macros, by Sven Eckelmann
---------------------------------------------------------------- Antonio Quartulli (1): batman-adv: remove unsed argument from batadv_dbg_arp() function
Linus Lüssing (2): batman-adv: fix batadv_forw_packet kerneldoc for list attribute batman-adv: Allow selecting BATMAN V if CFG80211 is not built
Markus Elfring (1): batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Simon Wunderlich (1): batman-adv: Start new development cycle
Sven Eckelmann (12): batman-adv: Add B.A.T.M.A.N. V sysfs files to README batman-adv: Add network_coding and mcast sysfs files to README batman-adv: Add dat, mcast, nc and neighbor debugfs files to README batman-adv: Document new nc, mcast and tpmeter log levels batman-adv: Remove unused function batadv_hash_delete batman-adv: Move batadv_sum_counter to soft-interface.c batman-adv: Remove unused batadv_icmp_user_cmd_type batman-adv: Remove needless init of variables on stack batman-adv: Use proper name for fragments list head batman-adv: Use proper name for gateway list head batman-adv: Use octal permissions instead of macros batman-adv: Avoid precedence issues in macros
Documentation/networking/batman-adv.txt | 35 ++++++++++++---------- net/batman-adv/Kconfig | 2 +- net/batman-adv/bat_iv_ogm.c | 6 ++-- net/batman-adv/bat_v.c | 8 ++--- net/batman-adv/bat_v_ogm.c | 4 +-- net/batman-adv/debugfs.c | 26 ++++++++-------- net/batman-adv/distributed-arp-table.c | 17 ++++------- net/batman-adv/fragmentation.c | 18 +++++------ net/batman-adv/fragmentation.h | 2 +- net/batman-adv/gateway_client.c | 9 +++--- net/batman-adv/hash.h | 30 ------------------- net/batman-adv/icmp_socket.c | 5 ++-- net/batman-adv/log.c | 4 +-- net/batman-adv/log.h | 12 ++++---- net/batman-adv/main.c | 2 +- net/batman-adv/main.h | 27 ++--------------- net/batman-adv/network-coding.c | 8 ++--- net/batman-adv/originator.c | 10 +++---- net/batman-adv/packet.h | 12 +------- net/batman-adv/send.c | 2 +- net/batman-adv/soft-interface.c | 21 +++++++++++++ net/batman-adv/sysfs.c | 53 ++++++++++++++------------------- net/batman-adv/translation-table.c | 25 +++++++--------- net/batman-adv/types.h | 16 +++++----- 24 files changed, 149 insertions(+), 205 deletions(-)
Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 09af21e..8b0979b 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -24,7 +24,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv"
#ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2016.4" +#define BATADV_SOURCE_VERSION "2016.5" #endif
/* B.A.T.M.A.N. parameters */
From: Sven Eckelmann sven@narfation.org
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- Documentation/networking/batman-adv.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/networking/batman-adv.txt b/Documentation/networking/batman-adv.txt index 8a8d3d9..d414e60 100644 --- a/Documentation/networking/batman-adv.txt +++ b/Documentation/networking/batman-adv.txt @@ -32,7 +32,7 @@ compatible interfaces. Once found, it will create subfolders in the /sys directories of each supported interface, e.g.
# ls /sys/class/net/eth0/batman_adv/ -# iface_status mesh_iface +# elp_interval iface_status mesh_iface throughput_override
If an interface does not have the "batman_adv" subfolder it prob- ably is not supported. Not supported interfaces are: loopback,
From: Sven Eckelmann sven@narfation.org
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- Documentation/networking/batman-adv.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/Documentation/networking/batman-adv.txt b/Documentation/networking/batman-adv.txt index d414e60..8afa991 100644 --- a/Documentation/networking/batman-adv.txt +++ b/Documentation/networking/batman-adv.txt @@ -71,10 +71,11 @@ All mesh wide settings can be found in batman's own interface folder:
# ls /sys/class/net/bat0/mesh/ -#aggregated_ogms distributed_arp_table gw_sel_class orig_interval -#ap_isolation fragmentation hop_penalty routing_algo -#bonding gw_bandwidth isolation_mark vlan0 -#bridge_loop_avoidance gw_mode log_level +# aggregated_ogms fragmentation isolation_mark routing_algo +# ap_isolation gw_bandwidth log_level vlan0 +# bonding gw_mode multicast_mode +# bridge_loop_avoidance gw_sel_class network_coding +# distributed_arp_table hop_penalty orig_interval
There is a special folder for debugging information:
Thu, Oct 27, 2016 at 09:01:36PM CEST, sw@simonwunderlich.de wrote:
From: Sven Eckelmann sven@narfation.org
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
Documentation/networking/batman-adv.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/Documentation/networking/batman-adv.txt b/Documentation/networking/batman-adv.txt index d414e60..8afa991 100644 --- a/Documentation/networking/batman-adv.txt +++ b/Documentation/networking/batman-adv.txt @@ -71,10 +71,11 @@ All mesh wide settings can be found in batman's own interface folder:
# ls /sys/class/net/bat0/mesh/ -#aggregated_ogms distributed_arp_table gw_sel_class orig_interval -#ap_isolation fragmentation hop_penalty routing_algo -#bonding gw_bandwidth isolation_mark vlan0 -#bridge_loop_avoidance gw_mode log_level +# aggregated_ogms fragmentation isolation_mark routing_algo +# ap_isolation gw_bandwidth log_level vlan0 +# bonding gw_mode multicast_mode +# bridge_loop_avoidance gw_sel_class network_coding +# distributed_arp_table hop_penalty orig_interval
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
On Samstag, 29. Oktober 2016 12:33:01 CEST Jiri Pirko wrote: [...]
--- a/Documentation/networking/batman-adv.txt +++ b/Documentation/networking/batman-adv.txt @@ -71,10 +71,11 @@ All mesh wide settings can be found in batman's own interface folder:
# ls /sys/class/net/bat0/mesh/ -#aggregated_ogms distributed_arp_table gw_sel_class orig_interval -#ap_isolation fragmentation hop_penalty routing_algo -#bonding gw_bandwidth isolation_mark vlan0 -#bridge_loop_avoidance gw_mode log_level +# aggregated_ogms fragmentation isolation_mark routing_algo +# ap_isolation gw_bandwidth log_level vlan0 +# bonding gw_mode multicast_mode +# bridge_loop_avoidance gw_sel_class network_coding +# distributed_arp_table hop_penalty orig_interval
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Kind regards, Sven
Sat, Oct 29, 2016 at 12:37:07PM CEST, sven@narfation.org wrote:
On Samstag, 29. Oktober 2016 12:33:01 CEST Jiri Pirko wrote: [...]
--- a/Documentation/networking/batman-adv.txt +++ b/Documentation/networking/batman-adv.txt @@ -71,10 +71,11 @@ All mesh wide settings can be found in batman's own interface folder:
# ls /sys/class/net/bat0/mesh/ -#aggregated_ogms distributed_arp_table gw_sel_class orig_interval -#ap_isolation fragmentation hop_penalty routing_algo -#bonding gw_bandwidth isolation_mark vlan0 -#bridge_loop_avoidance gw_mode log_level +# aggregated_ogms fragmentation isolation_mark routing_algo +# ap_isolation gw_bandwidth log_level vlan0 +# bonding gw_mode multicast_mode +# bridge_loop_avoidance gw_sel_class network_coding +# distributed_arp_table hop_penalty orig_interval
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Kind regards, Sven
On Samstag, 29. Oktober 2016 12:56:28 CEST Jiri Pirko wrote: [...]
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Fair enough, I have added it to the issue tracker [1].
It seems there is no easy way to drop support for modifying batman-adv attributes of the interface or its ports via sysfs in the near future. But disallowing sysfs for new attributes might be a viable policy.
Kind regards, Sven
Sat, Oct 29, 2016 at 01:46:59PM CEST, sven@narfation.org wrote:
On Samstag, 29. Oktober 2016 12:56:28 CEST Jiri Pirko wrote: [...]
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Fair enough, I have added it to the issue tracker [1].
It seems there is no easy way to drop support for modifying batman-adv attributes of the interface or its ports via sysfs in the near future. But disallowing sysfs for new attributes might be a viable policy.
Cool. Thanks!
Kind regards, Sven
On Sat, Oct 29, 2016 at 12:56:28PM +0200, Jiri Pirko wrote:
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Hi Jiri,
Thanks for sharing your thoughts!
Could you explain a bit more on which disadvantages you see in the usage of sysfs here?
Regards, Linus
On Dienstag, 27. März 2018 17:43:08 CEST Linus Lüssing wrote:
On Sat, Oct 29, 2016 at 12:56:28PM +0200, Jiri Pirko wrote:
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Hi Jiri,
Thanks for sharing your thoughts!
Could you explain a bit more on which disadvantages you see in the usage of sysfs here?
Linus is asking because of following patch: https://patchwork.open-mesh.org/patch/17340/
Kind regards, Sven
Hi Jiri,
seems like you still haven't answered Linus' question.
On Montag, 7. Mai 2018 08:34:16 CEST Sven Eckelmann wrote:
On Dienstag, 27. März 2018 17:43:08 CEST Linus Lüssing wrote:
On Sat, Oct 29, 2016 at 12:56:28PM +0200, Jiri Pirko wrote:
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Hi Jiri,
Thanks for sharing your thoughts!
Could you explain a bit more on which disadvantages you see in the usage of sysfs here?
Linus is asking because of following patch: https://patchwork.open-mesh.org/patch/17340/
The next patch with a similar problem would be https://patchwork.open-mesh.org/patch/17372/. It is rather important that you are discussing this with Linus Luessing and Marek Lindner.
Kind regards, Sven
Tue, Mar 27, 2018 at 05:43:08PM CEST, linus.luessing@c0d3.blue wrote:
On Sat, Oct 29, 2016 at 12:56:28PM +0200, Jiri Pirko wrote:
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Hi Jiri,
Thanks for sharing your thoughts!
Could you explain a bit more on which disadvantages you see in the usage of sysfs here?
There are 2 major disadvantages. 1) You don't have any events on a change. An app has to poll in order to know what changed in kernel. Netlink handles this by sending multicast messages on a specific socket while whoever is interested gets the messages. 2) In sysfs, everything is string. There are even mixed values like "1 (means something)". There are no well defined values. Every driver can expose same things differently. In Netlink, you have well-defined attributes, with typed values. You can pass multiple attributes for the same value if needed.
In general, usage of sysfs in netdev subsystem is frowned upon. I would suggest to convert your iface to Generic Netlink API and let the existing sysfs API to rot.
Regards, Linus
Hi Jiri,
On 20/05/18 14:19, Jiri Pirko wrote:
Tue, Mar 27, 2018 at 05:43:08PM CEST, linus.luessing@c0d3.blue wrote:
On Sat, Oct 29, 2016 at 12:56:28PM +0200, Jiri Pirko wrote:
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Hi Jiri,
Thanks for sharing your thoughts!
Could you explain a bit more on which disadvantages you see in the usage of sysfs here?
There are 2 major disadvantages.
- You don't have any events on a change. An app has to poll in order to know what changed in kernel. Netlink handles this by sending multicast messages on a specific socket while whoever is interested gets the messages.
- In sysfs, everything is string. There are even mixed values like "1 (means something)". There are no well defined values. Every driver can expose same things differently. In Netlink, you have well-defined attributes, with typed values. You can pass multiple attributes for the same value if needed.
In general, usage of sysfs in netdev subsystem is frowned upon. I would suggest to convert your iface to Generic Netlink API and let the existing sysfs API to rot.
Do you have any pointer about where this discussion took place? I imagine it happened in conjunction with some patches intended to other drivers/netdev changes.
Reading that could give us a sense of how strict/important/severe this decision was and how to prioritize future work.
I am asking because we have been working on a new feature since several months and this feature introduces a new sysfs knob.
Now, although I understand the recommendation of switching to netlink, I find it a bit impractical to delay a new (and fairly big) feature, simply because it uses a potentially obsolete, but current, API.
Any opinion about this?
Thanks a lot
Regards,
Sat, Aug 04, 2018 at 11:24:11AM CEST, a@unstable.cc wrote:
Hi Jiri,
On 20/05/18 14:19, Jiri Pirko wrote:
Tue, Mar 27, 2018 at 05:43:08PM CEST, linus.luessing@c0d3.blue wrote:
On Sat, Oct 29, 2016 at 12:56:28PM +0200, Jiri Pirko wrote:
I strongly believe it is a huge mistake to use sysfs for things like this. This should be done via generic netlink api.
This doesn't change the problem that it is already that way. This patch only adds the list of available files to the README.
Sure. Just found out you did it like that. Therefore I commented. I suggest to rework the api to use genl entirely.
Hi Jiri,
Thanks for sharing your thoughts!
Could you explain a bit more on which disadvantages you see in the usage of sysfs here?
There are 2 major disadvantages.
- You don't have any events on a change. An app has to poll in order to know what changed in kernel. Netlink handles this by sending multicast messages on a specific socket while whoever is interested gets the messages.
- In sysfs, everything is string. There are even mixed values like "1 (means something)". There are no well defined values. Every driver can expose same things differently. In Netlink, you have well-defined attributes, with typed values. You can pass multiple attributes for the same value if needed.
In general, usage of sysfs in netdev subsystem is frowned upon. I would suggest to convert your iface to Generic Netlink API and let the existing sysfs API to rot.
Do you have any pointer about where this discussion took place? I imagine it happened in conjunction with some patches intended to other drivers/netdev changes.
Reading that could give us a sense of how strict/important/severe this decision was and how to prioritize future work.
I am asking because we have been working on a new feature since several months and this feature introduces a new sysfs knob.
Now, although I understand the recommendation of switching to netlink, I find it a bit impractical to delay a new (and fairly big) feature, simply because it uses a potentially obsolete, but current, API.
Any opinion about this?
I agree, that does not make sense.
I just wanted you to consider introducing netlink iface and migrate to it as it is generally the preffered way to comunicate with userspace in networking area (I don't have pointer any specific discussion though - it is just a common knowledge :)). I will be more then happy to help you with that. You should look at net/core/devlink.c and net/wireless/nl80211.c to get some inspiration.
Thanks a lot
Regards,
-- Antonio Quartulli
On 04/08/18 17:36, Jiri Pirko wrote:
Do you have any pointer about where this discussion took place? I imagine it happened in conjunction with some patches intended to other drivers/netdev changes.
Reading that could give us a sense of how strict/important/severe this decision was and how to prioritize future work.
I am asking because we have been working on a new feature since several months and this feature introduces a new sysfs knob.
Now, although I understand the recommendation of switching to netlink, I find it a bit impractical to delay a new (and fairly big) feature, simply because it uses a potentially obsolete, but current, API.
Any opinion about this?
I agree, that does not make sense.
Thanks for your reply, Jiri.
I just wanted you to consider introducing netlink iface and migrate to it as it is generally the preffered way to comunicate with userspace in networking area (I don't have pointer any specific discussion though - it is just a common knowledge :)).
That's ok. I was asking because in the past batman-adv was using debugfs for dealing with settings and we were (properly) redirected to sysfs by David. Now it seems we need to migrate to the next thing :-) So I just wanted to be sure we have to do it, but this seems to be the case..
I will be more then happy to help you with that. You should look at net/core/devlink.c and net/wireless/nl80211.c to get some inspiration.
Actually we have already implemented a basic netlink API to be used when sending information to userspace (i.e. routing tables, neighbour tables, etc..), therefore I think we might be able to leverage on that. But of course, any help will be appreciated :)
Thanks!
Cheers,
Sat, Aug 04, 2018 at 01:19:39PM CEST, a@unstable.cc wrote:
On 04/08/18 17:36, Jiri Pirko wrote:
Do you have any pointer about where this discussion took place? I imagine it happened in conjunction with some patches intended to other drivers/netdev changes.
Reading that could give us a sense of how strict/important/severe this decision was and how to prioritize future work.
I am asking because we have been working on a new feature since several months and this feature introduces a new sysfs knob.
Now, although I understand the recommendation of switching to netlink, I find it a bit impractical to delay a new (and fairly big) feature, simply because it uses a potentially obsolete, but current, API.
Any opinion about this?
I agree, that does not make sense.
Thanks for your reply, Jiri.
I just wanted you to consider introducing netlink iface and migrate to it as it is generally the preffered way to comunicate with userspace in networking area (I don't have pointer any specific discussion though - it is just a common knowledge :)).
That's ok. I was asking because in the past batman-adv was using debugfs for dealing with settings and we were (properly) redirected to sysfs by David. Now it seems we need to migrate to the next thing :-) So I just wanted to be sure we have to do it, but this seems to be the case..
I will be more then happy to help you with that. You should look at net/core/devlink.c and net/wireless/nl80211.c to get some inspiration.
Actually we have already implemented a basic netlink API to be used when sending information to userspace (i.e. routing tables, neighbour tables, etc..), therefore I think we might be able to leverage on that. But of course, any help will be appreciated :)
Yes, I see net/batman-adv/netlink.c. That looks fine. Shouldn't be hard to migrate the existing sysfs things there and add new features. Please don't forget to echo the configured options via netlink notifications from the very beginning. Feel free to send me patches to look at.
Thanks!
Thanks!
Cheers,
-- Antonio Quartulli
From: Sven Eckelmann sven@narfation.org
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- Documentation/networking/batman-adv.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Documentation/networking/batman-adv.txt b/Documentation/networking/batman-adv.txt index 8afa991..a918131 100644 --- a/Documentation/networking/batman-adv.txt +++ b/Documentation/networking/batman-adv.txt @@ -80,9 +80,10 @@ folder: There is a special folder for debugging information:
# ls /sys/kernel/debug/batman_adv/bat0/ -# bla_backbone_table log transtable_global -# bla_claim_table originators transtable_local -# gateways socket +# bla_backbone_table log neighbors transtable_local +# bla_claim_table mcast_flags originators +# dat_cache nc socket +# gateways nc_nodes transtable_global
Some of the files contain all sort of status information regard- ing the mesh network. For example, you can view the table of
From: Sven Eckelmann sven@narfation.org
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- Documentation/networking/batman-adv.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/Documentation/networking/batman-adv.txt b/Documentation/networking/batman-adv.txt index a918131..ccf9467 100644 --- a/Documentation/networking/batman-adv.txt +++ b/Documentation/networking/batman-adv.txt @@ -161,13 +161,16 @@ file in debugfs The additional debug output is by default disabled. It can be en- abled during run time. Following log_levels are defined:
-0 - All debug output disabled -1 - Enable messages related to routing / flooding / broadcasting -2 - Enable messages related to route added / changed / deleted -4 - Enable messages related to translation table operations -8 - Enable messages related to bridge loop avoidance -16 - Enable messaged related to DAT, ARP snooping and parsing -31 - Enable all messages + 0 - All debug output disabled + 1 - Enable messages related to routing / flooding / broadcasting + 2 - Enable messages related to route added / changed / deleted + 4 - Enable messages related to translation table operations + 8 - Enable messages related to bridge loop avoidance + 16 - Enable messages related to DAT, ARP snooping and parsing + 32 - Enable messages related to network coding + 64 - Enable messages related to multicast +128 - Enable messages related to throughput meter +255 - Enable all messages
The debug output can be changed at runtime using the file /sys/class/net/bat0/mesh/log_level. e.g.
From: Sven Eckelmann sven@narfation.org
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/hash.h | 30 ------------------------------ 1 file changed, 30 deletions(-)
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h index cbbf870..557a704 100644 --- a/net/batman-adv/hash.h +++ b/net/batman-adv/hash.h @@ -61,36 +61,6 @@ void batadv_hash_set_lock_class(struct batadv_hashtable *hash, /* free only the hashtable and the hash itself. */ void batadv_hash_destroy(struct batadv_hashtable *hash);
-/* remove the hash structure. if hashdata_free_cb != NULL, this function will be - * called to remove the elements inside of the hash. if you don't remove the - * elements, memory might be leaked. - */ -static inline void batadv_hash_delete(struct batadv_hashtable *hash, - batadv_hashdata_free_cb free_cb, - void *arg) -{ - struct hlist_head *head; - struct hlist_node *node, *node_tmp; - spinlock_t *list_lock; /* spinlock to protect write access */ - u32 i; - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - list_lock = &hash->list_locks[i]; - - spin_lock_bh(list_lock); - hlist_for_each_safe(node, node_tmp, head) { - hlist_del_rcu(node); - - if (free_cb) - free_cb(node, arg); - } - spin_unlock_bh(list_lock); - } - - batadv_hash_destroy(hash); -} - /** * batadv_hash_add - adds data to the hashtable * @hash: storage hash table
From: Sven Eckelmann sven@narfation.org
The function batadv_sum_counter is only used in soft-interface.c and has no special relevance for main.h.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/main.h | 21 --------------------- net/batman-adv/soft-interface.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 8b0979b..6a2328d 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -185,7 +185,6 @@ enum batadv_uev_type {
#include <linux/bitops.h> /* for packet.h */ #include <linux/compiler.h> -#include <linux/cpumask.h> #include <linux/etherdevice.h> #include <linux/if_ether.h> /* for packet.h */ #include <linux/if_vlan.h> @@ -284,26 +283,6 @@ static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
-/** - * batadv_sum_counter - Sum the cpu-local counters for index 'idx' - * @bat_priv: the bat priv with all the soft interface information - * @idx: index of counter to sum up - * - * Return: sum of all cpu-local counters - */ -static inline u64 batadv_sum_counter(struct batadv_priv *bat_priv, size_t idx) -{ - u64 *counters, sum = 0; - int cpu; - - for_each_possible_cpu(cpu) { - counters = per_cpu_ptr(bat_priv->bat_counters, cpu); - sum += counters[idx]; - } - - return sum; -} - /* Define a macro to reach the control buffer of the skb. The members of the * control buffer are defined in struct batadv_skb_cb in types.h. * The macro is inspired by the similar macro TCP_SKB_CB() in tcp.h. diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 49e16b6..f37c1c7 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -22,6 +22,7 @@ #include <linux/byteorder/generic.h> #include <linux/cache.h> #include <linux/compiler.h> +#include <linux/cpumask.h> #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> @@ -116,6 +117,26 @@ static int batadv_interface_release(struct net_device *dev) return 0; }
+/** + * batadv_sum_counter - Sum the cpu-local counters for index 'idx' + * @bat_priv: the bat priv with all the soft interface information + * @idx: index of counter to sum up + * + * Return: sum of all cpu-local counters + */ +static u64 batadv_sum_counter(struct batadv_priv *bat_priv, size_t idx) +{ + u64 *counters, sum = 0; + int cpu; + + for_each_possible_cpu(cpu) { + counters = per_cpu_ptr(bat_priv->bat_counters, cpu); + sum += counters[idx]; + } + + return sum; +} + static struct net_device_stats *batadv_interface_stats(struct net_device *dev) { struct batadv_priv *bat_priv = netdev_priv(dev);
From: Sven Eckelmann sven@narfation.org
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/packet.h | 10 ---------- 1 file changed, 10 deletions(-)
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index 6afc0b8..d2e9bbd 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -252,16 +252,6 @@ struct batadv_elp_packet { #define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
/** - * enum batadv_icmp_user_cmd_type - types for batman-adv icmp cmd modes - * @BATADV_TP_START: start a throughput meter run - * @BATADV_TP_STOP: stop a throughput meter run - */ -enum batadv_icmp_user_cmd_type { - BATADV_TP_START = 0, - BATADV_TP_STOP = 2, -}; - -/** * struct batadv_icmp_header - common members among all the ICMP packets * @packet_type: batman-adv packet type, part of the general header * @version: batman-adv protocol version, part of the genereal header
From: Linus Lüssing linus.luessing@c0d3.blue
The forw_packet list node is wrongly attributed to the icmp socket code.
Signed-off-by: Linus Lüssing linus.luessing@c0d3.blue Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index b3dd1a3..97336ec 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -1363,7 +1363,7 @@ struct batadv_skb_cb {
/** * struct batadv_forw_packet - structure for bcast packets to be sent/forwarded - * @list: list node for batadv_socket_client::queue_list + * @list: list node for batadv_priv::forw_{bat,bcast}_list * @send_time: execution time for delayed_work (packet sending) * @own: bool for locally generated packets (local OGMs are re-scheduled after * sending)
From: Antonio Quartulli a@unstable.cc
The argument "type" passed to the batadv_dbg_arp() function is never used. Remove it.
Signed-off-by: Antonio Quartulli a@unstable.cc Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/distributed-arp-table.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index e257efd..cbb4f32 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -369,12 +369,11 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, * batadv_dbg_arp - print a debug message containing all the ARP packet details * @bat_priv: the bat priv with all the soft interface information * @skb: ARP packet - * @type: ARP type * @hdr_size: size of the possible header before the ARP packet * @msg: message to print together with the debugging information */ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb, - u16 type, int hdr_size, char *msg) + int hdr_size, char *msg) { struct batadv_unicast_4addr_packet *unicast_4addr_packet; struct batadv_bcast_packet *bcast_pkt; @@ -441,7 +440,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb, #else
static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb, - u16 type, int hdr_size, char *msg) + int hdr_size, char *msg) { }
@@ -983,8 +982,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, if (type != ARPOP_REQUEST) goto out;
- batadv_dbg_arp(bat_priv, skb, type, hdr_size, - "Parsing outgoing ARP REQUEST"); + batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing outgoing ARP REQUEST");
ip_src = batadv_arp_ip_src(skb, hdr_size); hw_src = batadv_arp_hw_src(skb, hdr_size); @@ -1075,8 +1073,7 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, ip_src = batadv_arp_ip_src(skb, hdr_size); ip_dst = batadv_arp_ip_dst(skb, hdr_size);
- batadv_dbg_arp(bat_priv, skb, type, hdr_size, - "Parsing incoming ARP REQUEST"); + batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing incoming ARP REQUEST");
batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
@@ -1149,8 +1146,7 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, if (type != ARPOP_REPLY) return;
- batadv_dbg_arp(bat_priv, skb, type, hdr_size, - "Parsing outgoing ARP REPLY"); + batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing outgoing ARP REPLY");
hw_src = batadv_arp_hw_src(skb, hdr_size); ip_src = batadv_arp_ip_src(skb, hdr_size); @@ -1195,8 +1191,7 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, if (type != ARPOP_REPLY) goto out;
- batadv_dbg_arp(bat_priv, skb, type, hdr_size, - "Parsing incoming ARP REPLY"); + batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing incoming ARP REPLY");
hw_src = batadv_arp_hw_src(skb, hdr_size); ip_src = batadv_arp_ip_src(skb, hdr_size);
From: Linus Lüssing linus.luessing@c0d3.blue
With the new stub for cfg80211_get_station(), we can now build the BATMAN V protocol even with a kernel that was built without any wireless support.
Signed-off-by: Linus Lüssing linus.luessing@c0d3.blue Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig index f20742c..b73b96a 100644 --- a/net/batman-adv/Kconfig +++ b/net/batman-adv/Kconfig @@ -17,7 +17,7 @@ config BATMAN_ADV
config BATMAN_ADV_BATMAN_V bool "B.A.T.M.A.N. V protocol (experimental)" - depends on BATMAN_ADV && CFG80211=y || (CFG80211=m && BATMAN_ADV=m) + depends on BATMAN_ADV && !(CFG80211=m && BATMAN_ADV=y) default n help This option enables the B.A.T.M.A.N. V protocol, the successor
From: Markus Elfring elfring@users.sourceforge.net
The variables "tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.
* Avoid this double check by reordering a function call sequence and the better selection of jump targets.
* Omit the initialisation for these variables at the beginning then.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/translation-table.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 7f66309..ad1e3bc 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -3835,8 +3835,8 @@ void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv) bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst, unsigned short vid) { - struct batadv_tt_local_entry *tt_local_entry = NULL; - struct batadv_tt_global_entry *tt_global_entry = NULL; + struct batadv_tt_local_entry *tt_local_entry; + struct batadv_tt_global_entry *tt_global_entry; struct batadv_softif_vlan *vlan; bool ret = false;
@@ -3845,27 +3845,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst, return false;
if (!atomic_read(&vlan->ap_isolation)) - goto out; + goto vlan_put;
tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid); if (!tt_local_entry) - goto out; + goto vlan_put;
tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid); if (!tt_global_entry) - goto out; - - if (!_batadv_is_ap_isolated(tt_local_entry, tt_global_entry)) - goto out; + goto local_entry_put;
- ret = true; + if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry)) + ret = true;
-out: + batadv_tt_global_entry_put(tt_global_entry); +local_entry_put: + batadv_tt_local_entry_put(tt_local_entry); +vlan_put: batadv_softif_vlan_put(vlan); - if (tt_global_entry) - batadv_tt_global_entry_put(tt_global_entry); - if (tt_local_entry) - batadv_tt_local_entry_put(tt_local_entry); return ret; }
From: Sven Eckelmann sven@narfation.org
Some variables are overwritten immediatelly in a functions. These don't have to be initialized to a specific value on the stack because the value will be overwritten before they will be used anywhere.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/bat_v.c | 2 +- net/batman-adv/bat_v_ogm.c | 4 ++-- net/batman-adv/fragmentation.c | 4 ++-- net/batman-adv/gateway_client.c | 2 +- net/batman-adv/originator.c | 8 ++++---- net/batman-adv/send.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index e79f6f0..57c795c 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -787,7 +787,7 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv, struct batadv_orig_node *curr_gw_orig, struct batadv_orig_node *orig_node) { - struct batadv_gw_node *curr_gw = NULL, *orig_gw = NULL; + struct batadv_gw_node *curr_gw, *orig_gw = NULL; u32 gw_throughput, orig_throughput, threshold; bool ret = false;
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 1aeeadc..61ff5f8 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -401,7 +401,7 @@ static int batadv_v_ogm_metric_update(struct batadv_priv *bat_priv, struct batadv_hard_iface *if_incoming, struct batadv_hard_iface *if_outgoing) { - struct batadv_orig_ifinfo *orig_ifinfo = NULL; + struct batadv_orig_ifinfo *orig_ifinfo; struct batadv_neigh_ifinfo *neigh_ifinfo = NULL; bool protection_started = false; int ret = -EINVAL; @@ -486,7 +486,7 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv, struct batadv_hard_iface *if_outgoing) { struct batadv_neigh_node *router = NULL; - struct batadv_orig_node *orig_neigh_node = NULL; + struct batadv_orig_node *orig_neigh_node; struct batadv_neigh_node *orig_neigh_router = NULL; struct batadv_neigh_ifinfo *router_ifinfo = NULL, *neigh_ifinfo = NULL; u32 router_throughput, neigh_throughput; diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index 0934730..1b2f5b9 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -252,7 +252,7 @@ batadv_frag_merge_packets(struct hlist_head *chain) { struct batadv_frag_packet *packet; struct batadv_frag_list_entry *entry; - struct sk_buff *skb_out = NULL; + struct sk_buff *skb_out; int size, hdr_size = sizeof(struct batadv_frag_packet);
/* Remove first entry, as this is the destination for the rest of the @@ -352,7 +352,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, struct batadv_orig_node *orig_node_src) { struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); - struct batadv_orig_node *orig_node_dst = NULL; + struct batadv_orig_node *orig_node_dst; struct batadv_neigh_node *neigh_node = NULL; struct batadv_frag_packet *packet; u16 total_size; diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index de055d6..69bfe98 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -704,7 +704,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, { struct batadv_neigh_node *neigh_curr = NULL; struct batadv_neigh_node *neigh_old = NULL; - struct batadv_orig_node *orig_dst_node = NULL; + struct batadv_orig_node *orig_dst_node; struct batadv_gw_node *gw_node = NULL; struct batadv_gw_node *curr_gw = NULL; struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo; diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 5f3bfc4..6af87c9 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -364,7 +364,7 @@ struct batadv_orig_ifinfo * batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node, struct batadv_hard_iface *if_outgoing) { - struct batadv_orig_ifinfo *orig_ifinfo = NULL; + struct batadv_orig_ifinfo *orig_ifinfo; unsigned long reset_time;
spin_lock_bh(&orig_node->neigh_list_lock); @@ -520,7 +520,7 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface, const u8 *neigh_addr) { struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); - struct batadv_hardif_neigh_node *hardif_neigh = NULL; + struct batadv_hardif_neigh_node *hardif_neigh;
spin_lock_bh(&hard_iface->neigh_list_lock);
@@ -563,7 +563,7 @@ static struct batadv_hardif_neigh_node * batadv_hardif_neigh_get_or_create(struct batadv_hard_iface *hard_iface, const u8 *neigh_addr) { - struct batadv_hardif_neigh_node *hardif_neigh = NULL; + struct batadv_hardif_neigh_node *hardif_neigh;
/* first check without locking to avoid the overhead */ hardif_neigh = batadv_hardif_neigh_get(hard_iface, neigh_addr); @@ -683,7 +683,7 @@ batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node, struct batadv_hard_iface *hard_iface, const u8 *neigh_addr) { - struct batadv_neigh_node *neigh_node = NULL; + struct batadv_neigh_node *neigh_node;
/* first check without locking to avoid the overhead */ neigh_node = batadv_neigh_node_get(orig_node, hard_iface, neigh_addr); diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 8d4e1f5..e1e9136 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -562,7 +562,7 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, const struct sk_buff *skb, unsigned long delay) { - struct batadv_hard_iface *primary_if = NULL; + struct batadv_hard_iface *primary_if; struct batadv_forw_packet *forw_packet; struct batadv_bcast_packet *bcast_packet; struct sk_buff *newskb;
From: Sven Eckelmann sven@narfation.org
The batman-adv codebase is using "list" for the list node (prev/next) and <list content descriptor>+"_list" for the head of a list. Not using this naming scheme can up in confusions because list_head is used for both the head of the list and the list node (prev/next) in each item of the list.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/fragmentation.c | 14 +++++++------- net/batman-adv/fragmentation.h | 2 +- net/batman-adv/originator.c | 2 +- net/batman-adv/types.h | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index 1b2f5b9..2b967a3 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -73,7 +73,7 @@ void batadv_frag_purge_orig(struct batadv_orig_node *orig_node, spin_lock_bh(&chain->lock);
if (!check_cb || check_cb(chain)) { - batadv_frag_clear_chain(&chain->head); + batadv_frag_clear_chain(&chain->fragment_list); chain->size = 0; }
@@ -117,8 +117,8 @@ static bool batadv_frag_init_chain(struct batadv_frag_table_entry *chain, if (chain->seqno == seqno) return false;
- if (!hlist_empty(&chain->head)) - batadv_frag_clear_chain(&chain->head); + if (!hlist_empty(&chain->fragment_list)) + batadv_frag_clear_chain(&chain->fragment_list);
chain->size = 0; chain->seqno = seqno; @@ -176,7 +176,7 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node, chain = &orig_node->fragments[bucket]; spin_lock_bh(&chain->lock); if (batadv_frag_init_chain(chain, seqno)) { - hlist_add_head(&frag_entry_new->list, &chain->head); + hlist_add_head(&frag_entry_new->list, &chain->fragment_list); chain->size = skb->len - hdr_size; chain->timestamp = jiffies; chain->total_size = ntohs(frag_packet->total_size); @@ -185,7 +185,7 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node, }
/* Find the position for the new fragment. */ - hlist_for_each_entry(frag_entry_curr, &chain->head, list) { + hlist_for_each_entry(frag_entry_curr, &chain->fragment_list, list) { /* Drop packet if fragment already exists. */ if (frag_entry_curr->no == frag_entry_new->no) goto err_unlock; @@ -220,11 +220,11 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node, * exceeds the maximum size of one merged packet. Don't allow * packets to have different total_size. */ - batadv_frag_clear_chain(&chain->head); + batadv_frag_clear_chain(&chain->fragment_list); chain->size = 0; } else if (ntohs(frag_packet->total_size) == chain->size) { /* All fragments received. Hand over chain to caller. */ - hlist_move_list(&chain->head, chain_out); + hlist_move_list(&chain->fragment_list, chain_out); chain->size = 0; }
diff --git a/net/batman-adv/fragmentation.h b/net/batman-adv/fragmentation.h index 3202fe3..b95f619 100644 --- a/net/batman-adv/fragmentation.h +++ b/net/batman-adv/fragmentation.h @@ -47,7 +47,7 @@ int batadv_frag_send_packet(struct sk_buff *skb, static inline bool batadv_frag_check_entry(struct batadv_frag_table_entry *frags_entry) { - if (!hlist_empty(&frags_entry->head) && + if (!hlist_empty(&frags_entry->fragment_list) && batadv_has_timed_out(frags_entry->timestamp, BATADV_FRAG_TIMEOUT)) return true; return false; diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 6af87c9..518b1ed 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -1021,7 +1021,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, batadv_orig_node_vlan_put(vlan);
for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) { - INIT_HLIST_HEAD(&orig_node->fragments[i].head); + INIT_HLIST_HEAD(&orig_node->fragments[i].fragment_list); spin_lock_init(&orig_node->fragments[i].lock); orig_node->fragments[i].size = 0; } diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 97336ec..d31e7ec 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -184,7 +184,7 @@ struct batadv_orig_ifinfo {
/** * struct batadv_frag_table_entry - head in the fragment buffer table - * @head: head of list with fragments + * @fragment_list: head of list with fragments * @lock: lock to protect the list of fragments * @timestamp: time (jiffie) of last received fragment * @seqno: sequence number of the fragments in the list @@ -192,8 +192,8 @@ struct batadv_orig_ifinfo { * @total_size: expected size of the assembled packet */ struct batadv_frag_table_entry { - struct hlist_head head; - spinlock_t lock; /* protects head */ + struct hlist_head fragment_list; + spinlock_t lock; /* protects fragment_list */ unsigned long timestamp; u16 seqno; u16 size;
From: Sven Eckelmann sven@narfation.org
The batman-adv codebase is using "list" for the list node (prev/next) and <list content descriptor>+"_list" for the head of a list. Not using this naming scheme can up in confusions when reading the code.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/bat_iv_ogm.c | 6 +++--- net/batman-adv/bat_v.c | 6 +++--- net/batman-adv/gateway_client.c | 7 ++++--- net/batman-adv/main.c | 2 +- net/batman-adv/types.h | 8 ++++---- 5 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index e2d18d0..0b9be62 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -2486,7 +2486,7 @@ batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv) struct batadv_orig_node *orig_node;
rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { + hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { orig_node = gw_node->orig_node; router = batadv_orig_router_get(orig_node, BATADV_IF_DEFAULT); if (!router) @@ -2674,7 +2674,7 @@ static void batadv_iv_gw_print(struct batadv_priv *bat_priv, " Gateway (#/255) Nexthop [outgoingIF]: advertised uplink bandwidth\n");
rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { + hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { /* fails if orig_node has no router */ if (batadv_iv_gw_write_buffer_text(bat_priv, seq, gw_node) < 0) continue; @@ -2774,7 +2774,7 @@ static void batadv_iv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb, int idx = 0;
rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { + hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { if (idx++ < idx_skip) continue;
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index 57c795c..2ac612d 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -750,7 +750,7 @@ batadv_v_gw_get_best_gw_node(struct batadv_priv *bat_priv) u32 max_bw = 0, bw;
rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { + hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { if (!kref_get_unless_zero(&gw_node->refcount)) continue;
@@ -889,7 +889,7 @@ static void batadv_v_gw_print(struct batadv_priv *bat_priv, " Gateway ( throughput) Nexthop [outgoingIF]: advertised uplink bandwidth\n");
rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { + hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { /* fails if orig_node has no router */ if (batadv_v_gw_write_buffer_text(bat_priv, seq, gw_node) < 0) continue; @@ -1009,7 +1009,7 @@ static void batadv_v_gw_dump(struct sk_buff *msg, struct netlink_callback *cb, int idx = 0;
rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { + hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { if (idx++ < idx_skip) continue;
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 69bfe98..52b8bd6 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -348,7 +348,7 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
spin_lock_bh(&bat_priv->gw.list_lock); kref_get(&gw_node->refcount); - hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.list); + hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.gateway_list); spin_unlock_bh(&bat_priv->gw.list_lock);
batadv_dbg(BATADV_DBG_BATMAN, bat_priv, @@ -376,7 +376,8 @@ struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv, struct batadv_gw_node *gw_node_tmp, *gw_node = NULL;
rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node_tmp, &bat_priv->gw.list, list) { + hlist_for_each_entry_rcu(gw_node_tmp, &bat_priv->gw.gateway_list, + list) { if (gw_node_tmp->orig_node != orig_node) continue;
@@ -475,7 +476,7 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv)
spin_lock_bh(&bat_priv->gw.list_lock); hlist_for_each_entry_safe(gw_node, node_tmp, - &bat_priv->gw.list, list) { + &bat_priv->gw.gateway_list, list) { hlist_del_init_rcu(&gw_node->list); batadv_gw_node_put(gw_node); } diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 2c017ab..5e4e818 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -160,7 +160,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
INIT_HLIST_HEAD(&bat_priv->forw_bat_list); INIT_HLIST_HEAD(&bat_priv->forw_bcast_list); - INIT_HLIST_HEAD(&bat_priv->gw.list); + INIT_HLIST_HEAD(&bat_priv->gw.gateway_list); #ifdef CONFIG_BATMAN_ADV_MCAST INIT_HLIST_HEAD(&bat_priv->mcast.want_all_unsnoopables_list); INIT_HLIST_HEAD(&bat_priv->mcast.want_all_ipv4_list); diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index d31e7ec..673a22e 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -706,8 +706,8 @@ struct batadv_priv_debug_log {
/** * struct batadv_priv_gw - per mesh interface gateway data - * @list: list of available gateway nodes - * @list_lock: lock protecting gw_list & curr_gw + * @gateway_list: list of available gateway nodes + * @list_lock: lock protecting gateway_list & curr_gw * @curr_gw: pointer to currently selected gateway node * @mode: gateway operation: off, client or server (see batadv_gw_modes) * @sel_class: gateway selection class (applies if gw_mode client) @@ -716,8 +716,8 @@ struct batadv_priv_debug_log { * @reselect: bool indicating a gateway re-selection is in progress */ struct batadv_priv_gw { - struct hlist_head list; - spinlock_t list_lock; /* protects gw_list & curr_gw */ + struct hlist_head gateway_list; + spinlock_t list_lock; /* protects gateway_list & curr_gw */ struct batadv_gw_node __rcu *curr_gw; /* rcu protected pointer */ atomic_t mode; atomic_t sel_class;
From: Sven Eckelmann sven@narfation.org
Linus prefers to have octal permission numbers instead of combinations of macro names ("random line noise"). Also old existing "bad symbolic permission bit macro use" should be converted to octal numbers. (http://lkml.kernel.org/r/CA+55aFw5v23T-zvDZp-MmD_EYxF8WbafwwB59934FV7g21uMGQ...)
Also remove the S_IFREG bit from the octal representation because it is filtered out by debugfs_create.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/debugfs.c | 26 ++++++++++---------- net/batman-adv/icmp_socket.c | 5 ++-- net/batman-adv/log.c | 4 +--- net/batman-adv/network-coding.c | 8 +++---- net/batman-adv/sysfs.c | 53 ++++++++++++++++++----------------------- 5 files changed, 41 insertions(+), 55 deletions(-)
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index b4ffba7..7792550 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c @@ -186,7 +186,7 @@ struct batadv_debuginfo batadv_debuginfo_##_name = { \ /* the following attributes are general and therefore they will be directly * placed in the BATADV_DEBUGFS_SUBDIR subdirectory of debugfs */ -static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); +static BATADV_DEBUGINFO(routing_algos, 0444, batadv_algorithms_open);
static struct batadv_debuginfo *batadv_general_debuginfos[] = { &batadv_debuginfo_routing_algos, @@ -194,26 +194,24 @@ static struct batadv_debuginfo *batadv_general_debuginfos[] = { };
/* The following attributes are per soft interface */ -static BATADV_DEBUGINFO(neighbors, S_IRUGO, neighbors_open); -static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); -static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); -static BATADV_DEBUGINFO(transtable_global, S_IRUGO, - batadv_transtable_global_open); +static BATADV_DEBUGINFO(neighbors, 0444, neighbors_open); +static BATADV_DEBUGINFO(originators, 0444, batadv_originators_open); +static BATADV_DEBUGINFO(gateways, 0444, batadv_gateways_open); +static BATADV_DEBUGINFO(transtable_global, 0444, batadv_transtable_global_open); #ifdef CONFIG_BATMAN_ADV_BLA -static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open); -static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO, +static BATADV_DEBUGINFO(bla_claim_table, 0444, batadv_bla_claim_table_open); +static BATADV_DEBUGINFO(bla_backbone_table, 0444, batadv_bla_backbone_table_open); #endif #ifdef CONFIG_BATMAN_ADV_DAT -static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open); +static BATADV_DEBUGINFO(dat_cache, 0444, batadv_dat_cache_open); #endif -static BATADV_DEBUGINFO(transtable_local, S_IRUGO, - batadv_transtable_local_open); +static BATADV_DEBUGINFO(transtable_local, 0444, batadv_transtable_local_open); #ifdef CONFIG_BATMAN_ADV_NC -static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open); +static BATADV_DEBUGINFO(nc_nodes, 0444, batadv_nc_nodes_open); #endif #ifdef CONFIG_BATMAN_ADV_MCAST -static BATADV_DEBUGINFO(mcast_flags, S_IRUGO, batadv_mcast_flags_open); +static BATADV_DEBUGINFO(mcast_flags, 0444, batadv_mcast_flags_open); #endif
static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { @@ -253,7 +251,7 @@ struct batadv_debuginfo batadv_hardif_debuginfo_##_name = { \ }, \ }
-static BATADV_HARDIF_DEBUGINFO(originators, S_IRUGO, +static BATADV_HARDIF_DEBUGINFO(originators, 0444, batadv_originators_hardif_open);
static struct batadv_debuginfo *batadv_hardif_debuginfos[] = { diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index 378cc11..b310f381a 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -38,7 +38,6 @@ #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/spinlock.h> -#include <linux/stat.h> #include <linux/stddef.h> #include <linux/string.h> #include <linux/uaccess.h> @@ -322,8 +321,8 @@ int batadv_socket_setup(struct batadv_priv *bat_priv) if (!bat_priv->debug_dir) goto err;
- d = debugfs_create_file(BATADV_ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, - bat_priv->debug_dir, bat_priv, &batadv_fops); + d = debugfs_create_file(BATADV_ICMP_SOCKET, 0600, bat_priv->debug_dir, + bat_priv, &batadv_fops); if (!d) goto err;
diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c index 56dc532..c73c317 100644 --- a/net/batman-adv/log.c +++ b/net/batman-adv/log.c @@ -31,7 +31,6 @@ #include <linux/sched.h> /* for linux/wait.h */ #include <linux/slab.h> #include <linux/spinlock.h> -#include <linux/stat.h> #include <linux/stddef.h> #include <linux/types.h> #include <linux/uaccess.h> @@ -212,8 +211,7 @@ int batadv_debug_log_setup(struct batadv_priv *bat_priv) spin_lock_init(&bat_priv->debug_log->lock); init_waitqueue_head(&bat_priv->debug_log->queue_wait);
- d = debugfs_create_file("log", S_IFREG | S_IRUSR, - bat_priv->debug_dir, bat_priv, + d = debugfs_create_file("log", 0400, bat_priv->debug_dir, bat_priv, &batadv_log_fops); if (!d) goto err; diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index e3baf69..c213dde 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -44,7 +44,6 @@ #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/spinlock.h> -#include <linux/stat.h> #include <linux/stddef.h> #include <linux/string.h> #include <linux/workqueue.h> @@ -1961,17 +1960,16 @@ int batadv_nc_init_debugfs(struct batadv_priv *bat_priv) if (!nc_dir) goto out;
- file = debugfs_create_u8("min_tq", S_IRUGO | S_IWUSR, nc_dir, - &bat_priv->nc.min_tq); + file = debugfs_create_u8("min_tq", 0644, nc_dir, &bat_priv->nc.min_tq); if (!file) goto out;
- file = debugfs_create_u32("max_fwd_delay", S_IRUGO | S_IWUSR, nc_dir, + file = debugfs_create_u32("max_fwd_delay", 0644, nc_dir, &bat_priv->nc.max_fwd_delay); if (!file) goto out;
- file = debugfs_create_u32("max_buffer_time", S_IRUGO | S_IWUSR, nc_dir, + file = debugfs_create_u32("max_buffer_time", 0644, nc_dir, &bat_priv->nc.max_buffer_time); if (!file) goto out; diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index 02d96f2..17c8441 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c @@ -33,7 +33,6 @@ #include <linux/rcupdate.h> #include <linux/rtnetlink.h> #include <linux/slab.h> -#include <linux/stat.h> #include <linux/stddef.h> #include <linux/string.h> #include <linux/stringify.h> @@ -666,41 +665,36 @@ static ssize_t batadv_store_isolation_mark(struct kobject *kobj, return count; }
-BATADV_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL); -BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL); +BATADV_ATTR_SIF_BOOL(aggregated_ogms, 0644, NULL); +BATADV_ATTR_SIF_BOOL(bonding, 0644, NULL); #ifdef CONFIG_BATMAN_ADV_BLA -BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, - batadv_bla_status_update); +BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, 0644, batadv_bla_status_update); #endif #ifdef CONFIG_BATMAN_ADV_DAT -BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR, - batadv_dat_status_update); +BATADV_ATTR_SIF_BOOL(distributed_arp_table, 0644, batadv_dat_status_update); #endif -BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); -static BATADV_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL); -static BATADV_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode, - batadv_store_gw_mode); -BATADV_ATTR_SIF_UINT(orig_interval, orig_interval, S_IRUGO | S_IWUSR, - 2 * BATADV_JITTER, INT_MAX, NULL); -BATADV_ATTR_SIF_UINT(hop_penalty, hop_penalty, S_IRUGO | S_IWUSR, 0, - BATADV_TQ_MAX_VALUE, NULL); -static BATADV_ATTR(gw_sel_class, S_IRUGO | S_IWUSR, batadv_show_gw_sel_class, +BATADV_ATTR_SIF_BOOL(fragmentation, 0644, batadv_update_min_mtu); +static BATADV_ATTR(routing_algo, 0444, batadv_show_bat_algo, NULL); +static BATADV_ATTR(gw_mode, 0644, batadv_show_gw_mode, batadv_store_gw_mode); +BATADV_ATTR_SIF_UINT(orig_interval, orig_interval, 0644, 2 * BATADV_JITTER, + INT_MAX, NULL); +BATADV_ATTR_SIF_UINT(hop_penalty, hop_penalty, 0644, 0, BATADV_TQ_MAX_VALUE, + NULL); +static BATADV_ATTR(gw_sel_class, 0644, batadv_show_gw_sel_class, batadv_store_gw_sel_class); -static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, +static BATADV_ATTR(gw_bandwidth, 0644, batadv_show_gw_bwidth, batadv_store_gw_bwidth); #ifdef CONFIG_BATMAN_ADV_MCAST -BATADV_ATTR_SIF_BOOL(multicast_mode, S_IRUGO | S_IWUSR, NULL); +BATADV_ATTR_SIF_BOOL(multicast_mode, 0644, NULL); #endif #ifdef CONFIG_BATMAN_ADV_DEBUG -BATADV_ATTR_SIF_UINT(log_level, log_level, S_IRUGO | S_IWUSR, 0, - BATADV_DBG_ALL, NULL); +BATADV_ATTR_SIF_UINT(log_level, log_level, 0644, 0, BATADV_DBG_ALL, NULL); #endif #ifdef CONFIG_BATMAN_ADV_NC -BATADV_ATTR_SIF_BOOL(network_coding, S_IRUGO | S_IWUSR, - batadv_nc_status_update); +BATADV_ATTR_SIF_BOOL(network_coding, 0644, batadv_nc_status_update); #endif -static BATADV_ATTR(isolation_mark, S_IRUGO | S_IWUSR, - batadv_show_isolation_mark, batadv_store_isolation_mark); +static BATADV_ATTR(isolation_mark, 0644, batadv_show_isolation_mark, + batadv_store_isolation_mark);
static struct batadv_attribute *batadv_mesh_attrs[] = { &batadv_attr_aggregated_ogms, @@ -731,7 +725,7 @@ static struct batadv_attribute *batadv_mesh_attrs[] = { NULL, };
-BATADV_ATTR_VLAN_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); +BATADV_ATTR_VLAN_BOOL(ap_isolation, 0644, NULL);
/* array of vlan specific sysfs attributes */ static struct batadv_attribute *batadv_vlan_attrs[] = { @@ -1116,14 +1110,13 @@ static ssize_t batadv_show_throughput_override(struct kobject *kobj,
#endif
-static BATADV_ATTR(mesh_iface, S_IRUGO | S_IWUSR, batadv_show_mesh_iface, +static BATADV_ATTR(mesh_iface, 0644, batadv_show_mesh_iface, batadv_store_mesh_iface); -static BATADV_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL); +static BATADV_ATTR(iface_status, 0444, batadv_show_iface_status, NULL); #ifdef CONFIG_BATMAN_ADV_BATMAN_V -BATADV_ATTR_HIF_UINT(elp_interval, bat_v.elp_interval, S_IRUGO | S_IWUSR, +BATADV_ATTR_HIF_UINT(elp_interval, bat_v.elp_interval, 0644, 2 * BATADV_JITTER, INT_MAX, NULL); -static BATADV_ATTR(throughput_override, S_IRUGO | S_IWUSR, - batadv_show_throughput_override, +static BATADV_ATTR(throughput_override, 0644, batadv_show_throughput_override, batadv_store_throughput_override); #endif
From: Sven Eckelmann sven@narfation.org
It must be avoided that arguments to a macro are evaluated ungrouped (which enforces normal operator precendence). Otherwise the result of the macro is not well defined.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de --- net/batman-adv/log.h | 12 ++++++------ net/batman-adv/main.h | 4 ++-- net/batman-adv/packet.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h index e0e1a88..ab47acf 100644 --- a/net/batman-adv/log.h +++ b/net/batman-adv/log.h @@ -71,12 +71,12 @@ int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) __printf(2, 3);
/* possibly ratelimited debug output */ -#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \ - do { \ - if (atomic_read(&bat_priv->log_level) & type && \ - (!ratelimited || net_ratelimit())) \ - batadv_debug_log(bat_priv, fmt, ## arg);\ - } \ +#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \ + do { \ + if (atomic_read(&(bat_priv)->log_level) & (type) && \ + (!(ratelimited) || net_ratelimit())) \ + batadv_debug_log(bat_priv, fmt, ## arg); \ + } \ while (0) #else /* !CONFIG_BATMAN_ADV_DEBUG */ __printf(4, 5) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 6a2328d..daddca9 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -199,8 +199,8 @@ struct packet_type; struct seq_file; struct sk_buff;
-#define BATADV_PRINT_VID(vid) ((vid & BATADV_VLAN_HAS_TAG) ? \ - (int)(vid & VLAN_VID_MASK) : -1) +#define BATADV_PRINT_VID(vid) (((vid) & BATADV_VLAN_HAS_TAG) ? \ + (int)((vid) & VLAN_VID_MASK) : -1)
extern struct list_head batadv_hardif_list;
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index d2e9bbd..7a36bcf 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -21,7 +21,7 @@ #include <asm/byteorder.h> #include <linux/types.h>
-#define batadv_tp_is_error(n) ((u8)n > 127 ? 1 : 0) +#define batadv_tp_is_error(n) ((u8)(n) > 127 ? 1 : 0)
/** * enum batadv_packettype - types for batman-adv encapsulated packets
On Thu, 2016-10-27 at 21:01 +0200, Simon Wunderlich wrote:
From: Sven Eckelmann sven@narfation.org
It must be avoided that arguments to a macro are evaluated ungrouped (which enforces normal operator precendence). Otherwise the result of the macro is not well defined.
Curiosity:
in net/batman-adv/tp_meter.c
static int batadv_tp_send(void *arg) { struct batadv_tp_vars *tp_vars = arg; struct batadv_priv *bat_priv = tp_vars->bat_priv; struct batadv_hard_iface *primary_if = NULL; struct batadv_orig_node *orig_node = NULL; size_t payload_len, packet_len; int err = 0;
if (unlikely(tp_vars->role != BATADV_TP_SENDER)) { err = BATADV_TP_REASON_DST_UNREACHABLE; tp_vars->reason = err; goto out; }
orig_node = batadv_orig_hash_find(bat_priv, tp_vars->other_end); if (unlikely(!orig_node)) { err = BATADV_TP_REASON_DST_UNREACHABLE; tp_vars->reason = err; goto out; }
primary_if = batadv_primary_if_get_selected(bat_priv); if (unlikely(!primary_if)) { err = BATADV_TP_REASON_DST_UNREACHABLE; goto out; }
err is not used in the out block
Is the last if block supposed to set tp_vars->reason to err?
On Freitag, 28. Oktober 2016 14:13:06 CEST Joe Perches wrote:
On Thu, 2016-10-27 at 21:01 +0200, Simon Wunderlich wrote:
From: Sven Eckelmann sven@narfation.org
It must be avoided that arguments to a macro are evaluated ungrouped (which enforces normal operator precendence). Otherwise the result of the macro is not well defined.
Curiosity:
in net/batman-adv/tp_meter.c
[...]
orig_node = batadv_orig_hash_find(bat_priv, tp_vars->other_end); if (unlikely(!orig_node)) { err = BATADV_TP_REASON_DST_UNREACHABLE; tp_vars->reason = err; goto out; }
primary_if = batadv_primary_if_get_selected(bat_priv); if (unlikely(!primary_if)) { err = BATADV_TP_REASON_DST_UNREACHABLE; goto out; }
err is not used in the out block
Is the last if block supposed to set tp_vars->reason to err?
This seems to be unrelated to this patch.
But yes, looks to me like it is missing. Do you want to propose a patch or should I do? Just make sure you Cc Antonio Quartulli a@unstable.cc (and of course b.a.t.m.a.n@lists.open-mesh.org). He is the original author of 33a3bb4a3345 ("batman-adv: throughput meter implementation").
Kind regards, Sven
On Fri, 2016-10-28 at 23:27 +0200, Sven Eckelmann wrote:
On Freitag, 28. Oktober 2016 14:13:06 CEST Joe Perches wrote:
On Thu, 2016-10-27 at 21:01 +0200, Simon Wunderlich wrote:
From: Sven Eckelmann sven@narfation.org
It must be avoided that arguments to a macro are evaluated ungrouped (which enforces normal operator precendence). Otherwise the result of the macro is not well defined.
Curiosity:
in net/batman-adv/tp_meter.c
[...]
orig_node = batadv_orig_hash_find(bat_priv, tp_vars->other_end); if (unlikely(!orig_node)) { err = BATADV_TP_REASON_DST_UNREACHABLE; tp_vars->reason = err; goto out; }
primary_if = batadv_primary_if_get_selected(bat_priv); if (unlikely(!primary_if)) { err = BATADV_TP_REASON_DST_UNREACHABLE; goto out; }
err is not used in the out block
Is the last if block supposed to set tp_vars->reason to err?
This seems to be unrelated to this patch.
Kinda. I was looking at how the one instance of batadv_tp_is_error was used and it's in this file.
But yes, looks to me like it is missing. Do you want to propose a patch or should I do?
As you are working on this file, perhaps you should.
cheers, Joe
On Freitag, 28. Oktober 2016 18:56:24 CEST Joe Perches wrote: [...]
But yes, looks to me like it is missing. Do you want to propose a patch or should I do?
As you are working on this file, perhaps you should.
Ok, I will submit a patch with you as Reported-by to the batman-adv mailing list
Kind regards, Sven
From: Simon Wunderlich sw@simonwunderlich.de Date: Thu, 27 Oct 2016 21:01:33 +0200
this is our first feature pull request for batman-adv (mostly containing code cleanup stuff), there are at least two more to come.
Please pull or let me know of any problem!
Pulled, thanks Simon.
b.a.t.m.a.n@lists.open-mesh.org