summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authordenis <denis@openbsd.org>2020-01-03 17:25:48 +0000
committerdenis <denis@openbsd.org>2020-01-03 17:25:48 +0000
commit7e18f1931aebad97de98a0cc9022e259c7fda4fb (patch)
treeaaff923c6c1809517d7ba4b9045f04d904a031ab /usr.sbin/ospf6d
parentRename the pipe I/O lock routines for improved clarity. This is just a (diff)
downloadwireguard-openbsd-7e18f1931aebad97de98a0cc9022e259c7fda4fb.tar.xz
wireguard-openbsd-7e18f1931aebad97de98a0cc9022e259c7fda4fb.zip
Sync with ospfd's hello.c
OK remi@
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/hello.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/usr.sbin/ospf6d/hello.c b/usr.sbin/ospf6d/hello.c
index a2cc1c47859..9c9b7a51484 100644
--- a/usr.sbin/ospf6d/hello.c
+++ b/usr.sbin/ospf6d/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.21 2019/12/23 11:25:41 remi Exp $ */
+/* $OpenBSD: hello.c,v 1.22 2020/01/03 17:25:48 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -41,8 +41,6 @@ send_hello(struct iface *iface)
struct hello_hdr hello;
struct nbr *nbr;
struct ibuf *buf;
- int ret;
- u_int32_t opts;
switch (iface->type) {
case IF_TYPE_POINTOPOINT:
@@ -72,10 +70,8 @@ send_hello(struct iface *iface)
/* hello header */
hello.iface_id = htonl(iface->ifindex);
LSA_24_SETHI(hello.opts, iface->priority);
- opts = area_ospf_options(iface->area);
- LSA_24_SETLO(hello.opts, opts);
+ LSA_24_SETLO(hello.opts, area_ospf_options(iface->area));
hello.opts = htonl(hello.opts);
-
hello.hello_interval = htons(iface->hello_interval);
hello.rtr_dead_interval = htons(iface->dead_interval);
@@ -104,10 +100,11 @@ send_hello(struct iface *iface)
if (upd_ospf_hdr(buf, iface))
goto fail;
- ret = send_packet(iface, buf, &dst);
+ if (send_packet(iface, buf, &dst) == -1)
+ goto fail;
ibuf_free(buf);
- return (ret);
+ return (0);
fail:
log_warn("send_hello");
ibuf_free(buf);
@@ -120,7 +117,6 @@ recv_hello(struct iface *iface, struct in6_addr *src, u_int32_t rtr_id,
{
struct hello_hdr hello;
struct nbr *nbr = NULL, *dr;
- struct area *area;
u_int32_t nbr_id, opts;
int nbr_change = 0;
@@ -148,12 +144,9 @@ recv_hello(struct iface *iface, struct in6_addr *src, u_int32_t rtr_id,
return;
}
- if ((area = iface->area) == NULL)
- fatalx("interface lost area");
-
opts = LSA_24_GETLO(ntohl(hello.opts));
- if ((opts & OSPF_OPTION_E && area->stub) ||
- ((opts & OSPF_OPTION_E) == 0 && !area->stub)) {
+ if ((opts & OSPF_OPTION_E && iface->area->stub) ||
+ ((opts & OSPF_OPTION_E) == 0 && !iface->area->stub)) {
log_warnx("recv_hello: ExternalRoutingCapability mismatch, "
"interface %s", iface->name);
return;
@@ -161,8 +154,15 @@ recv_hello(struct iface *iface, struct in6_addr *src, u_int32_t rtr_id,
/* match router-id */
LIST_FOREACH(nbr, &iface->nbr_list, entry) {
- if (nbr == iface->self)
+ if (nbr == iface->self) {
+ if (nbr->id.s_addr == rtr_id) {
+ log_warnx("recv_hello: Router-ID collision on "
+ "interface %s neighbor IP %s", iface->name,
+ log_in6addr(src));
+ return;
+ }
continue;
+ }
if (nbr->id.s_addr == rtr_id)
break;
}