* Re: [PATCH 1/1]core:Change a wrong explain about dev_get_by_name
From: Eric Dumazet @ 2013-03-20 15:32 UTC (permalink / raw)
To: tingwei liu; +Cc: netdev, Alexey Kuznetsov, davem
In-Reply-To: <CA+qZnSSMfbeGsThYe-=tK-kZ3h1GEKDGkNom+07-hRSqgLUUWg@mail.gmail.com>
On Wed, 2013-03-20 at 17:33 +0800, tingwei liu wrote:
> From 5d787e8c3725efa6af3036eeb52aba1905c70de9 Mon Sep 17 00:00:00 2001
> From: root <root@linux-19.site>
> Date: Wed, 20 Mar 2013 17:39:59 +0800
> Subject: [PATCH] Change a wrong explain about dev_get_by_name
>
No changelog ? This patch really needs a changelog.
I have no idea why we should document this function being not safe in
irq context.
Most part of networking stack is non safe in hard irq context.
Should we add a comment in front of all possible entry points ?
^ permalink raw reply
* [PATCH] net: fec: Define indexes as 'unsigned int'
From: Fabio Estevam @ 2013-03-20 15:31 UTC (permalink / raw)
To: davem; +Cc: netdev, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
Fix the following warnings that happen when building with W=1 option:
drivers/net/ethernet/freescale/fec.c: In function 'fec_enet_free_buffers':
drivers/net/ethernet/freescale/fec.c:1337:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
drivers/net/ethernet/freescale/fec.c: In function 'fec_enet_alloc_buffers':
drivers/net/ethernet/freescale/fec.c:1361:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
drivers/net/ethernet/freescale/fec.c: In function 'fec_enet_init':
drivers/net/ethernet/freescale/fec.c:1631:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/net/ethernet/freescale/fec.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 8ca2cf6..186222e 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1329,7 +1329,7 @@ static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
static void fec_enet_free_buffers(struct net_device *ndev)
{
struct fec_enet_private *fep = netdev_priv(ndev);
- int i;
+ unsigned int i;
struct sk_buff *skb;
struct bufdesc *bdp;
@@ -1353,7 +1353,7 @@ static void fec_enet_free_buffers(struct net_device *ndev)
static int fec_enet_alloc_buffers(struct net_device *ndev)
{
struct fec_enet_private *fep = netdev_priv(ndev);
- int i;
+ unsigned int i;
struct sk_buff *skb;
struct bufdesc *bdp;
@@ -1595,7 +1595,7 @@ static int fec_enet_init(struct net_device *ndev)
struct fec_enet_private *fep = netdev_priv(ndev);
struct bufdesc *cbd_base;
struct bufdesc *bdp;
- int i;
+ unsigned int i;
/* Allocate memory for buffer descriptors. */
cbd_base = dma_alloc_coherent(NULL, PAGE_SIZE, &fep->bd_dma,
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH] rename configure.in to configure.ac
From: Stephen Hemminger @ 2013-03-20 15:29 UTC (permalink / raw)
To: yegorslists; +Cc: netdev, buytenh
In-Reply-To: <1363359946-7703-1-git-send-email-yegorslists@googlemail.com>
On Fri, 15 Mar 2013 16:05:46 +0100
yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> Automake 1.14 will likely drop support for the long-deprecated
> 'configure.in' name for the Autoconf input file.
>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Ok, applied this and cleaned up some other debris in make stuff.
^ permalink raw reply
* [PATCH] net/irda: add missing error path release_sock call
From: Kees Cook @ 2013-03-20 15:19 UTC (permalink / raw)
To: linux-kernel; +Cc: Samuel Ortiz, David S. Miller, netdev, Brad Spengler
This makes sure that release_sock is called for all error conditions in
irda_getsockopt.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reported-by: Brad Spengler <spender@grsecurity.net>
Cc: stable@vger.kernel.org
---
net/irda/af_irda.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index d07e3a6..d28e7f0 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -2583,8 +2583,10 @@ bed:
NULL, NULL, NULL);
/* Check if the we got some results */
- if (!self->cachedaddr)
- return -EAGAIN; /* Didn't find any devices */
+ if (!self->cachedaddr) {
+ err = -EAGAIN; /* Didn't find any devices */
+ goto out;
+ }
daddr = self->cachedaddr;
/* Cleanup */
self->cachedaddr = 0;
--
1.7.9.5
--
Kees Cook
Chrome OS Security
^ permalink raw reply related
* RE: [PATCH] net: fec: make local function fec_poll_controller() static
From: Li Frank-B20596 @ 2013-03-20 15:11 UTC (permalink / raw)
To: Wei Yongjun, grant.likely@secretlab.ca, rob.herring@calxeda.com,
davem@davemloft.net, shawn.guo@linaro.org, Estevam Fabio-R49496,
s.hauer@pengutronix.de
Cc: yongjun_wei@trendmicro.com.cn, netdev@vger.kernel.org,
devicetree-discuss@lists.ozlabs.org
In-Reply-To: <CAPgLHd-ZLKjHdqc_Bm44co+9eTF48TOg9zY8c1jbqeG+jnn3GQ@mail.gmail.com>
Acked.
> -----Original Message-----
> From: Wei Yongjun [mailto:weiyj.lk@gmail.com]
> Sent: Wednesday, March 20, 2013 11:06 PM
> To: grant.likely@secretlab.ca; rob.herring@calxeda.com; davem@davemloft.net;
> Li Frank-B20596; shawn.guo@linaro.org; Estevam Fabio-R49496;
> s.hauer@pengutronix.de
> Cc: yongjun_wei@trendmicro.com.cn; netdev@vger.kernel.org; devicetree-
> discuss@lists.ozlabs.org
> Subject: [PATCH] net: fec: make local function fec_poll_controller() static
>
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> fec_poll_controller() was not declared. It should be static.
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
> drivers/net/ethernet/freescale/fec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec.c
> b/drivers/net/ethernet/freescale/fec.c
> index e3f3937..1ece68b 100644
> --- a/drivers/net/ethernet/freescale/fec.c
> +++ b/drivers/net/ethernet/freescale/fec.c
> @@ -1559,7 +1559,7 @@ fec_set_mac_address(struct net_device *ndev, void *p)
> * Polled functionality used by netconsole and others in non interrupt mode
> *
> */
> -void fec_poll_controller(struct net_device *dev)
> +static void fec_poll_controller(struct net_device *dev)
> {
> int i;
> struct fec_enet_private *fep = netdev_priv(dev);
>
>
^ permalink raw reply
* Re: [BUG][mvebu] mvneta: cannot request irq 25 on openblocks-ax3
From: Gregory CLEMENT @ 2013-03-20 15:09 UTC (permalink / raw)
To: Florian Fainelli
Cc: Masami Hiramatsu, Ezequiel Garcia, linux-arm-kernel,
thomas.petazzoni, Jason Cooper, netdev, linux-kernel,
yrl.pp-manager.tt@hitachi.com
In-Reply-To: <2482565.pAEcuMH9qj@bender>
On 03/19/2013 08:48 PM, Florian Fainelli wrote:
> On Tuesday 19 March 2013 17:43:49 Gregory CLEMENT wrote:
>>
>> Hi Masami,
>>
>> You can try this patch if you want.
>> I don't have the hardware today so I didn't test it.
>> If you (and also Florian and Ezequiel) can test it and if it fixed
>> the bug, then I will be able send a proper email for it,
>
> I just tested your patch on RD-A370-A1 and DB-MV784MP-GP and it works fine,
> thanks! Feel free to add my Tested-by: Florian Fainelli <florian@openwrt.org>
> to your next submission.
>
> Thanks!
>
Thanks for having tested it, but with this patch there is still an issue when
we try to release the network interface. In this case the the interrupt line
is not properly freed.
Unfortunately the state of the percpu_irq API prevents the driver to use it.
Indeed the interrupts have to be freed when the .stop() function is
called. As the free_percpu_irq() function don't disable the interrupt
line, we have to do it on each CPU before calling this. The function
disable_percpu_irq() only disable the percpu on the current CPU and
there is no function which allows to disable a percpu irq on a given
CPU. Waiting for the extension of the percpu_irq API, this fix allows
to use again the mvneta driver.
I have just wrote and tested a new patch to fix this issue by just go back
on the old way we managed the irq for the mvenat as global irq and not
as local ones.
I am going to send the fix on the LAKML in a few minutes.
Thanks,
Gregory
^ permalink raw reply
* [PATCH] net: fec: make local function fec_poll_controller() static
From: Wei Yongjun @ 2013-03-20 15:06 UTC (permalink / raw)
To: grant.likely, rob.herring, davem, Frank.Li, shawn.guo,
fabio.estevam, s.hauer
Cc: yongjun_wei, netdev, devicetree-discuss
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
fec_poll_controller() was not declared. It should be static.
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
drivers/net/ethernet/freescale/fec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index e3f3937..1ece68b 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1559,7 +1559,7 @@ fec_set_mac_address(struct net_device *ndev, void *p)
* Polled functionality used by netconsole and others in non interrupt mode
*
*/
-void fec_poll_controller(struct net_device *dev)
+static void fec_poll_controller(struct net_device *dev)
{
int i;
struct fec_enet_private *fep = netdev_priv(dev);
^ permalink raw reply related
* [PATCH] net: ethernet: davinci_emac: make local function emac_poll_controller() static
From: Wei Yongjun @ 2013-03-20 15:01 UTC (permalink / raw)
To: grant.likely, rob.herring, davem, mugunthanvnm, jiri, agust,
bhutchings
Cc: yongjun_wei, netdev, devicetree-discuss
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
emac_poll_controller() was not declared. It should be static.
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
drivers/net/ethernet/ti/davinci_emac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index ae1b77a..e38e3d8 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1438,7 +1438,7 @@ static int emac_poll(struct napi_struct *napi, int budget)
* Polled functionality used by netconsole and others in non interrupt mode
*
*/
-void emac_poll_controller(struct net_device *ndev)
+static void emac_poll_controller(struct net_device *ndev)
{
struct emac_priv *priv = netdev_priv(ndev);
^ permalink raw reply related
* Re: [PATCH 0/7] netfilter fixes for 3.9-rc
From: David Miller @ 2013-03-20 14:25 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, netdev
In-Reply-To: <1363776574-4766-1-git-send-email-pablo@netfilter.org>
From: pablo@netfilter.org
Date: Wed, 20 Mar 2013 11:49:27 +0100
> The following patchset contains 7 Netfilter/IPVS fixes for 3.9-rc, they are:
>
> * Restrict IPv6 stateless NPT targets to the mangle table. Many users are
> complaining that this target does not work in the nat table, which is the
> wrong table for it, from Florian Westphal.
>
> * Fix possible use before initialization in the netns init path of several
> conntrack protocol trackers (introduced recently while improving conntrack
> netns support), from Gao Feng.
>
> * Fix incorrect initialization of copy_range in nfnetlink_queue, spotted
> by Eric Dumazet during the NFWS2013, patch from myself.
>
> * Fix wrong calculation of next SCTP chunk in IPVS, from Julian Anastasov.
>
> * Remove rcu_read_lock section in IPVS while calling ipv4_update_pmtu
> not required anymore after change introduced in 3.7, again from Julian.
>
> * Fix SYN looping in IPVS state sync if the backup is used a real server
> in DR/TUN modes, this required a new /proc entry to disable the director
> function when acting as backup, also from Julian.
>
> * Remove leftover IP_NF_QUEUE Kconfig after ip_queue removal, noted by
> Paul Bolle.
>
> You can pull these changes from:
>
> git://1984.lsi.us.es/nf master
Pulled, thanks!
^ permalink raw reply
* Re: [PATCH net-next 1/2] net_sched: don't do precise pkt_len computation for untrusted packets
From: Eric Dumazet @ 2013-03-20 13:46 UTC (permalink / raw)
To: Jason Wang
Cc: David Miller, netdev, linux-kernel, mst, edumazet,
Daniel Borkmann
In-Reply-To: <514954F0.2040604@redhat.com>
On Wed, 2013-03-20 at 14:19 +0800, Jason Wang wrote:
> I was consider a just skb_reset_transport_header() here. Consider the
> transport header maybe checked and reset during header check for packets
> of gso or partial checksum. And bypass precise pkt len computation.
>
> Some problems with skb_flow_dissect():
>
> - it can only recognizes a subset of all ethernet protocols. The may
> blocks guest who may want to use other protocol such as IPX.
Oh yes IPX
> - almost no check in the validity of the L4 protocol header which may be
> used by qdisc_pkt_len_init(), which may still give a chance to evil
> guest to use
> - gso_segs were untouched (still zero)
>
> Another method is doing header check here which needs more work.
Most uses are caught by the helper.
So in the case dissection fails, just reset transport header instead of
dropping as I suggested.
Otherwise, set the transport header to the right value
-> precise qdisc pkt lengths.
Instead of pretending DODGY packets have no headers, at least try to do
the right thing.
^ permalink raw reply
* Re: [PATCH 1/2] sh_eth: fix bitbang memory leak
From: Sergei Shtylyov @ 2013-03-20 13:38 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj
In-Reply-To: <201303200240.23975.sergei.shtylyov@cogentembedded.com>
Hello.
On 20-03-2013 3:40, Sergei Shtylyov wrote:
> sh_mdio_init() allocates pointer to 'struct bb_info' but only stores it locally,
> so that sh_mdio_release() can't free it on driver unload. Add the pointer to
> 'struct bb_info' to 'struct sh_eth_private', so that sh_mdio_init() can save
> 'bitbang' variable for sh_mdio_release() to be able to free it later...
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
I was in a bit of hurry and forgot to add:
CC: stable@vger.kernel.org
Do I need to repost?
WBR, Sergei
^ permalink raw reply
* Re: [PATCH 2/7] netfilter: nfnetlink_queue: fix incorrect initialization of copy range field
From: Sergei Shtylyov @ 2013-03-20 13:33 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, davem, netdev
In-Reply-To: <1363776574-4766-3-git-send-email-pablo@netfilter.org>
Hello.
On 20-03-2013 14:49, pablo@netfilter.org wrote:
> From: Pablo Neira Ayuso <pablo@netfilter.org>
> 2^16 = 0xffff,
2^16-1, to be precise.
> not 0xfffff (note the extra 'f'). Not dangerous since you
> adjust it to min_t(data_len, skb->len) just after on.
> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
WBR, Sergei
^ permalink raw reply
* Re: [PATCH v3 1/1 net-next] net: fec: put tx to napi poll function to fix dead lock
From: Frank Li @ 2013-03-20 13:33 UTC (permalink / raw)
To: Shawn Guo; +Cc: Frank Li, B38611, davem, linux-arm-kernel, netdev, s.hauer
In-Reply-To: <20130320114824.GA6088@S2101-09.ap.freescale.net>
2013/3/20 Shawn Guo <shawn.guo@linaro.org>:
> Frank,
>
> I'm running v3.9-rc3 image with NFS on imx6q, and seeing system fail
> to resume back. The resume seems being stopped by fec driver. If you
> wait long enough, you might see the repeated "eth0: tx queue full!."
> error message.
>
> Reverting the patch gets resume back to work. Can you please
> investigate?
Okay. I will check tomorrow
>
> Shawn
>
> On Mon, Mar 04, 2013 at 11:34:25AM +0800, Frank Li wrote:
>> up stack ndo_start_xmit already hold lock.
>> fec_enet_start_xmit needn't spin lock.
>> stat_xmit just update fep->cur_tx
>> fec_enet_tx just update fep->dirty_tx
>>
>> Reserve a empty bdb to check full or empty
>> cur_tx == dirty_tx means full
>> cur_tx == dirty_tx +1 means empty
>>
>> So needn't is_full variable.
>>
>> Fix spin lock deadlock
>> =================================
>> [ INFO: inconsistent lock state ]
>> 3.8.0-rc5+ #107 Not tainted
>> ---------------------------------
>> inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
>> ptp4l/615 [HC1[1]:SC0[0]:HE0:SE1] takes:
>> (&(&list->lock)->rlock#3){?.-...}, at: [<8042c3c4>] skb_queue_tail+0x20/0x50
>> {HARDIRQ-ON-W} state was registered at:
>> [<80067250>] mark_lock+0x154/0x4e8
>> [<800676f4>] mark_irqflags+0x110/0x1a4
>> [<80069208>] __lock_acquire+0x494/0x9c0
>> [<80069ce8>] lock_acquire+0x90/0xa4
>> [<80527ad0>] _raw_spin_lock_bh+0x44/0x54
>> [<804877e0>] first_packet_length+0x38/0x1f0
>> [<804879e4>] udp_poll+0x4c/0x5c
>> [<804231f8>] sock_poll+0x24/0x28
>> [<800d27f0>] do_poll.isra.10+0x120/0x254
>> [<800d36e4>] do_sys_poll+0x15c/0x1e8
>> [<800d3828>] sys_poll+0x60/0xc8
>> [<8000e780>] ret_fast_syscall+0x0/0x3c
>>
>> *** DEADLOCK ***
>>
>> 1 lock held by ptp4l/615:
>> #0: (&(&fep->hw_lock)->rlock){-.-...}, at: [<80355f9c>] fec_enet_tx+0x24/0x268
>> stack backtrace:
>> Backtrace:
>> [<800121e0>] (dump_backtrace+0x0/0x10c) from [<80516210>] (dump_stack+0x18/0x1c)
>> r6:8063b1fc r5:bf38b2f8 r4:bf38b000 r3:bf38b000
>> [<805161f8>] (dump_stack+0x0/0x1c) from [<805189d0>] (print_usage_bug.part.34+0x164/0x1a4)
>> [<8051886c>] (print_usage_bug.part.34+0x0/0x1a4) from [<80518a88>] (print_usage_bug+0x78/0x88)
>> r8:80065664 r7:bf38b2f8 r6:00000002 r5:00000000 r4:bf38b000
>> [<80518a10>] (print_usage_bug+0x0/0x88) from [<80518b58>] (mark_lock_irq+0xc0/0x270)
>> r7:bf38b000 r6:00000002 r5:bf38b2f8 r4:00000000
>> [<80518a98>] (mark_lock_irq+0x0/0x270) from [<80067270>] (mark_lock+0x174/0x4e8)
>> [<800670fc>] (mark_lock+0x0/0x4e8) from [<80067744>] (mark_irqflags+0x160/0x1a4)
>> [<800675e4>] (mark_irqflags+0x0/0x1a4) from [<80069208>] (__lock_acquire+0x494/0x9c0)
>> r5:00000002 r4:bf38b2f8
>> [<80068d74>] (__lock_acquire+0x0/0x9c0) from [<80069ce8>] (lock_acquire+0x90/0xa4)
>> [<80069c58>] (lock_acquire+0x0/0xa4) from [<805278d8>] (_raw_spin_lock_irqsave+0x4c/0x60)
>> [<8052788c>] (_raw_spin_lock_irqsave+0x0/0x60) from [<8042c3c4>] (skb_queue_tail+0x20/0x50)
>> r6:bfbb2180 r5:bf1d0190 r4:bf1d0184
>> [<8042c3a4>] (skb_queue_tail+0x0/0x50) from [<8042c4cc>] (sock_queue_err_skb+0xd8/0x188)
>> r6:00000056 r5:bfbb2180 r4:bf1d0000 r3:00000000
>> [<8042c3f4>] (sock_queue_err_skb+0x0/0x188) from [<8042d15c>] (skb_tstamp_tx+0x70/0xa0)
>> r6:bf0dddb0 r5:bf1d0000 r4:bfbb2180 r3:00000004
>> [<8042d0ec>] (skb_tstamp_tx+0x0/0xa0) from [<803561d0>] (fec_enet_tx+0x258/0x268)
>> r6:c089d260 r5:00001c00 r4:bfbd0000
>> [<80355f78>] (fec_enet_tx+0x0/0x268) from [<803562cc>] (fec_enet_interrupt+0xec/0xf8)
>> [<803561e0>] (fec_enet_interrupt+0x0/0xf8) from [<8007d5b0>] (handle_irq_event_percpu+0x54/0x1a0)
>> [<8007d55c>] (handle_irq_event_percpu+0x0/0x1a0) from [<8007d740>] (handle_irq_event+0x44/0x64)
>> [<8007d6fc>] (handle_irq_event+0x0/0x64) from [<80080690>] (handle_fasteoi_irq+0xc4/0x15c)
>> r6:bf0dc000 r5:bf811290 r4:bf811240 r3:00000000
>> [<800805cc>] (handle_fasteoi_irq+0x0/0x15c) from [<8007ceec>] (generic_handle_irq+0x28/0x38)
>> r5:807130c8 r4:00000096
>> [<8007cec4>] (generic_handle_irq+0x0/0x38) from [<8000f16c>] (handle_IRQ+0x54/0xb4)
>> r4:8071d280 r3:00000180
>> [<8000f118>] (handle_IRQ+0x0/0xb4) from [<80008544>] (gic_handle_irq+0x30/0x64)
>> r8:8000e924 r7:f4000100 r6:bf0ddef8 r5:8071c974 r4:f400010c
>> r3:00000000
>> [<80008514>] (gic_handle_irq+0x0/0x64) from [<8000e2e4>] (__irq_svc+0x44/0x5c)
>> Exception stack(0xbf0ddef8 to 0xbf0ddf40)
>>
>> Signed-off-by: Frank Li <Frank.Li@freescale.com>
>> ---
>> Change from v3 to v2
>> * remove return value of fec_enet_tx
>> Change from v1 to v2
>> * ignore TX package count in poll function
>>
>> drivers/net/ethernet/freescale/fec.c | 85 ++++++++++++++++-----------------
>> drivers/net/ethernet/freescale/fec.h | 3 -
>> 2 files changed, 41 insertions(+), 47 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
>> index 0fe68c4..bca5a24 100644
>> --- a/drivers/net/ethernet/freescale/fec.c
>> +++ b/drivers/net/ethernet/freescale/fec.c
>> @@ -246,14 +246,13 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>> struct bufdesc *bdp;
>> void *bufaddr;
>> unsigned short status;
>> - unsigned long flags;
>> + unsigned int index;
>>
>> if (!fep->link) {
>> /* Link is down or autonegotiation is in progress. */
>> return NETDEV_TX_BUSY;
>> }
>>
>> - spin_lock_irqsave(&fep->hw_lock, flags);
>> /* Fill in a Tx ring entry */
>> bdp = fep->cur_tx;
>>
>> @@ -264,7 +263,6 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>> * This should not happen, since ndev->tbusy should be set.
>> */
>> printk("%s: tx queue full!.\n", ndev->name);
>> - spin_unlock_irqrestore(&fep->hw_lock, flags);
>> return NETDEV_TX_BUSY;
>> }
>>
>> @@ -280,13 +278,13 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>> * 4-byte boundaries. Use bounce buffers to copy data
>> * and get it aligned. Ugh.
>> */
>> + if (fep->bufdesc_ex)
>> + index = (struct bufdesc_ex *)bdp -
>> + (struct bufdesc_ex *)fep->tx_bd_base;
>> + else
>> + index = bdp - fep->tx_bd_base;
>> +
>> if (((unsigned long) bufaddr) & FEC_ALIGNMENT) {
>> - unsigned int index;
>> - if (fep->bufdesc_ex)
>> - index = (struct bufdesc_ex *)bdp -
>> - (struct bufdesc_ex *)fep->tx_bd_base;
>> - else
>> - index = bdp - fep->tx_bd_base;
>> memcpy(fep->tx_bounce[index], skb->data, skb->len);
>> bufaddr = fep->tx_bounce[index];
>> }
>> @@ -300,10 +298,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>> swap_buffer(bufaddr, skb->len);
>>
>> /* Save skb pointer */
>> - fep->tx_skbuff[fep->skb_cur] = skb;
>> -
>> - ndev->stats.tx_bytes += skb->len;
>> - fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK;
>> + fep->tx_skbuff[index] = skb;
>>
>> /* Push the data cache so the CPM does not get stale memory
>> * data.
>> @@ -331,26 +326,22 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>> ebdp->cbd_esc = BD_ENET_TX_INT;
>> }
>> }
>> - /* Trigger transmission start */
>> - writel(0, fep->hwp + FEC_X_DES_ACTIVE);
>> -
>> /* If this was the last BD in the ring, start at the beginning again. */
>> if (status & BD_ENET_TX_WRAP)
>> bdp = fep->tx_bd_base;
>> else
>> bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex);
>>
>> - if (bdp == fep->dirty_tx) {
>> - fep->tx_full = 1;
>> + fep->cur_tx = bdp;
>> +
>> + if (fep->cur_tx == fep->dirty_tx)
>> netif_stop_queue(ndev);
>> - }
>>
>> - fep->cur_tx = bdp;
>> + /* Trigger transmission start */
>> + writel(0, fep->hwp + FEC_X_DES_ACTIVE);
>>
>> skb_tx_timestamp(skb);
>>
>> - spin_unlock_irqrestore(&fep->hw_lock, flags);
>> -
>> return NETDEV_TX_OK;
>> }
>>
>> @@ -406,11 +397,8 @@ fec_restart(struct net_device *ndev, int duplex)
>> writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc)
>> * RX_RING_SIZE, fep->hwp + FEC_X_DES_START);
>>
>> - fep->dirty_tx = fep->cur_tx = fep->tx_bd_base;
>> fep->cur_rx = fep->rx_bd_base;
>>
>> - /* Reset SKB transmit buffers. */
>> - fep->skb_cur = fep->skb_dirty = 0;
>> for (i = 0; i <= TX_RING_MOD_MASK; i++) {
>> if (fep->tx_skbuff[i]) {
>> dev_kfree_skb_any(fep->tx_skbuff[i]);
>> @@ -573,20 +561,35 @@ fec_enet_tx(struct net_device *ndev)
>> struct bufdesc *bdp;
>> unsigned short status;
>> struct sk_buff *skb;
>> + int index = 0;
>>
>> fep = netdev_priv(ndev);
>> - spin_lock(&fep->hw_lock);
>> bdp = fep->dirty_tx;
>>
>> + /* get next bdp of dirty_tx */
>> + if (bdp->cbd_sc & BD_ENET_TX_WRAP)
>> + bdp = fep->tx_bd_base;
>> + else
>> + bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex);
>> +
>> while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) {
>> - if (bdp == fep->cur_tx && fep->tx_full == 0)
>> +
>> + /* current queue is empty */
>> + if (bdp == fep->cur_tx)
>> break;
>>
>> + if (fep->bufdesc_ex)
>> + index = (struct bufdesc_ex *)bdp -
>> + (struct bufdesc_ex *)fep->tx_bd_base;
>> + else
>> + index = bdp - fep->tx_bd_base;
>> +
>> dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr,
>> FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
>> bdp->cbd_bufaddr = 0;
>>
>> - skb = fep->tx_skbuff[fep->skb_dirty];
>> + skb = fep->tx_skbuff[index];
>> +
>> /* Check for errors. */
>> if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC |
>> BD_ENET_TX_RL | BD_ENET_TX_UN |
>> @@ -631,8 +634,9 @@ fec_enet_tx(struct net_device *ndev)
>>
>> /* Free the sk buffer associated with this last transmit */
>> dev_kfree_skb_any(skb);
>> - fep->tx_skbuff[fep->skb_dirty] = NULL;
>> - fep->skb_dirty = (fep->skb_dirty + 1) & TX_RING_MOD_MASK;
>> + fep->tx_skbuff[index] = NULL;
>> +
>> + fep->dirty_tx = bdp;
>>
>> /* Update pointer to next buffer descriptor to be transmitted */
>> if (status & BD_ENET_TX_WRAP)
>> @@ -642,14 +646,12 @@ fec_enet_tx(struct net_device *ndev)
>>
>> /* Since we have freed up a buffer, the ring is no longer full
>> */
>> - if (fep->tx_full) {
>> - fep->tx_full = 0;
>> + if (fep->dirty_tx != fep->cur_tx) {
>> if (netif_queue_stopped(ndev))
>> netif_wake_queue(ndev);
>> }
>> }
>> - fep->dirty_tx = bdp;
>> - spin_unlock(&fep->hw_lock);
>> + return;
>> }
>>
>>
>> @@ -816,7 +818,7 @@ fec_enet_interrupt(int irq, void *dev_id)
>> int_events = readl(fep->hwp + FEC_IEVENT);
>> writel(int_events, fep->hwp + FEC_IEVENT);
>>
>> - if (int_events & FEC_ENET_RXF) {
>> + if (int_events & (FEC_ENET_RXF | FEC_ENET_TXF)) {
>> ret = IRQ_HANDLED;
>>
>> /* Disable the RX interrupt */
>> @@ -827,15 +829,6 @@ fec_enet_interrupt(int irq, void *dev_id)
>> }
>> }
>>
>> - /* Transmit OK, or non-fatal error. Update the buffer
>> - * descriptors. FEC handles all errors, we just discover
>> - * them as part of the transmit process.
>> - */
>> - if (int_events & FEC_ENET_TXF) {
>> - ret = IRQ_HANDLED;
>> - fec_enet_tx(ndev);
>> - }
>> -
>> if (int_events & FEC_ENET_MII) {
>> ret = IRQ_HANDLED;
>> complete(&fep->mdio_done);
>> @@ -851,6 +844,8 @@ static int fec_enet_rx_napi(struct napi_struct *napi, int budget)
>> int pkts = fec_enet_rx(ndev, budget);
>> struct fec_enet_private *fep = netdev_priv(ndev);
>>
>> + fec_enet_tx(ndev);
>> +
>> if (pkts < budget) {
>> napi_complete(napi);
>> writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
>> @@ -1646,6 +1641,7 @@ static int fec_enet_init(struct net_device *ndev)
>>
>> /* ...and the same for transmit */
>> bdp = fep->tx_bd_base;
>> + fep->cur_tx = bdp;
>> for (i = 0; i < TX_RING_SIZE; i++) {
>>
>> /* Initialize the BD for every fragment in the page. */
>> @@ -1657,6 +1653,7 @@ static int fec_enet_init(struct net_device *ndev)
>> /* Set the last buffer to wrap */
>> bdp = fec_enet_get_prevdesc(bdp, fep->bufdesc_ex);
>> bdp->cbd_sc |= BD_SC_WRAP;
>> + fep->dirty_tx = bdp;
>>
>> fec_restart(ndev, 0);
>>
>> diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
>> index 01579b8..c0f63be 100644
>> --- a/drivers/net/ethernet/freescale/fec.h
>> +++ b/drivers/net/ethernet/freescale/fec.h
>> @@ -214,8 +214,6 @@ struct fec_enet_private {
>> unsigned char *tx_bounce[TX_RING_SIZE];
>> struct sk_buff *tx_skbuff[TX_RING_SIZE];
>> struct sk_buff *rx_skbuff[RX_RING_SIZE];
>> - ushort skb_cur;
>> - ushort skb_dirty;
>>
>> /* CPM dual port RAM relative addresses */
>> dma_addr_t bd_dma;
>> @@ -227,7 +225,6 @@ struct fec_enet_private {
>> /* The ring entries to be free()ed */
>> struct bufdesc *dirty_tx;
>>
>> - uint tx_full;
>> /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */
>> spinlock_t hw_lock;
>>
>> --
>> 1.7.1
>>
>>
>
^ permalink raw reply
* [PATCH -next] lpc_eth: fix error return code in lpc_eth_drv_probe()
From: Wei Yongjun @ 2013-03-20 12:21 UTC (permalink / raw)
To: grant.likely, rob.herring, davem, stigge, edumazet, gregkh, jiri
Cc: yongjun_wei, netdev, devicetree-discuss
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Fix to return a negative error code from the error handling
case instead of 0, as returned elsewhere in this function.
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
drivers/net/ethernet/nxp/lpc_eth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 9c88c00..89d1b0e 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1470,7 +1470,8 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, ndev);
- if (lpc_mii_init(pldat) != 0)
+ ret = lpc_mii_init(pldat);
+ if (ret)
goto err_out_unregister_netdev;
netdev_info(ndev, "LPC mac at 0x%08x irq %d\n",
^ permalink raw reply related
* [PATCH -next] openvswitch: fix error return code in ovs_vport_cmd_set()
From: Wei Yongjun @ 2013-03-20 12:14 UTC (permalink / raw)
To: jesse, davem; +Cc: yongjun_wei, dev, netdev
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Fix to return a negative error code from the error handling
case instead of 0, as returned elsewhere in this function.
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
net/openvswitch/datapath.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index d61cd99..1ee11c3 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1736,6 +1736,7 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
reply = ovs_vport_cmd_build_info(vport, info->snd_portid, info->snd_seq,
OVS_VPORT_CMD_NEW);
+ err = PTR_ERR(reply);
if (IS_ERR(reply)) {
netlink_set_err(sock_net(skb->sk)->genl_sock, 0,
ovs_dp_vport_multicast_group.id, PTR_ERR(reply));
^ permalink raw reply related
* Re: [PATCH] fix mv643xx_eth for disabled autoneg
From: Phil Sutter @ 2013-03-20 11:49 UTC (permalink / raw)
To: Lennert Buytenhek; +Cc: Andrew Lunn, netdev
In-Reply-To: <1362592142-4049-1-git-send-email-phil.sutter@viprinet.com>
On Wed, Mar 06, 2013 at 06:49:02PM +0100, Phil Sutter wrote:
> When autoneg has been disabled in the PHY (Marvell 88E1118 here), auto
> negotiation between MAC and PHY seem non-functional anymore. The only
> way I found to workaround this is to manually configure the MAC with the
> settings sent to the PHY earlier.
And still, this is somehow broken for turned off autoneg. Not a DoS
anymore, but it seems like one can not disable duplex autoneg. No matter
what duplex settings I configure on each side, communication is still
possible.
Do you have any idea what could be missing or how to furtherly track
down the problem? Could this even be a bug in the hardware?
Best wishes, Phil
^ permalink raw reply
* [PATCH 3/5] net: au1k_ir: Use module_platform_driver()
From: Sachin Kamat @ 2013-03-20 11:41 UTC (permalink / raw)
To: netdev; +Cc: davem, sachin.kamat, Samuel Ortiz
In-Reply-To: <1363779692-4395-1-git-send-email-sachin.kamat@linaro.org>
module_platform_driver macro removes some boilerplate and
simplifies the code.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Samuel Ortiz <samuel@sortiz.org>
---
drivers/net/irda/au1k_ir.c | 13 +------------
1 files changed, 1 insertions(+), 12 deletions(-)
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index 56f1e6d..7a1f684 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -953,18 +953,7 @@ static struct platform_driver au1k_irda_driver = {
.remove = au1k_irda_remove,
};
-static int __init au1k_irda_load(void)
-{
- return platform_driver_register(&au1k_irda_driver);
-}
-
-static void __exit au1k_irda_unload(void)
-{
- return platform_driver_unregister(&au1k_irda_driver);
-}
+module_platform_driver(au1k_irda_driver);
MODULE_AUTHOR("Pete Popov <ppopov@mvista.com>");
MODULE_DESCRIPTION("Au1000 IrDA Device Driver");
-
-module_init(au1k_irda_load);
-module_exit(au1k_irda_unload);
--
1.7.4.1
^ permalink raw reply related
* Re: 3.9-rc3 forcedeth lockdep splat with netconsole
From: Borislav Petkov @ 2013-03-20 11:58 UTC (permalink / raw)
To: ML netdev, lkml
In-Reply-To: <20130320110150.GB15471@pd.tnic>
On Wed, Mar 20, 2013 at 12:01:51PM +0100, Borislav Petkov wrote:
> Hi,
>
> when trying to log stuff with netconsole, I get the following:
>
> [ … ]
>
> [ 2.036977] netpoll: netconsole: device eth0 not up yet, forcing it
> [ 2.037632] forcedeth 0000:00:08.0: irq 42 for MSI/MSI-X
> [ 2.037763] forcedeth 0000:00:08.0 eth0: MSI enabled
> [ 2.038074] forcedeth 0000:00:08.0 eth0: no link during initialization
> [ 2.780061] forcedeth 0000:00:08.0 eth0: link up
Hehe,
so it is actually funny to see the things lockdep is warning about,
in action: I was just able to hang the box with the last line above
appearing on the screen.
Fun.
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply
* [PATCH 5/5] net: mdio-octeon: Use module_platform_driver()
From: Sachin Kamat @ 2013-03-20 11:41 UTC (permalink / raw)
To: netdev; +Cc: davem, sachin.kamat, David Daney
In-Reply-To: <1363779692-4395-1-git-send-email-sachin.kamat@linaro.org>
module_platform_driver macro removes some boilerplate and
simplifies the code.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: David Daney <ddaney@caviumnetworks.com>
---
drivers/net/phy/mdio-octeon.c | 13 +------------
1 files changed, 1 insertions(+), 12 deletions(-)
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
index 09297fe..c2c878d 100644
--- a/drivers/net/phy/mdio-octeon.c
+++ b/drivers/net/phy/mdio-octeon.c
@@ -197,18 +197,7 @@ void octeon_mdiobus_force_mod_depencency(void)
}
EXPORT_SYMBOL(octeon_mdiobus_force_mod_depencency);
-static int __init octeon_mdiobus_mod_init(void)
-{
- return platform_driver_register(&octeon_mdiobus_driver);
-}
-
-static void __exit octeon_mdiobus_mod_exit(void)
-{
- platform_driver_unregister(&octeon_mdiobus_driver);
-}
-
-module_init(octeon_mdiobus_mod_init);
-module_exit(octeon_mdiobus_mod_exit);
+module_platform_driver(octeon_mdiobus_driver);
MODULE_DESCRIPTION(DRV_DESCRIPTION);
MODULE_VERSION(DRV_VERSION);
--
1.7.4.1
^ permalink raw reply related
* [PATCH 4/5] net: mdio-gpio: Use module_platform_driver()
From: Sachin Kamat @ 2013-03-20 11:41 UTC (permalink / raw)
To: netdev; +Cc: davem, sachin.kamat
In-Reply-To: <1363779692-4395-1-git-send-email-sachin.kamat@linaro.org>
module_platform_driver macro removes some boilerplate and
simplifies the code.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/net/phy/mdio-gpio.c | 12 +-----------
1 files changed, 1 insertions(+), 11 deletions(-)
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 2727498..a47f923 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -235,17 +235,7 @@ static struct platform_driver mdio_gpio_driver = {
},
};
-static int __init mdio_gpio_init(void)
-{
- return platform_driver_register(&mdio_gpio_driver);
-}
-module_init(mdio_gpio_init);
-
-static void __exit mdio_gpio_exit(void)
-{
- platform_driver_unregister(&mdio_gpio_driver);
-}
-module_exit(mdio_gpio_exit);
+module_platform_driver(mdio_gpio_driver);
MODULE_ALIAS("platform:mdio-gpio");
MODULE_AUTHOR("Laurent Pinchart, Paulius Zaleckas");
--
1.7.4.1
^ permalink raw reply related
* [PATCH 2/5] net: s6gmac: Use module_platform_driver()
From: Sachin Kamat @ 2013-03-20 11:41 UTC (permalink / raw)
To: netdev; +Cc: davem, sachin.kamat
In-Reply-To: <1363779692-4395-1-git-send-email-sachin.kamat@linaro.org>
module_platform_driver macro removes some boilerplate and
simplifies the code.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/net/ethernet/s6gmac.c | 15 +--------------
1 files changed, 1 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/s6gmac.c b/drivers/net/ethernet/s6gmac.c
index 21683e2..cd5f4e2 100644
--- a/drivers/net/ethernet/s6gmac.c
+++ b/drivers/net/ethernet/s6gmac.c
@@ -1053,20 +1053,7 @@ static struct platform_driver s6gmac_driver = {
},
};
-static int __init s6gmac_init(void)
-{
- printk(KERN_INFO DRV_PRMT "S6 GMAC ethernet driver\n");
- return platform_driver_register(&s6gmac_driver);
-}
-
-
-static void __exit s6gmac_exit(void)
-{
- platform_driver_unregister(&s6gmac_driver);
-}
-
-module_init(s6gmac_init);
-module_exit(s6gmac_exit);
+module_platform_driver(s6gmac_driver);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("S6105 on chip Ethernet driver");
--
1.7.4.1
^ permalink raw reply related
* [PATCH 1/5] net: ks8695net: Use module_platform_driver()
From: Sachin Kamat @ 2013-03-20 11:41 UTC (permalink / raw)
To: netdev; +Cc: davem, sachin.kamat
module_platform_driver macro removes some boilerplate and
simplifies the code.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/net/ethernet/micrel/ks8695net.c | 20 +-------------------
1 files changed, 1 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/micrel/ks8695net.c b/drivers/net/ethernet/micrel/ks8695net.c
index 07a6ebc..b6c60fd 100644
--- a/drivers/net/ethernet/micrel/ks8695net.c
+++ b/drivers/net/ethernet/micrel/ks8695net.c
@@ -1622,25 +1622,7 @@ static struct platform_driver ks8695_driver = {
.resume = ks8695_drv_resume,
};
-/* Module interface */
-
-static int __init
-ks8695_init(void)
-{
- printk(KERN_INFO "%s Ethernet driver, V%s\n",
- MODULENAME, MODULEVERSION);
-
- return platform_driver_register(&ks8695_driver);
-}
-
-static void __exit
-ks8695_cleanup(void)
-{
- platform_driver_unregister(&ks8695_driver);
-}
-
-module_init(ks8695_init);
-module_exit(ks8695_cleanup);
+module_platform_driver(ks8695_driver);
MODULE_AUTHOR("Simtec Electronics");
MODULE_DESCRIPTION("Micrel KS8695 (Centaur) Ethernet driver");
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH v3 1/1 net-next] net: fec: put tx to napi poll function to fix dead lock
From: Shawn Guo @ 2013-03-20 11:48 UTC (permalink / raw)
To: Frank Li; +Cc: B38611, netdev, s.hauer, lznuaa, davem, linux-arm-kernel
In-Reply-To: <1362368065-5809-1-git-send-email-Frank.Li@freescale.com>
Frank,
I'm running v3.9-rc3 image with NFS on imx6q, and seeing system fail
to resume back. The resume seems being stopped by fec driver. If you
wait long enough, you might see the repeated "eth0: tx queue full!."
error message.
Reverting the patch gets resume back to work. Can you please
investigate?
Shawn
On Mon, Mar 04, 2013 at 11:34:25AM +0800, Frank Li wrote:
> up stack ndo_start_xmit already hold lock.
> fec_enet_start_xmit needn't spin lock.
> stat_xmit just update fep->cur_tx
> fec_enet_tx just update fep->dirty_tx
>
> Reserve a empty bdb to check full or empty
> cur_tx == dirty_tx means full
> cur_tx == dirty_tx +1 means empty
>
> So needn't is_full variable.
>
> Fix spin lock deadlock
> =================================
> [ INFO: inconsistent lock state ]
> 3.8.0-rc5+ #107 Not tainted
> ---------------------------------
> inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
> ptp4l/615 [HC1[1]:SC0[0]:HE0:SE1] takes:
> (&(&list->lock)->rlock#3){?.-...}, at: [<8042c3c4>] skb_queue_tail+0x20/0x50
> {HARDIRQ-ON-W} state was registered at:
> [<80067250>] mark_lock+0x154/0x4e8
> [<800676f4>] mark_irqflags+0x110/0x1a4
> [<80069208>] __lock_acquire+0x494/0x9c0
> [<80069ce8>] lock_acquire+0x90/0xa4
> [<80527ad0>] _raw_spin_lock_bh+0x44/0x54
> [<804877e0>] first_packet_length+0x38/0x1f0
> [<804879e4>] udp_poll+0x4c/0x5c
> [<804231f8>] sock_poll+0x24/0x28
> [<800d27f0>] do_poll.isra.10+0x120/0x254
> [<800d36e4>] do_sys_poll+0x15c/0x1e8
> [<800d3828>] sys_poll+0x60/0xc8
> [<8000e780>] ret_fast_syscall+0x0/0x3c
>
> *** DEADLOCK ***
>
> 1 lock held by ptp4l/615:
> #0: (&(&fep->hw_lock)->rlock){-.-...}, at: [<80355f9c>] fec_enet_tx+0x24/0x268
> stack backtrace:
> Backtrace:
> [<800121e0>] (dump_backtrace+0x0/0x10c) from [<80516210>] (dump_stack+0x18/0x1c)
> r6:8063b1fc r5:bf38b2f8 r4:bf38b000 r3:bf38b000
> [<805161f8>] (dump_stack+0x0/0x1c) from [<805189d0>] (print_usage_bug.part.34+0x164/0x1a4)
> [<8051886c>] (print_usage_bug.part.34+0x0/0x1a4) from [<80518a88>] (print_usage_bug+0x78/0x88)
> r8:80065664 r7:bf38b2f8 r6:00000002 r5:00000000 r4:bf38b000
> [<80518a10>] (print_usage_bug+0x0/0x88) from [<80518b58>] (mark_lock_irq+0xc0/0x270)
> r7:bf38b000 r6:00000002 r5:bf38b2f8 r4:00000000
> [<80518a98>] (mark_lock_irq+0x0/0x270) from [<80067270>] (mark_lock+0x174/0x4e8)
> [<800670fc>] (mark_lock+0x0/0x4e8) from [<80067744>] (mark_irqflags+0x160/0x1a4)
> [<800675e4>] (mark_irqflags+0x0/0x1a4) from [<80069208>] (__lock_acquire+0x494/0x9c0)
> r5:00000002 r4:bf38b2f8
> [<80068d74>] (__lock_acquire+0x0/0x9c0) from [<80069ce8>] (lock_acquire+0x90/0xa4)
> [<80069c58>] (lock_acquire+0x0/0xa4) from [<805278d8>] (_raw_spin_lock_irqsave+0x4c/0x60)
> [<8052788c>] (_raw_spin_lock_irqsave+0x0/0x60) from [<8042c3c4>] (skb_queue_tail+0x20/0x50)
> r6:bfbb2180 r5:bf1d0190 r4:bf1d0184
> [<8042c3a4>] (skb_queue_tail+0x0/0x50) from [<8042c4cc>] (sock_queue_err_skb+0xd8/0x188)
> r6:00000056 r5:bfbb2180 r4:bf1d0000 r3:00000000
> [<8042c3f4>] (sock_queue_err_skb+0x0/0x188) from [<8042d15c>] (skb_tstamp_tx+0x70/0xa0)
> r6:bf0dddb0 r5:bf1d0000 r4:bfbb2180 r3:00000004
> [<8042d0ec>] (skb_tstamp_tx+0x0/0xa0) from [<803561d0>] (fec_enet_tx+0x258/0x268)
> r6:c089d260 r5:00001c00 r4:bfbd0000
> [<80355f78>] (fec_enet_tx+0x0/0x268) from [<803562cc>] (fec_enet_interrupt+0xec/0xf8)
> [<803561e0>] (fec_enet_interrupt+0x0/0xf8) from [<8007d5b0>] (handle_irq_event_percpu+0x54/0x1a0)
> [<8007d55c>] (handle_irq_event_percpu+0x0/0x1a0) from [<8007d740>] (handle_irq_event+0x44/0x64)
> [<8007d6fc>] (handle_irq_event+0x0/0x64) from [<80080690>] (handle_fasteoi_irq+0xc4/0x15c)
> r6:bf0dc000 r5:bf811290 r4:bf811240 r3:00000000
> [<800805cc>] (handle_fasteoi_irq+0x0/0x15c) from [<8007ceec>] (generic_handle_irq+0x28/0x38)
> r5:807130c8 r4:00000096
> [<8007cec4>] (generic_handle_irq+0x0/0x38) from [<8000f16c>] (handle_IRQ+0x54/0xb4)
> r4:8071d280 r3:00000180
> [<8000f118>] (handle_IRQ+0x0/0xb4) from [<80008544>] (gic_handle_irq+0x30/0x64)
> r8:8000e924 r7:f4000100 r6:bf0ddef8 r5:8071c974 r4:f400010c
> r3:00000000
> [<80008514>] (gic_handle_irq+0x0/0x64) from [<8000e2e4>] (__irq_svc+0x44/0x5c)
> Exception stack(0xbf0ddef8 to 0xbf0ddf40)
>
> Signed-off-by: Frank Li <Frank.Li@freescale.com>
> ---
> Change from v3 to v2
> * remove return value of fec_enet_tx
> Change from v1 to v2
> * ignore TX package count in poll function
>
> drivers/net/ethernet/freescale/fec.c | 85 ++++++++++++++++-----------------
> drivers/net/ethernet/freescale/fec.h | 3 -
> 2 files changed, 41 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
> index 0fe68c4..bca5a24 100644
> --- a/drivers/net/ethernet/freescale/fec.c
> +++ b/drivers/net/ethernet/freescale/fec.c
> @@ -246,14 +246,13 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> struct bufdesc *bdp;
> void *bufaddr;
> unsigned short status;
> - unsigned long flags;
> + unsigned int index;
>
> if (!fep->link) {
> /* Link is down or autonegotiation is in progress. */
> return NETDEV_TX_BUSY;
> }
>
> - spin_lock_irqsave(&fep->hw_lock, flags);
> /* Fill in a Tx ring entry */
> bdp = fep->cur_tx;
>
> @@ -264,7 +263,6 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> * This should not happen, since ndev->tbusy should be set.
> */
> printk("%s: tx queue full!.\n", ndev->name);
> - spin_unlock_irqrestore(&fep->hw_lock, flags);
> return NETDEV_TX_BUSY;
> }
>
> @@ -280,13 +278,13 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> * 4-byte boundaries. Use bounce buffers to copy data
> * and get it aligned. Ugh.
> */
> + if (fep->bufdesc_ex)
> + index = (struct bufdesc_ex *)bdp -
> + (struct bufdesc_ex *)fep->tx_bd_base;
> + else
> + index = bdp - fep->tx_bd_base;
> +
> if (((unsigned long) bufaddr) & FEC_ALIGNMENT) {
> - unsigned int index;
> - if (fep->bufdesc_ex)
> - index = (struct bufdesc_ex *)bdp -
> - (struct bufdesc_ex *)fep->tx_bd_base;
> - else
> - index = bdp - fep->tx_bd_base;
> memcpy(fep->tx_bounce[index], skb->data, skb->len);
> bufaddr = fep->tx_bounce[index];
> }
> @@ -300,10 +298,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> swap_buffer(bufaddr, skb->len);
>
> /* Save skb pointer */
> - fep->tx_skbuff[fep->skb_cur] = skb;
> -
> - ndev->stats.tx_bytes += skb->len;
> - fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK;
> + fep->tx_skbuff[index] = skb;
>
> /* Push the data cache so the CPM does not get stale memory
> * data.
> @@ -331,26 +326,22 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> ebdp->cbd_esc = BD_ENET_TX_INT;
> }
> }
> - /* Trigger transmission start */
> - writel(0, fep->hwp + FEC_X_DES_ACTIVE);
> -
> /* If this was the last BD in the ring, start at the beginning again. */
> if (status & BD_ENET_TX_WRAP)
> bdp = fep->tx_bd_base;
> else
> bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex);
>
> - if (bdp == fep->dirty_tx) {
> - fep->tx_full = 1;
> + fep->cur_tx = bdp;
> +
> + if (fep->cur_tx == fep->dirty_tx)
> netif_stop_queue(ndev);
> - }
>
> - fep->cur_tx = bdp;
> + /* Trigger transmission start */
> + writel(0, fep->hwp + FEC_X_DES_ACTIVE);
>
> skb_tx_timestamp(skb);
>
> - spin_unlock_irqrestore(&fep->hw_lock, flags);
> -
> return NETDEV_TX_OK;
> }
>
> @@ -406,11 +397,8 @@ fec_restart(struct net_device *ndev, int duplex)
> writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc)
> * RX_RING_SIZE, fep->hwp + FEC_X_DES_START);
>
> - fep->dirty_tx = fep->cur_tx = fep->tx_bd_base;
> fep->cur_rx = fep->rx_bd_base;
>
> - /* Reset SKB transmit buffers. */
> - fep->skb_cur = fep->skb_dirty = 0;
> for (i = 0; i <= TX_RING_MOD_MASK; i++) {
> if (fep->tx_skbuff[i]) {
> dev_kfree_skb_any(fep->tx_skbuff[i]);
> @@ -573,20 +561,35 @@ fec_enet_tx(struct net_device *ndev)
> struct bufdesc *bdp;
> unsigned short status;
> struct sk_buff *skb;
> + int index = 0;
>
> fep = netdev_priv(ndev);
> - spin_lock(&fep->hw_lock);
> bdp = fep->dirty_tx;
>
> + /* get next bdp of dirty_tx */
> + if (bdp->cbd_sc & BD_ENET_TX_WRAP)
> + bdp = fep->tx_bd_base;
> + else
> + bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex);
> +
> while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) {
> - if (bdp == fep->cur_tx && fep->tx_full == 0)
> +
> + /* current queue is empty */
> + if (bdp == fep->cur_tx)
> break;
>
> + if (fep->bufdesc_ex)
> + index = (struct bufdesc_ex *)bdp -
> + (struct bufdesc_ex *)fep->tx_bd_base;
> + else
> + index = bdp - fep->tx_bd_base;
> +
> dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr,
> FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
> bdp->cbd_bufaddr = 0;
>
> - skb = fep->tx_skbuff[fep->skb_dirty];
> + skb = fep->tx_skbuff[index];
> +
> /* Check for errors. */
> if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC |
> BD_ENET_TX_RL | BD_ENET_TX_UN |
> @@ -631,8 +634,9 @@ fec_enet_tx(struct net_device *ndev)
>
> /* Free the sk buffer associated with this last transmit */
> dev_kfree_skb_any(skb);
> - fep->tx_skbuff[fep->skb_dirty] = NULL;
> - fep->skb_dirty = (fep->skb_dirty + 1) & TX_RING_MOD_MASK;
> + fep->tx_skbuff[index] = NULL;
> +
> + fep->dirty_tx = bdp;
>
> /* Update pointer to next buffer descriptor to be transmitted */
> if (status & BD_ENET_TX_WRAP)
> @@ -642,14 +646,12 @@ fec_enet_tx(struct net_device *ndev)
>
> /* Since we have freed up a buffer, the ring is no longer full
> */
> - if (fep->tx_full) {
> - fep->tx_full = 0;
> + if (fep->dirty_tx != fep->cur_tx) {
> if (netif_queue_stopped(ndev))
> netif_wake_queue(ndev);
> }
> }
> - fep->dirty_tx = bdp;
> - spin_unlock(&fep->hw_lock);
> + return;
> }
>
>
> @@ -816,7 +818,7 @@ fec_enet_interrupt(int irq, void *dev_id)
> int_events = readl(fep->hwp + FEC_IEVENT);
> writel(int_events, fep->hwp + FEC_IEVENT);
>
> - if (int_events & FEC_ENET_RXF) {
> + if (int_events & (FEC_ENET_RXF | FEC_ENET_TXF)) {
> ret = IRQ_HANDLED;
>
> /* Disable the RX interrupt */
> @@ -827,15 +829,6 @@ fec_enet_interrupt(int irq, void *dev_id)
> }
> }
>
> - /* Transmit OK, or non-fatal error. Update the buffer
> - * descriptors. FEC handles all errors, we just discover
> - * them as part of the transmit process.
> - */
> - if (int_events & FEC_ENET_TXF) {
> - ret = IRQ_HANDLED;
> - fec_enet_tx(ndev);
> - }
> -
> if (int_events & FEC_ENET_MII) {
> ret = IRQ_HANDLED;
> complete(&fep->mdio_done);
> @@ -851,6 +844,8 @@ static int fec_enet_rx_napi(struct napi_struct *napi, int budget)
> int pkts = fec_enet_rx(ndev, budget);
> struct fec_enet_private *fep = netdev_priv(ndev);
>
> + fec_enet_tx(ndev);
> +
> if (pkts < budget) {
> napi_complete(napi);
> writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
> @@ -1646,6 +1641,7 @@ static int fec_enet_init(struct net_device *ndev)
>
> /* ...and the same for transmit */
> bdp = fep->tx_bd_base;
> + fep->cur_tx = bdp;
> for (i = 0; i < TX_RING_SIZE; i++) {
>
> /* Initialize the BD for every fragment in the page. */
> @@ -1657,6 +1653,7 @@ static int fec_enet_init(struct net_device *ndev)
> /* Set the last buffer to wrap */
> bdp = fec_enet_get_prevdesc(bdp, fep->bufdesc_ex);
> bdp->cbd_sc |= BD_SC_WRAP;
> + fep->dirty_tx = bdp;
>
> fec_restart(ndev, 0);
>
> diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
> index 01579b8..c0f63be 100644
> --- a/drivers/net/ethernet/freescale/fec.h
> +++ b/drivers/net/ethernet/freescale/fec.h
> @@ -214,8 +214,6 @@ struct fec_enet_private {
> unsigned char *tx_bounce[TX_RING_SIZE];
> struct sk_buff *tx_skbuff[TX_RING_SIZE];
> struct sk_buff *rx_skbuff[RX_RING_SIZE];
> - ushort skb_cur;
> - ushort skb_dirty;
>
> /* CPM dual port RAM relative addresses */
> dma_addr_t bd_dma;
> @@ -227,7 +225,6 @@ struct fec_enet_private {
> /* The ring entries to be free()ed */
> struct bufdesc *dirty_tx;
>
> - uint tx_full;
> /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */
> spinlock_t hw_lock;
>
> --
> 1.7.1
>
>
^ permalink raw reply
* 3.9-rc3 forcedeth lockdep splat with netconsole
From: Borislav Petkov @ 2013-03-20 11:01 UTC (permalink / raw)
To: ML netdev; +Cc: lkml
Hi,
when trying to log stuff with netconsole, I get the following:
[ … ]
[ 2.036977] netpoll: netconsole: device eth0 not up yet, forcing it
[ 2.037632] forcedeth 0000:00:08.0: irq 42 for MSI/MSI-X
[ 2.037763] forcedeth 0000:00:08.0 eth0: MSI enabled
[ 2.038074] forcedeth 0000:00:08.0 eth0: no link during initialization
[ 2.780061] forcedeth 0000:00:08.0 eth0: link up
[ 2.780709]
[ 2.780710] =================================
[ 2.780710] [ INFO: inconsistent lock state ]
[ 2.780712] 3.9.0-rc3+ #2 Not tainted
[ 2.780712] ---------------------------------
[ 2.780713] inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
[ 2.780715] swapper/0/1 [HC0[0]:SC0[0]:HE1:SE1] takes:
[ 2.780723] (&(&napi->poll_lock)->rlock){+.?...}, at: [<ffffffff8147b045>] netpoll_poll_dev+0xe5/0xc80
[ 2.780723] {IN-SOFTIRQ-W} state was registered at:
[ 2.780728] [<ffffffff8109ade8>] __lock_acquire+0x608/0x1de0
[ 2.780730] [<ffffffff8109cc9e>] lock_acquire+0x9e/0x1f0
[ 2.780733] [<ffffffff81529811>] _raw_spin_lock+0x41/0x80
[ 2.780736] [<ffffffff8145fc1e>] net_rx_action+0xbe/0x330
[ 2.780739] [<ffffffff81044949>] __do_softirq+0xe9/0x3d0
[ 2.780740] [<ffffffff81044c65>] run_ksoftirqd+0x35/0x50
[ 2.780744] [<ffffffff8106dba4>] smpboot_thread_fn+0x1d4/0x2e0
[ 2.780749] [<ffffffff81064b4b>] kthread+0xdb/0xe0
[ 2.780751] [<ffffffff8152b45c>] ret_from_fork+0x7c/0xb0
[ 2.780752] irq event stamp: 576121
[ 2.780754] hardirqs last enabled at (576121): [<ffffffff8152aa20>] restore_args+0x0/0x30
[ 2.780756] hardirqs last disabled at (576120): [<ffffffff8152a96a>] common_interrupt+0x6a/0x6f
[ 2.780758] softirqs last enabled at (576090): [<ffffffff810449d5>] __do_softirq+0x175/0x3d0
[ 2.780759] softirqs last disabled at (576085): [<ffffffff81044d96>] irq_exit+0x96/0xb0
[ 2.780760]
[ 2.780760] other info that might help us debug this:
[ 2.780760] Possible unsafe locking scenario:
[ 2.780760]
[ 2.780761] CPU0
[ 2.780761] ----
[ 2.780762] lock(&(&napi->poll_lock)->rlock);
[ 2.780763] <Interrupt>
[ 2.780764] lock(&(&napi->poll_lock)->rlock);
[ 2.780764]
[ 2.780764] *** DEADLOCK ***
[ 2.780764]
[ 2.780765] 3 locks held by swapper/0/1:
[ 2.780768] #0: (console_lock){+.+.+.}, at: [<ffffffff8103e96e>] register_console+0xfe/0x390
[ 2.780772] #1: (target_list_lock){+.+...}, at: [<ffffffff81370033>] write_msg+0x53/0x110
[ 2.780775] #2: (&npinfo->dev_lock){+.+...}, at: [<ffffffff8147afa6>] netpoll_poll_dev+0x46/0xc80
[ 2.780776]
[ 2.780776] stack backtrace:
[ 2.780777] Pid: 1, comm: swapper/0 Not tainted 3.9.0-rc3+ #2
[ 2.780778] Call Trace:
[ 2.780781] [<ffffffff81521b9a>] print_usage_bug.part.34+0x270/0x27f
[ 2.780785] [<ffffffff810108cf>] ? save_stack_trace+0x2f/0x50
[ 2.780787] [<ffffffff810792e3>] ? local_clock+0x43/0x50
[ 2.780789] [<ffffffff81097630>] ? print_shortest_lock_dependencies+0x1d0/0x1d0
[ 2.780791] [<ffffffff810984fb>] mark_lock+0x27b/0x600
[ 2.780793] [<ffffffff8109ae56>] __lock_acquire+0x676/0x1de0
[ 2.780795] [<ffffffff8152aa20>] ? retint_restore_args+0xe/0xe
[ 2.780797] [<ffffffff8152a3a7>] ? _raw_spin_unlock_irqrestore+0x67/0x80
[ 2.780799] [<ffffffff8109cc9e>] lock_acquire+0x9e/0x1f0
[ 2.780801] [<ffffffff8147b045>] ? netpoll_poll_dev+0xe5/0xc80
[ 2.780803] [<ffffffff8152a4e3>] _raw_spin_trylock+0x73/0x90
[ 2.780804] [<ffffffff8147b045>] ? netpoll_poll_dev+0xe5/0xc80
[ 2.780806] [<ffffffff8147b045>] netpoll_poll_dev+0xe5/0xc80
[ 2.780808] [<ffffffff810967ae>] ? put_lock_stats.isra.17+0xe/0x40
[ 2.780810] [<ffffffff8147bee4>] ? netpoll_send_skb_on_dev+0x304/0x400
[ 2.780812] [<ffffffff8147bef5>] netpoll_send_skb_on_dev+0x315/0x400
[ 2.780814] [<ffffffff8147c267>] netpoll_send_udp+0x287/0x3a0
[ 2.780815] [<ffffffff81370033>] ? write_msg+0x53/0x110
[ 2.780817] [<ffffffff8137009f>] write_msg+0xbf/0x110
[ 2.780818] [<ffffffff8103d8c7>] ? console_unlock+0x3d7/0x450
[ 2.780820] [<ffffffff8103c9da>] call_console_drivers.constprop.15+0x9a/0x1d0
[ 2.780822] [<ffffffff8103d8d7>] console_unlock+0x3e7/0x450
[ 2.780823] [<ffffffff8103e9a7>] register_console+0x137/0x390
[ 2.780826] [<ffffffff81a18281>] init_netconsole+0x1a6/0x214
[ 2.780828] [<ffffffff8131db00>] ? driver_deferred_probe_trigger.part.9+0x80/0x80
[ 2.780830] [<ffffffff81a180db>] ? option_setup+0x1f/0x1f
[ 2.780832] [<ffffffff81000312>] do_one_initcall+0x122/0x170
[ 2.780836] [<ffffffff819f5e2b>] kernel_init_freeable+0x103/0x192
[ 2.780837] [<ffffffff819f57e8>] ? do_early_param+0x8c/0x8c
[ 2.780840] [<ffffffff81512760>] ? rest_init+0x140/0x140
[ 2.780842] [<ffffffff8151276e>] kernel_init+0xe/0xe0
[ 2.780844] [<ffffffff8152b45c>] ret_from_fork+0x7c/0xb0
[ 2.780845] [<ffffffff81512760>] ? rest_init+0x140/0x140
[ 2.780899] ------------[ cut here ]------------
[ 2.780901] WARNING: at net/core/netpoll.c:412 netpoll_send_skb_on_dev+0x3e9/0x400()
[ 2.780903] Hardware name:
[ 2.780905] netpoll_send_skb_on_dev(): eth0 enabled interrupts in poll (nv_start_xmit_optimized+0x0/0x720)
[ 2.780907] Modules linked in:
[ 2.780908] Pid: 1, comm: swapper/0 Not tainted 3.9.0-rc3+ #2
[ 2.780908] Call Trace:
[ 2.780910] [<ffffffff8147bfc9>] ? netpoll_send_skb_on_dev+0x3e9/0x400
[ 2.780913] [<ffffffff8103b4ff>] warn_slowpath_common+0x7f/0xc0
[ 2.780915] [<ffffffff8103b5f6>] warn_slowpath_fmt+0x46/0x50
[ 2.780916] [<ffffffff813752a0>] ? nv_get_drvinfo+0x80/0x80
[ 2.780918] [<ffffffff8147bfc9>] netpoll_send_skb_on_dev+0x3e9/0x400
[ 2.780920] [<ffffffff8147c267>] netpoll_send_udp+0x287/0x3a0
[ 2.780922] [<ffffffff81370033>] ? write_msg+0x53/0x110
[ 2.780924] [<ffffffff8137009f>] write_msg+0xbf/0x110
[ 2.780925] [<ffffffff8103d8c7>] ? console_unlock+0x3d7/0x450
[ 2.780927] [<ffffffff8103c9da>] call_console_drivers.constprop.15+0x9a/0x1d0
[ 2.780928] [<ffffffff8103d8d7>] console_unlock+0x3e7/0x450
[ 2.780931] [<ffffffff8103e9a7>] register_console+0x137/0x390
[ 2.780933] [<ffffffff81a18281>] init_netconsole+0x1a6/0x214
[ 2.780934] [<ffffffff8131db00>] ? driver_deferred_probe_trigger.part.9+0x80/0x80
[ 2.780936] [<ffffffff81a180db>] ? option_setup+0x1f/0x1f
[ 2.780938] [<ffffffff81000312>] do_one_initcall+0x122/0x170
[ 2.780940] [<ffffffff819f5e2b>] kernel_init_freeable+0x103/0x192
[ 2.780941] [<ffffffff819f57e8>] ? do_early_param+0x8c/0x8c
[ 2.780943] [<ffffffff81512760>] ? rest_init+0x140/0x140
[ 2.780945] [<ffffffff8151276e>] kernel_init+0xe/0xe0
[ 2.780947] [<ffffffff8152b45c>] ret_from_fork+0x7c/0xb0
[ 2.780948] [<ffffffff81512760>] ? rest_init+0x140/0x140
[ 2.780950] ---[ end trace a7ed4414d27e5db1 ]---
[ 2.789399] console [netcon0] enabled
[ 2.789445] netconsole: network logging started
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply
* [PATCH 5/7] ipvs: add backup_only flag to avoid loops
From: pablo @ 2013-03-20 10:49 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
In-Reply-To: <1363776574-4766-1-git-send-email-pablo@netfilter.org>
From: Julian Anastasov <ja@ssi.bg>
Dmitry Akindinov is reporting for a problem where SYNs are looping
between the master and backup server when the backup server is used as
real server in DR mode and has IPVS rules to function as director.
Even when the backup function is enabled we continue to forward
traffic and schedule new connections when the current master is using
the backup server as real server. While this is not a problem for NAT,
for DR and TUN method the backup server can not determine if a request
comes from client or from director.
To avoid such loops add new sysctl flag backup_only. It can be needed
for DR/TUN setups that do not need backup and director function at the
same time. When the backup function is enabled we stop any forwarding
and pass the traffic to the local stack (real server mode). The flag
disables the director function when the backup function is enabled.
For setups that enable backup function for some virtual services and
director function for other virtual services there should be another
more complex solution to support DR/TUN mode, may be to assign
per-virtual service syncid value, so that we can differentiate the
requests.
Reported-by: Dmitry Akindinov <dimak@stalker.com>
Tested-by: German Myzovsky <lawyer@sipnet.ru>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
Documentation/networking/ipvs-sysctl.txt | 7 +++++++
include/net/ip_vs.h | 12 ++++++++++++
net/netfilter/ipvs/ip_vs_core.c | 12 ++++++++----
net/netfilter/ipvs/ip_vs_ctl.c | 7 +++++++
4 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/Documentation/networking/ipvs-sysctl.txt b/Documentation/networking/ipvs-sysctl.txt
index f2a2488..9573d0c 100644
--- a/Documentation/networking/ipvs-sysctl.txt
+++ b/Documentation/networking/ipvs-sysctl.txt
@@ -15,6 +15,13 @@ amemthresh - INTEGER
enabled and the variable is automatically set to 2, otherwise
the strategy is disabled and the variable is set to 1.
+backup_only - BOOLEAN
+ 0 - disabled (default)
+ not 0 - enabled
+
+ If set, disable the director function while the server is
+ in backup mode to avoid packet loops for DR/TUN methods.
+
conntrack - BOOLEAN
0 - disabled (default)
not 0 - enabled
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 68c69d5..fce8e6b 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -976,6 +976,7 @@ struct netns_ipvs {
int sysctl_sync_retries;
int sysctl_nat_icmp_send;
int sysctl_pmtu_disc;
+ int sysctl_backup_only;
/* ip_vs_lblc */
int sysctl_lblc_expiration;
@@ -1067,6 +1068,12 @@ static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs)
return ipvs->sysctl_pmtu_disc;
}
+static inline int sysctl_backup_only(struct netns_ipvs *ipvs)
+{
+ return ipvs->sync_state & IP_VS_STATE_BACKUP &&
+ ipvs->sysctl_backup_only;
+}
+
#else
static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
@@ -1114,6 +1121,11 @@ static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs)
return 1;
}
+static inline int sysctl_backup_only(struct netns_ipvs *ipvs)
+{
+ return 0;
+}
+
#endif
/*
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 47edf5a..18b4bc5 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1577,7 +1577,8 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
}
/* ipvs enabled in this netns ? */
net = skb_net(skb);
- if (!net_ipvs(net)->enable)
+ ipvs = net_ipvs(net);
+ if (unlikely(sysctl_backup_only(ipvs) || !ipvs->enable))
return NF_ACCEPT;
ip_vs_fill_iph_skb(af, skb, &iph);
@@ -1654,7 +1655,6 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
}
IP_VS_DBG_PKT(11, af, pp, skb, 0, "Incoming packet");
- ipvs = net_ipvs(net);
/* Check the server status */
if (cp->dest && !(cp->dest->flags & IP_VS_DEST_F_AVAILABLE)) {
/* the destination server is not available */
@@ -1815,13 +1815,15 @@ ip_vs_forward_icmp(unsigned int hooknum, struct sk_buff *skb,
{
int r;
struct net *net;
+ struct netns_ipvs *ipvs;
if (ip_hdr(skb)->protocol != IPPROTO_ICMP)
return NF_ACCEPT;
/* ipvs enabled in this netns ? */
net = skb_net(skb);
- if (!net_ipvs(net)->enable)
+ ipvs = net_ipvs(net);
+ if (unlikely(sysctl_backup_only(ipvs) || !ipvs->enable))
return NF_ACCEPT;
return ip_vs_in_icmp(skb, &r, hooknum);
@@ -1835,6 +1837,7 @@ ip_vs_forward_icmp_v6(unsigned int hooknum, struct sk_buff *skb,
{
int r;
struct net *net;
+ struct netns_ipvs *ipvs;
struct ip_vs_iphdr iphdr;
ip_vs_fill_iph_skb(AF_INET6, skb, &iphdr);
@@ -1843,7 +1846,8 @@ ip_vs_forward_icmp_v6(unsigned int hooknum, struct sk_buff *skb,
/* ipvs enabled in this netns ? */
net = skb_net(skb);
- if (!net_ipvs(net)->enable)
+ ipvs = net_ipvs(net);
+ if (unlikely(sysctl_backup_only(ipvs) || !ipvs->enable))
return NF_ACCEPT;
return ip_vs_in_icmp_v6(skb, &r, hooknum, &iphdr);
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index c68198b..9e2d1cc 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -1808,6 +1808,12 @@ static struct ctl_table vs_vars[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
+ {
+ .procname = "backup_only",
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
#ifdef CONFIG_IP_VS_DEBUG
{
.procname = "debug_level",
@@ -3741,6 +3747,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
tbl[idx++].data = &ipvs->sysctl_nat_icmp_send;
ipvs->sysctl_pmtu_disc = 1;
tbl[idx++].data = &ipvs->sysctl_pmtu_disc;
+ tbl[idx++].data = &ipvs->sysctl_backup_only;
ipvs->sysctl_hdr = register_net_sysctl(net, "net/ipv4/vs", tbl);
--
1.7.10.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox