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/4597f2ce444a
branches: netbsd-8
changeset: 434836:4597f2ce444a
user: snj <snj%NetBSD.org@localhost>
date: Sun Apr 08 06:09:12 2018 +0000
description:
Pull up following revision(s) (requested by ozaki-r in ticket #701):
sys/netinet/in.c: 1.227
sys/netinet6/in6.c: 1.265
tests/net/arp/t_arp.sh: 1.35-1.36
Make GARP work again when DAD is disabled
The change avoids setting an IP address tentative on initializing it when
the IPv4 DAD is disabled (net.inet.ip.dad_count=0), which allows a GARP packet
to be sent (see arpannounce). This is the same behavior of NetBSD 7, i.e.,
before introducing the IPv4 DAD.
Additionally do the same change to IPv6 DAD for consistency.
The change is suggested by roy@
--
Improve packet checks and error reporting
--
Add tests for GARP without DAD
Additionally make the existing tests for GARP more explicit.
diffstat:
sys/netinet/in.c | 6 +-
sys/netinet6/in6.c | 8 ++-
tests/net/arp/t_arp.sh | 106 ++++++++++++++++++++++++++++++++++++++++--------
3 files changed, 96 insertions(+), 24 deletions(-)
diffs (249 lines):
diff -r 96a2a3b8d3e2 -r 4597f2ce444a sys/netinet/in.c
--- a/sys/netinet/in.c Sun Apr 08 06:06:07 2018 +0000
+++ b/sys/netinet/in.c Sun Apr 08 06:09:12 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in.c,v 1.203.2.11 2018/03/13 13:27:10 martin Exp $ */
+/* $NetBSD: in.c,v 1.203.2.12 2018/04/08 06:09:12 snj 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.203.2.11 2018/03/13 13:27:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.203.2.12 2018/04/08 06:09:12 snj Exp $");
#include "arp.h"
@@ -1150,7 +1150,7 @@
if (ifp->if_link_state == LINK_STATE_DOWN) {
ia->ia4_flags |= IN_IFF_DETACHED;
ia->ia4_flags &= ~IN_IFF_TENTATIVE;
- } else if (hostIsNew && if_do_dad(ifp))
+ } else if (hostIsNew && if_do_dad(ifp) && ip_dad_count > 0)
ia->ia4_flags |= IN_IFF_TRYTENTATIVE;
/*
diff -r 96a2a3b8d3e2 -r 4597f2ce444a sys/netinet6/in6.c
--- a/sys/netinet6/in6.c Sun Apr 08 06:06:07 2018 +0000
+++ b/sys/netinet6/in6.c Sun Apr 08 06:09:12 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.245.2.9 2018/03/13 13:27:10 martin Exp $ */
+/* $NetBSD: in6.c,v 1.245.2.10 2018/04/08 06:09:12 snj 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.2.9 2018/03/13 13:27:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.245.2.10 2018/04/08 06:09:12 snj Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1240,8 +1240,10 @@
if (ifp->if_link_state == LINK_STATE_DOWN) {
ia->ia6_flags |= IN6_IFF_DETACHED;
ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
- } else if ((hostIsNew || was_tentative) && if_do_dad(ifp))
+ } else if ((hostIsNew || was_tentative) && if_do_dad(ifp) &&
+ ip6_dad_count > 0) {
ia->ia6_flags |= IN6_IFF_TENTATIVE;
+ }
/*
* backward compatibility - if IN6_IFF_DEPRECATED is set from the
diff -r 96a2a3b8d3e2 -r 4597f2ce444a tests/net/arp/t_arp.sh
--- a/tests/net/arp/t_arp.sh Sun Apr 08 06:06:07 2018 +0000
+++ b/tests/net/arp/t_arp.sh Sun Apr 08 06:09:12 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_arp.sh,v 1.22.6.1 2017/07/07 13:57:26 martin Exp $
+# $NetBSD: t_arp.sh,v 1.22.6.2 2018/04/08 06:09:12 snj Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -41,6 +41,7 @@
atf_test_case arp_cache_expiration_10s cleanup
atf_test_case arp_command cleanup
atf_test_case arp_garp cleanup
+atf_test_case arp_garp_without_dad cleanup
atf_test_case arp_cache_overwriting cleanup
atf_test_case arp_proxy_arp_pub cleanup
atf_test_case arp_proxy_arp_pubproxy cleanup
@@ -71,6 +72,13 @@
atf_set "require.progs" "rump_server"
}
+arp_garp_without_dad_head()
+{
+
+ atf_set "descr" "Tests for GARP with DAD disabled"
+ atf_set "require.progs" "rump_server"
+}
+
arp_cache_overwriting_head()
{
atf_set "descr" "Tests for behavior of overwriting ARP caches"
@@ -292,50 +300,105 @@
{
local target=$1
local sender=$2
- pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42:"
+ pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP \(0x0806\), length 42:"
pkt="$pkt Request who-has $target tell $sender, length 28"
echo $pkt
}
-arp_garp_body()
+test_garp_common()
{
+ local no_dad=$1
local pkt=
rump_server_start $SOCKSRC
export RUMP_SERVER=$SOCKSRC
+ if $no_dad; then
+ atf_check -s exit:0 -o match:'3 -> 0' \
+ rump.sysctl -w net.inet.ip.dad_count=0
+ fi
+
# Setup an interface
rump_server_add_iface $SOCKSRC shmif0 bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24
- atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias
atf_check -s exit:0 rump.ifconfig shmif0 up
$DEBUG && rump.ifconfig shmif0
atf_check -s exit:0 sleep 1
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out
+ extract_new_packets bus1 > ./out
+ #
+ # Assign an address to an interface without IFF_UP
+ #
# A GARP packet is sent for the primary address
pkt=$(make_pkt_str_arpreq 10.0.0.1 10.0.0.1)
- atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
- # No GARP packet is sent for the alias address
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+
+ atf_check -s exit:0 rump.ifconfig shmif0 down
+ atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias
+
+ atf_check -s exit:0 sleep 1
+ extract_new_packets bus1 > ./out
+
+ # A GARP packet is sent for the alias address
pkt=$(make_pkt_str_arpreq 10.0.0.2 10.0.0.2)
- atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+
+ # Clean up
+ atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 delete
+ atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 delete
+
+ #
+ # Assign an address to an interface with IFF_UP
+ #
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+
+ # Primary address
+ atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24
- atf_check -s exit:0 rump.ifconfig -w 10
- atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24
+ atf_check -s exit:0 sleep 1
+ extract_new_packets bus1 > ./out
+
+ pkt=$(make_pkt_str_arpreq 10.0.0.3 10.0.0.3)
+ if $no_dad; then
+ # A GARP packet is sent
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+ else
+ # No GARP packet is sent
+ atf_check -s exit:0 -o not-match:"$pkt" cat ./out
+ fi
+
+ # Alias address
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.4/24 alias
- # No GARP packets are sent during IFF_UP
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out
- pkt=$(make_pkt_str_arpreq 10.0.0.3 10.0.0.3)
- atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
+ atf_check -s exit:0 sleep 1
+ extract_new_packets bus1 > ./out
+
pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4)
- atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
+ if $no_dad; then
+ # A GARP packet is sent
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+ else
+ # No GARP packet is sent
+ atf_check -s exit:0 -o not-match:"$pkt" cat ./out
+ fi
rump_server_destroy_ifaces
}
+arp_garp_body()
+{
+
+ test_garp_common false
+}
+
+arp_garp_without_dad_body()
+{
+
+ test_garp_common true
+}
+
arp_cache_overwriting_body()
{
local bonus=2
@@ -519,7 +582,7 @@
$DEBUG && cat ./out
pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC)
- atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
+ atf_check -s exit:0 -o not-match:"$pkt" cat ./out
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 link \
b2:a1:00:00:00:02 active
@@ -529,8 +592,7 @@
$DEBUG && cat ./out
pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC)
- atf_check -s exit:0 -x \
- "cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'"
+ atf_check -s exit:0 -o match:"b2:a1:00:00:00:02 $pkt" cat ./out
rump_server_destroy_ifaces
}
@@ -584,6 +646,13 @@
cleanup
}
+arp_garp_without_dad_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
arp_cache_overwriting_cleanup()
{
$DEBUG && dump
@@ -882,6 +951,7 @@
atf_add_test_case arp_cache_expiration_10s
atf_add_test_case arp_command
atf_add_test_case arp_garp
+ atf_add_test_case arp_garp_without_dad
atf_add_test_case arp_cache_overwriting
atf_add_test_case arp_proxy_arp_pub
atf_add_test_case arp_proxy_arp_pubproxy
Home |
Main Index |
Thread Index |
Old Index