Deleted Added
full compact
sctp_output.c (196364) sctp_output.c (197288)
1/*-
2 * Copyright (c) 2001-2008, 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_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2008, 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_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 196364 2009-08-18 19:58:49Z tuexen $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 197288 2009-09-17 15:11:12Z rrs $");
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>

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

3824 flowTop = ((flowlabel & 0x000f0000) >> 16);
3825 tosTop = (((flowlabel & 0xf0) >> 4) | IPV6_VERSION);
3826 /* protect *sin6 from overwrite */
3827 sin6 = (struct sockaddr_in6 *)to;
3828 tmp = *sin6;
3829 sin6 = &tmp;
3830
3831 /* KAME hack: embed scopeid */
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>

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

3824 flowTop = ((flowlabel & 0x000f0000) >> 16);
3825 tosTop = (((flowlabel & 0xf0) >> 4) | IPV6_VERSION);
3826 /* protect *sin6 from overwrite */
3827 sin6 = (struct sockaddr_in6 *)to;
3828 tmp = *sin6;
3829 sin6 = &tmp;
3830
3831 /* KAME hack: embed scopeid */
3832 if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
3832 if (sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone)) != 0) {
3833 SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
3834 return (EINVAL);
3835 }
3836 if (net == NULL) {
3837 memset(&ip6route, 0, sizeof(ip6route));
3838 ro = (sctp_route_t *) & ip6route;
3839 memcpy(&ro->ro_dst, sin6, sin6->sin6_len);
3840 } else {

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

3878 if (ro->ro_rt) {
3879 RTFREE(ro->ro_rt);
3880 ro->ro_rt = NULL;
3881 }
3882 }
3883 if (net->src_addr_selected == 0) {
3884 sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
3885 /* KAME hack: embed scopeid */
3833 SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
3834 return (EINVAL);
3835 }
3836 if (net == NULL) {
3837 memset(&ip6route, 0, sizeof(ip6route));
3838 ro = (sctp_route_t *) & ip6route;
3839 memcpy(&ro->ro_dst, sin6, sin6->sin6_len);
3840 } else {

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

3878 if (ro->ro_rt) {
3879 RTFREE(ro->ro_rt);
3880 ro->ro_rt = NULL;
3881 }
3882 }
3883 if (net->src_addr_selected == 0) {
3884 sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
3885 /* KAME hack: embed scopeid */
3886 if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
3886 if (sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone)) != 0) {
3887 SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
3888 return (EINVAL);
3889 }
3890 /* Cache the source address */
3891 net->ro._s_addr = sctp_source_address_selection(inp,
3892 stcb,
3893 ro,
3894 net,

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

3901 SCTPDBG(SCTP_DEBUG_OUTPUT3, "V6:No route to host\n");
3902 net->src_addr_selected = 0;
3903 goto no_route;
3904 }
3905 lsa6->sin6_addr = net->ro._s_addr->address.sin6.sin6_addr;
3906 } else {
3907 sin6 = (struct sockaddr_in6 *)&ro->ro_dst;
3908 /* KAME hack: embed scopeid */
3887 SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
3888 return (EINVAL);
3889 }
3890 /* Cache the source address */
3891 net->ro._s_addr = sctp_source_address_selection(inp,
3892 stcb,
3893 ro,
3894 net,

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

3901 SCTPDBG(SCTP_DEBUG_OUTPUT3, "V6:No route to host\n");
3902 net->src_addr_selected = 0;
3903 goto no_route;
3904 }
3905 lsa6->sin6_addr = net->ro._s_addr->address.sin6.sin6_addr;
3906 } else {
3907 sin6 = (struct sockaddr_in6 *)&ro->ro_dst;
3908 /* KAME hack: embed scopeid */
3909 if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
3909 if (sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone)) != 0) {
3910 SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
3911 return (EINVAL);
3912 }
3913 if (over_addr == NULL) {
3914 struct sctp_ifa *_lsrc;
3915
3916 _lsrc = sctp_source_address_selection(inp, stcb, ro,
3917 net,

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

5138 stc.scope_id = 0;
5139 if (sctp_is_address_on_local_host((struct sockaddr *)sin6, vrf_id)) {
5140 /*
5141 * FIX ME: does this have scope from
5142 * rcvif?
5143 */
5144 (void)sa6_recoverscope(sin6);
5145 stc.scope_id = sin6->sin6_scope_id;
3910 SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
3911 return (EINVAL);
3912 }
3913 if (over_addr == NULL) {
3914 struct sctp_ifa *_lsrc;
3915
3916 _lsrc = sctp_source_address_selection(inp, stcb, ro,
3917 net,

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

5138 stc.scope_id = 0;
5139 if (sctp_is_address_on_local_host((struct sockaddr *)sin6, vrf_id)) {
5140 /*
5141 * FIX ME: does this have scope from
5142 * rcvif?
5143 */
5144 (void)sa6_recoverscope(sin6);
5145 stc.scope_id = sin6->sin6_scope_id;
5146 sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone));
5146 sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone));
5147 stc.loopback_scope = 1;
5148 stc.local_scope = 0;
5149 stc.site_scope = 1;
5150 stc.ipv4_scope = 1;
5151 } else if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
5152 /*
5153 * If the new destination is a
5154 * LINK_LOCAL we must have common

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

5174 * incoming pkt
5175 */
5176 /*
5177 * FIX ME: does this have scope from
5178 * rcvif?
5179 */
5180 (void)sa6_recoverscope(sin6);
5181 stc.scope_id = sin6->sin6_scope_id;
5147 stc.loopback_scope = 1;
5148 stc.local_scope = 0;
5149 stc.site_scope = 1;
5150 stc.ipv4_scope = 1;
5151 } else if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
5152 /*
5153 * If the new destination is a
5154 * LINK_LOCAL we must have common

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

5174 * incoming pkt
5175 */
5176 /*
5177 * FIX ME: does this have scope from
5178 * rcvif?
5179 */
5180 (void)sa6_recoverscope(sin6);
5181 stc.scope_id = sin6->sin6_scope_id;
5182 sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone));
5182 sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone));
5183 } else if (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) {
5184 /*
5185 * If the new destination is
5186 * SITE_LOCAL then we must have site
5187 * scope in common.
5188 */
5189 stc.site_scope = 1;
5190 }

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

10763 break;
10764#ifdef INET6
10765 case IPV6_VERSION >> 4:
10766 ip6 = (struct ip6_hdr *)iph;
10767 ip6_out = mtod(mout, struct ip6_hdr *);
10768
10769 /* Fill in the IPv6 header for the ABORT */
10770 ip6_out->ip6_flow = ip6->ip6_flow;
5183 } else if (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) {
5184 /*
5185 * If the new destination is
5186 * SITE_LOCAL then we must have site
5187 * scope in common.
5188 */
5189 stc.site_scope = 1;
5190 }

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

10763 break;
10764#ifdef INET6
10765 case IPV6_VERSION >> 4:
10766 ip6 = (struct ip6_hdr *)iph;
10767 ip6_out = mtod(mout, struct ip6_hdr *);
10768
10769 /* Fill in the IPv6 header for the ABORT */
10770 ip6_out->ip6_flow = ip6->ip6_flow;
10771 ip6_out->ip6_hlim = MODULE_GLOBAL(MOD_INET6, ip6_defhlim);
10771 ip6_out->ip6_hlim = MODULE_GLOBAL(ip6_defhlim);
10772 if (port) {
10773 ip6_out->ip6_nxt = IPPROTO_UDP;
10774 } else {
10775 ip6_out->ip6_nxt = IPPROTO_SCTP;
10776 }
10777 ip6_out->ip6_src = ip6->ip6_dst;
10778 ip6_out->ip6_dst = ip6->ip6_src;
10779 /*

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

11782 break;
11783#ifdef INET6
11784 case IPV6_VERSION >> 4:
11785 ip6 = (struct ip6_hdr *)iph;
11786 ip6_out = mtod(mout, struct ip6_hdr *);
11787
11788 /* Fill in the IP6 header for the ABORT */
11789 ip6_out->ip6_flow = ip6->ip6_flow;
10772 if (port) {
10773 ip6_out->ip6_nxt = IPPROTO_UDP;
10774 } else {
10775 ip6_out->ip6_nxt = IPPROTO_SCTP;
10776 }
10777 ip6_out->ip6_src = ip6->ip6_dst;
10778 ip6_out->ip6_dst = ip6->ip6_src;
10779 /*

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

11782 break;
11783#ifdef INET6
11784 case IPV6_VERSION >> 4:
11785 ip6 = (struct ip6_hdr *)iph;
11786 ip6_out = mtod(mout, struct ip6_hdr *);
11787
11788 /* Fill in the IP6 header for the ABORT */
11789 ip6_out->ip6_flow = ip6->ip6_flow;
11790 ip6_out->ip6_hlim = MODULE_GLOBAL(MOD_INET6, ip6_defhlim);
11790 ip6_out->ip6_hlim = MODULE_GLOBAL(ip6_defhlim);
11791 if (port) {
11792 ip6_out->ip6_nxt = IPPROTO_UDP;
11793 } else {
11794 ip6_out->ip6_nxt = IPPROTO_SCTP;
11795 }
11796 ip6_out->ip6_src = ip6->ip6_dst;
11797 ip6_out->ip6_dst = ip6->ip6_src;
11798

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

12009 break;
12010#ifdef INET6
12011 case IPV6_VERSION >> 4:
12012 ip6 = (struct ip6_hdr *)iph;
12013 ip6_out = mtod(mout, struct ip6_hdr *);
12014
12015 /* Fill in the IP6 header for the ABORT */
12016 ip6_out->ip6_flow = ip6->ip6_flow;
11791 if (port) {
11792 ip6_out->ip6_nxt = IPPROTO_UDP;
11793 } else {
11794 ip6_out->ip6_nxt = IPPROTO_SCTP;
11795 }
11796 ip6_out->ip6_src = ip6->ip6_dst;
11797 ip6_out->ip6_dst = ip6->ip6_src;
11798

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

12009 break;
12010#ifdef INET6
12011 case IPV6_VERSION >> 4:
12012 ip6 = (struct ip6_hdr *)iph;
12013 ip6_out = mtod(mout, struct ip6_hdr *);
12014
12015 /* Fill in the IP6 header for the ABORT */
12016 ip6_out->ip6_flow = ip6->ip6_flow;
12017 ip6_out->ip6_hlim = MODULE_GLOBAL(MOD_INET6, ip6_defhlim);
12017 ip6_out->ip6_hlim = MODULE_GLOBAL(ip6_defhlim);
12018 if (port) {
12019 ip6_out->ip6_nxt = IPPROTO_UDP;
12020 } else {
12021 ip6_out->ip6_nxt = IPPROTO_SCTP;
12022 }
12023 ip6_out->ip6_src = ip6->ip6_dst;
12024 ip6_out->ip6_dst = ip6->ip6_src;
12025

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

13754 struct nd_prefix *pfx = NULL;
13755 struct nd_pfxrouter *pfxrtr = NULL;
13756 struct sockaddr_in6 gw6;
13757
13758 if (ro == NULL || ro->ro_rt == NULL || src6->sin6_family != AF_INET6)
13759 return (0);
13760
13761 /* get prefix entry of address */
12018 if (port) {
12019 ip6_out->ip6_nxt = IPPROTO_UDP;
12020 } else {
12021 ip6_out->ip6_nxt = IPPROTO_SCTP;
12022 }
12023 ip6_out->ip6_src = ip6->ip6_dst;
12024 ip6_out->ip6_dst = ip6->ip6_src;
12025

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

13754 struct nd_prefix *pfx = NULL;
13755 struct nd_pfxrouter *pfxrtr = NULL;
13756 struct sockaddr_in6 gw6;
13757
13758 if (ro == NULL || ro->ro_rt == NULL || src6->sin6_family != AF_INET6)
13759 return (0);
13760
13761 /* get prefix entry of address */
13762 LIST_FOREACH(pfx, &MODULE_GLOBAL(MOD_INET6, nd_prefix), ndpr_entry) {
13762 LIST_FOREACH(pfx, &MODULE_GLOBAL(nd_prefix), ndpr_entry) {
13763 if (pfx->ndpr_stateflags & NDPRF_DETACHED)
13764 continue;
13765 if (IN6_ARE_MASKED_ADDR_EQUAL(&pfx->ndpr_prefix.sin6_addr,
13766 &src6->sin6_addr, &pfx->ndpr_mask))
13767 break;
13768 }
13769 /* no prefix entry in the prefix list */
13770 if (pfx == NULL) {

--- 60 unchanged lines hidden ---
13763 if (pfx->ndpr_stateflags & NDPRF_DETACHED)
13764 continue;
13765 if (IN6_ARE_MASKED_ADDR_EQUAL(&pfx->ndpr_prefix.sin6_addr,
13766 &src6->sin6_addr, &pfx->ndpr_mask))
13767 break;
13768 }
13769 /* no prefix entry in the prefix list */
13770 if (pfx == NULL) {

--- 60 unchanged lines hidden ---