0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Merge commit '00b139bd' into thread-merge-2.16

This commit is contained in:
Maria Matejka 2024-11-28 09:09:00 +01:00
commit cbd986cd35

View File

@ -1593,8 +1593,24 @@ done:
}
static inline int
nl_allow_replace(struct krt_proto *p, rte *new)
nl_allow_replace(struct krt_proto *p, const rte *new, const rte *old)
{
/*
* In kernel routing tables, (net, metric) is the primary key. Therefore, we
* can use NL_OP_REPLACE only if the new and and the old route have the same
* kernel metric, otherwise the replace would just add the new route while
* keep the old one.
*/
if ((p->af != AF_MPLS) && (KRT_CF->sys.metric == 0))
{
uint new_metric = ea_get_int(new->attrs, &ea_krt_metric, 0);
uint old_metric = ea_get_int(old->attrs, &ea_krt_metric, 0);
if (new_metric != old_metric)
return 0;
}
/*
* We use NL_OP_REPLACE for IPv4, it has an issue with not checking for
* matching rtm_protocol, but that is OK when dedicated priority is used.
@ -1626,7 +1642,7 @@ krt_replace_rte(struct krt_proto *p, const net_addr *n UNUSED, rte *new, const r
{
int err = 0;
if (old && new && nl_allow_replace(p, new))
if (old && new && nl_allow_replace(p, new, old))
{
err = nl_send_route(p, new, NL_OP_REPLACE);
}