[B.A.T.M.A.N.] [PATCH v2 1/4] batman-adv: Return EINVAL on invalid gw_bandwidth change
by Sven Eckelmann
Invalid speed settings by the user are currently acknowledged as correct
but not stored. Instead the return of the store operation of the file
"gw_bandwidth" should indicate that the given value is not acceptable.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
v2:
* rebased on current master
* add missing header linux/errno.h
net/batman-adv/gateway_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c
index c50931c..6b930a6 100644
--- a/net/batman-adv/gateway_common.c
+++ b/net/batman-adv/gateway_common.c
@@ -19,6 +19,7 @@
#include "main.h"
#include <linux/atomic.h>
+#include <linux/errno.h>
#include <linux/byteorder/generic.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
@@ -160,7 +161,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
ret = batadv_parse_gw_bandwidth(net_dev, buff, &down_new, &up_new);
if (!ret)
- goto end;
+ return -EINVAL;
if (!down_new)
down_new = 1;
@@ -184,7 +185,6 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
atomic_set(&bat_priv->gw.bandwidth_up, up_new);
batadv_gw_tvlv_container_update(bat_priv);
-end:
return count;
}
--
2.1.4
6 years, 12 months
[B.A.T.M.A.N.] [PATCHv2 maint 0/4] batman-adv: Fix broken capability checks
by Linus Lüssing
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()
7 years
[B.A.T.M.A.N.] [PATCHv10 0/4] Multicast optimizations for bridges
by Linus Lüssing
This patchset enables the usage of the batman-adv multicast optimizations
for scenarios involving bridges on top of e.g. bat0, too.
The first one alters the forwarding behaviour for IGMP and MLD reports
which is a prerequisite before enabling multicast optimizations in
bridged setups. It also increases the MCAST TVLV version number to 2.
More on the issue of insufficient report handling with the v1
MCAST TVLV can be found here:
http://www.open-mesh.org/projects/batman-adv/wiki/Multicast-optimizations...
The second patch finally enables the multicast optimizations for
bridged setups.
Along come two more patches adding according debugging facilities
to make it possible for the user to check why the multicast
optimizations might not work ideally to give hints about
what they might change about their topology.
This patchset can be found in the current linus/multicast-bridge
branch.
Cheers, Linus
-----
This patchset is based on master plus the currently pending,
multicast related patches for maint.
As always, thanks for the many, valuable feedback!
Changes in v10:
- PATCH 1/4:
* Former "[PATCH 4/4] batman-adv: Forward IGMP/MLD reports to selected querier (only)"
substituted by the interim branch "batman-adv: Always flood IGMP/MLD reports"
with the following changes:
* Increased compatibility to mcast-v1-tvlv nodes by
registering a v1 tvlv container and handler, too
(note: PATCH 2/4 needs to still unregister the handler
if the node is bridged bc. it can't "trust" v1 nodes)
* Removed skb_set_network_header() call
(extra patch pending for review for maint)
* Compared to patchset v9 this substitution makes things
compilable again for kernels < 2.6.35
- PATCH 2/4:
* Moved enum introduction of BATADV_DBG_MCAST to PATCH 3/4,
not needed in PATCH 2/4 yet
* Adjusted compat code to new compat layout
* Adjustments to batadv_mcast_mla_tvlv_update() to fit now
preceding PATCH 1/4
* bat_priv->mcast.bridged flag already introduced here
(instead of in PATCH 3/4) because we need it for the new
mcast-v1-tvlv handling
---
Interim Changlog of
"batman-adv: Always flood IGMP/MLD reports"
v1:
* Removed query snooping and state
* Squashed all three patches into one
* Renamed "batadv_mcast_tvlv_ogm_handler_v1()" to *_v2()
* Added explicit icmpv6.h include
* Rebased on top of master
-----
Interim Interim Changelog of
"batman-adv: Unicasting multicast reports to querier-node only"
v6:
* compat: copied copyright headers from original upstream c files
* compat: unified ordering in compat c files:
-> copyright header, then includes, then kernel specific functions
v5:
* Removed RFC tag: Needed exports got merged to net-next and are going to
be available with Linux 4.2
* Redid compat solution - now fully backwards compatible down to 2.6.33
v4:
* excluded bridge part from this patchset, they should
hopefully be added to net-next soon
* Added a compat solution (PATCH 3/3)
* Removed Kconfig-depends as by David's suggestion the needed parsing
functions for MLD are going to be forced built-ins even if IPv6 is
going to be built as a module
* Removed unused variable 'int ret' in batadv_mcast_is_report_ipv6()
* Adjusted to new folder structure
v3:
* Adding Kconfig-depends and #if's
(so basically adding similar dependancy constraints as the bridge code
has, except that there are no depends if batman-adv gets compiled without
multicast optimizations)
-> the case of IPv6=M and batman-adv=y is still impossible if multicast
optimizations are enabled; but I don't see the practical demand for that
either - people who use IPv6 as a module will probably also want to
use batman-adv as a module
v2:
* various bugfixes (now runtime tested, too - should(tm) work)
* added netdev+bridge mailinglists
-----
---
Changes in v9:
- PATCH 1/4:
* fix: added compat code for pr_warn_once()
* compat fix for bridge export stubs: fixes compile error
with kernels < 3.16 without bridge (snooping) support
- PATCH 2/4:
* perform updates of variables within bat_priv->mcast.querier_ipv{4,6}
individually (there's a new, third member in 4/4 which shouldn't be
overriden)
* PATCH 4/4: NEW
Changes in v8 (thanks to Simon's suggestions):
- PATCH 2/3:
* print shadowing status log of an appearing and shadowing querier, too
(the bridge-querier-existence call has an additional 10s delay
to ensure reports had their time to arrive -
the bridge-querier-port call doesn't have that)
- PATCH 3/3:
* changing debugfs output from "+" and "-" to "U/4/6" and "."
* fixing "no querier present" logic (introduced in [PATCHv7 3/3])
Changes in v7 (thanks to Simon's suggestions):
- PATCH 2/3:
* renaming old/new_querier to old/new_state
* slightly extended kerneldoc of batadv_mcast_querier_log()
* removing words "good" and "bad" from debug output
* simplified batadv_mcast_flags_log()
* assignment instead of memset in batadv_mcast_mla_tvlv_update()
and batadv_softif_init_late()
* simple struct member assignments instead of one complex struct
assigment
* removing unnecessary memcmp's
* substituting return statement for an if-block in
batadv_mcast_querier_log() and batadv_mcast_bridge_log()
* print "Unsnoopables(U)-flag" instead of just "U-flag"
- PATCH 3/3:
* use bat_priv values instead of querying bridge ABI in
batadv_mcast_flags_print_header()
Changes in v6:
* New PATCH 2/3 inserted, moving logging to separate patch
* More verbose logging added to PATCH 2/3:
Bridge and querier state changes are logged too
* upper case to lower case for kernel doc of batadv_mcast_flags_open
(PATCH 2/3)
* Adding note to kernel doc of batadv_mcast_get_bridge about
increased refcount (PATCH 1/3)
* Printing some lines about current bridge and querier state to
debugfs too (PATCH 3/3)
Changes in v5 (PATCH 2/2 only):
* s/dat_cache/mcast_flags/ in kerneldoc (copy&paste error)
Changes in v4 (PATCH 2/2 only):
* initial {ad,e}dition of this patch
Changes in v3 (PATCH 1/2 only):
* Removed "RFC" tag in title again: The stubs and new export are upstream
in net-next and therefore going to be included in 3.17
* Added some debug output:
* Two warning messages:
-> Old kernel version or no bridge IGMP/MLD snooping compiled
* New batman-adv log-level "mcast":
-> Logging mcast flag changes
(a third debugging facility, a new table for debugfs for a global
mcast flag overview will be added in a separate patch later
as discussed with Simon)
Changes in v2 (PATCH 1/2 only):
* fetching local (= on this same kernel) multicast listeners from
the bridge instead of the bat0 interface if a bridge is present
- just like ip addresses and routes should be used from br0, the
same goes for multicast listeners
* beautification of batadv_mcast_mla_br_addr_cpy(), now using already
present functions from the kernel instead of own, hackish approach
* changed names of some goto-labels (not using "skip" anymore)
* using new, third bridge multicast export (because this export is
not upstream yet, I've added the "RFC" in the title):
br_multicast_has_querier_anywhere()
* adding compat stubs for two bridge multicast exports, to make
batman-adv compile- and usable even if a 3.16 kernel was compiled
without bridge code - the stubs are supposed to be upstream in the
bridge code in 3.17 (therefore just 'compat')
* updated kerneldocs for batadv_mcast_mla_bridge_get() and
batadv_mcast_mla_softif_get()
* The two sentences in the commit message starting with "Queriers: ..."
were slightly modified to include the third bridge multicast export
7 years
[B.A.T.M.A.N.] [PATCH maint] batman-adv: Fix broken capability checks
by Linus Lüssing
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 in the according features.
Fixing this by making the capability enum a non-bitmasked one and by
that passing non-masked values to set_bit()/clear_bit() while explicitly
masking with BIT() for testing capability presence.
Fixes: bfd0fbaef270 ("batman-adv: Make DAT capability changes atomic")
Fixes: 586df9e2537b ("batman-adv: Make NC capability changes atomic")
Fixes: a51fa16ecf3f ("batman-adv: Make TT capability changes atomic")
Fixes: 201a54ba710a ("batman-adv: Make MCAST capability changes atomic")
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
---
Maybe wait for a desired "Reported-by" name/email in #219.
distributed-arp-table.c | 2 +-
multicast.c | 16 ++++++++--------
network-coding.c | 2 +-
translation-table.c | 3 ++-
types.h | 8 ++++----
5 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index b2cc19b..c663201 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 (!(candidate->capabilities & BIT(BATADV_ORIG_CAPA_HAS_DAT)))
goto out;
/* Check if this node has already been selected... */
diff --git a/multicast.c b/multicast.c
index b75bcc3..5b6a679 100644
--- a/multicast.c
+++ b/multicast.c
@@ -702,22 +702,22 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
{
bool orig_mcast_enabled = !(flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND);
uint8_t mcast_flags = BATADV_NO_FLAGS;
- bool orig_initialized;
+ bool initialized;
if (orig_mcast_enabled && tvlv_value &&
(tvlv_value_len >= sizeof(mcast_flags)))
mcast_flags = *(uint8_t *)tvlv_value;
spin_lock_bh(&orig->mcast_handler_lock);
- orig_initialized = orig->capa_initialized & BATADV_ORIG_CAPA_HAS_MCAST;
+ initialized = orig->capa_initialized & BIT(BATADV_ORIG_CAPA_HAS_MCAST);
/* 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)) {
- if (orig_initialized)
+ !(orig->capabilities & BIT(BATADV_ORIG_CAPA_HAS_MCAST))) {
+ if (initialized)
atomic_dec(&bat_priv->mcast.num_disabled);
set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities);
/* If mcast support is being switched off or if this is an initial
@@ -725,8 +725,8 @@ 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 ||
- !orig_initialized)) {
+ (orig->capabilities & BIT(BATADV_ORIG_CAPA_HAS_MCAST) ||
+ !initialized)) {
atomic_inc(&bat_priv->mcast.num_disabled);
clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities);
}
@@ -774,8 +774,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 (!(orig->capabilities & BIT(BATADV_ORIG_CAPA_HAS_MCAST)) &&
+ orig->capa_initialized & BIT(BATADV_ORIG_CAPA_HAS_MCAST))
atomic_dec(&bat_priv->mcast.num_disabled);
batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS);
diff --git a/network-coding.c b/network-coding.c
index 3ce493e..3690606 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 (!(orig_node->capabilities & BIT(BATADV_ORIG_CAPA_HAS_NC)))
goto out;
/* accept ogms from 'good' neighbors and single hop neighbors */
diff --git a/translation-table.c b/translation-table.c
index b6c0f52..8de5df4 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -3319,11 +3319,12 @@ static void batadv_tt_update_orig(struct batadv_priv *bat_priv,
{
uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn);
struct batadv_tvlv_tt_vlan_data *tt_vlan;
+ unsigned long capa_initialized = orig_node->capa_initialized;
bool full_table = true;
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 = capa_initialized & BIT(BATADV_ORIG_CAPA_HAS_TT);
/* 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 65dc6bf..3baf595 100644
--- a/types.h
+++ b/types.h
@@ -299,10 +299,10 @@ 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_NC = BIT(1),
- BATADV_ORIG_CAPA_HAS_TT = BIT(2),
- BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
+ BATADV_ORIG_CAPA_HAS_DAT,
+ BATADV_ORIG_CAPA_HAS_NC,
+ BATADV_ORIG_CAPA_HAS_TT,
+ BATADV_ORIG_CAPA_HAS_MCAST,
};
/**
--
1.7.10.4
7 years