Deleted Added
full compact
ip_output.c (90698) ip_output.c (90868)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 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 * @(#)ip_output.c 8.3 (Berkeley) 1/21/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 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 * @(#)ip_output.c 8.3 (Berkeley) 1/21/94
34 * $FreeBSD: head/sys/netinet/ip_output.c 90698 2002-02-15 12:19:03Z ru $
34 * $FreeBSD: head/sys/netinet/ip_output.c 90868 2002-02-18 20:35:27Z mike $
35 */
36
37#define _IP_VHL
38
39#include "opt_ipfw.h"
40#include "opt_ipdn.h"
41#include "opt_ipdivert.h"
42#include "opt_ipfilter.h"

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

508 * XXX
509 * delayed checksums are not currently compatible with IPsec
510 */
511 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
512 in_delayed_cksum(m);
513 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
514 }
515
35 */
36
37#define _IP_VHL
38
39#include "opt_ipfw.h"
40#include "opt_ipdn.h"
41#include "opt_ipdivert.h"
42#include "opt_ipfilter.h"

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

508 * XXX
509 * delayed checksums are not currently compatible with IPsec
510 */
511 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
512 in_delayed_cksum(m);
513 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
514 }
515
516 HTONS(ip->ip_len);
517 HTONS(ip->ip_off);
516 ip->ip_len = htons(ip->ip_len);
517 ip->ip_off = htons(ip->ip_off);
518
519 error = ipsec4_output(&state, sp, flags);
520
521 m = state.m;
522 if (flags & IP_ROUTETOIF) {
523 /*
524 * if we have tunnel mode SA, we may need to ignore
525 * IP_ROUTETOIF.

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

568 goto bad;
569 }
570 } else {
571 ia = ifatoia(ro->ro_rt->rt_ifa);
572 ifp = ro->ro_rt->rt_ifp;
573 }
574
575 /* make it flipped, again. */
518
519 error = ipsec4_output(&state, sp, flags);
520
521 m = state.m;
522 if (flags & IP_ROUTETOIF) {
523 /*
524 * if we have tunnel mode SA, we may need to ignore
525 * IP_ROUTETOIF.

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

568 goto bad;
569 }
570 } else {
571 ia = ifatoia(ro->ro_rt->rt_ifa);
572 ifp = ro->ro_rt->rt_ifp;
573 }
574
575 /* make it flipped, again. */
576 NTOHS(ip->ip_len);
577 NTOHS(ip->ip_off);
576 ip->ip_len = ntohs(ip->ip_len);
577 ip->ip_off = ntohs(ip->ip_off);
578skip_ipsec:
579#endif /*IPSEC*/
580
581 /*
582 * IpHack's section.
583 * - Xlate: translate packet's addr/port (NAT).
584 * - Firewall: deny/allow/etc.
585 * - Wrap: fake packet's addr/port <unimpl.>

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

676 * with divert sockets.
677 */
678 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
679 in_delayed_cksum(m);
680 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
681 }
682
683 /* Restore packet header fields to original values */
578skip_ipsec:
579#endif /*IPSEC*/
580
581 /*
582 * IpHack's section.
583 * - Xlate: translate packet's addr/port (NAT).
584 * - Firewall: deny/allow/etc.
585 * - Wrap: fake packet's addr/port <unimpl.>

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

676 * with divert sockets.
677 */
678 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
679 in_delayed_cksum(m);
680 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
681 }
682
683 /* Restore packet header fields to original values */
684 HTONS(ip->ip_len);
685 HTONS(ip->ip_off);
684 ip->ip_len = htons(ip->ip_len);
685 ip->ip_off = htons(ip->ip_off);
686
687 /* Deliver packet to divert input routine */
688 ip_divert_cookie = divert_cookie;
689 divert_packet(m, 0, off & 0xffff);
690
691 /* If 'tee', continue with original packet */
692 if (clone != NULL) {
693 m = clone;

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

750 m->m_pkthdr.rcvif = ifunit("lo0");
751 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
752 m->m_pkthdr.csum_flags |=
753 CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
754 m0->m_pkthdr.csum_data = 0xffff;
755 }
756 m->m_pkthdr.csum_flags |=
757 CSUM_IP_CHECKED | CSUM_IP_VALID;
686
687 /* Deliver packet to divert input routine */
688 ip_divert_cookie = divert_cookie;
689 divert_packet(m, 0, off & 0xffff);
690
691 /* If 'tee', continue with original packet */
692 if (clone != NULL) {
693 m = clone;

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

750 m->m_pkthdr.rcvif = ifunit("lo0");
751 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
752 m->m_pkthdr.csum_flags |=
753 CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
754 m0->m_pkthdr.csum_data = 0xffff;
755 }
756 m->m_pkthdr.csum_flags |=
757 CSUM_IP_CHECKED | CSUM_IP_VALID;
758 HTONS(ip->ip_len);
759 HTONS(ip->ip_off);
758 ip->ip_len = htons(ip->ip_len);
759 ip->ip_off = htons(ip->ip_off);
760 ip_input(m);
761 goto done;
762 }
763 /* Some of the logic for this was
764 * nicked from above.
765 *
766 * This rewrites the cached route in a local PCB.
767 * Is this what we want to do?

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

832 m->m_pkthdr.csum_flags &= ifp->if_hwassist;
833
834 /*
835 * If small enough for interface, or the interface will take
836 * care of the fragmentation for us, can just send directly.
837 */
838 if ((u_short)ip->ip_len <= ifp->if_mtu ||
839 ifp->if_hwassist & CSUM_FRAGMENT) {
760 ip_input(m);
761 goto done;
762 }
763 /* Some of the logic for this was
764 * nicked from above.
765 *
766 * This rewrites the cached route in a local PCB.
767 * Is this what we want to do?

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

832 m->m_pkthdr.csum_flags &= ifp->if_hwassist;
833
834 /*
835 * If small enough for interface, or the interface will take
836 * care of the fragmentation for us, can just send directly.
837 */
838 if ((u_short)ip->ip_len <= ifp->if_mtu ||
839 ifp->if_hwassist & CSUM_FRAGMENT) {
840 HTONS(ip->ip_len);
841 HTONS(ip->ip_off);
840 ip->ip_len = htons(ip->ip_len);
841 ip->ip_off = htons(ip->ip_off);
842 ip->ip_sum = 0;
843 if (sw_csum & CSUM_DELAY_IP) {
844 if (ip->ip_vhl == IP_VHL_BORING) {
845 ip->ip_sum = in_cksum_hdr(ip);
846 } else {
847 ip->ip_sum = in_cksum(m, hlen);
848 }
849 }

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

938 (void) m_free(m);
939 error = ENOBUFS; /* ??? */
940 ipstat.ips_odropped++;
941 goto sendorfree;
942 }
943 m->m_pkthdr.len = mhlen + len;
944 m->m_pkthdr.rcvif = (struct ifnet *)0;
945 m->m_pkthdr.csum_flags = m0->m_pkthdr.csum_flags;
842 ip->ip_sum = 0;
843 if (sw_csum & CSUM_DELAY_IP) {
844 if (ip->ip_vhl == IP_VHL_BORING) {
845 ip->ip_sum = in_cksum_hdr(ip);
846 } else {
847 ip->ip_sum = in_cksum(m, hlen);
848 }
849 }

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

938 (void) m_free(m);
939 error = ENOBUFS; /* ??? */
940 ipstat.ips_odropped++;
941 goto sendorfree;
942 }
943 m->m_pkthdr.len = mhlen + len;
944 m->m_pkthdr.rcvif = (struct ifnet *)0;
945 m->m_pkthdr.csum_flags = m0->m_pkthdr.csum_flags;
946 HTONS(mhip->ip_off);
946 mhip->ip_off = htons(mhip->ip_off);
947 mhip->ip_sum = 0;
948 if (sw_csum & CSUM_DELAY_IP) {
949 if (mhip->ip_vhl == IP_VHL_BORING) {
950 mhip->ip_sum = in_cksum_hdr(mhip);
951 } else {
952 mhip->ip_sum = in_cksum(m, mhlen);
953 }
954 }

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

967 * Update first fragment by trimming what's been copied out
968 * and updating header, then send each fragment (in order).
969 */
970 m = m0;
971 m_adj(m, hlen + firstlen - (u_short)ip->ip_len);
972 m->m_pkthdr.len = hlen + firstlen;
973 ip->ip_len = htons((u_short)m->m_pkthdr.len);
974 ip->ip_off |= IP_MF;
947 mhip->ip_sum = 0;
948 if (sw_csum & CSUM_DELAY_IP) {
949 if (mhip->ip_vhl == IP_VHL_BORING) {
950 mhip->ip_sum = in_cksum_hdr(mhip);
951 } else {
952 mhip->ip_sum = in_cksum(m, mhlen);
953 }
954 }

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

967 * Update first fragment by trimming what's been copied out
968 * and updating header, then send each fragment (in order).
969 */
970 m = m0;
971 m_adj(m, hlen + firstlen - (u_short)ip->ip_len);
972 m->m_pkthdr.len = hlen + firstlen;
973 ip->ip_len = htons((u_short)m->m_pkthdr.len);
974 ip->ip_off |= IP_MF;
975 HTONS(ip->ip_off);
975 ip->ip_off = htons(ip->ip_off);
976 ip->ip_sum = 0;
977 if (sw_csum & CSUM_DELAY_IP) {
978 if (ip->ip_vhl == IP_VHL_BORING) {
979 ip->ip_sum = in_cksum_hdr(ip);
980 } else {
981 ip->ip_sum = in_cksum(m, hlen);
982 }
983 }

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

1945 if (copym != NULL && (copym->m_flags & M_EXT || copym->m_len < hlen))
1946 copym = m_pullup(copym, hlen);
1947 if (copym != NULL) {
1948 /*
1949 * We don't bother to fragment if the IP length is greater
1950 * than the interface's MTU. Can this possibly matter?
1951 */
1952 ip = mtod(copym, struct ip *);
976 ip->ip_sum = 0;
977 if (sw_csum & CSUM_DELAY_IP) {
978 if (ip->ip_vhl == IP_VHL_BORING) {
979 ip->ip_sum = in_cksum_hdr(ip);
980 } else {
981 ip->ip_sum = in_cksum(m, hlen);
982 }
983 }

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

1945 if (copym != NULL && (copym->m_flags & M_EXT || copym->m_len < hlen))
1946 copym = m_pullup(copym, hlen);
1947 if (copym != NULL) {
1948 /*
1949 * We don't bother to fragment if the IP length is greater
1950 * than the interface's MTU. Can this possibly matter?
1951 */
1952 ip = mtod(copym, struct ip *);
1953 HTONS(ip->ip_len);
1954 HTONS(ip->ip_off);
1953 ip->ip_len = htons(ip->ip_len);
1954 ip->ip_off = htons(ip->ip_off);
1955 ip->ip_sum = 0;
1956 if (ip->ip_vhl == IP_VHL_BORING) {
1957 ip->ip_sum = in_cksum_hdr(ip);
1958 } else {
1959 ip->ip_sum = in_cksum(copym, hlen);
1960 }
1961 /*
1962 * NB:

--- 31 unchanged lines hidden ---
1955 ip->ip_sum = 0;
1956 if (ip->ip_vhl == IP_VHL_BORING) {
1957 ip->ip_sum = in_cksum_hdr(ip);
1958 } else {
1959 ip->ip_sum = in_cksum(copym, hlen);
1960 }
1961 /*
1962 * NB:

--- 31 unchanged lines hidden ---