From 1187627a1dded6a3673c0d43033f431f15cd1b8f Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 2 Jul 2019 16:30:36 +0200 Subject: Netlink: Do unified scan for both IPv4 and IPv6 Instead of separate scans for IPv4, IPv6 and MPLS, do one AF_UNSPEC scan. This also avoids kernel issue when kernel reported IPv4 and IPv6 routes during MPLS scan if MPLS is not active. --- sysdep/linux/netlink.c | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index d773743d..5a0b4d0c 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -1393,10 +1393,10 @@ krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old) } static int -nl_mergable_route(struct nl_parse_state *s, net *net, struct krt_proto *p, uint priority, uint krt_type) +nl_mergable_route(struct nl_parse_state *s, net *net, struct krt_proto *p, uint priority, uint krt_type, uint rtm_family) { - /* Route merging must be active */ - if (!s->merge) + /* Route merging is used for IPv6 scans */ + if (!s->scan || (rtm_family != AF_INET6)) return 0; /* Saved and new route must have same network, proto/table, and priority */ @@ -1433,12 +1433,11 @@ nl_announce_route(struct nl_parse_state *s) } static inline void -nl_parse_begin(struct nl_parse_state *s, int scan, int merge) +nl_parse_begin(struct nl_parse_state *s, int scan) { memset(s, 0, sizeof (struct nl_parse_state)); s->pool = nl_linpool; s->scan = scan; - s->merge = merge; } static inline void @@ -1581,7 +1580,7 @@ nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h) net *net = net_get(p->p.main_channel->table, n); - if (s->net && !nl_mergable_route(s, net, p, priority, i->rtm_type)) + if (s->net && !nl_mergable_route(s, net, p, priority, i->rtm_type, i->rtm_family)) nl_announce_route(s); rta *ra = lp_allocz(s->pool, RTA_MAX_SIZE); @@ -1814,34 +1813,14 @@ krt_do_scan(struct krt_proto *p UNUSED) /* CONFIG_ALL_TABLES_AT_ONCE => p is NUL struct nlmsghdr *h; struct nl_parse_state s; - nl_parse_begin(&s, 1, 0); - nl_request_dump(AF_INET, RTM_GETROUTE); + nl_parse_begin(&s, 1); + nl_request_dump(AF_UNSPEC, RTM_GETROUTE); while (h = nl_get_scan()) if (h->nlmsg_type == RTM_NEWROUTE || h->nlmsg_type == RTM_DELROUTE) nl_parse_route(&s, h); else log(L_DEBUG "nl_scan_fire: Unknown packet received (type=%d)", h->nlmsg_type); nl_parse_end(&s); - - nl_parse_begin(&s, 1, 1); - nl_request_dump(AF_INET6, RTM_GETROUTE); - while (h = nl_get_scan()) - if (h->nlmsg_type == RTM_NEWROUTE || h->nlmsg_type == RTM_DELROUTE) - nl_parse_route(&s, h); - else - log(L_DEBUG "nl_scan_fire: Unknown packet received (type=%d)", h->nlmsg_type); - nl_parse_end(&s); - -#ifdef HAVE_MPLS_KERNEL - nl_parse_begin(&s, 1, 1); - nl_request_dump(AF_MPLS, RTM_GETROUTE); - while (h = nl_get_scan()) - if (h->nlmsg_type == RTM_NEWROUTE || h->nlmsg_type == RTM_DELROUTE) - nl_parse_route(&s, h); - else - log(L_DEBUG "nl_scan_fire: Unknown packet received (type=%d)", h->nlmsg_type); - nl_parse_end(&s); -#endif } /* @@ -1861,7 +1840,7 @@ nl_async_msg(struct nlmsghdr *h) case RTM_NEWROUTE: case RTM_DELROUTE: DBG("KRT: Received async route notification (%d)\n", h->nlmsg_type); - nl_parse_begin(&s, 0, 0); + nl_parse_begin(&s, 0); nl_parse_route(&s, h); nl_parse_end(&s); break; -- cgit v1.2.3 From 59d3a3611f05c05040cec4bf09f31c26ade0fa0a Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 2 Jul 2019 18:23:06 +0200 Subject: Netlink: Handle alien routes with unsorted nexthops Nest requires that nexthops are sorted, the kernel protocol have to ensure that for alien routes. --- nest/route.h | 1 + nest/rt-attr.c | 20 +++++++++++++++++++- sysdep/linux/netlink.c | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/nest/route.h b/nest/route.h index 15aac8f6..e356f686 100644 --- a/nest/route.h +++ b/nest/route.h @@ -628,6 +628,7 @@ int nexthop__same(struct nexthop *x, struct nexthop *y); /* Compare multipath ne static inline int nexthop_same(struct nexthop *x, struct nexthop *y) { return (x == y) || nexthop__same(x, y); } struct nexthop *nexthop_merge(struct nexthop *x, struct nexthop *y, int rx, int ry, int max, linpool *lp); +struct nexthop *nexthop_sort(struct nexthop *x); static inline void nexthop_link(struct rta *a, struct nexthop *from) { memcpy(&a->nh, from, nexthop_size(from)); } void nexthop_insert(struct nexthop **n, struct nexthop *y); diff --git a/nest/rt-attr.c b/nest/rt-attr.c index cc362cab..1803db92 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -200,7 +200,7 @@ nexthop__same(struct nexthop *x, struct nexthop *y) } static int -nexthop_compare_node(struct nexthop *x, struct nexthop *y) +nexthop_compare_node(const struct nexthop *x, const struct nexthop *y) { int r; @@ -318,6 +318,24 @@ nexthop_insert(struct nexthop **n, struct nexthop *x) *n = x; } +struct nexthop * +nexthop_sort(struct nexthop *x) +{ + struct nexthop *s = NULL; + + /* Simple insert-sort */ + while (x) + { + struct nexthop *n = x; + x = n->next; + n->next = NULL; + + nexthop_insert(&s, n); + } + + return s; +} + int nexthop_is_sorted(struct nexthop *x) { diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index 5a0b4d0c..6e3fe488 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -725,6 +725,10 @@ nl_parse_multipath(struct nl_parse_state *s, struct krt_proto *p, struct rtattr nh = RTNH_NEXT(nh); } + /* Ensure nexthops are sorted to satisfy nest invariant */ + if (!nexthop_is_sorted(first)) + first = nexthop_sort(first); + return first; } -- cgit v1.2.3 From fa1e0ba35416561bda3708ec808d24641dd8995f Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Thu, 4 Jul 2019 13:34:42 +0200 Subject: OSPF: Update DR when local priority changes When priority is reconfigured locally, we need to trigger DR election. --- proto/ospf/iface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index f5c69199..6e7e498f 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -880,6 +880,7 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new) ifname, ifa->priority, new->priority); ifa->priority = new->priority; + ospf_iface_sm(ifa, ISM_NEICH); ospf_notify_link_lsa(ifa); } -- cgit v1.2.3 From 2ce25ebbefd2eaf517361a446fe40679e78e23e9 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Mon, 8 Jul 2019 13:00:13 +0200 Subject: Libdmalloc macros fixed --- lib/resource.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/resource.h b/lib/resource.h index d9d4bb8f..91049b81 100644 --- a/lib/resource.h +++ b/lib/resource.h @@ -101,9 +101,9 @@ void buffer_realloc(void **buf, unsigned *size, unsigned need, unsigned item_siz */ #define DMALLOC_DISABLE #include -#define xmalloc(size) _xmalloc_leap(__FILE__, __LINE__, size) -#define xrealloc(size) _xrealloc_leap(__FILE__, __LINE__, size) -#define xfree(ptr) _xfree_leap(__FILE__, __LINE__, ptr) +#define xmalloc(size) dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 1) +#define xrealloc(ptr, size) dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 1) +#define xfree(ptr) dmalloc_free(__FILE__, __LINE__, (ptr), DMALLOC_FUNC_FREE) #else /* * Unfortunately, several libraries we might want to link to define -- cgit v1.2.3 From 05e3933c06b488e71c9c149c25aec9c733a8bd1f Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Mon, 8 Jul 2019 13:04:50 +0200 Subject: Nest: Uninitialized variable fix Thanks to Vincent Bernat for reporting this. --- nest/rt-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nest/rt-table.c b/nest/rt-table.c index 0b796228..327156c8 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -1575,7 +1575,7 @@ rte_update2(struct channel *c, const net_addr *n, rte *new, struct rte_src *src) } else if (filter) { - rta *old_attrs; + rta *old_attrs = NULL; rte_make_tmp_attrs(&new, rte_update_pool, &old_attrs); int fr = f_run(filter, &new, rte_update_pool, 0); -- cgit v1.2.3 From 85840d4c03552a69927b666774fa39921e7b1047 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 9 Jul 2019 03:31:54 +0200 Subject: OSPF: Fix handling of external routes on graceful restart We need to flush learned external LSAs a bit later than other LSAs (after first feed after end of the graceful restart) to avoid flap of external routes. --- proto/ospf/iface.c | 1 - proto/ospf/ospf.c | 38 ++++++++++++++++++++++++++++++-------- proto/ospf/ospf.h | 3 ++- proto/ospf/rt.c | 4 ++-- proto/ospf/topology.c | 33 +++++++++++++++++++++------------ proto/ospf/topology.h | 31 ++++++++++++++++++++----------- 6 files changed, 75 insertions(+), 35 deletions(-) diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index 6e7e498f..f5c69199 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -880,7 +880,6 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new) ifname, ifa->priority, new->priority); ifa->priority = new->priority; - ospf_iface_sm(ifa, ISM_NEICH); ospf_notify_link_lsa(ifa); } diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 968d7aa0..abd4cd84 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -246,18 +246,33 @@ void ospf_stop_gr_recovery(struct ospf_proto *p) { p->gr_recovery = 0; + p->gr_cleanup = 1; p->gr_timeout = 0; - channel_graceful_restart_unlock(p->p.main_channel); /* Reorigination of router/network LSAs is already scheduled */ - ospf_mark_lsadb(p); - /* - * NOTE: We should move channel_graceful_restart_unlock() to the end of - * ospf_disp() in order to have local LSA reorigination / LSAdb cleanup / - * routing table recomputation before official end of GR. It does not matter - * when we are single-threaded. - */ + /* Rest is done in ospf_cleanup_gr_recovery() */ +} + +static void +ospf_cleanup_gr_recovery(struct ospf_proto *p) +{ + struct top_hash_entry *en; + + /* Flush dirty LSAa except external ones, these will be handled by feed */ + WALK_SLIST(en, p->lsal) + if (en->gr_dirty) + { + if ((en->lsa_type == LSA_T_EXT) || (en->lsa_type == LSA_T_NSSA)) + en->mode = LSA_M_EXPORT; + else + ospf_flush_lsa(p, en); + } + + /* End graceful restart on channel, will also schedule feed */ + channel_graceful_restart_unlock(p->p.main_channel); + + p->gr_cleanup = 0; } static int @@ -361,6 +376,8 @@ ospf_init(struct proto_config *CF) P->ifa_notify = cf->ospf2 ? ospf_ifa_notify2 : ospf_ifa_notify3; P->preexport = ospf_preexport; P->reload_routes = ospf_reload_routes; + P->feed_begin = ospf_feed_begin; + P->feed_end = ospf_feed_end; P->make_tmp_attrs = ospf_make_tmp_attrs; P->store_tmp_attrs = ospf_store_tmp_attrs; P->rte_better = ospf_rte_better; @@ -436,6 +453,7 @@ ospf_disp(timer * timer) { struct ospf_proto *p = timer->data; + /* Check for end of graceful restart */ if (p->gr_recovery) ospf_update_gr_recovery(p); @@ -448,6 +466,10 @@ ospf_disp(timer * timer) /* Calculate routing table */ if (p->calcrt) ospf_rt_spf(p); + + /* Cleanup after graceful restart */ + if (p->gr_cleanup) + ospf_cleanup_gr_recovery(p); } diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index aac13512..3fd1c363 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -223,7 +223,8 @@ struct ospf_proto int areano; /* Number of area I belong to */ int padj; /* Number of neighbors in Exchange or Loading state */ int gr_count; /* Number of neighbors in graceful restart state */ - int gr_recovery; /* Graceful restart recovery is active */ + u8 gr_recovery; /* Graceful restart recovery is active */ + u8 gr_cleanup; /* GR cleanup scheduled */ btime gr_timeout; /* The end time of grace restart recovery */ struct fib rtf; /* Routing table */ struct idm idm; /* OSPFv3 LSA ID map */ diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index 126ef201..b5787b54 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -1640,7 +1640,7 @@ ospf_rt_reset(struct ospf_proto *p) en->lb = IPA_NONE; if (en->mode == LSA_M_RTCALC) - en->mode = LSA_M_STALE; + en->mode = LSA_M_RTCALC_STALE; } WALK_LIST(oa, p->area_list) @@ -2117,7 +2117,7 @@ again2: /* Cleanup stale LSAs */ WALK_SLIST(en, p->lsal) - if (en->mode == LSA_M_STALE) + if (en->mode == LSA_M_RTCALC_STALE) ospf_flush_lsa(p, en); } diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index efd03b54..a5875770 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -71,6 +71,7 @@ ospf_install_lsa(struct ospf_proto *p, struct ospf_lsa_header *lsa, u32 type, u3 en->lsa = *lsa; en->init_age = en->lsa.age; en->inst_time = current_time(); + en->gr_dirty = p->gr_recovery && (lsa->rt == p->router_id); /* * We do not set en->mode. It is either default LSA_M_BASIC, or in a special @@ -246,7 +247,7 @@ ospf_do_originate_lsa(struct ospf_proto *p, struct top_hash_entry *en, void *lsa en->lsa.age = 0; en->init_age = 0; en->inst_time = current_time(); - en->dirty = 0; + en->gr_dirty = 0; lsa_generate_checksum(&en->lsa, en->lsa_body); OSPF_TRACE(D_EVENTS, "Originating LSA: Type: %04x, Id: %R, Rt: %R, Seq: %08x", @@ -329,7 +330,7 @@ ospf_originate_lsa(struct ospf_proto *p, struct ospf_new_lsa *lsa) (lsa_length == en->lsa.length) && !memcmp(lsa_body, en->lsa_body, lsa_blen) && (!ospf_is_v2(p) || (lsa->opts == lsa_get_options(&en->lsa))) && - !en->dirty) + !en->gr_dirty) goto drop; lsa_body = lsab_flush(p); @@ -422,6 +423,7 @@ void ospf_flush_lsa(struct ospf_proto *p, struct top_hash_entry *en) { en->nf = NULL; + en->gr_dirty = 0; if (en->next_lsa_body) { @@ -520,12 +522,6 @@ ospf_update_lsadb(struct ospf_proto *p) continue; } - if (en->dirty) - { - ospf_flush_lsa(p, en); - continue; - } - if ((en->lsa.rt == p->router_id) && (real_age >= LSREFRESHTIME)) { ospf_refresh_lsa(p, en); @@ -543,14 +539,27 @@ ospf_update_lsadb(struct ospf_proto *p) } void -ospf_mark_lsadb(struct ospf_proto *p) +ospf_feed_begin(struct channel *C, int initial UNUSED) { + struct ospf_proto *p = (struct ospf_proto *) C->proto; struct top_hash_entry *en; - /* Mark all local LSAs as dirty */ + /* Mark all external LSAs as stale */ WALK_SLIST(en, p->lsal) - if (en->lsa.rt == p->router_id) - en->dirty = 1; + if (en->mode == LSA_M_EXPORT) + en->mode = LSA_M_EXPORT_STALE; +} + +void +ospf_feed_end(struct channel *C) +{ + struct ospf_proto *p = (struct ospf_proto *) C->proto; + struct top_hash_entry *en; + + /* Flush stale LSAs */ + WALK_SLIST(en, p->lsal) + if (en->mode == LSA_M_EXPORT_STALE) + ospf_flush_lsa(p, en); } static u32 diff --git a/proto/ospf/topology.h b/proto/ospf/topology.h index ffae436a..535d1f1b 100644 --- a/proto/ospf/topology.h +++ b/proto/ospf/topology.h @@ -33,7 +33,7 @@ struct top_hash_entry u32 lb_id; /* Interface ID of link back iface (for bcast or NBMA networks) */ u32 dist; /* Distance from the root */ int ret_count; /* Number of retransmission lists referencing the entry */ - u8 dirty; /* Will be flushed during next LSAdb update unless reoriginated*/ + u8 gr_dirty; /* Local LSA received during GR, will be removed unless reoriginated */ u8 color; #define OUTSPF 0 #define CANDIDATE 1 @@ -115,10 +115,11 @@ struct top_hash_entry */ -#define LSA_M_BASIC 0 -#define LSA_M_EXPORT 1 -#define LSA_M_RTCALC 2 -#define LSA_M_STALE 3 +#define LSA_M_BASIC 0 +#define LSA_M_EXPORT 1 +#define LSA_M_RTCALC 2 +#define LSA_M_EXPORT_STALE 3 +#define LSA_M_RTCALC_STALE 4 /* * LSA entry modes: @@ -128,9 +129,13 @@ struct top_hash_entry * routing table calculation is scheduled. This is also the mode used for LSAs * received from neighbors. Example: Router-LSAs, Network-LSAs. * - * LSA_M_EXPORT - like LSA_M_BASIC, but the routing table calculation does not - * depend on the LSA. Therefore, the calculation is not scheduled when the LSA - * is changed. Example: AS-external-LSAs for exported routes. + * LSA_M_EXPORT - The LSA is originated using ospf_originate_lsa() as a + * consequence of route export to the OSPF instance. It has to be reoriginated + * during each channel feed, otherwise it is flushed automatically at the end of + * the feed. May be originated and flushed asynchronously. Also, routing table + * calculation does not depend on the LSA. Therefore, the routing table + * calculation is not scheduled when the LSA is changed. Example: + * AS-external-LSAs for exported routes. * * LSA_M_RTCALC - The LSA has to be requested using ospf_originate_lsa() during * each routing table calculation, otherwise it is flushed automatically at the @@ -138,8 +143,11 @@ struct top_hash_entry * source for it. Therefore, the calculation is not scheduled when the LSA is * changed. Example: Summary-LSAs. * - * LSA_M_STALE - Temporary state for LSA_M_RTCALC that is not requested during - * the current routing table calculation. + * LSA_M_EXPORT_STALE - Temporary state for LSA_M_EXPORT that is not requested + * during current external route feed. + * + * LSA_M_RTCALC_STALE - Temporary state for LSA_M_RTCALC that is not requested + * during current routing table calculation. * * * Note that we do not schedule the routing table calculation when the age of @@ -181,7 +189,8 @@ struct top_hash_entry * ospf_originate_lsa(struct ospf_proto *p, struct ospf_new void ospf_advance_lsa(struct ospf_proto *p, struct top_hash_entry *en, struct ospf_lsa_header *lsa, u32 type, u32 domain, void *body); void ospf_flush_lsa(struct ospf_proto *p, struct top_hash_entry *en); void ospf_update_lsadb(struct ospf_proto *p); -void ospf_mark_lsadb(struct ospf_proto *p); +void ospf_feed_begin(struct channel *C, int initial); +void ospf_feed_end(struct channel *C); static inline void ospf_flush2_lsa(struct ospf_proto *p, struct top_hash_entry **en) { if (*en) { ospf_flush_lsa(p, *en); *en = NULL; } } -- cgit v1.2.3 From 2872ab927ecb94b1555f5e3c8bd33021261d0c54 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 9 Jul 2019 03:48:02 +0200 Subject: OSPF: Update DR when local priority changes When priority is reconfigured locally, we need to trigger DR election. (recommiting, was reset by the previous commit) --- proto/ospf/iface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index f5c69199..6e7e498f 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -880,6 +880,7 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new) ifname, ifa->priority, new->priority); ifa->priority = new->priority; + ospf_iface_sm(ifa, ISM_NEICH); ospf_notify_link_lsa(ifa); } -- cgit v1.2.3 From bb001af0e8022f6445ff50b7f32c9ac102cc244e Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 9 Jul 2019 14:34:26 +0200 Subject: Test: better random u64 generator --- test/birdtest.c | 16 +++++----------- test/birdtest.h | 5 +++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/test/birdtest.c b/test/birdtest.c index 823b02ff..d503890a 100644 --- a/test/birdtest.c +++ b/test/birdtest.c @@ -43,23 +43,17 @@ int bt_result; /* Overall program run result */ int bt_suite_result; /* One suit result */ char bt_out_fmt_buf[1024]; /* Temporary memory buffer for output of testing function */ -long int -bt_random(void) -{ - /* Seeded in bt_init() */ - long int rand_low, rand_high; - - rand_low = random(); - rand_high = random(); - return (rand_low & 0xffff) | ((rand_high & 0xffff) << 16); -} +u64 bt_random_state[] = { + 0x80241f302bd4d95d, 0xd10ba2e910f772b, 0xea188c9046f507c5, 0x4c4c581f04e6da05, + 0x53d9772877c1b647, 0xab8ce3eb466de6c5, 0xad02844c8a8e865f, 0xe8cc78080295065d +}; void bt_init(int argc, char *argv[]) { int c; - srandom(BT_RANDOM_SEED); + initstate(BT_RANDOM_SEED, (char *) bt_random_state, sizeof(bt_random_state)); bt_verbose = 0; bt_filename = argv[0]; diff --git a/test/birdtest.h b/test/birdtest.h index 4443bfc1..b2d572d0 100644 --- a/test/birdtest.h +++ b/test/birdtest.h @@ -33,7 +33,8 @@ extern const char *bt_test_id; void bt_init(int argc, char *argv[]); int bt_exit_value(void); int bt_test_suite_base(int (*test_fn)(const void *), const char *test_id, const void *test_fn_argument, int forked, int timeout, const char *dsc, ...); -long int bt_random(void); +static inline u64 bt_random(void) +{ return ((u64) random() & 0xffffffff) | ((u64) random() << 32); } void bt_log_suite_result(int result, const char *fmt, ...); void bt_log_suite_case_result(int result, const char *fmt, ...); @@ -41,7 +42,7 @@ void bt_log_suite_case_result(int result, const char *fmt, ...); #define BT_TIMEOUT 5 /* Default timeout in seconds */ #define BT_FORKING 1 /* Forking is enabled in default */ -#define BT_RANDOM_SEED 982451653 +#define BT_RANDOM_SEED 0x5097d2bb #define BT_BUFFER_SIZE 10000 -- cgit v1.2.3 From 1322e205e2066c0da8526bed505dc699d0f5b92a Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Fri, 8 Feb 2019 11:19:04 +0100 Subject: Test: Fixed annoying warnings (and possible obscure bugs). --- filter/filter_test.c | 2 +- test/birdtest.c | 5 +---- test/birdtest.h | 4 +++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/filter/filter_test.c b/filter/filter_test.c index be7fd521..916290ed 100644 --- a/filter/filter_test.c +++ b/filter/filter_test.c @@ -29,7 +29,7 @@ parse_config_file(const void *filename_void) size_t fn_size = strlen((const char *) filename_void) + 1; char *filename = alloca(fn_size); - strncpy(filename, filename_void, fn_size); + memcpy(filename, filename_void, fn_size); struct config *c = bt_config_file_parse(filename); bt_bird_cleanup(); diff --git a/test/birdtest.c b/test/birdtest.c index d503890a..7b6fb0b5 100644 --- a/test/birdtest.c +++ b/test/birdtest.c @@ -149,10 +149,7 @@ int bt_run_test_fn(int (*fn)(const void *), const void *fn_arg, int timeout) int result; alarm(timeout); - if (fn_arg) - result = fn(fn_arg); - else - result = ((int (*)(void))fn)(); + result = fn(fn_arg); if (!bt_suite_result) result = 0; diff --git a/test/birdtest.h b/test/birdtest.h index b2d572d0..dacfb095 100644 --- a/test/birdtest.h +++ b/test/birdtest.h @@ -55,11 +55,13 @@ void bt_log_suite_case_result(int result, const char *fmt, ...); #define BT_PROMPT_FAIL_NO_COLOR " [" "FAIL" "] " #define BT_PROMPT_OK_FAIL_STRLEN 8 /* strlen ' [FAIL] ' */ +static inline int bt_test_fn_noarg(const void *cp) { return ((int (*)(void)) cp)(); } + #define bt_test_suite(fn, dsc, ...) \ bt_test_suite_extra(fn, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__) #define bt_test_suite_extra(fn, f, t, dsc, ...) \ - bt_test_suite_base((int (*)(const void *))fn, #fn, NULL, f, t, dsc, ##__VA_ARGS__) + bt_test_suite_base(bt_test_fn_noarg, #fn, fn, f, t, dsc, ##__VA_ARGS__) #define bt_test_suite_arg(fn, arg, dsc, ...) \ bt_test_suite_arg_extra(fn, arg, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__) -- cgit v1.2.3 From e840cb9cd54162efca72137f53fddbb0e490d6fe Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 9 Jul 2019 15:25:40 +0200 Subject: Doc: Fix typo in BGP dynamic names feature description --- doc/bird.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index e0b60c81..c69ab87f 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -2246,7 +2246,7 @@ using the following configuration parameters: