Skip to content

Commit 09ea90d

Browse files
simonartxavieralmusil
authored andcommitted
ovn-ic: Fix routes not deleted when lr is disabled.
Fix routes not deleted when lr is disabled and pb address is cleared simultaneously. When a logical router is disabled, northd clears the IC-SB port binding address. If ovn-ic handles both changes in the same iteration, learned routes were not deleted. This issue was highlighted by sporadic failures of test [0]. [0] "ovn-ic -- Check loop with lsp orphan in same subnet of new lsp in other TS". Fixes: ddc0200 ("ic: Fix loop disable/enable logical router.") Signed-off-by: Xavier Simonart <xsimonar@redhat.com> Acked-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ales Musil <amusil@redhat.com> (cherry picked from commit f452d37)
1 parent 996f2d3 commit 09ea90d

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

ic/ovn-ic.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,32 @@ advertise_routes(struct ic_context *ctx,
17641764
}
17651765
}
17661766

1767+
static void
1768+
collect_learned_routes(struct ic_router_info *ic_lr)
1769+
{
1770+
const struct nbrec_logical_router *lr = ic_lr->lr;
1771+
1772+
/* Check static routes of the LR and collect learned routes */
1773+
for (int i = 0; i < lr->n_static_routes; i++) {
1774+
const struct nbrec_logical_router_static_route *nb_route
1775+
= lr->static_routes[i];
1776+
struct uuid isb_uuid;
1777+
if (smap_get_uuid(&nb_route->external_ids, "ic-learned-route",
1778+
&isb_uuid)) {
1779+
/* It is a learned route */
1780+
if (!add_to_routes_learned(&ic_lr->routes_learned, nb_route, lr,
1781+
&isb_uuid)) {
1782+
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
1783+
VLOG_WARN_RL(&rl, "Bad format of learned route in NB: "
1784+
"%s -> %s. Delete it.", nb_route->ip_prefix,
1785+
nb_route->nexthop);
1786+
nbrec_logical_router_update_static_routes_delvalue(lr,
1787+
nb_route);
1788+
}
1789+
}
1790+
}
1791+
}
1792+
17671793
static void
17681794
build_ts_routes_to_adv(struct ic_context *ctx,
17691795
struct ic_router_info *ic_lr,
@@ -1834,6 +1860,7 @@ collect_lr_routes(struct ic_context *ctx,
18341860

18351861
struct hmap *routes_ad;
18361862
const struct icnbrec_transit_switch *t_sw;
1863+
bool routes_built = false;
18371864
for (int i = 0; i < ic_lr->n_isb_pbs; i++) {
18381865
isb_pb = ic_lr->isb_pbs[i];
18391866
key = icnbrec_transit_switch_index_init_row(
@@ -1870,10 +1897,17 @@ collect_lr_routes(struct ic_context *ctx,
18701897
route_table = "";
18711898
route_tag = "";
18721899
}
1900+
routes_built = true;
18731901
build_ts_routes_to_adv(ctx, ic_lr, routes_ad, &ts_port_addrs,
18741902
nb_global, route_table, route_tag);
18751903
destroy_lport_addresses(&ts_port_addrs);
18761904
}
1905+
/* If no port binding had valid addresses (e.g. LR disabled
1906+
* and PB address cleared simultaneously), collect learned routes so
1907+
* they can be deleted by sync_learned_routes(). */
1908+
if (!routes_built) {
1909+
collect_learned_routes(ic_lr);
1910+
}
18771911
}
18781912

18791913
static void

tests/ovn-ic.at

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,6 +3069,25 @@ OVS_WAIT_FOR_OUTPUT([ovn_as az1 ovn-nbctl lr-route-list lr11 | grep 192.168 |
30693069
192.168.0.0/24 169.254.101.22
30703070
])
30713071

3072+
# Do the same but with ovn-ic handling both northd and isb change at the same time.
3073+
echo az1/ic going to sleep
3074+
AT_CHECK([kill -STOP $(cat az1/ic/ovn-ic.pid)])
3075+
on_exit "test -e az1/ic/ovn-ic.pid && kill -CONT $(cat az1/ic/ovn-ic.pid)"
3076+
3077+
check ovn_as az1 ovn-nbctl --wait=sb set logical_router lr11 enable=false
3078+
echo az1/ic going to wake up
3079+
AT_CHECK([kill -CONT $(cat az1/ic/ovn-ic.pid)])
3080+
3081+
OVS_WAIT_FOR_OUTPUT([ovn_as az1 ovn-nbctl lr-route-list lr11 | grep 192.168 |
3082+
grep learned | awk '{print $1, $2}' | sort ], [0], [dnl
3083+
])
3084+
3085+
check ovn_as az1 ovn-nbctl set logical_router lr11 enable=true
3086+
OVS_WAIT_FOR_OUTPUT([ovn_as az1 ovn-nbctl lr-route-list lr11 | grep 192.168 |
3087+
grep learned | awk '{print $1, $2}' | sort ], [0], [dnl
3088+
192.168.0.0/24 169.254.101.22
3089+
])
3090+
30723091
OVN_CLEANUP_IC([az1], [az2])
30733092

30743093
AT_CLEANUP

0 commit comments

Comments
 (0)