* Re: [PATCH 0/3] net: usb: cdc_ether: improve telit support and code cleanups
From: David Miller @ 2013-09-17 1:38 UTC (permalink / raw)
To: fabio.porcedda-Re5JQEeQqe8AvxtiuMwx3w
Cc: oliver-GvhC2dPhHPQdnm+yROfE0A, linux-usb-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1379324872-15944-1-git-send-email-fabio.porcedda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Fabio Porcedda <fabio.porcedda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Mon, 16 Sep 2013 11:47:49 +0200
> Some patches to improve telit modules support and to cleanup the code.
Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH net] ip6_tunnels: raddr and laddr are inverted in nl msg
From: David Miller @ 2013-09-17 1:36 UTC (permalink / raw)
To: nicolas.dichtel; +Cc: netdev, zhi.ding
In-Reply-To: <1379323875-3794-1-git-send-email-nicolas.dichtel@6wind.com>
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Mon, 16 Sep 2013 11:31:15 +0200
> From: Ding Zhi <zhi.ding@6wind.com>
>
> IFLA_IPTUN_LOCAL and IFLA_IPTUN_REMOTE were inverted.
>
> Introduced by c075b13098b3 (ip6tnl: advertise tunnel param via rtnl).
>
> Signed-off-by: Ding Zhi <zhi.ding@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply
* Re: [PATCH net-next] net loopback: Set loopback_dev to NULL when freed
From: David Miller @ 2013-09-17 1:34 UTC (permalink / raw)
To: eric.dumazet
Cc: ebiederm, edumazet, jiri, alexander.h.duyck, amwang, netdev,
fruggeri
In-Reply-To: <1379379051.4751.0.camel@edumazet-glaptop>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 16 Sep 2013 17:50:51 -0700
> On Mon, 2013-09-16 at 16:52 -0700, Eric W. Biederman wrote:
>> It has recently turned up that we have a number of long standing bugs
>> in the network stack cleanup code with use of the loopback device
>> after it has been freed that have not turned up because in most cases
>> the storage allocated to the loopback device is not reused, when those
>> accesses happen.
>>
>> Set looback_dev to NULL to trigger oopses instead of silent data corrupt
>> when we hit this class of bug.
>>
>> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
>> ---
>
> Acked-by: Eric Dumazet <edumazet@google.com>
I'd like to apply this to 'net', any objections?
^ permalink raw reply
* Re: [PATCH] bgmac: implement unaligned addressing for DMA rings that support it
From: David Miller @ 2013-09-17 1:31 UTC (permalink / raw)
To: zajec5; +Cc: netdev, hauke
In-Reply-To: <1379279598-25274-1-git-send-email-zajec5@gmail.com>
From: Rafał Miłecki <zajec5@gmail.com>
Date: Sun, 15 Sep 2013 23:13:18 +0200
> This is important patch for new devices that support unaligned
> addressing. That devices suffer from the backward-compatibility bug in
> DMA engine. In theory we should be able to use old mechanism, but in
> practice DMA address seems to be randomly copied into status register
> when hardware reaches end of a ring. This breaks reading slot number
> from status register and we can't use DMA anymore.
>
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Applied.
^ permalink raw reply
* Re: [PATCH V2] bgmac: allow bigger et_swtype nvram variable
From: David Miller @ 2013-09-17 1:31 UTC (permalink / raw)
To: zajec5; +Cc: netdev, hauke
In-Reply-To: <1379278148-6966-1-git-send-email-zajec5@gmail.com>
From: Rafał Miłecki <zajec5@gmail.com>
Date: Sun, 15 Sep 2013 22:49:08 +0200
> From: Hauke Mehrtens <hauke@hauke-m.de>
>
> Without this patch it is impossible to read et_swtype, because the 1
> byte space is needed for the terminating null byte. The max expected
> value is 0xF, so now it should be possible to read decimal form ("15")
> and hex form ("0xF").
>
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Applied.
^ permalink raw reply
* Re: [PATCH] bgmac: fix internal switch initialization
From: David Miller @ 2013-09-17 1:31 UTC (permalink / raw)
To: zajec5; +Cc: netdev, hauke, stable
In-Reply-To: <1379197367-19116-1-git-send-email-zajec5@gmail.com>
From: Rafał Miłecki <zajec5@gmail.com>
Date: Sun, 15 Sep 2013 00:22:47 +0200
> Some devices (BCM4749, BCM5357, BCM53572) have internal switch that
> requires initialization. We already have code for this, but because
> of the typo in code it was never working. This resulted in network not
> working for some routers and possibility of soft-bricking them.
>
> Use correct bit for switch initialization and fix typo in the define.
>
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Applied.
^ permalink raw reply
* Re: [patch 1/4] drivers/net/ethernet/ibm/ehea/ehea_main.c: add alias entry for portN properties
From: David Miller @ 2013-09-17 1:29 UTC (permalink / raw)
To: cascardo; +Cc: akpm, netdev, ohering, jeffm, jslaby
In-Reply-To: <20130916210141.GB14221@oc0268524204.ibm.com>
From: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Date: Mon, 16 Sep 2013 18:01:41 -0300
> Sorry for the noise. I just checked again the bug, and had to read
> between the lines that this issue might happen with the generation of
> initrd, when the scripts check for /sys/class/net/eth0/device/modalias,
> which links to the port device at
> /sys/devices/ibmebus/23c00400.lhea/port0/.
>
> I think that should be clarified in the log message. Besides that, since
> this has also been in the field for a long time:
>
> Acked-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
I adjusted the commit message and applied this, thanks.
^ permalink raw reply
* Re: [PATCH v3 net-next 07/27] net: add for_each iterators through neighbour lower link's private
From: Ben Hutchings @ 2013-09-17 1:26 UTC (permalink / raw)
To: Veaceslav Falico
Cc: netdev, jiri, David S. Miller, Eric Dumazet, Alexander Duyck
In-Reply-To: <1379378812-18346-8-git-send-email-vfalico@redhat.com>
On Tue, 2013-09-17 at 02:46 +0200, Veaceslav Falico wrote:
[...]
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -4537,6 +4537,72 @@ struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev,
> }
> EXPORT_SYMBOL(netdev_all_upper_get_next_dev_rcu);
>
> +/* netdev_lower_get_next_private - Get the next ->private from the
> + * lower neighbour list
[...]
This is not correct kernel-doc syntax. You must begin the comment like
this:
/**
* function_name - summary on one physical line, no wrapping allowed
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [PATCH] net, mellanox mlx4 Fix compile warnings
From: David Miller @ 2013-09-17 1:25 UTC (permalink / raw)
To: prarit; +Cc: netdev, dledford, amirv, ogerlitz
In-Reply-To: <1379075438-20240-1-git-send-email-prarit@redhat.com>
From: Prarit Bhargava <prarit@redhat.com>
Date: Fri, 13 Sep 2013 08:30:38 -0400
> @@ -2563,7 +2563,7 @@ int mlx4_HW2SW_CQ_wrapper(struct mlx4_dev *dev, int slave,
> {
> int err;
> int cqn = vhcr->in_modifier;
> - struct res_cq *cq;
> + struct res_cq *uninitialized_var(cq);
>
> err = cq_res_start_move_to(dev, slave, cqn, RES_CQ_ALLOCATED, &cq);
> if (err)
This gross annotation is not necessary.
Make cq_res_start_move_to() return 'cq' as an error pointer instead of
setting 'cq' by reference.
^ permalink raw reply
* Re: [PATCH] net, vxlan Fix compile warning
From: David Miller @ 2013-09-17 1:23 UTC (permalink / raw)
To: prarit; +Cc: netdev, jpirko, tgraf
In-Reply-To: <1379075352-20051-1-git-send-email-prarit@redhat.com>
From: Prarit Bhargava <prarit@redhat.com>
Date: Fri, 13 Sep 2013 08:29:12 -0400
> Fix a unintialized variable warning.
>
> drivers/net/vxlan.c: In function ‘vxlan_sock_add’:
> drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> vs->sock = sock;
> ^
> drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here
> struct socket *sock;
> ^
>
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Make create_v{4,6}_sock() return an err pointer.
Problem solved and no incredibly ugly, unnecessary, annotations.
The error code return from these functions already gets turned into
and error pointer at the call site, which makes this situation even
more rediculous.
^ permalink raw reply
* Re: [PATCH v3 net-next 02/27] net: add RCU variant to search for netdev_adjacent link
From: Ben Hutchings @ 2013-09-17 1:23 UTC (permalink / raw)
To: Veaceslav Falico
Cc: netdev, jiri, David S. Miller, Eric Dumazet, Alexander Duyck,
Cong Wang
In-Reply-To: <1379378812-18346-3-git-send-email-vfalico@redhat.com>
On Tue, 2013-09-17 at 02:46 +0200, Veaceslav Falico wrote:
> Currently we have only the RTNL flavour, however we can traverse it while
> holding only RCU, so add the RCU search. Add only one function that will be
> used further, other functions can be added easily afterwards, if anyone
> would need them.
[...]
> +static struct netdev_adjacent *__netdev_find_adj_rcu(struct net_device *dev,
> + struct net_device *adj_dev,
> + bool upper, bool neighbour)
> +{
> + struct netdev_adjacent *adj;
> + struct list_head *adj_list;
> +
> + if (neighbour)
> + adj_list = upper ? &dev->adj_list.upper :
> + &dev->adj_list.lower;
> + else
> + adj_list = upper ? &dev->all_adj_list.upper :
> + &dev->all_adj_list.lower;
I think it would be clearer to make adj_list a parameter, rather than
taking the dev and a pair of booleans.
Ben.
> + list_for_each_entry_rcu(adj, adj_list, list) {
> + if (adj->dev == adj_dev)
> + return adj;
> + }
> + return NULL;
> +}
> +
> +static struct netdev_adjacent *__netdev_lower_find_rcu(struct net_device *dev,
> + struct net_device *ldev)
> +{
> + return __netdev_find_adj_rcu(dev, ldev, false, true);
> +}
> +
> static struct netdev_adjacent *__netdev_find_adj(struct net_device *dev,
> struct net_device *adj_dev,
> bool upper, bool neighbour)
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* [PATCH net RFC 2/2] ixgbe: fix sleep bug caused by napi_disable inside local_bh_disable()d context
From: Jacob Keller @ 2013-09-17 0:59 UTC (permalink / raw)
To: netdev
In-Reply-To: <20130917005703.13357.70276.stgit@jekeller-desk1.amr.corp.intel.com>
This patch fixes a bug caused by calling napi_disable after local_bh_disable.
It is possible for napi_disable to sleep, (though not guarunteed) so it could
cause an atomic sleep bug during the schedule() call in msleep. This patch
resolves the issue by moving the local_bh_disable() calls inside the for loop
in ixgbe_napi_disable_all().
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Cc: Eliezer Tamir <eliezer.tamir@linux.intel.com>
Cc: Alexander Duyck <alexander.duyck@intel.com>
Cc: Hyong-Youb Kim <hykim@myri.com>
Cc: Amir Vadai <amirv@mellanox.com>
Cc: Dmitry Kravkov <dmitry@broadcom.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index ce3eb60..39b3424 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3891,15 +3891,15 @@ static void ixgbe_napi_disable_all(struct ixgbe_adapter *adapter)
{
int q_idx;
- local_bh_disable(); /* for ixgbe_qv_lock_napi() */
for (q_idx = 0; q_idx < adapter->num_q_vectors; q_idx++) {
napi_disable(&adapter->q_vector[q_idx]->napi);
+ local_bh_disable(); /* for ixgbe_qv_lock_napi() */
while (!ixgbe_qv_lock_napi(adapter->q_vector[q_idx])) {
pr_info("QV %d locked\n", q_idx);
mdelay(1);
}
+ local_bh_enable();
}
- local_bh_enable();
}
#ifdef CONFIG_IXGBE_DCB
^ permalink raw reply related
* [PATCH net RFC 1/2] netdevice: add might_sleep() call to napi_disable
From: Jacob Keller @ 2013-09-17 0:59 UTC (permalink / raw)
To: netdev
In-Reply-To: <20130917005703.13357.70276.stgit@jekeller-desk1.amr.corp.intel.com>
napi_disable potentially calls msleep(1) if the NAPI_STATE_SCHED bit is
previously set by something else. Because it does not always call msleep, it
was difficult to track down a bug related to calling napi_disable within
local_bh_disable()d context. This patch adds a might_sleep() call to the
napi_disable routine in order to aid in the future debugging of similar issues.
This will cause a BUG in drivers which have implemented busy polling in a
similar fashion to ixgbe, and which call napi_disable inside the
local_bh_disable()d section where the vector napi lock is taken.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Cc: Eliezer Tamir <eliezer.tamir@linux.intel.com>
Cc: Alex Duyck <alexander.h.duyck@intel.com>
Cc: Hyong-Youb Kim <hykim@myri.com>
Cc: Amir Vadai <amirv@mellanox.com>
Cc: Dmitry Kravkov <dmitry@broadcom.com>
---
include/linux/netdevice.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 041b42a..5e3ef61 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -483,6 +483,8 @@ extern void napi_hash_del(struct napi_struct *napi);
*/
static inline void napi_disable(struct napi_struct *n)
{
+ might_sleep();
+
set_bit(NAPI_STATE_DISABLE, &n->state);
while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
msleep(1);
^ permalink raw reply related
* [PATCH net RFC 0/2] Series short description
From: Jacob Keller @ 2013-09-17 0:59 UTC (permalink / raw)
To: netdev
This series contains patches which help resolve a 'sleeping function called
from invalid context' bug introduced by the busy polling code. The first patch
simply adds a might_sleep() call to napi_disable. The second patch provides the
actual fix for the sleeping during a local_bh_disable()d section of code. I
tried to Cc everyone that might be interested in the solution, as I am unsure
if my solution of moving the local_bh_disable() call is correct.
---
Jacob Keller (2):
netdevice: add might_sleep() call to napi_disable
ixgbe: fix sleep bug caused by napi_disable inside local_bh_disable()d context
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++--
include/linux/netdevice.h | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
--
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply
* Re: [PATCH net-next] net loopback: Set loopback_dev to NULL when freed
From: Eric Dumazet @ 2013-09-17 0:50 UTC (permalink / raw)
To: Eric W. Biederman
Cc: David S. Miller, Eric Dumazet, Jiri Pirko, Alexander Duyck,
Cong Wang, netdev, Francesco Ruggeri
In-Reply-To: <87k3iggw8m.fsf_-_@xmission.com>
On Mon, 2013-09-16 at 16:52 -0700, Eric W. Biederman wrote:
> It has recently turned up that we have a number of long standing bugs
> in the network stack cleanup code with use of the loopback device
> after it has been freed that have not turned up because in most cases
> the storage allocated to the loopback device is not reused, when those
> accesses happen.
>
> Set looback_dev to NULL to trigger oopses instead of silent data corrupt
> when we hit this class of bug.
>
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
> ---
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply
* [PATCH v3 net-next 27/27] net: create sysfs symlinks for neighbour devices
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev
Cc: jiri, Veaceslav Falico, Jay Vosburgh, Andy Gospodarek,
David S. Miller, Eric Dumazet, Alexander Duyck
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
Also, remove the same functionality from bonding - it will be already done
for any device that links to its lower/upper neighbour.
The links will be created for dev's kobject, and will look like
lower_eth0 for lower device eth0 and upper_bridge0 for upper device
bridge0.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <jiri@resnulli.us>
CC: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v1:
Rename lower devices from slave_eth0 to lower_eth0, so that it meets
the lower/upper naming. I've searched for any active users of bonding's
slave_eth0, and seems that nobody's actively using it or relying on it.
drivers/net/bonding/bond_main.c | 11 +----------
drivers/net/bonding/bond_sysfs.c | 25 -------------------------
drivers/net/bonding/bonding.h | 2 --
net/core/dev.c | 29 +++++++++++++++++++++++++++++
4 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 707b0bc..2c0e4a5 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1612,15 +1612,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
read_unlock(&bond->lock);
- res = bond_create_slave_symlinks(bond_dev, slave_dev);
- if (res)
- goto err_detach;
-
res = netdev_rx_handler_register(slave_dev, bond_handle_frame,
new_slave);
if (res) {
pr_debug("Error %d calling netdev_rx_handler_register\n", res);
- goto err_dest_symlinks;
+ goto err_detach;
}
res = bond_master_upper_dev_link(bond_dev, slave_dev, new_slave);
@@ -1642,9 +1638,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
err_unregister:
netdev_rx_handler_unregister(slave_dev);
-err_dest_symlinks:
- bond_destroy_slave_symlinks(bond_dev, slave_dev);
-
err_detach:
if (!USES_PRIMARY(bond->params.mode))
bond_hw_addr_flush(bond_dev, slave_dev);
@@ -1842,8 +1835,6 @@ static int __bond_release_one(struct net_device *bond_dev,
bond_dev->name, slave_dev->name, bond_dev->name);
/* must do this from outside any spinlocks */
- bond_destroy_slave_symlinks(bond_dev, slave_dev);
-
vlan_vids_del_by_dev(slave_dev, bond_dev);
/* If the mode USES_PRIMARY, then this cases was handled above by
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index fd178a4..ef75471 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -168,31 +168,6 @@ static const struct class_attribute class_attr_bonding_masters = {
.namespace = bonding_namespace,
};
-int bond_create_slave_symlinks(struct net_device *master,
- struct net_device *slave)
-{
- char linkname[IFNAMSIZ+7];
- int ret = 0;
-
- /* create a link from the master to the slave */
- sprintf(linkname, "slave_%s", slave->name);
- ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj),
- linkname);
-
- return ret;
-
-}
-
-void bond_destroy_slave_symlinks(struct net_device *master,
- struct net_device *slave)
-{
- char linkname[IFNAMSIZ+7];
-
- sprintf(linkname, "slave_%s", slave->name);
- sysfs_remove_link(&(master->dev.kobj), linkname);
-}
-
-
/*
* Show the slaves in the current bond.
*/
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 0e8e00e..74efa45 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -410,8 +410,6 @@ int bond_create(struct net *net, const char *name);
int bond_create_sysfs(struct bond_net *net);
void bond_destroy_sysfs(struct bond_net *net);
void bond_prepare_sysfs_group(struct bonding *bond);
-int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave);
-void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave);
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
void bond_mii_monitor(struct work_struct *);
diff --git a/net/core/dev.c b/net/core/dev.c
index 27ca03f..5fe2dd0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4638,6 +4638,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
bool upper, void *private)
{
struct netdev_adjacent *adj, *neigh = NULL;
+ char linkname[IFNAMSIZ+7];
int ret;
adj = __netdev_find_adj(dev, adj_dev, upper, false);
@@ -4685,6 +4686,16 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
*/
if (master)
neigh->private = private;
+
+ sprintf(linkname, "lower_%s", adj_dev->name);
+ ret = sysfs_create_link(&(dev->dev.kobj),
+ &(adj_dev->dev.kobj),
+ linkname);
+ if (ret) {
+ kfree(neigh);
+ kfree(adj);
+ return ret;
+ }
list_add_tail_rcu(&neigh->list,
&dev->adj_list.lower);
}
@@ -4692,10 +4703,24 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
return 0;
}
+ /* it's upper neighbour, we don't care if it's master or not */
+ if (neigh) {
+ sprintf(linkname, "upper_%s", adj_dev->name);
+ ret = sysfs_create_link(&(dev->dev.kobj), &(adj_dev->dev.kobj),
+ linkname);
+ if (ret) {
+ kfree(neigh);
+ kfree(adj);
+ return ret;
+ }
+ }
+
/* Ensure that master upper link is always the first item in list. */
if (master) {
ret = sysfs_create_link(&(dev->dev.kobj), &(adj_dev->dev.kobj), "master");
if (ret) {
+ if (neigh)
+ sysfs_remove_link(&(dev->dev.kobj), linkname);
kfree(neigh);
kfree(adj);
return ret;
@@ -4736,6 +4761,7 @@ void __netdev_adjacent_dev_remove(struct net_device *dev,
bool is_neigh)
{
struct netdev_adjacent *adj, *neighbour;
+ char linkname[IFNAMSIZ+7];
if (upper) {
adj = __netdev_all_upper_find(dev, adj_dev);
@@ -4758,6 +4784,9 @@ void __netdev_adjacent_dev_remove(struct net_device *dev,
adj_dev->name);
if (neighbour->master && upper)
sysfs_remove_link(&(dev->dev.kobj), "master");
+ sprintf(linkname, "%s_%s", upper ? "upper" : "lower",
+ adj_dev->name);
+ sysfs_remove_link(&(dev->dev.kobj), linkname);
list_del_rcu(&neighbour->list);
dev_put(adj_dev);
kfree_rcu(neighbour, rcu);
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 20/27] bonding: remove bond_prev_slave()
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev; +Cc: jiri, Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
We don't really need it, and it's really hard to RCUify the list->prev.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v1:
New patch.
drivers/net/bonding/bond_main.c | 9 +++------
drivers/net/bonding/bonding.h | 4 ----
2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c91b754..65eae12 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1255,7 +1255,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
{
struct bonding *bond = netdev_priv(bond_dev);
const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
- struct slave *new_slave = NULL;
+ struct slave *new_slave = NULL, *prev_slave;
struct sockaddr addr;
int link_reporting;
int res = 0, i;
@@ -1472,6 +1472,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
write_lock_bh(&bond->lock);
+ prev_slave = bond_last_slave(bond);
bond_attach_slave(bond, new_slave);
new_slave->delay = 0;
@@ -1566,9 +1567,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
*/
bond_3ad_initialize(bond, 1000/AD_TIMER_INTERVAL);
} else {
- struct slave *prev_slave;
-
- prev_slave = bond_prev_slave(bond, new_slave);
SLAVE_AD_INFO(new_slave).id =
SLAVE_AD_INFO(prev_slave).id + 1;
}
@@ -3506,9 +3504,8 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
*/
bond_for_each_slave(bond, slave, iter) {
- pr_debug("s %p s->p %p c_m %p\n",
+ pr_debug("s %p c_m %p\n",
slave,
- bond_prev_slave(bond, slave),
slave->dev->netdev_ops->ndo_change_mtu);
res = dev_set_mtu(slave->dev, new_mtu);
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index b82474d..03daadd 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -96,10 +96,6 @@
(bond_is_last_slave(bond, pos) ? bond_first_slave(bond) : \
bond_to_slave((pos)->list.next))
-#define bond_prev_slave(bond, pos) \
- (bond_is_first_slave(bond, pos) ? bond_last_slave(bond) : \
- bond_to_slave((pos)->list.prev))
-
/**
* bond_for_each_slave - iterate over all slaves
* @bond: the bond holding this list
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 12/27] bonding: rework rlb_next_rx_slave() to use bond_for_each_slave()
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev; +Cc: jiri, Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
Currently, we're using bond_for_each_slave_from(), which is really hard to
implement under RCU and/or neighbour list.
Remove it and use bond_for_each_slave() instead, taking care of the last
used slave.
Also, rename next_rx_slave to rx_slave and store the current (last)
rx_slave.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v1:
New patch.
drivers/net/bonding/bond_alb.c | 41 +++++++++++++++++++++--------------------
drivers/net/bonding/bond_alb.h | 4 +---
2 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index caa437d..1172474 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -383,30 +383,31 @@ out:
static struct slave *rlb_next_rx_slave(struct bonding *bond)
{
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
- struct slave *rx_slave, *slave, *start_at;
- int i = 0;
-
- if (bond_info->next_rx_slave)
- start_at = bond_info->next_rx_slave;
- else
- start_at = bond_first_slave(bond);
-
- rx_slave = NULL;
+ struct slave *before = NULL, *rx_slave = NULL, *slave;
+ struct list_head *iter;
+ bool found = false;
- bond_for_each_slave_from(bond, slave, i, start_at) {
- if (SLAVE_IS_OK(slave)) {
- if (!rx_slave) {
- rx_slave = slave;
- } else if (slave->speed > rx_slave->speed) {
+ bond_for_each_slave(bond, slave, iter) {
+ if (!SLAVE_IS_OK(slave))
+ continue;
+ if (!found) {
+ if (!before || before->speed < slave->speed)
+ before = slave;
+ } else {
+ if (!rx_slave || rx_slave->speed < slave->speed)
rx_slave = slave;
- }
}
+ if (slave == bond_info->rx_slave)
+ found = true;
}
+ /* we didn't find anything after the current or we have something
+ * better before and up to the current slave
+ */
+ if (!rx_slave || (before && rx_slave->speed < before->speed))
+ rx_slave = before;
- if (rx_slave) {
- slave = bond_next_slave(bond, rx_slave);
- bond_info->next_rx_slave = slave;
- }
+ if (rx_slave)
+ bond_info->rx_slave = rx_slave;
return rx_slave;
}
@@ -1611,7 +1612,7 @@ void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
tlb_clear_slave(bond, slave, 0);
if (bond->alb_info.rlb_enabled) {
- bond->alb_info.next_rx_slave = NULL;
+ bond->alb_info.rx_slave = NULL;
rlb_clear_slave(bond, slave);
}
}
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index 28d8e4c..7736ce2 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -153,9 +153,7 @@ struct alb_bond_info {
u8 rx_ntt; /* flag - need to transmit
* to all rx clients
*/
- struct slave *next_rx_slave;/* next slave to be assigned
- * to a new rx client for
- */
+ struct slave *rx_slave;/* last slave to xmit from */
u8 primary_is_promisc; /* boolean */
u32 rlb_promisc_timeout_counter;/* counts primary
* promiscuity time
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 05/27] bonding: populate neighbour's private on enslave
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev; +Cc: jiri, Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
Use the new provided function when attaching the lower slave to populate
its ->private with struct slave *new_slave. Also, move it to the end to
be able to 'find' it only after it was completely initialized, and
deinitialize in the first place on release.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v1:
Move the patch right after the introduction of ->private, to immediately
use it - easier for review and more logical.
drivers/net/bonding/bond_main.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 72bdb8b..f862dc8 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1233,11 +1233,12 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
}
static int bond_master_upper_dev_link(struct net_device *bond_dev,
- struct net_device *slave_dev)
+ struct net_device *slave_dev,
+ struct slave *slave)
{
int err;
- err = netdev_master_upper_dev_link(slave_dev, bond_dev);
+ err = netdev_master_upper_dev_link_private(slave_dev, bond_dev, slave);
if (err)
return err;
slave_dev->flags |= IFF_SLAVE;
@@ -1413,17 +1414,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
}
}
- res = bond_master_upper_dev_link(bond_dev, slave_dev);
- if (res) {
- pr_debug("Error %d calling bond_master_upper_dev_link\n", res);
- goto err_restore_mac;
- }
-
/* open the slave since the application closed it */
res = dev_open(slave_dev);
if (res) {
pr_debug("Opening slave %s failed\n", slave_dev->name);
- goto err_unset_master;
+ goto err_restore_mac;
}
new_slave->bond = bond;
@@ -1637,6 +1632,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
goto err_dest_symlinks;
}
+ res = bond_master_upper_dev_link(bond_dev, slave_dev, new_slave);
+ if (res) {
+ pr_debug("Error %d calling bond_master_upper_dev_link\n", res);
+ goto err_unregister;
+ }
+
+
pr_info("%s: enslaving %s as a%s interface with a%s link.\n",
bond_dev->name, slave_dev->name,
bond_is_active_slave(new_slave) ? "n active" : " backup",
@@ -1646,6 +1648,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
return 0;
/* Undo stages on error */
+err_unregister:
+ netdev_rx_handler_unregister(slave_dev);
+
err_dest_symlinks:
bond_destroy_slave_symlinks(bond_dev, slave_dev);
@@ -1675,9 +1680,6 @@ err_close:
slave_dev->priv_flags &= ~IFF_BONDING;
dev_close(slave_dev);
-err_unset_master:
- bond_upper_dev_unlink(bond_dev, slave_dev);
-
err_restore_mac:
if (!bond->params.fail_over_mac) {
/* XXX TODO - fom follow mode needs to change master's
@@ -1748,6 +1750,8 @@ static int __bond_release_one(struct net_device *bond_dev,
}
write_unlock_bh(&bond->lock);
+
+ bond_upper_dev_unlink(bond_dev, slave_dev);
/* unregister rx_handler early so bond_handle_frame wouldn't be called
* for this slave anymore.
*/
@@ -1866,8 +1870,6 @@ static int __bond_release_one(struct net_device *bond_dev,
bond_hw_addr_flush(bond_dev, slave_dev);
}
- bond_upper_dev_unlink(bond_dev, slave_dev);
-
slave_disable_netpoll(slave);
/* close slave before restoring its mac address */
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 26/27] net: expose the master link to sysfs, and remove it from bond
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev
Cc: jiri, Veaceslav Falico, Jay Vosburgh, Andy Gospodarek,
David S. Miller, Eric Dumazet, Alexander Duyck
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
Currently, we can have only one master upper neighbour, so it would be
useful to create a symlink to it in the sysfs device directory, the way
that bonding now does it, for every device. Lower devices from
bridge/team/etc will automagically get it, so we could rely on it.
Also, remove the same functionality from bonding.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <jiri@resnulli.us>
CC: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v1:
No changes.
drivers/net/bonding/bond_sysfs.c | 12 +-----------
net/core/dev.c | 9 +++++++++
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 5d40889..fd178a4 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -174,20 +174,11 @@ int bond_create_slave_symlinks(struct net_device *master,
char linkname[IFNAMSIZ+7];
int ret = 0;
- /* first, create a link from the slave back to the master */
- ret = sysfs_create_link(&(slave->dev.kobj), &(master->dev.kobj),
- "master");
- if (ret)
- return ret;
- /* next, create a link from the master to the slave */
+ /* create a link from the master to the slave */
sprintf(linkname, "slave_%s", slave->name);
ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj),
linkname);
- /* free the master link created earlier in case of error */
- if (ret)
- sysfs_remove_link(&(slave->dev.kobj), "master");
-
return ret;
}
@@ -197,7 +188,6 @@ void bond_destroy_slave_symlinks(struct net_device *master,
{
char linkname[IFNAMSIZ+7];
- sysfs_remove_link(&(slave->dev.kobj), "master");
sprintf(linkname, "slave_%s", slave->name);
sysfs_remove_link(&(master->dev.kobj), linkname);
}
diff --git a/net/core/dev.c b/net/core/dev.c
index d58ca53..27ca03f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4638,6 +4638,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
bool upper, void *private)
{
struct netdev_adjacent *adj, *neigh = NULL;
+ int ret;
adj = __netdev_find_adj(dev, adj_dev, upper, false);
@@ -4693,6 +4694,12 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
/* Ensure that master upper link is always the first item in list. */
if (master) {
+ ret = sysfs_create_link(&(dev->dev.kobj), &(adj_dev->dev.kobj), "master");
+ if (ret) {
+ kfree(neigh);
+ kfree(adj);
+ return ret;
+ }
if (neigh)
list_add_rcu(&neigh->list,
&dev->adj_list.upper);
@@ -4749,6 +4756,8 @@ void __netdev_adjacent_dev_remove(struct net_device *dev,
pr_debug("dev_put for %s, because of %s link removed from %s to %s (neighbour)\n",
adj_dev->name, upper ? "upper" : "lower", dev->name,
adj_dev->name);
+ if (neighbour->master && upper)
+ sysfs_remove_link(&(dev->dev.kobj), "master");
list_del_rcu(&neighbour->list);
dev_put(adj_dev);
kfree_rcu(neighbour, rcu);
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 24/27] vlan: link the upper neighbour only after registering
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev; +Cc: jiri, Veaceslav Falico, Patrick McHardy, David S. Miller
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
Otherwise users might access it without being fully registered, as per
sysfs - it only inits in register_netdevice(), so is unusable till it is
called.
CC: Patrick McHardy <kaber@trash.net>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v1:
No changes.
net/8021q/vlan.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 61fc573..69b4a35 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -169,13 +169,13 @@ int register_vlan_dev(struct net_device *dev)
if (err < 0)
goto out_uninit_mvrp;
- err = netdev_upper_dev_link(real_dev, dev);
- if (err)
- goto out_uninit_mvrp;
-
err = register_netdevice(dev);
if (err < 0)
- goto out_upper_dev_unlink;
+ goto out_uninit_mvrp;
+
+ err = netdev_upper_dev_link(real_dev, dev);
+ if (err)
+ goto out_unregister_netdev;
/* Account for reference in struct vlan_dev_priv */
dev_hold(real_dev);
@@ -191,8 +191,8 @@ int register_vlan_dev(struct net_device *dev)
return 0;
-out_upper_dev_unlink:
- netdev_upper_dev_unlink(real_dev, dev);
+out_unregister_netdev:
+ unregister_netdevice(dev);
out_uninit_mvrp:
if (grp->nr_vlan_devs == 0)
vlan_mvrp_uninit_applicant(real_dev);
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 25/27] vlan: unlink the upper neighbour before unregistering
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev; +Cc: jiri, Veaceslav Falico, Patrick McHardy, David S. Miller
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
On netdev unregister we're removing also all of its sysfs-associated stuff,
including the sysfs symlinks that are controlled by netdev neighbour code.
Also, it's a subtle race condition - cause we can still access it after
unregistering.
Move the unlinking right before the unregistering to fix both.
CC: Patrick McHardy <kaber@trash.net>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v2:
New patch.
net/8021q/vlan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 69b4a35..b3d17d1 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -98,14 +98,14 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
vlan_gvrp_request_leave(dev);
vlan_group_set_device(grp, vlan->vlan_proto, vlan_id, NULL);
+
+ netdev_upper_dev_unlink(real_dev, dev);
/* Because unregister_netdevice_queue() makes sure at least one rcu
* grace period is respected before device freeing,
* we dont need to call synchronize_net() here.
*/
unregister_netdevice_queue(dev, head);
- netdev_upper_dev_unlink(real_dev, dev);
-
if (grp->nr_vlan_devs == 0) {
vlan_mvrp_uninit_applicant(real_dev);
vlan_gvrp_uninit_applicant(real_dev);
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 23/27] bonding: remove slave lists
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev; +Cc: jiri, Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
And all the initialization.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
RFC -> v2:
New patch.
drivers/net/bonding/bond_main.c | 4 ----
drivers/net/bonding/bonding.h | 2 --
2 files changed, 6 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 65eae12..707b0bc 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -972,7 +972,6 @@ void bond_select_active_slave(struct bonding *bond)
*/
static void bond_attach_slave(struct bonding *bond, struct slave *new_slave)
{
- list_add_tail_rcu(&new_slave->list, &bond->slave_list);
bond->slave_cnt++;
}
@@ -988,7 +987,6 @@ static void bond_attach_slave(struct bonding *bond, struct slave *new_slave)
*/
static void bond_detach_slave(struct bonding *bond, struct slave *slave)
{
- list_del_rcu(&slave->list);
bond->slave_cnt--;
}
@@ -1374,7 +1372,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
res = -ENOMEM;
goto err_undo_flags;
}
- INIT_LIST_HEAD(&new_slave->list);
/*
* Set the new_slave's queue_id to be zero. Queue ID mapping
* is set via sysfs or module option if desired.
@@ -4022,7 +4019,6 @@ static void bond_setup(struct net_device *bond_dev)
/* initialize rwlocks */
rwlock_init(&bond->lock);
rwlock_init(&bond->curr_slave_lock);
- INIT_LIST_HEAD(&bond->slave_list);
bond->params = bonding_defaults;
/* Initialize pointers */
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 9329509..0e8e00e 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -167,7 +167,6 @@ struct bond_parm_tbl {
struct slave {
struct net_device *dev; /* first - useful for panic debug */
- struct list_head list;
struct bonding *bond; /* our master */
int delay;
unsigned long jiffies;
@@ -207,7 +206,6 @@ struct slave {
*/
struct bonding {
struct net_device *dev; /* first - useful for panic debug */
- struct list_head slave_list;
struct slave *curr_active_slave;
struct slave *current_arp_slave;
struct slave *primary_slave;
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 21/27] net: add a function to get the next private
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev
Cc: jiri, Veaceslav Falico, David S. Miller, Eric Dumazet,
Alexander Duyck
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
It searches for the provided private and returns the next one. If private
is not found or next list element is list head - returns NULL.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <jiri@resnulli.us>
CC: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v1:
Drop the bool switch - it only goes to ->next now, and rework it so
that it doesn't go over the head, but rather returns NULL.
include/linux/netdevice.h | 2 ++
net/core/dev.c | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 72d1631..b487302 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2866,6 +2866,8 @@ extern void *netdev_lower_dev_get_private_rcu(struct net_device *dev,
struct net_device *lower_dev);
extern void *netdev_lower_dev_get_private(struct net_device *dev,
struct net_device *lower_dev);
+extern void *netdev_lower_dev_get_next_private(struct net_device *dev,
+ void *private);
extern int skb_checksum_help(struct sk_buff *skb);
extern struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
netdev_features_t features, bool tx_path);
diff --git a/net/core/dev.c b/net/core/dev.c
index 24c7d17..d58ca53 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5055,6 +5055,33 @@ void *netdev_lower_dev_get_private(struct net_device *dev,
}
EXPORT_SYMBOL(netdev_lower_dev_get_private);
+/* netdev_lower_dev_get_next_private - return the ->private of the list
+ * element whos ->private == private.
+ * @dev - device to search
+ * @private - private pointer to search for.
+ *
+ * Returns the next ->private pointer, if ->next is not head and private is
+ * found.
+ */
+extern void *netdev_lower_dev_get_next_private(struct net_device *dev,
+ void *private)
+{
+ struct netdev_adjacent *lower;
+
+ list_for_each_entry(lower, &dev->adj_list.lower, list) {
+ if (lower->private == private) {
+ lower = list_entry(lower->list.next,
+ struct netdev_adjacent, list);
+ if (&lower->list == &dev->adj_list.lower)
+ return NULL;
+ return lower->private;
+ }
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL(netdev_lower_dev_get_next_private);
+
static void dev_change_rx_flags(struct net_device *dev, int flags)
{
const struct net_device_ops *ops = dev->netdev_ops;
--
1.8.4
^ permalink raw reply related
* [PATCH v3 net-next 22/27] bonding: use neighbours for bond_next_slave()
From: Veaceslav Falico @ 2013-09-17 0:46 UTC (permalink / raw)
To: netdev; +Cc: jiri, Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com>
If it's the last slave - return the first slave, otherwise - return the
next slave via netdev_lower_dev_get_next_private().
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
Notes:
v2 -> v3:
No change.
v1 -> v2:
No changes.
RFC -> v1:
Change to standard logic - if it's the last slave - return the first one,
otherwise - return the next via netdev_lower_dev_get_next_private().
Also, bond_prev_slave() was dropped - so we don't need it.
drivers/net/bonding/bonding.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 03daadd..9329509 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -76,8 +76,6 @@
#define bond_has_slaves(bond) !list_empty(bond_slave_list(bond))
-#define bond_to_slave(ptr) list_entry(ptr, struct slave, list)
-
/* IMPORTANT: bond_first/last_slave can return NULL in case of an empty list */
#define bond_first_slave(bond) \
(bond_has_slaves(bond) ? \
@@ -93,8 +91,9 @@
/* Since bond_first/last_slave can return NULL, these can return NULL too */
#define bond_next_slave(bond, pos) \
- (bond_is_last_slave(bond, pos) ? bond_first_slave(bond) : \
- bond_to_slave((pos)->list.next))
+ (bond_is_last_slave(bond, pos) ? \
+ bond_first_slave(bond) : \
+ netdev_lower_dev_get_next_private((bond)->dev, pos))
/**
* bond_for_each_slave - iterate over all slaves
--
1.8.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox