Netdev List
 help / color / mirror / Atom feed
* Re: [patch net-next-2.6] vlan: introduce ndo_vlan_[enable/disable]
From: Michał Mirosław @ 2011-07-16 14:14 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, shemminger, eric.dumazet, greearb
In-Reply-To: <1310811359-4440-1-git-send-email-jpirko@redhat.com>

2011/7/16 Jiri Pirko <jpirko@redhat.com>:
> Some devices are not able to enable/disable rx/tw vlan accel separately.
> they depend on ndo_vlan_rx_register to know if to enable of disable
> hw accel. And since ndo_vlan_rx_register is going to die soon,
> this must be resolved.
>
> One solution might be to enable accel on device start every time, even
> if there are no vlan up on. But this would change behaviour and might
> lead to possible regression (on older devices).
[...]

Please describe the possible regression. As I see it, there won't be
any user visible change of behaviour - network code takes care of
reinserting VLAN tag when necessary. If you think that disabling tag
stripping is beneficial for cases where no VLANs are configured, it's
better to do that in netdev_fix_features() for devices which advertise
NETIF_F_HW_VLAN_RX in hw_features.

Best Regards,
Michał Mirosław

^ permalink raw reply

* [patch net-next-2.6] vlan: introduce ndo_vlan_[enable/disable]
From: Jiri Pirko @ 2011-07-16 10:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, shemminger, eric.dumazet, greearb, mirqus

Some devices are not able to enable/disable rx/tw vlan accel separately.
they depend on ndo_vlan_rx_register to know if to enable of disable
hw accel. And since ndo_vlan_rx_register is going to die soon,
this must be resolved.

One solution might be to enable accel on device start every time, even
if there are no vlan up on. But this would change behaviour and might
lead to possible regression (on older devices).

Better is to preserve current behaviour and introduce a couple of ndos
to let device driver know when to enable/disable vlan accel. They are
alled at the same time as ndo_vlan_rx_register.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 include/linux/netdevice.h |   14 ++++++++++++++
 net/8021q/vlan.c          |    4 ++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f84dfd2..8a69f33 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -775,6 +775,18 @@ struct netdev_tc_txq {
  *	when vlan groups for the device changes.  Note: grp is NULL
  *	if no vlan's groups are being used.
  *
+ * void (*ndo_vlan_enable)(struct net_device *dev);
+ *	This function is called when first vlan is registered on this device.
+ *	This is primary to be implemented for devices what can enable rx/tx
+ *	vlan accel only at one. Otherwise enabling of vlan accel should be
+ *	implemented using ndo_set_features.
+ *
+ * void (*ndo_vlan_disable)(struct net_device *dev);
+ *	This function is called when last vlan is unregistered on this device.
+ *	This is primary to be implemented for devices what can disable rx/tx
+ *	vlan accel only at one. Otherwise disabling of vlan accel should be
+ *	implemented using ndo_set_features.
+ *
  * void (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid);
  *	If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
  *	this function is called when a VLAN id is registered.
@@ -895,6 +907,8 @@ struct net_device_ops {
 
 	void			(*ndo_vlan_rx_register)(struct net_device *dev,
 						        struct vlan_group *grp);
+	void			(*ndo_vlan_enable)(struct net_device *dev);
+	void			(*ndo_vlan_disable)(struct net_device *dev);
 	void			(*ndo_vlan_rx_add_vid)(struct net_device *dev,
 						       unsigned short vid);
 	void			(*ndo_vlan_rx_kill_vid)(struct net_device *dev,
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index d24c464..051c3cd 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -136,6 +136,8 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
 		rcu_assign_pointer(real_dev->vlgrp, NULL);
 		if (ops->ndo_vlan_rx_register)
 			ops->ndo_vlan_rx_register(real_dev, NULL);
+		if (ops->ndo_vlan_disable)
+			ops->ndo_vlan_disable(real_dev);
 
 		/* Free the group, after all cpu's are done. */
 		call_rcu(&grp->rcu, vlan_rcu_free);
@@ -209,6 +211,8 @@ int register_vlan_dev(struct net_device *dev)
 	if (ngrp) {
 		if (ops->ndo_vlan_rx_register && (real_dev->features & NETIF_F_HW_VLAN_RX))
 			ops->ndo_vlan_rx_register(real_dev, ngrp);
+		if (ops->ndo_vlan_enable)
+			ops->ndo_vlan_enable(real_dev);
 		rcu_assign_pointer(real_dev->vlgrp, ngrp);
 	}
 	if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
-- 
1.7.6


^ permalink raw reply related

* Re: [patch net-next-2.6 00/22] vlan cleanup round1
From: Jiri Pirko @ 2011-07-16 10:05 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: netdev, davem, shemminger, eric.dumazet, greearb
In-Reply-To: <20110715230719.GB3499@minipsycho.orion>

Sat, Jul 16, 2011 at 01:07:19AM CEST, jpirko@redhat.com wrote:
>Sat, Jul 16, 2011 at 12:15:42AM CEST, mirqus@gmail.com wrote:
>>2011/7/15 Jiri Pirko <jpirko@redhat.com>:
>>> This patchset converts several drivers to new vlan model.
>>> Also kills several vlan helpers:
>>> vlan_hwaccel_receive_skb,
>>> lro_vlan_hwaccel_receive_frags,
>>> lro_vlan_hwaccel_receive_skb
>>
>>It looks like most drivers that implement rx_add/kill_vid also need
>>bitmap recording all enabled VLANs. I think this could be done in
>>networking core for those devices in a generic way (set/clear before
>>corresponding rx_add/kill_vid call). The bitmap should be dynamically
>>allocated when needed (either on device registration time, or adding
>>first VLAN).

Problem is that for example in bonding, slaves do not have their
netdev->vlgrp set, they are not "officially" used by vlan code.
So their must maintain list of vids themselves. I would leave this as
it is atm and see what we can do later on.

>
>Right, I'm going to think about it. I might repost this patchset after
>that, So Dave please do not apply right away, thanks.

I will probably repost some of patches if my ndo_vlan_[enable/disable]
patch will be applied.

>
>Jirka
>>
>>This might be out of scope for this cleanup, though.
>>
>>Looks good otherwise.
>>
>>Best Regards,
>>Michał Mirosław

^ permalink raw reply

* Re: [PATCH] Fix panic in virtnet_remove
From: Krishna Kumar2 @ 2011-07-16  5:32 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, shemminger, mst
In-Reply-To: <20110715.081909.1693878001743345571.davem@davemloft.net>

[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]

David Miller <davem@davemloft.net> wrote on 07/15/2011 08:49:09 PM:

> > modprobe -r virtio_net panics in free_netdev() as the
> > dev is already freed in the newly introduced virtnet_free
> > (commit 3fa2a1df9094). Since virtnet_remove doesn't require
> > dev after unregister, I am removing the free_netdev call
> > in virtnet_remove instead of in virtnet_free (which seems
> > to be the right place to free the dev). Confirmed that
> > the panic is fixed with this patch.
> >
> > Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
>
> I guess the virtio NET maintainers don't deserve to get CC:'d on a fix
> like this? :-(
>
> Michael Tsirkin is who maintains this driver actively and is the one
> who will merge this kind of fix to me, therefore if you don't CC:
> him it might not get integrated at all.

Sorry, but it was not intentional. I saw that Stephen had
made that change so cc'd him instead.

Michael, I am attaching the patch below, please let me know if
you need it inlined:


(See attached file: patch)

Thanks,

- KK

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 921 bytes --]

modprobe -r virtio_net panics in free_netdev() as the
dev is already freed in the newly introduced virtnet_free
(commit 3fa2a1df9094). Since virtnet_remove doesn't require
dev after unregister, I am removing the free_netdev call
in virtnet_remove instead of in virtnet_free (which seems
to be the right place to free the dev). Confirmed that
the panic is fixed with this patch.

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
---
 drivers/net/virtio_net.c |    2 --
 1 file changed, 2 deletions(-)

diff -ruNp org/drivers/net/virtio_net.c new/drivers/net/virtio_net.c
--- org/drivers/net/virtio_net.c	2011-07-04 10:38:33.000000000 +0530
+++ new/drivers/net/virtio_net.c	2011-07-15 14:27:48.000000000 +0530
@@ -1121,8 +1121,6 @@ static void __devexit virtnet_remove(str
 
 	while (vi->pages)
 		__free_pages(get_a_page(vi, GFP_KERNEL), 0);
-
-	free_netdev(vi->dev);
 }
 
 static struct virtio_device_id id_table[] = {

^ permalink raw reply

* [PATCH 2/2] Bluetooth: Fix crash with incoming L2CAP connections
From: Gustavo F. Padovan @ 2011-07-16  4:30 UTC (permalink / raw)
  To: davem; +Cc: linville, netdev, linux-bluetooth, Ilia Kolomisnky
In-Reply-To: <1310790621-28510-2-git-send-email-padovan@profusion.mobi>

From: Ilia Kolomisnky <iliak@ti.com>

Another regression fix considering incomming l2cap connections with
defer_setup enabled. In situations when incomming connection is
extracted with l2cap_sock_accept, it's bt_sock info will have
'parent' member zerroed, but 'parent' may be used unconditionally
in l2cap_conn_start() and l2cap_security_cfm() when defer_setup
is enabled.

Backtrace:
[<bf02d5ac>] (l2cap_security_cfm+0x0/0x2ac [bluetooth]) from [<bf01f01c>] (hci_event_pac
ket+0xc2c/0x4aa4 [bluetooth])
[<bf01e3f0>] (hci_event_packet+0x0/0x4aa4 [bluetooth]) from [<bf01a844>] (hci_rx_task+0x
cc/0x27c [bluetooth])
[<bf01a778>] (hci_rx_task+0x0/0x27c [bluetooth]) from [<c008eee4>] (tasklet_action+0xa0/
0x15c)
[<c008ee44>] (tasklet_action+0x0/0x15c) from [<c008f38c>] (__do_softirq+0x98/0x130)
 r7:00000101 r6:00000018 r5:00000001 r4:efc46000
[<c008f2f4>] (__do_softirq+0x0/0x130) from [<c008f524>] (do_softirq+0x4c/0x58)
[<c008f4d8>] (do_softirq+0x0/0x58) from [<c008f5e0>] (run_ksoftirqd+0xb0/0x1b4)
 r4:efc46000 r3:00000001
[<c008f530>] (run_ksoftirqd+0x0/0x1b4) from [<c009f2a8>] (kthread+0x84/0x8c)
 r7:00000000 r6:c008f530 r5:efc47fc4 r4:efc41f08
[<c009f224>] (kthread+0x0/0x8c) from [<c008cc84>] (do_exit+0x0/0x5f0)

Signed-off-by: Ilia Kolomisnky <iliak@ti.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 net/bluetooth/l2cap_core.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 4fbf67e..7705e26 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -620,7 +620,8 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
 					struct sock *parent = bt_sk(sk)->parent;
 					rsp.result = cpu_to_le16(L2CAP_CR_PEND);
 					rsp.status = cpu_to_le16(L2CAP_CS_AUTHOR_PEND);
-					parent->sk_data_ready(parent, 0);
+					if (parent)
+						parent->sk_data_ready(parent, 0);
 
 				} else {
 					sk->sk_state = BT_CONFIG;
@@ -4009,7 +4010,8 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
 					struct sock *parent = bt_sk(sk)->parent;
 					res = L2CAP_CR_PEND;
 					stat = L2CAP_CS_AUTHOR_PEND;
-					parent->sk_data_ready(parent, 0);
+					if (parent)
+						parent->sk_data_ready(parent, 0);
 				} else {
 					sk->sk_state = BT_CONFIG;
 					res = L2CAP_CR_SUCCESS;
-- 
1.7.6


^ permalink raw reply related

* [PATCH 1/2] Bluetooth: Fix regression in L2CAP connection procedure
From: Gustavo F. Padovan @ 2011-07-16  4:30 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: linville-2XuSBdqkA4R54TAoqtyWWQ, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA, Gustavo F. Padovan
In-Reply-To: <1310790621-28510-1-git-send-email-padovan-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org>

From: "Gustavo F. Padovan" <padovan-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org>

Caused by the following commit, partially revert it.

commit 9fa7e4f76f3658ba1f44fbdb95c77e7df3f53f95
Author: Gustavo F. Padovan <padovan-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org>
Date:   Thu Jun 30 16:11:30 2011 -0300

    Bluetooth: Fix regression with incoming L2CAP connections

    PTS test A2DP/SRC/SRC_SET/TC_SRC_SET_BV_02_I revealed that
    ( probably after the df3c3931e commit ) the l2cap connection
    could not be established in case when the "Auth Complete" HCI
    event does not arive before the initiator send "Configuration
    request", in which case l2cap replies with "Command rejected"
    since the channel is still in BT_CONNECT2 state.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Gustavo F. Padovan <padovan-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org>
---
 net/bluetooth/l2cap_core.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ebff14c..4fbf67e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2323,8 +2323,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
 
 	sk = chan->sk;
 
-	if ((bt_sk(sk)->defer_setup && sk->sk_state != BT_CONNECT2) ||
-		 (!bt_sk(sk)->defer_setup && sk->sk_state != BT_CONFIG)) {
+	if (sk->sk_state != BT_CONFIG && sk->sk_state != BT_CONNECT2) {
 		struct l2cap_cmd_rej rej;
 
 		rej.reason = cpu_to_le16(0x0002);
-- 
1.7.6

^ permalink raw reply related

* [PATCH 0/2] Bluetooth: Fix regressions for 3.0
From: Gustavo F. Padovan @ 2011-07-16  4:30 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: linville-2XuSBdqkA4R54TAoqtyWWQ, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA, Gustavo F. Padovan

From: "Gustavo F. Padovan" <padovan-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org>

Gustavo F. Padovan (1):
  Bluetooth: Fix regression in L2CAP connection procedure

Ilia Kolomisnky (1):
  Bluetooth: Fix crash with incoming L2CAP connections

 net/bluetooth/l2cap_core.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

-- 
1.7.6

^ permalink raw reply

* Re: [PATCH net-next] bnx2: Close device if tx_timeout reset fails
From: Flavio Leitner @ 2011-07-16  3:16 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev
In-Reply-To: <1310748838-30877-1-git-send-email-mchan@broadcom.com>

On Fri, 15 Jul 2011 09:53:58 -0700
"Michael Chan" <mchan@broadcom.com> wrote:
...
> To fix it, we call dev_close() if bnx2_init_nic() fails.
> One minor wrinkle to deal with is the cancel_work_sync()
> call in bnx2_close() to cancel bnx2_reset_task().  The
> call will wait forever because it is trying to cancel
> itself and the workqueue will be stuck.
> 
> Since bnx2_reset_task() holds the rtnl_lock() and checks
> for netif_running() before proceeding, there is no need
> to cancel bnx2_reset_task() in bnx2_close() even if
> bnx2_close() and bnx2_reset_task() are running concurrently.
> The rtnl_lock() serializes the 2 calls.
> 
> We need to move the cancel_work_sync() call to
> bnx2_remove_one() to make sure it is canceled before freeing
> the netdev struct.

It looks good. I'm traveling now, so I'll test this on Monday.
thanks,
fbl

^ permalink raw reply

* Re: [PATCH] iproute2: Auto-detect the presence of setns in libc
From: Dan McGee @ 2011-07-16  0:34 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Stephen Hemminger, netdev
In-Reply-To: <m1mxgfkr3g.fsf@fess.ebiederm.org>

On Fri, Jul 15, 2011 at 7:26 PM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
>
> If libc has setns present use that version instead of
> rolling the syscall wrapper by hand.
>
> Dan McGee found the following compile error:
>
>    gcc -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -I../include
>    -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib/\"   -c -o ipnetns.o ipnetns.c
>    ipnetns.c:31:12: error: static declaration of ‘setns’ follows non-static
>    declaration
>    /usr/include/bits/sched.h:93:12: note: previous declaration of ‘setns’
>    was here
>    make[1]: *** [ipnetns.o] Error 1
>
> Reported-by:  Dan McGee <dan@archlinux.org>
> Tested-by:  Dan McGee <dan@archlinux.org>
Should mention that this was tested on glibc 2.14, where the setns
function was introduced.

> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>

And I forgot to be explicit, but:
Signed-off--by:  Dan McGee <dan@archlinux.org>

> ---
>  configure    |   24 ++++++++++++++++++++++++
>  ip/Makefile  |    6 ++++++
>  ip/ipnetns.c |    2 ++
>  3 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/configure b/configure
> index 69797ab..cfcc82a 100755
> --- a/configure
> +++ b/configure
> @@ -163,6 +163,27 @@ check_ipt_lib_dir()
>        echo "not found!"
>  }
>
> +check_setns()
> +{
> +cat >/tmp/setnstest.c <<EOF
> +#include <sched.h>
> +int main(int argc, char **argv)
> +{
> +       (void)setns(0,0);
> +       return 0;
> +}
> +EOF
> +gcc -I$INCLUDE -o /tmp/setnstest /tmp/setnstest.c >/dev/null 2>&1
> +if [ $? -eq 0 ]
> +then
> +       echo "IP_CONFIG_SETNS:=y" >>Config
> +       echo "yes"
> +else
> +       echo "no"
> +fi
> +rm -f /tmp/setnstest.c /tmp/setnstest
> +}
> +
>  echo "# Generated config based on" $INCLUDE >Config
>
>  echo "TC schedulers"
> @@ -178,3 +199,6 @@ check_ipt
>
>  echo -n "iptables modules directory: "
>  check_ipt_lib_dir
> +
> +echo -n "libc has setns: "
> +check_setns
> diff --git a/ip/Makefile b/ip/Makefile
> index 2ee4e7c..8d03993 100644
> --- a/ip/Makefile
> +++ b/ip/Makefile
> @@ -7,6 +7,12 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
>
>  RTMONOBJ=rtmon.o
>
> +include ../Config
> +
> +ifeq ($(IP_CONFIG_SETNS),y)
> +       CFLAGS += -DHAVE_SETNS
> +endif
> +
>  ALLOBJ=$(IPOBJ) $(RTMONOBJ)
>  SCRIPTS=ifcfg rtpr routel routef
>  TARGETS=ip rtmon
> diff --git a/ip/ipnetns.c b/ip/ipnetns.c
> index db7007c..dff3497 100644
> --- a/ip/ipnetns.c
> +++ b/ip/ipnetns.c
> @@ -28,6 +28,7 @@
>  #define MNT_DETACH     0x00000002      /* Just detach from the tree */
>  #endif /* MNT_DETACH */
>
> +#ifndef HAVE_SETNS
>  static int setns(int fd, int nstype)
>  {
>  #ifdef __NR_setns
> @@ -37,6 +38,7 @@ static int setns(int fd, int nstype)
>        return -1;
>  #endif
>  }
> +#endif /* HAVE_SETNS */
>
>
>  static int touch(const char *path, mode_t mode)
> --
> 1.7.5.1.217.g4e3aa
>
>

^ permalink raw reply

* [PATCH] iproute2: Fail "ip netns add" on existing network namespaces.
From: Eric W. Biederman @ 2011-07-16  0:29 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev


Use O_EXCL so that we only create and mount a new network namespace
if there is no chance an existing network namespace is present.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---

 ip/ipnetns.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index dff3497..e41a598 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -41,16 +41,6 @@ static int setns(int fd, int nstype)
 #endif /* HAVE_SETNS */
 
 
-static int touch(const char *path, mode_t mode)
-{
-	int fd;
-	fd = open(path, O_RDONLY|O_CREAT, mode);
-	if (fd < 0)
-		return -1;
-	close(fd);
-	return 0;
-}
-
 static void usage(void) __attribute__((noreturn));
 
 static void usage(void)
@@ -214,6 +204,7 @@ static int netns_add(int argc, char **argv)
 	 */
 	char netns_path[MAXPATHLEN];
 	const char *name;
+	int fd;
 
 	if (argc < 1) {
 		fprintf(stderr, "No netns name specified\n");
@@ -227,11 +218,13 @@ static int netns_add(int argc, char **argv)
 	mkdir(NETNS_RUN_DIR, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
 
 	/* Create the filesystem state */
-	if (touch(netns_path, 0) < 0) {
+	fd = open(netns_path, O_RDONLY|O_CREAT|O_EXCL, 0);
+	if (fd < 0) {
 		fprintf(stderr, "Could not create %s: %s\n",
 			netns_path, strerror(errno));
-		goto out_delete;
+		return -1;
 	}
+	close(fd);
 	if (unshare(CLONE_NEWNET) < 0) {
 		fprintf(stderr, "Failed to create a new network namespace: %s\n",
 			strerror(errno));
-- 
1.7.5.1.217.g4e3aa


^ permalink raw reply related

* [PATCH] iproute2: Auto-detect the presence of setns in libc
From: Eric W. Biederman @ 2011-07-16  0:26 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Dan McGee


If libc has setns present use that version instead of
rolling the syscall wrapper by hand.

Dan McGee found the following compile error:

    gcc -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -I../include
    -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib/\"   -c -o ipnetns.o ipnetns.c
    ipnetns.c:31:12: error: static declaration of ‘setns’ follows non-static
    declaration
    /usr/include/bits/sched.h:93:12: note: previous declaration of ‘setns’
    was here
    make[1]: *** [ipnetns.o] Error 1

Reported-by:  Dan McGee <dan@archlinux.org>
Tested-by:  Dan McGee <dan@archlinux.org>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 configure    |   24 ++++++++++++++++++++++++
 ip/Makefile  |    6 ++++++
 ip/ipnetns.c |    2 ++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 69797ab..cfcc82a 100755
--- a/configure
+++ b/configure
@@ -163,6 +163,27 @@ check_ipt_lib_dir()
 	echo "not found!"
 }
 
+check_setns()
+{
+cat >/tmp/setnstest.c <<EOF
+#include <sched.h>
+int main(int argc, char **argv) 
+{
+	(void)setns(0,0);
+	return 0;
+}
+EOF
+gcc -I$INCLUDE -o /tmp/setnstest /tmp/setnstest.c >/dev/null 2>&1
+if [ $? -eq 0 ]
+then
+	echo "IP_CONFIG_SETNS:=y" >>Config
+	echo "yes"
+else
+	echo "no"
+fi
+rm -f /tmp/setnstest.c /tmp/setnstest
+}
+
 echo "# Generated config based on" $INCLUDE >Config
 
 echo "TC schedulers"
@@ -178,3 +199,6 @@ check_ipt
 
 echo -n "iptables modules directory: "
 check_ipt_lib_dir
+
+echo -n "libc has setns: "
+check_setns
diff --git a/ip/Makefile b/ip/Makefile
index 2ee4e7c..8d03993 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -7,6 +7,12 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
 
 RTMONOBJ=rtmon.o
 
+include ../Config
+
+ifeq ($(IP_CONFIG_SETNS),y)
+	CFLAGS += -DHAVE_SETNS
+endif
+
 ALLOBJ=$(IPOBJ) $(RTMONOBJ)
 SCRIPTS=ifcfg rtpr routel routef
 TARGETS=ip rtmon
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index db7007c..dff3497 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -28,6 +28,7 @@
 #define MNT_DETACH	0x00000002	/* Just detach from the tree */
 #endif /* MNT_DETACH */
 
+#ifndef HAVE_SETNS
 static int setns(int fd, int nstype)
 {
 #ifdef __NR_setns
@@ -37,6 +38,7 @@ static int setns(int fd, int nstype)
 	return -1;
 #endif
 }
+#endif /* HAVE_SETNS */
 
 
 static int touch(const char *path, mode_t mode)
-- 
1.7.5.1.217.g4e3aa


^ permalink raw reply related

* Re: recommended way to support duplicate IP addresses on different VLANs?
From: Eric W. Biederman @ 2011-07-16  0:24 UTC (permalink / raw)
  To: Rémi Denis-Courmont; +Cc: Chris Friesen, netdev
In-Reply-To: <201107111804.26500.remi@remlab.net>

"Rémi Denis-Courmont" <remi@remlab.net> writes:

> Le lundi 11 juillet 2011 17:58:14 Chris Friesen, vous avez écrit :
>> Hi all,
>> 
>> We've got a server that sits on multiple VLANs.  Each VLAN is segregated
>> and doesn't know about the others.  The IP address ranges in each of the
>> VLANs may overlap, and the server may be assigned the same IP address in
>> multiple VLANs.
>> 
>> We've got a messy solution now involving unique internal addresses and
>> NATing between those and the duplicate external addresses, but I'm
>> wondering if there is a cleaner way to handle this.
>> 
>> It seems like network namespaces would work, but it would require
>> multiple instances of our software which is a dealbreaker.
>> 
>> Is there any other way to deal with this scenario?
>
> Namespace file descriptors if/when they get accepted.

For reference.

The namespace file descriptor code is in 3.0.  setns is present in the
latest glibc.  And the iproute support is just finishing up.

What doesn't exist at the moment is a handy socketat library
function to make it a userspace program that uses multiple network
namespaces trivial.  But that is only a few lines of code.

It sounds like you don't need the full generality of network
namespaces but if you do the functionality is present.

Eric

^ permalink raw reply

* Re: [PATCH] Rename static setns() function
From: Dan McGee @ 2011-07-16  0:02 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: netdev
In-Reply-To: <m1d3hbm7s7.fsf@fess.ebiederm.org>

On Fri, Jul 15, 2011 at 6:41 PM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
>
> Dan can you try this patch I think it does a better job at dealing
> with libc defining setns but I don't have a brand new libc handy
> to test with.

Works perfectly (as long as one remembers to rerun ./configure first).
It also works fine with my other configure patch I sent to the list.

-Dan

> From: "Eric W. Biederman" <ebiederm@xmission.com>
> Date: Fri, 15 Jul 2011 16:36:33 -0700
> Subject: [PATCH] iproute2: Auto-detect the presence of setns in libc
>
> If libc has setns present use that version instead of
> rolling the syscall wrapper by hand.
>
> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
> ---
>  configure    |   24 ++++++++++++++++++++++++
>  ip/Makefile  |    6 ++++++
>  ip/ipnetns.c |    2 ++
>  3 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/configure b/configure
> index 69797ab..cfcc82a 100755
> --- a/configure
> +++ b/configure
> @@ -163,6 +163,27 @@ check_ipt_lib_dir()
>        echo "not found!"
>  }
>
> +check_setns()
> +{
> +cat >/tmp/setnstest.c <<EOF
> +#include <sched.h>
> +int main(int argc, char **argv)
> +{
> +       (void)setns(0,0);
> +       return 0;
> +}
> +EOF
> +gcc -I$INCLUDE -o /tmp/setnstest /tmp/setnstest.c >/dev/null 2>&1
> +if [ $? -eq 0 ]
> +then
> +       echo "IP_CONFIG_SETNS:=y" >>Config
> +       echo "yes"
> +else
> +       echo "no"
> +fi
> +rm -f /tmp/setnstest.c /tmp/setnstest
> +}
> +
>  echo "# Generated config based on" $INCLUDE >Config
>
>  echo "TC schedulers"
> @@ -178,3 +199,6 @@ check_ipt
>
>  echo -n "iptables modules directory: "
>  check_ipt_lib_dir
> +
> +echo -n "libc has setns: "
> +check_setns
> diff --git a/ip/Makefile b/ip/Makefile
> index 2ee4e7c..8d03993 100644
> --- a/ip/Makefile
> +++ b/ip/Makefile
> @@ -7,6 +7,12 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
>
>  RTMONOBJ=rtmon.o
>
> +include ../Config
> +
> +ifeq ($(IP_CONFIG_SETNS),y)
> +       CFLAGS += -DHAVE_SETNS
> +endif
> +
>  ALLOBJ=$(IPOBJ) $(RTMONOBJ)
>  SCRIPTS=ifcfg rtpr routel routef
>  TARGETS=ip rtmon
> diff --git a/ip/ipnetns.c b/ip/ipnetns.c
> index db7007c..dff3497 100644
> --- a/ip/ipnetns.c
> +++ b/ip/ipnetns.c
> @@ -28,6 +28,7 @@
>  #define MNT_DETACH     0x00000002      /* Just detach from the tree */
>  #endif /* MNT_DETACH */
>
> +#ifndef HAVE_SETNS
>  static int setns(int fd, int nstype)
>  {
>  #ifdef __NR_setns
> @@ -37,6 +38,7 @@ static int setns(int fd, int nstype)
>        return -1;
>  #endif
>  }
> +#endif /* HAVE_SETNS */
>
>
>  static int touch(const char *path, mode_t mode)
> --
> 1.7.5.1.217.g4e3aa
>
>

^ permalink raw reply

* Re: [PATCH] Rename static setns() function
From: Eric W. Biederman @ 2011-07-15 23:41 UTC (permalink / raw)
  To: Dan McGee; +Cc: netdev
In-Reply-To: <1310755099-32438-1-git-send-email-dan@archlinux.org>


Dan can you try this patch I think it does a better job at dealing
with libc defining setns but I don't have a brand new libc handy
to test with.

Eric

From: "Eric W. Biederman" <ebiederm@xmission.com>
Date: Fri, 15 Jul 2011 16:36:33 -0700
Subject: [PATCH] iproute2: Auto-detect the presence of setns in libc

If libc has setns present use that version instead of
rolling the syscall wrapper by hand.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 configure    |   24 ++++++++++++++++++++++++
 ip/Makefile  |    6 ++++++
 ip/ipnetns.c |    2 ++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 69797ab..cfcc82a 100755
--- a/configure
+++ b/configure
@@ -163,6 +163,27 @@ check_ipt_lib_dir()
 	echo "not found!"
 }
 
+check_setns()
+{
+cat >/tmp/setnstest.c <<EOF
+#include <sched.h>
+int main(int argc, char **argv) 
+{
+	(void)setns(0,0);
+	return 0;
+}
+EOF
+gcc -I$INCLUDE -o /tmp/setnstest /tmp/setnstest.c >/dev/null 2>&1
+if [ $? -eq 0 ]
+then
+	echo "IP_CONFIG_SETNS:=y" >>Config
+	echo "yes"
+else
+	echo "no"
+fi
+rm -f /tmp/setnstest.c /tmp/setnstest
+}
+
 echo "# Generated config based on" $INCLUDE >Config
 
 echo "TC schedulers"
@@ -178,3 +199,6 @@ check_ipt
 
 echo -n "iptables modules directory: "
 check_ipt_lib_dir
+
+echo -n "libc has setns: "
+check_setns
diff --git a/ip/Makefile b/ip/Makefile
index 2ee4e7c..8d03993 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -7,6 +7,12 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
 
 RTMONOBJ=rtmon.o
 
+include ../Config
+
+ifeq ($(IP_CONFIG_SETNS),y)
+	CFLAGS += -DHAVE_SETNS
+endif
+
 ALLOBJ=$(IPOBJ) $(RTMONOBJ)
 SCRIPTS=ifcfg rtpr routel routef
 TARGETS=ip rtmon
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index db7007c..dff3497 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -28,6 +28,7 @@
 #define MNT_DETACH	0x00000002	/* Just detach from the tree */
 #endif /* MNT_DETACH */
 
+#ifndef HAVE_SETNS
 static int setns(int fd, int nstype)
 {
 #ifdef __NR_setns
@@ -37,6 +38,7 @@ static int setns(int fd, int nstype)
 	return -1;
 #endif
 }
+#endif /* HAVE_SETNS */
 
 
 static int touch(const char *path, mode_t mode)
-- 
1.7.5.1.217.g4e3aa


^ permalink raw reply related

* Re: [patch net-next-2.6 00/22] vlan cleanup round1
From: Jiri Pirko @ 2011-07-15 23:07 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: netdev, davem, shemminger, eric.dumazet, greearb
In-Reply-To: <CAHXqBFJiNx3N+Rs_dxMqSThN59kvmYauU=-mWvZEf9pUQ-MoZA@mail.gmail.com>

Sat, Jul 16, 2011 at 12:15:42AM CEST, mirqus@gmail.com wrote:
>2011/7/15 Jiri Pirko <jpirko@redhat.com>:
>> This patchset converts several drivers to new vlan model.
>> Also kills several vlan helpers:
>> vlan_hwaccel_receive_skb,
>> lro_vlan_hwaccel_receive_frags,
>> lro_vlan_hwaccel_receive_skb
>
>It looks like most drivers that implement rx_add/kill_vid also need
>bitmap recording all enabled VLANs. I think this could be done in
>networking core for those devices in a generic way (set/clear before
>corresponding rx_add/kill_vid call). The bitmap should be dynamically
>allocated when needed (either on device registration time, or adding
>first VLAN).

Right, I'm going to think about it. I might repost this patchset after
that, So Dave please do not apply right away, thanks.

Jirka
>
>This might be out of scope for this cleanup, though.
>
>Looks good otherwise.
>
>Best Regards,
>Michał Mirosław

^ permalink raw reply

* Re: [PATCH] gianfar: rx parser
From: David Miller @ 2011-07-15 23:00 UTC (permalink / raw)
  To: jpirko; +Cc: sebastian.belden, netdev, sandeep.kumar
In-Reply-To: <20110715195133.GA3499@minipsycho.orion>

From: Jiri Pirko <jpirko@redhat.com>
Date: Fri, 15 Jul 2011 21:51:34 +0200

> From: Sebastian Pöhn <sebastian.belden@googlemail.com>
> Subject: [patch net-next-2.6] gianfar: rx parser
> 
> Only let the rx parser be enabled if it is necessary (if VLAN extraction,
> IP or TCP checksumming or the rx queue filer are enabled). Otherwise
> disable it.
> 
> The new routine gfar_check_rx_parser_mode should be run after every
> change on this features and will enable/disable the parser as necessary.
> 
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> Signed-off-by: Sebastian Poehn <sebastian.poehn@belden.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] Rename static setns() function
From: David Miller @ 2011-07-15 22:58 UTC (permalink / raw)
  To: dan; +Cc: netdev, ebiederm
In-Reply-To: <1310755099-32438-1-git-send-email-dan@archlinux.org>

From: Dan McGee <dan@archlinux.org>
Date: Fri, 15 Jul 2011 13:38:19 -0500

> Fixes the following error:
> 
>     gcc -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -I../include
>     -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib/\"   -c -o ipnetns.o ipnetns.c
>     ipnetns.c:31:12: error: static declaration of ‘setns’ follows non-static
>     declaration
>     /usr/include/bits/sched.h:93:12: note: previous declaration of ‘setns’
>     was here
>     make[1]: *** [ipnetns.o] Error 1
> 
> Fixes issue introduced in commit 0dc34c7713bb7055.
> 
> Signed-off-by: Dan McGee <dan@archlinux.org>

Thanks for fixing this:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH 03/10] net: add APIs for manipulating skb page fragments.
From: Michał Mirosław @ 2011-07-15 22:34 UTC (permalink / raw)
  To: Ian Campbell
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-nfs-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1310728031-19569-3-git-send-email-ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>

2011/7/15 Ian Campbell <ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>:
[...]
> +static inline dma_addr_t skb_frag_pci_map(struct pci_dev *hwdev,
> +                                         const skb_frag_t *frag,
> +                                         unsigned long offset,
> +                                         size_t size,
> +                                         int direction)
> +
> +{
> +       return pci_map_page(hwdev, __skb_frag_page(frag),
> +                           frag->page_offset + offset, size, direction);
> +}

You can get rid of this one, as drivers should be converted to generic
DMA API instead. The change is only in passing &pci_dev->dev instead
of pci_dev.

Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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-2.6 00/22] vlan cleanup round1
From: Michał Mirosław @ 2011-07-15 22:15 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, shemminger, eric.dumazet, greearb
In-Reply-To: <1310765619-27827-1-git-send-email-jpirko@redhat.com>

2011/7/15 Jiri Pirko <jpirko@redhat.com>:
> This patchset converts several drivers to new vlan model.
> Also kills several vlan helpers:
> vlan_hwaccel_receive_skb,
> lro_vlan_hwaccel_receive_frags,
> lro_vlan_hwaccel_receive_skb

It looks like most drivers that implement rx_add/kill_vid also need
bitmap recording all enabled VLANs. I think this could be done in
networking core for those devices in a generic way (set/clear before
corresponding rx_add/kill_vid call). The bitmap should be dynamically
allocated when needed (either on device registration time, or adding
first VLAN).

This might be out of scope for this cleanup, though.

Looks good otherwise.

Best Regards,
Michał Mirosław

^ permalink raw reply

* [patch net-next-2.6 14/21] mlx4: do vlan cleanup
From: Jiri Pirko @ 2011-07-15 21:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, shemminger, eric.dumazet, greearb, mirqus
In-Reply-To: <1310765619-27827-1-git-send-email-jpirko@redhat.com>

- unify vlan and nonvlan path
- kill priv->vlgrp and mlx4_en_vlan_rx_register

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/mlx4/en_netdev.c |   49 +++++++++--------------------------------
 drivers/net/mlx4/en_port.c   |   23 +++++++------------
 drivers/net/mlx4/en_rx.c     |   24 +++++++++++---------
 drivers/net/mlx4/mlx4_en.h   |    6 +++-
 4 files changed, 37 insertions(+), 65 deletions(-)

diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 61850ad..9d3f57e 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -45,25 +45,6 @@
 #include "mlx4_en.h"
 #include "en_port.h"
 
-
-static void mlx4_en_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
-{
-	struct mlx4_en_priv *priv = netdev_priv(dev);
-	struct mlx4_en_dev *mdev = priv->mdev;
-	int err;
-
-	en_dbg(HW, priv, "Registering VLAN group:%p\n", grp);
-	priv->vlgrp = grp;
-
-	mutex_lock(&mdev->state_lock);
-	if (mdev->device_up && priv->port_up) {
-		err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, grp);
-		if (err)
-			en_err(priv, "Failed configuring VLAN filter\n");
-	}
-	mutex_unlock(&mdev->state_lock);
-}
-
 static void mlx4_en_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
 {
 	struct mlx4_en_priv *priv = netdev_priv(dev);
@@ -71,16 +52,14 @@ static void mlx4_en_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
 	int err;
 	int idx;
 
-	if (!priv->vlgrp)
-		return;
+	en_dbg(HW, priv, "adding VLAN:%d\n", vid);
 
-	en_dbg(HW, priv, "adding VLAN:%d (vlgrp entry:%p)\n",
-	       vid, vlan_group_get_device(priv->vlgrp, vid));
+	set_bit(vid, priv->active_vlans);
 
 	/* Add VID to port VLAN filter */
 	mutex_lock(&mdev->state_lock);
 	if (mdev->device_up && priv->port_up) {
-		err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, priv->vlgrp);
+		err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
 		if (err)
 			en_err(priv, "Failed configuring VLAN filter\n");
 	}
@@ -97,12 +76,9 @@ static void mlx4_en_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
 	int err;
 	int idx;
 
-	if (!priv->vlgrp)
-		return;
+	en_dbg(HW, priv, "Killing VID:%d\n", vid);
 
-	en_dbg(HW, priv, "Killing VID:%d (vlgrp:%p vlgrp entry:%p)\n",
-	       vid, priv->vlgrp, vlan_group_get_device(priv->vlgrp, vid));
-	vlan_group_set_device(priv->vlgrp, vid, NULL);
+	clear_bit(vid, priv->active_vlans);
 
 	/* Remove VID from port VLAN filter */
 	mutex_lock(&mdev->state_lock);
@@ -112,7 +88,7 @@ static void mlx4_en_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
 		en_err(priv, "could not find vid %d in cache\n", vid);
 
 	if (mdev->device_up && priv->port_up) {
-		err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, priv->vlgrp);
+		err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
 		if (err)
 			en_err(priv, "Failed configuring VLAN filter\n");
 	}
@@ -265,12 +241,10 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
 				priv->flags |= MLX4_EN_FLAG_MC_PROMISC;
 			}
 
-			if (priv->vlgrp) {
-				/* Disable port VLAN filter */
-				err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, NULL);
-				if (err)
-					en_err(priv, "Failed disabling VLAN filter\n");
-			}
+			/* Disable port VLAN filter */
+			err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
+			if (err)
+				en_err(priv, "Failed disabling VLAN filter\n");
 		}
 		goto out;
 	}
@@ -304,7 +278,7 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
 		}
 
 		/* Enable port VLAN filter */
-		err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, priv->vlgrp);
+		err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
 		if (err)
 			en_err(priv, "Failed enabling VLAN filter\n");
 	}
@@ -1046,7 +1020,6 @@ static const struct net_device_ops mlx4_netdev_ops = {
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_change_mtu		= mlx4_en_change_mtu,
 	.ndo_tx_timeout		= mlx4_en_tx_timeout,
-	.ndo_vlan_rx_register	= mlx4_en_vlan_rx_register,
 	.ndo_vlan_rx_add_vid	= mlx4_en_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= mlx4_en_vlan_rx_kill_vid,
 #ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/mlx4/en_port.c b/drivers/net/mlx4/en_port.c
index f2a4f5d..2a74bc8 100644
--- a/drivers/net/mlx4/en_port.c
+++ b/drivers/net/mlx4/en_port.c
@@ -48,7 +48,7 @@ int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port,
 			MLX4_CMD_SET_MCAST_FLTR, MLX4_CMD_TIME_CLASS_B);
 }
 
-int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, struct vlan_group *grp)
+int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv)
 {
 	struct mlx4_cmd_mailbox *mailbox;
 	struct mlx4_set_vlan_fltr_mbox *filter;
@@ -63,20 +63,15 @@ int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, struct vlan_group *grp)
 		return PTR_ERR(mailbox);
 
 	filter = mailbox->buf;
-	if (grp) {
-		memset(filter, 0, sizeof *filter);
-		for (i = VLAN_FLTR_SIZE - 1; i >= 0; i--) {
-			entry = 0;
-			for (j = 0; j < 32; j++)
-				if (vlan_group_get_device(grp, index++))
-					entry |= 1 << j;
-			filter->entry[i] = cpu_to_be32(entry);
-		}
-	} else {
-		/* When no vlans are configured we block all vlans */
-		memset(filter, 0, sizeof(*filter));
+	memset(filter, 0, sizeof(*filter));
+	for (i = VLAN_FLTR_SIZE - 1; i >= 0; i--) {
+		entry = 0;
+		for (j = 0; j < 32; j++)
+			if (test_bit(index++, priv->active_vlans))
+				entry |= 1 << j;
+		filter->entry[i] = cpu_to_be32(entry);
 	}
-	err = mlx4_cmd(dev, mailbox->dma, port, 0, MLX4_CMD_SET_VLAN_FLTR,
+	err = mlx4_cmd(dev, mailbox->dma, priv->port, 0, MLX4_CMD_SET_VLAN_FLTR,
 		       MLX4_CMD_TIME_CLASS_B);
 	mlx4_free_cmd_mailbox(dev, mailbox);
 	return err;
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 5197b50..37cc9e5 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -611,11 +611,14 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 					gro_skb->truesize += length;
 					gro_skb->ip_summed = CHECKSUM_UNNECESSARY;
 
-					if (priv->vlgrp && (cqe->vlan_my_qpn &
-							    cpu_to_be32(MLX4_CQE_VLAN_PRESENT_MASK)))
-						vlan_gro_frags(&cq->napi, priv->vlgrp, be16_to_cpu(cqe->sl_vid));
-					else
-						napi_gro_frags(&cq->napi);
+					if (cqe->vlan_my_qpn &
+					    cpu_to_be32(MLX4_CQE_VLAN_PRESENT_MASK)) {
+						u16 vid = be16_to_cpu(cqe->sl_vid);
+
+						__vlan_hwaccel_put_tag(gro_skb, vid);
+					}
+
+					napi_gro_frags(&cq->napi);
 
 					goto next;
 				}
@@ -647,13 +650,12 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 		skb->protocol = eth_type_trans(skb, dev);
 		skb_record_rx_queue(skb, cq->ring);
 
+		if (be32_to_cpu(cqe->vlan_my_qpn) &
+		    MLX4_CQE_VLAN_PRESENT_MASK)
+			__vlan_hwaccel_put_tag(skb, be16_to_cpu(cqe->sl_vid));
+
 		/* Push it up the stack */
-		if (priv->vlgrp && (be32_to_cpu(cqe->vlan_my_qpn) &
-				    MLX4_CQE_VLAN_PRESENT_MASK)) {
-			vlan_hwaccel_receive_skb(skb, priv->vlgrp,
-						be16_to_cpu(cqe->sl_vid));
-		} else
-			netif_receive_skb(skb);
+		netif_receive_skb(skb);
 
 next:
 		++cq->mcq.cons_index;
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index 0b5150d..ed84811 100644
--- a/drivers/net/mlx4/mlx4_en.h
+++ b/drivers/net/mlx4/mlx4_en.h
@@ -34,10 +34,12 @@
 #ifndef _MLX4_EN_H_
 #define _MLX4_EN_H_
 
+#include <linux/bitops.h>
 #include <linux/compiler.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
 #include <linux/netdevice.h>
+#include <linux/if_vlan.h>
 
 #include <linux/mlx4/device.h>
 #include <linux/mlx4/qp.h>
@@ -418,7 +420,7 @@ struct mlx4_en_priv {
 	struct mlx4_en_dev *mdev;
 	struct mlx4_en_port_profile *prof;
 	struct net_device *dev;
-	struct vlan_group *vlgrp;
+	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
 	struct net_device_stats stats;
 	struct net_device_stats ret_stats;
 	struct mlx4_en_port_state port_state;
@@ -553,7 +555,7 @@ int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring);
 void mlx4_en_rx_irq(struct mlx4_cq *mcq);
 
 int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode);
-int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, struct vlan_group *grp);
+int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv);
 int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
 			  u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
 int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
-- 
1.7.6


^ permalink raw reply related

* [patch net-next-2.6 17/21] spider_net: do not mention dying vlan_hwaccel_receive_skb
From: Jiri Pirko @ 2011-07-15 21:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, shemminger, eric.dumazet, greearb, mirqus, kou.ishizaki,
	jens
In-Reply-To: <1310765619-27827-1-git-send-email-jpirko@redhat.com>

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/spider_net.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 9bc6c20..1ff3491c 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -1004,9 +1004,7 @@ spider_net_pass_skb_up(struct spider_net_descr *descr,
 	}
 
 	if (data_status & SPIDER_NET_VLAN_PACKET) {
-		/* further enhancements: HW-accel VLAN
-		 * vlan_hwaccel_receive_skb
-		 */
+		/* further enhancements: HW-accel VLAN */
 	}
 
 	/* update netdevice statistics */
-- 
1.7.6


^ permalink raw reply related

* [patch net-next-2.6 05/21] atl1c: do vlan cleanup
From: Jiri Pirko @ 2011-07-15 21:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, shemminger, eric.dumazet, greearb, mirqus
In-Reply-To: <1310765619-27827-1-git-send-email-jpirko@redhat.com>

- unify vlan and nonvlan rx path
- kill adapter->vlgrp and atl1c_vlan_rx_register
- enable vlan hw accel always

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/atl1c/atl1c.h      |    1 -
 drivers/net/atl1c/atl1c_main.c |   51 ++++-----------------------------------
 2 files changed, 6 insertions(+), 46 deletions(-)

diff --git a/drivers/net/atl1c/atl1c.h b/drivers/net/atl1c/atl1c.h
index 0f481b9..ca70e16 100644
--- a/drivers/net/atl1c/atl1c.h
+++ b/drivers/net/atl1c/atl1c.h
@@ -555,7 +555,6 @@ struct atl1c_smb {
 struct atl1c_adapter {
 	struct net_device   *netdev;
 	struct pci_dev      *pdev;
-	struct vlan_group   *vlgrp;
 	struct napi_struct  napi;
 	struct atl1c_hw        hw;
 	struct atl1c_hw_stats  hw_stats;
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index 1269ba5..2abef19 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -411,41 +411,6 @@ static void atl1c_set_multi(struct net_device *netdev)
 	}
 }
 
-static void atl1c_vlan_rx_register(struct net_device *netdev,
-				   struct vlan_group *grp)
-{
-	struct atl1c_adapter *adapter = netdev_priv(netdev);
-	struct pci_dev *pdev = adapter->pdev;
-	u32 mac_ctrl_data = 0;
-
-	if (netif_msg_pktdata(adapter))
-		dev_dbg(&pdev->dev, "atl1c_vlan_rx_register\n");
-
-	atl1c_irq_disable(adapter);
-
-	adapter->vlgrp = grp;
-	AT_READ_REG(&adapter->hw, REG_MAC_CTRL, &mac_ctrl_data);
-
-	if (grp) {
-		/* enable VLAN tag insert/strip */
-		mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
-	} else {
-		/* disable VLAN tag insert/strip */
-		mac_ctrl_data &= ~MAC_CTRL_RMV_VLAN;
-	}
-
-	AT_WRITE_REG(&adapter->hw, REG_MAC_CTRL, mac_ctrl_data);
-	atl1c_irq_enable(adapter);
-}
-
-static void atl1c_restore_vlan(struct atl1c_adapter *adapter)
-{
-	struct pci_dev *pdev = adapter->pdev;
-
-	if (netif_msg_pktdata(adapter))
-		dev_dbg(&pdev->dev, "atl1c_restore_vlan !");
-	atl1c_vlan_rx_register(adapter->netdev, adapter->vlgrp);
-}
 /*
  * atl1c_set_mac - Change the Ethernet Address of the NIC
  * @netdev: network interface device structure
@@ -1433,8 +1398,7 @@ static void atl1c_setup_mac_ctrl(struct atl1c_adapter *adapter)
 	mac_ctrl_data |= ((hw->preamble_len & MAC_CTRL_PRMLEN_MASK) <<
 			MAC_CTRL_PRMLEN_SHIFT);
 
-	if (adapter->vlgrp)
-		mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
+	mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
 
 	mac_ctrl_data |= MAC_CTRL_BC_EN;
 	if (netdev->flags & IFF_PROMISC)
@@ -1878,14 +1842,14 @@ rrs_checked:
 		skb_put(skb, length - ETH_FCS_LEN);
 		skb->protocol = eth_type_trans(skb, netdev);
 		atl1c_rx_checksum(adapter, skb, rrs);
-		if (unlikely(adapter->vlgrp) && rrs->word3 & RRS_VLAN_INS) {
+		if (rrs->word3 & RRS_VLAN_INS) {
 			u16 vlan;
 
 			AT_TAG_TO_VLAN(rrs->vlan_tag, vlan);
 			vlan = le16_to_cpu(vlan);
-			vlan_hwaccel_receive_skb(skb, adapter->vlgrp, vlan);
-		} else
-			netif_receive_skb(skb);
+			__vlan_hwaccel_put_tag(skb, vlan);
+		}
+		netif_receive_skb(skb);
 
 		(*work_done)++;
 		count++;
@@ -2320,7 +2284,6 @@ static int atl1c_up(struct atl1c_adapter *adapter)
 	netif_carrier_off(netdev);
 	atl1c_init_ring_ptrs(adapter);
 	atl1c_set_multi(netdev);
-	atl1c_restore_vlan(adapter);
 
 	for (i = 0; i < adapter->num_rx_queues; i++) {
 		num = atl1c_alloc_rx_buffer(adapter, i);
@@ -2507,8 +2470,7 @@ static int atl1c_suspend(struct device *dev)
 		/* clear phy interrupt */
 		atl1c_read_phy_reg(hw, MII_ISR, &mii_intr_status_data);
 		/* Config MAC Ctrl register */
-		if (adapter->vlgrp)
-			mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
+		mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
 
 		/* magic packet maybe Broadcast&multicast&Unicast frame */
 		if (wufc & AT_WUFC_MAG)
@@ -2588,7 +2550,6 @@ static const struct net_device_ops atl1c_netdev_ops = {
 	.ndo_do_ioctl		= atl1c_ioctl,
 	.ndo_tx_timeout		= atl1c_tx_timeout,
 	.ndo_get_stats		= atl1c_get_stats,
-	.ndo_vlan_rx_register	= atl1c_vlan_rx_register,
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller	= atl1c_netpoll,
 #endif
-- 
1.7.6


^ permalink raw reply related

* [patch net-next-2.6 02/21] ehea: unify vlan and nonvlan rx path
From: Jiri Pirko @ 2011-07-15 21:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, shemminger, eric.dumazet, greearb, mirqus, leitao
In-Reply-To: <1310765619-27827-1-git-send-email-jpirko@redhat.com>

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/ehea/ehea_main.c |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 3fd5a24..8dffb80 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -686,21 +686,13 @@ static void ehea_proc_skb(struct ehea_port_res *pr, struct ehea_cqe *cqe,
 	int vlan_extracted = ((cqe->status & EHEA_CQE_VLAN_TAG_XTRACT) &&
 			      pr->port->vgrp);
 
-	if (skb->dev->features & NETIF_F_LRO) {
-		if (vlan_extracted)
-			lro_vlan_hwaccel_receive_skb(&pr->lro_mgr, skb,
-						     pr->port->vgrp,
-						     cqe->vlan_tag,
-						     cqe);
-		else
-			lro_receive_skb(&pr->lro_mgr, skb, cqe);
-	} else {
-		if (vlan_extracted)
-			vlan_hwaccel_receive_skb(skb, pr->port->vgrp,
-						 cqe->vlan_tag);
-		else
-			netif_receive_skb(skb);
-	}
+	if (vlan_extracted)
+		__vlan_hwaccel_put_tag(skb, cqe->vlan_tag);
+
+	if (skb->dev->features & NETIF_F_LRO)
+		lro_receive_skb(&pr->lro_mgr, skb, cqe);
+	else
+		netif_receive_skb(skb);
 }
 
 static int ehea_proc_rwqes(struct net_device *dev,
-- 
1.7.6


^ permalink raw reply related

* [patch net-next-2.6 21/21] vlan: kill vlan_hwaccel_receive_skb
From: Jiri Pirko @ 2011-07-15 21:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, shemminger, eric.dumazet, greearb, mirqus
In-Reply-To: <1310765619-27827-1-git-send-email-jpirko@redhat.com>

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 include/linux/if_vlan.h |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index affa273..472f3df 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -212,19 +212,6 @@ static inline int vlan_hwaccel_rx(struct sk_buff *skb,
 }
 
 /**
- * vlan_hwaccel_receive_skb - netif_receive_skb wrapper for VLAN RX acceleration
- * @skb: buffer
- * @grp: vlan group
- * @vlan_tci: VLAN TCI as received from the card
- */
-static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
-					   struct vlan_group *grp,
-					   u16 vlan_tci)
-{
-	return __vlan_hwaccel_rx(skb, grp, vlan_tci, 1);
-}
-
-/**
  * vlan_insert_tag - regular VLAN tag inserting
  * @skb: skbuff to tag
  * @vlan_tci: VLAN TCI to insert
-- 
1.7.6


^ permalink raw reply related

* [patch net-next-2.6 18/21] tehuti: do vlan cleanup
From: Jiri Pirko @ 2011-07-15 21:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, shemminger, eric.dumazet, greearb, mirqus, baum
In-Reply-To: <1310765619-27827-1-git-send-email-jpirko@redhat.com>

- unify vlan and nonvlan rx path
- kill priv->vlgrp and bdx_vlan_rx_register

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/tehuti.c |   37 +++++++------------------------------
 drivers/net/tehuti.h |    1 -
 2 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c
index 80fbee0..749bbf1 100644
--- a/drivers/net/tehuti.c
+++ b/drivers/net/tehuti.c
@@ -742,22 +742,6 @@ static void bdx_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid)
 	__bdx_vlan_rx_vid(ndev, vid, 0);
 }
 
-/*
- * bdx_vlan_rx_register - kernel hook for adding VLAN group
- * @ndev network device
- * @grp  VLAN group
- */
-static void
-bdx_vlan_rx_register(struct net_device *ndev, struct vlan_group *grp)
-{
-	struct bdx_priv *priv = netdev_priv(ndev);
-
-	ENTER;
-	DBG("device='%s', group='%p'\n", ndev->name, grp);
-	priv->vlgrp = grp;
-	RET();
-}
-
 /**
  * bdx_change_mtu - Change the Maximum Transfer Unit
  * @netdev: network interface device structure
@@ -1146,21 +1130,15 @@ NETIF_RX_MUX(struct bdx_priv *priv, u32 rxd_val1, u16 rxd_vlan,
 	     struct sk_buff *skb)
 {
 	ENTER;
-	DBG("rxdd->flags.bits.vtag=%d vlgrp=%p\n", GET_RXD_VTAG(rxd_val1),
-	    priv->vlgrp);
-	if (priv->vlgrp && GET_RXD_VTAG(rxd_val1)) {
-		DBG("%s: vlan rcv vlan '%x' vtag '%x', device name '%s'\n",
+	DBG("rxdd->flags.bits.vtag=%d\n", GET_RXD_VTAG(rxd_val1));
+	if (GET_RXD_VTAG(rxd_val1)) {
+		DBG("%s: vlan rcv vlan '%x' vtag '%x'\n",
 		    priv->ndev->name,
 		    GET_RXD_VLAN_ID(rxd_vlan),
-		    GET_RXD_VTAG(rxd_val1),
-		    vlan_group_get_device(priv->vlgrp,
-					  GET_RXD_VLAN_ID(rxd_vlan))->name);
-		/* NAPI variant of receive functions */
-		vlan_hwaccel_receive_skb(skb, priv->vlgrp,
-					 GET_RXD_VLAN_TCI(rxd_vlan));
-	} else {
-		netif_receive_skb(skb);
+		    GET_RXD_VTAG(rxd_val1));
+		__vlan_hwaccel_put_tag(skb, GET_RXD_VLAN_TCI(rxd_vlan));
 	}
+	netif_receive_skb(skb);
 }
 
 static void bdx_recycle_skb(struct bdx_priv *priv, struct rxd_desc *rxdd)
@@ -1877,7 +1855,7 @@ static void bdx_tx_push_desc_safe(struct bdx_priv *priv, void *data, int size)
 }
 
 static const struct net_device_ops bdx_netdev_ops = {
-	.ndo_open	 	= bdx_open,
+	.ndo_open		= bdx_open,
 	.ndo_stop		= bdx_close,
 	.ndo_start_xmit		= bdx_tx_transmit,
 	.ndo_validate_addr	= eth_validate_addr,
@@ -1885,7 +1863,6 @@ static const struct net_device_ops bdx_netdev_ops = {
 	.ndo_set_multicast_list = bdx_setmulti,
 	.ndo_change_mtu		= bdx_change_mtu,
 	.ndo_set_mac_address	= bdx_set_mac,
-	.ndo_vlan_rx_register	= bdx_vlan_rx_register,
 	.ndo_vlan_rx_add_vid	= bdx_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= bdx_vlan_rx_kill_vid,
 };
diff --git a/drivers/net/tehuti.h b/drivers/net/tehuti.h
index c5642fe..709ebd6 100644
--- a/drivers/net/tehuti.h
+++ b/drivers/net/tehuti.h
@@ -250,7 +250,6 @@ struct bdx_priv {
 	struct rxf_fifo rxf_fifo0;
 	struct rxdb *rxdb;	/* rx dbs to store skb pointers */
 	int napi_stop;
-	struct vlan_group *vlgrp;
 
 	/* Tx FIFOs: 1 for data desc, 1 for empty (acks) desc */
 	struct txd_fifo txd_fifo0;
-- 
1.7.6


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox