feat.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  1. /*
  2. * net/dccp/feat.c
  3. *
  4. * An implementation of the DCCP protocol
  5. * Andrea Bittau <a.bittau@cs.ucl.ac.uk>
  6. *
  7. * ASSUMPTIONS
  8. * -----------
  9. * o Feature negotiation is coordinated with connection setup (as in TCP), wild
  10. * changes of parameters of an established connection are not supported.
  11. * o All currently known SP features have 1-byte quantities. If in the future
  12. * extensions of RFCs 4340..42 define features with item lengths larger than
  13. * one byte, a feature-specific extension of the code will be required.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version
  18. * 2 of the License, or (at your option) any later version.
  19. */
  20. #include <linux/module.h>
  21. #include "ccid.h"
  22. #include "feat.h"
  23. #define DCCP_FEAT_SP_NOAGREE (-123)
  24. static const struct {
  25. u8 feat_num; /* DCCPF_xxx */
  26. enum dccp_feat_type rxtx; /* RX or TX */
  27. enum dccp_feat_type reconciliation; /* SP or NN */
  28. u8 default_value; /* as in 6.4 */
  29. /*
  30. * Lookup table for location and type of features (from RFC 4340/4342)
  31. * +--------------------------+----+-----+----+----+---------+-----------+
  32. * | Feature | Location | Reconc. | Initial | Section |
  33. * | | RX | TX | SP | NN | Value | Reference |
  34. * +--------------------------+----+-----+----+----+---------+-----------+
  35. * | DCCPF_CCID | | X | X | | 2 | 10 |
  36. * | DCCPF_SHORT_SEQNOS | | X | X | | 0 | 7.6.1 |
  37. * | DCCPF_SEQUENCE_WINDOW | | X | | X | 100 | 7.5.2 |
  38. * | DCCPF_ECN_INCAPABLE | X | | X | | 0 | 12.1 |
  39. * | DCCPF_ACK_RATIO | | X | | X | 2 | 11.3 |
  40. * | DCCPF_SEND_ACK_VECTOR | X | | X | | 0 | 11.5 |
  41. * | DCCPF_SEND_NDP_COUNT | | X | X | | 0 | 7.7.2 |
  42. * | DCCPF_MIN_CSUM_COVER | X | | X | | 0 | 9.2.1 |
  43. * | DCCPF_DATA_CHECKSUM | X | | X | | 0 | 9.3.1 |
  44. * | DCCPF_SEND_LEV_RATE | X | | X | | 0 | 4342/8.4 |
  45. * +--------------------------+----+-----+----+----+---------+-----------+
  46. */
  47. } dccp_feat_table[] = {
  48. { DCCPF_CCID, FEAT_AT_TX, FEAT_SP, 2 },
  49. { DCCPF_SHORT_SEQNOS, FEAT_AT_TX, FEAT_SP, 0 },
  50. { DCCPF_SEQUENCE_WINDOW, FEAT_AT_TX, FEAT_NN, 100 },
  51. { DCCPF_ECN_INCAPABLE, FEAT_AT_RX, FEAT_SP, 0 },
  52. { DCCPF_ACK_RATIO, FEAT_AT_TX, FEAT_NN, 2 },
  53. { DCCPF_SEND_ACK_VECTOR, FEAT_AT_RX, FEAT_SP, 0 },
  54. { DCCPF_SEND_NDP_COUNT, FEAT_AT_TX, FEAT_SP, 0 },
  55. { DCCPF_MIN_CSUM_COVER, FEAT_AT_RX, FEAT_SP, 0 },
  56. { DCCPF_DATA_CHECKSUM, FEAT_AT_RX, FEAT_SP, 0 },
  57. { DCCPF_SEND_LEV_RATE, FEAT_AT_RX, FEAT_SP, 0 },
  58. };
  59. #define DCCP_FEAT_SUPPORTED_MAX ARRAY_SIZE(dccp_feat_table)
  60. /**
  61. * dccp_feat_index - Hash function to map feature number into array position
  62. * Returns consecutive array index or -1 if the feature is not understood.
  63. */
  64. static int dccp_feat_index(u8 feat_num)
  65. {
  66. /* The first 9 entries are occupied by the types from RFC 4340, 6.4 */
  67. if (feat_num > DCCPF_RESERVED && feat_num <= DCCPF_DATA_CHECKSUM)
  68. return feat_num - 1;
  69. /*
  70. * Other features: add cases for new feature types here after adding
  71. * them to the above table.
  72. */
  73. switch (feat_num) {
  74. case DCCPF_SEND_LEV_RATE:
  75. return DCCP_FEAT_SUPPORTED_MAX - 1;
  76. }
  77. return -1;
  78. }
  79. static u8 dccp_feat_type(u8 feat_num)
  80. {
  81. int idx = dccp_feat_index(feat_num);
  82. if (idx < 0)
  83. return FEAT_UNKNOWN;
  84. return dccp_feat_table[idx].reconciliation;
  85. }
  86. static int dccp_feat_default_value(u8 feat_num)
  87. {
  88. int idx = dccp_feat_index(feat_num);
  89. /*
  90. * There are no default values for unknown features, so encountering a
  91. * negative index here indicates a serious problem somewhere else.
  92. */
  93. DCCP_BUG_ON(idx < 0);
  94. return idx < 0 ? 0 : dccp_feat_table[idx].default_value;
  95. }
  96. /* copy constructor, fval must not already contain allocated memory */
  97. static int dccp_feat_clone_sp_val(dccp_feat_val *fval, u8 const *val, u8 len)
  98. {
  99. fval->sp.len = len;
  100. if (fval->sp.len > 0) {
  101. fval->sp.vec = kmemdup(val, len, gfp_any());
  102. if (fval->sp.vec == NULL) {
  103. fval->sp.len = 0;
  104. return -ENOBUFS;
  105. }
  106. }
  107. return 0;
  108. }
  109. static void dccp_feat_val_destructor(u8 feat_num, dccp_feat_val *val)
  110. {
  111. if (unlikely(val == NULL))
  112. return;
  113. if (dccp_feat_type(feat_num) == FEAT_SP)
  114. kfree(val->sp.vec);
  115. memset(val, 0, sizeof(*val));
  116. }
  117. static struct dccp_feat_entry *
  118. dccp_feat_clone_entry(struct dccp_feat_entry const *original)
  119. {
  120. struct dccp_feat_entry *new;
  121. u8 type = dccp_feat_type(original->feat_num);
  122. if (type == FEAT_UNKNOWN)
  123. return NULL;
  124. new = kmemdup(original, sizeof(struct dccp_feat_entry), gfp_any());
  125. if (new == NULL)
  126. return NULL;
  127. if (type == FEAT_SP && dccp_feat_clone_sp_val(&new->val,
  128. original->val.sp.vec,
  129. original->val.sp.len)) {
  130. kfree(new);
  131. return NULL;
  132. }
  133. return new;
  134. }
  135. static void dccp_feat_entry_destructor(struct dccp_feat_entry *entry)
  136. {
  137. if (entry != NULL) {
  138. dccp_feat_val_destructor(entry->feat_num, &entry->val);
  139. kfree(entry);
  140. }
  141. }
  142. /*
  143. * List management functions
  144. *
  145. * Feature negotiation lists rely on and maintain the following invariants:
  146. * - each feat_num in the list is known, i.e. we know its type and default value
  147. * - each feat_num/is_local combination is unique (old entries are overwritten)
  148. * - SP values are always freshly allocated
  149. * - list is sorted in increasing order of feature number (faster lookup)
  150. */
  151. static struct dccp_feat_entry *dccp_feat_list_lookup(struct list_head *fn_list,
  152. u8 feat_num, bool is_local)
  153. {
  154. struct dccp_feat_entry *entry;
  155. list_for_each_entry(entry, fn_list, node) {
  156. if (entry->feat_num == feat_num && entry->is_local == is_local)
  157. return entry;
  158. else if (entry->feat_num > feat_num)
  159. break;
  160. }
  161. return NULL;
  162. }
  163. /**
  164. * dccp_feat_entry_new - Central list update routine (called by all others)
  165. * @head: list to add to
  166. * @feat: feature number
  167. * @local: whether the local (1) or remote feature with number @feat is meant
  168. * This is the only constructor and serves to ensure the above invariants.
  169. */
  170. static struct dccp_feat_entry *
  171. dccp_feat_entry_new(struct list_head *head, u8 feat, bool local)
  172. {
  173. struct dccp_feat_entry *entry;
  174. list_for_each_entry(entry, head, node)
  175. if (entry->feat_num == feat && entry->is_local == local) {
  176. dccp_feat_val_destructor(entry->feat_num, &entry->val);
  177. return entry;
  178. } else if (entry->feat_num > feat) {
  179. head = &entry->node;
  180. break;
  181. }
  182. entry = kmalloc(sizeof(*entry), gfp_any());
  183. if (entry != NULL) {
  184. entry->feat_num = feat;
  185. entry->is_local = local;
  186. list_add_tail(&entry->node, head);
  187. }
  188. return entry;
  189. }
  190. /**
  191. * dccp_feat_push_change - Add/overwrite a Change option in the list
  192. * @fn_list: feature-negotiation list to update
  193. * @feat: one of %dccp_feature_numbers
  194. * @local: whether local (1) or remote (0) @feat_num is meant
  195. * @needs_mandatory: whether to use Mandatory feature negotiation options
  196. * @fval: pointer to NN/SP value to be inserted (will be copied)
  197. */
  198. static int dccp_feat_push_change(struct list_head *fn_list, u8 feat, u8 local,
  199. u8 mandatory, dccp_feat_val *fval)
  200. {
  201. struct dccp_feat_entry *new = dccp_feat_entry_new(fn_list, feat, local);
  202. if (new == NULL)
  203. return -ENOMEM;
  204. new->feat_num = feat;
  205. new->is_local = local;
  206. new->state = FEAT_INITIALISING;
  207. new->needs_confirm = 0;
  208. new->empty_confirm = 0;
  209. new->val = *fval;
  210. new->needs_mandatory = mandatory;
  211. return 0;
  212. }
  213. static inline void dccp_feat_list_pop(struct dccp_feat_entry *entry)
  214. {
  215. list_del(&entry->node);
  216. dccp_feat_entry_destructor(entry);
  217. }
  218. void dccp_feat_list_purge(struct list_head *fn_list)
  219. {
  220. struct dccp_feat_entry *entry, *next;
  221. list_for_each_entry_safe(entry, next, fn_list, node)
  222. dccp_feat_entry_destructor(entry);
  223. INIT_LIST_HEAD(fn_list);
  224. }
  225. EXPORT_SYMBOL_GPL(dccp_feat_list_purge);
  226. /* generate @to as full clone of @from - @to must not contain any nodes */
  227. int dccp_feat_clone_list(struct list_head const *from, struct list_head *to)
  228. {
  229. struct dccp_feat_entry *entry, *new;
  230. INIT_LIST_HEAD(to);
  231. list_for_each_entry(entry, from, node) {
  232. new = dccp_feat_clone_entry(entry);
  233. if (new == NULL)
  234. goto cloning_failed;
  235. list_add_tail(&new->node, to);
  236. }
  237. return 0;
  238. cloning_failed:
  239. dccp_feat_list_purge(to);
  240. return -ENOMEM;
  241. }
  242. /**
  243. * dccp_feat_valid_nn_length - Enforce length constraints on NN options
  244. * Length is between 0 and %DCCP_OPTVAL_MAXLEN. Used for outgoing packets only,
  245. * incoming options are accepted as long as their values are valid.
  246. */
  247. static u8 dccp_feat_valid_nn_length(u8 feat_num)
  248. {
  249. if (feat_num == DCCPF_ACK_RATIO) /* RFC 4340, 11.3 and 6.6.8 */
  250. return 2;
  251. if (feat_num == DCCPF_SEQUENCE_WINDOW) /* RFC 4340, 7.5.2 and 6.5 */
  252. return 6;
  253. return 0;
  254. }
  255. static u8 dccp_feat_is_valid_nn_val(u8 feat_num, u64 val)
  256. {
  257. switch (feat_num) {
  258. case DCCPF_ACK_RATIO:
  259. return val <= DCCPF_ACK_RATIO_MAX;
  260. case DCCPF_SEQUENCE_WINDOW:
  261. return val >= DCCPF_SEQ_WMIN && val <= DCCPF_SEQ_WMAX;
  262. }
  263. return 0; /* feature unknown - so we can't tell */
  264. }
  265. /* check that SP values are within the ranges defined in RFC 4340 */
  266. static u8 dccp_feat_is_valid_sp_val(u8 feat_num, u8 val)
  267. {
  268. switch (feat_num) {
  269. case DCCPF_CCID:
  270. return val == DCCPC_CCID2 || val == DCCPC_CCID3;
  271. /* Type-check Boolean feature values: */
  272. case DCCPF_SHORT_SEQNOS:
  273. case DCCPF_ECN_INCAPABLE:
  274. case DCCPF_SEND_ACK_VECTOR:
  275. case DCCPF_SEND_NDP_COUNT:
  276. case DCCPF_DATA_CHECKSUM:
  277. case DCCPF_SEND_LEV_RATE:
  278. return val < 2;
  279. case DCCPF_MIN_CSUM_COVER:
  280. return val < 16;
  281. }
  282. return 0; /* feature unknown */
  283. }
  284. static u8 dccp_feat_sp_list_ok(u8 feat_num, u8 const *sp_list, u8 sp_len)
  285. {
  286. if (sp_list == NULL || sp_len < 1)
  287. return 0;
  288. while (sp_len--)
  289. if (!dccp_feat_is_valid_sp_val(feat_num, *sp_list++))
  290. return 0;
  291. return 1;
  292. }
  293. /**
  294. * dccp_feat_insert_opts - Generate FN options from current list state
  295. * @skb: next sk_buff to be sent to the peer
  296. * @dp: for client during handshake and general negotiation
  297. * @dreq: used by the server only (all Changes/Confirms in LISTEN/RESPOND)
  298. */
  299. int dccp_feat_insert_opts(struct dccp_sock *dp, struct dccp_request_sock *dreq,
  300. struct sk_buff *skb)
  301. {
  302. struct list_head *fn = dreq ? &dreq->dreq_featneg : &dp->dccps_featneg;
  303. struct dccp_feat_entry *pos, *next;
  304. u8 opt, type, len, *ptr, nn_in_nbo[DCCP_OPTVAL_MAXLEN];
  305. bool rpt;
  306. /* put entries into @skb in the order they appear in the list */
  307. list_for_each_entry_safe_reverse(pos, next, fn, node) {
  308. opt = dccp_feat_genopt(pos);
  309. type = dccp_feat_type(pos->feat_num);
  310. rpt = false;
  311. if (pos->empty_confirm) {
  312. len = 0;
  313. ptr = NULL;
  314. } else {
  315. if (type == FEAT_SP) {
  316. len = pos->val.sp.len;
  317. ptr = pos->val.sp.vec;
  318. rpt = pos->needs_confirm;
  319. } else if (type == FEAT_NN) {
  320. len = dccp_feat_valid_nn_length(pos->feat_num);
  321. ptr = nn_in_nbo;
  322. dccp_encode_value_var(pos->val.nn, ptr, len);
  323. } else {
  324. DCCP_BUG("unknown feature %u", pos->feat_num);
  325. return -1;
  326. }
  327. }
  328. if (dccp_insert_fn_opt(skb, opt, pos->feat_num, ptr, len, rpt))
  329. return -1;
  330. if (pos->needs_mandatory && dccp_insert_option_mandatory(skb))
  331. return -1;
  332. /*
  333. * Enter CHANGING after transmitting the Change option (6.6.2).
  334. */
  335. if (pos->state == FEAT_INITIALISING)
  336. pos->state = FEAT_CHANGING;
  337. }
  338. return 0;
  339. }
  340. /**
  341. * __feat_register_nn - Register new NN value on socket
  342. * @fn: feature-negotiation list to register with
  343. * @feat: an NN feature from %dccp_feature_numbers
  344. * @mandatory: use Mandatory option if 1
  345. * @nn_val: value to register (restricted to 4 bytes)
  346. * Note that NN features are local by definition (RFC 4340, 6.3.2).
  347. */
  348. static int __feat_register_nn(struct list_head *fn, u8 feat,
  349. u8 mandatory, u64 nn_val)
  350. {
  351. dccp_feat_val fval = { .nn = nn_val };
  352. if (dccp_feat_type(feat) != FEAT_NN ||
  353. !dccp_feat_is_valid_nn_val(feat, nn_val))
  354. return -EINVAL;
  355. /* Don't bother with default values, they will be activated anyway. */
  356. if (nn_val - (u64)dccp_feat_default_value(feat) == 0)
  357. return 0;
  358. return dccp_feat_push_change(fn, feat, 1, mandatory, &fval);
  359. }
  360. /**
  361. * __feat_register_sp - Register new SP value/list on socket
  362. * @fn: feature-negotiation list to register with
  363. * @feat: an SP feature from %dccp_feature_numbers
  364. * @is_local: whether the local (1) or the remote (0) @feat is meant
  365. * @mandatory: use Mandatory option if 1
  366. * @sp_val: SP value followed by optional preference list
  367. * @sp_len: length of @sp_val in bytes
  368. */
  369. static int __feat_register_sp(struct list_head *fn, u8 feat, u8 is_local,
  370. u8 mandatory, u8 const *sp_val, u8 sp_len)
  371. {
  372. dccp_feat_val fval;
  373. if (dccp_feat_type(feat) != FEAT_SP ||
  374. !dccp_feat_sp_list_ok(feat, sp_val, sp_len))
  375. return -EINVAL;
  376. /* Avoid negotiating alien CCIDs by only advertising supported ones */
  377. if (feat == DCCPF_CCID && !ccid_support_check(sp_val, sp_len))
  378. return -EOPNOTSUPP;
  379. if (dccp_feat_clone_sp_val(&fval, sp_val, sp_len))
  380. return -ENOMEM;
  381. return dccp_feat_push_change(fn, feat, is_local, mandatory, &fval);
  382. }
  383. /**
  384. * dccp_feat_register_sp - Register requests to change SP feature values
  385. * @sk: client or listening socket
  386. * @feat: one of %dccp_feature_numbers
  387. * @is_local: whether the local (1) or remote (0) @feat is meant
  388. * @list: array of preferred values, in descending order of preference
  389. * @len: length of @list in bytes
  390. */
  391. int dccp_feat_register_sp(struct sock *sk, u8 feat, u8 is_local,
  392. u8 const *list, u8 len)
  393. { /* any changes must be registered before establishing the connection */
  394. if (sk->sk_state != DCCP_CLOSED)
  395. return -EISCONN;
  396. if (dccp_feat_type(feat) != FEAT_SP)
  397. return -EINVAL;
  398. return __feat_register_sp(&dccp_sk(sk)->dccps_featneg, feat, is_local,
  399. 0, list, len);
  400. }
  401. /* Analogous to dccp_feat_register_sp(), but for non-negotiable values */
  402. int dccp_feat_register_nn(struct sock *sk, u8 feat, u64 val)
  403. {
  404. /* any changes must be registered before establishing the connection */
  405. if (sk->sk_state != DCCP_CLOSED)
  406. return -EISCONN;
  407. if (dccp_feat_type(feat) != FEAT_NN)
  408. return -EINVAL;
  409. return __feat_register_nn(&dccp_sk(sk)->dccps_featneg, feat, 0, val);
  410. }
  411. /*
  412. * Tracking features whose value depend on the choice of CCID
  413. *
  414. * This is designed with an extension in mind so that a list walk could be done
  415. * before activating any features. However, the existing framework was found to
  416. * work satisfactorily up until now, the automatic verification is left open.
  417. * When adding new CCIDs, add a corresponding dependency table here.
  418. */
  419. static const struct ccid_dependency *dccp_feat_ccid_deps(u8 ccid, bool is_local)
  420. {
  421. static const struct ccid_dependency ccid2_dependencies[2][2] = {
  422. /*
  423. * CCID2 mandates Ack Vectors (RFC 4341, 4.): as CCID is a TX
  424. * feature and Send Ack Vector is an RX feature, `is_local'
  425. * needs to be reversed.
  426. */
  427. { /* Dependencies of the receiver-side (remote) CCID2 */
  428. {
  429. .dependent_feat = DCCPF_SEND_ACK_VECTOR,
  430. .is_local = true,
  431. .is_mandatory = true,
  432. .val = 1
  433. },
  434. { 0, 0, 0, 0 }
  435. },
  436. { /* Dependencies of the sender-side (local) CCID2 */
  437. {
  438. .dependent_feat = DCCPF_SEND_ACK_VECTOR,
  439. .is_local = false,
  440. .is_mandatory = true,
  441. .val = 1
  442. },
  443. { 0, 0, 0, 0 }
  444. }
  445. };
  446. static const struct ccid_dependency ccid3_dependencies[2][5] = {
  447. { /*
  448. * Dependencies of the receiver-side CCID3
  449. */
  450. { /* locally disable Ack Vectors */
  451. .dependent_feat = DCCPF_SEND_ACK_VECTOR,
  452. .is_local = true,
  453. .is_mandatory = false,
  454. .val = 0
  455. },
  456. { /* see below why Send Loss Event Rate is on */
  457. .dependent_feat = DCCPF_SEND_LEV_RATE,
  458. .is_local = true,
  459. .is_mandatory = true,
  460. .val = 1
  461. },
  462. { /* NDP Count is needed as per RFC 4342, 6.1.1 */
  463. .dependent_feat = DCCPF_SEND_NDP_COUNT,
  464. .is_local = false,
  465. .is_mandatory = true,
  466. .val = 1
  467. },
  468. { 0, 0, 0, 0 },
  469. },
  470. { /*
  471. * CCID3 at the TX side: we request that the HC-receiver
  472. * will not send Ack Vectors (they will be ignored, so
  473. * Mandatory is not set); we enable Send Loss Event Rate
  474. * (Mandatory since the implementation does not support
  475. * the Loss Intervals option of RFC 4342, 8.6).
  476. * The last two options are for peer's information only.
  477. */
  478. {
  479. .dependent_feat = DCCPF_SEND_ACK_VECTOR,
  480. .is_local = false,
  481. .is_mandatory = false,
  482. .val = 0
  483. },
  484. {
  485. .dependent_feat = DCCPF_SEND_LEV_RATE,
  486. .is_local = false,
  487. .is_mandatory = true,
  488. .val = 1
  489. },
  490. { /* this CCID does not support Ack Ratio */
  491. .dependent_feat = DCCPF_ACK_RATIO,
  492. .is_local = true,
  493. .is_mandatory = false,
  494. .val = 0
  495. },
  496. { /* tell receiver we are sending NDP counts */
  497. .dependent_feat = DCCPF_SEND_NDP_COUNT,
  498. .is_local = true,
  499. .is_mandatory = false,
  500. .val = 1
  501. },
  502. { 0, 0, 0, 0 }
  503. }
  504. };
  505. switch (ccid) {
  506. case DCCPC_CCID2:
  507. return ccid2_dependencies[is_local];
  508. case DCCPC_CCID3:
  509. return ccid3_dependencies[is_local];
  510. default:
  511. return NULL;
  512. }
  513. }
  514. /**
  515. * dccp_feat_propagate_ccid - Resolve dependencies of features on choice of CCID
  516. * @fn: feature-negotiation list to update
  517. * @id: CCID number to track
  518. * @is_local: whether TX CCID (1) or RX CCID (0) is meant
  519. * This function needs to be called after registering all other features.
  520. */
  521. static int dccp_feat_propagate_ccid(struct list_head *fn, u8 id, bool is_local)
  522. {
  523. const struct ccid_dependency *table = dccp_feat_ccid_deps(id, is_local);
  524. int i, rc = (table == NULL);
  525. for (i = 0; rc == 0 && table[i].dependent_feat != DCCPF_RESERVED; i++)
  526. if (dccp_feat_type(table[i].dependent_feat) == FEAT_SP)
  527. rc = __feat_register_sp(fn, table[i].dependent_feat,
  528. table[i].is_local,
  529. table[i].is_mandatory,
  530. &table[i].val, 1);
  531. else
  532. rc = __feat_register_nn(fn, table[i].dependent_feat,
  533. table[i].is_mandatory,
  534. table[i].val);
  535. return rc;
  536. }
  537. /**
  538. * dccp_feat_finalise_settings - Finalise settings before starting negotiation
  539. * @dp: client or listening socket (settings will be inherited)
  540. * This is called after all registrations (socket initialisation, sysctls, and
  541. * sockopt calls), and before sending the first packet containing Change options
  542. * (ie. client-Request or server-Response), to ensure internal consistency.
  543. */
  544. int dccp_feat_finalise_settings(struct dccp_sock *dp)
  545. {
  546. struct list_head *fn = &dp->dccps_featneg;
  547. struct dccp_feat_entry *entry;
  548. int i = 2, ccids[2] = { -1, -1 };
  549. /*
  550. * Propagating CCIDs:
  551. * 1) not useful to propagate CCID settings if this host advertises more
  552. * than one CCID: the choice of CCID may still change - if this is
  553. * the client, or if this is the server and the client sends
  554. * singleton CCID values.
  555. * 2) since is that propagate_ccid changes the list, we defer changing
  556. * the sorted list until after the traversal.
  557. */
  558. list_for_each_entry(entry, fn, node)
  559. if (entry->feat_num == DCCPF_CCID && entry->val.sp.len == 1)
  560. ccids[entry->is_local] = entry->val.sp.vec[0];
  561. while (i--)
  562. if (ccids[i] > 0 && dccp_feat_propagate_ccid(fn, ccids[i], i))
  563. return -1;
  564. return 0;
  565. }
  566. /**
  567. * dccp_feat_server_ccid_dependencies - Resolve CCID-dependent features
  568. * It is the server which resolves the dependencies once the CCID has been
  569. * fully negotiated. If no CCID has been negotiated, it uses the default CCID.
  570. */
  571. int dccp_feat_server_ccid_dependencies(struct dccp_request_sock *dreq)
  572. {
  573. struct list_head *fn = &dreq->dreq_featneg;
  574. struct dccp_feat_entry *entry;
  575. u8 is_local, ccid;
  576. for (is_local = 0; is_local <= 1; is_local++) {
  577. entry = dccp_feat_list_lookup(fn, DCCPF_CCID, is_local);
  578. if (entry != NULL && !entry->empty_confirm)
  579. ccid = entry->val.sp.vec[0];
  580. else
  581. ccid = dccp_feat_default_value(DCCPF_CCID);
  582. if (dccp_feat_propagate_ccid(fn, ccid, is_local))
  583. return -1;
  584. }
  585. return 0;
  586. }
  587. static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr)
  588. {
  589. struct dccp_sock *dp = dccp_sk(sk);
  590. struct dccp_minisock *dmsk = dccp_msk(sk);
  591. /* figure out if we are changing our CCID or the peer's */
  592. const int rx = type == DCCPO_CHANGE_R;
  593. const u8 ccid_nr = rx ? dmsk->dccpms_rx_ccid : dmsk->dccpms_tx_ccid;
  594. struct ccid *new_ccid;
  595. /* Check if nothing is being changed. */
  596. if (ccid_nr == new_ccid_nr)
  597. return 0;
  598. new_ccid = ccid_new(new_ccid_nr, sk, rx, GFP_ATOMIC);
  599. if (new_ccid == NULL)
  600. return -ENOMEM;
  601. if (rx) {
  602. ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
  603. dp->dccps_hc_rx_ccid = new_ccid;
  604. dmsk->dccpms_rx_ccid = new_ccid_nr;
  605. } else {
  606. ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
  607. dp->dccps_hc_tx_ccid = new_ccid;
  608. dmsk->dccpms_tx_ccid = new_ccid_nr;
  609. }
  610. return 0;
  611. }
  612. static int dccp_feat_update(struct sock *sk, u8 type, u8 feat, u8 val)
  613. {
  614. dccp_feat_debug(type, feat, val);
  615. switch (feat) {
  616. case DCCPF_CCID:
  617. return dccp_feat_update_ccid(sk, type, val);
  618. default:
  619. dccp_pr_debug("UNIMPLEMENTED: %s(%d, ...)\n",
  620. dccp_feat_typename(type), feat);
  621. break;
  622. }
  623. return 0;
  624. }
  625. static int dccp_feat_reconcile(struct sock *sk, struct dccp_opt_pend *opt,
  626. u8 *rpref, u8 rlen)
  627. {
  628. struct dccp_sock *dp = dccp_sk(sk);
  629. u8 *spref, slen, *res = NULL;
  630. int i, j, rc, agree = 1;
  631. BUG_ON(rpref == NULL);
  632. /* check if we are the black sheep */
  633. if (dp->dccps_role == DCCP_ROLE_CLIENT) {
  634. spref = rpref;
  635. slen = rlen;
  636. rpref = opt->dccpop_val;
  637. rlen = opt->dccpop_len;
  638. } else {
  639. spref = opt->dccpop_val;
  640. slen = opt->dccpop_len;
  641. }
  642. /*
  643. * Now we have server preference list in spref and client preference in
  644. * rpref
  645. */
  646. BUG_ON(spref == NULL);
  647. BUG_ON(rpref == NULL);
  648. /* FIXME sanity check vals */
  649. /* Are values in any order? XXX Lame "algorithm" here */
  650. for (i = 0; i < slen; i++) {
  651. for (j = 0; j < rlen; j++) {
  652. if (spref[i] == rpref[j]) {
  653. res = &spref[i];
  654. break;
  655. }
  656. }
  657. if (res)
  658. break;
  659. }
  660. /* we didn't agree on anything */
  661. if (res == NULL) {
  662. /* confirm previous value */
  663. switch (opt->dccpop_feat) {
  664. case DCCPF_CCID:
  665. /* XXX did i get this right? =P */
  666. if (opt->dccpop_type == DCCPO_CHANGE_L)
  667. res = &dccp_msk(sk)->dccpms_tx_ccid;
  668. else
  669. res = &dccp_msk(sk)->dccpms_rx_ccid;
  670. break;
  671. default:
  672. DCCP_BUG("Fell through, feat=%d", opt->dccpop_feat);
  673. /* XXX implement res */
  674. return -EFAULT;
  675. }
  676. dccp_pr_debug("Don't agree... reconfirming %d\n", *res);
  677. agree = 0; /* this is used for mandatory options... */
  678. }
  679. /* need to put result and our preference list */
  680. rlen = 1 + opt->dccpop_len;
  681. rpref = kmalloc(rlen, GFP_ATOMIC);
  682. if (rpref == NULL)
  683. return -ENOMEM;
  684. *rpref = *res;
  685. memcpy(&rpref[1], opt->dccpop_val, opt->dccpop_len);
  686. /* put it in the "confirm queue" */
  687. if (opt->dccpop_sc == NULL) {
  688. opt->dccpop_sc = kmalloc(sizeof(*opt->dccpop_sc), GFP_ATOMIC);
  689. if (opt->dccpop_sc == NULL) {
  690. kfree(rpref);
  691. return -ENOMEM;
  692. }
  693. } else {
  694. /* recycle the confirm slot */
  695. BUG_ON(opt->dccpop_sc->dccpoc_val == NULL);
  696. kfree(opt->dccpop_sc->dccpoc_val);
  697. dccp_pr_debug("recycling confirm slot\n");
  698. }
  699. memset(opt->dccpop_sc, 0, sizeof(*opt->dccpop_sc));
  700. opt->dccpop_sc->dccpoc_val = rpref;
  701. opt->dccpop_sc->dccpoc_len = rlen;
  702. /* update the option on our side [we are about to send the confirm] */
  703. rc = dccp_feat_update(sk, opt->dccpop_type, opt->dccpop_feat, *res);
  704. if (rc) {
  705. kfree(opt->dccpop_sc->dccpoc_val);
  706. kfree(opt->dccpop_sc);
  707. opt->dccpop_sc = NULL;
  708. return rc;
  709. }
  710. dccp_pr_debug("Will confirm %d\n", *rpref);
  711. /* say we want to change to X but we just got a confirm X, suppress our
  712. * change
  713. */
  714. if (!opt->dccpop_conf) {
  715. if (*opt->dccpop_val == *res)
  716. opt->dccpop_conf = 1;
  717. dccp_pr_debug("won't ask for change of same feature\n");
  718. }
  719. return agree ? 0 : DCCP_FEAT_SP_NOAGREE; /* used for mandatory opts */
  720. }
  721. static int dccp_feat_sp(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
  722. {
  723. struct dccp_minisock *dmsk = dccp_msk(sk);
  724. struct dccp_opt_pend *opt;
  725. int rc = 1;
  726. u8 t;
  727. /*
  728. * We received a CHANGE. We gotta match it against our own preference
  729. * list. If we got a CHANGE_R it means it's a change for us, so we need
  730. * to compare our CHANGE_L list.
  731. */
  732. if (type == DCCPO_CHANGE_L)
  733. t = DCCPO_CHANGE_R;
  734. else
  735. t = DCCPO_CHANGE_L;
  736. /* find our preference list for this feature */
  737. list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
  738. if (opt->dccpop_type != t || opt->dccpop_feat != feature)
  739. continue;
  740. /* find the winner from the two preference lists */
  741. rc = dccp_feat_reconcile(sk, opt, val, len);
  742. break;
  743. }
  744. /* We didn't deal with the change. This can happen if we have no
  745. * preference list for the feature. In fact, it just shouldn't
  746. * happen---if we understand a feature, we should have a preference list
  747. * with at least the default value.
  748. */
  749. BUG_ON(rc == 1);
  750. return rc;
  751. }
  752. static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
  753. {
  754. struct dccp_opt_pend *opt;
  755. struct dccp_minisock *dmsk = dccp_msk(sk);
  756. u8 *copy;
  757. int rc;
  758. /* NN features must be Change L (sec. 6.3.2) */
  759. if (type != DCCPO_CHANGE_L) {
  760. dccp_pr_debug("received %s for NN feature %d\n",
  761. dccp_feat_typename(type), feature);
  762. return -EFAULT;
  763. }
  764. /* XXX sanity check opt val */
  765. /* copy option so we can confirm it */
  766. opt = kzalloc(sizeof(*opt), GFP_ATOMIC);
  767. if (opt == NULL)
  768. return -ENOMEM;
  769. copy = kmemdup(val, len, GFP_ATOMIC);
  770. if (copy == NULL) {
  771. kfree(opt);
  772. return -ENOMEM;
  773. }
  774. opt->dccpop_type = DCCPO_CONFIRM_R; /* NN can only confirm R */
  775. opt->dccpop_feat = feature;
  776. opt->dccpop_val = copy;
  777. opt->dccpop_len = len;
  778. /* change feature */
  779. rc = dccp_feat_update(sk, type, feature, *val);
  780. if (rc) {
  781. kfree(opt->dccpop_val);
  782. kfree(opt);
  783. return rc;
  784. }
  785. dccp_feat_debug(type, feature, *copy);
  786. list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf);
  787. return 0;
  788. }
  789. static void dccp_feat_empty_confirm(struct dccp_minisock *dmsk,
  790. u8 type, u8 feature)
  791. {
  792. /* XXX check if other confirms for that are queued and recycle slot */
  793. struct dccp_opt_pend *opt = kzalloc(sizeof(*opt), GFP_ATOMIC);
  794. if (opt == NULL) {
  795. /* XXX what do we do? Ignoring should be fine. It's a change
  796. * after all =P
  797. */
  798. return;
  799. }
  800. switch (type) {
  801. case DCCPO_CHANGE_L:
  802. opt->dccpop_type = DCCPO_CONFIRM_R;
  803. break;
  804. case DCCPO_CHANGE_R:
  805. opt->dccpop_type = DCCPO_CONFIRM_L;
  806. break;
  807. default:
  808. DCCP_WARN("invalid type %d\n", type);
  809. kfree(opt);
  810. return;
  811. }
  812. opt->dccpop_feat = feature;
  813. opt->dccpop_val = NULL;
  814. opt->dccpop_len = 0;
  815. /* change feature */
  816. dccp_pr_debug("Empty %s(%d)\n", dccp_feat_typename(type), feature);
  817. list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf);
  818. }
  819. static void dccp_feat_flush_confirm(struct sock *sk)
  820. {
  821. struct dccp_minisock *dmsk = dccp_msk(sk);
  822. /* Check if there is anything to confirm in the first place */
  823. int yes = !list_empty(&dmsk->dccpms_conf);
  824. if (!yes) {
  825. struct dccp_opt_pend *opt;
  826. list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
  827. if (opt->dccpop_conf) {
  828. yes = 1;
  829. break;
  830. }
  831. }
  832. }
  833. if (!yes)
  834. return;
  835. /* OK there is something to confirm... */
  836. /* XXX check if packet is in flight? Send delayed ack?? */
  837. if (sk->sk_state == DCCP_OPEN)
  838. dccp_send_ack(sk);
  839. }
  840. int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
  841. {
  842. int rc;
  843. /* Ignore Change requests other than during connection setup */
  844. if (sk->sk_state != DCCP_LISTEN && sk->sk_state != DCCP_REQUESTING)
  845. return 0;
  846. dccp_feat_debug(type, feature, *val);
  847. /* figure out if it's SP or NN feature */
  848. switch (feature) {
  849. /* deal with SP features */
  850. case DCCPF_CCID:
  851. rc = dccp_feat_sp(sk, type, feature, val, len);
  852. break;
  853. /* deal with NN features */
  854. case DCCPF_ACK_RATIO:
  855. rc = dccp_feat_nn(sk, type, feature, val, len);
  856. break;
  857. /* XXX implement other features */
  858. default:
  859. dccp_pr_debug("UNIMPLEMENTED: not handling %s(%d, ...)\n",
  860. dccp_feat_typename(type), feature);
  861. rc = -EFAULT;
  862. break;
  863. }
  864. /* check if there were problems changing features */
  865. if (rc) {
  866. /* If we don't agree on SP, we sent a confirm for old value.
  867. * However we propagate rc to caller in case option was
  868. * mandatory
  869. */
  870. if (rc != DCCP_FEAT_SP_NOAGREE)
  871. dccp_feat_empty_confirm(dccp_msk(sk), type, feature);
  872. }
  873. /* generate the confirm [if required] */
  874. dccp_feat_flush_confirm(sk);
  875. return rc;
  876. }
  877. EXPORT_SYMBOL_GPL(dccp_feat_change_recv);
  878. int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
  879. u8 *val, u8 len)
  880. {
  881. u8 t;
  882. struct dccp_opt_pend *opt;
  883. struct dccp_minisock *dmsk = dccp_msk(sk);
  884. int found = 0;
  885. int all_confirmed = 1;
  886. /* Ignore Confirm options other than during connection setup */
  887. if (sk->sk_state != DCCP_LISTEN && sk->sk_state != DCCP_REQUESTING)
  888. return 0;
  889. dccp_feat_debug(type, feature, *val);
  890. /* locate our change request */
  891. switch (type) {
  892. case DCCPO_CONFIRM_L: t = DCCPO_CHANGE_R; break;
  893. case DCCPO_CONFIRM_R: t = DCCPO_CHANGE_L; break;
  894. default: DCCP_WARN("invalid type %d\n", type);
  895. return 1;
  896. }
  897. /* XXX sanity check feature value */
  898. list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
  899. if (!opt->dccpop_conf && opt->dccpop_type == t &&
  900. opt->dccpop_feat == feature) {
  901. found = 1;
  902. dccp_pr_debug("feature %d found\n", opt->dccpop_feat);
  903. /* XXX do sanity check */
  904. opt->dccpop_conf = 1;
  905. /* We got a confirmation---change the option */
  906. dccp_feat_update(sk, opt->dccpop_type,
  907. opt->dccpop_feat, *val);
  908. /* XXX check the return value of dccp_feat_update */
  909. break;
  910. }
  911. if (!opt->dccpop_conf)
  912. all_confirmed = 0;
  913. }
  914. if (!found)
  915. dccp_pr_debug("%s(%d, ...) never requested\n",
  916. dccp_feat_typename(type), feature);
  917. return 0;
  918. }
  919. EXPORT_SYMBOL_GPL(dccp_feat_confirm_recv);
  920. void dccp_feat_clean(struct dccp_minisock *dmsk)
  921. {
  922. struct dccp_opt_pend *opt, *next;
  923. list_for_each_entry_safe(opt, next, &dmsk->dccpms_pending,
  924. dccpop_node) {
  925. BUG_ON(opt->dccpop_val == NULL);
  926. kfree(opt->dccpop_val);
  927. if (opt->dccpop_sc != NULL) {
  928. BUG_ON(opt->dccpop_sc->dccpoc_val == NULL);
  929. kfree(opt->dccpop_sc->dccpoc_val);
  930. kfree(opt->dccpop_sc);
  931. }
  932. kfree(opt);
  933. }
  934. INIT_LIST_HEAD(&dmsk->dccpms_pending);
  935. list_for_each_entry_safe(opt, next, &dmsk->dccpms_conf, dccpop_node) {
  936. BUG_ON(opt == NULL);
  937. if (opt->dccpop_val != NULL)
  938. kfree(opt->dccpop_val);
  939. kfree(opt);
  940. }
  941. INIT_LIST_HEAD(&dmsk->dccpms_conf);
  942. }
  943. EXPORT_SYMBOL_GPL(dccp_feat_clean);
  944. /* this is to be called only when a listening sock creates its child. It is
  945. * assumed by the function---the confirm is not duplicated, but rather it is
  946. * "passed on".
  947. */
  948. int dccp_feat_clone(struct sock *oldsk, struct sock *newsk)
  949. {
  950. struct dccp_minisock *olddmsk = dccp_msk(oldsk);
  951. struct dccp_minisock *newdmsk = dccp_msk(newsk);
  952. struct dccp_opt_pend *opt;
  953. int rc = 0;
  954. INIT_LIST_HEAD(&newdmsk->dccpms_pending);
  955. INIT_LIST_HEAD(&newdmsk->dccpms_conf);
  956. list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) {
  957. struct dccp_opt_pend *newopt;
  958. /* copy the value of the option */
  959. u8 *val = kmemdup(opt->dccpop_val, opt->dccpop_len, GFP_ATOMIC);
  960. if (val == NULL)
  961. goto out_clean;
  962. newopt = kmemdup(opt, sizeof(*newopt), GFP_ATOMIC);
  963. if (newopt == NULL) {
  964. kfree(val);
  965. goto out_clean;
  966. }
  967. /* insert the option */
  968. newopt->dccpop_val = val;
  969. list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending);
  970. /* XXX what happens with backlogs and multiple connections at
  971. * once...
  972. */
  973. /* the master socket no longer needs to worry about confirms */
  974. opt->dccpop_sc = NULL; /* it's not a memleak---new socket has it */
  975. /* reset state for a new socket */
  976. opt->dccpop_conf = 0;
  977. }
  978. /* XXX not doing anything about the conf queue */
  979. out:
  980. return rc;
  981. out_clean:
  982. dccp_feat_clean(newdmsk);
  983. rc = -ENOMEM;
  984. goto out;
  985. }
  986. EXPORT_SYMBOL_GPL(dccp_feat_clone);
  987. int dccp_feat_init(struct sock *sk)
  988. {
  989. struct dccp_sock *dp = dccp_sk(sk);
  990. struct dccp_minisock *dmsk = dccp_msk(sk);
  991. int rc;
  992. INIT_LIST_HEAD(&dmsk->dccpms_pending); /* XXX no longer used */
  993. INIT_LIST_HEAD(&dmsk->dccpms_conf); /* XXX no longer used */
  994. /* CCID L */
  995. rc = __feat_register_sp(&dp->dccps_featneg, DCCPF_CCID, 1, 0,
  996. &dmsk->dccpms_tx_ccid, 1);
  997. if (rc)
  998. goto out;
  999. /* CCID R */
  1000. rc = __feat_register_sp(&dp->dccps_featneg, DCCPF_CCID, 0, 0,
  1001. &dmsk->dccpms_rx_ccid, 1);
  1002. if (rc)
  1003. goto out;
  1004. /* Ack ratio */
  1005. rc = __feat_register_nn(&dp->dccps_featneg, DCCPF_ACK_RATIO, 0,
  1006. dp->dccps_l_ack_ratio);
  1007. out:
  1008. return rc;
  1009. }
  1010. EXPORT_SYMBOL_GPL(dccp_feat_init);
  1011. #ifdef CONFIG_IP_DCCP_DEBUG
  1012. const char *dccp_feat_typename(const u8 type)
  1013. {
  1014. switch(type) {
  1015. case DCCPO_CHANGE_L: return("ChangeL");
  1016. case DCCPO_CONFIRM_L: return("ConfirmL");
  1017. case DCCPO_CHANGE_R: return("ChangeR");
  1018. case DCCPO_CONFIRM_R: return("ConfirmR");
  1019. /* the following case must not appear in feature negotation */
  1020. default: dccp_pr_debug("unknown type %d [BUG!]\n", type);
  1021. }
  1022. return NULL;
  1023. }
  1024. EXPORT_SYMBOL_GPL(dccp_feat_typename);
  1025. const char *dccp_feat_name(const u8 feat)
  1026. {
  1027. static const char *feature_names[] = {
  1028. [DCCPF_RESERVED] = "Reserved",
  1029. [DCCPF_CCID] = "CCID",
  1030. [DCCPF_SHORT_SEQNOS] = "Allow Short Seqnos",
  1031. [DCCPF_SEQUENCE_WINDOW] = "Sequence Window",
  1032. [DCCPF_ECN_INCAPABLE] = "ECN Incapable",
  1033. [DCCPF_ACK_RATIO] = "Ack Ratio",
  1034. [DCCPF_SEND_ACK_VECTOR] = "Send ACK Vector",
  1035. [DCCPF_SEND_NDP_COUNT] = "Send NDP Count",
  1036. [DCCPF_MIN_CSUM_COVER] = "Min. Csum Coverage",
  1037. [DCCPF_DATA_CHECKSUM] = "Send Data Checksum",
  1038. };
  1039. if (feat > DCCPF_DATA_CHECKSUM && feat < DCCPF_MIN_CCID_SPECIFIC)
  1040. return feature_names[DCCPF_RESERVED];
  1041. if (feat == DCCPF_SEND_LEV_RATE)
  1042. return "Send Loss Event Rate";
  1043. if (feat >= DCCPF_MIN_CCID_SPECIFIC)
  1044. return "CCID-specific";
  1045. return feature_names[feat];
  1046. }
  1047. EXPORT_SYMBOL_GPL(dccp_feat_name);
  1048. #endif /* CONFIG_IP_DCCP_DEBUG */