From fe164aedade678211ae088a10f04bb29f1b734d0 Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 19 Aug 2022 09:11:18 +0000 Subject: [PATCH] Fix nexthop lookup for connected routes. In knexthop_true_nexthop() connected routes need to be handled specially. If a nexthop is directly reachable the gateway needs to remain the same. There is no nexthop set for F_CONNECTED kroutes. A very similar trick is used in rde_rib.c::nexthop_update() but was forgotten here. Regression noticed by Daniel Jakots (danj at chown.me). OK tb@ --- usr.sbin/bgpd/kroute.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 8c55e80cd18..b7778fb1cb5 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.294 2022/08/18 17:02:42 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.295 2022/08/19 09:11:18 claudio Exp $ */ /* * Copyright (c) 2022 Claudio Jeker @@ -2152,11 +2152,15 @@ knexthop_true_nexthop(struct ktable *kt, struct kroute_full *kf) switch (kn->nexthop.aid) { case AID_INET: kr = kn->kroute; + if (kr->flags & F_CONNECTED) + return 1; gateway.aid = AID_INET; gateway.v4.s_addr = kr->nexthop.s_addr; break; case AID_INET6: kr6 = kn->kroute; + if (kr6->flags & F_CONNECTED) + return 1; gateway.aid = AID_INET6; gateway.v6 = kr6->nexthop; gateway.scope_id = kr6->nexthop_scope_id; -- 2.20.1