Source-Changes-HG archive

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

[src/trunk]: src/sys nd: Name l3addr union of llentry and use in-place of nd_...



details:   https://anonhg.NetBSD.org/src/rev/9d9825d75175
branches:  trunk
changeset: 943991:9d9825d75175
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Sep 14 15:09:57 2020 +0000

description:
nd: Name l3addr union of llentry and use in-place of nd_addr.

Probably makes more sense and makes nd.h less messy.

diffstat:

 sys/net/if_llatbl.h  |   6 +++---
 sys/net/nd.c         |   8 ++++----
 sys/net/nd.h         |  16 +++++-----------
 sys/netinet/if_arp.c |  35 ++++++++++++++++++-----------------
 sys/netinet6/nd6.c   |  32 ++++++++++++++++----------------
 5 files changed, 46 insertions(+), 51 deletions(-)

diffs (285 lines):

diff -r 9138dac1dc13 -r 9d9825d75175 sys/net/if_llatbl.h
--- a/sys/net/if_llatbl.h       Mon Sep 14 15:01:57 2020 +0000
+++ b/sys/net/if_llatbl.h       Mon Sep 14 15:09:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_llatbl.h,v 1.17 2019/07/18 06:47:10 ozaki-r Exp $   */
+/*     $NetBSD: if_llatbl.h,v 1.18 2020/09/14 15:09:57 roy Exp $       */
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -63,7 +63,7 @@
  */
 struct llentry {
        LIST_ENTRY(llentry)      lle_next;
-       union {
+       union l3addr {
                struct in_addr  addr4;
                struct in6_addr addr6;
        } r_l3addr;
@@ -86,7 +86,7 @@
        uint16_t                 la_asked;
        uint16_t                 la_preempt;
        uint16_t                 ln_byhint;
-       int16_t                  ln_state;      /* IPv6 has ND6_LLINFO_NOSTATE == -2 */
+       int16_t                  ln_state;      /* ND_LLINFO_NOSTATE == -2 */
        uint16_t                 ln_router;
        time_t                   ln_ntick;
        int                      lle_refcnt;
diff -r 9138dac1dc13 -r 9d9825d75175 sys/net/nd.c
--- a/sys/net/nd.c      Mon Sep 14 15:01:57 2020 +0000
+++ b/sys/net/nd.c      Mon Sep 14 15:09:57 2020 +0000
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd.c,v 1.1 2020/09/11 14:59:22 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd.c,v 1.2 2020/09/14 15:09:57 roy Exp $");
 
 #include <sys/callout.h>
 #include <sys/mbuf.h>
@@ -57,7 +57,7 @@
        struct psref psref;
        struct mbuf *m = NULL;
        bool send_ns = false, missed = false;
-       union nd_addr taddr, *daddrp = NULL;
+       union l3addr taddr, *daddrp = NULL;
 
        SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE();
        LLE_WLOCK(ln);
@@ -158,7 +158,7 @@
 
        if (send_ns) {
                uint8_t lladdr[255], *lladdrp;
-               union nd_addr src, *psrc;
+               union l3addr src, *psrc;
 
                nd_set_timer(ln, ND_TIMER_RETRANS);
                if (ln->ln_state > ND_LLINFO_INCOMPLETE &&
@@ -353,7 +353,7 @@
         */
        if (!ND_IS_LLINFO_PERMANENT(ln) && ln->ln_asked == 0) {
                struct psref psref;
-               union nd_addr dst, src, *psrc;
+               union l3addr dst, src, *psrc;
 
                ln->ln_asked++;
                nd_set_timer(ln, ND_TIMER_RETRANS);
diff -r 9138dac1dc13 -r 9d9825d75175 sys/net/nd.h
--- a/sys/net/nd.h      Mon Sep 14 15:01:57 2020 +0000
+++ b/sys/net/nd.h      Mon Sep 14 15:09:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd.h,v 1.1 2020/09/11 14:59:22 roy Exp $       */
+/*     $NetBSD: nd.h,v 1.2 2020/09/14 15:09:57 roy Exp $       */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -65,12 +65,6 @@
                ((MIN_RANDOM_FACTOR * (x >> 10)) + (cprng_fast32() & \
                ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10))))
 
-#include <netinet/in.h>
-union nd_addr {
-       struct in_addr  nd_addr4;
-       struct in6_addr nd_addr6;
-};
-
 struct nd_domain {
        int nd_family;
        int nd_delay;           /* delay first probe time in seconds */
@@ -81,10 +75,10 @@
        bool (*nd_nud_enabled)(struct ifnet *);
        unsigned int (*nd_reachable)(struct ifnet *);   /* msec */
        unsigned int (*nd_retrans)(struct ifnet *);     /* msec */
-       union nd_addr *(*nd_holdsrc)(struct llentry *, union nd_addr *);
-       void (*nd_output)(struct ifnet *, const union nd_addr *,
-           const union nd_addr *, const uint8_t *, const union nd_addr *);
-       void (*nd_missed)(struct ifnet *, const union nd_addr *, struct mbuf *);
+       union l3addr *(*nd_holdsrc)(struct llentry *, union l3addr *);
+       void (*nd_output)(struct ifnet *, const union l3addr *,
+           const union l3addr *, const uint8_t *, const union l3addr *);
+       void (*nd_missed)(struct ifnet *, const union l3addr *, struct mbuf *);
        void (*nd_free)(struct llentry *, int);
 };
 
diff -r 9138dac1dc13 -r 9d9825d75175 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Mon Sep 14 15:01:57 2020 +0000
+++ b/sys/netinet/if_arp.c      Mon Sep 14 15:09:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.295 2020/09/11 15:16:00 roy Exp $ */
+/*     $NetBSD: if_arp.c,v 1.296 2020/09/14 15:09:57 roy 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.295 2020/09/11 15:16:00 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.296 2020/09/14 15:09:57 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -141,10 +141,10 @@
 static bool arp_nud_enabled(struct ifnet *);
 static unsigned int arp_llinfo_reachable(struct ifnet *);
 static unsigned int arp_llinfo_retrans(struct ifnet *);
-static union nd_addr *arp_llinfo_holdsrc(struct llentry *, union nd_addr *);
-static void arp_llinfo_output(struct ifnet *, const union nd_addr *,
-    const union nd_addr *, const uint8_t *, const union nd_addr *);
-static void arp_llinfo_missed(struct ifnet *, const union nd_addr *,
+static union l3addr *arp_llinfo_holdsrc(struct llentry *, union l3addr *);
+static void arp_llinfo_output(struct ifnet *, const union l3addr *,
+    const union l3addr *, const uint8_t *, const union l3addr *);
+static void arp_llinfo_missed(struct ifnet *, const union l3addr *,
     struct mbuf *);
 static void arp_free(struct llentry *, int);
 
@@ -1305,8 +1305,8 @@
  * and stores it in @src.
  * Returns pointer to @src (if hold queue is not empty) or NULL.
  */
-static union nd_addr *
-arp_llinfo_holdsrc(struct llentry *ln, union nd_addr *src)
+static union l3addr *
+arp_llinfo_holdsrc(struct llentry *ln, union l3addr *src)
 {
        struct ip *ip;
 
@@ -1319,7 +1319,7 @@
        ip = mtod(ln->ln_hold, struct ip *);
        /* XXX pullup? */
        if (sizeof(*ip) < ln->ln_hold->m_len)
-               src->nd_addr4 = ip->ip_src;
+               src->addr4 = ip->ip_src;
        else
                src = NULL;
 
@@ -1327,20 +1327,20 @@
 }
 
 static void
-arp_llinfo_output(struct ifnet *ifp, __unused const union nd_addr *daddr,
-    const union nd_addr *taddr, const uint8_t *tlladdr,
-    const union nd_addr *hsrc)
+arp_llinfo_output(struct ifnet *ifp, __unused const union l3addr *daddr,
+    const union l3addr *taddr, const uint8_t *tlladdr,
+    const union l3addr *hsrc)
 {
-       struct in_addr tip = taddr->nd_addr4, sip = zeroin_addr;
+       struct in_addr tip = taddr->addr4, sip = zeroin_addr;
        const uint8_t *slladdr = CLLADDR(ifp->if_sadl);
 
        if (hsrc != NULL) {
                struct in_ifaddr *ia;
                struct psref psref;
 
-               ia = in_get_ia_on_iface_psref(hsrc->nd_addr4, ifp, &psref);
+               ia = in_get_ia_on_iface_psref(hsrc->addr4, ifp, &psref);
                if (ia != NULL) {
-                       sip = hsrc->nd_addr4;
+                       sip = hsrc->addr4;
                        ia4_release(ia, &psref);
                }
        }
@@ -1373,7 +1373,8 @@
 
 
 static void
-arp_llinfo_missed(struct ifnet *ifp, const union nd_addr *taddr, struct mbuf *m)
+arp_llinfo_missed(struct ifnet *ifp, const union l3addr *taddr,
+    struct mbuf *m)
 {
        struct in_addr mdaddr = zeroin_addr;
        struct sockaddr_in dsin, tsin;
@@ -1395,7 +1396,7 @@
        } else
                sa = NULL;
 
-       sockaddr_in_init(&tsin, &taddr->nd_addr4, 0);
+       sockaddr_in_init(&tsin, &taddr->addr4, 0);
        rt_clonedmsg(RTM_MISS, sa, sintosa(&tsin), NULL, ifp);
 }
 
diff -r 9138dac1dc13 -r 9d9825d75175 sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c        Mon Sep 14 15:01:57 2020 +0000
+++ b/sys/netinet6/nd6.c        Mon Sep 14 15:09:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6.c,v 1.272 2020/09/11 15:03:33 roy Exp $    */
+/*     $NetBSD: nd6.c,v 1.273 2020/09/14 15:09:57 roy Exp $    */
 /*     $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $   */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.272 2020/09/11 15:03:33 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.273 2020/09/14 15:09:57 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -107,10 +107,10 @@
 static bool nd6_nud_enabled(struct ifnet *);
 static unsigned int nd6_llinfo_reachable(struct ifnet *);
 static unsigned int nd6_llinfo_retrans(struct ifnet *);
-static union nd_addr *nd6_llinfo_holdsrc(struct llentry *, union nd_addr *);
-static void nd6_llinfo_output(struct ifnet *, const union nd_addr *,
-    const union nd_addr *, const uint8_t *, const union nd_addr *);
-static void nd6_llinfo_missed(struct ifnet *, const union nd_addr *,
+static union l3addr *nd6_llinfo_holdsrc(struct llentry *, union l3addr *);
+static void nd6_llinfo_output(struct ifnet *, const union l3addr *,
+    const union l3addr *, const uint8_t *, const union l3addr *);
+static void nd6_llinfo_missed(struct ifnet *, const union l3addr *,
     struct mbuf *);
 static void nd6_timer(void *);
 static void nd6_timer_work(struct work *, void *);
@@ -367,23 +367,23 @@
        return src;
 }
 
-static union nd_addr *
-nd6_llinfo_holdsrc(struct llentry *ln, union nd_addr *src)
+static union l3addr *
+nd6_llinfo_holdsrc(struct llentry *ln, union l3addr *src)
 {
 
-       if (nd6_llinfo_get_holdsrc(ln, &src->nd_addr6) == NULL)
+       if (nd6_llinfo_get_holdsrc(ln, &src->addr6) == NULL)
                return NULL;
        return src;
 }
 
 static void
-nd6_llinfo_output(struct ifnet *ifp, const union nd_addr *daddr,
-    const union nd_addr *taddr, __unused const uint8_t *tlladdr,
-    const union nd_addr *hsrc)
+nd6_llinfo_output(struct ifnet *ifp, const union l3addr *daddr,
+    const union l3addr *taddr, __unused const uint8_t *tlladdr,
+    const union l3addr *hsrc)
 {
 
-       nd6_ns_output(ifp, &daddr->nd_addr6, &taddr->nd_addr6,
-           &hsrc->nd_addr6, NULL);
+       nd6_ns_output(ifp, &daddr->addr6, &taddr->addr6,
+           &hsrc->addr6, NULL);
 }
 
 static bool
@@ -411,7 +411,7 @@
 }
 
 static void
-nd6_llinfo_missed(struct ifnet *ifp, const union nd_addr *taddr, struct mbuf *m)
+nd6_llinfo_missed(struct ifnet *ifp, const union l3addr *taddr, struct mbuf *m)
 {
        struct in6_addr mdaddr6 = zeroin6_addr;
        struct sockaddr_in6 dsin6, tsin6;
@@ -426,7 +426,7 @@
        } else
                sa = NULL;
 
-       sockaddr_in6_init(&tsin6, &taddr->nd_addr6, 0, 0, 0);
+       sockaddr_in6_init(&tsin6, &taddr->addr6, 0, 0, 0);
        rt_clonedmsg(RTM_MISS, sa, sin6tosa(&tsin6), NULL, ifp);
 }
 



Home | Main Index | Thread Index | Old Index