Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/netinet Pull up following revision(s) (requested by r...



details:   https://anonhg.NetBSD.org/src/rev/dcfa4cefc8c7
branches:  netbsd-9
changeset: 962935:dcfa4cefc8c7
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Sep 05 08:34:11 2019 +0000

description:
Pull up following revision(s) (requested by roy in ticket #170):

        sys/netinet/if_arp.c: revision 1.287

inet: Send RTM_MISS when we fail to resolve an address.

Takes the same approach as when adding a new address - we no longer
announce the new lladdr right away but we announce the result.

This will either be RTM_ADD or RTM_MISS.
RTM_DELETE is only sent if we have a lladdr assigned OR gc'ed.

This tells us when a new lladdr has been added (RTM_ADD),
changed (RTM_CHANGE), deleted (RTM_DELETED) or has failed to been
resolved (RTM_MISS). The latter case can be interpreted as unreachable.

diffstat:

 sys/netinet/if_arp.c |  46 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 32 insertions(+), 14 deletions(-)

diffs (115 lines):

diff -r 54fdbb7b6116 -r dcfa4cefc8c7 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Thu Sep 05 08:32:34 2019 +0000
+++ b/sys/netinet/if_arp.c      Thu Sep 05 08:34:11 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.282.2.2 2019/09/01 14:04:37 martin Exp $  */
+/*     $NetBSD: if_arp.c,v 1.282.2.3 2019/09/05 08:34:11 martin Exp $  */
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.2 2019/09/01 14:04:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.3 2019/09/05 08:34:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -308,6 +308,17 @@
        if (lle->la_flags & LLE_LINKED) {
                size_t pkts_dropped;
 
+               if (lle->la_flags & LLE_VALID) {
+                       struct in_addr *in;
+                       struct sockaddr_in sin;
+                       const char *lladdr;
+
+                       in = &lle->r_l3addr.addr4;
+                       sockaddr_in_init(&sin, in, 0);
+                       lladdr = (const char *)&lle->ll_addr;
+                       rt_clonedmsg(RTM_DELETE, sintosa(&sin), lladdr, ifp);
+               }
+
                LLE_REMREF(lle);
                pkts_dropped = llentry_free(lle);
                ARP_STATADD(ARP_STAT_DFRDROPPED, pkts_dropped);
@@ -738,14 +749,8 @@
                        rt_unref(_rt);
                if (la == NULL)
                        ARP_STATINC(ARP_STAT_ALLOCFAIL);
-               else {
-                       struct sockaddr_in sin;
-
+               else
                        arp_init_llentry(ifp, la);
-                       sockaddr_in_init(&sin, &la->r_l3addr.addr4, 0);
-                       if (rt != NULL)
-                               rt_clonedmsg(RTM_ADD, sintosa(&sin), NULL, ifp);
-               }
        } else if (LLE_TRY_UPGRADE(la) == 0) {
                create_lookup = "lookup";
                LLE_RUNLOCK(la);
@@ -845,9 +850,16 @@
 
        if (renew) {
                const uint8_t *enaddr = CLLADDR(ifp->if_sadl);
+               struct sockaddr_in sin;
+
                la->la_expire = time_uptime;
                arp_settimer(la, arpt_down);
                la->la_asked++;
+
+               sockaddr_in_init(&sin, &la->r_l3addr.addr4, 0);
+               if (error != EWOULDBLOCK)
+                       rt_clonedmsg(RTM_MISS, sintosa(&sin), NULL, ifp);
+
                LLE_WUNLOCK(la);
 
                if (rt != NULL) {
@@ -855,11 +867,8 @@
                            &satocsin(rt->rt_ifa->ifa_addr)->sin_addr,
                            &satocsin(dst)->sin_addr, enaddr);
                } else {
-                       struct sockaddr_in sin;
                        struct rtentry *_rt;
 
-                       sockaddr_in_init(&sin, &la->r_l3addr.addr4, 0);
-
                        /* XXX */
                        _rt = rtalloc1((struct sockaddr *)&sin, 0);
                        if (_rt == NULL)
@@ -1000,7 +1009,7 @@
 #endif
        struct sockaddr sa;
        struct in_addr isaddr, itaddr, myaddr;
-       int op;
+       int op, rt_cmd;
        void *tha;
        uint64_t *arps;
        struct psref psref, psref_ia;
@@ -1210,7 +1219,9 @@
                                    "for %s by %s\n",
                                    IN_PRINT(ipbuf, &isaddr), llastr);
                }
-       }
+               rt_cmd = RTM_CHANGE;
+       } else
+               rt_cmd = la->la_flags & LLE_VALID ? 0 : RTM_ADD;
 
        KASSERT(ifp->if_sadl->sdl_alen == ifp->if_addrlen);
 
@@ -1252,6 +1263,13 @@
        la->la_asked = 0;
        /* rt->rt_flags &= ~RTF_REJECT; */
 
+       if (rt_cmd != 0) {
+               struct sockaddr_in sin;
+
+               sockaddr_in_init(&sin, &la->r_l3addr.addr4, 0);
+               rt_clonedmsg(rt_cmd, sintosa(&sin), ar_sha(ah), ifp);
+       }
+
        if (la->la_hold != NULL) {
                int n = la->la_numheld;
                struct mbuf *m_hold, *m_hold_next;



Home | Main Index | Thread Index | Old Index