From: Maria Matejka Date: Thu, 23 Nov 2023 22:33:44 +0000 (+0100) Subject: Table: nicer route validation errors X-Git-Tag: v3.0.0~326 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bcbff42cacaa1ae2f234e2b5d37fd8b72c6b8c6;p=thirdparty%2Fbird.git Table: nicer route validation errors --- diff --git a/nest/rt-table.c b/nest/rt-table.c index a038b266d..54a471b2b 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -1614,22 +1614,19 @@ rte_validate(struct channel *ch, rte *e) int c; const net_addr *n = e->net; +#define IGNORING(pre, post) do { \ + log(L_WARN "%s.%s: Ignoring " pre " %N " post, ch->proto->name, ch->name, n); \ + return 0; \ + } while (0) + if (!net_validate(n)) - { - log(L_WARN "Ignoring bogus prefix %N received via %s", - n, ch->proto->name); - return 0; - } + IGNORING("bogus prefix", ""); /* FIXME: better handling different nettypes */ c = !net_is_flow(n) ? net_classify(n): (IADDR_HOST | SCOPE_UNIVERSE); if ((c < 0) || !(c & IADDR_HOST) || ((c & IADDR_SCOPE_MASK) <= SCOPE_LINK)) - { - log(L_WARN "Ignoring bogus route %N received via %s", - n, ch->proto->name); - return 0; - } + IGNORING("bogus route", ""); if (net_type_match(n, NB_DEST)) { @@ -1637,26 +1634,14 @@ rte_validate(struct channel *ch, rte *e) int dest = nhea_dest(nhea); if (dest == RTD_NONE) - { - log(L_WARN "Ignoring route %N with no destination received via %s", - n, ch->proto->name); - return 0; - } + IGNORING("route", "with no destination"); if ((dest == RTD_UNICAST) && !nexthop_is_sorted((struct nexthop_adata *) nhea->u.ptr)) - { - log(L_WARN "Ignoring unsorted multipath route %N received via %s", - n, ch->proto->name); - return 0; - } + IGNORING("unsorted multipath route", ""); } else if (ea_find(e->attrs, &ea_gen_nexthop)) - { - log(L_WARN "Ignoring route %N having a nexthop attribute received via %s", - n, ch->proto->name); - return 0; - } + IGNORING("route", "having a superfluous nexthop attribute"); return 1; }