FreeBSD kernel IPv4 code
|
#include <sys/cdefs.h>
#include "opt_bootp.h"
#include "opt_ipstealth.h"
#include "opt_ipsec.h"
#include "opt_route.h"
#include "opt_rss.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/hhook.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/domain.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/rmlock.h>
#include <sys/rwlock.h>
#include <sys/sdt.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_types.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/pfil.h>
#include <net/route.h>
#include <net/route/nhop.h>
#include <net/netisr.h>
#include <net/rss_config.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_kdtrace.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
#include <netinet/in_fib.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/ip_fw.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_options.h>
#include <machine/in_cksum.h>
#include <netinet/ip_carp.h>
#include <netinet/in_rss.h>
#include <netipsec/ipsec_support.h>
#include <sys/socketvar.h>
#include <security/mac/mac_framework.h>
Go to the source code of this file.
Macros | |
#define | V_ip_strong_es VNET(ip_strong_es) |
#define | V_ip_sav VNET(ip_sav) |
#define | CHECK_SO_CT(sp, ct) (((sp->so_options & SO_TIMESTAMP) && (sp->so_ts_clock == ct)) ? 1 : 0) |
#define | V_ip_rsvp_on VNET(ip_rsvp_on) |
Functions | |
__FBSDID ("$FreeBSD$") | |
void | ipreass_init (void) |
void | ipreass_drain (void) |
void | ipreass_slowtimo (void) |
VNET_DEFINE (int, rsvp_on) | |
VNET_DEFINE (int, ipforwarding) | |
SYSCTL_INT (_net_inet_ip, IPCTL_FORWARDING, forwarding, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ipforwarding), 0, "Enable IP forwarding between interfaces") | |
VNET_DEFINE (int, ipsendredirects) | |
SYSCTL_INT (_net_inet_ip, IPCTL_SENDREDIRECTS, redirect, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ipsendredirects), 0, "Enable sending IP redirects") | |
VNET_DEFINE_STATIC (bool, ip_strong_es) | |
SYSCTL_BOOL (_net_inet_ip, OID_AUTO, rfc1122_strong_es, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ip_strong_es), false, "Packet's IP destination address must match address on arrival interface") | |
VNET_DEFINE_STATIC (bool, ip_sav) | |
SYSCTL_BOOL (_net_inet_ip, OID_AUTO, source_address_validation, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ip_sav), true, "Drop incoming packets with source address that is a local address") | |
VNET_DEFINE (pfil_head_t, inet_pfil_head) | |
VNET_DEFINE (struct in_ifaddrhead, in_ifaddrhead) | |
VNET_DEFINE (struct in_ifaddrhashhead *, in_ifaddrhashtbl) | |
VNET_DEFINE (u_long, in_ifaddrhmask) | |
CTASSERT (sizeof(struct in_ifaddrhashhead)==sizeof(LIST_HEAD(, in_addr))) | |
VNET_PCPUSTAT_DEFINE (struct ipstat, ipstat) | |
VNET_PCPUSTAT_SYSINIT (ipstat) | |
SYSCTL_VNET_PCPUSTAT (_net_inet_ip, IPCTL_STATS, stats, struct ipstat, ipstat, "IP statistics (struct ipstat, netinet/ip_var.h)") | |
void | kmod_ipstat_inc (int statnum) |
void | kmod_ipstat_dec (int statnum) |
static int | sysctl_netinet_intr_queue_maxlen (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_net_inet_ip, IPCTL_INTRQMAXLEN, intr_queue_maxlen, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, 0, 0, sysctl_netinet_intr_queue_maxlen, "I", "Maximum size of the IP input queue") | |
static int | sysctl_netinet_intr_queue_drops (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_net_inet_ip, IPCTL_INTRQDROPS, intr_queue_drops, CTLTYPE_INT|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, 0, sysctl_netinet_intr_queue_drops, "I", "Number of packets dropped from the IP input queue") | |
static void | ip_vnet_init (void *arg __unused) |
VNET_SYSINIT (ip_vnet_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, ip_vnet_init, NULL) | |
static void | ip_init (const void *unused __unused) |
SYSINIT (ip_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, ip_init, NULL) | |
void | ip_input (struct mbuf *m) |
void | ip_slowtimo (void) |
void | ip_drain (void) |
int | ipproto_register (short ipproto) |
int | ipproto_unregister (short ipproto) |
void | ip_forward (struct mbuf *m, int srcrt) |
void | ip_savecontrol (struct inpcb *inp, struct mbuf **mp, struct ip *ip, struct mbuf *m) |
VNET_DEFINE_STATIC (int, ip_rsvp_on) | |
VNET_DEFINE (struct socket *, ip_rsvpd) | |
int | ip_rsvp_init (struct socket *so) |
int | ip_rsvp_done (void) |
int | rsvp_input (struct mbuf **mp, int *offp, int proto) |
Variables | |
static struct netisr_handler | ip_nh |
struct domain | inetdomain |
struct protosw | inetsw [] |
u_char | ip_protox [IPPROTO_MAX] |
u_char | inetctlerrmap [PRC_NCMDS] |
#define CHECK_SO_CT | ( | sp, | |
ct | |||
) | (((sp->so_options & SO_TIMESTAMP) && (sp->so_ts_clock == ct)) ? 1 : 0) |
Definition at line 1146 of file ip_input.c.
#define V_ip_rsvp_on VNET(ip_rsvp_on) |
Definition at line 1363 of file ip_input.c.
#define V_ip_sav VNET(ip_sav) |
Definition at line 127 of file ip_input.c.
#define V_ip_strong_es VNET(ip_strong_es) |
Definition at line 121 of file ip_input.c.
__FBSDID | ( | "$FreeBSD$" | ) |
void ip_drain | ( | void | ) |
Definition at line 866 of file ip_input.c.
References ipreass_drain().
void ip_forward | ( | struct mbuf * | m, |
int | srcrt | ||
) |
Definition at line 959 of file ip_input.c.
References fib4_lookup(), in_ifaddr::ia_subnet, in_ifaddr::ia_subnetmask, icmp_error(), ICMP_REDIRECT, ICMP_REDIRECT_HOST, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, ICMP_UNREACH, ICMP_UNREACH_HOST, ICMP_UNREACH_NEEDFRAG, ifatoia, in_canforward(), ip::ip_dst, IP_FORWARDING, ip::ip_len, ip_next_mtu(), ip_output(), ip::ip_ttl, IPSTAT_INC, IPTTLDEC, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_len, and V_ipsendredirects.
Referenced by ip_dooptions(), and ip_input().
|
static |
Definition at line 344 of file ip_input.c.
References inetdomain, inetsw, ip_nh, and ip_protox.
void ip_input | ( | struct mbuf * | m | ) |
Definition at line 448 of file ip_input.c.
References in_ifaddr::ia_ifa, IA_SIN, ifatoia, in_cksum_hdr(), in_localip_fib(), INADDR_ANY, INADDR_BROADCAST, INADDR_HASH, inetsw, ip_dooptions(), ip::ip_dst, ip_forward(), ip::ip_hl, ip_len, ip::ip_len, IP_MF, ip_mforward, ip::ip_off, IP_OFFMASK, ip::ip_p, IP_PROBE, ip_protox, ip_reass(), ip_tryforward(), ip::ip_v, IPSTAT_INC, IPVERSION, in_addr::s_addr, satosin, V_in_ifaddrhead, V_inet_pfil_head, V_ip_mrouter, V_ip_sav, V_ip_strong_es, V_ipforwarding, and V_rsvp_on.
int ip_rsvp_done | ( | void | ) |
Definition at line 1390 of file ip_input.c.
References V_ip_rsvp_on, V_ip_rsvpd, and V_rsvp_on.
int ip_rsvp_init | ( | struct socket * | so | ) |
Definition at line 1366 of file ip_input.c.
References V_ip_rsvp_on, V_ip_rsvpd, and V_rsvp_on.
Definition at line 1150 of file ip_input.c.
References CHECK_SO_CT, inpcb::inp_flags, inpcb::inp_flags2, INP_RECVDSTADDR, INP_RECVFLOWID, INP_RECVIF, INP_RECVOPTS, INP_RECVRETOPTS, INP_RECVRSSBUCKETID, INP_RECVTOS, INP_RECVTTL, inpcb::inp_socket, ip::ip_dst, ip_srcroute(), ip::ip_tos, ip::ip_ttl, and IPPROTO_IP.
void ip_slowtimo | ( | void | ) |
Definition at line 852 of file ip_input.c.
References ipreass_slowtimo().
|
static |
Definition at line 304 of file ip_input.c.
References INADDR_NHASH, ip_nh, ipreass_init(), PFIL_INET_NAME, V_in_ifaddrhashtbl, V_in_ifaddrhead, V_in_ifaddrhmask, and V_inet_pfil_head.
int ipproto_register | ( | short | ipproto | ) |
Definition at line 884 of file ip_input.c.
References inetdomain, inetsw, and ip_protox.
Referenced by carp_mod_load(), and sctp_module_load().
int ipproto_unregister | ( | short | ipproto | ) |
Definition at line 915 of file ip_input.c.
References inetsw, and ip_protox.
Referenced by carp_mod_cleanup(), and sctp_module_unload().
void ipreass_drain | ( | void | ) |
Definition at line 614 of file ip_reass.c.
References count, ipq_drop(), IPQ_LOCK, IPQ_UNLOCK, IPREASS_NHASH, and V_ipq.
Referenced by ip_drain(), and sysctl_maxfragpackets().
void ipreass_init | ( | void | ) |
Definition at line 563 of file ip_reass.c.
References IP_MAXFRAGPACKETS, IP_MAXFRAGS, IPREASS_NHASH, ipreass_zone_change(), maxfrags, V_ipq, V_ipq_hashseed, V_ipq_zone, V_ipreass_maxbucketsize, and V_maxfragsperpacket.
Referenced by ip_vnet_init().
void ipreass_slowtimo | ( | void | ) |
Definition at line 592 of file ip_reass.c.
References IPQ_LOCK, ipq_timeout(), ipq::ipq_ttl, IPQ_UNLOCK, IPREASS_NHASH, nfrags, and V_ipq.
Referenced by ip_slowtimo().
void kmod_ipstat_dec | ( | int | statnum | ) |
Definition at line 211 of file ip_input.c.
void kmod_ipstat_inc | ( | int | statnum | ) |
Definition at line 204 of file ip_input.c.
int rsvp_input | ( | struct mbuf ** | mp, |
int * | offp, | ||
int | proto | ||
) |
Definition at line 1406 of file ip_input.c.
References rip_input(), rsvp_input_p, V_ip_rsvpd, and V_rsvp_on.
SYSCTL_BOOL | ( | _net_inet_ip | , |
OID_AUTO | , | ||
rfc1122_strong_es | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEip_strong_es, | ||
false | , | ||
"Packet's IP destination address must match address on arrival interface" | |||
) |
SYSCTL_BOOL | ( | _net_inet_ip | , |
OID_AUTO | , | ||
source_address_validation | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEip_sav, | ||
true | , | ||
"Drop incoming packets with source address that is a local address" | |||
) |
SYSCTL_INT | ( | _net_inet_ip | , |
IPCTL_FORWARDING | , | ||
forwarding | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEipforwarding, | ||
0 | , | ||
"Enable IP forwarding between interfaces" | |||
) |
SYSCTL_INT | ( | _net_inet_ip | , |
IPCTL_SENDREDIRECTS | , | ||
redirect | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEipsendredirects, | ||
0 | , | ||
"Enable sending IP redirects" | |||
) |
|
static |
Definition at line 236 of file ip_input.c.
References ip_nh.
|
static |
Definition at line 218 of file ip_input.c.
References ip_nh.
SYSCTL_PROC | ( | _net_inet_ip | , |
IPCTL_INTRQDROPS | , | ||
intr_queue_drops | , | ||
CTLTYPE_INT|CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_netinet_intr_queue_drops | , | ||
"I" | , | ||
"Number of packets dropped from the IP input queue" | |||
) |
SYSCTL_PROC | ( | _net_inet_ip | , |
IPCTL_INTRQMAXLEN | , | ||
intr_queue_maxlen | , | ||
CTLTYPE_INT|CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_netinet_intr_queue_maxlen | , | ||
"I" | , | ||
"Maximum size of the IP input queue" | |||
) |
SYSCTL_VNET_PCPUSTAT | ( | _net_inet_ip | , |
IPCTL_STATS | , | ||
stats | , | ||
struct ipstat | , | ||
ipstat | , | ||
"IP statistics (struct ipstat, netinet/ip_var.h)" | |||
) |
VNET_DEFINE | ( | int | , |
ipforwarding | |||
) |
VNET_DEFINE | ( | int | , |
ipsendredirects | |||
) |
VNET_DEFINE | ( | int | , |
rsvp_on | |||
) |
VNET_DEFINE | ( | pfil_head_t | , |
inet_pfil_head | |||
) |
VNET_DEFINE | ( | struct in_ifaddrhashhead * | , |
in_ifaddrhashtbl | |||
) |
VNET_DEFINE | ( | struct in_ifaddrhead | , |
in_ifaddrhead | |||
) |
VNET_DEFINE | ( | struct socket * | , |
ip_rsvpd | |||
) |
VNET_DEFINE | ( | u_long | , |
in_ifaddrhmask | |||
) |
VNET_DEFINE_STATIC | ( | bool | , |
ip_sav | |||
) |
VNET_DEFINE_STATIC | ( | bool | , |
ip_strong_es | |||
) |
VNET_DEFINE_STATIC | ( | int | , |
ip_rsvp_on | |||
) |
VNET_PCPUSTAT_SYSINIT | ( | ipstat | ) |
VNET_SYSINIT | ( | ip_vnet_init | , |
SI_SUB_PROTO_DOMAIN | , | ||
SI_ORDER_FOURTH | , | ||
ip_vnet_init | , | ||
NULL | |||
) |
u_char inetctlerrmap[PRC_NCMDS] |
Definition at line 935 of file ip_input.c.
|
extern |
Referenced by ip_init(), and ipproto_register().
|
extern |
Referenced by ip_init(), ip_input(), ipproto_register(), and ipproto_unregister().
|
static |
Definition at line 134 of file ip_input.c.
Referenced by ip_init(), ip_vnet_init(), sysctl_netinet_intr_queue_drops(), and sysctl_netinet_intr_queue_maxlen().
u_char ip_protox[IPPROTO_MAX] |
Definition at line 167 of file ip_input.c.
Referenced by ip_init(), ip_input(), ipproto_register(), and ipproto_unregister().