Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 439030821e5db7241857e3eaebb4263562e5c615
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Mar 5 19:05:24 2016 +0100
batman-adv: Use kref_get for _batadv_update_route
_batadv_update_route requires that the caller already has a valid reference
for neigh_node. It is therefore not possible that it has an reference
counter of 0 and was still given to this function
The kref_get function instead WARNs (with debug information) when the
reference counter would still be 0. This makes a bug in batman-adv better
visible because kref_get_unless_zero would have ignored this problem.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Marek Lindner <mareklindner(a)neomailbox.ch>
>---------------------------------------------------------------
439030821e5db7241857e3eaebb4263562e5c615
net/batman-adv/routing.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 94b4356..ae850f2 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -100,10 +100,6 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
if (curr_router)
batadv_neigh_node_put(curr_router);
- /* increase refcount of new best neighbor */
- if (neigh_node && !kref_get_unless_zero(&neigh_node->refcount))
- neigh_node = NULL;
-
spin_lock_bh(&orig_node->neigh_list_lock);
/* curr_router used earlier may not be the current orig_ifinfo->router
* anymore because it was dereferenced outside of the neigh_list_lock
@@ -114,6 +110,10 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
*/
curr_router = rcu_dereference_protected(orig_ifinfo->router, true);
+ /* increase refcount of new best neighbor */
+ if (neigh_node)
+ kref_get(&neigh_node->refcount);
+
rcu_assign_pointer(orig_ifinfo->router, neigh_node);
spin_unlock_bh(&orig_node->neigh_list_lock);
batadv_orig_ifinfo_put(orig_ifinfo);
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 25a303d311c76f749ccd96a45b458eaf560e6243
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Mar 5 16:09:23 2016 +0100
batman-adv: Use kref_get for batadv_gw_node_add
batadv_gw_node_add requires that the caller already has a valid reference
for orig_node. It is therefore not possible that it has an reference
counter of 0 and was still given to this function
The kref_get function instead WARNs (with debug information) when the
reference counter would still be 0. This makes a bug in batman-adv better
visible because kref_get_unless_zero would have ignored this problem.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Marek Lindner <mareklindner(a)neomailbox.ch>
>---------------------------------------------------------------
25a303d311c76f749ccd96a45b458eaf560e6243
net/batman-adv/gateway_client.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index bb1c4f3..5839c56 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -440,15 +440,11 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
if (gateway->bandwidth_down == 0)
return;
- if (!kref_get_unless_zero(&orig_node->refcount))
- return;
-
gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC);
- if (!gw_node) {
- batadv_orig_node_put(orig_node);
+ if (!gw_node)
return;
- }
+ kref_get(&orig_node->refcount);
INIT_HLIST_NODE(&gw_node->list);
gw_node->orig_node = orig_node;
gw_node->bandwidth_down = ntohl(gateway->bandwidth_down);
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit e698321151040710f632bf8c014ec23c5bc406c8
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Mar 5 16:09:22 2016 +0100
batman-adv: Use kref_get for batadv_gw_select
batadv_gw_select requires that the caller already has a valid reference for
new_gw_node. It is therefore not possible that it has an reference counter
of 0 and was still given to this function
The kref_get function instead WARNs (with debug information) when the
reference counter would still be 0. This makes a bug in batman-adv better
visible because kref_get_unless_zero would have ignored this problem.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Marek Lindner <mareklindner(a)neomailbox.ch>
>---------------------------------------------------------------
e698321151040710f632bf8c014ec23c5bc406c8
net/batman-adv/gateway_client.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index c59aff5..bb1c4f3 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -135,8 +135,8 @@ static void batadv_gw_select(struct batadv_priv *bat_priv,
spin_lock_bh(&bat_priv->gw.list_lock);
- if (new_gw_node && !kref_get_unless_zero(&new_gw_node->refcount))
- new_gw_node = NULL;
+ if (new_gw_node)
+ kref_get(&new_gw_node->refcount);
curr_gw_node = rcu_dereference_protected(bat_priv->gw.curr_gw, 1);
rcu_assign_pointer(bat_priv->gw.curr_gw, new_gw_node);
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit e0fbb37fe0b0ae615f555346150174de6277df9c
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Mar 5 16:09:21 2016 +0100
batman-adv: Use kref_get for batadv_nc_get_nc_node
batadv_nc_get_nc_node requires that the caller already has a valid
reference for orig_neigh_node. It is therefore not possible that it has an
reference counter of 0 and was still given to this function
The kref_get function instead WARNs (with debug information) when the
reference counter would still be 0. This makes a bug in batman-adv better
visible because kref_get_unless_zero would have ignored this problem.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Marek Lindner <mareklindner(a)neomailbox.ch>
>---------------------------------------------------------------
e0fbb37fe0b0ae615f555346150174de6277df9c
net/batman-adv/network-coding.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index 164f567..678f068 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -854,8 +854,7 @@ batadv_nc_get_nc_node(struct batadv_priv *bat_priv,
if (!nc_node)
return NULL;
- if (!kref_get_unless_zero(&orig_neigh_node->refcount))
- goto free;
+ kref_get(&orig_neigh_node->refcount);
/* Initialize nc_node */
INIT_LIST_HEAD(&nc_node->list);
@@ -882,10 +881,6 @@ batadv_nc_get_nc_node(struct batadv_priv *bat_priv,
spin_unlock_bh(lock);
return nc_node;
-
-free:
- kfree(nc_node);
- return NULL;
}
/**
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 21a288fb1b87d11a48d7605b8e00eddee8ed1cf8
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Mar 5 16:09:20 2016 +0100
batman-adv: Use kref_get for batadv_tvlv_container_get
batadv_tvlv_container_get requires that tvlv.container_list_lock is held by
the caller. It is therefore not possible that an item in
tvlv.container_list has an reference counter of 0 and is still in the list
The kref_get function instead WARNs (with debug information) when the
reference counter would still be 0. This makes a bug in batman-adv better
visible because kref_get_unless_zero would have ignored this problem.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Marek Lindner <mareklindner(a)neomailbox.ch>
>---------------------------------------------------------------
21a288fb1b87d11a48d7605b8e00eddee8ed1cf8
net/batman-adv/main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index c8d8bc7..5f2974b 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -748,9 +748,7 @@ batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)
if (tvlv_tmp->tvlv_hdr.version != version)
continue;
- if (!kref_get_unless_zero(&tvlv_tmp->refcount))
- continue;
-
+ kref_get(&tvlv_tmp->refcount);
tvlv = tvlv_tmp;
break;
}
Repository : ssh://git@open-mesh.org/alfred
On branch : master
>---------------------------------------------------------------
commit 7782e616b0e8eefac915d1aa3b6cca6f442f840e
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sun Apr 3 19:21:47 2016 +0200
alfred: Don't accept user defined dataset source address in slave mode
The dataset source is used by master servers to identify if it has to be
forwarded to other master servers. The data::source of an incoming UDP
push_data is checked and compared against the address of the node sending
the dataset. If both are same then the dataset is marked as
SOURCE_FIRST_HAND. Otherwise it is already synced dataset (SOURCE_SYNCED).
Only datasets marked as SOURCE_FIRST_HAND or SOURCE_LOCAL will be forwarded
by master servers.
Allowing slave servers to accept push_data packets via unix socket with a
modified data::source would break the synchronization of datasets between
the master servers. The slave server would forward data to the master
server as always but the master would now mark the packet as SOURCE_SYNCED.
The synchronization process would end here. Parts of the alfred servers
would therefore have access to the dataset and some not.
Instead drop the incoming push_data with a set data::source on the slave.
No alfred server will have the dataset and the stable inconsistency is
avoided.
Fixes: 58e109973bbe ("alfred: Allow setting the source mac via unix sock")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
>---------------------------------------------------------------
7782e616b0e8eefac915d1aa3b6cca6f442f840e
unix_sock.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/unix_sock.c b/unix_sock.c
index ee6dd8f..150ad32 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -122,10 +122,18 @@ static int unix_sock_add_data(struct globals *globals,
/* clients should set the source mac to 00:00:00:00:00:00
* to make the server set the source for them
+ *
+ * Only alfred in master mode can accept a user defined
+ * source addresses. Otherwise the data would not be
+ * synced between master servers.
*/
- if (!is_valid_ether_addr(data->source))
- memcpy(data->source, &interface->hwaddr,
- sizeof(interface->hwaddr));
+ if (is_valid_ether_addr(data->source)) {
+ if (memcmp(data->source, &interface->hwaddr, ETH_ALEN) != 0 &&
+ globals->opmode != OPMODE_MASTER)
+ goto err;
+ } else {
+ memcpy(data->source, &interface->hwaddr, ETH_ALEN);
+ }
if ((int)(data_len + sizeof(*data)) > len)
goto err;
Repository : ssh://git@open-mesh.org/alfred
On branch : master
>---------------------------------------------------------------
commit 25b4ae66dca453604e91d90d459b2523bb3da891
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Fri Apr 1 19:22:36 2016 +0200
alfred: Only accept valid mac addresses via unix socket
Not only 00:00:00:00:00:00 but also multicast addresses are invalid as data
source for alfred. These have to be checked too before accepting the mac
address received from the client over the unix socket.
Fixes: 58e109973bbe ("alfred: Allow setting the source mac via unix sock")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
>---------------------------------------------------------------
25b4ae66dca453604e91d90d459b2523bb3da891
unix_sock.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/unix_sock.c b/unix_sock.c
index a0ccc13..ee6dd8f 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -97,7 +97,6 @@ static int unix_sock_add_data(struct globals *globals,
struct alfred_push_data_v0 *push,
int client_sock)
{
- static const char zero[ETH_ALEN] = { 0 };
struct alfred_data *data;
struct dataset *dataset;
int len, data_len, ret = -1;
@@ -124,7 +123,7 @@ static int unix_sock_add_data(struct globals *globals,
/* clients should set the source mac to 00:00:00:00:00:00
* to make the server set the source for them
*/
- if (memcmp(zero, data->source, sizeof(data->source)) == 0)
+ if (!is_valid_ether_addr(data->source))
memcpy(data->source, &interface->hwaddr,
sizeof(interface->hwaddr));
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit e2c48f277c7a5ceb22da5414e9e0599091b52bb6
Author: Sven Eckelmann <sven.eckelmann(a)open-mesh.com>
Date: Fri Apr 1 11:37:14 2016 +0200
batman-adv: Fix checkpatch warning about 'unsigned' type
checkpatch.pl warns about the use of 'unsigned' as a short form for
'unsigned int'.
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner(a)neomailbox.ch>
>---------------------------------------------------------------
e2c48f277c7a5ceb22da5414e9e0599091b52bb6
net/batman-adv/fragmentation.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 910c841..65536db 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -452,7 +452,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
/* To avoid merge and refragmentation at next-hops we never send
* fragments larger than BATADV_FRAG_MAX_FRAG_SIZE
*/
- mtu = min_t(unsigned, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
+ mtu = min_t(unsigned int, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
max_fragment_size = mtu - header_size;
max_packet_size = max_fragment_size * BATADV_FRAG_MAX_FRAGMENTS;