Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/route_ctl.c
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
#include <net/route/nhop_var.h> | #include <net/route/nhop_var.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet6/scope6_var.h> | #include <netinet6/scope6_var.h> | ||||
#include <netinet6/in6_var.h> | #include <netinet6/in6_var.h> | ||||
#define DEBUG_MOD_NAME route_ctl | #define DEBUG_MOD_NAME route_ctl | ||||
#define DEBUG_MAX_LEVEL LOG_DEBUG | #define DEBUG_MAX_LEVEL LOG_DEBUG | ||||
#include <net/route/route_debug.h> | #include <net/route/route_debug.h> | ||||
_DECLARE_DEBUG(LOG_INFO); | _DECLARE_DEBUG(LOG_DEBUG3); | ||||
/* | /* | ||||
* This file contains control plane routing tables functions. | * This file contains control plane routing tables functions. | ||||
* | * | ||||
* All functions assumes they are called in net epoch. | * All functions assumes they are called in net epoch. | ||||
*/ | */ | ||||
union sockaddr_union { | union sockaddr_union { | ||||
▲ Show 20 Lines • Show All 1,516 Lines • ▼ Show 20 Lines | case AF_INET: | ||||
return ("inet"); | return ("inet"); | ||||
case AF_INET6: | case AF_INET6: | ||||
return ("inet6"); | return ("inet6"); | ||||
case AF_LINK: | case AF_LINK: | ||||
return ("link"); | return ("link"); | ||||
} | } | ||||
return ("unknown"); | return ("unknown"); | ||||
} | } | ||||
CK_STAILQ_HEAD(rib_event_bridge_head, rib_event_bridge); | |||||
static struct rib_event_bridge_head bridge_head; | |||||
glebius: Why not static? | |||||
struct mtx bridge_lock; | |||||
static void | |||||
rib_bridge_init(void) | |||||
{ | |||||
CK_STAILQ_INIT(&bridge_head); | |||||
mtx_init(&bridge_lock, "rib_event_bridge_lock", NULL, MTX_DEF); | |||||
} | |||||
Done Inline ActionsBoth tailq head and mutex can be initialized with standard initializer macros. glebius: Both tailq head and mutex can be initialized with standard initializer macros. | |||||
SYSINIT(rib_bridge_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_SECOND, rib_bridge_init, NULL); | |||||
void | |||||
rib_bridge_generic_event(int provider_id, uint32_t event_type, uint32_t val1, | |||||
void *ptr1, void *ptr2) | |||||
{ | |||||
struct rib_event_bridge *reb; | |||||
NET_EPOCH_ASSERT(); | |||||
CK_STAILQ_FOREACH(reb, &bridge_head, reb_link) { | |||||
RT_LOG(LOG_DEBUG3, "HERE reb %p %d", reb, reb->reb_provider_id); | |||||
if (reb->reb_provider_id != provider_id) | |||||
reb->reb_cb(event_type, val1, ptr1, ptr2, reb->reb_cb_arg); | |||||
} | |||||
} | |||||
void | |||||
rib_bridge_rt_event(int provider_id, uint32_t fibnum, struct rt_addrinfo *info, | |||||
struct rib_cmd_info *rc) | |||||
{ | |||||
#if DEBUG_MAX_LEVEL >= LOG_DEBUG2 | |||||
char rtbuf[INET6_ADDRSTRLEN + 5]; | |||||
FIB_LOG(LOG_DEBUG3, fibnum, rt_get_family(rc->rc_rt), "received cmd %s for %s", | |||||
rib_print_cmd(rc->rc_cmd), rt_print_buf(rc->rc_rt, rtbuf, sizeof(rtbuf))); | |||||
#endif | |||||
rib_bridge_generic_event(provider_id, NLBR_EVENT_ROUTE, fibnum, info, rc); | |||||
} | |||||
void | |||||
rib_bridge_link(struct rib_event_bridge *reb) | |||||
{ | |||||
mtx_lock(&bridge_lock); | |||||
CK_STAILQ_INSERT_HEAD(&bridge_head, reb, reb_link); | |||||
mtx_unlock(&bridge_lock); | |||||
RT_LOG(LOG_DEBUG, "link %p", reb); | |||||
} | |||||
void | |||||
rib_bridge_unlink(struct rib_event_bridge *reb) | |||||
{ | |||||
mtx_lock(&bridge_lock); | |||||
CK_STAILQ_REMOVE(&bridge_head, reb, rib_event_bridge, reb_link); | |||||
mtx_unlock(&bridge_lock); | |||||
RT_LOG(LOG_DEBUG, "unlink %p", reb); | |||||
} | |||||
Why not static?