Deleted Added
full compact
ip_fastfwd.c (258541) ip_fastfwd.c (262763)
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

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

69 */
70
71/*
72 * Many thanks to Matt Thomas of NetBSD for basic structure of ip_flow.c which
73 * is being followed here.
74 */
75
76#include <sys/cdefs.h>
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

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

69 */
70
71/*
72 * Many thanks to Matt Thomas of NetBSD for basic structure of ip_flow.c which
73 * is being followed here.
74 */
75
76#include <sys/cdefs.h>
77__FBSDID("$FreeBSD: head/sys/netinet/ip_fastfwd.c 258541 2013-11-25 07:38:45Z attilio $");
77__FBSDID("$FreeBSD: head/sys/netinet/ip_fastfwd.c 262763 2014-03-05 01:17:47Z glebius $");
78
79#include "opt_ipfw.h"
80#include "opt_ipstealth.h"
81
82#include <sys/param.h>
83#include <sys/systm.h>
84#include <sys/kernel.h>
85#include <sys/malloc.h>

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

485 */
486 ip_len = ntohs(ip->ip_len);
487 ip_off = ntohs(ip->ip_off);
488
489 /*
490 * Check if route is dampned (when ARP is unable to resolve)
491 */
492 if ((ro.ro_rt->rt_flags & RTF_REJECT) &&
78
79#include "opt_ipfw.h"
80#include "opt_ipstealth.h"
81
82#include <sys/param.h>
83#include <sys/systm.h>
84#include <sys/kernel.h>
85#include <sys/malloc.h>

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

485 */
486 ip_len = ntohs(ip->ip_len);
487 ip_off = ntohs(ip->ip_off);
488
489 /*
490 * Check if route is dampned (when ARP is unable to resolve)
491 */
492 if ((ro.ro_rt->rt_flags & RTF_REJECT) &&
493 (ro.ro_rt->rt_rmx.rmx_expire == 0 ||
494 time_uptime < ro.ro_rt->rt_rmx.rmx_expire)) {
493 (ro.ro_rt->rt_expire == 0 || time_uptime < ro.ro_rt->rt_expire)) {
495 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
496 goto consumed;
497 }
498
499#ifndef ALTQ
500 /*
501 * Check if there is enough space in the interface queue
502 */

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

514 if (ifp->if_link_state == LINK_STATE_DOWN) {
515 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
516 goto consumed;
517 }
518
519 /*
520 * Check if packet fits MTU or if hardware will fragment for us
521 */
494 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
495 goto consumed;
496 }
497
498#ifndef ALTQ
499 /*
500 * Check if there is enough space in the interface queue
501 */

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

513 if (ifp->if_link_state == LINK_STATE_DOWN) {
514 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
515 goto consumed;
516 }
517
518 /*
519 * Check if packet fits MTU or if hardware will fragment for us
520 */
522 if (ro.ro_rt->rt_rmx.rmx_mtu)
523 mtu = min(ro.ro_rt->rt_rmx.rmx_mtu, ifp->if_mtu);
521 if (ro.ro_rt->rt_mtu)
522 mtu = min(ro.ro_rt->rt_mtu, ifp->if_mtu);
524 else
525 mtu = ifp->if_mtu;
526
527 if (ip_len <= mtu ||
528 (ifp->if_hwassist & CSUM_FRAGMENT && (ip_off & IP_DF) == 0)) {
529 /*
530 * Avoid confusing lower layers.
531 */

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

580 } else
581 IPSTAT_INC(ips_fragmented);
582 }
583 }
584
585 if (error != 0)
586 IPSTAT_INC(ips_odropped);
587 else {
523 else
524 mtu = ifp->if_mtu;
525
526 if (ip_len <= mtu ||
527 (ifp->if_hwassist & CSUM_FRAGMENT && (ip_off & IP_DF) == 0)) {
528 /*
529 * Avoid confusing lower layers.
530 */

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

579 } else
580 IPSTAT_INC(ips_fragmented);
581 }
582 }
583
584 if (error != 0)
585 IPSTAT_INC(ips_odropped);
586 else {
588 ro.ro_rt->rt_rmx.rmx_pksent++;
587 counter_u64_add(ro.ro_rt->rt_pksent, 1);
589 IPSTAT_INC(ips_forward);
590 IPSTAT_INC(ips_fastforward);
591 }
592consumed:
593 RTFREE(ro.ro_rt);
594 return NULL;
595drop:
596 if (m)
597 m_freem(m);
598 if (ro.ro_rt)
599 RTFREE(ro.ro_rt);
600 return NULL;
601}
588 IPSTAT_INC(ips_forward);
589 IPSTAT_INC(ips_fastforward);
590 }
591consumed:
592 RTFREE(ro.ro_rt);
593 return NULL;
594drop:
595 if (m)
596 m_freem(m);
597 if (ro.ro_rt)
598 RTFREE(ro.ro_rt);
599 return NULL;
600}