On Sun, Dec 18, 2016 at 10:40:47PM +0100, Alexander Bluhm wrote:
> The mess made me send an incorrect diff.  In case that both if_ioctl()
> and rt_ifa_addlocal() fail, we could still end in an inconsistent
> sate.
> 
> I think this is better.  Still ok?

Yes, it's fine.

> bluhm
> 
> Index: netinet/in.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in.c,v
> retrieving revision 1.130
> diff -u -p -u -p -r1.130 in.c
> --- netinet/in.c      5 Dec 2016 15:31:43 -0000       1.130
> +++ netinet/in.c      18 Dec 2016 20:28:24 -0000
> @@ -603,7 +603,7 @@ in_ifinit(struct ifnet *ifp, struct in_i
>  {
>       u_int32_t i = sin->sin_addr.s_addr;
>       struct sockaddr_in oldaddr;
> -     int error = 0;
> +     int error = 0, rterror;
>  
>       splsoftassert(IPL_SOFTNET);
>  
> @@ -633,8 +633,15 @@ in_ifinit(struct ifnet *ifp, struct in_i
>        * error occured, put back the original address.
>        */
>       ifa_add(ifp, &ia->ia_ifa);
> -     rt_ifa_addlocal(&ia->ia_ifa);
> +     rterror = rt_ifa_addlocal(&ia->ia_ifa);
>  
> +     if (rterror) {
> +             if (!newaddr)
> +                     ifa_del(ifp, &ia->ia_ifa);
> +             if (!error)
> +                     error = rterror;
> +             goto out;
> +     }
>       if (error)
>               goto out;
>  
> 

Reply via email to