Always create a local route for every configured IPv4 address on the
authormpi <mpi@openbsd.org>
Wed, 11 Jun 2014 11:30:03 +0000 (11:30 +0000)
committermpi <mpi@openbsd.org>
Wed, 11 Jun 2014 11:30:03 +0000 (11:30 +0000)
machine and restore the original behavior of RTM_ADD and RTM_DELETE
by always generating one message per locally configured address.

Tested by krw@, jca@ and florian@

sys/net/route.c
sys/netinet/if_ether.c
sys/netinet/in.c

index abd170b..e830494 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: route.c,v 1.169 2014/06/11 11:29:01 mpi Exp $ */
+/*     $OpenBSD: route.c,v 1.170 2014/06/11 11:30:03 mpi Exp $ */
 /*     $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $      */
 
 /*
@@ -1129,7 +1129,8 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst)
                        if (ifa->ifa_rtrequest)
                                ifa->ifa_rtrequest(RTM_ADD, rt);
                }
-               rt_newaddrmsg(RTM_ADD, ifa, error, nrt);
+               if (flags & RTF_LOCAL)
+                       rt_newaddrmsg(RTM_ADD, ifa, error, nrt);
        }
        return (error);
 }
@@ -1183,7 +1184,8 @@ rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst)
 
        error = rtrequest1(RTM_DELETE, &info, prio, &nrt, rtableid);
        if (error == 0 && (rt = nrt) != NULL) {
-               rt_newaddrmsg(RTM_DELETE, ifa, error, nrt);
+               if (flags & RTF_LOCAL)
+                       rt_newaddrmsg(RTM_DELETE, ifa, error, nrt);
                if (rt->rt_refcnt <= 0) {
                        rt->rt_refcnt++;
                        rtfree(rt);
index 8c8433d..a4a6d67 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_ether.c,v 1.127 2014/05/07 08:14:59 mpi Exp $      */
+/*     $OpenBSD: if_ether.c,v 1.128 2014/06/11 11:30:03 mpi Exp $      */
 /*     $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $    */
 
 /*
@@ -174,7 +174,8 @@ arp_rtrequest(int req, struct rtentry *rt)
                if ((rt->rt_flags & RTF_HOST) == 0 && rt_mask(rt) &&
                    satosin(rt_mask(rt))->sin_addr.s_addr != 0xffffffff)
                        rt->rt_flags |= RTF_CLONING;
-               if (rt->rt_flags & RTF_CLONING) {
+               if (rt->rt_flags & RTF_CLONING ||
+                   ((rt->rt_flags & RTF_LLINFO) && !la)) {
                        /*
                         * Case 1: This route should come from a route to iface.
                         */
@@ -189,7 +190,8 @@ arp_rtrequest(int req, struct rtentry *rt)
                         * from it do not need their expiration time set.
                         */
                        rt->rt_expire = time_second;
-                       break;
+                       if ((rt->rt_flags & RTF_CLONING) != 0)
+                               break;
                }
                /* Announce a new entry if requested. */
                if (rt->rt_flags & RTF_ANNOUNCE)
index 2379651..bbf7db6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: in.c,v 1.96 2014/04/25 09:44:38 mpi Exp $     */
+/*     $OpenBSD: in.c,v 1.97 2014/06/11 11:30:03 mpi Exp $     */
 /*     $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
 
 /*
@@ -702,6 +702,7 @@ out:
         * carp(4).
         */
        ifa_add(ifp, &ia->ia_ifa);
+       rt_ifa_addloop(&ia->ia_ifa);
 
        if (error && newaddr)
                in_purgeaddr(&ia->ia_ifa);
@@ -719,6 +720,8 @@ in_purgeaddr(struct ifaddr *ifa)
 
        in_ifscrub(ifp, ia);
 
+       rt_ifa_delloop(&ia->ia_ifa);
+
        ifa_del(ifp, &ia->ia_ifa);
        TAILQ_REMOVE(&in_ifaddr, ia, ia_list);
        if (ia->ia_allhosts != NULL) {