-/* $OpenBSD: rde.c,v 1.519 2021/04/27 09:07:10 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.520 2021/05/06 09:18:54 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
rde_dump_ctx_throttle(imsg.hdr.pid, 1);
}
break;
+ case IMSG_RECONF_DRAIN:
+ imsg_compose(ibuf_se, IMSG_RECONF_DRAIN, 0, 0,
+ -1, NULL, 0);
+ break;
default:
break;
}
char *p = NULL;
if (!((conf->log & BGPD_LOG_UPDATES) ||
- (peer->conf.flags & PEERFLAG_LOG_UPDATES)))
+ (peer->flags & PEERFLAG_LOG_UPDATES)))
return;
if (next != NULL)
if (peer->state != PEER_UP)
continue;
/* handle evaluate all, keep track if it is needed */
- if (peer->conf.flags & PEERFLAG_EVALUATE_ALL)
+ if (peer->flags & PEERFLAG_EVALUATE_ALL)
rde_eval_all = 1;
else if (eval_all)
/* skip default peers if the best path didn't change */
if (peer->capa.mp[aid] == 0)
continue;
/* skip peers with special export types */
- if (peer->conf.export_type == EXPORT_NONE ||
- peer->conf.export_type == EXPORT_DEFAULT_ROUTE)
+ if (peer->export_type == EXPORT_NONE ||
+ peer->export_type == EXPORT_DEFAULT_ROUTE)
continue;
up_generate_updates(out_rules, peer, new, old);
continue;
peer->reconf_out = 0;
peer->reconf_rib = 0;
+ if (peer->export_type != peer->conf.export_type) {
+ log_peer_info(&peer->conf, "export type change, "
+ "reloading");
+ peer->reconf_rib = 1;
+ }
+ if ((peer->flags & PEERFLAG_EVALUATE_ALL) !=
+ (peer->conf.flags & PEERFLAG_EVALUATE_ALL)) {
+ log_peer_info(&peer->conf, "rde evaluate change, "
+ "reloading");
+ peer->reconf_rib = 1;
+ }
+ if ((peer->flags & PEERFLAG_TRANS_AS) !=
+ (peer->conf.flags & PEERFLAG_TRANS_AS)) {
+ log_peer_info(&peer->conf, "transparent-as change, "
+ "reloading");
+ peer->reconf_rib = 1;
+ }
if (peer->loc_rib_id != rib_find(peer->conf.rib)) {
log_peer_info(&peer->conf, "rib change, reloading");
peer->loc_rib_id = rib_find(peer->conf.rib);
if (peer->loc_rib_id == RIB_NOTFOUND)
fatalx("King Bula's peer met an unknown RIB");
peer->reconf_rib = 1;
- softreconfig++;
+ }
+ peer->export_type = peer->conf.export_type;
+ peer->flags = peer->conf.flags;
+
+ if (peer->reconf_rib) {
if (prefix_dump_new(peer, AID_UNSPEC,
RDE_RUNNER_ROUNDS, NULL, rde_up_flush_upcall,
rde_softreconfig_in_done, NULL) == -1)
log_info("RDE reconfigured");
+ softreconfig++;
if (reload > 0) {
- softreconfig++;
if (rib_dump_new(RIB_ADJ_IN, AID_UNSPEC, RDE_RUNNER_ROUNDS,
- rib_byid(RIB_ADJ_IN), rde_softreconfig_in,
- rde_softreconfig_in_done, NULL) == -1)
+ NULL, rde_softreconfig_in, rde_softreconfig_in_done,
+ NULL) == -1)
fatal("%s: rib_dump_new", __func__);
log_info("running softreconfig in");
} else {
- rde_softreconfig_in_done(NULL, AID_UNSPEC);
+ rde_softreconfig_in_done((void *)1, AID_UNSPEC);
}
}
struct rde_peer *peer;
u_int16_t i;
- if (arg != NULL) {
- softreconfig--;
- /* one guy done but other dumps are still running */
- if (softreconfig > 0)
- return;
+ softreconfig--;
+ /* one guy done but other dumps are still running */
+ if (softreconfig > 0)
+ return;
+ if (arg == NULL)
log_info("softreconfig in done");
- }
/* now do the Adj-RIB-Out sync and a possible FIB sync */
softreconfig = 0;
u_int8_t aid;
if (peer->reconf_out) {
- if (peer->conf.export_type == EXPORT_NONE) {
+ if (peer->export_type == EXPORT_NONE) {
/* nothing to do here */
peer->reconf_out = 0;
- } else if (peer->conf.export_type ==
- EXPORT_DEFAULT_ROUTE) {
+ } else if (peer->export_type == EXPORT_DEFAULT_ROUTE) {
/* just resend the default route */
for (aid = 0; aid < AID_MAX; aid++) {
if (peer->capa.mp[aid])
static int
rde_no_as_set(struct rde_peer *peer)
{
- return (peer->conf.flags & PEERFLAG_NO_AS_SET);
+ return (peer->flags & PEERFLAG_NO_AS_SET);
}
/* End-of-RIB marker, RFC 4724 */
-/* $OpenBSD: rde.h,v 1.237 2021/03/02 09:45:07 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.238 2021/05/06 09:18:54 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
u_int32_t up_nlricnt;
u_int32_t up_wcnt;
enum peer_state state;
+ enum export_type export_type;
u_int16_t loc_rib_id;
u_int16_t short_as;
u_int16_t mrt_idx;
u_int8_t reconf_out; /* out filter changed */
u_int8_t reconf_rib; /* rib changed */
u_int8_t throttled;
+ u_int8_t flags;
};
#define AS_SET 1
-/* $OpenBSD: rde_peer.c,v 1.6 2020/12/04 11:57:13 claudio Exp $ */
+/* $OpenBSD: rde_peer.c,v 1.7 2021/05/06 09:18:54 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
if (peer->loc_rib_id == RIB_NOTFOUND)
fatalx("King Bula's new peer met an unknown RIB");
peer->state = PEER_NONE;
+ peer->export_type = peer->conf.export_type;
+ peer->flags = peer->conf.flags;
SIMPLEQ_INIT(&peer->imsg_queue);
head = PEER_HASH(id);
void
peer_dump(struct rde_peer *peer, u_int8_t aid)
{
- if (peer->conf.export_type == EXPORT_NONE) {
+ if (peer->export_type == EXPORT_NONE) {
/* nothing to send apart from the marker */
if (peer->capa.grestart.restart)
prefix_add_eor(peer, aid);
- } else if (peer->conf.export_type == EXPORT_DEFAULT_ROUTE) {
+ } else if (peer->export_type == EXPORT_DEFAULT_ROUTE) {
up_generate_default(out_rules, peer, aid);
rde_up_dump_done(peer, aid);
} else {
-/* $OpenBSD: rde_update.c,v 1.126 2021/04/20 11:19:56 claudio Exp $ */
+/* $OpenBSD: rde_update.c,v 1.127 2021/05/06 09:18:54 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
* skip the filters.
*/
if (need_withdraw &&
- !(peer->conf.flags & PEERFLAG_EVALUATE_ALL)) {
+ !(peer->flags & PEERFLAG_EVALUATE_ALL)) {
new = NULL;
goto again;
}
new->pt->prefixlen, prefix_vstate(new), &state) ==
ACTION_DENY) {
rde_filterstate_clean(&state);
- if (peer->conf.flags & PEERFLAG_EVALUATE_ALL)
+ if (peer->flags & PEERFLAG_EVALUATE_ALL)
new = LIST_NEXT(new, entry.list.rib);
else
new = NULL;
break;
case ATTR_ASPATH:
if (!peer->conf.ebgp ||
- peer->conf.flags & PEERFLAG_TRANS_AS)
+ peer->flags & PEERFLAG_TRANS_AS)
pdata = aspath_prepend(asp->aspath,
peer->conf.local_as, 0, &plen);
else
*/
if (asp->flags & F_ATTR_MED && (!peer->conf.ebgp ||
asp->flags & F_ATTR_MED_ANNOUNCE ||
- peer->conf.flags & PEERFLAG_TRANS_AS)) {
+ peer->flags & PEERFLAG_TRANS_AS)) {
tmp32 = htonl(asp->med);
if ((r = attr_write(buf + wlen, len,
ATTR_OPTIONAL, ATTR_MED, &tmp32, 4)) == -1)
case ATTR_AS4_PATH:
if (neednewpath) {
if (!peer->conf.ebgp ||
- peer->conf.flags & PEERFLAG_TRANS_AS)
+ peer->flags & PEERFLAG_TRANS_AS)
pdata = aspath_prepend(asp->aspath,
peer->conf.local_as, 0, &plen);
else
-/* $OpenBSD: session.c,v 1.413 2021/05/03 14:08:09 claudio Exp $ */
+/* $OpenBSD: session.c,v 1.414 2021/05/06 09:18:54 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
}
break;
case IMSG_RECONF_DRAIN:
- if (idx != PFD_PIPE_MAIN)
- fatalx("reconf request not from parent");
- imsg_compose(ibuf_main, IMSG_RECONF_DRAIN, 0, 0,
- -1, NULL, 0);
+ switch (idx) {
+ case PFD_PIPE_ROUTE:
+ if (nconf != NULL)
+ fatalx("got unexpected %s from RDE",
+ "IMSG_RECONF_DONE");
+ imsg_compose(ibuf_main, IMSG_RECONF_DONE, 0, 0,
+ -1, NULL, 0);
+ break;
+ case PFD_PIPE_MAIN:
+ if (nconf == NULL)
+ fatalx("got unexpected %s from parent",
+ "IMSG_RECONF_DONE");
+ imsg_compose(ibuf_main, IMSG_RECONF_DRAIN, 0, 0,
+ -1, NULL, 0);
+ break;
+ default:
+ fatalx("reconf request not from parent or RDE");
+ }
break;
case IMSG_RECONF_DONE:
if (idx != PFD_PIPE_MAIN)
nconf = NULL;
pending_reconf = 0;
log_info("SE reconfigured");
- imsg_compose(ibuf_main, IMSG_RECONF_DONE, 0, 0,
- -1, NULL, 0);
+ /*
+ * IMSG_RECONF_DONE is sent when the RDE drained
+ * the peer config sent in merge_peers().
+ */
break;
case IMSG_IFINFO:
if (idx != PFD_PIPE_MAIN)
}
}
+ if (imsg_rde(IMSG_RECONF_DRAIN, 0, NULL, 0) == -1)
+ fatalx("imsg_compose error");
+
/* pfkeys of new peers already loaded by the parent process */
RB_FOREACH_SAFE(np, peer_head, &nc->peers, next) {
RB_REMOVE(peer_head, &nc->peers, np);