sctputil.c (237565) | sctputil.c (237715) |
---|---|
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 237565 2012-06-25 17:15:09Z tuexen $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 237715 2012-06-28 16:01:08Z 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, 3827 struct mbuf *op_err, | 3826 struct mbuf *m, int iphlen, 3827 struct sockaddr *src, struct sockaddr *dst, 3828 struct sctphdr *sh, struct mbuf *op_err, |
3828 uint8_t use_mflowid, uint32_t mflowid, 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 } | 3829 uint8_t use_mflowid, uint32_t mflowid, 3830 uint32_t vrf_id, uint16_t port) 3831{ 3832 uint32_t vtag; 3833 3834#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) 3835 struct socket *so; 3836 3837#endif 3838 3839 vtag = 0; 3840 if (stcb != NULL) { 3841 /* We have a TCB to abort, send notification too */ 3842 vtag = stcb->asoc.peer_vtag; 3843 sctp_abort_notification(stcb, 0, 0, NULL, SCTP_SO_NOT_LOCKED); 3844 /* get the assoc vrf id and table id */ 3845 vrf_id = stcb->asoc.vrf_id; 3846 stcb->asoc.state |= SCTP_STATE_WAS_ABORTED; 3847 } |
3847 sctp_send_abort(m, iphlen, sh, vtag, op_err, | 3848 sctp_send_abort(m, iphlen, src, dst, sh, vtag, op_err, |
3848 use_mflowid, mflowid, 3849 vrf_id, port); 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); --- 134 unchanged lines hidden (view full) --- 3990#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) 3991 if (!so_locked) { 3992 SCTP_SOCKET_UNLOCK(so, 1); 3993 } 3994#endif 3995} 3996 3997void | 3849 use_mflowid, mflowid, 3850 vrf_id, port); 3851 if (stcb != NULL) { 3852 /* Ok, now lets free it */ 3853#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) 3854 so = SCTP_INP_SO(inp); 3855 atomic_add_int(&stcb->asoc.refcnt, 1); 3856 SCTP_TCB_UNLOCK(stcb); --- 134 unchanged lines hidden (view full) --- 3991#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) 3992 if (!so_locked) { 3993 SCTP_SOCKET_UNLOCK(so, 1); 3994 } 3995#endif 3996} 3997 3998void |
3998sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, 3999 struct sctp_inpcb *inp, | 3999sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, 4000 struct sockaddr *src, struct sockaddr *dst, 4001 struct sctphdr *sh, struct sctp_inpcb *inp, |
4000 uint8_t use_mflowid, uint32_t mflowid, 4001 uint32_t vrf_id, uint16_t port) 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); --- 28 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: | 4002 uint8_t use_mflowid, uint32_t mflowid, 4003 uint32_t vrf_id, uint16_t port) 4004{ 4005 struct sctp_chunkhdr *ch, chunk_buf; 4006 unsigned int chk_length; 4007 int contains_init_chunk; 4008 4009 SCTP_STAT_INCR_COUNTER32(sctps_outoftheblue); --- 28 unchanged lines hidden (view full) --- 4038 return; 4039 case SCTP_SHUTDOWN_COMPLETE: 4040 /* 4041 * we ignore it since we are not waiting for it and 4042 * peer is gone 4043 */ 4044 return; 4045 case SCTP_SHUTDOWN_ACK: |
4044 sctp_send_shutdown_complete2(m, sh, | 4046 sctp_send_shutdown_complete2(src, dst, sh, |
4045 use_mflowid, mflowid, 4046 vrf_id, port); 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))) { | 4047 use_mflowid, mflowid, 4048 vrf_id, port); 4049 return; 4050 default: 4051 break; 4052 } 4053 offset += SCTP_SIZE32(chk_length); 4054 ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset, 4055 sizeof(*ch), (uint8_t *) & chunk_buf); 4056 } 4057 if ((SCTP_BASE_SYSCTL(sctp_blackhole) == 0) || 4058 ((SCTP_BASE_SYSCTL(sctp_blackhole) == 1) && 4059 (contains_init_chunk == 0))) { |
4058 sctp_send_abort(m, iphlen, sh, 0, NULL, | 4060 sctp_send_abort(m, iphlen, src, dst, sh, 0, NULL, |
4059 use_mflowid, mflowid, 4060 vrf_id, port); 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. --- 176 unchanged lines hidden (view full) --- 4243#endif 4244 default: 4245 SCTP_PRINTF("?\n"); 4246 break; 4247 } 4248} 4249 4250void | 4061 use_mflowid, mflowid, 4062 vrf_id, port); 4063 } 4064} 4065 4066/* 4067 * check the inbound datagram to make sure there is not an abort inside it, 4068 * if there is return 1, else return 0. --- 176 unchanged lines hidden (view full) --- 4245#endif 4246 default: 4247 SCTP_PRINTF("?\n"); 4248 break; 4249 } 4250} 4251 4252void |
4251sctp_print_address_pkt(struct ip *iph, struct sctphdr *sh) 4252{ 4253 switch (iph->ip_v) { 4254#ifdef INET 4255 case IPVERSION: 4256 { 4257 struct sockaddr_in lsa, fsa; 4258 4259 bzero(&lsa, sizeof(lsa)); 4260 lsa.sin_len = sizeof(lsa); 4261 lsa.sin_family = AF_INET; 4262 lsa.sin_addr = iph->ip_src; 4263 lsa.sin_port = sh->src_port; 4264 bzero(&fsa, sizeof(fsa)); 4265 fsa.sin_len = sizeof(fsa); 4266 fsa.sin_family = AF_INET; 4267 fsa.sin_addr = iph->ip_dst; 4268 fsa.sin_port = sh->dest_port; 4269 SCTP_PRINTF("src: "); 4270 sctp_print_address((struct sockaddr *)&lsa); 4271 SCTP_PRINTF("dest: "); 4272 sctp_print_address((struct sockaddr *)&fsa); 4273 break; 4274 } 4275#endif 4276#ifdef INET6 4277 case IPV6_VERSION >> 4: 4278 { 4279 struct ip6_hdr *ip6; 4280 struct sockaddr_in6 lsa6, fsa6; 4281 4282 ip6 = (struct ip6_hdr *)iph; 4283 bzero(&lsa6, sizeof(lsa6)); 4284 lsa6.sin6_len = sizeof(lsa6); 4285 lsa6.sin6_family = AF_INET6; 4286 lsa6.sin6_addr = ip6->ip6_src; 4287 lsa6.sin6_port = sh->src_port; 4288 bzero(&fsa6, sizeof(fsa6)); 4289 fsa6.sin6_len = sizeof(fsa6); 4290 fsa6.sin6_family = AF_INET6; 4291 fsa6.sin6_addr = ip6->ip6_dst; 4292 fsa6.sin6_port = sh->dest_port; 4293 SCTP_PRINTF("src: "); 4294 sctp_print_address((struct sockaddr *)&lsa6); 4295 SCTP_PRINTF("dest: "); 4296 sctp_print_address((struct sockaddr *)&fsa6); 4297 break; 4298 } 4299#endif 4300 default: 4301 /* TSNH */ 4302 break; 4303 } 4304} 4305 4306void | |
4307sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp, 4308 struct sctp_inpcb *new_inp, 4309 struct sctp_tcb *stcb, 4310 int waitflags) 4311{ 4312 /* 4313 * go through our old INP and pull off any control structures that 4314 * belong to stcb and move then to the new inp. --- 2659 unchanged lines hidden --- | 4253sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp, 4254 struct sctp_inpcb *new_inp, 4255 struct sctp_tcb *stcb, 4256 int waitflags) 4257{ 4258 /* 4259 * go through our old INP and pull off any control structures that 4260 * belong to stcb and move then to the new inp. --- 2659 unchanged lines hidden --- |