Source-Changes-HG archive

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

[src/netbsd-8]: src Pull up following revision(s) (requested by ozaki-r in ti...



details:   https://anonhg.NetBSD.org/src/rev/357e7266d7b9
branches:  netbsd-8
changeset: 850814:357e7266d7b9
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jul 07 13:57:26 2017 +0000

description:
Pull up following revision(s) (requested by ozaki-r in ticket #107):
        usr.sbin/arp/arp.c: revision 1.56
        sys/net/rtsock.c: revision 1.218
        sys/net/if_llatbl.c: revision 1.20
        usr.sbin/arp/arp.c: revision 1.57
        sys/net/rtsock.c: revision 1.219
        sys/net/if_llatbl.c: revision 1.21
        usr.sbin/arp/arp.c: revision 1.58
        tests/net/net_common.sh: revision 1.19
        sys/netinet6/nd6.h: revision 1.84
        sys/netinet6/nd6.h: revision 1.85
        tests/net/arp/t_arp.sh: revision 1.23
        sys/netinet6/in6.c: revision 1.246
        tests/net/arp/t_arp.sh: revision 1.24
        sys/netinet6/in6.c: revision 1.247
        tests/net/arp/t_arp.sh: revision 1.25
        sys/netinet6/in6.c: revision 1.248
        tests/net/arp/t_arp.sh: revision 1.26
        usr.sbin/ndp/ndp.c: revision 1.49
        tests/net/arp/t_arp.sh: revision 1.27
        tests/net/ndp/t_ndp.sh: revision 1.20
        tests/net/arp/t_arp.sh: revision 1.28
        tests/net/ndp/t_ndp.sh: revision 1.21
        tests/net/arp/t_arp.sh: revision 1.29
        tests/net/ndp/t_ndp.sh: revision 1.22
        tests/net/ndp/t_ndp.sh: revision 1.23
        tests/net/route/t_flags6.sh: revision 1.13
        tests/net/ndp/t_ndp.sh: revision 1.24
        tests/net/route/t_flags6.sh: revision 1.14
        tests/net/ndp/t_ndp.sh: revision 1.25
        tests/net/route/t_flags6.sh: revision 1.15
        tests/net/ndp/t_ndp.sh: revision 1.26
        sbin/route/rtutil.c: revision 1.9
        tests/net/ndp/t_ndp.sh: revision 1.27
        tests/net/ndp/t_ndp.sh: revision 1.28
        tests/net/net/t_ipv6address.sh: revision 1.14
        tests/net/ndp/t_ra.sh: revision 1.28
        tests/net/ndp/t_ndp.sh: revision 1.29
        sys/net/route.h: revision 1.113
        tests/net/ndp/t_ra.sh: revision 1.29
        sys/net/rtsock.c: revision 1.220
        sys/net/rtsock.c: revision 1.221
        sys/net/rtsock.c: revision 1.222
        sys/net/rtsock.c: revision 1.223
        tests/net/route/t_route.sh: revision 1.13
        sys/net/rtsock.c: revision 1.224
        sys/net/route.c: revision 1.196
        sys/net/if_llatbl.c: revision 1.19
        sys/net/route.c: revision 1.197
        sbin/route/route.c: revision 1.156
        tests/net/route/t_flags.sh: revision 1.16
        tests/net/route/t_flags.sh: revision 1.17
        usr.sbin/ndp/ndp.c: revision 1.50
        tests/net/route/t_flags.sh: revision 1.18
        sys/netinet/in.c: revision 1.204
        tests/net/route/t_flags.sh: revision 1.19
        sys/netinet/in.c: revision 1.205
        tests/net/arp/t_arp.sh: revision 1.30
        tests/net/arp/t_arp.sh: revision 1.31
        sys/net/if_llatbl.h: revision 1.11
        tests/net/arp/t_arp.sh: revision 1.32
        sys/net/if_llatbl.h: revision 1.12
        tests/net/arp/t_arp.sh: revision 1.33
        sys/netinet6/nd6.c: revision 1.233
        sys/netinet6/nd6.c: revision 1.234
        sys/netinet/if_arp.c: revision 1.251
        sys/netinet6/nd6.c: revision 1.235
        sys/netinet/if_arp.c: revision 1.252
        sbin/route/route.8: revision 1.57
        sys/net/rtsock.c: revision 1.214
        sys/net/rtsock.c: revision 1.215
        sys/net/rtsock.c: revision 1.216
        sys/net/rtsock.c: revision 1.217
whitespace police
Simplify
We can assume that rt_ifp is always non-NULL.
Sending a routing message (RTM_ADD) on adding an llentry
A message used to be sent on adding a cloned route. Restore the
behavior for backward compatibility.
Requested by ryo@
Drop RTF_CONNECTED from a result of RTM_GET for ARP/NDP entries
ARP/NDP entries aren't connected routes.
Reported by ryo@
Support -c <count> option for route monitor
route command exits if it receives <count> routing messages where
<count> is a value specified by -c.
The option is useful to get only particular message(s) in a test script.
Test routing messages emitted on operations of ARP/NDP entries
Do netstat -a for an appropriate protocol
Add missing declarations for cleanup
Set net.inet.arp.keep only if it's required
Don't create a permanent L2 cache entry on adding an address to an interface
It was created to copy FreeBSD, however actually the cache isn't
necessary. Remove it to simplify the code and reduce the cost to
maintain it (e.g., keep a consistency with a corresponding local
route).
Fix typo
Fix in_lltable_match_prefix
The function has not been used but will be used soon.
Remove unused function (nd6_rem_ifa_lle)
Allow in6_lltable_free_entry to be called without holding the afdata lock of ifp as well as in_lltable_free_entry
This behavior is a bit odd and should be fixed in the future...
Purge ARP/NDP entries on an interface when the interface is down
Fix PR kern/51179
Purge all related L2 caches on removing a route
The change addresses situations similar to PR 51179.
Purge L2 caches on changing an interface of a route
The change addresses situations similar to PR 51179.
Test implicit removals of ARP/NDP entries
One test case reproudces PR 51179.
Fix build of kernels without both INET and INET6
Tweak lltable_sysctl_dumparp
- Rename lltable_sysctl_dumparp to lltable_sysctl_dump
  because it's not only for ARP
- Enable it not only for INET but also for INET6
Fix usage of routing messages on arp -d and ndp -d
It didn't work as we expected; we should set RTA_GATEWAY not
RTA_IFP on RTM_GET to return an if_index and the kernel should
use it on RTM_DELETE.
Improve backward compatibility of (fake) routing messages on adding an ARP/NDP entry
A message originally included only DST and GATEWAY. Restore it.
Fix ifdef; care about a case w/ INET6 and w/o INET
Drop RTF_UP from a routing message of a deleted ARP/NDP entry
Check existence of ARP/NDP entries
Checking ARP/NDP entries is valid rather than checking routes.
Fix wrong comment
Drop RTF_LLINFO flag (now it's RTF_LLDATA) from local routes
They don't have llinfo anymore. And also the change fixes unexpected
behavior of ARP proxy.
Restore ARP/NDP entries to route show and netstat -r
Requested by dyoung@ some time ago
Enable to remove multiple ARP/NDP entries for one destination
The kernel can have multiple ARP/NDP entries which have an indentical
destination on different interfaces. This is normal and can be
reproduce easily by ping -I or ping6 -S. We should be able to remove
such entries.
arp -d <ip> and ndp -d <ip> are changed to fetch all ARP/NDP entries
and remove matched entries. So we can remove multiple entries
described above. This fetch all and selective removal behavior is
the same as arp <ip> and ndp <ip>; they also do fetch all entries
and show only matched entries.
Related to PR 51179
Check if ARP/NDP entries are purged when a related route is deleted

diffstat:

 sbin/route/route.8             |   13 +-
 sbin/route/route.c             |   31 ++-
 sbin/route/rtutil.c            |   12 +-
 sys/net/if_llatbl.c            |   17 +-
 sys/net/if_llatbl.h            |    8 +-
 sys/net/route.c                |   13 +-
 sys/net/route.h                |    6 +-
 sys/net/rtsock.c               |  112 +++++++++--
 sys/netinet/if_arp.c           |   41 +---
 sys/netinet/in.c               |   10 +-
 sys/netinet6/in6.c             |   25 +-
 sys/netinet6/nd6.c             |   64 +------
 sys/netinet6/nd6.h             |    4 +-
 tests/net/arp/t_arp.sh         |  385 +++++++++++++++++++++++++++++++++++-----
 tests/net/ndp/t_ndp.sh         |  302 +++++++++++++++++++++++++++++++-
 tests/net/ndp/t_ra.sh          |   14 +-
 tests/net/net/t_ipv6address.sh |    4 +-
 tests/net/net_common.sh        |    8 +-
 tests/net/route/t_flags.sh     |   24 ++-
 tests/net/route/t_flags6.sh    |   26 ++-
 tests/net/route/t_route.sh     |    6 +-
 usr.sbin/arp/arp.c             |  131 ++++++-------
 usr.sbin/ndp/ndp.c             |  106 ++++++----
 23 files changed, 1013 insertions(+), 349 deletions(-)

diffs (truncated from 2690 to 300 lines):

diff -r 17fa02b8a650 -r 357e7266d7b9 sbin/route/route.8
--- a/sbin/route/route.8        Fri Jul 07 09:46:40 2017 +0000
+++ b/sbin/route/route.8        Fri Jul 07 13:57:26 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: route.8,v 1.56 2016/04/04 07:37:07 ozaki-r Exp $
+.\"    $NetBSD: route.8,v 1.56.8.1 2017/07/07 13:57:26 martin Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)route.8    8.4 (Berkeley) 6/1/94
 .\"
-.Dd March 30, 2016
+.Dd June 16, 2017
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -139,8 +139,17 @@
 .Nm
 .Op Fl n
 .Cm monitor
+.Op Fl c Ar count
 .Ed
 .Pp
+If
+.Ar count
+is specified,
+.Nm
+exits after receiving
+.Ar count
+routing messages.
+.Pp
 The flush command has the syntax
 .Pp
 .Bd -filled -offset indent -compact
diff -r 17fa02b8a650 -r 357e7266d7b9 sbin/route/route.c
--- a/sbin/route/route.c        Fri Jul 07 09:46:40 2017 +0000
+++ b/sbin/route/route.c        Fri Jul 07 13:57:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.155 2017/03/17 16:13:44 roy Exp $  */
+/*     $NetBSD: route.c,v 1.155.4.1 2017/07/07 13:57:26 martin Exp $   */
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)route.c    8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.155 2017/03/17 16:13:44 roy Exp $");
+__RCSID("$NetBSD: route.c,v 1.155.4.1 2017/07/07 13:57:26 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -108,7 +108,7 @@
 static int prefixlen(const char *, struct sou *);
 #ifndef SMALL
 static void interfaces(void);
-__dead static void monitor(void);
+static void monitor(int, char * const *);
 static int print_getmsg(struct rt_msghdr *, int, struct sou *);
 static const char *linkstate(struct if_msghdr *);
 static sup readtag(sup, const char *);
@@ -236,7 +236,7 @@
 
 #ifndef SMALL
        case K_MONITOR:
-               monitor();
+               monitor(argc, argv);
                return 0;
 
 #endif /* SMALL */
@@ -1105,20 +1105,37 @@
 }
 
 static void
-monitor(void)
+monitor(int argc, char * const *argv)
 {
-       int n;
+       int i, n;
        union {
                char msg[2048];
                struct rt_msghdr hdr;
        } u;
+       int count = 0;
+
+       /* usage: route monitor [-c <count>] */
+
+       /* eat "monitor" */
+       argc -= 1;
+       argv += 1;
+
+       /* parse [-c <count>] */
+       if (argc > 0) {
+               if (argc != 2)
+                       usage(argv[0]);
+               if (strcmp(argv[0], "-c") != 0)
+                       usage(argv[0]);
+
+               count = atoi(argv[1]);
+       }
 
        verbose = 1;
        if (debugonly) {
                interfaces();
                exit(0);
        }
-       for(;;) {
+       for(i = 0; count == 0 || i < count; i++) {
                time_t now;
                n = prog_read(sock, &u, sizeof(u));
                now = time(NULL);
diff -r 17fa02b8a650 -r 357e7266d7b9 sbin/route/rtutil.c
--- a/sbin/route/rtutil.c       Fri Jul 07 09:46:40 2017 +0000
+++ b/sbin/route/rtutil.c       Fri Jul 07 13:57:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtutil.c,v 1.8 2016/04/04 07:37:07 ozaki-r Exp $       */
+/*     $NetBSD: rtutil.c,v 1.8.8.1 2017/07/07 13:57:26 martin Exp $    */
 /*     $OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $        */
 
 /*
@@ -59,6 +59,11 @@
 #include "prog_ops.h"
 #include "rtutil.h"
 
+/*
+ * Keep to handle ARP/NDP entries (fake routes)
+ * for backward compatibility.
+ */
+#define RTF_LLINFO     0x400
 
 #define PLEN    (LONG_BIT / 4 + 2)
 #define PFKEYV2_CHUNK sizeof(u_int64_t)
@@ -84,7 +89,7 @@
        /* { RTF_CLONING,       'C' }, */
        { RTF_CONNECTED, 'C' },
        /* { RTF_XRESOLVE,      'X' }, */
-       /* { RTF_LLINFO,        'L' }, */
+       { RTF_LLINFO,   'L' },
        { RTF_STATIC,   'S' },
        { RTF_PROTO1,   '1' },
        { RTF_PROTO2,   '2' },
@@ -263,6 +268,9 @@
        char             ifbuf[IF_NAMESIZE];
 #endif
 
+       if ((flags & RT_LFLAG) && (rtm->rtm_flags & RTF_LLINFO))
+               return;
+
        if (old_af != sa->sa_family) {
                old_af = sa->sa_family;
                p_family(sa->sa_family);
diff -r 17fa02b8a650 -r 357e7266d7b9 sys/net/if_llatbl.c
--- a/sys/net/if_llatbl.c       Fri Jul 07 09:46:40 2017 +0000
+++ b/sys/net/if_llatbl.c       Fri Jul 07 13:57:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_llatbl.c,v 1.18 2017/03/03 06:27:20 msaitoh Exp $   */
+/*     $NetBSD: if_llatbl.c,v 1.18.6.1 2017/07/07 13:57:26 martin Exp $        */
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -80,6 +80,8 @@
 lltable_dump_entry(struct lltable *llt, struct llentry *lle,
     struct rt_walkarg *w, struct sockaddr *sa)
 {
+#define RTF_LLINFO     0x400
+#define RTF_CLONED     0x2000
        struct ifnet *ifp = llt->llt_ifp;
        int error;
        void *a;
@@ -107,9 +109,14 @@
                struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem;
 
                /* Need to copy by myself */
+               rtm->rtm_index = ifp->if_index;
+               rtm->rtm_rmx.rmx_mtu = 0;
                rtm->rtm_rmx.rmx_expire =
                    (lle->la_flags & LLE_STATIC) ? 0 : lle->la_expire;
+               rtm->rtm_flags = RTF_UP;
                rtm->rtm_flags |= RTF_HOST; /* For ndp */
+               /* For backward compatibility */
+               rtm->rtm_flags |= RTF_LLINFO | RTF_CLONED;
                rtm->rtm_flags |= (lle->la_flags & LLE_STATIC) ? RTF_STATIC : 0;
                if (lle->la_flags & LLE_PUB)
                        rtm->rtm_flags |= RTF_ANNOUNCE;
@@ -121,6 +128,8 @@
        }
 
        return error;
+#undef RTF_LLINFO
+#undef RTF_CLONED
 }
 
 /*
@@ -149,7 +158,7 @@
  * Dump arp state for a specific address family.
  */
 int
-lltable_sysctl_dumparp(int af, struct rt_walkarg *w)
+lltable_sysctl_dump(int af, struct rt_walkarg *w)
 {
        struct lltable *llt;
        int error = 0;
@@ -486,8 +495,8 @@
 }
 
 void
-lltable_prefix_free(int af, struct sockaddr *prefix, struct sockaddr *mask,
-    u_int flags)
+lltable_prefix_free(const int af, const struct sockaddr *prefix,
+    const struct sockaddr *mask, const u_int flags)
 {
        struct lltable *llt;
 
diff -r 17fa02b8a650 -r 357e7266d7b9 sys/net/if_llatbl.h
--- a/sys/net/if_llatbl.h       Fri Jul 07 09:46:40 2017 +0000
+++ b/sys/net/if_llatbl.h       Fri Jul 07 13:57:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_llatbl.h,v 1.10 2016/12/21 08:47:02 ozaki-r Exp $   */
+/*     $NetBSD: if_llatbl.h,v 1.10.8.1 2017/07/07 13:57:26 martin Exp $        */
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -254,11 +254,11 @@
 struct lltable *lltable_allocate_htbl(uint32_t hsize);
 void           lltable_free(struct lltable *);
 void           lltable_link(struct lltable *llt);
-void           lltable_prefix_free(int, struct sockaddr *,
-                   struct sockaddr *, u_int);
+void           lltable_prefix_free(const int, const struct sockaddr *,
+                   const struct sockaddr *, const u_int);
 void           lltable_drain(int);
 void           lltable_purge_entries(struct lltable *);
-int            lltable_sysctl_dumparp(int, struct rt_walkarg *);
+int            lltable_sysctl_dump(int, struct rt_walkarg *);
 int            lltable_dump_entry(struct lltable *, struct llentry *,
                    struct rt_walkarg *, struct sockaddr *);
 
diff -r 17fa02b8a650 -r 357e7266d7b9 sys/net/route.c
--- a/sys/net/route.c   Fri Jul 07 09:46:40 2017 +0000
+++ b/sys/net/route.c   Fri Jul 07 13:57:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.194.6.1 2017/06/25 06:31:58 snj Exp $      */
+/*     $NetBSD: route.c,v 1.194.6.2 2017/07/07 13:57:26 martin Exp $   */
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.194.6.1 2017/06/25 06:31:58 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.194.6.2 2017/07/07 13:57:26 martin Exp $");
 
 #include <sys/param.h>
 #ifdef RTFLUSH_DEBUG
@@ -123,6 +123,9 @@
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/route.h>
+#if defined(INET) || defined(INET6)
+#include <net/if_llatbl.h>
+#endif
 
 #include <netinet/in.h>
 #include <netinet/in_var.h>
@@ -1249,6 +1252,10 @@
                need_unlock = false;
                rt_timer_remove_all(rt);
                rtcache_clear_rtentry(dst->sa_family, rt);
+#if defined(INET) || defined(INET6)
+               if (netmask != NULL)
+                       lltable_prefix_free(dst->sa_family, dst, netmask, 0);
+#endif
                if (ret_nrt == NULL) {
                        /* Adjust the refcount */
                        rt_ref(rt);
@@ -1587,8 +1594,6 @@
 
                memset(&info, 0, sizeof(info));
                info.rti_flags = RTF_HOST | RTF_LOCAL;
-               if (!(ifa->ifa_ifp->if_flags & (IFF_LOOPBACK|IFF_POINTOPOINT)))
-                       info.rti_flags |= RTF_LLDATA;
                info.rti_info[RTAX_DST] = ifa->ifa_addr;
                info.rti_info[RTAX_GATEWAY] =
                    (const struct sockaddr *)ifa->ifa_ifp->if_sadl;
diff -r 17fa02b8a650 -r 357e7266d7b9 sys/net/route.h
--- a/sys/net/route.h   Fri Jul 07 09:46:40 2017 +0000
+++ b/sys/net/route.h   Fri Jul 07 13:57:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.h,v 1.112 2017/04/11 13:55:54 roy Exp $  */
+/*     $NetBSD: route.h,v 1.112.4.1 2017/07/07 13:57:26 martin Exp $   */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -500,6 +500,10 @@
 void   rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
 void   route_enqueue(struct mbuf *, int);
 



Home | Main Index | Thread Index | Old Index