Deleted Added
full compact
tcp_usrreq.c (127504) tcp_usrreq.c (127505)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
34 * $FreeBSD: head/sys/netinet/tcp_usrreq.c 127504 2004-03-27 20:41:32Z pjd $
34 * $FreeBSD: head/sys/netinet/tcp_usrreq.c 127505 2004-03-27 21:05:46Z pjd $
35 */
36
37#include "opt_ipsec.h"
38#include "opt_inet.h"
39#include "opt_inet6.h"
40#include "opt_tcpdebug.h"
41
42#include <sys/param.h>

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

247 sinp = (struct sockaddr_in *)nam;
248 if (nam->sa_len != sizeof (*sinp))
249 return (EINVAL);
250 if (sinp->sin_family == AF_INET &&
251 IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
252 error = EAFNOSUPPORT;
253 goto out;
254 }
35 */
36
37#include "opt_ipsec.h"
38#include "opt_inet.h"
39#include "opt_inet6.h"
40#include "opt_tcpdebug.h"
41
42#include <sys/param.h>

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

247 sinp = (struct sockaddr_in *)nam;
248 if (nam->sa_len != sizeof (*sinp))
249 return (EINVAL);
250 if (sinp->sin_family == AF_INET &&
251 IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
252 error = EAFNOSUPPORT;
253 goto out;
254 }
255 error = in_pcbbind(inp, nam, td);
255 error = in_pcbbind(inp, nam, td->td_ucred);
256 if (error)
257 goto out;
258 COMMON_END(PRU_BIND);
259}
260
261#ifdef INET6
262static int
263tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)

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

289 if (IN6_IS_ADDR_UNSPECIFIED(&sin6p->sin6_addr))
290 inp->inp_vflag |= INP_IPV4;
291 else if (IN6_IS_ADDR_V4MAPPED(&sin6p->sin6_addr)) {
292 struct sockaddr_in sin;
293
294 in6_sin6_2_sin(&sin, sin6p);
295 inp->inp_vflag |= INP_IPV4;
296 inp->inp_vflag &= ~INP_IPV6;
256 if (error)
257 goto out;
258 COMMON_END(PRU_BIND);
259}
260
261#ifdef INET6
262static int
263tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)

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

289 if (IN6_IS_ADDR_UNSPECIFIED(&sin6p->sin6_addr))
290 inp->inp_vflag |= INP_IPV4;
291 else if (IN6_IS_ADDR_V4MAPPED(&sin6p->sin6_addr)) {
292 struct sockaddr_in sin;
293
294 in6_sin6_2_sin(&sin, sin6p);
295 inp->inp_vflag |= INP_IPV4;
296 inp->inp_vflag &= ~INP_IPV6;
297 error = in_pcbbind(inp, (struct sockaddr *)&sin, td);
297 error = in_pcbbind(inp, (struct sockaddr *)&sin,
298 td->td_ucred);
298 goto out;
299 }
300 }
299 goto out;
300 }
301 }
301 error = in6_pcbbind(inp, nam, td);
302 error = in6_pcbbind(inp, nam, td->td_ucred);
302 if (error)
303 goto out;
304 COMMON_END(PRU_BIND);
305}
306#endif /* INET6 */
307
308/*
309 * Prepare to accept connections.

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

314 int s = splnet();
315 int error = 0;
316 struct inpcb *inp;
317 struct tcpcb *tp;
318 const int inirw = INI_WRITE;
319
320 COMMON_START();
321 if (inp->inp_lport == 0)
303 if (error)
304 goto out;
305 COMMON_END(PRU_BIND);
306}
307#endif /* INET6 */
308
309/*
310 * Prepare to accept connections.

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

315 int s = splnet();
316 int error = 0;
317 struct inpcb *inp;
318 struct tcpcb *tp;
319 const int inirw = INI_WRITE;
320
321 COMMON_START();
322 if (inp->inp_lport == 0)
322 error = in_pcbbind(inp, (struct sockaddr *)0, td);
323 error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
323 if (error == 0)
324 tp->t_state = TCPS_LISTEN;
325 COMMON_END(PRU_LISTEN);
326}
327
328#ifdef INET6
329static int
330tcp6_usr_listen(struct socket *so, struct thread *td)

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

335 struct tcpcb *tp;
336 const int inirw = INI_WRITE;
337
338 COMMON_START();
339 if (inp->inp_lport == 0) {
340 inp->inp_vflag &= ~INP_IPV4;
341 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0)
342 inp->inp_vflag |= INP_IPV4;
324 if (error == 0)
325 tp->t_state = TCPS_LISTEN;
326 COMMON_END(PRU_LISTEN);
327}
328
329#ifdef INET6
330static int
331tcp6_usr_listen(struct socket *so, struct thread *td)

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

336 struct tcpcb *tp;
337 const int inirw = INI_WRITE;
338
339 COMMON_START();
340 if (inp->inp_lport == 0) {
341 inp->inp_vflag &= ~INP_IPV4;
342 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0)
343 inp->inp_vflag |= INP_IPV4;
343 error = in6_pcbbind(inp, (struct sockaddr *)0, td);
344 error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
344 }
345 if (error == 0)
346 tp->t_state = TCPS_LISTEN;
347 COMMON_END(PRU_LISTEN);
348}
349#endif /* INET6 */
350
351/*

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

860 struct rmxp_tao tao;
861 struct in_addr laddr;
862 u_short lport;
863 int error;
864
865 bzero(&tao, sizeof(tao));
866
867 if (inp->inp_lport == 0) {
345 }
346 if (error == 0)
347 tp->t_state = TCPS_LISTEN;
348 COMMON_END(PRU_LISTEN);
349}
350#endif /* INET6 */
351
352/*

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

861 struct rmxp_tao tao;
862 struct in_addr laddr;
863 u_short lport;
864 int error;
865
866 bzero(&tao, sizeof(tao));
867
868 if (inp->inp_lport == 0) {
868 error = in_pcbbind(inp, (struct sockaddr *)0, td);
869 error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
869 if (error)
870 return error;
871 }
872
873 /*
874 * Cannot simply call in_pcbconnect, because there might be an
875 * earlier incarnation of this same connection still in
876 * TIME_WAIT state, creating an ADDRINUSE error.
877 */
878 laddr = inp->inp_laddr;
879 lport = inp->inp_lport;
880 error = in_pcbconnect_setup(inp, nam, &laddr.s_addr, &lport,
870 if (error)
871 return error;
872 }
873
874 /*
875 * Cannot simply call in_pcbconnect, because there might be an
876 * earlier incarnation of this same connection still in
877 * TIME_WAIT state, creating an ADDRINUSE error.
878 */
879 laddr = inp->inp_laddr;
880 lport = inp->inp_lport;
881 error = in_pcbconnect_setup(inp, nam, &laddr.s_addr, &lport,
881 &inp->inp_faddr.s_addr, &inp->inp_fport, &oinp, td);
882 &inp->inp_faddr.s_addr, &inp->inp_fport, &oinp, td->td_ucred);
882 if (error && oinp == NULL)
883 return error;
884 if (oinp) {
885 if (oinp != inp &&
886 (oinp->inp_vflag & INP_TIMEWAIT) &&
887 (ticks - (otw = intotw(oinp))->t_starttime) < tcp_msl &&
888 otw->cc_recv != 0) {
889 inp->inp_faddr = oinp->inp_faddr;

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

944 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
945 struct in6_addr *addr6;
946 struct rmxp_tao tao;
947 int error;
948
949 bzero(&tao, sizeof(tao));
950
951 if (inp->inp_lport == 0) {
883 if (error && oinp == NULL)
884 return error;
885 if (oinp) {
886 if (oinp != inp &&
887 (oinp->inp_vflag & INP_TIMEWAIT) &&
888 (ticks - (otw = intotw(oinp))->t_starttime) < tcp_msl &&
889 otw->cc_recv != 0) {
890 inp->inp_faddr = oinp->inp_faddr;

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

945 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
946 struct in6_addr *addr6;
947 struct rmxp_tao tao;
948 int error;
949
950 bzero(&tao, sizeof(tao));
951
952 if (inp->inp_lport == 0) {
952 error = in6_pcbbind(inp, (struct sockaddr *)0, td);
953 error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
953 if (error)
954 return error;
955 }
956
957 /*
958 * Cannot simply call in_pcbconnect, because there might be an
959 * earlier incarnation of this same connection still in
960 * TIME_WAIT state, creating an ADDRINUSE error.

--- 349 unchanged lines hidden ---
954 if (error)
955 return error;
956 }
957
958 /*
959 * Cannot simply call in_pcbconnect, because there might be an
960 * earlier incarnation of this same connection still in
961 * TIME_WAIT state, creating an ADDRINUSE error.

--- 349 unchanged lines hidden ---