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 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) && |
493 (ro.ro_rt->rt_expire == 0 || time_uptime < ro.ro_rt->rt_expire)) { |
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 */ |
521 if (ro.ro_rt->rt_mtu) 522 mtu = min(ro.ro_rt->rt_mtu, ifp->if_mtu); |
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 { |
587 counter_u64_add(ro.ro_rt->rt_pksent, 1); |
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} |