Netdev List
 help / color / mirror / Atom feed
* [PATCH 2/2] SELinux: indicate fatal error in compat netfilter code
From: Eric Paris @ 2010-11-23 16:28 UTC (permalink / raw)
  To: netdev, selinux; +Cc: sds, paul.moore, davem
In-Reply-To: <20101123162802.3588.74894.stgit@paris.rdu.redhat.com>

The SELinux ip postroute code indicates when policy rejected a packet and
passes the error back up the stack.  The compat code does not.  This patch
sends the same kind of error back up the stack in the compat code.

Based-on-patch-by: Paul Moore <paul.moore@hp.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
---

 security/selinux/hooks.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index bd6dc16..dd1690f 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4529,11 +4529,11 @@ static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb,
 	if (selinux_secmark_enabled())
 		if (avc_has_perm(sksec->sid, skb->secmark,
 				 SECCLASS_PACKET, PACKET__SEND, &ad))
-			return NF_DROP;
+			return NF_DROP_ERR(-ECONNREFUSED);
 
 	if (selinux_policycap_netpeer)
 		if (selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto))
-			return NF_DROP;
+			return NF_DROP_ERR(-ECONNREFUSED);
 
 	return NF_ACCEPT;
 }


^ permalink raw reply related

* [PATCH 1/2] SELinux: Only return netlink error when we know the return is fatal
From: Eric Paris @ 2010-11-23 16:28 UTC (permalink / raw)
  To: netdev, selinux; +Cc: sds, paul.moore, davem

Some of the SELinux netlink code returns a fatal error when the error might
actually be transient.  This patch just silently drops packets on
potentially transient errors but continues to return a permanant error
indicator when the denial was because of policy.

Based-on-comments-by: Paul Moore <paul.moore@hp.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
---

 security/selinux/hooks.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index a0bc5c0..bd6dc16 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4594,7 +4594,7 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
 		}
 		if (secmark_perm == PACKET__FORWARD_OUT) {
 			if (selinux_skb_peerlbl_sid(skb, family, &peer_sid))
-				return NF_DROP_ERR(-ECONNREFUSED);
+				return NF_DROP;
 		} else
 			peer_sid = SECINITSID_KERNEL;
 	} else {
@@ -4607,7 +4607,7 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
 	ad.u.net.netif = ifindex;
 	ad.u.net.family = family;
 	if (selinux_parse_skb(skb, &ad, &addrp, 0, NULL))
-		return NF_DROP_ERR(-ECONNREFUSED);
+		return NF_DROP;
 
 	if (secmark_active)
 		if (avc_has_perm(peer_sid, skb->secmark,
@@ -4619,13 +4619,13 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
 		u32 node_sid;
 
 		if (sel_netif_sid(ifindex, &if_sid))
-			return NF_DROP_ERR(-ECONNREFUSED);
+			return NF_DROP;
 		if (avc_has_perm(peer_sid, if_sid,
 				 SECCLASS_NETIF, NETIF__EGRESS, &ad))
 			return NF_DROP_ERR(-ECONNREFUSED);
 
 		if (sel_netnode_sid(addrp, family, &node_sid))
-			return NF_DROP_ERR(-ECONNREFUSED);
+			return NF_DROP;
 		if (avc_has_perm(peer_sid, node_sid,
 				 SECCLASS_NODE, NODE__SENDTO, &ad))
 			return NF_DROP_ERR(-ECONNREFUSED);


^ permalink raw reply related

* Re: [PATCH 00/62] drivers/net: Use static const
From: David Miller @ 2010-11-23 16:28 UTC (permalink / raw)
  To: joe-6d6DIl74uiNBDgjK7y7TUQ
  Cc: ath5k-devel-xDcbHBWguxEUs3QNXV6qNA,
	libertas-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	e1000-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	users-poMEt7QlJxcwIE2E9O76wjtx2kNaKg5H,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	ath9k-devel-xDcbHBWguxHbcTqmT+pZeQ
In-Reply-To: <1290465605.27683.52.camel@Joe-Laptop>

From: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
Date: Mon, 22 Nov 2010 14:40:05 -0800

> I'll see who picks up or acks what and send a pull request to
> you for the remainder of these patches mid December or so.

Thanks.

> Do you want micro patches or a single patch?

You can group them by directory or similar if you like.

F.e.:

Patch 1: drivers/net/*.c
Patch 2: drivers/net/*/*.c (wired drivers)
Patch 3: drivers/net/wireless/*

Thanks again.

^ permalink raw reply

* Re: [PATCH] iproute2: support xfrm upper protocol gre key
From: Stephen Hemminger @ 2010-11-23 16:24 UTC (permalink / raw)
  To: Timo Teräs; +Cc: netdev
In-Reply-To: <1290524559-22086-1-git-send-email-timo.teras@iki.fi>

On Tue, 23 Nov 2010 17:02:39 +0200
Timo Teräs <timo.teras@iki.fi> wrote:

> +	case IPPROTO_GRE:
> +		if (sel->sport_mask || sel->dport_mask) {
> +			struct in_addr key;
> +			key.s_addr = htonl((ntohs(sel->sport) << 16) + ntohs(sel->dport));
> +			inet_ntop(AF_INET, &key, abuf, sizeof(abuf));
> +			fprintf(fp, "key %s ", abuf);
> +		}

The GRE key is not really an IPv4 address. Why should the utilities
use IPv4 address manipulation to format/scan it.  It makes more sense
to me to just use u32 an do the necessary ntohl.


-- 

^ permalink raw reply

* [PATCH net-next] bnx2x: Resolving a possible dead-lock situation
From: Vladislav Zolotarov @ 2010-11-23 16:15 UTC (permalink / raw)
  To: Dave Miller; +Cc: Eilon Greenstein, netdev list

There is a possible dead-lock situation between sch_direct_xmit() 
(called from soft_IRQ context) and bnx2x_tx_int() when called from 
an ethtool self-test flow (syscall context).

To prevent a dead-lock, disable bottom-halves on a local CPU when taking
a tx_lock from bnx2x_tx_int() (use __netif_tx_lock_bh(txq)).

The flow in the bnx2x_tx_int() where tx_lock is taken should be hit
very rarely thus performance penalty of this change should be minimal.

Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
 drivers/net/bnx2x/bnx2x_cmn.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index 94d5f59..5189788 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -144,14 +144,14 @@ int bnx2x_tx_int(struct bnx2x_fastpath *fp)
 		 * stops the queue
 		 */
 
-		__netif_tx_lock(txq, smp_processor_id());
+		__netif_tx_lock_bh(txq);
 
 		if ((netif_tx_queue_stopped(txq)) &&
 		    (bp->state == BNX2X_STATE_OPEN) &&
 		    (bnx2x_tx_avail(fp) >= MAX_SKB_FRAGS + 3))
 			netif_tx_wake_queue(txq);
 
-		__netif_tx_unlock(txq);
+		__netif_tx_unlock_bh(txq);
 	}
 	return 0;
 }
-- 
1.7.0.4





^ permalink raw reply related

* Re: [PATCH 4/9] AF_UNIX: find the recipients for multicast messages
From: Eric Dumazet @ 2010-11-23 16:08 UTC (permalink / raw)
  To: Alban Crequy
  Cc: David Miller, shemminger, gorcunov, adobriyan, lennart,
	kay.sievers, ian.molton, netdev, linux-kernel
In-Reply-To: <20101123150315.4e67a139@chocolatine.cbg.collabora.co.uk>

Le mardi 23 novembre 2010 à 15:03 +0000, Alban Crequy a écrit :
> Le Mon, 22 Nov 2010 11:05:19 -0800 (PST),
> David Miller <davem@davemloft.net> a écrit :
> 
> > From: Alban Crequy <alban.crequy@collabora.co.uk>
> > Date: Mon, 22 Nov 2010 18:36:17 +0000
> > 
> > > unix_find_multicast_recipients() builds an array of recipients. It
> > > can either find the peers of a specific multicast address, or find
> > > all the peers of all multicast group the sender is part of.
> > > 
> > > Signed-off-by: Alban Crequy <alban.crequy@collabora.co.uk>
> > 
> > You really should use RCU to lock this stuff, this way sends run
> > lockless and have less worries wrt. the memory allocation.  You'll
> > also only take a spinlock in the write paths which change the
> > multicast groups, which ought to be rare.
> 
> I understand the benefit to use RCU in order to have lockless sends.
> 
> But with RCU I will still have worries about the memory allocation:
> 
> - I cannot allocate inside a rcu_read_lock()-rcu_read_unlock() block.
> 

Thats not true.

Sames rules than inside a spin_lock() or write_lock() apply.

We already allocate memory inside rcu_read_lock() in network stack.

> - If I iterate locklessly over the multicast group members with 
>   hlist_for_each_entry_rcu(), new members can be added, so the
>   array can be allocated with the wrong size and I have to try again
>   ("goto try_again") when this rare case occurs.

You are allowed to allocate memory to add stuff while doing your loop
iteration.

Nothing prevents you to use a chain of items, each item holding up to
128 sockets for example. If full, allocate a new item.

We have such schem in poll()/select() for example 

fs/select.c  function poll_get_entry()

Use a small embedded struct on stack, and allocate extra items if number
of fd is too big.

(If you cant allocate memory to hold pointers, chance is you wont be
able to clone skbs anyway. One skb is about 400 bytes.)

If new members are added to the group while you are iterating the list,
they wont receive a copy of the message.

Or just chain skbs while you clone them, store in skb->sk the socket...
no need for extra memory allocations.

> 
> - Another idea would be to avoid completely the allocation by inlining
>   unix_find_multicast_recipients() inside unix_dgram_sendmsg() and
>   delivering the messages to the recipients as long as the list is
>   being iterated locklessly. But I want to provide atomicity of
>   delivery: the message must be delivered with skb_queue_tail() either
>   to all the recipients or to none of them in case of interruption or
>   memory pressure. I don't see how I can achieve that without
>   iterating several times on the list of recipients, hence the
>   allocation and the copy in the array. I also want to guarantee the
>   order of delivery as described in multicast-unix-sockets.txt and for
>   this, I am taking lots of spinlocks anyway. I don't see how to avoid
>   that, but I would be happy to be wrong and have a better solution.
> 


So if one destination has a full receive queue, you want nobody receive
the message ? That seems a bit risky to me, if someone sends SIGSTOP to
one of your process...



> 
> To give an idea of the number of members in a multicast group for the
> D-Bus use case, I have 90 D-Bus connections on my session bus:
> 
> $ dbus-send --print-reply --dest=org.freedesktop.DBus \
> /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep '":'|wc -l
> 90
> 
> In common cases, there should be only a few real recipients (1 or 2?)
> after the socket filters eliminate most of them, but
> unix_find_multicast_recipients() will still allocate an array of
> about that size.
> 

I am not sure if doing 90 clones of skb and filtering them one by one is
going to be fast :-(

^ permalink raw reply

* Re: [PATCH] flexcan: fix NAPI for bus errors
From: Marc Kleine-Budde @ 2010-11-23 15:39 UTC (permalink / raw)
  To: John Ogness
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	netdev-u79uwXL29TY76Z2rM5mHXA, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	Wolfgang Grandegger
In-Reply-To: <80k4k45csy.fsf-l77OnrVvfFAyMciVaGeJ0d53zsg1cpMQ@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 3280 bytes --]

Hello,

On 11/23/2010 03:34 PM, John Ogness wrote:
> If bus error reporting is disabled and bus errors occur, the flexcan
> driver will hog the system because it continually re-enables the IRQs
> (work_done = 0). This patch changes the driver to only re-enable the
> IRQs if some work was actually done. This allows the features of NAPI to
> be used for bus errors as well (when bus error reporting is disabled).

Good idea, however the chip has IMHO a bug:

The problem with the error interrupt is, when disabled the can core
doesn't issue any can bus warning or bus passive interrupts.

Can you ensure that you get both error warning and error passive can
error messages with disabled BERR and you patch applied?

> This patch is against Linux next-20101123.
> 
> Signed-off-by: John Ogness <john.ogness-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> ---
>  drivers/net/can/flexcan.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> --- next-20101123-a/drivers/net/can/flexcan.c
> +++ next-20101123-b/drivers/net/can/flexcan.c
> @@ -535,9 +535,12 @@ static int flexcan_poll(struct napi_stru
>  
>  	if (work_done < quota) {
>  		napi_complete(napi);
> -		/* enable IRQs */
> -		writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
> -		writel(priv->reg_ctrl_default, &regs->ctrl);
> +
> +		if (work_done > 0) {
> +			/* enable IRQs */
> +			writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
> +			writel(priv->reg_ctrl_default, &regs->ctrl);
> +		}
>  	}
>  
>  	return work_done;

If a bus error occurs and bus error reporting is disabled, work_done
will stay 0, so both the RX and the ERR interrupt stay disabled (which
is done in flexcan_irq). I think we should always enable the RX
interrupt. (However, if the bus is working again the chip can probably
send messages again, so we get a TX-complete IRQ, but this depends on
the application.)

Having a look at flexcan_irq:

> 	/*
> 	 * schedule NAPI in case of:
> 	 * - rx IRQ
> 	 * - state change IRQ
> 	 * - bus error IRQ and bus error reporting is activated
> 	 */

This mean with disabled BERR NAPI should only be scheduled in case of a
RX or a state change interrupt. Both of these interrupts should generate
a can_frame in flexcan_poll and this the work_done shoud be > 0, modulo
out of memory situations.

> 	if ((reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE) ||
> 	    (reg_esr & FLEXCAN_ESR_ERR_STATE) ||
> 	    flexcan_has_and_handle_berr(priv, reg_esr)) {
> 		/*
> 		 * The error bits are cleared on read,
> 		 * save them for later use.
> 		 */
> 		priv->reg_esr = reg_esr & FLEXCAN_ESR_ERR_BUS;
> 		writel(FLEXCAN_IFLAG_DEFAULT & ~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE,
> 		       &regs->imask1);
> 		writel(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
> 		       &regs->ctrl);
> 		napi_schedule(&priv->napi);
> 	}

So thinking about the problem I don't see how your patch works. But
there might be a bug in the driver or my logic.

Cheers, Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 188 bytes --]

_______________________________________________
Socketcan-core mailing list
Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
https://lists.berlios.de/mailman/listinfo/socketcan-core

^ permalink raw reply

* Re: alchemy/gpr: au1000_eth regression with v2.6.37rc2
From: Florian Fainelli @ 2010-11-23 15:33 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: Linux-MIPS, Netdev
In-Reply-To: <4CEBD751.7090807@grandegger.com>

Hello Wolfgang,

On Tuesday 23 November 2010 16:01:37 Wolfgang Grandegger wrote:
> Hi Florian,
> 
> On 11/19/2010 11:46 AM, Florian Fainelli wrote:
> > Hello Wolfgang,
> > 
> > On Friday 19 November 2010 11:29:45 Wolfgang Grandegger wrote:
> >> Hello Florian,
> >> 
> >> On 11/18/2010 11:30 PM, Florian Fainelli wrote:
> >>> Hello Wolfgang,
> >>> 
> >>> Le Thursday 18 November 2010 20:59:15, Wolfgang Grandegger a écrit :
> >>>> Hello,
> >>>> 
> >>>> I just realized that the v2.6.37-rc2 kernel does not boot any more on
> >>>> the Alchemy GPR board. It works fine with v2.6.36. It hangs in the
> >>>> probe function of the au1000_eth driver when probing the second
> >>>> 
> >>>> ethernet port (eth1):
> >>>>   au1000_eth_mii: probed
> >>>>   au1000-eth au1000-eth.0: (unregistered net_device): attached PHY
> >>>>   driver
> >>>> 
> >>>> [Generic PHY] (mii_bus:phy_addr=0:00, irq=-1) au1000-eth au1000-eth.0:
> >>>> eth0: Au1xx0 Ethernet found at 0x10500000, irq 35 au1000_eth:
> >>>> au1000_eth version 1.7 Pete Popov <ppopov@embeddedalley.com> ...
> >>>> hangs ...
> >>>> 
> >>>> Similar messages should follow for eth1. I narrowed down (bisect'ed)
> >>>> the
> >>>> 
> >>>> problem to commit:
> >>>>   commit d0e7cb5d401695809ba8c980124ab1d8c66efc8b
> >>>>   Author: Florian Fainelli <florian@openwrt.org>
> >>>>   Date:   Wed Sep 8 11:15:13 2010 +0000
> >>>>   
> >>>>     au1000-eth: remove volatiles, switch to I/O accessors
> >>>>     
> >>>>     Remove all the volatile keywords where they were used, switch to
> >>>>     using
> >>>> 
> >>>> the proper readl/writel accessors.
> >>>> 
> >>>>     Signed-off-by: Florian Fainelli <florian@openwrt.org>
> >>>>     Signed-off-by: David S. Miller <davem@davemloft.net>
> >>>> 
> >>>> The kernel actually hangs when accessing "&aup->mac->mii_control" in
> >>>> au1000_mdio_read(), but only for eth1. Any idea what does go wrong?
> >>> 
> >>> I do not understand so far while it hangs only for eth1. My device only
> >>> has one ethernet MAC, so I could not notice the problem. Looking at
> >>> this close, there are a couple of u32 const* usages in
> >>> au1000_mdio_{read,write} which are looking wrong to me now. Can you try
> >>> to remove these?
> >> 
> >> That did not help.
> > 
> > I suspected it, but thanks for the confirmation.
> > 
> >>>> In principle, I do not want to access the MII regs of the MAC because
> >>>> eth0 and eth1 are connected to switches. But that's not possible, even
> >>>> with "aup->phy_static_config=1" and "aup->phy_addr=0".
> >>> 
> >>> If you think this is another issue, I will fix it in another patch.
> >> 
> >> Accessing the MII registers of the MAC should not hang the system even
> >> if I do not need to. First I want to  understand why. Looks like a wired
> >> optimizer issue.
> > 
> > I definitively agree, furthermore since there is a timeout for read and
> > write operations. I will look at the assembly and see if I can see
> > anything different.
> 
> The attached patch fixes the issue. It's caused by a simple porting
> error. I'm going to prepare a proper patch later today.

Nasty and simple enough not to be noticed at compile time. Thanks for 
debugging this. Feel free to add my:

Acked-by: Florian Fainelli <florian@openwrt.org>
--
Florian

^ permalink raw reply

* Re: addrconf: refcnt with  IPV6_PRIVACY enabled
From: Sergey Senozhatsky @ 2010-11-23 15:17 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S. Miller, netdev, linux-kernel, Pekka Savola (ipv6),
	Hideaki YOSHIFUJI
In-Reply-To: <1290522803.3046.11.camel@edumazet-laptop>

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

On (11/23/10 15:33), Eric Dumazet wrote:
> Are you sure the problem you try to solve is not already solved in
> commit 88b2a9a3d98a19496d64aadda7158c0ad51cbe7d in net-2.6 tree ?
> 
> http://git.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commitdiff;h=88b2a9a3d98a19496d64aadda7158c0ad51cbe7d
> 

Seems to work for me. 
Sorry for noise, thank you.

Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>


	Sergey

[-- Attachment #2: Type: application/pgp-signature, Size: 316 bytes --]

^ permalink raw reply

* Re: addrconf: refcnt with  IPV6_PRIVACY enabled
From: Eric Dumazet @ 2010-11-23 15:08 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: David S. Miller, netdev, linux-kernel, Pekka Savola (ipv6),
	Hideaki YOSHIFUJI
In-Reply-To: <20101123145331.GA4102@swordfish.minsk.epam.com>

Le mardi 23 novembre 2010 à 16:53 +0200, Sergey Senozhatsky a écrit :
>  
> > ipv6_regen_rndid() is the timer handler function, it must call
> > in6_dev_put() at the end, unless we rearm the timer.
> > 
> > So this code is correct.
> > 
> > 
> > if (!mod_timer(&idev->regen_timer, expires))
> > 	in6_dev_hold(idev);
> > ...
> > in6_dev_put(idev);
> >
> 
> Even if in6_dev_hold hasn't been called from ipv6_regen_rndid?
> 


Yes.

Rules are :

in6_dev_hold() when arming timer, so that device doesnt disappear while
timer handler might run and need it.

in6_dev_put() when timer handler finishes

^ permalink raw reply

* Re: [PATCH 4/9] AF_UNIX: find the recipients for multicast messages
From: Alban Crequy @ 2010-11-23 15:03 UTC (permalink / raw)
  To: David Miller
  Cc: eric.dumazet, shemminger, gorcunov, adobriyan, lennart,
	kay.sievers, ian.molton, netdev, linux-kernel
In-Reply-To: <20101122.110519.39205345.davem@davemloft.net>

Le Mon, 22 Nov 2010 11:05:19 -0800 (PST),
David Miller <davem@davemloft.net> a écrit :

> From: Alban Crequy <alban.crequy@collabora.co.uk>
> Date: Mon, 22 Nov 2010 18:36:17 +0000
> 
> > unix_find_multicast_recipients() builds an array of recipients. It
> > can either find the peers of a specific multicast address, or find
> > all the peers of all multicast group the sender is part of.
> > 
> > Signed-off-by: Alban Crequy <alban.crequy@collabora.co.uk>
> 
> You really should use RCU to lock this stuff, this way sends run
> lockless and have less worries wrt. the memory allocation.  You'll
> also only take a spinlock in the write paths which change the
> multicast groups, which ought to be rare.

I understand the benefit to use RCU in order to have lockless sends.

But with RCU I will still have worries about the memory allocation:

- I cannot allocate inside a rcu_read_lock()-rcu_read_unlock() block.

- If I iterate locklessly over the multicast group members with 
  hlist_for_each_entry_rcu(), new members can be added, so the
  array can be allocated with the wrong size and I have to try again
  ("goto try_again") when this rare case occurs.

- Another idea would be to avoid completely the allocation by inlining
  unix_find_multicast_recipients() inside unix_dgram_sendmsg() and
  delivering the messages to the recipients as long as the list is
  being iterated locklessly. But I want to provide atomicity of
  delivery: the message must be delivered with skb_queue_tail() either
  to all the recipients or to none of them in case of interruption or
  memory pressure. I don't see how I can achieve that without
  iterating several times on the list of recipients, hence the
  allocation and the copy in the array. I also want to guarantee the
  order of delivery as described in multicast-unix-sockets.txt and for
  this, I am taking lots of spinlocks anyway. I don't see how to avoid
  that, but I would be happy to be wrong and have a better solution.

> Although to be honest you should optimize the case of small numbers of
> recipients, in the same way we optimize small numbers of iovecs on
> sends.  Have an on-stack array that holds a small number of entries
> and use that if the set fits, otherwise dynamic allocation.

To give an idea of the number of members in a multicast group for the
D-Bus use case, I have 90 D-Bus connections on my session bus:

$ dbus-send --print-reply --dest=org.freedesktop.DBus \
/org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep '":'|wc -l
90

In common cases, there should be only a few real recipients (1 or 2?)
after the socket filters eliminate most of them, but
unix_find_multicast_recipients() will still allocate an array of
about that size.

^ permalink raw reply

* [PATCH] iproute2: support xfrm upper protocol gre key
From: Timo Teräs @ 2010-11-23 15:02 UTC (permalink / raw)
  To: shemminger, netdev; +Cc: Timo Teräs

The gre key handling is consistent with ip tunnel side: both
dotted-quad and number are accepted, but dotted-quad is used
for printing.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
---
This is the userland part for:
  http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=cc9ff19da9bf76a2f70bcb80225a1c587c162e52

However, that commit is flawed, and for this patch to work
properly, the following patch is needed:
  http://patchwork.ozlabs.org/patch/72668/

 ip/ipxfrm.c      |   42 ++++++++++++++++++++++++++++++++++++++++++
 ip/xfrm_policy.c |    3 ++-
 man/man8/ip.8    |   25 ++++++++++++++++---------
 3 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
index 99a6756..cf4b7c7 100644
--- a/ip/ipxfrm.c
+++ b/ip/ipxfrm.c
@@ -35,6 +35,7 @@
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 #include <linux/xfrm.h>
+#include <arpa/inet.h>
 
 #include "utils.h"
 #include "xfrm.h"
@@ -483,6 +484,14 @@ void xfrm_selector_print(struct xfrm_selector *sel, __u16 family,
 		if (sel->dport_mask)
 			fprintf(fp, "code %u ", ntohs(sel->dport));
 		break;
+	case IPPROTO_GRE:
+		if (sel->sport_mask || sel->dport_mask) {
+			struct in_addr key;
+			key.s_addr = htonl((ntohs(sel->sport) << 16) + ntohs(sel->dport));
+			inet_ntop(AF_INET, &key, abuf, sizeof(abuf));
+			fprintf(fp, "key %s ", abuf);
+		}
+		break;
 	case IPPROTO_MH:
 		if (sel->sport_mask)
 			fprintf(fp, "type %u ", ntohs(sel->sport));
@@ -1086,6 +1095,7 @@ static int xfrm_selector_upspec_parse(struct xfrm_selector *sel,
 	char *dportp = NULL;
 	char *typep = NULL;
 	char *codep = NULL;
+	char *grekey = NULL;
 
 	while (1) {
 		if (strcmp(*argv, "proto") == 0) {
@@ -1162,6 +1172,29 @@ static int xfrm_selector_upspec_parse(struct xfrm_selector *sel,
 
 			filter.upspec_dport_mask = XFRM_FILTER_MASK_FULL;
 
+		} else if (strcmp(*argv, "key") == 0) {
+			unsigned key;
+
+			grekey = *argv;
+
+			NEXT_ARG();
+
+			if (strchr(*argv, '.'))
+				key = htonl(get_addr32(*argv));
+			else {
+				if (get_unsigned(&key, *argv, 0)<0) {
+					fprintf(stderr, "invalid value of \"key\"\n");
+					exit(-1);
+				}
+			}
+
+			sel->sport = htons(key >> 16);
+			sel->dport = htons(key & 0xffff);
+			sel->sport_mask = ~((__u16)0);
+			sel->dport_mask = ~((__u16)0);
+
+			filter.upspec_dport_mask = XFRM_FILTER_MASK_FULL;
+
 		} else {
 			PREV_ARG(); /* back track */
 			break;
@@ -1196,6 +1229,15 @@ static int xfrm_selector_upspec_parse(struct xfrm_selector *sel,
 			exit(1);
 		}
 	}
+	if (grekey) {
+		switch (sel->proto) {
+		case IPPROTO_GRE:
+			break;
+		default:
+			fprintf(stderr, "\"key\" is invalid with proto=%s\n", strxf_proto(sel->proto));
+			exit(1);
+		}
+	}
 
 	*argcp = argc;
 	*argvp = argv;
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index 121afa1..dcb3da4 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -66,7 +66,8 @@ static void usage(void)
 	fprintf(stderr, "SELECTOR := src ADDR[/PLEN] dst ADDR[/PLEN] [ UPSPEC ] [ dev DEV ]\n");
 
 	fprintf(stderr, "UPSPEC := proto PROTO [ [ sport PORT ] [ dport PORT ] |\n");
-	fprintf(stderr, "                        [ type NUMBER ] [ code NUMBER ] ]\n");
+	fprintf(stderr, "                        [ type NUMBER ] [ code NUMBER ] |\n");
+	fprintf(stderr, "                        [ key { DOTTED_QUAD | NUMBER } ] ]\n");
 
 	//fprintf(stderr, "DEV - device name(default=none)\n");
 
diff --git a/man/man8/ip.8 b/man/man8/ip.8
index 1a73efa..c1e03f3 100644
--- a/man/man8/ip.8
+++ b/man/man8/ip.8
@@ -547,7 +547,10 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
 .RB " [ " type
 .IR NUMBER " ] "
 .RB " [ " code
-.IR NUMBER " ]] "
+.IR NUMBER " ] | "
+.br
+.RB " [ " key
+.IR KEY " ]] "
 
 .ti -8
 .IR LIMIT-LIST " := [ " LIMIT-LIST " ] |"
@@ -642,7 +645,10 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
 .RB " [ " type
 .IR NUMBER " ] "
 .RB " [ " code
-.IR NUMBER " ] ] "
+.IR NUMBER " ] | "
+.br
+.RB " [ " key
+.IR KEY " ] ] "
 
 .ti -8
 .IR ACTION " := "
@@ -2487,9 +2493,11 @@ is defined by source port
 .BR sport ", "
 destination port
 .BR dport ", " type
-as number and
+as number,
 .B code
-also number.
+also number and
+.BR key
+as dotted-quad or number.
 
 .TP
 .BI dev " DEV "
@@ -2556,11 +2564,10 @@ and the other choice is
 .TP
 .IR UPSPEC
 is specified by
-.BR sport ", "
-.BR dport ", " type
-and
-.B code
-(NUMBER).
+.BR sport " and " dport " (for UDP/TCP), "
+.BR type " and " code " (for ICMP; as number) or "
+.BR key " (for GRE; as dotted-quad or number)."
+.
 
 .SS ip xfrm monitor - is used for listing all objects or defined group of them.
 The
-- 
1.7.1


^ permalink raw reply related

* Re: alchemy/gpr: au1000_eth regression with v2.6.37rc2
From: Wolfgang Grandegger @ 2010-11-23 15:01 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: Linux-MIPS, Netdev
In-Reply-To: <201011191146.01454.florian@openwrt.org>

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

Hi Florian,

On 11/19/2010 11:46 AM, Florian Fainelli wrote:
> Hello Wolfgang,
> 
> On Friday 19 November 2010 11:29:45 Wolfgang Grandegger wrote:
>> Hello Florian,
>>
>> On 11/18/2010 11:30 PM, Florian Fainelli wrote:
>>> Hello Wolfgang,
>>>
>>> Le Thursday 18 November 2010 20:59:15, Wolfgang Grandegger a écrit :
>>>> Hello,
>>>>
>>>> I just realized that the v2.6.37-rc2 kernel does not boot any more on
>>>> the Alchemy GPR board. It works fine with v2.6.36. It hangs in the
>>>> probe function of the au1000_eth driver when probing the second
>>>>
>>>> ethernet port (eth1):
>>>>   au1000_eth_mii: probed
>>>>   au1000-eth au1000-eth.0: (unregistered net_device): attached PHY
>>>>   driver
>>>>
>>>> [Generic PHY] (mii_bus:phy_addr=0:00, irq=-1) au1000-eth au1000-eth.0:
>>>> eth0: Au1xx0 Ethernet found at 0x10500000, irq 35 au1000_eth: au1000_eth
>>>> version 1.7 Pete Popov <ppopov@embeddedalley.com> ... hangs ...
>>>>
>>>> Similar messages should follow for eth1. I narrowed down (bisect'ed) the
>>>>
>>>> problem to commit:
>>>>   commit d0e7cb5d401695809ba8c980124ab1d8c66efc8b
>>>>   Author: Florian Fainelli <florian@openwrt.org>
>>>>   Date:   Wed Sep 8 11:15:13 2010 +0000
>>>>   
>>>>     au1000-eth: remove volatiles, switch to I/O accessors
>>>>     
>>>>     Remove all the volatile keywords where they were used, switch to
>>>>     using
>>>>
>>>> the proper readl/writel accessors.
>>>>
>>>>     Signed-off-by: Florian Fainelli <florian@openwrt.org>
>>>>     Signed-off-by: David S. Miller <davem@davemloft.net>
>>>>
>>>> The kernel actually hangs when accessing "&aup->mac->mii_control" in
>>>> au1000_mdio_read(), but only for eth1. Any idea what does go wrong?
>>>
>>> I do not understand so far while it hangs only for eth1. My device only
>>> has one ethernet MAC, so I could not notice the problem. Looking at this
>>> close, there are a couple of u32 const* usages in
>>> au1000_mdio_{read,write} which are looking wrong to me now. Can you try
>>> to remove these?
>>
>> That did not help.
> 
> I suspected it, but thanks for the confirmation.
> 
>>
>>>> In principle, I do not want to access the MII regs of the MAC because
>>>> eth0 and eth1 are connected to switches. But that's not possible, even
>>>> with "aup->phy_static_config=1" and "aup->phy_addr=0".
>>>
>>> If you think this is another issue, I will fix it in another patch.
>>
>> Accessing the MII registers of the MAC should not hang the system even
>> if I do not need to. First I want to  understand why. Looks like a wired
>> optimizer issue.
> 
> I definitively agree, furthermore since there is a timeout for read and write 
> operations. I will look at the assembly and see if I can see anything 
> different.

The attached patch fixes the issue. It's caused by a simple porting
error. I'm going to prepare a proper patch later today.

Wolfgang.



[-- Attachment #2: au1000-eth-mac-enable.patch --]
[-- Type: text/x-diff, Size: 1261 bytes --]

diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 43489f8..53eff9b 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -155,10 +155,10 @@ static void au1000_enable_mac(struct net_device *dev, int force_reset)
 	spin_lock_irqsave(&aup->lock, flags);
 
 	if (force_reset || (!aup->mac_enabled)) {
-		writel(MAC_EN_CLOCK_ENABLE, &aup->enable);
+		writel(MAC_EN_CLOCK_ENABLE, aup->enable);
 		au_sync_delay(2);
 		writel((MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2
-				| MAC_EN_CLOCK_ENABLE), &aup->enable);
+				| MAC_EN_CLOCK_ENABLE), aup->enable);
 		au_sync_delay(2);
 
 		aup->mac_enabled = 1;
@@ -503,9 +503,9 @@ static void au1000_reset_mac_unlocked(struct net_device *dev)
 
 	au1000_hard_stop(dev);
 
-	writel(MAC_EN_CLOCK_ENABLE, &aup->enable);
+	writel(MAC_EN_CLOCK_ENABLE, aup->enable);
 	au_sync_delay(2);
-	writel(0, &aup->enable);
+	writel(0, aup->enable);
 	au_sync_delay(2);
 
 	aup->tx_full = 0;
@@ -1119,7 +1119,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
 	/* set a random MAC now in case platform_data doesn't provide one */
 	random_ether_addr(dev->dev_addr);
 
-	writel(0, &aup->enable);
+	writel(0, aup->enable);
 	aup->mac_enabled = 0;
 
 	pd = pdev->dev.platform_data;

^ permalink raw reply related

* Re: addrconf: refcnt with  IPV6_PRIVACY enabled
From: Sergey Senozhatsky @ 2010-11-23 14:53 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S. Miller, netdev, linux-kernel, Pekka Savola (ipv6),
	Hideaki YOSHIFUJI
In-Reply-To: <1290522803.3046.11.camel@edumazet-laptop>

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

Hello Eric,

On (11/23/10 15:33), Eric Dumazet wrote:
> Sergey, I dont think your patches (V1 or V2) are correct.
> 
> You leak a refcount if (idev->dead) is true
>
Hm, that's true. Thank you.

 
> ipv6_regen_rndid() is the timer handler function, it must call
> in6_dev_put() at the end, unless we rearm the timer.
> 
> So this code is correct.
> 
> 
> if (!mod_timer(&idev->regen_timer, expires))
> 	in6_dev_hold(idev);
> ...
> in6_dev_put(idev);
>

Even if in6_dev_hold hasn't been called from ipv6_regen_rndid?


> 
> And we must call in6_dev_hold() before calling the handler, either
> directly from ipv6_add_dev() [Where your first patch tried to remove the
> dev_hold() call], or when arming the timer.
> 
> Are you sure the problem you try to solve is not already solved in
> commit 88b2a9a3d98a19496d64aadda7158c0ad51cbe7d in net-2.6 tree ?
> 
> http://git.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commitdiff;h=88b2a9a3d98a19496d64aadda7158c0ad51cbe7d
> 

Oh, haven't seen this one. I'll try, thank you.


	Sergey

[-- Attachment #2: Type: application/pgp-signature, Size: 316 bytes --]

^ permalink raw reply

* Re: pc300too on a modern kernel?
From: Ward Vandewege @ 2010-11-23 14:44 UTC (permalink / raw)
  To: Krzysztof Halasa; +Cc: Bernie Innocenti, lkml, Jan Seiffert, netdev
In-Reply-To: <m38w0l2gzh.fsf@intrepid.localdomain>

On Mon, Nov 22, 2010 at 10:20:02PM +0100, Krzysztof Halasa wrote:
> > With this workaround applied, we're st seeing occasional clusters of
> > packet loss. We're working to graph the ping loss alongside traffic to
> > see if there's any correlation.
> 
> That's interesting. I remember seeing some TX underruns at higher
> speeds, though nothing alike at 2 Mb/s. What bit rate are you using?
> Does "ifconfig hdlc0" show any errors?

This turned out to be caused by line saturation. We were not seeing this
before we upgraded to the latest kernel because we have a set of qos rules
that we forgot to install on our new box. Mea culpa...

Thanks,
Ward.

-- 
Ward Vandewege <ward@gnu.org>

^ permalink raw reply

* [PATCH] flexcan: fix NAPI for bus errors
From: John Ogness @ 2010-11-23 14:34 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: socketcan-core, netdev, kernel

If bus error reporting is disabled and bus errors occur, the flexcan
driver will hog the system because it continually re-enables the IRQs
(work_done = 0). This patch changes the driver to only re-enable the
IRQs if some work was actually done. This allows the features of NAPI to
be used for bus errors as well (when bus error reporting is disabled).

This patch is against Linux next-20101123.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 drivers/net/can/flexcan.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- next-20101123-a/drivers/net/can/flexcan.c
+++ next-20101123-b/drivers/net/can/flexcan.c
@@ -535,9 +535,12 @@ static int flexcan_poll(struct napi_stru
 
 	if (work_done < quota) {
 		napi_complete(napi);
-		/* enable IRQs */
-		writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
-		writel(priv->reg_ctrl_default, &regs->ctrl);
+
+		if (work_done > 0) {
+			/* enable IRQs */
+			writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
+			writel(priv->reg_ctrl_default, &regs->ctrl);
+		}
 	}
 
 	return work_done;

^ permalink raw reply

* Re: addrconf: refcnt with  IPV6_PRIVACY enabled
From: Eric Dumazet @ 2010-11-23 14:33 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: David S. Miller, netdev, linux-kernel, Pekka Savola (ipv6),
	Hideaki YOSHIFUJI
In-Reply-To: <20101123134003.GB4142@swordfish.minsk.epam.com>

Le mardi 23 novembre 2010 à 15:40 +0200, Sergey Senozhatsky a écrit :
> Hello,
> 
> I've sent a patch http://lkml.org/lkml/2010/11/21/124 
> "[PATCH] ipv6: fix inet6_dev refcnt with IPV6_PRIVACY enabled" related
> to wrong in6_dev refcnt value when IPV6_PRIVACY enabled.
> 
> I've took a second look, and question arised - 
> Is it actually necessary to in6_dev_hold/in6_dev_put in ipv6_regen_rndid?
> In ipv6_regen_rndid we call in6_dev_hold only when mod_timer == 0,
> and always in6_dev_put. 
> 
> 
> I've removed check for < 0 and goto from __ipv6_regen_rndid call, since it 
> always return 0.
> 
> 
> Please, kindly review V2.
> 
> ---
> 
>  net/ipv6/addrconf.c |   10 +++-------
>  1 files changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 2fc35b3..8187d14 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -425,7 +425,6 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
>  		       dev->name);
>  		ndev->cnf.use_tempaddr = -1;
>  	} else {
> -		in6_dev_hold(ndev);
>  		ipv6_regen_rndid((unsigned long) ndev);
>  	}
>  #endif
> @@ -1653,8 +1652,7 @@ static void ipv6_regen_rndid(unsigned long data)
>  	if (idev->dead)
>  		goto out;
>  
> -	if (__ipv6_regen_rndid(idev) < 0)
> -		goto out;
> +	__ipv6_regen_rndid(idev);
>  
>  	expires = jiffies +
>  		idev->cnf.temp_prefered_lft * HZ -
> @@ -1667,13 +1665,11 @@ static void ipv6_regen_rndid(unsigned long data)
>  		goto out;
>  	}
>  
> -	if (!mod_timer(&idev->regen_timer, expires))
> -		in6_dev_hold(idev);
> -
> +	mod_timer(&idev->regen_timer, expires);
> +	
>  out:
>  	write_unlock_bh(&idev->lock);
>  	rcu_read_unlock_bh();
> -	in6_dev_put(idev);
>  }
>  
>  static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr) {
> 


Sergey, I dont think your patches (V1 or V2) are correct.

You leak a refcount if (idev->dead) is true

ipv6_regen_rndid() is the timer handler function, it must call
in6_dev_put() at the end, unless we rearm the timer.

So this code is correct.


if (!mod_timer(&idev->regen_timer, expires))
	in6_dev_hold(idev);
...
in6_dev_put(idev);


And we must call in6_dev_hold() before calling the handler, either
directly from ipv6_add_dev() [Where your first patch tried to remove the
dev_hold() call], or when arming the timer.

Are you sure the problem you try to solve is not already solved in
commit 88b2a9a3d98a19496d64aadda7158c0ad51cbe7d in net-2.6 tree ?

http://git.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commitdiff;h=88b2a9a3d98a19496d64aadda7158c0ad51cbe7d

^ permalink raw reply

* Re: [PATCH] xfrm: use gre key as flow upper protocol info
From: Timo Teräs @ 2010-11-23 14:03 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, herbert
In-Reply-To: <20101115.104322.212675424.davem@davemloft.net>

On 11/15/2010 08:43 PM, David Miller wrote:
> From: Timo Teräs <timo.teras@iki.fi>
> Date: Wed,  3 Nov 2010 16:41:38 +0200
> 
>> The GRE Key field is intended to be used for identifying an individual
>> traffic flow within a tunnel. It is useful to be able to have XFRM
>> policy selector matches to have different policies for different
>> GRE tunnels.
>>
>> Signed-off-by: Timo Teräs <timo.teras@iki.fi>
> 
> I'll apply this to net-next-2.6, thanks.

Hmm.. I tested this with using the "ip xfrm" sport and dport manually
(without doing the actual userland support for this), and checking it in
kernel with printk's in various places that the stuff matches. In these
tests I checked the sport/dport by hand and apparently messed up the
byte order.

Now that I'm writing the GRE support for "ip xfrm" I think that missed
two htons() calls.

I was confused if xfrm_flowi_{s|d}port was supposed to return host or
net byte order for non-TCP/UDP packets.

I was under the assumption that host byte order since case IPPROTO_ICMP
swaps the byte order. But it would appear that the fl->fl_icmp_* is
actually host order and it's turned to network order; this is also
implied by using htons instead of ntohs. Since I decided to keep
fl_gre_key in network order, the return value would now be inconsistent,
and make userland abi endianess dependent.

I'll follow up with iproute2 patch soon.

So we probably would need to do:

xfrm: fix gre key endianess

fl->fl_gre_key is network byte order contrary to fl->fl_icmp_*.
Make xfrm_flowi_{s|d}port return network byte order values for gre
key too.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 1a57ff9..916ac47 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -806,7 +806,7 @@ __be16 xfrm_flowi_sport(struct flowi *fl)
 		port = htons(fl->fl_mh_type);
 		break;
 	case IPPROTO_GRE:
-		port = htonl(fl->fl_gre_key) >> 16;
+		port = htons(ntohl(fl->fl_gre_key) >> 16);
 		break;
 	default:
 		port = 0;	/*XXX*/
@@ -830,7 +830,7 @@ __be16 xfrm_flowi_dport(struct flowi *fl)
 		port = htons(fl->fl_icmp_code);
 		break;
 	case IPPROTO_GRE:
-		port = htonl(fl->fl_gre_key) & 0xffff;
+		port = htons(ntohl(fl->fl_gre_key) & 0xffff);
 		break;
 	default:
 		port = 0;	/*XXX*/

^ permalink raw reply related

* addrconf: refcnt with  IPV6_PRIVACY enabled
From: Sergey Senozhatsky @ 2010-11-23 13:40 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, linux-kernel, Pekka Savola (ipv6), Hideaki YOSHIFUJI

Hello,

I've sent a patch http://lkml.org/lkml/2010/11/21/124 
"[PATCH] ipv6: fix inet6_dev refcnt with IPV6_PRIVACY enabled" related
to wrong in6_dev refcnt value when IPV6_PRIVACY enabled.

I've took a second look, and question arised - 
Is it actually necessary to in6_dev_hold/in6_dev_put in ipv6_regen_rndid?
In ipv6_regen_rndid we call in6_dev_hold only when mod_timer == 0,
and always in6_dev_put. 


I've removed check for < 0 and goto from __ipv6_regen_rndid call, since it 
always return 0.


Please, kindly review V2.

---

 net/ipv6/addrconf.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 2fc35b3..8187d14 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -425,7 +425,6 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
 		       dev->name);
 		ndev->cnf.use_tempaddr = -1;
 	} else {
-		in6_dev_hold(ndev);
 		ipv6_regen_rndid((unsigned long) ndev);
 	}
 #endif
@@ -1653,8 +1652,7 @@ static void ipv6_regen_rndid(unsigned long data)
 	if (idev->dead)
 		goto out;
 
-	if (__ipv6_regen_rndid(idev) < 0)
-		goto out;
+	__ipv6_regen_rndid(idev);
 
 	expires = jiffies +
 		idev->cnf.temp_prefered_lft * HZ -
@@ -1667,13 +1665,11 @@ static void ipv6_regen_rndid(unsigned long data)
 		goto out;
 	}
 
-	if (!mod_timer(&idev->regen_timer, expires))
-		in6_dev_hold(idev);
-
+	mod_timer(&idev->regen_timer, expires);
+	
 out:
 	write_unlock_bh(&idev->lock);
 	rcu_read_unlock_bh();
-	in6_dev_put(idev);
 }
 
 static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr) {

^ permalink raw reply related

* [PATCH v3 08/22] rds: stop including asm-generic/bitops/le.h
From: Akinobu Mita @ 2010-11-23 13:38 UTC (permalink / raw)
  To: linux-kernel, linux-arch, Andrew Morton
  Cc: Akinobu Mita, Andy Grover, rds-devel, David S. Miller, netdev
In-Reply-To: <1290519504-3958-1-git-send-email-akinobu.mita@gmail.com>

No need to include asm-generic/bitops/le.h as all architectures
provide little-endian bit operations now.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Andy Grover <andy.grover@oracle.com>
Cc: rds-devel@oss.oracle.com
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---
No change from previous submission
 net/rds/cong.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/net/rds/cong.c b/net/rds/cong.c
index 90ca44f..fa578d3 100644
--- a/net/rds/cong.c
+++ b/net/rds/cong.c
@@ -34,8 +34,6 @@
 #include <linux/types.h>
 #include <linux/rbtree.h>
 
-#include <asm-generic/bitops/le.h>
-
 #include "rds.h"
 
 /*
-- 
1.7.3.2

^ permalink raw reply related

* [PATCH v3 02/22] bitops: rename generic little-endian bitops functions
From: Akinobu Mita @ 2010-11-23 13:38 UTC (permalink / raw)
  To: linux-kernel, linux-arch, Andrew Morton
  Cc: rds-devel, kvm, Marcelo Tosatti, Akinobu Mita, Andy Grover,
	linux-m68k, netdev, Andreas Schwab, Avi Kivity, Greg Ungerer,
	Geert Uytterhoeven, linuxppc-dev, David S. Miller, Paul Mackerras
In-Reply-To: <1290519504-3958-1-git-send-email-akinobu.mita@gmail.com>

As a preparation for providing little-endian bitops for all architectures,
This removes generic_ prefix from little-endian bitops function names
in asm-generic/bitops/le.h.

s/generic_find_next_le_bit/find_next_le_bit/
s/generic_find_next_zero_le_bit/find_next_zero_le_bit/
s/generic_find_first_zero_le_bit/find_first_zero_le_bit/
s/generic___test_and_set_le_bit/__test_and_set_le_bit/
s/generic___test_and_clear_le_bit/__test_and_clear_le_bit/
s/generic_test_le_bit/test_le_bit/
s/generic___set_le_bit/__set_le_bit/
s/generic___clear_le_bit/__clear_le_bit/
s/generic_test_and_set_le_bit/test_and_set_le_bit/
s/generic_test_and_clear_le_bit/test_and_clear_le_bit/

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org
Cc: Greg Ungerer <gerg@uclinux.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Andy Grover <andy.grover@oracle.com>
Cc: rds-devel@oss.oracle.com
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
---
No change from previous submission
 arch/avr32/kernel/avr32_ksyms.c              |    4 ++--
 arch/avr32/lib/findbit.S                     |    4 ++--
 arch/m68k/include/asm/bitops_mm.h            |    8 ++++----
 arch/m68k/include/asm/bitops_no.h            |    2 +-
 arch/powerpc/include/asm/bitops.h            |   11 ++++++-----
 include/asm-generic/bitops/ext2-non-atomic.h |   12 ++++++------
 include/asm-generic/bitops/le.h              |   26 +++++++++++++-------------
 include/asm-generic/bitops/minix-le.h        |   10 +++++-----
 lib/find_next_bit.c                          |    9 ++++-----
 net/rds/cong.c                               |    6 +++---
 virt/kvm/kvm_main.c                          |    2 +-
 11 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/arch/avr32/kernel/avr32_ksyms.c b/arch/avr32/kernel/avr32_ksyms.c
index 11e310c..c63b943 100644
--- a/arch/avr32/kernel/avr32_ksyms.c
+++ b/arch/avr32/kernel/avr32_ksyms.c
@@ -58,8 +58,8 @@ EXPORT_SYMBOL(find_first_zero_bit);
 EXPORT_SYMBOL(find_next_zero_bit);
 EXPORT_SYMBOL(find_first_bit);
 EXPORT_SYMBOL(find_next_bit);
-EXPORT_SYMBOL(generic_find_next_le_bit);
-EXPORT_SYMBOL(generic_find_next_zero_le_bit);
+EXPORT_SYMBOL(find_next_le_bit);
+EXPORT_SYMBOL(find_next_zero_le_bit);
 
 /* I/O primitives (lib/io-*.S) */
 EXPORT_SYMBOL(__raw_readsb);
diff --git a/arch/avr32/lib/findbit.S b/arch/avr32/lib/findbit.S
index 997b33b..6880d85 100644
--- a/arch/avr32/lib/findbit.S
+++ b/arch/avr32/lib/findbit.S
@@ -123,7 +123,7 @@ ENTRY(find_next_bit)
 	brgt	1b
 	retal	r11
 
-ENTRY(generic_find_next_le_bit)
+ENTRY(find_next_le_bit)
 	lsr	r8, r10, 5
 	sub	r9, r11, r10
 	retle	r11
@@ -153,7 +153,7 @@ ENTRY(generic_find_next_le_bit)
 	brgt	1b
 	retal	r11
 
-ENTRY(generic_find_next_zero_le_bit)
+ENTRY(find_next_zero_le_bit)
 	lsr	r8, r10, 5
 	sub	r9, r11, r10
 	retle	r11
diff --git a/arch/m68k/include/asm/bitops_mm.h b/arch/m68k/include/asm/bitops_mm.h
index b4ecdaa..f1010ab 100644
--- a/arch/m68k/include/asm/bitops_mm.h
+++ b/arch/m68k/include/asm/bitops_mm.h
@@ -366,9 +366,9 @@ static inline int minix_test_bit(int nr, const void *vaddr)
 #define ext2_clear_bit(nr, addr)		__test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr))
 #define ext2_clear_bit_atomic(lock, nr, addr)	test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr))
 #define ext2_find_next_zero_bit(addr, size, offset) \
-	generic_find_next_zero_le_bit((unsigned long *)addr, size, offset)
+	find_next_zero_le_bit((unsigned long *)addr, size, offset)
 #define ext2_find_next_bit(addr, size, offset) \
-	generic_find_next_le_bit((unsigned long *)addr, size, offset)
+	find_next_le_bit((unsigned long *)addr, size, offset)
 
 static inline int ext2_test_bit(int nr, const void *vaddr)
 {
@@ -398,7 +398,7 @@ static inline int ext2_find_first_zero_bit(const void *vaddr, unsigned size)
 	return (p - addr) * 32 + res;
 }
 
-static inline unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
+static inline unsigned long find_next_zero_le_bit(const unsigned long *addr,
 		unsigned long size, unsigned long offset)
 {
 	const unsigned long *p = addr + (offset >> 5);
@@ -440,7 +440,7 @@ static inline int ext2_find_first_bit(const void *vaddr, unsigned size)
 	return (p - addr) * 32 + res;
 }
 
-static inline unsigned long generic_find_next_le_bit(const unsigned long *addr,
+static inline unsigned long find_next_le_bit(const unsigned long *addr,
 		unsigned long size, unsigned long offset)
 {
 	const unsigned long *p = addr + (offset >> 5);
diff --git a/arch/m68k/include/asm/bitops_no.h b/arch/m68k/include/asm/bitops_no.h
index 9d3cbe5..292e1ce 100644
--- a/arch/m68k/include/asm/bitops_no.h
+++ b/arch/m68k/include/asm/bitops_no.h
@@ -325,7 +325,7 @@ found_middle:
 }
 
 #define ext2_find_next_bit(addr, size, off) \
-	generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
+	find_next_le_bit((unsigned long *)(addr), (size), (off))
 #include <asm-generic/bitops/minix.h>
 
 #endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 30964ae..b4f3f84 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -294,11 +294,12 @@ static __inline__ int test_le_bit(unsigned long nr,
 #define __test_and_clear_le_bit(nr, addr) \
 	__test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
 
-#define find_first_zero_le_bit(addr, size) generic_find_next_zero_le_bit((addr), (size), 0)
-unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
+#define find_first_zero_le_bit(addr, size) \
+	find_next_zero_le_bit((addr), (size), 0)
+unsigned long find_next_zero_le_bit(const unsigned long *addr,
 				    unsigned long size, unsigned long offset);
 
-unsigned long generic_find_next_le_bit(const unsigned long *addr,
+unsigned long find_next_le_bit(const unsigned long *addr,
 				    unsigned long size, unsigned long offset);
 /* Bitmap functions for the ext2 filesystem */
 
@@ -317,10 +318,10 @@ unsigned long generic_find_next_le_bit(const unsigned long *addr,
 #define ext2_find_first_zero_bit(addr, size) \
 	find_first_zero_le_bit((unsigned long*)addr, size)
 #define ext2_find_next_zero_bit(addr, size, off) \
-	generic_find_next_zero_le_bit((unsigned long*)addr, size, off)
+	find_next_zero_le_bit((unsigned long *)addr, size, off)
 
 #define ext2_find_next_bit(addr, size, off) \
-	generic_find_next_le_bit((unsigned long *)addr, size, off)
+	find_next_le_bit((unsigned long *)addr, size, off)
 /* Bitmap functions for the minix filesystem.  */
 
 #define minix_test_and_set_bit(nr,addr) \
diff --git a/include/asm-generic/bitops/ext2-non-atomic.h b/include/asm-generic/bitops/ext2-non-atomic.h
index 63cf822..9c7bb9a 100644
--- a/include/asm-generic/bitops/ext2-non-atomic.h
+++ b/include/asm-generic/bitops/ext2-non-atomic.h
@@ -4,17 +4,17 @@
 #include <asm-generic/bitops/le.h>
 
 #define ext2_set_bit(nr,addr)	\
-	generic___test_and_set_le_bit((nr),(unsigned long *)(addr))
+	__test_and_set_le_bit((nr), (unsigned long *)(addr))
 #define ext2_clear_bit(nr,addr)	\
-	generic___test_and_clear_le_bit((nr),(unsigned long *)(addr))
+	__test_and_clear_le_bit((nr), (unsigned long *)(addr))
 
 #define ext2_test_bit(nr,addr)	\
-	generic_test_le_bit((nr),(unsigned long *)(addr))
+	test_le_bit((nr), (unsigned long *)(addr))
 #define ext2_find_first_zero_bit(addr, size) \
-	generic_find_first_zero_le_bit((unsigned long *)(addr), (size))
+	find_first_zero_le_bit((unsigned long *)(addr), (size))
 #define ext2_find_next_zero_bit(addr, size, off) \
-	generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off))
+	find_next_zero_le_bit((unsigned long *)(addr), (size), (off))
 #define ext2_find_next_bit(addr, size, off) \
-	generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
+	find_next_le_bit((unsigned long *)(addr), (size), (off))
 
 #endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index db2be81..6ad46ce 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -8,42 +8,42 @@
 
 #define BITOP_LE_SWIZZLE	0
 
-#define generic_find_next_zero_le_bit(addr, size, offset) \
+#define find_next_zero_le_bit(addr, size, offset) \
 	find_next_zero_bit(addr, size, offset)
-#define generic_find_next_le_bit(addr, size, offset) \
+#define find_next_le_bit(addr, size, offset) \
 	find_next_bit(addr, size, offset)
 
 #elif defined(__BIG_ENDIAN)
 
 #define BITOP_LE_SWIZZLE	((BITS_PER_LONG-1) & ~0x7)
 
-extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
+extern unsigned long find_next_zero_le_bit(const unsigned long *addr,
 		unsigned long size, unsigned long offset);
-extern unsigned long generic_find_next_le_bit(const unsigned long *addr,
+extern unsigned long find_next_le_bit(const unsigned long *addr,
 		unsigned long size, unsigned long offset);
 
 #else
 #error "Please fix <asm/byteorder.h>"
 #endif
 
-#define generic_test_le_bit(nr, addr) \
+#define test_le_bit(nr, addr) \
 	test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
-#define generic___set_le_bit(nr, addr) \
+#define __set_le_bit(nr, addr) \
 	__set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
-#define generic___clear_le_bit(nr, addr) \
+#define __clear_le_bit(nr, addr) \
 	__clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
 
-#define generic_test_and_set_le_bit(nr, addr) \
+#define test_and_set_le_bit(nr, addr) \
 	test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
-#define generic_test_and_clear_le_bit(nr, addr) \
+#define test_and_clear_le_bit(nr, addr) \
 	test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
 
-#define generic___test_and_set_le_bit(nr, addr) \
+#define __test_and_set_le_bit(nr, addr) \
 	__test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
-#define generic___test_and_clear_le_bit(nr, addr) \
+#define __test_and_clear_le_bit(nr, addr) \
 	__test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
 
-#define generic_find_first_zero_le_bit(addr, size) \
-        generic_find_next_zero_le_bit((addr), (size), 0)
+#define find_first_zero_le_bit(addr, size) \
+	find_next_zero_le_bit((addr), (size), 0)
 
 #endif /* _ASM_GENERIC_BITOPS_LE_H_ */
diff --git a/include/asm-generic/bitops/minix-le.h b/include/asm-generic/bitops/minix-le.h
index 4a981c1..ed0ae09 100644
--- a/include/asm-generic/bitops/minix-le.h
+++ b/include/asm-generic/bitops/minix-le.h
@@ -4,14 +4,14 @@
 #include <asm-generic/bitops/le.h>
 
 #define minix_test_and_set_bit(nr,addr)	\
-	generic___test_and_set_le_bit((nr),(unsigned long *)(addr))
+	__test_and_set_le_bit((nr), (unsigned long *)(addr))
 #define minix_set_bit(nr,addr)		\
-	generic___set_le_bit((nr),(unsigned long *)(addr))
+	__set_le_bit((nr), (unsigned long *)(addr))
 #define minix_test_and_clear_bit(nr,addr) \
-	generic___test_and_clear_le_bit((nr),(unsigned long *)(addr))
+	__test_and_clear_le_bit((nr), (unsigned long *)(addr))
 #define minix_test_bit(nr,addr)		\
-	generic_test_le_bit((nr),(unsigned long *)(addr))
+	test_le_bit((nr), (unsigned long *)(addr))
 #define minix_find_first_zero_bit(addr,size) \
-	generic_find_first_zero_le_bit((unsigned long *)(addr),(size))
+	find_first_zero_le_bit((unsigned long *)(addr), (size))
 
 #endif /* _ASM_GENERIC_BITOPS_MINIX_LE_H_ */
diff --git a/lib/find_next_bit.c b/lib/find_next_bit.c
index 24c59de..eb8934b 100644
--- a/lib/find_next_bit.c
+++ b/lib/find_next_bit.c
@@ -185,7 +185,7 @@ static inline unsigned long ext2_swab(const unsigned long y)
 #endif
 }
 
-unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, unsigned
+unsigned long find_next_zero_le_bit(const unsigned long *addr, unsigned
 		long size, unsigned long offset)
 {
 	const unsigned long *p = addr + BITOP_WORD(offset);
@@ -226,10 +226,9 @@ found_middle:
 found_middle_swap:
 	return result + ffz(ext2_swab(tmp));
 }
+EXPORT_SYMBOL(find_next_zero_le_bit);
 
-EXPORT_SYMBOL(generic_find_next_zero_le_bit);
-
-unsigned long generic_find_next_le_bit(const unsigned long *addr, unsigned
+unsigned long find_next_le_bit(const unsigned long *addr, unsigned
 		long size, unsigned long offset)
 {
 	const unsigned long *p = addr + BITOP_WORD(offset);
@@ -271,5 +270,5 @@ found_middle:
 found_middle_swap:
 	return result + __ffs(ext2_swab(tmp));
 }
-EXPORT_SYMBOL(generic_find_next_le_bit);
+EXPORT_SYMBOL(find_next_le_bit);
 #endif /* __BIG_ENDIAN */
diff --git a/net/rds/cong.c b/net/rds/cong.c
index 75ea686..90ca44f 100644
--- a/net/rds/cong.c
+++ b/net/rds/cong.c
@@ -285,7 +285,7 @@ void rds_cong_set_bit(struct rds_cong_map *map, __be16 port)
 	i = be16_to_cpu(port) / RDS_CONG_MAP_PAGE_BITS;
 	off = be16_to_cpu(port) % RDS_CONG_MAP_PAGE_BITS;
 
-	generic___set_le_bit(off, (void *)map->m_page_addrs[i]);
+	__set_le_bit(off, (void *)map->m_page_addrs[i]);
 }
 
 void rds_cong_clear_bit(struct rds_cong_map *map, __be16 port)
@@ -299,7 +299,7 @@ void rds_cong_clear_bit(struct rds_cong_map *map, __be16 port)
 	i = be16_to_cpu(port) / RDS_CONG_MAP_PAGE_BITS;
 	off = be16_to_cpu(port) % RDS_CONG_MAP_PAGE_BITS;
 
-	generic___clear_le_bit(off, (void *)map->m_page_addrs[i]);
+	__clear_le_bit(off, (void *)map->m_page_addrs[i]);
 }
 
 static int rds_cong_test_bit(struct rds_cong_map *map, __be16 port)
@@ -310,7 +310,7 @@ static int rds_cong_test_bit(struct rds_cong_map *map, __be16 port)
 	i = be16_to_cpu(port) / RDS_CONG_MAP_PAGE_BITS;
 	off = be16_to_cpu(port) % RDS_CONG_MAP_PAGE_BITS;
 
-	return generic_test_le_bit(off, (void *)map->m_page_addrs[i]);
+	return test_le_bit(off, (void *)map->m_page_addrs[i]);
 }
 
 void rds_cong_add_socket(struct rds_sock *rs)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5225052..da16155 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1252,7 +1252,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
 	if (memslot && memslot->dirty_bitmap) {
 		unsigned long rel_gfn = gfn - memslot->base_gfn;
 
-		generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
+		__set_le_bit(rel_gfn, memslot->dirty_bitmap);
 	}
 }
 
-- 
1.7.3.2

^ permalink raw reply related

* ucc_geth: transmit queue timeout at half-duplex mode
From: Schmitz, Andreas @ 2010-11-23 13:29 UTC (permalink / raw)
  To: leoli@freescale.com; +Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org


[-- Attachment #1.1: Type: text/plain, Size: 1227 bytes --]

Hi all,
on my MPC8321E with linux-2.6.36 I get this netdev watchdog warning "NETDEV WATCHDOG: eth0 (of:ucc_geth): transmit queue 0 timed out" if the link mode is half-duplex.
The warning is caused, because all Tx BDs are full and packet transmission is stopped with netif_stop_queue() in ucc_geth_start_xmit().

You can reproduce the bug in the following way:
- Connect to a switch, that supports only 10baseT, or set the mode manually with "mii-diag -F 10baseT".
- Open a telnet session to the target. Generate higher traffic with executing maybe "cat /proc/interrupts" many times.
- After some tries the ethernet connection will be down, then again after approx. 30s seconds the netdev watchdog will dump the warning.

It is unclear to me why the TxBDs get full. Due to missing "Tx buffer sent" interrupts, it seems that the QE stops the transmission.

I found some issue in the errata: "QE_ENET20: UEC may stop transmitting after late collision". But UCCE[TXE] is never set in this case.

Thank you for your help in advance and best regards,

Andreas Schmitz
Software Engineer
_______________________________________
RIEDEL
Communications GmbH & Co. KG
Uellendahler Str. 353
42109 Wuppertal
Germany


[-- Attachment #1.2: Type: text/html, Size: 2213 bytes --]

[-- Attachment #2: ucc_geth_half_duplex_netdev_watchdog.txt --]
[-- Type: text/plain, Size: 13531 bytes --]

PHY: mdio@e0102320:01 - Link is Up - 10/Half
NETDEV WATCHDOG: eth0 (of:ucc_geth): transmit queue 0 timed out
------------[ cut here ]------------
WARNING: at net/sched/sch_generic.c:258
Modules linked in: gpio
NIP: c01887c0 LR: c01887c0 CTR: c012b8d4
REGS: c3ffbe30 TRAP: 0700   Not tainted  (2.6.36)
MSR: 00029032 <EE,ME,CE,IR,DR>  CR: 44022084  XER: 20000000
TASK = c07f6410[0] 'swapper' THREAD: c080e000
GPR00: c01887c0 c3ffbee0 c07f6410 00000046 00001848 ffffffff c012c2b0 2074696d
GPR08: 00001808 c3ffa000 c0817eb8 00000004 00000000 1007d144 03fff000 c07f94e4
GPR16: 00200200 c020dcd4 00000000 00000001 c0837fc0 c08381ec c083826c c08382ec
GPR24: c083836c 00000002 ffffffff 00000000 c3ffa03c c2607fa0 00000000 c2583000
NIP [c01887c0] dev_watchdog+0x198/0x28c
LR [c01887c0] dev_watchdog+0x198/0x28c
Call Trace:
[c3ffbee0] [c01887c0] dev_watchdog+0x198/0x28c (unreliable)
[c3ffbf50] [c003c9b0] run_timer_softirq+0x1b0/0x250
[c3ffbfb0] [c0036d18] __do_softirq+0xa8/0x124
[c3ffbff0] [c000e5dc] call_do_softirq+0x14/0x24
[c080fe70] [c0005e38] do_softirq+0x6c/0x8c
[c080fe90] [c00367b4] irq_exit+0x3c/0x54
[c080fea0] [c0005fec] do_IRQ+0x128/0x144
[c080fec0] [c000f2ac] ret_from_except+0x0/0x14
--- Exception: 501 at cpu_idle+0x94/0xe4
    LR = cpu_idle+0x94/0xe4
[c080ff80] [c00090c4] cpu_idle+0xe0/0xe4 (unreliable)
[c080ffa0] [c0003e50] rest_init+0xa8/0xd8
[c080ffc0] [c023e80c] start_kernel+0x2b8/0x2cc
[c080fff0] [00003438] 0x3438
Instruction dump:
2f800000 40be003c 38810008 7fe3fb78 38a00040 4bfeb799 7fc6f378 7fe4fb78
7c651b78 3c60c022 386316b0 4804f631 <0fe00000> 38000001 3d20c085 9809aa6c
---[ end trace 0cbe1c7362251e03 ]---
UCC2 Fast registers:
Base address: 0xc91c6200
gumr  : addr=0xc91c6200, val=0x0000003c
upsmr : addr=0xc91c6204, val=0x02002000
utodr : addr=0xc91c6208, val=0x0000
udsr  : addr=0xc91c620c, val=0x7e7e
ucce  : addr=0xc91c6210, val=0x00000000
uccm  : addr=0xc91c6214, val=0x5fff00ff
uccs  : addr=0xc91c6218, val=0x00
urfb  : addr=0xc91c6220, val=0x00001780
urfs  : addr=0xc91c6224, val=0x0200
urfet : addr=0xc91c6228, val=0x0100
urfset: addr=0xc91c622a, val=0x0180
utfb  : addr=0xc91c622c, val=0x00001580
utfs  : addr=0xc91c6230, val=0x0200
utfet : addr=0xc91c6234, val=0x0100
utftt : addr=0xc91c6238, val=0x0200
utpt  : addr=0xc91c623c, val=0x0100
urtry : addr=0xc91c6240, val=0x00000000
guemr : addr=0xc91c6290, val=0x13
UCC3 Geth registers:
Base address: 0xc91ca200
maccfg1    : addr - 0xc91ca300, val - 0x0000003f
maccfg2    : addr - 0xc91ca304, val - 0x00007124
ipgifg     : addr - 0xc91ca308, val - 0x40605060
hafdup     : addr - 0xc91ca30c, val - 0x00a1f037
ifctl      : addr - 0xc91ca338, val - 0x01000000
ifstat     : addr - 0xc91ca33c, val - 0x00000008
macstnaddr1: addr - 0xc91ca340, val - 0x4708007c
macstnaddr2: addr - 0xc91ca344, val - 0x19000000
uempr      : addr - 0xc91ca350, val - 0x00000000
utbipar    : addr - 0xc91ca354, val - 0x00000020
uescr      : addr - 0xc91ca358, val - 0x0804
tx64       : addr - 0xc91ca380, val - 0x00000005
tx127      : addr - 0xc91ca384, val - 0x00000046
tx255      : addr - 0xc91ca388, val - 0x00000121
rx64       : addr - 0xc91ca38c, val - 0x00000002
rx127      : addr - 0xc91ca390, val - 0x00000078
rx255      : addr - 0xc91ca394, val - 0x00000139
txok       : addr - 0xc91ca398, val - 0x0001294f
txcf       : addr - 0xc91ca39c, val - 0x0000
tmca       : addr - 0xc91ca3a0, val - 0x00000000
tbca       : addr - 0xc91ca3a4, val - 0x00000002
rxfok      : addr - 0xc91ca3a8, val - 0x000001a8
rxbok      : addr - 0xc91ca3ac, val - 0x0001563d
rbyt       : addr - 0xc91ca3b0, val - 0x0001843b
rmca       : addr - 0xc91ca3b4, val - 0x00000000
rbca       : addr - 0xc91ca3b8, val - 0x00000004
scar       : addr - 0xc91ca3bc, val - 0x00000000
scam       : addr - 0xc91ca3c0, val - 0xfffe0000
Thread data TXs:
Base address: 0xfdefbb00
Thread data TX[0]:
Base address: 0xfdefbb00
0xfdefbb00: 18000000 188000ca 18000000 18800044
0xfdefbb10: 18000000 1880005e 0260e130 18800044
0xfdefbb20: 02000318 202490c5 00181204 0c00800e
0xfdefbb30: 69fdf7fe b6a7fa9f eddffeaf bb7fff77
0xfdefbb40: 800016e0 b2000080 0260e138 02179876
0xfdefbb50: 80001580 b0000080 0260e138 021798f6
0xfdefbb60: 80001608 b0000080
Thread data RX:
Base address: 0xfdefbd00
Thread data RX[0]:
Base address: 0xfdefbd00
0xfdefbd00: 00000000 08c01055 00000000 02003000
0xfdefbd10: 00000000 08c01055 00000000 02003000
0xfdefbd20: 00001f00 00000005
TX global param:
Base address: 0xfdefba00
temoder      : addr - 0xfdefba00, val - 0x0110
sqptr        : addr - 0xfdefba38, val - 0x000019a0
schedulerbasepointer: addr - 0xfdefba3c, val - 0x00000000
txrmonbaseptr: addr - 0xfdefba40, val - 0x00001a80
tstate       : addr - 0xfdefba44, val - 0x30000000
iphoffset[0] : addr - 0xfdefba48, val - 0x00
iphoffset[1] : addr - 0xfdefba49, val - 0x00
iphoffset[2] : addr - 0xfdefba4a, val - 0x00
iphoffset[3] : addr - 0xfdefba4b, val - 0x00
iphoffset[4] : addr - 0xfdefba4c, val - 0x00
iphoffset[5] : addr - 0xfdefba4d, val - 0x00
iphoffset[6] : addr - 0xfdefba4e, val - 0x00
iphoffset[7] : addr - 0xfdefba4f, val - 0x00
vtagtable[0] : addr - 0xfdefba50, val - 0x00000000
vtagtable[1] : addr - 0xfdefba54, val - 0x00000000
vtagtable[2] : addr - 0xfdefba58, val - 0x00000000
vtagtable[3] : addr - 0xfdefba5c, val - 0x00000000
vtagtable[4] : addr - 0xfdefba60, val - 0x00000000
vtagtable[5] : addr - 0xfdefba64, val - 0x00000000
vtagtable[6] : addr - 0xfdefba68, val - 0x00000000
vtagtable[7] : addr - 0xfdefba6c, val - 0x00000000
tqptr        : addr - 0xfdefba70, val - 0x00001b00
RX global param:
Base address: 0xfdefbc00
remoder         : addr - 0xfdefbc00, val - 0x00001000
rqptr           : addr - 0xfdefbc04, val - 0x00001d00
typeorlen       : addr - 0xfdefbc20, val - 0x0c00
rxgstpack       : addr - 0xfdefbc23, val - 0x00
rxrmonbaseptr   : addr - 0xfdefbc24, val - 0x00001e00
intcoalescingptr: addr - 0xfdefbc30, val - 0x00001ac0
rstate          : addr - 0xfdefbc36, val - 0x30
mrblr           : addr - 0xfdefbc46, val - 0x0600
rbdqptr         : addr - 0xfdefbc48, val - 0x00001e60
mflr            : addr - 0xfdefbc4c, val - 0x05ee
minflr          : addr - 0xfdefbc4e, val - 0x0040
maxd1           : addr - 0xfdefbc50, val - 0x05f0
maxd2           : addr - 0xfdefbc52, val - 0x05f0
ecamptr         : addr - 0xfdefbc54, val - 0x00000000
l2qt            : addr - 0xfdefbc58, val - 0x00000000
l3qt[0]         : addr - 0xfdefbc5c, val - 0x00000000
l3qt[1]         : addr - 0xfdefbc60, val - 0x00000000
l3qt[2]         : addr - 0xfdefbc64, val - 0x00000000
l3qt[3]         : addr - 0xfdefbc68, val - 0x00000000
l3qt[4]         : addr - 0xfdefbc6c, val - 0x00000000
l3qt[5]         : addr - 0xfdefbc70, val - 0x00000000
l3qt[6]         : addr - 0xfdefbc74, val - 0x00000000
l3qt[7]         : addr - 0xfdefbc78, val - 0x00000000
vlantype        : addr - 0xfdefbc7c, val - 0x8100
vlantci         : addr - 0xfdefbc7e, val - 0x0000
addressfiltering[0]: addr - 0xfdefbc80, val - 0x00
addressfiltering[1]: addr - 0xfdefbc81, val - 0x00
addressfiltering[2]: addr - 0xfdefbc82, val - 0x00
addressfiltering[3]: addr - 0xfdefbc83, val - 0x00
addressfiltering[4]: addr - 0xfdefbc84, val - 0x00
addressfiltering[5]: addr - 0xfdefbc85, val - 0x00
addressfiltering[6]: addr - 0xfdefbc86, val - 0x00
addressfiltering[7]: addr - 0xfdefbc87, val - 0x00
addressfiltering[8]: addr - 0xfdefbc88, val - 0x00
addressfiltering[9]: addr - 0xfdefbc89, val - 0x00
addressfiltering[10]: addr - 0xfdefbc8a, val - 0x00
addressfiltering[11]: addr - 0xfdefbc8b, val - 0x01
addressfiltering[12]: addr - 0xfdefbc8c, val - 0x00
addressfiltering[13]: addr - 0xfdefbc8d, val - 0x00
addressfiltering[14]: addr - 0xfdefbc8e, val - 0x00
addressfiltering[15]: addr - 0xfdefbc8f, val - 0x00
addressfiltering[16]: addr - 0xfdefbc90, val - 0x00
addressfiltering[17]: addr - 0xfdefbc91, val - 0x00
addressfiltering[18]: addr - 0xfdefbc92, val - 0x01
addressfiltering[19]: addr - 0xfdefbc93, val - 0x00
addressfiltering[20]: addr - 0xfdefbc94, val - 0x00
addressfiltering[21]: addr - 0xfdefbc95, val - 0x5e
addressfiltering[22]: addr - 0xfdefbc96, val - 0x00
addressfiltering[23]: addr - 0xfdefbc97, val - 0x01
addressfiltering[24]: addr - 0xfdefbc98, val - 0x00
addressfiltering[25]: addr - 0xfdefbc99, val - 0x00
addressfiltering[26]: addr - 0xfdefbc9a, val - 0xff
addressfiltering[27]: addr - 0xfdefbc9b, val - 0xff
addressfiltering[28]: addr - 0xfdefbc9c, val - 0xff
addressfiltering[29]: addr - 0xfdefbc9d, val - 0xff
addressfiltering[30]: addr - 0xfdefbc9e, val - 0xff
addressfiltering[31]: addr - 0xfdefbc9f, val - 0xff
addressfiltering[32]: addr - 0xfdefbca0, val - 0x00
addressfiltering[33]: addr - 0xfdefbca1, val - 0x00
addressfiltering[34]: addr - 0xfdefbca2, val - 0xff
addressfiltering[35]: addr - 0xfdefbca3, val - 0xff
addressfiltering[36]: addr - 0xfdefbca4, val - 0xff
addressfiltering[37]: addr - 0xfdefbca5, val - 0xff
addressfiltering[38]: addr - 0xfdefbca6, val - 0xff
addressfiltering[39]: addr - 0xfdefbca7, val - 0xff
addressfiltering[40]: addr - 0xfdefbca8, val - 0x00
addressfiltering[41]: addr - 0xfdefbca9, val - 0x00
addressfiltering[42]: addr - 0xfdefbcaa, val - 0xff
addressfiltering[43]: addr - 0xfdefbcab, val - 0xff
addressfiltering[44]: addr - 0xfdefbcac, val - 0xff
addressfiltering[45]: addr - 0xfdefbcad, val - 0xff
addressfiltering[46]: addr - 0xfdefbcae, val - 0xff
addressfiltering[47]: addr - 0xfdefbcaf, val - 0xff
addressfiltering[48]: addr - 0xfdefbcb0, val - 0x00
addressfiltering[49]: addr - 0xfdefbcb1, val - 0x00
addressfiltering[50]: addr - 0xfdefbcb2, val - 0xff
addressfiltering[51]: addr - 0xfdefbcb3, val - 0xff
addressfiltering[52]: addr - 0xfdefbcb4, val - 0xff
addressfiltering[53]: addr - 0xfdefbcb5, val - 0xff
addressfiltering[54]: addr - 0xfdefbcb6, val - 0xff
addressfiltering[55]: addr - 0xfdefbcb7, val - 0xff
addressfiltering[56]: addr - 0xfdefbcb8, val - 0x81
addressfiltering[57]: addr - 0xfdefbcb9, val - 0x00
addressfiltering[58]: addr - 0xfdefbcba, val - 0x00
addressfiltering[59]: addr - 0xfdefbcbb, val - 0x00
addressfiltering[60]: addr - 0xfdefbcbc, val - 0x00
addressfiltering[61]: addr - 0xfdefbcbd, val - 0x00
addressfiltering[62]: addr - 0xfdefbcbe, val - 0x00
addressfiltering[63]: addr - 0xfdefbcbf, val - 0x00
exfGlobalParam  : addr - 0xfdefbcc0, val - 0x00000000
Send Q memory registers:
Base address: 0xfdefb9a0
SQQD[0]:
Base address: 0xfdefb9a0
0xfdefb9a0: 0260e0c0 000019c0 0260e0c0 0260e128
0xfdefb9b0: b73b3fff 0260e128 0260e0c0 0260e138
0xfdefb9c0: 180000cb 02158076 18000213 02175876
0xfdefb9d0: 18000044 02158076 1800005e 02203876
TX FW statistics pram:
Base address: 0xfdefba80
0xfdefba80: 00000000 00000000 00000000 00000000
0xfdefba90: 00000000 00000033 0000015b 00000000
0xfdefbaa0: 00000015 0000000c 00000002 00000000
RX FW statistics pram:
Base address: 0xfdefbe00
0xfdefbe00: 00000032 00000000 00000000 00000000
0xfdefbe10: 00000000 00000001 00000000 00000000
0xfdefbe20: 00000000 00000000 00000000 00000000
0xfdefbe30: 00000000 0000000c 00000013 00000007
0xfdefbe40: 00000000 00000000 00000000 00000000
0xfdefbe50: 00000000 00000000 00000000
RX IRQ coalescing tables:
Base address: 0xfdefbac0
RX IRQ coalescing table entry[0]:
Base address: 0xfdefbac0
interruptcoalescingmaxvalue: addr - 0xfdefbac0, val - 0x00000001
interruptcoalescingcounter : addr - 0xfdefbac4, val - 0x00000001
RX BD QS tables:
Base address: 0xfdefbe60
RX BD QS table[0]:
Base address: 0xfdefbe60
bdbaseptr        : addr - 0xfdefbe60, val - 0x00001e70
bdptr            : addr - 0xfdefbe64, val - 0x00001e70
externalbdbaseptr: addr - 0xfdefbe68, val - 0x0260e180
externalbdptr    : addr - 0xfdefbe6c, val - 0x0260e1c0
ucode RX Prefetched BDs:
Base address: 0xfdefbe70
0xfdefbe70: 90000000 0215b040 90000000 02157040
0xfdefbe80: 90000000 0220d040 90000000 02179040
Init enet param shadow:
Base address: 0xc209ccc0
0xc209ccc0: 0630ff00 04000000 11001c03 04000003
0xc209ccd0: 05001f03 00000000 00000000 00000000
0xc209cce0: 00000000 00000000 00000000 00000000
0xc209ccf0: 00000000 00000000 00001a03 0c001ec3
0xc209cd00: 00000000 00000000 00000000 00000000
0xc209cd10: 00000000 00000000 00000000 00
Init enet entry 0:
Base address: 0xfdefbec0
0xfdefbec0: 40001a00 86001b70 80000000 0000000c
0xfdefbed0: a4e3ff7f e27eff3f df196bd9 33fffc2f
0xfdefbee0: 10904802 00000020 06001b60 06001b60
0xfdefbef0: 67bdf7ed 1aebfcba 35fbeddb ff799df6
Init enet entry 1:
Base address: 0xfdefbf00
0xfdefbf00: 00001c00 00000000 80201000 30000001
0xfdefbf10: 8ebffdbf df001ec0 020031fe 08c01055
0xfdefbf20: 1cc00056 0215b840 05f00000 00001e60
0xfdefbf30: 021588c0 00bf2d7e 00000000 ebc77fc7
0xfdefbf40: 00060402 00016482 ca1c80c6 9810e8c3
0xfdefbf50: a7e195b7 0260e1b8 00000005 00000005
0xfdefbf60: 00001000 81000000 8f040182 30069982
0xfdefbf70: affc77bf f1e3eeff 00000580 00000056
TX BDs[0]
0xc260e0c0: 980001b4 02083876 980001b4 0215a076
0xc260e0d0: 980001b4 02159076 98000042 0216a25e
0xc260e0e0: 9800004e 02079452 9800004e 0216aa52
0xc260e0f0: 980001b4 02158076 9800004e 0216ac52
0xc260e100: 9800004e 0216a052 980001b4 0260c076
0xc260e110: 9800004e 02625e52 980001b4 02161876
0xc260e120: 9800004e 02625052 980001b4 02161076
0xc260e130: 98000044 02175876 b80001b4 02179876
RX BDs[0]
0xc260e180: 90000000 02154840 90000000 0220d840
0xc260e190: 90000000 02158840 90000000 02154040
0xc260e1a0: 90000000 02159840 90000000 02175040
0xc260e1b0: 90000000 02203840 90000000 0215b840
0xc260e1c0: 90000000 0215b040 90000000 02157040
0xc260e1d0: 90000000 0220d040 90000000 02179040
0xc260e1e0: 90000000 02083040 90000000 0215a840
0xc260e1f0: 90000000 02157840 b0000000 0260c840
PHY: mdio@e0102320:01 - Link is Up - 10/Half

[-- Attachment #3: Type: text/plain, Size: 150 bytes --]

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* [PATCH] netxen: avoid using reset_devices as it may become obsolete
From: Amit Kumar Salecha @ 2010-11-23 13:08 UTC (permalink / raw)
  To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty, Rajesh Borundia

From: Rajesh Borundia <rajesh.borundia@qlogic.com>

In kdump environment do not depend on reset_devices
parameter to reset the device as the parameter may become obsolete.
Instead use an adapter specific mechanism to determine if the device
needs a reset.

Driver maintains a count of number of pci functions probed
and decrements the count when remove handler of that pci function
is called. If the first probe, probe of function 0,
detects the count as non zero then reset the device.

Signed-off-by: Rajesh Borundia <rajesh.borundia@qlogic.com>
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
---
 drivers/net/netxen/netxen_nic_main.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index e1d30d7..ceeaac9 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1277,6 +1277,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	int i = 0, err;
 	int pci_func_id = PCI_FUNC(pdev->devfn);
 	uint8_t revision_id;
+	u32 val;
 
 	if (pdev->revision >= NX_P3_A0 && pdev->revision <= NX_P3_B1) {
 		pr_warning("%s: chip revisions between 0x%x-0x%x "
@@ -1352,8 +1353,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		break;
 	}
 
-	if (reset_devices) {
-		if (adapter->portnum == 0) {
+	if (adapter->portnum == 0) {
+		val = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
+		if (val != 0xffffffff && val != 0) {
 			NXWR32(adapter, NX_CRB_DEV_REF_COUNT, 0);
 			adapter->need_fw_reset = 1;
 		}
-- 
1.7.3.2


^ permalink raw reply related

* Patch for man unix(7)
From: Tetsuo Handa @ 2010-11-23 12:59 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w
  Cc: linux-man-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <201010262115.FEH09326.OMFJHSVOFLQFOt-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>

 From f388eedbdc0b099bb9f36ab007f9370432abb300 Mon Sep 17 00:00:00 2001
 From: Tetsuo Handa <penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>
Date: Tue, 23 Nov 2010 21:34:25 +0900
Subject: [PATCH] unix.7: Fix description of "pathname" sockets

Since unix_mkname() in net/unix/af_unix.c does

  ((char *)sunaddr)[len] = 0;

rather than

  ((char *)sunaddr)[len - 1] = 0;

, sunaddr->sun_path may not be terminated with a null byte if
len == sizeof(*sunaddr).

Therefore, the caller of getsockname(), getpeername(), accept() must not assume
that sunaddr->sun_path contains a null-terminated pathname even if the returned
addrlen is greater than sizeof(sa_family_t) and sun_path[0] != '\0'.

Signed-off-by: Tetsuo Handa <penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>
---
 man7/unix.7 |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/man7/unix.7 b/man7/unix.7
index b53328b..7b0b47c 100644
--- a/man7/unix.7
+++ b/man7/unix.7
@@ -80,10 +80,23 @@ When the address of the socket is returned by
 and
 .BR accept (2),
 its length is
-.IR "offsetof(struct sockaddr_un, sun_path) + strlen(sun_path) + 1" ,
+.IR "offsetof(struct sockaddr_un, sun_path) + strlen(sun_path) + 1".
+Note that this length can be one byte larger than
+.IR "sizeof(struct sockaddr_un)"
+because
+.BR bind (2)
+accepts
+.IR sun_path
+which is not terminated with a null byte ('\\0').
+Therefore, you must not use string manipulation functions (e.g. strlen(),
+printf("%s")) against
+.IR sun_path
+because
+.BR getsockname (2),
+.BR getpeername (2),
 and
-.I sun_path
-contains the null-terminated pathname.
+.BR accept (2)
+may not have stored a null-terminated string.
 .IP *
 .IR unnamed :
 A stream socket that has not been bound to a pathname using
-- 
1.6.1
--
To unsubscribe from this list: send the line "unsubscribe linux-man" 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 related

* dccp-test-tree [RFC][Patch 1/1] dccp: requesting comments re updating ARP/neighbour table state
From: Gerrit Renker @ 2010-11-23 12:44 UTC (permalink / raw)
  To: dccp, netdev
In-Reply-To: <20101123123656.GB3915@gerrit.erg.abdn.ac.uk>

I noted that DCCP apparently does not update the neighbour tables in the same
way as TCP (or UDP with MSG_CONFIRM). 

This patch adds the missing calls to dst_update(). I would appreciate review
and comments in case I missed something.

DCCP does not have the equivalent of tcp_init_metrics()/tcp_update_metrics().
It seems that this functionality would be more in the CCIDs than in the main
DCCP module (for instance, CCID-3 does not understand ssthresh/cwnd and uses
a different RTT sampling algorithm).

This patch is meant for RFC, not currently for submission. It is in the DCCP
test tree, on 
     
     git://eden-feed.erg.abdn.ac.uk/dccp_exp    [subtree 'dccp']


>>>>>>>>>>>>>>>>>>>>>>>>> Patch <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
dccp: indicate forward progress of connection to lower layer

This patch implements three cases of indicating forward progress:

 1. Peer acknowledging receipt of connection initiation.
    This corresponds to the cases where tcp_init_metrics() is called:
    * receiving Syn-Ack in response to Syn (tcp_rcv_synsent_state_process),
    * receiving Ack to finish the handshake (TCP_SYN_RECV -> TCP_ESTABLISHED);
    which in DCCP corresponds to
    * receiving Response after Request (dccp_rcv_request_sent_state_process),
    * moving from RESPOND/PARTOPEN to OPEN when receiving an Ack/DataAck
      (RESPOND) or non-Sync/Reset (PARTOPEN).
    The latter does no extra rebuild_header() as in tcp_rcv_state_process(),
    since in DCCP an active (client) socket can not become a passive one later,
    and since dccp_v{4,6}_request_recv_sock() already talk to the routing
    system.

 2. Peer advancing GAR (greatest acknowledgment number received).
    This is comparable to making forward progress in tcp_ack().

 3. Peer acknowledging request to terminate the connection.
    This corresponds to TCP teardown -
    * receiving Ack-of-Fin in FIN_WAIT1/LAST_ACK (tcp_rcv_state_process),
    * entering TIME_WAIT (tcp_time_wait),
    and is realized in DCCP when receiving
    * a Reset packet with code "Closed" (in response to DCCP-Close),
    * a Close packet after sending a CloseReq,
    * a Close packet after sending a Close (simultaneous close).

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
 net/dccp/input.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -71,6 +71,7 @@ static int dccp_rcv_close(struct sock *s
 		/* fall through */
 	case DCCP_REQUESTING:
 	case DCCP_ACTIVE_CLOSEREQ:
+		dst_confirm(__sk_dst_get(sk));
 		dccp_send_reset(sk, DCCP_RESET_CODE_CLOSED);
 		dccp_done(sk);
 		break;
@@ -155,6 +156,8 @@ static void dccp_rcv_reset(struct sock *
 	/* Queue the equivalent of TCP fin so that dccp_recvmsg exits the loop */
 	dccp_fin(sk, skb);
 
+	if (dccp_hdr_reset(skb)->dccph_reset_code == DCCP_RESET_CODE_CLOSED)
+		dst_confirm(__sk_dst_get(sk));
 	if (err && !sock_flag(sk, SOCK_DEAD))
 		sk_wake_async(sk, SOCK_WAKE_IO, POLL_ERR);
 	dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
@@ -242,8 +245,10 @@ static int dccp_check_seqno(struct sock 
 
 		if (dh->dccph_type != DCCP_PKT_SYNC &&
 		    ackno != DCCP_PKT_WITHOUT_ACK_SEQ &&
-		    after48(ackno, dp->dccps_gar))
+		    after48(ackno, dp->dccps_gar)) {
+			dst_confirm(__sk_dst_get(sk));
 			dp->dccps_gar = ackno;
+		}
 	} else {
 		unsigned long now = jiffies;
 		/*
@@ -475,6 +480,8 @@ static int dccp_rcv_request_sent_state_p
 		/* Make sure socket is routed, for correct metrics. */
 		icsk->icsk_af_ops->rebuild_header(sk);
 
+		dst_confirm(__sk_dst_get(sk));
+
 		if (!sock_flag(sk, SOCK_DEAD)) {
 			sk->sk_state_change(sk);
 			sk_wake_async(sk, SOCK_WAKE_IO, POLL_OUT);
@@ -556,6 +563,8 @@ static int dccp_rcv_respond_partopen_sta
 			dp->dccps_syn_rtt = dccp_sample_rtt(sk, 10 * delta);
 		}
 
+		dst_confirm(__sk_dst_get(sk));
+
 		dp->dccps_osr = DCCP_SKB_CB(skb)->dccpd_seq;
 		dccp_set_state(sk, DCCP_OPEN);
 

^ permalink raw reply


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