aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/sctp/user.h15
-rw-r--r--net/sctp/socket.c54
2 files changed, 52 insertions, 17 deletions
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 4ed752119bbc..80b7afea17fc 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -513,16 +513,17 @@ struct sctp_setadaptation {
513 * address's parameters: 513 * address's parameters:
514 */ 514 */
515enum sctp_spp_flags { 515enum sctp_spp_flags {
516 SPP_HB_ENABLE = 1, /*Enable heartbeats*/ 516 SPP_HB_ENABLE = 1<<0, /*Enable heartbeats*/
517 SPP_HB_DISABLE = 2, /*Disable heartbeats*/ 517 SPP_HB_DISABLE = 1<<1, /*Disable heartbeats*/
518 SPP_HB = SPP_HB_ENABLE | SPP_HB_DISABLE, 518 SPP_HB = SPP_HB_ENABLE | SPP_HB_DISABLE,
519 SPP_HB_DEMAND = 4, /*Send heartbeat immediately*/ 519 SPP_HB_DEMAND = 1<<2, /*Send heartbeat immediately*/
520 SPP_PMTUD_ENABLE = 8, /*Enable PMTU discovery*/ 520 SPP_PMTUD_ENABLE = 1<<3, /*Enable PMTU discovery*/
521 SPP_PMTUD_DISABLE = 16, /*Disable PMTU discovery*/ 521 SPP_PMTUD_DISABLE = 1<<4, /*Disable PMTU discovery*/
522 SPP_PMTUD = SPP_PMTUD_ENABLE | SPP_PMTUD_DISABLE, 522 SPP_PMTUD = SPP_PMTUD_ENABLE | SPP_PMTUD_DISABLE,
523 SPP_SACKDELAY_ENABLE = 32, /*Enable SACK*/ 523 SPP_SACKDELAY_ENABLE = 1<<5, /*Enable SACK*/
524 SPP_SACKDELAY_DISABLE = 64, /*Disable SACK*/ 524 SPP_SACKDELAY_DISABLE = 1<<6, /*Disable SACK*/
525 SPP_SACKDELAY = SPP_SACKDELAY_ENABLE | SPP_SACKDELAY_DISABLE, 525 SPP_SACKDELAY = SPP_SACKDELAY_ENABLE | SPP_SACKDELAY_DISABLE,
526 SPP_HB_TIME_IS_ZERO = 1<<7, /* Set HB delay to 0 */
526}; 527};
527 528
528struct sctp_paddrparams { 529struct sctp_paddrparams {
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 1e787a2d0b5f..dda2f6700f5b 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2039,6 +2039,10 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
2039 * SPP_HB_DEMAND - Request a user initiated heartbeat 2039 * SPP_HB_DEMAND - Request a user initiated heartbeat
2040 * to be made immediately. 2040 * to be made immediately.
2041 * 2041 *
2042 * SPP_HB_TIME_IS_ZERO - Specify's that the time for
2043 * heartbeat delayis to be set to the value of 0
2044 * milliseconds.
2045 *
2042 * SPP_PMTUD_ENABLE - This field will enable PMTU 2046 * SPP_PMTUD_ENABLE - This field will enable PMTU
2043 * discovery upon the specified address. Note that 2047 * discovery upon the specified address. Note that
2044 * if the address feild is empty then all addresses 2048 * if the address feild is empty then all addresses
@@ -2081,13 +2085,30 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params,
2081 return error; 2085 return error;
2082 } 2086 }
2083 2087
2084 if (params->spp_hbinterval) { 2088 /* Note that unless the spp_flag is set to SPP_HB_ENABLE the value of
2085 if (trans) { 2089 * this field is ignored. Note also that a value of zero indicates
2086 trans->hbinterval = msecs_to_jiffies(params->spp_hbinterval); 2090 * the current setting should be left unchanged.
2087 } else if (asoc) { 2091 */
2088 asoc->hbinterval = msecs_to_jiffies(params->spp_hbinterval); 2092 if (params->spp_flags & SPP_HB_ENABLE) {
2089 } else { 2093
2090 sp->hbinterval = params->spp_hbinterval; 2094 /* Re-zero the interval if the SPP_HB_TIME_IS_ZERO is
2095 * set. This lets us use 0 value when this flag
2096 * is set.
2097 */
2098 if (params->spp_flags & SPP_HB_TIME_IS_ZERO)
2099 params->spp_hbinterval = 0;
2100
2101 if (params->spp_hbinterval ||
2102 (params->spp_flags & SPP_HB_TIME_IS_ZERO)) {
2103 if (trans) {
2104 trans->hbinterval =
2105 msecs_to_jiffies(params->spp_hbinterval);
2106 } else if (asoc) {
2107 asoc->hbinterval =
2108 msecs_to_jiffies(params->spp_hbinterval);
2109 } else {
2110 sp->hbinterval = params->spp_hbinterval;
2111 }
2091 } 2112 }
2092 } 2113 }
2093 2114
@@ -2104,7 +2125,12 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params,
2104 } 2125 }
2105 } 2126 }
2106 2127
2107 if (params->spp_pathmtu) { 2128 /* When Path MTU discovery is disabled the value specified here will
2129 * be the "fixed" path mtu (i.e. the value of the spp_flags field must
2130 * include the flag SPP_PMTUD_DISABLE for this field to have any
2131 * effect).
2132 */
2133 if ((params->spp_flags & SPP_PMTUD_DISABLE) && params->spp_pathmtu) {
2108 if (trans) { 2134 if (trans) {
2109 trans->pathmtu = params->spp_pathmtu; 2135 trans->pathmtu = params->spp_pathmtu;
2110 sctp_assoc_sync_pmtu(asoc); 2136 sctp_assoc_sync_pmtu(asoc);
@@ -2135,7 +2161,11 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params,
2135 } 2161 }
2136 } 2162 }
2137 2163
2138 if (params->spp_sackdelay) { 2164 /* Note that unless the spp_flag is set to SPP_SACKDELAY_ENABLE the
2165 * value of this field is ignored. Note also that a value of zero
2166 * indicates the current setting should be left unchanged.
2167 */
2168 if ((params->spp_flags & SPP_SACKDELAY_ENABLE) && params->spp_sackdelay) {
2139 if (trans) { 2169 if (trans) {
2140 trans->sackdelay = 2170 trans->sackdelay =
2141 msecs_to_jiffies(params->spp_sackdelay); 2171 msecs_to_jiffies(params->spp_sackdelay);
@@ -2163,7 +2193,11 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params,
2163 } 2193 }
2164 } 2194 }
2165 2195
2166 if (params->spp_pathmaxrxt) { 2196 /* Note that unless the spp_flag is set to SPP_PMTUD_ENABLE the value
2197 * of this field is ignored. Note also that a value of zero
2198 * indicates the current setting should be left unchanged.
2199 */
2200 if ((params->spp_flags & SPP_PMTUD_ENABLE) && params->spp_pathmaxrxt) {
2167 if (trans) { 2201 if (trans) {
2168 trans->pathmaxrxt = params->spp_pathmaxrxt; 2202 trans->pathmaxrxt = params->spp_pathmaxrxt;
2169 } else if (asoc) { 2203 } else if (asoc) {