diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2018-06-28 08:55:57 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2018-06-28 08:55:57 +0000 |
commit | b3cb197b949759ba51666900651f4a2b8b1a73ca (patch) | |
tree | 7ea307549f85d2e0c1702968e020640a11a6fec6 | |
parent | fff229ff59fdb45017e257976da874ff5cf76ce9 (diff) |
Instead of passing the rde_aspath to nexthop_modify() pass pointers to
the nexthop and the flags.
-rw-r--r-- | usr.sbin/bgpd/rde.h | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_filter.c | 8 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 32 |
3 files changed, 25 insertions, 21 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 6bb7f7b8c0d..c85551b1764 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.172 2018/06/28 08:07:21 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.173 2018/06/28 08:55:56 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -507,8 +507,8 @@ prefix_peer(struct prefix *p) void nexthop_init(u_int32_t); void nexthop_shutdown(void); -void nexthop_modify(struct rde_aspath *, struct nexthop *, - enum action_types, u_int8_t); +void nexthop_modify(struct nexthop *, enum action_types, u_int8_t, + struct nexthop **, u_int32_t *); void nexthop_link(struct rde_aspath *); void nexthop_unlink(struct rde_aspath *); void nexthop_update(struct kroute_nexthop *); diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c index 08de8583921..ed236ec691a 100644 --- a/usr.sbin/bgpd/rde_filter.c +++ b/usr.sbin/bgpd/rde_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_filter.c,v 1.91 2018/06/28 08:07:21 claudio Exp $ */ +/* $OpenBSD: rde_filter.c,v 1.92 2018/06/28 08:55:56 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -49,6 +49,9 @@ rde_apply_set(struct filter_set_head *sh, struct rde_aspath *asp, if (asp == NULL) return; + if (asp->flags & F_ATTR_LINKED) + fatalx("rde_apply_set: trying to modify linked asp"); + TAILQ_FOREACH(set, sh, entry) { switch (set->type) { case ACTION_SET_LOCALPREF: @@ -130,7 +133,8 @@ rde_apply_set(struct filter_set_head *sh, struct rde_aspath *asp, case ACTION_SET_NEXTHOP_BLACKHOLE: case ACTION_SET_NEXTHOP_NOMODIFY: case ACTION_SET_NEXTHOP_SELF: - nexthop_modify(asp, set->action.nh, set->type, aid); + nexthop_modify(set->action.nh, set->type, aid, + &asp->nexthop, &asp->flags); break; case ACTION_SET_COMMUNITY: switch (set->action.community.as) { diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 7e51e58a793..6ba15e94998 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.163 2018/06/28 08:07:21 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.164 2018/06/28 08:55:56 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -1227,32 +1227,32 @@ nexthop_update(struct kroute_nexthop *msg) } void -nexthop_modify(struct rde_aspath *asp, struct nexthop *nh, - enum action_types type, u_int8_t aid) +nexthop_modify(struct nexthop *setnh, enum action_types type, u_int8_t aid, + struct nexthop **nexthop, u_int32_t *flags) { - if (asp->flags & F_ATTR_LINKED) - fatalx("nexthop_modify: trying to modify linked asp"); - - if (type == ACTION_SET_NEXTHOP && aid != nh->exit_nexthop.aid) - return; - - asp->flags &= ~F_NEXTHOP_MASK; + *flags &= ~F_NEXTHOP_MASK; switch (type) { case ACTION_SET_NEXTHOP_REJECT: - asp->flags |= F_NEXTHOP_REJECT; + *flags |= F_NEXTHOP_REJECT; break; case ACTION_SET_NEXTHOP_BLACKHOLE: - asp->flags |= F_NEXTHOP_BLACKHOLE; + *flags |= F_NEXTHOP_BLACKHOLE; break; case ACTION_SET_NEXTHOP_NOMODIFY: - asp->flags |= F_NEXTHOP_NOMODIFY; + *flags |= F_NEXTHOP_NOMODIFY; break; case ACTION_SET_NEXTHOP_SELF: - asp->flags |= F_NEXTHOP_SELF; + *flags |= F_NEXTHOP_SELF; break; case ACTION_SET_NEXTHOP: - nexthop_put(asp->nexthop); - asp->nexthop = nexthop_ref(nh); + /* + * it is possible that a prefix matches but has the wrong + * address family for the set nexthop. In this case ignore it. + */ + if (aid != setnh->exit_nexthop.aid) + break; + nexthop_put(*nexthop); + *nexthop = nexthop_ref(setnh); break; default: break; |