diff options
author | denis <denis@cvs.openbsd.org> | 2020-01-03 17:25:49 +0000 |
---|---|---|
committer | denis <denis@cvs.openbsd.org> | 2020-01-03 17:25:49 +0000 |
commit | f5fb74aa6c5011a882527f0294128e3f8822a2e3 (patch) | |
tree | 625f269fb51ba0aadb9369829e8f8902a1ffe5cc | |
parent | 995f113e92224aeab2430ba076a6403415ade514 (diff) |
Sync with ospfd's hello.c
OK remi@
-rw-r--r-- | usr.sbin/ospf6d/hello.c | 30 |
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; } |