Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Joe Perches @ 2011-01-26 21:33 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, john.r.fastabend
In-Reply-To: <1296077287.2631.9.camel@edumazet-laptop>

On Wed, 2011-01-26 at 22:28 +0100, Eric Dumazet wrote:
> Le mercredi 26 janvier 2011 à 13:24 -0800, Joe Perches a écrit :
> > Ugly maybe, but correct, definitely.
> > The same can not be said of the {0}.
> What about fixing real problems Joe ?

What about it?  You seem to have fixed it.

> Are you telling me I dont know C ?

All I'm saying is that from a style and auditing
perspective, it's better to use memset for all
structs that are exposed to user space.

Other than that, there's no issue here.

cheers, Joe



^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Eric Dumazet @ 2011-01-26 21:28 UTC (permalink / raw)
  To: Joe Perches; +Cc: David Miller, netdev, john.r.fastabend
In-Reply-To: <1296077098.2448.5.camel@Joe-Laptop>

Le mercredi 26 janvier 2011 à 13:24 -0800, Joe Perches a écrit :

> Ugly maybe, but correct, definitely.
> The same can not be said of the {0}.

What about fixing real problems Joe ?

Are you telling me I dont know C ?




^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Joe Perches @ 2011-01-26 21:24 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, john.r.fastabend
In-Reply-To: <1296073390.2631.4.camel@edumazet-laptop>

On Wed, 2011-01-26 at 21:23 +0100, Eric Dumazet wrote:
> Le mercredi 26 janvier 2011 à 11:55 -0800, David Miller a écrit :
> > From: Joe Perches <joe@perches.com>
> > > I think the best style to use memset so that any
> > > possible struct padding is guaranteed to be zeroed.
> > Such padding does not exist, and we won't add such padding since this is
> > a user visible data structure and thus whose layout is cast in stone.
> > Anyways, I'm ambivalent to how this is fixed actually.
> I am perfectly aware of this ugly memset() style some people prefer, and
> 5 % of the time they swap 2nd and 3rd param.

Ugly maybe, but correct, definitely.
The same can not be said of the {0}.

This use ends up the same so it doesn't
matter here, it's just a style question.

> Two patches instead of one ;)

How uninteresting.  Any API can be misused.

> In this particular case, I only used existing codestyle: In the same
> file I noticed :

There are memset's in the file as well.
In fact, memset is used in the same function.

cheers, Joe


^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: David Miller @ 2011-01-26 21:15 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, john.r.fastabend
In-Reply-To: <1296062517.2899.86.camel@edumazet-laptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 26 Jan 2011 18:21:57 +0100

> mqprio_dump() should make sure all fields of struct tc_mqprio_qopt are
> initialized.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> CC: John Fastabend <john.r.fastabend@intel.com>

Applied, thanks Eric.

^ permalink raw reply

* Re: [PATCH net-2.6] tg3: Use new VLAN code
From: David Miller @ 2011-01-26 21:13 UTC (permalink / raw)
  To: mcarlson; +Cc: netdev
In-Reply-To: <1296074396-25158-1-git-send-email-mcarlson@broadcom.com>

From: "Matt Carlson" <mcarlson@broadcom.com>
Date: Wed, 26 Jan 2011 12:39:56 -0800

> This patch pivots the tg3 driver to the new VLAN infrastructure.
> All references to vlgrp have been removed.  The driver still attempts to
> disable VLAN tag stripping if CONFIG_VLAN_8021Q or
> CONFIG_VLAN_8021Q_MODULE is not defined.
> 
> Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
> Reviewed-by: Michael Chan <mchan@broadcom.com>

Applied, thanks for doing this backport.

^ permalink raw reply

* [PATCH net-2.6] tg3: Use new VLAN code
From: Matt Carlson @ 2011-01-26 20:39 UTC (permalink / raw)
  To: davem; +Cc: netdev, mcarlson

This patch pivots the tg3 driver to the new VLAN infrastructure.
All references to vlgrp have been removed.  The driver still attempts to
disable VLAN tag stripping if CONFIG_VLAN_8021Q or
CONFIG_VLAN_8021Q_MODULE is not defined.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/tg3.c |   95 +++++-----------------------------------------------
 drivers/net/tg3.h |    3 --
 2 files changed, 10 insertions(+), 88 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 7841a8f..93b32d3 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -60,12 +60,6 @@
 #define BAR_0	0
 #define BAR_2	2
 
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
-#define TG3_VLAN_TAG_USED 1
-#else
-#define TG3_VLAN_TAG_USED 0
-#endif
-
 #include "tg3.h"
 
 #define DRV_MODULE_NAME		"tg3"
@@ -134,9 +128,6 @@
 				 TG3_TX_RING_SIZE)
 #define NEXT_TX(N)		(((N) + 1) & (TG3_TX_RING_SIZE - 1))
 
-#define TG3_RX_DMA_ALIGN		16
-#define TG3_RX_HEADROOM			ALIGN(VLAN_HLEN, TG3_RX_DMA_ALIGN)
-
 #define TG3_DMA_BYTE_ENAB		64
 
 #define TG3_RX_STD_DMA_SZ		1536
@@ -4722,8 +4713,6 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 		struct sk_buff *skb;
 		dma_addr_t dma_addr;
 		u32 opaque_key, desc_idx, *post_ptr;
-		bool hw_vlan __maybe_unused = false;
-		u16 vtag __maybe_unused = 0;
 
 		desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK;
 		opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK;
@@ -4782,12 +4771,12 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 			tg3_recycle_rx(tnapi, tpr, opaque_key,
 				       desc_idx, *post_ptr);
 
-			copy_skb = netdev_alloc_skb(tp->dev, len + VLAN_HLEN +
+			copy_skb = netdev_alloc_skb(tp->dev, len +
 						    TG3_RAW_IP_ALIGN);
 			if (copy_skb == NULL)
 				goto drop_it_no_recycle;
 
-			skb_reserve(copy_skb, TG3_RAW_IP_ALIGN + VLAN_HLEN);
+			skb_reserve(copy_skb, TG3_RAW_IP_ALIGN);
 			skb_put(copy_skb, len);
 			pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE);
 			skb_copy_from_linear_data(skb, copy_skb->data, len);
@@ -4814,30 +4803,11 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 		}
 
 		if (desc->type_flags & RXD_FLAG_VLAN &&
-		    !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG)) {
-			vtag = desc->err_vlan & RXD_VLAN_MASK;
-#if TG3_VLAN_TAG_USED
-			if (tp->vlgrp)
-				hw_vlan = true;
-			else
-#endif
-			{
-				struct vlan_ethhdr *ve = (struct vlan_ethhdr *)
-						    __skb_push(skb, VLAN_HLEN);
-
-				memmove(ve, skb->data + VLAN_HLEN,
-					ETH_ALEN * 2);
-				ve->h_vlan_proto = htons(ETH_P_8021Q);
-				ve->h_vlan_TCI = htons(vtag);
-			}
-		}
+		    !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG))
+			__vlan_hwaccel_put_tag(skb,
+					       desc->err_vlan & RXD_VLAN_MASK);
 
-#if TG3_VLAN_TAG_USED
-		if (hw_vlan)
-			vlan_gro_receive(&tnapi->napi, tp->vlgrp, vtag, skb);
-		else
-#endif
-			napi_gro_receive(&tnapi->napi, skb);
+		napi_gro_receive(&tnapi->napi, skb);
 
 		received++;
 		budget--;
@@ -5740,11 +5710,9 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb,
 		base_flags |= TXD_FLAG_TCPUDP_CSUM;
 	}
 
-#if TG3_VLAN_TAG_USED
 	if (vlan_tx_tag_present(skb))
 		base_flags |= (TXD_FLAG_VLAN |
 			       (vlan_tx_tag_get(skb) << 16));
-#endif
 
 	len = skb_headlen(skb);
 
@@ -5986,11 +5954,10 @@ static netdev_tx_t tg3_start_xmit_dma_bug(struct sk_buff *skb,
 			}
 		}
 	}
-#if TG3_VLAN_TAG_USED
+
 	if (vlan_tx_tag_present(skb))
 		base_flags |= (TXD_FLAG_VLAN |
 			       (vlan_tx_tag_get(skb) << 16));
-#endif
 
 	if ((tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG) &&
 	    !mss && skb->len > VLAN_ETH_FRAME_LEN)
@@ -9532,17 +9499,10 @@ static void __tg3_set_rx_mode(struct net_device *dev)
 	rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC |
 				  RX_MODE_KEEP_VLAN_TAG);
 
+#if !defined(CONFIG_VLAN_8021Q) && !defined(CONFIG_VLAN_8021Q_MODULE)
 	/* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG
 	 * flag clear.
 	 */
-#if TG3_VLAN_TAG_USED
-	if (!tp->vlgrp &&
-	    !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF))
-		rx_mode |= RX_MODE_KEEP_VLAN_TAG;
-#else
-	/* By definition, VLAN is disabled always in this
-	 * case.
-	 */
 	if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF))
 		rx_mode |= RX_MODE_KEEP_VLAN_TAG;
 #endif
@@ -11230,31 +11190,6 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 	return -EOPNOTSUPP;
 }
 
-#if TG3_VLAN_TAG_USED
-static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
-{
-	struct tg3 *tp = netdev_priv(dev);
-
-	if (!netif_running(dev)) {
-		tp->vlgrp = grp;
-		return;
-	}
-
-	tg3_netif_stop(tp);
-
-	tg3_full_lock(tp, 0);
-
-	tp->vlgrp = grp;
-
-	/* Update RX_MODE_KEEP_VLAN_TAG bit in RX_MODE register. */
-	__tg3_set_rx_mode(dev);
-
-	tg3_netif_start(tp);
-
-	tg3_full_unlock(tp);
-}
-#endif
-
 static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
 {
 	struct tg3 *tp = netdev_priv(dev);
@@ -13066,9 +13001,7 @@ static struct pci_dev * __devinit tg3_find_peer(struct tg3 *);
 
 static void inline vlan_features_add(struct net_device *dev, unsigned long flags)
 {
-#if TG3_VLAN_TAG_USED
 	dev->vlan_features |= flags;
-#endif
 }
 
 static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp)
@@ -13861,11 +13794,11 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
 	else
 		tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES;
 
-	tp->rx_offset = NET_IP_ALIGN + TG3_RX_HEADROOM;
+	tp->rx_offset = NET_IP_ALIGN;
 	tp->rx_copy_thresh = TG3_RX_COPY_THRESHOLD;
 	if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
 	    (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
-		tp->rx_offset -= NET_IP_ALIGN;
+		tp->rx_offset = 0;
 #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
 		tp->rx_copy_thresh = ~(u16)0;
 #endif
@@ -14629,9 +14562,6 @@ static const struct net_device_ops tg3_netdev_ops = {
 	.ndo_do_ioctl		= tg3_ioctl,
 	.ndo_tx_timeout		= tg3_tx_timeout,
 	.ndo_change_mtu		= tg3_change_mtu,
-#if TG3_VLAN_TAG_USED
-	.ndo_vlan_rx_register	= tg3_vlan_rx_register,
-#endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller	= tg3_poll_controller,
 #endif
@@ -14648,9 +14578,6 @@ static const struct net_device_ops tg3_netdev_ops_dma_bug = {
 	.ndo_do_ioctl		= tg3_ioctl,
 	.ndo_tx_timeout		= tg3_tx_timeout,
 	.ndo_change_mtu		= tg3_change_mtu,
-#if TG3_VLAN_TAG_USED
-	.ndo_vlan_rx_register	= tg3_vlan_rx_register,
-#endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller	= tg3_poll_controller,
 #endif
@@ -14700,9 +14627,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
 
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
-#if TG3_VLAN_TAG_USED
 	dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
-#endif
 
 	tp = netdev_priv(dev);
 	tp->pdev = pdev;
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index d62c8d9..f528243 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2808,9 +2808,6 @@ struct tg3 {
 	u32				rx_std_max_post;
 	u32				rx_offset;
 	u32				rx_pkt_map_sz;
-#if TG3_VLAN_TAG_USED
-	struct vlan_group		*vlgrp;
-#endif
 
 
 	/* begin "everything else" cacheline(s) section */
-- 
1.7.2.2



^ permalink raw reply related

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Eric Dumazet @ 2011-01-26 20:25 UTC (permalink / raw)
  To: David Miller; +Cc: joe, netdev, john.r.fastabend
In-Reply-To: <1296073390.2631.4.camel@edumazet-laptop>

Le mercredi 26 janvier 2011 à 21:23 +0100, Eric Dumazet a écrit :

> I am perfectly aware of this ugly memset() style some people prefer, and
> 5 % of the time they swap 2nd and 3rd param.
> 
> Two patches instead of one ;)
> 

One random example of memset() troubles : 

commit fe10ae53384e48c51996941b7720ee16995cbcb7
fixed by commit 5b919f833d9d60588d026ad82d17f17e8872c7a9




^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Eric Dumazet @ 2011-01-26 20:23 UTC (permalink / raw)
  To: David Miller; +Cc: joe, netdev, john.r.fastabend
In-Reply-To: <20110126.115530.226756606.davem@davemloft.net>

Le mercredi 26 janvier 2011 à 11:55 -0800, David Miller a écrit :
> From: Joe Perches <joe@perches.com>
> > 
> > I think the best style to use memset so that any
> > possible struct padding is guaranteed to be zeroed.
> 
> Such padding does not exist, and we won't add such padding since this is
> a user visible data structure and thus whose layout is cast in stone.
> 
> Anyways, I'm ambivalent to how this is fixed actually.

I am perfectly aware of this ugly memset() style some people prefer, and
5 % of the time they swap 2nd and 3rd param.

Two patches instead of one ;)

In this particular case, I only used existing codestyle: In the same
file I noticed :

vi +322 net/sched/sch_mqprio.c

static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
                               struct gnet_dump *d)
{
        struct net_device *dev = qdisc_dev(sch);

        if (cl <= netdev_get_num_tc(dev)) {
                int i;
                struct Qdisc *qdisc;
                struct gnet_stats_queue qstats = {0};
                struct gnet_stats_basic_packed bstats = {0};
                struct netdev_tc_txq tc = dev->tc_to_txq[cl - 1];





^ permalink raw reply

* Re: [patch] kconfig: unify GENERIC_ISA_DMA and ISA_DMA_API
From: Russell King - ARM Linux @ 2011-01-26 20:10 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Ralf Baechle, Kyle McMartin, James Bottomley,
	Benjamin Herrenschmidt, Thomas Gleixner, H. Peter Anvin,
	Ingo Molnar, David S. Miller, Greg Kroah-Hartman, Randy Dunlap,
	x86, linux-arch, netdev, linux-scsi, linux-kernel
In-Reply-To: <alpine.DEB.2.00.1101261158490.13163@chino.kir.corp.google.com>

On Wed, Jan 26, 2011 at 12:00:08PM -0800, David Rientjes wrote:
> On Wed, 26 Jan 2011, Russell King - ARM Linux wrote:
> 
> > On Tue, Jan 25, 2011 at 05:06:28PM -0800, David Rientjes wrote:
> > > CONFIG_GENERIC_ISA_DMA and CONFIG_ISA_DMA_API usually have dependencies
> > > on one another depending on the architecture and generic kernel code uses
> > > either to determine whether an ISA-style DMA API is configured.
> > 
> > Wrong.
> > 
> > GENERIC_ISA_DMA enables support for the standard ISA DMA allocator found
> > in kernel/dma.c
> > 
> > ISA_DMA_API says that a platform supports the ISA DMA interfaces.
> > 
> > An architecture can provide the ISA DMA interfaces, but not use the
> > standard ISA DMA allocator found in kernel/dma.c.  Such as the one in
> > arch/arm/kernel/dma.c.
> > 
> > So on ARM, we have platforms where ISA_DMA_API=y but GENERIC_ISA_DMA=n.
> > 
> 
> Ok, fair enough.  Thanks for pointing that out.  I'll work to resolve the 
> existing dependency chain on x86 that cause build failures when one is 
> disabled and another is not and add Kconfig dependencies on drivers that 
> require GENERIC_ISA_DMA.

Drivers should depend on ISA_DMA_API as that indicates that the ISA DMA
API is present - in other words, when the following are available from
an architecture/platform:

dma_spin_lock
claim_dma_lock
release_dma_lock
enable_dma
disable_dma
clear_dma_ff
set_dma_mode
set_dma_page
set_dma_addr
set_dma_count
get_dma_residue
request_dma
free_dma

GENERIC_ISA_DMA should be set by an architecture/platform when ISA_DMA_API
has already been set -and- it wants to use kernel/dma.c.  No drivers should
depend on GENERIC_ISA_DMA.

^ permalink raw reply

* Re: [PATCH net-next 0/11] tg3: 5719, VLAN, and EEE bugfixes
From: Matt Carlson @ 2011-01-26 20:01 UTC (permalink / raw)
  To: David Miller
  Cc: eric.dumazet@gmail.com, Matthew Carlson, netdev@vger.kernel.org,
	andy@greyhouse.net
In-Reply-To: <20110125.222734.189693738.davem@davemloft.net>

On Tue, Jan 25, 2011 at 10:27:34PM -0800, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Wed, 26 Jan 2011 07:14:37 +0100
> 
> > I tested the vlan patch on my machine, and it solves the problem I had
> > with linux-2.6
> > 
> > I believe this particular patch should be net-2.6 material, not
> > net-next-2.6
> 
> Agreed.
> 
> > (There is a small rejected hunk)
> 
> Matt, if you would send me a net-2.6 backport with your blessing
> I'd appreciate it.

Sure.  Coming right up.


^ permalink raw reply

* Re: [patch] kconfig: unify GENERIC_ISA_DMA and ISA_DMA_API
From: David Rientjes @ 2011-01-26 20:00 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Andrew Morton, Ralf Baechle, Kyle McMartin, James Bottomley,
	Benjamin Herrenschmidt, Thomas Gleixner, H. Peter Anvin,
	Ingo Molnar, David S. Miller, Greg Kroah-Hartman, Randy Dunlap,
	x86, linux-arch, netdev, linux-scsi, linux-kernel
In-Reply-To: <20110126112908.GD2562@n2100.arm.linux.org.uk>

On Wed, 26 Jan 2011, Russell King - ARM Linux wrote:

> On Tue, Jan 25, 2011 at 05:06:28PM -0800, David Rientjes wrote:
> > CONFIG_GENERIC_ISA_DMA and CONFIG_ISA_DMA_API usually have dependencies
> > on one another depending on the architecture and generic kernel code uses
> > either to determine whether an ISA-style DMA API is configured.
> 
> Wrong.
> 
> GENERIC_ISA_DMA enables support for the standard ISA DMA allocator found
> in kernel/dma.c
> 
> ISA_DMA_API says that a platform supports the ISA DMA interfaces.
> 
> An architecture can provide the ISA DMA interfaces, but not use the
> standard ISA DMA allocator found in kernel/dma.c.  Such as the one in
> arch/arm/kernel/dma.c.
> 
> So on ARM, we have platforms where ISA_DMA_API=y but GENERIC_ISA_DMA=n.
> 

Ok, fair enough.  Thanks for pointing that out.  I'll work to resolve the 
existing dependency chain on x86 that cause build failures when one is 
disabled and another is not and add Kconfig dependencies on drivers that 
require GENERIC_ISA_DMA.

^ permalink raw reply

* Re: pull request: wireless-2.6 2011-01-26
From: David Miller @ 2011-01-26 19:56 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, netdev, linux-kernel
In-Reply-To: <20110126184745.GB3084@tuxdriver.com>

From: "John W. Linville" <linville@tuxdriver.com>
Date: Wed, 26 Jan 2011 13:47:46 -0500

> Dave,
> 
> Here is a collection of fixes intended for 2.6.38.  There is a
> MAINTAINERS fix for iwlwifi, a fix to avoid disabling .11n on iwl4965, a
> NULL pointer fix for rtlwifi, a powersaving wakeup fix for ath9k, and
> some others.
> 
> Also included is a batch of Bluetooth fixes via Gustavo.  These include
> a fix for an RFCOMM crash, a HCI blacklist leak fix, and a number of other
> simple fixes.
> 
> Please let me know if there are problems!

Pulled, thanks John.

^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: David Miller @ 2011-01-26 19:56 UTC (permalink / raw)
  To: joe; +Cc: eric.dumazet, netdev, john.r.fastabend
In-Reply-To: <1296064578.6115.39.camel@Joe-Laptop>

From: Joe Perches <joe@perches.com>
Date: Wed, 26 Jan 2011 09:56:18 -0800

> On Wed, 2011-01-26 at 18:49 +0100, Eric Dumazet wrote:
>> Le mercredi 26 janvier 2011 à 09:43 -0800, Joe Perches a écrit :
>> > I think the best style to use memset so that any
>> > possible struct padding is guaranteed to be zeroed.
>> We use the { 0 } style in net/sched,
> 
> That's nice, but it's the wrong style.
> https://lkml.org/lkml/2010/12/15/63
> 
>> and there is no padding in this
>> structure, I checked this point.
> 
> That may be true right now for this particular
> structure, but that style is not future-proof.

It is future-proof if the data-structure is user-visible and therefore
will never change, as is the case here.

^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: David Miller @ 2011-01-26 19:55 UTC (permalink / raw)
  To: joe; +Cc: eric.dumazet, netdev, john.r.fastabend
In-Reply-To: <1296063823.6115.37.camel@Joe-Laptop>

From: Joe Perches <joe@perches.com>
Date: Wed, 26 Jan 2011 09:43:43 -0800

> On Wed, 2011-01-26 at 18:21 +0100, Eric Dumazet wrote:
>> mqprio_dump() should make sure all fields of struct tc_mqprio_qopt are
>> initialized.
>> 
>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
>> CC: John Fastabend <john.r.fastabend@intel.com>
>> ---
>>  net/sched/sch_mqprio.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
>> index fbc6f53..effd4ee 100644
>> --- a/net/sched/sch_mqprio.c
>> +++ b/net/sched/sch_mqprio.c
>> @@ -215,7 +215,7 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
>>  	struct net_device *dev = qdisc_dev(sch);
>>  	struct mqprio_sched *priv = qdisc_priv(sch);
>>  	unsigned char *b = skb_tail_pointer(skb);
>> -	struct tc_mqprio_qopt opt;
>> +	struct tc_mqprio_qopt opt = { 0 };
> 
> I think the best style to use memset so that any
> possible struct padding is guaranteed to be zeroed.

Such padding does not exist, and we won't add such padding since this is
a user visible data structure and thus whose layout is cast in stone.

Anyways, I'm ambivalent to how this is fixed actually.

^ permalink raw reply

* biosdevname v0.3.6
From: Matt Domsch @ 2011-01-26 19:18 UTC (permalink / raw)
  To: linux-hotplug, netdev, K, Narendra, Hargrave, Jordan,
	Rose, Charles, Co

biosdevname, now version 0.3.6.

(0.3.5 was a dud due to a change in gcc/libtool that broke building
 the static copy.  https://bugzilla.redhat.com/show_bug.cgi?id=672689)

this fixes the udev rules, such that biosdevname is not invoked if an
earlier rule (such as 70-persistent-net.rules) sets a name.  this has
been the intended behavior, but was missed until now.  
furthermore, /usr/sbin/dump_pirq was added as a debugging aid, the
static copy biosdevnames is no longer built (it was originally
intended for use inside fairly limited initrd environments, but was
never really used there, and with dracut is now unnecessary),
and it checks if you're running as root, as it needs root to read
SMBIOS and PCI IRQ Routing Table information.

Grab it here:
http://linux.dell.com/files/biosdevname/permalink/biosdevname-0.3.6.tar.gz
http://linux.dell.com/files/biosdevname/permalink/biosdevname-0.3.6.tar.gz.sign
git://linux.dell.com/biosdevname.git

I built this yesterday for Fedora rawhide (will be 15), and I encourage
other distributions to pick it up as well.

There is a Fedora Test Day tomorrow (Thursday)
  https://fedoraproject.org/wiki/Test_Day:2011-01-27_Network_Device_Naming_With_Biosdevname
and I encourage you to give this a try and report success/failures as
noted here.

There has also been a good bit of blog coverage over the last few
days, with thanks to Joe Brockmeier.  
  http://www.networkworld.com/community/fedora-15-changes-network-device-naming



shortlog:

Matt Domsch (13):
      add check for running as root, exit if not
      add exit code 3 to manpage
      udev rules: skip if NAME is already set
      build dump_pirq, minimizing library linking
      install dump_pirq into /usr/sbin/
      install dump_pirq in debs too
      update changelogs, bump version
      move udev rules file into /lib/udev/rules.d
      update changelog
      add TODO
      automatically determine which dir the rules file goes
      drop biosdevnameS, it's unused and fails to build on F15
      bump version


Thanks,
Matt

-- 
Matt Domsch
Technology Strategist
Dell | Office of the CTO

^ permalink raw reply

* pull request: wireless-2.6 2011-01-26
From: John W. Linville @ 2011-01-26 18:47 UTC (permalink / raw)
  To: davem; +Cc: linux-wireless, netdev, linux-kernel

Dave,

Here is a collection of fixes intended for 2.6.38.  There is a
MAINTAINERS fix for iwlwifi, a fix to avoid disabling .11n on iwl4965, a
NULL pointer fix for rtlwifi, a powersaving wakeup fix for ath9k, and
some others.

Also included is a batch of Bluetooth fixes via Gustavo.  These include
a fix for an RFCOMM crash, a HCI blacklist leak fix, and a number of other
simple fixes.

Please let me know if there are problems!

Thanks,

John

---

The following changes since commit 3dce38a02d6370dca690cd923619d4b00024b723:

  dcbnl: make get_app handling symmetric for IEEE and CEE DCBx (2011-01-24 15:19:55 -0800)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git master

Alexander Holler (1):
      Bluetooth: ath3k: reduce memory usage

David Sterba (1):
      Bluetooth: l2cap: fix misuse of logical operation in place of bitop

Felix Fietkau (2):
      ath9k: add missing ps wakeup/restore calls
      mac80211: fix a crash in ieee80211_beacon_get_tim on change_interface

Greg Kroah-Hartman (1):
      rt2x00: add device id for windy31 usb device

Jesper Juhl (1):
      rtlwifi: Fix possible NULL dereference

Johan Hedberg (6):
      Bluetooth: Fix leaking blacklist when unregistering a hci device
      Revert "Bluetooth: Update sec_level/auth_type for already existing connections"
      Bluetooth: Fix MITM protection requirement preservation
      Bluetooth: Create a unified auth_type evaluation function
      Bluetooth: Fix authentication request for L2CAP raw sockets
      Bluetooth: Fix race condition with conn->sec_level

Luis R. Rodriguez (1):
      ath9k_hw: disabled PAPRD for AR9003

Lukáš Turek (1):
      Bluetooth: Never deallocate a session when some DLC points to it

Reinette Chatre (1):
      MAINTAINERS: remove Reinette Chatre as iwlwifi maintainer

Wey-Yi Guy (1):
      iwlwifi: don't read sku information from EEPROM for 4965

 MAINTAINERS                                   |    1 -
 drivers/bluetooth/ath3k.c                     |   75 ++++++----------------
 drivers/net/wireless/ath/ath9k/hw.c           |    6 ++-
 drivers/net/wireless/ath/ath9k/hw.h           |    1 +
 drivers/net/wireless/ath/ath9k/main.c         |    8 ++-
 drivers/net/wireless/ath/ath9k/xmit.c         |    2 -
 drivers/net/wireless/iwlwifi/iwl-4965.c       |    1 +
 drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c |   11 ++-
 drivers/net/wireless/rt2x00/rt73usb.c         |    1 +
 drivers/net/wireless/rtlwifi/pci.c            |   11 +++-
 include/net/bluetooth/hci_core.h              |    1 +
 net/bluetooth/hci_conn.c                      |   16 +++--
 net/bluetooth/hci_core.c                      |    4 +
 net/bluetooth/hci_event.c                     |    9 ++-
 net/bluetooth/l2cap.c                         |   84 +++++++++---------------
 net/bluetooth/rfcomm/core.c                   |    3 +-
 net/mac80211/tx.c                             |    3 +
 17 files changed, 105 insertions(+), 132 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 23d0436..c9ec9d8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3209,7 +3209,6 @@ F:	drivers/net/wimax/i2400m/
 F:	include/linux/wimax/i2400m.h
 
 INTEL WIRELESS WIFI LINK (iwlwifi)
-M:	Reinette Chatre <reinette.chatre@intel.com>
 M:	Wey-Yi Guy <wey-yi.w.guy@intel.com>
 M:	Intel Linux Wireless <ilw@linux.intel.com>
 L:	linux-wireless@vger.kernel.org
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 949ed09..a126e61 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -47,46 +47,40 @@ MODULE_DEVICE_TABLE(usb, ath3k_table);
 #define USB_REQ_DFU_DNLOAD	1
 #define BULK_SIZE		4096
 
-struct ath3k_data {
-	struct usb_device *udev;
-	u8 *fw_data;
-	u32 fw_size;
-	u32 fw_sent;
-};
-
-static int ath3k_load_firmware(struct ath3k_data *data,
-				unsigned char *firmware,
-				int count)
+static int ath3k_load_firmware(struct usb_device *udev,
+				const struct firmware *firmware)
 {
 	u8 *send_buf;
 	int err, pipe, len, size, sent = 0;
+	int count = firmware->size;
 
-	BT_DBG("ath3k %p udev %p", data, data->udev);
+	BT_DBG("udev %p", udev);
 
-	pipe = usb_sndctrlpipe(data->udev, 0);
+	pipe = usb_sndctrlpipe(udev, 0);
 
-	if ((usb_control_msg(data->udev, pipe,
+	send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC);
+	if (!send_buf) {
+		BT_ERR("Can't allocate memory chunk for firmware");
+		return -ENOMEM;
+	}
+
+	memcpy(send_buf, firmware->data, 20);
+	if ((err = usb_control_msg(udev, pipe,
 				USB_REQ_DFU_DNLOAD,
 				USB_TYPE_VENDOR, 0, 0,
-				firmware, 20, USB_CTRL_SET_TIMEOUT)) < 0) {
+				send_buf, 20, USB_CTRL_SET_TIMEOUT)) < 0) {
 		BT_ERR("Can't change to loading configuration err");
-		return -EBUSY;
+		goto error;
 	}
 	sent += 20;
 	count -= 20;
 
-	send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC);
-	if (!send_buf) {
-		BT_ERR("Can't allocate memory chunk for firmware");
-		return -ENOMEM;
-	}
-
 	while (count) {
 		size = min_t(uint, count, BULK_SIZE);
-		pipe = usb_sndbulkpipe(data->udev, 0x02);
-		memcpy(send_buf, firmware + sent, size);
+		pipe = usb_sndbulkpipe(udev, 0x02);
+		memcpy(send_buf, firmware->data + sent, size);
 
-		err = usb_bulk_msg(data->udev, pipe, send_buf, size,
+		err = usb_bulk_msg(udev, pipe, send_buf, size,
 					&len, 3000);
 
 		if (err || (len != size)) {
@@ -112,57 +106,28 @@ static int ath3k_probe(struct usb_interface *intf,
 {
 	const struct firmware *firmware;
 	struct usb_device *udev = interface_to_usbdev(intf);
-	struct ath3k_data *data;
-	int size;
 
 	BT_DBG("intf %p id %p", intf, id);
 
 	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	data->udev = udev;
-
 	if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) {
-		kfree(data);
 		return -EIO;
 	}
 
-	size = max_t(uint, firmware->size, 4096);
-	data->fw_data = kmalloc(size, GFP_KERNEL);
-	if (!data->fw_data) {
+	if (ath3k_load_firmware(udev, firmware)) {
 		release_firmware(firmware);
-		kfree(data);
-		return -ENOMEM;
-	}
-
-	memcpy(data->fw_data, firmware->data, firmware->size);
-	data->fw_size = firmware->size;
-	data->fw_sent = 0;
-	release_firmware(firmware);
-
-	usb_set_intfdata(intf, data);
-	if (ath3k_load_firmware(data, data->fw_data, data->fw_size)) {
-		usb_set_intfdata(intf, NULL);
-		kfree(data->fw_data);
-		kfree(data);
 		return -EIO;
 	}
+	release_firmware(firmware);
 
 	return 0;
 }
 
 static void ath3k_disconnect(struct usb_interface *intf)
 {
-	struct ath3k_data *data = usb_get_intfdata(intf);
-
 	BT_DBG("ath3k_disconnect intf %p", intf);
-
-	kfree(data->fw_data);
-	kfree(data);
 }
 
 static struct usb_driver ath3k_driver = {
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 1afb8bb..9f01e50 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -369,6 +369,9 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
 	else
 		ah->config.ht_enable = 0;
 
+	/* PAPRD needs some more work to be enabled */
+	ah->config.paprd_disable = 1;
+
 	ah->config.rx_intr_mitigation = true;
 	ah->config.pcieSerDesWrite = true;
 
@@ -1933,7 +1936,8 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
 		pCap->rx_status_len = sizeof(struct ar9003_rxs);
 		pCap->tx_desc_len = sizeof(struct ar9003_txc);
 		pCap->txs_len = sizeof(struct ar9003_txs);
-		if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
+		if (!ah->config.paprd_disable &&
+		    ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
 			pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
 	} else {
 		pCap->tx_desc_len = sizeof(struct ath_desc);
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 5a3dfec..ea9fde6 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -225,6 +225,7 @@ struct ath9k_ops_config {
 	u32 pcie_waen;
 	u8 analog_shiftreg;
 	u8 ht_enable;
+	u8 paprd_disable;
 	u32 ofdm_trig_low;
 	u32 ofdm_trig_high;
 	u32 cck_trig_high;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index f90a6ca..c79c97b 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -592,14 +592,12 @@ void ath9k_tasklet(unsigned long data)
 	u32 status = sc->intrstatus;
 	u32 rxmask;
 
-	ath9k_ps_wakeup(sc);
-
 	if (status & ATH9K_INT_FATAL) {
 		ath_reset(sc, true);
-		ath9k_ps_restore(sc);
 		return;
 	}
 
+	ath9k_ps_wakeup(sc);
 	spin_lock(&sc->sc_pcu_lock);
 
 	if (!ath9k_hw_check_alive(ah))
@@ -969,6 +967,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
 	/* Stop ANI */
 	del_timer_sync(&common->ani.timer);
 
+	ath9k_ps_wakeup(sc);
 	spin_lock_bh(&sc->sc_pcu_lock);
 
 	ieee80211_stop_queues(hw);
@@ -1015,6 +1014,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
 
 	/* Start ANI */
 	ath_start_ani(common);
+	ath9k_ps_restore(sc);
 
 	return r;
 }
@@ -1701,7 +1701,9 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
 skip_chan_change:
 	if (changed & IEEE80211_CONF_CHANGE_POWER) {
 		sc->config.txpowlimit = 2 * conf->power_level;
+		ath9k_ps_wakeup(sc);
 		ath_update_txpow(sc);
+		ath9k_ps_restore(sc);
 	}
 
 	spin_lock_bh(&sc->wiphy_lock);
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 332d1fe..33a37ed 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2113,9 +2113,7 @@ static void ath_tx_complete_poll_work(struct work_struct *work)
 	if (needreset) {
 		ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
 			"tx hung, resetting the chip\n");
-		ath9k_ps_wakeup(sc);
 		ath_reset(sc, true);
-		ath9k_ps_restore(sc);
 	}
 
 	ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 3f1e5f1..91a9f52 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2624,6 +2624,7 @@ struct iwl_cfg iwl4965_agn_cfg = {
 	.fw_name_pre = IWL4965_FW_PRE,
 	.ucode_api_max = IWL4965_UCODE_API_MAX,
 	.ucode_api_min = IWL4965_UCODE_API_MIN,
+	.sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
 	.valid_tx_ant = ANT_AB,
 	.valid_rx_ant = ANT_ABC,
 	.eeprom_ver = EEPROM_4965_EEPROM_VERSION,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
index 14ceb4d..27b5a3e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
@@ -152,11 +152,14 @@ int iwl_eeprom_check_sku(struct iwl_priv *priv)
 
 	eeprom_sku = iwl_eeprom_query16(priv, EEPROM_SKU_CAP);
 
-	priv->cfg->sku = ((eeprom_sku & EEPROM_SKU_CAP_BAND_SELECTION) >>
+	if (!priv->cfg->sku) {
+		/* not using sku overwrite */
+		priv->cfg->sku =
+			((eeprom_sku & EEPROM_SKU_CAP_BAND_SELECTION) >>
 			EEPROM_SKU_CAP_BAND_POS);
-	if (eeprom_sku & EEPROM_SKU_CAP_11N_ENABLE)
-		priv->cfg->sku |= IWL_SKU_N;
-
+		if (eeprom_sku & EEPROM_SKU_CAP_11N_ENABLE)
+			priv->cfg->sku |= IWL_SKU_N;
+	}
 	if (!priv->cfg->sku) {
 		IWL_ERR(priv, "Invalid device sku\n");
 		return -EINVAL;
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 0b4e859..029be3c 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2446,6 +2446,7 @@ static struct usb_device_id rt73usb_device_table[] = {
 	{ USB_DEVICE(0x04bb, 0x093d), USB_DEVICE_DATA(&rt73usb_ops) },
 	{ USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt73usb_ops) },
 	{ USB_DEVICE(0x148f, 0x2671), USB_DEVICE_DATA(&rt73usb_ops) },
+	{ USB_DEVICE(0x0812, 0x3101), USB_DEVICE_DATA(&rt73usb_ops) },
 	/* Qcom */
 	{ USB_DEVICE(0x18e8, 0x6196), USB_DEVICE_DATA(&rt73usb_ops) },
 	{ USB_DEVICE(0x18e8, 0x6229), USB_DEVICE_DATA(&rt73usb_ops) },
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 0fa36aa..1758d44 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -619,6 +619,13 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 					struct sk_buff *uskb = NULL;
 					u8 *pdata;
 					uskb = dev_alloc_skb(skb->len + 128);
+					if (!uskb) {
+						RT_TRACE(rtlpriv,
+							(COMP_INTR | COMP_RECV),
+							DBG_EMERG,
+							("can't alloc rx skb\n"));
+						goto done;
+					}
 					memcpy(IEEE80211_SKB_RXCB(uskb),
 							&rx_status,
 							sizeof(rx_status));
@@ -641,7 +648,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 			new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
 			if (unlikely(!new_skb)) {
 				RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
-					 DBG_DMESG,
+					 DBG_EMERG,
 					 ("can't alloc skb for rx\n"));
 				goto done;
 			}
@@ -1066,9 +1073,9 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw)
 			struct sk_buff *skb =
 			    dev_alloc_skb(rtlpci->rxbuffersize);
 			u32 bufferaddress;
-			entry = &rtlpci->rx_ring[rx_queue_idx].desc[i];
 			if (!skb)
 				return 0;
+			entry = &rtlpci->rx_ring[rx_queue_idx].desc[i];
 
 			/*skb->dev = dev; */
 
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index a29feb0..d2cf884 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -184,6 +184,7 @@ struct hci_conn {
 	__u32		 link_mode;
 	__u8             auth_type;
 	__u8             sec_level;
+	__u8		 pending_sec_level;
 	__u8             power_save;
 	__u16            disc_timeout;
 	unsigned long	 pend;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 6b90a41..99cd8d9 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -379,14 +379,10 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
 	hci_conn_hold(acl);
 
 	if (acl->state == BT_OPEN || acl->state == BT_CLOSED) {
-		acl->sec_level = sec_level;
+		acl->sec_level = BT_SECURITY_LOW;
+		acl->pending_sec_level = sec_level;
 		acl->auth_type = auth_type;
 		hci_acl_connect(acl);
-	} else {
-		if (acl->sec_level < sec_level)
-			acl->sec_level = sec_level;
-		if (acl->auth_type < auth_type)
-			acl->auth_type = auth_type;
 	}
 
 	if (type == ACL_LINK)
@@ -442,11 +438,17 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
 {
 	BT_DBG("conn %p", conn);
 
+	if (conn->pending_sec_level > sec_level)
+		sec_level = conn->pending_sec_level;
+
 	if (sec_level > conn->sec_level)
-		conn->sec_level = sec_level;
+		conn->pending_sec_level = sec_level;
 	else if (conn->link_mode & HCI_LM_AUTH)
 		return 1;
 
+	/* Make sure we preserve an existing MITM requirement*/
+	auth_type |= (conn->auth_type & 0x01);
+
 	conn->auth_type = auth_type;
 
 	if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8b602d8..9c4541b 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1011,6 +1011,10 @@ int hci_unregister_dev(struct hci_dev *hdev)
 
 	destroy_workqueue(hdev->workqueue);
 
+	hci_dev_lock_bh(hdev);
+	hci_blacklist_clear(hdev);
+	hci_dev_unlock_bh(hdev);
+
 	__hci_dev_put(hdev);
 
 	return 0;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 3810017..a290854 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -692,13 +692,13 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev,
 	if (conn->state != BT_CONFIG || !conn->out)
 		return 0;
 
-	if (conn->sec_level == BT_SECURITY_SDP)
+	if (conn->pending_sec_level == BT_SECURITY_SDP)
 		return 0;
 
 	/* Only request authentication for SSP connections or non-SSP
 	 * devices with sec_level HIGH */
 	if (!(hdev->ssp_mode > 0 && conn->ssp_mode > 0) &&
-					conn->sec_level != BT_SECURITY_HIGH)
+				conn->pending_sec_level != BT_SECURITY_HIGH)
 		return 0;
 
 	return 1;
@@ -1095,9 +1095,10 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
 
 	conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
 	if (conn) {
-		if (!ev->status)
+		if (!ev->status) {
 			conn->link_mode |= HCI_LM_AUTH;
-		else
+			conn->sec_level = conn->pending_sec_level;
+		} else
 			conn->sec_level = BT_SECURITY_LOW;
 
 		clear_bit(HCI_CONN_AUTH_PEND, &conn->pend);
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index c791fcd..7550abb 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -305,33 +305,44 @@ static void l2cap_chan_del(struct sock *sk, int err)
 	}
 }
 
-/* Service level security */
-static inline int l2cap_check_security(struct sock *sk)
+static inline u8 l2cap_get_auth_type(struct sock *sk)
 {
-	struct l2cap_conn *conn = l2cap_pi(sk)->conn;
-	__u8 auth_type;
+	if (sk->sk_type == SOCK_RAW) {
+		switch (l2cap_pi(sk)->sec_level) {
+		case BT_SECURITY_HIGH:
+			return HCI_AT_DEDICATED_BONDING_MITM;
+		case BT_SECURITY_MEDIUM:
+			return HCI_AT_DEDICATED_BONDING;
+		default:
+			return HCI_AT_NO_BONDING;
+		}
+	} else if (l2cap_pi(sk)->psm == cpu_to_le16(0x0001)) {
+		if (l2cap_pi(sk)->sec_level == BT_SECURITY_LOW)
+			l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
 
-	if (l2cap_pi(sk)->psm == cpu_to_le16(0x0001)) {
 		if (l2cap_pi(sk)->sec_level == BT_SECURITY_HIGH)
-			auth_type = HCI_AT_NO_BONDING_MITM;
+			return HCI_AT_NO_BONDING_MITM;
 		else
-			auth_type = HCI_AT_NO_BONDING;
-
-		if (l2cap_pi(sk)->sec_level == BT_SECURITY_LOW)
-			l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
+			return HCI_AT_NO_BONDING;
 	} else {
 		switch (l2cap_pi(sk)->sec_level) {
 		case BT_SECURITY_HIGH:
-			auth_type = HCI_AT_GENERAL_BONDING_MITM;
-			break;
+			return HCI_AT_GENERAL_BONDING_MITM;
 		case BT_SECURITY_MEDIUM:
-			auth_type = HCI_AT_GENERAL_BONDING;
-			break;
+			return HCI_AT_GENERAL_BONDING;
 		default:
-			auth_type = HCI_AT_NO_BONDING;
-			break;
+			return HCI_AT_NO_BONDING;
 		}
 	}
+}
+
+/* Service level security */
+static inline int l2cap_check_security(struct sock *sk)
+{
+	struct l2cap_conn *conn = l2cap_pi(sk)->conn;
+	__u8 auth_type;
+
+	auth_type = l2cap_get_auth_type(sk);
 
 	return hci_conn_security(conn->hcon, l2cap_pi(sk)->sec_level,
 								auth_type);
@@ -1068,39 +1079,7 @@ static int l2cap_do_connect(struct sock *sk)
 
 	err = -ENOMEM;
 
-	if (sk->sk_type == SOCK_RAW) {
-		switch (l2cap_pi(sk)->sec_level) {
-		case BT_SECURITY_HIGH:
-			auth_type = HCI_AT_DEDICATED_BONDING_MITM;
-			break;
-		case BT_SECURITY_MEDIUM:
-			auth_type = HCI_AT_DEDICATED_BONDING;
-			break;
-		default:
-			auth_type = HCI_AT_NO_BONDING;
-			break;
-		}
-	} else if (l2cap_pi(sk)->psm == cpu_to_le16(0x0001)) {
-		if (l2cap_pi(sk)->sec_level == BT_SECURITY_HIGH)
-			auth_type = HCI_AT_NO_BONDING_MITM;
-		else
-			auth_type = HCI_AT_NO_BONDING;
-
-		if (l2cap_pi(sk)->sec_level == BT_SECURITY_LOW)
-			l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
-	} else {
-		switch (l2cap_pi(sk)->sec_level) {
-		case BT_SECURITY_HIGH:
-			auth_type = HCI_AT_GENERAL_BONDING_MITM;
-			break;
-		case BT_SECURITY_MEDIUM:
-			auth_type = HCI_AT_GENERAL_BONDING;
-			break;
-		default:
-			auth_type = HCI_AT_NO_BONDING;
-			break;
-		}
-	}
+	auth_type = l2cap_get_auth_type(sk);
 
 	hcon = hci_connect(hdev, ACL_LINK, dst,
 					l2cap_pi(sk)->sec_level, auth_type);
@@ -1127,7 +1106,8 @@ static int l2cap_do_connect(struct sock *sk)
 		if (sk->sk_type != SOCK_SEQPACKET &&
 				sk->sk_type != SOCK_STREAM) {
 			l2cap_sock_clear_timer(sk);
-			sk->sk_state = BT_CONNECTED;
+			if (l2cap_check_security(sk))
+				sk->sk_state = BT_CONNECTED;
 		} else
 			l2cap_do_start(sk);
 	}
@@ -1893,8 +1873,8 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
 		if (pi->mode == L2CAP_MODE_STREAMING) {
 			l2cap_streaming_send(sk);
 		} else {
-			if (pi->conn_state & L2CAP_CONN_REMOTE_BUSY &&
-					pi->conn_state && L2CAP_CONN_WAIT_F) {
+			if ((pi->conn_state & L2CAP_CONN_REMOTE_BUSY) &&
+					(pi->conn_state & L2CAP_CONN_WAIT_F)) {
 				err = len;
 				break;
 			}
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index ff8aaa7..6b83776 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -1164,7 +1164,8 @@ static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)
 			 * initiator rfcomm_process_rx already calls
 			 * rfcomm_session_put() */
 			if (s->sock->sk->sk_state != BT_CLOSED)
-				rfcomm_session_put(s);
+				if (list_empty(&s->dlcs))
+					rfcomm_session_put(s);
 			break;
 		}
 	}
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 5950e3a..b64b42b 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2230,6 +2230,9 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
 
 	sdata = vif_to_sdata(vif);
 
+	if (!ieee80211_sdata_running(sdata))
+		goto out;
+
 	if (tim_offset)
 		*tim_offset = 0;
 	if (tim_length)
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply related

* [RFC PATCH 1/2] net: add ndo_fcoe_ddp_target() to support FCoE DDP in target mode
From: Kiran Patil @ 2011-01-26 18:09 UTC (permalink / raw)
  To: netdev, jeffrey.t.kirsher, yi.zou, robert.w.love, kiran.patil
In-Reply-To: <20110126180855.25039.82793.stgit@localhost.localdomain>

From: Yi Zou <yi.zou@intel.com>

The Fiber Channel over Ethernet (FCoE) Direct Data Placement (DDP) can also be
used for FCoE target, where the DDP used for read I/O on an initiator can be
used on an FCoE target to speed up the write I/O to the target from the initiator.
The added ndo_fcoe_ddp_target() works in the similar way as the existing
ndo_fcoe_ddp_setup() to allow the underlying hardware set up the DDP context
accordingly when it gets called from the FCoE target implementation on top
the existing Open-FCoE fcoe/libfc protocol stack so without losing the ability
to provide DDP for read I/O as an initiator, it can also provide DDP offload
to the write I/O coming from the initiator as a target.

Signed-off-by: Yi Zou <yi.zou@intel.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
---

 include/linux/netdevice.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d8fd2c2..d96a198 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -774,6 +774,10 @@ struct net_device_ops {
 						      unsigned int sgc);
 	int			(*ndo_fcoe_ddp_done)(struct net_device *dev,
 						     u16 xid);
+	int			(*ndo_fcoe_ddp_target)(struct net_device *dev,
+						       u16 xid,
+						       struct scatterlist *sgl,
+						       unsigned int sgc);
 #define NETDEV_FCOE_WWNN 0
 #define NETDEV_FCOE_WWPN 1
 	int			(*ndo_fcoe_get_wwn)(struct net_device *dev,


^ permalink raw reply related

* [RFC PATCH 2/2] vlan: add support to ndo_fcoe_ddp_target()
From: Kiran Patil @ 2011-01-26 18:09 UTC (permalink / raw)
  To: netdev, jeffrey.t.kirsher, yi.zou, robert.w.love, kiran.patil
In-Reply-To: <20110126180855.25039.82793.stgit@localhost.localdomain>

From: Yi Zou <yi.zou@intel.com>

Add the new target ddp offload support ndo_fcoe_ddp_target().

Signed-off-by: Yi Zou <yi.zou@intel.com>
---

 net/8021q/vlan_dev.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 14e3d1f..f6e1ace 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -670,6 +670,19 @@ static int vlan_dev_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type)
 		rc = ops->ndo_fcoe_get_wwn(real_dev, wwn, type);
 	return rc;
 }
+
+static int vlan_dev_fcoe_ddp_target(struct net_device *dev, u16 xid,
+				    struct scatterlist *sgl, unsigned int sgc)
+{
+	struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
+	const struct net_device_ops *ops = real_dev->netdev_ops;
+	int rc = 0;
+
+	if (ops->ndo_fcoe_ddp_target)
+		rc = ops->ndo_fcoe_ddp_target(real_dev, xid, sgl, sgc);
+
+	return rc;
+}
 #endif
 
 static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
@@ -905,6 +918,7 @@ static const struct net_device_ops vlan_netdev_ops = {
 	.ndo_fcoe_enable	= vlan_dev_fcoe_enable,
 	.ndo_fcoe_disable	= vlan_dev_fcoe_disable,
 	.ndo_fcoe_get_wwn	= vlan_dev_fcoe_get_wwn,
+	.ndo_fcoe_ddp_target	= vlan_dev_fcoe_ddp_target,
 #endif
 };
 


^ permalink raw reply related

* [RFC PATCH 0/2] Preparing NetDev and VLAN for FCoE targets (offload using DDP)
From: Kiran Patil @ 2011-01-26 18:08 UTC (permalink / raw)
  To: netdev, jeffrey.t.kirsher, yi.zou, robert.w.love, kiran.patil

The following series implements...

1) NetDev: Add ndo_fcoe_ddp_target() in struct net_device_ops to 
   support FCoE DDP in target mode
2) VLAN: Add new target DDP offload support ndo_fcoe_ddp_target.
   This patch depends upon patch 1 of this series. 


Dependencies: This series is preparing the NetDev and VLAN for
   FCoE target (offload using DDP). This series is pre-requistie 
   for the patch which shall be submitted later after final version
   of these patches for ixgbe (10Gb Ethernet Driver).

---

Yi Zou (2):
      vlan: add support to ndo_fcoe_ddp_target()
      net: add ndo_fcoe_ddp_target() to support FCoE DDP in target mode


 drivers/net/ixgbe/ixgbe.h      |    2 +
 drivers/net/ixgbe/ixgbe_fcoe.c |   86 ++++++++++++++++++++++++++++++++++------
 drivers/net/ixgbe/ixgbe_fcoe.h |    4 ++
 drivers/net/ixgbe/ixgbe_main.c |    1 
 include/linux/netdevice.h      |    4 ++
 net/8021q/vlan_dev.c           |   14 +++++++
 6 files changed, 99 insertions(+), 12 deletions(-)

-- 
Thanks,
-- Kiran P

^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Joe Perches @ 2011-01-26 17:56 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, John Fastabend
In-Reply-To: <1296064190.2899.88.camel@edumazet-laptop>

On Wed, 2011-01-26 at 18:49 +0100, Eric Dumazet wrote:
> Le mercredi 26 janvier 2011 à 09:43 -0800, Joe Perches a écrit :
> > I think the best style to use memset so that any
> > possible struct padding is guaranteed to be zeroed.
> We use the { 0 } style in net/sched,

That's nice, but it's the wrong style.
https://lkml.org/lkml/2010/12/15/63

> and there is no padding in this
> structure, I checked this point.

That may be true right now for this particular
structure, but that style is not future-proof.



^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Eric Dumazet @ 2011-01-26 17:49 UTC (permalink / raw)
  To: Joe Perches; +Cc: David Miller, netdev, John Fastabend
In-Reply-To: <1296063823.6115.37.camel@Joe-Laptop>

Le mercredi 26 janvier 2011 à 09:43 -0800, Joe Perches a écrit :

> I think the best style to use memset so that any
> possible struct padding is guaranteed to be zeroed.
> 
> 

We use the { 0 } style in net/sched, and there is no padding in this
structure, I checked this point.




^ permalink raw reply

* Re: [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Joe Perches @ 2011-01-26 17:43 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, John Fastabend
In-Reply-To: <1296062517.2899.86.camel@edumazet-laptop>

On Wed, 2011-01-26 at 18:21 +0100, Eric Dumazet wrote:
> mqprio_dump() should make sure all fields of struct tc_mqprio_qopt are
> initialized.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> CC: John Fastabend <john.r.fastabend@intel.com>
> ---
>  net/sched/sch_mqprio.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
> index fbc6f53..effd4ee 100644
> --- a/net/sched/sch_mqprio.c
> +++ b/net/sched/sch_mqprio.c
> @@ -215,7 +215,7 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
>  	struct net_device *dev = qdisc_dev(sch);
>  	struct mqprio_sched *priv = qdisc_priv(sch);
>  	unsigned char *b = skb_tail_pointer(skb);
> -	struct tc_mqprio_qopt opt;
> +	struct tc_mqprio_qopt opt = { 0 };

I think the best style to use memset so that any
possible struct padding is guaranteed to be zeroed.



^ permalink raw reply

* [PATCH] iproute2: fix man page whitespace
From: Vlad Dogaru @ 2011-01-26 17:35 UTC (permalink / raw)
  To: netdev; +Cc: Vlad Dogaru

Signed-off-by: Vlad Dogaru <ddvlad@rosedu.org>
---
 man/man8/ip.8 |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/man/man8/ip.8 b/man/man8/ip.8
index 8d55fa9..83b7358 100644
--- a/man/man8/ip.8
+++ b/man/man8/ip.8
@@ -42,7 +42,7 @@ ip \- show / manipulate routing, devices, policy routing and tunnels
 .RB "[ " mtu
 .IR MTU " ]"
 .br
-.BR type TYPE
+.BR type " TYPE"
 .RI "[ " ARGS " ]"
 
 .ti -8
@@ -51,7 +51,7 @@ ip \- show / manipulate routing, devices, policy routing and tunnels
 
 .ti -8
 .BI "ip link delete " DEVICE
-.BI type TYPE
+.BI type " TYPE"
 .RI "[ " ARGS " ]"
 
 .ti -8
-- 
1.7.1


^ permalink raw reply related

* [PATCH net-next-2.6] net_sched: sch_mqprio: dont leak kernel memory
From: Eric Dumazet @ 2011-01-26 17:21 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, John Fastabend

mqprio_dump() should make sure all fields of struct tc_mqprio_qopt are
initialized.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: John Fastabend <john.r.fastabend@intel.com>
---
 net/sched/sch_mqprio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index fbc6f53..effd4ee 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -215,7 +215,7 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
 	struct net_device *dev = qdisc_dev(sch);
 	struct mqprio_sched *priv = qdisc_priv(sch);
 	unsigned char *b = skb_tail_pointer(skb);
-	struct tc_mqprio_qopt opt;
+	struct tc_mqprio_qopt opt = { 0 };
 	struct Qdisc *qdisc;
 	unsigned int i;
 



^ permalink raw reply related

* [PATCH v3 1/3] iproute2: add support for setting device groups
From: Vlad Dogaru @ 2011-01-26 16:41 UTC (permalink / raw)
  To: netdev; +Cc: Vlad Dogaru, Stephen Hemminger
In-Reply-To: <1296060086-18777-1-git-send-email-ddvlad@rosedu.org>

Use the group keyword to specify what group the device should belong to.
Since the kernel uses numbers internally, mapping of group names to
numbers is defined in /etc/iproute2/group_map. Example usage:

  ip link set dev eth0 group default

Signed-off-by: Vlad Dogaru <ddvlad@rosedu.org>
---
 etc/iproute2/group_map  |    2 ++
 include/linux/if_link.h |    1 +
 include/utils.h         |    2 ++
 ip/ip_common.h          |    2 ++
 ip/iplink.c             |    9 +++++++++
 lib/utils.c             |   41 +++++++++++++++++++++++++++++++++++++++++
 man/man8/ip.8           |    9 +++++++++
 tc/m_ematch.c           |   39 ---------------------------------------
 8 files changed, 66 insertions(+), 39 deletions(-)
 create mode 100644 etc/iproute2/group_map

diff --git a/etc/iproute2/group_map b/etc/iproute2/group_map
new file mode 100644
index 0000000..6f000b2
--- /dev/null
+++ b/etc/iproute2/group_map
@@ -0,0 +1,2 @@
+# device group names
+0	default
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index e87456c..54d05f9 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -135,6 +135,7 @@ enum {
 	IFLA_VF_PORTS,
 	IFLA_PORT_SELF,
 	IFLA_AF_SPEC,
+	IFLA_GROUP,
 	__IFLA_MAX
 };
 
diff --git a/include/utils.h b/include/utils.h
index 3da6998..327373e 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -152,4 +152,6 @@ extern int makeargs(char *line, char *argv[], int maxargs);
 struct iplink_req;
 int iplink_parse(int argc, char **argv, struct iplink_req *req,
 		char **name, char **type, char **link, char **dev);
+
+int lookup_map_id(const char *kind, int *dst, const char *file);
 #endif /* __UTILS_H__ */
diff --git a/ip/ip_common.h b/ip/ip_common.h
index a114186..b751d46 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -68,3 +68,5 @@ struct link_util *get_link_kind(const char *kind);
 #ifndef	INFINITY_LIFE_TIME
 #define     INFINITY_LIFE_TIME      0xFFFFFFFFU
 #endif
+
+#define GROUP_MAP "/etc/iproute2/group_map"
diff --git a/ip/iplink.c b/ip/iplink.c
index cb2c4f5..6c9df43 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -68,6 +68,7 @@ void iplink_usage(void)
 	fprintf(stderr, "	                  [ mtu MTU ]\n");
 	fprintf(stderr, "	                  [ netns PID ]\n");
 	fprintf(stderr, "			  [ alias NAME ]\n");
+	fprintf(stderr, "			  [ group GROUP ]\n");
 	fprintf(stderr, "	                  [ vf NUM [ mac LLADDR ]\n");
 	fprintf(stderr, "				   [ vlan VLANID [ qos VLAN-QOS ] ]\n");
 	fprintf(stderr, "				   [ rate TXRATE ] ] \n");
@@ -252,6 +253,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 	int mtu = -1;
 	int netns = -1;
 	int vf = -1;
+	int group = -1;
 
 	ret = argc;
 
@@ -297,6 +299,13 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 			if (get_integer(&mtu, *argv, 0))
 				invarg("Invalid \"mtu\" value\n", *argv);
 			addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
+		} else if (strcmp(*argv, "group") == 0) {
+			NEXT_ARG();
+			if (group != -1)
+				duparg("group", *argv);
+			if (lookup_map_id(*argv, &group, GROUP_MAP))
+				invarg("Invalid \"group\" value\n", *argv);
+			addattr_l(&req->n, sizeof(*req), IFLA_GROUP, &group, 4);
                 } else if (strcmp(*argv, "netns") == 0) {
                         NEXT_ARG();
                         if (netns != -1)
diff --git a/lib/utils.c b/lib/utils.c
index a60d884..3642cb7 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -25,6 +25,7 @@
 #include <linux/pkt_sched.h>
 #include <time.h>
 #include <sys/time.h>
+#include <errno.h>
 
 
 #include "utils.h"
@@ -760,3 +761,43 @@ int makeargs(char *line, char *argv[], int maxargs)
 
 	return argc;
 }
+
+int lookup_map_id(const char *kind, int *dst, const char *file)
+{
+	int err = -EINVAL;
+	char buf[512];
+	FILE *fd = fopen(file, "r");
+
+	if (fd == NULL) {
+		fprintf(stderr, "open %s: %s\n", file, strerror(errno));
+		return -errno;
+	}
+
+	while (fgets(buf, sizeof(buf), fd)) {
+		char namebuf[512], *p = buf;
+		int id;
+
+		while (*p == ' ' || *p == '\t')
+			p++;
+		if (*p == '#' || *p == '\n' || *p == 0)
+			continue;
+
+		if (sscanf(p, "%d %s", &id, namebuf) != 2) {
+			fprintf(stderr, "map %s corrupted at %s\n",
+			    file, p);
+			goto out;
+		}
+
+		if (!strcasecmp(namebuf, kind)) {
+			if (dst)
+				*dst = id;
+			err = 0;
+			goto out;
+		}
+	}
+
+	err = -ENOENT;
+out:
+	fclose(fd);
+	return err;
+}
diff --git a/man/man8/ip.8 b/man/man8/ip.8
index 8d55fa9..77e03d8 100644
--- a/man/man8/ip.8
+++ b/man/man8/ip.8
@@ -86,6 +86,9 @@ ip \- show / manipulate routing, devices, policy routing and tunnels
 .B alias
 .IR NAME  " |"
 .br
+.B  group
+.IR GROUP " |"
+.br
 .B vf
 .IR NUM " ["
 .B  mac
@@ -994,6 +997,12 @@ move the device to the network namespace associated with the process
 give the device a symbolic name for easy reference.
 
 .TP
+.BI group " GROUP"
+specify the group the device belongs to.
+The available groups are listed in file
+.BR "/etc/iproute2/group_map" .
+
+.TP
 .BI vf " NUM"
 specify a Virtual Function device to be configured. The associated PF device
 must be specified using the
diff --git a/tc/m_ematch.c b/tc/m_ematch.c
index 4c3acf8..4a6855c 100644
--- a/tc/m_ematch.c
+++ b/tc/m_ematch.c
@@ -87,45 +87,6 @@ out:
 	return err;
 }
 
-static int lookup_map_id(char *kind, int *dst, const char *file)
-{
-	int err = -EINVAL;
-	char buf[512];
-	FILE *fd = fopen(file, "r");
-
-	if (fd == NULL)
-		return -errno;
-
-	while (fgets(buf, sizeof(buf), fd)) {
-		char namebuf[512], *p = buf;
-		int id;
-
-		while (*p == ' ' || *p == '\t')
-			p++;
-		if (*p == '#' || *p == '\n' || *p == 0)
-			continue;
-
-		if (sscanf(p, "%d %s", &id, namebuf) != 2) {
-			fprintf(stderr, "ematch map %s corrupted at %s\n",
-			    file, p);
-			goto out;
-		}
-
-		if (!strcasecmp(namebuf, kind)) {
-			if (dst)
-				*dst = id;
-			err = 0;
-			goto out;
-		}
-	}
-
-	err = -ENOENT;
-	*dst = 0;
-out:
-	fclose(fd);
-	return err;
-}
-
 static struct ematch_util *get_ematch_kind(char *kind)
 {
 	static void *body;
-- 
1.7.1


^ 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