Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171796162
D59639.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D59639.diff
View Options
diff --git a/sys/net/route/fib_algo.h b/sys/net/route/fib_algo.h
--- a/sys/net/route/fib_algo.h
+++ b/sys/net/route/fib_algo.h
@@ -81,6 +81,8 @@
struct fib_change_queue *q, void *data);
typedef uint8_t flm_get_pref_t(const struct rib_rtable_info *rinfo);
+#define FLM_FLAG_OWN_NHOPS 0x0001
+
struct fib_lookup_module {
char *flm_name; /* algo name */
int flm_family; /* address family this module supports */
diff --git a/sys/net/route/fib_algo.c b/sys/net/route/fib_algo.c
--- a/sys/net/route/fib_algo.c
+++ b/sys/net/route/fib_algo.c
@@ -828,6 +828,11 @@
}
result = fd->fd_flm->flm_change_rib_item_cb(rnh, rc, fd->fd_algo_data);
+ if (result == FLM_BATCH &&
+ (fd->fd_flm->flm_flags & FLM_FLAG_OWN_NHOPS) != 0) {
+ FD_PRINTF(LOG_ERR, fd, "reference-owning module requested batching");
+ result = FLM_ERROR;
+ }
switch (result) {
case FLM_SUCCESS:
@@ -1182,23 +1187,25 @@
FD_PRINTF(LOG_DEBUG, fd, "allocated fd %p", fd);
- /* Allocate nhidx -> nhop_ptr table */
- size = fd->number_nhops * sizeof(void *);
- fd->nh_idx = malloc(size, M_RTABLE, M_NOWAIT | M_ZERO);
- if (fd->nh_idx == NULL) {
- FD_PRINTF(LOG_INFO, fd, "Unable to allocate nhop table idx (sz:%zu)", size);
- return (FLM_REBUILD);
- }
+ if ((flm->flm_flags & FLM_FLAG_OWN_NHOPS) == 0) {
+ /* Allocate nhidx -> nhop_ptr table */
+ size = fd->number_nhops * sizeof(void *);
+ fd->nh_idx = malloc(size, M_RTABLE, M_NOWAIT | M_ZERO);
+ if (fd->nh_idx == NULL) {
+ FD_PRINTF(LOG_INFO, fd, "Unable to allocate nhop table idx (sz:%zu)", size);
+ return (FLM_REBUILD);
+ }
- /* Allocate nhop index refcount table */
- size = sizeof(struct nhop_ref_table);
- size += fd->number_nhops * sizeof(uint32_t);
- fd->nh_ref_table = malloc(size, M_RTABLE, M_NOWAIT | M_ZERO);
- if (fd->nh_ref_table == NULL) {
- FD_PRINTF(LOG_INFO, fd, "Unable to allocate nhop refcount table (sz:%zu)", size);
- return (FLM_REBUILD);
+ /* Allocate nhop index refcount table */
+ size = sizeof(struct nhop_ref_table);
+ size += fd->number_nhops * sizeof(uint32_t);
+ fd->nh_ref_table = malloc(size, M_RTABLE, M_NOWAIT | M_ZERO);
+ if (fd->nh_ref_table == NULL) {
+ FD_PRINTF(LOG_INFO, fd, "Unable to allocate nhop refcount table (sz:%zu)", size);
+ return (FLM_REBUILD);
+ }
+ FD_PRINTF(LOG_DEBUG, fd, "Allocated %u nhop indexes", fd->number_nhops);
}
- FD_PRINTF(LOG_DEBUG, fd, "Allocated %u nhop indexes", fd->number_nhops);
/* Okay, we're ready for algo init */
void *old_algo_data = (old_fd != NULL) ? old_fd->fd_algo_data : NULL;
@@ -1754,6 +1761,7 @@
fib_get_nhop_array(struct fib_data *fd)
{
+ MPASS((fd->fd_flm->flm_flags & FLM_FLAG_OWN_NHOPS) == 0);
return (fd->nh_idx);
}
@@ -1770,6 +1778,7 @@
fib_get_nhop_idx(struct fib_data *fd, struct nhop_object *nh)
{
+ MPASS((fd->fd_flm->flm_flags & FLM_FLAG_OWN_NHOPS) == 0);
return (get_nhop_idx(nh));
}
@@ -1783,7 +1792,11 @@
static uint32_t
fib_ref_nhop(struct fib_data *fd, struct nhop_object *nh)
{
- uint32_t idx = get_nhop_idx(nh);
+ uint32_t idx;
+
+ if ((fd->fd_flm->flm_flags & FLM_FLAG_OWN_NHOPS) != 0)
+ return (1);
+ idx = get_nhop_idx(nh);
if (idx >= fd->number_nhops) {
fd->hit_nhops = 1;
@@ -1844,7 +1857,11 @@
static void
fib_unref_nhop(struct fib_data *fd, struct nhop_object *nh)
{
- uint32_t idx = get_nhop_idx(nh);
+ uint32_t idx;
+
+ if ((fd->fd_flm->flm_flags & FLM_FLAG_OWN_NHOPS) != 0)
+ return;
+ idx = get_nhop_idx(nh);
KASSERT((idx < fd->number_nhops), ("invalid nhop index"));
KASSERT((nh == fd->nh_idx[idx]), ("index table contains whong nh"));
@@ -2023,6 +2040,10 @@
fib_module_register(struct fib_lookup_module *flm)
{
+ if ((flm->flm_flags & FLM_FLAG_OWN_NHOPS) != 0 &&
+ flm->flm_change_rib_items_cb != NULL)
+ return (EINVAL);
+
FIB_MOD_LOCK();
ALGO_PRINTF(LOG_INFO, "attaching %s to %s", flm->flm_name,
print_family(flm->flm_family));
diff --git a/sys/net/route/nhop.h b/sys/net/route/nhop.h
--- a/sys/net/route/nhop.h
+++ b/sys/net/route/nhop.h
@@ -246,6 +246,7 @@
};
void nhop_free(struct nhop_object *nh);
+int nhop_try_ref_object(struct nhop_object *nh);
struct sysctl_req;
struct sockaddr_dl;
diff --git a/sys/net/route/route_var.h b/sys/net/route/route_var.h
--- a/sys/net/route/route_var.h
+++ b/sys/net/route/route_var.h
@@ -247,7 +247,6 @@
int nhops_init_rib(struct rib_head *rh);
void nhops_destroy_rib(struct rib_head *rh);
void nhop_ref_object(struct nhop_object *nh);
-int nhop_try_ref_object(struct nhop_object *nh);
void nhop_ref_any(struct nhop_object *nh);
void nhop_free_any(struct nhop_object *nh);
struct nhop_object *nhop_get_nhop_internal(struct rib_head *rnh,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Sep 14, 2:25 PM (8 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38907486
Default Alt Text
D59639.diff (4 KB)
Attached To
Mode
D59639: route: Let FIB modules own nexthop references
Attached
Detach File
Event Timeline
Log In to Comment