Deleted Added
full compact
sctp_asconf.c (243882) sctp_asconf.c (246595)
1/*-
2 * Copyright (c) 2001-2007, 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-2007, 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_asconf.c 243882 2012-12-05 08:04:20Z glebius $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 246595 2013-02-09 17:26:14Z tuexen $");
35
36#include <netinet/sctp_os.h>
37#include <netinet/sctp_var.h>
38#include <netinet/sctp_sysctl.h>
39#include <netinet/sctp_pcb.h>
40#include <netinet/sctp_header.h>
41#include <netinet/sctputil.h>
42#include <netinet/sctp_output.h>

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

1911 struct sockaddr_in6 *sin6;
1912
1913 sin6 = (struct sockaddr_in6 *)&ifa->address.sin6;
1914 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
1915 /* we skip unspecifed addresses */
1916 return;
1917 }
1918 if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
35
36#include <netinet/sctp_os.h>
37#include <netinet/sctp_var.h>
38#include <netinet/sctp_sysctl.h>
39#include <netinet/sctp_pcb.h>
40#include <netinet/sctp_header.h>
41#include <netinet/sctputil.h>
42#include <netinet/sctp_output.h>

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

1911 struct sockaddr_in6 *sin6;
1912
1913 sin6 = (struct sockaddr_in6 *)&ifa->address.sin6;
1914 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
1915 /* we skip unspecifed addresses */
1916 return;
1917 }
1918 if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
1919 if (stcb->asoc.local_scope == 0) {
1919 if (stcb->asoc.scope.local_scope == 0) {
1920 return;
1921 }
1922 /* is it the right link local scope? */
1923 if (sctp_is_scopeid_in_nets(stcb, &ifa->address.sa) == 0) {
1924 return;
1925 }
1926 }
1920 return;
1921 }
1922 /* is it the right link local scope? */
1923 if (sctp_is_scopeid_in_nets(stcb, &ifa->address.sa) == 0) {
1924 return;
1925 }
1926 }
1927 if (stcb->asoc.site_scope == 0 &&
1927 if (stcb->asoc.scope.site_scope == 0 &&
1928 IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) {
1929 return;
1930 }
1931 break;
1932 }
1933#endif
1934#ifdef INET
1935 case AF_INET:

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

1943 SCTP_IPV6_V6ONLY(inp6))
1944 return;
1945
1946 sin = (struct sockaddr_in *)&ifa->address.sa;
1947 if (sin->sin_addr.s_addr == 0) {
1948 /* we skip unspecifed addresses */
1949 return;
1950 }
1928 IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) {
1929 return;
1930 }
1931 break;
1932 }
1933#endif
1934#ifdef INET
1935 case AF_INET:

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

1943 SCTP_IPV6_V6ONLY(inp6))
1944 return;
1945
1946 sin = (struct sockaddr_in *)&ifa->address.sa;
1947 if (sin->sin_addr.s_addr == 0) {
1948 /* we skip unspecifed addresses */
1949 return;
1950 }
1951 if (stcb->asoc.ipv4_local_scope == 0 &&
1951 if (stcb->asoc.scope.ipv4_local_scope == 0 &&
1952 IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) {
1953 return;
1954 }
1955 break;
1956 }
1957#endif
1958 default:
1959 /* else, not AF_INET or AF_INET6, so skip */

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

2101 continue;
2102 }
2103 sin6 = (struct sockaddr_in6 *)&ifa->address.sin6;
2104 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
2105 /* we skip unspecifed addresses */
2106 continue;
2107 }
2108 if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
1952 IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) {
1953 return;
1954 }
1955 break;
1956 }
1957#endif
1958 default:
1959 /* else, not AF_INET or AF_INET6, so skip */

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

2101 continue;
2102 }
2103 sin6 = (struct sockaddr_in6 *)&ifa->address.sin6;
2104 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
2105 /* we skip unspecifed addresses */
2106 continue;
2107 }
2108 if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
2109 if (stcb->asoc.local_scope == 0) {
2109 if (stcb->asoc.scope.local_scope == 0) {
2110 continue;
2111 }
2112 /* is it the right link local scope? */
2113 if (sctp_is_scopeid_in_nets(stcb, &ifa->address.sa) == 0) {
2114 continue;
2115 }
2116 }
2117 break;

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

2130 SCTP_IPV6_V6ONLY(inp6))
2131 continue;
2132
2133 sin = (struct sockaddr_in *)&ifa->address.sa;
2134 if (sin->sin_addr.s_addr == 0) {
2135 /* we skip unspecifed addresses */
2136 continue;
2137 }
2110 continue;
2111 }
2112 /* is it the right link local scope? */
2113 if (sctp_is_scopeid_in_nets(stcb, &ifa->address.sa) == 0) {
2114 continue;
2115 }
2116 }
2117 break;

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

2130 SCTP_IPV6_V6ONLY(inp6))
2131 continue;
2132
2133 sin = (struct sockaddr_in *)&ifa->address.sa;
2134 if (sin->sin_addr.s_addr == 0) {
2135 /* we skip unspecifed addresses */
2136 continue;
2137 }
2138 if (stcb->asoc.ipv4_local_scope == 0 &&
2138 if (stcb->asoc.scope.ipv4_local_scope == 0 &&
2139 IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) {
2140 continue;
2141 }
2142 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
2143 SCTP_IPV6_V6ONLY(inp6)) {
2144 cnt_invalid++;
2145 if (asc->cnt == cnt_invalid)
2146 return;

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

2193 } else if (type == SCTP_SET_PRIM_ADDR) {
2194 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) {
2195 /* must validate the ifa is in the ep */
2196 if (sctp_is_addr_in_ep(stcb->sctp_ep, ifa) == 0) {
2197 continue;
2198 }
2199 } else {
2200 /* Need to check scopes for this guy */
2139 IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) {
2140 continue;
2141 }
2142 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
2143 SCTP_IPV6_V6ONLY(inp6)) {
2144 cnt_invalid++;
2145 if (asc->cnt == cnt_invalid)
2146 return;

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

2193 } else if (type == SCTP_SET_PRIM_ADDR) {
2194 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) {
2195 /* must validate the ifa is in the ep */
2196 if (sctp_is_addr_in_ep(stcb->sctp_ep, ifa) == 0) {
2197 continue;
2198 }
2199 } else {
2200 /* Need to check scopes for this guy */
2201 if (sctp_is_address_in_scope(ifa,
2202 stcb->asoc.ipv4_addr_legal,
2203 stcb->asoc.ipv6_addr_legal,
2204 stcb->asoc.loopback_scope,
2205 stcb->asoc.ipv4_local_scope,
2206 stcb->asoc.local_scope,
2207 stcb->asoc.site_scope, 0) == 0) {
2201 if (sctp_is_address_in_scope(ifa, &stcb->asoc.scope, 0) == 0) {
2208 continue;
2209 }
2210 }
2211 }
2212 /* queue an asconf for this address add/delete */
2213 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF) &&
2214 stcb->asoc.peer_supports_asconf) {
2215 /* queue an asconf for this addr */

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

2432 SCTP_IPI_ADDR_RLOCK();
2433 vrf = sctp_find_vrf(stcb->asoc.vrf_id);
2434 if (vrf == NULL) {
2435 if (addr_locked == SCTP_ADDR_NOT_LOCKED)
2436 SCTP_IPI_ADDR_RUNLOCK();
2437 return (NULL);
2438 }
2439 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
2202 continue;
2203 }
2204 }
2205 }
2206 /* queue an asconf for this address add/delete */
2207 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF) &&
2208 stcb->asoc.peer_supports_asconf) {
2209 /* queue an asconf for this addr */

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

2426 SCTP_IPI_ADDR_RLOCK();
2427 vrf = sctp_find_vrf(stcb->asoc.vrf_id);
2428 if (vrf == NULL) {
2429 if (addr_locked == SCTP_ADDR_NOT_LOCKED)
2430 SCTP_IPI_ADDR_RUNLOCK();
2431 return (NULL);
2432 }
2433 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
2440 if (stcb->asoc.loopback_scope == 0 &&
2434 if (stcb->asoc.scope.loopback_scope == 0 &&
2441 SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) {
2442 /* Skip if loopback_scope not set */
2443 continue;
2444 }
2445 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
2446 switch (sctp_ifa->address.sa.sa_family) {
2447#ifdef INET
2448 case AF_INET:
2435 SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) {
2436 /* Skip if loopback_scope not set */
2437 continue;
2438 }
2439 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
2440 switch (sctp_ifa->address.sa.sa_family) {
2441#ifdef INET
2442 case AF_INET:
2449 if (stcb->asoc.ipv4_addr_legal) {
2443 if (stcb->asoc.scope.ipv4_addr_legal) {
2450 struct sockaddr_in *sin;
2451
2452 sin = (struct sockaddr_in *)&sctp_ifa->address.sa;
2453 if (sin->sin_addr.s_addr == 0) {
2454 /* skip unspecifed addresses */
2455 continue;
2456 }
2444 struct sockaddr_in *sin;
2445
2446 sin = (struct sockaddr_in *)&sctp_ifa->address.sa;
2447 if (sin->sin_addr.s_addr == 0) {
2448 /* skip unspecifed addresses */
2449 continue;
2450 }
2457 if (stcb->asoc.ipv4_local_scope == 0 &&
2451 if (stcb->asoc.scope.ipv4_local_scope == 0 &&
2458 IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))
2459 continue;
2460
2461 if (sctp_is_addr_restricted(stcb, sctp_ifa) &&
2462 (!sctp_is_addr_pending(stcb, sctp_ifa)))
2463 continue;
2464 /*
2465 * found a valid local v4 address to
2466 * use
2467 */
2468 if (addr_locked == SCTP_ADDR_NOT_LOCKED)
2469 SCTP_IPI_ADDR_RUNLOCK();
2470 return (&sctp_ifa->address.sa);
2471 }
2472 break;
2473#endif
2474#ifdef INET6
2475 case AF_INET6:
2452 IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))
2453 continue;
2454
2455 if (sctp_is_addr_restricted(stcb, sctp_ifa) &&
2456 (!sctp_is_addr_pending(stcb, sctp_ifa)))
2457 continue;
2458 /*
2459 * found a valid local v4 address to
2460 * use
2461 */
2462 if (addr_locked == SCTP_ADDR_NOT_LOCKED)
2463 SCTP_IPI_ADDR_RUNLOCK();
2464 return (&sctp_ifa->address.sa);
2465 }
2466 break;
2467#endif
2468#ifdef INET6
2469 case AF_INET6:
2476 if (stcb->asoc.ipv6_addr_legal) {
2470 if (stcb->asoc.scope.ipv6_addr_legal) {
2477 struct sockaddr_in6 *sin6;
2478
2479 if (sctp_ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) {
2480 continue;
2481 }
2482 sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa;
2483 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
2484 /*
2485 * we skip unspecifed
2486 * addresses
2487 */
2488 continue;
2489 }
2471 struct sockaddr_in6 *sin6;
2472
2473 if (sctp_ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) {
2474 continue;
2475 }
2476 sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa;
2477 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
2478 /*
2479 * we skip unspecifed
2480 * addresses
2481 */
2482 continue;
2483 }
2490 if (stcb->asoc.local_scope == 0 &&
2484 if (stcb->asoc.scope.local_scope == 0 &&
2491 IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
2492 continue;
2485 IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
2486 continue;
2493 if (stcb->asoc.site_scope == 0 &&
2487 if (stcb->asoc.scope.site_scope == 0 &&
2494 IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))
2495 continue;
2496
2497 if (sctp_is_addr_restricted(stcb, sctp_ifa) &&
2498 (!sctp_is_addr_pending(stcb, sctp_ifa)))
2499 continue;
2500 /*
2501 * found a valid local v6 address to

--- 976 unchanged lines hidden ---
2488 IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))
2489 continue;
2490
2491 if (sctp_is_addr_restricted(stcb, sctp_ifa) &&
2492 (!sctp_is_addr_pending(stcb, sctp_ifa)))
2493 continue;
2494 /*
2495 * found a valid local v6 address to

--- 976 unchanged lines hidden ---