Deleted Added
full compact
tcp_subr.c (251296) tcp_subr.c (254889)
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

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

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
30 */
31
32#include <sys/cdefs.h>
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

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

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/netinet/tcp_subr.c 251296 2013-06-03 12:55:13Z andre $");
33__FBSDID("$FreeBSD: head/sys/netinet/tcp_subr.c 254889 2013-08-25 21:54:41Z markj $");
34
35#include "opt_compat.h"
36#include "opt_inet.h"
37#include "opt_inet6.h"
38#include "opt_ipsec.h"
34
35#include "opt_compat.h"
36#include "opt_inet.h"
37#include "opt_inet6.h"
38#include "opt_ipsec.h"
39#include "opt_kdtrace.h"
39#include "opt_tcpdebug.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/callout.h>
44#include <sys/hhook.h>
45#include <sys/kernel.h>
46#include <sys/khelp.h>
47#include <sys/sysctl.h>
48#include <sys/jail.h>
49#include <sys/malloc.h>
50#include <sys/mbuf.h>
51#ifdef INET6
52#include <sys/domain.h>
53#endif
54#include <sys/priv.h>
55#include <sys/proc.h>
40#include "opt_tcpdebug.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/callout.h>
45#include <sys/hhook.h>
46#include <sys/kernel.h>
47#include <sys/khelp.h>
48#include <sys/sysctl.h>
49#include <sys/jail.h>
50#include <sys/malloc.h>
51#include <sys/mbuf.h>
52#ifdef INET6
53#include <sys/domain.h>
54#endif
55#include <sys/priv.h>
56#include <sys/proc.h>
57#include <sys/sdt.h>
56#include <sys/socket.h>
57#include <sys/socketvar.h>
58#include <sys/protosw.h>
59#include <sys/random.h>
60
61#include <vm/uma.h>
62
63#include <net/route.h>
64#include <net/if.h>
65#include <net/vnet.h>
66
67#include <netinet/cc.h>
68#include <netinet/in.h>
58#include <sys/socket.h>
59#include <sys/socketvar.h>
60#include <sys/protosw.h>
61#include <sys/random.h>
62
63#include <vm/uma.h>
64
65#include <net/route.h>
66#include <net/if.h>
67#include <net/vnet.h>
68
69#include <netinet/cc.h>
70#include <netinet/in.h>
71#include <netinet/in_kdtrace.h>
69#include <netinet/in_pcb.h>
70#include <netinet/in_systm.h>
71#include <netinet/in_var.h>
72#include <netinet/ip.h>
73#include <netinet/ip_icmp.h>
74#include <netinet/ip_var.h>
75#ifdef INET6
76#include <netinet/ip6.h>

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

627 xchg(nth->th_dport, nth->th_sport, uint16_t);
628#undef xchg
629 }
630#ifdef INET6
631 if (isipv6) {
632 ip6->ip6_flow = 0;
633 ip6->ip6_vfc = IPV6_VERSION;
634 ip6->ip6_nxt = IPPROTO_TCP;
72#include <netinet/in_pcb.h>
73#include <netinet/in_systm.h>
74#include <netinet/in_var.h>
75#include <netinet/ip.h>
76#include <netinet/ip_icmp.h>
77#include <netinet/ip_var.h>
78#ifdef INET6
79#include <netinet/ip6.h>

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

630 xchg(nth->th_dport, nth->th_sport, uint16_t);
631#undef xchg
632 }
633#ifdef INET6
634 if (isipv6) {
635 ip6->ip6_flow = 0;
636 ip6->ip6_vfc = IPV6_VERSION;
637 ip6->ip6_nxt = IPPROTO_TCP;
635 ip6->ip6_plen = 0; /* Set in ip6_output(). */
636 tlen += sizeof (struct ip6_hdr) + sizeof (struct tcphdr);
638 tlen += sizeof (struct ip6_hdr) + sizeof (struct tcphdr);
639 ip6->ip6_plen = htons(tlen - sizeof(*ip6));
637 }
638#endif
639#if defined(INET) && defined(INET6)
640 else
641#endif
642#ifdef INET
643 {
644 tlen += sizeof (struct tcpiphdr);

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

697 nth->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
698 htons((u_short)(tlen - sizeof(struct ip) + ip->ip_p)));
699 }
700#endif /* INET */
701#ifdef TCPDEBUG
702 if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG))
703 tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0);
704#endif
640 }
641#endif
642#if defined(INET) && defined(INET6)
643 else
644#endif
645#ifdef INET
646 {
647 tlen += sizeof (struct tcpiphdr);

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

700 nth->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
701 htons((u_short)(tlen - sizeof(struct ip) + ip->ip_p)));
702 }
703#endif /* INET */
704#ifdef TCPDEBUG
705 if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG))
706 tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0);
707#endif
708 if (flags & TH_RST)
709 TCP_PROBE5(accept_refused, NULL, NULL, m->m_data, tp, nth);
710
711 TCP_PROBE5(send, NULL, tp, m->m_data, tp, nth);
705#ifdef INET6
706 if (isipv6)
707 (void) ip6_output(m, NULL, NULL, ipflags, NULL, NULL, inp);
708#endif /* INET6 */
709#if defined(INET) && defined(INET6)
710 else
711#endif
712#ifdef INET

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

877tcp_drop(struct tcpcb *tp, int errno)
878{
879 struct socket *so = tp->t_inpcb->inp_socket;
880
881 INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
882 INP_WLOCK_ASSERT(tp->t_inpcb);
883
884 if (TCPS_HAVERCVDSYN(tp->t_state)) {
712#ifdef INET6
713 if (isipv6)
714 (void) ip6_output(m, NULL, NULL, ipflags, NULL, NULL, inp);
715#endif /* INET6 */
716#if defined(INET) && defined(INET6)
717 else
718#endif
719#ifdef INET

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

884tcp_drop(struct tcpcb *tp, int errno)
885{
886 struct socket *so = tp->t_inpcb->inp_socket;
887
888 INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
889 INP_WLOCK_ASSERT(tp->t_inpcb);
890
891 if (TCPS_HAVERCVDSYN(tp->t_state)) {
885 tp->t_state = TCPS_CLOSED;
892 tcp_state_change(tp, TCPS_CLOSED);
886 (void) tcp_output(tp);
887 TCPSTAT_INC(tcps_drops);
888 } else
889 TCPSTAT_INC(tcps_conndrops);
890 if (errno == ETIMEDOUT && tp->t_softerror)
891 errno = tp->t_softerror;
892 so->so_error = errno;
893 return (tcp_close(tp));

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

2371 }
2372 sp = s + strlen(s);
2373 if (th)
2374 sprintf(sp, " tcpflags 0x%b", th->th_flags, PRINT_TH_FLAGS);
2375 if (*(s + size - 1) != '\0')
2376 panic("%s: string too long", __func__);
2377 return (s);
2378}
893 (void) tcp_output(tp);
894 TCPSTAT_INC(tcps_drops);
895 } else
896 TCPSTAT_INC(tcps_conndrops);
897 if (errno == ETIMEDOUT && tp->t_softerror)
898 errno = tp->t_softerror;
899 so->so_error = errno;
900 return (tcp_close(tp));

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

2378 }
2379 sp = s + strlen(s);
2380 if (th)
2381 sprintf(sp, " tcpflags 0x%b", th->th_flags, PRINT_TH_FLAGS);
2382 if (*(s + size - 1) != '\0')
2383 panic("%s: string too long", __func__);
2384 return (s);
2385}
2386
2387/*
2388 * A subroutine which makes it easy to track TCP state changes with DTrace.
2389 * This function shouldn't be called for t_state initializations that don't
2390 * correspond to actual TCP state transitions.
2391 */
2392void
2393tcp_state_change(struct tcpcb *tp, int newstate)
2394{
2395#if defined(KDTRACE_HOOKS)
2396 int pstate = tp->t_state;
2397#endif
2398
2399 tp->t_state = newstate;
2400 TCP_PROBE6(state_change, NULL, tp, NULL, tp, NULL, pstate);
2401}