Unbreak ''route flush'': the kernel now adds local (RTF_LOCAL) routes
authorjca <jca@openbsd.org>
Thu, 24 Jul 2014 17:45:35 +0000 (17:45 +0000)
committerjca <jca@openbsd.org>
Thu, 24 Jul 2014 17:45:35 +0000 (17:45 +0000)
for addresses configured on the system, and prevents userland from
deleting them.  Just skip those routes when flushing.
Problem noticed by mlarkin@, ok henning@ mpi@ claudio@ sthen@ deraadt@

sbin/route/route.c

index d9b9008..d85ce7a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: route.c,v 1.168 2014/06/23 03:46:16 guenther Exp $    */
+/*     $OpenBSD: route.c,v 1.169 2014/07/24 17:45:35 jca Exp $ */
 /*     $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $   */
 
 /*
@@ -320,6 +320,8 @@ flushroutes(int argc, char **argv)
                        print_rtmsg(rtm, rtm->rtm_msglen);
                if ((rtm->rtm_flags & (RTF_GATEWAY|RTF_STATIC|RTF_LLINFO)) == 0)
                        continue;
+               if ((rtm->rtm_flags & RTF_LOCAL) != 0)
+                       continue;
                sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
                if (af && sa->sa_family != af)
                        continue;