Commit d364d927 authored by Wei Yongjun's avatar Wei Yongjun Committed by David S. Miller

sctp: Bring SCTP_DELAYED_ACK socket option into API compliance

Brings delayed_ack socket option set/get into line with the latest ietf
socket extensions API draft, while maintaining backwards compatibility.
Signed-off-by: default avatarWei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: default avatarVlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c5e1289
...@@ -300,6 +300,7 @@ struct sctp_sock { ...@@ -300,6 +300,7 @@ struct sctp_sock {
/* The default SACK delay timeout for new associations. */ /* The default SACK delay timeout for new associations. */
__u32 sackdelay; __u32 sackdelay;
__u32 sackfreq;
/* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */ /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */
__u32 param_flags; __u32 param_flags;
...@@ -938,6 +939,7 @@ struct sctp_transport { ...@@ -938,6 +939,7 @@ struct sctp_transport {
/* SACK delay timeout */ /* SACK delay timeout */
unsigned long sackdelay; unsigned long sackdelay;
__u32 sackfreq;
/* When was the last time (in jiffies) that we heard from this /* When was the last time (in jiffies) that we heard from this
* transport? We use this to pick new active and retran paths. * transport? We use this to pick new active and retran paths.
...@@ -1542,6 +1544,7 @@ struct sctp_association { ...@@ -1542,6 +1544,7 @@ struct sctp_association {
* : SACK's are not delayed (see Section 6). * : SACK's are not delayed (see Section 6).
*/ */
__u8 sack_needed; /* Do we need to sack the peer? */ __u8 sack_needed; /* Do we need to sack the peer? */
__u32 sack_cnt;
/* These are capabilities which our peer advertised. */ /* These are capabilities which our peer advertised. */
__u8 ecn_capable; /* Can peer do ECN? */ __u8 ecn_capable; /* Can peer do ECN? */
...@@ -1651,6 +1654,7 @@ struct sctp_association { ...@@ -1651,6 +1654,7 @@ struct sctp_association {
/* SACK delay timeout */ /* SACK delay timeout */
unsigned long sackdelay; unsigned long sackdelay;
__u32 sackfreq;
unsigned long timeouts[SCTP_NUM_TIMEOUT_TYPES]; unsigned long timeouts[SCTP_NUM_TIMEOUT_TYPES];
......
...@@ -93,8 +93,9 @@ enum sctp_optname { ...@@ -93,8 +93,9 @@ enum sctp_optname {
#define SCTP_STATUS SCTP_STATUS #define SCTP_STATUS SCTP_STATUS
SCTP_GET_PEER_ADDR_INFO, SCTP_GET_PEER_ADDR_INFO,
#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO #define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
SCTP_DELAYED_ACK_TIME, SCTP_DELAYED_ACK,
#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME #define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK
#define SCTP_DELAYED_ACK SCTP_DELAYED_ACK
SCTP_CONTEXT, /* Receive Context */ SCTP_CONTEXT, /* Receive Context */
#define SCTP_CONTEXT SCTP_CONTEXT #define SCTP_CONTEXT SCTP_CONTEXT
SCTP_FRAGMENT_INTERLEAVE, SCTP_FRAGMENT_INTERLEAVE,
...@@ -618,13 +619,26 @@ struct sctp_authkeyid { ...@@ -618,13 +619,26 @@ struct sctp_authkeyid {
}; };
/* 7.1.23. Delayed Ack Timer (SCTP_DELAYED_ACK_TIME) /*
* 7.1.23. Get or set delayed ack timer (SCTP_DELAYED_SACK)
* *
* This options will get or set the delayed ack timer. The time is set * This option will effect the way delayed acks are performed. This
* in milliseconds. If the assoc_id is 0, then this sets or gets the * option allows you to get or set the delayed ack time, in
* endpoints default delayed ack timer value. If the assoc_id field is * milliseconds. It also allows changing the delayed ack frequency.
* non-zero, then the set or get effects the specified association. * Changing the frequency to 1 disables the delayed sack algorithm. If
* the assoc_id is 0, then this sets or gets the endpoints default
* values. If the assoc_id field is non-zero, then the set or get
* effects the specified association for the one to many model (the
* assoc_id field is ignored by the one to one model). Note that if
* sack_delay or sack_freq are 0 when setting this option, then the
* current values will remain unchanged.
*/ */
struct sctp_sack_info {
sctp_assoc_t sack_assoc_id;
uint32_t sack_delay;
uint32_t sack_freq;
};
struct sctp_assoc_value { struct sctp_assoc_value {
sctp_assoc_t assoc_id; sctp_assoc_t assoc_id;
uint32_t assoc_value; uint32_t assoc_value;
......
...@@ -136,6 +136,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a ...@@ -136,6 +136,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
/* Set association default SACK delay */ /* Set association default SACK delay */
asoc->sackdelay = msecs_to_jiffies(sp->sackdelay); asoc->sackdelay = msecs_to_jiffies(sp->sackdelay);
asoc->sackfreq = sp->sackfreq;
/* Set the association default flags controlling /* Set the association default flags controlling
* Heartbeat, SACK delay, and Path MTU Discovery. * Heartbeat, SACK delay, and Path MTU Discovery.
...@@ -261,6 +262,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a ...@@ -261,6 +262,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
* already received one packet.] * already received one packet.]
*/ */
asoc->peer.sack_needed = 1; asoc->peer.sack_needed = 1;
asoc->peer.sack_cnt = 0;
/* Assume that the peer will tell us if he recognizes ASCONF /* Assume that the peer will tell us if he recognizes ASCONF
* as part of INIT exchange. * as part of INIT exchange.
...@@ -615,6 +617,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, ...@@ -615,6 +617,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
* association configured value. * association configured value.
*/ */
peer->sackdelay = asoc->sackdelay; peer->sackdelay = asoc->sackdelay;
peer->sackfreq = asoc->sackfreq;
/* Enable/disable heartbeat, SACK delay, and path MTU discovery /* Enable/disable heartbeat, SACK delay, and path MTU discovery
* based on association setting. * based on association setting.
......
...@@ -190,20 +190,28 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force, ...@@ -190,20 +190,28 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force,
* unacknowledged DATA chunk. ... * unacknowledged DATA chunk. ...
*/ */
if (!asoc->peer.sack_needed) { if (!asoc->peer.sack_needed) {
/* We will need a SACK for the next packet. */ asoc->peer.sack_cnt++;
asoc->peer.sack_needed = 1;
/* Set the SACK delay timeout based on the /* Set the SACK delay timeout based on the
* SACK delay for the last transport * SACK delay for the last transport
* data was received from, or the default * data was received from, or the default
* for the association. * for the association.
*/ */
if (trans) if (trans) {
/* We will need a SACK for the next packet. */
if (asoc->peer.sack_cnt >= trans->sackfreq - 1)
asoc->peer.sack_needed = 1;
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
trans->sackdelay; trans->sackdelay;
else } else {
/* We will need a SACK for the next packet. */
if (asoc->peer.sack_cnt >= asoc->sackfreq - 1)
asoc->peer.sack_needed = 1;
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
asoc->sackdelay; asoc->sackdelay;
}
/* Restart the SACK timer. */ /* Restart the SACK timer. */
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
...@@ -216,6 +224,7 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force, ...@@ -216,6 +224,7 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force,
goto nomem; goto nomem;
asoc->peer.sack_needed = 0; asoc->peer.sack_needed = 0;
asoc->peer.sack_cnt = 0;
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(sack)); sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(sack));
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment