summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ospfd/kroute.c19
-rw-r--r--usr.sbin/ospfd/ospfd.h7
-rw-r--r--usr.sbin/ospfd/ospfe.c35
3 files changed, 50 insertions, 11 deletions
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c
index dd078776b1b..233e4f9281b 100644
--- a/usr.sbin/ospfd/kroute.c
+++ b/usr.sbin/ospfd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.109 2018/02/11 02:27:33 benno Exp $ */
+/* $OpenBSD: kroute.c,v 1.110 2018/06/25 22:16:53 remi Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -1072,8 +1072,9 @@ void
if_newaddr(u_short ifindex, struct sockaddr_in *ifa, struct sockaddr_in *mask,
struct sockaddr_in *brd)
{
- struct kif_node *kif;
- struct kif_addr *ka;
+ struct kif_node *kif;
+ struct kif_addr *ka;
+ struct ifaddrchange ifn;
if (ifa == NULL || ifa->sin_family != AF_INET)
return;
@@ -1094,15 +1095,21 @@ if_newaddr(u_short ifindex, struct sockaddr_in *ifa, struct sockaddr_in *mask,
ka->dstbrd.s_addr = INADDR_NONE;
TAILQ_INSERT_TAIL(&kif->addrs, ka, entry);
+
+ ifn.addr = ka->addr;
+ ifn.mask = ka->mask;
+ ifn.dst = ka->dstbrd;
+ ifn.ifindex = ifindex;
+ main_imsg_compose_ospfe(IMSG_IFADDRADD, 0, &ifn, sizeof(ifn));
}
void
if_deladdr(u_short ifindex, struct sockaddr_in *ifa, struct sockaddr_in *mask,
struct sockaddr_in *brd)
{
- struct kif_node *kif;
- struct kif_addr *ka, *nka;
- struct ifaddrdel ifc;
+ struct kif_node *kif;
+ struct kif_addr *ka, *nka;
+ struct ifaddrchange ifc;
if (ifa == NULL || ifa->sin_family != AF_INET)
return;
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index dd397d27cd5..1b772a4acdc 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.100 2018/02/11 02:27:33 benno Exp $ */
+/* $OpenBSD: ospfd.h,v 1.101 2018/06/25 22:16:53 remi Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -132,6 +132,7 @@ enum imsg_type {
IMSG_RECONF_REDIST,
IMSG_RECONF_END,
IMSG_DEMOTE,
+ IMSG_IFADDRADD,
IMSG_IFADDRDEL
};
@@ -363,8 +364,10 @@ struct iface {
u_int8_t passive;
};
-struct ifaddrdel {
+struct ifaddrchange {
struct in_addr addr;
+ struct in_addr mask;
+ struct in_addr dst;
unsigned int ifindex;
};
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index 693e3a6d5a9..d222670208b 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.100 2018/02/05 12:11:28 remi Exp $ */
+/* $OpenBSD: ospfe.c,v 1.101 2018/06/25 22:16:53 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -275,7 +275,7 @@ ospfe_dispatch_main(int fd, short event, void *bula)
{
static struct area *narea;
static struct iface *niface;
- struct ifaddrdel *ifc;
+ struct ifaddrchange *ifc;
struct imsg imsg;
struct imsgev *iev = bula;
struct imsgbuf *ibuf = &iev->ibuf;
@@ -361,9 +361,38 @@ ospfe_dispatch_main(int fd, short event, void *bula)
}
}
break;
+ case IMSG_IFADDRADD:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE +
+ sizeof(struct ifaddrchange))
+ fatalx("IFADDRADD imsg with wrong len");
+ ifc = imsg.data;
+
+ LIST_FOREACH(area, &oeconf->area_list, entry) {
+ LIST_FOREACH(iface, &area->iface_list, entry) {
+ if (ifc->ifindex == iface->ifindex &&
+ ifc->addr.s_addr ==
+ iface->addr.s_addr) {
+ iface->mask = ifc->mask;
+ iface->dst = ifc->dst;
+ /*
+ * Previous down event might
+ * have failed if the address
+ * was not present at that
+ * time.
+ */
+ if_fsm(iface, IF_EVT_DOWN);
+ if_fsm(iface, IF_EVT_UP);
+ log_warnx("interface %s:%s "
+ "returned", iface->name,
+ inet_ntoa(iface->addr));
+ break;
+ }
+ }
+ }
+ break;
case IMSG_IFADDRDEL:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct ifaddrdel))
+ sizeof(struct ifaddrchange))
fatalx("IFADDRDEL imsg with wrong len");
ifc = imsg.data;