diff options
author | Dmitry Mishin <dim@openvz.org> | 2006-03-21 01:45:21 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:45:21 -0500 |
commit | 3fdadf7d27e3fbcf72930941884387d1f4936f04 (patch) | |
tree | 167072cf1e60b6b307610563614b435ff0caa52d /net/ipv4/raw.c | |
parent | c750360938b403e6cc193d293cfbcb099dd6c60e (diff) |
[NET]: {get|set}sockopt compatibility layer
This patch extends {get|set}sockopt compatibility layer in order to
move protocol specific parts to their place and avoid huge universal
net/compat.c file in the future.
Signed-off-by: Dmitry Mishin <dim@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r-- | net/ipv4/raw.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index f29a12da5109..f1b02b34fc0a 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -660,12 +660,9 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o | |||
660 | out: return ret; | 660 | out: return ret; |
661 | } | 661 | } |
662 | 662 | ||
663 | static int raw_setsockopt(struct sock *sk, int level, int optname, | 663 | static int do_raw_setsockopt(struct sock *sk, int level, int optname, |
664 | char __user *optval, int optlen) | 664 | char __user *optval, int optlen) |
665 | { | 665 | { |
666 | if (level != SOL_RAW) | ||
667 | return ip_setsockopt(sk, level, optname, optval, optlen); | ||
668 | |||
669 | if (optname == ICMP_FILTER) { | 666 | if (optname == ICMP_FILTER) { |
670 | if (inet_sk(sk)->num != IPPROTO_ICMP) | 667 | if (inet_sk(sk)->num != IPPROTO_ICMP) |
671 | return -EOPNOTSUPP; | 668 | return -EOPNOTSUPP; |
@@ -675,12 +672,28 @@ static int raw_setsockopt(struct sock *sk, int level, int optname, | |||
675 | return -ENOPROTOOPT; | 672 | return -ENOPROTOOPT; |
676 | } | 673 | } |
677 | 674 | ||
678 | static int raw_getsockopt(struct sock *sk, int level, int optname, | 675 | static int raw_setsockopt(struct sock *sk, int level, int optname, |
679 | char __user *optval, int __user *optlen) | 676 | char __user *optval, int optlen) |
680 | { | 677 | { |
681 | if (level != SOL_RAW) | 678 | if (level != SOL_RAW) |
682 | return ip_getsockopt(sk, level, optname, optval, optlen); | 679 | return ip_setsockopt(sk, level, optname, optval, optlen); |
680 | return do_raw_setsockopt(sk, level, optname, optval, optlen); | ||
681 | } | ||
683 | 682 | ||
683 | #ifdef CONFIG_COMPAT | ||
684 | static int compat_raw_setsockopt(struct sock *sk, int level, int optname, | ||
685 | char __user *optval, int optlen) | ||
686 | { | ||
687 | if (level != SOL_RAW) | ||
688 | return compat_ip_setsockopt(sk, level, | ||
689 | optname, optval, optlen); | ||
690 | return do_raw_setsockopt(sk, level, optname, optval, optlen); | ||
691 | } | ||
692 | #endif | ||
693 | |||
694 | static int do_raw_getsockopt(struct sock *sk, int level, int optname, | ||
695 | char __user *optval, int __user *optlen) | ||
696 | { | ||
684 | if (optname == ICMP_FILTER) { | 697 | if (optname == ICMP_FILTER) { |
685 | if (inet_sk(sk)->num != IPPROTO_ICMP) | 698 | if (inet_sk(sk)->num != IPPROTO_ICMP) |
686 | return -EOPNOTSUPP; | 699 | return -EOPNOTSUPP; |
@@ -690,6 +703,25 @@ static int raw_getsockopt(struct sock *sk, int level, int optname, | |||
690 | return -ENOPROTOOPT; | 703 | return -ENOPROTOOPT; |
691 | } | 704 | } |
692 | 705 | ||
706 | static int raw_getsockopt(struct sock *sk, int level, int optname, | ||
707 | char __user *optval, int __user *optlen) | ||
708 | { | ||
709 | if (level != SOL_RAW) | ||
710 | return ip_getsockopt(sk, level, optname, optval, optlen); | ||
711 | return do_raw_getsockopt(sk, level, optname, optval, optlen); | ||
712 | } | ||
713 | |||
714 | #ifdef CONFIG_COMPAT | ||
715 | static int compat_raw_getsockopt(struct sock *sk, int level, int optname, | ||
716 | char __user *optval, int __user *optlen) | ||
717 | { | ||
718 | if (level != SOL_RAW) | ||
719 | return compat_ip_getsockopt(sk, level, | ||
720 | optname, optval, optlen); | ||
721 | return do_raw_getsockopt(sk, level, optname, optval, optlen); | ||
722 | } | ||
723 | #endif | ||
724 | |||
693 | static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) | 725 | static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) |
694 | { | 726 | { |
695 | switch (cmd) { | 727 | switch (cmd) { |
@@ -728,6 +760,10 @@ struct proto raw_prot = { | |||
728 | .init = raw_init, | 760 | .init = raw_init, |
729 | .setsockopt = raw_setsockopt, | 761 | .setsockopt = raw_setsockopt, |
730 | .getsockopt = raw_getsockopt, | 762 | .getsockopt = raw_getsockopt, |
763 | #ifdef CONFIG_COMPAT | ||
764 | .compat_setsockopt = compat_raw_setsockopt, | ||
765 | .compat_getsockopt = compat_raw_getsockopt, | ||
766 | #endif | ||
731 | .sendmsg = raw_sendmsg, | 767 | .sendmsg = raw_sendmsg, |
732 | .recvmsg = raw_recvmsg, | 768 | .recvmsg = raw_recvmsg, |
733 | .bind = raw_bind, | 769 | .bind = raw_bind, |