Deleted Added
full compact
sctp_input.c (165647) sctp_input.c (166023)
1/*-
2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.

--- 17 unchanged lines hidden (view full) ---

26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/* $KAME: sctp_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.

--- 17 unchanged lines hidden (view full) ---

26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/* $KAME: sctp_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 165647 2006-12-29 20:21:42Z rrs $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 166023 2007-01-15 15:12:10Z rrs $");
35
36#include "opt_ipsec.h"
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_inet.h"
40#include "opt_sctp.h"
41
42#include <sys/param.h>

--- 1054 unchanged lines hidden (view full) ---

1097{
1098 struct sctp_association *asoc;
1099 struct sctp_init_chunk *init_cp, init_buf;
1100 struct sctp_init_ack_chunk *initack_cp, initack_buf;
1101 int chk_length;
1102 int init_offset, initack_offset, i;
1103 int retval;
1104 int spec_flag = 0;
35
36#include "opt_ipsec.h"
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_inet.h"
40#include "opt_sctp.h"
41
42#include <sys/param.h>

--- 1054 unchanged lines hidden (view full) ---

1097{
1098 struct sctp_association *asoc;
1099 struct sctp_init_chunk *init_cp, init_buf;
1100 struct sctp_init_ack_chunk *initack_cp, initack_buf;
1101 int chk_length;
1102 int init_offset, initack_offset, i;
1103 int retval;
1104 int spec_flag = 0;
1105 int how_indx;
1105
1106 /* I know that the TCB is non-NULL from the caller */
1107 asoc = &stcb->asoc;
1106
1107 /* I know that the TCB is non-NULL from the caller */
1108 asoc = &stcb->asoc;
1108
1109 for (how_indx = 0; how_indx < sizeof(asoc->cookie_how); i++) {
1110 if (asoc->cookie_how[how_indx] == 0)
1111 break;
1112 }
1113 if (how_indx < sizeof(asoc->cookie_how)) {
1114 asoc->cookie_how[how_indx] = 1;
1115 }
1109 if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) {
1110 /* SHUTDOWN came in after sending INIT-ACK */
1111 struct mbuf *op_err;
1112 struct sctp_paramhdr *ph;
1113
1114 sctp_send_shutdown_ack(stcb, stcb->asoc.primary_destination);
1115 op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr),
1116 0, M_DONTWAIT, 1, MT_DATA);

--- 6 unchanged lines hidden (view full) ---

1123 SCTP_BUF_RESV_UF(op_err, sizeof(struct sctphdr));
1124 SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr));
1125 /* Set the len */
1126 SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr);
1127 ph = mtod(op_err, struct sctp_paramhdr *);
1128 ph->param_type = htons(SCTP_CAUSE_COOKIE_IN_SHUTDOWN);
1129 ph->param_length = htons(sizeof(struct sctp_paramhdr));
1130 sctp_send_operr_to(m, iphlen, op_err, cookie->peers_vtag);
1116 if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) {
1117 /* SHUTDOWN came in after sending INIT-ACK */
1118 struct mbuf *op_err;
1119 struct sctp_paramhdr *ph;
1120
1121 sctp_send_shutdown_ack(stcb, stcb->asoc.primary_destination);
1122 op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr),
1123 0, M_DONTWAIT, 1, MT_DATA);

--- 6 unchanged lines hidden (view full) ---

1130 SCTP_BUF_RESV_UF(op_err, sizeof(struct sctphdr));
1131 SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr));
1132 /* Set the len */
1133 SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr);
1134 ph = mtod(op_err, struct sctp_paramhdr *);
1135 ph->param_type = htons(SCTP_CAUSE_COOKIE_IN_SHUTDOWN);
1136 ph->param_length = htons(sizeof(struct sctp_paramhdr));
1137 sctp_send_operr_to(m, iphlen, op_err, cookie->peers_vtag);
1138 if (how_indx < sizeof(asoc->cookie_how))
1139 asoc->cookie_how[how_indx] = 2;
1131 return (NULL);
1132 }
1133 /*
1134 * find and validate the INIT chunk in the cookie (peer's info) the
1135 * INIT should start after the cookie-echo header struct (chunk
1136 * header, state cookie header struct)
1137 */
1138 init_offset = offset += sizeof(struct sctp_cookie_echo_chunk);

--- 26 unchanged lines hidden (view full) ---

1165 return (NULL);
1166 }
1167 if ((ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag) &&
1168 (ntohl(init_cp->init.initiate_tag) == asoc->peer_vtag)) {
1169 /*
1170 * case D in Section 5.2.4 Table 2: MMAA process accordingly
1171 * to get into the OPEN state
1172 */
1140 return (NULL);
1141 }
1142 /*
1143 * find and validate the INIT chunk in the cookie (peer's info) the
1144 * INIT should start after the cookie-echo header struct (chunk
1145 * header, state cookie header struct)
1146 */
1147 init_offset = offset += sizeof(struct sctp_cookie_echo_chunk);

--- 26 unchanged lines hidden (view full) ---

1174 return (NULL);
1175 }
1176 if ((ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag) &&
1177 (ntohl(init_cp->init.initiate_tag) == asoc->peer_vtag)) {
1178 /*
1179 * case D in Section 5.2.4 Table 2: MMAA process accordingly
1180 * to get into the OPEN state
1181 */
1182 if (ntohl(initack_cp->init.initial_tsn) != asoc->init_seq_number) {
1183 panic("Case D and non-match seq?");
1184 }
1173 switch SCTP_GET_STATE
1174 (asoc) {
1175 case SCTP_STATE_COOKIE_WAIT:
1185 switch SCTP_GET_STATE
1186 (asoc) {
1187 case SCTP_STATE_COOKIE_WAIT:
1188 case SCTP_STATE_COOKIE_ECHOED:
1176 /*
1177 * INIT was sent, but got got a COOKIE_ECHO with the
1189 /*
1190 * INIT was sent, but got got a COOKIE_ECHO with the
1178 * correct tags... just accept it...
1191 * correct tags... just accept it...but we must
1192 * process the init so that we can make sure we have
1193 * the right seq no's.
1179 */
1180 /* First we must process the INIT !! */
1181 retval = sctp_process_init(init_cp, stcb, net);
1182 if (retval < 0) {
1194 */
1195 /* First we must process the INIT !! */
1196 retval = sctp_process_init(init_cp, stcb, net);
1197 if (retval < 0) {
1198 if (how_indx < sizeof(asoc->cookie_how))
1199 asoc->cookie_how[how_indx] = 3;
1183 return (NULL);
1184 }
1200 return (NULL);
1201 }
1185 /* intentional fall through to below... */
1186
1187 case SCTP_STATE_COOKIE_ECHOED:
1188 /* Duplicate INIT case */
1189 /* we have already processed the INIT so no problem */
1190 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb,
1191 net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_11);
1192 sctp_timer_stop(SCTP_TIMER_TYPE_INIT, inp, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_12);
1193 /* update current state */
1194 if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
1195 asoc->state = SCTP_STATE_OPEN |
1196 SCTP_STATE_SHUTDOWN_PENDING;

--- 44 unchanged lines hidden (view full) ---

1241 /*
1242 * We ignore the return code here.. not sure if we should
1243 * somehow abort.. but we do have an existing asoc. This
1244 * really should not fail.
1245 */
1246 if (sctp_load_addresses_from_init(stcb, m, iphlen,
1247 init_offset + sizeof(struct sctp_init_chunk),
1248 initack_offset, sh, init_src)) {
1202 /* we have already processed the INIT so no problem */
1203 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb,
1204 net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_11);
1205 sctp_timer_stop(SCTP_TIMER_TYPE_INIT, inp, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_12);
1206 /* update current state */
1207 if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
1208 asoc->state = SCTP_STATE_OPEN |
1209 SCTP_STATE_SHUTDOWN_PENDING;

--- 44 unchanged lines hidden (view full) ---

1254 /*
1255 * We ignore the return code here.. not sure if we should
1256 * somehow abort.. but we do have an existing asoc. This
1257 * really should not fail.
1258 */
1259 if (sctp_load_addresses_from_init(stcb, m, iphlen,
1260 init_offset + sizeof(struct sctp_init_chunk),
1261 initack_offset, sh, init_src)) {
1262 if (how_indx < sizeof(asoc->cookie_how))
1263 asoc->cookie_how[how_indx] = 4;
1249 return (NULL);
1250 }
1251 /* respond with a COOKIE-ACK */
1252 sctp_toss_old_cookies(stcb, asoc);
1253 sctp_send_cookie_ack(stcb);
1264 return (NULL);
1265 }
1266 /* respond with a COOKIE-ACK */
1267 sctp_toss_old_cookies(stcb, asoc);
1268 sctp_send_cookie_ack(stcb);
1269 if (how_indx < sizeof(asoc->cookie_how))
1270 asoc->cookie_how[how_indx] = 5;
1254 return (stcb);
1255 } /* end if */
1256 if (ntohl(initack_cp->init.initiate_tag) != asoc->my_vtag &&
1257 ntohl(init_cp->init.initiate_tag) == asoc->peer_vtag &&
1258 cookie->tie_tag_my_vtag == 0 &&
1259 cookie->tie_tag_peer_vtag == 0) {
1260 /*
1261 * case C in Section 5.2.4 Table 2: XMOO silently discard
1262 */
1271 return (stcb);
1272 } /* end if */
1273 if (ntohl(initack_cp->init.initiate_tag) != asoc->my_vtag &&
1274 ntohl(init_cp->init.initiate_tag) == asoc->peer_vtag &&
1275 cookie->tie_tag_my_vtag == 0 &&
1276 cookie->tie_tag_peer_vtag == 0) {
1277 /*
1278 * case C in Section 5.2.4 Table 2: XMOO silently discard
1279 */
1280 if (how_indx < sizeof(asoc->cookie_how))
1281 asoc->cookie_how[how_indx] = 6;
1263 return (NULL);
1264 }
1265 if (ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag &&
1266 (ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag ||
1267 init_cp->init.initiate_tag == 0)) {
1268 /*
1269 * case B in Section 5.2.4 Table 2: MXAA or MOAA my info
1270 * should be ok, re-accept peer info
1271 */
1282 return (NULL);
1283 }
1284 if (ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag &&
1285 (ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag ||
1286 init_cp->init.initiate_tag == 0)) {
1287 /*
1288 * case B in Section 5.2.4 Table 2: MXAA or MOAA my info
1289 * should be ok, re-accept peer info
1290 */
1291 if (ntohl(initack_cp->init.initial_tsn) != asoc->init_seq_number) {
1292 /*
1293 * Extension of case C. If we hit this, then the
1294 * random number generator returned the same vtag
1295 * when we first sent our INIT-ACK and when we later
1296 * sent our INIT. The side with the seq numbers that
1297 * are different will be the one that normnally
1298 * would have hit case C. This in effect "extends"
1299 * our vtags in this collision case to be 64 bits.
1300 * The same collision could occur aka you get both
1301 * vtag and seq number the same twice in a row.. but
1302 * is much less likely. If it did happen then we
1303 * would proceed through and bring up the assoc.. we
1304 * may end up with the wrong stream setup however..
1305 * which would be bad.. but there is no way to
1306 * tell.. until we send on a stream that does not
1307 * exist :-)
1308 */
1309 if (how_indx < sizeof(asoc->cookie_how))
1310 asoc->cookie_how[how_indx] = 7;
1311
1312 return (NULL);
1313 }
1314 if (how_indx < sizeof(asoc->cookie_how))
1315 asoc->cookie_how[how_indx] = 8;
1272 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_13);
1273 sctp_stop_all_cookie_timers(stcb);
1274 /*
1275 * since we did not send a HB make sure we don't double
1276 * things
1277 */
1278 net->hb_responded = 1;
1279 if (stcb->asoc.sctp_autoclose_ticks &&

--- 24 unchanged lines hidden (view full) ---

1304 spec_flag++;
1305 }
1306 }
1307
1308 }
1309 /* process the INIT info (peer's info) */
1310 retval = sctp_process_init(init_cp, stcb, net);
1311 if (retval < 0) {
1316 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_13);
1317 sctp_stop_all_cookie_timers(stcb);
1318 /*
1319 * since we did not send a HB make sure we don't double
1320 * things
1321 */
1322 net->hb_responded = 1;
1323 if (stcb->asoc.sctp_autoclose_ticks &&

--- 24 unchanged lines hidden (view full) ---

1348 spec_flag++;
1349 }
1350 }
1351
1352 }
1353 /* process the INIT info (peer's info) */
1354 retval = sctp_process_init(init_cp, stcb, net);
1355 if (retval < 0) {
1356 if (how_indx < sizeof(asoc->cookie_how))
1357 asoc->cookie_how[how_indx] = 9;
1312 return (NULL);
1313 }
1314 if (sctp_load_addresses_from_init(stcb, m, iphlen,
1315 init_offset + sizeof(struct sctp_init_chunk),
1316 initack_offset, sh, init_src)) {
1358 return (NULL);
1359 }
1360 if (sctp_load_addresses_from_init(stcb, m, iphlen,
1361 init_offset + sizeof(struct sctp_init_chunk),
1362 initack_offset, sh, init_src)) {
1363 if (how_indx < sizeof(asoc->cookie_how))
1364 asoc->cookie_how[how_indx] = 10;
1317 return (NULL);
1318 }
1319 if ((asoc->state & SCTP_STATE_COOKIE_WAIT) ||
1320 (asoc->state & SCTP_STATE_COOKIE_ECHOED)) {
1321 *notification = SCTP_NOTIFY_ASSOC_UP;
1322
1323 if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
1324 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) &&

--- 20 unchanged lines hidden (view full) ---

1345 * only if we have retrans set do we do this. What
1346 * this call does is get only the COOKIE-ACK out and
1347 * then when we return the normal call to
1348 * sctp_chunk_output will get the retrans out behind
1349 * this.
1350 */
1351 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_COOKIE_ACK);
1352 }
1365 return (NULL);
1366 }
1367 if ((asoc->state & SCTP_STATE_COOKIE_WAIT) ||
1368 (asoc->state & SCTP_STATE_COOKIE_ECHOED)) {
1369 *notification = SCTP_NOTIFY_ASSOC_UP;
1370
1371 if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
1372 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) &&

--- 20 unchanged lines hidden (view full) ---

1393 * only if we have retrans set do we do this. What
1394 * this call does is get only the COOKIE-ACK out and
1395 * then when we return the normal call to
1396 * sctp_chunk_output will get the retrans out behind
1397 * this.
1398 */
1399 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_COOKIE_ACK);
1400 }
1401 if (how_indx < sizeof(asoc->cookie_how))
1402 asoc->cookie_how[how_indx] = 11;
1403
1353 return (stcb);
1354 }
1355 if ((ntohl(initack_cp->init.initiate_tag) != asoc->my_vtag &&
1356 ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) &&
1357 cookie->tie_tag_my_vtag == asoc->my_vtag_nonce &&
1358 cookie->tie_tag_peer_vtag == asoc->peer_vtag_nonce &&
1359 cookie->tie_tag_peer_vtag != 0) {
1360 struct sctpasochead *head;
1361
1362 /*
1363 * case A in Section 5.2.4 Table 2: XXMM (peer restarted)
1364 */
1365 /* temp code */
1404 return (stcb);
1405 }
1406 if ((ntohl(initack_cp->init.initiate_tag) != asoc->my_vtag &&
1407 ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) &&
1408 cookie->tie_tag_my_vtag == asoc->my_vtag_nonce &&
1409 cookie->tie_tag_peer_vtag == asoc->peer_vtag_nonce &&
1410 cookie->tie_tag_peer_vtag != 0) {
1411 struct sctpasochead *head;
1412
1413 /*
1414 * case A in Section 5.2.4 Table 2: XXMM (peer restarted)
1415 */
1416 /* temp code */
1417 if (how_indx < sizeof(asoc->cookie_how))
1418 asoc->cookie_how[how_indx] = 12;
1366 sctp_timer_stop(SCTP_TIMER_TYPE_INIT, inp, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_14);
1367 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_15);
1368
1369 *sac_assoc_id = sctp_get_associd(stcb);
1370 /* notify upper layer */
1371 *notification = SCTP_NOTIFY_ASSOC_RESTART;
1372 atomic_add_int(&stcb->asoc.refcnt, 1);
1373 if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {

--- 59 unchanged lines hidden (view full) ---

1433 }
1434 /* process the INIT info (peer's info) */
1435 SCTP_TCB_SEND_UNLOCK(stcb);
1436 SCTP_INP_WUNLOCK(stcb->sctp_ep);
1437 SCTP_INP_INFO_WUNLOCK();
1438
1439 retval = sctp_process_init(init_cp, stcb, net);
1440 if (retval < 0) {
1419 sctp_timer_stop(SCTP_TIMER_TYPE_INIT, inp, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_14);
1420 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_15);
1421
1422 *sac_assoc_id = sctp_get_associd(stcb);
1423 /* notify upper layer */
1424 *notification = SCTP_NOTIFY_ASSOC_RESTART;
1425 atomic_add_int(&stcb->asoc.refcnt, 1);
1426 if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {

--- 59 unchanged lines hidden (view full) ---

1486 }
1487 /* process the INIT info (peer's info) */
1488 SCTP_TCB_SEND_UNLOCK(stcb);
1489 SCTP_INP_WUNLOCK(stcb->sctp_ep);
1490 SCTP_INP_INFO_WUNLOCK();
1491
1492 retval = sctp_process_init(init_cp, stcb, net);
1493 if (retval < 0) {
1494 if (how_indx < sizeof(asoc->cookie_how))
1495 asoc->cookie_how[how_indx] = 13;
1496
1441 return (NULL);
1442 }
1443 /*
1444 * since we did not send a HB make sure we don't double
1445 * things
1446 */
1447 net->hb_responded = 1;
1448
1449 if (sctp_load_addresses_from_init(stcb, m, iphlen,
1450 init_offset + sizeof(struct sctp_init_chunk),
1451 initack_offset, sh, init_src)) {
1497 return (NULL);
1498 }
1499 /*
1500 * since we did not send a HB make sure we don't double
1501 * things
1502 */
1503 net->hb_responded = 1;
1504
1505 if (sctp_load_addresses_from_init(stcb, m, iphlen,
1506 init_offset + sizeof(struct sctp_init_chunk),
1507 initack_offset, sh, init_src)) {
1508 if (how_indx < sizeof(asoc->cookie_how))
1509 asoc->cookie_how[how_indx] = 14;
1510
1452 return (NULL);
1453 }
1454 /* respond with a COOKIE-ACK */
1455 sctp_stop_all_cookie_timers(stcb);
1456 sctp_toss_old_cookies(stcb, asoc);
1457 sctp_send_cookie_ack(stcb);
1511 return (NULL);
1512 }
1513 /* respond with a COOKIE-ACK */
1514 sctp_stop_all_cookie_timers(stcb);
1515 sctp_toss_old_cookies(stcb, asoc);
1516 sctp_send_cookie_ack(stcb);
1517 if (how_indx < sizeof(asoc->cookie_how))
1518 asoc->cookie_how[how_indx] = 15;
1458
1459 return (stcb);
1460 }
1461 /* if we are not a restart we need the assoc_id field pop'd */
1462 asoc->assoc_id = ntohl(initack_cp->init.initiate_tag);
1519
1520 return (stcb);
1521 }
1522 /* if we are not a restart we need the assoc_id field pop'd */
1523 asoc->assoc_id = ntohl(initack_cp->init.initiate_tag);
1463
1524 if (how_indx < sizeof(asoc->cookie_how))
1525 asoc->cookie_how[how_indx] = 16;
1464 /* all other cases... */
1465 return (NULL);
1466}
1467
1468/*
1469 * handle a state cookie for a new association m: input packet mbuf chain--
1470 * assumes a pullup on IP/SCTP/COOKIE-ECHO chunk note: this is a "split" mbuf
1471 * and the cookie signature does not exist offset: offset into mbuf to the

--- 1599 unchanged lines hidden (view full) ---

3071 sctp_alloc_a_chunk(stcb, chk);
3072 if (chk == NULL) {
3073 return (ret_code);
3074 }
3075 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
3076 chk->asoc = &stcb->asoc;
3077 chk->no_fr_allowed = 0;
3078 chk->book_size = chk->send_size = sizeof(struct sctp_chunkhdr);
1526 /* all other cases... */
1527 return (NULL);
1528}
1529
1530/*
1531 * handle a state cookie for a new association m: input packet mbuf chain--
1532 * assumes a pullup on IP/SCTP/COOKIE-ECHO chunk note: this is a "split" mbuf
1533 * and the cookie signature does not exist offset: offset into mbuf to the

--- 1599 unchanged lines hidden (view full) ---

3133 sctp_alloc_a_chunk(stcb, chk);
3134 if (chk == NULL) {
3135 return (ret_code);
3136 }
3137 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
3138 chk->asoc = &stcb->asoc;
3139 chk->no_fr_allowed = 0;
3140 chk->book_size = chk->send_size = sizeof(struct sctp_chunkhdr);
3141 chk->book_size_scale = 0;
3079 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_DONTWAIT, 1, MT_DATA);
3080 if (chk->data == NULL) {
3081strres_nochunk:
3082 if (chk->data) {
3083 sctp_m_freem(chk->data);
3084 chk->data = NULL;
3085 }
3086 sctp_free_a_chunk(stcb, chk);

--- 1174 unchanged lines hidden (view full) ---

4261 * we did not bother to define a
4262 * error cause struct. They are the
4263 * same basic format with different
4264 * names.
4265 */
4266 phd->param_type = htons(SCTP_CAUSE_UNRECOG_CHUNK);
4267 phd->param_length = htons(chk_length + sizeof(*phd));
4268 SCTP_BUF_LEN(mm) = sizeof(*phd);
3142 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_DONTWAIT, 1, MT_DATA);
3143 if (chk->data == NULL) {
3144strres_nochunk:
3145 if (chk->data) {
3146 sctp_m_freem(chk->data);
3147 chk->data = NULL;
3148 }
3149 sctp_free_a_chunk(stcb, chk);

--- 1174 unchanged lines hidden (view full) ---

4324 * we did not bother to define a
4325 * error cause struct. They are the
4326 * same basic format with different
4327 * names.
4328 */
4329 phd->param_type = htons(SCTP_CAUSE_UNRECOG_CHUNK);
4330 phd->param_length = htons(chk_length + sizeof(*phd));
4331 SCTP_BUF_LEN(mm) = sizeof(*phd);
4269 SCTP_BUF_NEXT(mm) = sctp_m_copym(m, *offset, SCTP_SIZE32(chk_length),
4332 SCTP_BUF_NEXT(mm) = SCTP_M_COPYM(m, *offset, SCTP_SIZE32(chk_length),
4270 M_DONTWAIT);
4271 if (SCTP_BUF_NEXT(mm)) {
4272 sctp_queue_op_err(stcb, mm);
4273 } else {
4274 sctp_m_freem(mm);
4275 }
4276 }
4277 }

--- 404 unchanged lines hidden (view full) ---

4682 goto bad;
4683 }
4684 /* destination port of 0 is illegal, based on RFC2960. */
4685 if (sh->dest_port == 0) {
4686 SCTP_STAT_INCR(sctps_hdrops);
4687 goto bad;
4688 }
4689 /* validate SCTP checksum */
4333 M_DONTWAIT);
4334 if (SCTP_BUF_NEXT(mm)) {
4335 sctp_queue_op_err(stcb, mm);
4336 } else {
4337 sctp_m_freem(mm);
4338 }
4339 }
4340 }

--- 404 unchanged lines hidden (view full) ---

4745 goto bad;
4746 }
4747 /* destination port of 0 is illegal, based on RFC2960. */
4748 if (sh->dest_port == 0) {
4749 SCTP_STAT_INCR(sctps_hdrops);
4750 goto bad;
4751 }
4752 /* validate SCTP checksum */
4690 if ((sctp_no_csum_on_loopback == 0) ||
4691 SCTP_IS_IT_LOOPBACK(i_pak)) {
4753 if ((sctp_no_csum_on_loopback == 0) || !SCTP_IS_IT_LOOPBACK(i_pak)) {
4692 /*
4693 * we do NOT validate things from the loopback if the sysctl
4694 * is set to 1.
4695 */
4696 check = sh->checksum; /* save incoming checksum */
4697 if ((check == 0) && (sctp_no_csum_on_loopback)) {
4698 /*
4699 * special hook for where we got a local address

--- 35 unchanged lines hidden (view full) ---

4735 if (mlen < (ip->ip_len - iphlen)) {
4736 SCTP_STAT_INCR(sctps_hdrops);
4737 goto bad;
4738 } {
4739 /* TEMP log the first chunk */
4740 int x;
4741
4742 x = atomic_fetchadd_int(&sctp_buf_index, 1);
4754 /*
4755 * we do NOT validate things from the loopback if the sysctl
4756 * is set to 1.
4757 */
4758 check = sh->checksum; /* save incoming checksum */
4759 if ((check == 0) && (sctp_no_csum_on_loopback)) {
4760 /*
4761 * special hook for where we got a local address

--- 35 unchanged lines hidden (view full) ---

4797 if (mlen < (ip->ip_len - iphlen)) {
4798 SCTP_STAT_INCR(sctps_hdrops);
4799 goto bad;
4800 } {
4801 /* TEMP log the first chunk */
4802 int x;
4803
4804 x = atomic_fetchadd_int(&sctp_buf_index, 1);
4743 if (x > 30000) {
4805 if (x >= 30000) {
4744 sctp_buf_index = 1;
4745 x = 0;;
4746 }
4747 sctp_list_of_chunks[x] = ch->chunk_type;
4748 }
4749 /*
4750 * Locate pcb and tcb for datagram sctp_findassociation_addr() wants
4751 * IP/SCTP/first chunk header...

--- 100 unchanged lines hidden ---
4806 sctp_buf_index = 1;
4807 x = 0;;
4808 }
4809 sctp_list_of_chunks[x] = ch->chunk_type;
4810 }
4811 /*
4812 * Locate pcb and tcb for datagram sctp_findassociation_addr() wants
4813 * IP/SCTP/first chunk header...

--- 100 unchanged lines hidden ---