* [PATCH] ipv6: Do cleanup for ip_mr_init @ 2008-06-24 3:42 Wang Chen 2008-07-02 8:49 ` Wang Chen 2008-07-02 9:18 ` YOSHIFUJI Hideaki / 吉藤英明 0 siblings, 2 replies; 8+ messages in thread From: Wang Chen @ 2008-06-24 3:42 UTC (permalink / raw) To: David S. Miller; +Cc: NETDEV, YOSHIFUJI Hideaki If do not do it, we will get following issues: 1. Leaving junks after inet6_init failing halfway. 2. Leaving proc and notifier junks after ipv6 modules unloading. Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> --- include/linux/mroute6.h | 1 + net/ipv6/af_inet6.c | 5 +++++ net/ipv6/ip6mr.c | 10 ++++++++++ 3 files changed, 16 insertions(+), 0 deletions(-) diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h index e798959..05ffaac 100644 --- a/include/linux/mroute6.h +++ b/include/linux/mroute6.h @@ -136,6 +136,7 @@ extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user * extern int ip6_mr_input(struct sk_buff *skb); extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); extern void ip6_mr_init(void); +extern void ip6_mr_cleanup(void); struct mif_device { diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index e84b3fd..15d4138 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -1061,6 +1061,9 @@ netfilter_fail: igmp_fail: ndisc_cleanup(); ndisc_fail: +#ifdef CONFIG_IPV6_MROUTE + ip6_mr_cleanup(); +#endif icmpv6_cleanup(); icmp_fail: unregister_pernet_subsys(&inet6_net_ops); @@ -1115,7 +1118,9 @@ static void __exit inet6_exit(void) ipv6_netfilter_fini(); igmp6_cleanup(); ndisc_cleanup(); +#ifdef CONFIG_IPV6_MROUTE icmpv6_cleanup(); +#endif rawv6_exit(); unregister_pernet_subsys(&inet6_net_ops); diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 1479618..245c350 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -973,6 +973,16 @@ void __init ip6_mr_init(void) #endif } +void ip6_mr_cleanup(void) +{ +#ifdef CONFIG_PROC_FS + proc_net_remove(&init_net, "ip6_mr_cache"); + proc_net_remove(&init_net, "ip6_mr_vif"); +#endif + unregister_netdevice_notifier(&ip6_mr_notifier); + del_timer(&ipmr_expire_timer); + kmem_cache_destroy(mrt_cachep); +} static int ip6mr_mfc_add(struct mf6cctl *mfc, int mrtsock) { -- 1.5.3.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] ipv6: Do cleanup for ip_mr_init 2008-06-24 3:42 [PATCH] ipv6: Do cleanup for ip_mr_init Wang Chen @ 2008-07-02 8:49 ` Wang Chen 2008-07-02 9:18 ` YOSHIFUJI Hideaki / 吉藤英明 1 sibling, 0 replies; 8+ messages in thread From: Wang Chen @ 2008-07-02 8:49 UTC (permalink / raw) To: David S. Miller, YOSHIFUJI Hideaki; +Cc: NETDEV Wang Chen said the following on 2008-6-24 11:42: > If do not do it, we will get following issues: > 1. Leaving junks after inet6_init failing halfway. > 2. Leaving proc and notifier junks after ipv6 modules unloading. > > Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> > --- > include/linux/mroute6.h | 1 + > net/ipv6/af_inet6.c | 5 +++++ > net/ipv6/ip6mr.c | 10 ++++++++++ > 3 files changed, 16 insertions(+), 0 deletions(-) Yoshifuji-san, would please take a look at this patch. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ipv6: Do cleanup for ip_mr_init 2008-06-24 3:42 [PATCH] ipv6: Do cleanup for ip_mr_init Wang Chen 2008-07-02 8:49 ` Wang Chen @ 2008-07-02 9:18 ` YOSHIFUJI Hideaki / 吉藤英明 2008-07-02 9:38 ` Wang Chen ` (2 more replies) 1 sibling, 3 replies; 8+ messages in thread From: YOSHIFUJI Hideaki / 吉藤英明 @ 2008-07-02 9:18 UTC (permalink / raw) To: wangchen; +Cc: davem, netdev, yoshfuji In article <48606D1B.3040507@cn.fujitsu.com> (at Tue, 24 Jun 2008 11:42:19 +0800), Wang Chen <wangchen@cn.fujitsu.com> says: > If do not do it, we will get following issues: > 1. Leaving junks after inet6_init failing halfway. > 2. Leaving proc and notifier junks after ipv6 modules unloading. > > Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> > diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h > index e798959..05ffaac 100644 > --- a/include/linux/mroute6.h > +++ b/include/linux/mroute6.h > diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c > index e84b3fd..15d4138 100644 > --- a/net/ipv6/af_inet6.c > +++ b/net/ipv6/af_inet6.c > @@ -1115,7 +1118,9 @@ static void __exit inet6_exit(void) > ipv6_netfilter_fini(); > igmp6_cleanup(); > ndisc_cleanup(); > +#ifdef CONFIG_IPV6_MROUTE > icmpv6_cleanup(); > +#endif > rawv6_exit(); > > unregister_pernet_subsys(&inet6_net_ops); Well we really need this #ifdef ... #endif? And well, would you please make ip6_mr_init() return error and handle it correctly? We need to fix ipv4-side as well. --yoshfuji ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ipv6: Do cleanup for ip_mr_init 2008-07-02 9:18 ` YOSHIFUJI Hideaki / 吉藤英明 @ 2008-07-02 9:38 ` Wang Chen 2008-07-03 4:13 ` v2 [PATCH 1/2] ipv6: Do cleanup for ip6_mr_init Wang Chen [not found] ` <486C50AE.7000207@cn.fujitsu.com> 2 siblings, 0 replies; 8+ messages in thread From: Wang Chen @ 2008-07-02 9:38 UTC (permalink / raw) To: YOSHIFUJI Hideaki / 吉藤英明; +Cc: davem, netdev YOSHIFUJI Hideaki / 吉藤英明 said the following on 2008-7-2 17:18: > In article <48606D1B.3040507@cn.fujitsu.com> (at Tue, 24 Jun 2008 11:42:19 +0800), Wang Chen <wangchen@cn.fujitsu.com> says: > >> If do not do it, we will get following issues: >> 1. Leaving junks after inet6_init failing halfway. >> 2. Leaving proc and notifier junks after ipv6 modules unloading. >> >> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> > >> diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h >> index e798959..05ffaac 100644 >> --- a/include/linux/mroute6.h >> +++ b/include/linux/mroute6.h >> diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c >> index e84b3fd..15d4138 100644 >> --- a/net/ipv6/af_inet6.c >> +++ b/net/ipv6/af_inet6.c >> @@ -1115,7 +1118,9 @@ static void __exit inet6_exit(void) >> ipv6_netfilter_fini(); >> igmp6_cleanup(); >> ndisc_cleanup(); >> +#ifdef CONFIG_IPV6_MROUTE >> icmpv6_cleanup(); >> +#endif >> rawv6_exit(); >> >> unregister_pernet_subsys(&inet6_net_ops); > > Well we really need this #ifdef ... #endif? > My fault. I meant: +#ifdef CONFIG_IPV6_MROUTE + ip6_mr_cleanup(); +#endif icmpv6_cleanup(); I will fix. > And well, would you please make ip6_mr_init() return > error and handle it correctly? > Sure, I will do it. > We need to fix ipv4-side as well. > Of course, it can be done by me. Thank you for the comments. ^ permalink raw reply [flat|nested] 8+ messages in thread
* v2 [PATCH 1/2] ipv6: Do cleanup for ip6_mr_init 2008-07-02 9:18 ` YOSHIFUJI Hideaki / 吉藤英明 2008-07-02 9:38 ` Wang Chen @ 2008-07-03 4:13 ` Wang Chen 2008-07-03 7:09 ` YOSHIFUJI Hideaki / 吉藤英明 [not found] ` <486C50AE.7000207@cn.fujitsu.com> 2 siblings, 1 reply; 8+ messages in thread From: Wang Chen @ 2008-07-03 4:13 UTC (permalink / raw) To: YOSHIFUJI Hideaki / 吉藤英明, davem; +Cc: netdev If do not do it, we will get following issues: 1. Leaving junks after inet6_init failing halfway. 2. Leaving proc and notifier junks after ipv6 modules unloading. Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> --- diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h index e798959..4c4d6f5 100644 --- a/include/linux/mroute6.h +++ b/include/linux/mroute6.h @@ -135,7 +135,8 @@ extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, int); extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); extern int ip6_mr_input(struct sk_buff *skb); extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); -extern void ip6_mr_init(void); +extern int ip6_mr_init(void); +extern void ip6_mr_cleanup(void); struct mif_device { diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index e84b3fd..5cb7bb4 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -957,7 +957,9 @@ static int __init inet6_init(void) if (err) goto icmp_fail; #ifdef CONFIG_IPV6_MROUTE - ip6_mr_init(); + err = ip6_mr_init(); + if (err) + goto ipmr_fail; #endif err = ndisc_init(); if (err) @@ -1061,6 +1063,10 @@ netfilter_fail: igmp_fail: ndisc_cleanup(); ndisc_fail: +#ifdef CONFIG_IPV6_MROUTE + ip6_mr_cleanup(); +ipmr_fail: +#endif icmpv6_cleanup(); icmp_fail: unregister_pernet_subsys(&inet6_net_ops); @@ -1115,6 +1121,9 @@ static void __exit inet6_exit(void) ipv6_netfilter_fini(); igmp6_cleanup(); ndisc_cleanup(); +#ifdef CONFIG_IPV6_MROUTE + ip6_mr_cleanup(); +#endif icmpv6_cleanup(); rawv6_exit(); diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 1479618..3b785db 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -956,23 +956,51 @@ static struct notifier_block ip6_mr_notifier = { * Setup for IP multicast routing */ -void __init ip6_mr_init(void) +int __init ip6_mr_init(void) { + int err; + mrt_cachep = kmem_cache_create("ip6_mrt_cache", sizeof(struct mfc6_cache), 0, SLAB_HWCACHE_ALIGN, NULL); if (!mrt_cachep) - panic("cannot allocate ip6_mrt_cache"); + return -ENOMEM; setup_timer(&ipmr_expire_timer, ipmr_expire_process, 0); - register_netdevice_notifier(&ip6_mr_notifier); + err = register_netdevice_notifier(&ip6_mr_notifier); + if (err) + goto reg_notif_fail; +#ifdef CONFIG_PROC_FS + err = -ENOMEM; + if (!proc_net_fops_create(&init_net, "ip6_mr_vif", 0, &ip6mr_vif_fops)) + goto proc_vif_fail; + if (!proc_net_fops_create(&init_net, "ip6_mr_cache", + 0, &ip6mr_mfc_fops)) + goto proc_cache_fail; +#endif + return 0; +reg_notif_fail: + kmem_cache_destroy(mrt_cachep); #ifdef CONFIG_PROC_FS - proc_net_fops_create(&init_net, "ip6_mr_vif", 0, &ip6mr_vif_fops); - proc_net_fops_create(&init_net, "ip6_mr_cache", 0, &ip6mr_mfc_fops); +proc_vif_fail: + unregister_netdevice_notifier(&ip6_mr_notifier); +proc_cache_fail: + proc_net_remove(&init_net, "ip6_mr_vif"); #endif + return err; } +void ip6_mr_cleanup(void) +{ +#ifdef CONFIG_PROC_FS + proc_net_remove(&init_net, "ip6_mr_cache"); + proc_net_remove(&init_net, "ip6_mr_vif"); +#endif + unregister_netdevice_notifier(&ip6_mr_notifier); + del_timer(&ipmr_expire_timer); + kmem_cache_destroy(mrt_cachep); +} static int ip6mr_mfc_add(struct mf6cctl *mfc, int mrtsock) { ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: v2 [PATCH 1/2] ipv6: Do cleanup for ip6_mr_init 2008-07-03 4:13 ` v2 [PATCH 1/2] ipv6: Do cleanup for ip6_mr_init Wang Chen @ 2008-07-03 7:09 ` YOSHIFUJI Hideaki / 吉藤英明 0 siblings, 0 replies; 8+ messages in thread From: YOSHIFUJI Hideaki / 吉藤英明 @ 2008-07-03 7:09 UTC (permalink / raw) To: wangchen; +Cc: davem, netdev, yoshfuji In article <486C51EA.2040401@cn.fujitsu.com> (at Thu, 03 Jul 2008 12:13:30 +0800), Wang Chen <wangchen@cn.fujitsu.com> says: > If do not do it, we will get following issues: > 1. Leaving junks after inet6_init failing halfway. > 2. Leaving proc and notifier junks after ipv6 modules unloading. > > Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> Applied to my linux-2.6-next tree. Thanks. --yoshfuji ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <486C50AE.7000207@cn.fujitsu.com>]
* v2 [PATCH 2/2] ipv4: Do cleanup for ip_mr_init [not found] ` <486C50AE.7000207@cn.fujitsu.com> @ 2008-07-03 4:13 ` Wang Chen 2008-07-03 7:10 ` YOSHIFUJI Hideaki / 吉藤英明 0 siblings, 1 reply; 8+ messages in thread From: Wang Chen @ 2008-07-03 4:13 UTC (permalink / raw) To: davem; +Cc: YOSHIFUJI Hideaki / 吉藤英明, netdev Same as ip6_mr_init(), make ip_mr_init() return errno if fails. But do not do error handling in inet_init(), just print a msg. Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> --- diff --git a/include/linux/igmp.h b/include/linux/igmp.h index f5a1a0d..7bb3c09 100644 --- a/include/linux/igmp.h +++ b/include/linux/igmp.h @@ -228,7 +228,6 @@ extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf, extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf, struct group_filter __user *optval, int __user *optlen); extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt, int dif); -extern void ip_mr_init(void); extern void ip_mc_init_dev(struct in_device *); extern void ip_mc_destroy_dev(struct in_device *); extern void ip_mc_up(struct in_device *); diff --git a/include/linux/mroute.h b/include/linux/mroute.h index de4decf..df8efd4 100644 --- a/include/linux/mroute.h +++ b/include/linux/mroute.h @@ -147,8 +147,7 @@ static inline int ip_mroute_opt(int opt) extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int); extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); -extern void ip_mr_init(void); - +extern int ip_mr_init(void); struct vif_device { diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 24eca23..3bb9007 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1481,14 +1481,15 @@ static int __init inet_init(void) * Initialise the multicast router */ #if defined(CONFIG_IP_MROUTE) - ip_mr_init(); + if (ip_mr_init()) + printk(KERN_CRIT "inet_init: Cannot init ipv4 mroute\n"); #endif /* * Initialise per-cpu ipv4 mibs */ if (init_ipv4_mibs()) - printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); ; + printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); ipv4_proc_init(); diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 11700a4..5225587 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -1887,16 +1887,36 @@ static struct net_protocol pim_protocol = { * Setup for IP multicast routing */ -void __init ip_mr_init(void) +int __init ip_mr_init(void) { + int err; + mrt_cachep = kmem_cache_create("ip_mrt_cache", sizeof(struct mfc_cache), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); + if (!mrt_cachep) + return -ENOMEM; + setup_timer(&ipmr_expire_timer, ipmr_expire_process, 0); - register_netdevice_notifier(&ip_mr_notifier); + err = register_netdevice_notifier(&ip_mr_notifier); + if (err) + goto reg_notif_fail; #ifdef CONFIG_PROC_FS - proc_net_fops_create(&init_net, "ip_mr_vif", 0, &ipmr_vif_fops); - proc_net_fops_create(&init_net, "ip_mr_cache", 0, &ipmr_mfc_fops); + err = -ENOMEM; + if (!proc_net_fops_create(&init_net, "ip_mr_vif", 0, &ipmr_vif_fops)) + goto proc_vif_fail; + if (!proc_net_fops_create(&init_net, "ip_mr_cache", 0, &ipmr_mfc_fops)) + goto proc_cache_fail; #endif + return 0; +reg_notif_fail: + kmem_cache_destroy(mrt_cachep); +#ifdef CONFIG_PROC_FS +proc_vif_fail: + unregister_netdevice_notifier(&ip_mr_notifier); +proc_cache_fail: + proc_net_remove(&init_net, "ip_mr_vif"); +#endif + return err; } ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: v2 [PATCH 2/2] ipv4: Do cleanup for ip_mr_init 2008-07-03 4:13 ` v2 [PATCH 2/2] ipv4: Do cleanup for ip_mr_init Wang Chen @ 2008-07-03 7:10 ` YOSHIFUJI Hideaki / 吉藤英明 0 siblings, 0 replies; 8+ messages in thread From: YOSHIFUJI Hideaki / 吉藤英明 @ 2008-07-03 7:10 UTC (permalink / raw) To: wangchen; +Cc: davem, netdev, yoshfuji In article <486C51F0.4010205@cn.fujitsu.com> (at Thu, 03 Jul 2008 12:13:36 +0800), Wang Chen <wangchen@cn.fujitsu.com> says: > Same as ip6_mr_init(), make ip_mr_init() return errno if fails. > But do not do error handling in inet_init(), just print a msg. > > Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> Applied to my linux-2.6-next tree. Thanks. --yoshfuji ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-07-03 7:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24 3:42 [PATCH] ipv6: Do cleanup for ip_mr_init Wang Chen
2008-07-02 8:49 ` Wang Chen
2008-07-02 9:18 ` YOSHIFUJI Hideaki / 吉藤英明
2008-07-02 9:38 ` Wang Chen
2008-07-03 4:13 ` v2 [PATCH 1/2] ipv6: Do cleanup for ip6_mr_init Wang Chen
2008-07-03 7:09 ` YOSHIFUJI Hideaki / 吉藤英明
[not found] ` <486C50AE.7000207@cn.fujitsu.com>
2008-07-03 4:13 ` v2 [PATCH 2/2] ipv4: Do cleanup for ip_mr_init Wang Chen
2008-07-03 7:10 ` YOSHIFUJI Hideaki / 吉藤英明
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).