Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178324117
D61038.1796494885.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
D61038.1796494885.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
@@ -95,6 +95,7 @@
ip6_tryforward(struct mbuf *m)
{
struct sockaddr_in6 dst;
+ struct in6_addr odst;
struct nhop_object *nh;
struct m_tag *fwd_tag;
struct ip6_hdr *ip6;
@@ -218,6 +219,7 @@
/*
* Outgoing packet firewall processing.
*/
+ odst = ip6->ip6_dst;
if (pfil_mbuf_fwd(V_inet6_pfil_head, &m, nh->nh_ifp,
NULL) != PFIL_PASS)
goto dropout;
@@ -258,7 +260,7 @@
fwd_tag = NULL;
if (fwd_tag != NULL ||
- !IN6_ARE_ADDR_EQUAL(&dst.sin6_addr, &ip6->ip6_dst)) {
+ !IN6_ARE_ADDR_EQUAL(&odst, &ip6->ip6_dst)) {
if (fwd_tag != NULL) {
bcopy((fwd_tag + 1), &dst, sizeof(dst));
m->m_flags &= ~M_IP6_NEXTHOP;
diff --git a/tests/sys/netpfil/ipfw/fwd.sh b/tests/sys/netpfil/ipfw/fwd.sh
--- a/tests/sys/netpfil/ipfw/fwd.sh
+++ b/tests/sys/netpfil/ipfw/fwd.sh
@@ -64,7 +64,63 @@
firewall_cleanup $1
}
+atf_test_case "nexthop_v6" "cleanup"
+nexthop_v6_head()
+{
+ atf_set descr 'Test that an inbound IPv6 fwd rule chooses the next hop'
+ atf_set require.user root
+}
+
+nexthop_v6_body()
+{
+ firewall_init "ipfw"
+
+ epair_c=$(vnet_mkepair)
+ epair_1=$(vnet_mkepair)
+ epair_2=$(vnet_mkepair)
+
+ vnet_mkjail rtr ${epair_c}b ${epair_1}a ${epair_2}a
+ vnet_mkjail srv1 ${epair_1}b
+ vnet_mkjail srv2 ${epair_2}b
+
+ atf_check ifconfig ${epair_c}a inet6 2001:db8:1::2/64 up no_dad \
+ -ifdisabled
+ atf_check -o ignore route add -6 2001:db8:4::/64 2001:db8:1::1
+
+ atf_check ifconfig -j rtr ${epair_c}b inet6 2001:db8:1::1/64 up no_dad
+ atf_check ifconfig -j rtr ${epair_1}a inet6 2001:db8:2::1/64 up no_dad
+ atf_check ifconfig -j rtr ${epair_2}a inet6 2001:db8:3::1/64 up no_dad
+ atf_check -o ignore sysctl -j rtr net.inet6.ip6.forwarding=1
+ atf_check -o ignore route -j rtr add -6 2001:db8:4::/64 2001:db8:2::2
+
+ # 2001:db8:4::1 lives on srv2, but the route points to srv1.
+ atf_check ifconfig -j srv1 ${epair_1}b inet6 2001:db8:2::2/64 up no_dad
+ atf_check ifconfig -j srv2 ${epair_2}b inet6 2001:db8:3::2/64 up no_dad
+ atf_check ifconfig -j srv2 lo0 inet6 2001:db8:4::1/128 up
+ atf_check -o ignore route -j srv2 add -6 default 2001:db8:3::1
+
+ firewall_config rtr ipfw ipfw \
+ "ipfw add 20 allow all from any to any"
+ atf_check -s exit:2 -o ignore ping -6 -c 1 -W 1 2001:db8:4::1
+
+ firewall_config rtr ipfw ipfw \
+ "ipfw add 10 fwd 2001:db8:3::2 ip6 from any to 2001:db8:4::1 in via ${epair_c}b" \
+ "ipfw add 20 allow all from any to any"
+
+ for redirect in 0 1; do
+ atf_check -o ignore \
+ sysctl -j rtr net.inet6.ip6.redirect=${redirect}
+ atf_check -o ignore ping -6 -c 1 -W 1 2001:db8:4::1
+ done
+}
+
+nexthop_v6_cleanup()
+{
+ firewall_cleanup $1
+}
+
atf_init_test_cases()
{
atf_add_test_case "local"
+ atf_add_test_case "nexthop_v6"
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 5, 6:21 PM (15 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42232156
Default Alt Text
D61038.1796494885.diff (2 KB)
Attached To
Mode
D61038: netinet6: Keep a pfil-chosen next hop in ip6_tryforward()
Attached
Detach File
Event Timeline