diff options
Diffstat (limited to 'net/dccp/dccp.h')
| -rw-r--r-- | net/dccp/dccp.h | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 019d6ffee354..3eb264b60823 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
| @@ -153,18 +153,27 @@ static inline u64 max48(const u64 seq1, const u64 seq2) | |||
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | /** | 155 | /** |
| 156 | * dccp_loss_free - Evaluates condition for data loss from RFC 4340, 7.7.1 | 156 | * dccp_loss_count - Approximate the number of lost data packets in a burst loss |
| 157 | * @s1: start sequence number | 157 | * @s1: last known sequence number before the loss ('hole') |
| 158 | * @s2: end sequence number | 158 | * @s2: first sequence number seen after the 'hole' |
| 159 | * @ndp: NDP count on packet with sequence number @s2 | 159 | * @ndp: NDP count on packet with sequence number @s2 |
| 160 | * Returns true if the sequence range s1...s2 has no data loss. | ||
| 161 | */ | 160 | */ |
| 162 | static inline bool dccp_loss_free(const u64 s1, const u64 s2, const u64 ndp) | 161 | static inline u64 dccp_loss_count(const u64 s1, const u64 s2, const u64 ndp) |
| 163 | { | 162 | { |
| 164 | s64 delta = dccp_delta_seqno(s1, s2); | 163 | s64 delta = dccp_delta_seqno(s1, s2); |
| 165 | 164 | ||
| 166 | WARN_ON(delta < 0); | 165 | WARN_ON(delta < 0); |
| 167 | return (u64)delta <= ndp + 1; | 166 | delta -= ndp + 1; |
| 167 | |||
| 168 | return delta > 0 ? delta : 0; | ||
| 169 | } | ||
| 170 | |||
| 171 | /** | ||
| 172 | * dccp_loss_free - Evaluate condition for data loss from RFC 4340, 7.7.1 | ||
| 173 | */ | ||
| 174 | static inline bool dccp_loss_free(const u64 s1, const u64 s2, const u64 ndp) | ||
| 175 | { | ||
| 176 | return dccp_loss_count(s1, s2, ndp) == 0; | ||
| 168 | } | 177 | } |
| 169 | 178 | ||
| 170 | enum { | 179 | enum { |
| @@ -414,6 +423,23 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq) | |||
| 414 | dp->dccps_gsr = seq; | 423 | dp->dccps_gsr = seq; |
| 415 | /* Sequence validity window depends on remote Sequence Window (7.5.1) */ | 424 | /* Sequence validity window depends on remote Sequence Window (7.5.1) */ |
| 416 | dp->dccps_swl = SUB48(ADD48(dp->dccps_gsr, 1), dp->dccps_r_seq_win / 4); | 425 | dp->dccps_swl = SUB48(ADD48(dp->dccps_gsr, 1), dp->dccps_r_seq_win / 4); |
| 426 | /* | ||
| 427 | * Adjust SWL so that it is not below ISR. In contrast to RFC 4340, | ||
| 428 | * 7.5.1 we perform this check beyond the initial handshake: W/W' are | ||
| 429 | * always > 32, so for the first W/W' packets in the lifetime of a | ||
| 430 | * connection we always have to adjust SWL. | ||
| 431 | * A second reason why we are doing this is that the window depends on | ||
| 432 | * the feature-remote value of Sequence Window: nothing stops the peer | ||
| 433 | * from updating this value while we are busy adjusting SWL for the | ||
| 434 | * first W packets (we would have to count from scratch again then). | ||
| 435 | * Therefore it is safer to always make sure that the Sequence Window | ||
| 436 | * is not artificially extended by a peer who grows SWL downwards by | ||
| 437 | * continually updating the feature-remote Sequence-Window. | ||
| 438 | * If sequence numbers wrap it is bad luck. But that will take a while | ||
| 439 | * (48 bit), and this measure prevents Sequence-number attacks. | ||
| 440 | */ | ||
| 441 | if (before48(dp->dccps_swl, dp->dccps_isr)) | ||
| 442 | dp->dccps_swl = dp->dccps_isr; | ||
| 417 | dp->dccps_swh = ADD48(dp->dccps_gsr, (3 * dp->dccps_r_seq_win) / 4); | 443 | dp->dccps_swh = ADD48(dp->dccps_gsr, (3 * dp->dccps_r_seq_win) / 4); |
| 418 | } | 444 | } |
| 419 | 445 | ||
| @@ -424,14 +450,16 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq) | |||
| 424 | dp->dccps_gss = seq; | 450 | dp->dccps_gss = seq; |
| 425 | /* Ack validity window depends on local Sequence Window value (7.5.1) */ | 451 | /* Ack validity window depends on local Sequence Window value (7.5.1) */ |
| 426 | dp->dccps_awl = SUB48(ADD48(dp->dccps_gss, 1), dp->dccps_l_seq_win); | 452 | dp->dccps_awl = SUB48(ADD48(dp->dccps_gss, 1), dp->dccps_l_seq_win); |
| 453 | /* Adjust AWL so that it is not below ISS - see comment above for SWL */ | ||
| 454 | if (before48(dp->dccps_awl, dp->dccps_iss)) | ||
| 455 | dp->dccps_awl = dp->dccps_iss; | ||
| 427 | dp->dccps_awh = dp->dccps_gss; | 456 | dp->dccps_awh = dp->dccps_gss; |
| 428 | } | 457 | } |
| 429 | 458 | ||
| 430 | static inline int dccp_ack_pending(const struct sock *sk) | 459 | static inline int dccp_ack_pending(const struct sock *sk) |
| 431 | { | 460 | { |
| 432 | const struct dccp_sock *dp = dccp_sk(sk); | 461 | const struct dccp_sock *dp = dccp_sk(sk); |
| 433 | return dp->dccps_timestamp_echo != 0 || | 462 | return (dp->dccps_hc_rx_ackvec != NULL && |
| 434 | (dp->dccps_hc_rx_ackvec != NULL && | ||
| 435 | dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) || | 463 | dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) || |
| 436 | inet_csk_ack_scheduled(sk); | 464 | inet_csk_ack_scheduled(sk); |
| 437 | } | 465 | } |
