Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Don't create a permanent L2 cache entry on adding an address...
details: https://anonhg.NetBSD.org/src/rev/238c05f001ae
branches: trunk
changeset: 824858:238c05f001ae
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Jun 21 09:05:31 2017 +0000
description:
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).
diffstat:
sys/netinet/if_arp.c | 34 +++-------------------------------
sys/netinet6/in6.c | 13 +++++++------
sys/netinet6/nd6.c | 41 ++---------------------------------------
sys/netinet6/nd6.h | 3 +--
tests/net/arp/t_arp.sh | 20 +++++++++-----------
tests/net/ndp/t_ndp.sh | 16 +++++++---------
tests/net/ndp/t_ra.sh | 12 ++++++------
tests/net/net/t_ipv6address.sh | 4 ++--
8 files changed, 37 insertions(+), 106 deletions(-)
diffs (truncated from 368 to 300 lines):
diff -r 5de693b0e2ec -r 238c05f001ae sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c Wed Jun 21 08:40:05 2017 +0000
+++ b/sys/netinet/if_arp.c Wed Jun 21 09:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arp.c,v 1.251 2017/06/16 02:24:54 ozaki-r Exp $ */
+/* $NetBSD: if_arp.c,v 1.252 2017/06/21 09:05:31 ozaki-r 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.251 2017/06/16 02:24:54 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.252 2017/06/21 09:05:31 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1472,41 +1472,13 @@
void
arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa)
{
- struct in_addr *ip;
struct in_ifaddr *ia = (struct in_ifaddr *)ifa;
- /*
- * Warn the user if another station has this IP address,
- * but only if the interface IP address is not zero.
- */
- ip = &IA_SIN(ifa)->sin_addr;
- if (!in_nullhost(*ip) &&
- (ia->ia4_flags & (IN_IFF_NOTREADY | IN_IFF_DETACHED)) == 0) {
- struct llentry *lle;
-
- /*
- * interface address is considered static entry
- * because the output of the arp utility shows
- * that L2 entry as permanent
- */
- IF_AFDATA_WLOCK(ifp);
- lle = lla_create(LLTABLE(ifp), (LLE_IFADDR | LLE_STATIC),
- (struct sockaddr *)IA_SIN(ifa));
- IF_AFDATA_WUNLOCK(ifp);
- if (lle == NULL)
- log(LOG_INFO, "%s: cannot create arp entry for"
- " interface address\n", __func__);
- else {
- arp_init_llentry(ifp, lle);
- LLE_RUNLOCK(lle);
- }
- }
-
ifa->ifa_rtrequest = arp_rtrequest;
ifa->ifa_flags |= RTF_CONNECTED;
/* ARP will handle DAD for this address. */
- if (in_nullhost(*ip)) {
+ if (in_nullhost(IA_SIN(ifa)->sin_addr)) {
if (ia->ia_dad_stop != NULL) /* safety */
ia->ia_dad_stop(ifa);
ia->ia_dad_start = NULL;
diff -r 5de693b0e2ec -r 238c05f001ae sys/netinet6/in6.c
--- a/sys/netinet6/in6.c Wed Jun 21 08:40:05 2017 +0000
+++ b/sys/netinet6/in6.c Wed Jun 21 09:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.245 2017/04/28 05:56:33 ozaki-r Exp $ */
+/* $NetBSD: in6.c,v 1.246 2017/06/21 09:05:31 ozaki-r Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.245 2017/04/28 05:56:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.246 2017/06/21 09:05:31 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1298,10 +1298,11 @@
goto cleanup;
}
- /* Add local address to lltable, if necessary (ex. on p2p link). */
- error = nd6_add_ifa_lle(ia);
- if (error != 0)
- goto cleanup;
+ if (nd6_need_cache(ifp)) {
+ /* XXX maybe unnecessary */
+ ia->ia_ifa.ifa_rtrequest = nd6_rtrequest;
+ ia->ia_ifa.ifa_flags |= RTF_CONNECTED;
+ }
/*
* Perform DAD, if needed.
diff -r 5de693b0e2ec -r 238c05f001ae sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c Wed Jun 21 08:40:05 2017 +0000
+++ b/sys/netinet6/nd6.c Wed Jun 21 09:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.c,v 1.233 2017/06/16 02:24:54 ozaki-r Exp $ */
+/* $NetBSD: nd6.c,v 1.234 2017/06/21 09:05:31 ozaki-r 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.233 2017/06/16 02:24:54 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.234 2017/06/21 09:05:31 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -2424,43 +2424,6 @@
}
/*
- * Add pernament ND6 link-layer record for given
- * interface address.
- *
- * Very similar to IPv4 arp_ifinit(), but:
- * 1) IPv6 DAD is performed in different place
- * 2) It is called by IPv6 protocol stack in contrast to
- * arp_ifinit() which is typically called in SIOCSIFADDR
- * driver ioctl handler.
- *
- */
-int
-nd6_add_ifa_lle(struct in6_ifaddr *ia)
-{
- struct ifnet *ifp;
- struct llentry *ln;
-
- ifp = ia->ia_ifa.ifa_ifp;
- if (nd6_need_cache(ifp) == 0)
- return 0;
- ia->ia_ifa.ifa_rtrequest = nd6_rtrequest;
- ia->ia_ifa.ifa_flags |= RTF_CONNECTED;
-
- IF_AFDATA_WLOCK(ifp);
- ln = lla_create(LLTABLE6(ifp), LLE_IFADDR | LLE_EXCLUSIVE,
- sin6tosa(&ia->ia_addr));
- IF_AFDATA_WUNLOCK(ifp);
- if (ln == NULL)
- return ENOBUFS;
-
- ln->la_expire = 0; /* for IPv6 this means permanent */
- ln->ln_state = ND6_LLINFO_REACHABLE;
-
- LLE_WUNLOCK(ln);
- return 0;
-}
-
-/*
* Removes ALL lle records for interface address prefix.
* XXXME: That's probably not we really want to do, we need
* to remove address record only and keep other records
diff -r 5de693b0e2ec -r 238c05f001ae sys/netinet6/nd6.h
--- a/sys/netinet6/nd6.h Wed Jun 21 08:40:05 2017 +0000
+++ b/sys/netinet6/nd6.h Wed Jun 21 09:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.h,v 1.83 2017/02/22 03:02:55 ozaki-r Exp $ */
+/* $NetBSD: nd6.h,v 1.84 2017/06/21 09:05:31 ozaki-r Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
@@ -447,7 +447,6 @@
int nd6_sysctl(int, void *, size_t *, void *, size_t);
int nd6_need_cache(struct ifnet *);
void nd6_llinfo_release_pkts(struct llentry *, struct ifnet *);
-int nd6_add_ifa_lle(struct in6_ifaddr *);
void nd6_rem_ifa_lle(struct in6_ifaddr *);
/* nd6_nbr.c */
diff -r 5de693b0e2ec -r 238c05f001ae tests/net/arp/t_arp.sh
--- a/tests/net/arp/t_arp.sh Wed Jun 21 08:40:05 2017 +0000
+++ b/tests/net/arp/t_arp.sh Wed Jun 21 09:05:31 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_arp.sh,v 1.25 2017/06/21 03:10:42 ozaki-r Exp $
+# $NetBSD: t_arp.sh,v 1.26 2017/06/21 09:05:31 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -134,8 +134,8 @@
# Sanity check
$DEBUG && rump.ifconfig shmif0
$DEBUG && rump.arp -n -a
- atf_check -s exit:0 -o ignore rump.arp -n $IP4SRC
- atf_check -s not-exit:0 -e ignore rump.arp -n $IP4DST
+ atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4SRC
+ atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4DST
}
test_cache_expiration()
@@ -156,16 +156,16 @@
atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST
$DEBUG && rump.arp -n -a
- atf_check -s exit:0 -o ignore rump.arp -n $IP4SRC
+ atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4SRC
# Should be cached
atf_check -s exit:0 -o ignore rump.arp -n $IP4DST
atf_check -s exit:0 sleep $(($arp_keep + $bonus))
$DEBUG && rump.arp -n -a
- atf_check -s exit:0 -o ignore rump.arp -n $IP4SRC
+ atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4SRC
# Should be expired
- atf_check -s not-exit:0 -e ignore rump.arp -n $IP4DST
+ atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4DST
}
arp_cache_expiration_5s_body()
@@ -195,9 +195,6 @@
export RUMP_SERVER=$SOCKSRC
- # We can delete the entry for the interface's IP address
- atf_check -s exit:0 -o ignore rump.arp -d $IP4SRC
-
# Add and delete a static entry
$DEBUG && rump.arp -n -a
atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10
@@ -323,9 +320,10 @@
export RUMP_SERVER=$SOCKSRC
# Cannot overwrite a permanent cache
+ atf_check -s exit:0 rump.arp -s $IP4SRC b2:a0:20:00:00:ff
+ $DEBUG && rump.arp -n -a
atf_check -s not-exit:0 -e match:'File exists' \
- rump.arp -s $IP4SRC b2:a0:20:00:00:ff
- $DEBUG && rump.arp -n -a
+ rump.arp -s $IP4SRC b2:a0:20:00:00:fe
atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST
$DEBUG && rump.arp -n -a
diff -r 5de693b0e2ec -r 238c05f001ae tests/net/ndp/t_ndp.sh
--- a/tests/net/ndp/t_ndp.sh Wed Jun 21 08:40:05 2017 +0000
+++ b/tests/net/ndp/t_ndp.sh Wed Jun 21 09:05:31 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ndp.sh,v 1.21 2017/06/19 10:57:37 ozaki-r Exp $
+# $NetBSD: t_ndp.sh,v 1.22 2017/06/21 09:05:31 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -99,8 +99,8 @@
# Sanity check
$DEBUG && rump.ifconfig shmif0
$DEBUG && rump.ndp -n -a
- atf_check -s exit:0 -o ignore rump.ndp -n $IP6SRC
- atf_check -s not-exit:0 -o ignore -e ignore rump.ndp -n $IP6DST
+ atf_check -s not-exit:0 -o ignore -e match:'no entry' rump.ndp -n $IP6SRC
+ atf_check -s not-exit:0 -o ignore -e match:'no entry' rump.ndp -n $IP6DST
}
get_timeout()
@@ -126,7 +126,7 @@
atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6DST
$DEBUG && rump.ndp -n -a
- atf_check -s exit:0 -o match:'permanent' rump.ndp -n $IP6SRC
+ atf_check -s not-exit:0 -o ignore -e match:'no entry' rump.ndp -n $IP6SRC
# Should be cached
atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n $IP6DST
@@ -135,7 +135,7 @@
atf_check -s exit:0 sleep $(($timeout + 1))
$DEBUG && rump.ndp -n -a
- atf_check -s exit:0 -o match:'permanent' rump.ndp -n $IP6SRC
+ atf_check -s not-exit:0 -o ignore -e match:'no entry' rump.ndp -n $IP6SRC
# Expired but remains until GC sweaps it (1 day)
atf_check -s exit:0 -o match:"$ONEDAYISH" rump.ndp -n $IP6DST
@@ -160,9 +160,6 @@
export RUMP_SERVER=$SOCKSRC
- # We can delete the entry for the interface's IP address
- atf_check -s exit:0 -o match:"$IP6SRC" rump.ndp -d $IP6SRC
-
# Add and delete a static entry
$DEBUG && rump.ndp -n -a
atf_check -s exit:0 -o ignore rump.ndp -s fc00::10 b2:a0:20:00:00:10
@@ -229,8 +226,9 @@
export RUMP_SERVER=$SOCKSRC
# Cannot overwrite a permanent cache
- atf_check -s not-exit:0 -e ignore rump.ndp -s $IP6SRC b2:a0:20:00:00:ff
+ atf_check -s exit:0 rump.ndp -s $IP6SRC b2:a0:20:00:00:ff
$DEBUG && rump.ndp -n -a
+ atf_check -s not-exit:0 -e ignore rump.ndp -s $IP6SRC b2:a0:20:00:00:fe
atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6DST
$DEBUG && rump.ndp -n -a
diff -r 5de693b0e2ec -r 238c05f001ae tests/net/ndp/t_ra.sh
--- a/tests/net/ndp/t_ra.sh Wed Jun 21 08:40:05 2017 +0000
+++ b/tests/net/ndp/t_ra.sh Wed Jun 21 09:05:31 2017 +0000
@@ -1,4 +1,4 @@
Home |
Main Index |
Thread Index |
Old Index