Deleted Added
full compact
ip_fastfwd.c (144301) ip_fastfwd.c (145863)
1/*-
2 * Copyright (c) 2003 Andre Oppermann, Internet Business Solutions AG
3 * 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

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

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
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 *
1/*-
2 * Copyright (c) 2003 Andre Oppermann, Internet Business Solutions AG
3 * 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

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

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
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 * $FreeBSD: head/sys/netinet/ip_fastfwd.c 144301 2005-03-29 13:43:09Z glebius $
29 * $FreeBSD: head/sys/netinet/ip_fastfwd.c 145863 2005-05-04 13:09:19Z andre $
30 */
31
32/*
33 * ip_fastforward gets its speed from processing the forwarded packet to
34 * completion (if_output on the other side) without any queues or netisr's.
35 * The receiving interface DMAs the packet into memory, the upper half of
36 * driver calls ip_fastforward, we do our routing table lookup and directly
37 * send it off to the outgoing interface which DMAs the packet to the

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

132 (rt->rt_ifp->if_flags & IFF_RUNNING)) {
133 if (rt->rt_flags & RTF_GATEWAY)
134 dst = (struct sockaddr_in *)rt->rt_gateway;
135 } else {
136 ipstat.ips_noroute++;
137 ipstat.ips_cantforward++;
138 if (rt)
139 RTFREE(rt);
30 */
31
32/*
33 * ip_fastforward gets its speed from processing the forwarded packet to
34 * completion (if_output on the other side) without any queues or netisr's.
35 * The receiving interface DMAs the packet into memory, the upper half of
36 * driver calls ip_fastforward, we do our routing table lookup and directly
37 * send it off to the outgoing interface which DMAs the packet to the

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

132 (rt->rt_ifp->if_flags & IFF_RUNNING)) {
133 if (rt->rt_flags & RTF_GATEWAY)
134 dst = (struct sockaddr_in *)rt->rt_gateway;
135 } else {
136 ipstat.ips_noroute++;
137 ipstat.ips_cantforward++;
138 if (rt)
139 RTFREE(rt);
140 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, NULL);
140 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
141 return NULL;
142 }
143 return dst;
144}
145
146/*
147 * Try to forward a packet based on the destination address.
148 * This is a fast path optimized for the plain forwarding case.

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

292 /*
293 * Only IP packets without options
294 */
295 if (ip->ip_hl != (sizeof(struct ip) >> 2)) {
296 if (ip_doopts == 1)
297 return 0;
298 else if (ip_doopts == 2) {
299 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_FILTER_PROHIB,
141 return NULL;
142 }
143 return dst;
144}
145
146/*
147 * Try to forward a packet based on the destination address.
148 * This is a fast path optimized for the plain forwarding case.

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

292 /*
293 * Only IP packets without options
294 */
295 if (ip->ip_hl != (sizeof(struct ip) >> 2)) {
296 if (ip_doopts == 1)
297 return 0;
298 else if (ip_doopts == 2) {
299 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_FILTER_PROHIB,
300 0, NULL);
300 0, 0);
301 return 1;
302 }
303 /* else ignore IP options and continue */
304 }
305
306 /*
307 * Only unicast IP, not from loopback, no L2 or IP broadcast,
308 * no multicast, no INADDR_ANY

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

402
403 /*
404 * Check TTL
405 */
406#ifdef IPSTEALTH
407 if (!ipstealth) {
408#endif
409 if (ip->ip_ttl <= IPTTLDEC) {
301 return 1;
302 }
303 /* else ignore IP options and continue */
304 }
305
306 /*
307 * Only unicast IP, not from loopback, no L2 or IP broadcast,
308 * no multicast, no INADDR_ANY

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

402
403 /*
404 * Check TTL
405 */
406#ifdef IPSTEALTH
407 if (!ipstealth) {
408#endif
409 if (ip->ip_ttl <= IPTTLDEC) {
410 icmp_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, NULL);
410 icmp_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, 0);
411 return 1;
412 }
413
414 /*
415 * Decrement the TTL and incrementally change the IP header checksum.
416 * Don't bother doing this with hw checksum offloading, it's faster
417 * doing it right here.
418 */

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

507 * Step 6: send off the packet
508 */
509
510 /*
511 * Check if route is dampned (when ARP is unable to resolve)
512 */
513 if ((ro.ro_rt->rt_flags & RTF_REJECT) &&
514 ro.ro_rt->rt_rmx.rmx_expire >= time_second) {
411 return 1;
412 }
413
414 /*
415 * Decrement the TTL and incrementally change the IP header checksum.
416 * Don't bother doing this with hw checksum offloading, it's faster
417 * doing it right here.
418 */

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

507 * Step 6: send off the packet
508 */
509
510 /*
511 * Check if route is dampned (when ARP is unable to resolve)
512 */
513 if ((ro.ro_rt->rt_flags & RTF_REJECT) &&
514 ro.ro_rt->rt_rmx.rmx_expire >= time_second) {
515 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, NULL);
515 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
516 goto consumed;
517 }
518
519#ifndef ALTQ
520 /*
521 * Check if there is enough space in the interface queue
522 */
523 if ((ifp->if_snd.ifq_len + ip->ip_len / ifp->if_mtu + 1) >=
524 ifp->if_snd.ifq_maxlen) {
525 ipstat.ips_odropped++;
526 /* would send source quench here but that is depreciated */
527 goto drop;
528 }
529#endif
530
531 /*
532 * Check if media link state of interface is not down
533 */
534 if (ifp->if_link_state == LINK_STATE_DOWN) {
516 goto consumed;
517 }
518
519#ifndef ALTQ
520 /*
521 * Check if there is enough space in the interface queue
522 */
523 if ((ifp->if_snd.ifq_len + ip->ip_len / ifp->if_mtu + 1) >=
524 ifp->if_snd.ifq_maxlen) {
525 ipstat.ips_odropped++;
526 /* would send source quench here but that is depreciated */
527 goto drop;
528 }
529#endif
530
531 /*
532 * Check if media link state of interface is not down
533 */
534 if (ifp->if_link_state == LINK_STATE_DOWN) {
535 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, NULL);
535 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
536 goto consumed;
537 }
538
539 /*
540 * Check if packet fits MTU or if hardware will fragement for us
541 */
542 if (ro.ro_rt->rt_rmx.rmx_mtu)
543 mtu = min(ro.ro_rt->rt_rmx.rmx_mtu, ifp->if_mtu);

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

558 (struct sockaddr *)dst, ro.ro_rt);
559 } else {
560 /*
561 * Handle EMSGSIZE with icmp reply needfrag for TCP MTU discovery
562 */
563 if (ip->ip_off & IP_DF) {
564 ipstat.ips_cantfrag++;
565 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG,
536 goto consumed;
537 }
538
539 /*
540 * Check if packet fits MTU or if hardware will fragement for us
541 */
542 if (ro.ro_rt->rt_rmx.rmx_mtu)
543 mtu = min(ro.ro_rt->rt_rmx.rmx_mtu, ifp->if_mtu);

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

558 (struct sockaddr *)dst, ro.ro_rt);
559 } else {
560 /*
561 * Handle EMSGSIZE with icmp reply needfrag for TCP MTU discovery
562 */
563 if (ip->ip_off & IP_DF) {
564 ipstat.ips_cantfrag++;
565 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG,
566 0, ifp);
566 0, mtu);
567 goto consumed;
568 } else {
569 /*
570 * We have to fragement the packet
571 */
572 m->m_pkthdr.csum_flags |= CSUM_IP;
573 /*
574 * ip_fragment expects ip_len and ip_off in host byte

--- 48 unchanged lines hidden ---
567 goto consumed;
568 } else {
569 /*
570 * We have to fragement the packet
571 */
572 m->m_pkthdr.csum_flags |= CSUM_IP;
573 /*
574 * ip_fragment expects ip_len and ip_off in host byte

--- 48 unchanged lines hidden ---