Page MenuHomeFreeBSD

D62283.1796237414.diff
No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None

D62283.1796237414.diff

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
@@ -242,15 +242,8 @@
in6_ifstat_inc(rcvif, ifs6_in_noroute);
goto dropin;
}
- if (!PFIL_HOOKED_OUT(V_inet6_pfil_head)) {
- if (m->m_pkthdr.len > nh->nh_mtu) {
- in6_ifstat_inc(nh->nh_ifp, ifs6_in_toobig);
- icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, nh->nh_mtu);
- m = NULL;
- goto dropout;
- }
+ if (!PFIL_HOOKED_OUT(V_inet6_pfil_head))
goto passout;
- }
/*
* Outgoing packet firewall processing.
@@ -269,17 +262,6 @@
goto dropout;
}
- /*
- * We used slow path processing for packets with scoped addresses.
- * So, scope checks aren't needed here.
- */
- if (m->m_pkthdr.len > nh->nh_mtu) {
- in6_ifstat_inc(nh->nh_ifp, ifs6_in_toobig);
- icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, nh->nh_mtu);
- m = NULL;
- goto dropout;
- }
-
/*
* If packet filter sets the M_FASTFWD_OURS flag, this means
* that new destination or next hop is our local address.
@@ -327,6 +309,13 @@
}
}
passout:
+ /* The route the packet leaves by: an outbound hook may have changed it. */
+ if (m->m_pkthdr.len > nh->nh_mtu) {
+ in6_ifstat_inc(nh->nh_ifp, ifs6_in_toobig);
+ icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, nh->nh_mtu);
+ m = NULL;
+ goto dropout;
+ }
/*
* If TCP/UDP header still needs a valid checksum and interface will not
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
@@ -156,9 +156,84 @@
firewall_cleanup $1
}
+atf_test_case "nexthop_mtu_v6" "cleanup"
+nexthop_mtu_v6_head()
+{
+ atf_set descr 'Test that an outbound IPv6 fwd rule uses the MTU of its next hop'
+ atf_set require.user root
+}
+
+nexthop_mtu_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 -o ignore route add -6 2001:db8:5::/64 2001:db8:1::1
+
+ # The link to srv1 has an MTU of 1500, the link to srv2 1280.
+ 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 mtu 1280
+ 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
+ atf_check -o ignore route -j rtr add -6 2001:db8:5::/64 2001:db8:3::2
+
+ # 2001:db8:4::1 lives on srv2 and 2001:db8:5::1 on srv1, each behind
+ # the route to the other.
+ atf_check ifconfig -j srv1 ${epair_1}b inet6 2001:db8:2::2/64 up no_dad
+ atf_check ifconfig -j srv1 lo0 inet6 2001:db8:5::1/128 up
+ atf_check -o ignore route -j srv1 add -6 default 2001:db8:2::1
+ 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 10 fwd 2001:db8:3::2 ip6 from any to 2001:db8:4::1 out via ${epair_1}a" \
+ "ipfw add 20 fwd 2001:db8:2::2 ip6 from any to 2001:db8:5::1 out via ${epair_2}a" \
+ "ipfw add 30 allow all from any to any"
+
+ n=0
+ for redirect in 0 1; do
+ atf_check -o ignore \
+ sysctl -j rtr net.inet6.ip6.redirect=${redirect}
+ # Forget the path MTU the last round learned.
+ atf_check -o ignore sysctl net.inet.tcp.hostcache.purgenow=1
+
+ # 1348 bytes do not fit the next hop's link. ping -u sends them
+ # whole instead of in fragments of the minimum IPv6 MTU.
+ n=$((n + 1))
+ atf_check -s exit:2 -o ignore -e ignore \
+ ping -6 -u -c 1 -W 1 -s 1300 2001:db8:4::1
+ atf_check -o match:"[[:space:]]${n} packet too big" \
+ netstat -j rtr -s -p icmp6
+
+ # They fit the next hop's link, though not the route's.
+ atf_check -o ignore ping -6 -u -c 1 -W 1 -s 1300 2001:db8:5::1
+ atf_check -o match:"[[:space:]]${n} packet too big" \
+ netstat -j rtr -s -p icmp6
+ done
+}
+
+nexthop_mtu_v6_cleanup()
+{
+ firewall_cleanup $1
+}
+
atf_init_test_cases()
{
atf_add_test_case "local"
atf_add_test_case "local_out_v6"
atf_add_test_case "nexthop_v6"
+ atf_add_test_case "nexthop_mtu_v6"
}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 2, 6:50 PM (15 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42148531
Default Alt Text
D62283.1796237414.diff (4 KB)

Event Timeline