diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-11-17 01:56:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-17 01:56:55 -0500 |
commit | 191029963630719e867d8bd0c315d32c822622cb (patch) | |
tree | fb8284951c59eb8f3547c9cde09c189c07b702c1 /net/dccp/proto.c | |
parent | dd9c0e363cef32b7d6f23d4c87e8dfe4f91fd1c5 (diff) |
dccp: Tidy up setsockopt calls
This splits the setsockopt calls into two groups, depending on whether an
integer argument (val) is required and whether routines being called do
their own locking.
Some options (such as setting the CCID) use u8 rather than int, so that for
these the test with regard to integer-sizeof can not be used.
The second switch-case statement now only has those statements which need
locking and which make use of `val'.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Reviewed-by: Eugene Teo <eugeneteo@kernel.sg>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/proto.c')
-rw-r--r-- | net/dccp/proto.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index c6b4362bb1d7..bdf784c422b5 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -512,7 +512,17 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, | |||
512 | struct dccp_sock *dp = dccp_sk(sk); | 512 | struct dccp_sock *dp = dccp_sk(sk); |
513 | int val, err = 0; | 513 | int val, err = 0; |
514 | 514 | ||
515 | if (optlen < sizeof(int)) | 515 | switch (optname) { |
516 | case DCCP_SOCKOPT_PACKET_SIZE: | ||
517 | DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n"); | ||
518 | return 0; | ||
519 | case DCCP_SOCKOPT_CHANGE_L: | ||
520 | case DCCP_SOCKOPT_CHANGE_R: | ||
521 | DCCP_WARN("sockopt(CHANGE_L/R) is deprecated: fix your app\n"); | ||
522 | return 0; | ||
523 | } | ||
524 | |||
525 | if (optlen < (int)sizeof(int)) | ||
516 | return -EINVAL; | 526 | return -EINVAL; |
517 | 527 | ||
518 | if (get_user(val, (int __user *)optval)) | 528 | if (get_user(val, (int __user *)optval)) |
@@ -523,15 +533,6 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, | |||
523 | 533 | ||
524 | lock_sock(sk); | 534 | lock_sock(sk); |
525 | switch (optname) { | 535 | switch (optname) { |
526 | case DCCP_SOCKOPT_PACKET_SIZE: | ||
527 | DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n"); | ||
528 | err = 0; | ||
529 | break; | ||
530 | case DCCP_SOCKOPT_CHANGE_L: | ||
531 | case DCCP_SOCKOPT_CHANGE_R: | ||
532 | DCCP_WARN("sockopt(CHANGE_L/R) is deprecated: fix your app\n"); | ||
533 | err = 0; | ||
534 | break; | ||
535 | case DCCP_SOCKOPT_SERVER_TIMEWAIT: | 536 | case DCCP_SOCKOPT_SERVER_TIMEWAIT: |
536 | if (dp->dccps_role != DCCP_ROLE_SERVER) | 537 | if (dp->dccps_role != DCCP_ROLE_SERVER) |
537 | err = -EOPNOTSUPP; | 538 | err = -EOPNOTSUPP; |
@@ -548,8 +549,8 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, | |||
548 | err = -ENOPROTOOPT; | 549 | err = -ENOPROTOOPT; |
549 | break; | 550 | break; |
550 | } | 551 | } |
551 | |||
552 | release_sock(sk); | 552 | release_sock(sk); |
553 | |||
553 | return err; | 554 | return err; |
554 | } | 555 | } |
555 | 556 | ||