| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 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 | *      This program is free software; you can redistribute it and/or | 
|  | 8 | *      modify it under the terms of the GNU General Public License | 
|  | 9 | *      as published by the Free Software Foundation; either version | 
|  | 10 | *      2 of the License, or (at your option) any later version. | 
|  | 11 | */ | 
|  | 12 |  | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 13 | #include <linux/module.h> | 
|  | 14 |  | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 15 | #include "ccid.h" | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 16 | #include "feat.h" | 
|  | 17 |  | 
|  | 18 | #define DCCP_FEAT_SP_NOAGREE (-123) | 
|  | 19 |  | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 20 | int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, | 
|  | 21 | u8 *val, u8 len, gfp_t gfp) | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 22 | { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 23 | struct dccp_opt_pend *opt; | 
|  | 24 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 25 | dccp_feat_debug(type, feature, *val); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 26 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 27 | if (!dccp_feat_is_valid_type(type)) { | 
| Gerrit Renker | 59348b1 | 2006-11-20 18:39:23 -0200 | [diff] [blame] | 28 | DCCP_WARN("option type %d invalid in negotiation\n", type); | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 29 | return 1; | 
|  | 30 | } | 
|  | 31 | if (!dccp_feat_is_valid_length(type, feature, len)) { | 
| Gerrit Renker | 59348b1 | 2006-11-20 18:39:23 -0200 | [diff] [blame] | 32 | DCCP_WARN("invalid length %d\n", len); | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 33 | return 1; | 
|  | 34 | } | 
|  | 35 | /* XXX add further sanity checks */ | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 36 |  | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 37 | /* check if that feature is already being negotiated */ | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 38 | list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 39 | /* ok we found a negotiation for this option already */ | 
|  | 40 | if (opt->dccpop_feat == feature && opt->dccpop_type == type) { | 
|  | 41 | dccp_pr_debug("Replacing old\n"); | 
|  | 42 | /* replace */ | 
|  | 43 | BUG_ON(opt->dccpop_val == NULL); | 
|  | 44 | kfree(opt->dccpop_val); | 
|  | 45 | opt->dccpop_val	 = val; | 
|  | 46 | opt->dccpop_len	 = len; | 
|  | 47 | opt->dccpop_conf = 0; | 
|  | 48 | return 0; | 
|  | 49 | } | 
|  | 50 | } | 
|  | 51 |  | 
|  | 52 | /* negotiation for a new feature */ | 
|  | 53 | opt = kmalloc(sizeof(*opt), gfp); | 
|  | 54 | if (opt == NULL) | 
|  | 55 | return -ENOMEM; | 
|  | 56 |  | 
|  | 57 | opt->dccpop_type = type; | 
|  | 58 | opt->dccpop_feat = feature; | 
|  | 59 | opt->dccpop_len	 = len; | 
|  | 60 | opt->dccpop_val	 = val; | 
|  | 61 | opt->dccpop_conf = 0; | 
|  | 62 | opt->dccpop_sc	 = NULL; | 
|  | 63 |  | 
|  | 64 | BUG_ON(opt->dccpop_val == NULL); | 
|  | 65 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 66 | list_add_tail(&opt->dccpop_node, &dmsk->dccpms_pending); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 67 | return 0; | 
|  | 68 | } | 
|  | 69 |  | 
|  | 70 | EXPORT_SYMBOL_GPL(dccp_feat_change); | 
|  | 71 |  | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 72 | static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr) | 
|  | 73 | { | 
|  | 74 | struct dccp_sock *dp = dccp_sk(sk); | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 75 | struct dccp_minisock *dmsk = dccp_msk(sk); | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 76 | /* figure out if we are changing our CCID or the peer's */ | 
|  | 77 | const int rx = type == DCCPO_CHANGE_R; | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 78 | const u8 ccid_nr = rx ? dmsk->dccpms_rx_ccid : dmsk->dccpms_tx_ccid; | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 79 | struct ccid *new_ccid; | 
|  | 80 |  | 
|  | 81 | /* Check if nothing is being changed. */ | 
|  | 82 | if (ccid_nr == new_ccid_nr) | 
|  | 83 | return 0; | 
|  | 84 |  | 
|  | 85 | new_ccid = ccid_new(new_ccid_nr, sk, rx, GFP_ATOMIC); | 
|  | 86 | if (new_ccid == NULL) | 
|  | 87 | return -ENOMEM; | 
|  | 88 |  | 
|  | 89 | if (rx) { | 
|  | 90 | ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); | 
|  | 91 | dp->dccps_hc_rx_ccid = new_ccid; | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 92 | dmsk->dccpms_rx_ccid = new_ccid_nr; | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 93 | } else { | 
|  | 94 | ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); | 
|  | 95 | dp->dccps_hc_tx_ccid = new_ccid; | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 96 | dmsk->dccpms_tx_ccid = new_ccid_nr; | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 97 | } | 
|  | 98 |  | 
|  | 99 | return 0; | 
|  | 100 | } | 
|  | 101 |  | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 102 | /* XXX taking only u8 vals */ | 
|  | 103 | static int dccp_feat_update(struct sock *sk, u8 type, u8 feat, u8 val) | 
|  | 104 | { | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 105 | dccp_feat_debug(type, feat, val); | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 106 |  | 
|  | 107 | switch (feat) { | 
|  | 108 | case DCCPF_CCID: | 
|  | 109 | return dccp_feat_update_ccid(sk, type, val); | 
|  | 110 | default: | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 111 | dccp_pr_debug("UNIMPLEMENTED: %s(%d, ...)\n", | 
|  | 112 | dccp_feat_typename(type), feat); | 
| Andrea Bittau | 6ffd30f | 2006-03-20 19:22:37 -0800 | [diff] [blame] | 113 | break; | 
|  | 114 | } | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 115 | return 0; | 
|  | 116 | } | 
|  | 117 |  | 
|  | 118 | static int dccp_feat_reconcile(struct sock *sk, struct dccp_opt_pend *opt, | 
|  | 119 | u8 *rpref, u8 rlen) | 
|  | 120 | { | 
|  | 121 | struct dccp_sock *dp = dccp_sk(sk); | 
|  | 122 | u8 *spref, slen, *res = NULL; | 
|  | 123 | int i, j, rc, agree = 1; | 
|  | 124 |  | 
|  | 125 | BUG_ON(rpref == NULL); | 
|  | 126 |  | 
|  | 127 | /* check if we are the black sheep */ | 
|  | 128 | if (dp->dccps_role == DCCP_ROLE_CLIENT) { | 
|  | 129 | spref = rpref; | 
|  | 130 | slen  = rlen; | 
|  | 131 | rpref = opt->dccpop_val; | 
|  | 132 | rlen  = opt->dccpop_len; | 
|  | 133 | } else { | 
|  | 134 | spref = opt->dccpop_val; | 
|  | 135 | slen  = opt->dccpop_len; | 
|  | 136 | } | 
|  | 137 | /* | 
|  | 138 | * Now we have server preference list in spref and client preference in | 
|  | 139 | * rpref | 
|  | 140 | */ | 
|  | 141 | BUG_ON(spref == NULL); | 
|  | 142 | BUG_ON(rpref == NULL); | 
|  | 143 |  | 
|  | 144 | /* FIXME sanity check vals */ | 
|  | 145 |  | 
|  | 146 | /* Are values in any order?  XXX Lame "algorithm" here */ | 
|  | 147 | /* XXX assume values are 1 byte */ | 
|  | 148 | for (i = 0; i < slen; i++) { | 
|  | 149 | for (j = 0; j < rlen; j++) { | 
|  | 150 | if (spref[i] == rpref[j]) { | 
|  | 151 | res = &spref[i]; | 
|  | 152 | break; | 
|  | 153 | } | 
|  | 154 | } | 
|  | 155 | if (res) | 
|  | 156 | break; | 
|  | 157 | } | 
|  | 158 |  | 
|  | 159 | /* we didn't agree on anything */ | 
|  | 160 | if (res == NULL) { | 
|  | 161 | /* confirm previous value */ | 
|  | 162 | switch (opt->dccpop_feat) { | 
|  | 163 | case DCCPF_CCID: | 
|  | 164 | /* XXX did i get this right? =P */ | 
|  | 165 | if (opt->dccpop_type == DCCPO_CHANGE_L) | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 166 | res = &dccp_msk(sk)->dccpms_tx_ccid; | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 167 | else | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 168 | res = &dccp_msk(sk)->dccpms_rx_ccid; | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 169 | break; | 
|  | 170 |  | 
|  | 171 | default: | 
| Gerrit Renker | 59348b1 | 2006-11-20 18:39:23 -0200 | [diff] [blame] | 172 | DCCP_BUG("Fell through, feat=%d", opt->dccpop_feat); | 
|  | 173 | /* XXX implement res */ | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 174 | return -EFAULT; | 
|  | 175 | } | 
|  | 176 |  | 
|  | 177 | dccp_pr_debug("Don't agree... reconfirming %d\n", *res); | 
|  | 178 | agree = 0; /* this is used for mandatory options... */ | 
|  | 179 | } | 
|  | 180 |  | 
|  | 181 | /* need to put result and our preference list */ | 
|  | 182 | /* XXX assume 1 byte vals */ | 
|  | 183 | rlen = 1 + opt->dccpop_len; | 
|  | 184 | rpref = kmalloc(rlen, GFP_ATOMIC); | 
|  | 185 | if (rpref == NULL) | 
|  | 186 | return -ENOMEM; | 
|  | 187 |  | 
|  | 188 | *rpref = *res; | 
|  | 189 | memcpy(&rpref[1], opt->dccpop_val, opt->dccpop_len); | 
|  | 190 |  | 
|  | 191 | /* put it in the "confirm queue" */ | 
|  | 192 | if (opt->dccpop_sc == NULL) { | 
|  | 193 | opt->dccpop_sc = kmalloc(sizeof(*opt->dccpop_sc), GFP_ATOMIC); | 
|  | 194 | if (opt->dccpop_sc == NULL) { | 
|  | 195 | kfree(rpref); | 
|  | 196 | return -ENOMEM; | 
|  | 197 | } | 
|  | 198 | } else { | 
|  | 199 | /* recycle the confirm slot */ | 
|  | 200 | BUG_ON(opt->dccpop_sc->dccpoc_val == NULL); | 
|  | 201 | kfree(opt->dccpop_sc->dccpoc_val); | 
|  | 202 | dccp_pr_debug("recycling confirm slot\n"); | 
|  | 203 | } | 
|  | 204 | memset(opt->dccpop_sc, 0, sizeof(*opt->dccpop_sc)); | 
|  | 205 |  | 
|  | 206 | opt->dccpop_sc->dccpoc_val = rpref; | 
|  | 207 | opt->dccpop_sc->dccpoc_len = rlen; | 
|  | 208 |  | 
|  | 209 | /* update the option on our side [we are about to send the confirm] */ | 
|  | 210 | rc = dccp_feat_update(sk, opt->dccpop_type, opt->dccpop_feat, *res); | 
|  | 211 | if (rc) { | 
|  | 212 | kfree(opt->dccpop_sc->dccpoc_val); | 
|  | 213 | kfree(opt->dccpop_sc); | 
| Randy Dunlap | 68907da | 2006-03-29 13:58:25 -0800 | [diff] [blame] | 214 | opt->dccpop_sc = NULL; | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 215 | return rc; | 
|  | 216 | } | 
|  | 217 |  | 
|  | 218 | dccp_pr_debug("Will confirm %d\n", *rpref); | 
|  | 219 |  | 
|  | 220 | /* say we want to change to X but we just got a confirm X, suppress our | 
|  | 221 | * change | 
|  | 222 | */ | 
|  | 223 | if (!opt->dccpop_conf) { | 
|  | 224 | if (*opt->dccpop_val == *res) | 
|  | 225 | opt->dccpop_conf = 1; | 
|  | 226 | dccp_pr_debug("won't ask for change of same feature\n"); | 
|  | 227 | } | 
|  | 228 |  | 
|  | 229 | return agree ? 0 : DCCP_FEAT_SP_NOAGREE; /* used for mandatory opts */ | 
|  | 230 | } | 
|  | 231 |  | 
|  | 232 | static int dccp_feat_sp(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len) | 
|  | 233 | { | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 234 | struct dccp_minisock *dmsk = dccp_msk(sk); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 235 | struct dccp_opt_pend *opt; | 
|  | 236 | int rc = 1; | 
|  | 237 | u8 t; | 
|  | 238 |  | 
|  | 239 | /* | 
|  | 240 | * We received a CHANGE.  We gotta match it against our own preference | 
|  | 241 | * list.  If we got a CHANGE_R it means it's a change for us, so we need | 
|  | 242 | * to compare our CHANGE_L list. | 
|  | 243 | */ | 
|  | 244 | if (type == DCCPO_CHANGE_L) | 
|  | 245 | t = DCCPO_CHANGE_R; | 
|  | 246 | else | 
|  | 247 | t = DCCPO_CHANGE_L; | 
|  | 248 |  | 
|  | 249 | /* find our preference list for this feature */ | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 250 | list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 251 | if (opt->dccpop_type != t || opt->dccpop_feat != feature) | 
|  | 252 | continue; | 
|  | 253 |  | 
|  | 254 | /* find the winner from the two preference lists */ | 
|  | 255 | rc = dccp_feat_reconcile(sk, opt, val, len); | 
|  | 256 | break; | 
|  | 257 | } | 
|  | 258 |  | 
|  | 259 | /* We didn't deal with the change.  This can happen if we have no | 
|  | 260 | * preference list for the feature.  In fact, it just shouldn't | 
|  | 261 | * happen---if we understand a feature, we should have a preference list | 
|  | 262 | * with at least the default value. | 
|  | 263 | */ | 
|  | 264 | BUG_ON(rc == 1); | 
|  | 265 |  | 
|  | 266 | return rc; | 
|  | 267 | } | 
|  | 268 |  | 
|  | 269 | static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len) | 
|  | 270 | { | 
|  | 271 | struct dccp_opt_pend *opt; | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 272 | struct dccp_minisock *dmsk = dccp_msk(sk); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 273 | u8 *copy; | 
|  | 274 | int rc; | 
|  | 275 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 276 | /* NN features must be Change L (sec. 6.3.2) */ | 
|  | 277 | if (type != DCCPO_CHANGE_L) { | 
|  | 278 | dccp_pr_debug("received %s for NN feature %d\n", | 
|  | 279 | dccp_feat_typename(type), feature); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 280 | return -EFAULT; | 
|  | 281 | } | 
|  | 282 |  | 
|  | 283 | /* XXX sanity check opt val */ | 
|  | 284 |  | 
|  | 285 | /* copy option so we can confirm it */ | 
|  | 286 | opt = kzalloc(sizeof(*opt), GFP_ATOMIC); | 
|  | 287 | if (opt == NULL) | 
|  | 288 | return -ENOMEM; | 
|  | 289 |  | 
| Arnaldo Carvalho de Melo | eed7341 | 2006-11-17 12:21:43 -0200 | [diff] [blame] | 290 | copy = kmemdup(val, len, GFP_ATOMIC); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 291 | if (copy == NULL) { | 
|  | 292 | kfree(opt); | 
|  | 293 | return -ENOMEM; | 
|  | 294 | } | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 295 |  | 
|  | 296 | opt->dccpop_type = DCCPO_CONFIRM_R; /* NN can only confirm R */ | 
|  | 297 | opt->dccpop_feat = feature; | 
|  | 298 | opt->dccpop_val	 = copy; | 
|  | 299 | opt->dccpop_len	 = len; | 
|  | 300 |  | 
|  | 301 | /* change feature */ | 
|  | 302 | rc = dccp_feat_update(sk, type, feature, *val); | 
|  | 303 | if (rc) { | 
|  | 304 | kfree(opt->dccpop_val); | 
|  | 305 | kfree(opt); | 
|  | 306 | return rc; | 
|  | 307 | } | 
|  | 308 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 309 | dccp_feat_debug(type, feature, *copy); | 
|  | 310 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 311 | list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 312 |  | 
|  | 313 | return 0; | 
|  | 314 | } | 
|  | 315 |  | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 316 | static void dccp_feat_empty_confirm(struct dccp_minisock *dmsk, | 
|  | 317 | u8 type, u8 feature) | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 318 | { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 319 | /* XXX check if other confirms for that are queued and recycle slot */ | 
|  | 320 | struct dccp_opt_pend *opt = kzalloc(sizeof(*opt), GFP_ATOMIC); | 
|  | 321 |  | 
|  | 322 | if (opt == NULL) { | 
|  | 323 | /* XXX what do we do?  Ignoring should be fine.  It's a change | 
|  | 324 | * after all =P | 
|  | 325 | */ | 
|  | 326 | return; | 
|  | 327 | } | 
|  | 328 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 329 | switch (type) { | 
| Jesper Juhl | e576de8 | 2007-08-10 15:23:54 -0700 | [diff] [blame] | 330 | case DCCPO_CHANGE_L: | 
|  | 331 | opt->dccpop_type = DCCPO_CONFIRM_R; | 
|  | 332 | break; | 
|  | 333 | case DCCPO_CHANGE_R: | 
|  | 334 | opt->dccpop_type = DCCPO_CONFIRM_L; | 
|  | 335 | break; | 
|  | 336 | default: | 
|  | 337 | DCCP_WARN("invalid type %d\n", type); | 
|  | 338 | kfree(opt); | 
|  | 339 | return; | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 340 | } | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 341 | opt->dccpop_feat = feature; | 
| Randy Dunlap | 68907da | 2006-03-29 13:58:25 -0800 | [diff] [blame] | 342 | opt->dccpop_val	 = NULL; | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 343 | opt->dccpop_len	 = 0; | 
|  | 344 |  | 
|  | 345 | /* change feature */ | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 346 | dccp_pr_debug("Empty %s(%d)\n", dccp_feat_typename(type), feature); | 
|  | 347 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 348 | list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 349 | } | 
|  | 350 |  | 
|  | 351 | static void dccp_feat_flush_confirm(struct sock *sk) | 
|  | 352 | { | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 353 | struct dccp_minisock *dmsk = dccp_msk(sk); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 354 | /* Check if there is anything to confirm in the first place */ | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 355 | int yes = !list_empty(&dmsk->dccpms_conf); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 356 |  | 
|  | 357 | if (!yes) { | 
|  | 358 | struct dccp_opt_pend *opt; | 
|  | 359 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 360 | list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 361 | if (opt->dccpop_conf) { | 
|  | 362 | yes = 1; | 
|  | 363 | break; | 
|  | 364 | } | 
|  | 365 | } | 
|  | 366 | } | 
|  | 367 |  | 
|  | 368 | if (!yes) | 
|  | 369 | return; | 
|  | 370 |  | 
|  | 371 | /* OK there is something to confirm... */ | 
|  | 372 | /* XXX check if packet is in flight?  Send delayed ack?? */ | 
|  | 373 | if (sk->sk_state == DCCP_OPEN) | 
|  | 374 | dccp_send_ack(sk); | 
|  | 375 | } | 
|  | 376 |  | 
|  | 377 | int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len) | 
|  | 378 | { | 
|  | 379 | int rc; | 
|  | 380 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 381 | dccp_feat_debug(type, feature, *val); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 382 |  | 
|  | 383 | /* figure out if it's SP or NN feature */ | 
|  | 384 | switch (feature) { | 
|  | 385 | /* deal with SP features */ | 
|  | 386 | case DCCPF_CCID: | 
|  | 387 | rc = dccp_feat_sp(sk, type, feature, val, len); | 
|  | 388 | break; | 
|  | 389 |  | 
|  | 390 | /* deal with NN features */ | 
|  | 391 | case DCCPF_ACK_RATIO: | 
|  | 392 | rc = dccp_feat_nn(sk, type, feature, val, len); | 
|  | 393 | break; | 
|  | 394 |  | 
|  | 395 | /* XXX implement other features */ | 
|  | 396 | default: | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 397 | dccp_pr_debug("UNIMPLEMENTED: not handling %s(%d, ...)\n", | 
|  | 398 | dccp_feat_typename(type), feature); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 399 | rc = -EFAULT; | 
|  | 400 | break; | 
|  | 401 | } | 
|  | 402 |  | 
|  | 403 | /* check if there were problems changing features */ | 
|  | 404 | if (rc) { | 
|  | 405 | /* If we don't agree on SP, we sent a confirm for old value. | 
|  | 406 | * However we propagate rc to caller in case option was | 
|  | 407 | * mandatory | 
|  | 408 | */ | 
|  | 409 | if (rc != DCCP_FEAT_SP_NOAGREE) | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 410 | dccp_feat_empty_confirm(dccp_msk(sk), type, feature); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 411 | } | 
|  | 412 |  | 
|  | 413 | /* generate the confirm [if required] */ | 
|  | 414 | dccp_feat_flush_confirm(sk); | 
|  | 415 |  | 
|  | 416 | return rc; | 
|  | 417 | } | 
|  | 418 |  | 
|  | 419 | EXPORT_SYMBOL_GPL(dccp_feat_change_recv); | 
|  | 420 |  | 
|  | 421 | int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature, | 
|  | 422 | u8 *val, u8 len) | 
|  | 423 | { | 
|  | 424 | u8 t; | 
|  | 425 | struct dccp_opt_pend *opt; | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 426 | struct dccp_minisock *dmsk = dccp_msk(sk); | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 427 | int found = 0; | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 428 | int all_confirmed = 1; | 
|  | 429 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 430 | dccp_feat_debug(type, feature, *val); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 431 |  | 
|  | 432 | /* locate our change request */ | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 433 | switch (type) { | 
|  | 434 | case DCCPO_CONFIRM_L: t = DCCPO_CHANGE_R; break; | 
|  | 435 | case DCCPO_CONFIRM_R: t = DCCPO_CHANGE_L; break; | 
| Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 436 | default:	      DCCP_WARN("invalid type %d\n", type); | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 437 | return 1; | 
|  | 438 |  | 
|  | 439 | } | 
|  | 440 | /* XXX sanity check feature value */ | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 441 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 442 | list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 443 | if (!opt->dccpop_conf && opt->dccpop_type == t && | 
|  | 444 | opt->dccpop_feat == feature) { | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 445 | found = 1; | 
|  | 446 | dccp_pr_debug("feature %d found\n", opt->dccpop_feat); | 
|  | 447 |  | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 448 | /* XXX do sanity check */ | 
|  | 449 |  | 
|  | 450 | opt->dccpop_conf = 1; | 
|  | 451 |  | 
|  | 452 | /* We got a confirmation---change the option */ | 
|  | 453 | dccp_feat_update(sk, opt->dccpop_type, | 
|  | 454 | opt->dccpop_feat, *val); | 
|  | 455 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 456 | /* XXX check the return value of dccp_feat_update */ | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 457 | break; | 
|  | 458 | } | 
|  | 459 |  | 
|  | 460 | if (!opt->dccpop_conf) | 
|  | 461 | all_confirmed = 0; | 
|  | 462 | } | 
|  | 463 |  | 
|  | 464 | /* fix re-transmit timer */ | 
|  | 465 | /* XXX gotta make sure that no option negotiation occurs during | 
|  | 466 | * connection shutdown.  Consider that the CLOSEREQ is sent and timer is | 
|  | 467 | * on.  if all options are confirmed it might kill timer which should | 
|  | 468 | * remain alive until close is received. | 
|  | 469 | */ | 
|  | 470 | if (all_confirmed) { | 
|  | 471 | dccp_pr_debug("clear feat negotiation timer %p\n", sk); | 
|  | 472 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); | 
|  | 473 | } | 
|  | 474 |  | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 475 | if (!found) | 
|  | 476 | dccp_pr_debug("%s(%d, ...) never requested\n", | 
|  | 477 | dccp_feat_typename(type), feature); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 478 | return 0; | 
|  | 479 | } | 
|  | 480 |  | 
|  | 481 | EXPORT_SYMBOL_GPL(dccp_feat_confirm_recv); | 
|  | 482 |  | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 483 | void dccp_feat_clean(struct dccp_minisock *dmsk) | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 484 | { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 485 | struct dccp_opt_pend *opt, *next; | 
|  | 486 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 487 | list_for_each_entry_safe(opt, next, &dmsk->dccpms_pending, | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 488 | dccpop_node) { | 
| YOSHIFUJI Hideaki | c9eaf17 | 2007-02-09 23:24:38 +0900 | [diff] [blame] | 489 | BUG_ON(opt->dccpop_val == NULL); | 
|  | 490 | kfree(opt->dccpop_val); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 491 |  | 
|  | 492 | if (opt->dccpop_sc != NULL) { | 
|  | 493 | BUG_ON(opt->dccpop_sc->dccpoc_val == NULL); | 
|  | 494 | kfree(opt->dccpop_sc->dccpoc_val); | 
|  | 495 | kfree(opt->dccpop_sc); | 
|  | 496 | } | 
|  | 497 |  | 
| YOSHIFUJI Hideaki | c9eaf17 | 2007-02-09 23:24:38 +0900 | [diff] [blame] | 498 | kfree(opt); | 
|  | 499 | } | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 500 | INIT_LIST_HEAD(&dmsk->dccpms_pending); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 501 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 502 | list_for_each_entry_safe(opt, next, &dmsk->dccpms_conf, dccpop_node) { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 503 | BUG_ON(opt == NULL); | 
|  | 504 | if (opt->dccpop_val != NULL) | 
|  | 505 | kfree(opt->dccpop_val); | 
|  | 506 | kfree(opt); | 
|  | 507 | } | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 508 | INIT_LIST_HEAD(&dmsk->dccpms_conf); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 509 | } | 
|  | 510 |  | 
|  | 511 | EXPORT_SYMBOL_GPL(dccp_feat_clean); | 
|  | 512 |  | 
|  | 513 | /* this is to be called only when a listening sock creates its child.  It is | 
|  | 514 | * assumed by the function---the confirm is not duplicated, but rather it is | 
|  | 515 | * "passed on". | 
|  | 516 | */ | 
|  | 517 | int dccp_feat_clone(struct sock *oldsk, struct sock *newsk) | 
|  | 518 | { | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 519 | struct dccp_minisock *olddmsk = dccp_msk(oldsk); | 
|  | 520 | struct dccp_minisock *newdmsk = dccp_msk(newsk); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 521 | struct dccp_opt_pend *opt; | 
|  | 522 | int rc = 0; | 
|  | 523 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 524 | INIT_LIST_HEAD(&newdmsk->dccpms_pending); | 
|  | 525 | INIT_LIST_HEAD(&newdmsk->dccpms_conf); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 526 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 527 | list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 528 | struct dccp_opt_pend *newopt; | 
|  | 529 | /* copy the value of the option */ | 
| Arnaldo Carvalho de Melo | eed7341 | 2006-11-17 12:21:43 -0200 | [diff] [blame] | 530 | u8 *val = kmemdup(opt->dccpop_val, opt->dccpop_len, GFP_ATOMIC); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 531 |  | 
|  | 532 | if (val == NULL) | 
|  | 533 | goto out_clean; | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 534 |  | 
| Arnaldo Carvalho de Melo | eed7341 | 2006-11-17 12:21:43 -0200 | [diff] [blame] | 535 | newopt = kmemdup(opt, sizeof(*newopt), GFP_ATOMIC); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 536 | if (newopt == NULL) { | 
|  | 537 | kfree(val); | 
|  | 538 | goto out_clean; | 
|  | 539 | } | 
|  | 540 |  | 
|  | 541 | /* insert the option */ | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 542 | newopt->dccpop_val = val; | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 543 | list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 544 |  | 
|  | 545 | /* XXX what happens with backlogs and multiple connections at | 
|  | 546 | * once... | 
|  | 547 | */ | 
|  | 548 | /* the master socket no longer needs to worry about confirms */ | 
| Randy Dunlap | 68907da | 2006-03-29 13:58:25 -0800 | [diff] [blame] | 549 | opt->dccpop_sc = NULL; /* it's not a memleak---new socket has it */ | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 550 |  | 
|  | 551 | /* reset state for a new socket */ | 
|  | 552 | opt->dccpop_conf = 0; | 
|  | 553 | } | 
|  | 554 |  | 
|  | 555 | /* XXX not doing anything about the conf queue */ | 
|  | 556 |  | 
|  | 557 | out: | 
|  | 558 | return rc; | 
|  | 559 |  | 
|  | 560 | out_clean: | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 561 | dccp_feat_clean(newdmsk); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 562 | rc = -ENOMEM; | 
|  | 563 | goto out; | 
|  | 564 | } | 
|  | 565 |  | 
|  | 566 | EXPORT_SYMBOL_GPL(dccp_feat_clone); | 
|  | 567 |  | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 568 | static int __dccp_feat_init(struct dccp_minisock *dmsk, u8 type, u8 feat, | 
|  | 569 | u8 *val, u8 len) | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 570 | { | 
|  | 571 | int rc = -ENOMEM; | 
| Arnaldo Carvalho de Melo | eed7341 | 2006-11-17 12:21:43 -0200 | [diff] [blame] | 572 | u8 *copy = kmemdup(val, len, GFP_KERNEL); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 573 |  | 
|  | 574 | if (copy != NULL) { | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 575 | rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 576 | if (rc) | 
|  | 577 | kfree(copy); | 
|  | 578 | } | 
|  | 579 | return rc; | 
|  | 580 | } | 
|  | 581 |  | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 582 | int dccp_feat_init(struct dccp_minisock *dmsk) | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 583 | { | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 584 | int rc; | 
|  | 585 |  | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 586 | INIT_LIST_HEAD(&dmsk->dccpms_pending); | 
|  | 587 | INIT_LIST_HEAD(&dmsk->dccpms_conf); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 588 |  | 
|  | 589 | /* CCID L */ | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 590 | rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_L, DCCPF_CCID, | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 591 | &dmsk->dccpms_tx_ccid, 1); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 592 | if (rc) | 
|  | 593 | goto out; | 
|  | 594 |  | 
|  | 595 | /* CCID R */ | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 596 | rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_R, DCCPF_CCID, | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 597 | &dmsk->dccpms_rx_ccid, 1); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 598 | if (rc) | 
|  | 599 | goto out; | 
|  | 600 |  | 
|  | 601 | /* Ack ratio */ | 
| Arnaldo Carvalho de Melo | 8ca0d17 | 2006-03-20 22:51:53 -0800 | [diff] [blame] | 602 | rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_L, DCCPF_ACK_RATIO, | 
| Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 603 | &dmsk->dccpms_ack_ratio, 1); | 
| Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 604 | out: | 
|  | 605 | return rc; | 
|  | 606 | } | 
|  | 607 |  | 
|  | 608 | EXPORT_SYMBOL_GPL(dccp_feat_init); | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 609 |  | 
|  | 610 | #ifdef CONFIG_IP_DCCP_DEBUG | 
|  | 611 | const char *dccp_feat_typename(const u8 type) | 
|  | 612 | { | 
|  | 613 | switch(type) { | 
|  | 614 | case DCCPO_CHANGE_L:  return("ChangeL"); | 
|  | 615 | case DCCPO_CONFIRM_L: return("ConfirmL"); | 
|  | 616 | case DCCPO_CHANGE_R:  return("ChangeR"); | 
|  | 617 | case DCCPO_CONFIRM_R: return("ConfirmR"); | 
|  | 618 | /* the following case must not appear in feature negotation  */ | 
| Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 619 | default:	      dccp_pr_debug("unknown type %d [BUG!]\n", type); | 
| Gerrit Renker | c02fdc0 | 2006-11-14 12:48:10 -0200 | [diff] [blame] | 620 | } | 
|  | 621 | return NULL; | 
|  | 622 | } | 
|  | 623 |  | 
|  | 624 | EXPORT_SYMBOL_GPL(dccp_feat_typename); | 
|  | 625 |  | 
|  | 626 | const char *dccp_feat_name(const u8 feat) | 
|  | 627 | { | 
|  | 628 | static const char *feature_names[] = { | 
|  | 629 | [DCCPF_RESERVED]	= "Reserved", | 
|  | 630 | [DCCPF_CCID]		= "CCID", | 
|  | 631 | [DCCPF_SHORT_SEQNOS]	= "Allow Short Seqnos", | 
|  | 632 | [DCCPF_SEQUENCE_WINDOW]	= "Sequence Window", | 
|  | 633 | [DCCPF_ECN_INCAPABLE]	= "ECN Incapable", | 
|  | 634 | [DCCPF_ACK_RATIO]	= "Ack Ratio", | 
|  | 635 | [DCCPF_SEND_ACK_VECTOR]	= "Send ACK Vector", | 
|  | 636 | [DCCPF_SEND_NDP_COUNT]	= "Send NDP Count", | 
|  | 637 | [DCCPF_MIN_CSUM_COVER]	= "Min. Csum Coverage", | 
|  | 638 | [DCCPF_DATA_CHECKSUM]	= "Send Data Checksum", | 
|  | 639 | }; | 
|  | 640 | if (feat >= DCCPF_MIN_CCID_SPECIFIC) | 
|  | 641 | return "CCID-specific"; | 
|  | 642 |  | 
|  | 643 | if (dccp_feat_is_reserved(feat)) | 
|  | 644 | return feature_names[DCCPF_RESERVED]; | 
|  | 645 |  | 
|  | 646 | return feature_names[feat]; | 
|  | 647 | } | 
|  | 648 |  | 
|  | 649 | EXPORT_SYMBOL_GPL(dccp_feat_name); | 
|  | 650 | #endif /* CONFIG_IP_DCCP_DEBUG */ |