From 0d986b66d2d97d792c958059559baa9c9dbf2c89 Mon Sep 17 00:00:00 2001 From: Rob Brockbank Date: Tue, 16 Jan 2018 23:13:23 -0800 Subject: [PATCH] Check interface index when scanning routes --- .gitignore | 2 ++ sysdep/unix/krt.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 52510836..ec75d6fe 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ /configure /bird.conf /bird.log +dist +configure.lineno diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index d4c9cc62..25563bde 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -657,7 +657,17 @@ krt_same_dest(rte *k, rte *e) switch (ka->dest) { case RTD_ROUTER: - return ipa_equal(ka->gw, ea->gw); + /* Calico-BIRD specific: in addition to checking that the gw is the same, we + * also check that the interface is as expected - this covers the case where + * a route was previously using the IPIP tunnel but is no longer: the gateway + * may be the same but the interface will be different. The calculated + * interface index will be for the non-tunl route. Only at the point the route + * is programmed in nl_send_route does the tunnel index get calculated. + * Therefore the check performed here is not valid when the route should be + * over the tunnel - hence there is an an explicit check in krt_got_route for + * the tunnel scenario, and in that case krt_same_dest is not invoked. + */ + return ipa_equal(ka->gw, ea->gw) && ka->iface->index == ea->iface->index; case RTD_DEVICE: return !strcmp(ka->iface->name, ea->iface->name); case RTD_MULTIPATH: