Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177684007
D61673.1795025553.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D61673.1795025553.diff
View Options
diff --git a/sys/netinet6/ip6_fastfwd.c b/sys/netinet6/ip6_fastfwd.c
--- a/sys/netinet6/ip6_fastfwd.c
+++ b/sys/netinet6/ip6_fastfwd.c
@@ -114,6 +114,8 @@
IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_dst) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) ||
+ IN6_IS_ADDR_LOOPBACK(&ip6->ip6_dst) ||
+ IN6_IS_ADDR_LOOPBACK(&ip6->ip6_src) ||
in6_localip_fib(&ip6->ip6_dst, M_GETFIB(m)))
return (m);
/*
diff --git a/tests/sys/netinet6/forward6.sh b/tests/sys/netinet6/forward6.sh
--- a/tests/sys/netinet6/forward6.sh
+++ b/tests/sys/netinet6/forward6.sh
@@ -519,6 +519,78 @@
vnet_cleanup
}
+atf_test_case "fwd_ip6_loopback_src" "cleanup"
+fwd_ip6_loopback_src_head() {
+
+ atf_set descr 'Test that packets from the loopback address are not forwarded'
+ atf_set require.user root
+ atf_set require.progs python3 scapy
+}
+
+fwd_ip6_loopback_src_body() {
+
+ ids=65522
+ id=`printf "%x" ${ids}`
+ if [ $$ -gt 65535 ]; then
+ xl=`printf "%x" $(($$ - 65535))`
+ yl="1"
+ else
+ xl=`printf "%x" $$`
+ yl=""
+ fi
+
+ vnet_init
+
+ ip6a="2001:db8:6666:0000:${yl}:${id}:1:${xl}"
+ ip6b="2001:db8:6666:0000:${yl}:${id}:2:${xl}"
+ plen=96
+
+ script_name="../common/sender.py"
+
+ epair=$(vnet_mkepair)
+ ifconfig ${epair}a up
+ ifconfig ${epair}a inet6 ${ip6a}/${plen}
+
+ jname="v6t-${id}-${yl}-${xl}"
+ vnet_mkjail ${jname} ${epair}b
+ jexec ${jname} ifconfig ${epair}b up
+ jexec ${jname} ifconfig ${epair}b inet6 ${ip6b}/${plen}
+
+ jail_mac=`jexec ${jname} ifconfig ${epair}b ether | awk '$1~/ether/{print$2}'`
+
+ our_mac=`ifconfig ${epair}a ether | awk '$1~/ether/{print$2}'`
+
+ # wait for DAD to complete
+ while [ `jexec ${jname} ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do
+ sleep 0.1
+ done
+ while [ `ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do
+ sleep 0.1
+ done
+
+ jexec ${jname} sysctl net.inet6.ip6.forwarding=1
+
+ # Neither ip6_tryforward() (0) nor ip6_forward() (1) lets it through.
+ for redirect in 0 1; do
+ jexec ${jname} sysctl net.inet6.ip6.redirect=${redirect}
+ atf_check -s not-exit:0 -o ignore -e ignore \
+ $(atf_get_srcdir)/${script_name} \
+ --test_name fwd_ip6_icmp \
+ --smac ${our_mac} --dmac ${jail_mac} \
+ --sip ::1 --dip ${ip6a} \
+ --iface ${epair}a
+ done
+
+ atf_check -o match:'[[:space:]]0 packets forwarded' \
+ -o match:'[[:space:]]2 packets that violated scope rules' \
+ jexec ${jname} netstat -sp ip6
+}
+
+fwd_ip6_loopback_src_cleanup() {
+
+ vnet_cleanup
+}
+
atf_init_test_cases()
{
@@ -529,6 +601,7 @@
atf_add_test_case "fwd_ip6_gu_icmp_gw_gu_slow_success"
atf_add_test_case "fwd_ip6_gu_icmp_gw_ll_slow_success"
atf_add_test_case "fwd_ip6_blackhole"
+ atf_add_test_case "fwd_ip6_loopback_src"
}
# end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 18, 6:12 PM (23 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41825928
Default Alt Text
D61673.1795025553.diff (2 KB)
Attached To
Mode
D61673: netinet6: Do not forward packets with a loopback address in ip6_tryforward()
Attached
Detach File
Event Timeline