Inline useless ND_IFINFO() macro
authorkn <kn@openbsd.org>
Wed, 23 Nov 2022 16:59:10 +0000 (16:59 +0000)
committerkn <kn@openbsd.org>
Wed, 23 Nov 2022 16:59:10 +0000 (16:59 +0000)
A single cast-free struct pointer dereference needs no indirection.
ND_IFINFO() is under _KERNEL.

OK mvs

sys/netinet6/nd6.c
sys/netinet6/nd6.h
sys/netinet6/nd6_nbr.c

index 41cf226..ce6b1c0 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: nd6.c,v 1.252 2022/11/23 16:57:37 kn Exp $    */
+/*     $OpenBSD: nd6.c,v 1.253 2022/11/23 16:59:10 kn Exp $    */
 /*     $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $   */
 
 /*
@@ -367,7 +367,7 @@ nd6_llinfo_timer(struct rtentry *rt)
        case ND6_LLINFO_INCOMPLETE:
                if (ln->ln_asked < nd6_mmaxtries) {
                        ln->ln_asked++;
-                       nd6_llinfo_settimer(ln, ND_IFINFO(ifp)->retrans / 1000);
+                       nd6_llinfo_settimer(ln, ifp->if_nd->retrans / 1000);
                        nd6_ns_output(ifp, NULL, &dst->sin6_addr, ln, 0);
                } else {
                        struct mbuf *m = ln->ln_hold;
@@ -414,13 +414,13 @@ nd6_llinfo_timer(struct rtentry *rt)
                /* We need NUD */
                ln->ln_asked = 1;
                ln->ln_state = ND6_LLINFO_PROBE;
-               nd6_llinfo_settimer(ln, ND_IFINFO(ifp)->retrans / 1000);
+               nd6_llinfo_settimer(ln, ifp->if_nd->retrans / 1000);
                nd6_ns_output(ifp, &dst->sin6_addr, &dst->sin6_addr, ln, 0);
                break;
        case ND6_LLINFO_PROBE:
                if (ln->ln_asked < nd6_umaxtries) {
                        ln->ln_asked++;
-                       nd6_llinfo_settimer(ln, ND_IFINFO(ifp)->retrans / 1000);
+                       nd6_llinfo_settimer(ln, ifp->if_nd->retrans / 1000);
                        nd6_ns_output(ifp, &dst->sin6_addr,
                            &dst->sin6_addr, ln, 0);
                } else {
@@ -766,7 +766,7 @@ nd6_nud_hint(struct rtentry *rt)
 
        ln->ln_state = ND6_LLINFO_REACHABLE;
        if (!ND6_LLINFO_PERMANENT(ln))
-               nd6_llinfo_settimer(ln, ND_IFINFO(ifp)->reachable);
+               nd6_llinfo_settimer(ln, ifp->if_nd->reachable);
 out:
        if_put(ifp);
 }
@@ -1014,7 +1014,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
        switch (cmd) {
        case SIOCGIFINFO_IN6:
                NET_LOCK_SHARED();
-               ndi->ndi = *ND_IFINFO(ifp);
+               ndi->ndi = *ifp->if_nd;
                NET_UNLOCK_SHARED();
                return (0);
        case SIOCGNBRINFO_IN6:
@@ -1295,7 +1295,7 @@ nd6_slowtimo(void *ignored_arg)
        timeout_add_sec(&nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL);
 
        TAILQ_FOREACH(ifp, &ifnetlist, if_list) {
-               nd6if = ND_IFINFO(ifp);
+               nd6if = ifp->if_nd;
                if (nd6if->basereachable && /* already initialized */
                    (nd6if->recalctm -= ND6_SLOWTIMER_INTERVAL) <= 0) {
                        /*
@@ -1414,7 +1414,7 @@ nd6_resolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
         */
        if (!ND6_LLINFO_PERMANENT(ln) && ln->ln_asked == 0) {
                ln->ln_asked++;
-               nd6_llinfo_settimer(ln, ND_IFINFO(ifp)->retrans / 1000);
+               nd6_llinfo_settimer(ln, ifp->if_nd->retrans / 1000);
                nd6_ns_output(ifp, NULL, &satosin6(dst)->sin6_addr, ln, 0);
        }
        return (EAGAIN);
index 8322630..5e92668 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: nd6.h,v 1.85 2022/11/23 16:57:37 kn Exp $     */
+/*     $OpenBSD: nd6.h,v 1.86 2022/11/23 16:59:10 kn Exp $     */
 /*     $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $    */
 
 /*
@@ -93,9 +93,6 @@ struct        in6_ndifreq {
 
 #include <sys/queue.h>
 
-#define ND_IFINFO(ifp) \
-       ((ifp)->if_nd)
-
 struct llinfo_nd6 {
        TAILQ_ENTRY(llinfo_nd6) ln_list;
        struct  rtentry *ln_rt;
index 3701ae4..0cd55d9 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: nd6_nbr.c,v 1.133 2022/08/29 07:51:45 bluhm Exp $     */
+/*     $OpenBSD: nd6_nbr.c,v 1.134 2022/11/23 16:59:10 kn Exp $        */
 /*     $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $        */
 
 /*
@@ -716,7 +716,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
                        rtm_send(rt, RTM_RESOLVE, 0, ifp->if_rdomain);
                        if (!ND6_LLINFO_PERMANENT(ln)) {
                                nd6_llinfo_settimer(ln,
-                                   ND_IFINFO(ifp)->reachable);
+                                   ifp->if_nd->reachable);
                        }
                } else {
                        ln->ln_state = ND6_LLINFO_STALE;
@@ -806,7 +806,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
                                ln->ln_byhint = 0;
                                if (!ND6_LLINFO_PERMANENT(ln)) {
                                        nd6_llinfo_settimer(ln,
-                                           ND_IFINFO(ifp)->reachable);
+                                           ifp->if_nd->reachable);
                                }
                        } else {
                                if (lladdr && llchange) {
@@ -1129,7 +1129,7 @@ nd6_dad_start(struct ifaddr *ifa)
        dp->dad_ns_icount = dp->dad_na_icount = 0;
        dp->dad_ns_ocount = dp->dad_ns_tcount = 0;
        nd6_dad_ns_output(dp, ifa);
-       nd6_dad_starttimer(dp, ND_IFINFO(ifa->ifa_ifp)->retrans);
+       nd6_dad_starttimer(dp, ifa->ifa_ifp->if_nd->retrans);
 }
 
 /*
@@ -1211,7 +1211,7 @@ nd6_dad_timer(void *xifa)
                 * We have more NS to go.  Send NS packet for DAD.
                 */
                nd6_dad_ns_output(dp, ifa);
-               nd6_dad_starttimer(dp, ND_IFINFO(ifa->ifa_ifp)->retrans);
+               nd6_dad_starttimer(dp, ifa->ifa_ifp->if_nd->retrans);
        } else {
                /*
                 * We have transmitted sufficient number of DAD packets.