Deleted Added
full compact
tcp_timewait.c (77900) tcp_timewait.c (78064)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
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 * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
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 * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
34 * $FreeBSD: head/sys/netinet/tcp_timewait.c 77900 2001-06-08 05:24:21Z peter $
34 * $FreeBSD: head/sys/netinet/tcp_timewait.c 78064 2001-06-11 12:39:29Z ume $
35 */
36
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_ipsec.h"
40#include "opt_tcpdebug.h"
41
42#include <sys/param.h>

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

438 m->m_pkthdr.csum_flags = CSUM_TCP;
439 m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum);
440 }
441#ifdef TCPDEBUG
442 if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
443 tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0);
444#endif
445#ifdef IPSEC
35 */
36
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_ipsec.h"
40#include "opt_tcpdebug.h"
41
42#include <sys/param.h>

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

438 m->m_pkthdr.csum_flags = CSUM_TCP;
439 m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum);
440 }
441#ifdef TCPDEBUG
442 if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
443 tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0);
444#endif
445#ifdef IPSEC
446 ipsec_setsocket(m, tp ? tp->t_inpcb->inp_socket : NULL);
446 if (ipsec_setsocket(m, tp ? tp->t_inpcb->inp_socket : NULL) != 0) {
447 m_freem(m);
448 return;
449 }
447#endif
448#ifdef INET6
449 if (isipv6) {
450 (void)ip6_output(m, NULL, ro6, ipflags, NULL, NULL);
451 if (ro6 == &sro6 && ro6->ro_rt) {
452 RTFREE(ro6->ro_rt);
453 ro6->ro_rt = NULL;
454 }

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

1015
1016#ifdef INET6
1017void
1018tcp6_ctlinput(cmd, sa, d)
1019 int cmd;
1020 struct sockaddr *sa;
1021 void *d;
1022{
450#endif
451#ifdef INET6
452 if (isipv6) {
453 (void)ip6_output(m, NULL, ro6, ipflags, NULL, NULL);
454 if (ro6 == &sro6 && ro6->ro_rt) {
455 RTFREE(ro6->ro_rt);
456 ro6->ro_rt = NULL;
457 }

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

1018
1019#ifdef INET6
1020void
1021tcp6_ctlinput(cmd, sa, d)
1022 int cmd;
1023 struct sockaddr *sa;
1024 void *d;
1025{
1023 register struct tcphdr *thp;
1024 struct tcphdr th;
1025 void (*notify) __P((struct inpcb *, int)) = tcp_notify;
1026 struct tcphdr th;
1027 void (*notify) __P((struct inpcb *, int)) = tcp_notify;
1026 struct sockaddr_in6 sa6;
1027 struct ip6_hdr *ip6;
1028 struct mbuf *m;
1028 struct ip6_hdr *ip6;
1029 struct mbuf *m;
1030 struct ip6ctlparam *ip6cp = NULL;
1031 const struct sockaddr_in6 *sa6_src = NULL;
1029 int off;
1032 int off;
1033 struct tcp_portonly {
1034 u_int16_t th_sport;
1035 u_int16_t th_dport;
1036 } *thp;
1030
1031 if (sa->sa_family != AF_INET6 ||
1032 sa->sa_len != sizeof(struct sockaddr_in6))
1033 return;
1034
1035 if (cmd == PRC_QUENCH)
1036 notify = tcp_quench;
1037 else if (cmd == PRC_MSGSIZE)
1038 notify = tcp_mtudisc;
1039 else if (!PRC_IS_REDIRECT(cmd) &&
1040 ((unsigned)cmd > PRC_NCMDS || inet6ctlerrmap[cmd] == 0))
1041 return;
1042
1043 /* if the parameter is from icmp6, decode it. */
1044 if (d != NULL) {
1037
1038 if (sa->sa_family != AF_INET6 ||
1039 sa->sa_len != sizeof(struct sockaddr_in6))
1040 return;
1041
1042 if (cmd == PRC_QUENCH)
1043 notify = tcp_quench;
1044 else if (cmd == PRC_MSGSIZE)
1045 notify = tcp_mtudisc;
1046 else if (!PRC_IS_REDIRECT(cmd) &&
1047 ((unsigned)cmd > PRC_NCMDS || inet6ctlerrmap[cmd] == 0))
1048 return;
1049
1050 /* if the parameter is from icmp6, decode it. */
1051 if (d != NULL) {
1045 struct ip6ctlparam *ip6cp = (struct ip6ctlparam *)d;
1052 ip6cp = (struct ip6ctlparam *)d;
1046 m = ip6cp->ip6c_m;
1047 ip6 = ip6cp->ip6c_ip6;
1048 off = ip6cp->ip6c_off;
1053 m = ip6cp->ip6c_m;
1054 ip6 = ip6cp->ip6c_ip6;
1055 off = ip6cp->ip6c_off;
1056 sa6_src = ip6cp->ip6c_src;
1049 } else {
1050 m = NULL;
1051 ip6 = NULL;
1052 off = 0; /* fool gcc */
1057 } else {
1058 m = NULL;
1059 ip6 = NULL;
1060 off = 0; /* fool gcc */
1061 sa6_src = &sa6_any;
1053 }
1054
1062 }
1063
1055 /*
1056 * Translate addresses into internal form.
1057 * Sa check if it is AF_INET6 is done at the top of this funciton.
1058 */
1059 sa6 = *(struct sockaddr_in6 *)sa;
1060 if (IN6_IS_ADDR_LINKLOCAL(&sa6.sin6_addr) != 0 && m != NULL &&
1061 m->m_pkthdr.rcvif != NULL)
1062 sa6.sin6_addr.s6_addr16[1] = htons(m->m_pkthdr.rcvif->if_index);
1063
1064 if (ip6) {
1065 /*
1066 * XXX: We assume that when IPV6 is non NULL,
1067 * M and OFF are valid.
1068 */
1064 if (ip6) {
1065 /*
1066 * XXX: We assume that when IPV6 is non NULL,
1067 * M and OFF are valid.
1068 */
1069 struct in6_addr s;
1070
1069
1071 /* translate addresses into internal form */
1072 memcpy(&s, &ip6->ip6_src, sizeof(s));
1073 if (IN6_IS_ADDR_LINKLOCAL(&s) != 0 && m != NULL &&
1074 m->m_pkthdr.rcvif != NULL)
1075 s.s6_addr16[1] = htons(m->m_pkthdr.rcvif->if_index);
1076
1077 /* check if we can safely examine src and dst ports */
1070 /* check if we can safely examine src and dst ports */
1078 if (m->m_pkthdr.len < off + sizeof(th))
1071 if (m->m_pkthdr.len < off + sizeof(*thp))
1079 return;
1080
1072 return;
1073
1081 if (m->m_len < off + sizeof(th)) {
1082 /*
1083 * this should be rare case
1084 * because now MINCLSIZE is "(MHLEN + 1)",
1085 * so we compromise on this copy...
1086 */
1087 m_copydata(m, off, sizeof(th), (caddr_t)&th);
1088 thp = &th;
1089 } else
1090 thp = (struct tcphdr *)(mtod(m, caddr_t) + off);
1091 in6_pcbnotify(&tcb, (struct sockaddr *)&sa6, thp->th_dport,
1092 &s, thp->th_sport, cmd, notify);
1074 bzero(&th, sizeof(th));
1075 m_copydata(m, off, sizeof(*thp), (caddr_t)&th);
1076
1077 in6_pcbnotify(&tcb, sa, th.th_dport,
1078 (struct sockaddr *)ip6cp->ip6c_src,
1079 th.th_sport, cmd, notify);
1093 } else
1080 } else
1094 in6_pcbnotify(&tcb, (struct sockaddr *)&sa6, 0, &zeroin6_addr,
1081 in6_pcbnotify(&tcb, sa, 0, (struct sockaddr *)sa6_src,
1095 0, cmd, notify);
1096}
1097#endif /* INET6 */
1098
1099#define TCP_RNDISS_ROUNDS 16
1100#define TCP_RNDISS_OUT 7200
1101#define TCP_RNDISS_MAX 30000
1102

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

1318 struct route_in6 *ro6;
1319 struct rtentry *rt;
1320
1321 ro6 = &inp->in6p_route;
1322 rt = ro6->ro_rt;
1323 if (rt == NULL || !(rt->rt_flags & RTF_UP)) {
1324 /* No route yet, so try to acquire one */
1325 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
1082 0, cmd, notify);
1083}
1084#endif /* INET6 */
1085
1086#define TCP_RNDISS_ROUNDS 16
1087#define TCP_RNDISS_OUT 7200
1088#define TCP_RNDISS_MAX 30000
1089

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

1305 struct route_in6 *ro6;
1306 struct rtentry *rt;
1307
1308 ro6 = &inp->in6p_route;
1309 rt = ro6->ro_rt;
1310 if (rt == NULL || !(rt->rt_flags & RTF_UP)) {
1311 /* No route yet, so try to acquire one */
1312 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
1326 ro6->ro_dst.sin6_family = AF_INET6;
1327 ro6->ro_dst.sin6_len = sizeof(ro6->ro_dst);
1328 ro6->ro_dst.sin6_addr = inp->in6p_faddr;
1313 struct sockaddr_in6 *dst6;
1314
1315 dst6 = (struct sockaddr_in6 *)&ro6->ro_dst;
1316 dst6->sin6_family = AF_INET6;
1317 dst6->sin6_len = sizeof(ro6->ro_dst);
1318 dst6->sin6_addr = inp->in6p_faddr;
1329 rtalloc((struct route *)ro6);
1330 rt = ro6->ro_rt;
1331 }
1332 }
1333 return rt;
1334}
1335#endif /* INET6 */
1336

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

1371 {
1372 ip = mtod(m, struct ip *);
1373 th = (struct tcphdr *)(ip + 1);
1374 m->m_pkthdr.len = m->m_len = sizeof(struct tcpiphdr);
1375 bcopy((caddr_t)tp->t_template->tt_ipgen, (caddr_t)ip,
1376 sizeof(struct ip));
1377 bcopy((caddr_t)&tp->t_template->tt_t, (caddr_t)th,
1378 sizeof(struct tcphdr));
1319 rtalloc((struct route *)ro6);
1320 rt = ro6->ro_rt;
1321 }
1322 }
1323 return rt;
1324}
1325#endif /* INET6 */
1326

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

1361 {
1362 ip = mtod(m, struct ip *);
1363 th = (struct tcphdr *)(ip + 1);
1364 m->m_pkthdr.len = m->m_len = sizeof(struct tcpiphdr);
1365 bcopy((caddr_t)tp->t_template->tt_ipgen, (caddr_t)ip,
1366 sizeof(struct ip));
1367 bcopy((caddr_t)&tp->t_template->tt_t, (caddr_t)th,
1368 sizeof(struct tcphdr));
1369 ip->ip_vhl = IP_VHL_BORING;
1379 hdrsiz = ipsec4_hdrsiz(m, IPSEC_DIR_OUTBOUND, inp);
1380 }
1381
1382 m_free(m);
1383 return hdrsiz;
1384}
1385#endif /*IPSEC*/
1386

--- 38 unchanged lines hidden ---
1370 hdrsiz = ipsec4_hdrsiz(m, IPSEC_DIR_OUTBOUND, inp);
1371 }
1372
1373 m_free(m);
1374 return hdrsiz;
1375}
1376#endif /*IPSEC*/
1377

--- 38 unchanged lines hidden ---