-/* $OpenBSD: bgpd.c,v 1.247 2022/06/22 14:56:11 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.248 2022/06/23 13:09:03 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
else
kr_show_route(&imsg);
break;
- case IMSG_IFINFO:
+ case IMSG_SESSION_DEPENDON:
if (idx != PFD_PIPE_SESSION)
- log_warnx("IFINFO request not from SE");
+ log_warnx("DEPENDON request not from SE");
else if (imsg.hdr.len != IMSG_HEADER_SIZE + IFNAMSIZ)
- log_warnx("IFINFO request with wrong len");
+ log_warnx("DEPENDON request with wrong len");
else
kr_ifinfo(imsg.data);
break;
-/* $OpenBSD: bgpd.h,v 1.436 2022/06/23 07:43:37 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.437 2022/06/23 13:09:03 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
IMSG_SESSION_STALE,
IMSG_SESSION_FLUSH,
IMSG_SESSION_RESTARTED,
+ IMSG_SESSION_DEPENDON,
IMSG_PFKEY_RELOAD,
IMSG_MRT_OPEN,
IMSG_MRT_REOPEN,
IMSG_PFTABLE_REMOVE,
IMSG_PFTABLE_COMMIT,
IMSG_REFRESH,
- IMSG_IFINFO,
IMSG_DEMOTE,
IMSG_XON,
IMSG_XOFF
uint8_t netlen;
};
-struct kif {
+struct session_dependon {
char ifname[IFNAMSIZ];
- uint64_t baudrate;
- u_int rdomain;
- int flags;
- u_short ifindex;
- uint8_t if_type;
- uint8_t link_state;
- uint8_t nh_reachable; /* for nexthop verification */
uint8_t depend_state; /* for session depend on */
};
-/* $OpenBSD: kroute.c,v 1.267 2022/06/23 10:22:23 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.268 2022/06/23 13:09:03 claudio Exp $ */
/*
* Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org>
LIST_HEAD(kif_kr_head, kif_kr);
LIST_HEAD(kif_kr6_head, kif_kr6);
+struct kif {
+ char ifname[IFNAMSIZ];
+ uint64_t baudrate;
+ u_int rdomain;
+ int flags;
+ u_short ifindex;
+ uint8_t if_type;
+ uint8_t link_state;
+ uint8_t nh_reachable; /* for nexthop verification */
+ uint8_t depend_state; /* for session depend on */
+};
+
struct kif_node {
RB_ENTRY(kif_node) entry;
struct kif k;
send_imsg_session(IMSG_CTL_END, imsg->hdr.pid, NULL, 0);
}
+static void
+kr_send_dependon(struct kif *kif)
+{
+ struct session_dependon sdon = { 0 };
+
+ strlcpy(sdon.ifname, kif->ifname, sizeof(sdon.ifname));
+ sdon.depend_state = kif->depend_state;
+ send_imsg_session(IMSG_SESSION_DEPENDON, 0, &sdon, sizeof(sdon));
+}
+
void
kr_ifinfo(char *ifname)
{
RB_FOREACH(kif, kif_tree, &kit)
if (!strcmp(ifname, kif->k.ifname)) {
- send_imsg_session(IMSG_IFINFO, 0,
- &kif->k, sizeof(kif->k));
+ kr_send_dependon(&kif->k);
return;
}
}
kif->k.baudrate = ifd->ifi_baudrate;
kif->k.depend_state = kif_depend_state(&kif->k);
- send_imsg_session(IMSG_IFINFO, 0, &kif->k, sizeof(kif->k));
+ kr_send_dependon(&kif->k);
if ((reachable = kif_validate(&kif->k)) == kif->k.nh_reachable)
return; /* nothing changed wrt nexthop validity */
-/* $OpenBSD: session.c,v 1.428 2022/06/19 10:30:10 claudio Exp $ */
+/* $OpenBSD: session.c,v 1.429 2022/06/23 13:09:03 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
p->fd = p->wbuf.fd = -1;
if (p->conf.if_depend[0])
- imsg_compose(ibuf_main, IMSG_IFINFO, 0, 0, -1,
+ imsg_compose(ibuf_main, IMSG_SESSION_DEPENDON, 0, 0, -1,
p->conf.if_depend, sizeof(p->conf.if_depend));
else
p->depend_ok = 1;
struct imsgbuf *i;
struct peer *p;
struct listen_addr *la, *nla;
- struct kif *kif;
+ struct session_dependon *sdon;
u_char *data;
int n, fd, depend_ok, restricted;
uint16_t t;
fatalx("reconf request not from parent");
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(restricted))
- fatalx("IFINFO imsg with wrong len");
+ fatalx("RECONF_CTRL imsg with wrong len");
memcpy(&restricted, imsg.data, sizeof(restricted));
if (imsg.fd == -1) {
log_warnx("expected to receive fd for control "
* the peer config sent in merge_peers().
*/
break;
- case IMSG_IFINFO:
+ case IMSG_SESSION_DEPENDON:
if (idx != PFD_PIPE_MAIN)
fatalx("IFINFO message not from parent");
if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct kif))
- fatalx("IFINFO imsg with wrong len");
- kif = imsg.data;
- depend_ok = kif->depend_state;
+ sizeof(struct session_dependon))
+ fatalx("DEPENDON imsg with wrong len");
+ sdon = imsg.data;
+ depend_ok = sdon->depend_state;
RB_FOREACH(p, peer_head, &conf->peers)
- if (!strcmp(p->conf.if_depend, kif->ifname)) {
+ if (!strcmp(p->conf.if_depend, sdon->ifname)) {
if (depend_ok && !p->depend_ok) {
p->depend_ok = depend_ok;
bgp_fsm(p, EVNT_START);