Hi Martin

thanks for your patch. This patch works for me on OpenBSD 4.9-stable and
-current. Still some issues left but at least ospf6d does not crash on
interface add...

it would be really nice if this gets into the tree...


Am 01.06.2011 22:46, schrieb Martin Pelikan:
> Hi!
>
> So my last attempt wasn't met with much appreciation, so I'll slow down:
>
> - when I add a vlan(4), vether(4) or something, my ospf6d dies
> - I don't like that
> - therefore, with new release comes new diff
> - this time I tried to make it as small as possible, in separate parts
>
> It doesn't fix departures (if_leave_group jumps on a non-existing
> interface), but I guess people don't remove interfaces that often. 
> I will rewrite and post the rest of the big one if someone shows
> interest in this bit.
>
> --
> Martin Pelikan
>
>
> Index: kroute.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ospf6d/kroute.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 kroute.c
> --- kroute.c  7 Mar 2011 07:43:02 -0000       1.30
> +++ kroute.c  1 Jun 2011 20:36:31 -0000
> @@ -973,15 +973,22 @@ if_announce(void *msg)
>               if ((iface = if_new(ifan->ifan_index, ifan->ifan_name)) == NULL)
>                       fatal("if_announce failed");
>               iface->cflags |= F_IFACE_AVAIL;
> +             main_imsg_compose_rde(IMSG_IFADD, 0,
> +                 iface, sizeof(struct iface));
> +             main_imsg_compose_ospfe(IMSG_IFADD, 0,
> +                 iface, sizeof(struct iface));
>               break;
>       case IFAN_DEPARTURE:
> -             iface = if_find(ifan->ifan_index);
> -             if (iface->cflags & F_IFACE_CONFIGURED) {
> -                     main_imsg_compose_rde(IMSG_IFDELETE, 0,
> -                         &iface->ifindex, sizeof(iface->ifindex));
> -                     main_imsg_compose_ospfe(IMSG_IFDELETE, 0,
> -                         &iface->ifindex, sizeof(iface->ifindex));
> +             if ((iface = if_find(ifan->ifan_index)) == NULL)  {
> +                     log_warn("someone announced departure of non-existing "
> +                         "interface %s - possible race condition?",
> +                         ifan->ifan_name);
> +                     return;
>               }
> +             main_imsg_compose_rde(IMSG_IFDELETE, 0,
> +                 &iface->ifindex, sizeof(iface->ifindex));
> +             main_imsg_compose_ospfe(IMSG_IFDELETE, 0,
> +                 &iface->ifindex, sizeof(iface->ifindex));
>               if_del(iface);
>               break;
>       }
> Index: ospfe.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ospf6d/ospfe.c,v
> retrieving revision 1.34
> diff -u -p -r1.34 ospfe.c
> --- ospfe.c   2 May 2011 09:24:00 -0000       1.34
> +++ ospfe.c   1 Jun 2011 20:36:31 -0000
> @@ -299,16 +299,16 @@ ospfe_dispatch_main(int fd, short event,
>                       }
>                       break;
>               case IMSG_IFADD:
> -                     if ((iface = malloc(sizeof(struct iface))) == NULL)
> -                             fatal(NULL);
> -                     memcpy(iface, imsg.data, sizeof(struct iface));
> +                     ifp = imsg.data;
> +                     if ((iface = if_new(ifp->ifindex, ifp->name)) == NULL)
> +                             fatalx("IFADD in ospfe");
>  
> -                     LIST_INIT(&iface->nbr_list);
> -                     TAILQ_INIT(&iface->ls_ack_list);
> -                     RB_INIT(&iface->lsa_tree);
> +                     /* ifaces from config belong to some area */
> +                     if ((iface->cflags & F_IFACE_CONFIGURED) &&
> +                         (area = area_find(oeconf, iface->area_id)) != NULL)
> +                             LIST_INSERT_HEAD(&area->iface_list, iface,
> +                                 entry);
>  
> -                     area = area_find(oeconf, iface->area_id);
> -                     LIST_INSERT_HEAD(&area->iface_list, iface, entry);
>                       break;
>               case IMSG_IFDELETE:
>                       if (imsg.hdr.len != IMSG_HEADER_SIZE +
> Index: rde.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ospf6d/rde.c,v
> retrieving revision 1.52
> diff -u -p -r1.52 rde.c
> --- rde.c     5 May 2011 15:58:02 -0000       1.52
> +++ rde.c     1 Jun 2011 20:36:31 -0000
> @@ -623,7 +623,7 @@ rde_dispatch_parent(int fd, short event,
>  {
>       static struct area      *narea;
>       struct area             *area;
> -     struct iface            *iface;
> +     struct iface            *iface, *ifp;
>       struct ifaddrchange     *ifc;
>       struct iface_addr       *ia, *nia;
>       struct imsg              imsg;
> @@ -710,16 +710,16 @@ rde_dispatch_parent(int fd, short event,
>                                   0, -1, &kr, sizeof(kr));
>                       break;
>               case IMSG_IFADD:
> -                     if ((iface = malloc(sizeof(struct iface))) == NULL)
> -                             fatal(NULL);
> -                     memcpy(iface, imsg.data, sizeof(struct iface));
> -
> -                     LIST_INIT(&iface->nbr_list);
> -                     TAILQ_INIT(&iface->ls_ack_list);
> -                     RB_INIT(&iface->lsa_tree);
> +                     ifp = imsg.data;
> +                     if ((iface = if_new(ifp->ifindex, ifp->name)) == NULL)
> +                             fatalx("IFADD in rde");
> +
> +                     /* ifaces from config belong to area */
> +                     if ((iface->cflags & F_IFACE_CONFIGURED) &&
> +                         (area = area_find(rdeconf, iface->area_id)) != NULL)
> +                             LIST_INSERT_HEAD(&area->iface_list, iface,
> +                                 entry);
>  
> -                     area = area_find(rdeconf, iface->area_id);
> -                     LIST_INSERT_HEAD(&area->iface_list, iface, entry);
>                       break;
>               case IMSG_IFDELETE:
>                       if (imsg.hdr.len != IMSG_HEADER_SIZE +

Reply via email to