FreeBSD kernel IPv4 code
ip_encap.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/eventhandler.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <netinet/in.h>
#include <netinet/ip_var.h>
#include <netinet/ip_encap.h>
Include dependency graph for ip_encap.c:

Go to the source code of this file.

Data Structures

struct  encaptab
 
struct  srcaddrtab
 

Macros

#define ENCAP_WLOCK()   mtx_lock(&encapmtx)
 
#define ENCAP_WUNLOCK()   mtx_unlock(&encapmtx)
 
#define ENCAP_RLOCK_TRACKER   struct epoch_tracker encap_et
 
#define ENCAP_RLOCK()   NET_EPOCH_ENTER(encap_et)
 
#define ENCAP_RUNLOCK()   NET_EPOCH_EXIT(encap_et)
 
#define ENCAP_WAIT()   NET_EPOCH_WAIT()
 
#define SRCADDR_WLOCK()   mtx_lock(&srcaddrmtx)
 
#define SRCADDR_WUNLOCK()   mtx_unlock(&srcaddrmtx)
 
#define SRCADDR_RLOCK_TRACKER   struct epoch_tracker srcaddr_et
 
#define SRCADDR_RLOCK()    epoch_enter_preempt(net_epoch_preempt, &srcaddr_et)
 
#define SRCADDR_RUNLOCK()    epoch_exit_preempt(net_epoch_preempt, &srcaddr_et)
 
#define SRCADDR_WAIT()   epoch_wait_preempt(net_epoch_preempt)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static MALLOC_DEFINE (M_NETADDR, "encap_export_host", "Export host address structure")
 
 CK_LIST_HEAD (encaptab_head, encaptab)
 
 CK_LIST_HEAD (srcaddrtab_head, srcaddrtab)
 
 MTX_SYSINIT (encapmtx, &encapmtx, "encapmtx", MTX_DEF)
 
 MTX_SYSINIT (srcaddrmtx, &srcaddrmtx, "srcaddrmtx", MTX_DEF)
 
static void srcaddr_change_event (void *arg __unused, struct ifnet *ifp, struct ifaddr *ifa, int event)
 
 EVENTHANDLER_DEFINE (ifaddr_event_ext, srcaddr_change_event, NULL, 0)
 
static struct srcaddrtabencap_register_srcaddr (struct srcaddrtab_head *head, encap_srcaddr_t func, void *arg, int mflags)
 
static int encap_unregister_srcaddr (struct srcaddrtab_head *head, const struct srcaddrtab *cookie)
 
static struct encaptabencap_attach (struct encaptab_head *head, const struct encap_config *cfg, void *arg, int mflags)
 
static int encap_detach (struct encaptab_head *head, const struct encaptab *cookie)
 
static int encap_input (struct encaptab_head *head, struct mbuf *m, int off, int proto)
 

Variables

static struct mtx encapmtx srcaddrmtx
 

Macro Definition Documentation

◆ ENCAP_RLOCK

#define ENCAP_RLOCK ( )    NET_EPOCH_ENTER(encap_et)

Definition at line 128 of file ip_encap.c.

◆ ENCAP_RLOCK_TRACKER

#define ENCAP_RLOCK_TRACKER   struct epoch_tracker encap_et

Definition at line 127 of file ip_encap.c.

◆ ENCAP_RUNLOCK

#define ENCAP_RUNLOCK ( )    NET_EPOCH_EXIT(encap_et)

Definition at line 129 of file ip_encap.c.

◆ ENCAP_WAIT

#define ENCAP_WAIT ( )    NET_EPOCH_WAIT()

Definition at line 130 of file ip_encap.c.

◆ ENCAP_WLOCK

#define ENCAP_WLOCK ( )    mtx_lock(&encapmtx)

Definition at line 125 of file ip_encap.c.

◆ ENCAP_WUNLOCK

#define ENCAP_WUNLOCK ( )    mtx_unlock(&encapmtx)

Definition at line 126 of file ip_encap.c.

◆ SRCADDR_RLOCK

#define SRCADDR_RLOCK ( )     epoch_enter_preempt(net_epoch_preempt, &srcaddr_et)

Definition at line 135 of file ip_encap.c.

◆ SRCADDR_RLOCK_TRACKER

#define SRCADDR_RLOCK_TRACKER   struct epoch_tracker srcaddr_et

Definition at line 134 of file ip_encap.c.

◆ SRCADDR_RUNLOCK

#define SRCADDR_RUNLOCK ( )     epoch_exit_preempt(net_epoch_preempt, &srcaddr_et)

Definition at line 137 of file ip_encap.c.

◆ SRCADDR_WAIT

#define SRCADDR_WAIT ( )    epoch_wait_preempt(net_epoch_preempt)

Definition at line 139 of file ip_encap.c.

◆ SRCADDR_WLOCK

#define SRCADDR_WLOCK ( )    mtx_lock(&srcaddrmtx)

Definition at line 132 of file ip_encap.c.

◆ SRCADDR_WUNLOCK

#define SRCADDR_WUNLOCK ( )    mtx_unlock(&srcaddrmtx)

Definition at line 133 of file ip_encap.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ CK_LIST_HEAD() [1/2]

CK_LIST_HEAD ( encaptab_head  ,
encaptab   
)

◆ CK_LIST_HEAD() [2/2]

CK_LIST_HEAD ( srcaddrtab_head  ,
srcaddrtab   
)

◆ encap_attach()

static struct encaptab * encap_attach ( struct encaptab_head *  head,
const struct encap_config cfg,
void *  arg,
int  mflags 
)
static

◆ encap_detach()

static int encap_detach ( struct encaptab_head *  head,
const struct encaptab cookie 
)
static

Definition at line 273 of file ip_encap.c.

References cookie, ENCAP_WAIT, ENCAP_WLOCK, and ENCAP_WUNLOCK.

◆ encap_input()

static int encap_input ( struct encaptab_head *  head,
struct mbuf *  m,
int  off,
int  proto 
)
static

Definition at line 292 of file ip_encap.c.

References ENCAP_DRV_LOOKUP, ENCAP_RLOCK, ENCAP_RLOCK_TRACKER, and ENCAP_RUNLOCK.

◆ encap_register_srcaddr()

static struct srcaddrtab * encap_register_srcaddr ( struct srcaddrtab_head *  head,
encap_srcaddr_t  func,
void *  arg,
int  mflags 
)
static

Definition at line 186 of file ip_encap.c.

References SRCADDR_WLOCK, and SRCADDR_WUNLOCK.

◆ encap_unregister_srcaddr()

static int encap_unregister_srcaddr ( struct srcaddrtab_head *  head,
const struct srcaddrtab cookie 
)
static

Definition at line 216 of file ip_encap.c.

References cookie, SRCADDR_WAIT, SRCADDR_WLOCK, and SRCADDR_WUNLOCK.

◆ EVENTHANDLER_DEFINE()

EVENTHANDLER_DEFINE ( ifaddr_event_ext  ,
srcaddr_change_event  ,
NULL  ,
 
)

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_NETADDR  ,
"encap_export_host"  ,
"Export host address structure"   
)
static

◆ MTX_SYSINIT() [1/2]

MTX_SYSINIT ( encapmtx  ,
encapmtx,
"encapmtx"  ,
MTX_DEF   
)

◆ MTX_SYSINIT() [2/2]

MTX_SYSINIT ( srcaddrmtx  ,
srcaddrmtx,
"srcaddrmtx"  ,
MTX_DEF   
)

◆ srcaddr_change_event()

static void srcaddr_change_event ( void *arg  __unused,
struct ifnet *  ifp,
struct ifaddr *  ifa,
int  event 
)
static

Definition at line 151 of file ip_encap.c.

References ipv4_srcaddrtab, SRCADDR_RLOCK, SRCADDR_RLOCK_TRACKER, and SRCADDR_RUNLOCK.

Variable Documentation

◆ srcaddrmtx

struct mtx encapmtx srcaddrmtx
static

Definition at line 122 of file ip_encap.c.