-/* $OpenBSD: bgpd.c,v 1.251 2022/07/22 17:26:58 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.252 2022/07/23 10:24:00 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
return (0);
}
+/*
+ * Return true if a route can be used for nexthop resolution.
+ */
int
-bgpd_filternexthop(struct kroute_full *kf)
+bgpd_oknexthop(struct kroute_full *kf)
{
- /* kernel routes are never filtered */
- if (kf->flags & F_KERNEL && kf->prefixlen != 0)
- return (0);
+ if (kf->flags & F_BGPD)
+ return ((cflags & BGPD_FLAG_NEXTHOP_BGP) != 0);
- if (cflags & BGPD_FLAG_NEXTHOP_BGP) {
- if (kf->flags & F_BGPD)
- return (0);
- }
-
- if (cflags & BGPD_FLAG_NEXTHOP_DEFAULT) {
- if (kf->prefixlen == 0)
- return (0);
- }
+ if (kf->prefixlen == 0)
+ return ((cflags & BGPD_FLAG_NEXTHOP_DEFAULT) != 0);
+ /* any other route is fine */
return (1);
}
-/* $OpenBSD: bgpd.h,v 1.444 2022/07/22 17:26:58 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.445 2022/07/23 10:24:01 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
void send_imsg_session(int, pid_t, void *, uint16_t);
int send_network(int, struct network_config *,
struct filter_set_head *);
-int bgpd_filternexthop(struct kroute_full *);
+int bgpd_oknexthop(struct kroute_full *);
void set_pollfd(struct pollfd *, struct imsgbuf *);
int handle_pollfd(struct pollfd *, struct imsgbuf *);
-/* $OpenBSD: kroute.c,v 1.278 2022/07/22 17:26:58 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.279 2022/07/23 10:24:01 claudio Exp $ */
/*
* Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org>
}
struct kroute *
-kroute_match(struct ktable *kt, struct bgpd_addr *key, int matchall)
+kroute_match(struct ktable *kt, struct bgpd_addr *key, int matchany)
{
int i;
struct kroute *kr;
for (i = 32; i >= 0; i--) {
applymask(&masked, key, i);
if ((kr = kroute_find(kt, &masked, i, RTP_ANY)) != NULL)
- if (matchall ||
- bgpd_filternexthop(kr_tofull(kr)) == 0)
+ if (matchany || bgpd_oknexthop(kr_tofull(kr)))
return (kr);
}
}
struct kroute6 *
-kroute6_match(struct ktable *kt, struct bgpd_addr *key, int matchall)
+kroute6_match(struct ktable *kt, struct bgpd_addr *key, int matchany)
{
int i;
struct kroute6 *kr6;
for (i = 128; i >= 0; i--) {
applymask(&masked, key, i);
if ((kr6 = kroute6_find(kt, &masked, i, RTP_ANY)) != NULL)
- if (matchall ||
- bgpd_filternexthop(kr6_tofull(kr6)) == 0)
+ if (matchany || bgpd_oknexthop(kr6_tofull(kr6)))
return (kr6);
}