Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dccp: support for the exchange of NN options in established state 1/2

In contrast to static feature negotiation at the begin of a connection, this
patch introduces support for exchange of dynamically changing options.

Such an update/exchange is necessary in at least two cases:
* CCID-2's Ack Ratio (RFC 4341, 6.1.2) which changes during the connection;
* Sequence Window values that, as per RFC 4340, 7.5.2, should be sent "as
the connection progresses".

Both are non-negotiable (NN) features, which means that no new capabilities
are negotiated, but rather that changes in known parameters are brought
up-to-date at either end.

Thse characteristics are reflected by the implementation:
* only NN options can be exchanged after connection setup;
* an ack is scheduled directly after activation to speed up the update;
* CCIDs may request changes to an NN feature even if a negotiation for that
feature is already underway: this is required by CCID-2, where changes in
cwnd necessitate Ack Ratio changes, such that the previous Ack Ratio (which
is still being negotiated) would cause irrecoverable RTO timeouts (thanks
to work by Samuel Jero).

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Samuel Jero <sj323707@ohio.edu>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.uk>

+67
+1
net/dccp/dccp.h
··· 474 474 return dccp_ackvec_pending(sk) || inet_csk_ack_scheduled(sk); 475 475 } 476 476 477 + extern int dccp_feat_signal_nn_change(struct sock *sk, u8 feat, u64 nn_val); 477 478 extern int dccp_feat_finalise_settings(struct dccp_sock *dp); 478 479 extern int dccp_feat_server_ccid_dependencies(struct dccp_request_sock *dreq); 479 480 extern int dccp_feat_insert_opts(struct dccp_sock*, struct dccp_request_sock*,
+65
net/dccp/feat.c
··· 12 12 * ----------- 13 13 * o Feature negotiation is coordinated with connection setup (as in TCP), wild 14 14 * changes of parameters of an established connection are not supported. 15 + * o Changing non-negotiable (NN) values is supported in state OPEN/PARTOPEN. 15 16 * o All currently known SP features have 1-byte quantities. If in the future 16 17 * extensions of RFCs 4340..42 define features with item lengths larger than 17 18 * one byte, a feature-specific extension of the code will be required. ··· 731 730 0, list, len); 732 731 } 733 732 733 + /** 734 + * dccp_feat_nn_get - Query current/pending value of NN feature 735 + * @sk: DCCP socket of an established connection 736 + * @feat: NN feature number from %dccp_feature_numbers 737 + * For a known NN feature, returns value currently being negotiated, or 738 + * current (confirmed) value if no negotiation is going on. 739 + */ 740 + u64 dccp_feat_nn_get(struct sock *sk, u8 feat) 741 + { 742 + if (dccp_feat_type(feat) == FEAT_NN) { 743 + struct dccp_sock *dp = dccp_sk(sk); 744 + struct dccp_feat_entry *entry; 745 + 746 + entry = dccp_feat_list_lookup(&dp->dccps_featneg, feat, 1); 747 + if (entry != NULL) 748 + return entry->val.nn; 749 + 750 + switch (feat) { 751 + case DCCPF_ACK_RATIO: 752 + return dp->dccps_l_ack_ratio; 753 + case DCCPF_SEQUENCE_WINDOW: 754 + return dp->dccps_l_seq_win; 755 + } 756 + } 757 + DCCP_BUG("attempt to look up unsupported feature %u", feat); 758 + return 0; 759 + } 760 + EXPORT_SYMBOL_GPL(dccp_feat_nn_get); 761 + 762 + /** 763 + * dccp_feat_signal_nn_change - Update NN values for an established connection 764 + * @sk: DCCP socket of an established connection 765 + * @feat: NN feature number from %dccp_feature_numbers 766 + * @nn_val: the new value to use 767 + * This function is used to communicate NN updates out-of-band. 768 + */ 769 + int dccp_feat_signal_nn_change(struct sock *sk, u8 feat, u64 nn_val) 770 + { 771 + struct list_head *fn = &dccp_sk(sk)->dccps_featneg; 772 + dccp_feat_val fval = { .nn = nn_val }; 773 + struct dccp_feat_entry *entry; 774 + 775 + if (sk->sk_state != DCCP_OPEN && sk->sk_state != DCCP_PARTOPEN) 776 + return 0; 777 + 778 + if (dccp_feat_type(feat) != FEAT_NN || 779 + !dccp_feat_is_valid_nn_val(feat, nn_val)) 780 + return -EINVAL; 781 + 782 + if (nn_val == dccp_feat_nn_get(sk, feat)) 783 + return 0; /* already set or negotiation under way */ 784 + 785 + entry = dccp_feat_list_lookup(fn, feat, 1); 786 + if (entry != NULL) { 787 + dccp_pr_debug("Clobbering existing NN entry %llu -> %llu\n", 788 + (unsigned long long)entry->val.nn, 789 + (unsigned long long)nn_val); 790 + dccp_feat_list_pop(entry); 791 + } 792 + 793 + inet_csk_schedule_ack(sk); 794 + return dccp_feat_push_change(fn, feat, 1, 0, &fval); 795 + } 796 + EXPORT_SYMBOL_GPL(dccp_feat_signal_nn_change); 734 797 735 798 /* 736 799 * Tracking features whose value depend on the choice of CCID
+1
net/dccp/feat.h
··· 129 129 130 130 extern void dccp_encode_value_var(const u64 value, u8 *to, const u8 len); 131 131 extern u64 dccp_decode_value_var(const u8 *bf, const u8 len); 132 + extern u64 dccp_feat_nn_get(struct sock *sk, u8 feat); 132 133 133 134 extern int dccp_insert_option_mandatory(struct sk_buff *skb); 134 135 extern int dccp_insert_fn_opt(struct sk_buff *skb, u8 type, u8 feat,