CVS commit: src/tests/net/if_vlan

2023-11-02 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Nov  2 09:50:50 UTC 2023

Modified Files:
src/tests/net/if_vlan: t_vlan.sh

Log Message:
Added the test for vlan over l2tp


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/tests/net/if_vlan/t_vlan.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_vlan/t_vlan.sh
diff -u src/tests/net/if_vlan/t_vlan.sh:1.24 src/tests/net/if_vlan/t_vlan.sh:1.25
--- src/tests/net/if_vlan/t_vlan.sh:1.24	Thu Aug 19 03:27:05 2021
+++ src/tests/net/if_vlan/t_vlan.sh	Thu Nov  2 09:50:50 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: t_vlan.sh,v 1.24 2021/08/19 03:27:05 yamaguchi Exp $
+#	$NetBSD: t_vlan.sh,v 1.25 2023/11/02 09:50:50 yamaguchi Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -1035,6 +1035,139 @@ vlan_promisc_cleanup()
 	cleanup
 }
 
+vlan_l2tp_body_common()
+{
+	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
+
+	local af=$1
+	local ping_cmd="rump.ping -c 1"
+	local pfx=24
+	local local0=$IP_LOCAL0
+	local local1=$IP_LOCAL1
+	local remote0=$IP_REMOTE0
+	local remote1=$IP_REMOTE1
+	local sysctl_param="net.inet.ip.dad_count=0"
+	local vid0=10
+	local vid1=11
+
+	local l2tp_laddr=10.222.222.1
+	local l2tp_lsession=1001
+	local l2tp_raddr=10.222.222.2
+	local l2tp_rsession=1002
+
+	if [ x"$af" = x"inet6" ]; then
+		ping_cmd="rump.ping6 -c 1"
+		rumplib="netinet6"
+		pfx=64
+		local0=$IP6_LOCAL0
+		local1=$IP6_LOCAL1
+		remote0=$IP6_REMOTE0
+		remote1=$IP6_REMOTE1
+		sysctl_param="net.inet6.ip6.dad_count=0"
+	fi
+
+	rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+	rump_server_add_iface $SOCK_LOCAL l2tp0
+	rump_server_add_iface $SOCK_LOCAL vlan0
+	rump_server_add_iface $SOCK_LOCAL vlan1
+
+	rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
+	rump_server_add_iface $SOCK_REMOTE l2tp0
+	rump_server_add_iface $SOCK_REMOTE vlan0
+	rump_server_add_iface $SOCK_REMOTE vlan1
+
+	export RUMP_SERVER=$SOCK_LOCAL
+	atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param
+	$atf_ifconfig shmif0 $l2tp_laddr/24
+	$atf_ifconfig l2tp0 tunnel  $l2tp_laddr $l2tp_raddr
+	$atf_ifconfig l2tp0 session $l2tp_lsession $l2tp_rsession
+	$atf_ifconfig l2tp0 up
+
+	export RUMP_SERVER=$SOCK_REMOTE
+	atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param
+	$atf_ifconfig shmif0 $l2tp_raddr/24
+	$atf_ifconfig l2tp0 tunnel  $l2tp_raddr $l2tp_laddr
+	$atf_ifconfig l2tp0 session $l2tp_rsession $l2tp_lsession
+	$atf_ifconfig l2tp0 up
+
+	# configure vlans on l2tp(4)
+	export RUMP_SERVER=$SOCK_LOCAL
+	$atf_ifconfig vlan0 vlan $vid0 vlanif l2tp0
+	$atf_ifconfig vlan0 $af $local0/$pfx
+	$atf_ifconfig vlan1 vlan $vid1 vlanif l2tp0
+	$atf_ifconfig vlan1 $af $local1/$pfx
+	export RUMP_SERVER=$SOCK_REMOTE
+	$atf_ifconfig vlan0 vlan $vid0 vlanif l2tp0
+	$atf_ifconfig vlan0 $af $remote0/$pfx
+	$atf_ifconfig vlan1 vlan $vid1 vlanif l2tp0
+	$atf_ifconfig vlan1 $af $remote1/$pfx
+
+	# test for VLAN frame transfer
+	export RUMP_SERVER=$SOCK_LOCAL
+	atf_check -s exit:0 -o ignore $ping_cmd $remote0
+	atf_check -s exit:0 -o ignore $ping_cmd $remote1
+
+	# unconfig vlans
+	export RUMP_SERVER=$SOCK_LOCAL
+	$atf_ifconfig vlan0 -vlanif
+	export RUMP_SERVER=$SOCK_REMOTE
+	$atf_ifconfig vlan0 -vlanif
+
+	# remove l2tp0 that has vlan1
+	export RUMP_SERVER=$SOCK_LOCAL
+	$atf_ifconfig l2tp0 destroy
+	export RUMP_SERVER=$SOCK_REMOTE
+	$atf_ifconfig l2tp0 destroy
+}
+
+atf_test_case vlan_l2tp cleanup
+vlan_l2tp_head()
+{
+
+	atf_set "descr" "tests of vlan(IPv4) over l2tp(IPv4)"
+	atf_set "require.progs" "rump_server"
+}
+
+vlan_l2tp_body()
+{
+
+	rump_server_start $SOCK_LOCAL  vlan l2tp
+	rump_server_start $SOCK_REMOTE vlan l2tp
+
+	vlan_l2tp_body_common "inet"
+}
+
+vlan_l2tp_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
+atf_test_case vlan_l2tp6 cleanup
+vlan_l2tp6_head()
+{
+
+	atf_set "descr" "tests of vlan(IPv6) over l2tp(IPv4)"
+	atf_set "require.progs" "rump_server"
+}
+
+vlan_l2tp6_body()
+{
+
+	rump_server_start $SOCK_LOCAL  vlan l2tp netinet6
+	rump_server_start $SOCK_REMOTE vlan l2tp netinet6
+
+	vlan_l2tp_body_common "inet6"
+}
+
+vlan_l2tp6_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 atf_init_test_cases()
 {
 
@@ -1046,6 +1179,7 @@ atf_init_test_cases()
 	atf_add_test_case vlan_bridge
 	atf_add_test_case vlan_multicast
 	atf_add_test_case vlan_promisc
+	atf_add_test_case vlan_l2tp
 
 	atf_add_test_case vlan_create_destroy6
 	atf_add_test_case vlan_basic6
@@ -1054,4 +1188,5 @@ atf_init_test_cases()
 	atf_add_test_case vlan_configs6
 	atf_add_test_case vlan_bridge6
 	atf_add_test_case vlan_multicast6
+	atf_add_test_case vlan_l2tp6
 }



CVS commit: src/tests/net/if_vlan

2023-11-02 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Nov  2 09:50:50 UTC 2023

Modified Files:
src/tests/net/if_vlan: t_vlan.sh

Log Message:
Added the test for vlan over l2tp


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/tests/net/if_vlan/t_vlan.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/net/if_vlan

2021-08-18 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Aug 19 03:36:42 UTC 2021

Modified Files:
src/tests/net/if_vlan: siocXmulti.c

Log Message:
Added description of license


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_vlan/siocXmulti.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_vlan/siocXmulti.c
diff -u src/tests/net/if_vlan/siocXmulti.c:1.2 src/tests/net/if_vlan/siocXmulti.c:1.3
--- src/tests/net/if_vlan/siocXmulti.c:1.2	Sun Oct 13 07:46:16 2019
+++ src/tests/net/if_vlan/siocXmulti.c	Thu Aug 19 03:36:42 2021
@@ -1,3 +1,33 @@
+/*	$NetBSD: siocXmulti.c,v 1.3 2021/08/19 03:36:42 yamaguchi Exp $	*/
+
+/*
+ * Copyright (c) 2021 Internet Initiative Japan Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__RCSID("$NetBSD: siocXmulti.c,v 1.3 2021/08/19 03:36:42 yamaguchi Exp $");
 
 #include 
 #include 



CVS commit: src/tests/net/if_vlan

2021-08-18 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Aug 19 03:36:42 UTC 2021

Modified Files:
src/tests/net/if_vlan: siocXmulti.c

Log Message:
Added description of license


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_vlan/siocXmulti.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/net/if_vlan

2021-08-18 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Aug 19 03:27:05 UTC 2021

Modified Files:
src/tests/net/if_vlan: Makefile bpfopen.c t_vlan.sh

Log Message:
Make the test program run in background after doing BIOCPROMISC

t_vlan has rarely failed by checking IFF_PROMISC before the
test program do BIOCPROMISC. To solve this, BIOCPROMISC is
done in the foreground.

fixes PR/56357


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/net/if_vlan/Makefile
cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_vlan/bpfopen.c
cvs rdiff -u -r1.23 -r1.24 src/tests/net/if_vlan/t_vlan.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_vlan/Makefile
diff -u src/tests/net/if_vlan/Makefile:1.3 src/tests/net/if_vlan/Makefile:1.4
--- src/tests/net/if_vlan/Makefile:1.3	Fri Jul  9 05:54:11 2021
+++ src/tests/net/if_vlan/Makefile	Thu Aug 19 03:27:05 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2021/07/09 05:54:11 yamaguchi Exp $
+# $NetBSD: Makefile,v 1.4 2021/08/19 03:27:05 yamaguchi Exp $
 #
 
 .include 
@@ -17,5 +17,7 @@ BINDIR.siocXmulti=	${TESTSDIR}
 PROGS+=			bpfopen
 MAN.bpfopen=	#empty
 BINDIR.bpfopen=	${TESTSDIR}
+DPADD.bpfopen+=	${LIBUTIL}
+LDADD.bpfopen+=	-lutil
 
 .include 

Index: src/tests/net/if_vlan/bpfopen.c
diff -u src/tests/net/if_vlan/bpfopen.c:1.1 src/tests/net/if_vlan/bpfopen.c:1.2
--- src/tests/net/if_vlan/bpfopen.c:1.1	Fri Jul  9 05:54:11 2021
+++ src/tests/net/if_vlan/bpfopen.c	Thu Aug 19 03:27:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfopen.c,v 1.1 2021/07/09 05:54:11 yamaguchi Exp $	*/
+/*	$NetBSD: bpfopen.c,v 1.2 2021/08/19 03:27:05 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: bpfopen.c,v 1.1 2021/07/09 05:54:11 yamaguchi Exp $");
+__RCSID("$NetBSD: bpfopen.c,v 1.2 2021/08/19 03:27:05 yamaguchi Exp $");
 
 #include 
 #include 
@@ -45,6 +45,8 @@ __RCSID("$NetBSD: bpfopen.c,v 1.1 2021/0
 #include 
 #include 
 
+#include 
+
 enum {
 	ARG_PROG = 0,
 	ARG_HOST,
@@ -58,16 +60,25 @@ enum {
 };
 
 static void	sighandler(int);
-
-static sig_atomic_t quit;
+static void	log_debug(const char *, ...) __printflike(1, 2);
+static int	bpf_open(void);
+static void	bpf_close(int);
+static void	bpf_read(int);
+
+static sig_atomic_t	 quit;
+static bool		 daemonize = false;
+static int		 verbose = 0;
+static const char	*path_pid = "/var/run/bpfopen.pid";
+static const char	*path_bpf = "/dev/bpf";
+static const char	*ifname = NULL;
 
 static void
 usage(void)
 {
 
-	fprintf(stderr, "%s {-r|-h} \n"
-	"\t-r: rump_server\n"
-	"\t-h: host\n",
+	fprintf(stderr, "%s [-vd] [-p pidfile] [-b devbpf ] \n"
+	"\t-v: verbose\n"
+	"\t-d: daemon mode\n",
 	getprogname());
 	exit(1);
 }
@@ -75,42 +86,146 @@ usage(void)
 int
 main(int argc, char *argv[])
 {
-	struct ifreq ifr;
-	struct pollfd pfd[PFD_NUM];
-	const char *bpf_path;
-	int n, bpfd, nfds;
-	size_t bufsiz;
-	char *buf;
+	int bpfd;
+	int ch;
 
-	if (argc != ARG_NUM)
+	while ((ch = getopt(argc, argv, "b:dp:v")) != -1) {
+		switch (ch) {
+		case 'b':
+			path_bpf = optarg;
+			break;
+		case 'd':
+			daemonize = true;
+			break;
+		case 'p':
+			path_pid = optarg;
+			break;
+		case 'v':
+			verbose++;
+			break;
+		default:
+			usage();
+		}
+	}
+
+	argc -= optind;
+	argv += optind;
+
+	if (argc != 1)
 		usage();
 
-	if (strcmp(argv[ARG_HOST], "-h") == 0) {
-		bpf_path = "/dev/bpf";
-	} else if (strcmp(argv[ARG_HOST], "-r") == 0){
-		bpf_path = "/rump/dev/bpf";
-	} else {
-		errx(1, "-r or -h");
-	}
+	ifname = argv[0];
 
-	bpfd = open(bpf_path, O_RDONLY);
+	bpfd = bpf_open();
 	if (bpfd < 0)
-		err(1, "open %s", bpf_path);
+		err(1, "bpf_open");
+	log_debug("bpf opened");
+
+	if (daemonize) {
+		if (daemon(1, 1) != 0) {
+			bpf_close(bpfd);
+			err(1, "daemon");
+		}
+		log_debug("daemonized");
+
+		if (pidfile(path_pid) != 0) {
+			bpf_close(bpfd);
+			err(1, "pidfile");
+		}
+	}
+
+	bpf_read(bpfd);
+	bpf_close(bpfd);
+	if (daemonize)
+		pidfile_clean();
+
+	return 0;
+}
+
+static void
+sighandler(int signo)
+{
+
+	quit = 1;
+}
+
+static void
+log_debug(const char *fmt, ...)
+{
+	va_list ap;
+
+	if (verbose <= 0)
+		return;
+
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+
+	fprintf(stderr, "\n");
+}
+
+static int
+bpf_open(void)
+{
+	struct ifreq ifr;
+	int bpfd;
+
+	bpfd = open(path_bpf, O_RDONLY);
+	if (bpfd < 0) {
+		log_debug("open: %s", strerror(errno));
+		return -1;
+	}
 
 	memset(, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, argv[ARG_IFNAME],
-	sizeof(ifr.ifr_name));
-	if (ioctl(bpfd, BIOCSETIF, ) != 0)
-		err(1, "BIOCSETIF");
-	if (ioctl(bpfd, BIOCPROMISC, NULL) != 0)
-		err(1, "BIOCPROMISC");
-	if (ioctl(bpfd, BIOCGBLEN, ) != 0)
-		err(1, "BIOCGBLEN");
+	strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+
+	if (ioctl(bpfd, BIOCSETIF, ) != 0) {
+		log_debug("BIOCSETIF: %s", strerror(errno));
+		goto 

CVS commit: src/tests/net/if_vlan

2021-08-18 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Aug 19 03:27:05 UTC 2021

Modified Files:
src/tests/net/if_vlan: Makefile bpfopen.c t_vlan.sh

Log Message:
Make the test program run in background after doing BIOCPROMISC

t_vlan has rarely failed by checking IFF_PROMISC before the
test program do BIOCPROMISC. To solve this, BIOCPROMISC is
done in the foreground.

fixes PR/56357


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/net/if_vlan/Makefile
cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_vlan/bpfopen.c
cvs rdiff -u -r1.23 -r1.24 src/tests/net/if_vlan/t_vlan.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/net/if_vlan

2019-11-10 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Nov 11 02:40:48 UTC 2019

Modified Files:
src/tests/net/if_vlan: t_vlan.sh

Log Message:
atf: add test cases for MTU that is increased on SIOCSETVLAN

>From t-kusaba@IIJ, thanks


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/net/if_vlan/t_vlan.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/net/if_vlan

2019-11-10 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Nov 11 02:40:48 UTC 2019

Modified Files:
src/tests/net/if_vlan: t_vlan.sh

Log Message:
atf: add test cases for MTU that is increased on SIOCSETVLAN

>From t-kusaba@IIJ, thanks


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/net/if_vlan/t_vlan.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_vlan/t_vlan.sh
diff -u src/tests/net/if_vlan/t_vlan.sh:1.15 src/tests/net/if_vlan/t_vlan.sh:1.16
--- src/tests/net/if_vlan/t_vlan.sh:1.15	Tue Dec 11 03:47:51 2018
+++ src/tests/net/if_vlan/t_vlan.sh	Mon Nov 11 02:40:48 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: t_vlan.sh,v 1.15 2018/12/11 03:47:51 ozaki-r Exp $
+#	$NetBSD: t_vlan.sh,v 1.16 2019/11/11 02:40:48 yamaguchi Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -33,9 +33,9 @@ IP_LOCAL1=10.0.1.1
 IP_REMOTE0=10.0.0.2
 IP_REMOTE1=10.0.1.2
 IP_MCADDR0=224.0.0.10
-IP6_LOCAL0=fc00:0::1
+IP6_LOCAL0=fc00::1
 IP6_LOCAL1=fc00:1::1
-IP6_REMOTE0=fc00:0::2
+IP6_REMOTE0=fc00::2
 IP6_REMOTE1=fc00:1::2
 IP6_MCADDR0=ff11::10
 ETH_IP_MCADDR0=01:00:5e:00:00:0a
@@ -255,6 +255,133 @@ vlan_basic6_cleanup()
 	cleanup
 }
 
+vlan_auto_follow_mtu_body_common()
+{
+	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
+	local outfile=./out
+	local af=inet
+	local prefix=24
+	local local0=$IP_LOCAL0
+	local remote0=$IP_REMOTE0
+	local ping_cmd="rump.ping -D -n -w 1 -c 1"
+	local mtu=1500
+	local vlan_mtu=`expr $mtu - 4`
+	# ipv4 header=20bytes, icmp header=8bytes
+	local padding=`expr $vlan_mtu - 20 - 8`
+	local over_padding=`expr $vlan_mtu - 20 - 8 + 1`
+	local nonfrag_msg="$local0 > $remote0: ICMP echo request"
+	# unused for ipv4
+	local frag_msg=""
+
+	if [ x"$1" = x"inet6" ]; then
+		af="inet6"
+		prefix=64
+		local0=$IP6_LOCAL0
+		remote0=$IP6_REMOTE0
+		# ipv6 header=40bytes, icmpv6 header=8bytes
+		padding=`expr $vlan_mtu - 40 - 8`
+		over_padding=`expr $vlan_mtu - 40 - 8 + 1`
+		ping_cmd="rump.ping6 -mm -n -c 1 -i 1"
+		nonfrag_msg="$local0 > $remote0: ICMP6, echo request"
+		frag_msg="$local0 > $remote0: frag .* ICMP6, echo request"
+	fi
+
+	rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+	rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
+
+	export RUMP_SERVER=$SOCK_LOCAL
+	$atf_ifconfig shmif0 up
+	export RUMP_SERVER=$SOCK_REMOTE
+	$atf_ifconfig shmif0 up
+
+	export RUMP_SERVER=$SOCK_LOCAL
+	$atf_ifconfig vlan0 create
+
+	# since upper bound of shmif's mtu is 1500,
+	# so we lower vlan's mtu instead of raising shmif's.
+	# to do this, we change the interface's parameter
+	# such as ND_IFINFO(ifp)->maxmtu that is changed by SIOCSIFMTU.
+
+	# $atf_config shmif0 mtu 1600
+	$atf_ifconfig vlan0 vlan 10 vlanif shmif0
+	$atf_ifconfig vlan0 mtu 1400
+	$atf_ifconfig vlan0 -vlanif shmif0
+
+	$atf_ifconfig vlan0 vlan 10 vlanif shmif0
+	$atf_ifconfig vlan0 $af $local0/$prefix
+	$atf_ifconfig vlan0 up
+	$atf_ifconfig -w 10
+
+	export RUMP_SERVER=$SOCK_REMOTE
+	$atf_ifconfig vlan0 create
+	$atf_ifconfig vlan0 vlan 10 vlanif shmif0
+	$atf_ifconfig vlan0 $af $remote0/$prefix
+	$atf_ifconfig vlan0 up
+	$atf_ifconfig -w 10
+
+	extract_new_packets $BUS > $outfile
+	export RUMP_SERVER=$SOCK_LOCAL
+
+	atf_check -s exit:0 -o ignore $ping_cmd -s $padding $remote0
+	extract_new_packets $BUS > $outfile
+	atf_check -s exit:0 -o match:"$nonfrag_msg" cat $outfile
+
+	if [ x"$1" = x"inet6" ]; then
+		atf_check -s exit:0 -o ignore $ping_cmd -s $over_padding $remote0
+		extract_new_packets $BUS > $outfile
+		atf_check -s exit:0 -o match:"$frag_msg" cat $outfile
+	else
+		atf_check -s not-exit:0 -o ignore -e match:"Message too long" \
+$ping_cmd -s $over_padding $remote0
+	fi
+}
+
+atf_test_case vlan_auto_follow_mtu cleanup
+vlan_auto_follow_mtu_head()
+{
+
+	atf_set "descr" "tests of setting vlan mtu using IPv4"
+	atf_set "require.progs" "rump_server"
+}
+
+vlan_auto_follow_mtu_body()
+{
+	rump_server_start $SOCK_LOCAL vlan
+	rump_server_start $SOCK_REMOTE vlan
+
+	vlan_auto_follow_mtu_body_common inet
+}
+
+vlan_auto_follow_mtu_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
+atf_test_case vlan_auto_follow_mtu6 cleanup
+vlan_auto_follow_mtu6_head()
+{
+
+	atf_set "descr" "tests of setting vlan mtu using IPv6"
+	atf_set "require.progs" "rump_server"
+}
+
+vlan_auto_follow_mtu6_body()
+{
+	rump_server_start $SOCK_LOCAL vlan netinet6
+	rump_server_start $SOCK_REMOTE vlan netinet6
+
+	vlan_auto_follow_mtu_body_common inet6
+}
+
+vlan_auto_follow_mtu6_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 vlanid_config_and_ping()
 {
 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
@@ -738,6 +865,7 @@ atf_init_test_cases()
 
 	atf_add_test_case vlan_create_destroy
 	atf_add_test_case vlan_basic
+	atf_add_test_case vlan_auto_follow_mtu
 	atf_add_test_case vlan_vlanid
 	atf_add_test_case vlan_configs
 	atf_add_test_case vlan_bridge
@@ -745,6 +873,7 @@ atf_init_test_cases()