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/dccp/proto.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/dccp/proto.c')
-rw-r--r-- | net/dccp/proto.c | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index baccaf35ffbd..59b214995f28 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -455,18 +455,13 @@ out_free_val: | |||
455 | goto out; | 455 | goto out; |
456 | } | 456 | } |
457 | 457 | ||
458 | int dccp_setsockopt(struct sock *sk, int level, int optname, | 458 | static int do_dccp_setsockopt(struct sock *sk, int level, int optname, |
459 | char __user *optval, int optlen) | 459 | char __user *optval, int optlen) |
460 | { | 460 | { |
461 | struct dccp_sock *dp; | 461 | struct dccp_sock *dp; |
462 | int err; | 462 | int err; |
463 | int val; | 463 | int val; |
464 | 464 | ||
465 | if (level != SOL_DCCP) | ||
466 | return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, | ||
467 | optname, optval, | ||
468 | optlen); | ||
469 | |||
470 | if (optlen < sizeof(int)) | 465 | if (optlen < sizeof(int)) |
471 | return -EINVAL; | 466 | return -EINVAL; |
472 | 467 | ||
@@ -512,8 +507,34 @@ int dccp_setsockopt(struct sock *sk, int level, int optname, | |||
512 | return err; | 507 | return err; |
513 | } | 508 | } |
514 | 509 | ||
510 | int dccp_setsockopt(struct sock *sk, int level, int optname, | ||
511 | char __user *optval, int optlen) | ||
512 | { | ||
513 | if (level != SOL_DCCP) | ||
514 | return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, | ||
515 | optname, optval, | ||
516 | optlen); | ||
517 | return do_dccp_setsockopt(sk, level, optname, optval, optlen); | ||
518 | } | ||
515 | EXPORT_SYMBOL_GPL(dccp_setsockopt); | 519 | EXPORT_SYMBOL_GPL(dccp_setsockopt); |
516 | 520 | ||
521 | #ifdef CONFIG_COMPAT | ||
522 | int compat_dccp_setsockopt(struct sock *sk, int level, int optname, | ||
523 | char __user *optval, int optlen) | ||
524 | { | ||
525 | if (level != SOL_DCCP) { | ||
526 | if (inet_csk(sk)->icsk_af_ops->compat_setsockopt) | ||
527 | return inet_csk(sk)->icsk_af_ops->compat_setsockopt(sk, | ||
528 | level, optname, optval, optlen); | ||
529 | else | ||
530 | return inet_csk(sk)->icsk_af_ops->setsockopt(sk, | ||
531 | level, optname, optval, optlen); | ||
532 | } | ||
533 | return do_dccp_setsockopt(sk, level, optname, optval, optlen); | ||
534 | } | ||
535 | EXPORT_SYMBOL_GPL(compat_dccp_setsockopt); | ||
536 | #endif | ||
537 | |||
517 | static int dccp_getsockopt_service(struct sock *sk, int len, | 538 | static int dccp_getsockopt_service(struct sock *sk, int len, |
518 | __be32 __user *optval, | 539 | __be32 __user *optval, |
519 | int __user *optlen) | 540 | int __user *optlen) |
@@ -545,16 +566,12 @@ out: | |||
545 | return err; | 566 | return err; |
546 | } | 567 | } |
547 | 568 | ||
548 | int dccp_getsockopt(struct sock *sk, int level, int optname, | 569 | static int do_dccp_getsockopt(struct sock *sk, int level, int optname, |
549 | char __user *optval, int __user *optlen) | 570 | char __user *optval, int __user *optlen) |
550 | { | 571 | { |
551 | struct dccp_sock *dp; | 572 | struct dccp_sock *dp; |
552 | int val, len; | 573 | int val, len; |
553 | 574 | ||
554 | if (level != SOL_DCCP) | ||
555 | return inet_csk(sk)->icsk_af_ops->getsockopt(sk, level, | ||
556 | optname, optval, | ||
557 | optlen); | ||
558 | if (get_user(len, optlen)) | 575 | if (get_user(len, optlen)) |
559 | return -EFAULT; | 576 | return -EFAULT; |
560 | 577 | ||
@@ -587,8 +604,34 @@ int dccp_getsockopt(struct sock *sk, int level, int optname, | |||
587 | return 0; | 604 | return 0; |
588 | } | 605 | } |
589 | 606 | ||
607 | int dccp_getsockopt(struct sock *sk, int level, int optname, | ||
608 | char __user *optval, int __user *optlen) | ||
609 | { | ||
610 | if (level != SOL_DCCP) | ||
611 | return inet_csk(sk)->icsk_af_ops->getsockopt(sk, level, | ||
612 | optname, optval, | ||
613 | optlen); | ||
614 | return do_dccp_getsockopt(sk, level, optname, optval, optlen); | ||
615 | } | ||
590 | EXPORT_SYMBOL_GPL(dccp_getsockopt); | 616 | EXPORT_SYMBOL_GPL(dccp_getsockopt); |
591 | 617 | ||
618 | #ifdef CONFIG_COMPAT | ||
619 | int compat_dccp_getsockopt(struct sock *sk, int level, int optname, | ||
620 | char __user *optval, int __user *optlen) | ||
621 | { | ||
622 | if (level != SOL_DCCP) { | ||
623 | if (inet_csk(sk)->icsk_af_ops->compat_setsockopt) | ||
624 | return inet_csk(sk)->icsk_af_ops->compat_getsockopt(sk, | ||
625 | level, optname, optval, optlen); | ||
626 | else | ||
627 | return inet_csk(sk)->icsk_af_ops->getsockopt(sk, | ||
628 | level, optname, optval, optlen); | ||
629 | } | ||
630 | return do_dccp_getsockopt(sk, level, optname, optval, optlen); | ||
631 | } | ||
632 | EXPORT_SYMBOL_GPL(compat_dccp_getsockopt); | ||
633 | #endif | ||
634 | |||
592 | int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | 635 | int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
593 | size_t len) | 636 | size_t len) |
594 | { | 637 | { |