0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00

Route export: dropped tail-execution of do_rt_notify()

This commit is contained in:
Maria Matejka 2020-03-06 15:41:51 +01:00 committed by Maria Matejka
parent 05336bb615
commit d53623f120
2 changed files with 33 additions and 19 deletions

View File

@ -73,6 +73,7 @@ static inline int u64_cmp(u64 i1, u64 i2)
#define UNUSED __attribute__((unused))
#define PACKED __attribute__((packed))
#define NONNULL(...) __attribute__((nonnull((__VA_ARGS__))))
#define USE_RESULT __attribute__((warn_unused_result))
#ifndef HAVE_THREAD_LOCAL
#define _Thread_local

View File

@ -566,7 +566,7 @@ do_rt_notify(struct channel *c, struct rte_export_internal *e)
rte_free_quick(old_exported);
}
static void
USE_RESULT static _Bool
rt_notify_basic(struct channel *c, struct rte_export_internal *e)
{
if (e->pub.new)
@ -581,12 +581,12 @@ rt_notify_basic(struct channel *c, struct rte_export_internal *e)
e->pub.old = NULL;
if (!e->pub.new && !e->pub.old)
return;
return 0;
do_rt_notify(c, e);
return 1;
}
static void
USE_RESULT static _Bool
rt_notify_accepted(struct channel *c, struct rte_export_internal *e)
{
// struct proto *p = c->proto;
@ -648,18 +648,18 @@ rt_notify_accepted(struct channel *c, struct rte_export_internal *e)
if (new_first && (e->pub.new = export_filter(c, e->pub.new, &e->rt_free, 0)))
new_best = e->pub.new;
else
return;
return 0;
}
if (!new_best && !old_best)
return;
return 0;
e->pub.new = new_best;
e->pub.new_src = new_best ? new_best->attrs->src : NULL;
e->pub.old = old_best;
e->pub.old_src = old_best ? old_best->attrs->src : NULL;
do_rt_notify(c, e);
return 1;
}
@ -722,21 +722,21 @@ rt_export_merged(struct channel *c, net *net, rte **rt_free, linpool *pool, int
}
static void
USE_RESULT static _Bool
rt_notify_merged(struct channel *c, struct rte_export_internal *e)
{
/* We assume that all rte arguments are either NULL or rte_is_valid() */
/* This check should be done by the caller */
if (!e->new_best && !e->old_best)
return;
return 0;
/* Check whether the change is relevant to the merged route */
if ((e->new_best == e->old_best) &&
(e->pub.new != e->pub.old) &&
!rte_mergable(e->new_best, e->pub.new) &&
!rte_mergable(e->old_best, e->pub.old))
return;
return 0;
if (e->new_best)
c->stats.exp_updates_received++;
@ -752,12 +752,12 @@ rt_notify_merged(struct channel *c, struct rte_export_internal *e)
e->pub.old = NULL;
if (!e->pub.new && !e->pub.old)
return;
return 0;
e->pub.new_src = e->pub.new ? e->pub.new->attrs->src : NULL;
e->pub.old_src = e->pub.old ? e->pub.old->attrs->src : NULL;
do_rt_notify(c, e);
return 1;
}
@ -862,24 +862,31 @@ rte_announce(rtable *tab, uint type, net *net, rte *new, rte *old,
e.pub.new_src = new_best ? new_best->attrs->src : NULL;
e.pub.old = old_best;
e.pub.old_src = old_best ? old_best->attrs->src : NULL;
rt_notify_basic(c, &e);
if (!rt_notify_basic(c, &e))
goto next_channel;
}
break;
case RA_ANY:
if (new != old)
rt_notify_basic(c, &e);
if (!rt_notify_basic(c, &e))
goto next_channel;
break;
case RA_ACCEPTED:
rt_notify_accepted(c, &e);
if (!rt_notify_accepted(c, &e))
goto next_channel;
break;
case RA_MERGED:
rt_notify_merged(c, &e);
if (!rt_notify_merged(c, &e))
goto next_channel;
break;
}
do_rt_notify(c, &e);
next_channel:
/* Discard temporary rte */
if (e.rt_free)
rte_free(e.rt_free);
@ -2267,19 +2274,25 @@ rt_feed_channel(struct channel *c)
ee.pub.new_src = e->attrs->src;
ee.pub.old = e;
ee.pub.old_src = e->attrs->src;
rt_notify_basic(c, &ee);
if (!rt_notify_basic(c, &ee))
goto next_rte;
break;
case RA_ACCEPTED:
rt_notify_accepted(c, &ee);
if (!rt_notify_accepted(c, &ee))
goto next_rte;
break;
case RA_MERGED:
rt_notify_merged(c, &ee);
if (!rt_notify_merged(c, &ee))
goto next_rte;
break;
default:
ASSERT(0);
}
do_rt_notify(c, &ee);
/* Discard temporary rte */
next_rte:
if (ee.rt_free)
rte_free(ee.rt_free);
}