Page MenuHomeFreeBSD

D29969.id88111.diff
No OneTemporary

D29969.id88111.diff

Index: sys/net/route/fib_algo.c
===================================================================
--- sys/net/route/fib_algo.c
+++ sys/net/route/fib_algo.c
@@ -1526,6 +1526,12 @@
set_algo_inet6_sysctl_handler, "A", "Set IPv6 lookup algo");
#endif
+static struct nhop_object *
+dummy_lookup(void *algo_data, const struct flm_lookup_key key, uint32_t scopeid)
+{
+ return (NULL);
+}
+
static void
destroy_fdh_epoch(epoch_context_t ctx)
{
@@ -1544,8 +1550,15 @@
sz = sizeof(struct fib_dp_header);
sz += sizeof(struct fib_dp) * num_tables;
fdh = malloc(sz, M_RTABLE, (waitok ? M_WAITOK : M_NOWAIT) | M_ZERO);
- if (fdh != NULL)
+ if (fdh != NULL) {
fdh->fdh_num_tables = num_tables;
+ /*
+ * Set dummy lookup function ptr always returning NULL, so
+ * we can delay algo init.
+ */
+ for (uint32_t i = 0; i < num_tables; i++)
+ fdh->fdh_idx[i].f = dummy_lookup;
+ }
return (fdh);
}
Index: sys/net/route/route_tables.c
===================================================================
--- sys/net/route/route_tables.c
+++ sys/net/route/route_tables.c
@@ -70,6 +70,7 @@
#define RT_NUMFIBS 1
#endif
+static inline struct rib_head *rt_tables_get_rnh_ptr(uint32_t table, sa_family_t family);
static void grow_rtables(uint32_t num_fibs);
VNET_DEFINE_STATIC(struct sx, rtables_lock);
@@ -214,13 +215,6 @@
if (rh == NULL)
log(LOG_ERR, "unable to create routing table for %d.%d\n",
dom->dom_family, i);
-#ifdef FIB_ALGO
- if (fib_select_algo_initial(rh) != 0) {
- log(LOG_ERR, "unable to select algo for table %d.%d\n",
- dom->dom_family, i);
- // TODO: detach table
- }
-#endif
*prnh = rh;
}
}
@@ -238,9 +232,30 @@
atomic_thread_fence_rel();
epoch_wait_preempt(net_epoch_preempt);
- /* Finally, set number of fibs to a new value */
+ /* Set number of fibs to a new value */
V_rt_numfibs = num_tables;
+#ifdef FIB_ALGO
+ /* Attach fib algo to the new rtables */
+ for (dom = domains; dom; dom = dom->dom_next) {
+ if (dom->dom_rtattach == NULL)
+ continue;
+ family = dom->dom_family;
+ for (int i = 0; i < num_tables; i++) {
+ rh = rt_tables_get_rnh_ptr(i, family);
+ if (rh->rib_algo_init)
+ continue;
+ if (fib_select_algo_initial(rh) != 0) {
+ log(LOG_ERR, "[fib_algo] Unable to select algo for table %d.%d\n",
+ dom->dom_family, i);
+ continue;
+ }
+
+ rh->rib_algo_init = true;
+ }
+ }
+#endif
+
if (old_rt_tables != NULL)
free(old_rt_tables, M_RTABLE);
}
Index: sys/net/route/route_var.h
===================================================================
--- sys/net/route/route_var.h
+++ sys/net/route/route_var.h
@@ -76,6 +76,7 @@
#endif
uint32_t rib_dying:1; /* rib is detaching */
uint32_t rib_algo_fixed:1;/* fixed algorithm */
+ uint32_t rib_algo_init:1;/* algo init done */
struct nh_control *nh_control; /* nexthop subsystem data */
CK_STAILQ_HEAD(, rib_subscription) rnh_subscribers;/* notification subscribers */
};

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 30, 10:42 AM (5 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35743260
Default Alt Text
D29969.id88111.diff (2 KB)

Event Timeline