aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/raw.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r--net/ipv4/raw.c50
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
660out: return ret; 660out: return ret;
661} 661}
662 662
663static int raw_setsockopt(struct sock *sk, int level, int optname, 663static 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
678static int raw_getsockopt(struct sock *sk, int level, int optname, 675static 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
684static 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
694static 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
706static 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
715static 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
693static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) 725static 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,