[batctl] master: batctl: replace multicast_mode with multicast_forceflood command (3ab8f42)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : master
>---------------------------------------------------------------
commit 3ab8f4295876366d66537aab995897af12a81248
Author: Linus Lüssing <linus.luessing(a)c0d3.blue>
Date: Sat Feb 16 03:58:54 2019 +0100
batctl: replace multicast_mode with multicast_forceflood command
This patch hides the multicast_mode setting in the UI and adds a new
multicast_forceflood command. multicast_forceflood is basically the
inverse of the current multicast_mode setting.
For the netlink config additions to batman-adv "multicast_mode" was
not added. Instead a "multicast_forceflood" attribute was introduced.
The multicast_mode batctl command is kept for compatibility for now
but should be removed eventually.
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
3ab8f4295876366d66537aab995897af12a81248
Makefile | 1 +
README.rst | 8 +++----
functions.c | 16 +++++++++++++-
functions.h | 1 +
main.c | 3 +++
main.h | 1 +
man/batctl.8 | 8 ++++---
multicast_mode.c => multicast_forceflood.c | 34 +++++++++++++++---------------
multicast_mode.c | 3 +--
sys.c | 30 +++++++++++++++++++++-----
10 files changed, 73 insertions(+), 32 deletions(-)
diff --git a/Makefile b/Makefile
index 55105cc..03dc804 100755
--- a/Makefile
+++ b/Makefile
@@ -69,6 +69,7 @@ $(eval $(call add_command,isolation_mark,y))
$(eval $(call add_command,log,y))
$(eval $(call add_command,loglevel,y))
$(eval $(call add_command,mcast_flags,y))
+$(eval $(call add_command,multicast_forceflood,y))
$(eval $(call add_command,multicast_mode,y))
$(eval $(call add_command,nc_nodes,y))
$(eval $(call add_command,neighbors,y))
diff --git a/README.rst b/README.rst
index e30b5b9..e20c7c4 100644
--- a/README.rst
+++ b/README.rst
@@ -468,14 +468,14 @@ Usage::
Note that network coding requires a working promiscuous mode on all interfaces.
-batctl multicast_mode
-=====================
+batctl multicast_forceflood
+===========================
-display or modify the multicast mode setting
+display or modify the multicast forceflood setting
Usage::
- batctl multicast_mode|mm [0|1]
+ batctl multicast_forceflood|mff [0|1]
batctl mcast_flags
diff --git a/functions.c b/functions.c
index 76deab7..a202969 100644
--- a/functions.c
+++ b/functions.c
@@ -175,6 +175,16 @@ static bool ether_addr_valid(const uint8_t *addr)
return true;
}
+static void print_inv_bool(char *line)
+{
+ if (!strncmp("enabled", line, strlen("enabled")))
+ printf("disabled\n");
+ else if (!strncmp("disabled", line, strlen("disabled")))
+ printf("enabled\n");
+ else
+ printf("%s", line);
+}
+
int read_file(const char *dir, const char *fname, int read_opt,
float orig_timeout, float watch_interval, size_t header_lines)
{
@@ -237,7 +247,11 @@ read:
continue;
if (!(read_opt & USE_BAT_HOSTS)) {
- printf("%s", line_ptr);
+ if (read_opt & INVERSE_BOOL)
+ print_inv_bool(line_ptr);
+ else
+ printf("%s", line_ptr);
+
continue;
}
diff --git a/functions.h b/functions.h
index e2bbb4e..b3f2159 100644
--- a/functions.h
+++ b/functions.h
@@ -91,6 +91,7 @@ enum {
SKIP_HEADER = 0x100,
UNICAST_ONLY = 0x200,
MULTICAST_ONLY = 0x400,
+ INVERSE_BOOL = 0x800,
};
#endif
diff --git a/main.c b/main.c
index 2a28642..199c7a4 100644
--- a/main.c
+++ b/main.c
@@ -74,6 +74,9 @@ static void print_usage(void)
if (cmd->type != type[i])
continue;
+ if (!cmd->usage)
+ continue;
+
if (strcmp(cmd->name, cmd->abbr) == 0)
snprintf(buf, sizeof(buf), "%s", cmd->name);
else
diff --git a/main.h b/main.h
index fca2a32..92d0e61 100644
--- a/main.h
+++ b/main.h
@@ -67,6 +67,7 @@ extern char module_ver_path[];
enum command_flags {
COMMAND_FLAG_MESH_IFACE = BIT(0),
COMMAND_FLAG_NETLINK = BIT(1),
+ COMMAND_FLAG_INVERSE = BIT(2),
};
enum command_type {
diff --git a/man/batctl.8 b/man/batctl.8
index 0fbf1dd..418bd96 100644
--- a/man/batctl.8
+++ b/man/batctl.8
@@ -105,9 +105,11 @@ hop penalty. The penalty is can be 0-255 (255 sets originator message's TQ to ze
If no parameter is given the current network coding mode setting is displayed. Otherwise the parameter is used to enable or
disable network coding.
.br
-.IP "\fBmulticast_mode\fP|\fBmm\fP [\fB0\fP|\fB1\fP]"
-If no parameter is given the current multicast mode setting is displayed. Otherwise the parameter is used to enable or
-disable multicast optimizations (i.e. disabling means always sending own multicast frames via classic flooding).
+.IP "\fBmulticast_forceflood\fP|\fBmff\fP [\fB0\fP|\fB1\fP]"
+If no parameter is given the current multicast forceflood setting is displayed. Otherwise the parameter is used to enable or
+disable multicast forceflood. This setting defines whether multicast optimizations should be replaced by simple broadcast-like
+flooding of multicast packets. If set to non-zero then all nodes in the mesh are going to use classic flooding for any
+multicast packet with no optimizations.
.br
.IP "\fBloglevel\fP|\fBll\fP [\fBlevel\fP[ \fBlevel\fP[ \fBlevel\fP]] \fB...\fP]"
If no parameter is given the current log level settings are displayed otherwise the parameter(s) is/are used to set the log
diff --git a/multicast_mode.c b/multicast_forceflood.c
similarity index 63%
copy from multicast_mode.c
copy to multicast_forceflood.c
index 836a744..daaa6d0 100644
--- a/multicast_mode.c
+++ b/multicast_forceflood.c
@@ -30,9 +30,9 @@
#include "netlink.h"
#include "sys.h"
-static struct simple_boolean_data multicast_mode;
+static struct simple_boolean_data multicast_forceflood;
-static int print_multicast_mode(struct nl_msg *msg, void *arg)
+static int print_multicast_forceflood(struct nl_msg *msg, void *arg)
{
struct nlattr *attrs[BATADV_ATTR_MAX + 1];
struct nlmsghdr *nlh = nlmsg_hdr(msg);
@@ -52,44 +52,44 @@ static int print_multicast_mode(struct nl_msg *msg, void *arg)
if (!attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED])
return NL_OK;
- printf("%s\n", !nla_get_u8(attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED]) ? "enabled" : "disabled");
+ printf("%s\n", nla_get_u8(attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED]) ? "enabled" : "disabled");
*result = 0;
return NL_STOP;
}
-static int get_multicast_mode(struct state *state)
+static int get_multicast_forceflood(struct state *state)
{
return sys_simple_nlquery(state, BATADV_CMD_GET_MESH,
- NULL, print_multicast_mode);
+ NULL, print_multicast_forceflood);
}
-static int set_attrs_multicast_mode(struct nl_msg *msg, void *arg)
+static int set_attrs_multicast_forceflood(struct nl_msg *msg, void *arg)
{
struct state *state = arg;
struct settings_data *settings = state->cmd->arg;
struct simple_boolean_data *data = settings->data;
- nla_put_u8(msg, BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED, !data->val);
+ nla_put_u8(msg, BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED, data->val);
return 0;
}
-static int set_multicast_mode(struct state *state)
+static int set_multicast_forceflood(struct state *state)
{
return sys_simple_nlquery(state, BATADV_CMD_SET_MESH,
- set_attrs_multicast_mode, NULL);
+ set_attrs_multicast_forceflood, NULL);
}
-static struct settings_data batctl_settings_multicast_mode = {
+static struct settings_data batctl_settings_multicast_forceflood = {
.sysfs_name = "multicast_mode",
- .data = &multicast_mode,
+ .data = &multicast_forceflood,
.parse = parse_simple_boolean,
- .netlink_get = get_multicast_mode,
- .netlink_set = set_multicast_mode,
+ .netlink_get = get_multicast_forceflood,
+ .netlink_set = set_multicast_forceflood,
};
-COMMAND_NAMED(SUBCOMMAND, multicast_mode, "mm", handle_sys_setting,
- COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK,
- &batctl_settings_multicast_mode,
- "[0|1] \tdisplay or modify multicast_mode setting");
+COMMAND_NAMED(SUBCOMMAND, multicast_forceflood, "mff", handle_sys_setting,
+ COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK | COMMAND_FLAG_INVERSE,
+ &batctl_settings_multicast_forceflood,
+ "[0|1] \tdisplay or modify multicast_forceflood setting");
diff --git a/multicast_mode.c b/multicast_mode.c
index 836a744..fb17586 100644
--- a/multicast_mode.c
+++ b/multicast_mode.c
@@ -91,5 +91,4 @@ static struct settings_data batctl_settings_multicast_mode = {
COMMAND_NAMED(SUBCOMMAND, multicast_mode, "mm", handle_sys_setting,
COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK,
- &batctl_settings_multicast_mode,
- "[0|1] \tdisplay or modify multicast_mode setting");
+ &batctl_settings_multicast_mode, NULL);
diff --git a/sys.c b/sys.c
index 9a7966f..b0864cd 100644
--- a/sys.c
+++ b/sys.c
@@ -156,7 +156,8 @@ int sys_simple_print_boolean(struct nl_msg *msg, void *arg,
static void settings_usage(struct state *state)
{
fprintf(stderr, "Usage: batctl [options] %s|%s [parameters] %s\n",
- state->cmd->name, state->cmd->abbr, state->cmd->usage);
+ state->cmd->name, state->cmd->abbr,
+ state->cmd->usage ? state->cmd->usage : "");
fprintf(stderr, "parameters:\n");
fprintf(stderr, " \t -h print this help\n");
@@ -167,6 +168,7 @@ static int sys_read_setting(struct state *state, const char *path_buff,
{
struct settings_data *settings = state->cmd->arg;
int res = EXIT_FAILURE;
+ int read_opt = NO_FLAGS;
if (settings->netlink_get) {
res = settings->netlink_get(state);
@@ -176,8 +178,12 @@ static int sys_read_setting(struct state *state, const char *path_buff,
return EXIT_SUCCESS;
}
- if (sysfs_name)
- res = read_file(path_buff, sysfs_name, NO_FLAGS, 0, 0, 0);
+ if (sysfs_name) {
+ if (state->cmd->flags & COMMAND_FLAG_INVERSE)
+ read_opt |= INVERSE_BOOL;
+
+ res = read_file(path_buff, sysfs_name, read_opt, 0, 0, 0);
+ }
return res;
}
@@ -187,6 +193,7 @@ static int sys_write_setting(struct state *state, const char *path_buff,
{
struct settings_data *settings = state->cmd->arg;
int res = EXIT_FAILURE;
+ char *argv1 = argv[1];
if (settings->netlink_set) {
res = settings->netlink_set(state);
@@ -196,9 +203,22 @@ static int sys_write_setting(struct state *state, const char *path_buff,
return EXIT_SUCCESS;
}
- if (sysfs_name)
+ if (sysfs_name) {
+ if (state->cmd->flags & COMMAND_FLAG_INVERSE) {
+ if (!strncmp("0", argv[1], strlen("0")) ||
+ !strncmp("disable", argv[1], strlen("disable")) ||
+ !strncmp("disabled", argv[1], strlen("disabled"))) {
+ argv1 = "enabled";
+ } else if (!strncmp("1", argv[1], strlen("1")) ||
+ !strncmp("enable", argv[1], strlen("enable")) ||
+ !strncmp("enabled", argv[1], strlen("enabled"))) {
+ argv1 = "disabled";
+ }
+ }
+
res = write_file(path_buff, sysfs_name,
- argv[1], argc > 2 ? argv[2] : NULL);
+ argv1, argc > 2 ? argv[2] : NULL);
+ }
return res;
}
3 years, 11 months
[batctl] master: batctl: Add hop_penalty setting command (cde0af8)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : master
>---------------------------------------------------------------
commit cde0af82935131f37b308fde47aba06e6d15a5b7
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Feb 23 08:41:08 2019 +0100
batctl: Add hop_penalty setting command
OpenWrt was switched to use batctl as abstraction of the sysfs and netlink
configuration interface. The only additional configuration option to finish
this process is hop_penalty. It is required to define the penalty which
will be applied to an originator message's tq-field on every hop.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
cde0af82935131f37b308fde47aba06e6d15a5b7
Makefile | 1 +
README.rst | 15 ++++++++++++
orig_interval.c => hop_penalty.c | 50 ++++++++++++++++++++--------------------
man/batctl.8 | 4 ++++
4 files changed, 45 insertions(+), 25 deletions(-)
diff --git a/Makefile b/Makefile
index 4d8b709..55105cc 100755
--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,7 @@ $(eval $(call add_command,event,y))
$(eval $(call add_command,fragmentation,y))
$(eval $(call add_command,gateways,y))
$(eval $(call add_command,gw_mode,y))
+$(eval $(call add_command,hop_penalty,y))
$(eval $(call add_command,interface,y))
$(eval $(call add_command,isolation_mark,y))
$(eval $(call add_command,log,y))
diff --git a/README.rst b/README.rst
index 4c0f544..e30b5b9 100644
--- a/README.rst
+++ b/README.rst
@@ -530,6 +530,21 @@ Usage::
batctl aggregation|ag [0|1]
+batctl hop_penalty
+==================
+
+display or modify the hop_penalty (0-255)
+
+Usage::
+
+ batctl hop_penalty|hp [penalty]
+
+Example::
+
+ $ batctl penalty
+ 30
+
+
batctl isolation_mark
=====================
diff --git a/orig_interval.c b/hop_penalty.c
similarity index 62%
copy from orig_interval.c
copy to hop_penalty.c
index d1501af..58067bf 100644
--- a/orig_interval.c
+++ b/hop_penalty.c
@@ -28,14 +28,14 @@
#include "main.h"
#include "sys.h"
-static struct orig_interval_data {
- uint32_t orig_interval;
-} orig_interval;
+static struct hop_penalty_data {
+ uint8_t hop_penalty;
+} hop_penalty;
-static int parse_orig_interval(struct state *state, int argc, char *argv[])
+static int parse_hop_penalty(struct state *state, int argc, char *argv[])
{
struct settings_data *settings = state->cmd->arg;
- struct orig_interval_data *data = settings->data;
+ struct hop_penalty_data *data = settings->data;
char *endptr;
if (argc != 2) {
@@ -43,7 +43,7 @@ static int parse_orig_interval(struct state *state, int argc, char *argv[])
return -EINVAL;
}
- data->orig_interval = strtoul(argv[1], &endptr, 0);
+ data->hop_penalty = strtoul(argv[1], &endptr, 0);
if (!endptr || *endptr != '\0') {
fprintf(stderr, "Error - the supplied argument is invalid: %s\n", argv[1]);
return -EINVAL;
@@ -52,7 +52,7 @@ static int parse_orig_interval(struct state *state, int argc, char *argv[])
return 0;
}
-static int print_orig_interval(struct nl_msg *msg, void *arg)
+static int print_hop_penalty(struct nl_msg *msg, void *arg)
{
struct nlattr *attrs[BATADV_ATTR_MAX + 1];
struct nlmsghdr *nlh = nlmsg_hdr(msg);
@@ -69,47 +69,47 @@ static int print_orig_interval(struct nl_msg *msg, void *arg)
return NL_OK;
}
- if (!attrs[BATADV_ATTR_ORIG_INTERVAL])
+ if (!attrs[BATADV_ATTR_HOP_PENALTY])
return NL_OK;
- printf("%u\n", nla_get_u32(attrs[BATADV_ATTR_ORIG_INTERVAL]));
+ printf("%u\n", nla_get_u8(attrs[BATADV_ATTR_HOP_PENALTY]));
*result = 0;
return NL_STOP;
}
-static int get_orig_interval(struct state *state)
+static int get_hop_penalty(struct state *state)
{
return sys_simple_nlquery(state, BATADV_CMD_GET_MESH,
- NULL, print_orig_interval);
+ NULL, print_hop_penalty);
}
-static int set_attrs_orig_interval(struct nl_msg *msg, void *arg)
+static int set_attrs_hop_penalty(struct nl_msg *msg, void *arg)
{
struct state *state = arg;
struct settings_data *settings = state->cmd->arg;
- struct orig_interval_data *data = settings->data;
+ struct hop_penalty_data *data = settings->data;
- nla_put_u32(msg, BATADV_ATTR_ORIG_INTERVAL, data->orig_interval);
+ nla_put_u8(msg, BATADV_ATTR_HOP_PENALTY, data->hop_penalty);
return 0;
}
-static int set_orig_interval(struct state *state)
+static int set_hop_penalty(struct state *state)
{
return sys_simple_nlquery(state, BATADV_CMD_SET_MESH,
- set_attrs_orig_interval, NULL);
+ set_attrs_hop_penalty, NULL);
}
-static struct settings_data batctl_settings_orig_interval = {
- .sysfs_name = "orig_interval",
- .data = &orig_interval,
- .parse = parse_orig_interval,
- .netlink_get = get_orig_interval,
- .netlink_set = set_orig_interval,
+static struct settings_data batctl_settings_hop_penalty = {
+ .sysfs_name = "hop_penalty",
+ .data = &hop_penalty,
+ .parse = parse_hop_penalty,
+ .netlink_get = get_hop_penalty,
+ .netlink_set = set_hop_penalty,
};
-COMMAND_NAMED(SUBCOMMAND, orig_interval, "it", handle_sys_setting,
+COMMAND_NAMED(SUBCOMMAND, hop_penalty, "hp", handle_sys_setting,
COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK,
- &batctl_settings_orig_interval,
- "[interval] \tdisplay or modify orig_interval setting");
+ &batctl_settings_hop_penalty,
+ "[penalty] \tdisplay or modify hop_penalty setting");
diff --git a/man/batctl.8 b/man/batctl.8
index ed8e71f..0fbf1dd 100644
--- a/man/batctl.8
+++ b/man/batctl.8
@@ -97,6 +97,10 @@ when parameter \fB\-t\fP is specified. Parameter \fB\-r\fP will do the same but
If no parameter is given the current fragmentation mode setting is displayed. Otherwise the parameter is used to enable or
disable fragmentation.
.br
+.IP "\fBhop_penalty\fP|\fBhp\fP [\fBpenalty\fP]"
+If no parameter is given the current hop penalty setting is displayed. Otherwise the parameter is used to set the
+hop penalty. The penalty is can be 0-255 (255 sets originator message's TQ to zero when forwarded by this hop).
+.br
.IP "\fBnetwork_coding\fP|\fBnc\fP [\fB0\fP|\fB1\fP]"
If no parameter is given the current network coding mode setting is displayed. Otherwise the parameter is used to enable or
disable network coding.
3 years, 11 months
[batman-adv] master: batman-adv: fix warning in function batadv_v_elp_get_throughput (d09933a2)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit d09933a22938fbd5c37ccb444a608b8559cef468
Author: Anders Roxell <anders.roxell(a)linaro.org>
Date: Fri Feb 22 16:25:54 2019 +0100
batman-adv: fix warning in function batadv_v_elp_get_throughput
When CONFIG_CFG80211 isn't enabled the compiler correcly warns about
'sinfo.pertid' may be unused. It can also happen for other error
conditions that it not warn about.
net/batman-adv/bat_v_elp.c: In function ‘batadv_v_elp_get_throughput.isra.0’:
include/net/cfg80211.h:6370:13: warning: ‘sinfo.pertid’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
kfree(sinfo->pertid);
~~~~~^~~~~~~~
Rework so that we only release '&sinfo' if cfg80211_get_station returns
zero.
Signed-off-by: Anders Roxell <anders.roxell(a)linaro.org>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
d09933a22938fbd5c37ccb444a608b8559cef468
net/batman-adv/bat_v_elp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index a9b7919c..d5df0114 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -104,8 +104,10 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
ret = cfg80211_get_station(real_netdev, neigh->addr, &sinfo);
- /* free the TID stats immediately */
- cfg80211_sinfo_release_content(&sinfo);
+ if (!ret) {
+ /* free the TID stats immediately */
+ cfg80211_sinfo_release_content(&sinfo);
+ }
dev_put(real_netdev);
if (ret == -ENOENT) {
3 years, 11 months
[batman-adv] master: Merge branch 'maint' (6ffe4d5c)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 6ffe4d5cec5103a95ab8dab8137e700b00eb4704
Merge: 816f978a d09933a2
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Wed Feb 27 21:39:14 2019 +0100
Merge branch 'maint'
>---------------------------------------------------------------
6ffe4d5cec5103a95ab8dab8137e700b00eb4704
net/batman-adv/bat_v_elp.c | 6 ++++--
net/batman-adv/bridge_loop_avoidance.c | 16 +++++++++++++---
net/batman-adv/translation-table.c | 32 ++++++++++++++++++++++++--------
3 files changed, 41 insertions(+), 13 deletions(-)
3 years, 11 months
[batman-adv] master: batman-adv: Reduce tt_local hash refcnt only for removed entry (0c86a051)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 0c86a0511e97de502276900c5d6f22b09e042d21
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Feb 23 15:09:05 2019 +0100
batman-adv: Reduce tt_local hash refcnt only for removed entry
The batadv_hash_remove is a function which searches the hashtable for an
entry using a needle, a hashtable bucket selection function and a compare
function. It will lock the bucket list and delete an entry when the compare
function matches it with the needle. It returns the pointer to the
hlist_node which matches or NULL when no entry matches the needle.
The batadv_tt_local_remove is not itself protected in anyway to avoid that
any other function is modifying the hashtable between the search for the
entry and the call to batadv_hash_remove. It can therefore happen that the
entry either doesn't exist anymore or an entry was deleted which is not the
same object as the needle. In such an situation, the reference counter (for
the reference stored in the hashtable) must not be reduced for the needle.
Instead the reference counter of the actually removed entry has to be
reduced.
Otherwise the reference counter will underflow and the object might be
freed before all its references were dropped. The kref helpers reported
this problem as:
refcount_t: underflow; use-after-free.
Fixes: af912d77181f ("batman-adv: protect tt_local_entry from concurrent delete events")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
0c86a0511e97de502276900c5d6f22b09e042d21
net/batman-adv/translation-table.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index f73d7913..b5cfc506 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1337,9 +1337,10 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
unsigned short vid, const char *message,
bool roaming)
{
+ struct batadv_tt_local_entry *tt_removed_entry;
struct batadv_tt_local_entry *tt_local_entry;
u16 flags, curr_flags = BATADV_NO_FLAGS;
- void *tt_entry_exists;
+ struct hlist_node *tt_removed_node;
tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid);
if (!tt_local_entry)
@@ -1368,15 +1369,18 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
*/
batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL);
- tt_entry_exists = batadv_hash_remove(bat_priv->tt.local_hash,
+ tt_removed_node = batadv_hash_remove(bat_priv->tt.local_hash,
batadv_compare_tt,
batadv_choose_tt,
&tt_local_entry->common);
- if (!tt_entry_exists)
+ if (!tt_removed_node)
goto out;
- /* extra call to free the local tt entry */
- batadv_tt_local_entry_put(tt_local_entry);
+ /* drop reference of remove hash entry */
+ tt_removed_entry = hlist_entry(tt_removed_node,
+ struct batadv_tt_local_entry,
+ common.hash_entry);
+ batadv_tt_local_entry_put(tt_removed_entry);
out:
if (tt_local_entry)
3 years, 11 months
[batman-adv] master: batman-adv: Reduce tt_global hash refcnt only for removed entry (bd6df24d)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit bd6df24da0063fe50828c287d05bdc1876f4f6cc
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Feb 23 15:09:06 2019 +0100
batman-adv: Reduce tt_global hash refcnt only for removed entry
The batadv_hash_remove is a function which searches the hashtable for an
entry using a needle, a hashtable bucket selection function and a compare
function. It will lock the bucket list and delete an entry when the compare
function matches it with the needle. It returns the pointer to the
hlist_node which matches or NULL when no entry matches the needle.
The batadv_tt_global_free is not itself protected in anyway to avoid that
any other function is modifying the hashtable between the search for the
entry and the call to batadv_hash_remove. It can therefore happen that the
entry either doesn't exist anymore or an entry was deleted which is not the
same object as the needle. In such an situation, the reference counter (for
the reference stored in the hashtable) must not be reduced for the needle.
Instead the reference counter of the actually removed entry has to be
reduced.
Otherwise the reference counter will underflow and the object might be
freed before all its references were dropped. The kref helpers reported
this problem as:
refcount_t: underflow; use-after-free.
Fixes: 7bad46397eff ("batman-adv: protect the local and the global trans-tables with rcu")
Reported-by: Martin Weinelt <martin(a)linuxlounge.net>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Acked-by: Antonio Quartulli <a(a)unstable.cc>
>---------------------------------------------------------------
bd6df24da0063fe50828c287d05bdc1876f4f6cc
net/batman-adv/translation-table.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index b5cfc506..26c4e249 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -616,14 +616,26 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv,
struct batadv_tt_global_entry *tt_global,
const char *message)
{
+ struct batadv_tt_global_entry *tt_removed_entry;
+ struct hlist_node *tt_removed_node;
+
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting global tt entry %pM (vid: %d): %s\n",
tt_global->common.addr,
batadv_print_vid(tt_global->common.vid), message);
- batadv_hash_remove(bat_priv->tt.global_hash, batadv_compare_tt,
- batadv_choose_tt, &tt_global->common);
- batadv_tt_global_entry_put(tt_global);
+ tt_removed_node = batadv_hash_remove(bat_priv->tt.global_hash,
+ batadv_compare_tt,
+ batadv_choose_tt,
+ &tt_global->common);
+ if (!tt_removed_node)
+ return;
+
+ /* drop reference of remove hash entry */
+ tt_removed_entry = hlist_entry(tt_removed_node,
+ struct batadv_tt_global_entry,
+ common.hash_entry);
+ batadv_tt_global_entry_put(tt_removed_entry);
}
/**
3 years, 11 months
[batman-adv] master: batman-adv: Reduce claim hash refcnt only for removed entry (3a7af70a)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 3a7af70ae7c4209324dbb08b91e013c17108bdd6
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Feb 23 15:09:04 2019 +0100
batman-adv: Reduce claim hash refcnt only for removed entry
The batadv_hash_remove is a function which searches the hashtable for an
entry using a needle, a hashtable bucket selection function and a compare
function. It will lock the bucket list and delete an entry when the compare
function matches it with the needle. It returns the pointer to the
hlist_node which matches or NULL when no entry matches the needle.
The batadv_bla_del_claim is not itself protected in anyway to avoid that
any other function is modifying the hashtable between the search for the
entry and the call to batadv_hash_remove. It can therefore happen that the
entry either doesn't exist anymore or an entry was deleted which is not the
same object as the needle. In such an situation, the reference counter (for
the reference stored in the hashtable) must not be reduced for the needle.
Instead the reference counter of the actually removed entry has to be
reduced.
Otherwise the reference counter will underflow and the object might be
freed before all its references were dropped. The kref helpers reported
this problem as:
refcount_t: underflow; use-after-free.
Fixes: a9ce0dc43e2c ("batman-adv: add basic bridge loop avoidance code")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
3a7af70ae7c4209324dbb08b91e013c17108bdd6
net/batman-adv/bridge_loop_avoidance.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index ef39aabd..4fb01108 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -803,6 +803,8 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
const u8 *mac, const unsigned short vid)
{
struct batadv_bla_claim search_claim, *claim;
+ struct batadv_bla_claim *claim_removed_entry;
+ struct hlist_node *claim_removed_node;
ether_addr_copy(search_claim.addr, mac);
search_claim.vid = vid;
@@ -813,10 +815,18 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): %pM, vid %d\n", __func__,
mac, batadv_print_vid(vid));
- batadv_hash_remove(bat_priv->bla.claim_hash, batadv_compare_claim,
- batadv_choose_claim, claim);
- batadv_claim_put(claim); /* reference from the hash is gone */
+ claim_removed_node = batadv_hash_remove(bat_priv->bla.claim_hash,
+ batadv_compare_claim,
+ batadv_choose_claim, claim);
+ if (!claim_removed_node)
+ goto free_claim;
+ /* reference from the hash is gone */
+ claim_removed_entry = hlist_entry(claim_removed_node,
+ struct batadv_bla_claim, hash_entry);
+ batadv_claim_put(claim_removed_entry);
+
+free_claim:
/* don't need the reference from hash_find() anymore */
batadv_claim_put(claim);
}
3 years, 11 months
[linux-merge]linux integration; annotated tag, v5.0-rc8, created. v5.0-rc8
by postmaster@open-mesh.org
The annotated tag, v5.0-rc8 has been created
at 497dce527948a0e9e471ddf45c66d542828c3561 (tag)
tagging 5908e6b738e3357af42c10e1183753c70a0117a9 (commit)
replaces v5.0-rc7
tagged by Linus Torvalds
on Sun Feb 24 16:46:53 2019 -0800
- Shortlog ------------------------------------------------------------
Linux 5.0-rc8
-----BEGIN PGP SIGNATURE-----
iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAlxzOv0eHHRvcnZhbGRz
QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiGChYH/igkDX6FOcqiQCpx
o5jZ5fvPEH8khspBnszNl8r1WMZjq+DNsjIKtOEu6ITuJDG30Mr2asqazxwrmPHX
pvq7+GsqHlrlik6Gz4FK3ZcuUQGmumlYj7di3dxM8XwLgA1xHY8QVC3AuzXJHyyw
/m+mNvgmnCdWhQ7xuSJDCrbPcIrnhYpW88laa5K/5XYLvNR02eCNAlyffXDhxkoS
bveYCErQIDD5Nz87eN+om8ONPoJIgCbOpdgiXjopsDcvni/TFnGYbVfiHWhAlEGB
0P7/UDtADF4dLpJ+9WtRaSs827Vg1AgsgAY+/TKU7xeYGUgPkpp8/r8IWcJzRiJt
rZKu9Ks=
=A2yc
-----END PGP SIGNATURE-----
-----------------------------------------------------------------------
--
linux integration
3 years, 11 months
[linux-merge]linux integration; annotated tag, v5.0-rc7, created. v5.0-rc7
by postmaster@open-mesh.org
The annotated tag, v5.0-rc7 has been created
at d4588d950276a68c2f52bed31d6fb3e564f87919 (tag)
tagging a3b22b9f11d9fbc48b0291ea92259a5a810e9438 (commit)
replaces v5.0-rc6
tagged by Linus Torvalds
on Sun Feb 17 18:46:46 2019 -0800
- Shortlog ------------------------------------------------------------
Linux 5.0-rc7
-----BEGIN PGP SIGNATURE-----
iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAlxqHJYeHHRvcnZhbGRz
QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiGWl8H/jPI4EipzD2GbnjZ
GaFpMBBjcXBaVmoA+Y69so+7BHx1Ql+5GQtqbK0RHJRb9qEPLw3FBhHNjM/N8Sgf
nSrK+GnBZp9s+k/NR/Yf2RacUR3jhz+Q9JEoQd3u9bFUeQyvE8Rf3vgtoBBwFOfz
+t7N1memYVF3asLGWB4e4sP1YVMGfseTQpSPojvM30YWM86Bv+QtSx1AGgHczQIM
kMKealR8ZPelN6JAXgLhQ5opDojBrE4YKB98pwsMDI6abz0Tz2JLFEUTTxsv5XNN
o/Iz+XDoylskEyxN2unNWfHx7Swkvoklog8J/hDg5XlTvipL/WkT66PHBgcGMNvj
BW9GgU8=
=ZizU
-----END PGP SIGNATURE-----
Eric Dumazet (1):
batman-adv: fix uninit-value in batadv_interface_tx()
-----------------------------------------------------------------------
--
linux integration
3 years, 11 months