On Fri, Mar 22, 2019 at 02:56:21PM -0500, Corban Johnson wrote:
> > If you want, i can send you patch to fix
> > that.
>
> That would be very helpful, thank you :)
Attached (untested).
It adds read-only integer property nh_cost to access that.
The name of the property is horrible (that is why the patch is not
commited), i would be glad for a better idea. Unfortunately, 'igp_metric'
cannot be used (as it represent the original property of OSPF routes,
which is technically a different property with a different access
code).
--
Elen sila lumenn' omentielvo
Ondrej 'Santiago' Zajicek (email: [email protected])
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
diff --git a/filter/config.Y b/filter/config.Y
index 02de3416..7941500b 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -408,7 +408,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
SET, STRING, BGPMASK, BGPPATH, CLIST, ECLIST, LCLIST,
IF, THEN, ELSE, CASE,
TRUE, FALSE, RT, RO, UNKNOWN, GENERIC,
- FROM, GW, NET, MASK, PROTO, SOURCE, SCOPE, DEST, IFNAME, IFINDEX,
+ FROM, GW, NET, MASK, PROTO, SOURCE, SCOPE, DEST, IFNAME, IFINDEX, NH_COST,
PREFERENCE,
ROA_CHECK, ASN, SRC,
IS_V4, IS_V6,
@@ -867,6 +867,7 @@ static_attr:
| DEST { $$ = f_new_static_attr(T_ENUM_RTD, SA_DEST, 1); }
| IFNAME { $$ = f_new_static_attr(T_STRING, SA_IFNAME, 1); }
| IFINDEX { $$ = f_new_static_attr(T_INT, SA_IFINDEX, 0); }
+ | NH_COST { $$ = f_new_static_attr(T_INT, SA_NH_COST, 0); }
;
term:
diff --git a/filter/filter.c b/filter/filter.c
index 37cf16a3..e6464a10 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -949,6 +949,7 @@ interpret(struct f_inst *what)
case SA_DEST: res.val.i = rta->dest; break;
case SA_IFNAME: res.val.s = rta->nh.iface ? rta->nh.iface->name : ""; break;
case SA_IFINDEX: res.val.i = rta->nh.iface ? rta->nh.iface->index : 0; break;
+ case SA_NH_COST: res.val.i = rta->igp_metric; break;
default:
bug("Invalid static attribute access (%x)", res.type);
diff --git a/filter/filter.h b/filter/filter.h
index a8c33287..4f9a5bbe 100644
--- a/filter/filter.h
+++ b/filter/filter.h
@@ -260,6 +260,7 @@ void val_format(struct f_val v, buffer *buf);
#define SA_DEST 7
#define SA_IFNAME 8
#define SA_IFINDEX 9
+#define SA_NH_COST 10
struct f_tree {