Deleted Added
full compact
ip_output.c (108533) ip_output.c (109623)
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 108533 2003-01-01 18:49:04Z schweikh $
34 * $FreeBSD: head/sys/netinet/ip_output.c 109623 2003-01-21 08:56:16Z alfred $
35 */
36
37#include "opt_ipfw.h"
38#include "opt_ipdn.h"
39#include "opt_ipdivert.h"
40#include "opt_ipfilter.h"
41#include "opt_ipsec.h"
42#include "opt_mac.h"

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

788 goto done;
789 }
790#ifdef IPDIVERT
791 if (off != 0 && (off & IP_FW_PORT_DYNT_FLAG) == 0) {
792 struct mbuf *clone = NULL;
793
794 /* Clone packet if we're doing a 'tee' */
795 if ((off & IP_FW_PORT_TEE_FLAG) != 0)
35 */
36
37#include "opt_ipfw.h"
38#include "opt_ipdn.h"
39#include "opt_ipdivert.h"
40#include "opt_ipfilter.h"
41#include "opt_ipsec.h"
42#include "opt_mac.h"

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

788 goto done;
789 }
790#ifdef IPDIVERT
791 if (off != 0 && (off & IP_FW_PORT_DYNT_FLAG) == 0) {
792 struct mbuf *clone = NULL;
793
794 /* Clone packet if we're doing a 'tee' */
795 if ((off & IP_FW_PORT_TEE_FLAG) != 0)
796 clone = m_dup(m, M_DONTWAIT);
796 clone = m_dup(m, M_NOWAIT);
797
798 /*
799 * XXX
800 * delayed checksums are not currently compatible
801 * with divert sockets.
802 */
803 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
804 in_delayed_cksum(m);

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

1094
1095 /*
1096 * Loop through length of segment after first fragment,
1097 * make new header and copy data of each part and link onto chain.
1098 */
1099 m0 = m;
1100 mhlen = sizeof (struct ip);
1101 for (; off < (u_short)ip->ip_len; off += len) {
797
798 /*
799 * XXX
800 * delayed checksums are not currently compatible
801 * with divert sockets.
802 */
803 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
804 in_delayed_cksum(m);

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

1094
1095 /*
1096 * Loop through length of segment after first fragment,
1097 * make new header and copy data of each part and link onto chain.
1098 */
1099 m0 = m;
1100 mhlen = sizeof (struct ip);
1101 for (; off < (u_short)ip->ip_len; off += len) {
1102 MGETHDR(m, M_DONTWAIT, MT_HEADER);
1102 MGETHDR(m, M_NOWAIT, MT_HEADER);
1103 if (m == 0) {
1104 error = ENOBUFS;
1105 ipstat.ips_odropped++;
1106 goto sendorfree;
1107 }
1108 m->m_flags |= (m0->m_flags & M_MCAST) | M_FRAG;
1109 m->m_data += max_linkhdr;
1110 mhip = mtod(m, struct ip *);

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

1260 optlen = opt->m_len - sizeof(p->ipopt_dst);
1261 if (optlen + (u_short)ip->ip_len > IP_MAXPACKET) {
1262 *phlen = 0;
1263 return (m); /* XXX should fail */
1264 }
1265 if (p->ipopt_dst.s_addr)
1266 ip->ip_dst = p->ipopt_dst;
1267 if (m->m_flags & M_EXT || m->m_data - optlen < m->m_pktdat) {
1103 if (m == 0) {
1104 error = ENOBUFS;
1105 ipstat.ips_odropped++;
1106 goto sendorfree;
1107 }
1108 m->m_flags |= (m0->m_flags & M_MCAST) | M_FRAG;
1109 m->m_data += max_linkhdr;
1110 mhip = mtod(m, struct ip *);

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

1260 optlen = opt->m_len - sizeof(p->ipopt_dst);
1261 if (optlen + (u_short)ip->ip_len > IP_MAXPACKET) {
1262 *phlen = 0;
1263 return (m); /* XXX should fail */
1264 }
1265 if (p->ipopt_dst.s_addr)
1266 ip->ip_dst = p->ipopt_dst;
1267 if (m->m_flags & M_EXT || m->m_data - optlen < m->m_pktdat) {
1268 MGETHDR(n, M_DONTWAIT, MT_HEADER);
1268 MGETHDR(n, M_NOWAIT, MT_HEADER);
1269 if (n == 0) {
1270 *phlen = 0;
1271 return (m);
1272 }
1273 n->m_pkthdr.rcvif = (struct ifnet *)0;
1274#ifdef MAC
1275 mac_create_mbuf_from_mbuf(m, n);
1276#endif

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

1365 case IP_RETOPTS:
1366#endif
1367 {
1368 struct mbuf *m;
1369 if (sopt->sopt_valsize > MLEN) {
1370 error = EMSGSIZE;
1371 break;
1372 }
1269 if (n == 0) {
1270 *phlen = 0;
1271 return (m);
1272 }
1273 n->m_pkthdr.rcvif = (struct ifnet *)0;
1274#ifdef MAC
1275 mac_create_mbuf_from_mbuf(m, n);
1276#endif

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

1365 case IP_RETOPTS:
1366#endif
1367 {
1368 struct mbuf *m;
1369 if (sopt->sopt_valsize > MLEN) {
1370 error = EMSGSIZE;
1371 break;
1372 }
1373 MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_HEADER);
1373 MGET(m, sopt->sopt_td ? 0 : M_NOWAIT, MT_HEADER);
1374 if (m == 0) {
1375 error = ENOBUFS;
1376 break;
1377 }
1378 m->m_len = sopt->sopt_valsize;
1379 error = sooptcopyin(sopt, mtod(m, char *), m->m_len,
1380 m->m_len);
1381

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

1759 int s;
1760
1761 if (imo == NULL) {
1762 /*
1763 * No multicast option buffer attached to the pcb;
1764 * allocate one and initialize to default values.
1765 */
1766 imo = (struct ip_moptions*)malloc(sizeof(*imo), M_IPMOPTS,
1374 if (m == 0) {
1375 error = ENOBUFS;
1376 break;
1377 }
1378 m->m_len = sopt->sopt_valsize;
1379 error = sooptcopyin(sopt, mtod(m, char *), m->m_len,
1380 m->m_len);
1381

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

1759 int s;
1760
1761 if (imo == NULL) {
1762 /*
1763 * No multicast option buffer attached to the pcb;
1764 * allocate one and initialize to default values.
1765 */
1766 imo = (struct ip_moptions*)malloc(sizeof(*imo), M_IPMOPTS,
1767 M_WAITOK);
1767 0);
1768
1769 if (imo == NULL)
1770 return (ENOBUFS);
1771 *imop = imo;
1772 imo->imo_multicast_ifp = NULL;
1773 imo->imo_multicast_addr.s_addr = INADDR_ANY;
1774 imo->imo_multicast_vif = -1;
1775 imo->imo_multicast_ttl = IP_DEFAULT_MULTICAST_TTL;

--- 409 unchanged lines hidden ---
1768
1769 if (imo == NULL)
1770 return (ENOBUFS);
1771 *imop = imo;
1772 imo->imo_multicast_ifp = NULL;
1773 imo->imo_multicast_addr.s_addr = INADDR_ANY;
1774 imo->imo_multicast_vif = -1;
1775 imo->imo_multicast_ttl = IP_DEFAULT_MULTICAST_TTL;

--- 409 unchanged lines hidden ---