Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109442348
D29799.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
D29799.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
@@ -128,5 +128,7 @@
struct nhop_object **fib_get_nhop_array(struct fib_data *fd);
void fib_get_rtable_info(struct rib_head *rh, struct rib_rtable_info *rinfo);
struct rib_head *fib_get_rh(struct fib_data *fd);
-
+bool fib_set_datapath_ptr(struct fib_data *fd, struct fib_dp *dp);
+void fib_set_algo_ptr(struct fib_data *fd, void *algo_data);
+void fib_epoch_call(epoch_callback_t callback, epoch_context_t ctx);
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
@@ -197,7 +197,6 @@
static bool rebuild_fd_flm(struct fib_data *fd, struct fib_lookup_module *flm_new);
static void handle_fd_callout(void *_data);
static void destroy_fd_instance_epoch(epoch_context_t ctx);
-static enum flm_op_result attach_datapath(struct fib_data *fd);
static bool is_idx_free(struct fib_data *fd, uint32_t index);
static void set_algo_fixed(struct rib_head *rh);
static bool is_algo_fixed(struct rib_head *rh);
@@ -1014,8 +1013,7 @@
*/
callout_stop(&fd->fd_callout);
- epoch_call(net_epoch_preempt, destroy_fd_instance_epoch,
- &fd->fd_epoch_ctx);
+ fib_epoch_call(destroy_fd_instance_epoch, &fd->fd_epoch_ctx);
return (0);
}
@@ -1237,8 +1235,10 @@
for (int i = 0; i < FIB_MAX_TRIES; i++) {
result = try_setup_fd_instance(flm, rh, prev_fd, &new_fd);
- if ((result == FLM_SUCCESS) && attach)
- result = attach_datapath(new_fd);
+ if ((result == FLM_SUCCESS) && attach) {
+ if (!fib_set_datapath_ptr(new_fd, &new_fd->fd_dp))
+ result = FLM_REBUILD;
+ }
if ((prev_fd != NULL) && (prev_fd != orig_fd)) {
schedule_destroy_fd_instance(prev_fd, false);
@@ -1546,32 +1546,33 @@
/*
* Replace per-family index pool @pdp with a new one which
* contains updated callback/algo data from @fd.
- * Returns 0 on success.
+ * Returns true on success.
*/
-static enum flm_op_result
-replace_rtables_family(struct fib_dp **pdp, struct fib_data *fd)
+static bool
+replace_rtables_family(struct fib_dp **pdp, struct fib_data *fd, struct fib_dp *dp)
{
struct fib_dp_header *new_fdh, *old_fdh;
NET_EPOCH_ASSERT();
FD_PRINTF(LOG_DEBUG, fd, "[vnet %p] replace with f:%p arg:%p",
- curvnet, fd->fd_dp.f, fd->fd_dp.arg);
+ curvnet, dp->f, dp->arg);
FIB_MOD_LOCK();
old_fdh = get_fib_dp_header(*pdp);
+
new_fdh = alloc_fib_dp_array(old_fdh->fdh_num_tables, false);
FD_PRINTF(LOG_DEBUG, fd, "OLD FDH: %p NEW FDH: %p", old_fdh, new_fdh);
if (new_fdh == NULL) {
FIB_MOD_UNLOCK();
FD_PRINTF(LOG_WARNING, fd, "error attaching datapath");
- return (FLM_REBUILD);
+ return (false);
}
memcpy(&new_fdh->fdh_idx[0], &old_fdh->fdh_idx[0],
old_fdh->fdh_num_tables * sizeof(struct fib_dp));
/* Update relevant data structure for @fd */
- new_fdh->fdh_idx[fd->fd_fibnum] = fd->fd_dp;
+ new_fdh->fdh_idx[fd->fd_fibnum] = *dp;
/* Ensure memcpy() writes have completed */
atomic_thread_fence_rel();
@@ -1580,10 +1581,9 @@
FIB_MOD_UNLOCK();
FD_PRINTF(LOG_DEBUG, fd, "update %p -> %p", old_fdh, new_fdh);
- epoch_call(net_epoch_preempt, destroy_fdh_epoch,
- &old_fdh->fdh_epoch_ctx);
+ fib_epoch_call(destroy_fdh_epoch, &old_fdh->fdh_epoch_ctx);
- return (FLM_SUCCESS);
+ return (true);
}
static struct fib_dp **
@@ -1601,13 +1601,13 @@
/*
* Make datapath use fib instance @fd
*/
-static enum flm_op_result
-attach_datapath(struct fib_data *fd)
+bool
+fib_set_datapath_ptr(struct fib_data *fd, struct fib_dp *dp)
{
struct fib_dp **pdp;
pdp = get_family_dp_ptr(fd->fd_family);
- return (replace_rtables_family(pdp, fd));
+ return (replace_rtables_family(pdp, fd, dp));
}
/*
@@ -1635,8 +1635,7 @@
FIB_MOD_UNLOCK();
if (old_fdh != NULL)
- epoch_call(net_epoch_preempt, destroy_fdh_epoch,
- &old_fdh->fdh_epoch_ctx);
+ fib_epoch_call(destroy_fdh_epoch, &old_fdh->fdh_epoch_ctx);
}
/*
@@ -1667,6 +1666,26 @@
#endif
}
+/*
+ * Updates pointer to the algo data for the @fd.
+ */
+void
+fib_set_algo_ptr(struct fib_data *fd, void *algo_data)
+{
+ RIB_WLOCK_ASSERT(fd->fd_rh);
+
+ fd->fd_algo_data = algo_data;
+}
+
+/*
+ * Calls @callback with @ctx after the end of a current epoch.
+ */
+void
+fib_epoch_call(epoch_callback_t callback, epoch_context_t ctx)
+{
+ epoch_call(net_epoch_preempt, callback, ctx);
+}
+
/*
* Accessor to get rib instance @fd is attached to.
*/
@@ -1765,7 +1784,7 @@
nrd = malloc(sizeof(struct nhop_release_data), M_TEMP, M_NOWAIT | M_ZERO);
if (nrd != NULL) {
nrd->nh = nh;
- epoch_call(net_epoch_preempt, release_nhop_epoch, &nrd->ctx);
+ fib_epoch_call(release_nhop_epoch, &nrd->ctx);
} else {
/*
* Unable to allocate memory. Leak nexthop to maintain guarantee
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 6, 3:07 AM (21 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16485816
Default Alt Text
D29799.diff (4 KB)
Attached To
Mode
D29799: Fib algo: extend KPI by allowing algo to set datapath pointers.
Attached
Detach File
Event Timeline
Log In to Comment