FreeBSD kernel IPv4 code
in_gif.c File Reference
#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_inet6.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/jail.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/route.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/in_var.h>
#include <netinet/ip_encap.h>
#include <netinet/ip_ecn.h>
#include <netinet/in_fib.h>
#include <net/if_gif.h>
Include dependency graph for in_gif.c:

Go to the source code of this file.

Macros

#define GIF_TTL   30
 
#define V_ip_gif_ttl   VNET(ip_gif_ttl)
 
#define V_ipv4_hashtbl   VNET(ipv4_hashtbl)
 
#define V_ipv4_srchashtbl   VNET(ipv4_srchashtbl)
 
#define V_ipv4_list   VNET(ipv4_list)
 
#define GIF_HASH(src, dst)
 
#define GIF_SRCHASH(src)
 
#define GIF_HASH_SC(sc)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 VNET_DEFINE_STATIC (int, ip_gif_ttl)
 
 SYSCTL_INT (_net_inet_ip, IPCTL_GIF_TTL, gifttl, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ip_gif_ttl), 0, "Default TTL value for encapsulated packets")
 
 VNET_DEFINE_STATIC (struct gif_list *, ipv4_hashtbl)
 
 VNET_DEFINE_STATIC (struct gif_list *, ipv4_srchashtbl)
 
 VNET_DEFINE_STATIC (struct gif_list, ipv4_list)
 
static uint32_t in_gif_hashval (in_addr_t src, in_addr_t dst)
 
static int in_gif_checkdup (const struct gif_softc *sc, in_addr_t src, in_addr_t dst)
 
static void in_gif_set_running (struct gif_softc *sc)
 
static void in_gif_srcaddr (void *arg __unused, const struct sockaddr *sa, int event __unused)
 
static void in_gif_attach (struct gif_softc *sc)
 
int in_gif_setopts (struct gif_softc *sc, u_int options)
 
int in_gif_ioctl (struct gif_softc *sc, u_long cmd, caddr_t data)
 
int in_gif_output (struct ifnet *ifp, struct mbuf *m, int proto, uint8_t ecn)
 
static int in_gif_input (struct mbuf *m, int off, int proto, void *arg)
 
static int in_gif_lookup (const struct mbuf *m, int off, int proto, void **arg)
 
void in_gif_init (void)
 
void in_gif_uninit (void)
 

Variables

static const struct srcaddrtabipv4_srcaddrtab
 
struct {
   const struct encap_config   encap
 
   const struct encaptab *   cookie
 
ipv4_encap_cfg []
 

Macro Definition Documentation

◆ GIF_HASH

#define GIF_HASH (   src,
  dst 
)
Value:
in_gif_hashval((src), (dst)) & (GIF_HASH_SIZE - 1)])
#define V_ipv4_hashtbl
Definition: in_gif.c:87

Definition at line 91 of file in_gif.c.

◆ GIF_HASH_SC

#define GIF_HASH_SC (   sc)
Value:
GIF_HASH((sc)->gif_iphdr->ip_src.s_addr,\
(sc)->gif_iphdr->ip_dst.s_addr)
#define GIF_HASH(src, dst)
Definition: in_gif.c:91

Definition at line 95 of file in_gif.c.

◆ GIF_SRCHASH

#define GIF_SRCHASH (   src)
Value:
fnv_32_buf(&(src), sizeof(src), FNV1_32_INIT) & (GIF_HASH_SIZE - 1)])
#define V_ipv4_srchashtbl
Definition: in_gif.c:88

Definition at line 93 of file in_gif.c.

◆ GIF_TTL

#define GIF_TTL   30

Definition at line 74 of file in_gif.c.

◆ V_ip_gif_ttl

#define V_ip_gif_ttl   VNET(ip_gif_ttl)

Definition at line 76 of file in_gif.c.

◆ V_ipv4_hashtbl

#define V_ipv4_hashtbl   VNET(ipv4_hashtbl)

Definition at line 87 of file in_gif.c.

◆ V_ipv4_list

#define V_ipv4_list   VNET(ipv4_list)

Definition at line 89 of file in_gif.c.

◆ V_ipv4_srchashtbl

#define V_ipv4_srchashtbl   VNET(ipv4_srchashtbl)

Definition at line 88 of file in_gif.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ in_gif_attach()

static void in_gif_attach ( struct gif_softc *  sc)
static

Definition at line 165 of file in_gif.c.

References GIF_HASH_SC, GIF_SRCHASH, and V_ipv4_list.

Referenced by in_gif_ioctl(), and in_gif_setopts().

Here is the caller graph for this function:

◆ in_gif_checkdup()

static int in_gif_checkdup ( const struct gif_softc *  sc,
in_addr_t  src,
in_addr_t  dst 
)
static

Definition at line 107 of file in_gif.c.

References GIF_HASH.

Referenced by in_gif_ioctl().

Here is the caller graph for this function:

◆ in_gif_hashval()

static uint32_t in_gif_hashval ( in_addr_t  src,
in_addr_t  dst 
)
static

Definition at line 98 of file in_gif.c.

◆ in_gif_init()

void in_gif_init ( void  )

Definition at line 433 of file in_gif.c.

References cookie, encap, in_gif_srcaddr(), ip_encap_attach(), ip_encap_register_srcaddr(), ipv4_encap_cfg, and ipv4_srcaddrtab.

Here is the call graph for this function:

◆ in_gif_input()

static int in_gif_input ( struct mbuf *  m,
int  off,
int  proto,
void *  arg 
)
static

Definition at line 313 of file in_gif.c.

References ip::ip_tos, and KMOD_IPSTAT_INC.

◆ in_gif_ioctl()

int in_gif_ioctl ( struct gif_softc *  sc,
u_long  cmd,
caddr_t  data 
)

◆ in_gif_lookup()

static int in_gif_lookup ( const struct mbuf *  m,
int  off,
int  proto,
void **  arg 
)
static

Definition at line 340 of file in_gif.c.

References ENCAP_DRV_LOOKUP, fib4_check_urpf(), GIF_HASH, ip::ip_dst, in_addr::s_addr, V_ipv4_hashtbl, and V_ipv4_list.

Here is the call graph for this function:

◆ in_gif_output()

int in_gif_output ( struct ifnet *  ifp,
struct mbuf *  m,
int  proto,
uint8_t  ecn 
)

Definition at line 274 of file in_gif.c.

References ip::ip_len, ip_output(), ip::ip_p, ip::ip_tos, ip::ip_ttl, and V_ip_gif_ttl.

Here is the call graph for this function:

◆ in_gif_set_running()

static void in_gif_set_running ( struct gif_softc *  sc)
static

Definition at line 130 of file in_gif.c.

References in_localip().

Referenced by in_gif_ioctl(), and in_gif_srcaddr().

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

◆ in_gif_setopts()

int in_gif_setopts ( struct gif_softc *  sc,
u_int  options 
)

Definition at line 178 of file in_gif.c.

References in_gif_attach().

Here is the call graph for this function:

◆ in_gif_srcaddr()

static void in_gif_srcaddr ( void *arg  __unused,
const struct sockaddr *  sa,
int event  __unused 
)
static

Definition at line 145 of file in_gif.c.

References GIF_SRCHASH, in_gif_set_running(), in_addr::s_addr, sockaddr_in::sin_addr, and V_ipv4_hashtbl.

Referenced by in_gif_init().

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

◆ in_gif_uninit()

void in_gif_uninit ( void  )

Definition at line 448 of file in_gif.c.

References cookie, ip_encap_detach(), ip_encap_unregister_srcaddr(), ipv4_encap_cfg, ipv4_srcaddrtab, V_ipv4_hashtbl, and V_ipv4_srchashtbl.

Here is the call graph for this function:

◆ SYSCTL_INT()

SYSCTL_INT ( _net_inet_ip  ,
IPCTL_GIF_TTL  ,
gifttl  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEip_gif_ttl,
,
"Default TTL value for encapsulated packets"   
)

◆ VNET_DEFINE_STATIC() [1/4]

VNET_DEFINE_STATIC ( int  ,
ip_gif_ttl   
)

◆ VNET_DEFINE_STATIC() [2/4]

VNET_DEFINE_STATIC ( struct gif_list *  ,
ipv4_hashtbl   
)

◆ VNET_DEFINE_STATIC() [3/4]

VNET_DEFINE_STATIC ( struct gif_list *  ,
ipv4_srchashtbl   
)

◆ VNET_DEFINE_STATIC() [4/4]

VNET_DEFINE_STATIC ( struct gif_list  ,
ipv4_list   
)

Variable Documentation

◆ cookie

◆ encap

const struct encap_config encap

Definition at line 395 of file in_gif.c.

Referenced by in_gif_init().

◆ 

struct { ... } ipv4_encap_cfg[]

Referenced by in_gif_init(), and in_gif_uninit().

◆ ipv4_srcaddrtab

const struct srcaddrtab* ipv4_srcaddrtab
static

Definition at line 393 of file in_gif.c.

Referenced by in_gif_init(), in_gif_uninit(), and srcaddr_change_event().