diff mbox

inet: Initialize per-netns inetpeer roots in net/ipv{4,6}/route.c

Message ID 20120610101640.GA14476@localhost
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Wu Fengguang June 10, 2012, 10:16 a.m. UTC
On Sat, Jun 09, 2012 at 10:18:01PM -0400, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Sat, 09 Jun 2012 19:09:29 -0700 (PDT)
> 
> > From: Fengguang Wu <wfg@linux.intel.com>
> > Date: Sun, 10 Jun 2012 10:08:01 +0800
> > 
> >> And in another config, an old error still triggers:
> >> 
> >> net/ipv4/inetpeer.c: In function ‘family_to_base’:
> >> net/ipv4/inetpeer.c:397:50: error: ‘struct net’ has no member named ‘ipv6’
> >> net/ipv4/inetpeer.c:398:1: warning: control reaches end of non-void function [-Wreturn-type]
> >> 
> >> I'm building this patch on top of net-next master.
> > 
> > What a fucking mess Gao created, I'll fix this.
> > 
> > Thanks for the report.
> 
> I just pushed the following to net-next:
> 
> --------------------
> inet: Pass inetpeer root into inet_getpeer*() interfaces.
> 
> Otherwise we reference potentially non-existing members when
> ipv6 is disabled.
> 
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
>  include/net/inetpeer.h |   10 +++++-----
>  net/ipv4/inetpeer.c    |    9 +--------
>  net/ipv4/ip_fragment.c |    2 +-
>  net/ipv4/route.c       |    6 +++---
>  net/ipv6/route.c       |    2 +-
>  5 files changed, 11 insertions(+), 18 deletions(-)

It triggers some other errors:

net/ipv4/inetpeer.c: In function ‘inetpeer_invalidate_tree’:
net/ipv4/inetpeer.c:585:9: error: implicit declaration of function ‘family_to_base’ [-Werror=implicit-function-declaration]
net/ipv4/inetpeer.c:585:32: warning: initialization makes pointer from integer without a cast [enabled by default]
net/ipv6/tcp_ipv6.c:1758:2: warning: passing argument 1 of ‘inet_getpeer_v6’ from incompatible pointer type [enabled by default]
include/net/inetpeer.h:101:33: note: expected ‘struct inet_peer_base *’ but argument is of type ‘struct net *’
net/ipv4/tcp_ipv4.c:1843:2: warning: passing argument 1 of ‘inet_getpeer_v4’ from incompatible pointer type [enabled by default]
include/net/inetpeer.h:90:33: note: expected ‘struct inet_peer_base *’ but argument is of type ‘struct net *’

which can be fixed by the following diff.

Thanks,
Fengguang
---
 net/ipv4/inetpeer.c |    6 ++++++
 net/ipv4/tcp_ipv4.c |    2 +-
 net/ipv6/tcp_ipv6.c |    2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

Comments

Gao feng June 11, 2012, 12:27 a.m. UTC | #1
Hi fengguang:

于 2012年06月10日 18:16, Fengguang Wu 写道:
> On Sat, Jun 09, 2012 at 10:18:01PM -0400, David Miller wrote:
>> From: David Miller <davem@davemloft.net>
>> Date: Sat, 09 Jun 2012 19:09:29 -0700 (PDT)
>>
>>> From: Fengguang Wu <wfg@linux.intel.com>
>>> Date: Sun, 10 Jun 2012 10:08:01 +0800
>>>
>>>> And in another config, an old error still triggers:
>>>>
>>>> net/ipv4/inetpeer.c: In function ‘family_to_base’:
>>>> net/ipv4/inetpeer.c:397:50: error: ‘struct net’ has no member named ‘ipv6’
>>>> net/ipv4/inetpeer.c:398:1: warning: control reaches end of non-void function [-Wreturn-type]
>>>>
>>>> I'm building this patch on top of net-next master.
>>>
>>> What a fucking mess Gao created, I'll fix this.
>>>
>>> Thanks for the report.
>>
>> I just pushed the following to net-next:
>>
>> --------------------
>> inet: Pass inetpeer root into inet_getpeer*() interfaces.
>>
>> Otherwise we reference potentially non-existing members when
>> ipv6 is disabled.
>>
>> Signed-off-by: David S. Miller <davem@davemloft.net>
>> ---
>>  include/net/inetpeer.h |   10 +++++-----
>>  net/ipv4/inetpeer.c    |    9 +--------
>>  net/ipv4/ip_fragment.c |    2 +-
>>  net/ipv4/route.c       |    6 +++---
>>  net/ipv6/route.c       |    2 +-
>>  5 files changed, 11 insertions(+), 18 deletions(-)
> 
> It triggers some other errors:
> 
> net/ipv4/inetpeer.c: In function ‘inetpeer_invalidate_tree’:
> net/ipv4/inetpeer.c:585:9: error: implicit declaration of function ‘family_to_base’ [-Werror=implicit-function-declaration]
> net/ipv4/inetpeer.c:585:32: warning: initialization makes pointer from integer without a cast [enabled by default]
> net/ipv6/tcp_ipv6.c:1758:2: warning: passing argument 1 of ‘inet_getpeer_v6’ from incompatible pointer type [enabled by default]
> include/net/inetpeer.h:101:33: note: expected ‘struct inet_peer_base *’ but argument is of type ‘struct net *’
> net/ipv4/tcp_ipv4.c:1843:2: warning: passing argument 1 of ‘inet_getpeer_v4’ from incompatible pointer type [enabled by default]
> include/net/inetpeer.h:90:33: note: expected ‘struct inet_peer_base *’ but argument is of type ‘struct net *’
> 
> which can be fixed by the following diff.

seams you did not pull the last codes
David has delete the tcp_v(4,6)_tw_get_peer
in commit 2397849baa7c44c242e5d5142d5d16d1e7ed53d0.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wu Fengguang June 11, 2012, 1:44 a.m. UTC | #2
> seams you did not pull the last codes
> David has delete the tcp_v(4,6)_tw_get_peer
> in commit 2397849baa7c44c242e5d5142d5d16d1e7ed53d0.

Ah OK, I retested net-next head and it compiles fine, except for these
errors I reported in another thread:

ERROR: "stmmac_pltfr_driver" [drivers/net/ethernet/stmicro/stmmac/stmmac.ko] undefined!
ERROR: "stmmac_pci_driver" [drivers/net/ethernet/stmicro/stmmac/stmmac.ko] undefined!

It seems the bug fixing patch

        stmmac: fix driver built w/ w/o both pci and platf modules

was only applied to net/master, but not in net-next/master yet.

Thanks,
Fengguang
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller June 11, 2012, 3:03 a.m. UTC | #3
From: Fengguang Wu <wfg@linux.intel.com>

Date: Sun, 10 Jun 2012 18:16:40 +0800

> net/ipv4/inetpeer.c:585:9: error: implicit declaration of function ‘family_to_base’ [-Werror=implicit-function-declaration]


There are no references to family_to_base in the net-next tree.

If you only applied the patches you were explicitly CC:'d on,
that's the problem.  There were other changes made in the net-next
tree in-between that remove the other references to that function.
diff mbox

Patch

diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 98cf1f8..7ad6b76 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -391,6 +391,12 @@  static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base,
 	call_rcu(&p->rcu, inetpeer_free_rcu);
 }
 
+static struct inet_peer_base *family_to_base(struct net *net,
+					     int family)
+{
+	return family == AF_INET ? net->ipv4.peers : net->ipv6.peers;
+}
+
 /* perform garbage collect on all items stacked during a lookup */
 static int inet_peer_gc(struct inet_peer_base *base,
 			struct inet_peer __rcu **stack[PEER_MAXDEPTH],
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 77f049d..cf7fe92 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1840,7 +1840,7 @@  void *tcp_v4_tw_get_peer(struct sock *sk)
 	const struct inet_timewait_sock *tw = inet_twsk(sk);
 	struct net *net = sock_net(sk);
 
-	return inet_getpeer_v4(net, tw->tw_daddr, 1);
+	return inet_getpeer_v4(net->ipv4.peers, tw->tw_daddr, 1);
 }
 EXPORT_SYMBOL(tcp_v4_tw_get_peer);
 
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index b5ecf37..927c029 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1755,7 +1755,7 @@  static void *tcp_v6_tw_get_peer(struct sock *sk)
 	if (tw->tw_family == AF_INET)
 		return tcp_v4_tw_get_peer(sk);
 
-	return inet_getpeer_v6(net, &tw6->tw_v6_daddr, 1);
+	return inet_getpeer_v6(net->ipv6.peers, &tw6->tw_v6_daddr, 1);
 }
 
 static struct timewait_sock_ops tcp6_timewait_sock_ops = {