From 668be0ffb32630c57bdd202a02f167d5fffd2322 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Wed, 24 Oct 2018 16:24:27 +0200 Subject: [PATCH] Nest: Change preference to lower-is-better --- nest/proto.c | 2 +- nest/route.h | 1 + nest/rt-table.c | 4 ++-- proto/babel/babel.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nest/proto.c b/nest/proto.c index 15d6f4de..b22f6d18 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -483,7 +483,7 @@ channel_config_new(const struct channel_class *cc, const char *name, uint net_ty cf->net_type = net_type; cf->ra_mode = RA_OPTIMAL; - cf->preference = proto->protocol->preference; + cf->preference = 250 - proto->protocol->preference; add_tail(&proto->channels, &cf->n); diff --git a/nest/route.h b/nest/route.h index c52b7592..3af86c38 100644 --- a/nest/route.h +++ b/nest/route.h @@ -666,6 +666,7 @@ extern struct protocol *attr_class_to_protocol[EAP_MAX]; /* * Default protocol preferences + * (effective values are 250-X of these) */ #define DEF_PREF_DIRECT 240 /* Directly connected */ diff --git a/nest/rt-table.c b/nest/rt-table.c index 293138d1..5a0ef914 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -335,9 +335,9 @@ rte_better(rte *new, rte *old) if (!rte_is_valid(new)) return 0; - if (new->pref > old->pref) - return 1; if (new->pref < old->pref) + return 1; + if (new->pref > old->pref) return 0; if (new->attrs->src->proto->proto != old->attrs->src->proto->proto) { diff --git a/proto/babel/babel.c b/proto/babel/babel.c index 88c4711e..cb5bb707 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -664,7 +664,7 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e) rte *rte = rte_get_temp(a); memset(&rte->u.babel, 0, sizeof(rte->u.babel)); rte->pflags = 0; - rte->pref = 1; + rte->pref = 65535; e->unreachable = 1; rte_update2(c, e->n.addr, rte, p->p.main_source);