Netdev List
 help / color / mirror / Atom feed
* [PATCH 3/4] net/ipv6/udp: introduce encap_rcv hook into IPv6
From: Benjamin LaHaise @ 2012-04-18 13:44 UTC (permalink / raw)
  To: David S. Miller, James Chapman; +Cc: netdev

Now that the sematics of udpv6_queue_rcv_skb() match IPv4's
udp_queue_rcv_skb(), introduce the UDP encap_rcv() hook for IPv6.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
---
 include/net/udp.h |    3 +++
 net/ipv6/udp.c    |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/include/net/udp.h b/include/net/udp.h
index e66fc29..065f379 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -268,4 +268,7 @@ extern int udp4_ufo_send_check(struct sk_buff *skb);
 extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
 	netdev_features_t features);
 extern void udp_encap_enable(void);
+#if IS_ENABLED(CONFIG_IPV6)
+extern void udpv6_encap_enable(void);
+#endif
 #endif	/* _UDP_H */
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index e507654..d3a486b 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -525,6 +525,14 @@ static __inline__ void udpv6_err(struct sk_buff *skb,
 	__udp6_lib_err(skb, opt, type, code, offset, info, &udp_table);
 }
 
+static struct static_key udpv6_encap_needed __read_mostly;
+void udpv6_encap_enable(void)
+{
+	if (!static_key_enabled(&udpv6_encap_needed))
+		static_key_slow_inc(&udpv6_encap_needed);
+}
+EXPORT_SYMBOL(udpv6_encap_enable);
+
 int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 {
 	struct udp_sock *up = udp_sk(sk);
@@ -534,6 +542,37 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 	if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
 		goto drop;
 
+	if (static_key_false(&udpv6_encap_needed) && up->encap_type) {
+		int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
+
+		/*
+		 * This is an encapsulation socket so pass the skb to
+		 * the socket's udp_encap_rcv() hook. Otherwise, just
+		 * fall through and pass this up the UDP socket.
+		 * up->encap_rcv() returns the following value:
+		 * =0 if skb was successfully passed to the encap
+		 *    handler or was discarded by it.
+		 * >0 if skb should be passed on to UDP.
+		 * <0 if skb should be resubmitted as proto -N
+		 */
+
+		/* if we're overly short, let UDP handle it */
+		encap_rcv = ACCESS_ONCE(up->encap_rcv);
+		if (skb->len > sizeof(struct udphdr) && encap_rcv != NULL) {
+			int ret;
+
+			ret = encap_rcv(sk, skb);
+			if (ret <= 0) {
+				UDP_INC_STATS_BH(sock_net(sk),
+						 UDP_MIB_INDATAGRAMS,
+						 is_udplite);
+				return -ret;
+			}
+		}
+
+		/* FALLTHROUGH -- it's a UDP Packet */
+	}
+
 	/*
 	 * UDP-Lite specific tests, ignored on UDP sockets (see net/ipv4/udp.c).
 	 */
-- 
1.7.4.1


-- 
"Thought is the essence of where you are now."

^ permalink raw reply related

* [PATCH 2/4] net/ipv6/udp: UDP encapsulation: move socket locking into udpv6_queue_rcv_skb()
From: Benjamin LaHaise @ 2012-04-18 13:43 UTC (permalink / raw)
  To: David S. Miller, James Chapman; +Cc: netdev, jchapman

In order to make sure that when the encap_rcv() hook is introduced it is
not called with the socket lock held, move socket locking from callers into
udpv6_queue_rcv_skb(), matching what happens in IPv4.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
---
 net/ipv6/udp.c |   97 +++++++++++++++++++++++++------------------------------
 1 files changed, 44 insertions(+), 53 deletions(-)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 90fcdf6..e507654 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -558,14 +558,25 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 			goto drop;
 	}
 
+	if (sk_rcvqueues_full(sk, skb))
+		goto drop;
+
 	skb_dst_drop(skb);
 
-	rc = __udpv6_queue_rcv_skb(sk, skb);
+	bh_lock_sock(sk);
+	rc = 0;
+	if (!sock_owned_by_user(sk))
+		rc = __udpv6_queue_rcv_skb(sk, skb);
+	else if (sk_add_backlog(sk, skb)) {
+		bh_unlock_sock(sk);
+		goto drop;
+	}
+	bh_unlock_sock(sk);
 
 	return rc;
 drop:
-	atomic_inc(&sk->sk_drops);
 	UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
+	atomic_inc(&sk->sk_drops);
 	kfree_skb(skb);
 	return -1;
 }
@@ -614,37 +625,27 @@ static struct sock *udp_v6_mcast_next(struct net *net, struct sock *sk,
 static void flush_stack(struct sock **stack, unsigned int count,
 			struct sk_buff *skb, unsigned int final)
 {
-	unsigned int i;
+	struct sk_buff *skb1 = NULL;
 	struct sock *sk;
-	struct sk_buff *skb1;
+	unsigned int i;
 
 	for (i = 0; i < count; i++) {
-		skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
-
 		sk = stack[i];
-		if (skb1) {
-			if (sk_rcvqueues_full(sk, skb1)) {
-				kfree_skb(skb1);
-				goto drop;
-			}
-			bh_lock_sock(sk);
-			if (!sock_owned_by_user(sk))
-				udpv6_queue_rcv_skb(sk, skb1);
-			else if (sk_add_backlog(sk, skb1)) {
-				kfree_skb(skb1);
-				bh_unlock_sock(sk);
-				goto drop;
-			}
-			bh_unlock_sock(sk);
-			continue;
+		if (likely(skb1 == NULL))
+			skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
+		if (!skb1) {
+			atomic_inc(&sk->sk_drops);
+			UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
+					  IS_UDPLITE(sk));
+			UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
+					  IS_UDPLITE(sk));
 		}
-drop:
-		atomic_inc(&sk->sk_drops);
-		UDP6_INC_STATS_BH(sock_net(sk),
-				UDP_MIB_RCVBUFERRORS, IS_UDPLITE(sk));
-		UDP6_INC_STATS_BH(sock_net(sk),
-				UDP_MIB_INERRORS, IS_UDPLITE(sk));
+
+		if (skb1 && udpv6_queue_rcv_skb(sk, skb1) <= 0)
+			skb1 = NULL;
 	}
+	if (unlikely(skb1))
+		kfree_skb(skb1);
 }
 /*
  * Note: called only from the BH handler context,
@@ -784,39 +785,29 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	 * for sock caches... i'll skip this for now.
 	 */
 	sk = __udp6_lib_lookup_skb(skb, uh->source, uh->dest, udptable);
+	if (sk != NULL) {
+		int ret = udpv6_queue_rcv_skb(sk, skb);
+		sock_put(sk);
 
-	if (sk == NULL) {
-		if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
-			goto discard;
-
-		if (udp_lib_checksum_complete(skb))
-			goto discard;
-		UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS,
-				proto == IPPROTO_UDPLITE);
-
-		icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
+		/* a return value > 0 means to resubmit the input, but
+		 * it wants the return to be -protocol, or 0
+		 */
+		if (ret > 0)
+			return -ret;
 
-		kfree_skb(skb);
 		return 0;
 	}
 
-	/* deliver */
-
-	if (sk_rcvqueues_full(sk, skb)) {
-		sock_put(sk);
+	if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
 		goto discard;
-	}
-	bh_lock_sock(sk);
-	if (!sock_owned_by_user(sk))
-		udpv6_queue_rcv_skb(sk, skb);
-	else if (sk_add_backlog(sk, skb)) {
-		atomic_inc(&sk->sk_drops);
-		bh_unlock_sock(sk);
-		sock_put(sk);
+
+	if (udp_lib_checksum_complete(skb))
 		goto discard;
-	}
-	bh_unlock_sock(sk);
-	sock_put(sk);
+
+	UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
+	icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
+
+	kfree_skb(skb);
 	return 0;
 
 short_packet:
-- 
1.7.4.1


-- 
"Thought is the essence of where you are now."

^ permalink raw reply related

* [PATCH 1/4] net/ipv6/udp: UDP encapsulation: break backlog_rcv into __udpv6_queue_rcv_skb
From: Benjamin LaHaise @ 2012-04-18 13:42 UTC (permalink / raw)
  To: David S. Miller, James Chapman; +Cc: netdev

This is the first step in reworking the IPv6 UDP code to be structured more
like the IPv4 UDP code.  This patch creates __udpv6_queue_rcv_skb() with
the equivalent sematics to __udp_queue_rcv_skb(), and wires it up to the
backlog_rcv method.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
---
 net/ipv6/udp.c |   42 +++++++++++++++++++++++++++---------------
 1 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 37b0699..90fcdf6 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -496,6 +496,28 @@ out:
 	sock_put(sk);
 }
 
+static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
+{
+	int rc;
+
+	if (!ipv6_addr_any(&inet6_sk(sk)->daddr))
+		sock_rps_save_rxhash(sk, skb);
+
+	rc = sock_queue_rcv_skb(sk, skb);
+	if (rc < 0) {
+		int is_udplite = IS_UDPLITE(sk);
+
+		/* Note that an ENOMEM error is charged twice */
+		if (rc == -ENOMEM)
+			UDP6_INC_STATS_BH(sock_net(sk),
+					UDP_MIB_RCVBUFERRORS, is_udplite);
+		UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
+		kfree_skb(skb);
+		return -1;
+	}
+	return 0;
+}
+
 static __inline__ void udpv6_err(struct sk_buff *skb,
 				 struct inet6_skb_parm *opt, u8 type,
 				 u8 code, int offset, __be32 info     )
@@ -503,15 +525,12 @@ static __inline__ void udpv6_err(struct sk_buff *skb,
 	__udp6_lib_err(skb, opt, type, code, offset, info, &udp_table);
 }
 
-int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
+int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 {
 	struct udp_sock *up = udp_sk(sk);
 	int rc;
 	int is_udplite = IS_UDPLITE(sk);
 
-	if (!ipv6_addr_any(&inet6_sk(sk)->daddr))
-		sock_rps_save_rxhash(sk, skb);
-
 	if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
 		goto drop;
 
@@ -540,19 +559,12 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
 	}
 
 	skb_dst_drop(skb);
-	rc = sock_queue_rcv_skb(sk, skb);
-	if (rc < 0) {
-		/* Note that an ENOMEM error is charged twice */
-		if (rc == -ENOMEM)
-			UDP6_INC_STATS_BH(sock_net(sk),
-					UDP_MIB_RCVBUFERRORS, is_udplite);
-		goto drop_no_sk_drops_inc;
-	}
 
-	return 0;
+	rc = __udpv6_queue_rcv_skb(sk, skb);
+
+	return rc;
 drop:
 	atomic_inc(&sk->sk_drops);
-drop_no_sk_drops_inc:
 	UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
 	kfree_skb(skb);
 	return -1;
@@ -1471,7 +1483,7 @@ struct proto udpv6_prot = {
 	.getsockopt	   = udpv6_getsockopt,
 	.sendmsg	   = udpv6_sendmsg,
 	.recvmsg	   = udpv6_recvmsg,
-	.backlog_rcv	   = udpv6_queue_rcv_skb,
+	.backlog_rcv	   = __udpv6_queue_rcv_skb,
 	.hash		   = udp_lib_hash,
 	.unhash		   = udp_lib_unhash,
 	.rehash		   = udp_v6_rehash,
-- 
1.7.4.1


-- 
"Thought is the essence of where you are now."

^ permalink raw reply related

* RE: [PATCH 00/14] usb/net: rndis: first step toward consolidation
From: Haiyang Zhang @ 2012-04-18 13:17 UTC (permalink / raw)
  To: Linus Walleij
  Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	Greg Kroah-Hartman, David S. Miller, Felipe Balbi,
	Jussi Kivilinna, Wei Yongjun, Ben Hutchings
In-Reply-To: <CACRpkdZ79RtQDeQnFczsH8noX01Qp5cmAPysVs-5v=Nb=aBw=Q@mail.gmail.com>



> -----Original Message-----
> From: Linus Walleij [mailto:linus.walleij@linaro.org]
> Sent: Wednesday, April 18, 2012 8:26 AM
> To: Haiyang Zhang
> Cc: netdev@vger.kernel.org; linux-usb@vger.kernel.org; Greg Kroah-
> Hartman; David S. Miller; Felipe Balbi; Jussi Kivilinna; Wei Yongjun; Ben
> Hutchings
> Subject: Re: [PATCH 00/14] usb/net: rndis: first step toward consolidation
> 
> On Sun, Apr 8, 2012 at 3:58 PM, Haiyang Zhang <haiyangz@microsoft.com>
> wrote:
> > _______________________________________
> >> From: Linus Walleij [linus.walleij@linaro.org]
> >> Sent: Sunday, April 08, 2012 4:46 AM
> >> To: netdev@vger.kernel.org; linux-usb@vger.kernel.org; Greg
> >> Kroah-Hartman; David S. Miller; Felipe Balbi
> >> Cc: Jussi Kivilinna; Haiyang Zhang; Wei Yongjun; Ben Hutchings; Linus
> >> Walleij
> >> Subject: [PATCH 00/14] usb/net: rndis: first step toward
> >> consolidation
> >
> >> So if you like this, let's proceed, but if you're all in "I wanna
> >> keep this one implementation in my corner" I'll just give up right now.
> >
> >> So: what do you think?
> >
> > I will test this soon.
> 
> Ping on this... any testing so far?

I saw Jussi Kivilinna <jussi.kivilinna@mbnet.fi>'s comments saying it does not
work. And your patches are in "changes requested" state. So I'm waiting for
your updated patches before testing.

Thanks,
- Haiyang

^ permalink raw reply

* Re: [patch] Fix handling of overlength pathname in AF_UNIX sun_path
From: Thadeu Lima de Souza Cascardo @ 2012-04-18 13:13 UTC (permalink / raw)
  To: David Laight
  Cc: Carlos O'Donell, David Miller, mtk.manpages, netdev,
	penguin-kernel, linux-api, yoshfuji, jengelh, w, alan
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B6EE2@saturn3.aculab.com>

On Wed, Apr 18, 2012 at 09:17:26AM +0100, David Laight wrote:
> 
> > 
> > Why not have:
> > 
> > diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> > index d510353..f9f77a7 100644
> > --- a/net/unix/af_unix.c
> > +++ b/net/unix/af_unix.c
> > @@ -216,6 +216,9 @@ static int unix_mkname(struct sockaddr_un
> > *sunaddr, int len, unsigned *hashp)
> >                  */
> >                 ((char *)sunaddr)[len] = 0;
> >                 len = strlen(sunaddr->sun_path)+1+sizeof(short);
> > +               /* No null terminator was found in the path. */
> > +               if (len > sizeof(*sunaddr))
> > +                       return -EINVAL;
> >                 return len;
> 
> That could generate a kernel page fault!
> (Depending on what follows (or rather doesn't follow!) sun_path.)
> You'd need to use memchr() not strlen().
> 
> 	David
> 

Hi, David.

What follows is a 0 byte, because it's set that way in the line before
strlen. Note that len is tested for sizeof(*sunaddr), and there is a
huge comment about that extra byte that was omitted.

The whole function is at net/unix/af_unix.c:203.

Regards,
Cascardo.

^ permalink raw reply

* ethtool enhancement proposal
From: Yaniv Rosner @ 2012-04-18 13:05 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev@vger.kernel.org

Hi Ben,
I want to propose new enhancement for the ethtool to display the content of attached SFP+ module.
The format should be similar to the "-e" option, and optionally parse it's content based on SFF-8472.
Please let me know what you think.

Thanks,
Yaniv

^ permalink raw reply

* Re: [patch] Fix handling of overlength pathname in AF_UNIX sun_path
From: Carlos O'Donell @ 2012-04-18 12:57 UTC (permalink / raw)
  To: David Miller
  Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	penguin-kernel-1yMVhJb1mP/7nzcFbJAaVXf5DAMn2ifp,
	linux-api-u79uwXL29TY76Z2rM5mHXA, yoshfuji-VfPWfsRibaP+Ru+s062T9g,
	jengelh-nopoi9nDyk+ELgA04lAiVw, w,
	alan-qBU/x9rampVanCEyBjwyrvXRex20P6io
In-Reply-To: <20120418.001650.1042781402985153056.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>

On Wed, Apr 18, 2012 at 12:16 AM, David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org> wrote:
> From: "Carlos O'Donell" <carlos-v2tUB8YBRSi3e3T8WW9gsA@public.gmane.org>
> Date: Wed, 18 Apr 2012 00:08:47 -0400
>
>> I don't clearly understand your position here, and perhaps that's my
>> own ignorance, but could you please clarify, with examples, exactly
>> why the change is not acceptable?
>
> My position is that since millions upon millions of Linux systems, in
> fact every single Linux system, exists right now with the current
> behavior we are not helping application writers at all by changing
> behavior now after it's been this way for nearly 20 years.
>
> Because if an application writer wants his code to work on systems
> that actually exist he has to accomodate the non-NULL termination
> situation if he wants to inspect or print out an AF_UNIX path.
>
> Because every system in existence right now allows the non-NULL
> terminated AF_UNIX paths, therefore it's possible on every system
> in existence right now.
>
> Catch my drift?
>
> The very thing the patch claims to help, it doesn't.  We install this
> kernel patch now and then tell application writers that they can just
> assume all AF_UNIX paths are NULL terminated when they want to print
> it out, because such code will not actually be guarenteed to work on
> all deployed Linux machines out there.
>
> You cannot just ignore 20 years of precedence and say "oh let's change
> this in the kernel now, and that way application writers don't have to
> worry about that lack of NULL termination any more."  It simply
> doesn't work like that.
>
> All of this talk about whether applications actually create non-NULL
> terminated AF_UNIX paths don't even factor into the conversation.
>
> So the value proposition for this patch simply does not exist.

Thank you, this is the kind of position statement I can point to if I
ever get asked about this again.

In summary your opinion is that the API has and always will allow up
to 108 chars to be used in sun_path?

In which case I will talk to the Austin group to get a good example
added to POSIX showing safe usage.

Cheers,
Carlos.

^ permalink raw reply

* Re: [PATCH] NET: bcm63xx_enet: move phy_(dis)connect into probe/remove
From: Maxime Bizon @ 2012-04-18 12:48 UTC (permalink / raw)
  To: Jonas Gorski; +Cc: netdev, Florian Fainelli, Eric Dumazet, David S. Miller
In-Reply-To: <1334750537-14896-1-git-send-email-jonas.gorski@gmail.com>


On Wed, 2012-04-18 at 14:02 +0200, Jonas Gorski wrote:

> Only connect/disconnect the phy during probe and remove, not during open
> and close. The phy seldom changes during the runtime, and disconnecting
> the phy during close will prevent the phy driver from keeping any
> configuration over a down/up cycle.
> 
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

please CC me, I wrote this driver

> -		phydev = phy_connect(dev, phy_id, bcm_enet_adjust_phy_link, 0,
> -				     PHY_INTERFACE_MODE_MII);

bcm_enet_adjust_link() may modify some dma registers that are reset by
bcm_enet_open(), since it can now be called after probe, we may end up
with broken flow control depending on whatever was called first.


-- 
Maxime

^ permalink raw reply

* Re: [PATCH 3/3] ehea: do not dereference possible NULL port
From: Thadeu Lima de Souza Cascardo @ 2012-04-18 12:42 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, joe
In-Reply-To: <20120417.222912.1038252957653077871.davem@davemloft.net>

On Tue, Apr 17, 2012 at 10:29:12PM -0400, David Miller wrote:
> From: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
> Date: Tue, 17 Apr 2012 11:41:55 -0300
> 
> > port may be NULL when we receive an interrupt too early in the probe.
> > 
> > commit 8c4877a4128e7931077b024a891a4b284d8756a3, in particular, has
> > introduced this problem in the case of port state change interrupt.
> > 
> > This causes crashes in some situations:
> 
> Never fix this kind of bug like this.  Do not make a tasklet or
> an irq handler pay the price of the probe not doing things in the
> right order.
> 
> Do not register asynchronous threads of control until all the
> state is setup properly.
> 
> That's the right way to fix this problem.
> 

Sure. That was in my plans too.

However, at first, I suspected this interrupt may have come from some
other port from ehca, for example, considering a possible firmware bug.
After more investigation, I found out that the real problem was some
physical ports in some odd states, that caused the IRQs before the ports
were enabled. Note that this is not really supposed to happen.

So, consider the possibility that we receive, for a reason like a
firmware bug, an interrupt is received and the EQE indicates a port
number we don't know about. We oops even if we have registered the IRQ
after enabling the ports.

So, I think it's better to be safe to just check for a NULL pointer in
the interrupt (which was being checked either way, just not in the right
place).

So, in fact, I just moved a pointer check because the pointer is now
being used when it wasn't before, due to the commit I referred to.

Would you apply this patch if I include the other one, registering the
IRQ later in the probe process?

Thanks for the comment.
Cascardo.

^ permalink raw reply

* Re[2]:  [PATCH 2/2] IPVS: make failure of netns init more stable
From: Hans Schillstrom @ 2012-04-18 12:37 UTC (permalink / raw)
  To: Julian Anastasov, horms@verge.net.au
  Cc: Hans Schillstrom, wensong@linux-vs.org, lvs-devel@vger.kernel.org,
	netdev@vger.kernel.org, netfilter-devel@vger.kernel.org

Hello 
>
>Hello,
>
>On Tue, 17 Apr 2012, Hans Schillstrom wrote:
>
>> I wonder if we are chasing ghosts...
>> 
>> With proper fault handling I can't even see a case when it (net->ipvs) can be used.
>> Can you see a case when it could happen?
>> Still we can set it to NULL on error exit and cleanup as you suggested, that doesn't harm I think.
>> 
>> A. If you add a netns and it fails the entire ns will be rolled back, 
>>    and no access to that ns can occur.
>>    That ns does not exist
>
>	Agreed
>
>> B. If you insert ip_vs.ko when having one or more name spaces and 
>>    __ip_vs_init() returns an error the module will be unloaded.
>>    All ready loaded ns will not be affected.
>
>	Yes, ip_vs_init fails.
>
>> C. insmod of ex. ip_vs_ftp only affects loaded name spaces
>>    and if the load of ip_vs_ftp fails it will be unloaded without affecting ip_vs(.ko)
>>    (If ip_vs.ko is not loaded then it has to be loaded first case B...)
>> 
>> With a "compiled in" ip_vs case B doesn't exist.
>
>	It is this case that can happen, we can only guess how
>difficult is to get ENOMEM here. IIRC, we can generate only
>ENOMEM error on IPVS core load.
>
>	I assume Simon has such setup and changes code to
>trigger load error. When I generate ENOMEM on IPVS core init
>for such case I get ENOENT from register_ip_vs_app when
>patch 1 and 2 for apps are applied, i.e. net->ipvs is NULL.
>You can check it with NF_CONNTRACK=y, IP_VS=y and
>IP_VS_FTP=m. You only need to trigger ENOMEM in __ip_vs_init.


I did test this with 4 netns loaded and modprobe ip_vs_ftp
In the 4:th netns  (ipvs->gen >= 4) fire a -ENOMEM 
The result was as expected, ip_vs_ftp was not loaded.

All patches below was loaded. (included the ipvs NULL check)

Just for "fun" I also added a printk in the ipvs NULL check
but I can't trigger it. 

Simon:
 do you have any possibility to test it or give me a hint how to do ?
(Just to make sure that the patches below will be sufficient)

>
>> With proper fault handling i.e. all ways returning fault codes to the netns init,
>> there is no need for checking for  "if (!net->ipvs)" or any other action.
>
>	Probably but one check on load does not hurt much.

I think I have tested all of above now and my conclusion is that we need the following patches
which also was applied when the tests was run.
(with a small reservation that I might have missed some..)

[PATCH v3 1/2] netfilter: ipvs: Verify that IP_VS protocol has been registered, Sasha Levin
[PATCH v3 2/2] netfilter: ipvs: use GFP_KERNEL allocation where possible, Sasha Levin

[PATCH 0/6] Convert some GFP_ATOMIC allocations, Julian Anastasov
[PATCH 1/6] ipvs: timeout tables do not need GFP_ATOMIC allocation, Julian Anastasov
[PATCH 2/6] ipvs: SH scheduler does not need GFP_ATOMIC allocation, Julian Anastasov
[PATCH 5/6] ipvs: LBLCR scheduler does not need GFP_ATOMIC allocation on init, Julian Anastasov
[PATCH 6/6] ipvs: WRR scheduler does not need GFP_ATOMIC allocation, Julian Anastasov
[PATCH 3/6] ipvs: DH scheduler does not need GFP_ATOMIC allocation, Julian Anastasov
[PATCH 4/6] ipvs: LBLC scheduler does not need GFP_ATOMIC allocation on init, Julian Anastasov

[PATCH] ipvs: fix crash in ip_vs_control_net_cleanup on unload, Julian Anastasov

[PATCH 1/2] ipvs: reset ipvs pointer in netns, Julian Anastasov
[PATCH 1/2] IPVS: take care of return value from protocol init_netns, Hans Schillstrom

To be safe,  add this to  [PATCH 1/2] ipvs: reset ipvs pointer in netns or make a new patch

diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index 538d74e..c757359 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -439,6 +439,9 @@ static int __net_init __ip_vs_ftp_init(struct net *net)
        struct ip_vs_app *app;
        struct netns_ipvs *ipvs = net_ipvs(net);
 
+       if (!ipvs)
+               return ERR_PTR(-ENOENT);
+
        app = kmemdup(&ip_vs_ftp, sizeof(struct ip_vs_app), GFP_KERNEL);
        if (!app)
                return -ENOMEM;

diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index 74c7278..1d74996 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -549,6 +549,9 @@ static int __net_init __ip_vs_lblc_init(struct net *net)
 {
        struct netns_ipvs *ipvs = net_ipvs(net);
 
+       if (!ipvs)
+               return ERR_PTR(-ENOENT);
+
        if (!net_eq(net, &init_net)) {
                ipvs->lblc_ctl_table = kmemdup(vs_vars_table,
                                                sizeof(vs_vars_table),
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index 8620c68..c328ee0 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -743,6 +743,9 @@ static int __net_init __ip_vs_lblcr_init(struct net *net)
 {
        struct netns_ipvs *ipvs = net_ipvs(net);
 
+       if (!ipvs)
+               return ERR_PTR(-ENOENT);
+
        if (!net_eq(net, &init_net)) {
                ipvs->lblcr_ctl_table = kmemdup(vs_vars_table,
                                                sizeof(vs_vars_table),

>
>Regards
>
>--
>Julian Anastasov <ja@ssi.bg>

Regards
Hans Schillstrom <hans@schillstrom.com>


^ permalink raw reply related

* Re: [PATCH v2] bonding: start slaves with link down for ARP monitor
From: Michal Kubeček @ 2012-04-18 12:32 UTC (permalink / raw)
  To: Jay Vosburgh; +Cc: Flavio Leitner, netdev, Andy Gospodarek
In-Reply-To: <1343782.ObcgmM0SbX@alaris>

On Tuesday 17 of April 2012 13:58EN, Michal Kubeček wrote:
> On Monday 16 of April 2012 12:27EN, Michal Kubeček wrote:
> > On Saturday 14 of April 2012 21:48EN, Jay Vosburgh wrote:
> > > Anybody got a 10 or 100 card laying around with fast autoneg to
> > > try?  Back in the day I used 3c59x and e100s, and I seem to recall
> > > that the 3c59x board I had was pretty speedy at going carrier up.
> > 
> > It seems these cards are hard to find these days (I tried to find
> > one
> > in our office but no luck yet). However, I tried an onboard adapter
> > with r8169 driver and patched kernel succeeded to detect carrier in
> > time for bonding driver to start the slave in "up" state (and it
> > started in "down" state with unplugged cable so that the detection
> > is
> > correct).
> 
> I tested few more cards:
> 
> - two 100 Mb/s Realtek 8139C and 8139D with 8139too driver:
>   driver sets carrier on soon enough and slave starts with "up" and
>   stays that way (same as r8169)
> 
> - 1 Gb/s Intel Pro/1000PT (82572EI) with e1000e driver:
>   essentially the same as igb, driver is slow and patch prevents the
>   up -> down -> up sequence by starting the slave in "down" state
> 
> - 100 Mb/s Intel (?) cards with DECchip Tulip 21142/3, tulip driver:
>   card/driver either doesn't set the flag properly or is extremely
> slow with up -> down transition so that the state was "up" all the
> time no matter what the real link state was

Thanks to Andreas Taschner, I could test some more cards, including 
3COM:

- both 3COM's (3C905CX and 3C595 with 3c59x driver) reset the flag fast
  enough for bonding to detect "up" from the start

- e100 (Compaq NC3120) took about 46 ms which was too late and slave
  started in "down", waiting for ARP monitor

- Marvell 88E8001 (skge driver) needs 2-3 seconds so that the patch
  prevented spurious failure

All tested cards can be divided into three groups:

1. patch helps: igb, e1000e, skge
2. no change: r8169, 8139too, 3c59x, tulip
3. delay introduced: e100

(I also tested a virtual e1000 in VMware Workstation guest, it falls 
into group 2 - initial detection fast enough.)

IMHO the cards currently in use are much more likely to fall into first 
group than into third.

                                                         Michal Kubecek

^ permalink raw reply

* Re: [PATCH 00/14] usb/net: rndis: first step toward consolidation
From: Linus Walleij @ 2012-04-18 12:26 UTC (permalink / raw)
  To: Haiyang Zhang
  Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	Greg Kroah-Hartman, David S. Miller, Felipe Balbi,
	Jussi Kivilinna, Wei Yongjun, Ben Hutchings
In-Reply-To: <A1F3067C9B68744AA19F6802BAB8FFDC0DD215D0@TK5EX14MBXC222.redmond.corp.microsoft.com>

On Sun, Apr 8, 2012 at 3:58 PM, Haiyang Zhang <haiyangz@microsoft.com> wrote:
> _______________________________________
>> From: Linus Walleij [linus.walleij@linaro.org]
>> Sent: Sunday, April 08, 2012 4:46 AM
>> To: netdev@vger.kernel.org; linux-usb@vger.kernel.org; Greg Kroah-Hartman; David S. Miller; Felipe Balbi
>> Cc: Jussi Kivilinna; Haiyang Zhang; Wei Yongjun; Ben Hutchings; Linus Walleij
>> Subject: [PATCH 00/14] usb/net: rndis: first step toward consolidation
>
>> So if you like this, let's proceed, but if you're all in "I wanna keep
>> this one implementation in my corner" I'll just give up right now.
>
>> So: what do you think?
>
> I will test this soon.

Ping on this... any testing so far?

Yours,
Linus Walleij

^ permalink raw reply

* Re: [PATCH] NET: bcm63xx_enet: move phy_(dis)connect into probe/remove
From: Florian Fainelli @ 2012-04-18 12:20 UTC (permalink / raw)
  To: Jonas Gorski; +Cc: netdev, Eric Dumazet, David S. Miller
In-Reply-To: <1334750537-14896-1-git-send-email-jonas.gorski@gmail.com>

Le 04/18/12 14:02, Jonas Gorski a écrit :
> Only connect/disconnect the phy during probe and remove, not during open
> and close. The phy seldom changes during the runtime, and disconnecting
> the phy during close will prevent the phy driver from keeping any
> configuration over a down/up cycle.
>
> Signed-off-by: Jonas Gorski<jonas.gorski@gmail.com>

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

> ---
>   drivers/net/ethernet/broadcom/bcm63xx_enet.c |   84 +++++++++++++-------------
>   1 files changed, 41 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> index c7ca7ec..2744cf0 100644
> --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> @@ -784,10 +784,8 @@ static int bcm_enet_open(struct net_device *dev)
>   	struct bcm_enet_priv *priv;
>   	struct sockaddr addr;
>   	struct device *kdev;
> -	struct phy_device *phydev;
>   	int i, ret;
>   	unsigned int size;
> -	char phy_id[MII_BUS_ID_SIZE + 3];
>   	void *p;
>   	u32 val;
>
> @@ -795,40 +793,10 @@ static int bcm_enet_open(struct net_device *dev)
>   	kdev =&priv->pdev->dev;
>
>   	if (priv->has_phy) {
> -		/* connect to PHY */
> -		snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
> -			 priv->mii_bus->id, priv->phy_id);
> -
> -		phydev = phy_connect(dev, phy_id, bcm_enet_adjust_phy_link, 0,
> -				     PHY_INTERFACE_MODE_MII);
> -
> -		if (IS_ERR(phydev)) {
> -			dev_err(kdev, "could not attach to PHY\n");
> -			return PTR_ERR(phydev);
> -		}
> -
> -		/* mask with MAC supported features */
> -		phydev->supported&= (SUPPORTED_10baseT_Half |
> -				      SUPPORTED_10baseT_Full |
> -				      SUPPORTED_100baseT_Half |
> -				      SUPPORTED_100baseT_Full |
> -				      SUPPORTED_Autoneg |
> -				      SUPPORTED_Pause |
> -				      SUPPORTED_MII);
> -		phydev->advertising = phydev->supported;
> -
> -		if (priv->pause_auto&&  priv->pause_rx&&  priv->pause_tx)
> -			phydev->advertising |= SUPPORTED_Pause;
> -		else
> -			phydev->advertising&= ~SUPPORTED_Pause;
> -
> -		dev_info(kdev, "attached PHY at address %d [%s]\n",
> -			 phydev->addr, phydev->drv->name);
> -
> +		/* Reset state */
>   		priv->old_link = 0;
>   		priv->old_duplex = -1;
>   		priv->old_pause = -1;
> -		priv->phydev = phydev;
>   	}
>
>   	/* mask all interrupts and request them */
> @@ -838,7 +806,7 @@ static int bcm_enet_open(struct net_device *dev)
>
>   	ret = request_irq(dev->irq, bcm_enet_isr_mac, 0, dev->name, dev);
>   	if (ret)
> -		goto out_phy_disconnect;
> +		return ret;
>
>   	ret = request_irq(priv->irq_rx, bcm_enet_isr_dma, IRQF_DISABLED,
>   			  dev->name, dev);
> @@ -1025,9 +993,6 @@ out_freeirq_rx:
>   out_freeirq:
>   	free_irq(dev->irq, dev);
>
> -out_phy_disconnect:
> -	phy_disconnect(priv->phydev);
> -
>   	return ret;
>   }
>
> @@ -1132,12 +1097,6 @@ static int bcm_enet_stop(struct net_device *dev)
>   	free_irq(priv->irq_rx, dev);
>   	free_irq(dev->irq, dev);
>
> -	/* release phy */
> -	if (priv->has_phy) {
> -		phy_disconnect(priv->phydev);
> -		priv->phydev = NULL;
> -	}
> -
>   	return 0;
>   }
>
> @@ -1714,6 +1673,8 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
>
>   	/* MII bus registration */
>   	if (priv->has_phy) {
> +		struct phy_device *phydev;
> +		char phy_id[MII_BUS_ID_SIZE + 3];
>
>   		priv->mii_bus = mdiobus_alloc();
>   		if (!priv->mii_bus) {
> @@ -1750,6 +1711,38 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
>   			dev_err(&pdev->dev, "unable to register mdio bus\n");
>   			goto out_free_mdio;
>   		}
> +
> +		/* connect to PHY */
> +		snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
> +			 priv->mii_bus->id, priv->phy_id);
> +
> +		phydev = phy_connect(dev, phy_id, bcm_enet_adjust_phy_link, 0,
> +				     PHY_INTERFACE_MODE_MII);
> +
> +		if (IS_ERR(phydev)) {
> +			dev_err(&pdev->dev, "could not attach to PHY\n");
> +			goto out_unregister_mdio;
> +		}
> +
> +		/* mask with MAC supported features */
> +		phydev->supported&= (SUPPORTED_10baseT_Half |
> +				      SUPPORTED_10baseT_Full |
> +				      SUPPORTED_100baseT_Half |
> +				      SUPPORTED_100baseT_Full |
> +				      SUPPORTED_Autoneg |
> +				      SUPPORTED_Pause |
> +				      SUPPORTED_MII);
> +		phydev->advertising = phydev->supported;
> +
> +		if (priv->pause_auto&&  priv->pause_rx&&  priv->pause_tx)
> +			phydev->advertising |= SUPPORTED_Pause;
> +		else
> +			phydev->advertising&= ~SUPPORTED_Pause;
> +
> +		dev_info(&pdev->dev, "attached PHY at address %d [%s]\n",
> +			 phydev->addr, phydev->drv->name);
> +
> +		priv->phydev = phydev;
>   	} else {
>
>   		/* run platform code to initialize PHY device */
> @@ -1795,6 +1788,9 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
>   	return 0;
>
>   out_unregister_mdio:
> +	if (!IS_ERR_OR_NULL(priv->phydev))
> +		phy_disconnect(priv->phydev);
> +
>   	if (priv->mii_bus) {
>   		mdiobus_unregister(priv->mii_bus);
>   		kfree(priv->mii_bus->irq);
> @@ -1845,6 +1841,8 @@ static int __devexit bcm_enet_remove(struct platform_device *pdev)
>   	enet_writel(priv, 0, ENET_MIISC_REG);
>
>   	if (priv->has_phy) {
> +		phy_disconnect(priv->phydev);
> +		priv->phydev = NULL;
>   		mdiobus_unregister(priv->mii_bus);
>   		kfree(priv->mii_bus->irq);
>   		mdiobus_free(priv->mii_bus);

^ permalink raw reply

* [PATCH] NET: bcm63xx_enet: move phy_(dis)connect into probe/remove
From: Jonas Gorski @ 2012-04-18 12:02 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Eric Dumazet, David S. Miller

Only connect/disconnect the phy during probe and remove, not during open
and close. The phy seldom changes during the runtime, and disconnecting
the phy during close will prevent the phy driver from keeping any
configuration over a down/up cycle.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 drivers/net/ethernet/broadcom/bcm63xx_enet.c |   84 +++++++++++++-------------
 1 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index c7ca7ec..2744cf0 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -784,10 +784,8 @@ static int bcm_enet_open(struct net_device *dev)
 	struct bcm_enet_priv *priv;
 	struct sockaddr addr;
 	struct device *kdev;
-	struct phy_device *phydev;
 	int i, ret;
 	unsigned int size;
-	char phy_id[MII_BUS_ID_SIZE + 3];
 	void *p;
 	u32 val;
 
@@ -795,40 +793,10 @@ static int bcm_enet_open(struct net_device *dev)
 	kdev = &priv->pdev->dev;
 
 	if (priv->has_phy) {
-		/* connect to PHY */
-		snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
-			 priv->mii_bus->id, priv->phy_id);
-
-		phydev = phy_connect(dev, phy_id, bcm_enet_adjust_phy_link, 0,
-				     PHY_INTERFACE_MODE_MII);
-
-		if (IS_ERR(phydev)) {
-			dev_err(kdev, "could not attach to PHY\n");
-			return PTR_ERR(phydev);
-		}
-
-		/* mask with MAC supported features */
-		phydev->supported &= (SUPPORTED_10baseT_Half |
-				      SUPPORTED_10baseT_Full |
-				      SUPPORTED_100baseT_Half |
-				      SUPPORTED_100baseT_Full |
-				      SUPPORTED_Autoneg |
-				      SUPPORTED_Pause |
-				      SUPPORTED_MII);
-		phydev->advertising = phydev->supported;
-
-		if (priv->pause_auto && priv->pause_rx && priv->pause_tx)
-			phydev->advertising |= SUPPORTED_Pause;
-		else
-			phydev->advertising &= ~SUPPORTED_Pause;
-
-		dev_info(kdev, "attached PHY at address %d [%s]\n",
-			 phydev->addr, phydev->drv->name);
-
+		/* Reset state */
 		priv->old_link = 0;
 		priv->old_duplex = -1;
 		priv->old_pause = -1;
-		priv->phydev = phydev;
 	}
 
 	/* mask all interrupts and request them */
@@ -838,7 +806,7 @@ static int bcm_enet_open(struct net_device *dev)
 
 	ret = request_irq(dev->irq, bcm_enet_isr_mac, 0, dev->name, dev);
 	if (ret)
-		goto out_phy_disconnect;
+		return ret;
 
 	ret = request_irq(priv->irq_rx, bcm_enet_isr_dma, IRQF_DISABLED,
 			  dev->name, dev);
@@ -1025,9 +993,6 @@ out_freeirq_rx:
 out_freeirq:
 	free_irq(dev->irq, dev);
 
-out_phy_disconnect:
-	phy_disconnect(priv->phydev);
-
 	return ret;
 }
 
@@ -1132,12 +1097,6 @@ static int bcm_enet_stop(struct net_device *dev)
 	free_irq(priv->irq_rx, dev);
 	free_irq(dev->irq, dev);
 
-	/* release phy */
-	if (priv->has_phy) {
-		phy_disconnect(priv->phydev);
-		priv->phydev = NULL;
-	}
-
 	return 0;
 }
 
@@ -1714,6 +1673,8 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
 
 	/* MII bus registration */
 	if (priv->has_phy) {
+		struct phy_device *phydev;
+		char phy_id[MII_BUS_ID_SIZE + 3];
 
 		priv->mii_bus = mdiobus_alloc();
 		if (!priv->mii_bus) {
@@ -1750,6 +1711,38 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "unable to register mdio bus\n");
 			goto out_free_mdio;
 		}
+
+		/* connect to PHY */
+		snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
+			 priv->mii_bus->id, priv->phy_id);
+
+		phydev = phy_connect(dev, phy_id, bcm_enet_adjust_phy_link, 0,
+				     PHY_INTERFACE_MODE_MII);
+
+		if (IS_ERR(phydev)) {
+			dev_err(&pdev->dev, "could not attach to PHY\n");
+			goto out_unregister_mdio;
+		}
+
+		/* mask with MAC supported features */
+		phydev->supported &= (SUPPORTED_10baseT_Half |
+				      SUPPORTED_10baseT_Full |
+				      SUPPORTED_100baseT_Half |
+				      SUPPORTED_100baseT_Full |
+				      SUPPORTED_Autoneg |
+				      SUPPORTED_Pause |
+				      SUPPORTED_MII);
+		phydev->advertising = phydev->supported;
+
+		if (priv->pause_auto && priv->pause_rx && priv->pause_tx)
+			phydev->advertising |= SUPPORTED_Pause;
+		else
+			phydev->advertising &= ~SUPPORTED_Pause;
+
+		dev_info(&pdev->dev, "attached PHY at address %d [%s]\n",
+			 phydev->addr, phydev->drv->name);
+
+		priv->phydev = phydev;
 	} else {
 
 		/* run platform code to initialize PHY device */
@@ -1795,6 +1788,9 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
 	return 0;
 
 out_unregister_mdio:
+	if (!IS_ERR_OR_NULL(priv->phydev))
+		phy_disconnect(priv->phydev);
+
 	if (priv->mii_bus) {
 		mdiobus_unregister(priv->mii_bus);
 		kfree(priv->mii_bus->irq);
@@ -1845,6 +1841,8 @@ static int __devexit bcm_enet_remove(struct platform_device *pdev)
 	enet_writel(priv, 0, ENET_MIISC_REG);
 
 	if (priv->has_phy) {
+		phy_disconnect(priv->phydev);
+		priv->phydev = NULL;
 		mdiobus_unregister(priv->mii_bus);
 		kfree(priv->mii_bus->irq);
 		mdiobus_free(priv->mii_bus);
-- 
1.7.2.5

^ permalink raw reply related

* Re: tg3 'No PHY devices' loading issue
From: Josh Boyer @ 2012-04-18 11:43 UTC (permalink / raw)
  To: Harald Hoyer
  Cc: Matt Carlson, Michael Chan, netdev, linux-kernel, Ben Hutchings
In-Reply-To: <4F8E77F7.3080300@redhat.com>

On Wed, Apr 18, 2012 at 10:14:47AM +0200, Harald Hoyer wrote:
> Am 17.04.2012 23:05, schrieb Josh Boyer:
> > So it seems my issue is basically because the initramfs isn't built with
> > the broadcom module included.  I'll have to figure out a way to teach
> > dracut what to do here, since it doesn't seem to be automatically
> > picking it up (Harald CC'd).
> > 
> > Thanks much for the very quick response from everyone.
> > 
> > josh
> 
> Ok, so we have to include all kernel/drivers/net/phy/*.ko in the initramfs?

I believe that is probably the safest and most expedient solution, yes.
Ben said the Debian initramfs tool is doing just that.

josh

^ permalink raw reply

* Re: 3.3.0, 3.4-rc1 reproducible tun Oops
From: Stanislav Kinsbursky @ 2012-04-18 11:32 UTC (permalink / raw)
  To: Simon Kirby; +Cc: Eric Dumazet, netdev@vger.kernel.org
In-Reply-To: <20120417183528.GA32726@hostway.ca>

17.04.2012 22:35, Simon Kirby пишет:
> On Tue, Apr 17, 2012 at 04:18:53PM +0400, Stanislav Kinsbursky wrote:
>
>> 17.04.2012 06:08, Simon Kirby ??????????:
>>> On Thu, Apr 05, 2012 at 04:41:04AM +0200, Eric Dumazet wrote:
>>>
>>>> Hmm, is it happening if you remove the nvidia module ?
>>>>
>>>> If yes, please try to add slub_debug=FZPU
>>>
>>> Finally got annoyed enough at this to bisect it. It doesn't happen every
>>> time and I got a bit confused, but I finally tracked it down to:
>>>
>>> 1ab5ecb90cb6a3df1476e052f76a6e8f6511cb3d is the first bad commit
>>> commit 1ab5ecb90cb6a3df1476e052f76a6e8f6511cb3d
>>> Author: Stanislav Kinsbursky<skinsbursky@parallels.com>
>>> Date:   Mon Mar 12 02:59:41 2012 +0000
>>>
>>>      tun: don't hold network namespace by tun sockets
>>>
>>>      v3: added previously removed sock_put() to the tun_release() callback, because
>>>      sk_release_kernel() doesn't drop the socket reference.
>>>
>>>      v2: sk_release_kernel() used for socket release. Dummy tun_release() is
>>>      required for sk_release_kernel() --->   sock_release() --->   sock->ops->release()
>>>      call.
>>>
>>>      TUN was designed to destroy it's socket on network namesapce shutdown. But this
>>>      will never happen for persistent device, because it's socket holds network
>>>      namespace.
>>>      This patch removes of holding network namespace by TUN socket and replaces it
>>>      by creating socket in init_net and then changing it's net it to desired one. On
>>>      shutdown socket is moved back to init_net prior to final put.
>>>
>>>      Signed-off-by: Stanislav Kinsbursky<skinsbursky@parallels.com>
>>>      Signed-off-by: David S. Miller<davem@davemloft.net>
>>>
>>> ...With this reverted on top of 3.4-rc3, I no longer see crashes when I
>>> keep making and breaking the SSH tunnel while running "vmstat 1" in an
>>> SSH session over a socket that is running through that tunnel.
>>>
>>> Simon-
>>
>> Hi, Simon.
>> Could you please try to apply the patch below on top of your the
>> tree (with 1ab5ecb90cb6a3df1476e052f76a6e8f6511cb3d applied) and
>> check does it fix the problem:
>>
>> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
>> index bb8c72c..1fc4622 100644
>> --- a/drivers/net/tun.c
>> +++ b/drivers/net/tun.c
>> @@ -1540,13 +1540,10 @@ static int tun_chr_close(struct inode
>> *inode, struct file *file)
>>   			if (dev->reg_state == NETREG_REGISTERED)
>>   				unregister_netdevice(dev);
>>   			rtnl_unlock();
>> -		}
>> +		} else
>> +			sock_put(tun->socket.sk);
>>   	}
>>
>> -	tun = tfile->tun;
>> -	if (tun)
>> -		sock_put(tun->socket.sk);
>> -
>>   	put_net(tfile->net);
>>   	kfree(tfile);
>
> (Whitespace-damaged patch, applied manually)
>
> Yes, I no longer see crashes with this applied. I haven't tried with
> kmemleak or similar, but it seems to work.
>
> Thanks,
>

This bug looks like double free, but I can't understand how does this can happen...
Simon, would be really great, if you'll describe in details some simple way, how 
to reproduce the bug.

-- 
Best regards,
Stanislav Kinsbursky

^ permalink raw reply

* Re: fake rtable dst patch applied but kernel keeps panicing
From: Eric Dumazet @ 2012-04-18 10:31 UTC (permalink / raw)
  To: Massimo Cetra; +Cc: netdev, peter.huangpeng
In-Reply-To: <4F8E9291.9000607@navynet.it>

On Wed, 2012-04-18 at 12:08 +0200, Massimo Cetra wrote:
> Hi Eric,
> Hi Peter,
> 
> I applied the 1st patch by Peter to a 3.2.14 kernel, compiled, installed 
> and rebooted.
> 
> I have had another panic and i'm attaching the oops as i received it 
> through netcnsole.
> 
> I don't think the patch is enough to prevent the OOPS.
> 
> Can i be helpful in some way ?
> 
> Thanks,
>   Massimo

Seems a different issue, skb->nf_bridge seems to be NULL

^ permalink raw reply

* fake rtable dst patch applied but kernel keeps panicing
From: Massimo Cetra @ 2012-04-18 10:08 UTC (permalink / raw)
  To: netdev; +Cc: Eric Dumazet, peter.huangpeng

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

Hi Eric,
Hi Peter,

I applied the 1st patch by Peter to a 3.2.14 kernel, compiled, installed 
and rebooted.

I have had another panic and i'm attaching the oops as i received it 
through netcnsole.

I don't think the patch is enough to prevent the OOPS.

Can i be helpful in some way ?

Thanks,
  Massimo

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

Apr 18 11:53:31 lamu [ 1749.735232] BUG: unable to handle kernel 
Apr 18 11:53:31 NULL pointer dereference
Apr 18 11:53:31 lamu  at 0000000000000018
Apr 18 11:53:31 lamu [ 1749.750893] IP:
Apr 18 11:53:31 lamu  [<ffffffffa02d233d>] br_nf_forward_finish+0x2e/0x95 [bridge]
Apr 18 11:53:31 lamu [ 1749.764978] PGD 0 
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1749.768992] Oops: 0000 [#1] 
Apr 18 11:53:31 SMP  
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1749.775450] CPU 0 
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1749.779105] Modules linked in:
Apr 18 11:53:31 lamu  ipt_MASQUERADE
Apr 18 11:53:31 lamu  iptable_nat
Apr 18 11:53:31 lamu  nf_nat
Apr 18 11:53:31 lamu  nf_conntrack_ipv4
Apr 18 11:53:31 lamu  nf_defrag_ipv4
Apr 18 11:53:31 lamu  ip_vs_rr
Apr 18 11:53:31 lamu  ip_vs
Apr 18 11:53:31 lamu  nf_conntrack
Apr 18 11:53:31 lamu  libcrc32c
Apr 18 11:53:31 lamu  ip6table_filter
Apr 18 11:53:31 lamu  ip6_tables
Apr 18 11:53:31 lamu  iptable_filter
Apr 18 11:53:31 lamu  ip_tables
Apr 18 11:53:31 lamu  ebtable_nat
Apr 18 11:53:31 lamu  ebtables
Apr 18 11:53:31 lamu  x_tables
Apr 18 11:53:31 lamu  crc32c
Apr 18 11:53:31 lamu  drbd
Apr 18 11:53:31 lamu  lru_cache
Apr 18 11:53:31 lamu  cn
Apr 18 11:53:31 lamu  sit
Apr 18 11:53:31 lamu  tunnel4
Apr 18 11:53:31 lamu  tun
Apr 18 11:53:31 lamu  bridge
Apr 18 11:53:31 lamu  stp
Apr 18 11:53:31 lamu  virtio_net
Apr 18 11:53:31 lamu  virtio_blk
Apr 18 11:53:31 lamu  virtio_rng
Apr 18 11:53:31 lamu  rng_core
Apr 18 11:53:31 lamu  virtio_pci
Apr 18 11:53:31 lamu  virtio_ring
Apr 18 11:53:31 lamu  virtio
Apr 18 11:53:31 lamu  kvm_intel
Apr 18 11:53:31 lamu  kvm
Apr 18 11:53:31 lamu  ipmi_devintf
Apr 18 11:53:31 lamu  ipmi_poweroff
Apr 18 11:53:31 lamu  ipmi_si
Apr 18 11:53:31 lamu  ipmi_watchdog
Apr 18 11:53:31 lamu  ipmi_msghandler
Apr 18 11:53:31 lamu  netconsole
Apr 18 11:53:31 lamu  configfs
Apr 18 11:53:31 lamu  loop
Apr 18 11:53:31 lamu  snd_pcm
Apr 18 11:53:31 lamu  snd_page_alloc
Apr 18 11:53:31 lamu  option
Apr 18 11:53:31 lamu  snd_timer
Apr 18 11:53:31 lamu  snd
Apr 18 11:53:31 lamu  usb_wwan
Apr 18 11:53:31 lamu  usbserial
Apr 18 11:53:31 lamu  iTCO_wdt
Apr 18 11:53:31 lamu  i7core_edac
Apr 18 11:53:31 lamu  edac_core
Apr 18 11:53:31 lamu  processor
Apr 18 11:53:31 lamu  joydev
Apr 18 11:53:31 lamu  soundcore
Apr 18 11:53:31 lamu  iTCO_vendor_support
Apr 18 11:53:31 lamu  psmouse
Apr 18 11:53:31 lamu  button
Apr 18 11:53:31 lamu  dcdbas
Apr 18 11:53:31 lamu  serio_raw
Apr 18 11:53:31 lamu  evdev
Apr 18 11:53:31 lamu  pcspkr
Apr 18 11:53:31 lamu  thermal_sys
Apr 18 11:53:31 lamu  ext3
Apr 18 11:53:31 lamu  mbcache
Apr 18 11:53:31 lamu  jbd
Apr 18 11:53:31 lamu  dm_mod
Apr 18 11:53:31 lamu  sr_mod
Apr 18 11:53:31 lamu  cdrom
Apr 18 11:53:31 lamu  ses
Apr 18 11:53:31 lamu  sd_mod
Apr 18 11:53:31 lamu  usbhid
Apr 18 11:53:31 lamu  hid
Apr 18 11:53:31 lamu  usb_storage
Apr 18 11:53:31 lamu  uas
Apr 18 11:53:31 lamu  crc_t10dif
Apr 18 11:53:31 lamu  enclosure
Apr 18 11:53:31 lamu  ata_generic
Apr 18 11:53:31 lamu  uhci_hcd
Apr 18 11:53:31 lamu  ata_piix
Apr 18 11:53:31 lamu  ehci_hcd
Apr 18 11:53:31 lamu  libata
Apr 18 11:53:31 lamu  usbcore
Apr 18 11:53:31 lamu  usb_common
Apr 18 11:53:31 lamu  megaraid_sas
Apr 18 11:53:31 lamu  scsi_mod
Apr 18 11:53:31 lamu  bnx2
Apr 18 11:53:31 lamu  [last unloaded: scsi_wait_scan]
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1749.931103] 
Apr 18 11:53:31 lamu [ 1749.934064] Pid: 5936, comm: kvm Not tainted 3.2.0-2-amd64 #1
Apr 18 11:53:31 lamu  Dell Inc. PowerEdge R410
Apr 18 11:53:31 lamu /0N051F 
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1749.951108] RIP: 0010:[<ffffffffa02d233d>] 
Apr 18 11:53:31 lamu  [<ffffffffa02d233d>] br_nf_forward_finish+0x2e/0x95 [bridge]
Apr 18 11:53:31 lamu [ 1749.970058] RSP: 0018:ffff88042fc03b18  EFLAGS: 00010293
Apr 18 11:53:31 lamu [ 1749.980667] RAX: 0000000000000000 RBX: ffff880419b10880 RCX: 0000000100058883
Apr 18 11:53:31 lamu [ 1749.994915] RDX: ffffffffa02d230f RSI: 0000000000000282 RDI: ffff880419b10880
Apr 18 11:53:31 lamu [ 1750.009164] RBP: ffff880225216000 R08: 0000000000000000 R09: ffff88042fc03ad0
Apr 18 11:53:31 lamu [ 1750.023414] R10: ffffffff8165aac0 R11: ffffffff8165aac0 R12: 0000000000000000
Apr 18 11:53:31 lamu [ 1750.037662] R13: ffff880225afc002 R14: ffff8803ec883c00 R15: ffff880225afc000
Apr 18 11:53:31 lamu [ 1750.051911] FS:  00007f4355786900(0000) GS:ffff88042fc00000(0000) knlGS:0000000000000000
Apr 18 11:53:31 lamu [ 1750.068085] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Apr 18 11:53:31 lamu [ 1750.079560] CR2: 0000000000000018 CR3: 0000000417220000 CR4: 00000000000026e0
Apr 18 11:53:31 lamu [ 1750.093809] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Apr 18 11:53:31 lamu [ 1750.108060] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Apr 18 11:53:31 lamu [ 1750.122309] Process kvm (pid: 5936, threadinfo ffff88041b750000, task ffff880419bce930)
Apr 18 11:53:31 lamu [ 1750.138306] Stack:
Apr 18 11:53:31 lamu [ 1750.142323]  ffffffff80000000
Apr 18 11:53:31 lamu  ffffffffa02d2714
Apr 18 11:53:31 lamu  ffff880419b10880
Apr 18 11:53:31 lamu  ffff880225216000
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1750.157156]  ffff8802279a5000
Apr 18 11:53:31 lamu  ffffffffa02d2aa0
Apr 18 11:53:31 lamu  ffff880380000000
Apr 18 11:53:31 lamu  0000000225216740
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1750.171986]  ffff880419b10880
Apr 18 11:53:31 lamu  ffffffffa02d8cd0
Apr 18 11:53:31 lamu  ffffffff81691190
Apr 18 11:53:31 lamu  0000000000000002
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1750.186819] Call Trace:
Apr 18 11:53:31 lamu [ 1750.191703]  <IRQ> 
Apr 18 11:53:31 lamu  
Apr 18 11:53:31 lamu [ 1750.195909]  [<ffffffffa02d2714>] ? br_parse_ip_options+0x3d/0x19a [bridge]
Apr 18 11:53:31 lamu [ 1750.209816]  [<ffffffffa02d2aa0>] ? br_nf_forward_ip+0x1c0/0x1d4 [bridge]
Apr 18 11:53:31 lamu [ 1750.223375]  [<ffffffff812abfa1>] ? nf_iterate+0x41/0x77
Apr 18 11:53:31 lamu [ 1750.233986]  [<ffffffffa02cd941>] ? __br_deliver+0xa0/0xa0 [bridge]
Apr 18 11:53:31 lamu [ 1750.246504]  [<ffffffffa02cd941>] ? __br_deliver+0xa0/0xa0 [bridge]
Apr 18 11:53:31 lamu [ 1750.259020]  [<ffffffff812ac03f>] ? nf_hook_slow+0x68/0x101
Apr 18 11:53:31 lamu [ 1750.270152]  [<ffffffffa02cd941>] ? __br_deliver+0xa0/0xa0 [bridge]
Apr 18 11:53:31 lamu [ 1750.282670]  [<ffffffffa02ce3a2>] ? NF_HOOK.constprop.4+0x56/0x56 [bridge]
Apr 18 11:53:31 lamu [ 1750.296403]  [<ffffffffa02cd941>] ? __br_deliver+0xa0/0xa0 [bridge]
Apr 18 11:53:31 lamu [ 1750.308921]  [<ffffffffa02cd887>] ? NF_HOOK.constprop.10+0x3c/0x56 [bridge]
Apr 18 11:53:31 ataru ntpd[14048]: Listen normally on 56 br0:0 77.238.6.181 UDP 123
Apr 18 11:53:31 ataru ntpd[14048]: Listen normally on 57 br1:0 172.16.1.39 UDP 123
Apr 18 11:53:31 ataru ntpd[14048]: peers refreshed
Apr 18 11:53:31 lamu [ 1750.322826]  [<ffffffffa02cda1b>] ? br_forward+0x16/0x5a [bridge]
Apr 18 11:53:31 lamu [ 1750.334998]  [<ffffffffa02ce543>] ? br_handle_frame_finish+0x1a1/0x20f [bridge]
Apr 18 11:53:31 lamu [ 1750.349613]  [<ffffffffa02d2638>] ? br_nf_pre_routing_finish+0x1ee/0x1fb [bridge]
Apr 18 11:53:31 lamu [ 1750.364575]  [<ffffffffa02d1ff7>] ? NF_HOOK_THRESH+0x3b/0x55 [bridge]
Apr 18 11:53:31 lamu [ 1750.377440]  [<ffffffffa02d2f91>] ? br_nf_pre_routing+0x3e8/0x3f5 [bridge]
Apr 18 11:53:31 lamu [ 1750.391171]  [<ffffffff812abfa1>] ? nf_iterate+0x41/0x77
Apr 18 11:53:31 lamu [ 1750.401783]  [<ffffffffa02ce3a2>] ? NF_HOOK.constprop.4+0x56/0x56 [bridge]
Apr 18 11:53:31 lamu [ 1750.415514]  [<ffffffff812ac03f>] ? nf_hook_slow+0x68/0x101
Apr 18 11:53:31 lamu [ 1750.426644]  [<ffffffffa02ce3a2>] ? NF_HOOK.constprop.4+0x56/0x56 [bridge]
Apr 18 11:53:31 lamu [ 1750.440375]  [<ffffffffa02ce3a2>] ? NF_HOOK.constprop.4+0x56/0x56 [bridge]
Apr 18 11:53:32 lamu [ 1750.454106]  [<ffffffffa02ce388>] ? NF_HOOK.constprop.4+0x3c/0x56 [bridge]
Apr 18 11:53:32 lamu [ 1750.467839]  [<ffffffff810135ad>] ? paravirt_read_tsc+0x5/0x8
Apr 18 11:53:32 lamu [ 1750.479314]  [<ffffffff81013622>] ? read_tsc+0x5/0x14
Apr 18 11:53:32 lamu [ 1750.489403]  [<ffffffffa02ce764>] ? br_handle_frame+0x1b3/0x1cb [bridge]
Apr 18 11:53:32 lamu [ 1750.502788]  [<ffffffffa02ce5b1>] ? br_handle_frame_finish+0x20f/0x20f [bridge]
Apr 18 11:53:32 lamu [ 1750.517406]  [<ffffffff81289222>] ? __netif_receive_skb+0x324/0x41f
Apr 18 11:53:32 lamu [ 1750.529922]  [<ffffffff81289389>] ? process_backlog+0x6c/0x123
Apr 18 11:53:32 lamu [ 1750.541573]  [<ffffffff8128b26f>] ? net_rx_action+0xa1/0x1af
Apr 18 11:53:32 lamu [ 1750.552878]  [<ffffffff81036faf>] ? test_tsk_need_resched+0xa/0x13
Apr 18 11:53:32 lamu [ 1750.565222]  [<ffffffff8104be34>] ? __do_softirq+0xb9/0x177
Apr 18 11:53:32 lamu [ 1750.576355]  [<ffffffff813503ec>] ? call_softirq+0x1c/0x30
Apr 18 11:53:32 lamu [ 1750.587307]  <EOI> 
Apr 18 11:53:32 lamu  
Apr 18 11:53:32 lamu [ 1750.591512]  [<ffffffff8100f8e5>] ? do_softirq+0x3c/0x7b
Apr 18 11:53:32 lamu [ 1750.602120]  [<ffffffff8128b55f>] ? netif_rx_ni+0x1e/0x27
Apr 18 11:53:32 lamu [ 1750.612904]  [<ffffffffa0309721>] ? tun_get_user+0x39a/0x3c2 [tun]
Apr 18 11:53:32 lamu [ 1750.625249]  [<ffffffffa0309a66>] ? tun_chr_poll+0xcd/0xcd [tun]
Apr 18 11:53:32 lamu [ 1750.637245]  [<ffffffffa0309ac4>] ? tun_chr_aio_write+0x5e/0x79 [tun]
Apr 18 11:53:32 lamu [ 1750.650111]  [<ffffffff810f95e4>] ? do_sync_readv_writev+0x9a/0xd7
Apr 18 11:53:32 lamu [ 1750.662455]  [<ffffffff810363cb>] ? should_resched+0x5/0x23
Apr 18 11:53:32 lamu [ 1750.673583]  [<ffffffff810363cb>] ? should_resched+0x5/0x23
Apr 18 11:53:32 lamu [ 1750.684718]  [<ffffffff81162649>] ? security_file_permission+0x16/0x2d
Apr 18 11:53:32 lamu [ 1750.697755]  [<ffffffff810f9848>] ? do_readv_writev+0xaf/0x11c
Apr 18 11:53:32 lamu [ 1750.709407]  [<ffffffff8112abce>] ? eventfd_ctx_read+0x162/0x174
Apr 18 11:53:32 lamu [ 1750.721405]  [<ffffffff8103f403>] ? try_to_wake_up+0x197/0x197
Apr 18 11:53:32 lamu [ 1750.733054]  [<ffffffff810f9a1d>] ? sys_writev+0x45/0x90
Apr 18 11:53:32 lamu [ 1750.743664]  [<ffffffff8134e192>] ? system_call_fastpath+0x16/0x1b
Apr 18 11:53:32 lamu [ 1750.756004] Code: 
Apr 18 11:53:32 53  
Apr 18 11:53:32 48  
Apr 18 11:53:32 89  
Apr 18 11:53:32 fb  
Apr 18 11:53:32 48  
Apr 18 11:53:32 83  
Apr 18 11:53:32 ec  
Apr 18 11:53:32 10  
Apr 18 11:53:32 66  
Apr 18 11:53:32 81  
Apr 18 11:53:32 7f  
Apr 18 11:53:32 7e  
Apr 18 11:53:32 08  
Apr 18 11:53:32 06  
Apr 18 11:53:32 4c  
Apr 18 11:53:32 8b  
Apr 18 11:53:32 a7  
Apr 18 11:53:32 98  
Apr 18 11:53:32 00  
Apr 18 11:53:32 00  
Apr 18 11:53:32 00  
Apr 18 11:53:32 74  
Apr 18 11:53:32 3d  
Apr 18 11:53:32 e8  
Apr 18 11:53:32 07  
Apr 18 11:53:32 fe  
Apr 18 11:53:32 ff  
Apr 18 11:53:32 ff  
Apr 18 11:53:32 66  
Apr 18 11:53:32 3d  
Apr 18 11:53:32 08  
Apr 18 11:53:32 06  
Apr 18 11:53:32 75  
Apr 18 11:53:32 09  
Apr 18 11:53:32 83  
Apr 18 11:53:32 3d  
Apr 18 11:53:32 91  
Apr 18 11:53:32 6a  
Apr 18 11:53:32 00  
Apr 18 11:53:32 00  
Apr 18 11:53:32 00  
Apr 18 11:53:32 75  
Apr 18 11:53:32 29  
Apr 18 11:53:32 lamu  
Apr 18 11:53:32 f6  
Apr 18 11:53:32 44  
Apr 18 11:53:32 24  
Apr 18 11:53:32 18  
Apr 18 11:53:32 01  
Apr 18 11:53:32 49  
Apr 18 11:53:32 8b  
Apr 18 11:53:32 6c  
Apr 18 11:53:32 24  
Apr 18 11:53:32 08  
Apr 18 11:53:32 74  
Apr 18 11:53:32 12  
Apr 18 11:53:32 8a  
Apr 18 11:53:32 43  
Apr 18 11:53:32 7d  
Apr 18 11:53:32 83  
Apr 18 11:53:32 e0  
Apr 18 11:53:32 f8  
Apr 18 11:53:32 83  
Apr 18 11:53:32 c8  
Apr 18 11:53:32 lamu  
Apr 18 11:53:32 lamu [ 1750.794643] RIP 
Apr 18 11:53:32 lamu  [<ffffffffa02d233d>] br_nf_forward_finish+0x2e/0x95 [bridge]
Apr 18 11:53:32 lamu [ 1750.808909]  RSP <ffff88042fc03b18>
Apr 18 11:53:32 lamu [ 1750.815875] CR2: 0000000000000018
Apr 18 11:53:32 lamu [ 1750.823229] ---[ end trace edf4c83afa62cdb9 ]---
Apr 18 11:53:32 lamu [ 1750.832693] Kernel panic - not syncing: Fatal exception in interrupt
Apr 18 11:53:32 lamu [ 1750.845601] Pid: 5936, comm: kvm Tainted: G      D      3.2.0-2-amd64 #1
Apr 18 11:53:32 lamu [ 1750.859399] Call Trace:
Apr 18 11:53:32 lamu [ 1750.864741]  <IRQ> 
Apr 18 11:53:32 lamu  [<ffffffff81342aa0>] ? panic+0x95/0x1a5
Apr 18 11:53:32 lamu [ 1750.876729]  [<ffffffff8134a006>] ? oops_end+0xa9/0xb6
Apr 18 11:53:32 lamu [ 1750.887462]  [<ffffffff813423ec>] ? no_context+0x1ff/0x20e
Apr 18 11:53:32 lamu [ 1750.898989]  [<ffffffff81052266>] ? __mod_timer+0x139/0x14b
Apr 18 11:53:32 lamu [ 1750.910619]  [<ffffffff8134c019>] ? do_page_fault+0x1a8/0x337
Apr 18 11:53:32 lamu [ 1750.922490]  [<ffffffffa03d9f06>] ? ip_vs_conn_put+0x28/0x32 [ip_vs]
Apr 18 11:53:32 lamu [ 1750.935665]  [<ffffffffa03dc0e0>] ? ip_vs_out+0x2bd/0x432 [ip_vs]
Apr 18 11:53:32 lamu [ 1750.948343]  [<ffffffffa02cd847>] ? br_dev_queue_push_xmit+0x9b/0x9f [bridge]
Apr 18 11:53:32 lamu [ 1750.963100]  [<ffffffff81349775>] ? page_fault+0x25/0x30
Apr 18 11:53:32 lamu [ 1750.974217]  [<ffffffffa02d230f>] ? nf_bridge_update_protocol+0x20/0x20 [bridge]
Apr 18 11:53:32 lamu [ 1750.989475]  [<ffffffffa02d233d>] ? br_nf_forward_finish+0x2e/0x95 [bridge]
Apr 18 11:53:32 lamu [ 1751.003874]  [<ffffffffa02d232e>] ? br_nf_forward_finish+0x1f/0x95 [bridge]
Apr 18 11:53:32 lamu [ 1751.018288]  [<ffffffffa02d2714>] ? br_parse_ip_options+0x3d/0x19a [bridge]
Apr 18 11:53:32 lamu [ 1751.032665]  [<ffffffffa02d2aa0>] ? br_nf_forward_ip+0x1c0/0x1d4 [bridge]
Apr 18 11:53:32 lamu [ 1751.046726]  [<ffffffff812abfa1>] ? nf_iterate+0x41/0x77
Apr 18 11:53:32 lamu [ 1751.057748]  [<ffffffffa02cd941>] ? __br_deliver+0xa0/0xa0 [bridge]
Apr 18 11:53:32 lamu [ 1751.070699]  [<ffffffffa02cd941>] ? __br_deliver+0xa0/0xa0 [bridge]
Apr 18 11:53:32 lamu [ 1751.083635]  [<ffffffff812ac03f>] ? nf_hook_slow+0x68/0x101
Apr 18 11:53:32 lamu [ 1751.095178]  [<ffffffffa02cd941>] ? __br_deliver+0xa0/0xa0 [bridge]
Apr 18 11:53:32 lamu [ 1751.108133]  [<ffffffffa02ce3a2>] ? NF_HOOK.constprop.4+0x56/0x56 [bridge]
Apr 18 11:53:32 lamu [ 1751.122284]  [<ffffffffa02cd941>] ? __br_deliver+0xa0/0xa0 [bridge]
Apr 18 11:53:32 lamu [ 1751.135191]  [<ffffffffa02cd887>] ? NF_HOOK.constprop.10+0x3c/0x56 [bridge]
Apr 18 11:53:32 lamu [ 1751.149495]  [<ffffffffa02cda1b>] ? br_forward+0x16/0x5a [bridge]
Apr 18 11:53:32 lamu [ 1751.162178]  [<ffffffffa02ce543>] ? br_handle_frame_finish+0x1a1/0x20f [bridge]
Apr 18 11:53:32 lamu [ 1751.177209]  [<ffffffffa02d2638>] ? br_nf_pre_routing_finish+0x1ee/0x1fb [bridge]
Apr 18 11:53:32 lamu [ 1751.192580]  [<ffffffffa02d1ff7>] ? NF_HOOK_THRESH+0x3b/0x55 [bridge]
Apr 18 11:53:32 lamu [ 1751.205860]  [<ffffffffa02d2f91>] ? br_nf_pre_routing+0x3e8/0x3f5 [bridge]
Apr 18 11:53:32 lamu [ 1751.219995]  [<ffffffff812abfa1>] ? nf_iterate+0x41/0x77
Apr 18 11:53:32 lamu [ 1751.231061]  [<ffffffffa02ce3a2>] ? NF_HOOK.constprop.4+0x56/0x56 [bridge]
Apr 18 11:53:32 lamu [ 1751.245296]  [<ffffffff812ac03f>] ? nf_hook_slow+0x68/0x101
Apr 18 11:53:32 lamu [ 1751.256882]  [<ffffffffa02ce3a2>] ? NF_HOOK.constprop.4+0x56/0x56 [bridge]
Apr 18 11:53:32 lamu [ 1751.271011]  [<ffffffffa02ce3a2>] ? NF_HOOK.constprop.4+0x56/0x56 [bridge]
Apr 18 11:53:32 lamu [ 1751.285168]  [<ffffffffa02ce388>] ? NF_HOOK.constprop.4+0x3c/0x56 [bridge]
Apr 18 11:53:32 lamu [ 1751.299280]  [<ffffffff810135ad>] ? paravirt_read_tsc+0x5/0x8
Apr 18 11:53:32 lamu [ 1751.311154]  [<ffffffff81013622>] ? read_tsc+0x5/0x14
Apr 18 11:53:32 lamu [ 1751.321748]  [<ffffffffa02ce764>] ? br_handle_frame+0x1b3/0x1cb [bridge]
Apr 18 11:53:32 lamu [ 1751.335512]  [<ffffffffa02ce5b1>] ? br_handle_frame_finish+0x20f/0x20f [bridge]
Apr 18 11:53:32 lamu [ 1751.350390]  [<ffffffff81289222>] ? __netif_receive_skb+0x324/0x41f
Apr 18 11:53:32 lamu [ 1751.363287]  [<ffffffff81289389>] ? process_backlog+0x6c/0x123
Apr 18 11:53:32 lamu [ 1751.375344]  [<ffffffff8128b26f>] ? net_rx_action+0xa1/0x1af
Apr 18 11:53:32 lamu [ 1751.387056]  [<ffffffff81036faf>] ? test_tsk_need_resched+0xa/0x13
Apr 18 11:53:32 lamu [ 1751.399819]  [<ffffffff8104be34>] ? __do_softirq+0xb9/0x177
Apr 18 11:53:32 lamu [ 1751.411354]  [<ffffffff813503ec>] ? call_softirq+0x1c/0x30
Apr 18 11:53:32 lamu [ 1751.422774]  <EOI> 
Apr 18 11:53:32 lamu  [<ffffffff8100f8e5>] ? do_softirq+0x3c/0x7b
Apr 18 11:53:32 lamu [ 1751.435471]  [<ffffffff8128b55f>] ? netif_rx_ni+0x1e/0x27
Apr 18 11:53:32 lamu [ 1751.446679]  [<ffffffffa0309721>] ? tun_get_user+0x39a/0x3c2 [tun]
Apr 18 11:53:33 lamu [ 1751.459426]  [<ffffffffa0309a66>] ? tun_chr_poll+0xcd/0xcd [tun]
Apr 18 11:53:33 lamu [ 1751.471861]  [<ffffffffa0309ac4>] ? tun_chr_aio_write+0x5e/0x79 [tun]
Apr 18 11:53:33 lamu [ 1751.485116]  [<ffffffff810f95e4>] ? do_sync_readv_writev+0x9a/0xd7
Apr 18 11:53:33 lamu [ 1751.497903]  [<ffffffff810363cb>] ? should_resched+0x5/0x23
Apr 18 11:53:33 lamu [ 1751.509414]  [<ffffffff810363cb>] ? should_resched+0x5/0x23
Apr 18 11:53:33 lamu [ 1751.520933]  [<ffffffff81162649>] ? security_file_permission+0x16/0x2d
Apr 18 11:53:33 lamu [ 1751.534358]  [<ffffffff810f9848>] ? do_readv_writev+0xaf/0x11c
Apr 18 11:53:33 lamu [ 1751.546397]  [<ffffffff8112abce>] ? eventfd_ctx_read+0x162/0x174
Apr 18 11:53:33 lamu [ 1751.558815]  [<ffffffff8103f403>] ? try_to_wake_up+0x197/0x197
Apr 18 11:53:33 lamu [ 1751.570869]  [<ffffffff810f9a1d>] ? sys_writev+0x45/0x90
Apr 18 11:53:33 lamu [ 1751.581979]  [<ffffffff8134e192>] ? system_call_fastpath+0x16/0x1b

^ permalink raw reply

* pull request: batman-adv 2012-04-18
From: Antonio Quartulli @ 2012-04-18  9:59 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r

Hello David,

this is the fixed version of my previous pull request (issued on 2012-04-17).
In this patchset the issues you reported have been fixed; moreover I'm
also including two new patches (1/13 and 2/13) which are respectively:

1/13) a fix for Al Viro's report about the missing htons()
2/13) a fix for a wrongly duplicated line in a comment

The following changes since commit ecffe75f934b4e3c5301fe5db278068e0efb0d6b:

  hippi: fix printk format in rrunner.c (2012-04-16 23:48:38 -0400)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batman-adv-for-davem

for you to fetch changes up to 1e5cc266dbc401d11aefb966ad35e651c2f67414:

  batman-adv: skip the window protection test when the originator has no neighbours (2012-04-18 09:54:02 +0200)

----------------------------------------------------------------
Included changes:
* remove duplicated line in comment
* add htons() invocation for tt_crc as suggested by Al Viro
* OriGinator Message seqno initial value is now random
* some cleanups and fixes

----------------------------------------------------------------
Antonio Quartulli (5):
      batman-adv: convert the tt_crc to network order
      batman-adv: remove duplicated line in comment
      batman-adv: use ETH_HLEN instead of sizeof(struct ethhdr)
      batman-adv: print OGM seq numbers as unsigned int
      batman-adv: skip the window protection test when the originator has no neighbours

Marek Lindner (8):
      batman-adv: move ogm initialization into the proper function
      batman-adv: refactoring API: find generalized name for bat_ogm_init callback
      batman-adv: randomize initial seqno to avoid collision
      batman-adv: add iface_disable() callback to routing API
      batman-adv: handle routing code initialization properly
      batman-adv: refactoring API: find generalized name for bat_ogm_init_primary callback
      batman-adv: rename BATMAN_OGM_LEN to BATMAN_OGM_HLEN
      batman-adv: mark existing ogm variables as batman iv

 net/batman-adv/bat_iv_ogm.c            |   63 +++++++++++++++++++++-----------
 net/batman-adv/bridge_loop_avoidance.c |   11 ++----
 net/batman-adv/hard-interface.c        |   33 +++++++++--------
 net/batman-adv/icmp_socket.c           |    4 +-
 net/batman-adv/main.c                  |    5 ++-
 net/batman-adv/packet.h                |    6 +--
 net/batman-adv/routing.c               |   10 ++---
 net/batman-adv/send.c                  |   14 +++----
 net/batman-adv/soft-interface.c        |    2 +-
 net/batman-adv/translation-table.c     |    2 +-
 net/batman-adv/types.h                 |   12 +++---
 net/batman-adv/vis.c                   |    8 ++--
 12 files changed, 96 insertions(+), 74 deletions(-)

^ permalink raw reply

* [PATCH 11/13] batman-adv: use ETH_HLEN instead of sizeof(struct ethhdr)
From: Antonio Quartulli @ 2012-04-18 10:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n, Antonio Quartulli
In-Reply-To: <1334743210-12338-1-git-send-email-ordex@autistici.org>

Instead of using sizeof(struct ethhdr) it is strongly recommended to use the
kernel macro ETH_HLEN. This patch substitute each occurrence of the former
expressione with the latter one.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 net/batman-adv/bat_iv_ogm.c            |    7 +++----
 net/batman-adv/bridge_loop_avoidance.c |   10 ++++------
 net/batman-adv/hard-interface.c        |    3 +--
 net/batman-adv/icmp_socket.c           |    4 ++--
 net/batman-adv/routing.c               |    8 ++++----
 net/batman-adv/send.c                  |    2 +-
 net/batman-adv/soft-interface.c        |    2 +-
 net/batman-adv/types.h                 |    2 +-
 net/batman-adv/vis.c                   |    8 ++++----
 9 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 98f7182..d7fa8af 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -355,10 +355,9 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
 	if ((atomic_read(&bat_priv->aggregated_ogms)) &&
 	    (packet_len < MAX_AGGREGATION_BYTES))
 		forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES +
-						      sizeof(struct ethhdr));
+						      ETH_HLEN);
 	else
-		forw_packet_aggr->skb = dev_alloc_skb(packet_len +
-						      sizeof(struct ethhdr));
+		forw_packet_aggr->skb = dev_alloc_skb(packet_len + ETH_HLEN);
 
 	if (!forw_packet_aggr->skb) {
 		if (!own_packet)
@@ -366,7 +365,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
 		kfree(forw_packet_aggr);
 		goto out;
 	}
-	skb_reserve(forw_packet_aggr->skb, sizeof(struct ethhdr));
+	skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
 
 	INIT_HLIST_NODE(&forw_packet_aggr->list);
 
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index c8642b5..ad394c6 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -290,9 +290,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
 		goto out;
 
 	ethhdr = (struct ethhdr *)skb->data;
-	hw_src = (uint8_t *)ethhdr +
-		 sizeof(struct ethhdr) +
-		 sizeof(struct arphdr);
+	hw_src = (uint8_t *)ethhdr + ETH_HLEN + sizeof(struct arphdr);
 
 	/* now we pretend that the client would have sent this ... */
 	switch (claimtype) {
@@ -340,7 +338,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
 	skb_reset_mac_header(skb);
 	skb->protocol = eth_type_trans(skb, soft_iface);
 	bat_priv->stats.rx_packets++;
-	bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr);
+	bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
 	soft_iface->last_rx = jiffies;
 
 	netif_rx(skb);
@@ -844,7 +842,7 @@ static int bla_process_claim(struct bat_priv *bat_priv,
 		headlen = sizeof(*vhdr);
 	} else {
 		proto = ntohs(ethhdr->h_proto);
-		headlen = sizeof(*ethhdr);
+		headlen = ETH_HLEN;
 	}
 
 	if (proto != ETH_P_ARP)
@@ -1302,7 +1300,7 @@ int bla_is_backbone_gw(struct sk_buff *skb,
 		return 0;
 
 	/* first, find out the vid. */
-	if (!pskb_may_pull(skb, hdr_size + sizeof(struct ethhdr)))
+	if (!pskb_may_pull(skb, hdr_size + ETH_HLEN))
 		return 0;
 
 	ethhdr = (struct ethhdr *)(((uint8_t *)skb->data) + hdr_size);
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index e8c5da3..47c79d7 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -574,8 +574,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
 		goto err_free;
 
 	/* expect a valid ethernet header here. */
-	if (unlikely(skb->mac_len != sizeof(struct ethhdr) ||
-		     !skb_mac_header(skb)))
+	if (unlikely(skb->mac_len != ETH_HLEN || !skb_mac_header(skb)))
 		goto err_free;
 
 	if (!hard_iface->soft_iface)
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index b87518e..2e98a57 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -175,13 +175,13 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
 	if (len >= sizeof(struct icmp_packet_rr))
 		packet_len = sizeof(struct icmp_packet_rr);
 
-	skb = dev_alloc_skb(packet_len + sizeof(struct ethhdr));
+	skb = dev_alloc_skb(packet_len + ETH_HLEN);
 	if (!skb) {
 		len = -ENOMEM;
 		goto out;
 	}
 
-	skb_reserve(skb, sizeof(struct ethhdr));
+	skb_reserve(skb, ETH_HLEN);
 	icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len);
 
 	if (copy_from_user(icmp_packet, buff, packet_len)) {
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index ac13a6a..ff56086 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -313,7 +313,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
 		goto out;
 
 	/* create a copy of the skb, if needed, to modify it. */
-	if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+	if (skb_cow(skb, ETH_HLEN) < 0)
 		goto out;
 
 	icmp_packet = (struct icmp_packet_rr *)skb->data;
@@ -368,7 +368,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
 		goto out;
 
 	/* create a copy of the skb, if needed, to modify it. */
-	if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+	if (skb_cow(skb, ETH_HLEN) < 0)
 		goto out;
 
 	icmp_packet = (struct icmp_packet *)skb->data;
@@ -454,7 +454,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
 		goto out;
 
 	/* create a copy of the skb, if needed, to modify it. */
-	if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+	if (skb_cow(skb, ETH_HLEN) < 0)
 		goto out;
 
 	icmp_packet = (struct icmp_packet_rr *)skb->data;
@@ -841,7 +841,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
 		goto out;
 
 	/* create a copy of the skb, if needed, to modify it. */
-	if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+	if (skb_cow(skb, ETH_HLEN) < 0)
 		goto out;
 
 	unicast_packet = (struct unicast_packet *)skb->data;
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index b5f078c..7c66b61 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -51,7 +51,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
 	}
 
 	/* push to the ethernet header. */
-	if (my_skb_head_push(skb, sizeof(*ethhdr)) < 0)
+	if (my_skb_head_push(skb, ETH_HLEN) < 0)
 		goto send_skb_err;
 
 	skb_reset_mac_header(skb);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index efe0fba..6e2530b 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -292,7 +292,7 @@ void interface_rx(struct net_device *soft_iface,
 /*	skb->ip_summed = CHECKSUM_UNNECESSARY;*/
 
 	bat_priv->stats.rx_packets++;
-	bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr);
+	bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
 
 	soft_iface->last_rx = jiffies;
 
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 4d93aad..2f4848b 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -27,7 +27,7 @@
 #include "packet.h"
 #include "bitarray.h"
 
-#define BAT_HEADER_LEN (sizeof(struct ethhdr) + \
+#define BAT_HEADER_LEN (ETH_HLEN + \
 	((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \
 	 sizeof(struct unicast_packet) : \
 	 sizeof(struct bcast_packet))))
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index c4a5b8c..cec216f 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -434,12 +434,12 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
 		return NULL;
 
 	info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len +
-					 sizeof(struct ethhdr));
+					 ETH_HLEN);
 	if (!info->skb_packet) {
 		kfree(info);
 		return NULL;
 	}
-	skb_reserve(info->skb_packet, sizeof(struct ethhdr));
+	skb_reserve(info->skb_packet, ETH_HLEN);
 	packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet)
 					      + vis_info_len);
 
@@ -894,11 +894,11 @@ int vis_init(struct bat_priv *bat_priv)
 
 	bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) +
 							  MAX_VIS_PACKET_SIZE +
-							 sizeof(struct ethhdr));
+							  ETH_HLEN);
 	if (!bat_priv->my_vis_info->skb_packet)
 		goto free_info;
 
-	skb_reserve(bat_priv->my_vis_info->skb_packet, sizeof(struct ethhdr));
+	skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN);
 	packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet,
 					      sizeof(*packet));
 
-- 
1.7.9.4

^ permalink raw reply related

* [PATCH 13/13] batman-adv: skip the window protection test when the originator has no neighbours
From: Antonio Quartulli @ 2012-04-18 10:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n, Antonio Quartulli
In-Reply-To: <1334743210-12338-1-git-send-email-ordex@autistici.org>

When we receive an OGM from from a node for the first time, the last_real_seqno
field of the orig_node structure has not been initialised yet. The value of this
field is used to compute the current ogm-seqno window and therefore the
protection mechanism will probably drop the packet due to an out-of-window error.
To avoid this situation this patch adds a check to skip the window protection
mechanism if no neighbour nodes have already been added. When the first
neighbour node is added, the last_real_seqno field is initialised too.

Reported-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 net/batman-adv/bat_iv_ogm.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 1014210..8b2db2e 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -861,7 +861,8 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
 	seq_diff = batman_ogm_packet->seqno - orig_node->last_real_seqno;
 
 	/* signalize caller that the packet is to be dropped. */
-	if (window_protected(bat_priv, seq_diff,
+	if (!hlist_empty(&orig_node->neigh_list) &&
+	    window_protected(bat_priv, seq_diff,
 			     &orig_node->batman_seqno_reset))
 		goto out;
 
-- 
1.7.9.4

^ permalink raw reply related

* [PATCH 12/13] batman-adv: print OGM seq numbers as unsigned int
From: Antonio Quartulli @ 2012-04-18 10:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n, Antonio Quartulli
In-Reply-To: <1334743210-12338-1-git-send-email-ordex@autistici.org>

OGM sequence numbers are declared as uint32_t and so they have to printed
using %u instead of %d in order to avoid wrong representations.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 net/batman-adv/bat_iv_ogm.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index d7fa8af..1014210 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -152,7 +152,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
 							    "Sending own" :
 							    "Forwarding"));
 		bat_dbg(DBG_BATMAN, bat_priv,
-			"%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
+			"%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
 			fwd_str, (packet_num > 0 ? "aggregated " : ""),
 			batman_ogm_packet->orig,
 			ntohl(batman_ogm_packet->seqno),
@@ -211,7 +211,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
 
 		/* FIXME: what about aggregated packets ? */
 		bat_dbg(DBG_BATMAN, bat_priv,
-			"%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%pM]\n",
+			"%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n",
 			(forw_packet->own ? "Sending own" : "Forwarding"),
 			batman_ogm_packet->orig,
 			ntohl(batman_ogm_packet->seqno),
@@ -892,7 +892,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
 
 	if (need_update) {
 		bat_dbg(DBG_BATMAN, bat_priv,
-			"updating last_seqno: old %d, new %d\n",
+			"updating last_seqno: old %u, new %u\n",
 			orig_node->last_real_seqno, batman_ogm_packet->seqno);
 		orig_node->last_real_seqno = batman_ogm_packet->seqno;
 	}
@@ -945,7 +945,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
 					   batman_ogm_packet->orig) ? 1 : 0);
 
 	bat_dbg(DBG_BATMAN, bat_priv,
-		"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %d, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
+		"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
 		ethhdr->h_source, if_incoming->net_dev->name,
 		if_incoming->net_dev->dev_addr, batman_ogm_packet->orig,
 		batman_ogm_packet->prev_sender, batman_ogm_packet->seqno,
-- 
1.7.9.4

^ permalink raw reply related

* [PATCH 10/13] batman-adv: mark existing ogm variables as batman iv
From: Antonio Quartulli @ 2012-04-18 10:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n, Marek Lindner, Antonio Quartulli
In-Reply-To: <1334743210-12338-1-git-send-email-ordex@autistici.org>

From: Marek Lindner <lindner_marek@yahoo.de>

The coming protocol changes also will have a part called "OGM". That
makes it necessary to introduce a distinction in the code base.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 net/batman-adv/bat_iv_ogm.c     |    4 ++--
 net/batman-adv/hard-interface.c |    2 +-
 net/batman-adv/packet.h         |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index a2af289..98f7182 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -47,7 +47,7 @@ static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface)
 		goto out;
 
 	batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
-	batman_ogm_packet->header.packet_type = BAT_OGM;
+	batman_ogm_packet->header.packet_type = BAT_IV_OGM;
 	batman_ogm_packet->header.version = COMPAT_VERSION;
 	batman_ogm_packet->header.ttl = 2;
 	batman_ogm_packet->flags = NO_FLAGS;
@@ -934,7 +934,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
 	 * packet in an aggregation.  Here we expect that the padding
 	 * is always zero (or not 0x01)
 	 */
-	if (batman_ogm_packet->header.packet_type != BAT_OGM)
+	if (batman_ogm_packet->header.packet_type != BAT_IV_OGM)
 		return;
 
 	/* could be changed by schedule_own_packet() */
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 75a555b..e8c5da3 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -604,7 +604,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
 
 	switch (batman_ogm_packet->header.packet_type) {
 		/* batman originator packet */
-	case BAT_OGM:
+	case BAT_IV_OGM:
 		ret = recv_bat_ogm_packet(skb, hard_iface);
 		break;
 
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 59dec0a..f54969c 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -25,7 +25,7 @@
 #define ETH_P_BATMAN  0x4305	/* unofficial/not registered Ethertype */
 
 enum bat_packettype {
-	BAT_OGM		 = 0x01,
+	BAT_IV_OGM	 = 0x01,
 	BAT_ICMP	 = 0x02,
 	BAT_UNICAST	 = 0x03,
 	BAT_BCAST	 = 0x04,
@@ -38,7 +38,7 @@ enum bat_packettype {
 /* this file is included by batctl which needs these defines */
 #define COMPAT_VERSION 14
 
-enum batman_flags {
+enum batman_iv_flags {
 	PRIMARIES_FIRST_HOP = 1 << 4,
 	VIS_SERVER	    = 1 << 5,
 	DIRECTLINK	    = 1 << 6
-- 
1.7.9.4

^ permalink raw reply related

* [PATCH 08/13] batman-adv: refactoring API: find generalized name for bat_ogm_init_primary callback
From: Antonio Quartulli @ 2012-04-18 10:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n, Marek Lindner, Antonio Quartulli
In-Reply-To: <1334743210-12338-1-git-send-email-ordex@autistici.org>

From: Marek Lindner <lindner_marek@yahoo.de>

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 net/batman-adv/bat_iv_ogm.c     |    4 ++--
 net/batman-adv/hard-interface.c |    2 +-
 net/batman-adv/main.c           |    2 +-
 net/batman-adv/types.h          |    4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 2714670..c0bdb90 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -67,7 +67,7 @@ static void bat_iv_ogm_iface_disable(struct hard_iface *hard_iface)
 	hard_iface->packet_buff = NULL;
 }
 
-static void bat_iv_ogm_init_primary(struct hard_iface *hard_iface)
+static void bat_iv_ogm_primary_iface_set(struct hard_iface *hard_iface)
 {
 	struct batman_ogm_packet *batman_ogm_packet;
 
@@ -1191,7 +1191,7 @@ static struct bat_algo_ops batman_iv __read_mostly = {
 	.name = "BATMAN IV",
 	.bat_iface_enable = bat_iv_ogm_iface_enable,
 	.bat_iface_disable = bat_iv_ogm_iface_disable,
-	.bat_ogm_init_primary = bat_iv_ogm_init_primary,
+	.bat_primary_iface_set = bat_iv_ogm_primary_iface_set,
 	.bat_ogm_update_mac = bat_iv_ogm_update_mac,
 	.bat_ogm_schedule = bat_iv_ogm_schedule,
 	.bat_ogm_emit = bat_iv_ogm_emit,
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 3b391fd..75a555b 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -146,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
 	if (!new_hard_iface)
 		goto out;
 
-	bat_priv->bat_algo_ops->bat_ogm_init_primary(new_hard_iface);
+	bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface);
 	primary_if_update_addr(bat_priv, curr_hard_iface);
 
 out:
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index a47a6ce..7913272 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -210,7 +210,7 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
 	/* all algorithms must implement all ops (for now) */
 	if (!bat_algo_ops->bat_iface_enable ||
 	    !bat_algo_ops->bat_iface_disable ||
-	    !bat_algo_ops->bat_ogm_init_primary ||
+	    !bat_algo_ops->bat_primary_iface_set ||
 	    !bat_algo_ops->bat_ogm_update_mac ||
 	    !bat_algo_ops->bat_ogm_schedule ||
 	    !bat_algo_ops->bat_ogm_emit ||
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index dd78023..4d93aad 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -381,8 +381,8 @@ struct bat_algo_ops {
 	int (*bat_iface_enable)(struct hard_iface *hard_iface);
 	/* de-init routing info when hard-interface is disabled */
 	void (*bat_iface_disable)(struct hard_iface *hard_iface);
-	/* init primary OGM when primary interface is selected */
-	void (*bat_ogm_init_primary)(struct hard_iface *hard_iface);
+	/* called when primary interface is selected / changed */
+	void (*bat_primary_iface_set)(struct hard_iface *hard_iface);
 	/* init mac addresses of the OGM belonging to this hard-interface */
 	void (*bat_ogm_update_mac)(struct hard_iface *hard_iface);
 	/* prepare a new outgoing OGM for the send queue */
-- 
1.7.9.4

^ permalink raw reply related

* [PATCH 09/13] batman-adv: rename BATMAN_OGM_LEN to BATMAN_OGM_HLEN
From: Antonio Quartulli @ 2012-04-18 10:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n, Marek Lindner, Antonio Quartulli
In-Reply-To: <1334743210-12338-1-git-send-email-ordex@autistici.org>

From: Marek Lindner <lindner_marek@yahoo.de>

Using BATMAN_OGM_LEN leaves one with the impression that this is
the full packet size which is not the case. Therefore the variable
is renamed.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 net/batman-adv/bat_iv_ogm.c |   12 ++++++------
 net/batman-adv/packet.h     |    2 +-
 net/batman-adv/routing.c    |    2 +-
 net/batman-adv/send.c       |   12 ++++++------
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index c0bdb90..a2af289 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -40,7 +40,7 @@ static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface)
 	get_random_bytes(&random_seqno, sizeof(random_seqno));
 	atomic_set(&hard_iface->seqno, random_seqno);
 
-	hard_iface->packet_len = BATMAN_OGM_LEN;
+	hard_iface->packet_len = BATMAN_OGM_HLEN;
 	hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
 
 	if (!hard_iface->packet_buff)
@@ -112,7 +112,7 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
 static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len,
 				  int tt_num_changes)
 {
-	int next_buff_pos = buff_pos + BATMAN_OGM_LEN + tt_len(tt_num_changes);
+	int next_buff_pos = buff_pos + BATMAN_OGM_HLEN + tt_len(tt_num_changes);
 
 	return (next_buff_pos <= packet_len) &&
 		(next_buff_pos <= MAX_AGGREGATION_BYTES);
@@ -162,7 +162,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
 			batman_ogm_packet->ttvn, hard_iface->net_dev->name,
 			hard_iface->net_dev->dev_addr);
 
-		buff_pos += BATMAN_OGM_LEN +
+		buff_pos += BATMAN_OGM_HLEN +
 				tt_len(batman_ogm_packet->tt_num_changes);
 		packet_num++;
 		batman_ogm_packet = (struct batman_ogm_packet *)
@@ -540,7 +540,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
 		batman_ogm_packet->flags &= ~DIRECTLINK;
 
 	bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
-			     BATMAN_OGM_LEN + tt_len(tt_num_changes),
+			     BATMAN_OGM_HLEN + tt_len(tt_num_changes),
 			     if_incoming, 0, bat_iv_ogm_fwd_send_time());
 }
 
@@ -1173,12 +1173,12 @@ static void bat_iv_ogm_receive(struct hard_iface *if_incoming,
 		batman_ogm_packet->seqno = ntohl(batman_ogm_packet->seqno);
 		batman_ogm_packet->tt_crc = ntohs(batman_ogm_packet->tt_crc);
 
-		tt_buff = packet_buff + buff_pos + BATMAN_OGM_LEN;
+		tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN;
 
 		bat_iv_ogm_process(ethhdr, batman_ogm_packet,
 				   tt_buff, if_incoming);
 
-		buff_pos += BATMAN_OGM_LEN +
+		buff_pos += BATMAN_OGM_HLEN +
 				tt_len(batman_ogm_packet->tt_num_changes);
 
 		batman_ogm_packet = (struct batman_ogm_packet *)
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 59800e8..59dec0a 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -126,7 +126,7 @@ struct batman_ogm_packet {
 	uint16_t tt_crc;
 } __packed;
 
-#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)
+#define BATMAN_OGM_HLEN sizeof(struct batman_ogm_packet)
 
 struct icmp_packet {
 	struct batman_header header;
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 78eddc9..ac13a6a 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -254,7 +254,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
 	struct ethhdr *ethhdr;
 
 	/* drop packet if it has not necessary minimum size */
-	if (unlikely(!pskb_may_pull(skb, BATMAN_OGM_LEN)))
+	if (unlikely(!pskb_may_pull(skb, BATMAN_OGM_HLEN)))
 		return NET_RX_DROP;
 
 	ethhdr = (struct ethhdr *)skb_mac_header(skb);
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index af7a674..b5f078c 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -87,7 +87,7 @@ static void realloc_packet_buffer(struct hard_iface *hard_iface,
 	/* keep old buffer if kmalloc should fail */
 	if (new_buff) {
 		memcpy(new_buff, hard_iface->packet_buff,
-		       BATMAN_OGM_LEN);
+		       BATMAN_OGM_HLEN);
 
 		kfree(hard_iface->packet_buff);
 		hard_iface->packet_buff = new_buff;
@@ -101,13 +101,13 @@ static int prepare_packet_buffer(struct bat_priv *bat_priv,
 {
 	int new_len;
 
-	new_len = BATMAN_OGM_LEN +
+	new_len = BATMAN_OGM_HLEN +
 		  tt_len((uint8_t)atomic_read(&bat_priv->tt_local_changes));
 
 	/* if we have too many changes for one packet don't send any
 	 * and wait for the tt table request which will be fragmented */
 	if (new_len > hard_iface->soft_iface->mtu)
-		new_len = BATMAN_OGM_LEN;
+		new_len = BATMAN_OGM_HLEN;
 
 	realloc_packet_buffer(hard_iface, new_len);
 
@@ -117,14 +117,14 @@ static int prepare_packet_buffer(struct bat_priv *bat_priv,
 	atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX);
 
 	return tt_changes_fill_buffer(bat_priv,
-				      hard_iface->packet_buff + BATMAN_OGM_LEN,
-				      hard_iface->packet_len - BATMAN_OGM_LEN);
+				      hard_iface->packet_buff + BATMAN_OGM_HLEN,
+				      hard_iface->packet_len - BATMAN_OGM_HLEN);
 }
 
 static int reset_packet_buffer(struct bat_priv *bat_priv,
 				struct hard_iface *hard_iface)
 {
-	realloc_packet_buffer(hard_iface, BATMAN_OGM_LEN);
+	realloc_packet_buffer(hard_iface, BATMAN_OGM_HLEN);
 	return 0;
 }
 
-- 
1.7.9.4

^ permalink raw reply related


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