From: Florian Westphal <fw(a)strlen.de>
BATMAN uses it as an intermediate return value to signal
forwarding vs. buffering, but it did not return POLICED to
callers outside of BATMAN.
Signed-off-by: Florian Westphal <fw(a)strlen.de>
Signed-off-by: David S. Miller <davem(a)davemloft.net>
[sven(a)narfation.org: rebased on top of TX path rewrite]
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
Taken from upstream commit 99860208bc62 ("sched: remove NET_XMIT_POLICED").
Please make sure you first apply
* https://patchwork.open-mesh.org/patch/16362/
* https://patchwork.open-mesh.org/patch/16363/
* https://patchwork.open-mesh.org/patch/16364/
---
net/batman-adv/send.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 49836da..729deec 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -20,6 +20,7 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
+#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/fs.h>
#include <linux/if.h>
@@ -156,7 +157,7 @@ int batadv_send_unicast_skb(struct sk_buff *skb,
* host, NULL can be passed as recv_if and no interface alternating is
* attempted.
*
- * Return: -1 on failure (and the skb is not consumed), NET_XMIT_POLICED if the
+ * Return: -1 on failure (and the skb is not consumed), -EINPROGRESS if the
* skb is buffered for later transmit or the NET_XMIT status returned by the
* lower routine if the packet has been passed down.
*
@@ -191,7 +192,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb,
* network coding fails, then send the packet as usual.
*/
if (recv_if && batadv_nc_skb_forward(skb, neigh_node))
- ret = NET_XMIT_POLICED;
+ ret = -EINPROGRESS;
else
ret = batadv_send_unicast_skb(skb, neigh_node);
--
2.8.1
On Mon, Jun 13, 2016 at 07:36:37PM +0100, Ben Hutchings wrote:
> 3.16.36-rc1 review patch. If anyone has any objections, please let me know.
>
Hi Ben,
This one looks weird. The version you added for 3.2.81-rc1 looked
better.
Cheers, Linus
> ------------------
>
> From: Linus Lüssing <linus.luessing(a)c0d3.blue>
>
> commit c4fdb6cff2aa0ae740c5f19b6f745cbbe786d42f upstream.
>
> When removing a single interface while a broadcast or ogm packet is
> still pending then we will free the forward packet without releasing the
> queue slots again.
>
> This patch is supposed to fix this issue.
>
> Fixes: 6d5808d4ae1b ("batman-adv: Add missing hardif_free_ref in forw_packet_free")
> Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
> [sven(a)narfation.org: fix conflicts with current version]
> Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
> Signed-off-by: Marek Lindner <mareklindner(a)neomailbox.ch>
> Signed-off-by: Antonio Quartulli <a(a)unstable.cc>
> Signed-off-by: Ben Hutchings <ben(a)decadent.org.uk>
> ---
> net/batman-adv/send.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> --- a/net/batman-adv/send.c
> +++ b/net/batman-adv/send.c
> @@ -638,6 +638,12 @@ batadv_purge_outstanding_packets(struct
>
> if (pending) {
> hlist_del(&forw_packet->list);
> + if (!forw_packet->own)
> + atomic_inc(&bat_priv->bcast_queue_left);
> +
> + if (!forw_packet->own)
> + atomic_inc(&bat_priv->batman_queue_left);
> +
> batadv_forw_packet_free(forw_packet);
> }
> }
>
This patchset completes netns support, by disabling debugfs entries
when not in the default name space, and correctly handling interface
stack loops when the parent is in a different name space.
It additionally adds netlink support for most of the information found
in debugfs, and is netns aware.
This patchset is based on Andrews v7 series and contains an update/rebase
of the v8 sent by myself on May 23rd, with the following changes:
* removed useless initialization "struct net_device *soft_iface = NULL;" in:
- batadv_tt_global_dump
- batadv_hardif_neigh_dump
- batadv_orig_dump
- batadv_gw_dump
- batadv_bla_claim_dump
- batadv_bla_backbone_dump
* add kerneldoc about rcu_read_lock requirement to:
- batadv_tt_global_dump_entry
- batadv_iv_ogm_neigh_dump_hardif
- batadv_iv_ogm_orig_dump_entry
- batadv_v_neigh_dump_hardif
- batadv_v_orig_dump_entry
* simplify code to add BATADV_ATTR_LAST_SEEN_MSECS in batadv_tt_local_dump_entry
* rebased on top of current master and fix conflicts with batadv_algo_ops restructuring
It should apply clean on todays master.
The batctl patches will be sent separately.
Cheers,
Simon
Andrew Lunn (5):
batman-adv: Handle parent interfaces in a different netns
batman-adv: Suppress debugfs entries for netns's
batman-adv: add B.A.T.M.A.N. Dump gateways via netlink
batman-adv: add B.A.T.M.A.N. Dump BLA claims via netlink
batman-adv: Indicate netlink socket can be used with netns.
Matthias Schiffer (6):
batman-adv: netlink: add routing_algo query
batman-adv: netlink: hardif query
batman-adv: netlink: add translation table query
batman-adv: netlink: add originator and neighbor table queries
batman-adv: add B.A.T.M.A.N. IV bat_{orig, neigh}_dump implementations
batman-adv: add B.A.T.M.A.N. V bat_{orig, neigh}_dump implementations
Simon Wunderlich (1):
batman-adv: add backbone table netlink support
Sven Eckelmann (2):
batman-adv: Provide TTVN in the mesh_info netlink msg
batman-adv: Provide bla group in the mesh_info netlink msg
compat-include/linux/netlink.h | 18 ++
compat.h | 7 +
include/uapi/linux/batman_adv.h | 94 ++++++++
net/batman-adv/bat_algo.c | 68 ++++++
net/batman-adv/bat_algo.h | 3 +
net/batman-adv/bat_iv_ogm.c | 366 ++++++++++++++++++++++++++++++++
net/batman-adv/bat_v.c | 341 +++++++++++++++++++++++++++++
net/batman-adv/bridge_loop_avoidance.c | 333 +++++++++++++++++++++++++++++
net/batman-adv/bridge_loop_avoidance.h | 17 +-
net/batman-adv/debugfs.c | 18 ++
net/batman-adv/gateway_client.c | 148 +++++++++++++
net/batman-adv/gateway_client.h | 2 +
net/batman-adv/hard-interface.c | 50 ++++-
net/batman-adv/netlink.c | 217 ++++++++++++++++++-
net/batman-adv/netlink.h | 6 +
net/batman-adv/originator.c | 160 ++++++++++++++
net/batman-adv/originator.h | 4 +
net/batman-adv/packet.h | 36 ----
net/batman-adv/translation-table.c | 377 +++++++++++++++++++++++++++++++++
net/batman-adv/translation-table.h | 4 +
net/batman-adv/types.h | 9 +
21 files changed, 2230 insertions(+), 48 deletions(-)
--
2.8.1
The batman-adv module can automatically be loaded when operations over the
rtnl link are triggered. This requires only the correct rtnl link name in
the module header.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
v4:
- rebase on top of current master
v3:
- rebased on top of current master to fix conflicts with newest patches
v2:
- rebased on top of current master to fix conflicts with newest patches
---
net/batman-adv/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index fe4c5e2..f61479b 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -638,3 +638,4 @@ MODULE_AUTHOR(BATADV_DRIVER_AUTHOR);
MODULE_DESCRIPTION(BATADV_DRIVER_DESC);
MODULE_SUPPORTED_DEVICE(BATADV_DRIVER_DEVICE);
MODULE_VERSION(BATADV_SOURCE_VERSION);
+MODULE_ALIAS_RTNL_LINK("batadv");
--
2.8.1
Some operations in batadv_algo_ops are optional and marked as such in the
kerneldoc. But some of them miss the "(optional)" in their kerneldoc. These
have to also be marked to give an implementor of an algorithm the correct
background information without looking in the code calling these function
pointers.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/types.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 43db7b6..0eeb68f 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1392,6 +1392,7 @@ struct batadv_forw_packet {
/**
* struct batadv_algo_iface_ops - mesh algorithm callbacks (interface specific)
* @activate: start routing mechanisms when hard-interface is brought up
+ * (optional)
* @enable: init routing info when hard-interface is enabled
* @disable: de-init routing info when hard-interface is disabled
* @update_mac: (re-)init mac addresses of the protocol information
@@ -1409,6 +1410,7 @@ struct batadv_algo_iface_ops {
/**
* struct batadv_algo_neigh_ops - mesh algorithm callbacks (neighbour specific)
* @hardif_init: called on creation of single hop entry
+ * (optional)
* @cmp: compare the metrics of two neighbors for their respective outgoing
* interfaces
* @is_similar_or_better: check if neigh1 is equally similar or better than
@@ -1431,11 +1433,11 @@ struct batadv_algo_neigh_ops {
/**
* struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific)
* @free: free the resources allocated by the routing algorithm for an orig_node
- * object
+ * object (optional)
* @add_if: ask the routing algorithm to apply the needed changes to the
- * orig_node due to a new hard-interface being added into the mesh
+ * orig_node due to a new hard-interface being added into the mesh (optional)
* @del_if: ask the routing algorithm to apply the needed changes to the
- * orig_node due to an hard-interface being removed from the mesh
+ * orig_node due to an hard-interface being removed from the mesh (optional)
* @print: print the originator table (optional)
*/
struct batadv_algo_orig_ops {
--
2.8.1
A hard interface can be removed and then added back in quick
succession. This is particularly true for hdlc interface when changing
the protocol.
It is not possible it synchronously remove the sysfs and debugfs
entries for the hard interface when it is removed because the files
may be open. Thus removal is deferred. The files may thus already
exist in sysfs and debugfs when the hard interface is re-added, and
the operations fail.
To fix this race, synchronously rename the debugfs and sysfs files to
a unique temporary name, thus making the name available when the
interface comes back, yet keeps open files still available.
Signed-off-by: Andrew Lunn <andrew(a)lunn.ch>
---
net/batman-adv/debugfs.c | 23 +++++++++++++++++++++++
net/batman-adv/debugfs.h | 1 +
net/batman-adv/hard-interface.c | 19 +++++++++++++++++++
net/batman-adv/sysfs.c | 17 +++++++++++++++++
net/batman-adv/sysfs.h | 2 ++
5 files changed, 62 insertions(+)
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index 50545b0..8b852aa 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -55,6 +55,7 @@
#include "translation-table.h"
static struct dentry *batadv_debugfs;
+static atomic_t batadv_rename = ATOMIC_INIT(0);
#ifdef CONFIG_BATMAN_ADV_DEBUG
#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
@@ -570,6 +571,28 @@ void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface)
}
}
+/**
+ * batadv_debugfs_rename_hardif - rename the base directory
+ * @hard_iface: hard interface which is renamed.
+ *
+ * The interface may be removed and then quickly added back
+ * again. Rename the old instance to something temporary and unique,
+ * so avoiding a name space clash if it does reappear before the deferred
+ * work completes the removal.
+ */
+void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface)
+{
+ char new_name[32];
+
+ snprintf(new_name, sizeof(*new_name) - 1, "tmp-%d",
+ atomic_inc_return(&batadv_rename));
+
+ if (batadv_debugfs && hard_iface->debug_dir) {
+ debugfs_rename(batadv_debugfs, hard_iface->debug_dir,
+ batadv_debugfs, new_name);
+ }
+}
+
int batadv_debugfs_add_meshif(struct net_device *dev)
{
struct batadv_priv *bat_priv = netdev_priv(dev);
diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h
index 1ab4e2e..e7d19c1 100644
--- a/net/batman-adv/debugfs.h
+++ b/net/batman-adv/debugfs.h
@@ -34,6 +34,7 @@ int batadv_debugfs_add_meshif(struct net_device *dev);
void batadv_debugfs_del_meshif(struct net_device *dev);
int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface);
void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface);
+void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface);
#else
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index bf4ee24..08b62d9 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -747,6 +747,23 @@ out:
return NULL;
}
+/**
+ * batadv_hardif_rename - rename the sysfs and debugfs
+ * @hard_iface: The hard interface to rename
+ *
+ * The sysfs and debugfs files cannot be removed until all users close
+ * them. So the removal is differed into a work queue. This however
+ * means if the interface comes back before the work queue runs, the
+ * files are still there, and so the create gives an EEXISTS error. To
+ * avoid this, rename them to a tempory name.
+ */
+static void batadv_hardif_rename(struct batadv_hard_iface *hard_iface)
+{
+ batadv_sysfs_rename_hardif(&hard_iface->hardif_obj,
+ hard_iface->net_dev);
+ batadv_debugfs_rename_hardif(hard_iface);
+}
+
static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
{
ASSERT_RTNL();
@@ -760,6 +777,8 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
return;
hard_iface->if_status = BATADV_IF_TO_BE_REMOVED;
+ batadv_hardif_rename(hard_iface);
+
queue_work(batadv_event_workqueue, &hard_iface->cleanup_work);
}
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 233abcf..37b0aae 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -47,6 +47,8 @@
#include "packet.h"
#include "soft-interface.h"
+static atomic_t batadv_rename = ATOMIC_INIT(0);
+
static struct net_device *batadv_kobj_to_netdev(struct kobject *obj)
{
struct device *dev = container_of(obj->parent, struct device, kobj);
@@ -1045,6 +1047,21 @@ out:
return -ENOMEM;
}
+void batadv_sysfs_rename_hardif(struct kobject **hardif_obj,
+ struct net_device *dev)
+{
+ char new_name[32];
+ int err;
+
+ snprintf(new_name, sizeof(*new_name) - 1, "tmp-%d",
+ atomic_inc_return(&batadv_rename));
+
+ err = kobject_rename(*hardif_obj, new_name);
+ if (err)
+ batadv_err(dev, "Can't rename sysfs dir: %s/%s: %d\n",
+ dev->name, new_name, err);
+}
+
void batadv_sysfs_del_hardif(struct kobject **hardif_obj)
{
kobject_put(*hardif_obj);
diff --git a/net/batman-adv/sysfs.h b/net/batman-adv/sysfs.h
index c76021b..64d3722 100644
--- a/net/batman-adv/sysfs.h
+++ b/net/batman-adv/sysfs.h
@@ -48,6 +48,8 @@ void batadv_sysfs_del_meshif(struct net_device *dev);
int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
struct net_device *dev);
void batadv_sysfs_del_hardif(struct kobject **hardif_obj);
+void batadv_sysfs_rename_hardif(struct kobject **hardif_obj,
+ struct net_device *dev);
int batadv_sysfs_add_vlan(struct net_device *dev,
struct batadv_softif_vlan *vlan);
void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv,
--
2.8.0.rc3
batadv_send_skb_packet used by batadv_send_skb_to_orig and its return value
is given directly to callers of batadv_send_skb_packet.
batadv_send_skb_to_orig
-> batadv_send_unicast_skb
-> batadv_send_skb_packet
-> dev_queue_xmit
These callers of batadv_send_skb_to_orig expect that the skb isn't consumed
when they receive a -1. But dev_queue_xmit may still have consumed it and
still returned -1. Thus the free for the skb would be called twice.
Fixes: e3b8acbff9c8 ("batman-adv: return netdev status in the TX path")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
Antonio, this is not really tested. Could you please review it and tell me
if I may have missed something.
net/batman-adv/send.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 49836da..d76ccb2 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -72,6 +72,7 @@ int batadv_send_skb_packet(struct sk_buff *skb,
{
struct batadv_priv *bat_priv;
struct ethhdr *ethhdr;
+ int ret;
bat_priv = netdev_priv(hard_iface->soft_iface);
@@ -109,8 +110,15 @@ int batadv_send_skb_packet(struct sk_buff *skb,
/* dev_queue_xmit() returns a negative result on error. However on
* congestion and traffic shaping, it drops and returns NET_XMIT_DROP
* (which is > 0). This will not be treated as an error.
+ *
+ * a negative value cannot be returned because it could be interepreted
+ * as not consumed skb by callers of batadv_send_skb_to_orig.
*/
- return dev_queue_xmit(skb);
+ ret = dev_queue_xmit(skb);
+ if (ret < 0)
+ ret = NET_XMIT_DROP;
+
+ return ret;
send_skb_err:
kfree_skb(skb);
return NET_XMIT_DROP;
--
2.8.1