aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:30:19 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:45:28 -0400
commit73bbe095bbb9ce5f94d5475bad54c7ccd8573b1b (patch)
treef0bd33e1d28c3c5310b0321761dfc53d753d4b01
parent17c30b40ed79e9f3955e884632c8f01e577b204a (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>
-rw-r--r--net/dccp/proto.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 47b137a3feaf..e29bbf914057 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