Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111463
b: refs/heads/master
c: 20f41ee
h: refs/heads/master
i:
  111461: a7197dc
  111459: fb5773c
  111455: 1b4c33f
v: v3
  • Loading branch information
Gerrit Renker committed Sep 4, 2008
1 parent 7991be9 commit b7e63b5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 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: 668144f7b41716a9efe1b398e15ead32a26cd101
refs/heads/master: 20f41eee82864e308a5499308a1722dc3181cc3a
4 changes: 2 additions & 2 deletions trunk/include/linux/dccp.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ struct dccp_sock {
__u32 dccps_timestamp_time;
__u16 dccps_l_ack_ratio;
__u16 dccps_r_ack_ratio;
__u16 dccps_pcslen;
__u16 dccps_pcrlen;
__u8 dccps_pcslen:4;
__u8 dccps_pcrlen:4;
__u64 dccps_ndp_count:48;
unsigned long dccps_rate_last;
struct dccp_minisock dccps_minisock;
Expand Down
53 changes: 40 additions & 13 deletions trunk/net/dccp/proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,42 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service,
return 0;
}

static int dccp_setsockopt_cscov(struct sock *sk, int cscov, bool rx)
{
u8 *list, len;
int i, rc;

if (cscov < 0 || cscov > 15)
return -EINVAL;
/*
* Populate a list of permissible values, in the range cscov...15. This
* is necessary since feature negotiation of single values only works if
* both sides incidentally choose the same value. Since the list starts
* lowest-value first, negotiation will pick the smallest shared value.
*/
if (cscov == 0)
return 0;
len = 16 - cscov;

list = kmalloc(len, GFP_KERNEL);
if (list == NULL)
return -ENOBUFS;

for (i = 0; i < len; i++)
list[i] = cscov++;

rc = dccp_feat_register_sp(sk, DCCPF_MIN_CSUM_COVER, rx, list, len);

if (rc == 0) {
if (rx)
dccp_sk(sk)->dccps_pcrlen = cscov;
else
dccp_sk(sk)->dccps_pcslen = cscov;
}
kfree(list);
return rc;
}

static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, int optlen)
{
Expand Down Expand Up @@ -502,20 +538,11 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
else
dp->dccps_server_timewait = (val != 0);
break;
case DCCP_SOCKOPT_SEND_CSCOV: /* sender side, RFC 4340, sec. 9.2 */
if (val < 0 || val > 15)
err = -EINVAL;
else
dp->dccps_pcslen = val;
case DCCP_SOCKOPT_SEND_CSCOV:
err = dccp_setsockopt_cscov(sk, val, false);
break;
case DCCP_SOCKOPT_RECV_CSCOV: /* receiver side, RFC 4340 sec. 9.2.1 */
if (val < 0 || val > 15)
err = -EINVAL;
else {
dp->dccps_pcrlen = val;
/* FIXME: add feature negotiation,
* ChangeL(MinimumChecksumCoverage, val) */
}
case DCCP_SOCKOPT_RECV_CSCOV:
err = dccp_setsockopt_cscov(sk, val, true);
break;
default:
err = -ENOPROTOOPT;
Expand Down

0 comments on commit b7e63b5

Please sign in to comment.