Skip to content

Commit ab30880

Browse files
faicker-zlapconole
authored andcommitted
ipf: Fix the over-sized reassembly.
Fix the coredump of ovs_assert, The backtrace is as follows, #8 0x0000561ee52084bb in ovs_assert_failure (where=<>, function=<>, condition=<>) at ../lib/util.c:89 #9 0x0000561ee50f8ab2 in dp_packet_set_size (b=<>, v=<>) at ../lib/dp-packet.h:687 #10 dp_packet_set_size (v=<>, b=0x7f7f88143e80) at ../lib/dp-packet.h:687 #11 dp_packet_put_uninit (size=395, b=0x7f7f88143e80) at ../lib/dp-packet.c:355 #12 dp_packet_put (b=0x7f7f88143e80, p=0x7f7f88143ce2, size=395) at ../lib/dp-packet.c:376 #13 0x0000561ee512c147 in ipf_reassemble_v4_frags (ipf_list=0x7f7f88110810) at ../lib/ipf.c:430 The mbuf data_len is a uint16_t field, which includes the ether header. So does IPv6. Fixes: 4ea9669 ("Userspace datapath: Add fragmentation handling.") Acked-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: Faicker Mo <faicker.mo@zenlayer.com> Signed-off-by: Aaron Conole <aconole@redhat.com>
1 parent 8e7c08f commit ab30880

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

lib/ipf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,12 @@ ipf_reassemble_v4_frags(struct ipf_list *ipf_list)
410410
dp_packet_set_size(pkt, dp_packet_size(pkt) - dp_packet_l2_pad_size(pkt));
411411
struct ip_header *l3 = dp_packet_l3(pkt);
412412
int len = ntohs(l3->ip_tot_len);
413+
int orig_len = dp_packet_size(pkt);
413414

414415
int rest_len = frag_list[ipf_list->last_inuse_idx].end_data_byte -
415416
frag_list[1].start_data_byte + 1;
416417

417-
if (len + rest_len > IPV4_PACKET_MAX_SIZE) {
418+
if (orig_len + rest_len > IPV4_PACKET_MAX_SIZE) {
418419
ipf_print_reass_packet(
419420
"Unsupported big reassembled v4 packet; v4 hdr:", l3);
420421
dp_packet_delete(pkt);
@@ -457,11 +458,12 @@ ipf_reassemble_v6_frags(struct ipf_list *ipf_list)
457458
dp_packet_set_size(pkt, dp_packet_size(pkt) - dp_packet_l2_pad_size(pkt));
458459
struct ovs_16aligned_ip6_hdr *l3 = dp_packet_l3(pkt);
459460
int pl = ntohs(l3->ip6_plen) - sizeof(struct ovs_16aligned_ip6_frag);
461+
int orig_len = dp_packet_size(pkt);
460462

461463
int rest_len = frag_list[ipf_list->last_inuse_idx].end_data_byte -
462464
frag_list[1].start_data_byte + 1;
463465

464-
if (pl + rest_len > IPV6_PACKET_MAX_DATA) {
466+
if (orig_len + rest_len > IPV6_PACKET_MAX_DATA) {
465467
ipf_print_reass_packet(
466468
"Unsupported big reassembled v6 packet; v6 hdr:", l3);
467469
dp_packet_delete(pkt);

tests/system-kmod-macros.at

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ m4_define([DPCTL_CHECK_FRAGMENTATION_FAIL],
193193

194194
])
195195

196+
# OVS_CHECK_FRAG_LARGE
197+
#
198+
# This check isn't valid for kernel
199+
m4_define([OVS_CHECK_FRAG_LARGE],
200+
[
201+
202+
])
203+
196204
# OVS_CHECK_MIN_KERNEL([minversion], [minsublevel])
197205
#
198206
# Skip test if kernel version falls below minversion.minsublevel

tests/system-traffic.at

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,7 +3854,11 @@ NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -W 2 10.1.1.2 | FORMAT_PING
38543854
dnl Check userspace conntrack fragmentation counters.
38553855
DPCTL_CHECK_FRAGMENTATION_PASS()
38563856

3857-
OVS_TRAFFIC_VSWITCHD_STOP
3857+
dnl Ipv4 max packet size fragmentation dropped.
3858+
NS_EXEC([at_ns0], [ping -s 65507 -q -c 1 -W 0.5 10.1.1.2])
3859+
OVS_CHECK_FRAG_LARGE()
3860+
3861+
OVS_TRAFFIC_VSWITCHD_STOP(["/Unsupported big reassembled v4 packet/d"])
38583862
AT_CLEANUP
38593863

38603864
AT_SETUP([conntrack - IPv4 fragmentation expiry])
@@ -4147,7 +4151,11 @@ NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -W 2 fc00::2 | FORMAT_PING
41474151
3 packets transmitted, 3 received, 0% packet loss, time 0ms
41484152
])
41494153

4150-
OVS_TRAFFIC_VSWITCHD_STOP
4154+
dnl Ipv6 max packet size fragmentation dropped.
4155+
NS_EXEC([at_ns0], [ping6 -s 65487 -q -c 1 -W 0.5 fc00::2])
4156+
OVS_CHECK_FRAG_LARGE()
4157+
4158+
OVS_TRAFFIC_VSWITCHD_STOP(["/Unsupported big reassembled v6 packet/d"])
41514159
AT_CLEANUP
41524160

41534161
AT_SETUP([conntrack - IPv6 fragmentation expiry])

tests/system-userspace-macros.at

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status -m | FORMAT_FRAG_LIST()], [], [dnl
295295
])
296296
])
297297

298+
# OVS_CHECK_FRAG_LARGE()
299+
#
300+
# The userspace needs to check that ipf larger fragments have occurred.
301+
m4_define([OVS_CHECK_FRAG_LARGE],
302+
[
303+
OVS_WAIT_UNTIL([grep -Eq 'Unsupported big reassembled (v4|v6) packet' ovs-vswitchd.log])
304+
])
305+
298306
# OVS_CHECK_MIN_KERNEL([minversion], [maxversion])
299307
#
300308
# The userspace skips all tests that check kernel version.

0 commit comments

Comments
 (0)