Deleted Added
full compact
sctp_pcb.c (185366) sctp_pcb.c (185435)
1/*-
2 * Copyright (c) 2001-2007, 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_pcb.c,v 1.38 2005/03/06 16:04:18 itojun Exp $ */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2007, 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_pcb.c,v 1.38 2005/03/06 16:04:18 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 185366 2008-11-27 10:43:08Z bz $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 185435 2008-11-29 14:32:14Z bz $");
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_pcb.h>
41#include <netinet/sctputil.h>
42#include <netinet/sctp.h>

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

2548 struct sctp_ifa *sctp_ifap, struct thread *p)
2549{
2550 /* bind a ep to a socket address */
2551 struct sctppcbhead *head;
2552 struct sctp_inpcb *inp, *inp_tmp;
2553 struct inpcb *ip_inp;
2554 int port_reuse_active = 0;
2555 int bindall;
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_pcb.h>
41#include <netinet/sctputil.h>
42#include <netinet/sctp.h>

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

2548 struct sctp_ifa *sctp_ifap, struct thread *p)
2549{
2550 /* bind a ep to a socket address */
2551 struct sctppcbhead *head;
2552 struct sctp_inpcb *inp, *inp_tmp;
2553 struct inpcb *ip_inp;
2554 int port_reuse_active = 0;
2555 int bindall;
2556 int prison = 0;
2557 uint16_t lport;
2558 int error;
2559 uint32_t vrf_id;
2560
2561 lport = 0;
2562 error = 0;
2563 bindall = 1;
2564 inp = (struct sctp_inpcb *)so->so_pcb;

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

2575 /* already did a bind, subsequent binds NOT allowed ! */
2576 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2577 return (EINVAL);
2578 }
2579#ifdef INVARIANTS
2580 if (p == NULL)
2581 panic("null proc/thread");
2582#endif
2556 uint16_t lport;
2557 int error;
2558 uint32_t vrf_id;
2559
2560 lport = 0;
2561 error = 0;
2562 bindall = 1;
2563 inp = (struct sctp_inpcb *)so->so_pcb;

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

2574 /* already did a bind, subsequent binds NOT allowed ! */
2575 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2576 return (EINVAL);
2577 }
2578#ifdef INVARIANTS
2579 if (p == NULL)
2580 panic("null proc/thread");
2581#endif
2583 if (p && jailed(p->td_ucred)) {
2584 prison = 1;
2585 }
2586 if (addr != NULL) {
2587 switch (addr->sa_family) {
2588 case AF_INET:
2589 {
2590 struct sockaddr_in *sin;
2591
2592 /* IPV6_V6ONLY socket? */
2593 if (SCTP_IPV6_V6ONLY(ip_inp)) {
2594 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2595 return (EINVAL);
2596 }
2597 if (addr->sa_len != sizeof(*sin)) {
2598 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2599 return (EINVAL);
2600 }
2601 sin = (struct sockaddr_in *)addr;
2602 lport = sin->sin_port;
2582 if (addr != NULL) {
2583 switch (addr->sa_family) {
2584 case AF_INET:
2585 {
2586 struct sockaddr_in *sin;
2587
2588 /* IPV6_V6ONLY socket? */
2589 if (SCTP_IPV6_V6ONLY(ip_inp)) {
2590 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2591 return (EINVAL);
2592 }
2593 if (addr->sa_len != sizeof(*sin)) {
2594 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2595 return (EINVAL);
2596 }
2597 sin = (struct sockaddr_in *)addr;
2598 lport = sin->sin_port;
2603 if (prison) {
2604 /*
2605 * For INADDR_ANY and LOOPBACK the
2606 * prison_ip() call will transmute
2607 * the ip address to the proper
2608 * value (i.e. the IP address owned
2609 * by the jail).
2610 */
2611 if (prison_ip(p->td_ucred, 0, &sin->sin_addr.s_addr)) {
2612 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2613 return (EINVAL);
2614 }
2599 /*
2600 * For LOOPBACK the prison_local_ip4() call will transmute the ip address
2601 * to the proper value.
2602 */
2603 if (p && prison_local_ip4(p->td_ucred, &sin->sin_addr) != 0) {
2604 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2605 return (EINVAL);
2615 }
2616 if (sin->sin_addr.s_addr != INADDR_ANY) {
2617 bindall = 0;
2618 }
2619 break;
2620 }
2621#ifdef INET6
2622 case AF_INET6:

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

2629
2630 sin6 = (struct sockaddr_in6 *)addr;
2631
2632 if (addr->sa_len != sizeof(*sin6)) {
2633 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2634 return (EINVAL);
2635 }
2636 lport = sin6->sin6_port;
2606 }
2607 if (sin->sin_addr.s_addr != INADDR_ANY) {
2608 bindall = 0;
2609 }
2610 break;
2611 }
2612#ifdef INET6
2613 case AF_INET6:

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

2620
2621 sin6 = (struct sockaddr_in6 *)addr;
2622
2623 if (addr->sa_len != sizeof(*sin6)) {
2624 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2625 return (EINVAL);
2626 }
2627 lport = sin6->sin6_port;
2628
2637 /*
2629 /*
2638 * Jail checks for IPv6 should go HERE! i.e.
2639 * add the prison_ip() equivilant in this
2640 * postion to transmute the addresses to the
2641 * proper one jailed.
2630 * For LOOPBACK the prison_local_ip6() call will transmute the ipv6 address
2631 * to the proper value.
2642 */
2632 */
2633 if (p && prison_local_ip6(p->td_ucred, &sin6->sin6_addr,
2634 (SCTP_IPV6_V6ONLY(inp) != 0)) != 0) {
2635 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2636 return (EINVAL);
2637 }
2643 if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
2644 bindall = 0;
2645 /* KAME hack: embed scopeid */
2646 if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
2647 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2648 return (EINVAL);
2649 }
2650 }

--- 3918 unchanged lines hidden ---
2638 if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
2639 bindall = 0;
2640 /* KAME hack: embed scopeid */
2641 if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
2642 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2643 return (EINVAL);
2644 }
2645 }

--- 3918 unchanged lines hidden ---