From 38c8fc571162610bd165a44b6b15d2d6331ccba6 Mon Sep 17 00:00:00 2001 From: mpi Date: Mon, 11 Aug 2014 09:47:56 +0000 Subject: [PATCH] Do not try to delete RTF_LOCAL entries. Such routes are automatically 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 | 31 +++++++++++++++++-------------- usr.sbin/ndp/ndp.c | 11 ++++++----- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 055b6e8dff7..d18f56a600f 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -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); diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index 3c387bd2495..1b78be15c62 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -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. -- 2.20.1