* [PATCH net-next v2 0/6] bonding: remove bond->vlan_list
From: Veaceslav Falico @ 2013-08-08 16:57 UTC (permalink / raw)
To: netdev
Cc: Jay Vosburgh, Andy Gospodarek, Patrick McHardy, David S. Miller,
Nikolay Aleksandrov, Veaceslav Falico
RFC -> v1: Got some feedback from Nikolay Aleksandrov (privately), tried to
address it, also fixed some bugs that I've found on the way. I
think it's ready to be considered a patchset for
review/inclusion in net-next.
v1 -> v2: Remove ASSERT_RTNL() from vlan_uses_dev(), cause it can be
already called under rcu, without rtnl. Don't check for master
device in __vlan_find_dev_next(), otherwise we won't be able to
work in situations when a device has both vlans and master
device. Properly init vlan_dev in bond_has_this_ip() before
using (sigh). There was a proposal of making a macro
"dev_for_each_vlan_from(dev, vlan_dev, i, from)", which would
use __vlan_find_dev_deep() inside, with its strong and weak
parts, but I've decided to stick to the "while (dev = next())"
scheme currently - it might be added anytime, and now the only
user (bonding) doesn't really need it.
The aim of this patchset is to remove bond->vlan_list completely, and use
8021q's standard functions instead of it.
The patchset is on top of Nik's latest two patches:
[net-next,v2,1/2] bonding: change the bond's vlan syncing functions with
the standard ones
[net-next,v2,2/2] bonding: unwind on bond_add_vlan failure
First two patches add two helper functions to vlan code:
bonding: add rcu to vlan_uses_dev() and make bond_vlan_used() use it
Here we change vlan_uses_dev() to be able to work under both rtnl
and rcu, and use it under rcu_read_lock() in bond_vlan_used().
vlan: add __vlan_find_dev_next()
This function takes dev and vlan_dev and returns the next vlan dev
that uses this dev. It can be used to cycle through the vlan list,
and not only by bonding - but by any network driver that uses its
private vlan list.
Next four patches actually convert bonding to use the new
functions/approach and remove the vlan_list completely.
This patchset solves several issues with bonding, simplify it overall,
RCUify further and add infrastructure to anyone else who'd like to use
8021q standard functions instead of their own vlan_list, which is quite
common amongst network drivers currently.
I'm testing it continuously currently, no issues found, will update on
anything.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Patrick McHardy <kaber@trash.net>
CC: "David S. Miller" <davem@davemloft.net>
CC: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
drivers/net/bonding/bond_alb.c | 48 ++++++++----
drivers/net/bonding/bond_alb.h | 2 +-
drivers/net/bonding/bond_main.c | 163 ++++++---------------------------------
drivers/net/bonding/bonding.h | 16 ++--
include/linux/if_vlan.h | 8 ++
net/8021q/vlan.h | 6 +-
net/8021q/vlan_core.c | 36 ++++++++-
7 files changed, 115 insertions(+), 164 deletions(-)
^ permalink raw reply
* [PATCH v2 net-next 5/6] bonding: convert bond_arp_send_all to use bond->dev->vlan_info
From: Veaceslav Falico @ 2013-08-08 16:57 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1375981079-2936-1-git-send-email-vfalico@redhat.com>
RFC -> v1: use the new __vlan_find_dev_next(), also release rcu_read_lock()
only after we stop using the vlan_dev.
v1 -> v2: no change.
Instead of looping through bond->vlan_list, loop through
bond->dev->vlan_info via __vlan_find_dev_next() under rcu_read_lock().
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
drivers/net/bonding/bond_main.c | 29 +++++++++++++----------------
1 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e52e2d5..f536d05 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2440,11 +2440,10 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_
static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
{
- int i, vlan_id;
- __be32 *targets = bond->params.arp_targets;
- struct vlan_entry *vlan;
- struct net_device *vlan_dev = NULL;
+ struct net_device *vlan_dev;
struct rtable *rt;
+ __be32 *targets = bond->params.arp_targets;
+ int i;
for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
__be32 addr;
@@ -2486,28 +2485,26 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
continue;
}
- vlan_id = 0;
- list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
- rcu_read_lock();
- vlan_dev = __vlan_find_dev_deep(bond->dev,
- htons(ETH_P_8021Q),
- vlan->vlan_id);
- rcu_read_unlock();
+ vlan_dev = NULL;
+
+ rcu_read_lock();
+ while ((vlan_dev = __vlan_find_dev_next(bond->dev, vlan_dev)))
if (vlan_dev == rt->dst.dev) {
- vlan_id = vlan->vlan_id;
pr_debug("basa: vlan match on %s %d\n",
- vlan_dev->name, vlan_id);
+ vlan_dev->name,
+ vlan_dev_vlan_id(vlan_dev));
break;
}
- }
- if (vlan_id && vlan_dev) {
+ if (vlan_dev) {
ip_rt_put(rt);
addr = bond_confirm_addr(vlan_dev, targets[i], 0);
bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
- addr, vlan_id);
+ addr, vlan_dev_vlan_id(vlan_dev));
+ rcu_read_unlock();
continue;
}
+ rcu_read_unlock();
if (net_ratelimit()) {
pr_warning("%s: no path to arp_ip_target %pI4 via rt.dev %s\n",
--
1.7.1
^ permalink raw reply related
* [PATCH v2 net-next 6/6] bonding: remove unused bond->vlan_list
From: Veaceslav Falico @ 2013-08-08 16:57 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1375981079-2936-1-git-send-email-vfalico@redhat.com>
RFC -> v1: No changes.
v1 -> v2: No changes.
There are currently no users of bond->vlan_list (other than the maintaining
functions add/remove) - so remove it and every unneeded helper.
In this patch we remove:
vlan_list from struct bonding
bond_next_vlan - we don't need it anymore
struct vlan_entry - it was a helper struct for bond->vlan_list
some bits from bond_vlan_rx_add/kill_vid() - which were related to
bond->vlan_list
(de)initialization of vlan_list from bond_setup/uninit
bond_add_vlan - its only scope was to maintain bond->vlan_list
We don't fully remove bond_del_vlan() - bond_alb_clear_vlan() still needs
to be called when a vlan disappears. And we make bond_del_vlan() to not
return anything cause it cannot fail already.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
drivers/net/bonding/bond_main.c | 117 +-------------------------------------
drivers/net/bonding/bonding.h | 6 --
2 files changed, 4 insertions(+), 119 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index f536d05..6df818b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -282,113 +282,24 @@ const char *bond_mode_name(int mode)
/*---------------------------------- VLAN -----------------------------------*/
/**
- * bond_add_vlan - add a new vlan id on bond
- * @bond: bond that got the notification
- * @vlan_id: the vlan id to add
- *
- * Returns -ENOMEM if allocation failed.
- */
-static int bond_add_vlan(struct bonding *bond, unsigned short vlan_id)
-{
- struct vlan_entry *vlan;
-
- pr_debug("bond: %s, vlan id %d\n",
- (bond ? bond->dev->name : "None"), vlan_id);
-
- vlan = kzalloc(sizeof(struct vlan_entry), GFP_KERNEL);
- if (!vlan)
- return -ENOMEM;
-
- INIT_LIST_HEAD(&vlan->vlan_list);
- vlan->vlan_id = vlan_id;
-
- write_lock_bh(&bond->lock);
-
- list_add_tail(&vlan->vlan_list, &bond->vlan_list);
-
- write_unlock_bh(&bond->lock);
-
- pr_debug("added VLAN ID %d on bond %s\n", vlan_id, bond->dev->name);
-
- return 0;
-}
-
-/**
* bond_del_vlan - delete a vlan id from bond
* @bond: bond that got the notification
* @vlan_id: the vlan id to delete
*
* returns -ENODEV if @vlan_id was not found in @bond.
*/
-static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id)
+static void bond_del_vlan(struct bonding *bond, unsigned short vlan_id)
{
- struct vlan_entry *vlan;
- int res = -ENODEV;
-
pr_debug("bond: %s, vlan id %d\n", bond->dev->name, vlan_id);
block_netpoll_tx();
write_lock_bh(&bond->lock);
- list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
- if (vlan->vlan_id == vlan_id) {
- list_del(&vlan->vlan_list);
-
- if (bond_is_lb(bond))
- bond_alb_clear_vlan(bond, vlan_id);
-
- pr_debug("removed VLAN ID %d from bond %s\n",
- vlan_id, bond->dev->name);
+ if (bond_is_lb(bond))
+ bond_alb_clear_vlan(bond, vlan_id);
- kfree(vlan);
-
- res = 0;
- goto out;
- }
- }
-
- pr_debug("couldn't find VLAN ID %d in bond %s\n",
- vlan_id, bond->dev->name);
-
-out:
write_unlock_bh(&bond->lock);
unblock_netpoll_tx();
- return res;
-}
-
-/**
- * bond_next_vlan - safely skip to the next item in the vlans list.
- * @bond: the bond we're working on
- * @curr: item we're advancing from
- *
- * Returns %NULL if list is empty, bond->next_vlan if @curr is %NULL,
- * or @curr->next otherwise (even if it is @curr itself again).
- *
- * Caller must hold bond->lock
- */
-struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr)
-{
- struct vlan_entry *next, *last;
-
- if (list_empty(&bond->vlan_list))
- return NULL;
-
- if (!curr) {
- next = list_entry(bond->vlan_list.next,
- struct vlan_entry, vlan_list);
- } else {
- last = list_entry(bond->vlan_list.prev,
- struct vlan_entry, vlan_list);
- if (last == curr) {
- next = list_entry(bond->vlan_list.next,
- struct vlan_entry, vlan_list);
- } else {
- next = list_entry(curr->vlan_list.next,
- struct vlan_entry, vlan_list);
- }
- }
-
- return next;
}
/**
@@ -450,13 +361,6 @@ static int bond_vlan_rx_add_vid(struct net_device *bond_dev,
goto unwind;
}
- res = bond_add_vlan(bond, vid);
- if (res) {
- pr_err("%s: Error: Failed to add vlan id %d\n",
- bond_dev->name, vid);
- goto unwind;
- }
-
return 0;
unwind:
@@ -477,17 +381,11 @@ static int bond_vlan_rx_kill_vid(struct net_device *bond_dev,
{
struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
- int res;
bond_for_each_slave(bond, slave)
vlan_vid_del(slave->dev, proto, vid);
- res = bond_del_vlan(bond, vid);
- if (res) {
- pr_err("%s: Error: Failed to remove vlan id %d\n",
- bond_dev->name, vid);
- return res;
- }
+ bond_del_vlan(bond, vid);
return 0;
}
@@ -4135,7 +4033,6 @@ static void bond_setup(struct net_device *bond_dev)
/* Initialize pointers */
bond->dev = bond_dev;
- INIT_LIST_HEAD(&bond->vlan_list);
/* Initialize the device entry points */
ether_setup(bond_dev);
@@ -4188,7 +4085,6 @@ static void bond_uninit(struct net_device *bond_dev)
{
struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave, *tmp_slave;
- struct vlan_entry *vlan, *tmp;
bond_netpoll_cleanup(bond_dev);
@@ -4200,11 +4096,6 @@ static void bond_uninit(struct net_device *bond_dev)
list_del(&bond->bond_list);
bond_debug_unregister(bond);
-
- list_for_each_entry_safe(vlan, tmp, &bond->vlan_list, vlan_list) {
- list_del(&vlan->vlan_list);
- kfree(vlan);
- }
}
/*------------------------- Module initialization ---------------------------*/
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 9c4539e..bfa33c4 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -186,11 +186,6 @@ struct bond_parm_tbl {
#define BOND_MAX_MODENAME_LEN 20
-struct vlan_entry {
- struct list_head vlan_list;
- unsigned short vlan_id;
-};
-
struct slave {
struct net_device *dev; /* first - useful for panic debug */
struct list_head list;
@@ -255,7 +250,6 @@ struct bonding {
struct ad_bond_info ad_info;
struct alb_bond_info alb_info;
struct bond_params params;
- struct list_head vlan_list;
struct workqueue_struct *wq;
struct delayed_work mii_work;
struct delayed_work arp_work;
--
1.7.1
^ permalink raw reply related
* [PATCH v2 net-next 4/6] bonding: convert bond_has_this_ip to use bond->dev->vlan_info
From: Veaceslav Falico @ 2013-08-08 16:57 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1375981079-2936-1-git-send-email-vfalico@redhat.com>
RFC -> v1: use the new __vlan_find_dev_next(), which simplifies the code
and omits issues with vlan id 0.
v1 -> v2: fix the use of uninitialized vlan_dev
Use __vlan_find_dev_next() to loop through dev's vlan devices and verify if
the ip matches.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
drivers/net/bonding/bond_main.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 9d1045d..e52e2d5 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2392,20 +2392,18 @@ re_arm:
static int bond_has_this_ip(struct bonding *bond, __be32 ip)
{
- struct vlan_entry *vlan;
- struct net_device *vlan_dev;
+ struct net_device *vlan_dev = NULL;
if (ip == bond_confirm_addr(bond->dev, 0, ip))
return 1;
- list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
- rcu_read_lock();
- vlan_dev = __vlan_find_dev_deep(bond->dev, htons(ETH_P_8021Q),
- vlan->vlan_id);
- rcu_read_unlock();
- if (vlan_dev && ip == bond_confirm_addr(vlan_dev, 0, ip))
+ rcu_read_lock();
+ while ((vlan_dev = __vlan_find_dev_next(bond->dev, vlan_dev)))
+ if (ip == bond_confirm_addr(vlan_dev, 0, ip)) {
+ rcu_read_unlock();
return 1;
- }
+ }
+ rcu_read_unlock();
return 0;
}
--
1.7.1
^ permalink raw reply related
* [PATCH v2 net-next 3/6] bonding: make bond_alb use 8021q's dev->vlan_info instead of vlan_list
From: Veaceslav Falico @ 2013-08-08 16:57 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1375981079-2936-1-git-send-email-vfalico@redhat.com>
RFC -> v1: use the changed __vlan_find_dev_next, which now works with
vlan's net_device instead of vlan's id. Also, fix a subtle race
condition if we remove the only vlan while looping through
MAX_LP_BURST - we end up with using the old vlan_id, so set it
to 0 if we don't have vlans.
v1 -> v2: no change.
In alb mode, we only need each vlan's id (that is on top of bond) to tag
learning packets, so get them via __vlan_find_dev_next(bond->dev, last_dev).
We must also find *any* vlan (including last id stored in current_alb_vlan)
if we can't find anything >= current_alb_vlan id.
For that, we verify if bond has any vlans at all, and if yes - find the
next vlan id after current_alb_vlan id. So, if vlan id is not 0, we tag the
skb.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
drivers/net/bonding/bond_alb.c | 47 ++++++++++++++++++++++++++++-----------
drivers/net/bonding/bond_alb.h | 2 +-
2 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 2684329..ced5753 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -974,8 +974,9 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
{
struct bonding *bond = bond_get_bond_by_slave(slave);
struct learning_pkt pkt;
+ struct net_device *vlan_dev;
int size = sizeof(struct learning_pkt);
- int i;
+ int i, vlan_id;
memset(&pkt, 0, size);
memcpy(pkt.mac_dst, mac_addr, ETH_ALEN);
@@ -1000,22 +1001,42 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
skb->priority = TC_PRIO_CONTROL;
skb->dev = slave->dev;
+ rcu_read_lock();
if (bond_vlan_used(bond)) {
- struct vlan_entry *vlan;
-
- vlan = bond_next_vlan(bond,
- bond->alb_info.current_alb_vlan);
-
- bond->alb_info.current_alb_vlan = vlan;
- if (!vlan) {
+ /* first try to find the previously used vlan by
+ * id, which might have gone away already
+ */
+ vlan_id = bond->alb_info.current_alb_vlan;
+ vlan_dev = __vlan_find_dev_deep(bond->dev,
+ htons(ETH_P_8021Q),
+ vlan_id);
+
+ /* search for the next one, if not found - for any */
+ if (vlan_dev)
+ vlan_dev = __vlan_find_dev_next(bond->dev,
+ vlan_dev);
+ if (!vlan_dev)
+ vlan_dev = __vlan_find_dev_next(bond->dev,
+ NULL);
+
+ if (vlan_dev) {
+ vlan_id = vlan_dev_vlan_id(vlan_dev);
+ bond->alb_info.current_alb_vlan = vlan_id;
+ } else {
+ bond->alb_info.current_alb_vlan = 0;
+ rcu_read_unlock();
kfree_skb(skb);
continue;
}
+ } else
+ vlan_id = 0;
+ rcu_read_unlock();
- skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vlan->vlan_id);
+ if (vlan_id) {
+ skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_id);
if (!skb) {
- pr_err("%s: Error: failed to insert VLAN tag\n",
- bond->dev->name);
+ pr_err("%s: Error: failed to insert VLAN tag %d\n",
+ bond->dev->name, vlan_id);
continue;
}
}
@@ -1759,8 +1780,8 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
{
if (bond->alb_info.current_alb_vlan &&
- (bond->alb_info.current_alb_vlan->vlan_id == vlan_id)) {
- bond->alb_info.current_alb_vlan = NULL;
+ (bond->alb_info.current_alb_vlan == vlan_id)) {
+ bond->alb_info.current_alb_vlan = 0;
}
if (bond->alb_info.rlb_enabled) {
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index e7a5b8b..b2452aa 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -170,7 +170,7 @@ struct alb_bond_info {
* rx traffic should be
* rebalanced
*/
- struct vlan_entry *current_alb_vlan;
+ u16 current_alb_vlan;
};
int bond_alb_initialize(struct bonding *bond, int rlb_enabled);
--
1.7.1
^ permalink raw reply related
* [PATCH v2 net-next 1/6] bonding: add rcu to vlan_uses_dev() and make bond_vlan_used() use it
From: Veaceslav Falico @ 2013-08-08 16:57 UTC (permalink / raw)
To: netdev
Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek, Patrick McHardy,
David S. Miller, Nikolay Aleksandrov
In-Reply-To: <1375981079-2936-1-git-send-email-vfalico@redhat.com>
RFC -> v1: don't add vlan_uses_dev_rcu() and change vlan_uses_dev() instead
v1 -> v2: remove the ASSERT_RTNL(), cause we can now be called under rcu.
Currently, bond_vlan_used() looks for any vlan, including the pseudo-vlan
id 0, and always returns true if 8021q is loaded. This creates several bad
situations - some warnings in __bond_release_one() because it thinks that
we still have vlans while removing, sending LB packets with vlan id 0 and,
possibly, other caused by vlan id 0.
Fix it by changing vlan_uses_dev() to use rcu_dereference_rtnl() instead of
rtnl_dereference(), and thus it can already be used in bond_vlan_used()
under rcu_read_lock().
By the time vlan_uses_dev() returns we cannot be sure if there were no
vlans added/removed, so it's basicly an optimization function.
Also, use the vlan_uses_dev() in __bond_release_one() cause the rtnl lock
is held there.
For this call to be visible in bonding.h, add include <linux/if_vlan.h>,
and also remove it from any other bonding file, cause they all include
bonding.h, and thus linux/if_vlan.h.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Patrick McHardy <kaber@trash.net>
CC: "David S. Miller" <davem@davemloft.net>
CC: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
drivers/net/bonding/bond_alb.c | 1 -
drivers/net/bonding/bond_main.c | 3 +--
drivers/net/bonding/bonding.h | 10 +++++++++-
net/8021q/vlan_core.c | 5 ++---
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 3a5db7b..2684329 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -34,7 +34,6 @@
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/if_bonding.h>
-#include <linux/if_vlan.h>
#include <linux/in.h>
#include <net/ipx.h>
#include <net/arp.h>
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 4264a76..9d1045d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -69,7 +69,6 @@
#include <net/arp.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
-#include <linux/if_vlan.h>
#include <linux/if_bonding.h>
#include <linux/jiffies.h>
#include <linux/preempt.h>
@@ -1953,7 +1952,7 @@ static int __bond_release_one(struct net_device *bond_dev,
bond_set_carrier(bond);
eth_hw_addr_random(bond_dev);
- if (bond_vlan_used(bond)) {
+ if (vlan_uses_dev(bond_dev)) {
pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n",
bond_dev->name, bond_dev->name);
pr_warning("%s: When re-adding slaves, make sure the bond's HW address matches its VLANs'.\n",
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 4bf52d5..9c4539e 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -23,6 +23,7 @@
#include <linux/netpoll.h>
#include <linux/inetdevice.h>
#include <linux/etherdevice.h>
+#include <linux/if_vlan.h>
#include "bond_3ad.h"
#include "bond_alb.h"
@@ -267,9 +268,16 @@ struct bonding {
#endif /* CONFIG_DEBUG_FS */
};
+/* use vlan_uses_dev() if under rtnl */
static inline bool bond_vlan_used(struct bonding *bond)
{
- return !list_empty(&bond->vlan_list);
+ bool ret;
+
+ rcu_read_lock();
+ ret = vlan_uses_dev(bond->dev);
+ rcu_read_unlock();
+
+ return ret;
}
#define bond_slave_get_rcu(dev) \
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 4a78c4d..361c97b 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -387,13 +387,12 @@ void vlan_vids_del_by_dev(struct net_device *dev,
}
EXPORT_SYMBOL(vlan_vids_del_by_dev);
+/* Must hold either rtnl or rcu_read_lock */
bool vlan_uses_dev(const struct net_device *dev)
{
struct vlan_info *vlan_info;
- ASSERT_RTNL();
-
- vlan_info = rtnl_dereference(dev->vlan_info);
+ vlan_info = rcu_dereference_rtnl(dev->vlan_info);
if (!vlan_info)
return false;
return vlan_info->grp.nr_vlan_devs ? true : false;
--
1.7.1
^ permalink raw reply related
* [PATCH v2 net-next 2/6] vlan: add __vlan_find_dev_next()
From: Veaceslav Falico @ 2013-08-08 16:57 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Patrick McHardy, David S. Miller
In-Reply-To: <1375981079-2936-1-git-send-email-vfalico@redhat.com>
RFC -> v1: make the function accept/return vlan's net_device, this way we
won't have troubles with VLAN 0, and the user code will be
cleaner and faster.
v1 -> v2: don't check for the master device - if we'll want in the future
to convert a slave device - it will fail, but now we don't
actually care.
Add a new exported function __vlan_find_dev_next(dev, vlan_dev), which
returns the a vlan's net_device that is used by the dev and is its id is
greater or equal to vlan_dev's vlan id. If vlan_dev is NULL, return first
vlan, if nothing is found return NULL.
This function must be under rcu_read_lock(), is aware of master devices and
doesn't guarantee that, once it returns, the vlan dev will still be used by
dev as its vlan.
It's basically a helper for "for_each_vlan_in_dev(dev, vlan_dev)" logic,
and is supposed to be used like this:
vlan_dev = NULL;
while ((vlan_dev = __vlan_find_dev_next(dev, vlan_dev))) {
if (!vlan_dev)
continue;
do_work(vlan_dev);
}
In that case we're sure that vlan_dev at least was used as a vlan, and won't
go away while we're holding rcu_read_lock().
However, if we don't hold rtnl_lock(), we can't be sure that that vlan_dev
is still in dev's vlan_list.
CC: Patrick McHardy <kaber@trash.net>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
include/linux/if_vlan.h | 8 ++++++++
net/8021q/vlan.h | 6 ++++--
net/8021q/vlan_core.c | 28 ++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 715c343..1cfc201 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -86,6 +86,8 @@ static inline int is_vlan_dev(struct net_device *dev)
extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
__be16 vlan_proto, u16 vlan_id);
+extern struct net_device *__vlan_find_dev_next(struct net_device *dev,
+ struct net_device *vlan_dev);
extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
extern u16 vlan_dev_vlan_id(const struct net_device *dev);
@@ -109,6 +111,12 @@ __vlan_find_dev_deep(struct net_device *real_dev,
return NULL;
}
+static struct net_device *__vlan_find_dev_next(struct net_device *dev,
+ struct net_device *vlan_dev)
+{
+ return NULL;
+}
+
static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
{
BUG();
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index ba5983f..e13aeac 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -168,10 +168,12 @@ static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
return NULL;
}
-#define vlan_group_for_each_dev(grp, i, dev) \
- for ((i) = 0; i < VLAN_PROTO_NUM * VLAN_N_VID; i++) \
+#define vlan_group_for_each_dev_from(grp, i, dev, from) \
+ for ((i) = from; i < VLAN_PROTO_NUM * VLAN_N_VID; i++) \
if (((dev) = __vlan_group_get_device((grp), (i) / VLAN_N_VID, \
(i) % VLAN_N_VID)))
+#define vlan_group_for_each_dev(grp, i, dev) \
+ vlan_group_for_each_dev_from(grp, i, dev, 0)
/* found in vlan_dev.c */
void vlan_dev_set_ingress_priority(const struct net_device *dev,
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 361c97b..c0031c3 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -89,6 +89,34 @@ struct net_device *__vlan_find_dev_deep(struct net_device *dev,
}
EXPORT_SYMBOL(__vlan_find_dev_deep);
+/* Must be called under rcu_read_lock(), returns next vlan_id used by a
+ * vlan device on dev, starting with vlan_id, or 0 if no vlan_id found.
+ */
+struct net_device *__vlan_find_dev_next(struct net_device *dev,
+ struct net_device *vlan_dev)
+{
+ struct net_device *ret;
+ struct vlan_info *vlan_info;
+ struct vlan_group *grp;
+ u16 vlan_id = 0, i;
+
+ if (vlan_dev)
+ vlan_id = vlan_dev_priv(vlan_dev)->vlan_id + 1;
+
+ vlan_info = rcu_dereference(dev->vlan_info);
+
+ if (!vlan_info)
+ return NULL;
+
+ grp = &vlan_info->grp;
+
+ vlan_group_for_each_dev_from(grp, i, ret, vlan_id)
+ return ret;
+
+ return NULL;
+}
+EXPORT_SYMBOL(__vlan_find_dev_next);
+
struct net_device *vlan_dev_real_dev(const struct net_device *dev)
{
return vlan_dev_priv(dev)->real_dev;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH net-next v1 0/6] bonding: remove bond->vlan_list
From: Veaceslav Falico @ 2013-08-08 16:49 UTC (permalink / raw)
To: netdev
Cc: Jay Vosburgh, Andy Gospodarek, Patrick McHardy, David S. Miller,
Nikolay Aleksandrov
In-Reply-To: <1375957269-13100-1-git-send-email-vfalico@redhat.com>
On Thu, Aug 08, 2013 at 12:21:03PM +0200, Veaceslav Falico wrote:
>RFC -> v1: Got some feedback from Nikolay Aleksandrov (privately), tried to
> address it, also fixed some bugs that I've found on the way. I
> think it's ready to be considered a patchset for
> review/inclusion in net-next.
Got some more feedback and spotted some bugs, will send a full v2 shortly.
^ permalink raw reply
* Re: [PATCH v4 1/4] USB: introduce usb_device_no_sg_constraint() helper
From: Eric Dumazet @ 2013-08-08 16:28 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman, Oliver Neukum, Sarah Sharp,
netdev, linux-usb
In-Reply-To: <1375969705-24877-2-git-send-email-ming.lei@canonical.com>
On Thu, 2013-08-08 at 21:48 +0800, Ming Lei wrote:
> Some host controllers(such as xHCI) can support building
> packet from discontinuous buffers, so introduce one flag
> and helper for this kind of host controllers, then the
> feature can help some applications(such as usbnet) by
> supporting arbitrary length of sg buffers.
>
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
> ---
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply
* Re: [PATCH v4 2/4] USB: XHCI: mark no_sg_constraint
From: Eric Dumazet @ 2013-08-08 16:28 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman, Oliver Neukum, Sarah Sharp,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
Alan Stern
In-Reply-To: <1375969705-24877-3-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
On Thu, 2013-08-08 at 21:48 +0800, Ming Lei wrote:
> This patch marks all xHCI controllers as no_sg_constraint
> since xHCI supports building packet from discontinuous buffers.
>
> Cc: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
> Acked-by: Sarah Sharp <sarah.a.sharp-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
> ---
> drivers/usb/host/xhci.c | 4 ++++
> 1 file changed, 4 insertions(+)
Reviewed-by: Eric Dumazet <edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
--
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 v4 3/4] USBNET: support DMA SG
From: Eric Dumazet @ 2013-08-08 16:27 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman, Oliver Neukum, Sarah Sharp,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
Ben Hutchings, Grant Grundler, Freddy Xin, Alan Stern
In-Reply-To: <1375969705-24877-4-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
On Thu, 2013-08-08 at 21:48 +0800, Ming Lei wrote:
> This patch introduces support of DMA SG if the USB host controller
> which usbnet device is attached to is capable of building packet from
> discontinuous buffers.
> diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
> index 8fbc008..9cb2fe8 100644
> --- a/include/linux/usb/usbnet.h
> +++ b/include/linux/usb/usbnet.h
> @@ -35,6 +35,7 @@ struct usbnet {
> unsigned char suspend_count;
> unsigned char pkt_cnt, pkt_err;
> unsigned short rx_qlen, tx_qlen;
> + unsigned can_dma_sg:1;
We try to use "unsigned int" instead of plain "unsigned", but its a
minor point and should not block your patches.
Apart from this :
Reviewed-by: Eric Dumazet <edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
--
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-next] igbvf: do not force carrier off in igbvf_msix_other()
From: Alexander Duyck @ 2013-08-08 16:09 UTC (permalink / raw)
To: Stefan Assmann; +Cc: e1000-devel, netdev, davem
In-Reply-To: <1375963002-1624-1-git-send-email-sassmann@kpanic.de>
On 08/08/2013 04:56 AM, Stefan Assmann wrote:
> Currently carrier is forced off in igbvf_msix_other(). This seems
> unnecessary and causes multiple calls to igbvf_watchdog_task(), resulting
> in multiple link up messages when calling dhclient for example.
> [ 111.818106] igbvf 0000:00:04.0: Link is Up 1000 Mbps Full Duplex
> [ 111.819347] IPv6: ADDRCONF(NETDEV_UP): eth5: link is not ready
> [ 111.820509] IPv6: ADDRCONF(NETDEV_CHANGE): eth5: link becomes ready
> [ 111.822983] igbvf 0000:00:04.0: Link is Up 1000 Mbps Full Duplex
> [ 115.152421] igbvf 0000:00:04.0: Link is Up 1000 Mbps Full Duplex
> compared to
> [ 1040.422161] igbvf 0000:00:04.0: Link is Up 1000 Mbps Full Duplex
> [ 1040.423447] IPv6: ADDRCONF(NETDEV_UP): eth5: link is not ready
> [ 1040.424622] IPv6: ADDRCONF(NETDEV_CHANGE): eth5: link becomes ready
> when this patch is applied.
>
> Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
> ---
> drivers/net/ethernet/intel/igbvf/netdev.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
> index 93eb7ee..f041586 100644
> --- a/drivers/net/ethernet/intel/igbvf/netdev.c
> +++ b/drivers/net/ethernet/intel/igbvf/netdev.c
> @@ -876,8 +876,6 @@ static irqreturn_t igbvf_msix_other(int irq, void *data)
>
> adapter->int_counter1++;
>
> - netif_carrier_off(netdev);
> - hw->mac.get_link_status = 1;
> if (!test_bit(__IGBVF_DOWN, &adapter->state))
> mod_timer(&adapter->watchdog_timer, jiffies + 1);
>
While this patch helps to squelch the messages, did you test to see what
happens if for example you bring the PF interface down while the VFs are
trying to function? The reason for switching the carrier off is because
most interrupts on the mailbox indicate that something has been changed
in the underlying interface. If for example the PF is about to disable
the interfaces it should be triggering this interrupt. Otherwise you
are just setting up the VF to dump out a number of Tx hang and watchdog
messages.
Thanks,
Alex
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply
* Re: [PATCH v3 6/6] ARM: davinci: da850: configure system configuration chip(CFGCHIP3) for emac
From: Sekhar Nori @ 2013-08-08 16:05 UTC (permalink / raw)
To: Prabhakar Lad
Cc: DLOS, netdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, LKML, Heiko Schocher,
LAK
In-Reply-To: <CA+V-a8smEd_75Ab-_vxjBATr8Q9Sefs0tpxc+kgQJRtuLJad=w@mail.gmail.com>
On Thursday 08 August 2013 04:02 PM, Prabhakar Lad wrote:
> Hi Sekhar,
>
> Sorry for the delayed response I was on leave and now back again up
> and running.
>
> On Wed, Jul 31, 2013 at 11:17 AM, Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org> wrote:
>> On Sunday 23 June 2013 08:30 PM, Prabhakar Lad wrote:
>>> From: "Lad, Prabhakar" <prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>
>>> This patch makes a common function for to configure emac and calls
>>> it appropriately in DT and non DT boot mode. The system configuration
>>> chip CFGCHIP3, controls the emac module. This patch appropriately
>>> configures this register for emac and sets DA850_MII_MDIO_CLKEN_PIN
>>> GPIO pin appropriately.
>>>
> [Snip]
>
>>> + if (rmii_enabled)
>>> + val |= BIT(8);
>>> + else
>>> + val &= ~BIT(8);
>>> +
>>> + /* configure the CFGCHIP3 register for RMII or MII */
>>> + writel(val, cfg_chip3_base);
>>> +
>>> + ret = davinci_cfg_reg(DA850_GPIO2_6);
>>> + if (ret)
>>> + pr_warn("%s:GPIO(2,6) mux setup failed\n", __func__);
>>> +
>>> + ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
>>> + if (ret) {
>>> + pr_warn("Cannot open GPIO %d\n", DA850_MII_MDIO_CLKEN_PIN);
>>> + return;
>>> + }
>>
>> You cannot do this in SoC specific code. All boards wont use a GPIO to
>> choose between MII/RMII. You need to do this in a EVM specific manner.
>> This just means you retain the GPIO part of code in board-da850-evm.c
>
> OK
>
>> and for the DT case use a board specific GPIO node. See a similar
>> example in arch/arm/boot/dts/ste-nomadik-s8815.dts and how the code uses
> Alrite something similar to usb-s8815 node.
>
>> it in arch/arm/mach-nomadik/cpu-8815.c.
>>
> But I don't see any code to access this node in this file, can
> you point me to right direction ?
Look at cpu8815_eth_init() function in this file.
Thanks,
Sekhar
^ permalink raw reply
* Re: [PATCH v4 4/4] USBNET: ax88179_178a: enable tso if usb host supports sg dma
From: Eric Dumazet @ 2013-08-08 16:01 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman, Oliver Neukum, Sarah Sharp,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
Ben Hutchings, Grant Grundler, Alan Stern, Freddy Xin
In-Reply-To: <1375969705-24877-5-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
On Thu, 2013-08-08 at 21:48 +0800, Ming Lei wrote:
> This patch enables 'can_dma_sg' flag for ax88179_178a device
> if the attached host controller supports building packet from
> discontinuous buffers(DMA SG is possible), so TSO can be enabled
> and skb fragment buffers can be passed to usb stack via urb->sg
> directly.
>
> With the patch, system CPU utilization decreased ~50% and throughput
> increased by ~10% when doing iperf client test on one ARM A15 dual
> core board.
>
> Cc: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Ben Hutchings <bhutchings-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org>
> Cc: Grant Grundler <grundler-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> Cc: Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>
> Cc: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
> Cc: Freddy Xin <freddy-knRN6Y/kmf1NUHwG+Fw1Kw@public.gmane.org>
> Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
> ---
> drivers/net/usb/ax88179_178a.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
Acked-by: Eric Dumazet <edumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Thanks for doing this !
--
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: Preferred method for configuration
From: Stephen Hemminger @ 2013-08-08 16:01 UTC (permalink / raw)
To: Thomas Martitz; +Cc: Joe Perches, netdev@vger.kernel.org
In-Reply-To: <520332F4.5020206@hhi.fraunhofer.de>
On Thu, 08 Aug 2013 07:56:04 +0200
Thomas Martitz <thomas.martitz@hhi.fraunhofer.de> wrote:
> Resent with list in CC.
>
> Am 08.08.2013 07:41, schrieb Joe Perches:
> > On Thu, 2013-08-08 at 07:32 +0200, Thomas Martitz wrote:
> >> Hello,
> >>
> >> I'm developing a NIC driver and currently export some custom
> >> configuration settings and actions (e.g. enabling a loopback mode) via
> >> sysfs.
> >
> > Is there some reason you don't want to use ethtool?
> >
> >
>
> It doesn't allow for custom settings does it? For standards stuff I'm
> sure going to use ethtool.
Any feature "special to my driver" is sure to meet stiff resistance
from the kernel developers. Special features make it impossible for generic
configuration in distributions and by management layers.
^ permalink raw reply
* Re: [RFC net-next] ipip: Add room for custom tunnel header
From: Eric Dumazet @ 2013-08-08 16:00 UTC (permalink / raw)
To: Kristian Evensen; +Cc: netdev
In-Reply-To: <1375969927-22235-1-git-send-email-kristian.evensen@gmail.com>
On Thu, 2013-08-08 at 15:52 +0200, Kristian Evensen wrote:
> Hello,
...
> Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
> ---
> include/uapi/linux/if_tunnel.h | 1 +
> net/ipv4/ipip.c | 5 ++++-
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h
> index aee73d0..039bbc3 100644
> --- a/include/uapi/linux/if_tunnel.h
> +++ b/include/uapi/linux/if_tunnel.h
> @@ -35,6 +35,7 @@ struct ip_tunnel_parm {
> __be32 i_key;
> __be32 o_key;
> struct iphdr iph;
> + int hlen;
> };
>
> enum {
> diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
> index 51fc2a1..9705aa1 100644
> --- a/net/ipv4/ipip.c
> +++ b/net/ipv4/ipip.c
> @@ -226,6 +226,9 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
> skb->encapsulation = 1;
> }
>
> + if (tunnel->hlen > 0)
> + skb_push(skb, tunnel->hlen);
What happens if hlen is bigger than available headroom ?
hlen comes from userspace and there is no safety check, right ?
What guarantee do we have _something_ will fill the bytes ?
(We do not want to leak prior content of those bytes to the wire)
^ permalink raw reply
* Re: [PATCH] net/usb: rtl8150: allocate URB transfer_buffer and setup_packet separately
From: Petko Manolov @ 2013-08-08 15:14 UTC (permalink / raw)
To: Jussi Kivilinna; +Cc: netdev, Greg Kroah-Hartman, linux-usb, David S. Miller
In-Reply-To: <20130807133653.15587.35442.stgit@localhost6.localdomain6>
On Wed, 7 Aug 2013, Jussi Kivilinna wrote:
> rtl8150 allocates URB transfer_buffer and setup_packet as part of same
> structure 'struct async_req'. This can cause same cacheline to be
> DMA-mapped twice with same URB. This can lead to memory corruption on
> some systems.
I can see performance impact due to the double mapping. However, memory
corruption seems a bit too much for sane cache and DMA controllers. Out
of interest - which is the architecture that will potentially corrupt the
memory.
cheers,
Petko
^ permalink raw reply
* Re: [PATCH 3/5] netfilter: add SYNPROXY core/target
From: Jesper Dangaard Brouer @ 2013-08-08 15:07 UTC (permalink / raw)
To: Patrick McHardy; +Cc: pablo, netfilter-devel, netdev, mph, as
In-Reply-To: <20130808062255.GB24450@macbook.localnet>
On Thu, 8 Aug 2013 08:22:55 +0200
Patrick McHardy <kaber@trash.net> wrote:
> On Wed, Aug 07, 2013 at 10:56:03PM +0200, Patrick McHardy wrote:
> > On Wed, Aug 07, 2013 at 10:26:00PM +0200, Jesper Dangaard Brouer wrote:
> > > On Wed, 7 Aug 2013 19:42:49 +0200
> > > Patrick McHardy <kaber@trash.net> wrote:
> > >
> > > Besides when using net->proc_net_stat, then the first entry is usually
> > > "entries" which is not percpu, this will likely confusing the tool:
> > > lnstat -f synproxy -c 42
> >
> > I'll look into that.
>
> Ok right, the first field must contains something that is not per-CPU.
> Unfortunately I don't have anything to put there and I really don't want
> to keep any global state. The two possibilities I see are:
>
> - a dummy field
> - the number of proxied connections, but not using a global counter but
> gathered by iterating over the entire conntrack hash.
>
> Any opinions?
Well, I would of cause be nice to have some "entries" counter, e.g.
listing the number of active conntrack entries created by the SYNPROXY
target, but I don't think it's possible to identify those conntrack
entries, right.
So, I think it would be okay with just a dummy "entries" field which is
always zero.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Sr. Network Kernel Developer at Red Hat
Author of http://www.iptv-analyzer.org
LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply
* [PATCH] macvtap: fix two races
From: Eric Dumazet @ 2013-08-08 15:06 UTC (permalink / raw)
To: Thomas Huth, David Miller; +Cc: netdev, Vlad Yasevich
In-Reply-To: <20130808155634.239dbc2d@thhw500>
From: Eric Dumazet <edumazet@google.com>
Since commit ac4e4af1e59e1 ("macvtap: Consistently use rcu functions"),
Thomas gets two different warnings :
BUG: using smp_processor_id() in preemptible [00000000] code: vhost-45891/45892
caller is macvtap_do_read+0x45c/0x600 [macvtap]
CPU: 1 PID: 45892 Comm: vhost-45891 Not tainted 3.11.0-bisecttest #13
Call Trace:
([<00000000001126ee>] show_trace+0x126/0x144)
[<00000000001127d2>] show_stack+0xc6/0xd4
[<000000000068bcec>] dump_stack+0x74/0xd8
[<0000000000481066>] debug_smp_processor_id+0xf6/0x114
[<000003ff802e9a18>] macvtap_do_read+0x45c/0x600 [macvtap]
[<000003ff802e9c1c>] macvtap_recvmsg+0x60/0x88 [macvtap]
[<000003ff80318c5e>] handle_rx+0x5b2/0x800 [vhost_net]
[<000003ff8028f77c>] vhost_worker+0x15c/0x1c4 [vhost]
[<000000000015f3ac>] kthread+0xd8/0xe4
[<00000000006934a6>] kernel_thread_starter+0x6/0xc
[<00000000006934a0>] kernel_thread_starter+0x0/0xc
And
BUG: using smp_processor_id() in preemptible [00000000] code: vhost-45897/45898
caller is macvlan_start_xmit+0x10a/0x1b4 [macvlan]
CPU: 1 PID: 45898 Comm: vhost-45897 Not tainted 3.11.0-bisecttest #16
Call Trace:
([<00000000001126ee>] show_trace+0x126/0x144)
[<00000000001127d2>] show_stack+0xc6/0xd4
[<000000000068bdb8>] dump_stack+0x74/0xd4
[<0000000000481132>] debug_smp_processor_id+0xf6/0x114
[<000003ff802b72ca>] macvlan_start_xmit+0x10a/0x1b4 [macvlan]
[<000003ff802ea69a>] macvtap_get_user+0x982/0xbc4 [macvtap]
[<000003ff802ea92a>] macvtap_sendmsg+0x4e/0x60 [macvtap]
[<000003ff8031947c>] handle_tx+0x494/0x5ec [vhost_net]
[<000003ff8028f77c>] vhost_worker+0x15c/0x1c4 [vhost]
[<000000000015f3ac>] kthread+0xd8/0xe4
[<000000000069356e>] kernel_thread_starter+0x6/0xc
[<0000000000693568>] kernel_thread_starter+0x0/0xc
2 locks held by vhost-45897/45898:
#0: (&vq->mutex){+.+.+.}, at: [<000003ff8031903c>] handle_tx+0x54/0x5ec [vhost_net]
#1: (rcu_read_lock){.+.+..}, at: [<000003ff802ea53c>] macvtap_get_user+0x824/0xbc4 [macvtap]
In the first case, macvtap_put_user() calls macvlan_count_rx()
in a preempt-able context, and this is not allowed.
In the second case, macvtap_get_user() calls
macvlan_start_xmit() with BH enabled, and this is not allowed.
Reported-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Bisected-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Tested-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Cc: Vlad Yasevich <vyasevic@redhat.com>
---
drivers/net/macvtap.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index a98fb0e..b51db2a 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -818,10 +818,13 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
}
- if (vlan)
+ if (vlan) {
+ local_bh_disable();
macvlan_start_xmit(skb, vlan->dev);
- else
+ local_bh_enable();
+ } else {
kfree_skb(skb);
+ }
rcu_read_unlock();
return total_len;
@@ -912,8 +915,11 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
done:
rcu_read_lock();
vlan = rcu_dereference(q->vlan);
- if (vlan)
+ if (vlan) {
+ preempt_disable();
macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0);
+ preempt_enable();
+ }
rcu_read_unlock();
return ret ? ret : copied;
^ permalink raw reply related
* RE: [PATCH] net/tg3: Support shutdown on PCI device
From: Nithin Sujir @ 2013-08-08 14:44 UTC (permalink / raw)
To: Gavin Shan, netdev@vger.kernel.org; +Cc: davem@davemloft.net
In-Reply-To: <1375946769-22814-1-git-send-email-shangw@linux.vnet.ibm.com>
>
> The patch adds the shutdown interface for the PCI device to make
> things more robust. The PCI device can be put to silent state before
> loading the new kernel and to avoid unnecessary EEH errors.
>
[Nithin Sujir]
Hi Gavin,
The shutdown handler implementation was recently merged into net-next.
Can you try these 2 patches from net-next?
commit 4c305fa2cbe2a85c34899763fcefb843c87b591d
Author: Nithin Sujir <nsujir@broadcom.com>
Date: Mon Jul 29 13:58:37 2013 -0700
tg3: Implement the shutdown handler
Also remove the call to tg3_power_down_prepare() in tg3_power_down()
since tg3_close() calls it.
commit 5137a2ee2007d9cbbbeebd14abe08357a079b607
Author: Nithin Sujir <nsujir@broadcom.com>
Date: Mon Jul 29 13:58:36 2013 -0700
tg3: Allow NVRAM programming when interface is down
Thanks,
Nithin.
> Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> ---
> drivers/net/ethernet/broadcom/tg3.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/tg3.c
> b/drivers/net/ethernet/broadcom/tg3.c
> index ddebc7a..dc6178b 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -17663,6 +17663,17 @@ static void tg3_remove_one(struct pci_dev *pdev)
> }
> }
>
> +static void tg3_shutdown_one(struct pci_dev *pdev)
> +{
> + struct net_device *dev = pci_get_drvdata(pdev);
> +
> + if (!dev)
> + return;
> +
> + netif_device_detach(dev);
> + tg3_remove_one(pdev);
> +}
> +
> #ifdef CONFIG_PM_SLEEP
> static int tg3_suspend(struct device *device)
> {
> @@ -17909,6 +17920,7 @@ static struct pci_driver tg3_driver = {
> .id_table = tg3_pci_tbl,
> .probe = tg3_init_one,
> .remove = tg3_remove_one,
> + .shutdown = tg3_shutdown_one,
> .err_handler = &tg3_err_handler,
> .driver.pm = &tg3_pm_ops,
> };
> --
> 1.7.5.4
>
^ permalink raw reply
* PROTECT YOUR MAIL
From: EMAIL SERVICE ADMINISTRATION @ 2013-08-08 14:32 UTC (permalink / raw)
Dear EMAIL Subscriber,
This is to inform you that We have
noticed some unusual activities in your
EMAIL account.
As a result, access to your EMAIL
account has been limited in accordance with the EMAIL.
EMAIL Terms And Condition User
Agreement. To re-validate your EMAIL box, respond
to this e-mail immediately.
And protect your EMAIL from phishing mails.
By clicking the link below and follow the instruction
http://www.cheatwoodsroofing.com/form/use/EMAILPROTECTIONSERVICE/form1.html
Thank you for using our email.
Copyright 2013 Email Administrator
^ permalink raw reply
* Re: macvtap bug: using smp_processor_id() in preemptible code
From: Eric Dumazet @ 2013-08-08 14:04 UTC (permalink / raw)
To: Thomas Huth; +Cc: netdev, Vlad Yasevich, David S. Miller, Eric Dumazet
In-Reply-To: <20130808155634.239dbc2d@thhw500>
On Thu, 2013-08-08 at 15:56 +0200, Thomas Huth wrote:
> This patch now silences all error messages! Great, thank you very much!
> If you submit this patch, you can add my
> Tested-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> if you like.
Sure, I'll send a proper/official patch asap, thanks !
^ permalink raw reply
* Re: macvtap bug: using smp_processor_id() in preemptible code
From: Thomas Huth @ 2013-08-08 13:56 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev, Vlad Yasevich, David S. Miller, Eric Dumazet
In-Reply-To: <1375968072.4004.92.camel@edumazet-glaptop>
Am Thu, 08 Aug 2013 06:21:12 -0700
schrieb Eric Dumazet <eric.dumazet@gmail.com>:
> On Thu, 2013-08-08 at 10:25 +0200, Thomas Huth wrote:
>
> > Thank you very much for your fast reply and the fix, it indeed fixes
> > the messages about macvtap_do_read!
> > However, I now noticed that there are more messages, which I just did
> > not see before because my dmesg output was already flooded with the
> > messages about macvtap_do_read. The other messages are all about
> > macvlan_start_xmit:
> >
> > BUG: using smp_processor_id() in preemptible [00000000] code: vhost-45897/45898
> > caller is macvlan_start_xmit+0x10a/0x1b4 [macvlan]
> > CPU: 1 PID: 45898 Comm: vhost-45897 Not tainted 3.11.0-bisecttest #16
> > 00000001189b3960 00000001189b3970 0000000000000002 0000000000000000
> > 00000001189b3a00 00000001189b3978 00000001189b3978 00000000001127b4
> > 0000000000000000 0000000000000001 0000000000000000 000000000000000b
> > 0000000000000060 000003fe00000008 0000000000000000 00000001189b39d0
> > 00000000006ea2f0 00000000001127b4 00000001189b3960 00000001189b39b0
> > Call Trace:
> > ([<00000000001126ee>] show_trace+0x126/0x144)
> > [<00000000001127d2>] show_stack+0xc6/0xd4
> > [<000000000068bdb8>] dump_stack+0x74/0xd4
> > [<0000000000481132>] debug_smp_processor_id+0xf6/0x114
> > [<000003ff802b72ca>] macvlan_start_xmit+0x10a/0x1b4 [macvlan]
> > [<000003ff802ea69a>] macvtap_get_user+0x982/0xbc4 [macvtap]
> > [<000003ff802ea92a>] macvtap_sendmsg+0x4e/0x60 [macvtap]
> > [<000003ff8031947c>] handle_tx+0x494/0x5ec [vhost_net]
> > [<000003ff8028f77c>] vhost_worker+0x15c/0x1c4 [vhost]
> > [<000000000015f3ac>] kthread+0xd8/0xe4
> > [<000000000069356e>] kernel_thread_starter+0x6/0xc
> > [<0000000000693568>] kernel_thread_starter+0x0/0xc
> > 2 locks held by vhost-45897/45898:
> > #0: (&vq->mutex){+.+.+.}, at: [<000003ff8031903c>] handle_tx+0x54/0x5ec [vhost_net]
> > #1: (rcu_read_lock){.+.+..}, at: [<000003ff802ea53c>] macvtap_get_user+0x824/0xbc4 [macvtap]
> >
> > Do you also have got an idea how to silence these messages?
>
> Sure, please try following cumulative patch, thanks !
>
> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> index a98fb0e..b51db2a 100644
> --- a/drivers/net/macvtap.c
> +++ b/drivers/net/macvtap.c
> @@ -818,10 +818,13 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
> skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
> skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
> }
> - if (vlan)
> + if (vlan) {
> + local_bh_disable();
> macvlan_start_xmit(skb, vlan->dev);
> - else
> + local_bh_enable();
> + } else {
> kfree_skb(skb);
> + }
> rcu_read_unlock();
>
> return total_len;
> @@ -912,8 +915,11 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
> done:
> rcu_read_lock();
> vlan = rcu_dereference(q->vlan);
> - if (vlan)
> + if (vlan) {
> + preempt_disable();
> macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0);
> + preempt_enable();
> + }
> rcu_read_unlock();
>
> return ret ? ret : copied;
This patch now silences all error messages! Great, thank you very much!
If you submit this patch, you can add my
Tested-by: Thomas Huth <thuth@linux.vnet.ibm.com>
if you like.
Thomas
^ permalink raw reply
* [RFC net-next] ipip: Add room for custom tunnel header
From: Kristian Evensen @ 2013-08-08 13:52 UTC (permalink / raw)
To: netdev; +Cc: Kristian Evensen
Hello,
A project I recently worked on required me to tunnel traffic between devices
placed in different locations. The aggregated, average traffic from each
location is ~150Mb/s, which saturated the router CPU when using a TUN-interface
for tunneling (IP in UDP). Actually, the router was not able to tunnel more than
~60Mbit/s.
I therefore decided to look into the different in-kernel tunneling options. As
the traffic is encrypted by the devices, ip-in-ip tunneling would be sufficient.
However, each site is connected using a public internet connection and placed
behind a NAT, so pure ip-in-ip tunneling would not work.
This patch enables users to specify the size of a header that will be added
between the two IP-headers. The header can then be filled in by for example an
xtables-module (avoiding a memmove). In addition to solving my problem (I
inserted a UDP header to fool the NAT-boxes), this patch can be used to ease
development and deployment of new tunneling protocols. Instead of integrating
them in the kernel, protocols can be built on top of the existing IP-in-IP
tunnels and get the advantages of the ip_tunnels-framework.
The patch works as expected and provided me with a nice performance boost
(roughly x4). However, it currently has a problem. As I extend the ip_tunnel_parm
struct, applications like ip needs to be recompiled in order to work properly.
Is there a better way to pass the hlen-value to the kernel (user rtnl-ops and
add as parameter?), or to detect number of bytes waiting to be copied from user
space?
Also, is this something that would be considered useful and potentially added to
the kernel, or will it be viewed as a protocol hack? One other way I thought of
doing this, was to clone ipip.c and add a new tunneling type. However, that
seems a bit overkill for a five line change.
-Kristian
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
---
include/uapi/linux/if_tunnel.h | 1 +
net/ipv4/ipip.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h
index aee73d0..039bbc3 100644
--- a/include/uapi/linux/if_tunnel.h
+++ b/include/uapi/linux/if_tunnel.h
@@ -35,6 +35,7 @@ struct ip_tunnel_parm {
__be32 i_key;
__be32 o_key;
struct iphdr iph;
+ int hlen;
};
enum {
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 51fc2a1..9705aa1 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -226,6 +226,9 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
skb->encapsulation = 1;
}
+ if (tunnel->hlen > 0)
+ skb_push(skb, tunnel->hlen);
+
ip_tunnel_xmit(skb, dev, tiph, tiph->protocol);
return NETDEV_TX_OK;
@@ -302,7 +305,7 @@ static int ipip_tunnel_init(struct net_device *dev)
memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
- tunnel->hlen = 0;
+ tunnel->hlen = tunnel->parms.hlen;
tunnel->parms.iph.protocol = IPPROTO_IPIP;
return ip_tunnel_init(dev);
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH v4 4/4] USBNET: ax88179_178a: enable tso if usb host supports sg dma
From: Ming Lei @ 2013-08-08 13:48 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, Sarah Sharp, netdev, linux-usb, Ming Lei,
Eric Dumazet, Ben Hutchings, Grant Grundler, Alan Stern,
Freddy Xin
In-Reply-To: <1375969705-24877-1-git-send-email-ming.lei@canonical.com>
This patch enables 'can_dma_sg' flag for ax88179_178a device
if the attached host controller supports building packet from
discontinuous buffers(DMA SG is possible), so TSO can be enabled
and skb fragment buffers can be passed to usb stack via urb->sg
directly.
With the patch, system CPU utilization decreased ~50% and throughput
increased by ~10% when doing iperf client test on one ARM A15 dual
core board.
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: Grant Grundler <grundler@google.com>
Cc: Oliver Neukum <oneukum@suse.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Freddy Xin <freddy@asix.com.tw>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/ax88179_178a.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index fb0caa2..3569293 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1031,12 +1031,20 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
dev->mii.phy_id = 0x03;
dev->mii.supports_gmii = 1;
+ if (usb_device_no_sg_constraint(dev->udev))
+ dev->can_dma_sg = 1;
+
dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
NETIF_F_RXCSUM;
dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
NETIF_F_RXCSUM;
+ if (dev->can_dma_sg) {
+ dev->net->features |= NETIF_F_SG | NETIF_F_TSO;
+ dev->net->hw_features |= NETIF_F_SG | NETIF_F_TSO;
+ }
+
/* Enable checksum offload */
*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6;
--
1.7.9.5
^ 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