Deleted Added
full compact
ip_output.c (98666) ip_output.c (98849)
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 98666 2002-06-23 09:15:43Z luigi $
34 * $FreeBSD: head/sys/netinet/ip_output.c 98849 2002-06-26 03:37:47Z ken $
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"

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

912 * fragmented packets, then do it here.
913 */
914 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA &&
915 (ifp->if_hwassist & CSUM_IP_FRAGS) == 0) {
916 in_delayed_cksum(m);
917 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
918 }
919
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"

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

912 * fragmented packets, then do it here.
913 */
914 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA &&
915 (ifp->if_hwassist & CSUM_IP_FRAGS) == 0) {
916 in_delayed_cksum(m);
917 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
918 }
919
920 if (len > PAGE_SIZE) {
921 /*
922 * Fragement large datagrams such that each segment
923 * contains a multiple of PAGE_SIZE amount of data,
924 * plus headers. This enables a receiver to perform
925 * page-flipping zero-copy optimizations.
926 */
927
928 int newlen;
929 struct mbuf *mtmp;
930
931 for (mtmp = m, off = 0;
932 mtmp && ((off + mtmp->m_len) <= ifp->if_mtu);
933 mtmp = mtmp->m_next) {
934 off += mtmp->m_len;
935 }
936 /*
937 * firstlen (off - hlen) must be aligned on an
938 * 8-byte boundary
939 */
940 if (off < hlen)
941 goto smart_frag_failure;
942 off = ((off - hlen) & ~7) + hlen;
943 newlen = (~PAGE_MASK) & ifp->if_mtu;
944 if ((newlen + sizeof (struct ip)) > ifp->if_mtu) {
945 /* we failed, go back the default */
946smart_frag_failure:
947 newlen = len;
948 off = hlen + len;
949 }
950
951/* printf("ipfrag: len = %d, hlen = %d, mhlen = %d, newlen = %d, off = %d\n",
952 len, hlen, sizeof (struct ip), newlen, off);*/
953
954 len = newlen;
955
956 } else {
957 off = hlen + len;
958 }
959
960
961
920 {
962 {
921 int mhlen, firstlen = len;
963 int mhlen, firstlen = off - hlen;
922 struct mbuf **mnext = &m->m_nextpkt;
923 int nfrags = 1;
924
925 /*
926 * Loop through length of segment after first fragment,
927 * make new header and copy data of each part and link onto chain.
928 */
929 m0 = m;
930 mhlen = sizeof (struct ip);
964 struct mbuf **mnext = &m->m_nextpkt;
965 int nfrags = 1;
966
967 /*
968 * Loop through length of segment after first fragment,
969 * make new header and copy data of each part and link onto chain.
970 */
971 m0 = m;
972 mhlen = sizeof (struct ip);
931 for (off = hlen + len; off < (u_short)ip->ip_len; off += len) {
973 for (; off < (u_short)ip->ip_len; off += len) {
932 MGETHDR(m, M_DONTWAIT, MT_HEADER);
933 if (m == 0) {
934 error = ENOBUFS;
935 ipstat.ips_odropped++;
936 goto sendorfree;
937 }
938 m->m_flags |= (m0->m_flags & M_MCAST) | M_FRAG;
939 m->m_data += max_linkhdr;

--- 1069 unchanged lines hidden ---
974 MGETHDR(m, M_DONTWAIT, MT_HEADER);
975 if (m == 0) {
976 error = ENOBUFS;
977 ipstat.ips_odropped++;
978 goto sendorfree;
979 }
980 m->m_flags |= (m0->m_flags & M_MCAST) | M_FRAG;
981 m->m_data += max_linkhdr;

--- 1069 unchanged lines hidden ---