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>
This commit is contained in:
Родитель
17c30b40ed
Коммит
73bbe095bb
|
@ -512,7 +512,17 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
|
||||||
struct dccp_sock *dp = dccp_sk(sk);
|
struct dccp_sock *dp = dccp_sk(sk);
|
||||||
int val, err = 0;
|
int val, err = 0;
|
||||||
|
|
||||||
if (optlen < sizeof(int))
|
switch (optname) {
|
||||||
|
case DCCP_SOCKOPT_PACKET_SIZE:
|
||||||
|
DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
|
||||||
|
return 0;
|
||||||
|
case DCCP_SOCKOPT_CHANGE_L:
|
||||||
|
case DCCP_SOCKOPT_CHANGE_R:
|
||||||
|
DCCP_WARN("sockopt(CHANGE_L/R) is deprecated: fix your app\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optlen < (int)sizeof(int))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (get_user(val, (int __user *)optval))
|
if (get_user(val, (int __user *)optval))
|
||||||
|
@ -523,15 +533,6 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
|
||||||
|
|
||||||
lock_sock(sk);
|
lock_sock(sk);
|
||||||
switch (optname) {
|
switch (optname) {
|
||||||
case DCCP_SOCKOPT_PACKET_SIZE:
|
|
||||||
DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
|
|
||||||
err = 0;
|
|
||||||
break;
|
|
||||||
case DCCP_SOCKOPT_CHANGE_L:
|
|
||||||
case DCCP_SOCKOPT_CHANGE_R:
|
|
||||||
DCCP_WARN("sockopt(CHANGE_L/R) is deprecated: fix your app\n");
|
|
||||||
err = 0;
|
|
||||||
break;
|
|
||||||
case DCCP_SOCKOPT_SERVER_TIMEWAIT:
|
case DCCP_SOCKOPT_SERVER_TIMEWAIT:
|
||||||
if (dp->dccps_role != DCCP_ROLE_SERVER)
|
if (dp->dccps_role != DCCP_ROLE_SERVER)
|
||||||
err = -EOPNOTSUPP;
|
err = -EOPNOTSUPP;
|
||||||
|
@ -548,8 +549,8 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
|
||||||
err = -ENOPROTOOPT;
|
err = -ENOPROTOOPT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
release_sock(sk);
|
release_sock(sk);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче