public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: Marek Lindner <lindner_marek@yahoo.de>
Cc: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [PATCHv2 6/6] batman-adv: Allow to modify slaves of soft-interfaces through rntl_link
Date: Sun, 13 Jan 2013 13:12:20 +0100	[thread overview]
Message-ID: <1405827.5RSdDMUrGW@sven-desktop.home.narfation.org> (raw)
In-Reply-To: <1358070663-8226-6-git-send-email-lindner_marek@yahoo.de>


[-- Attachment #1.1: Type: text/plain, Size: 798 bytes --]

On Sunday 13 January 2013 17:51:03 Marek Lindner wrote:
> From: Sven Eckelmann <sven@narfation.org>
> 
> The sysfs configuration interface of batman-adv to add/remove slaves of an
> soft-iface is not deadlock free and doesn't follow the currently common way
> to modify slaves of an interface.
> 
> An additional configuration interface though rtnl_link is introduced which
> provides easy device adding/removing with tools like "ip":
> $ ip link set dev eth0 master bat0
> $ ip link set dev eth0 nomaster
> 
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---


Master setting is missing. This is necessary on current kernels to use 
"nomaster" of ip. Also reference counting is br0ken. An example patch is added 
(just to explain things... it will not apply directly).

Kind regards,
	Sven

[-- Attachment #1.2: fixes.patch --]
[-- Type: text/x-patch, Size: 2341 bytes --]

diff --git a/hard-interface.c b/hard-interface.c
index 5e2655d..c5c7f13 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -349,9 +349,16 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
 	hard_iface->soft_iface = soft_iface;
 	bat_priv = netdev_priv(hard_iface->soft_iface);
 
+	ret = netdev_set_master(hard_iface->net_dev, hard_iface->soft_iface);
+	if (ret) {
+		batadv_err(hard_iface->soft_iface,
+			   "Device %s failed to set master\n", iface_name);
+		goto err_dev;
+	}
+
 	ret = bat_priv->bat_algo_ops->bat_iface_enable(hard_iface);
 	if (ret < 0)
-		goto err_dev;
+		goto err_enable;
 
 	hard_iface->if_num = bat_priv->num_ifaces;
 	bat_priv->num_ifaces++;
@@ -361,7 +368,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
 		bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
 		bat_priv->num_ifaces--;
 		hard_iface->if_status = BATADV_IF_NOT_IN_USE;
-		goto err_dev;
+		goto err_enable;
 	}
 
 	hard_iface->batman_adv_ptype.type = ethertype;
@@ -400,6 +407,8 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
 out:
 	return 0;
 
+err_enable:
+	netdev_set_master(hard_iface->net_dev, NULL);
 err_dev:
 	dev_put(soft_iface);
 err:
@@ -450,6 +459,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
 		batadv_softif_destroy(hard_iface->soft_iface, NULL);
 
 	hard_iface->soft_iface = NULL;
+	netdev_set_master(hard_iface->net_dev, NULL);
 	batadv_hardif_free_ref(hard_iface);
 
 out:
diff --git a/soft-interface.c b/soft-interface.c
index 3cafe50..54eb2a9 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -486,12 +486,15 @@ static int batadv_add_slave(struct net_device *dev,
 			    struct net_device *slave_dev)
 {
 	struct batadv_hard_iface *hard_iface;
+	int ret;
 
 	hard_iface = batadv_hardif_get_by_netdev(slave_dev);
 	if (!hard_iface || hard_iface->soft_iface != NULL)
 		return -EINVAL;
 
-	return batadv_hardif_enable_interface(hard_iface, dev->name);
+	ret = batadv_hardif_enable_interface(hard_iface, dev->name);
+	batadv_hardif_free_ref(hard_iface);
+	return ret;
 }
 
 /**
@@ -509,6 +512,7 @@ static int batadv_del_slave(struct net_device *dev,
 		return -EINVAL;
 
 	batadv_hardif_disable_interface(hard_iface, BATADV_IF_CLEANUP_KEEP);
+	batadv_hardif_free_ref(hard_iface);
 	return 0;
 }
 

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-01-13 12:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-13  9:50 [B.A.T.M.A.N.] create batman-adv interfaces with netlink v2 Marek Lindner
2013-01-13  9:50 ` [B.A.T.M.A.N.] [PATCHv2 1/6] batman-adv: Move soft-interface initialization to ndo_init Marek Lindner
2013-01-13  9:50   ` [B.A.T.M.A.N.] [PATCHv2 2/6] batman-adv: Move deinitialization of soft-interface to destructor Marek Lindner
2013-01-13  9:51   ` [B.A.T.M.A.N.] [PATCHv2 3/6] batman-adv: Don't always delete softif when last slave was removed Marek Lindner
2013-01-13  9:51   ` [B.A.T.M.A.N.] [PATCHv2 4/6] batman-adv: rename batadv_softif_destroy to reflect sysfs use case Marek Lindner
2013-01-13  9:51   ` [B.A.T.M.A.N.] [PATCHv2 5/6] batman-adv: Allow to use rntl_link for device creation/deletion Marek Lindner
2013-01-13  9:51   ` [B.A.T.M.A.N.] [PATCHv2 6/6] batman-adv: Allow to modify slaves of soft-interfaces through rntl_link Marek Lindner
2013-01-13 12:12     ` Sven Eckelmann [this message]
2013-02-03 18:41       ` [B.A.T.M.A.N.] [FIX] batman-adv: fix master setting in rtnl interface Antonio Quartulli
2013-02-03 18:49         ` Antonio Quartulli
2013-02-03 19:02         ` [B.A.T.M.A.N.] [FIXv2] " Antonio Quartulli
2013-02-09 11:06           ` Marek Lindner
2013-02-09 21:20             ` Antonio Quartulli
2013-01-13 10:00 ` [B.A.T.M.A.N.] create batman-adv interfaces with netlink v2 Sven Eckelmann
2013-01-13 11:08   ` Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405827.5RSdDMUrGW@sven-desktop.home.narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=lindner_marek@yahoo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox