sctp_asconf.c (216821) | sctp_asconf.c (216822) |
---|---|
1/*- 2 * Copyright (c) 2001-2007, by 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_asconf.c,v 1.24 2005/03/06 16:04:16 itojun Exp $ */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2007, by 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_asconf.c,v 1.24 2005/03/06 16:04:16 itojun Exp $ */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 216821 2010-12-30 16:23:13Z tuexen $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 216822 2010-12-30 16:56:20Z tuexen $"); |
35#include <netinet/sctp_os.h> 36#include <netinet/sctp_var.h> 37#include <netinet/sctp_sysctl.h> 38#include <netinet/sctp_pcb.h> 39#include <netinet/sctp_header.h> 40#include <netinet/sctputil.h> 41#include <netinet/sctp_output.h> 42#include <netinet/sctp_asconf.h> --- 608 unchanged lines hidden (view full) --- 651 SCTPDBG(SCTP_DEBUG_ASCONF1, 652 "handle_asconf: asconf_limit=%u, sequence=%xh\n", 653 asconf_limit, serial_num); 654 655 if (first) { 656 /* delete old cache */ 657 SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: Now processing firstASCONF. Try to delte old cache\n"); 658 | 35#include <netinet/sctp_os.h> 36#include <netinet/sctp_var.h> 37#include <netinet/sctp_sysctl.h> 38#include <netinet/sctp_pcb.h> 39#include <netinet/sctp_header.h> 40#include <netinet/sctputil.h> 41#include <netinet/sctp_output.h> 42#include <netinet/sctp_asconf.h> --- 608 unchanged lines hidden (view full) --- 651 SCTPDBG(SCTP_DEBUG_ASCONF1, 652 "handle_asconf: asconf_limit=%u, sequence=%xh\n", 653 asconf_limit, serial_num); 654 655 if (first) { 656 /* delete old cache */ 657 SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: Now processing firstASCONF. Try to delte old cache\n"); 658 |
659 ack = TAILQ_FIRST(&stcb->asoc.asconf_ack_sent); 660 while (ack != NULL) { 661 ack_next = TAILQ_NEXT(ack, next); | 659 TAILQ_FOREACH_SAFE(ack, &asoc->asconf_ack_sent, next, ack_next) { |
662 if (ack->serial_number == serial_num) 663 break; 664 SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: delete old(%u) < first(%u)\n", 665 ack->serial_number, serial_num); | 660 if (ack->serial_number == serial_num) 661 break; 662 SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: delete old(%u) < first(%u)\n", 663 ack->serial_number, serial_num); |
666 TAILQ_REMOVE(&stcb->asoc.asconf_ack_sent, ack, next); | 664 TAILQ_REMOVE(&asoc->asconf_ack_sent, ack, next); |
667 if (ack->data != NULL) { 668 sctp_m_freem(ack->data); 669 } 670 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_asconf_ack), ack); | 665 if (ack->data != NULL) { 666 sctp_m_freem(ack->data); 667 } 668 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_asconf_ack), ack); |
671 ack = ack_next; | |
672 } 673 } 674 m_ack = sctp_get_mbuf_for_msg(sizeof(struct sctp_asconf_ack_chunk), 0, 675 M_DONTWAIT, 1, MT_DATA); 676 if (m_ack == NULL) { 677 SCTPDBG(SCTP_DEBUG_ASCONF1, 678 "handle_asconf: couldn't get mbuf!\n"); 679 return; --- 579 unchanged lines hidden (view full) --- 1259static int 1260sctp_asconf_queue_mgmt(struct sctp_tcb *stcb, struct sctp_ifa *ifa, 1261 uint16_t type) 1262{ 1263 struct sctp_asconf_addr *aa, *aa_next; 1264 struct sockaddr *sa; 1265 1266 /* make sure the request isn't already in the queue */ | 669 } 670 } 671 m_ack = sctp_get_mbuf_for_msg(sizeof(struct sctp_asconf_ack_chunk), 0, 672 M_DONTWAIT, 1, MT_DATA); 673 if (m_ack == NULL) { 674 SCTPDBG(SCTP_DEBUG_ASCONF1, 675 "handle_asconf: couldn't get mbuf!\n"); 676 return; --- 579 unchanged lines hidden (view full) --- 1256static int 1257sctp_asconf_queue_mgmt(struct sctp_tcb *stcb, struct sctp_ifa *ifa, 1258 uint16_t type) 1259{ 1260 struct sctp_asconf_addr *aa, *aa_next; 1261 struct sockaddr *sa; 1262 1263 /* make sure the request isn't already in the queue */ |
1267 for (aa = TAILQ_FIRST(&stcb->asoc.asconf_queue); aa != NULL; 1268 aa = aa_next) { 1269 aa_next = TAILQ_NEXT(aa, next); | 1264 TAILQ_FOREACH_SAFE(aa, &stcb->asoc.asconf_queue, next, aa_next) { |
1270 /* address match? */ 1271 if (sctp_asconf_addr_match(aa, &ifa->address.sa) == 0) 1272 continue; 1273 /* 1274 * is the request already in queue but not sent? pass the 1275 * request already sent in order to resolve the following 1276 * case: 1. arrival of ADD, then sent 2. arrival of DEL. we 1277 * can't remove the ADD request already sent 3. arrival of --- 197 unchanged lines hidden (view full) --- 1475 if (stcb == NULL) { 1476 return (-1); 1477 } 1478 /* see if peer supports ASCONF */ 1479 if (stcb->asoc.peer_supports_asconf == 0) { 1480 return (-1); 1481 } 1482 /* make sure the request isn't already in the queue */ | 1265 /* address match? */ 1266 if (sctp_asconf_addr_match(aa, &ifa->address.sa) == 0) 1267 continue; 1268 /* 1269 * is the request already in queue but not sent? pass the 1270 * request already sent in order to resolve the following 1271 * case: 1. arrival of ADD, then sent 2. arrival of DEL. we 1272 * can't remove the ADD request already sent 3. arrival of --- 197 unchanged lines hidden (view full) --- 1470 if (stcb == NULL) { 1471 return (-1); 1472 } 1473 /* see if peer supports ASCONF */ 1474 if (stcb->asoc.peer_supports_asconf == 0) { 1475 return (-1); 1476 } 1477 /* make sure the request isn't already in the queue */ |
1483 for (aa = TAILQ_FIRST(&stcb->asoc.asconf_queue); aa != NULL; 1484 aa = aa_next) { 1485 aa_next = TAILQ_NEXT(aa, next); | 1478 TAILQ_FOREACH_SAFE(aa, &stcb->asoc.asconf_queue, next, aa_next) { |
1486 /* address match? */ 1487 if (sctp_asconf_addr_match(aa, sa) == 0) 1488 continue; 1489 /* is the request already in queue (sent or not) */ 1490 if (aa->ap.aph.ph.param_type == SCTP_DEL_IP_ADDRESS) { 1491 return (-1); 1492 } 1493 /* is the negative request already in queue, and not sent */ --- 337 unchanged lines hidden (view full) --- 1831 * so process these appropriately 1832 * 1833 * we assume that the correlation_id's are monotonically increasing 1834 * beginning from 1 and that we don't have *that* many outstanding 1835 * at any given time 1836 */ 1837 if (last_error_id == 0) 1838 last_error_id--;/* set to "max" value */ | 1479 /* address match? */ 1480 if (sctp_asconf_addr_match(aa, sa) == 0) 1481 continue; 1482 /* is the request already in queue (sent or not) */ 1483 if (aa->ap.aph.ph.param_type == SCTP_DEL_IP_ADDRESS) { 1484 return (-1); 1485 } 1486 /* is the negative request already in queue, and not sent */ --- 337 unchanged lines hidden (view full) --- 1824 * so process these appropriately 1825 * 1826 * we assume that the correlation_id's are monotonically increasing 1827 * beginning from 1 and that we don't have *that* many outstanding 1828 * at any given time 1829 */ 1830 if (last_error_id == 0) 1831 last_error_id--;/* set to "max" value */ |
1839 for (aa = TAILQ_FIRST(&stcb->asoc.asconf_queue); aa != NULL; 1840 aa = aa_next) { 1841 aa_next = TAILQ_NEXT(aa, next); | 1832 TAILQ_FOREACH_SAFE(aa, &stcb->asoc.asconf_queue, next, aa_next) { |
1842 if (aa->sent == 1) { 1843 /* 1844 * implicitly successful or failed if correlation_id 1845 * < last_error_id, then success else, failure 1846 */ 1847 if (aa->ap.aph.correlation_id < last_error_id) 1848 sctp_asconf_process_param_ack(stcb, aa, 1); 1849 else --- 243 unchanged lines hidden (view full) --- 2093 LIST_FOREACH(laddr, &inp->sctp_addr_list, 2094 sctp_nxt_addr) { 2095 if (laddr->ifa == ifa) { 2096 laddr->action = 0; 2097 break; 2098 } 2099 } 2100 } else if (l->action == SCTP_DEL_IP_ADDRESS) { | 1833 if (aa->sent == 1) { 1834 /* 1835 * implicitly successful or failed if correlation_id 1836 * < last_error_id, then success else, failure 1837 */ 1838 if (aa->ap.aph.correlation_id < last_error_id) 1839 sctp_asconf_process_param_ack(stcb, aa, 1); 1840 else --- 243 unchanged lines hidden (view full) --- 2084 LIST_FOREACH(laddr, &inp->sctp_addr_list, 2085 sctp_nxt_addr) { 2086 if (laddr->ifa == ifa) { 2087 laddr->action = 0; 2088 break; 2089 } 2090 } 2091 } else if (l->action == SCTP_DEL_IP_ADDRESS) { |
2101 laddr = LIST_FIRST(&inp->sctp_addr_list); 2102 while (laddr) { 2103 nladdr = LIST_NEXT(laddr, sctp_nxt_addr); | 2092 LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) { |
2104 /* remove only after all guys are done */ 2105 if (laddr->ifa == ifa) { 2106 sctp_del_local_addr_ep(inp, ifa); 2107 } | 2093 /* remove only after all guys are done */ 2094 if (laddr->ifa == ifa) { 2095 sctp_del_local_addr_ep(inp, ifa); 2096 } |
2108 laddr = nladdr; | |
2109 } 2110 } 2111 } 2112 return (0); 2113} 2114 2115void 2116sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, --- 163 unchanged lines hidden (view full) --- 2280 } 2281} 2282 2283void 2284sctp_asconf_iterator_end(void *ptr, uint32_t val) 2285{ 2286 struct sctp_asconf_iterator *asc; 2287 struct sctp_ifa *ifa; | 2097 } 2098 } 2099 } 2100 return (0); 2101} 2102 2103void 2104sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, --- 163 unchanged lines hidden (view full) --- 2268 } 2269} 2270 2271void 2272sctp_asconf_iterator_end(void *ptr, uint32_t val) 2273{ 2274 struct sctp_asconf_iterator *asc; 2275 struct sctp_ifa *ifa; |
2288 struct sctp_laddr *l, *l_next; | 2276 struct sctp_laddr *l, *nl; |
2289 2290 asc = (struct sctp_asconf_iterator *)ptr; | 2277 2278 asc = (struct sctp_asconf_iterator *)ptr; |
2291 l = LIST_FIRST(&asc->list_of_work); 2292 while (l != NULL) { 2293 l_next = LIST_NEXT(l, sctp_nxt_addr); | 2279 LIST_FOREACH_SAFE(l, &asc->list_of_work, sctp_nxt_addr, nl) { |
2294 ifa = l->ifa; 2295 if (l->action == SCTP_ADD_IP_ADDRESS) { 2296 /* Clear the defer use flag */ 2297 ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE; 2298 } 2299 sctp_free_ifa(ifa); 2300 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_laddr), l); 2301 SCTP_DECR_LADDR_COUNT(); | 2280 ifa = l->ifa; 2281 if (l->action == SCTP_ADD_IP_ADDRESS) { 2282 /* Clear the defer use flag */ 2283 ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE; 2284 } 2285 sctp_free_ifa(ifa); 2286 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_laddr), l); 2287 SCTP_DECR_LADDR_COUNT(); |
2302 l = l_next; | |
2303 } 2304 SCTP_FREE(asc, SCTP_M_ASC_IT); 2305} 2306 2307/* 2308 * sa is the sockaddr to ask the peer to set primary to. 2309 * returns: 0 = completed, -1 = error 2310 */ --- 78 unchanged lines hidden (view full) --- 2389 struct sctp_asconf_paramhdr *aph; 2390 uint8_t aparam_buf[SCTP_PARAM_BUFFER_SIZE]; 2391 struct sctp_ipv6addr_param *p_addr; 2392 int add_cnt, del_cnt; 2393 uint16_t last_param_type; 2394 2395 add_cnt = del_cnt = 0; 2396 last_param_type = 0; | 2288 } 2289 SCTP_FREE(asc, SCTP_M_ASC_IT); 2290} 2291 2292/* 2293 * sa is the sockaddr to ask the peer to set primary to. 2294 * returns: 0 = completed, -1 = error 2295 */ --- 78 unchanged lines hidden (view full) --- 2374 struct sctp_asconf_paramhdr *aph; 2375 uint8_t aparam_buf[SCTP_PARAM_BUFFER_SIZE]; 2376 struct sctp_ipv6addr_param *p_addr; 2377 int add_cnt, del_cnt; 2378 uint16_t last_param_type; 2379 2380 add_cnt = del_cnt = 0; 2381 last_param_type = 0; |
2397 for (chk = TAILQ_FIRST(&stcb->asoc.asconf_send_queue); chk != NULL; 2398 chk = nchk) { 2399 /* get next chk */ 2400 nchk = TAILQ_NEXT(chk, sctp_next); 2401 | 2382 TAILQ_FOREACH_SAFE(chk, &stcb->asoc.asconf_send_queue, sctp_next, nchk) { |
2402 if (chk->data == NULL) { 2403 SCTPDBG(SCTP_DEBUG_ASCONF1, "is_addr_pending: No mbuf data?\n"); 2404 continue; 2405 } 2406 offset = 0; 2407 acp = mtod(chk->data, struct sctp_asconf_chunk *); 2408 offset += sizeof(struct sctp_asconf_chunk); 2409 asconf_limit = ntohs(acp->ch.chunk_length); --- 986 unchanged lines hidden --- | 2383 if (chk->data == NULL) { 2384 SCTPDBG(SCTP_DEBUG_ASCONF1, "is_addr_pending: No mbuf data?\n"); 2385 continue; 2386 } 2387 offset = 0; 2388 acp = mtod(chk->data, struct sctp_asconf_chunk *); 2389 offset += sizeof(struct sctp_asconf_chunk); 2390 asconf_limit = ntohs(acp->ch.chunk_length); --- 986 unchanged lines hidden --- |