* [B.A.T.M.A.N.] [PATCHv2 maint 0/4] batman-adv: Fix broken capability checks
@ 2015-07-03 16:29 Linus Lüssing
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check Linus Lüssing
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Linus Lüssing @ 2015-07-03 16:29 UTC (permalink / raw)
To: b.a.t.m.a.n
Hi,
Here are fixes for the bugs introduced by the last fixes to the capability
checks.
Cheers, Linus
PS: For internal things where the bit position isn't important (as in this
case), I think doing a "= BIT(x)" assignments only adds noise. For packet
format things where the bit position is more interesting, it might be good
to keep "= BIT(x)" as it gives O(1) access to the organic reader ;).
~~~~~
Changelog v2:
* Split into 4 individual patches
* Using test_bit() instead of BIT()
^ permalink raw reply [flat|nested] 9+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check
2015-07-03 16:29 [B.A.T.M.A.N.] [PATCHv2 maint 0/4] batman-adv: Fix broken capability checks Linus Lüssing
@ 2015-07-03 16:29 ` Linus Lüssing
2015-07-07 8:41 ` Marek Lindner
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 2/4] batman-adv: Fix broken NC " Linus Lüssing
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Linus Lüssing @ 2015-07-03 16:29 UTC (permalink / raw)
To: b.a.t.m.a.n
The introduction of set_bit() and clear_bit() calls in batman-adv
wrongly passed bitmasks and not the bit numbers to these functions.
This leads to broken capability checks.
Fixing this by making the capability enum a non-bitmasked one and by
that passing non-masked values to set_bit()/clear_bit().
Fixes: bfd0fbaef270 ("batman-adv: Make DAT capability changes atomic")
Reported-by: Def <def@laposte.net>
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
distributed-arp-table.c | 2 +-
types.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index b2cc19b..c0c514d 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -422,7 +422,7 @@ static bool batadv_is_orig_node_eligible(struct batadv_dat_candidate *res,
int j;
/* check if orig node candidate is running DAT */
- if (!(candidate->capabilities & BATADV_ORIG_CAPA_HAS_DAT))
+ if (!(test_bit(BATADV_ORIG_CAPA_HAS_DAT, &candidate->capabilities)))
goto out;
/* Check if this node has already been selected... */
diff --git a/types.h b/types.h
index 65dc6bf..08a6343 100644
--- a/types.h
+++ b/types.h
@@ -299,7 +299,7 @@ struct batadv_orig_node {
* (= orig node announces a tvlv of type BATADV_TVLV_MCAST)
*/
enum batadv_orig_capabilities {
- BATADV_ORIG_CAPA_HAS_DAT = BIT(0),
+ BATADV_ORIG_CAPA_HAS_DAT,
BATADV_ORIG_CAPA_HAS_NC = BIT(1),
BATADV_ORIG_CAPA_HAS_TT = BIT(2),
BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2 maint 2/4] batman-adv: Fix broken NC capability check
2015-07-03 16:29 [B.A.T.M.A.N.] [PATCHv2 maint 0/4] batman-adv: Fix broken capability checks Linus Lüssing
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check Linus Lüssing
@ 2015-07-03 16:29 ` Linus Lüssing
2015-07-07 8:45 ` Marek Lindner
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 3/4] batman-adv: Fix broken TT " Linus Lüssing
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 4/4] batman-adv: Fix broken MCAST " Linus Lüssing
3 siblings, 1 reply; 9+ messages in thread
From: Linus Lüssing @ 2015-07-03 16:29 UTC (permalink / raw)
To: b.a.t.m.a.n
The introduction of set_bit() and clear_bit() calls in batman-adv
wrongly passed bitmasks and not the bit numbers to these functions.
This leads to broken capability checks.
Fixing this by making the capability enum a non-bitmasked one and by
that passing non-masked values to set_bit()/clear_bit().
Fixes: 586df9e2537b ("batman-adv: Make NC capability changes atomic")
Reported-by: Def <def@laposte.net>
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
network-coding.c | 2 +-
types.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/network-coding.c b/network-coding.c
index 3ce493e..0309c2c 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -871,7 +871,7 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,
goto out;
/* check if orig node is network coding enabled */
- if (!(orig_node->capabilities & BATADV_ORIG_CAPA_HAS_NC))
+ if (!(test_bit(BATADV_ORIG_CAPA_HAS_NC, &orig_node->capabilities)))
goto out;
/* accept ogms from 'good' neighbors and single hop neighbors */
diff --git a/types.h b/types.h
index 08a6343..cb7ccb1 100644
--- a/types.h
+++ b/types.h
@@ -300,7 +300,7 @@ struct batadv_orig_node {
*/
enum batadv_orig_capabilities {
BATADV_ORIG_CAPA_HAS_DAT,
- BATADV_ORIG_CAPA_HAS_NC = BIT(1),
+ BATADV_ORIG_CAPA_HAS_NC,
BATADV_ORIG_CAPA_HAS_TT = BIT(2),
BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
};
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2 maint 3/4] batman-adv: Fix broken TT capability check
2015-07-03 16:29 [B.A.T.M.A.N.] [PATCHv2 maint 0/4] batman-adv: Fix broken capability checks Linus Lüssing
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check Linus Lüssing
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 2/4] batman-adv: Fix broken NC " Linus Lüssing
@ 2015-07-03 16:29 ` Linus Lüssing
2015-07-07 8:46 ` Marek Lindner
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 4/4] batman-adv: Fix broken MCAST " Linus Lüssing
3 siblings, 1 reply; 9+ messages in thread
From: Linus Lüssing @ 2015-07-03 16:29 UTC (permalink / raw)
To: b.a.t.m.a.n
The introduction of set_bit() and clear_bit() calls in batman-adv
wrongly passed bitmasks and not the bit numbers to these functions.
This leads to broken capability checks.
Fixing this by making the capability enum a non-bitmasked one and by
that passing non-masked values to set_bit()/clear_bit().
Fixes: a51fa16ecf3f ("batman-adv: Make TT capability changes atomic")
Reported-by: Def <def@laposte.net>
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
translation-table.c | 3 ++-
types.h | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index b6c0f52..d73b103 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -3323,7 +3323,8 @@ static void batadv_tt_update_orig(struct batadv_priv *bat_priv,
bool has_tt_init;
tt_vlan = (struct batadv_tvlv_tt_vlan_data *)tt_buff;
- has_tt_init = orig_node->capa_initialized & BATADV_ORIG_CAPA_HAS_TT;
+ has_tt_init = test_bit(BATADV_ORIG_CAPA_HAS_TT,
+ &orig_node->capa_initialized);
/* orig table not initialised AND first diff is in the OGM OR the ttvn
* increased by one -> we can apply the attached changes
diff --git a/types.h b/types.h
index cb7ccb1..6f4486c 100644
--- a/types.h
+++ b/types.h
@@ -301,7 +301,7 @@ struct batadv_orig_node {
enum batadv_orig_capabilities {
BATADV_ORIG_CAPA_HAS_DAT,
BATADV_ORIG_CAPA_HAS_NC,
- BATADV_ORIG_CAPA_HAS_TT = BIT(2),
+ BATADV_ORIG_CAPA_HAS_TT,
BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
};
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2 maint 4/4] batman-adv: Fix broken MCAST capability check
2015-07-03 16:29 [B.A.T.M.A.N.] [PATCHv2 maint 0/4] batman-adv: Fix broken capability checks Linus Lüssing
` (2 preceding siblings ...)
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 3/4] batman-adv: Fix broken TT " Linus Lüssing
@ 2015-07-03 16:29 ` Linus Lüssing
2015-07-07 8:48 ` Marek Lindner
3 siblings, 1 reply; 9+ messages in thread
From: Linus Lüssing @ 2015-07-03 16:29 UTC (permalink / raw)
To: b.a.t.m.a.n
The introduction of set_bit() and clear_bit() calls in batman-adv
wrongly passed bitmasks and not the bit numbers to these functions.
This leads to broken capability checks.
Fixing this by making the capability enum a non-bitmasked one and by
that passing non-masked values to set_bit()/clear_bit().
Fixes: 201a54ba710a ("batman-adv: Make MCAST capability changes atomic")
Reported-by: Def <def@laposte.net>
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
multicast.c | 11 ++++++-----
types.h | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/multicast.c b/multicast.c
index b75bcc3..ee8317f 100644
--- a/multicast.c
+++ b/multicast.c
@@ -709,14 +709,15 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
mcast_flags = *(uint8_t *)tvlv_value;
spin_lock_bh(&orig->mcast_handler_lock);
- orig_initialized = orig->capa_initialized & BATADV_ORIG_CAPA_HAS_MCAST;
+ orig_initialized = test_bit(BATADV_ORIG_CAPA_HAS_MCAST,
+ &orig->capa_initialized);
/* If mcast support is turned on decrease the disabled mcast node
* counter only if we had increased it for this node before. If this
* is a completely new orig_node no need to decrease the counter.
*/
if (orig_mcast_enabled &&
- !(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST)) {
+ !(test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities))) {
if (orig_initialized)
atomic_dec(&bat_priv->mcast.num_disabled);
set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities);
@@ -725,7 +726,7 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
* node counter.
*/
} else if (!orig_mcast_enabled &&
- (orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST ||
+ (test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities) ||
!orig_initialized)) {
atomic_inc(&bat_priv->mcast.num_disabled);
clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities);
@@ -774,8 +775,8 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig)
spin_lock_bh(&orig->mcast_handler_lock);
- if (!(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST) &&
- orig->capa_initialized & BATADV_ORIG_CAPA_HAS_MCAST)
+ if (!(test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) &&
+ test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capa_initialized))
atomic_dec(&bat_priv->mcast.num_disabled);
batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS);
diff --git a/types.h b/types.h
index 6f4486c..3baf595 100644
--- a/types.h
+++ b/types.h
@@ -302,7 +302,7 @@ enum batadv_orig_capabilities {
BATADV_ORIG_CAPA_HAS_DAT,
BATADV_ORIG_CAPA_HAS_NC,
BATADV_ORIG_CAPA_HAS_TT,
- BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
+ BATADV_ORIG_CAPA_HAS_MCAST,
};
/**
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check Linus Lüssing
@ 2015-07-07 8:41 ` Marek Lindner
0 siblings, 0 replies; 9+ messages in thread
From: Marek Lindner @ 2015-07-07 8:41 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 736 bytes --]
On Friday, July 03, 2015 18:29:56 Linus Lüssing wrote:
> The introduction of set_bit() and clear_bit() calls in batman-adv
> wrongly passed bitmasks and not the bit numbers to these functions.
> This leads to broken capability checks.
>
> Fixing this by making the capability enum a non-bitmasked one and by
> that passing non-masked values to set_bit()/clear_bit().
>
> Fixes: bfd0fbaef270 ("batman-adv: Make DAT capability changes atomic")
> Reported-by: Def <def@laposte.net>
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---
> distributed-arp-table.c | 2 +-
> types.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
Applied in revision de46667.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2 maint 2/4] batman-adv: Fix broken NC capability check
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 2/4] batman-adv: Fix broken NC " Linus Lüssing
@ 2015-07-07 8:45 ` Marek Lindner
0 siblings, 0 replies; 9+ messages in thread
From: Marek Lindner @ 2015-07-07 8:45 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 721 bytes --]
On Friday, July 03, 2015 18:29:57 Linus Lüssing wrote:
> The introduction of set_bit() and clear_bit() calls in batman-adv
> wrongly passed bitmasks and not the bit numbers to these functions.
> This leads to broken capability checks.
>
> Fixing this by making the capability enum a non-bitmasked one and by
> that passing non-masked values to set_bit()/clear_bit().
>
> Fixes: 586df9e2537b ("batman-adv: Make NC capability changes atomic")
> Reported-by: Def <def@laposte.net>
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---
> network-coding.c | 2 +-
> types.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
Applied in revision 188ac4f.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2 maint 3/4] batman-adv: Fix broken TT capability check
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 3/4] batman-adv: Fix broken TT " Linus Lüssing
@ 2015-07-07 8:46 ` Marek Lindner
0 siblings, 0 replies; 9+ messages in thread
From: Marek Lindner @ 2015-07-07 8:46 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 728 bytes --]
On Friday, July 03, 2015 18:29:58 Linus Lüssing wrote:
> The introduction of set_bit() and clear_bit() calls in batman-adv
> wrongly passed bitmasks and not the bit numbers to these functions.
> This leads to broken capability checks.
>
> Fixing this by making the capability enum a non-bitmasked one and by
> that passing non-masked values to set_bit()/clear_bit().
>
> Fixes: a51fa16ecf3f ("batman-adv: Make TT capability changes atomic")
> Reported-by: Def <def@laposte.net>
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---
> translation-table.c | 3 ++-
> types.h | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
Applied in revision a4824ff.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2 maint 4/4] batman-adv: Fix broken MCAST capability check
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 4/4] batman-adv: Fix broken MCAST " Linus Lüssing
@ 2015-07-07 8:48 ` Marek Lindner
0 siblings, 0 replies; 9+ messages in thread
From: Marek Lindner @ 2015-07-07 8:48 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 723 bytes --]
On Friday, July 03, 2015 18:29:59 Linus Lüssing wrote:
> The introduction of set_bit() and clear_bit() calls in batman-adv
> wrongly passed bitmasks and not the bit numbers to these functions.
> This leads to broken capability checks.
>
> Fixing this by making the capability enum a non-bitmasked one and by
> that passing non-masked values to set_bit()/clear_bit().
>
> Fixes: 201a54ba710a ("batman-adv: Make MCAST capability changes atomic")
> Reported-by: Def <def@laposte.net>
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---
> multicast.c | 11 ++++++-----
> types.h | 2 +-
> 2 files changed, 7 insertions(+), 6 deletions(-)
Applied in revision 1798ad3.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-07-07 8:48 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-03 16:29 [B.A.T.M.A.N.] [PATCHv2 maint 0/4] batman-adv: Fix broken capability checks Linus Lüssing
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check Linus Lüssing
2015-07-07 8:41 ` Marek Lindner
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 2/4] batman-adv: Fix broken NC " Linus Lüssing
2015-07-07 8:45 ` Marek Lindner
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 3/4] batman-adv: Fix broken TT " Linus Lüssing
2015-07-07 8:46 ` Marek Lindner
2015-07-03 16:29 ` [B.A.T.M.A.N.] [PATCHv2 maint 4/4] batman-adv: Fix broken MCAST " Linus Lüssing
2015-07-07 8:48 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).