dccp ccid-2: use new interface to refactor dynamic negotiation Using the new function dccp_feat_get_nn_next_val(), this simplifies existing code to not trigger a new negotiation if the requested new value equals the old one. --- net/dccp/ccids/ccid2.c | 22 +++++----------------- net/dccp/feat.c | 5 +++-- 2 files changed, 8 insertions(+), 19 deletions(-) --- a/net/dccp/feat.c +++ b/net/dccp/feat.c @@ -815,10 +815,11 @@ int dccp_feat_signal_nn_change(struct so !dccp_feat_is_valid_nn_val(feat, nn_val)) return -EINVAL; + if (nn_val == dccp_feat_get_nn_next_val(sk, feat)) + return 0; /* already set or negotiation under way */ + entry = dccp_feat_list_lookup(fn, feat, 1); if (entry != NULL) { - if (entry->val.nn == fval.nn) - return 0; dccp_pr_debug("Clobbering existing NN entry %llu -> %llu\n", (unsigned long long)entry->val.nn, (unsigned long long)nn_val); --- a/net/dccp/ccids/ccid2.c +++ b/net/dccp/ccids/ccid2.c @@ -102,27 +102,15 @@ static void ccid2_change_l_ack_ratio(str DCCP_WARN("Limiting Ack Ratio (%u) to %u\n", val, max_ratio); val = max_ratio; } - if (val > DCCPF_ACK_RATIO_MAX) - val = DCCPF_ACK_RATIO_MAX; - - if (val == ccid2_ack_ratio_next(sk)) - return; - - ccid2_pr_debug("changing local ack ratio to %u\n", val); - dccp_feat_signal_nn_change(sk, DCCPF_ACK_RATIO, val); + dccp_feat_signal_nn_change(sk, DCCPF_ACK_RATIO, + min_t(u32, val, DCCPF_ACK_RATIO_MAX)); } static void ccid2_change_l_seq_window(struct sock *sk, u64 val) { - struct dccp_sock *dp = dccp_sk(sk); - - if (val < DCCPF_SEQ_WMIN) - val = DCCPF_SEQ_WMIN; - if (val > DCCPF_SEQ_WMAX) - val = DCCPF_SEQ_WMAX; - - if (val != dp->dccps_l_seq_win) - dccp_feat_signal_nn_change(sk, DCCPF_SEQUENCE_WINDOW, val); + dccp_feat_signal_nn_change(sk, DCCPF_SEQUENCE_WINDOW, + clamp_val(val, DCCPF_SEQ_WMIN, + DCCPF_SEQ_WMAX)); } static void ccid2_hc_tx_rto_expire(unsigned long data)