Source-Changes-HG archive

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

[src/trunk]: src/sys inet: Add SIOCGNBRINFO to retrieve neighbor state about ...



details:   https://anonhg.NetBSD.org/src/rev/c080fb8f4ba8
branches:  trunk
changeset: 938589:c080fb8f4ba8
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Sep 11 15:22:12 2020 +0000

description:
inet: Add SIOCGNBRINFO to retrieve neighbor state about an address

diffstat:

 sys/netinet/in.c     |  22 ++++++++++++++++++++--
 sys/netinet/in_var.h |  10 +++++++++-
 sys/sys/sockio.h     |   4 +++-
 3 files changed, 32 insertions(+), 4 deletions(-)

diffs (83 lines):

diff -r a3254c287494 -r c080fb8f4ba8 sys/netinet/in.c
--- a/sys/netinet/in.c  Fri Sep 11 15:21:48 2020 +0000
+++ b/sys/netinet/in.c  Fri Sep 11 15:22:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.c,v 1.239 2020/09/11 15:19:31 roy Exp $     */
+/*     $NetBSD: in.c,v 1.240 2020/09/11 15:22:12 roy Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.239 2020/09/11 15:19:31 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.240 2020/09/11 15:22:12 roy Exp $");
 
 #include "arp.h"
 
@@ -424,6 +424,24 @@
                if (ifp == NULL)
                        return EINVAL;
                return ifaddrpref_ioctl(so, cmd, data, ifp);
+#if NARP > 0
+       case SIOCGNBRINFO:
+       {
+               struct in_nbrinfo *nbi = (struct in_nbrinfo *)data;
+               struct llentry *ln;
+               struct in_addr nb_addr = nbi->addr; /* make local for safety */
+
+               ln = arplookup(ifp, &nb_addr, NULL, 0);
+               if (ln == NULL)
+                       return EINVAL;
+               nbi->state = ln->ln_state;
+               nbi->asked = ln->ln_asked;
+               nbi->expire = ln->ln_expire ?
+                   time_mono_to_wall(ln->ln_expire) : 0;
+               LLE_RUNLOCK(ln);
+               return 0;
+       }
+#endif
        }
 
        bound = curlwp_bind();
diff -r a3254c287494 -r c080fb8f4ba8 sys/netinet/in_var.h
--- a/sys/netinet/in_var.h      Fri Sep 11 15:21:48 2020 +0000
+++ b/sys/netinet/in_var.h      Fri Sep 11 15:22:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_var.h,v 1.97 2018/11/29 09:51:20 ozaki-r Exp $      */
+/*     $NetBSD: in_var.h,v 1.98 2020/09/11 15:22:12 roy Exp $  */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -115,6 +115,14 @@
 #endif
 };
 
+struct in_nbrinfo {
+       char ifname[IFNAMSIZ];  /* if name, e.g. "en0" */
+       struct in_addr addr;    /* IPv4 address of the neighbor */
+       long    asked;          /* number of queries already sent for this addr */
+       int     state;          /* reachability state */
+       int     expire;         /* lifetime for NDP state transition */
+};
+
 #ifdef _KERNEL
 static __inline void
 ia4_acquire(struct in_ifaddr *ia, struct psref *psref)
diff -r a3254c287494 -r c080fb8f4ba8 sys/sys/sockio.h
--- a/sys/sys/sockio.h  Fri Sep 11 15:21:48 2020 +0000
+++ b/sys/sys/sockio.h  Fri Sep 11 15:22:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sockio.h,v 1.38 2019/07/04 02:44:25 ozaki-r Exp $      */
+/*     $NetBSD: sockio.h,v 1.39 2020/09/11 15:22:12 roy Exp $  */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993, 1994
@@ -153,4 +153,6 @@
 #define        SIOCSETPFSYNC   _IOW('i', 247, struct ifreq)    
 #define        SIOCGETPFSYNC   _IOWR('i', 248, struct ifreq)
 
+#define        SIOCGNBRINFO    _IOWR('i', 249, struct in_nbrinfo) /* get IA ND info */
+
 #endif /* !_SYS_SOCKIO_H_ */



Home | Main Index | Thread Index | Old Index