Deleted Added
full compact
tcp_usrreq.c (185371) tcp_usrreq.c (185435)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California.
4 * Copyright (c) 2006-2007 Robert N. M. Watson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California.
4 * Copyright (c) 2006-2007 Robert N. M. Watson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/netinet/tcp_usrreq.c 185371 2008-11-27 13:19:42Z bz $");
35__FBSDID("$FreeBSD: head/sys/netinet/tcp_usrreq.c 185435 2008-11-29 14:32:14Z bz $");
36
37#include "opt_ddb.h"
38#include "opt_inet.h"
39#include "opt_inet6.h"
40#include "opt_tcpdebug.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>

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

435 if (nam->sa_len != sizeof (*sinp))
436 return (EINVAL);
437 /*
438 * Must disallow TCP ``connections'' to multicast addresses.
439 */
440 if (sinp->sin_family == AF_INET
441 && IN_MULTICAST(ntohl(sinp->sin_addr.s_addr)))
442 return (EAFNOSUPPORT);
36
37#include "opt_ddb.h"
38#include "opt_inet.h"
39#include "opt_inet6.h"
40#include "opt_tcpdebug.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>

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

435 if (nam->sa_len != sizeof (*sinp))
436 return (EINVAL);
437 /*
438 * Must disallow TCP ``connections'' to multicast addresses.
439 */
440 if (sinp->sin_family == AF_INET
441 && IN_MULTICAST(ntohl(sinp->sin_addr.s_addr)))
442 return (EAFNOSUPPORT);
443 if (jailed(td->td_ucred))
444 prison_remote_ip(td->td_ucred, 0, &sinp->sin_addr.s_addr);
443 if (prison_remote_ip4(td->td_ucred, &sinp->sin_addr) != 0)
444 return (EINVAL);
445
446 TCPDEBUG0;
447 INP_INFO_WLOCK(&V_tcbinfo);
448 inp = sotoinpcb(so);
449 KASSERT(inp != NULL, ("tcp_usr_connect: inp == NULL"));
450 INP_WLOCK(inp);
451 if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
452 error = EINVAL;

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

502 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) {
503 error = EINVAL;
504 goto out;
505 }
506
507 in6_sin6_2_sin(&sin, sin6p);
508 inp->inp_vflag |= INP_IPV4;
509 inp->inp_vflag &= ~INP_IPV6;
445
446 TCPDEBUG0;
447 INP_INFO_WLOCK(&V_tcbinfo);
448 inp = sotoinpcb(so);
449 KASSERT(inp != NULL, ("tcp_usr_connect: inp == NULL"));
450 INP_WLOCK(inp);
451 if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
452 error = EINVAL;

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

502 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) {
503 error = EINVAL;
504 goto out;
505 }
506
507 in6_sin6_2_sin(&sin, sin6p);
508 inp->inp_vflag |= INP_IPV4;
509 inp->inp_vflag &= ~INP_IPV6;
510 if (prison_remote_ip4(td->td_ucred, &sin.sin_addr) != 0) {
511 error = EINVAL;
512 goto out;
513 }
510 if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0)
511 goto out;
512 error = tcp_output_connect(so, nam);
513 goto out;
514 }
515 inp->inp_vflag &= ~INP_IPV4;
516 inp->inp_vflag |= INP_IPV6;
517 inp->inp_inc.inc_isipv6 = 1;
514 if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0)
515 goto out;
516 error = tcp_output_connect(so, nam);
517 goto out;
518 }
519 inp->inp_vflag &= ~INP_IPV4;
520 inp->inp_vflag |= INP_IPV6;
521 inp->inp_inc.inc_isipv6 = 1;
522 if (prison_remote_ip6(td->td_ucred, &sin6p->sin6_addr) != 0) {
523 error = EINVAL;
524 goto out;
525 }
518 if ((error = tcp6_connect(tp, nam, td)) != 0)
519 goto out;
520 error = tcp_output_connect(so, nam);
521
522out:
523 TCPDEBUG2(PRU_CONNECT);
524 INP_WUNLOCK(inp);
525 INP_INFO_WUNLOCK(&V_tcbinfo);

--- 1364 unchanged lines hidden ---
526 if ((error = tcp6_connect(tp, nam, td)) != 0)
527 goto out;
528 error = tcp_output_connect(so, nam);
529
530out:
531 TCPDEBUG2(PRU_CONNECT);
532 INP_WUNLOCK(inp);
533 INP_INFO_WUNLOCK(&V_tcbinfo);

--- 1364 unchanged lines hidden ---