Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 87214
b: refs/heads/master
c: 219b99a
h: refs/heads/master
v: v3
  • Loading branch information
Neil Horman authored and David S. Miller committed Mar 5, 2008
1 parent 74f088e commit 0dd8c5f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 140ee9603c753ce11fc3088c1988a77e92183f9b
refs/heads/master: 219b99a9edab4fdc478c819acb38f4a592dffd7d
73 changes: 60 additions & 13 deletions trunk/net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2933,17 +2933,39 @@ static int sctp_setsockopt_maxburst(struct sock *sk,
char __user *optval,
int optlen)
{
struct sctp_assoc_value params;
struct sctp_sock *sp;
struct sctp_association *asoc;
int val;
int assoc_id = 0;

if (optlen != sizeof(int))
if (optlen < sizeof(int))
return -EINVAL;
if (get_user(val, (int __user *)optval))
return -EFAULT;

if (val < 0)
if (optlen == sizeof(int)) {
printk(KERN_WARNING
"SCTP: Use of int in max_burst socket option deprecated\n");
printk(KERN_WARNING
"SCTP: Use struct sctp_assoc_value instead\n");
if (copy_from_user(&val, optval, optlen))
return -EFAULT;
} else if (optlen == sizeof(struct sctp_assoc_value)) {
if (copy_from_user(&params, optval, optlen))
return -EFAULT;
val = params.assoc_value;
assoc_id = params.assoc_id;
} else
return -EINVAL;

sctp_sk(sk)->max_burst = val;
sp = sctp_sk(sk);

if (assoc_id != 0) {
asoc = sctp_id2assoc(sk, assoc_id);
if (!asoc)
return -EINVAL;
asoc->max_burst = val;
} else
sp->max_burst = val;

return 0;
}
Expand Down Expand Up @@ -5005,20 +5027,45 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len,
char __user *optval,
int __user *optlen)
{
int val;
struct sctp_assoc_value params;
struct sctp_sock *sp;
struct sctp_association *asoc;

if (len < sizeof(int))
return -EINVAL;

len = sizeof(int);
if (len == sizeof(int)) {
printk(KERN_WARNING
"SCTP: Use of int in max_burst socket option deprecated\n");
printk(KERN_WARNING
"SCTP: Use struct sctp_assoc_value instead\n");
params.assoc_id = 0;
} else if (len == sizeof (struct sctp_assoc_value)) {
if (copy_from_user(&params, optval, len))
return -EFAULT;
} else
return -EINVAL;

val = sctp_sk(sk)->max_burst;
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(optval, &val, len))
return -EFAULT;
sp = sctp_sk(sk);

if (params.assoc_id != 0) {
asoc = sctp_id2assoc(sk, params.assoc_id);
if (!asoc)
return -EINVAL;
params.assoc_value = asoc->max_burst;
} else
params.assoc_value = sp->max_burst;

if (len == sizeof(int)) {
if (copy_to_user(optval, &params.assoc_value, len))
return -EFAULT;
} else {
if (copy_to_user(optval, &params, len))
return -EFAULT;
}

return 0;

return -ENOTSUPP;
}

static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
Expand Down

0 comments on commit 0dd8c5f

Please sign in to comment.