On Thu, Jan 02, 2020 at 05:17:02PM +0100, Denis Fondras wrote:
> Sync with ospfd's hello.c

ok remi@

> 
> Index: hello.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ospf6d/hello.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 hello.c
> --- hello.c   23 Dec 2019 11:25:41 -0000      1.21
> +++ hello.c   2 Jan 2020 16:11:19 -0000
> @@ -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 i
>  {
>       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 i
>               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 i
>  
>       /* 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;
>       }
> 

Reply via email to