]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
KRT: Fix IPv6 route learn
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 6 Feb 2018 15:08:45 +0000 (16:08 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 6 Feb 2018 15:08:45 +0000 (16:08 +0100)
Internal table used for route learn was created with non-matching net
type for IPv6 kernel proto.

Thanks to Toke Hoiland-Jorgensen for the bugreport

bird.conf
nest/route.h
nest/rt-table.c
sysdep/unix/krt.c

index 410f190c1720f9f06b47a22f98e932d1a6d98ced..e383c93446e9cffaf588a402c985f3dd1f42014a 100644 (file)
--- a/bird.conf
+++ b/bird.conf
@@ -22,13 +22,14 @@ protocol direct {
 
 # Feed routes to kernel FIB
 protocol kernel {
-       ipv4 { export all; };
-#      learn;                  # Learn all routes from the kernel
+       ipv4 { export all; import all; };
+       learn;                  # Learn all routes from the kernel
 #      scan time 10;           # Scan kernel tables every 10 seconds
 }
 
 protocol kernel {
-       ipv6;
+       ipv6 { import all; };
+       learn;
 }
 
 # Static route feed
index 43d7d6968887e0906160a88d0767afc5006622d4..1c86110b7e117df26b63773c702be34192c14eb5 100644 (file)
@@ -282,7 +282,7 @@ void rt_preconfig(struct config *);
 void rt_commit(struct config *new, struct config *old);
 void rt_lock_table(rtable *);
 void rt_unlock_table(rtable *);
-void rt_setup(pool *, rtable *, char *, struct rtable_config *);
+void rt_setup(pool *, rtable *, struct rtable_config *);
 static inline net *net_find(rtable *tab, const net_addr *addr) { return (net *) fib_find(&tab->fib, addr); }
 static inline net *net_find_valid(rtable *tab, const net_addr *addr)
 { net *n = net_find(tab, addr); return (n && rte_is_valid(n->routes)) ? n : NULL; }
index 6ee261e80cecaee6cc94f4c32899466ca11d79f2..784f6cfb04ed072054e8e880ea1b096af4c4de68 100644 (file)
@@ -1599,22 +1599,19 @@ rt_event(void *ptr)
 }
 
 void
-rt_setup(pool *p, rtable *t, char *name, struct rtable_config *cf)
+rt_setup(pool *p, rtable *t, struct rtable_config *cf)
 {
   bzero(t, sizeof(*t));
-  t->name = name;
+  t->name = cf->name;
   t->config = cf;
-  t->addr_type = cf ? cf->addr_type : NET_IP4;
+  t->addr_type = cf->addr_type;
   fib_init(&t->fib, p, t->addr_type, sizeof(net), OFFSETOF(net, n), 0, NULL);
   init_list(&t->channels);
 
-  if (cf)
-    {
-      t->rt_event = ev_new(p);
-      t->rt_event->hook = rt_event;
-      t->rt_event->data = t;
-      t->gc_time = current_time();
-    }
+  t->rt_event = ev_new(p);
+  t->rt_event->hook = rt_event;
+  t->rt_event->data = t;
+  t->gc_time = current_time();
 }
 
 /**
@@ -2090,7 +2087,7 @@ rt_commit(struct config *new, struct config *old)
       {
        rtable *t = mb_alloc(rt_table_pool, sizeof(struct rtable));
        DBG("\t%s: created\n", r->name);
-       rt_setup(rt_table_pool, t, r->name, r);
+       rt_setup(rt_table_pool, t, r);
        add_tail(&routing_tables, &t->n);
        r->table = t;
       }
index e7bd79e3c3ee308aa3376e9ad0ca8c6b0d6412d1..a3cbb336dc7f19b472138ac38f8c899495c7d4fa 100644 (file)
@@ -506,7 +506,13 @@ static void
 krt_learn_init(struct krt_proto *p)
 {
   if (KRT_CF->learn)
-    rt_setup(p->p.pool, &p->krt_table, "Inherited", NULL);
+  {
+    struct rtable_config *cf = mb_allocz(p->p.pool, sizeof(struct rtable_config));
+    cf->name = "Inherited";
+    cf->addr_type = p->p.net_type;
+
+    rt_setup(p->p.pool, &p->krt_table, cf);
+  }
 }
 
 static void