Deleted Added
full compact
sctp_output.c (237049) sctp_output.c (237540)
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 237049 2012-06-14 06:54:48Z tuexen $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 237540 2012-06-24 21:25:54Z 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>

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

4102 ro->ro_rt);
4103
4104 if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) {
4105 /* failed to prepend data, give up */
4106 SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM);
4107 sctp_m_freem(m);
4108 return (ENOMEM);
4109 }
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>

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

4102 ro->ro_rt);
4103
4104 if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) {
4105 /* failed to prepend data, give up */
4106 SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM);
4107 sctp_m_freem(m);
4108 return (ENOMEM);
4109 }
4110#ifdef SCTP_PACKET_LOGGING
4111 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING)
4112 sctp_packet_log(m, packet_length);
4113#endif
4114 SCTP_ATTACH_CHAIN(o_pak, m, packet_length);
4115 if (port) {
4116#if defined(SCTP_WITH_NO_CSUM)
4117 SCTP_STAT_INCR(sctps_sendnocrc);
4118#else
4119 sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip) + sizeof(struct udphdr));
4120 SCTP_STAT_INCR(sctps_sendswcrc);
4121#endif

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

4126#if defined(SCTP_WITH_NO_CSUM)
4127 SCTP_STAT_INCR(sctps_sendnocrc);
4128#else
4129 m->m_pkthdr.csum_flags = CSUM_SCTP;
4130 m->m_pkthdr.csum_data = 0;
4131 SCTP_STAT_INCR(sctps_sendhwcrc);
4132#endif
4133 }
4110 SCTP_ATTACH_CHAIN(o_pak, m, packet_length);
4111 if (port) {
4112#if defined(SCTP_WITH_NO_CSUM)
4113 SCTP_STAT_INCR(sctps_sendnocrc);
4114#else
4115 sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip) + sizeof(struct udphdr));
4116 SCTP_STAT_INCR(sctps_sendswcrc);
4117#endif

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

4122#if defined(SCTP_WITH_NO_CSUM)
4123 SCTP_STAT_INCR(sctps_sendnocrc);
4124#else
4125 m->m_pkthdr.csum_flags = CSUM_SCTP;
4126 m->m_pkthdr.csum_data = 0;
4127 SCTP_STAT_INCR(sctps_sendhwcrc);
4128#endif
4129 }
4130#ifdef SCTP_PACKET_LOGGING
4131 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING)
4132 sctp_packet_log(o_pak);
4133#endif
4134 /* send it out. table id is taken from stcb */
4135#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
4136 if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) {
4137 so = SCTP_INP_SO(inp);
4138 SCTP_SOCKET_UNLOCK(so, 0);
4139 }
4140#endif
4141 SCTP_IP_OUTPUT(ret, o_pak, ro, stcb, vrf_id);

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

4454 prev_port = sin6->sin6_port;
4455 }
4456 if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) {
4457 /* failed to prepend data, give up */
4458 sctp_m_freem(m);
4459 SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM);
4460 return (ENOMEM);
4461 }
4134 /* send it out. table id is taken from stcb */
4135#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
4136 if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) {
4137 so = SCTP_INP_SO(inp);
4138 SCTP_SOCKET_UNLOCK(so, 0);
4139 }
4140#endif
4141 SCTP_IP_OUTPUT(ret, o_pak, ro, stcb, vrf_id);

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

4454 prev_port = sin6->sin6_port;
4455 }
4456 if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) {
4457 /* failed to prepend data, give up */
4458 sctp_m_freem(m);
4459 SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM);
4460 return (ENOMEM);
4461 }
4462#ifdef SCTP_PACKET_LOGGING
4463 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING)
4464 sctp_packet_log(m, packet_length);
4465#endif
4466 SCTP_ATTACH_CHAIN(o_pak, m, packet_length);
4467 if (port) {
4468#if defined(SCTP_WITH_NO_CSUM)
4469 SCTP_STAT_INCR(sctps_sendnocrc);
4470#else
4471 sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip6_hdr) + sizeof(struct udphdr));
4472 SCTP_STAT_INCR(sctps_sendswcrc);
4473#endif

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

4485 }
4486 /* send it out. table id is taken from stcb */
4487#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
4488 if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) {
4489 so = SCTP_INP_SO(inp);
4490 SCTP_SOCKET_UNLOCK(so, 0);
4491 }
4492#endif
4462 SCTP_ATTACH_CHAIN(o_pak, m, packet_length);
4463 if (port) {
4464#if defined(SCTP_WITH_NO_CSUM)
4465 SCTP_STAT_INCR(sctps_sendnocrc);
4466#else
4467 sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip6_hdr) + sizeof(struct udphdr));
4468 SCTP_STAT_INCR(sctps_sendswcrc);
4469#endif

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

4481 }
4482 /* send it out. table id is taken from stcb */
4483#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
4484 if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) {
4485 so = SCTP_INP_SO(inp);
4486 SCTP_SOCKET_UNLOCK(so, 0);
4487 }
4488#endif
4489#ifdef SCTP_PACKET_LOGGING
4490 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING)
4491 sctp_packet_log(o_pak);
4492#endif
4493 SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, &ifp, stcb, vrf_id);
4494#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
4495 if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) {
4496 atomic_add_int(&stcb->asoc.refcnt, 1);
4497 SCTP_TCB_UNLOCK(stcb);
4498 SCTP_SOCKET_LOCK(so, 0);
4499 SCTP_TCB_LOCK(stcb);
4500 atomic_subtract_int(&stcb->asoc.refcnt, 1);

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

11062 if (port) {
11063 if (V_udp_cksum) {
11064 udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP));
11065 } else {
11066 udp->uh_sum = 0;
11067 }
11068 }
11069 iph_out->ip_len = len;
4493 SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, &ifp, stcb, vrf_id);
4494#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
4495 if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) {
4496 atomic_add_int(&stcb->asoc.refcnt, 1);
4497 SCTP_TCB_UNLOCK(stcb);
4498 SCTP_SOCKET_LOCK(so, 0);
4499 SCTP_TCB_LOCK(stcb);
4500 atomic_subtract_int(&stcb->asoc.refcnt, 1);

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

11062 if (port) {
11063 if (V_udp_cksum) {
11064 udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP));
11065 } else {
11066 udp->uh_sum = 0;
11067 }
11068 }
11069 iph_out->ip_len = len;
11070#ifdef SCTP_PACKET_LOGGING
11071 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) {
11072 sctp_packet_log(mout, len);
11073 }
11074#endif
11075 if (port) {
11076#if defined(SCTP_WITH_NO_CSUM)
11077 SCTP_STAT_INCR(sctps_sendnocrc);
11078#else
11079 shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip) + sizeof(struct udphdr));
11080 SCTP_STAT_INCR(sctps_sendswcrc);
11081#endif
11082 if (V_udp_cksum) {
11083 SCTP_ENABLE_UDP_CSUM(o_pak);
11084 }
11085 } else {
11086#if defined(SCTP_WITH_NO_CSUM)
11087 SCTP_STAT_INCR(sctps_sendnocrc);
11088#else
11089 mout->m_pkthdr.csum_flags = CSUM_SCTP;
11090 mout->m_pkthdr.csum_data = 0;
11091 SCTP_STAT_INCR(sctps_sendhwcrc);
11092#endif
11093 }
11070 if (port) {
11071#if defined(SCTP_WITH_NO_CSUM)
11072 SCTP_STAT_INCR(sctps_sendnocrc);
11073#else
11074 shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip) + sizeof(struct udphdr));
11075 SCTP_STAT_INCR(sctps_sendswcrc);
11076#endif
11077 if (V_udp_cksum) {
11078 SCTP_ENABLE_UDP_CSUM(o_pak);
11079 }
11080 } else {
11081#if defined(SCTP_WITH_NO_CSUM)
11082 SCTP_STAT_INCR(sctps_sendnocrc);
11083#else
11084 mout->m_pkthdr.csum_flags = CSUM_SCTP;
11085 mout->m_pkthdr.csum_data = 0;
11086 SCTP_STAT_INCR(sctps_sendhwcrc);
11087#endif
11088 }
11089#ifdef SCTP_PACKET_LOGGING
11090 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) {
11091 sctp_packet_log(o_pak);
11092 }
11093#endif
11094 SCTP_IP_OUTPUT(ret, o_pak, &ro, NULL, vrf_id);
11095 /* Free the route if we got one back */
11096 if (ro.ro_rt) {
11097 RTFREE(ro.ro_rt);
11098 }
11099 }
11100#endif
11101#ifdef INET6
11102 if (ip6_out != NULL) {
11103 ip6_out->ip6_plen = len - sizeof(struct ip6_hdr);
11094 SCTP_IP_OUTPUT(ret, o_pak, &ro, NULL, vrf_id);
11095 /* Free the route if we got one back */
11096 if (ro.ro_rt) {
11097 RTFREE(ro.ro_rt);
11098 }
11099 }
11100#endif
11101#ifdef INET6
11102 if (ip6_out != NULL) {
11103 ip6_out->ip6_plen = len - sizeof(struct ip6_hdr);
11104#ifdef SCTP_PACKET_LOGGING
11105 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) {
11106 sctp_packet_log(mout, len);
11107 }
11108#endif
11109 if (port) {
11110#if defined(SCTP_WITH_NO_CSUM)
11111 SCTP_STAT_INCR(sctps_sendnocrc);
11112#else
11113 shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr));
11114 SCTP_STAT_INCR(sctps_sendswcrc);
11115#endif
11116 if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), len - sizeof(struct ip6_hdr))) == 0) {
11117 udp->uh_sum = 0xffff;
11118 }
11119 } else {
11120#if defined(SCTP_WITH_NO_CSUM)
11121 SCTP_STAT_INCR(sctps_sendnocrc);
11122#else
11123 mout->m_pkthdr.csum_flags = CSUM_SCTP;
11124 mout->m_pkthdr.csum_data = 0;
11125 SCTP_STAT_INCR(sctps_sendhwcrc);
11126#endif
11127 }
11104 if (port) {
11105#if defined(SCTP_WITH_NO_CSUM)
11106 SCTP_STAT_INCR(sctps_sendnocrc);
11107#else
11108 shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr));
11109 SCTP_STAT_INCR(sctps_sendswcrc);
11110#endif
11111 if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), len - sizeof(struct ip6_hdr))) == 0) {
11112 udp->uh_sum = 0xffff;
11113 }
11114 } else {
11115#if defined(SCTP_WITH_NO_CSUM)
11116 SCTP_STAT_INCR(sctps_sendnocrc);
11117#else
11118 mout->m_pkthdr.csum_flags = CSUM_SCTP;
11119 mout->m_pkthdr.csum_data = 0;
11120 SCTP_STAT_INCR(sctps_sendhwcrc);
11121#endif
11122 }
11123#ifdef SCTP_PACKET_LOGGING
11124 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) {
11125 sctp_packet_log(o_pak);
11126 }
11127#endif
11128 SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id);
11129 }
11130#endif
11131 SCTP_STAT_INCR(sctps_sendpackets);
11132 SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
11133 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
11134 return;
11135}

--- 2383 unchanged lines hidden ---
11128 SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id);
11129 }
11130#endif
11131 SCTP_STAT_INCR(sctps_sendpackets);
11132 SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
11133 SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
11134 return;
11135}

--- 2383 unchanged lines hidden ---