FreeBSD kernel IPv4 code
ip_output.c File Reference
#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_ipsec.h"
#include "opt_kern_tls.h"
#include "opt_mbuf_stress_test.h"
#include "opt_ratelimit.h"
#include "opt_route.h"
#include "opt_rss.h"
#include "opt_sctp.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/ktls.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/sdt.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/ucred.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_vlan_var.h>
#include <net/if_llatbl.h>
#include <net/ethernet.h>
#include <net/netisr.h>
#include <net/pfil.h>
#include <net/route.h>
#include <net/route/nhop.h>
#include <net/rss_config.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_fib.h>
#include <netinet/in_kdtrace.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
#include <netinet/in_rss.h>
#include <netinet/in_var.h>
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netipsec/ipsec_support.h>
#include <machine/in_cksum.h>
#include <security/mac/mac_framework.h>

Go to the source code of this file.

Macros

#define OPTSET(bit)
 
#define OPTSET2(bit, val)
 
#define OPTBIT(bit)   (inp->inp_flags & bit ? 1 : 0)
 
#define OPTBIT2(bit)   (inp->inp_flags2 & bit ? 1 : 0)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void ip_mloopback (struct ifnet *, const struct mbuf *, int)
 
static int ip_output_pfil (struct mbuf **mp, struct ifnet *ifp, int flags, struct inpcb *inp, struct sockaddr_in *dst, int *fibnum, int *error)
 
static int ip_output_send (struct inpcb *inp, struct ifnet *ifp, struct mbuf *m, const struct sockaddr *gw, struct route *ro, bool stamp_tag)
 
static void rt_update_ro_flags (struct route *ro, const struct nhop_object *nh)
 
int ip_output (struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, struct ip_moptions *imo, struct inpcb *inp)
 
int ip_fragment (struct ip *ip, struct mbuf **m_frag, int mtu, u_long if_hwassist_flags)
 
void in_delayed_cksum (struct mbuf *m)
 
int ip_ctloutput (struct socket *so, struct sockopt *sopt)
 

Variables

int in_mcast_loop
 
struct protosw inetsw []
 

Macro Definition Documentation

◆ OPTBIT

#define OPTBIT (   bit)    (inp->inp_flags & bit ? 1 : 0)

◆ OPTBIT2

#define OPTBIT2 (   bit)    (inp->inp_flags2 & bit ? 1 : 0)

◆ OPTSET

#define OPTSET (   bit)
Value:
do { \
INP_WLOCK(inp); \
if (optval) \
inp->inp_flags |= bit; \
else \
inp->inp_flags &= ~bit; \
INP_WUNLOCK(inp); \
} while (0)

◆ OPTSET2

#define OPTSET2 (   bit,
  val 
)
Value:
do { \
INP_WLOCK(inp); \
if (val) \
inp->inp_flags2 |= bit; \
else \
inp->inp_flags2 &= ~bit; \
INP_WUNLOCK(inp); \
} while (0)

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ 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:

◆ ip_ctloutput()

◆ 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_mloopback()

static void ip_mloopback ( struct ifnet *  ifp,
const struct mbuf *  m,
int  hlen 
)
static

Definition at line 1571 of file ip_output.c.

References in_delayed_cksum(), and ip::ip_sum.

Referenced by ip_output().

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

◆ ip_output()

◆ ip_output_pfil()

static int ip_output_pfil ( struct mbuf **  mp,
struct ifnet *  ifp,
int  flags,
struct inpcb inp,
struct sockaddr_in dst,
int *  fibnum,
int *  error 
)
inlinestatic

Definition at line 112 of file ip_output.c.

References in_localip(), ip::ip_dst, IP_FORWARDING, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_len, and V_inet_pfil_head.

Referenced by ip_output().

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

◆ ip_output_send()

static int ip_output_send ( struct inpcb inp,
struct ifnet *  ifp,
struct mbuf *  m,
const struct sockaddr *  gw,
struct route *  ro,
bool  stamp_tag 
)
static

Definition at line 212 of file ip_output.c.

References inpcb::inp_flags2, INP_RATE_LIMIT_CHANGED, and inpcb::inp_snd_tag.

Referenced by ip_output().

Here is the caller graph for this function:

◆ rt_update_ro_flags()

static void rt_update_ro_flags ( struct route *  ro,
const struct nhop_object *  nh 
)
inlinestatic

Definition at line 296 of file ip_output.c.

Referenced by ip_output().

Here is the caller graph for this function:

Variable Documentation

◆ in_mcast_loop

int in_mcast_loop
extern

Definition at line 188 of file in_mcast.c.

Referenced by inp_findmoptions(), and ip_output().

◆ inetsw

struct protosw inetsw[]
extern