FreeBSD kernel IPv4 code
ip_var.h File Reference
#include <sys/epoch.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/counter.h>
#include <net/vnet.h>
Include dependency graph for ip_var.h:
This graph shows which files directly or indirectly include this file:

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 *)
 

Macro Definition Documentation

◆ IP_ALLOWBROADCAST

#define IP_ALLOWBROADCAST   SO_BROADCAST /* 0x20 can send broadcast packets */

Definition at line 170 of file ip_var.h.

◆ IP_FORWARDING

#define IP_FORWARDING   0x1 /* most of ip header exists */

Definition at line 165 of file ip_var.h.

◆ IP_HDR_ALIGNED_P

#define IP_HDR_ALIGNED_P (   ip)    ((((intptr_t) (ip)) & 3) == 0)

Definition at line 177 of file ip_var.h.

◆ IP_NO_SND_TAG_RL

#define IP_NO_SND_TAG_RL   0x80 /* Don't send down the ratelimit tag */

Definition at line 172 of file ip_var.h.

◆ IP_NODEFAULTFLOWID

#define IP_NODEFAULTFLOWID   0x40 /* Don't set the flowid from inp */

Definition at line 171 of file ip_var.h.

◆ IP_RAWOUTPUT

#define IP_RAWOUTPUT   0x2 /* raw ip header exists */

Definition at line 166 of file ip_var.h.

◆ IP_ROUTETOIF

#define IP_ROUTETOIF   SO_DONTROUTE /* 0x10 bypass routing tables */

Definition at line 169 of file ip_var.h.

◆ IP_SENDONES

#define IP_SENDONES   0x4 /* send all-ones broadcast */

Definition at line 167 of file ip_var.h.

◆ IP_SENDTOIF

#define IP_SENDTOIF   0x8 /* send on specific ifnet */

Definition at line 168 of file ip_var.h.

◆ IPSTAT_ADD

#define IPSTAT_ADD (   name,
  val 
)     VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val))

Definition at line 148 of file ip_var.h.

◆ IPSTAT_DEC

#define IPSTAT_DEC (   name)    IPSTAT_SUB(name, 1)

Definition at line 152 of file ip_var.h.

◆ IPSTAT_INC

#define IPSTAT_INC (   name)    IPSTAT_ADD(name, 1)

Definition at line 151 of file ip_var.h.

◆ IPSTAT_SUB

#define IPSTAT_SUB (   name,
  val 
)    IPSTAT_ADD(name, -(val))

Definition at line 150 of file ip_var.h.

◆ KMOD_IPSTAT_DEC

#define KMOD_IPSTAT_DEC (   name)     kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(uint64_t))

Definition at line 161 of file ip_var.h.

◆ KMOD_IPSTAT_INC

#define KMOD_IPSTAT_INC (   name)     kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(uint64_t))

Definition at line 158 of file ip_var.h.

◆ MAX_IPOPTLEN

#define MAX_IPOPTLEN   40

Definition at line 81 of file ip_var.h.

◆ MTAG_IPFW

#define MTAG_IPFW   1148380143 /* IPFW-tagged cookie */

Definition at line 288 of file ip_var.h.

◆ MTAG_IPFW_CALL

#define MTAG_IPFW_CALL   1308397630 /* call stack */

Definition at line 290 of file ip_var.h.

◆ MTAG_IPFW_RULE

#define MTAG_IPFW_RULE   1262273568 /* rule reference */

Definition at line 289 of file ip_var.h.

◆ PFIL_INET_NAME

#define PFIL_INET_NAME   "inet"

Definition at line 250 of file ip_var.h.

◆ V_drop_redirect

#define V_drop_redirect   VNET(drop_redirect)

Definition at line 211 of file ip_var.h.

◆ V_inet_pfil_head

#define V_inet_pfil_head   VNET(inet_pfil_head)

Definition at line 249 of file ip_var.h.

◆ V_ip_defttl

#define V_ip_defttl   VNET(ip_defttl)

Definition at line 202 of file ip_var.h.

◆ V_ip_fw_ctl_ptr

#define V_ip_fw_ctl_ptr   VNET(ip_fw_ctl_ptr)

Definition at line 296 of file ip_var.h.

◆ V_ip_id

#define V_ip_id   VNET(ip_id)

Definition at line 201 of file ip_var.h.

◆ V_ip_mrouter

#define V_ip_mrouter   VNET(ip_mrouter)

Definition at line 209 of file ip_var.h.

◆ V_ip_rsvpd

#define V_ip_rsvpd   VNET(ip_rsvpd)

Definition at line 208 of file ip_var.h.

◆ V_ipforwarding

#define V_ipforwarding   VNET(ipforwarding)

Definition at line 203 of file ip_var.h.

◆ V_ipsendredirects

#define V_ipsendredirects   VNET(ipsendredirects)

Definition at line 204 of file ip_var.h.

◆ V_rsvp_on

#define V_rsvp_on   VNET(rsvp_on)

Definition at line 210 of file ip_var.h.

Typedef Documentation

◆ ip_fw_chk_ptr_t

typedef int(* ip_fw_chk_ptr_t) (struct ip_fw_args *args)

Definition at line 293 of file ip_var.h.

◆ ip_fw_ctl_ptr_t

typedef int(* ip_fw_ctl_ptr_t) (struct sockopt *)

Definition at line 294 of file ip_var.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IPFW_INFO_MASK 
IPFW_INFO_OUT 
IPFW_INFO_IN 
IPFW_ONEPASS 
IPFW_IS_MASK 
IPFW_IS_DIVERT 
IPFW_IS_DUMMYNET 
IPFW_IS_PIPE 

Definition at line 278 of file ip_var.h.

Function Documentation

◆ in_delayed_cksum()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inp_freemoptions()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inp_getmoptions()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inp_setmoptions()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip_ctloutput()

◆ ip_drain()

void ip_drain ( void  )

Definition at line 866 of file ip_input.c.

References ipreass_drain().

Here is the call graph for this function:

◆ ip_fillid()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip_forward()

◆ ip_fragment()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip_output()

◆ ip_reass()

◆ ip_rsvp_done()

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.

◆ ip_rsvp_init()

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.

◆ ip_savecontrol()

void ip_savecontrol ( struct inpcb inp,
struct mbuf **  mp,
struct ip ip,
struct mbuf *  m 
)

◆ ip_slowtimo()

void ip_slowtimo ( void  )

Definition at line 852 of file ip_input.c.

References ipreass_slowtimo().

Here is the call graph for this function:

◆ ipip_input()

int ipip_input ( struct mbuf **  ,
int *  ,
int   
)

◆ ipproto_register()

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().

Here is the caller graph for this function:

◆ ipproto_unregister()

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().

Here is the caller graph for this function:

◆ kmod_ipstat_dec()

void kmod_ipstat_dec ( int  statnum)

Definition at line 211 of file ip_input.c.

◆ kmod_ipstat_inc()

void kmod_ipstat_inc ( int  statnum)

Definition at line 204 of file ip_input.c.

◆ rip_ctlinput()

void rip_ctlinput ( int  ,
struct sockaddr *  ,
void *   
)

◆ rip_ctloutput()

int rip_ctloutput ( struct socket *  ,
struct sockopt *   
)

◆ rip_input()

int rip_input ( struct mbuf **  ,
int *  ,
int   
)

Referenced by igmp_input(), pim_input(), and rsvp_input().

Here is the caller graph for this function:

◆ rip_output()

int rip_output ( struct mbuf *  ,
struct socket *  ,
  ... 
)

◆ rsvp_input()

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.

Here is the call graph for this function:

◆ VNET_DECLARE() [1/9]

VNET_DECLARE ( int  ,
drop_redirect   
)

◆ VNET_DECLARE() [2/9]

VNET_DECLARE ( int  ,
ip_defttl   
)

◆ VNET_DECLARE() [3/9]

VNET_DECLARE ( int  ,
ipforwarding   
)

◆ VNET_DECLARE() [4/9]

VNET_DECLARE ( int  ,
ipsendredirects   
)

◆ VNET_DECLARE() [5/9]

VNET_DECLARE ( int  ,
rsvp_on   
)

◆ VNET_DECLARE() [6/9]

VNET_DECLARE ( ip_fw_ctl_ptr_t  ,
ip_fw_ctl_ptr   
)

◆ VNET_DECLARE() [7/9]

VNET_DECLARE ( struct pfil_head *  ,
inet_pfil_head   
)

◆ VNET_DECLARE() [8/9]

VNET_DECLARE ( struct socket *  ,
ip_mrouter   
)

◆ VNET_DECLARE() [9/9]

VNET_DECLARE ( struct socket *  ,
ip_rsvpd   
)

◆ VNET_PCPUSTAT_DECLARE()

VNET_PCPUSTAT_DECLARE ( struct ipstat  ,
ipstat   
)

Variable Documentation

◆ ip_divert_ptr

void(* ip_divert_ptr) (struct mbuf *m, bool incoming) ( struct mbuf *  m,
bool  incoming 
)
extern

Definition at line 103 of file raw_ip.c.

Referenced by div_modevent().

◆ ip_dn_ctl_ptr

int(* ip_dn_ctl_ptr) (struct sockopt *) ( struct sockopt *  )
extern

Definition at line 101 of file raw_ip.c.

◆ ip_dn_io_ptr

int(* ip_dn_io_ptr) (struct mbuf **, struct ip_fw_args *) ( struct mbuf **  ,
struct ip_fw_args *   
)
extern

Definition at line 102 of file raw_ip.c.

◆ ip_mcast_src

u_long(* ip_mcast_src) (int) ( int  )
extern

Referenced by ip_mroute_modevent(), and ip_output().

◆ ip_mforward

int(* ip_mforward) (struct ip *, struct ifnet *, struct mbuf *, struct ip_moptions *) ( struct ip ,
struct ifnet *  ,
struct mbuf *  ,
struct ip_moptions *   
)
extern

◆ ip_protox

u_char ip_protox[]
extern

Definition at line 167 of file ip_input.c.

Referenced by ip_init(), ip_input(), ipproto_register(), and ipproto_unregister().

◆ ip_rsvp_force_done

void(* ip_rsvp_force_done) (struct socket *) ( struct socket *  )
extern

Referenced by ip_mroute_modevent().

◆ ip_rsvp_vif

int(* ip_rsvp_vif) (struct socket *, struct sockopt *) ( struct socket *  ,
struct sockopt *   
)
extern

Referenced by ip_mroute_modevent().

◆ legal_vif_num

int(* legal_vif_num) (int) ( int  )
extern

◆ ng_ipfw_input_p

int(* ng_ipfw_input_p) (struct mbuf **, struct ip_fw_args *, bool) ( struct mbuf **  ,
struct ip_fw_args *  ,
bool   
)
extern

Definition at line 104 of file raw_ip.c.

◆ rip_usrreqs

struct pr_usrreqs rip_usrreqs
extern

◆ rsvp_input_p

int(* rsvp_input_p) (struct mbuf **, int *, int) ( struct mbuf **  ,
int *  ,
int   
)
extern

Referenced by ip_mroute_modevent(), and rsvp_input().