]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Make ifname attribute modifiable
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 5 Nov 2018 20:55:18 +0000 (21:55 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 5 Nov 2018 20:55:18 +0000 (21:55 +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 7cbb4de698d819cfc8a0ead26965797c688ecf52..46a936555efcc0f40b1e0b09b4e5d99591bcd7e1 100644 (file)
@@ -1405,7 +1405,8 @@ 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 6328ba094c02bce9b1506c1747ce7b3cfc86c135..3b7f90046ed791703d96629f48636e0d7a2ba843 100644 (file)
@@ -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); }
  ;
 
index 8b66b57e23c42a2f929ed44cd16f5d580deca622..02d3b9603d830618759e1dc0fb5c7e3cfd4889f6 100644 (file)
@@ -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);
       }
index 3dd4506538a3962ee4156fd4b753635a7b3266d0..56de1f5cf48f480d68a77784e0c2188bf8619c8b 100644 (file)
@@ -441,7 +441,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;
 }
@@ -451,8 +451,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));