FreeBSD kernel IPv4 code
ip_carp.c File Reference
#include <sys/cdefs.h>
#include "opt_bpf.h"
#include "opt_inet.h"
#include "opt_inet6.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/devctl.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/module.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/taskqueue.h>
#include <sys/counter.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_llatbl.h>
#include <net/if_types.h>
#include <net/route.h>
#include <net/vnet.h>
#include <crypto/sha1.h>
Include dependency graph for ip_carp.c:

Go to the source code of this file.

Data Structures

struct  carp_softc
 
struct  carp_if
 

Macros

#define CARP_SENDAD_MAX_ERRORS   3
 
#define CARP_SENDAD_MIN_SUCCESS   3
 
#define CARP_HMAC_PAD   64
 
#define CIF_PROMISC   0x00000001
 
#define CARP_INET   0
 
#define CARP_INET6   1
 
#define V_carp_allow   VNET(carp_allow)
 
#define V_carp_dscp   VNET(carp_dscp)
 
#define V_carp_preempt   VNET(carp_preempt)
 
#define V_carp_log   VNET(carp_log)
 
#define V_carp_demotion   VNET(carp_demotion)
 
#define V_carp_senderr_adj   VNET(carp_senderr_adj)
 
#define V_carp_ifdown_adj   VNET(carp_ifdown_adj)
 
#define CARPSTATS_ADD(name, val)
 
#define CARPSTATS_INC(name)   CARPSTATS_ADD(name, 1)
 
#define CARP_LOCK_INIT(sc)
 
#define CARP_LOCK_DESTROY(sc)   mtx_destroy(&(sc)->sc_mtx)
 
#define CARP_LOCK_ASSERT(sc)   mtx_assert(&(sc)->sc_mtx, MA_OWNED)
 
#define CARP_LOCK(sc)   mtx_lock(&(sc)->sc_mtx)
 
#define CARP_UNLOCK(sc)   mtx_unlock(&(sc)->sc_mtx)
 
#define CIF_LOCK_INIT(cif)
 
#define CIF_LOCK_DESTROY(cif)   mtx_destroy(&(cif)->cif_mtx)
 
#define CIF_LOCK_ASSERT(cif)   mtx_assert(&(cif)->cif_mtx, MA_OWNED)
 
#define CIF_LOCK(cif)   mtx_lock(&(cif)->cif_mtx)
 
#define CIF_UNLOCK(cif)   mtx_unlock(&(cif)->cif_mtx)
 
#define CIF_FREE(cif)
 
#define CARP_LOG(...)
 
#define CARP_DEBUG(...)
 
#define IFNET_FOREACH_IFA(ifp, ifa)
 
#define CARP_FOREACH_IFA(sc, ifa)
 
#define IFNET_FOREACH_CARP(ifp, sc)
 
#define DEMOTE_ADVSKEW(sc)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static MALLOC_DEFINE (M_CARP, "CARP", "CARP addresses")
 
 VNET_DEFINE_STATIC (int, carp_allow)
 
 VNET_DEFINE_STATIC (int, carp_dscp)
 
 VNET_DEFINE_STATIC (int, carp_preempt)=0
 
 VNET_DEFINE_STATIC (int, carp_log)
 
 VNET_DEFINE_STATIC (int, carp_demotion)=0
 
 VNET_DEFINE_STATIC (int, carp_senderr_adj)
 
 VNET_DEFINE_STATIC (int, carp_ifdown_adj)
 
static int carp_allow_sysctl (SYSCTL_HANDLER_ARGS)
 
static int carp_dscp_sysctl (SYSCTL_HANDLER_ARGS)
 
static int carp_demote_adj_sysctl (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_NODE (_net_inet, IPPROTO_CARP, carp, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "CARP")
 
 SYSCTL_PROC (_net_inet_carp, OID_AUTO, allow, CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, 0, 0, carp_allow_sysctl, "I", "Accept incoming CARP packets")
 
 SYSCTL_PROC (_net_inet_carp, OID_AUTO, dscp, CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, 0, 0, carp_dscp_sysctl, "I", "DSCP value for carp packets")
 
 SYSCTL_INT (_net_inet_carp, OID_AUTO, preempt, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(carp_preempt), 0, "High-priority backup preemption mode")
 
 SYSCTL_INT (_net_inet_carp, OID_AUTO, log, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(carp_log), 0, "CARP log level")
 
 SYSCTL_PROC (_net_inet_carp, OID_AUTO, demotion, CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, 0, 0, carp_demote_adj_sysctl, "I", "Adjust demotion factor (skew of advskew)")
 
 SYSCTL_INT (_net_inet_carp, OID_AUTO, senderr_demotion_factor, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(carp_senderr_adj), 0, "Send error demotion factor adjustment")
 
 SYSCTL_INT (_net_inet_carp, OID_AUTO, ifdown_demotion_factor, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(carp_ifdown_adj), 0, "Interface down demotion factor adjustment")
 
 VNET_PCPUSTAT_DEFINE (struct carpstats, carpstats)
 
 VNET_PCPUSTAT_SYSINIT (carpstats)
 
 VNET_PCPUSTAT_SYSUNINIT (carpstats)
 
 SYSCTL_VNET_PCPUSTAT (_net_inet_carp, OID_AUTO, stats, struct carpstats, carpstats, "CARP statistics (struct carpstats, netinet/ip_carp.h)")
 
static void carp_input_c (struct mbuf *, struct carp_header *, sa_family_t)
 
static struct carp_softccarp_alloc (struct ifnet *)
 
static void carp_destroy (struct carp_softc *)
 
static struct carp_ifcarp_alloc_if (struct ifnet *)
 
static void carp_free_if (struct carp_if *)
 
static void carp_set_state (struct carp_softc *, int, const char *reason)
 
static void carp_sc_state (struct carp_softc *)
 
static void carp_setrun (struct carp_softc *, sa_family_t)
 
static void carp_master_down (void *)
 
static void carp_master_down_locked (struct carp_softc *, const char *reason)
 
static void carp_send_ad (void *)
 
static void carp_send_ad_locked (struct carp_softc *)
 
static void carp_addroute (struct carp_softc *)
 
static void carp_ifa_addroute (struct ifaddr *)
 
static void carp_delroute (struct carp_softc *)
 
static void carp_ifa_delroute (struct ifaddr *)
 
static void carp_send_ad_all (void *, int)
 
static void carp_demote_adj (int, char *)
 
static LIST_HEAD (carp_softc)
 
static void carp_hmac_generate (struct carp_softc *sc, uint32_t counter[2], unsigned char md[20])
 
static int carp_hmac_verify (struct carp_softc *sc, uint32_t counter[2], unsigned char md[20])
 
static int carp_source_is_self (struct mbuf *m, struct ifaddr *ifa, sa_family_t af)
 
static int carp_prepare_ad (struct mbuf *m, struct carp_softc *sc, struct carp_header *ch)
 
static void carp_send_ad_all (void *ctx __unused, int pending __unused)
 
static void carp_send_ad_error (struct carp_softc *sc, int error)
 
static struct ifaddr * carp_best_ifa (int af, struct ifnet *ifp)
 
int carp_master (struct ifaddr *ifa)
 
int carp_forus (struct ifnet *ifp, u_char *dhost)
 
static int carp_multicast_setup (struct carp_if *cif, sa_family_t sa)
 
static void carp_multicast_cleanup (struct carp_if *cif, sa_family_t sa)
 
int carp_output (struct ifnet *ifp, struct mbuf *m, const struct sockaddr *sa)
 
static void carp_grow_ifas (struct carp_softc *sc)
 
static void carp_carprcp (struct carpreq *carpr, struct carp_softc *sc, int priv)
 
int carp_ioctl (struct ifreq *ifr, u_long cmd, struct thread *td)
 
static int carp_get_vhid (struct ifaddr *ifa)
 
int carp_attach (struct ifaddr *ifa, int vhid)
 
void carp_detach (struct ifaddr *ifa, bool keep_cif)
 
static void carp_linkstate (struct ifnet *ifp)
 
static void carp_mod_cleanup (void)
 
static int carp_mod_load (void)
 
static int carp_modevent (module_t mod, int type, void *data)
 
 DECLARE_MODULE (carp, carp_mod, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY)
 

Variables

static int proto_reg [] = {-1, -1}
 
static moduledata_t carp_mod
 

Macro Definition Documentation

◆ CARP_DEBUG

#define CARP_DEBUG (   ...)
Value:
do { \
if (V_carp_log > 1) \
log(LOG_DEBUG, __VA_ARGS__); \
} while (0)
#define V_carp_log
Definition: ip_carp.c:203

Definition at line 284 of file ip_carp.c.

◆ CARP_FOREACH_IFA

#define CARP_FOREACH_IFA (   sc,
  ifa 
)
Value:
for (int _i = 0; \
_i < (sc)->sc_naddrs + (sc)->sc_naddrs6 && \
((ifa) = sc->sc_ifas[_i]) != NULL; \
++_i)
#define CARP_LOCK_ASSERT(sc)
Definition: ip_carp.c:262

Definition at line 293 of file ip_carp.c.

◆ CARP_HMAC_PAD

#define CARP_HMAC_PAD   64

Definition at line 122 of file ip_carp.c.

◆ CARP_INET

#define CARP_INET   0

Definition at line 151 of file ip_carp.c.

◆ CARP_INET6

#define CARP_INET6   1

Definition at line 152 of file ip_carp.c.

◆ CARP_LOCK

#define CARP_LOCK (   sc)    mtx_lock(&(sc)->sc_mtx)

Definition at line 263 of file ip_carp.c.

◆ CARP_LOCK_ASSERT

#define CARP_LOCK_ASSERT (   sc)    mtx_assert(&(sc)->sc_mtx, MA_OWNED)

Definition at line 262 of file ip_carp.c.

◆ CARP_LOCK_DESTROY

#define CARP_LOCK_DESTROY (   sc)    mtx_destroy(&(sc)->sc_mtx)

Definition at line 261 of file ip_carp.c.

◆ CARP_LOCK_INIT

#define CARP_LOCK_INIT (   sc)
Value:
mtx_init(&(sc)->sc_mtx, "carp_softc", \
NULL, MTX_DEF)

Definition at line 259 of file ip_carp.c.

◆ CARP_LOG

#define CARP_LOG (   ...)
Value:
do { \
if (V_carp_log > 0) \
log(LOG_INFO, "carp: " __VA_ARGS__); \
} while (0)

Definition at line 279 of file ip_carp.c.

◆ CARP_SENDAD_MAX_ERRORS

#define CARP_SENDAD_MAX_ERRORS   3

Definition at line 114 of file ip_carp.c.

◆ CARP_SENDAD_MIN_SUCCESS

#define CARP_SENDAD_MIN_SUCCESS   3

Definition at line 116 of file ip_carp.c.

◆ CARP_UNLOCK

#define CARP_UNLOCK (   sc)    mtx_unlock(&(sc)->sc_mtx)

Definition at line 264 of file ip_carp.c.

◆ CARPSTATS_ADD

#define CARPSTATS_ADD (   name,
  val 
)
Value:
counter_u64_add(VNET(carpstats)[offsetof(struct carpstats, name) / \
sizeof(uint64_t)], (val))

Definition at line 251 of file ip_carp.c.

◆ CARPSTATS_INC

#define CARPSTATS_INC (   name)    CARPSTATS_ADD(name, 1)

Definition at line 254 of file ip_carp.c.

◆ CIF_FREE

#define CIF_FREE (   cif)
Value:
do { \
CIF_LOCK(cif); \
if (TAILQ_EMPTY(&(cif)->cif_vrs)) \
carp_free_if(cif); \
CIF_UNLOCK(cif); \
} while (0)
#define CIF_UNLOCK(cif)
Definition: ip_carp.c:270

Definition at line 271 of file ip_carp.c.

◆ CIF_LOCK

#define CIF_LOCK (   cif)    mtx_lock(&(cif)->cif_mtx)

Definition at line 269 of file ip_carp.c.

◆ CIF_LOCK_ASSERT

#define CIF_LOCK_ASSERT (   cif)    mtx_assert(&(cif)->cif_mtx, MA_OWNED)

Definition at line 268 of file ip_carp.c.

◆ CIF_LOCK_DESTROY

#define CIF_LOCK_DESTROY (   cif)    mtx_destroy(&(cif)->cif_mtx)

Definition at line 267 of file ip_carp.c.

◆ CIF_LOCK_INIT

#define CIF_LOCK_INIT (   cif)
Value:
mtx_init(&(cif)->cif_mtx, "carp_if", \
NULL, MTX_DEF)

Definition at line 265 of file ip_carp.c.

◆ CIF_PROMISC

#define CIF_PROMISC   0x00000001

◆ CIF_UNLOCK

#define CIF_UNLOCK (   cif)    mtx_unlock(&(cif)->cif_mtx)

Definition at line 270 of file ip_carp.c.

◆ DEMOTE_ADVSKEW

#define DEMOTE_ADVSKEW (   sc)
Value:
(((sc)->sc_advskew + V_carp_demotion > CARP_MAXSKEW) ? \
CARP_MAXSKEW : \
(((sc)->sc_advskew + V_carp_demotion < 0) ? \
0 : ((sc)->sc_advskew + V_carp_demotion)))
#define V_carp_demotion
Definition: ip_carp.c:207
#define CARP_MAXSKEW
Definition: ip_carp.h:133

Definition at line 305 of file ip_carp.c.

◆ IFNET_FOREACH_CARP

#define IFNET_FOREACH_CARP (   ifp,
  sc 
)
Value:
KASSERT(mtx_owned(&ifp->if_carp->cif_mtx) || \
sx_xlocked(&carp_sx), ("cif_vrs not locked")); \
TAILQ_FOREACH((sc), &(ifp)->if_carp->cif_vrs, sc_list)

Definition at line 300 of file ip_carp.c.

◆ IFNET_FOREACH_IFA

#define IFNET_FOREACH_IFA (   ifp,
  ifa 
)
Value:
CK_STAILQ_FOREACH((ifa), &(ifp)->if_addrhead, ifa_link) \
if ((ifa)->ifa_carp != NULL)

Definition at line 289 of file ip_carp.c.

◆ V_carp_allow

#define V_carp_allow   VNET(carp_allow)

Definition at line 191 of file ip_carp.c.

◆ V_carp_demotion

#define V_carp_demotion   VNET(carp_demotion)

Definition at line 207 of file ip_carp.c.

◆ V_carp_dscp

#define V_carp_dscp   VNET(carp_dscp)

Definition at line 195 of file ip_carp.c.

◆ V_carp_ifdown_adj

#define V_carp_ifdown_adj   VNET(carp_ifdown_adj)

Definition at line 215 of file ip_carp.c.

◆ V_carp_log

#define V_carp_log   VNET(carp_log)

Definition at line 203 of file ip_carp.c.

◆ V_carp_preempt

#define V_carp_preempt   VNET(carp_preempt)

Definition at line 199 of file ip_carp.c.

◆ V_carp_senderr_adj

#define V_carp_senderr_adj   VNET(carp_senderr_adj)

Definition at line 211 of file ip_carp.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ carp_addroute()

static void carp_addroute ( struct carp_softc sc)
static

Definition at line 1062 of file ip_carp.c.

References CARP_FOREACH_IFA, and carp_ifa_addroute().

Referenced by carp_master_down_locked().

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

◆ carp_alloc()

static struct carp_softc * carp_alloc ( struct ifnet *  ifp)
static

◆ carp_alloc_if()

static struct carp_if * carp_alloc_if ( struct ifnet *  ifp)
static

Definition at line 1669 of file ip_carp.c.

References CIF_LOCK_INIT, and CIF_PROMISC.

Referenced by carp_alloc().

Here is the caller graph for this function:

◆ carp_allow_sysctl()

static int carp_allow_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2118 of file ip_carp.c.

References CARP_LOCK, carp_sc_state(), CARP_UNLOCK, carp_softc::sc_carpdev, and V_carp_allow.

Here is the call graph for this function:

◆ carp_attach()

int carp_attach ( struct ifaddr *  ifa,
int  vhid 
)

Definition at line 1910 of file ip_carp.c.

References carp_grow_ifas(), CARP_LOCK, carp_multicast_setup(), carp_sc_state(), CARP_UNLOCK, CIF_FREE, IFNET_FOREACH_CARP, carp_softc::sc_ifas, carp_softc::sc_ifasiz, carp_softc::sc_naddrs, carp_softc::sc_naddrs6, and carp_softc::sc_vhid.

Referenced by carp_mod_load().

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

◆ carp_best_ifa()

static struct ifaddr * carp_best_ifa ( int  af,
struct ifnet *  ifp 
)
static

Definition at line 900 of file ip_carp.c.

Referenced by carp_send_ad_locked().

Here is the caller graph for this function:

◆ carp_carprcp()

static void carp_carprcp ( struct carpreq carpr,
struct carp_softc sc,
int  priv 
)
static

◆ carp_delroute()

static void carp_delroute ( struct carp_softc sc)
static

Definition at line 1093 of file ip_carp.c.

References CARP_FOREACH_IFA, and carp_ifa_delroute().

Referenced by carp_input_c(), and carp_ioctl().

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

◆ carp_demote_adj()

static void carp_demote_adj ( int  adj,
char *  reason 
)
static

Definition at line 2110 of file ip_carp.c.

References CARP_LOG, and V_carp_demotion.

Referenced by carp_demote_adj_sysctl(), carp_destroy(), carp_mod_load(), carp_sc_state(), and carp_send_ad_error().

Here is the caller graph for this function:

◆ carp_demote_adj_sysctl()

static int carp_demote_adj_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2163 of file ip_carp.c.

References carp_demote_adj(), and V_carp_demotion.

Here is the call graph for this function:

◆ carp_destroy()

static void carp_destroy ( struct carp_softc sc)
static

Definition at line 1636 of file ip_carp.c.

References carp_demote_adj(), CARP_LOCK_DESTROY, CARP_UNLOCK, CIF_LOCK, CIF_UNLOCK, carp_softc::sc_ad_tmo, carp_softc::sc_carpdev, carp_softc::sc_ifas, carp_softc::sc_suppress, and V_carp_ifdown_adj.

Referenced by carp_detach().

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

◆ carp_detach()

void carp_detach ( struct ifaddr *  ifa,
bool  keep_cif 
)

Definition at line 1986 of file ip_carp.c.

References carp_destroy(), carp_ifa_delroute(), CARP_LOCK, carp_multicast_cleanup(), carp_sc_state(), CARP_UNLOCK, CIF_FREE, carp_softc::sc_ifas, carp_softc::sc_naddrs, and carp_softc::sc_naddrs6.

Referenced by carp_mod_load().

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

◆ carp_dscp_sysctl()

static int carp_dscp_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2145 of file ip_carp.c.

References V_carp_dscp.

◆ carp_forus()

int carp_forus ( struct ifnet *  ifp,
u_char *  dhost 
)

Definition at line 1243 of file ip_carp.c.

References CIF_LOCK, CIF_UNLOCK, IFNET_FOREACH_CARP, carp_softc::MASTER, carp_softc::sc_addr, and carp_softc::sc_state.

Referenced by carp_mod_load().

Here is the caller graph for this function:

◆ carp_free_if()

static void carp_free_if ( struct carp_if cif)
static

Definition at line 1695 of file ip_carp.c.

References CIF_LOCK_ASSERT, CIF_LOCK_DESTROY, and CIF_PROMISC.

◆ carp_get_vhid()

static int carp_get_vhid ( struct ifaddr *  ifa)
static

Definition at line 1900 of file ip_carp.c.

Referenced by carp_mod_load().

Here is the caller graph for this function:

◆ carp_grow_ifas()

static void carp_grow_ifas ( struct carp_softc sc)
static

Definition at line 1622 of file ip_carp.c.

References CARP_LOCK, CARP_UNLOCK, carp_softc::sc_ifas, and carp_softc::sc_ifasiz.

Referenced by carp_attach().

Here is the caller graph for this function:

◆ carp_hmac_generate()

static void carp_hmac_generate ( struct carp_softc sc,
uint32_t  counter[2],
unsigned char  md[20] 
)
static

Definition at line 414 of file ip_carp.c.

References CARP_LOCK_ASSERT, carp_softc::sc_counter, carp_softc::sc_pad, and carp_softc::sc_sha1.

Referenced by carp_hmac_verify(), and carp_prepare_ad().

Here is the caller graph for this function:

◆ carp_hmac_verify()

static int carp_hmac_verify ( struct carp_softc sc,
uint32_t  counter[2],
unsigned char  md[20] 
)
static

Definition at line 435 of file ip_carp.c.

References carp_hmac_generate(), and CARP_LOCK_ASSERT.

Referenced by carp_input_c().

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

◆ carp_ifa_addroute()

static void carp_ifa_addroute ( struct ifaddr *  ifa)
static

Definition at line 1071 of file ip_carp.c.

References ifatoia, and in_addprefix().

Referenced by carp_addroute().

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

◆ carp_ifa_delroute()

static void carp_ifa_delroute ( struct ifaddr *  ifa)
static

Definition at line 1102 of file ip_carp.c.

References ifatoia, and in_scrubprefix().

Referenced by carp_delroute(), and carp_detach().

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

◆ carp_input_c()

◆ carp_ioctl()

◆ carp_linkstate()

static void carp_linkstate ( struct ifnet *  ifp)
static

Definition at line 2066 of file ip_carp.c.

References CARP_LOCK, carp_sc_state(), CARP_UNLOCK, CIF_LOCK, CIF_UNLOCK, and IFNET_FOREACH_CARP.

Referenced by carp_mod_load().

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

◆ carp_master()

int carp_master ( struct ifaddr *  ifa)

Definition at line 1124 of file ip_carp.c.

References carp_softc::MASTER, and carp_softc::sc_state.

Referenced by carp_mod_load().

Here is the caller graph for this function:

◆ carp_master_down()

static void carp_master_down ( void *  v)
static

Definition at line 1270 of file ip_carp.c.

References CARP_LOCK_ASSERT, carp_master_down_locked(), CARP_UNLOCK, carp_softc::sc_carpdev, and carp_softc::sc_state.

Referenced by carp_setrun().

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

◆ carp_master_down_locked()

static void carp_master_down_locked ( struct carp_softc sc,
const char *  reason 
)
static

Definition at line 1289 of file ip_carp.c.

References carp_addroute(), CARP_LOCK_ASSERT, carp_send_ad_locked(), carp_set_state(), carp_setrun(), carp_softc::sc_carpdev, carp_softc::sc_state, and carp_softc::sc_vhid.

Referenced by carp_input_c(), carp_ioctl(), and carp_master_down().

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

◆ carp_mod_cleanup()

static void carp_mod_cleanup ( void  )
static

Definition at line 2206 of file ip_carp.c.

References carp_attach_p, carp_demote_adj_p, carp_detach_p, carp_forus_p, carp_get_vhid_p, CARP_INET, CARP_INET6, carp_ioctl_p, carp_linkstate_p, carp_master_p, carp_output_p, ipproto_unregister(), and proto_reg.

Referenced by carp_mod_load(), and carp_modevent().

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

◆ carp_mod_load()

◆ carp_modevent()

static int carp_modevent ( module_t  mod,
int  type,
void *  data 
)
static

Definition at line 2296 of file ip_carp.c.

References carp_mod_cleanup(), and carp_mod_load().

Here is the call graph for this function:

◆ carp_multicast_cleanup()

static void carp_multicast_cleanup ( struct carp_if cif,
sa_family_t  sa 
)
static

Definition at line 1486 of file ip_carp.c.

References in_mfilter::imf_inm, in_leavegroup(), ip_mfilter_first(), ip_mfilter_free(), and ip_mfilter_remove().

Referenced by carp_detach().

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

◆ carp_multicast_setup()

static int carp_multicast_setup ( struct carp_if cif,
sa_family_t  sa 
)
static

Definition at line 1386 of file ip_carp.c.

References CARP_DFLTTL, in_mfilter::imf_inm, in_joingroup(), ip_mfilter_alloc(), ip_mfilter_first(), ip_mfilter_free(), ip_mfilter_init(), ip_mfilter_insert(), and in_addr::s_addr.

Referenced by carp_attach().

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

◆ carp_output()

int carp_output ( struct ifnet *  ifp,
struct mbuf *  m,
const struct sockaddr *  sa 
)

Definition at line 1527 of file ip_carp.c.

References carp_softc::sc_vhid.

Referenced by carp_mod_load().

Here is the caller graph for this function:

◆ carp_prepare_ad()

static int carp_prepare_ad ( struct mbuf *  m,
struct carp_softc sc,
struct carp_header ch 
)
static

Definition at line 783 of file ip_carp.c.

References carp_header::carp_counter, carp_hmac_generate(), carp_header::carp_md, CARPSTATS_INC, carp_softc::sc_counter, and carp_softc::sc_init_counter.

Referenced by carp_send_ad_locked().

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

◆ carp_sc_state()

static void carp_sc_state ( struct carp_softc sc)
static

Definition at line 2080 of file ip_carp.c.

References carp_demote_adj(), CARP_LOCK_ASSERT, carp_set_state(), carp_setrun(), carp_softc::INIT, carp_softc::sc_ad_tmo, carp_softc::sc_carpdev, carp_softc::sc_suppress, V_carp_allow, and V_carp_ifdown_adj.

Referenced by carp_allow_sysctl(), carp_attach(), carp_detach(), and carp_linkstate().

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

◆ carp_send_ad()

static void carp_send_ad ( void *  v)
static

Definition at line 839 of file ip_carp.c.

References CARP_LOCK_ASSERT, carp_send_ad_locked(), CARP_UNLOCK, and carp_softc::sc_carpdev.

Referenced by carp_send_ad_locked(), and carp_setrun().

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

◆ carp_send_ad_all() [1/2]

static void carp_send_ad_all ( void *  ,
int   
)
static

◆ carp_send_ad_all() [2/2]

static void carp_send_ad_all ( void *ctx  __unused,
int pending  __unused 
)
static

Definition at line 818 of file ip_carp.c.

References CARP_LOCK, carp_send_ad_locked(), CARP_UNLOCK, carp_softc::sc_carpdev, and carp_softc::sc_state.

Here is the call graph for this function:

◆ carp_send_ad_error()

static void carp_send_ad_error ( struct carp_softc sc,
int  error 
)
static

Definition at line 854 of file ip_carp.c.

References carp_demote_adj(), CARP_SENDAD_MAX_ERRORS, CARP_SENDAD_MIN_SUCCESS, carp_softc::sc_carpdev, carp_softc::sc_sendad_errors, carp_softc::sc_sendad_success, and V_carp_senderr_adj.

Referenced by carp_send_ad_locked().

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

◆ carp_send_ad_locked()

◆ carp_set_state()

static void carp_set_state ( struct carp_softc sc,
int  state,
const char *  reason 
)
static

Definition at line 2044 of file ip_carp.c.

References CARP_LOCK_ASSERT, CARP_LOG, CARP_STATES, carp_softc::sc_carpdev, carp_softc::sc_state, carp_softc::sc_vhid, and state.

Referenced by carp_input_c(), carp_ioctl(), carp_master_down_locked(), carp_sc_state(), and carp_setrun().

Here is the caller graph for this function:

◆ carp_setrun()

static void carp_setrun ( struct carp_softc sc,
sa_family_t  af 
)
static

◆ carp_source_is_self()

static int carp_source_is_self ( struct mbuf *  m,
struct ifaddr *  ifa,
sa_family_t  af 
)
static

Definition at line 616 of file ip_carp.c.

References ifatoia, ip6_hdr::ip6_src, and in_addr::s_addr.

Referenced by carp_input_c().

Here is the caller graph for this function:

◆ DECLARE_MODULE()

DECLARE_MODULE ( carp  ,
carp_mod  ,
SI_SUB_PROTO_DOMAIN  ,
SI_ORDER_ANY   
)

◆ LIST_HEAD()

static LIST_HEAD ( carp_softc  )
static

Definition at line 333 of file ip_carp.c.

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_CARP  ,
"CARP"  ,
"CARP addresses"   
)
static

◆ SYSCTL_INT() [1/4]

SYSCTL_INT ( _net_inet_carp  ,
OID_AUTO  ,
ifdown_demotion_factor  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcarp_ifdown_adj,
,
"Interface down demotion factor adjustment"   
)

◆ SYSCTL_INT() [2/4]

SYSCTL_INT ( _net_inet_carp  ,
OID_AUTO  ,
log  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcarp_log,
,
"CARP log level"   
)

◆ SYSCTL_INT() [3/4]

SYSCTL_INT ( _net_inet_carp  ,
OID_AUTO  ,
preempt  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcarp_preempt,
,
"High-priority backup preemption mode"   
)

◆ SYSCTL_INT() [4/4]

SYSCTL_INT ( _net_inet_carp  ,
OID_AUTO  ,
senderr_demotion_factor  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcarp_senderr_adj,
,
"Send error demotion factor adjustment"   
)

◆ SYSCTL_NODE()

SYSCTL_NODE ( _net_inet  ,
IPPROTO_CARP  ,
carp  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"CARP"   
)

◆ SYSCTL_PROC() [1/3]

SYSCTL_PROC ( _net_inet_carp  ,
OID_AUTO  ,
allow  ,
CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
,
carp_allow_sysctl  ,
"I"  ,
"Accept incoming CARP packets"   
)

◆ SYSCTL_PROC() [2/3]

SYSCTL_PROC ( _net_inet_carp  ,
OID_AUTO  ,
demotion  ,
CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
,
carp_demote_adj_sysctl  ,
"I"  ,
"Adjust demotion factor (skew of advskew)"   
)

◆ SYSCTL_PROC() [3/3]

SYSCTL_PROC ( _net_inet_carp  ,
OID_AUTO  ,
dscp  ,
CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
,
carp_dscp_sysctl  ,
"I"  ,
"DSCP value for carp packets"   
)

◆ SYSCTL_VNET_PCPUSTAT()

SYSCTL_VNET_PCPUSTAT ( _net_inet_carp  ,
OID_AUTO  ,
stats  ,
struct carpstats  ,
carpstats  ,
"CARP statistics (struct carpstats, netinet/ip_carp.h)"   
)

◆ VNET_DEFINE_STATIC() [1/7]

VNET_DEFINE_STATIC ( int  ,
carp_allow   
)

◆ VNET_DEFINE_STATIC() [2/7]

VNET_DEFINE_STATIC ( int  ,
carp_demotion   
)
pure virtual

◆ VNET_DEFINE_STATIC() [3/7]

VNET_DEFINE_STATIC ( int  ,
carp_dscp   
)

◆ VNET_DEFINE_STATIC() [4/7]

VNET_DEFINE_STATIC ( int  ,
carp_ifdown_adj   
)

◆ VNET_DEFINE_STATIC() [5/7]

VNET_DEFINE_STATIC ( int  ,
carp_log   
)

◆ VNET_DEFINE_STATIC() [6/7]

VNET_DEFINE_STATIC ( int  ,
carp_preempt   
)
pure virtual

◆ VNET_DEFINE_STATIC() [7/7]

VNET_DEFINE_STATIC ( int  ,
carp_senderr_adj   
)

◆ VNET_PCPUSTAT_DEFINE()

VNET_PCPUSTAT_DEFINE ( struct carpstats  ,
carpstats   
)

◆ VNET_PCPUSTAT_SYSINIT()

VNET_PCPUSTAT_SYSINIT ( carpstats  )

◆ VNET_PCPUSTAT_SYSUNINIT()

VNET_PCPUSTAT_SYSUNINIT ( carpstats  )

Variable Documentation

◆ carp_mod

moduledata_t carp_mod
static
Initial value:
= {
"carp",
0
}
static int carp_modevent(module_t mod, int type, void *data)
Definition: ip_carp.c:2296

Definition at line 2319 of file ip_carp.c.

◆ proto_reg

int proto_reg[] = {-1, -1}
static

Definition at line 153 of file ip_carp.c.

Referenced by carp_mod_cleanup(), and carp_mod_load().