* [TCP] Modular IPv6 support in tcpdiag
@ 2004-11-03 9:44 Herbert Xu
2004-11-03 11:26 ` YOSHIFUJI Hideaki / 吉藤英明
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Herbert Xu @ 2004-11-03 9:44 UTC (permalink / raw)
To: David S. Miller, netdev
[-- Attachment #1: Type: text/plain, Size: 545 bytes --]
Hi Dave:
This patch allows tcpdiag to support ipv6 work as a module when itself
is also a module.
I was planning for a more extensible method but now I think the effort
would be better directed at a new generic socket netlink interface than
the TCP-specific tcpdiag.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[-- Attachment #2: p --]
[-- Type: text/plain, Size: 3722 bytes --]
===== net/ipv4/Kconfig 1.22 vs edited =====
--- 1.22/net/ipv4/Kconfig 2004-11-02 11:48:28 +11:00
+++ edited/net/ipv4/Kconfig 2004-11-03 20:39:16 +11:00
@@ -351,12 +351,16 @@
config IP_TCPDIAG
tristate "IP: TCP socket monitoring interface"
+ depends on INET
default y
---help---
Support for TCP socket monitoring interface used by native Linux
tools such as ss.
If unsure, say Y.
+
+config IP_TCPDIAG_IPV6
+ def_bool (IP_TCPDIAG=y && IPV6=y) || (IP_TCPDIAG=m && IPV6)
source "net/ipv4/ipvs/Kconfig"
===== net/ipv4/tcp_diag.c 1.26 vs edited =====
--- 1.26/net/ipv4/tcp_diag.c 2004-11-02 11:48:28 +11:00
+++ edited/net/ipv4/tcp_diag.c 2004-11-03 20:37:03 +11:00
@@ -103,14 +103,12 @@
r->tcpdiag_wqueue = 0;
r->tcpdiag_uid = 0;
r->tcpdiag_inode = 0;
-#ifdef CONFIG_IPV6
if (r->tcpdiag_family == AF_INET6) {
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
&tw->tw_v6_rcv_saddr);
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
&tw->tw_v6_daddr);
}
-#endif
nlh->nlmsg_len = skb->tail - b;
return skb->len;
}
@@ -120,7 +118,6 @@
r->id.tcpdiag_src[0] = inet->rcv_saddr;
r->id.tcpdiag_dst[0] = inet->daddr;
-#ifdef CONFIG_IPV6
if (r->tcpdiag_family == AF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);
@@ -129,7 +126,6 @@
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
&np->daddr);
}
-#endif
#define EXPIRES_IN_MS(tmo) ((tmo-jiffies)*1000+HZ-1)/HZ
@@ -188,11 +184,19 @@
return -1;
}
-extern struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport, int dif);
-#ifdef CONFIG_IPV6
+extern struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport,
+ int dif);
+#ifdef CONFIG_IP_TCPDIAG_IPV6
extern struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
struct in6_addr *daddr, u16 dport,
int dif);
+#else
+static inline struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
+ struct in6_addr *daddr, u16 dport,
+ int dif)
+{
+ return NULL;
+}
#endif
static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh)
@@ -207,13 +211,11 @@
req->id.tcpdiag_src[0], req->id.tcpdiag_sport,
req->id.tcpdiag_if);
}
-#ifdef CONFIG_IPV6
else if (req->tcpdiag_family == AF_INET6) {
sk = tcp_v6_lookup((struct in6_addr*)req->id.tcpdiag_dst, req->id.tcpdiag_dport,
(struct in6_addr*)req->id.tcpdiag_src, req->id.tcpdiag_sport,
req->id.tcpdiag_if);
}
-#endif
else {
return -EINVAL;
}
@@ -422,14 +424,12 @@
struct inet_opt *inet = inet_sk(sk);
entry.family = sk->sk_family;
-#ifdef CONFIG_IPV6
if (entry.family == AF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);
entry.saddr = np->rcv_saddr.s6_addr32;
entry.daddr = np->daddr.s6_addr32;
} else
-#endif
{
entry.saddr = &inet->rcv_saddr;
entry.daddr = &inet->daddr;
@@ -482,14 +482,12 @@
r->tcpdiag_wqueue = 0;
r->tcpdiag_uid = sock_i_uid(sk);
r->tcpdiag_inode = 0;
-#ifdef CONFIG_IPV6
if (r->tcpdiag_family == AF_INET6) {
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
&req->af.v6_req.loc_addr);
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
&req->af.v6_req.rmt_addr);
}
-#endif
nlh->nlmsg_len = skb->tail - b;
return skb->len;
@@ -545,16 +543,12 @@
if (bc) {
entry.saddr =
-#ifdef CONFIG_IPV6
(entry.family == AF_INET6) ?
req->af.v6_req.loc_addr.s6_addr32 :
-#endif
&req->af.v4_req.loc_addr;
entry.daddr =
-#ifdef CONFIG_IPV6
(entry.family == AF_INET6) ?
req->af.v6_req.rmt_addr.s6_addr32 :
-#endif
&req->af.v4_req.rmt_addr;
entry.dport = ntohs(req->rmt_port);
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TCP] Modular IPv6 support in tcpdiag
2004-11-03 9:44 [TCP] Modular IPv6 support in tcpdiag Herbert Xu
@ 2004-11-03 11:26 ` YOSHIFUJI Hideaki / 吉藤英明
2004-11-03 17:16 ` Stephen Hemminger
2004-11-03 20:20 ` David S. Miller
2 siblings, 0 replies; 9+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2004-11-03 11:26 UTC (permalink / raw)
To: herbert, davem; +Cc: netdev
In article <20041103094451.GA20220@gondor.apana.org.au> (at Wed, 3 Nov 2004 20:44:51 +1100), Herbert Xu <herbert@gondor.apana.org.au> says:
> This patch allows tcpdiag to support ipv6 work as a module when itself
> is also a module.
I agree.
--yoshfuji
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TCP] Modular IPv6 support in tcpdiag
2004-11-03 9:44 [TCP] Modular IPv6 support in tcpdiag Herbert Xu
2004-11-03 11:26 ` YOSHIFUJI Hideaki / 吉藤英明
@ 2004-11-03 17:16 ` Stephen Hemminger
2004-11-03 20:32 ` Herbert Xu
2004-11-03 20:20 ` David S. Miller
2 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2004-11-03 17:16 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, netdev
On Wed, 3 Nov 2004 20:44:51 +1100
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> Hi Dave:
>
> This patch allows tcpdiag to support ipv6 work as a module when itself
> is also a module.
>
> I was planning for a more extensible method but now I think the effort
> would be better directed at a new generic socket netlink interface than
> the TCP-specific tcpdiag.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
I wanted to ask why all the work to make tcp_diag a module? If it is
a module there are more possibilties of user problems. Any utilities
that expect it would then have to deal with it not being loaded as well
as the possiblity of building a kernel without it.
Perhaps there ought to be a CONFIG_INET_EMBEDDED that is for those
configurations that want more restricted and smaller networking (ie no
cache's, smaller hash tables, less sysctl options, ...)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TCP] Modular IPv6 support in tcpdiag
2004-11-03 9:44 [TCP] Modular IPv6 support in tcpdiag Herbert Xu
2004-11-03 11:26 ` YOSHIFUJI Hideaki / 吉藤英明
2004-11-03 17:16 ` Stephen Hemminger
@ 2004-11-03 20:20 ` David S. Miller
2004-11-03 20:34 ` Herbert Xu
2 siblings, 1 reply; 9+ messages in thread
From: David S. Miller @ 2004-11-03 20:20 UTC (permalink / raw)
To: Herbert Xu; +Cc: netdev
On Wed, 3 Nov 2004 20:44:51 +1100
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> This patch allows tcpdiag to support ipv6 work as a module when itself
> is also a module.
Any particular reason you didn't use the same config ifdef
tests we use for structure layouts? Ie.
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
I don't see the need for the special new config option.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TCP] Modular IPv6 support in tcpdiag
2004-11-03 20:34 ` Herbert Xu
@ 2004-11-03 20:29 ` David S. Miller
2004-11-03 20:43 ` Herbert Xu
0 siblings, 1 reply; 9+ messages in thread
From: David S. Miller @ 2004-11-03 20:29 UTC (permalink / raw)
To: Herbert Xu; +Cc: netdev
On Thu, 4 Nov 2004 07:34:14 +1100
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Wed, Nov 03, 2004 at 12:20:50PM -0800, David S. Miller wrote:
> >
> > Any particular reason you didn't use the same config ifdef
> > tests we use for structure layouts? Ie.
> >
> > #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
>
> If I used that then it'll break when TCPDIAG is built-in and
> IPv6 is built as a module.
I see, you need the ipv6 tcp socket lookup symbols... hmmm.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TCP] Modular IPv6 support in tcpdiag
2004-11-03 17:16 ` Stephen Hemminger
@ 2004-11-03 20:32 ` Herbert Xu
0 siblings, 0 replies; 9+ messages in thread
From: Herbert Xu @ 2004-11-03 20:32 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David S. Miller, netdev
On Wed, Nov 03, 2004 at 09:16:09AM -0800, Stephen Hemminger wrote:
>
> I wanted to ask why all the work to make tcp_diag a module? If it is
> a module there are more possibilties of user problems. Any utilities
> that expect it would then have to deal with it not being loaded as well
> as the possiblity of building a kernel without it.
The reason is that prior to this if IPv6 was built as a module then
you couldn't have tcp_diag support for IPv6 sockets at all.
You're absolutely right about the potential problems with modules.
However, I did set the default to Y.
We should also have netlink module aliases so that these modules
can be loaded automatically by af_netlink.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TCP] Modular IPv6 support in tcpdiag
2004-11-03 20:20 ` David S. Miller
@ 2004-11-03 20:34 ` Herbert Xu
2004-11-03 20:29 ` David S. Miller
0 siblings, 1 reply; 9+ messages in thread
From: Herbert Xu @ 2004-11-03 20:34 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
On Wed, Nov 03, 2004 at 12:20:50PM -0800, David S. Miller wrote:
>
> Any particular reason you didn't use the same config ifdef
> tests we use for structure layouts? Ie.
>
> #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
If I used that then it'll break when TCPDIAG is built-in and
IPv6 is built as a module.
> I don't see the need for the special new config option.
The user won't see it at all since it's a def_bool.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TCP] Modular IPv6 support in tcpdiag
2004-11-03 20:43 ` Herbert Xu
@ 2004-11-03 20:41 ` David S. Miller
0 siblings, 0 replies; 9+ messages in thread
From: David S. Miller @ 2004-11-03 20:41 UTC (permalink / raw)
To: Herbert Xu; +Cc: netdev
On Thu, 4 Nov 2004 07:43:21 +1100
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Wed, Nov 03, 2004 at 12:29:41PM -0800, David S. Miller wrote:
> >
> > > If I used that then it'll break when TCPDIAG is built-in and
> > > IPv6 is built as a module.
> >
> > I see, you need the ipv6 tcp socket lookup symbols... hmmm.
>
> Well it really should be turned into a plugin system. However,
> since any effort to do that might as well be spent doing a
> generic socket info interface, I thought that we should just
> patch up tcp_diag and mark it as obsolete once we have a new
> interface.
I've put your patch in for now, but I don't know what I think
about deprecating an interface that took so much effort to get
people to use over the /proc/net/tcp{,6} stuff.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TCP] Modular IPv6 support in tcpdiag
2004-11-03 20:29 ` David S. Miller
@ 2004-11-03 20:43 ` Herbert Xu
2004-11-03 20:41 ` David S. Miller
0 siblings, 1 reply; 9+ messages in thread
From: Herbert Xu @ 2004-11-03 20:43 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
On Wed, Nov 03, 2004 at 12:29:41PM -0800, David S. Miller wrote:
>
> > If I used that then it'll break when TCPDIAG is built-in and
> > IPv6 is built as a module.
>
> I see, you need the ipv6 tcp socket lookup symbols... hmmm.
Well it really should be turned into a plugin system. However,
since any effort to do that might as well be spent doing a
generic socket info interface, I thought that we should just
patch up tcp_diag and mark it as obsolete once we have a new
interface.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-11-03 20:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-03 9:44 [TCP] Modular IPv6 support in tcpdiag Herbert Xu
2004-11-03 11:26 ` YOSHIFUJI Hideaki / 吉藤英明
2004-11-03 17:16 ` Stephen Hemminger
2004-11-03 20:32 ` Herbert Xu
2004-11-03 20:20 ` David S. Miller
2004-11-03 20:34 ` Herbert Xu
2004-11-03 20:29 ` David S. Miller
2004-11-03 20:43 ` Herbert Xu
2004-11-03 20:41 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).