Deleted Added
full compact
sctputil.c (236949) sctputil.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/sctputil.c 236949 2012-06-12 09:18:28Z tuexen $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 237049 2012-06-14 06:54:48Z tuexen $");
35
36#include <netinet/sctp_os.h>
37#include <netinet/sctp_pcb.h>
38#include <netinet/sctputil.h>
39#include <netinet/sctp_var.h>
40#include <netinet/sctp_sysctl.h>
41#ifdef INET6
42#endif

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

3818 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_REM_ABORTED, stcb, error, abort, so_locked);
3819 } else {
3820 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_LOC_ABORTED, stcb, error, abort, so_locked);
3821 }
3822}
3823
3824void
3825sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
35
36#include <netinet/sctp_os.h>
37#include <netinet/sctp_pcb.h>
38#include <netinet/sctputil.h>
39#include <netinet/sctp_var.h>
40#include <netinet/sctp_sysctl.h>
41#ifdef INET6
42#endif

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

3818 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_REM_ABORTED, stcb, error, abort, so_locked);
3819 } else {
3820 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_LOC_ABORTED, stcb, error, abort, so_locked);
3821 }
3822}
3823
3824void
3825sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
3826 struct mbuf *m, int iphlen, struct sctphdr *sh, struct mbuf *op_err,
3826 struct mbuf *m, int iphlen, struct sctphdr *sh,
3827 struct mbuf *op_err,
3828 uint8_t use_mflowid, uint32_t mflowid,
3827 uint32_t vrf_id, uint16_t port)
3828{
3829 uint32_t vtag;
3830
3831#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
3832 struct socket *so;
3833
3834#endif
3835
3836 vtag = 0;
3837 if (stcb != NULL) {
3838 /* We have a TCB to abort, send notification too */
3839 vtag = stcb->asoc.peer_vtag;
3840 sctp_abort_notification(stcb, 0, 0, NULL, SCTP_SO_NOT_LOCKED);
3841 /* get the assoc vrf id and table id */
3842 vrf_id = stcb->asoc.vrf_id;
3843 stcb->asoc.state |= SCTP_STATE_WAS_ABORTED;
3844 }
3829 uint32_t vrf_id, uint16_t port)
3830{
3831 uint32_t vtag;
3832
3833#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
3834 struct socket *so;
3835
3836#endif
3837
3838 vtag = 0;
3839 if (stcb != NULL) {
3840 /* We have a TCB to abort, send notification too */
3841 vtag = stcb->asoc.peer_vtag;
3842 sctp_abort_notification(stcb, 0, 0, NULL, SCTP_SO_NOT_LOCKED);
3843 /* get the assoc vrf id and table id */
3844 vrf_id = stcb->asoc.vrf_id;
3845 stcb->asoc.state |= SCTP_STATE_WAS_ABORTED;
3846 }
3845 sctp_send_abort(m, iphlen, sh, vtag, op_err, vrf_id, port);
3847 sctp_send_abort(m, iphlen, sh, vtag, op_err,
3848 use_mflowid, mflowid,
3849 vrf_id, port);
3846 if (stcb != NULL) {
3847 /* Ok, now lets free it */
3848#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
3849 so = SCTP_INP_SO(inp);
3850 atomic_add_int(&stcb->asoc.refcnt, 1);
3851 SCTP_TCB_UNLOCK(stcb);
3852 SCTP_SOCKET_LOCK(so, 1);
3853 SCTP_TCB_LOCK(stcb);

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

3987 if (!so_locked) {
3988 SCTP_SOCKET_UNLOCK(so, 1);
3989 }
3990#endif
3991}
3992
3993void
3994sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh,
3850 if (stcb != NULL) {
3851 /* Ok, now lets free it */
3852#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
3853 so = SCTP_INP_SO(inp);
3854 atomic_add_int(&stcb->asoc.refcnt, 1);
3855 SCTP_TCB_UNLOCK(stcb);
3856 SCTP_SOCKET_LOCK(so, 1);
3857 SCTP_TCB_LOCK(stcb);

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

3991 if (!so_locked) {
3992 SCTP_SOCKET_UNLOCK(so, 1);
3993 }
3994#endif
3995}
3996
3997void
3998sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh,
3995 struct sctp_inpcb *inp, uint32_t vrf_id, uint16_t port)
3999 struct sctp_inpcb *inp,
4000 uint8_t use_mflowid, uint32_t mflowid,
4001 uint32_t vrf_id, uint16_t port)
3996{
3997 struct sctp_chunkhdr *ch, chunk_buf;
3998 unsigned int chk_length;
3999 int contains_init_chunk;
4000
4001 SCTP_STAT_INCR_COUNTER32(sctps_outoftheblue);
4002 /* Generate a TO address for future reference */
4003 if (inp && (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {

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

4030 return;
4031 case SCTP_SHUTDOWN_COMPLETE:
4032 /*
4033 * we ignore it since we are not waiting for it and
4034 * peer is gone
4035 */
4036 return;
4037 case SCTP_SHUTDOWN_ACK:
4002{
4003 struct sctp_chunkhdr *ch, chunk_buf;
4004 unsigned int chk_length;
4005 int contains_init_chunk;
4006
4007 SCTP_STAT_INCR_COUNTER32(sctps_outoftheblue);
4008 /* Generate a TO address for future reference */
4009 if (inp && (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {

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

4036 return;
4037 case SCTP_SHUTDOWN_COMPLETE:
4038 /*
4039 * we ignore it since we are not waiting for it and
4040 * peer is gone
4041 */
4042 return;
4043 case SCTP_SHUTDOWN_ACK:
4038 sctp_send_shutdown_complete2(m, sh, vrf_id, port);
4044 sctp_send_shutdown_complete2(m, sh,
4045 use_mflowid, mflowid,
4046 vrf_id, port);
4039 return;
4040 default:
4041 break;
4042 }
4043 offset += SCTP_SIZE32(chk_length);
4044 ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,
4045 sizeof(*ch), (uint8_t *) & chunk_buf);
4046 }
4047 if ((SCTP_BASE_SYSCTL(sctp_blackhole) == 0) ||
4048 ((SCTP_BASE_SYSCTL(sctp_blackhole) == 1) &&
4049 (contains_init_chunk == 0))) {
4047 return;
4048 default:
4049 break;
4050 }
4051 offset += SCTP_SIZE32(chk_length);
4052 ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,
4053 sizeof(*ch), (uint8_t *) & chunk_buf);
4054 }
4055 if ((SCTP_BASE_SYSCTL(sctp_blackhole) == 0) ||
4056 ((SCTP_BASE_SYSCTL(sctp_blackhole) == 1) &&
4057 (contains_init_chunk == 0))) {
4050 sctp_send_abort(m, iphlen, sh, 0, NULL, vrf_id, port);
4058 sctp_send_abort(m, iphlen, sh, 0, NULL,
4059 use_mflowid, mflowid,
4060 vrf_id, port);
4051 }
4052}
4053
4054/*
4055 * check the inbound datagram to make sure there is not an abort inside it,
4056 * if there is return 1, else return 0.
4057 */
4058int

--- 2927 unchanged lines hidden ---
4061 }
4062}
4063
4064/*
4065 * check the inbound datagram to make sure there is not an abort inside it,
4066 * if there is return 1, else return 0.
4067 */
4068int

--- 2927 unchanged lines hidden ---