Page MenuHomeFreeBSD

D57007.id177854.diff
No OneTemporary

D57007.id177854.diff

diff --git a/sys/net/route/nhop.c b/sys/net/route/nhop.c
--- a/sys/net/route/nhop.c
+++ b/sys/net/route/nhop.c
@@ -386,3 +386,28 @@
return (nh_priv_ret);
}
+
+/*
+ * Searches for the nexthop by data specifcied in @nh_priv.
+ * Filtered with metric.
+ * Returns referenced nexthop or NULL.
+ */
+struct nhop_priv *
+find_nhop_with_metric(struct nh_control *ctl, const struct nhop_priv *nh_priv,
+ uint32_t metric)
+{
+ struct nhop_priv *nh_priv_ret;
+
+ NHOPS_RLOCK(ctl);
+ CHT_SLIST_FIND_BYOBJ(&ctl->nh_head, nhops, nh_priv, nh_priv_ret);
+ if (nh_priv_ret != NULL) {
+ if (nh_priv_ret->nh->nh_metric != metric ||
+ refcount_acquire_if_not_zero(&nh_priv_ret->nh_refcnt) == 0) {
+ /* refcount was 0 -> nhop is being deleted */
+ nh_priv_ret = NULL;
+ }
+ }
+ NHOPS_RUNLOCK(ctl);
+
+ return (nh_priv_ret);
+}
diff --git a/sys/net/route/nhop_ctl.c b/sys/net/route/nhop_ctl.c
--- a/sys/net/route/nhop_ctl.c
+++ b/sys/net/route/nhop_ctl.c
@@ -354,7 +354,11 @@
return (NULL);
}
- tmp_priv = find_nhop(rnh->nh_control, nh->nh_priv);
+ if (nh->nh_metric != 0)
+ tmp_priv = find_nhop_with_metric(rnh->nh_control,
+ nh->nh_priv, nh->nh_metric);
+ else
+ tmp_priv = find_nhop(rnh->nh_control, nh->nh_priv);
if (tmp_priv != NULL) {
nhop_free(nh);
*perror = 0;
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
@@ -102,6 +102,8 @@
/* nhop.c */
struct nhop_priv *find_nhop(struct nh_control *ctl,
const struct nhop_priv *nh_priv);
+struct nhop_priv *find_nhop_with_metric(struct nh_control *ctl,
+ const struct nhop_priv *nh_priv, uint32_t metric);
int link_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv);
struct nhop_priv *unlink_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv);

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 30, 7:17 PM (5 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39906169
Default Alt Text
D57007.id177854.diff (1 KB)

Event Timeline