From 716b904f4eb14349cdf66656eea0d90b040d51e5 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Mon, 5 Nov 2018 21:55:18 +0100 Subject: Filter: Make ifname attribute modifiable Allow to change an interface associated with a route by setting ifname attribute. It will also change the route to a direct one. --- filter/config.Y | 2 +- filter/filter.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'filter') diff --git a/filter/config.Y b/filter/config.Y index 6328ba09..3b7f9004 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -792,7 +792,7 @@ static_attr: | SCOPE { $$ = f_new_static_attr(T_ENUM_SCOPE, SA_SCOPE, 1); } | CAST { $$ = f_new_static_attr(T_ENUM_RTC, SA_CAST, 0); } | DEST { $$ = f_new_static_attr(T_ENUM_RTD, SA_DEST, 1); } - | IFNAME { $$ = f_new_static_attr(T_STRING, SA_IFNAME, 0); } + | IFNAME { $$ = f_new_static_attr(T_STRING, SA_IFNAME, 1); } | IFINDEX { $$ = f_new_static_attr(T_INT, SA_IFINDEX, 0); } ; diff --git a/filter/filter.c b/filter/filter.c index 8b66b57e..02d3b960 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -1000,6 +1000,20 @@ interpret(struct f_inst *what) rta->hostentry = NULL; break; + case SA_IFNAME: + { + struct iface *ifa = if_find_by_name(v1.val.s); + if (!ifa) + runtime( "Invalid iface name" ); + + rta->dest = RTD_DEVICE; + rta->gw = IPA_NONE; + rta->iface = ifa; + rta->nexthops = NULL; + rta->hostentry = NULL; + } + break; + default: bug("Invalid static attribute access (%x)", res.type); } -- cgit v1.2.3