Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH 1/3] tun: move internal flag defines out of uapi
From: Dan Williams @ 2014-11-19 16:47 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, rusty-8n+1lVoiYb80n/F98K4Iww,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q, Jason Wang, Zhi Yong Wu,
	Tom Herbert, Ben Hutchings, Masatake YAMATO, Xi Wang,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-api-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1416413891-29562-2-git-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Wed, 2014-11-19 at 18:18 +0200, Michael S. Tsirkin wrote:
> TUN_ flags are internal and never exposed
> to userspace. Any application using it is almost
> certainly buggy.

Except for TUN_TUN_DEV and TUN_TAP_DEV and TUN_TYPE_MASK...  which we're
using (for some reason) in NetworkManager, though I'll happily convert
those to IFF_* instead.  It might be worth #defining those to their
IFF_* equivalents since their usage is not technically broken.

Dan

> Move them out to tun.c, we'll remove them in follow-up patches.
> Signed-off-by: Michael S. Tsirkin <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  include/uapi/linux/if_tun.h | 14 --------------
>  drivers/net/tun.c           | 14 ++++++++++++++
>  2 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> index e9502dd..b82c276 100644
> --- a/include/uapi/linux/if_tun.h
> +++ b/include/uapi/linux/if_tun.h
> @@ -23,20 +23,6 @@
>  /* Read queue size */
>  #define TUN_READQ_SIZE	500
>  
> -/* TUN device flags */
> -#define TUN_TUN_DEV 	0x0001	
> -#define TUN_TAP_DEV	0x0002
> -#define TUN_TYPE_MASK   0x000f
> -
> -#define TUN_FASYNC	0x0010
> -#define TUN_NOCHECKSUM	0x0020
> -#define TUN_NO_PI	0x0040
> -/* This flag has no real effect */
> -#define TUN_ONE_QUEUE	0x0080
> -#define TUN_PERSIST 	0x0100	
> -#define TUN_VNET_HDR 	0x0200
> -#define TUN_TAP_MQ      0x0400
> -
>  /* Ioctl defines */
>  #define TUNSETNOCSUM  _IOW('T', 200, int) 
>  #define TUNSETDEBUG   _IOW('T', 201, int) 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 2e18ddd..81735f5 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -103,6 +103,20 @@ do {								\
>  } while (0)
>  #endif
>  
> +/* TUN device flags */
> +#define TUN_TUN_DEV 	0x0001
> +#define TUN_TAP_DEV	0x0002
> +#define TUN_TYPE_MASK   0x000f
> +
> +#define TUN_FASYNC	0x0010
> +#define TUN_NOCHECKSUM	0x0020
> +#define TUN_NO_PI	0x0040
> +/* This flag has no real effect */
> +#define TUN_ONE_QUEUE	0x0080
> +#define TUN_PERSIST 	0x0100
> +#define TUN_VNET_HDR 	0x0200
> +#define TUN_TAP_MQ      0x0400
> +
>  #define GOODCOPY_LEN 128
>  
>  #define FLT_EXACT_COUNT 8

^ permalink raw reply

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
From: John Fastabend @ 2014-11-19 16:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors,
	Coccinelle
In-Reply-To: <546BAB93.4010406@users.sourceforge.net>

On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:21:16 +0100
>
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   net/sched/cls_bpf.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
> index 0e30d58..f323944 100644
> --- a/net/sched/cls_bpf.c
> +++ b/net/sched/cls_bpf.c
> @@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
>
>   	if (fp_old)
>   		bpf_prog_destroy(fp_old);
> -	if (bpf_old)
> -		kfree(bpf_old);
> +	kfree(bpf_old);
>
>   	return 0;
>
>

Maybe I need some coffee but I can't figure out what this
patch is against...

# grep bpf_old ./net/sched/cls_bpf.c
#

Marcus, what tree are you looking at?

-- 
John Fastabend         Intel Corporation

^ permalink raw reply

* Re: [PATCH 1/3] tun: move internal flag defines out of uapi
From: Michael S. Tsirkin @ 2014-11-19 16:50 UTC (permalink / raw)
  To: Dan Williams
  Cc: linux-kernel, rusty, davem, Jason Wang, Zhi Yong Wu, Tom Herbert,
	Ben Hutchings, Masatake YAMATO, Xi Wang, netdev, linux-api
In-Reply-To: <1416415634.4763.9.camel@dcbw.local>

On Wed, Nov 19, 2014 at 10:47:14AM -0600, Dan Williams wrote:
> On Wed, 2014-11-19 at 18:18 +0200, Michael S. Tsirkin wrote:
> > TUN_ flags are internal and never exposed
> > to userspace. Any application using it is almost
> > certainly buggy.
> 
> Except for TUN_TUN_DEV and TUN_TAP_DEV and TUN_TYPE_MASK...  which we're
> using (for some reason) in NetworkManager, though I'll happily convert
> those to IFF_* instead.  It might be worth #defining those to their
> IFF_* equivalents since their usage is not technically broken.
> 
> Dan

Hmm you are right, they happen to have the same value.
I'll send v2 leaving these in place.


> > Move them out to tun.c, we'll remove them in follow-up patches.
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  include/uapi/linux/if_tun.h | 14 --------------
> >  drivers/net/tun.c           | 14 ++++++++++++++
> >  2 files changed, 14 insertions(+), 14 deletions(-)
> > 
> > diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> > index e9502dd..b82c276 100644
> > --- a/include/uapi/linux/if_tun.h
> > +++ b/include/uapi/linux/if_tun.h
> > @@ -23,20 +23,6 @@
> >  /* Read queue size */
> >  #define TUN_READQ_SIZE	500
> >  
> > -/* TUN device flags */
> > -#define TUN_TUN_DEV 	0x0001	
> > -#define TUN_TAP_DEV	0x0002
> > -#define TUN_TYPE_MASK   0x000f
> > -
> > -#define TUN_FASYNC	0x0010
> > -#define TUN_NOCHECKSUM	0x0020
> > -#define TUN_NO_PI	0x0040
> > -/* This flag has no real effect */
> > -#define TUN_ONE_QUEUE	0x0080
> > -#define TUN_PERSIST 	0x0100	
> > -#define TUN_VNET_HDR 	0x0200
> > -#define TUN_TAP_MQ      0x0400
> > -
> >  /* Ioctl defines */
> >  #define TUNSETNOCSUM  _IOW('T', 200, int) 
> >  #define TUNSETDEBUG   _IOW('T', 201, int) 
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > index 2e18ddd..81735f5 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -103,6 +103,20 @@ do {								\
> >  } while (0)
> >  #endif
> >  
> > +/* TUN device flags */
> > +#define TUN_TUN_DEV 	0x0001
> > +#define TUN_TAP_DEV	0x0002
> > +#define TUN_TYPE_MASK   0x000f
> > +
> > +#define TUN_FASYNC	0x0010
> > +#define TUN_NOCHECKSUM	0x0020
> > +#define TUN_NO_PI	0x0040
> > +/* This flag has no real effect */
> > +#define TUN_ONE_QUEUE	0x0080
> > +#define TUN_PERSIST 	0x0100
> > +#define TUN_VNET_HDR 	0x0200
> > +#define TUN_TAP_MQ      0x0400
> > +
> >  #define GOODCOPY_LEN 128
> >  
> >  #define FLT_EXACT_COUNT 8
> 

^ permalink raw reply

* Payment
From: Finance Department @ 2014-11-19 15:15 UTC (permalink / raw)


Dear Recipient,

You have been awarded the sum of  8,000,000.00 (Eight Million Pounds sterling) with reference number 77100146 by office of the ministry of finance UK.Send us your personal details to deliver your funds.

Gloria Peter

^ permalink raw reply

* [PATCH net-next] packet: make packet_snd fail on len smaller than l2 header
From: Willem de Bruijn @ 2014-11-19 16:56 UTC (permalink / raw)
  To: netdev; +Cc: davem, eric.dumazet, dborkman, Willem de Bruijn

From: Willem de Bruijn <willemb@google.com>

When sending packets out with PF_PACKET, SOCK_RAW, ensure that the
packet is at least as long as the device's expected link layer header.
This check already exists in tpacket_snd, but not in packet_snd.
Also rate limit the warning in tpacket_snd.

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 net/packet/af_packet.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4cd13d8..0d3cb44 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2095,6 +2095,18 @@ static void tpacket_destruct_skb(struct sk_buff *skb)
 	sock_wfree(skb);
 }
 
+static bool ll_header_truncated(int len, struct net_device *dev)
+{
+	/* net device doesn't like empty head */
+	if (unlikely(len <= dev->hard_header_len)) {
+		net_warn_ratelimited("%s: packet size is too short (%d < %d)\n",
+				     current->comm, len, dev->hard_header_len);
+		return true;
+	}
+
+	return false;
+}
+
 static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
 		void *frame, struct net_device *dev, int size_max,
 		__be16 proto, unsigned char *addr, int hlen)
@@ -2170,12 +2182,8 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
 		if (unlikely(err < 0))
 			return -EINVAL;
 	} else if (dev->hard_header_len) {
-		/* net device doesn't like empty head */
-		if (unlikely(tp_len <= dev->hard_header_len)) {
-			pr_err("packet size is too short (%d < %d)\n",
-			       tp_len, dev->hard_header_len);
+		if (ll_header_truncated(tp_len, dev))
 			return -EINVAL;
-		}
 
 		skb_push(skb, dev->hard_header_len);
 		err = skb_store_bits(skb, 0, data,
@@ -2500,9 +2508,15 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 	skb_set_network_header(skb, reserve);
 
 	err = -EINVAL;
-	if (sock->type == SOCK_DGRAM &&
-	    (offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len)) < 0)
-		goto out_free;
+	if (sock->type == SOCK_DGRAM) {
+		offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL,
+					 len);
+		if (unlikely(offset) < 0)
+			goto out_free;
+	} else {
+		if (ll_header_truncated(len, dev))
+			goto out_free;
+	}
 
 	/* Returns -EFAULT on error */
 	err = skb_copy_datagram_from_iovec(skb, offset, msg->msg_iov, 0, len);
-- 
2.1.0.rc2.206.gedb03e5

^ permalink raw reply related

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
From: Daniel Borkmann @ 2014-11-19 17:00 UTC (permalink / raw)
  To: John Fastabend
  Cc: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev,
	LKML, kernel-janitors, Coccinelle
In-Reply-To: <546CC9B3.5060405@gmail.com>

On 11/19/2014 05:47 PM, John Fastabend wrote:
> On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
...
>>       if (fp_old)
>>           bpf_prog_destroy(fp_old);
>> -    if (bpf_old)
>> -        kfree(bpf_old);
>> +    kfree(bpf_old);
>>
>>       return 0;
>>
>
> Maybe I need some coffee but I can't figure out what this
> patch is against...
>
> # grep bpf_old ./net/sched/cls_bpf.c
> #

Coffee is always good. :)

Yeah, you actually removed this in commit 1f947bf151e90ec ("net:
sched: rcu'ify cls_bpf"), so looks like Markus's tree is not
up to date ...

^ permalink raw reply

* [PATCH net] pptp: fix stack info leak in pptp_getname()
From: Mathias Krause @ 2014-11-19 17:05 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Mathias Krause, Dmitry Kozlov

pptp_getname() only partially initializes the stack variable sa,
particularly only fills the pptp part of the sa_addr union. The code
thereby discloses 16 bytes of kernel stack memory via getsockname().

Fix this by memset(0)'ing the union before.

Cc: Dmitry Kozlov <xeb@mail.ru>
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
Probably material for stable, too -- v2.6.37+.

 drivers/net/ppp/pptp.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index 1aff970be33e..1dc628ffce2b 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -506,7 +506,9 @@ static int pptp_getname(struct socket *sock, struct sockaddr *uaddr,
 	int len = sizeof(struct sockaddr_pppox);
 	struct sockaddr_pppox sp;
 
-	sp.sa_family	  = AF_PPPOX;
+	memset(&sp.sa_addr, 0, sizeof(sp.sa_addr));
+
+	sp.sa_family    = AF_PPPOX;
 	sp.sa_protocol  = PX_PROTO_PPTP;
 	sp.sa_addr.pptp = pppox_sk(sock->sk)->proto.pptp.src_addr;
 
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH 1/3] tun: move internal flag defines out of uapi
From: Michael S. Tsirkin @ 2014-11-19 17:08 UTC (permalink / raw)
  To: Dan Williams
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, rusty-8n+1lVoiYb80n/F98K4Iww,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q, Jason Wang, Zhi Yong Wu,
	Tom Herbert, Ben Hutchings, Masatake YAMATO, Xi Wang,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-api-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20141119165017.GA29759-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Wed, Nov 19, 2014 at 06:50:17PM +0200, Michael S. Tsirkin wrote:
> On Wed, Nov 19, 2014 at 10:47:14AM -0600, Dan Williams wrote:
> > On Wed, 2014-11-19 at 18:18 +0200, Michael S. Tsirkin wrote:
> > > TUN_ flags are internal and never exposed
> > > to userspace. Any application using it is almost
> > > certainly buggy.
> > 
> > Except for TUN_TUN_DEV and TUN_TAP_DEV and TUN_TYPE_MASK...  which we're
> > using (for some reason) in NetworkManager, though I'll happily convert
> > those to IFF_* instead.  It might be worth #defining those to their
> > IFF_* equivalents since their usage is not technically broken.
> > 
> > Dan
> 
> Hmm you are right, they happen to have the same value.
> I'll send v2 leaving these in place.
> 

Though I do think userspace shouldn't depend on them generally,
so it might be a good idea to stop using them, even though
I'll fix up my patches to avoid breaking this usecase.



> > > Move them out to tun.c, we'll remove them in follow-up patches.
> > > Signed-off-by: Michael S. Tsirkin <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > > ---
> > >  include/uapi/linux/if_tun.h | 14 --------------
> > >  drivers/net/tun.c           | 14 ++++++++++++++
> > >  2 files changed, 14 insertions(+), 14 deletions(-)
> > > 
> > > diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> > > index e9502dd..b82c276 100644
> > > --- a/include/uapi/linux/if_tun.h
> > > +++ b/include/uapi/linux/if_tun.h
> > > @@ -23,20 +23,6 @@
> > >  /* Read queue size */
> > >  #define TUN_READQ_SIZE	500
> > >  
> > > -/* TUN device flags */
> > > -#define TUN_TUN_DEV 	0x0001	
> > > -#define TUN_TAP_DEV	0x0002
> > > -#define TUN_TYPE_MASK   0x000f
> > > -
> > > -#define TUN_FASYNC	0x0010
> > > -#define TUN_NOCHECKSUM	0x0020
> > > -#define TUN_NO_PI	0x0040
> > > -/* This flag has no real effect */
> > > -#define TUN_ONE_QUEUE	0x0080
> > > -#define TUN_PERSIST 	0x0100	
> > > -#define TUN_VNET_HDR 	0x0200
> > > -#define TUN_TAP_MQ      0x0400
> > > -
> > >  /* Ioctl defines */
> > >  #define TUNSETNOCSUM  _IOW('T', 200, int) 
> > >  #define TUNSETDEBUG   _IOW('T', 201, int) 
> > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > > index 2e18ddd..81735f5 100644
> > > --- a/drivers/net/tun.c
> > > +++ b/drivers/net/tun.c
> > > @@ -103,6 +103,20 @@ do {								\
> > >  } while (0)
> > >  #endif
> > >  
> > > +/* TUN device flags */
> > > +#define TUN_TUN_DEV 	0x0001
> > > +#define TUN_TAP_DEV	0x0002
> > > +#define TUN_TYPE_MASK   0x000f
> > > +
> > > +#define TUN_FASYNC	0x0010
> > > +#define TUN_NOCHECKSUM	0x0020
> > > +#define TUN_NO_PI	0x0040
> > > +/* This flag has no real effect */
> > > +#define TUN_ONE_QUEUE	0x0080
> > > +#define TUN_PERSIST 	0x0100
> > > +#define TUN_VNET_HDR 	0x0200
> > > +#define TUN_TAP_MQ      0x0400
> > > +
> > >  #define GOODCOPY_LEN 128
> > >  
> > >  #define FLT_EXACT_COUNT 8
> > 

^ permalink raw reply

* Re: [PATCH 1/3] tun: move internal flag defines out of uapi
From: Dan Williams @ 2014-11-19 17:11 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, rusty, davem, Jason Wang, Zhi Yong Wu, Tom Herbert,
	Ben Hutchings, Masatake YAMATO, Xi Wang, netdev, linux-api
In-Reply-To: <20141119170835.GA29928@redhat.com>

On Wed, 2014-11-19 at 19:08 +0200, Michael S. Tsirkin wrote:
> On Wed, Nov 19, 2014 at 06:50:17PM +0200, Michael S. Tsirkin wrote:
> > On Wed, Nov 19, 2014 at 10:47:14AM -0600, Dan Williams wrote:
> > > On Wed, 2014-11-19 at 18:18 +0200, Michael S. Tsirkin wrote:
> > > > TUN_ flags are internal and never exposed
> > > > to userspace. Any application using it is almost
> > > > certainly buggy.
> > > 
> > > Except for TUN_TUN_DEV and TUN_TAP_DEV and TUN_TYPE_MASK...  which we're
> > > using (for some reason) in NetworkManager, though I'll happily convert
> > > those to IFF_* instead.  It might be worth #defining those to their
> > > IFF_* equivalents since their usage is not technically broken.
> > > 
> > > Dan
> > 
> > Hmm you are right, they happen to have the same value.
> > I'll send v2 leaving these in place.
> > 
> 
> Though I do think userspace shouldn't depend on them generally,
> so it might be a good idea to stop using them, even though
> I'll fix up my patches to avoid breaking this usecase.

Yeah, I'm doing an NM patch right now to use IFF_*.

Dan

> 
> 
> > > > Move them out to tun.c, we'll remove them in follow-up patches.
> > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > > ---
> > > >  include/uapi/linux/if_tun.h | 14 --------------
> > > >  drivers/net/tun.c           | 14 ++++++++++++++
> > > >  2 files changed, 14 insertions(+), 14 deletions(-)
> > > > 
> > > > diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> > > > index e9502dd..b82c276 100644
> > > > --- a/include/uapi/linux/if_tun.h
> > > > +++ b/include/uapi/linux/if_tun.h
> > > > @@ -23,20 +23,6 @@
> > > >  /* Read queue size */
> > > >  #define TUN_READQ_SIZE	500
> > > >  
> > > > -/* TUN device flags */
> > > > -#define TUN_TUN_DEV 	0x0001	
> > > > -#define TUN_TAP_DEV	0x0002
> > > > -#define TUN_TYPE_MASK   0x000f
> > > > -
> > > > -#define TUN_FASYNC	0x0010
> > > > -#define TUN_NOCHECKSUM	0x0020
> > > > -#define TUN_NO_PI	0x0040
> > > > -/* This flag has no real effect */
> > > > -#define TUN_ONE_QUEUE	0x0080
> > > > -#define TUN_PERSIST 	0x0100	
> > > > -#define TUN_VNET_HDR 	0x0200
> > > > -#define TUN_TAP_MQ      0x0400
> > > > -
> > > >  /* Ioctl defines */
> > > >  #define TUNSETNOCSUM  _IOW('T', 200, int) 
> > > >  #define TUNSETDEBUG   _IOW('T', 201, int) 
> > > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > > > index 2e18ddd..81735f5 100644
> > > > --- a/drivers/net/tun.c
> > > > +++ b/drivers/net/tun.c
> > > > @@ -103,6 +103,20 @@ do {								\
> > > >  } while (0)
> > > >  #endif
> > > >  
> > > > +/* TUN device flags */
> > > > +#define TUN_TUN_DEV 	0x0001
> > > > +#define TUN_TAP_DEV	0x0002
> > > > +#define TUN_TYPE_MASK   0x000f
> > > > +
> > > > +#define TUN_FASYNC	0x0010
> > > > +#define TUN_NOCHECKSUM	0x0020
> > > > +#define TUN_NO_PI	0x0040
> > > > +/* This flag has no real effect */
> > > > +#define TUN_ONE_QUEUE	0x0080
> > > > +#define TUN_PERSIST 	0x0100
> > > > +#define TUN_VNET_HDR 	0x0200
> > > > +#define TUN_TAP_MQ      0x0400
> > > > +
> > > >  #define GOODCOPY_LEN 128
> > > >  
> > > >  #define FLT_EXACT_COUNT 8
> > > 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH net] tcp: fix connect() invalid -EADDRNOTAVAIL error
From: Eric Dumazet @ 2014-11-19 17:12 UTC (permalink / raw)
  To: Jon Maxwell
  Cc: davem, kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel,
	jmaxwell
In-Reply-To: <1416379060-15685-1-git-send-email-jmaxwell37@gmail.com>

On Wed, 2014-11-19 at 17:37 +1100, Jon Maxwell wrote:

> Prerequisites for this to happen:
> 1) The local tcp port range must be exhausted.
> 2) A process must have called bind() followed by connect() for all 
> local ports.

How the bind() is done exactly ? How SO_REUSEADDR is used ?

> 3) A different process calls connect() only which returns -EADDRNOTAVAIL. 
> 4) The system more than 1 interface configured.
> 
> If a system has 2 IP Addresses and all local tcp ports are in use
> for connection from IP Address (1). Connecting to the same ports 
> via IP Address (2) should work based on the 4 tuple rule. But it 
> fails under this condition. 

I do not think this is generally true.

If process called bind() to reserve a port, another process should not
be able to use the same port.

Do you have a test program exhibiting the problem ?

Thanks !

^ permalink raw reply

* Re: [PATCH net-next] packet: make packet_snd fail on len smaller than l2 header
From: Daniel Borkmann @ 2014-11-19 17:16 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: netdev, davem, eric.dumazet
In-Reply-To: <1416416165-24697-1-git-send-email-willemb@google.com>

On 11/19/2014 05:56 PM, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
>
> When sending packets out with PF_PACKET, SOCK_RAW, ensure that the
> packet is at least as long as the device's expected link layer header.
> This check already exists in tpacket_snd, but not in packet_snd.
> Also rate limit the warning in tpacket_snd.
>
> Signed-off-by: Willem de Bruijn <willemb@google.com>

Ok, one thing below though, otherwise:

Acked-by: Daniel Borkmann <dborkman@redhat.com>

> ---
>   net/packet/af_packet.c | 30 ++++++++++++++++++++++--------
>   1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 4cd13d8..0d3cb44 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -2095,6 +2095,18 @@ static void tpacket_destruct_skb(struct sk_buff *skb)
>   	sock_wfree(skb);
>   }
>
> +static bool ll_header_truncated(int len, struct net_device *dev)
> +{

const struct net_device *dev

[ if at it, I'd perhaps also swap the arg order ]

> +	/* net device doesn't like empty head */
> +	if (unlikely(len <= dev->hard_header_len)) {
> +		net_warn_ratelimited("%s: packet size is too short (%d < %d)\n",
> +				     current->comm, len, dev->hard_header_len);
> +		return true;
> +	}
> +
> +	return false;
> +}
> +
>   static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
>   		void *frame, struct net_device *dev, int size_max,
>   		__be16 proto, unsigned char *addr, int hlen)
> @@ -2170,12 +2182,8 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
>   		if (unlikely(err < 0))
>   			return -EINVAL;
>   	} else if (dev->hard_header_len) {
> -		/* net device doesn't like empty head */
> -		if (unlikely(tp_len <= dev->hard_header_len)) {
> -			pr_err("packet size is too short (%d < %d)\n",
> -			       tp_len, dev->hard_header_len);
> +		if (ll_header_truncated(tp_len, dev))
>   			return -EINVAL;
> -		}
>
>   		skb_push(skb, dev->hard_header_len);
>   		err = skb_store_bits(skb, 0, data,
> @@ -2500,9 +2508,15 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
>   	skb_set_network_header(skb, reserve);
>
>   	err = -EINVAL;
> -	if (sock->type == SOCK_DGRAM &&
> -	    (offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len)) < 0)
> -		goto out_free;
> +	if (sock->type == SOCK_DGRAM) {
> +		offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL,
> +					 len);
> +		if (unlikely(offset) < 0)
> +			goto out_free;
> +	} else {
> +		if (ll_header_truncated(len, dev))
> +			goto out_free;
> +	}
>
>   	/* Returns -EFAULT on error */
>   	err = skb_copy_datagram_from_iovec(skb, offset, msg->msg_iov, 0, len);
>

^ permalink raw reply

* Re: [ovs-dev] [PATCH net] openvswitch: Fix mask generation for IPv6 labels.
From: Joe Stringer @ 2014-11-19 17:48 UTC (permalink / raw)
  To: Pravin Shelar; +Cc: dev@openvswitch.org, netdev, LKML
In-Reply-To: <CALnjE+rr2tFdvD+X=BbAza_5ad4DYs6viwvZWHCebQYmpvKU3Q@mail.gmail.com>

On Wednesday, November 19, 2014 00:11:01 Pravin Shelar wrote:
> On Tue, Nov 18, 2014 at 11:25 PM, Joe Stringer <joestringer@nicira.com> 
wrote:
> > On 18 November 2014 22:09, Pravin Shelar <pshelar@nicira.com> wrote:
> >> On Tue, Nov 18, 2014 at 10:54 AM, Joe Stringer <joestringer@nicira.com>
> >> 
> >> wrote:
> >> > When userspace doesn't provide a mask, OVS datapath generates a fully
> >> > unwildcarded mask for the flow. This is done by taking a copy of the
> >> > flow key, then iterating across its attributes, setting all values to
> >> > 0xff. This works for most attributes, as the length of the netlink
> >> > attribute typically matches the length of the value. However, IPv6
> >> > labels only use the lower 20 bits of the field. This patch makes a
> >> > special case to handle this.
> >> > 
> >> > This fixes the following error seen when installing IPv6 flows without
> >> > a mask:
> >> > 
> >> > openvswitch: netlink: Invalid IPv6 flow label value (value=ffffffff,
> >> > max=fffff)
> >> 
> >> We should allow exact match mask here rather than generating
> >> wildcarded mask. So that ovs can catch invalid ipv6.label.
> > 
> > I don't quite follow, I thought this was exact-match? (The existing
> > function sets all bits to 1)
> 
> With 0xffffffff value we can exact match on all ipv6.lable bits.

The label field is only 20 bits. The other bits in the same word of the IPv6 
header are for version (fixed) and traffic class (handled separately). We don't 
do anything with the other bits.

^ permalink raw reply

* Re: BCM4313 & brcmsmac & 3.12: only semi-working?
From: Arend van Spriel @ 2014-11-19 17:54 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: Maximilian Engelhardt, Rafał Miłecki, Seth Forshee,
	brcm80211 development, linux-wireless@vger.kernel.org,
	Network Development
In-Reply-To: <546C5D1F.108@msgid.tls.msk.ru>

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

On 11/19/14 10:04, Michael Tokarev wrote:
> 18.11.2014 01:36, Maximilian Engelhardt wrote:
> []
>> I just wanted to ask if there is any progress on this issue since I haven't
>> heard anything for a month. Please let me know if you need any additional
>> information.
>
> I've no idea if there's any progress.  Meanwhile I've an easy way of
> testing of my brcm4313 card in a mini-itx board with mini-PCIe slot.
> It works rather nicely and the stalls are easy to trigger.
> Running 3.16 kernel right now, tried to d/load a file from the
> AP, -- boom, it stalled after 77Kb.
>
> Since the previous discussion apparently ended prematurely and no patches
> to try emerged, I don't have anything to try on it...

In our last email exchange I got the impression you switch to Intel 
board and did not want to keep replacing cards for testing. Nice to hear 
you have an alternative setup for this and I assume are willing to do 
some testing.

I submitted two patches upstream and additionally I have attached two 
other that are still under review. Could you try these patches and sent 
me the content of the two debugfs files 'macstat' and 'hardware' after a 
stall has occurred.

Regards,
Arend

[-- Attachment #2: 0001-brcmutil-add-helper-function-to-format-board-revisio.patch --]
[-- Type: text/plain, Size: 2045 bytes --]

From dbc69f9769b92f3ce115fabf880f767d6bd4c436 Mon Sep 17 00:00:00 2001
From: Arend van Spriel <arend@broadcom.com>
Date: Thu, 13 Nov 2014 14:16:34 +0100
Subject: [PATCH 1/2] brcmutil: add helper function to format board revision

The board revision that is available in hardware can be translated
so it matches the labelling on the board. This is accomplished by
this helper function.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 drivers/net/wireless/brcm80211/brcmutil/utils.c      | 16 ++++++++++++++++
 drivers/net/wireless/brcm80211/include/brcmu_utils.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c
index 0f7e1c7..1575a1d 100644
--- a/drivers/net/wireless/brcm80211/brcmutil/utils.c
+++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c
@@ -292,4 +292,20 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
 	print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size);
 }
 EXPORT_SYMBOL(brcmu_dbg_hex_dump);
+
+/* Produce a human-readable string for boardrev */
+char *brcmu_boardrev_str(u32 brev, char *buf)
+{
+	char c;
+
+	if (brev < 0x100) {
+		snprintf(buf, 8, "%d.%d", (brev & 0xf0) >> 4, brev & 0xf);
+	} else {
+		c = (brev & 0xf000) == 0x1000 ? 'P' : 'A';
+		snprintf(buf, 8, "%c%03x", c, brev & 0xfff);
+	}
+	return (buf);
+}
+EXPORT_SYMBOL(brcmu_boardrev_str);
+
 #endif				/* defined(DEBUG) */
diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
index 8ba445b..a043e29 100644
--- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h
+++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
@@ -218,4 +218,6 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
 }
 #endif
 
+char *brcmu_boardrev_str(u32 brev, char *buf);
+
 #endif				/* _BRCMU_UTILS_H_ */
-- 
1.9.1


[-- Attachment #3: 0002-brcmsmac-extend-hardware-info-shown-in-debugfs.patch --]
[-- Type: text/plain, Size: 2491 bytes --]

From a197cf44ef058942928b48223fce9d3f112be9d0 Mon Sep 17 00:00:00 2001
From: Arend van Spriel <arend@broadcom.com>
Date: Thu, 13 Nov 2014 14:19:49 +0100
Subject: [PATCH 2/2] brcmsmac: extend hardware info shown in debugfs

The hardware info now also include radio and phy information, which
can be helpful in debugging issues.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 drivers/net/wireless/brcm80211/brcmsmac/debug.c | 40 +++++++++++++++++--------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/debug.c b/drivers/net/wireless/brcm80211/brcmsmac/debug.c
index 19740c1..c9a8b93 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/debug.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/debug.c
@@ -30,6 +30,7 @@
 #include "main.h"
 #include "debug.h"
 #include "brcms_trace_events.h"
+#include "phy/phy_int.h"
 
 static struct dentry *root_folder;
 
@@ -74,20 +75,33 @@ static
 int brcms_debugfs_hardware_read(struct seq_file *s, void *data)
 {
 	struct brcms_pub *drvr = s->private;
+	struct brcms_hardware *hw = drvr->wlc->hw;
+	struct bcma_device *core = hw->d11core;
+	struct bcma_bus *bus = core->bus;
+	char boardrev[10];
 
-	seq_printf(s, "board vendor: %x\n"
-		   "board type: %x\n"
-		   "board revision: %x\n"
-		   "board flags: %x\n"
-		   "board flags2: %x\n"
-		   "firmware revision: %x\n",
-		   drvr->wlc->hw->d11core->bus->boardinfo.vendor,
-		   drvr->wlc->hw->d11core->bus->boardinfo.type,
-		   drvr->wlc->hw->boardrev,
-		   drvr->wlc->hw->boardflags,
-		   drvr->wlc->hw->boardflags2,
-		   drvr->wlc->ucode_rev);
-
+	seq_printf(s, "chipnum 0x%x\n"
+		   "chiprev 0x%x\n"
+		   "chippackage 0x%x\n"
+		   "corerev 0x%x\n"
+		   "boardid 0x%x\n"
+		   "boardvendor 0x%x\n"
+		   "boardrev %s\n"
+		   "boardflags 0x%x\n"
+		   "boardflags2 0x%x\n"
+		   "ucoderev 0x%x\n"
+		   "radiorev 0x%x\n"
+		   "phytype 0x%x\n"
+		   "phyrev 0x%x\n"
+		   "anarev 0x%x\n"
+		   "nvramrev %d\n",
+		   bus->chipinfo.id, bus->chipinfo.rev, bus->chipinfo.pkg,
+		   core->id.rev, bus->boardinfo.type, bus->boardinfo.vendor,
+		   brcmu_boardrev_str(hw->boardrev, boardrev),
+		   drvr->wlc->hw->boardflags, drvr->wlc->hw->boardflags2,
+		   drvr->wlc->ucode_rev, hw->band->radiorev,
+		   hw->band->phytype, hw->band->phyrev, hw->band->pi->ana_rev,
+		   hw->sromrev);
 	return 0;
 }
 
-- 
1.9.1


^ permalink raw reply related

* Re: [PATCH net-next] packet: make packet_snd fail on len smaller than l2 header
From: Willem de Bruijn @ 2014-11-19 18:07 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: Network Development, David Miller, Eric Dumazet
In-Reply-To: <546CD087.9070003@redhat.com>

>> ---
>>   net/packet/af_packet.c | 30 ++++++++++++++++++++++--------
>>   1 file changed, 22 insertions(+), 8 deletions(-)
>>
>> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
>> index 4cd13d8..0d3cb44 100644
>> --- a/net/packet/af_packet.c
>> +++ b/net/packet/af_packet.c
>> @@ -2095,6 +2095,18 @@ static void tpacket_destruct_skb(struct sk_buff
>> *skb)
>>         sock_wfree(skb);
>>   }
>>
>> +static bool ll_header_truncated(int len, struct net_device *dev)
>> +{
>
>
> const struct net_device *dev
>
> [ if at it, I'd perhaps also swap the arg order ]

Thanks, Daniel. I'll resubmit with both changes.

^ permalink raw reply

* [PATCH net-next v2] packet: make packet_snd fail on len smaller than l2 header
From: Willem de Bruijn @ 2014-11-19 18:10 UTC (permalink / raw)
  To: netdev; +Cc: davem, eric.dumazet, dborkman, Willem de Bruijn

From: Willem de Bruijn <willemb@google.com>

When sending packets out with PF_PACKET, SOCK_RAW, ensure that the
packet is at least as long as the device's expected link layer header.
This check already exists in tpacket_snd, but not in packet_snd.
Also rate limit the warning in tpacket_snd.

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 net/packet/af_packet.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4cd13d8..58af5802 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2095,6 +2095,18 @@ static void tpacket_destruct_skb(struct sk_buff *skb)
 	sock_wfree(skb);
 }
 
+static bool ll_header_truncated(const struct net_device *dev, int len)
+{
+	/* net device doesn't like empty head */
+	if (unlikely(len <= dev->hard_header_len)) {
+		net_warn_ratelimited("%s: packet size is too short (%d < %d)\n",
+				     current->comm, len, dev->hard_header_len);
+		return true;
+	}
+
+	return false;
+}
+
 static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
 		void *frame, struct net_device *dev, int size_max,
 		__be16 proto, unsigned char *addr, int hlen)
@@ -2170,12 +2182,8 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
 		if (unlikely(err < 0))
 			return -EINVAL;
 	} else if (dev->hard_header_len) {
-		/* net device doesn't like empty head */
-		if (unlikely(tp_len <= dev->hard_header_len)) {
-			pr_err("packet size is too short (%d < %d)\n",
-			       tp_len, dev->hard_header_len);
+		if (ll_header_truncated(dev, tp_len))
 			return -EINVAL;
-		}
 
 		skb_push(skb, dev->hard_header_len);
 		err = skb_store_bits(skb, 0, data,
@@ -2500,9 +2508,14 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 	skb_set_network_header(skb, reserve);
 
 	err = -EINVAL;
-	if (sock->type == SOCK_DGRAM &&
-	    (offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len)) < 0)
-		goto out_free;
+	if (sock->type == SOCK_DGRAM) {
+		offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len);
+		if (unlikely(offset) < 0)
+			goto out_free;
+	} else {
+		if (ll_header_truncated(dev, len))
+			goto out_free;
+	}
 
 	/* Returns -EFAULT on error */
 	err = skb_copy_datagram_from_iovec(skb, offset, msg->msg_iov, 0, len);
-- 
2.1.0.rc2.206.gedb03e5

^ permalink raw reply related

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
From: David Miller @ 2014-11-19 18:19 UTC (permalink / raw)
  To: dan.carpenter
  Cc: elfring, herbert, steffen.klassert, netdev, linux-kernel,
	kernel-janitors, julia.lawall
In-Reply-To: <20141119101003.GL4905@mwanda>

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 19 Nov 2014 13:10:03 +0300

> I have come to view you as a very clever troll.

+1

^ permalink raw reply

* Re: [PATCH] net: team: expose sysfs attributes for each team option
From: David Miller @ 2014-11-19 18:24 UTC (permalink / raw)
  To: hkadmany; +Cc: jiri, netdev
In-Reply-To: <03067d01f18e264b30f86d0307d11b07.squirrel@www.codeaurora.org>

From: "Hamad Kadmany" <hkadmany@codeaurora.org>
Date: Wed, 19 Nov 2014 12:28:19 -0000

> Using team driver requires using libnl3. In Android based platforms,
> libnl3 is not supported, and libnl3 license poses constraints in
> Android's user-space.
> 
> This is the reason for the this change, to have at least the team
> options exposed through sysfs.

That's a completely and utterly bogus argument for duplicating
functionality in the kernel.  You could more easily write a license
compatible version of whatever userland component you need.

Seriously, this is not our problem.

^ permalink raw reply

* Re: [net-next 07/15] ixgbevf: Change receive model to use double buffered page based receives
From: Alexander Duyck @ 2014-11-19 18:24 UTC (permalink / raw)
  To: Jeff Kirsher, davem; +Cc: Emil Tantilov, netdev, nhorman, sassmann, jogreene
In-Reply-To: <1416370256-16834-8-git-send-email-jeffrey.t.kirsher@intel.com>

There were a few things in this patch that should be addressed.

Comments inline below.

- Alex

On 11/18/2014 08:10 PM, Jeff Kirsher wrote:
> From: Emil Tantilov <emil.s.tantilov@intel.com>
>
> This patch changes the basic receive path for ixgbevf so that instead of
> receiving the data into an skb it is received into a double buffered page.
> The main change is that the receives will be done in pages only and then
> pull the header out of the page and copy it into the sk_buff data.
>
> This has the advantages of reduced cache misses and improved performance on
> IOMMU enabled systems.
>
> CC: Alexander Duyck <alexander.h.duyck@redhat.com>
> Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>   drivers/net/ethernet/intel/ixgbevf/ixgbevf.h      |  24 +-
>   drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 452 +++++++++++++++-------
>   2 files changed, 331 insertions(+), 145 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
> index 72a354b..2362001 100644
> --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
> +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
> @@ -58,8 +58,9 @@ struct ixgbevf_tx_buffer {
>   };
>
>   struct ixgbevf_rx_buffer {
> -	struct sk_buff *skb;
>   	dma_addr_t dma;
> +	struct page *page;
> +	unsigned int page_offset;
>   };
>
>   struct ixgbevf_stats {
> @@ -91,9 +92,10 @@ struct ixgbevf_ring {
>   	void *desc;			/* descriptor ring memory */
>   	dma_addr_t dma;			/* phys. address of descriptor ring */
>   	unsigned int size;		/* length in bytes */
> -	unsigned int count;		/* amount of descriptors */
> -	unsigned int next_to_use;
> -	unsigned int next_to_clean;
> +	u16 count;			/* amount of descriptors */
> +	u16 next_to_use;
> +	u16 next_to_clean;
> +	u16 next_to_alloc;
>
>   	union {
>   		struct ixgbevf_tx_buffer *tx_buffer_info;
> @@ -109,12 +111,11 @@ struct ixgbevf_ring {
>
>   	u64 hw_csum_rx_error;
>   	u8 __iomem *tail;
> +	struct sk_buff *skb;
>
>   	u16 reg_idx; /* holds the special value that gets the hardware register
>   		      * offset associated with this ring, which is different
>   		      * for DCB and RSS modes */
> -
> -	u16 rx_buf_len;
>   	int queue_index; /* needed for multiqueue queue management */
>   };
>
> @@ -133,12 +134,10 @@ struct ixgbevf_ring {
>
>   /* Supported Rx Buffer Sizes */
>   #define IXGBEVF_RXBUFFER_256   256    /* Used for packet split */
> -#define IXGBEVF_RXBUFFER_2K    2048
> -#define IXGBEVF_RXBUFFER_4K    4096
> -#define IXGBEVF_RXBUFFER_8K    8192
> -#define IXGBEVF_RXBUFFER_10K   10240
> +#define IXGBEVF_RXBUFFER_2048	2048
>
>   #define IXGBEVF_RX_HDR_SIZE IXGBEVF_RXBUFFER_256
> +#define IXGBEVF_RX_BUFSZ	IXGBEVF_RXBUFFER_2048
>
>   #define MAXIMUM_ETHERNET_VLAN_SIZE (VLAN_ETH_FRAME_LEN + ETH_FCS_LEN)
>
> @@ -430,11 +429,6 @@ enum ixbgevf_state_t {
>   	__IXGBEVF_WORK_INIT,
>   };
>
> -struct ixgbevf_cb {
> -	struct sk_buff *prev;
> -};
> -#define IXGBE_CB(skb) ((struct ixgbevf_cb *)(skb)->cb)
> -
>   enum ixgbevf_boards {
>   	board_82599_vf,
>   	board_X540_vf,
> diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> index 20bebd2..2ca7c96 100644
> --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> @@ -422,8 +422,7 @@ static void ixgbevf_process_skb_fields(struct ixgbevf_ring *rx_ring,
>    * that this is in fact a non-EOP buffer.
>    **/
>   static bool ixgbevf_is_non_eop(struct ixgbevf_ring *rx_ring,
> -			       union ixgbe_adv_rx_desc *rx_desc,
> -			       struct sk_buff *skb)
> +			       union ixgbe_adv_rx_desc *rx_desc)
>   {
>   	u32 ntc = rx_ring->next_to_clean + 1;
>
> @@ -439,37 +438,40 @@ static bool ixgbevf_is_non_eop(struct ixgbevf_ring *rx_ring,
>   	return true;
>   }
>
> -static bool ixgbevf_alloc_mapped_skb(struct ixgbevf_ring *rx_ring,
> -				     struct ixgbevf_rx_buffer *bi)
> +static bool ixgbevf_alloc_mapped_page(struct ixgbevf_ring *rx_ring,
> +				      struct ixgbevf_rx_buffer *bi)
>   {
> -	struct sk_buff *skb = bi->skb;
> +	struct page *page = bi->page;
>   	dma_addr_t dma = bi->dma;
>
> -	if (unlikely(skb))
> +	/* since we are recycling buffers we should seldom need to alloc */
> +	if (likely(page))
>   		return true;
>
> -	skb = netdev_alloc_skb_ip_align(rx_ring->netdev,
> -					rx_ring->rx_buf_len);
> -	if (unlikely(!skb)) {
> -		rx_ring->rx_stats.alloc_rx_buff_failed++;
> +	/* alloc new page for storage */
> +	page = dev_alloc_page();
> +	if (unlikely(!page)) {
> +		rx_ring->rx_stats.alloc_rx_page_failed++;
>   		return false;
>   	}
>
> -	dma = dma_map_single(rx_ring->dev, skb->data,
> -			     rx_ring->rx_buf_len, DMA_FROM_DEVICE);
> +	/* map page for use */
> +	dma = dma_map_page(rx_ring->dev, page, 0,
> +			   PAGE_SIZE, DMA_FROM_DEVICE);
>
>   	/* if mapping failed free memory back to system since
>   	 * there isn't much point in holding memory we can't use
>   	 */
>   	if (dma_mapping_error(rx_ring->dev, dma)) {
> -		dev_kfree_skb_any(skb);
> +		__free_page(page);
>
>   		rx_ring->rx_stats.alloc_rx_buff_failed++;
>   		return false;
>   	}
>
> -	bi->skb = skb;
>   	bi->dma = dma;
> +	bi->page = page;
> +	bi->page_offset = 0;
>
>   	return true;
>   }
> @@ -495,13 +497,13 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,
>   	i -= rx_ring->count;
>
>   	do {
> -		if (!ixgbevf_alloc_mapped_skb(rx_ring, bi))
> +		if (!ixgbevf_alloc_mapped_page(rx_ring, bi))
>   			break;
>
>   		/* Refresh the desc even if pkt_addr didn't change
>   		 * because each write-back erases this info.
>   		 */
> -		rx_desc->read.pkt_addr = cpu_to_le64(bi->dma);
> +		rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + bi->page_offset);
>
>   		rx_desc++;
>   		bi++;
> @@ -524,6 +526,9 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,
>   		/* record the next descriptor to use */
>   		rx_ring->next_to_use = i;
>
> +		/* update next to alloc since we have filled the ring */
> +		rx_ring->next_to_alloc = i;
> +
>   		/* Force memory writes to complete before letting h/w
>   		 * know there are new descriptors to fetch.  (Only
>   		 * applicable for weak-ordered memory model archs,
> @@ -534,6 +539,257 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,
>   	}
>   }
>
> +/* ixgbevf_pull_tail - ixgbevf specific version of skb_pull_tail
> + * @rx_ring: Rx descriptor ring packet is being transacted on
> + * @skb: pointer to current skb being adjusted
> + *
> + * This function is an ixgbevf specific version of __pskb_pull_tail.  The
> + * main difference between this version and the original function is that
> + * this function can make several assumptions about the state of things
> + * that allow for significant optimizations versus the standard function.
> + * As a result we can do things like drop a frag and maintain an accurate
> + * truesize for the skb.
> + */
> +static void ixgbevf_pull_tail(struct ixgbevf_ring *rx_ring,
> +			      struct sk_buff *skb)
> +{
> +	struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[0];
> +	unsigned char *va;
> +	unsigned int pull_len;
> +
> +	/* it is valid to use page_address instead of kmap since we are
> +	 * working with pages allocated out of the lomem pool per
> +	 * alloc_page(GFP_ATOMIC)
> +	 */
> +	va = skb_frag_address(frag);
> +
> +	/* we need the header to contain the greater of either ETH_HLEN or
> +	 * 60 bytes if the skb->len is less than 60 for skb_pad.
> +	 */
> +	pull_len = eth_get_headlen(va, IXGBEVF_RX_HDR_SIZE);
> +
> +	/* align pull length to size of long to optimize memcpy performance */
> +	skb_copy_to_linear_data(skb, va, ALIGN(pull_len, sizeof(long)));
> +
> +	/* update all of the pointers */
> +	skb_frag_size_sub(frag, pull_len);
> +	frag->page_offset += pull_len;
> +	skb->data_len -= pull_len;
> +	skb->tail += pull_len;
> +}

I really think we should look at making this into a generic function. 
Maybe I will submit something later today to get a common function 
placed in the code.  Maybe something like eth_pull_tail.

> +/* ixgbevf_cleanup_headers - Correct corrupted or empty headers
> + * @rx_ring: Rx descriptor ring packet is being transacted on
> + * @rx_desc: pointer to the EOP Rx descriptor
> + * @skb: pointer to current skb being fixed
> + *
> + * Check for corrupted packet headers caused by senders on the local L2
> + * embedded NIC switch not setting up their Tx Descriptors right.  These
> + * should be very rare.
> + *
> + * Also address the case where we are pulling data in on pages only
> + * and as such no data is present in the skb header.
> + *
> + * In addition if skb is not at least 60 bytes we need to pad it so that
> + * it is large enough to qualify as a valid Ethernet frame.
> + *
> + * Returns true if an error was encountered and skb was freed.
> + */
> +static bool ixgbevf_cleanup_headers(struct ixgbevf_ring *rx_ring,
> +				    union ixgbe_adv_rx_desc *rx_desc,
> +				    struct sk_buff *skb)
> +{
> +	/* verify that the packet does not have any known errors */
> +	if (unlikely(ixgbevf_test_staterr(rx_desc,
> +					  IXGBE_RXDADV_ERR_FRAME_ERR_MASK))) {
> +		struct net_device *netdev = rx_ring->netdev;
> +
> +		if (!(netdev->features & NETIF_F_RXALL)) {
> +			dev_kfree_skb_any(skb);
> +			return true;
> +		}
> +	}
> +
> +	/* place header in linear portion of buffer */
> +	if (skb_is_nonlinear(skb))
> +		ixgbevf_pull_tail(rx_ring, skb);
> +
> +	/* if skb_pad returns an error the skb was freed */
> +	if (unlikely(skb->len < 60)) {
> +		int pad_len = 60 - skb->len;
> +
> +		if (skb_pad(skb, pad_len))
> +			return true;
> +		__skb_put(skb, pad_len);
> +	}
> +
> +	return false;
> +}

The same goes for the padding bit here.  Maybe something like eth_skb_pad.

> +/* ixgbevf_reuse_rx_page - page flip buffer and store it back on the ring
> + * @rx_ring: Rx descriptor ring to store buffers on
> + * @old_buff: donor buffer to have page reused
> + *
> + * Synchronizes page for reuse by the adapter
> + */
> +static void ixgbevf_reuse_rx_page(struct ixgbevf_ring *rx_ring,
> +				  struct ixgbevf_rx_buffer *old_buff)
> +{
> +	struct ixgbevf_rx_buffer *new_buff;
> +	u16 nta = rx_ring->next_to_alloc;
> +
> +	new_buff = &rx_ring->rx_buffer_info[nta];
> +
> +	/* update, and store next to alloc */
> +	nta++;
> +	rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
> +
> +	/* transfer page from old buffer to new buffer */
> +	new_buff->page = old_buff->page;
> +	new_buff->dma = old_buff->dma;
> +	new_buff->page_offset = old_buff->page_offset;
> +
> +	/* sync the buffer for use by the device */
> +	dma_sync_single_range_for_device(rx_ring->dev, new_buff->dma,
> +					 new_buff->page_offset,
> +					 IXGBEVF_RX_BUFSZ,
> +					 DMA_FROM_DEVICE);
> +}
> +
> +/* ixgbevf_add_rx_frag - Add contents of Rx buffer to sk_buff
> + * @rx_ring: Rx descriptor ring to transact packets on
> + * @rx_buffer: buffer containing page to add
> + * @rx_desc: descriptor containing length of buffer written by hardware
> + * @skb: sk_buff to place the data into
> + *
> + * This function will add the data contained in rx_buffer->page to the skb.
> + * This is done either through a direct copy if the data in the buffer is
> + * less than the skb header size, otherwise it will just attach the page as
> + * a frag to the skb.
> + *
> + * The function will then update the page offset if necessary and return
> + * true if the buffer can be reused by the adapter.
> + */
> +static bool ixgbevf_add_rx_frag(struct ixgbevf_ring *rx_ring,
> +				struct ixgbevf_rx_buffer *rx_buffer,
> +				union ixgbe_adv_rx_desc *rx_desc,
> +				struct sk_buff *skb)
> +{
> +	struct page *page = rx_buffer->page;
> +	unsigned int size = le16_to_cpu(rx_desc->wb.upper.length);
> +#if (PAGE_SIZE < 8192)
> +	unsigned int truesize = IXGBEVF_RX_BUFSZ;
> +#else
> +	unsigned int truesize = ALIGN(size, L1_CACHE_BYTES);
> +#endif
> +
> +	if ((size <= IXGBEVF_RX_HDR_SIZE) && !skb_is_nonlinear(skb)) {
> +		unsigned char *va = page_address(page) + rx_buffer->page_offset;
> +
> +		memcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long)));
> +
> +		/* we can reuse buffer as-is, just make sure it is local */
> +		if (likely(page_to_nid(page) == numa_node_id()))
> +			return true;
> +
> +		/* this page cannot be reused so discard it */
> +		put_page(page);
> +		return false;
> +	}
> +
> +	skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
> +			rx_buffer->page_offset, size, truesize);
> +
> +	/* avoid re-using remote pages */
> +	if (unlikely(page_to_nid(page) != numa_node_id()))
> +		return false;
> +

This is missing the pfmemalloc fix that is already in igb, and that I 
submitted for ixgbe and fm10k.


> +#if (PAGE_SIZE < 8192)
> +	/* if we are only owner of page we can reuse it */
> +	if (unlikely(page_count(page) != 1))
> +		return false;
> +
> +	/* flip page offset to other buffer */
> +	rx_buffer->page_offset ^= IXGBEVF_RX_BUFSZ;
> +
> +	/* since we are the only owner of the page and we need to
> +	 * increment it.
> +	 */
> +	atomic_inc(&page->_count);
> +#else
> +	/* move offset up to the next cache line */
> +	rx_buffer->page_offset += truesize;
> +
> +	if (rx_buffer->page_offset > (PAGE_SIZE - IXGBEVF_RX_BUFSZ))
> +		return false;
> +
> +	/* bump ref count on page before it is given to the stack */
> +	get_page(page);
> +#endif
> +
> +	return true;
> +}

The get_page and atomic_inc calls can be pulled out and placed after if 
#if/else logic.  The preference is to use atomic_inc since you are using 
an order 0 page and don't need to check for PageTail().

> +static struct sk_buff *ixgbevf_fetch_rx_buffer(struct ixgbevf_ring *rx_ring,
> +					       union ixgbe_adv_rx_desc *rx_desc,
> +					       struct sk_buff *skb)
> +{
> +	struct ixgbevf_rx_buffer *rx_buffer;
> +	struct page *page;
> +
> +	rx_buffer = &rx_ring->rx_buffer_info[rx_ring->next_to_clean];
> +	page = rx_buffer->page;
> +	prefetchw(page);
> +
> +	if (likely(!skb)) {
> +		void *page_addr = page_address(page) +
> +				  rx_buffer->page_offset;
> +
> +		/* prefetch first cache line of first page */
> +		prefetch(page_addr);
> +#if L1_CACHE_BYTES < 128
> +		prefetch(page_addr + L1_CACHE_BYTES);
> +#endif
> +
> +		/* allocate a skb to store the frags */
> +		skb = netdev_alloc_skb_ip_align(rx_ring->netdev,
> +						IXGBEVF_RX_HDR_SIZE);
> +		if (unlikely(!skb)) {
> +			rx_ring->rx_stats.alloc_rx_buff_failed++;
> +			return NULL;
> +		}
> +
> +		/* we will be copying header into skb->data in
> +		 * pskb_may_pull so it is in our interest to prefetch
> +		 * it now to avoid a possible cache miss
> +		 */
> +		prefetchw(skb->data);
> +	}
> +
> +	/* we are reusing so sync this buffer for CPU use */
> +	dma_sync_single_range_for_cpu(rx_ring->dev,
> +				      rx_buffer->dma,
> +				      rx_buffer->page_offset,
> +				      IXGBEVF_RX_BUFSZ,
> +				      DMA_FROM_DEVICE);
> +
> +	/* pull page into skb */
> +	if (ixgbevf_add_rx_frag(rx_ring, rx_buffer, rx_desc, skb)) {
> +		/* hand second half of page back to the ring */
> +		ixgbevf_reuse_rx_page(rx_ring, rx_buffer);
> +	} else {
> +		/* we are not reusing the buffer so unmap it */
> +		dma_unmap_page(rx_ring->dev, rx_buffer->dma,
> +			       PAGE_SIZE, DMA_FROM_DEVICE);
> +	}
> +
> +	/* clear contents of buffer_info */
> +	rx_buffer->dma = 0;
> +	rx_buffer->page = NULL;
> +
> +	return skb;
> +}
> +
>   static inline void ixgbevf_irq_enable_queues(struct ixgbevf_adapter *adapter,
>   					     u32 qmask)
>   {

<snip>

> @@ -3320,21 +3522,11 @@ static int ixgbevf_set_mac(struct net_device *netdev, void *p)
>   static int ixgbevf_change_mtu(struct net_device *netdev, int new_mtu)
>   {
>   	struct ixgbevf_adapter *adapter = netdev_priv(netdev);
> +	struct ixgbe_hw *hw = &adapter->hw;
>   	int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
> -	int max_possible_frame = MAXIMUM_ETHERNET_VLAN_SIZE;
> -
> -	switch (adapter->hw.api_version) {
> -	case ixgbe_mbox_api_11:
> -		max_possible_frame = IXGBE_MAX_JUMBO_FRAME_SIZE;
> -		break;
> -	default:
> -		if (adapter->hw.mac.type == ixgbe_mac_X540_vf)
> -			max_possible_frame = IXGBE_MAX_JUMBO_FRAME_SIZE;
> -		break;
> -	}
>
>   	/* MTU < 68 is an error and causes problems on some kernels */
> -	if ((new_mtu < 68) || (max_frame > max_possible_frame))
> +	if ((new_mtu < 68) || (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE))
>   		return -EINVAL;
>
>   	hw_dbg(&adapter->hw, "changing MTU from %d to %d\n",

This is wrong.  You are still limited by the PF so if it is a version 
1.0 mailbox on an 82599 you cannot enable jumbo frames.  Yes you can 
support it but the PF won't let you do it.

> @@ -3342,8 +3534,8 @@ static int ixgbevf_change_mtu(struct net_device *netdev, int new_mtu)
>   	/* must set new MTU before calling down or up */
>   	netdev->mtu = new_mtu;
>
> -	if (netif_running(netdev))
> -		ixgbevf_reinit_locked(adapter);
> +	/* notify the PF of our intent to use this size of frame */
> +	ixgbevf_rlpml_set_vf(hw, max_frame);
>
>   	return 0;
>   }
>

This is the reason why the change is wrong.  If the mailbox api is 
version 1.0 you cannot support jumbo frames so ixgbevf_rlmpl_set_vf will 
return an error via the mailbox indicating that the message is not 
supported.

^ permalink raw reply

* Re: [PATCH net-next v2] packet: make packet_snd fail on len smaller than l2 header
From: Eric Dumazet @ 2014-11-19 18:25 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: netdev, davem, dborkman
In-Reply-To: <1416420616-5029-1-git-send-email-willemb@google.com>

On Wed, 2014-11-19 at 13:10 -0500, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> When sending packets out with PF_PACKET, SOCK_RAW, ensure that the
> packet is at least as long as the device's expected link layer header.
> This check already exists in tpacket_snd, but not in packet_snd.
> Also rate limit the warning in tpacket_snd.
> 
> Signed-off-by: Willem de Bruijn <willemb@google.com>
> ---

Acked-by: Eric Dumazet <edumazet@google.com>

Thanks Willem

^ permalink raw reply

* Re: [PATCH] net: team: expose sysfs attributes for each team option
From: David Miller @ 2014-11-19 18:26 UTC (permalink / raw)
  To: jiri; +Cc: hkadmany, netdev
In-Reply-To: <20141119124043.GC1926@nanopsycho.orion>

From: Jiri Pirko <jiri@resnulli.us>
Date: Wed, 19 Nov 2014 13:40:43 +0100

> No, that is certainly not the reason. If libnl3 does not suit you, use a
> different lib. It is in my opinion unacceptaptable to work around
> certain licence issues by adding parallel sysfs api (not to mention that
> sysfs is totally unsuitable for that).
> 
> You should use existing Netlink API. That's it.

+1, these arguments for adding sysfs attributes are unacceptable.

^ permalink raw reply

* [PATCH net-next 0/2] net: systemport & bcmgenet instrumenting
From: Florian Fainelli @ 2014-11-19 18:29 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Hi David,

These two patches add similar instrumenting in the driver by logging RX SKB
allocation failures as well as RX & TX DMA mapping failures in order to help
troubleshoot heavy memory pressure conditions.

Thanks!

Florian Fainelli (2):
  net: systemport: log RX buffer allocation and RX/TX DMA failures
  net: bcmgenet: log RX buffer allocation and RX/TX dma failures

 drivers/net/ethernet/broadcom/bcmsysport.c     | 10 +++++++++-
 drivers/net/ethernet/broadcom/bcmsysport.h     |  3 +++
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 +++++++++-
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |  3 +++
 4 files changed, 24 insertions(+), 2 deletions(-)

-- 
1.9.1

^ permalink raw reply

* [PATCH net-next 1/2] net: systemport: log RX buffer allocation and RX/TX DMA failures
From: Florian Fainelli @ 2014-11-19 18:29 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli
In-Reply-To: <1416421796-27657-1-git-send-email-f.fainelli@gmail.com>

To help troubleshoot heavy memory pressure conditions, add a bunch of
statistics counter to log RX buffer allocation and RX/TX DMA mapping
failures. These are reported like any other counters through the ethtool
stats interface.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 10 +++++++++-
 drivers/net/ethernet/broadcom/bcmsysport.h |  3 +++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 3cb241155dac..c1d255972dae 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -274,6 +274,9 @@ static const struct bcm_sysport_stats bcm_sysport_gstrings_stats[] = {
 	/* RBUF misc statistics */
 	STAT_RBUF("rbuf_ovflow_cnt", mib.rbuf_ovflow_cnt, RBUF_OVFL_DISC_CNTR),
 	STAT_RBUF("rbuf_err_cnt", mib.rbuf_err_cnt, RBUF_ERR_PKT_CNTR),
+	STAT_MIB_RX("alloc_rx_buff_failed", mib.alloc_rx_buff_failed),
+	STAT_MIB_RX("rx_dma_failed", mib.rx_dma_failed),
+	STAT_MIB_TX("tx_dma_failed", mib.tx_dma_failed),
 };
 
 #define BCM_SYSPORT_STATS_LEN	ARRAY_SIZE(bcm_sysport_gstrings_stats)
@@ -477,6 +480,7 @@ static int bcm_sysport_rx_refill(struct bcm_sysport_priv *priv,
 				 RX_BUF_LENGTH, DMA_FROM_DEVICE);
 	ret = dma_mapping_error(kdev, mapping);
 	if (ret) {
+		priv->mib.rx_dma_failed++;
 		bcm_sysport_free_cb(cb);
 		netif_err(priv, rx_err, ndev, "DMA mapping failure\n");
 		return ret;
@@ -526,6 +530,7 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
 	unsigned int p_index;
 	u16 len, status;
 	struct bcm_rsb *rsb;
+	int ret;
 
 	/* Determine how much we should process since last call */
 	p_index = rdma_readl(priv, RDMA_PROD_INDEX);
@@ -620,7 +625,9 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
 
 		napi_gro_receive(&priv->napi, skb);
 refill:
-		bcm_sysport_rx_refill(priv, cb);
+		ret = bcm_sysport_rx_refill(priv, cb);
+		if (ret)
+			priv->mib.alloc_rx_buff_failed++;
 	}
 
 	return processed;
@@ -973,6 +980,7 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
 
 	mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
 	if (dma_mapping_error(kdev, mapping)) {
+		priv->mib.tx_dma_failed++;
 		netif_err(priv, tx_err, dev, "DMA map failed at %p (len=%d)\n",
 			  skb->data, skb_len);
 		ret = NETDEV_TX_OK;
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h
index b08dab828101..fc19417d82a5 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.h
+++ b/drivers/net/ethernet/broadcom/bcmsysport.h
@@ -557,6 +557,9 @@ struct bcm_sysport_mib {
 	u32 rxchk_other_pkt_disc;
 	u32 rbuf_ovflow_cnt;
 	u32 rbuf_err_cnt;
+	u32 alloc_rx_buff_failed;
+	u32 rx_dma_failed;
+	u32 tx_dma_failed;
 };
 
 /* HW maintains a large list of counters */
-- 
1.9.1

^ permalink raw reply related

* [PATCH net-next 2/2] net: bcmgenet: log RX buffer allocation and RX/TX dma failures
From: Florian Fainelli @ 2014-11-19 18:29 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli
In-Reply-To: <1416421796-27657-1-git-send-email-f.fainelli@gmail.com>

To help troubleshoot heavy memory pressure conditions, add a bunch of
statistics counter to log RX buffer allocation and RX/TX DMA mapping
failures. These are reported like any other counters through the ethtool
stats interface.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 +++++++++-
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |  3 +++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index da1a2500c91c..fcbf1255ae5a 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -613,6 +613,9 @@ static const struct bcmgenet_stats bcmgenet_gstrings_stats[] = {
 			UMAC_RBUF_OVFL_CNT),
 	STAT_GENET_MISC("rbuf_err_cnt", mib.rbuf_err_cnt, UMAC_RBUF_ERR_CNT),
 	STAT_GENET_MISC("mdf_err_cnt", mib.mdf_err_cnt, UMAC_MDF_ERR_CNT),
+	STAT_GENET_MIB_RX("alloc_rx_buff_failed", mib.alloc_rx_buff_failed),
+	STAT_GENET_MIB_RX("rx_dma_failed", mib.rx_dma_failed),
+	STAT_GENET_MIB_TX("tx_dma_failed", mib.tx_dma_failed),
 };
 
 #define BCMGENET_STATS_LEN	ARRAY_SIZE(bcmgenet_gstrings_stats)
@@ -989,6 +992,7 @@ static int bcmgenet_xmit_single(struct net_device *dev,
 	mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
 	ret = dma_mapping_error(kdev, mapping);
 	if (ret) {
+		priv->mib.tx_dma_failed++;
 		netif_err(priv, tx_err, dev, "Tx DMA map failed\n");
 		dev_kfree_skb(skb);
 		return ret;
@@ -1035,6 +1039,7 @@ static int bcmgenet_xmit_frag(struct net_device *dev,
 				   skb_frag_size(frag), DMA_TO_DEVICE);
 	ret = dma_mapping_error(kdev, mapping);
 	if (ret) {
+		priv->mib.tx_dma_failed++;
 		netif_err(priv, tx_err, dev, "%s: Tx DMA map failed\n",
 			  __func__);
 		return ret;
@@ -1231,6 +1236,7 @@ static int bcmgenet_rx_refill(struct bcmgenet_priv *priv, struct enet_cb *cb)
 				 priv->rx_buf_len, DMA_FROM_DEVICE);
 	ret = dma_mapping_error(kdev, mapping);
 	if (ret) {
+		priv->mib.rx_dma_failed++;
 		bcmgenet_free_cb(cb);
 		netif_err(priv, rx_err, priv->dev,
 			  "%s DMA map failed\n", __func__);
@@ -1397,8 +1403,10 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_priv *priv,
 		/* refill RX path on the current control block */
 refill:
 		err = bcmgenet_rx_refill(priv, cb);
-		if (err)
+		if (err) {
+			priv->mib.alloc_rx_buff_failed++;
 			netif_err(priv, rx_err, dev, "Rx refill failed\n");
+		}
 
 		rxpktprocessed++;
 		priv->rx_read_ptr++;
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
index 31b2da5f9b82..c4ca7282a601 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
@@ -143,6 +143,9 @@ struct bcmgenet_mib_counters {
 	u32	rbuf_ovflow_cnt;
 	u32	rbuf_err_cnt;
 	u32	mdf_err_cnt;
+	u32	alloc_rx_buff_failed;
+	u32	rx_dma_failed;
+	u32	tx_dma_failed;
 };
 
 #define UMAC_HD_BKP_CTRL		0x004
-- 
1.9.1

^ permalink raw reply related

* Re: [PATCH net-next v2] packet: make packet_snd fail on len smaller than l2 header
From: Daniel Borkmann @ 2014-11-19 18:31 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: netdev, davem, eric.dumazet
In-Reply-To: <1416420616-5029-1-git-send-email-willemb@google.com>

On 11/19/2014 07:10 PM, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
>
> When sending packets out with PF_PACKET, SOCK_RAW, ensure that the
> packet is at least as long as the device's expected link layer header.
> This check already exists in tpacket_snd, but not in packet_snd.
> Also rate limit the warning in tpacket_snd.
>
> Signed-off-by: Willem de Bruijn <willemb@google.com>

Looks good to me, thanks!

Acked-by: Daniel Borkmann <dborkman@redhat.com>

^ permalink raw reply

* Re: [PATCH] net: team: expose sysfs attributes for each team option
From: Cong Wang @ 2014-11-19 18:45 UTC (permalink / raw)
  To: Hamad Kadmany; +Cc: Jiri Pirko, netdev
In-Reply-To: <03067d01f18e264b30f86d0307d11b07.squirrel@www.codeaurora.org>

On Wed, Nov 19, 2014 at 4:28 AM, Hamad Kadmany <hkadmany@codeaurora.org> wrote:
> On Mon, November 17, 2014 1:02 pm, Jiri Pirko wrote:
>>
>> Nak.
>>
>> I don't like this patch. The plan for team was keep things simple and to
>> have single userspace api using netlink, as that is the correct way to
>> deal with things. Sysfs for this use-case is not. Please, use netlink api.
>
> Using team driver requires using libnl3. In Android based platforms, libnl3 is not supported, and libnl3 license poses constraints in Android's user-space.
>

Check if libmnl fits your license:
http://www.netfilter.org/projects/libmnl/

^ permalink raw reply


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