Deleted Added
full compact
sctp_asconf.c (171440) sctp_asconf.c (171477)
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 171440 2007-07-14 09:36:28Z rrs $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 171477 2007-07-17 20:58:26Z rrs $");
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>

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

89#endif /* INET6 */
90 else
91 return;
92}
93
94/*
95 * draft-ietf-tsvwg-addip-sctp
96 *
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>

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

89#endif /* INET6 */
90 else
91 return;
92}
93
94/*
95 * draft-ietf-tsvwg-addip-sctp
96 *
97 * Address management only currently supported For the bound all case: the asoc
98 * local addr list is always a "DO NOT USE" list For the subset bound case:
99 * If ASCONFs are allowed: the endpoint local addr list is the usable address
100 * list the asoc local addr list is the "DO NOT USE" list If ASCONFs are not
101 * allowed: the endpoint local addr list is the default usable list the asoc
102 * local addr list is the usable address list
103 *
104 * An ASCONF parameter queue exists per asoc which holds the pending address
105 * operations. Lists are updated upon receipt of ASCONF-ACK.
106 *
97 * An ASCONF parameter queue exists per asoc which holds the pending address
98 * operations. Lists are updated upon receipt of ASCONF-ACK.
99 *
100 * A restricted_addrs list exists per assoc to hold local addresses that are
101 * not (yet) usable by the assoc as a source address. These addresses are
102 * either pending an ASCONF operation (and exist on the ASCONF parameter
103 * queue), or they are permanently restricted (the peer has returned an
104 * ERROR indication to an ASCONF(ADD), or the peer does not support ASCONF).
105 *
107 * Deleted addresses are always immediately removed from the lists as they will
108 * (shortly) no longer exist in the kernel. We send ASCONFs as a courtesy,
109 * only if allowed.
110 */
111
112/*
106 * Deleted addresses are always immediately removed from the lists as they will
107 * (shortly) no longer exist in the kernel. We send ASCONFs as a courtesy,
108 * only if allowed.
109 */
110
111/*
113 * ASCONF parameter processing response_required: set if a reply is required
114 * (eg. SUCCESS_REPORT) returns a mbuf to an "error" response parameter or
115 * NULL/"success" if ok FIX: allocating this many mbufs on the fly is pretty
116 * inefficient...
112 * ASCONF parameter processing.
113 * response_required: set if a reply is required (eg. SUCCESS_REPORT).
114 * returns a mbuf to an "error" response parameter or NULL/"success" if ok.
115 * FIX: allocating this many mbufs on the fly is pretty inefficient...
117 */
118static struct mbuf *
119sctp_asconf_success_response(uint32_t id)
120{
121 struct mbuf *m_reply = NULL;
122 struct sctp_asconf_paramhdr *aph;
123
124 m_reply = sctp_get_mbuf_for_msg(sizeof(struct sctp_asconf_paramhdr),

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

903 * add an asconf add/delete IP address parameter to the queue.
904 * type = SCTP_ADD_IP_ADDRESS, SCTP_DEL_IP_ADDRESS, SCTP_SET_PRIM_ADDR.
905 * returns 0 if completed, non-zero if not completed.
906 * NOTE: if adding, but delete already scheduled (and not yet sent out),
907 * simply remove from queue. Same for deleting an address already scheduled
908 * for add. If a duplicate operation is found, ignore the new one.
909 */
910static uint32_t
116 */
117static struct mbuf *
118sctp_asconf_success_response(uint32_t id)
119{
120 struct mbuf *m_reply = NULL;
121 struct sctp_asconf_paramhdr *aph;
122
123 m_reply = sctp_get_mbuf_for_msg(sizeof(struct sctp_asconf_paramhdr),

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

902 * add an asconf add/delete IP address parameter to the queue.
903 * type = SCTP_ADD_IP_ADDRESS, SCTP_DEL_IP_ADDRESS, SCTP_SET_PRIM_ADDR.
904 * returns 0 if completed, non-zero if not completed.
905 * NOTE: if adding, but delete already scheduled (and not yet sent out),
906 * simply remove from queue. Same for deleting an address already scheduled
907 * for add. If a duplicate operation is found, ignore the new one.
908 */
909static uint32_t
911sctp_asconf_queue_add(struct sctp_tcb *stcb, struct sctp_ifa *ifa, uint16_t type)
910sctp_asconf_queue_add(struct sctp_tcb *stcb, struct sctp_ifa *ifa,
911 uint16_t type)
912{
913 struct sctp_asconf_addr *aa, *aa_next;
914 struct sockaddr *sa;
915
916 /* see if peer supports ASCONF */
917 if (stcb->asoc.peer_supports_asconf == 0) {
918 return (-1);
919 }

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

1218 break;
1219 default:
1220 break;
1221 }
1222 }
1223}
1224
1225/*
912{
913 struct sctp_asconf_addr *aa, *aa_next;
914 struct sockaddr *sa;
915
916 /* see if peer supports ASCONF */
917 if (stcb->asoc.peer_supports_asconf == 0) {
918 return (-1);
919 }

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

1218 break;
1219 default:
1220 break;
1221 }
1222 }
1223}
1224
1225/*
1226 * process an asconf queue param aparam: parameter to process, will be
1227 * removed from the queue flag: 1=success, 0=failure
1226 * process an asconf queue param.
1227 * aparam: parameter to process, will be removed from the queue.
1228 * flag: 1=success case, 0=failure case
1228 */
1229static void
1230sctp_asconf_process_param_ack(struct sctp_tcb *stcb,
1231 struct sctp_asconf_addr *aparam, uint32_t flag)
1232{
1233 uint16_t param_type;
1234
1235 /* process this param */

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

1427 aa = aa_next) {
1428 aa_next = TAILQ_NEXT(aa, next);
1429 if (aa->sent == 1) {
1430 /*
1431 * implicitly successful or failed if correlation_id
1432 * < last_error_id, then success else, failure
1433 */
1434 if (aa->ap.aph.correlation_id < last_error_id)
1229 */
1230static void
1231sctp_asconf_process_param_ack(struct sctp_tcb *stcb,
1232 struct sctp_asconf_addr *aparam, uint32_t flag)
1233{
1234 uint16_t param_type;
1235
1236 /* process this param */

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

1428 aa = aa_next) {
1429 aa_next = TAILQ_NEXT(aa, next);
1430 if (aa->sent == 1) {
1431 /*
1432 * implicitly successful or failed if correlation_id
1433 * < last_error_id, then success else, failure
1434 */
1435 if (aa->ap.aph.correlation_id < last_error_id)
1435 sctp_asconf_process_param_ack(stcb, aa,
1436 SCTP_SUCCESS_REPORT);
1436 sctp_asconf_process_param_ack(stcb, aa, 1);
1437 else
1437 else
1438 sctp_asconf_process_param_ack(stcb, aa,
1439 SCTP_ERROR_CAUSE_IND);
1438 sctp_asconf_process_param_ack(stcb, aa, 0);
1440 } else {
1441 /*
1442 * since we always process in order (FIFO queue) if
1443 * we reach one that hasn't been sent, the rest
1444 * should not have been sent either. so, we're
1445 * done...
1446 */
1447 break;

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

1524 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0)
1525 return;
1526 /* is the v6 addr really valid ? */
1527 if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) {
1528 return;
1529 }
1530 }
1531 /* put this address on the "pending/do not use yet" list */
1439 } else {
1440 /*
1441 * since we always process in order (FIFO queue) if
1442 * we reach one that hasn't been sent, the rest
1443 * should not have been sent either. so, we're
1444 * done...
1445 */
1446 break;

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

1523 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0)
1524 return;
1525 /* is the v6 addr really valid ? */
1526 if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) {
1527 return;
1528 }
1529 }
1530 /* put this address on the "pending/do not use yet" list */
1532 /*
1533 * Note: we do this primarily for the subset bind case We don't have
1534 * scoping flags at the EP level, so we must add link local/site
1535 * local addresses to the EP, then need to "negate" them here.
1536 * Recall that this routine is only called for the subset bound
1537 * w/ASCONF allowed case.
1538 */
1539 sctp_add_local_addr_assoc(stcb, ifa, 1);
1540 /*
1541 * check address scope if address is out of scope, don't queue
1542 * anything... note: this would leave the address on both inp and
1543 * asoc lists
1544 */
1545 if (ifa->address.sa.sa_family == AF_INET6) {
1546 struct sockaddr_in6 *sin6;

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

1819 stcb->asoc.ipv6_addr_legal,
1820 stcb->asoc.loopback_scope,
1821 stcb->asoc.ipv4_local_scope,
1822 stcb->asoc.local_scope,
1823 stcb->asoc.site_scope, 0) == 0) {
1824 continue;
1825 }
1826 }
1531 sctp_add_local_addr_assoc(stcb, ifa, 1);
1532 /*
1533 * check address scope if address is out of scope, don't queue
1534 * anything... note: this would leave the address on both inp and
1535 * asoc lists
1536 */
1537 if (ifa->address.sa.sa_family == AF_INET6) {
1538 struct sockaddr_in6 *sin6;

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

1811 stcb->asoc.ipv6_addr_legal,
1812 stcb->asoc.loopback_scope,
1813 stcb->asoc.ipv4_local_scope,
1814 stcb->asoc.local_scope,
1815 stcb->asoc.site_scope, 0) == 0) {
1816 continue;
1817 }
1818 }
1827
1828 }
1829 /* queue an asconf for this address add/delete */
1830 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF)) {
1831 /* does the peer do asconf? */
1832 if (stcb->asoc.peer_supports_asconf) {
1833 /* queue an asconf for this addr */
1834 status = sctp_asconf_queue_add(stcb, ifa, type);
1835 /*

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

2013 /* found a valid local address to use */
2014 return (&laddr->ifa->address.sa);
2015 }
2016 /* no valid addresses found */
2017 return (NULL);
2018}
2019
2020/*
1819 }
1820 /* queue an asconf for this address add/delete */
1821 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF)) {
1822 /* does the peer do asconf? */
1823 if (stcb->asoc.peer_supports_asconf) {
1824 /* queue an asconf for this addr */
1825 status = sctp_asconf_queue_add(stcb, ifa, type);
1826 /*

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

2004 /* found a valid local address to use */
2005 return (&laddr->ifa->address.sa);
2006 }
2007 /* no valid addresses found */
2008 return (NULL);
2009}
2010
2011/*
2021 * builds an ASCONF chunk from queued ASCONF params returns NULL on error (no
2022 * mbuf, no ASCONF params queued, etc)
2012 * builds an ASCONF chunk from queued ASCONF params.
2013 * returns NULL on error (no mbuf, no ASCONF params queued, etc).
2023 */
2024struct mbuf *
2025sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen)
2026{
2027 struct mbuf *m_asconf, *m_asconf_chk;
2028 struct sctp_asconf_addr *aa;
2029 struct sctp_asconf_chunk *acp;
2030 struct sctp_asconf_paramhdr *aph;

--- 594 unchanged lines hidden ---
2014 */
2015struct mbuf *
2016sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen)
2017{
2018 struct mbuf *m_asconf, *m_asconf_chk;
2019 struct sctp_asconf_addr *aa;
2020 struct sctp_asconf_chunk *acp;
2021 struct sctp_asconf_paramhdr *aph;

--- 594 unchanged lines hidden ---