Commit 6a9fb947 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

[IPV4]: Clean the ip_sockglue.c from some ugly ifdefs

The #idfed CONFIG_IP_MROUTE is sometimes places inside the if-s,
which looks completely bad. Similar ifdefs inside the functions
looks a bit better, but they are also not recommended to be used.

Provide an ifdef-ed ip_mroute_opt() helper to cleanup the code.
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4e058063
...@@ -128,6 +128,18 @@ struct igmpmsg ...@@ -128,6 +128,18 @@ struct igmpmsg
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <net/sock.h> #include <net/sock.h>
#ifdef CONFIG_IP_MROUTE
static inline int ip_mroute_opt(int opt)
{
return (opt >= MRT_BASE) && (opt <= MRT_BASE + 10);
}
#else
static inline int ip_mroute_opt(int opt)
{
return 0;
}
#endif
extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int); 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 ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
......
...@@ -437,10 +437,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -437,10 +437,8 @@ static int do_ip_setsockopt(struct sock *sk, int level,
/* If optlen==0, it is equivalent to val == 0 */ /* If optlen==0, it is equivalent to val == 0 */
#ifdef CONFIG_IP_MROUTE if (ip_mroute_opt(optname))
if (optname >= MRT_BASE && optname <= (MRT_BASE + 10))
return ip_mroute_setsockopt(sk,optname,optval,optlen); return ip_mroute_setsockopt(sk,optname,optval,optlen);
#endif
err = 0; err = 0;
lock_sock(sk); lock_sock(sk);
...@@ -909,11 +907,9 @@ int ip_setsockopt(struct sock *sk, int level, ...@@ -909,11 +907,9 @@ int ip_setsockopt(struct sock *sk, int level,
#ifdef CONFIG_NETFILTER #ifdef CONFIG_NETFILTER
/* we need to exclude all possible ENOPROTOOPTs except default case */ /* we need to exclude all possible ENOPROTOOPTs except default case */
if (err == -ENOPROTOOPT && optname != IP_HDRINCL && if (err == -ENOPROTOOPT && optname != IP_HDRINCL &&
optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY optname != IP_IPSEC_POLICY &&
#ifdef CONFIG_IP_MROUTE optname != IP_XFRM_POLICY &&
&& (optname < MRT_BASE || optname > (MRT_BASE + 10)) !ip_mroute_opt(optname)) {
#endif
) {
lock_sock(sk); lock_sock(sk);
err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); err = nf_setsockopt(sk, PF_INET, optname, optval, optlen);
release_sock(sk); release_sock(sk);
...@@ -935,11 +931,9 @@ int compat_ip_setsockopt(struct sock *sk, int level, int optname, ...@@ -935,11 +931,9 @@ int compat_ip_setsockopt(struct sock *sk, int level, int optname,
#ifdef CONFIG_NETFILTER #ifdef CONFIG_NETFILTER
/* we need to exclude all possible ENOPROTOOPTs except default case */ /* we need to exclude all possible ENOPROTOOPTs except default case */
if (err == -ENOPROTOOPT && optname != IP_HDRINCL && if (err == -ENOPROTOOPT && optname != IP_HDRINCL &&
optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY optname != IP_IPSEC_POLICY &&
#ifdef CONFIG_IP_MROUTE optname != IP_XFRM_POLICY &&
&& (optname < MRT_BASE || optname > (MRT_BASE + 10)) !ip_mroute_opt(optname)) {
#endif
) {
lock_sock(sk); lock_sock(sk);
err = compat_nf_setsockopt(sk, PF_INET, optname, err = compat_nf_setsockopt(sk, PF_INET, optname,
optval, optlen); optval, optlen);
...@@ -967,11 +961,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -967,11 +961,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
if (level != SOL_IP) if (level != SOL_IP)
return -EOPNOTSUPP; return -EOPNOTSUPP;
#ifdef CONFIG_IP_MROUTE if (ip_mroute_opt(optname))
if (optname >= MRT_BASE && optname <= MRT_BASE+10) {
return ip_mroute_getsockopt(sk,optname,optval,optlen); return ip_mroute_getsockopt(sk,optname,optval,optlen);
}
#endif
if (get_user(len,optlen)) if (get_user(len,optlen))
return -EFAULT; return -EFAULT;
...@@ -1171,11 +1162,8 @@ int ip_getsockopt(struct sock *sk, int level, ...@@ -1171,11 +1162,8 @@ int ip_getsockopt(struct sock *sk, int level,
err = do_ip_getsockopt(sk, level, optname, optval, optlen); err = do_ip_getsockopt(sk, level, optname, optval, optlen);
#ifdef CONFIG_NETFILTER #ifdef CONFIG_NETFILTER
/* we need to exclude all possible ENOPROTOOPTs except default case */ /* we need to exclude all possible ENOPROTOOPTs except default case */
if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS &&
#ifdef CONFIG_IP_MROUTE !ip_mroute_opt(optname)) {
&& (optname < MRT_BASE || optname > MRT_BASE+10)
#endif
) {
int len; int len;
if (get_user(len,optlen)) if (get_user(len,optlen))
...@@ -1200,11 +1188,8 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -1200,11 +1188,8 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname,
int err = do_ip_getsockopt(sk, level, optname, optval, optlen); int err = do_ip_getsockopt(sk, level, optname, optval, optlen);
#ifdef CONFIG_NETFILTER #ifdef CONFIG_NETFILTER
/* we need to exclude all possible ENOPROTOOPTs except default case */ /* we need to exclude all possible ENOPROTOOPTs except default case */
if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS &&
#ifdef CONFIG_IP_MROUTE !ip_mroute_opt(optname)) {
&& (optname < MRT_BASE || optname > MRT_BASE+10)
#endif
) {
int len; int len;
if (get_user(len, optlen)) if (get_user(len, optlen))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment