Page MenuHomeFreeBSD

D32342.diff
No OneTemporary

D32342.diff

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
@@ -1764,12 +1764,10 @@
{
#ifdef ROUTE_MPATH
if (NH_IS_NHGRP(nh))
- return (nhgrp_get_idx((struct nhgrp_object *)nh) * 2 - 1);
+ return (nhgrp_get_idx((struct nhgrp_object *)nh));
else
- return (nhop_get_idx(nh) * 2);
-#else
- return (nhop_get_idx(nh));
#endif
+ return (nhop_get_idx(nh));
}
uint32_t
diff --git a/sys/net/route/nhgrp.c b/sys/net/route/nhgrp.c
--- a/sys/net/route/nhgrp.c
+++ b/sys/net/route/nhgrp.c
@@ -159,9 +159,9 @@
NHOPS_WLOCK(ctl);
/* Check if we need to resize hash and index */
new_num_buckets = CHT_SLIST_GET_RESIZE_BUCKETS(&ctl->gr_head);
- new_num_items = bitmask_get_resize_items(&ctl->gr_idx_head);
+ new_num_items = bitmask_get_resize_items(&ctl->nh_idx_head);
- if (bitmask_alloc_idx(&ctl->gr_idx_head, &idx) != 0) {
+ if (bitmask_alloc_idx(&ctl->nh_idx_head, &idx) != 0) {
NHOPS_WUNLOCK(ctl);
DPRINTF("Unable to allocate mpath index");
consider_resize(ctl, new_num_buckets, new_num_items);
@@ -196,7 +196,7 @@
}
idx = nhg_priv_ret->nhg_idx;
- ret = bitmask_free_idx(&ctl->gr_idx_head, idx);
+ ret = bitmask_free_idx(&ctl->nh_idx_head, idx);
nhg_priv_ret->nhg_idx = 0;
nhg_priv_ret->nh_control = NULL;
@@ -243,8 +243,8 @@
CHT_SLIST_RESIZE(&ctl->gr_head, mpath, gr_ptr, new_gr_bucket);
}
if (gr_idx_ptr != NULL) {
- if (bitmask_copy(&ctl->gr_idx_head, gr_idx_ptr, new_idx_items) == 0)
- bitmask_swap(&ctl->gr_idx_head, gr_idx_ptr, new_idx_items, &old_idx_ptr);
+ if (bitmask_copy(&ctl->nh_idx_head, gr_idx_ptr, new_idx_items) == 0)
+ bitmask_swap(&ctl->nh_idx_head, gr_idx_ptr, new_idx_items, &old_idx_ptr);
}
NHOPS_WUNLOCK(ctl);
@@ -261,8 +261,8 @@
nhgrp_ctl_alloc_default(struct nh_control *ctl, int malloc_flags)
{
size_t alloc_size;
- uint32_t num_buckets, num_items;
- void *cht_ptr, *mask_ptr;
+ uint32_t num_buckets;
+ void *cht_ptr;
malloc_flags = (malloc_flags & (M_NOWAIT | M_WAITOK)) | M_ZERO;
@@ -275,29 +275,16 @@
return (false);
}
- /*
- * Allocate nexthop index bitmask.
- */
- num_items = 128;
- mask_ptr = malloc(bitmask_get_size(num_items), M_NHOP, malloc_flags);
- if (mask_ptr == NULL) {
- DPRINTF("mpath bitmask init failed");
- free(cht_ptr, M_NHOP);
- return (false);
- }
-
NHOPS_WLOCK(ctl);
if (ctl->gr_head.hash_size == 0) {
/* Init hash and bitmask */
CHT_SLIST_INIT(&ctl->gr_head, cht_ptr, num_buckets);
- bitmask_init(&ctl->gr_idx_head, mask_ptr, num_items);
NHOPS_WUNLOCK(ctl);
} else {
/* Other thread has already initiliazed hash/bitmask */
NHOPS_WUNLOCK(ctl);
free(cht_ptr, M_NHOP);
- free(mask_ptr, M_NHOP);
}
DPRINTF("mpath init done for fib/af %d/%d", ctl->rh->rib_fibnum,
@@ -315,18 +302,14 @@
* routes will not be necessarily used.
*/
CHT_SLIST_INIT(&ctl->gr_head, NULL, 0);
- bitmask_init(&ctl->gr_idx_head, NULL, 0);
return (0);
}
void
nhgrp_ctl_free(struct nh_control *ctl)
{
-
if (ctl->gr_head.ptr != NULL)
free(ctl->gr_head.ptr, M_NHOP);
- if (ctl->gr_idx_head.idx != NULL)
- free(ctl->gr_idx_head.idx, M_NHOP);
}
void
diff --git a/sys/net/route/nhop_var.h b/sys/net/route/nhop_var.h
--- a/sys/net/route/nhop_var.h
+++ b/sys/net/route/nhop_var.h
@@ -57,7 +57,6 @@
struct nhops_head nh_head; /* hash table head */
struct bitmask_head nh_idx_head; /* nhop index head */
struct nhgroups_head gr_head; /* nhgrp hash table head */
- struct bitmask_head gr_idx_head; /* nhgrp index head */
struct rwlock ctl_lock; /* overall ctl lock */
struct rib_head *ctl_rh; /* pointer back to rnh */
struct epoch_context ctl_epoch_ctx; /* epoch ctl helper */

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 2:22 PM (18 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15542175
Default Alt Text
D32342.diff (3 KB)

Event Timeline