netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: Let inet_diag and friends autoload
@ 2007-10-16 15:28 Jean Delvare
  2007-10-18  2:51 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Jean Delvare @ 2007-10-16 15:28 UTC (permalink / raw)
  To: netdev; +Cc: Alexey Kuznetsov

By adding module aliases to inet_diag, tcp_diag and dccp_diag, we let
them load automatically as needed. This makes tools like "ss" run
faster.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
---
The alias naming scheme for tcp_diag and dccp_diag follows what was
done for dccp_ipv4 and dccp_ipv6.

 include/linux/net.h  |    4 ++++
 net/dccp/diag.c      |    1 +
 net/ipv4/inet_diag.c |    7 +++++++
 net/ipv4/tcp_diag.c  |    1 +
 4 files changed, 13 insertions(+)

--- linux-2.6.23-rc0.orig/net/ipv4/inet_diag.c	2007-10-16 13:32:13.000000000 +0200
+++ linux-2.6.23-rc0/net/ipv4/inet_diag.c	2007-10-16 13:46:34.000000000 +0200
@@ -815,6 +815,12 @@ static int inet_diag_rcv_msg(struct sk_b
 	    nlmsg_len(nlh) < hdrlen)
 		return -EINVAL;
 
+#ifdef CONFIG_KMOD
+	if (inet_diag_table[nlh->nlmsg_type] == NULL)
+		request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
+			       NETLINK_INET_DIAG, nlh->nlmsg_type);
+#endif
+
 	if (inet_diag_table[nlh->nlmsg_type] == NULL)
 		return -ENOENT;
 
@@ -914,3 +920,4 @@ static void __exit inet_diag_exit(void)
 module_init(inet_diag_init);
 module_exit(inet_diag_exit);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_INET_DIAG);
--- linux-2.6.23-rc0.orig/include/linux/net.h	2007-10-15 21:39:08.000000000 +0200
+++ linux-2.6.23-rc0/include/linux/net.h	2007-10-16 14:31:02.000000000 +0200
@@ -313,6 +313,10 @@ static const struct proto_ops name##_ops
 #define MODULE_ALIAS_NET_PF_PROTO(pf, proto) \
 	MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto))
 
+#define MODULE_ALIAS_NET_PF_PROTO_TYPE(pf, proto, type) \
+	MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
+		     "-type-" __stringify(type))
+
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
 extern ctl_table net_table[];
--- linux-2.6.23-rc0.orig/net/ipv4/tcp_diag.c	2007-10-16 13:32:13.000000000 +0200
+++ linux-2.6.23-rc0/net/ipv4/tcp_diag.c	2007-10-16 13:51:09.000000000 +0200
@@ -56,3 +56,4 @@ static void __exit tcp_diag_exit(void)
 module_init(tcp_diag_init);
 module_exit(tcp_diag_exit);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_INET_DIAG, TCPDIAG_GETSOCK);
--- linux-2.6.23-rc0.orig/net/dccp/diag.c	2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6.23-rc0/net/dccp/diag.c	2007-10-16 14:27:10.000000000 +0200
@@ -68,3 +68,4 @@ module_exit(dccp_diag_fini);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
 MODULE_DESCRIPTION("DCCP inet_diag handler");
+MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_INET_DIAG, DCCPDIAG_GETSOCK);

-- 
Jean Delvare
Suse L3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: Let inet_diag and friends autoload
  2007-10-16 15:28 [PATCH 1/2] net: Let inet_diag and friends autoload Jean Delvare
@ 2007-10-18  2:51 ` David Miller
  2007-10-19  8:21   ` Herbert Xu
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2007-10-18  2:51 UTC (permalink / raw)
  To: jdelvare; +Cc: netdev, kuznet

From: Jean Delvare <jdelvare@suse.de>
Date: Tue, 16 Oct 2007 17:28:23 +0200

> By adding module aliases to inet_diag, tcp_diag and dccp_diag, we let
> them load automatically as needed. This makes tools like "ss" run
> faster.
> 
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
> ---
> The alias naming scheme for tcp_diag and dccp_diag follows what was
> done for dccp_ipv4 and dccp_ipv6.

I'm concerned it might be dangerous to load the module in
this context, the RTNL semaphore is held and the module we
are requesting could easily try to take it and deadlock.

Currently we are lucky and this won't happen, but if the sub-proto
registration is every changed to do so, it will be a nightmare for
whoever is so unlucky to try and debug it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: Let inet_diag and friends autoload
  2007-10-18  2:51 ` David Miller
@ 2007-10-19  8:21   ` Herbert Xu
  2007-10-19  8:34     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2007-10-19  8:21 UTC (permalink / raw)
  To: David Miller; +Cc: jdelvare, netdev, kuznet

David Miller <davem@davemloft.net> wrote:
>
> I'm concerned it might be dangerous to load the module in
> this context, the RTNL semaphore is held and the module we
> are requesting could easily try to take it and deadlock.

We shouldn't be holding the RTNL here.  AFAICS we only hold
inet_diag_mutex which is used in just one spot.

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] 4+ messages in thread

* Re: [PATCH 1/2] net: Let inet_diag and friends autoload
  2007-10-19  8:21   ` Herbert Xu
@ 2007-10-19  8:34     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2007-10-19  8:34 UTC (permalink / raw)
  To: herbert; +Cc: jdelvare, netdev, kuznet

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Fri, 19 Oct 2007 16:21:23 +0800

> David Miller <davem@davemloft.net> wrote:
> >
> > I'm concerned it might be dangerous to load the module in
> > this context, the RTNL semaphore is held and the module we
> > are requesting could easily try to take it and deadlock.
> 
> We shouldn't be holding the RTNL here.  AFAICS we only hold
> inet_diag_mutex which is used in just one spot.

You're right.

I'll reconsider these patches.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-10-19  8:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-16 15:28 [PATCH 1/2] net: Let inet_diag and friends autoload Jean Delvare
2007-10-18  2:51 ` David Miller
2007-10-19  8:21   ` Herbert Xu
2007-10-19  8:34     ` David 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).