Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH 3.8-stable] usbnet: smsc95xx: fix suspend failure
From: David Miller @ 2013-03-04 18:56 UTC (permalink / raw)
  To: ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw
  Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, oneukum-l3A5Bk7waGM,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	stable-u79uwXL29TY76Z2rM5mHXA,
	steve.glendinning-nksJyM/082jR7s880joybQ
In-Reply-To: <1362391633-27551-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

From: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Date: Mon,  4 Mar 2013 18:07:13 +0800

> The three below functions:
> 
>         smsc95xx_enter_suspend0()
>         smsc95xx_enter_suspend1()
>         smsc95xx_enter_suspend2()
> 
> return > 0 in case of success, so they will cause smsc95xx_suspend()
> to return > 0 and suspend failure.
> 
> This patch is backported from the upstream commit:
> 
> 	From 7643721471117d5f62ca36f328d3dc8d84af4402 Mon Sep 17 00:00:00 2001
> 	Subject: [PATCH] usbnet: smsc95xx: fix suspend failure
> 
> Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
> Cc: Steve Glendinning <steve.glendinning-nksJyM/082jR7s880joybQ@public.gmane.org>
> Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

This is fine, Greg please apply to 3.8-stable, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* RE: [PATCH] net/rds: using strlcpy instead of strncpy
From: Ben Hutchings @ 2013-03-04 18:34 UTC (permalink / raw)
  To: David Laight
  Cc: Chen Gang, venkat.x.venkatsubra, David Miller, rds-devel, netdev
In-Reply-To: <1362421944.2956.15.camel@bwh-desktop.uk.solarflarecom.com>

On Mon, 2013-03-04 at 18:32 +0000, Ben Hutchings wrote:
> On Thu, 2013-02-28 at 09:36 +0000, David Laight wrote:
> > >   when src strlen is sizeof(ctr.name) - 1, the dest str is not '\0' end.
> > >   better use strlcpy instead.
> > > 
> > > Signed-off-by: Chen Gang <gang.chen@asianux.com>
> > > ---
> > >  net/rds/stats.c |    2 +-
> > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/net/rds/stats.c b/net/rds/stats.c
> > > index 7be790d..b9ac1df 100644
> > > --- a/net/rds/stats.c
> > > +++ b/net/rds/stats.c
> > > @@ -86,7 +86,7 @@ void rds_stats_info_copy(struct rds_info_iterator *iter,
> > > 
> > >  	for (i = 0; i < nr; i++) {
> > >  		BUG_ON(strlen(names[i]) >= sizeof(ctr.name));
> > > -		strncpy(ctr.name, names[i], sizeof(ctr.name) - 1);
> > > +		strlcpy(ctr.name, names[i], sizeof(ctr.name));
> > >  		ctr.value = values[i];
> > > 
> > 
> > If the target buffer ends up being copied to userspace that
> > might lead to random kernel memory being leaked.
> 
> Seems it is.  The last byte of 'name' is not currently initialised and
> therefore is already leaked to userland.
> 
> But it's OK because rds_info_copy() uses memcpy() not __copy_to_user(),
> so SMAP will block this leak. :-)

Or not, as kmap() presumably evades that.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply

* RE: [PATCH] net/rds: using strlcpy instead of strncpy
From: Ben Hutchings @ 2013-03-04 18:32 UTC (permalink / raw)
  To: David Laight
  Cc: Chen Gang, venkat.x.venkatsubra, David Miller, rds-devel, netdev
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B716D@saturn3.aculab.com>

On Thu, 2013-02-28 at 09:36 +0000, David Laight wrote:
> >   when src strlen is sizeof(ctr.name) - 1, the dest str is not '\0' end.
> >   better use strlcpy instead.
> > 
> > Signed-off-by: Chen Gang <gang.chen@asianux.com>
> > ---
> >  net/rds/stats.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/net/rds/stats.c b/net/rds/stats.c
> > index 7be790d..b9ac1df 100644
> > --- a/net/rds/stats.c
> > +++ b/net/rds/stats.c
> > @@ -86,7 +86,7 @@ void rds_stats_info_copy(struct rds_info_iterator *iter,
> > 
> >  	for (i = 0; i < nr; i++) {
> >  		BUG_ON(strlen(names[i]) >= sizeof(ctr.name));
> > -		strncpy(ctr.name, names[i], sizeof(ctr.name) - 1);
> > +		strlcpy(ctr.name, names[i], sizeof(ctr.name));
> >  		ctr.value = values[i];
> > 
> 
> If the target buffer ends up being copied to userspace that
> might lead to random kernel memory being leaked.

Seems it is.  The last byte of 'name' is not currently initialised and
therefore is already leaked to userland.

But it's OK because rds_info_copy() uses memcpy() not __copy_to_user(),
so SMAP will block this leak. :-)

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply

* Re: [RFC PATCH 0/5] net: low latency Ethernet device polling
From: Stephen Hemminger @ 2013-03-04 17:19 UTC (permalink / raw)
  To: Eliezer Tamir
  Cc: linux-kernel, netdev, Dave Miller, Jesse Brandeburg, e1000-devel,
	Willem de Bruijn, Andi Kleen, HPA, Eliezer Tamir
In-Reply-To: <20130227175549.10611.82188.stgit@gitlad.jf.intel.com>

On Wed, 27 Feb 2013 09:55:49 -0800
Eliezer Tamir <eliezer.tamir@linux.jf.intel.com> wrote:

> This patchset adds the ability for the socket layer code to poll directly 
> on an Ethernet device's RX queue. This eliminates the cost of the interrupt
> and context switch and with proper tuning allows us to get very close
> to the HW latency.
> 
> This is a follow up to Jesse Brandeburg's Kernel Plumbers talk from last year
> http://www.linuxplumbersconf.org/2012/wp-content/uploads/2012/09/2012-lpc-Low-Latency-Sockets-slides-brandeburg.pdf
> 
> Patch 1 adds ndo_ll_poll and the IP code to use it.
> Patch 2 is an example of how TCP can use ndo_ll_poll.
> Patch 3 shows how this method would be implemented for the ixgbe driver.
> Patch 4 adds statistics to the ixgbe driver for ndo_ll_poll events.
> (Optional) Patch 5 is a handy kprobes module to measure detailed latency 
> numbers.
> 
> this patchset is also available in the following git branch
> git://github.com/jbrandeb/lls.git rfc
> 
> Performance numbers:
> Kernel   Config     C3/6  rx-usecs  TCP  UDP
> 3.8rc6   typical    off   adaptive  37k  40k
> 3.8rc6   typical    off   0*        50k  56k
> 3.8rc6   optimized  off   0*        61k  67k
> 3.8rc6   optimized  on    adaptive  26k  29k
> patched  typical    off   adaptive  70k  78k
> patched  optimized  off   adaptive  79k  88k
> patched  optimized  off   100       84k  92k
> patched  optimized  on    adaptive  83k  91k
> *rx-usecs=0 is usually not useful in a production environment.
> 
> Notice that the patched kernel gives good results even with no tweaking.
> Performance for the default configuration is up by almost 100%,
> tuning will get you another 14%. Comparing best-case performance
> patched vs. unpatched, we are up 36%.
> 
> Test setup details:
> Machines: each with two Intel Xeon 2680 CPUs and X520 (82599) optical NICs
> Tests: Netperf tcp_rr and udp_rr, 1 byte (round trips per second)
> Kernel: unmodified 3.8rc6 and patched 3.8rc6
> Config: typical is derived from RH6.2, optimized is a stripped down config
> Interrupt coalescing (ethtool rx-usecs) settings: 0=off, 1=adaptive, 100 us
> C3/6 states were turned on and off through BIOS.
> When C states were on the performance governor was used.
> 
> Design:
> Pointers to a napi_struct were added both to struct sk_buff and struct sk.
> These are used to track which NAPI we need to poll for a specific socket.
> (more about this in the open issues section)
> The device driver marks every incoming skb.
> This info is propagated to the sk when an skb is added to the socket queue.
> When the socket code does not find any more data on the socket queue,
> it now may call ndo_ll_poll which will crank the device's rx queue and feed
> incoming packets to the stack directly from the context of the socket.
> A sysctl value (net.ipv4.ip_low_latency_poll) controls how many cycles we 
> busy-wait before giving up. (setting to 0 globally disables busy-polling)
> 
> Locking: 
> Since what needs to be locked between a device's NAPI poll and ndo_ll_poll,
> is highly device / configuration dependent, we do this inside the
> Ethernet driver. For example, when packets for high priority connections
> are sent to separate rx queues, you might not need locking at all.
> For ixgbe we only lock the RX queue.
> ndo_ll_poll does not touch the interrupt state or the TX queues.
> (earlier versions of this patchset did touch them,
> but this design is simpler and works better.)
> Ndo_ll_poll is called with local BHs disabled. 
> 
> If a queue is actively polled by a socket (on another CPU) napi poll
> will not service it, but will wait until the queue can be locked 
> and cleaned before doing a napi_complete().
> If a socket can't lock the queue because another CPU has it,
> either from NAPI or from another socket polling on it,
> the socket code can busy wait on the socket's skb queue.
> Ndo_ll_poll does not have preferential treatment for the data from the
> calling socket vs. data from others, so if another CPU is polling,
> you will see your data on this socket's queue when it arrives.
> 
> Open issues:
> 1. Find a way to avoid the need to change the sk and skb structs.
> One big disadvantage of how we do this right now is that when a device is
> removed, it's hard to prevent it from getting polled by a socket
> which holds a stale reference. 
> 
> 2. How do we decide which sockets are eligible to do busy polling?
> Do we add a socket option to control this?
> How do we provide sane defaults while allowing flexibility and performance?
> 
> 3. Andi Kleen and HPA pointed out that using get_cycles() is not portable.
> 
> 4. How and where do we call ndo_ll_poll from the socket code?
> One good place seems to be wherever the kernel puts the process to sleep,
> waiting for more data, but this makes doing something intelligent about
> poll (the system call) hard. From the perspective of how ndo_ll_poll
> itself is implemented this does not seem to matter.
> 
> 5. I would like to hear suggestions on naming conventions and where
> to put the code that for now I have put in include/net/ll_poll.h 
> 
> How to test:
> 1. The patchset should apply cleanly to either net  or Linux 3.8 
> (don't forget to configure INET_LL_RX_POLL and INET_LL_TCP_POLL).
> 
> 2. The ethtool -c setting for rx-usecs should be on the order of 100.
> 
> 3. Sysctl value net.ipv4.ip_low_latency_poll controls how long
> (in cycles) to busy-wait for more data, You are encouraged to play
> with this and see what works for you. (setting it to 0 would
> globally disable the new mechanism altogether.)
> 
> 4. benchmark thread and IRQ should be bound to separate cores.
> Both cores should be on the same CPU NUMA node as the NIC.
> When the app and the IRQ run on the same CPU  you get a ~5% penalty.
> If interrupt coalescing is set to a low value this penalty
> can be very large.
> 
> 5. If you suspect that your machine is not configured properly,
> use numademo to make sure that the CPU to memory BW is OK.
> numademo 128m memcpy local copy numbers should be more than  
> 8GB/s on a properly configured machine.
> 
> Credit:
> Jesse Brandeburg, Arun Chekhov Ilango, Alexander Duyck, Eric Geisler,
> Jason Neighbors, Yadong Li, Mike Polehn, Anil Vasudevan, Don Wood
> Special thanks for finding bugs in earlier versions:
> Willem de Bruijn and Andi Kleen

This is not a criticism of this patch, but it seems that gradually, we have gotten
worse and worse at making network devices generic. There are more and more features
that require special case code in every device driver. This is fine for Intel devices but makes
the feature less generally useable and more error prone. 

^ permalink raw reply

* Re: [PATCH net] tcp: fix double-counted receiver RTT when leaving receiver fast path
From: Eric Dumazet @ 2013-03-04 16:55 UTC (permalink / raw)
  To: Neal Cardwell; +Cc: David Miller, edumazet, ycheng, nanditad, netdev
In-Reply-To: <1362414185-9874-1-git-send-email-ncardwell@google.com>

On Mon, 2013-03-04 at 11:23 -0500, Neal Cardwell wrote:
> We should not update ts_recent and call tcp_rcv_rtt_measure_ts() both
> before and after going to step5. That wastes CPU and double-counts the
> receiver-side RTT sample.
> 
> Signed-off-by: Neal Cardwell <ncardwell@google.com>
> ---
>  net/ipv4/tcp_input.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index a759e19..0d9bdac 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -5485,6 +5485,9 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
>  				if (tcp_checksum_complete_user(sk, skb))
>  					goto csum_error;
>  
> +				if ((int)skb->truesize > sk->sk_forward_alloc)
> +					goto step5;
> +
>  				/* Predicted packet is in window by definition.
>  				 * seq == rcv_nxt and rcv_wup <= rcv_nxt.
>  				 * Hence, check seq<=rcv_wup reduces to:
> @@ -5496,9 +5499,6 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
>  
>  				tcp_rcv_rtt_measure_ts(sk, skb);
>  
> -				if ((int)skb->truesize > sk->sk_forward_alloc)
> -					goto step5;
> -
>  				NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITS);
>  
>  				/* Bulk data transfer: receiver */

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

^ permalink raw reply

* [PATCH net] tcp: fix double-counted receiver RTT when leaving receiver fast path
From: Neal Cardwell @ 2013-03-04 16:23 UTC (permalink / raw)
  To: David Miller; +Cc: edumazet, ycheng, nanditad, netdev, Neal Cardwell

We should not update ts_recent and call tcp_rcv_rtt_measure_ts() both
before and after going to step5. That wastes CPU and double-counts the
receiver-side RTT sample.

Signed-off-by: Neal Cardwell <ncardwell@google.com>
---
 net/ipv4/tcp_input.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a759e19..0d9bdac 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5485,6 +5485,9 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
 				if (tcp_checksum_complete_user(sk, skb))
 					goto csum_error;
 
+				if ((int)skb->truesize > sk->sk_forward_alloc)
+					goto step5;
+
 				/* Predicted packet is in window by definition.
 				 * seq == rcv_nxt and rcv_wup <= rcv_nxt.
 				 * Hence, check seq<=rcv_wup reduces to:
@@ -5496,9 +5499,6 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
 
 				tcp_rcv_rtt_measure_ts(sk, skb);
 
-				if ((int)skb->truesize > sk->sk_forward_alloc)
-					goto step5;
-
 				NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITS);
 
 				/* Bulk data transfer: receiver */
-- 
1.8.1.3

^ permalink raw reply related

* Re: Multicast/Broadcast enhancement: SKB read-only with copy-on-write
From: Eric Dumazet @ 2013-03-04 16:28 UTC (permalink / raw)
  To: Yannick Koehler; +Cc: netdev
In-Reply-To: <CAJ4BwwGs2FebA0jgedDxxmQEXSV=g2B07KBgu4C+0nigLbyvnA@mail.gmail.com>

On Mon, 2013-03-04 at 10:29 -0500, Yannick Koehler wrote:
> Hi,
> 
>   Recently I was working into the kernel area where the code handle
> broadcast/multicast in bridge logical interface for example.  It seems
> today inevitable that when we flood, the bridge code has to duplicate
> the full SKB, metadata as well as data, in order to transmit to each
> link under it.  I was wondering if there was way for the SKB system to
> support copy-on-write, such that, from a starting point, the SKB would
> be "frozen" into a read-only mode and then if someone wants to modify
> the SKB metadata/data it is done in a way to preserve the original SKB
> memory, as to ensure that after the SKB has been transmitted over that
> particular link, it can also be used without a full memory copy to be
> sent to subsequent link, simultaneously on multi-core/mutli-interface
> system.
> 
>   I am wondering at what level such work would be consider, is it
> relatively easy, does Linux have anything like that, is it major work,
> since pretty much everyone expect SKB data to be writable (like
> skb_may_pull could be used to obtain a specific client SKB version
> area).  It would probably require a new field in the SKB to indicate
> that this is a read-only/copy-on-write version of a specific "original
> SKB".
> 
>   Anyway, just wanted some thoughts/opinions on the topic regarding
> the scale of such a change.
> 

Current skb handling already provides this "read-only" and
"copy-on-write" management.

We only have to use the correct API where it matters, like
skb_share_check()

For an example, take a look at commit de063b7040dcd9
(bonding: remove packet cloning in recv_probe())

ARP packets for example could be handled in a read-only way.

(You dont really explain what particular problem you have,
ARP is only a guess...)

^ permalink raw reply

* Re: [RFC PATCH 1/5] net: implement support for low latency socket polling
From: Eric Dumazet @ 2013-03-04 16:15 UTC (permalink / raw)
  To: Eliezer Tamir
  Cc: Eliezer Tamir, linux-kernel, netdev, Dave Miller,
	Jesse Brandeburg, e1000-devel, Willem de Bruijn, Andi Kleen, HPA,
	Eliezer Tamir
In-Reply-To: <5134BD9B.2080003@linux.intel.com>

On Mon, 2013-03-04 at 17:28 +0200, Eliezer Tamir wrote:
> On 04/03/2013 16:52, Eric Dumazet wrote:
> > On Mon, 2013-03-04 at 10:43 +0200, Eliezer Tamir wrote:
> >
> >> One could for example increment the generation id every time the RTNL is
> >> taken. or is this too much?
> >
> > RTNL is taken for a lot of operations, it would be better to have a
> > finer grained increment.
> 
> If is taken rarely enough it will still be worth it.
> 

Yes, but eventually it makes attempts to get rid of RTNL a nightmare.

When adding new network features, just use the right semantic from the
beginning.

> Otherwise it may be hard to know what operations need to invalidate the 
> napi reference. It can very well be HW dependent, and then you end up 
> adding a function for drivers to call to do the invalidation.
> 
> Or we can decide that we only care about catastrophic events and only 
> worry about a napi completely going away and not worry about 
> configuration changes.(Polling the wrong queue will not kill you, it's 
> just a waste of perfectly good CPU cycles.)

As long as the incoming packets are able to update the information, who
cares if one packet missed the poll ?
 

^ permalink raw reply

* [PATCH 1/1] reset nf before xmit vxlan encapsulated packet
From: Zang MingJie @ 2013-03-04 16:07 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: Zang MingJie


We should reset nf settings bond to the skb as ipip/ipgre do.

If not, the conntrack/nat info bond to the origin packet may continually
redirect the packet to vxlan interface causing a routing loop.

this is the scenario:

     VETP     VXLAN Gateway
    /----\  /---------------\
    |    |  |               |
    |  vx+--+vx --NAT-> eth0+--> Internet
    |    |  |               |
    \----/  \---------------/

when there are any packet coming from internet to the vetp, there will be lots
of garbage packets coming out the gateway's vxlan interface, but none actually
sent to the physical interface, because they are redirected back to the vxlan
interface in the postrouting chain of NAT rule, and dmesg complains:

    Mar  1 21:52:53 debian kernel: [ 8802.997699] Dead loop on virtual device vxlan0, fix it urgently!
    Mar  1 21:52:54 debian kernel: [ 8804.004907] Dead loop on virtual device vxlan0, fix it urgently!
    Mar  1 21:52:55 debian kernel: [ 8805.012189] Dead loop on virtual device vxlan0, fix it urgently!
    Mar  1 21:52:56 debian kernel: [ 8806.020593] Dead loop on virtual device vxlan0, fix it urgently!

the patch should fix the problem

Signed-off-by: Zang MingJie <zealot0630@gmail.com>
---
 drivers/net/vxlan.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index f10e58a..c3e3d29 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -961,6 +961,8 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
 	iph->ttl	= ttl ? : ip4_dst_hoplimit(&rt->dst);
 	tunnel_ip_select_ident(skb, old_iph, &rt->dst);
 
+	nf_reset(skb);
+
 	vxlan_set_owner(dev, skb);
 
 	/* See iptunnel_xmit() */
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH] netfilter: nfnetlink: silence warning if CONFIG_PROVE_RCU isn't set
From: Pablo Neira Ayuso @ 2013-03-04 15:59 UTC (permalink / raw)
  To: Paul Bolle
  Cc: Patrick McHardy, David S. Miller, netfilter-devel, netfilter,
	coreteam, netdev, linux-kernel
In-Reply-To: <1362401141.16460.24.camel@x61.thuisdomein>

On Mon, Mar 04, 2013 at 01:45:41PM +0100, Paul Bolle wrote:
> Since commit c14b78e7decd0d1d5add6a4604feb8609fe920a9 ("netfilter:
> nfnetlink: add mutex per subsystem") building nefnetlink.o without
> CONFIG_PROVE_RCU set, triggers this GCC warning:
>     net/netfilter/nfnetlink.c:65:22: warning: ‘nfnl_get_lock’ defined but not used [-Wunused-function]
> 
> The cause of that warning is, in short, that rcu_lockdep_assert()
> compiles away if CONFIG_PROVE_RCU is not set. Silence this warning by
> open coding nfnl_get_lock() in the sole place it was called, which
> allows to remove that function.

Applied, thanks Paul.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" 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

* Multicast/Broadcast enhancement: SKB read-only with copy-on-write
From: Yannick Koehler @ 2013-03-04 15:29 UTC (permalink / raw)
  To: netdev

Hi,

  Recently I was working into the kernel area where the code handle
broadcast/multicast in bridge logical interface for example.  It seems
today inevitable that when we flood, the bridge code has to duplicate
the full SKB, metadata as well as data, in order to transmit to each
link under it.  I was wondering if there was way for the SKB system to
support copy-on-write, such that, from a starting point, the SKB would
be "frozen" into a read-only mode and then if someone wants to modify
the SKB metadata/data it is done in a way to preserve the original SKB
memory, as to ensure that after the SKB has been transmitted over that
particular link, it can also be used without a full memory copy to be
sent to subsequent link, simultaneously on multi-core/mutli-interface
system.

  I am wondering at what level such work would be consider, is it
relatively easy, does Linux have anything like that, is it major work,
since pretty much everyone expect SKB data to be writable (like
skb_may_pull could be used to obtain a specific client SKB version
area).  It would probably require a new field in the SKB to indicate
that this is a read-only/copy-on-write version of a specific "original
SKB".

  Anyway, just wanted some thoughts/opinions on the topic regarding
the scale of such a change.

--
Yannick Koehler

^ permalink raw reply

* Re: [RFC PATCH 1/5] net: implement support for low latency socket polling
From: Eliezer Tamir @ 2013-03-04 15:28 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Eliezer Tamir, linux-kernel, netdev, Dave Miller,
	Jesse Brandeburg, e1000-devel, Willem de Bruijn, Andi Kleen, HPA,
	Eliezer Tamir
In-Reply-To: <1362408768.15793.89.camel@edumazet-glaptop>

On 04/03/2013 16:52, Eric Dumazet wrote:
> On Mon, 2013-03-04 at 10:43 +0200, Eliezer Tamir wrote:
>
>> One could for example increment the generation id every time the RTNL is
>> taken. or is this too much?
>
> RTNL is taken for a lot of operations, it would be better to have a
> finer grained increment.

If is taken rarely enough it will still be worth it.

Otherwise it may be hard to know what operations need to invalidate the 
napi reference. It can very well be HW dependent, and then you end up 
adding a function for drivers to call to do the invalidation.

Or we can decide that we only care about catastrophic events and only 
worry about a napi completely going away and not worry about 
configuration changes.(Polling the wrong queue will not kill you, it's 
just a waste of perfectly good CPU cycles.)

^ permalink raw reply

* Re: [PATCH] net: ipv6: Don't purge default router if accept_ra=2
From: Eric Dumazet @ 2013-03-04 14:58 UTC (permalink / raw)
  To: Lorenzo Colitti; +Cc: netdev, Eric Dumazet
In-Reply-To: <CAKD1Yr2e8Z8CDAM3tgp=nUR58OO9QZYEx8zkWwwcQ1S=14D2Qw@mail.gmail.com>

On Mon, 2013-03-04 at 15:46 +0900, Lorenzo Colitti wrote:
> Setting net.ipv6.conf.<interface>.accept_ra=2 causes the kernel
> to accept RAs even when forwarding is enabled. However, enabling
> forwarding purges all default routes on the system, breaking
> connectivity until the next RA is received. Fix this by not
> purging default routes on interfaces that have accept_ra=2.
> 
> Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
> ---
>  net/ipv6/route.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 9282665..e5fe004 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1915,7 +1915,8 @@ void rt6_purge_dflt_routers(struct net *net)
>  restart:
>  	read_lock_bh(&table->tb6_lock);
>  	for (rt = table->tb6_root.leaf; rt; rt = rt->dst.rt6_next) {
> -		if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) {
> +		if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF) &&
> +		    (!rt->rt6i_idev || rt->rt6i_idev->cnf.accept_ra != 2)) {
>  			dst_hold(&rt->dst);
>  			read_unlock_bh(&table->tb6_lock);
>  			ip6_del_rt(rt);

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

^ permalink raw reply

* Re: [Patch net] garp: fix a NULL pointer dereference bug
From: Eric Dumazet @ 2013-03-04 14:56 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, bugs, David Ward, Stephen Hemminger, David S. Miller
In-Reply-To: <1362390955.2383.2.camel@cr0>

On Mon, 2013-03-04 at 17:55 +0800, Cong Wang wrote:
> On Sun, 2013-03-03 at 21:26 -0800, Eric Dumazet wrote:
> > 
> > Nope this patch doesnt solve the problem
> > 
> > Crash is in :
> > 
> > 49 8b 1c c6             mov    (%r14,%rax,8),%rbx 
> > 
> > Thats because r14 (port) is NULL
> > 
> > 
> > 
> 
> Hmm, but I can't see how it can be NULL, the only place of NULL'ing it
> is inside garp_release_port(), right after the piece of code that I
> patched.
> 
> Thanks!
> 

Maybe port is NULL from the beginning.

Try to inject memory allocations error in garp_init_port()

^ permalink raw reply

* Re: [RFC PATCH 1/5] net: implement support for low latency socket polling
From: Eric Dumazet @ 2013-03-04 14:52 UTC (permalink / raw)
  To: Eliezer Tamir
  Cc: Eliezer Tamir, linux-kernel, netdev, Dave Miller,
	Jesse Brandeburg, e1000-devel, Willem de Bruijn, Andi Kleen, HPA,
	Eliezer Tamir
In-Reply-To: <51345EB8.9050309@linux.intel.com>

On Mon, 2013-03-04 at 10:43 +0200, Eliezer Tamir wrote:

> One could for example increment the generation id every time the RTNL is 
> taken. or is this too much?

RTNL is taken for a lot of operations, it would be better to have a
finer grained increment.

^ permalink raw reply

* Re: [Patch net] rds: limit the size allocated by rds_message_alloc()
From: venkat venkatsubra @ 2013-03-04 14:43 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, rds-devel, Dave Jones, David S. Miller
In-Reply-To: <1362363491-24501-1-git-send-email-amwang@redhat.com>


On 3/3/2013 8:18 PM, Cong Wang wrote:
> From: Cong Wang <amwang@redhat.com>
>
> Dave Jones reported the following bug:
>
> "When fed mangled socket data, rds will trust what userspace gives it,
> and tries to allocate enormous amounts of memory larger than what
> kmalloc can satisfy."
>
> Reported-by: Dave Jones <davej@redhat.com>
> Cc: Dave Jones <davej@redhat.com>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Venkat Venkatsubra <venkat.x.venkatsubra@oracle.com>
> Signed-off-by: Cong Wang <amwang@redhat.com>
>
Acked-by: Venkat Venkatsubra <venkat.x.venkatsubra@oracle.com>

^ permalink raw reply

* Re: [PATCH -v3 16/23] drivers/net: rename random32() to prandom_u32()
From: Arend van Spriel @ 2013-03-04 13:37 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, David S. Miller,
	Michael Chan, Thomas Sailer, Jean-Paul Roubelat, Bing Zhao,
	Brett Rudley, Franky (Zhenhui) Lin, Hante Meuleman,
	brcm80211-dev-list-dY08KVG/lbpWk0Htik3J/w,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-hams-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1362401911-14074-17-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On 03/04/13 13:58, Akinobu Mita wrote:
> Use more preferable function name which implies using a pseudo-random
> number generator.
>
> Signed-off-by: Akinobu Mita<akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Acked-by: Thomas Sailer<t.sailer-aAjG49QhEdKVRmA6MYkXiA@public.gmane.org>
> Acked-by: Bing Zhao<bzhao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>  [mwifiex]
> Cc: "David S. Miller"<davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
> Cc: Michael Chan<mchan-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> Cc: Thomas Sailer<t.sailer-aAjG49QhEdKVRmA6MYkXiA@public.gmane.org>
> Cc: Jean-Paul Roubelat<jpr-3OwtVqItl4LYtjvyW6yDsg@public.gmane.org>
> Cc: Bing Zhao<bzhao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
> Cc: Brett Rudley<brudley-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> Cc: Arend van Spriel<arend-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> Cc: "Franky (Zhenhui) Lin"<frankyl-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> Cc: Hante Meuleman<meuleman-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> Cc: brcm80211-dev-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org
> Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> ---
> * Changes from v2
> - add Acked-by: line
> - add rename for brcm80211
>
>   drivers/net/ethernet/broadcom/cnic.c          | 4 ++--
>   drivers/net/hamradio/baycom_epp.c             | 2 +-
>   drivers/net/hamradio/hdlcdrv.c                | 2 +-
>   drivers/net/hamradio/yam.c                    | 2 +-
>   drivers/net/wireless/brcm80211/brcmfmac/p2p.c | 2 +-
>   drivers/net/wireless/mwifiex/cfg80211.c       | 4 ++--
>   6 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
> index 4166e64..bca31a8 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
> @@ -1118,7 +1118,7 @@ static void brcmf_p2p_afx_handler(struct work_struct *work)
>   	if (afx_hdl->is_listen&&  afx_hdl->my_listen_chan)
>   		/* 100ms ~ 300ms */
>   		err = brcmf_p2p_discover_listen(p2p, afx_hdl->my_listen_chan,
> -						100 * (1 + (random32() % 3)));
> +					100 * (1 + (prandom_u32() % 3)));

Seems like indentation is wrong now. Please retain the alignment.

Regards,
Arend

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH -v3 22/23] net: rename random32 to prandom
From: Akinobu Mita @ 2013-03-04 12:58 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, David S. Miller, netdev
In-Reply-To: <1362401911-14074-1-git-send-email-akinobu.mita@gmail.com>

Commit 496f2f93b1cc286f5a4f4f9acdc1e5314978683f ("random32: rename
random32 to prandom") renamed random32() and srandom32() to prandom_u32()
and prandom_seed() respectively.

net_random() and net_srandom() need to be redefined with prandom_* in
order to finish the naming transition.

While I'm at it, enclose macro argument of net_srandom() with parenthesis.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

No change from v2

 include/linux/net.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index aa16731..99c9f0c 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -240,8 +240,8 @@ do {								\
 #define net_dbg_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
 
-#define net_random()		random32()
-#define net_srandom(seed)	srandom32((__force u32)seed)
+#define net_random()		prandom_u32()
+#define net_srandom(seed)	prandom_seed((__force u32)(seed))
 
 extern int   	     kernel_sendmsg(struct socket *sock, struct msghdr *msg,
 				    struct kvec *vec, size_t num, size_t len);
-- 
1.8.1.2

^ permalink raw reply related

* [PATCH -v3 21/23] net/core: remove duplicate statements by do-while loop
From: Akinobu Mita @ 2013-03-04 12:58 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, David S. Miller, netdev
In-Reply-To: <1362401911-14074-1-git-send-email-akinobu.mita@gmail.com>

Remove duplicate statements by using do-while loop instead of while loop.

- A;
- while (e) {
+ do {
	A;
- }
+ } while (e);

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

No change from v2

 net/core/pktgen.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 4582275..5c21742 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2396,18 +2396,15 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 				__be32 s;
 				if (pkt_dev->flags & F_IPDST_RND) {
 
-					t = prandom_u32() % (imx - imn) + imn;
-					s = htonl(t);
-
-					while (ipv4_is_loopback(s) ||
-					       ipv4_is_multicast(s) ||
-					       ipv4_is_lbcast(s) ||
-					       ipv4_is_zeronet(s) ||
-					       ipv4_is_local_multicast(s)) {
+					do {
 						t = prandom_u32() %
 							(imx - imn) + imn;
 						s = htonl(t);
-					}
+					} while (ipv4_is_loopback(s) ||
+						ipv4_is_multicast(s) ||
+						ipv4_is_lbcast(s) ||
+						ipv4_is_zeronet(s) ||
+						ipv4_is_local_multicast(s));
 					pkt_dev->cur_daddr = s;
 				} else {
 					t = ntohl(pkt_dev->cur_daddr);
-- 
1.8.1.2

^ permalink raw reply related

* [PATCH -v3 20/23] net/core:  rename random32() to prandom_u32()
From: Akinobu Mita @ 2013-03-04 12:58 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, David S. Miller, netdev
In-Reply-To: <1362401911-14074-1-git-send-email-akinobu.mita@gmail.com>

Use more preferable function name which implies using a pseudo-random
number generator.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

No change from v2

 net/core/pktgen.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 6048fc1..4582275 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2198,7 +2198,7 @@ static inline int f_pick(struct pktgen_dev *pkt_dev)
 				pkt_dev->curfl = 0; /*reset */
 		}
 	} else {
-		flow = random32() % pkt_dev->cflows;
+		flow = prandom_u32() % pkt_dev->cflows;
 		pkt_dev->curfl = flow;
 
 		if (pkt_dev->flows[flow].count > pkt_dev->lflow) {
@@ -2246,7 +2246,7 @@ static void set_cur_queue_map(struct pktgen_dev *pkt_dev)
 	else if (pkt_dev->queue_map_min <= pkt_dev->queue_map_max) {
 		__u16 t;
 		if (pkt_dev->flags & F_QUEUE_MAP_RND) {
-			t = random32() %
+			t = prandom_u32() %
 				(pkt_dev->queue_map_max -
 				 pkt_dev->queue_map_min + 1)
 				+ pkt_dev->queue_map_min;
@@ -2278,7 +2278,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 		__u32 tmp;
 
 		if (pkt_dev->flags & F_MACSRC_RND)
-			mc = random32() % pkt_dev->src_mac_count;
+			mc = prandom_u32() % pkt_dev->src_mac_count;
 		else {
 			mc = pkt_dev->cur_src_mac_offset++;
 			if (pkt_dev->cur_src_mac_offset >=
@@ -2304,7 +2304,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 		__u32 tmp;
 
 		if (pkt_dev->flags & F_MACDST_RND)
-			mc = random32() % pkt_dev->dst_mac_count;
+			mc = prandom_u32() % pkt_dev->dst_mac_count;
 
 		else {
 			mc = pkt_dev->cur_dst_mac_offset++;
@@ -2331,21 +2331,21 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 		for (i = 0; i < pkt_dev->nr_labels; i++)
 			if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
 				pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
-					     ((__force __be32)random32() &
+					     ((__force __be32)prandom_u32() &
 						      htonl(0x000fffff));
 	}
 
 	if ((pkt_dev->flags & F_VID_RND) && (pkt_dev->vlan_id != 0xffff)) {
-		pkt_dev->vlan_id = random32() & (4096-1);
+		pkt_dev->vlan_id = prandom_u32() & (4096 - 1);
 	}
 
 	if ((pkt_dev->flags & F_SVID_RND) && (pkt_dev->svlan_id != 0xffff)) {
-		pkt_dev->svlan_id = random32() & (4096 - 1);
+		pkt_dev->svlan_id = prandom_u32() & (4096 - 1);
 	}
 
 	if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) {
 		if (pkt_dev->flags & F_UDPSRC_RND)
-			pkt_dev->cur_udp_src = random32() %
+			pkt_dev->cur_udp_src = prandom_u32() %
 				(pkt_dev->udp_src_max - pkt_dev->udp_src_min)
 				+ pkt_dev->udp_src_min;
 
@@ -2358,7 +2358,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 
 	if (pkt_dev->udp_dst_min < pkt_dev->udp_dst_max) {
 		if (pkt_dev->flags & F_UDPDST_RND) {
-			pkt_dev->cur_udp_dst = random32() %
+			pkt_dev->cur_udp_dst = prandom_u32() %
 				(pkt_dev->udp_dst_max - pkt_dev->udp_dst_min)
 				+ pkt_dev->udp_dst_min;
 		} else {
@@ -2375,7 +2375,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 		if (imn < imx) {
 			__u32 t;
 			if (pkt_dev->flags & F_IPSRC_RND)
-				t = random32() % (imx - imn) + imn;
+				t = prandom_u32() % (imx - imn) + imn;
 			else {
 				t = ntohl(pkt_dev->cur_saddr);
 				t++;
@@ -2396,7 +2396,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 				__be32 s;
 				if (pkt_dev->flags & F_IPDST_RND) {
 
-					t = random32() % (imx - imn) + imn;
+					t = prandom_u32() % (imx - imn) + imn;
 					s = htonl(t);
 
 					while (ipv4_is_loopback(s) ||
@@ -2404,7 +2404,8 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 					       ipv4_is_lbcast(s) ||
 					       ipv4_is_zeronet(s) ||
 					       ipv4_is_local_multicast(s)) {
-						t = random32() % (imx - imn) + imn;
+						t = prandom_u32() %
+							(imx - imn) + imn;
 						s = htonl(t);
 					}
 					pkt_dev->cur_daddr = s;
@@ -2437,7 +2438,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 
 			for (i = 0; i < 4; i++) {
 				pkt_dev->cur_in6_daddr.s6_addr32[i] =
-				    (((__force __be32)random32() |
+				    (((__force __be32)prandom_u32() |
 				      pkt_dev->min_in6_daddr.s6_addr32[i]) &
 				     pkt_dev->max_in6_daddr.s6_addr32[i]);
 			}
@@ -2447,7 +2448,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 	if (pkt_dev->min_pkt_size < pkt_dev->max_pkt_size) {
 		__u32 t;
 		if (pkt_dev->flags & F_TXSIZE_RND) {
-			t = random32() %
+			t = prandom_u32() %
 				(pkt_dev->max_pkt_size - pkt_dev->min_pkt_size)
 				+ pkt_dev->min_pkt_size;
 		} else {
-- 
1.8.1.2

^ permalink raw reply related

* [PATCH -v3 19/23] net/netfilter: rename random32() to prandom_u32()
From: Akinobu Mita @ 2013-03-04 12:58 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, Pablo Neira Ayuso, Patrick McHardy, netfilter-devel,
	netfilter, coreteam, David S. Miller, netdev
In-Reply-To: <1362401911-14074-1-git-send-email-akinobu.mita@gmail.com>

Use more preferable function name which implies using a pseudo-random
number generator.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: netfilter-devel@vger.kernel.org
Cc: netfilter@vger.kernel.org
Cc: coreteam@netfilter.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

No change from v2

 net/netfilter/nf_conntrack_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index c8e001a..f84965a 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -264,7 +264,7 @@ static void death_by_event(unsigned long ul_conntrack)
 	if (nf_conntrack_event(IPCT_DESTROY, ct) < 0) {
 		/* bad luck, let's retry again */
 		ecache->timeout.expires = jiffies +
-			(random32() % net->ct.sysctl_events_retry_timeout);
+			(prandom_u32() % net->ct.sysctl_events_retry_timeout);
 		add_timer(&ecache->timeout);
 		return;
 	}
@@ -283,7 +283,7 @@ void nf_ct_dying_timeout(struct nf_conn *ct)
 	/* set a new timer to retry event delivery */
 	setup_timer(&ecache->timeout, death_by_event, (unsigned long)ct);
 	ecache->timeout.expires = jiffies +
-		(random32() % net->ct.sysctl_events_retry_timeout);
+		(prandom_u32() % net->ct.sysctl_events_retry_timeout);
 	add_timer(&ecache->timeout);
 }
 EXPORT_SYMBOL_GPL(nf_ct_dying_timeout);
-- 
1.8.1.2

^ permalink raw reply related

* [PATCH -v3 18/23] net/sched: rename random32() to prandom_u32()
From: Akinobu Mita @ 2013-03-04 12:58 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, Stephen Hemminger, Jamal Hadi Salim,
	David S. Miller, netem, netdev
In-Reply-To: <1362401911-14074-1-git-send-email-akinobu.mita@gmail.com>

Use more preferable function name which implies using a pseudo-random
number generator.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netem@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Cc: netdev@vger.kernel.org
---

No change from v2

 net/sched/sch_choke.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index cc37dd5..ef53ab8 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -80,7 +80,7 @@ struct choke_sched_data {
 /* deliver a random number between 0 and N - 1 */
 static u32 random_N(unsigned int N)
 {
-	return reciprocal_divide(random32(), N);
+	return reciprocal_divide(prandom_u32(), N);
 }
 
 /* number of elements in queue including holes */
-- 
1.8.1.2

^ permalink raw reply related

* [PATCH -v3 17/23] net/sunrpc: rename random32() to prandom_u32()
From: Akinobu Mita @ 2013-03-04 12:58 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, J. Bruce Fields, Trond Myklebust, David S. Miller,
	netdev, linux-nfs
In-Reply-To: <1362401911-14074-1-git-send-email-akinobu.mita@gmail.com>

Use more preferable function name which implies using a pseudo-random
number generator.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: linux-nfs@vger.kernel.org
---

No change from v2

 net/sunrpc/auth_gss/gss_krb5_wrap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c
index 88edec9..1da52d1 100644
--- a/net/sunrpc/auth_gss/gss_krb5_wrap.c
+++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c
@@ -130,8 +130,8 @@ gss_krb5_make_confounder(char *p, u32 conflen)
 
 	/* initialize to random value */
 	if (i == 0) {
-		i = random32();
-		i = (i << 32) | random32();
+		i = prandom_u32();
+		i = (i << 32) | prandom_u32();
 	}
 
 	switch (conflen) {
-- 
1.8.1.2

^ permalink raw reply related

* [PATCH -v3 16/23] drivers/net: rename random32() to prandom_u32()
From: Akinobu Mita @ 2013-03-04 12:58 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, David S. Miller, Michael Chan, Thomas Sailer,
	Jean-Paul Roubelat, Bing Zhao, Brett Rudley, Arend van Spriel,
	Franky (Zhenhui) Lin, Hante Meuleman, brcm80211-dev-list, netdev,
	linux-hams, linux-wireless
In-Reply-To: <1362401911-14074-1-git-send-email-akinobu.mita@gmail.com>

Use more preferable function name which implies using a pseudo-random
number generator.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Thomas Sailer <t.sailer@alumni.ethz.ch>
Acked-by: Bing Zhao <bzhao@marvell.com> [mwifiex]
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Michael Chan <mchan@broadcom.com>
Cc: Thomas Sailer <t.sailer@alumni.ethz.ch>
Cc: Jean-Paul Roubelat <jpr@f6fbb.org>
Cc: Bing Zhao <bzhao@marvell.com>
Cc: Brett Rudley <brudley@broadcom.com>
Cc: Arend van Spriel <arend@broadcom.com>
Cc: "Franky (Zhenhui) Lin" <frankyl@broadcom.com>
Cc: Hante Meuleman <meuleman@broadcom.com>
Cc: brcm80211-dev-list@broadcom.com
Cc: netdev@vger.kernel.org
Cc: linux-hams@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
---
* Changes from v2
- add Acked-by: line
- add rename for brcm80211

 drivers/net/ethernet/broadcom/cnic.c          | 4 ++--
 drivers/net/hamradio/baycom_epp.c             | 2 +-
 drivers/net/hamradio/hdlcdrv.c                | 2 +-
 drivers/net/hamradio/yam.c                    | 2 +-
 drivers/net/wireless/brcm80211/brcmfmac/p2p.c | 2 +-
 drivers/net/wireless/mwifiex/cfg80211.c       | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 149a3a0..5abdd48 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -4085,7 +4085,7 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev)
 	if (!cp->csk_tbl)
 		return -ENOMEM;
 
-	port_id = random32();
+	port_id = prandom_u32();
 	port_id %= CNIC_LOCAL_PORT_RANGE;
 	if (cnic_init_id_tbl(&cp->csk_port_tbl, CNIC_LOCAL_PORT_RANGE,
 			     CNIC_LOCAL_PORT_MIN, port_id)) {
@@ -4145,7 +4145,7 @@ static int cnic_cm_init_bnx2_hw(struct cnic_dev *dev)
 {
 	u32 seed;
 
-	seed = random32();
+	seed = prandom_u32();
 	cnic_ctx_wr(dev, 45, 0, seed);
 	return 0;
 }
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 49b8b58..484f77e 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -449,7 +449,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
 			if ((--bc->hdlctx.slotcnt) > 0)
 				return 0;
 			bc->hdlctx.slotcnt = bc->ch_params.slottime;
-			if ((random32() % 256) > bc->ch_params.ppersist)
+			if ((prandom_u32() % 256) > bc->ch_params.ppersist)
 				return 0;
 		}
 	}
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index a4a3516..3169252 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -389,7 +389,7 @@ void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
 	if ((--s->hdlctx.slotcnt) > 0)
 		return;
 	s->hdlctx.slotcnt = s->ch_params.slottime;
-	if ((random32() % 256) > s->ch_params.ppersist)
+	if ((prandom_u32() % 256) > s->ch_params.ppersist)
 		return;
 	start_tx(dev, s);
 }
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 4cf8f10..ae3feb0 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -638,7 +638,7 @@ static void yam_arbitrate(struct net_device *dev)
 	yp->slotcnt = yp->slot / 10;
 
 	/* is random > persist ? */
-	if ((random32() % 256) > yp->pers)
+	if ((prandom_u32() % 256) > yp->pers)
 		return;
 
 	yam_start_tx(dev, yp);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
index 4166e64..bca31a8 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
@@ -1118,7 +1118,7 @@ static void brcmf_p2p_afx_handler(struct work_struct *work)
 	if (afx_hdl->is_listen && afx_hdl->my_listen_chan)
 		/* 100ms ~ 300ms */
 		err = brcmf_p2p_discover_listen(p2p, afx_hdl->my_listen_chan,
-						100 * (1 + (random32() % 3)));
+					100 * (1 + (prandom_u32() % 3)));
 	else
 		err = brcmf_p2p_act_frm_search(p2p, afx_hdl->peer_listen_chan);
 
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index a44023a..4513707 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -216,7 +216,7 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 	mwifiex_form_mgmt_frame(skb, buf, len);
 	mwifiex_queue_tx_pkt(priv, skb);
 
-	*cookie = random32() | 1;
+	*cookie = prandom_u32() | 1;
 	cfg80211_mgmt_tx_status(wdev, *cookie, buf, len, true, GFP_ATOMIC);
 
 	wiphy_dbg(wiphy, "info: management frame transmitted\n");
@@ -271,7 +271,7 @@ mwifiex_cfg80211_remain_on_channel(struct wiphy *wiphy,
 					 duration);
 
 	if (!ret) {
-		*cookie = random32() | 1;
+		*cookie = prandom_u32() | 1;
 		priv->roc_cfg.cookie = *cookie;
 		priv->roc_cfg.chan = *chan;
 
-- 
1.8.1.2

^ permalink raw reply related

* [PATCH] netfilter: nfnetlink: silence warning if CONFIG_PROVE_RCU isn't set
From: Paul Bolle @ 2013-03-04 12:45 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Patrick McHardy, David S. Miller
  Cc: netfilter-devel, netfilter, coreteam, netdev, linux-kernel

Since commit c14b78e7decd0d1d5add6a4604feb8609fe920a9 ("netfilter:
nfnetlink: add mutex per subsystem") building nefnetlink.o without
CONFIG_PROVE_RCU set, triggers this GCC warning:
    net/netfilter/nfnetlink.c:65:22: warning: ‘nfnl_get_lock’ defined but not used [-Wunused-function]

The cause of that warning is, in short, that rcu_lockdep_assert()
compiles away if CONFIG_PROVE_RCU is not set. Silence this warning by
open coding nfnl_get_lock() in the sole place it was called, which
allows to remove that function.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
0) Compile tested only, but without CONFIG_PROVE_RCU set! This patch
needs building and running by someone who actually uses that option.

1) This patch triggers a checkpatch "line over 80 characters" warning.
But note that it actually shortens the line checkpatch complains about
(by one character!).

 net/netfilter/nfnetlink.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index d578ec2..0b1b32c 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -62,11 +62,6 @@ void nfnl_unlock(__u8 subsys_id)
 }
 EXPORT_SYMBOL_GPL(nfnl_unlock);
 
-static struct mutex *nfnl_get_lock(__u8 subsys_id)
-{
-	return &table[subsys_id].mutex;
-}
-
 int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n)
 {
 	nfnl_lock(n->subsys_id);
@@ -199,7 +194,7 @@ replay:
 			rcu_read_unlock();
 			nfnl_lock(subsys_id);
 			if (rcu_dereference_protected(table[subsys_id].subsys,
-				lockdep_is_held(nfnl_get_lock(subsys_id))) != ss ||
+				lockdep_is_held(&table[subsys_id].mutex)) != ss ||
 			    nfnetlink_find_client(type, ss) != nc)
 				err = -EAGAIN;
 			else if (nc->call)
-- 
1.7.11.7

^ 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