]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Make ifname attribute modifiable
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 5 Nov 2018 21:03:21 +0000 (22:03 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 5 Nov 2018 21:03:21 +0000 (22:03 +0100)
Allow to change an interface associated with a route by setting
ifname attribute. It will also change the route to a direct one.

doc/bird.sgml
filter/config.Y
filter/filter.c
nest/iface.c

index fdfae2a6b929c5e8905e386c7ff93915db305886..72c386f237af505e8db248eed6b6ca09eae9c269 100644 (file)
@@ -1606,7 +1606,8 @@ regarded as empty bgppath/*clist for most purposes.
        <tag><label id="rta-ifname"><m/string/ ifname</tag>
        Name of the outgoing interface. Sink routes (like blackhole, unreachable
        or prohibit) and multipath routes have no interface associated with
-       them, so <cf/ifname/ returns an empty string for such routes. Read-only.
+       them, so <cf/ifname/ returns an empty string for such routes. Setting it
+       would also change route to a direct one (remove gateway).
 
        <tag><label id="rta-ifindex"><m/int/ ifindex</tag>
        Index of the outgoing interface. System wide index of the interface. May
index 93ad8d8bdccba1f85328600349a3c1850cec7f6c..d865d11fbb77b864eb9fcecc2e118fba2dc41876 100644 (file)
@@ -852,7 +852,7 @@ static_attr:
  | SOURCE  { $$ = f_new_static_attr(T_ENUM_RTS,   SA_SOURCE,   0); }
  | SCOPE   { $$ = f_new_static_attr(T_ENUM_SCOPE, SA_SCOPE,    1); }
  | 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); }
  ;
 
index edf54ec09da31f17b92ba0f598c90d542330f6a1..f308e7fdc6c47eed6ceb7fce2c5871ee74e038fd 100644 (file)
@@ -1002,6 +1002,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_UNICAST;
+         rta->nh.gw = IPA_NONE;
+         rta->nh.iface = ifa;
+         rta->nh.next = NULL;
+         rta->hostentry = NULL;
+       }
+       break;
+
       default:
        bug("Invalid static attribute access (%x)", res.type);
       }
index 9462b6341d35c366f2f68f309d283634de703487..23a82ac5d26876c6c7d0be7447a66fc0bc172df6 100644 (file)
@@ -449,7 +449,7 @@ if_find_by_name(char *name)
   struct iface *i;
 
   WALK_LIST(i, iface_list)
-    if (!strcmp(i->name, name))
+    if (!strcmp(i->name, name) && !(i->flags & IF_SHUTDOWN))
       return i;
   return NULL;
 }
@@ -459,8 +459,9 @@ if_get_by_name(char *name)
 {
   struct iface *i;
 
-  if (i = if_find_by_name(name))
-    return i;
+  WALK_LIST(i, iface_list)
+    if (!strcmp(i->name, name))
+      return i;
 
   /* No active iface, create a dummy */
   i = mb_allocz(if_pool, sizeof(struct iface));