Deleted Added
full compact
tcp_input.c (133874) tcp_input.c (133920)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 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

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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_input.c 8.12 (Berkeley) 5/24/95
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 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

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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_input.c 8.12 (Berkeley) 5/24/95
30 * $FreeBSD: head/sys/netinet/tcp_input.c 133874 2004-08-16 18:32:07Z rwatson $
30 * $FreeBSD: head/sys/netinet/tcp_input.c 133920 2004-08-17 22:05:54Z andre $
31 */
32
33#include "opt_ipfw.h" /* for ipfw_fwd */
34#include "opt_inet.h"
35#include "opt_inet6.h"
36#include "opt_ipsec.h"
37#include "opt_mac.h"
38#include "opt_tcpdebug.h"

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

424 register struct tcpcb *tp = 0;
425 register int thflags;
426 struct socket *so = 0;
427 int todrop, acked, ourfinisacked, needoutput = 0;
428 u_long tiwin;
429 struct tcpopt to; /* options in this segment */
430 struct rmxp_tao tao; /* our TAO cache entry */
431 int headlocked = 0;
31 */
32
33#include "opt_ipfw.h" /* for ipfw_fwd */
34#include "opt_inet.h"
35#include "opt_inet6.h"
36#include "opt_ipsec.h"
37#include "opt_mac.h"
38#include "opt_tcpdebug.h"

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

424 register struct tcpcb *tp = 0;
425 register int thflags;
426 struct socket *so = 0;
427 int todrop, acked, ourfinisacked, needoutput = 0;
428 u_long tiwin;
429 struct tcpopt to; /* options in this segment */
430 struct rmxp_tao tao; /* our TAO cache entry */
431 int headlocked = 0;
432 struct sockaddr_in *next_hop = NULL;
432#ifdef IPFIREWALL_FORWARD
433 struct m_tag *fwd_tag;
434#endif
433 int rstreason; /* For badport_bandlim accounting purposes */
434
435 struct ip6_hdr *ip6 = NULL;
436#ifdef INET6
437 int isipv6;
438#else
439 const int isipv6 = 0;
440#endif
441
442#ifdef TCPDEBUG
443 /*
444 * The size of tcp_saveipgen must be the size of the max ip header,
445 * now IPv6.
446 */
447 u_char tcp_saveipgen[40];
448 struct tcphdr tcp_savetcp;
449 short ostate = 0;
450#endif
451
435 int rstreason; /* For badport_bandlim accounting purposes */
436
437 struct ip6_hdr *ip6 = NULL;
438#ifdef INET6
439 int isipv6;
440#else
441 const int isipv6 = 0;
442#endif
443
444#ifdef TCPDEBUG
445 /*
446 * The size of tcp_saveipgen must be the size of the max ip header,
447 * now IPv6.
448 */
449 u_char tcp_saveipgen[40];
450 struct tcphdr tcp_savetcp;
451 short ostate = 0;
452#endif
453
452 /* Grab info from PACKET_TAG_IPFORWARD tag prepended to the chain. */
453 next_hop = m_claim_next(m, PACKET_TAG_IPFORWARD);
454#ifdef INET6
455 isipv6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
456#endif
457 bzero(&tao, sizeof(tao));
458 bzero((char *)&to, sizeof(to));
459
460 tcpstat.tcps_rcvtotal++;
461

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

606 drop_hdrlen = off0 + off;
607
608 /*
609 * Locate pcb for segment.
610 */
611 INP_INFO_WLOCK(&tcbinfo);
612 headlocked = 1;
613findpcb:
454#ifdef INET6
455 isipv6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
456#endif
457 bzero(&tao, sizeof(tao));
458 bzero((char *)&to, sizeof(to));
459
460 tcpstat.tcps_rcvtotal++;
461

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

606 drop_hdrlen = off0 + off;
607
608 /*
609 * Locate pcb for segment.
610 */
611 INP_INFO_WLOCK(&tcbinfo);
612 headlocked = 1;
613findpcb:
614 /* IPFIREWALL_FORWARD section */
615 if (next_hop != NULL && isipv6 == 0) { /* IPv6 support is not yet */
614#ifdef IPFIREWALL_FORWARD
615 /* Grab info from PACKET_TAG_IPFORWARD tag prepended to the chain. */
616 fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL);
617
618 if (fwd_tag != NULL && isipv6 == 0) { /* IPv6 support is not yet */
619 struct sockaddr_in *next_hop;
620
621 next_hop = (struct sockaddr_in *)(fwd_tag+1);
616 /*
617 * Transparently forwarded. Pretend to be the destination.
618 * already got one like this?
619 */
622 /*
623 * Transparently forwarded. Pretend to be the destination.
624 * already got one like this?
625 */
620 inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
626 inp = in_pcblookup_hash(&tcbinfo,
627 ip->ip_src, th->th_sport,
621 ip->ip_dst, th->th_dport,
622 0, m->m_pkthdr.rcvif);
623 if (!inp) {
628 ip->ip_dst, th->th_dport,
629 0, m->m_pkthdr.rcvif);
630 if (!inp) {
624 /* It's new. Try find the ambushing socket. */
631 /* It's new. Try to find the ambushing socket. */
625 inp = in_pcblookup_hash(&tcbinfo,
626 ip->ip_src, th->th_sport,
627 next_hop->sin_addr,
628 next_hop->sin_port ?
629 ntohs(next_hop->sin_port) :
630 th->th_dport,
631 1, m->m_pkthdr.rcvif);
632 }
632 inp = in_pcblookup_hash(&tcbinfo,
633 ip->ip_src, th->th_sport,
634 next_hop->sin_addr,
635 next_hop->sin_port ?
636 ntohs(next_hop->sin_port) :
637 th->th_dport,
638 1, m->m_pkthdr.rcvif);
639 }
640 /* Remove the tag from the packet. We don't need it anymore. */
641 m_tag_delete(m, fwd_tag);
633 } else {
642 } else {
643#endif /* IPFIREWALL_FORWARD */
634 if (isipv6) {
635#ifdef INET6
636 inp = in6_pcblookup_hash(&tcbinfo,
637 &ip6->ip6_src, th->th_sport,
638 &ip6->ip6_dst, th->th_dport,
639 1, m->m_pkthdr.rcvif);
640#endif
641 } else
642 inp = in_pcblookup_hash(&tcbinfo,
643 ip->ip_src, th->th_sport,
644 ip->ip_dst, th->th_dport,
645 1, m->m_pkthdr.rcvif);
644 if (isipv6) {
645#ifdef INET6
646 inp = in6_pcblookup_hash(&tcbinfo,
647 &ip6->ip6_src, th->th_sport,
648 &ip6->ip6_dst, th->th_dport,
649 1, m->m_pkthdr.rcvif);
650#endif
651 } else
652 inp = in_pcblookup_hash(&tcbinfo,
653 ip->ip_src, th->th_sport,
654 ip->ip_dst, th->th_dport,
655 1, m->m_pkthdr.rcvif);
656#ifdef IPFIREWALL_FORWARD
646 }
657 }
658#endif /* IPFIREWALL_FORWARD */
647
648#if defined(IPSEC) || defined(FAST_IPSEC)
649#ifdef INET6
650 if (isipv6) {
651 if (inp != NULL && ipsec6_in_reject(m, inp)) {
652#ifdef IPSEC
653 ipsec6stat.in_polvio++;
654#endif

--- 2695 unchanged lines hidden ---
659
660#if defined(IPSEC) || defined(FAST_IPSEC)
661#ifdef INET6
662 if (isipv6) {
663 if (inp != NULL && ipsec6_in_reject(m, inp)) {
664#ifdef IPSEC
665 ipsec6stat.in_polvio++;
666#endif

--- 2695 unchanged lines hidden ---