Page MenuHomeFreeBSD

D24021.id69510.diff
No OneTemporary

D24021.id69510.diff

Index: sbin/ipfw/ipfw.8
===================================================================
--- sbin/ipfw/ipfw.8
+++ sbin/ipfw/ipfw.8
@@ -1343,7 +1343,7 @@
with multiple addresses) is provided for convenience only and
its use is discouraged.
.It Ar addr : Oo Cm not Oc Bro
-.Cm any | me | me6 |
+.Cm any | me | me4 | me6 |
.Cm table Ns Pq Ar name Ns Op , Ns Ar value
.Ar | addr-list | addr-set
.Brc
@@ -1351,7 +1351,10 @@
.It Cm any
Matches any IP address.
.It Cm me
-Matches any IP address configured on an interface in the system.
+Matches any IPv4 address configured on an interface in the system.
+.It Cm me4
+Alias for
+.Cm me .
.It Cm me6
Matches any IPv6 address configured on an interface in the system.
The address list is evaluated at the time the packet is
Index: sbin/ipfw/ipfw2.c
===================================================================
--- sbin/ipfw/ipfw2.c
+++ sbin/ipfw/ipfw2.c
@@ -3719,7 +3719,7 @@
ret = add_srcip6(cmd, av, cblen, tstate);
/* XXX: should check for IPv4, not !IPv6 */
if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
- inet_pton(AF_INET6, host, &a) != 1))
+ strcmp(av, "me4") == 0 || inet_pton(AF_INET6, host, &a) != 1))
ret = add_srcip(cmd, av, cblen, tstate);
if (ret == NULL && strcmp(av, "any") != 0)
ret = cmd;
@@ -3750,7 +3750,7 @@
ret = add_dstip6(cmd, av, cblen, tstate);
/* XXX: should check for IPv4, not !IPv6 */
if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
- inet_pton(AF_INET6, host, &a) != 1))
+ strcmp(av, "me4") == 0 || inet_pton(AF_INET6, host, &a) != 1))
ret = add_dstip(cmd, av, cblen, tstate);
if (ret == NULL && strcmp(av, "any") != 0)
ret = cmd;
Index: tests/sys/netpfil/common/Makefile
===================================================================
--- tests/sys/netpfil/common/Makefile
+++ tests/sys/netpfil/common/Makefile
@@ -10,7 +10,8 @@
nat \
tos \
fragments \
- forward
+ forward \
+ ipfw_me4
${PACKAGE}FILES+= \
utils.subr \
Index: tests/sys/netpfil/common/ipfw_me4.sh
===================================================================
--- tests/sys/netpfil/common/ipfw_me4.sh
+++ tests/sys/netpfil/common/ipfw_me4.sh
@@ -0,0 +1,73 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2019 Neel Chauhan
+#
+# 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 AUTHOR 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 AUTHOR 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.
+#
+# $FreeBSD$
+#
+
+. $(atf_get_srcdir)/utils.subr
+. $(atf_get_srcdir)/runner.subr
+
+me4_head()
+{
+ atf_set descr 'IPFW me4 identifier test'
+ atf_set require.user root
+}
+
+me4_body()
+{
+ firewall=$1
+ firewall_init $firewall
+
+ epair=$(vnet_mkepair)
+ ifconfig ${epair}a 192.0.2.1/24 up
+ vnet_mkjail iron ${epair}b
+ jexec iron ifconfig ${epair}b 192.0.2.2/24 up
+
+ firewall_config "iron" ${firewall} \
+ "ipfw" \
+ "ipfw -q add 100 allow all from any to any"
+ atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.2
+
+ firewall_config "iron" ${firewall} \
+ "ipfw" \
+ "ipfw -q add 100 deny all from any to me4"
+ atf_check -s exit:2 -o ignore ping -c 1 -t 1 192.0.2.2
+
+ firewall_config "iron" ${firewall} \
+ "ipfw" \
+ "ipfw -q add 100 deny all from me4 to any"
+ atf_check -s exit:2 -o ignore ping -c 1 -t 1 192.0.2.2
+}
+
+me4_cleanup()
+{
+ firewall=$1
+ firewall_cleanup $firewall
+}
+
+setup_tests \
+ me4 \
+ ipfw

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 31, 11:23 PM (2 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28215132
Default Alt Text
D24021.id69510.diff (4 KB)

Event Timeline