Do not try to delete RTF_LOCAL entries. Such routes are automatically
authormpi <mpi@openbsd.org>
Mon, 11 Aug 2014 09:47:56 +0000 (09:47 +0000)
committermpi <mpi@openbsd.org>
Mon, 11 Aug 2014 09:47:56 +0000 (09:47 +0000)
created /deleted by the kernel when an IP address is added/removed
on/from an interface and should not be manipulated by userland tools.

ok henning@, jca@

usr.sbin/arp/arp.c
usr.sbin/ndp/ndp.c

index 055b6e8..d18f56a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: arp.c,v 1.56 2014/03/18 14:18:22 mikeb Exp $ */
+/*     $OpenBSD: arp.c,v 1.57 2014/08/11 09:47:56 mpi Exp $ */
 /*     $NetBSD: arp.c,v 1.12 1995/04/24 13:25:18 cgd Exp $ */
 
 /*
@@ -406,19 +406,22 @@ tryagain:
        }
        sin = (struct sockaddr_inarp *)((char *)rtm + rtm->rtm_hdrlen);
        sdl = (struct sockaddr_dl *)(ROUNDUP(sin->sin_len) + (char *)sin);
-       if (sin->sin_addr.s_addr == sin_m.sin_addr.s_addr)
-               if (sdl->sdl_family == AF_LINK &&
-                   (rtm->rtm_flags & RTF_LLINFO) &&
-                   !(rtm->rtm_flags & RTF_GATEWAY))
-                       switch (sdl->sdl_type) {
-                       case IFT_ETHER:
-                       case IFT_FDDI:
-                       case IFT_ISO88023:
-                       case IFT_ISO88024:
-                       case IFT_ISO88025:
-                       case IFT_CARP:
-                               goto delete;
-                       }
+       if (sin->sin_addr.s_addr == sin_m.sin_addr.s_addr) {
+               if (sdl->sdl_family == AF_LINK && rtm->rtm_flags & RTF_LLINFO) {
+                       if (rtm->rtm_flags & RTF_LOCAL)
+                               return (0);
+                       if (!(rtm->rtm_flags & RTF_GATEWAY))
+                               switch (sdl->sdl_type) {
+                               case IFT_ETHER:
+                               case IFT_FDDI:
+                               case IFT_ISO88023:
+                               case IFT_ISO88024:
+                               case IFT_ISO88025:
+                               case IFT_CARP:
+                                       goto delete;
+                               }
+               }
+       }
 
        if (sin_m.sin_other & SIN_PROXY) {
                warnx("delete: can't locate %s", host);
index 3c387bd..1b78be1 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ndp.c,v 1.53 2013/10/21 12:41:52 jmc Exp $    */
+/*     $OpenBSD: ndp.c,v 1.54 2014/08/11 09:47:56 mpi Exp $    */
 /*     $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $   */
 
 /*
@@ -506,10 +506,11 @@ delete(char *host)
        sin = (struct sockaddr_in6 *)((char *)rtm + rtm->rtm_hdrlen);
        sdl = (struct sockaddr_dl *)(ROUNDUP(sin->sin6_len) + (char *)sin);
        if (IN6_ARE_ADDR_EQUAL(&sin->sin6_addr, &sin_m.sin6_addr)) {
-               if (sdl->sdl_family == AF_LINK &&
-                   (rtm->rtm_flags & RTF_LLINFO) &&
-                   !(rtm->rtm_flags & RTF_GATEWAY)) {
-                       goto delete;
+               if (sdl->sdl_family == AF_LINK && rtm->rtm_flags & RTF_LLINFO) {
+                       if (rtm->rtm_flags & RTF_LOCAL)
+                               return (0);
+                       if (!(rtm->rtm_flags & RTF_GATEWAY))
+                               goto delete;
                }
                /*
                 * IPv4 arp command retries with sin_other = SIN_PROXY here.