aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-07-03 03:51:22 -0400
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-07-03 04:51:57 -0400
commite0835f8fa56d2d308486f8a34cf1c4480cd27f4e (patch)
tree8b9e2f60795dbc6e0e0138c8e7c362efecb568e8
parent03d2f897e9fb3218989baa2139a951ce7f5414bf (diff)
ipv4,ipv6 mroute: Add some helper inline functions to remove ugly ifdefs.
ip{,v6}_mroute_{set,get}sockopt() should not matter by optimization but it would be better not to depend on optimization semantically. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
-rw-r--r--include/linux/mroute.h27
-rw-r--r--include/linux/mroute6.h32
-rw-r--r--net/ipv6/af_inet6.c8
3 files changed, 59 insertions, 8 deletions
diff --git a/include/linux/mroute.h b/include/linux/mroute.h
index df8efd42bf8a..07112ee9293a 100644
--- a/include/linux/mroute.h
+++ b/include/linux/mroute.h
@@ -144,10 +144,37 @@ static inline int ip_mroute_opt(int opt)
144} 144}
145#endif 145#endif
146 146
147#ifdef CONFIG_IP_MROUTE
147extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int); 148extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int);
148extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); 149extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
149extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); 150extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
150extern int ip_mr_init(void); 151extern int ip_mr_init(void);
152#else
153static inline
154int ip_mroute_setsockopt(struct sock *sock,
155 int optname, char __user *optval, int optlen)
156{
157 return -ENOPROTOOPT;
158}
159
160static inline
161int ip_mroute_getsockopt(struct sock *sock,
162 int optname, char __user *optval, int __user *optlen)
163{
164 return -ENOPROTOOPT;
165}
166
167static inline
168int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
169{
170 return -ENOIOCTLCMD;
171}
172
173static inline int ip_mr_init(void)
174{
175 return 0;
176}
177#endif
151 178
152struct vif_device 179struct vif_device
153{ 180{
diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h
index 4c4d6f57d5c5..5cf50473a10f 100644
--- a/include/linux/mroute6.h
+++ b/include/linux/mroute6.h
@@ -131,12 +131,44 @@ static inline int ip6_mroute_opt(int opt)
131 131
132struct sock; 132struct sock;
133 133
134#ifdef CONFIG_IPV6_MROUTE
134extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, int); 135extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, int);
135extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); 136extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
136extern int ip6_mr_input(struct sk_buff *skb); 137extern int ip6_mr_input(struct sk_buff *skb);
137extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); 138extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
138extern int ip6_mr_init(void); 139extern int ip6_mr_init(void);
139extern void ip6_mr_cleanup(void); 140extern void ip6_mr_cleanup(void);
141#else
142static inline
143int ip6_mroute_setsockopt(struct sock *sock,
144 int optname, char __user *optval, int optlen)
145{
146 return -ENOPROTOOPT;
147}
148
149static inline
150int ip6_mroute_getsockopt(struct sock *sock,
151 int optname, char __user *optval, int __user *optlen)
152{
153 return -ENOPROTOOPT;
154}
155
156static inline
157int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
158{
159 return -ENOIOCTLCMD;
160}
161
162static inline int ip6_mr_init(void)
163{
164 return 0;
165}
166
167static inline void ip6_mr_cleanup(void)
168{
169 return;
170}
171#endif
140 172
141struct mif_device 173struct mif_device
142{ 174{
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 6b39af1acb5e..3d828bc4b1cf 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -59,9 +59,7 @@
59 59
60#include <asm/uaccess.h> 60#include <asm/uaccess.h>
61#include <asm/system.h> 61#include <asm/system.h>
62#ifdef CONFIG_IPV6_MROUTE
63#include <linux/mroute6.h> 62#include <linux/mroute6.h>
64#endif
65 63
66MODULE_AUTHOR("Cast of dozens"); 64MODULE_AUTHOR("Cast of dozens");
67MODULE_DESCRIPTION("IPv6 protocol stack for Linux"); 65MODULE_DESCRIPTION("IPv6 protocol stack for Linux");
@@ -952,11 +950,9 @@ static int __init inet6_init(void)
952 err = icmpv6_init(); 950 err = icmpv6_init();
953 if (err) 951 if (err)
954 goto icmp_fail; 952 goto icmp_fail;
955#ifdef CONFIG_IPV6_MROUTE
956 err = ip6_mr_init(); 953 err = ip6_mr_init();
957 if (err) 954 if (err)
958 goto ipmr_fail; 955 goto ipmr_fail;
959#endif
960 err = ndisc_init(); 956 err = ndisc_init();
961 if (err) 957 if (err)
962 goto ndisc_fail; 958 goto ndisc_fail;
@@ -1059,10 +1055,8 @@ netfilter_fail:
1059igmp_fail: 1055igmp_fail:
1060 ndisc_cleanup(); 1056 ndisc_cleanup();
1061ndisc_fail: 1057ndisc_fail:
1062#ifdef CONFIG_IPV6_MROUTE
1063 ip6_mr_cleanup(); 1058 ip6_mr_cleanup();
1064ipmr_fail: 1059ipmr_fail:
1065#endif
1066 icmpv6_cleanup(); 1060 icmpv6_cleanup();
1067icmp_fail: 1061icmp_fail:
1068 unregister_pernet_subsys(&inet6_net_ops); 1062 unregister_pernet_subsys(&inet6_net_ops);
@@ -1117,9 +1111,7 @@ static void __exit inet6_exit(void)
1117 ipv6_netfilter_fini(); 1111 ipv6_netfilter_fini();
1118 igmp6_cleanup(); 1112 igmp6_cleanup();
1119 ndisc_cleanup(); 1113 ndisc_cleanup();
1120#ifdef CONFIG_IPV6_MROUTE
1121 ip6_mr_cleanup(); 1114 ip6_mr_cleanup();
1122#endif
1123 icmpv6_cleanup(); 1115 icmpv6_cleanup();
1124 rawv6_exit(); 1116 rawv6_exit();
1125 1117