Deleted Added
full compact
sctp_output.c (236956) sctp_output.c (237049)
1/*-
2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
4 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

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

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
4 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

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

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 236956 2012-06-12 13:15:27Z tuexen $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 237049 2012-06-14 06:54:48Z tuexen $");
35
36#include <netinet/sctp_os.h>
37#include <sys/proc.h>
38#include <netinet/sctp_var.h>
39#include <netinet/sctp_sysctl.h>
40#include <netinet/sctp_header.h>
41#include <netinet/sctp_pcb.h>
42#include <netinet/sctputil.h>

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

3854 uint16_t auth_keyid,
3855 int nofragment_flag,
3856 int ecn_ok,
3857 int out_of_asoc_ok,
3858 uint16_t src_port,
3859 uint16_t dest_port,
3860 uint32_t v_tag,
3861 uint16_t port,
35
36#include <netinet/sctp_os.h>
37#include <sys/proc.h>
38#include <netinet/sctp_var.h>
39#include <netinet/sctp_sysctl.h>
40#include <netinet/sctp_header.h>
41#include <netinet/sctp_pcb.h>
42#include <netinet/sctputil.h>

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

3854 uint16_t auth_keyid,
3855 int nofragment_flag,
3856 int ecn_ok,
3857 int out_of_asoc_ok,
3858 uint16_t src_port,
3859 uint16_t dest_port,
3860 uint32_t v_tag,
3861 uint16_t port,
3862 union sctp_sockstore *over_addr,
3863 uint8_t use_mflowid, uint32_t mflowid,
3862#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
3864#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
3863 int so_locked SCTP_UNUSED,
3865 int so_locked SCTP_UNUSED
3864#else
3866#else
3865 int so_locked,
3867 int so_locked
3866#endif
3868#endif
3867 union sctp_sockstore *over_addr,
3868 struct mbuf *init
3869)
3870/* nofragment_flag to tell if IP_DF should be set (IPv4 only) */
3871{
3872 /**
3873 * Given a mbuf chain (via SCTP_BUF_NEXT()) that holds a packet header
3874 * WITH an SCTPHDR but no IP header, endpoint inp and sa structure:
3875 * - fill in the HMAC digest of any AUTH chunk in the packet.
3876 * - calculate and fill in the SCTP checksum.

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

3946#ifdef INVARIANTS
3947 if (net->flowidset == 0) {
3948 panic("Flow ID not set");
3949 }
3950#endif
3951 m->m_pkthdr.flowid = net->flowid;
3952 m->m_flags |= M_FLOWID;
3953 } else {
3869)
3870/* nofragment_flag to tell if IP_DF should be set (IPv4 only) */
3871{
3872 /**
3873 * Given a mbuf chain (via SCTP_BUF_NEXT()) that holds a packet header
3874 * WITH an SCTPHDR but no IP header, endpoint inp and sa structure:
3875 * - fill in the HMAC digest of any AUTH chunk in the packet.
3876 * - calculate and fill in the SCTP checksum.

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

3946#ifdef INVARIANTS
3947 if (net->flowidset == 0) {
3948 panic("Flow ID not set");
3949 }
3950#endif
3951 m->m_pkthdr.flowid = net->flowid;
3952 m->m_flags |= M_FLOWID;
3953 } else {
3954 if ((init != NULL) && (init->m_flags & M_FLOWID)) {
3955 m->m_pkthdr.flowid = init->m_pkthdr.flowid;
3954 if (use_mflowid != 0) {
3955 m->m_pkthdr.flowid = mflowid;
3956 m->m_flags |= M_FLOWID;
3957 }
3958 }
3959 packet_length = sctp_calculate_len(m);
3960 ip = mtod(m, struct ip *);
3961 ip->ip_v = IPVERSION;
3962 ip->ip_hl = (sizeof(struct ip) >> 2);
3963 if (tos_value == 0) {

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

4238#ifdef INVARIANTS
4239 if (net->flowidset == 0) {
4240 panic("Flow ID not set");
4241 }
4242#endif
4243 m->m_pkthdr.flowid = net->flowid;
4244 m->m_flags |= M_FLOWID;
4245 } else {
3956 m->m_flags |= M_FLOWID;
3957 }
3958 }
3959 packet_length = sctp_calculate_len(m);
3960 ip = mtod(m, struct ip *);
3961 ip->ip_v = IPVERSION;
3962 ip->ip_hl = (sizeof(struct ip) >> 2);
3963 if (tos_value == 0) {

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

4238#ifdef INVARIANTS
4239 if (net->flowidset == 0) {
4240 panic("Flow ID not set");
4241 }
4242#endif
4243 m->m_pkthdr.flowid = net->flowid;
4244 m->m_flags |= M_FLOWID;
4245 } else {
4246 if ((init != NULL) && (init->m_flags & M_FLOWID)) {
4247 m->m_pkthdr.flowid = init->m_pkthdr.flowid;
4246 if (use_mflowid != 0) {
4247 m->m_pkthdr.flowid = mflowid;
4248 m->m_flags |= M_FLOWID;
4249 }
4250 }
4251 packet_length = sctp_calculate_len(m);
4252
4253 ip6h = mtod(m, struct ip6_hdr *);
4254 /* protect *sin6 from overwrite */
4255 sin6 = (struct sockaddr_in6 *)to;

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

4836 return;
4837 }
4838 }
4839 SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - calls lowlevel_output\n");
4840 ret = sctp_lowlevel_chunk_output(inp, stcb, net,
4841 (struct sockaddr *)&net->ro._l_addr,
4842 m, 0, NULL, 0, 0, 0, 0,
4843 inp->sctp_lport, stcb->rport, htonl(0),
4248 m->m_flags |= M_FLOWID;
4249 }
4250 }
4251 packet_length = sctp_calculate_len(m);
4252
4253 ip6h = mtod(m, struct ip6_hdr *);
4254 /* protect *sin6 from overwrite */
4255 sin6 = (struct sockaddr_in6 *)to;

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

4836 return;
4837 }
4838 }
4839 SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - calls lowlevel_output\n");
4840 ret = sctp_lowlevel_chunk_output(inp, stcb, net,
4841 (struct sockaddr *)&net->ro._l_addr,
4842 m, 0, NULL, 0, 0, 0, 0,
4843 inp->sctp_lport, stcb->rport, htonl(0),
4844 net->port, so_locked, NULL, NULL);
4844 net->port, NULL,
4845 0, 0,
4846 so_locked);
4845 SCTPDBG(SCTP_DEBUG_OUTPUT4, "lowlevel_output - %d\n", ret);
4846 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
4847 (void)SCTP_GETTIME_TIMEVAL(&net->last_sent_time);
4848}
4849
4850struct mbuf *
4851sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
4852 int param_offset, int *abort_processing, struct sctp_chunkhdr *cp, int *nat_friendly)

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

5365/*
5366 * Given a MBUF chain that was sent into us containing an INIT. Build a
5367 * INIT-ACK with COOKIE and send back. We assume that the in_initpkt has done
5368 * a pullup to include IPv6/4header, SCTP header and initial part of INIT
5369 * message (i.e. the struct sctp_init_msg).
5370 */
5371void
5372sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
4847 SCTPDBG(SCTP_DEBUG_OUTPUT4, "lowlevel_output - %d\n", ret);
4848 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
4849 (void)SCTP_GETTIME_TIMEVAL(&net->last_sent_time);
4850}
4851
4852struct mbuf *
4853sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
4854 int param_offset, int *abort_processing, struct sctp_chunkhdr *cp, int *nat_friendly)

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

5367/*
5368 * Given a MBUF chain that was sent into us containing an INIT. Build a
5369 * INIT-ACK with COOKIE and send back. We assume that the in_initpkt has done
5370 * a pullup to include IPv6/4header, SCTP header and initial part of INIT
5371 * message (i.e. the struct sctp_init_msg).
5372 */
5373void
5374sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
5373 struct mbuf *init_pkt, int iphlen, int offset, struct sctphdr *sh,
5374 struct sctp_init_chunk *init_chk, uint32_t vrf_id, uint16_t port, int hold_inp_lock)
5375 struct mbuf *init_pkt, int iphlen, int offset,
5376 struct sctphdr *sh, struct sctp_init_chunk *init_chk,
5377 uint8_t use_mflowid, uint32_t mflowid,
5378 uint32_t vrf_id, uint16_t port, int hold_inp_lock)
5375{
5376 struct sctp_association *asoc;
5377 struct mbuf *m, *m_at, *m_tmp, *m_cookie, *op_err, *mp_last;
5378 struct sctp_init_ack_chunk *initack;
5379 struct sctp_adaptation_layer_indication *ali;
5380 struct sctp_ecn_supported_param *ecn;
5381 struct sctp_prsctp_supported_param *prsctp;
5382 struct sctp_supported_chunk_types_param *pr_supported;

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

5417 (SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT) &&
5418 (sctp_are_there_new_addresses(asoc, init_pkt, offset))) {
5419 /* new addresses, out of here in non-cookie-wait states */
5420 /*
5421 * Send a ABORT, we don't add the new address error clause
5422 * though we even set the T bit and copy in the 0 tag.. this
5423 * looks no different than if no listener was present.
5424 */
5379{
5380 struct sctp_association *asoc;
5381 struct mbuf *m, *m_at, *m_tmp, *m_cookie, *op_err, *mp_last;
5382 struct sctp_init_ack_chunk *initack;
5383 struct sctp_adaptation_layer_indication *ali;
5384 struct sctp_ecn_supported_param *ecn;
5385 struct sctp_prsctp_supported_param *prsctp;
5386 struct sctp_supported_chunk_types_param *pr_supported;

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

5421 (SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT) &&
5422 (sctp_are_there_new_addresses(asoc, init_pkt, offset))) {
5423 /* new addresses, out of here in non-cookie-wait states */
5424 /*
5425 * Send a ABORT, we don't add the new address error clause
5426 * though we even set the T bit and copy in the 0 tag.. this
5427 * looks no different than if no listener was present.
5428 */
5425 sctp_send_abort(init_pkt, iphlen, sh, 0, NULL, vrf_id, port);
5429 sctp_send_abort(init_pkt, iphlen, sh, 0, NULL,
5430 use_mflowid, mflowid,
5431 vrf_id, port);
5426 return;
5427 }
5428 abort_flag = 0;
5429 op_err = sctp_arethere_unrecognized_parameters(init_pkt,
5430 (offset + sizeof(struct sctp_init_chunk)),
5431 &abort_flag, (struct sctp_chunkhdr *)init_chk, &nat_friendly);
5432 if (abort_flag) {
5433do_a_abort:
5434 sctp_send_abort(init_pkt, iphlen, sh,
5432 return;
5433 }
5434 abort_flag = 0;
5435 op_err = sctp_arethere_unrecognized_parameters(init_pkt,
5436 (offset + sizeof(struct sctp_init_chunk)),
5437 &abort_flag, (struct sctp_chunkhdr *)init_chk, &nat_friendly);
5438 if (abort_flag) {
5439do_a_abort:
5440 sctp_send_abort(init_pkt, iphlen, sh,
5435 init_chk->init.initiate_tag, op_err, vrf_id, port);
5441 init_chk->init.initiate_tag, op_err,
5442 use_mflowid, mflowid,
5443 vrf_id, port);
5436 return;
5437 }
5438 m = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_DONTWAIT, 1, MT_DATA);
5439 if (m == NULL) {
5440 /* No memory, INIT timer will re-attempt. */
5441 if (op_err)
5442 sctp_m_freem(op_err);
5443 return;

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

6029 over_addr = &store1;
6030 } else {
6031 over_addr = NULL;
6032 }
6033
6034 (void)sctp_lowlevel_chunk_output(inp, NULL, NULL, to, m, 0, NULL, 0, 0,
6035 0, 0,
6036 inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag,
5444 return;
5445 }
5446 m = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_DONTWAIT, 1, MT_DATA);
5447 if (m == NULL) {
5448 /* No memory, INIT timer will re-attempt. */
5449 if (op_err)
5450 sctp_m_freem(op_err);
5451 return;

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

6037 over_addr = &store1;
6038 } else {
6039 over_addr = NULL;
6040 }
6041
6042 (void)sctp_lowlevel_chunk_output(inp, NULL, NULL, to, m, 0, NULL, 0, 0,
6043 0, 0,
6044 inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag,
6037 port, SCTP_SO_NOT_LOCKED, over_addr, init_pkt);
6045 port, over_addr,
6046 use_mflowid, mflowid,
6047 SCTP_SO_NOT_LOCKED);
6038 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
6039}
6040
6041
6042static void
6043sctp_prune_prsctp(struct sctp_tcb *stcb,
6044 struct sctp_association *asoc,
6045 struct sctp_sndrcvinfo *srcv,

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

8111 */
8112 if ((error = sctp_lowlevel_chunk_output(inp, stcb, net,
8113 (struct sockaddr *)&net->ro._l_addr,
8114 outchain, auth_offset, auth,
8115 stcb->asoc.authinfo.active_keyid,
8116 no_fragmentflg, 0, asconf,
8117 inp->sctp_lport, stcb->rport,
8118 htonl(stcb->asoc.peer_vtag),
6048 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
6049}
6050
6051
6052static void
6053sctp_prune_prsctp(struct sctp_tcb *stcb,
6054 struct sctp_association *asoc,
6055 struct sctp_sndrcvinfo *srcv,

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

8121 */
8122 if ((error = sctp_lowlevel_chunk_output(inp, stcb, net,
8123 (struct sockaddr *)&net->ro._l_addr,
8124 outchain, auth_offset, auth,
8125 stcb->asoc.authinfo.active_keyid,
8126 no_fragmentflg, 0, asconf,
8127 inp->sctp_lport, stcb->rport,
8128 htonl(stcb->asoc.peer_vtag),
8119 net->port, so_locked, NULL, NULL))) {
8129 net->port, NULL,
8130 0, 0,
8131 so_locked))) {
8120 if (error == ENOBUFS) {
8121 asoc->ifp_had_enobuf = 1;
8122 SCTP_STAT_INCR(sctps_lowlevelerr);
8123 }
8124 if (from_where == 0) {
8125 SCTP_STAT_INCR(sctps_lowlevelerrusr);
8126 }
8127 if (*now_filled == 0) {

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

8383 if ((error = sctp_lowlevel_chunk_output(inp, stcb, net,
8384 (struct sockaddr *)&net->ro._l_addr,
8385 outchain,
8386 auth_offset, auth,
8387 stcb->asoc.authinfo.active_keyid,
8388 no_fragmentflg, 0, asconf,
8389 inp->sctp_lport, stcb->rport,
8390 htonl(stcb->asoc.peer_vtag),
8132 if (error == ENOBUFS) {
8133 asoc->ifp_had_enobuf = 1;
8134 SCTP_STAT_INCR(sctps_lowlevelerr);
8135 }
8136 if (from_where == 0) {
8137 SCTP_STAT_INCR(sctps_lowlevelerrusr);
8138 }
8139 if (*now_filled == 0) {

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

8395 if ((error = sctp_lowlevel_chunk_output(inp, stcb, net,
8396 (struct sockaddr *)&net->ro._l_addr,
8397 outchain,
8398 auth_offset, auth,
8399 stcb->asoc.authinfo.active_keyid,
8400 no_fragmentflg, 0, asconf,
8401 inp->sctp_lport, stcb->rport,
8402 htonl(stcb->asoc.peer_vtag),
8391 net->port, so_locked, NULL, NULL))) {
8403 net->port, NULL,
8404 0, 0,
8405 so_locked))) {
8392 if (error == ENOBUFS) {
8393 asoc->ifp_had_enobuf = 1;
8394 SCTP_STAT_INCR(sctps_lowlevelerr);
8395 }
8396 if (from_where == 0) {
8397 SCTP_STAT_INCR(sctps_lowlevelerrusr);
8398 }
8399 /* error, could not output */

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

8722 auth_offset,
8723 auth,
8724 auth_keyid,
8725 no_fragmentflg,
8726 bundle_at,
8727 asconf,
8728 inp->sctp_lport, stcb->rport,
8729 htonl(stcb->asoc.peer_vtag),
8406 if (error == ENOBUFS) {
8407 asoc->ifp_had_enobuf = 1;
8408 SCTP_STAT_INCR(sctps_lowlevelerr);
8409 }
8410 if (from_where == 0) {
8411 SCTP_STAT_INCR(sctps_lowlevelerrusr);
8412 }
8413 /* error, could not output */

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

8736 auth_offset,
8737 auth,
8738 auth_keyid,
8739 no_fragmentflg,
8740 bundle_at,
8741 asconf,
8742 inp->sctp_lport, stcb->rport,
8743 htonl(stcb->asoc.peer_vtag),
8730 net->port, so_locked, NULL, NULL))) {
8744 net->port, NULL,
8745 0, 0,
8746 so_locked))) {
8731 /* error, we could not output */
8732 if (error == ENOBUFS) {
8733 SCTP_STAT_INCR(sctps_lowlevelerr);
8734 asoc->ifp_had_enobuf = 1;
8735 }
8736 if (from_where == 0) {
8737 SCTP_STAT_INCR(sctps_lowlevelerrusr);
8738 }

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

9424 } else if (chk->rec.chunk_id.id == SCTP_ASCONF)
9425 sctp_timer_start(SCTP_TIMER_TYPE_ASCONF, inp, stcb, chk->whoTo);
9426 chk->snd_count++; /* update our count */
9427 if ((error = sctp_lowlevel_chunk_output(inp, stcb, chk->whoTo,
9428 (struct sockaddr *)&chk->whoTo->ro._l_addr, m,
9429 auth_offset, auth, stcb->asoc.authinfo.active_keyid,
9430 no_fragmentflg, 0, 0,
9431 inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag),
8747 /* error, we could not output */
8748 if (error == ENOBUFS) {
8749 SCTP_STAT_INCR(sctps_lowlevelerr);
8750 asoc->ifp_had_enobuf = 1;
8751 }
8752 if (from_where == 0) {
8753 SCTP_STAT_INCR(sctps_lowlevelerrusr);
8754 }

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

9440 } else if (chk->rec.chunk_id.id == SCTP_ASCONF)
9441 sctp_timer_start(SCTP_TIMER_TYPE_ASCONF, inp, stcb, chk->whoTo);
9442 chk->snd_count++; /* update our count */
9443 if ((error = sctp_lowlevel_chunk_output(inp, stcb, chk->whoTo,
9444 (struct sockaddr *)&chk->whoTo->ro._l_addr, m,
9445 auth_offset, auth, stcb->asoc.authinfo.active_keyid,
9446 no_fragmentflg, 0, 0,
9447 inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag),
9432 chk->whoTo->port, so_locked, NULL, NULL))) {
9448 chk->whoTo->port, NULL,
9449 0, 0,
9450 so_locked))) {
9433 SCTP_STAT_INCR(sctps_lowlevelerr);
9434 return (error);
9435 }
9436 endofchain = NULL;
9437 auth = NULL;
9438 auth_offset = 0;
9439 /*
9440 * We don't want to mark the net->sent time here since this

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

9689 tmr_started = 1;
9690 }
9691 /* Now lets send it, if there is anything to send :> */
9692 if ((error = sctp_lowlevel_chunk_output(inp, stcb, net,
9693 (struct sockaddr *)&net->ro._l_addr, m,
9694 auth_offset, auth, auth_keyid,
9695 no_fragmentflg, 0, 0,
9696 inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag),
9451 SCTP_STAT_INCR(sctps_lowlevelerr);
9452 return (error);
9453 }
9454 endofchain = NULL;
9455 auth = NULL;
9456 auth_offset = 0;
9457 /*
9458 * We don't want to mark the net->sent time here since this

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

9707 tmr_started = 1;
9708 }
9709 /* Now lets send it, if there is anything to send :> */
9710 if ((error = sctp_lowlevel_chunk_output(inp, stcb, net,
9711 (struct sockaddr *)&net->ro._l_addr, m,
9712 auth_offset, auth, auth_keyid,
9713 no_fragmentflg, 0, 0,
9714 inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag),
9697 net->port, so_locked, NULL, NULL))) {
9715 net->port, NULL,
9716 0, 0,
9717 so_locked))) {
9698 /* error, we could not output */
9699 SCTP_STAT_INCR(sctps_lowlevelerr);
9700 return (error);
9701 }
9702 endofchain = NULL;
9703 auth = NULL;
9704 auth_offset = 0;
9705 /* For HB's */

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

10807 abort->ch.chunk_type = SCTP_ABORT_ASSOCIATION;
10808 abort->ch.chunk_flags = 0;
10809 abort->ch.chunk_length = htons(sizeof(*abort) + sz);
10810
10811 (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
10812 (struct sockaddr *)&net->ro._l_addr,
10813 m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0,
10814 stcb->sctp_ep->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag),
9718 /* error, we could not output */
9719 SCTP_STAT_INCR(sctps_lowlevelerr);
9720 return (error);
9721 }
9722 endofchain = NULL;
9723 auth = NULL;
9724 auth_offset = 0;
9725 /* For HB's */

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

10827 abort->ch.chunk_type = SCTP_ABORT_ASSOCIATION;
10828 abort->ch.chunk_flags = 0;
10829 abort->ch.chunk_length = htons(sizeof(*abort) + sz);
10830
10831 (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
10832 (struct sockaddr *)&net->ro._l_addr,
10833 m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0,
10834 stcb->sctp_ep->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag),
10815 stcb->asoc.primary_destination->port, so_locked, NULL, NULL);
10835 stcb->asoc.primary_destination->port, NULL,
10836 0, 0,
10837 so_locked);
10816 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
10817}
10818
10819void
10820sctp_send_shutdown_complete(struct sctp_tcb *stcb,
10821 struct sctp_nets *net,
10822 int reflect_vtag)
10823{

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

10844 shutdown_complete->ch.chunk_flags = flags;
10845 shutdown_complete->ch.chunk_length = htons(sizeof(struct sctp_shutdown_complete_chunk));
10846 SCTP_BUF_LEN(m_shutdown_comp) = sizeof(struct sctp_shutdown_complete_chunk);
10847 (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
10848 (struct sockaddr *)&net->ro._l_addr,
10849 m_shutdown_comp, 0, NULL, 0, 1, 0, 0,
10850 stcb->sctp_ep->sctp_lport, stcb->rport,
10851 htonl(vtag),
10838 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
10839}
10840
10841void
10842sctp_send_shutdown_complete(struct sctp_tcb *stcb,
10843 struct sctp_nets *net,
10844 int reflect_vtag)
10845{

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

10866 shutdown_complete->ch.chunk_flags = flags;
10867 shutdown_complete->ch.chunk_length = htons(sizeof(struct sctp_shutdown_complete_chunk));
10868 SCTP_BUF_LEN(m_shutdown_comp) = sizeof(struct sctp_shutdown_complete_chunk);
10869 (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
10870 (struct sockaddr *)&net->ro._l_addr,
10871 m_shutdown_comp, 0, NULL, 0, 1, 0, 0,
10872 stcb->sctp_ep->sctp_lport, stcb->rport,
10873 htonl(vtag),
10852 net->port, SCTP_SO_NOT_LOCKED, NULL, NULL);
10874 net->port, NULL,
10875 0, 0,
10876 SCTP_SO_NOT_LOCKED);
10853 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
10854 return;
10855}
10856
10857static void
10858sctp_send_resp_msg(struct mbuf *m, struct sctphdr *sh, uint32_t vtag,
10877 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
10878 return;
10879}
10880
10881static void
10882sctp_send_resp_msg(struct mbuf *m, struct sctphdr *sh, uint32_t vtag,
10859 uint8_t type, struct mbuf *cause, uint32_t vrf_id, uint16_t port)
10883 uint8_t type, struct mbuf *cause,
10884 uint8_t use_mflowid, uint32_t mflowid,
10885 uint32_t vrf_id, uint16_t port)
10860{
10861 struct mbuf *o_pak;
10862 struct mbuf *mout;
10863 struct sctphdr *shout;
10864 struct sctp_chunkhdr *ch;
10865 struct ip *iph;
10866 struct udphdr *udp;
10867 int len, cause_len, padding_len, ret;

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

10924 if (cause) {
10925 sctp_m_freem(cause);
10926 }
10927 return;
10928 }
10929 SCTP_BUF_RESV_UF(mout, max_linkhdr);
10930 SCTP_BUF_LEN(mout) = len;
10931 SCTP_BUF_NEXT(mout) = cause;
10886{
10887 struct mbuf *o_pak;
10888 struct mbuf *mout;
10889 struct sctphdr *shout;
10890 struct sctp_chunkhdr *ch;
10891 struct ip *iph;
10892 struct udphdr *udp;
10893 int len, cause_len, padding_len, ret;

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

10950 if (cause) {
10951 sctp_m_freem(cause);
10952 }
10953 return;
10954 }
10955 SCTP_BUF_RESV_UF(mout, max_linkhdr);
10956 SCTP_BUF_LEN(mout) = len;
10957 SCTP_BUF_NEXT(mout) = cause;
10932 if (m->m_flags & M_FLOWID) {
10933 mout->m_pkthdr.flowid = m->m_pkthdr.flowid;
10958 if (use_mflowid != 0) {
10959 mout->m_pkthdr.flowid = mflowid;
10934 mout->m_flags |= M_FLOWID;
10935 }
10936#ifdef INET
10937 iph_out = NULL;
10938#endif
10939#ifdef INET6
10940 ip6_out = NULL;
10941#endif

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

11105 SCTP_STAT_INCR(sctps_sendpackets);
11106 SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
11107 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
11108 return;
11109}
11110
11111void
11112sctp_send_shutdown_complete2(struct mbuf *m, struct sctphdr *sh,
10960 mout->m_flags |= M_FLOWID;
10961 }
10962#ifdef INET
10963 iph_out = NULL;
10964#endif
10965#ifdef INET6
10966 ip6_out = NULL;
10967#endif

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

11131 SCTP_STAT_INCR(sctps_sendpackets);
11132 SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
11133 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
11134 return;
11135}
11136
11137void
11138sctp_send_shutdown_complete2(struct mbuf *m, struct sctphdr *sh,
11139 uint8_t use_mflowid, uint32_t mflowid,
11113 uint32_t vrf_id, uint16_t port)
11114{
11140 uint32_t vrf_id, uint16_t port)
11141{
11115 sctp_send_resp_msg(m, sh, 0, SCTP_SHUTDOWN_COMPLETE, NULL, vrf_id, port);
11142 sctp_send_resp_msg(m, sh, 0, SCTP_SHUTDOWN_COMPLETE, NULL,
11143 use_mflowid, mflowid,
11144 vrf_id, port);
11116}
11117
11118void
11119sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net, int so_locked
11120#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
11121 SCTP_UNUSED
11122#endif
11123)

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

11939 sctp_next);
11940 asoc->ctrl_queue_cnt++;
11941 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo);
11942 return (0);
11943}
11944
11945void
11946sctp_send_abort(struct mbuf *m, int iphlen, struct sctphdr *sh, uint32_t vtag,
11145}
11146
11147void
11148sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net, int so_locked
11149#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
11150 SCTP_UNUSED
11151#endif
11152)

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

11968 sctp_next);
11969 asoc->ctrl_queue_cnt++;
11970 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo);
11971 return (0);
11972}
11973
11974void
11975sctp_send_abort(struct mbuf *m, int iphlen, struct sctphdr *sh, uint32_t vtag,
11947 struct mbuf *cause, uint32_t vrf_id, uint16_t port)
11976 struct mbuf *cause,
11977 uint8_t use_mflowid, uint32_t mflowid,
11978 uint32_t vrf_id, uint16_t port)
11948{
11949 /* Don't respond to an ABORT with an ABORT. */
11950 if (sctp_is_there_an_abort_here(m, iphlen, &vtag)) {
11951 if (cause)
11952 sctp_m_freem(cause);
11953 return;
11954 }
11979{
11980 /* Don't respond to an ABORT with an ABORT. */
11981 if (sctp_is_there_an_abort_here(m, iphlen, &vtag)) {
11982 if (cause)
11983 sctp_m_freem(cause);
11984 return;
11985 }
11955 sctp_send_resp_msg(m, sh, vtag, SCTP_ABORT_ASSOCIATION, cause, vrf_id, port);
11986 sctp_send_resp_msg(m, sh, vtag, SCTP_ABORT_ASSOCIATION, cause,
11987 use_mflowid, mflowid,
11988 vrf_id, port);
11956 return;
11957}
11958
11959void
11960sctp_send_operr_to(struct mbuf *m, struct sctphdr *sh, uint32_t vtag,
11989 return;
11990}
11991
11992void
11993sctp_send_operr_to(struct mbuf *m, struct sctphdr *sh, uint32_t vtag,
11961 struct mbuf *cause, uint32_t vrf_id, uint16_t port)
11994 struct mbuf *cause,
11995 uint8_t use_mflowid, uint32_t mflowid,
11996 uint32_t vrf_id, uint16_t port)
11962{
11997{
11963 sctp_send_resp_msg(m, sh, vtag, SCTP_OPERATION_ERROR, cause, vrf_id, port);
11998 sctp_send_resp_msg(m, sh, vtag, SCTP_OPERATION_ERROR, cause,
11999 use_mflowid, mflowid,
12000 vrf_id, port);
11964 return;
11965}
11966
11967static struct mbuf *
11968sctp_copy_resume(struct uio *uio,
11969 int max_send_len,
11970 int user_marks_eor,
11971 int *error,

--- 1510 unchanged lines hidden ---
12001 return;
12002}
12003
12004static struct mbuf *
12005sctp_copy_resume(struct uio *uio,
12006 int max_send_len,
12007 int user_marks_eor,
12008 int *error,

--- 1510 unchanged lines hidden ---