From b94057911554e04df9b709f8354e2e220131096a Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 16 Jan 2018 16:20:01 +0100 Subject: Filter: Allow silent filter execution A filter should log messages only if executed explicitly (e.g., during route export or route import). When a filter is executed for technical reasons (e.g., to establish whether a route was exported before), it should run silently. --- sysdep/unix/krt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sysdep/unix') diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index 07a55c0d..526c0cab 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -632,7 +632,7 @@ krt_export_net(struct krt_proto *p, net *net, rte **rt_free, ea_list **tmpa) if (filter == FILTER_ACCEPT) goto accept; - if (f_run(filter, &rt, tmpa, krt_filter_lp, FF_FORCE_TMPATTR) > F_ACCEPT) + if (f_run(filter, &rt, tmpa, krt_filter_lp, FF_FORCE_TMPATTR | FF_SILENT) > F_ACCEPT) goto reject; -- cgit v1.2.3 From e5ff7929c4d85b84496cdfc46f006b8cd1b4c0e5 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 23 Jan 2018 14:48:07 +0100 Subject: KRT: Remove useless option --- sysdep/unix/krt.Y | 1 - sysdep/unix/krt.c | 2 +- sysdep/unix/krt.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) (limited to 'sysdep/unix') diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y index 1cb28389..31f5f1d4 100644 --- a/sysdep/unix/krt.Y +++ b/sysdep/unix/krt.Y @@ -78,7 +78,6 @@ kern_item: cf_error("Learning of kernel routes not supported on this platform"); #endif } - | DEVICE ROUTES bool { THIS_KRT->devroutes = $3; } | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; } | MERGE PATHS bool kern_mp_limit { krt_set_merge_paths(this_channel, $3, $4); diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index 29d2d01e..d4c0db72 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -1159,7 +1159,7 @@ krt_reconfigure(struct proto *p, struct proto_config *CF) return 0; /* persist, graceful restart need not be the same */ - return o->scan_time == n->scan_time && o->learn == n->learn && o->devroutes == n->devroutes; + return o->scan_time == n->scan_time && o->learn == n->learn; } struct proto_config * diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h index 3bfccfc2..8d3add0e 100644 --- a/sysdep/unix/krt.h +++ b/sysdep/unix/krt.h @@ -49,7 +49,6 @@ struct krt_config { btime scan_time; /* How often we re-scan routes */ int persist; /* Keep routes when we exit */ int learn; /* Learn routes from other sources */ - int devroutes; /* XXX: remove */ int graceful_restart; /* Regard graceful restart recovery */ }; -- cgit v1.2.3 From ace3072e09e445b2fd8554492b80bea5cc1f3411 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 23 Jan 2018 15:12:43 +0100 Subject: KRT: Fix option 'merge paths' --- sysdep/unix/krt.Y | 12 +----------- sysdep/unix/krt.c | 9 ++++++++- sysdep/unix/krt.h | 1 + 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'sysdep/unix') diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y index 31f5f1d4..9aac8668 100644 --- a/sysdep/unix/krt.Y +++ b/sysdep/unix/krt.Y @@ -16,16 +16,6 @@ CF_DEFINES #define THIS_KIF ((struct kif_config *) this_proto) #define KIF_IFACE ((struct kif_iface_config *) this_ipatt) -static void -krt_set_merge_paths(struct channel_config *cc, uint merge, uint limit) -{ - if ((limit <= 0) || (limit > 255)) - cf_error("Merge paths limit must be in range 1-255"); - - cc->ra_mode = merge ? RA_MERGED : RA_OPTIMAL; - cc->merge_limit = limit; -} - static void kif_set_preferred(ip_addr ip) { @@ -80,7 +70,7 @@ kern_item: } | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; } | MERGE PATHS bool kern_mp_limit { - krt_set_merge_paths(this_channel, $3, $4); + THIS_KRT->merge_paths = $3 ? $4 : 0; #ifndef KRT_ALLOW_MERGE_PATHS if ($3) cf_error("Path merging not supported on this platform"); diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index d4c0db72..bfdbfa4e 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -1059,11 +1059,18 @@ krt_postconfig(struct proto_config *CF) cf_error("All kernel syncers must use the same table scan interval"); #endif - struct rtable_config *tab = proto_cf_main_channel(CF)->table; + struct channel_config *cc = proto_cf_main_channel(CF); + struct rtable_config *tab = cc->table; if (tab->krt_attached) cf_error("Kernel syncer (%s) already attached to table %s", tab->krt_attached->name, tab->name); tab->krt_attached = CF; + if (cf->merge_paths) + { + cc->ra_mode = RA_MERGED; + cc->merge_limit = cf->merge_paths; + } + krt_sys_postconfig(cf); } diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h index 8d3add0e..b627882d 100644 --- a/sysdep/unix/krt.h +++ b/sysdep/unix/krt.h @@ -50,6 +50,7 @@ struct krt_config { int persist; /* Keep routes when we exit */ int learn; /* Learn routes from other sources */ int graceful_restart; /* Regard graceful restart recovery */ + int merge_paths; /* Exported routes are merged for ECMP */ }; struct krt_proto { -- cgit v1.2.3 From d6cf996151307d083c30e4ecde0f1d7449b19253 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 23 Jan 2018 17:05:45 +0100 Subject: IO: Fix socket priority On Linux, setting the ToS will also set the priority and the range of accepted values is quite limited (masked by 0x1e). Therefore, 0xc0 is translated to a priority of 0, not something we want, overriding the "7" priority which was set previously explicitely. To avoid that, just move setting priority later in the code. Thanks to Vincent Bernat for the patch. --- sysdep/unix/io.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sysdep/unix') diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 6d6a0990..53a37a50 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -1238,10 +1238,6 @@ sk_setup(sock *s) #endif } - if (s->priority >= 0) - if (sk_set_priority(s, s->priority) < 0) - return -1; - if (sk_is_ipv4(s)) { if (s->flags & SKF_LADDR_RX) @@ -1292,6 +1288,11 @@ sk_setup(sock *s) return -1; } + /* Must be after sk_set_tos4() as setting ToS on Linux also mangles priority */ + if (s->priority >= 0) + if (sk_set_priority(s, s->priority) < 0) + return -1; + return 0; } -- cgit v1.2.3 From 28b3b551222ab58456a067a9be4790824cdbb60e Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 6 Feb 2018 16:08:45 +0100 Subject: KRT: Fix IPv6 route learn 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 | 7 ++++--- nest/route.h | 2 +- nest/rt-table.c | 19 ++++++++----------- sysdep/unix/krt.c | 8 +++++++- 4 files changed, 20 insertions(+), 16 deletions(-) (limited to 'sysdep/unix') diff --git a/bird.conf b/bird.conf index 410f190c..e383c934 100644 --- 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 diff --git a/nest/route.h b/nest/route.h index 43d7d696..1c86110b 100644 --- a/nest/route.h +++ b/nest/route.h @@ -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; } diff --git a/nest/rt-table.c b/nest/rt-table.c index 6ee261e8..784f6cfb 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -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; } diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index e7bd79e3..a3cbb336 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -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 -- cgit v1.2.3 From be17805c0bbd37e865dc9b17b56e8e8d210c2c6c Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 13 Feb 2018 16:27:57 +0100 Subject: Add support for source-specific IPv6 routes to BIRD core This patch adds support for source-specific IPv6 routes to BIRD core. This is based on Dean Luga's original patch, with the review comments addressed. SADR support is added to network address parsing in confbase.Y and to the kernel protocol on Linux. Currently there is no way to mix source-specific and non-source-specific routes (i.e., SADR tables cannot be connected to non-SADR tables). Thanks to Toke Hoiland-Jorgensen for the original patch. Minor changes by Ondrej Santiago Zajicek. --- conf/confbase.Y | 24 ++++++++++++-- lib/net.c | 23 +++++++++++++ lib/net.h | 90 +++++++++++++++++++++++++++++++++++++++++++++----- nest/config.Y | 13 ++++++-- nest/rt-fib.c | 2 ++ nest/rt-table.c | 42 +++++++++++++++++++++++ sysdep/cf/linux.h | 1 + sysdep/linux/netlink.c | 43 +++++++++++++++++++----- sysdep/unix/krt.c | 25 +++++++++----- 9 files changed, 233 insertions(+), 30 deletions(-) (limited to 'sysdep/unix') diff --git a/conf/confbase.Y b/conf/confbase.Y index 7e0537c5..c2d647eb 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -83,7 +83,7 @@ CF_DECLS %type