FreeBSD kernel IPv4 code
|
#include <sys/epoch.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/counter.h>
#include <net/vnet.h>
Go to the source code of this file.
Data Structures | |
struct | ipovly |
struct | ipq |
struct | ipoption |
struct | ipstat |
struct | ipfw_rule_ref |
Macros | |
#define | MAX_IPOPTLEN 40 |
#define | IPSTAT_ADD(name, val) VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val)) |
#define | IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val)) |
#define | IPSTAT_INC(name) IPSTAT_ADD(name, 1) |
#define | IPSTAT_DEC(name) IPSTAT_SUB(name, 1) |
#define | KMOD_IPSTAT_INC(name) kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(uint64_t)) |
#define | KMOD_IPSTAT_DEC(name) kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(uint64_t)) |
#define | IP_FORWARDING 0x1 /* most of ip header exists */ |
#define | IP_RAWOUTPUT 0x2 /* raw ip header exists */ |
#define | IP_SENDONES 0x4 /* send all-ones broadcast */ |
#define | IP_SENDTOIF 0x8 /* send on specific ifnet */ |
#define | IP_ROUTETOIF SO_DONTROUTE /* 0x10 bypass routing tables */ |
#define | IP_ALLOWBROADCAST SO_BROADCAST /* 0x20 can send broadcast packets */ |
#define | IP_NODEFAULTFLOWID 0x40 /* Don't set the flowid from inp */ |
#define | IP_NO_SND_TAG_RL 0x80 /* Don't send down the ratelimit tag */ |
#define | IP_HDR_ALIGNED_P(ip) ((((intptr_t) (ip)) & 3) == 0) |
#define | V_ip_id VNET(ip_id) |
#define | V_ip_defttl VNET(ip_defttl) |
#define | V_ipforwarding VNET(ipforwarding) |
#define | V_ipsendredirects VNET(ipsendredirects) |
#define | V_ip_rsvpd VNET(ip_rsvpd) |
#define | V_ip_mrouter VNET(ip_mrouter) |
#define | V_rsvp_on VNET(rsvp_on) |
#define | V_drop_redirect VNET(drop_redirect) |
#define | V_inet_pfil_head VNET(inet_pfil_head) |
#define | PFIL_INET_NAME "inet" |
#define | MTAG_IPFW 1148380143 /* IPFW-tagged cookie */ |
#define | MTAG_IPFW_RULE 1262273568 /* rule reference */ |
#define | MTAG_IPFW_CALL 1308397630 /* call stack */ |
#define | V_ip_fw_ctl_ptr VNET(ip_fw_ctl_ptr) |
Typedefs | |
typedef int(* | ip_fw_chk_ptr_t) (struct ip_fw_args *args) |
typedef int(* | ip_fw_ctl_ptr_t) (struct sockopt *) |
Enumerations | |
enum | { IPFW_INFO_MASK = 0x0000ffff , IPFW_INFO_OUT = 0x00000000 , IPFW_INFO_IN = 0x80000000 , IPFW_ONEPASS = 0x40000000 , IPFW_IS_MASK = 0x30000000 , IPFW_IS_DIVERT = 0x20000000 , IPFW_IS_DUMMYNET =0x10000000 , IPFW_IS_PIPE = 0x08000000 } |
Functions | |
VNET_PCPUSTAT_DECLARE (struct ipstat, ipstat) | |
void | kmod_ipstat_inc (int statnum) |
void | kmod_ipstat_dec (int statnum) |
VNET_DECLARE (int, ip_defttl) | |
VNET_DECLARE (int, ipforwarding) | |
VNET_DECLARE (int, ipsendredirects) | |
VNET_DECLARE (struct socket *, ip_rsvpd) | |
VNET_DECLARE (struct socket *, ip_mrouter) | |
VNET_DECLARE (int, rsvp_on) | |
VNET_DECLARE (int, drop_redirect) | |
void | inp_freemoptions (struct ip_moptions *) |
int | inp_getmoptions (struct inpcb *, struct sockopt *) |
int | inp_setmoptions (struct inpcb *, struct sockopt *) |
int | ip_ctloutput (struct socket *, struct sockopt *sopt) |
void | ip_drain (void) |
int | ip_fragment (struct ip *ip, struct mbuf **m_frag, int mtu, u_long if_hwassist_flags) |
void | ip_forward (struct mbuf *m, int srcrt) |
int | ip_output (struct mbuf *, struct mbuf *, struct route *, int, struct ip_moptions *, struct inpcb *) |
int | ipproto_register (short) |
int | ipproto_unregister (short) |
struct mbuf * | ip_reass (struct mbuf *) |
void | ip_savecontrol (struct inpcb *, struct mbuf **, struct ip *, struct mbuf *) |
void | ip_slowtimo (void) |
void | ip_fillid (struct ip *) |
int | rip_ctloutput (struct socket *, struct sockopt *) |
void | rip_ctlinput (int, struct sockaddr *, void *) |
int | rip_input (struct mbuf **, int *, int) |
int | rip_output (struct mbuf *, struct socket *,...) |
int | ipip_input (struct mbuf **, int *, int) |
int | rsvp_input (struct mbuf **, int *, int) |
int | ip_rsvp_init (struct socket *) |
int | ip_rsvp_done (void) |
VNET_DECLARE (struct pfil_head *, inet_pfil_head) | |
void | in_delayed_cksum (struct mbuf *m) |
VNET_DECLARE (ip_fw_ctl_ptr_t, ip_fw_ctl_ptr) | |
Variables | |
u_char | ip_protox [] |
int(* | legal_vif_num )(int) |
u_long(* | ip_mcast_src )(int) |
struct pr_usrreqs | rip_usrreqs |
int(* | ip_mforward )(struct ip *, struct ifnet *, struct mbuf *, struct ip_moptions *) |
int(* | ip_rsvp_vif )(struct socket *, struct sockopt *) |
void(* | ip_rsvp_force_done )(struct socket *) |
int(* | rsvp_input_p )(struct mbuf **, int *, int) |
void(* | ip_divert_ptr )(struct mbuf *m, bool incoming) |
int(* | ng_ipfw_input_p )(struct mbuf **, struct ip_fw_args *, bool) |
int(* | ip_dn_ctl_ptr )(struct sockopt *) |
int(* | ip_dn_io_ptr )(struct mbuf **, struct ip_fw_args *) |
#define IP_ALLOWBROADCAST SO_BROADCAST /* 0x20 can send broadcast packets */ |
#define IP_NO_SND_TAG_RL 0x80 /* Don't send down the ratelimit tag */ |
#define IP_NODEFAULTFLOWID 0x40 /* Don't set the flowid from inp */ |
#define IP_ROUTETOIF SO_DONTROUTE /* 0x10 bypass routing tables */ |
#define IPSTAT_DEC | ( | name | ) | IPSTAT_SUB(name, 1) |
#define IPSTAT_INC | ( | name | ) | IPSTAT_ADD(name, 1) |
#define IPSTAT_SUB | ( | name, | |
val | |||
) | IPSTAT_ADD(name, -(val)) |
#define KMOD_IPSTAT_DEC | ( | name | ) | kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(uint64_t)) |
#define KMOD_IPSTAT_INC | ( | name | ) | kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(uint64_t)) |
anonymous enum |
void in_delayed_cksum | ( | struct mbuf * | m | ) |
Definition at line 1032 of file ip_output.c.
References in_cksum_skip(), ip::ip_hl, ip::ip_len, and udphdr::uh_ulen.
Referenced by divert_packet(), ip_fragment(), ip_mloopback(), ip_output(), and pim_register_prepare().
void inp_freemoptions | ( | struct ip_moptions * | imo | ) |
Definition at line 1593 of file in_mcast.c.
References in_mfilter::imf_inm, imf_leave(), in_leavegroup(), in_multi::inm_ifp, ip_mfilter_first(), ip_mfilter_free(), and ip_mfilter_remove().
Referenced by in_pcbfree().
int inp_getmoptions | ( | struct inpcb * | inp, |
struct sockopt * | sopt | ||
) |
Definition at line 1743 of file in_mcast.c.
References IA_SIN, IFP_TO_IA, in_nullhost, inp_get_source_filters(), inpcb::inp_moptions, inpcb::inp_socket, INP_UNLOCK_ASSERT, INP_WLOCK, and INP_WUNLOCK.
Referenced by ip_ctloutput().
int inp_setmoptions | ( | struct inpcb * | inp, |
struct sockopt * | sopt | ||
) |
Definition at line 2713 of file in_mcast.c.
References inp_block_unblock_source(), inp_findmoptions(), inp_join_group(), inp_leave_group(), inp_set_multicast_if(), inp_set_source_filters(), inpcb::inp_socket, INP_UNLOCK_ASSERT, INP_WUNLOCK, and legal_vif_num.
Referenced by ip_ctloutput().
int ip_ctloutput | ( | struct socket * | so, |
struct sockopt * | sopt | ||
) |
Definition at line 1070 of file ip_output.c.
References in_conninfo::inc_fibnum, INP_2PCP_MASK, INP_2PCP_SET, INP_2PCP_SHIFT, INP_BINDANY, INP_BINDMULTI, INP_DONTFRAG, inpcb::inp_flags, inpcb::inp_flags2, inpcb::inp_flowid, inpcb::inp_flowtype, inp_getmoptions(), INP_HIGHPORT, inpcb::inp_inc, inpcb::inp_ip_minttl, inpcb::inp_ip_tos, inpcb::inp_ip_ttl, INP_LOWPORT, INP_ONESBCAST, inpcb::inp_options, INP_ORIGDSTADDR, INP_RATE_LIMIT_CHANGED, INP_RECVDSTADDR, INP_RECVFLOWID, INP_RECVIF, INP_RECVOPTS, INP_RECVRETOPTS, INP_RECVRSSBUCKETID, INP_RECVTOS, INP_RECVTTL, INP_REUSEADDR, INP_REUSEPORT, INP_REUSEPORT_LB, INP_RLOCK, INP_RSS_BUCKET_SET, inpcb::inp_rss_listen_bucket, INP_RUNLOCK, inp_setmoptions(), INP_WLOCK, INP_WUNLOCK, ip_pcbopts(), IPPROTO_IP, MAXTTL, OPTBIT, OPTBIT2, OPTSET, OPTSET2, and sotoinpcb.
Referenced by sctp_ctloutput(), tcp_ctloutput_get(), tcp_ctloutput_set(), and udp_ctloutput().
void ip_drain | ( | void | ) |
Definition at line 866 of file ip_input.c.
References ipreass_drain().
void ip_fillid | ( | struct ip * | ip | ) |
Definition at line 243 of file ip_id.c.
References IP_DF, ip::ip_id, ip::ip_off, ip_randomid(), V_ip_do_randomid, V_ip_id, and V_ip_rfc6864.
Referenced by carp_send_ad_locked(), in_gre_output(), ip_output(), pim_register_send_rp(), sctp_lowlevel_chunk_output(), and sctp_send_resp_msg().
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().
int ip_fragment | ( | struct ip * | ip, |
struct mbuf ** | m_frag, | ||
int | mtu, | ||
u_long | if_hwassist_flags | ||
) |
Definition at line 859 of file ip_output.c.
References in_delayed_cksum(), IP_DF, ip::ip_hl, ip_len, ip::ip_len, IP_MF, ip_off, ip::ip_off, ip_optcopy(), ip::ip_sum, ip::ip_v, IPSTAT_ADD, IPSTAT_INC, IPVERSION, and nfrags.
Referenced by ip_output(), ip_tryforward(), and pim_register_prepare().
int ip_output | ( | struct mbuf * | m, |
struct mbuf * | opt, | ||
struct route * | ro, | ||
int | flags, | ||
struct ip_moptions * | imo, | ||
struct inpcb * | inp | ||
) |
Definition at line 320 of file ip_output.c.
References fib4_lookup(), in_ifaddr::ia_ifa, IA_SIN, ifatoia, IFP_TO_IA, in_delayed_cksum(), in_ifaddr_broadcast(), in_mcast_loop, INADDR_ANY, INADDR_BROADCAST, in_conninfo::inc_fibnum, INP_2PCP_MASK, INP_2PCP_SET, INP_2PCP_SHIFT, inpcb::inp_flags2, inpcb::inp_flowid, inpcb::inp_flowtype, inpcb::inp_inc, INP_LOCK_ASSERT, inpcb::inp_numa_domain, inpcb::inp_rt_cookie, IP_ALLOWBROADCAST, IP_DF, ip::ip_dst, ip_fillid(), IP_FORWARDING, ip_fragment(), ip::ip_hl, ip_insertoptions(), ip_len, ip::ip_len, ip_mcast_src, ip_mforward, ip_mloopback(), IP_NO_SND_TAG_RL, IP_NODEFAULTFLOWID, ip_off, ip::ip_off, ip_output_pfil(), ip_output_send(), IP_PROBE, IP_RAWOUTPUT, IP_ROUTETOIF, IP_SENDONES, ip::ip_sum, ip::ip_ttl, ip::ip_v, IPSTAT_INC, IPVERSION, rt_update_ro_flags(), in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_len, sintosa, V_inet_pfil_head, V_ip_mrouter, and V_rsvp_on.
Referenced by bbr_output_wtime(), carp_send_ad_locked(), div_output_outbound(), igmp_intr(), in_gif_output(), in_gre_output(), ip_forward(), rack_fast_output(), rack_fast_rsm_output(), rack_output(), send_packet(), syncache_respond(), tcp_default_output(), tcp_respond(), and tcp_twrespond().
struct mbuf * ip_reass | ( | struct mbuf * | m | ) |
Definition at line 183 of file ip_reass.c.
References count, GETIP, ip::ip_dst, ip::ip_hl, ip::ip_id, ip_len, ip::ip_len, IP_MAXPACKET, IP_MF, ip_off, ip::ip_off, ip::ip_p, ip::ip_tos, IPFRAGTTL, ipq_drop(), ipq::ipq_dst, ipq::ipq_frags, ipq::ipq_id, IPQ_LOCK, ipq::ipq_maxoff, ipq::ipq_nfrags, ipq::ipq_p, ipq_reuse(), ipq::ipq_ttl, IPQ_UNLOCK, IPREASS_HMASK, IPSTAT_INC, IPTOS_ECN_CE, IPTOS_ECN_MASK, IPTOS_ECN_NOTECT, M_IP_FRAG, maxfrags, next, nfrags, rss_mbuf_software_hash_v4(), in_addr::s_addr, V_ipq, V_ipq_hashseed, V_ipq_zone, V_ipreass_maxbucketsize, V_maxfragsperpacket, and V_noreass.
Referenced by ip_input().
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().
int ipip_input | ( | struct mbuf ** | , |
int * | , | ||
int | |||
) |
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 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.
void rip_ctlinput | ( | int | , |
struct sockaddr * | , | ||
void * | |||
) |
int rip_ctloutput | ( | struct socket * | , |
struct sockopt * | |||
) |
int rip_input | ( | struct mbuf ** | , |
int * | , | ||
int | |||
) |
Referenced by igmp_input(), pim_input(), and rsvp_input().
int rip_output | ( | struct mbuf * | , |
struct socket * | , | ||
... | |||
) |
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.
VNET_DECLARE | ( | int | , |
drop_redirect | |||
) |
VNET_DECLARE | ( | int | , |
ip_defttl | |||
) |
VNET_DECLARE | ( | int | , |
ipforwarding | |||
) |
VNET_DECLARE | ( | int | , |
ipsendredirects | |||
) |
VNET_DECLARE | ( | int | , |
rsvp_on | |||
) |
VNET_DECLARE | ( | ip_fw_ctl_ptr_t | , |
ip_fw_ctl_ptr | |||
) |
VNET_DECLARE | ( | struct pfil_head * | , |
inet_pfil_head | |||
) |
VNET_DECLARE | ( | struct socket * | , |
ip_mrouter | |||
) |
VNET_DECLARE | ( | struct socket * | , |
ip_rsvpd | |||
) |
|
extern |
Definition at line 103 of file raw_ip.c.
Referenced by div_modevent().
|
extern |
|
extern |
|
extern |
Referenced by ip_mroute_modevent(), and ip_output().
|
extern |
Referenced by ip_input(), ip_mroute_modevent(), and ip_output().
|
extern |
Definition at line 167 of file ip_input.c.
Referenced by ip_init(), ip_input(), ipproto_register(), and ipproto_unregister().
|
extern |
Referenced by ip_mroute_modevent().
|
extern |
Referenced by ip_mroute_modevent().
|
extern |
Referenced by inp_setmoptions(), and ip_mroute_modevent().
|
extern |
|
extern |
|
extern |
Referenced by ip_mroute_modevent(), and rsvp_input().