From patchwork Fri Apr 7 06:30:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faicker Mo X-Patchwork-Id: 1766421 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pt7mh346Lz1yY8 for ; Fri, 7 Apr 2023 16:31:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 63EE841FD1; Fri, 7 Apr 2023 06:31:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 63EE841FD1 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ExIZVGxIF3-X; Fri, 7 Apr 2023 06:31:09 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 0F25041FB7; Fri, 7 Apr 2023 06:31:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 0F25041FB7 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D5258C0036; Fri, 7 Apr 2023 06:31:07 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id A2746C002A for ; Fri, 7 Apr 2023 06:31:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7767C615F5 for ; Fri, 7 Apr 2023 06:31:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7767C615F5 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CUr3pGm0pbjT for ; Fri, 7 Apr 2023 06:31:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 72DBD60E3B Received: from mail-m312.qiye.163.com (mail-m312.qiye.163.com [103.74.31.2]) by smtp3.osuosl.org (Postfix) with ESMTPS id 72DBD60E3B for ; Fri, 7 Apr 2023 06:31:03 +0000 (UTC) Received: from ucloud.cn (unknown [127.0.0.1]) by mail-m312.qiye.163.com (Hmail) with ESMTP id 90E7D80296; Fri, 7 Apr 2023 14:30:22 +0800 (CST) Message-ID: To: dev X-Priority: 3 X-Mailer: HMail Webmail Server V2.0 Copyright (c) 2015-163.com X-Originating-IP: 106.75.220.2 MIME-Version: 1.0 Received: from mocan@ucloud.cn( [106.75.220.2) ] by ajax-webmail ( [127.0.0.1] ) ; Fri, 7 Apr 2023 14:30:22 +0800 (GMT+08:00) From: Faicker Mo Date: Fri, 7 Apr 2023 14:30:22 +0800 (GMT+08:00) X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaTk4YVh0ZTk0fThhCHxodQlUZERMWGhIXJBQOD1 lXWRgSC1lBWUpLTVVMTlVJSUtVSVlXWRYaDxIVHRRZQVlPS0hVSkpLSEpMVUpLS1VLWQY+ X-HM-Sender-Digest: e1kMHhlZQQ8JDh5XWRIfHhUPWUFZRzo*MjojKjlLMgweAhQTIzBDODYV IhoUTlVKVUpNQ0tDT0JLSUhLSUhVMxYaEhdVHRoSGBAeCVUWFDsOGBcUDh9VGBVFWVdZEgtZQVlK S01VTE5VSUlLVUlZV1kIAVlBTE1ISzcG X-HM-Tid: 0a875a64a80900d2kurm18722baa785 X-HM-MType: 1 Cc: i.maximets@ovn.org Subject: [ovs-dev] =?utf-8?q?=5BPATCH_v3=5D_learning-switch=3A_Fix_coredump_?= =?utf-8?q?of_OpenFlow15_learning-switch?= X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The OpenFlow15 Packet-Out message contains the match instead of the in_port. The flow.tunnel.metadata.tab is not inited but used in the loop of tun_metadata_to_nx_match. The coredump gdb backtrace is: #0 memcpy_from_metadata (dst=dst@entry=0x7ffcfac2f060, src=src@entry=0x7ffcfac30880, loc=loc@entry=0x10) at lib/tun-metadata.c:467 #1 0x00000000004506e8 in metadata_loc_from_match_read (match=0x7ffcfac30598, is_masked=, mask=0x7ffcfac30838, idx=0, map=0x0) at lib/tun-metadata.c:865 #2 metadata_loc_from_match_read (is_masked=, mask=0x7ffcfac30838, idx=0, match=0x7ffcfac30598, map=0x0) at lib/tun-metadata.c:854 #3 tun_metadata_to_nx_match (b=b@entry=0x892260, oxm=oxm@entry=OFP15_VERSION, match=match@entry=0x7ffcfac30598) at lib/tun-metadata.c:888 #4 0x000000000047c1f8 in nx_put_raw (b=b@entry=0x892260, oxm=oxm@entry=OFP15_VERSION, match=match@entry=0x7ffcfac30598, cookie=, cookie@entry=0, cookie_mask=, cookie_mask@entry=0) at lib/nx-match.c:1186 #5 0x000000000047d693 in oxm_put_match (b=b@entry=0x892260, match=match@entry=0x7ffcfac30598, version=version@entry=OFP15_VERSION) at lib/nx-match.c:1343 #6 0x000000000043194e in ofputil_encode_packet_out (po=po@entry=0x7ffcfac30580, protocol=) at lib/ofp-packet.c:1226 #7 0x000000000040a4fe in process_packet_in (sw=sw@entry=0x891d70, oh=) at lib/learning-switch.c:619 #8 0x000000000040acdc in lswitch_process_packet (msg=0x892210, sw=0x891d70) at lib/learning-switch.c:374 #9 lswitch_run (sw=0x891d70) at lib/learning-switch.c:324 #10 0x0000000000406f26 in main (argc=, argv=) at utilities/ovs-testcontroller.c:180 Fix that by initing the flow metadata. Fixes: 35eb6326d5d0 ("ofp-util: Add flow metadata to ofputil_packet_out") Signed-off-by: Faicker Mo Reviewed-by: Simon Horman --- v2: - changed the init and add test case v3: - better init method and test case --- lib/learning-switch.c | 1 + tests/automake.mk | 3 ++- tests/learning-switch.at | 23 +++++++++++++++++++++++ tests/testsuite.at | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/learning-switch.at diff --git a/lib/learning-switch.c b/lib/learning-switch.c index 8102475ca..cdf42935c 100644 --- a/lib/learning-switch.c +++ b/lib/learning-switch.c @@ -569,6 +569,7 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh) } /* Prepare packet_out in case we need one. */ + match_init_catchall(&po.flow_metadata); po.buffer_id = buffer_id; if (buffer_id == UINT32_MAX) { po.packet = dp_packet_data(&pkt); diff --git a/tests/automake.mk b/tests/automake.mk index 86e496a5b..720c94449 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -110,7 +110,8 @@ TESTSUITE_AT = \ tests/mcast-snooping.at \ tests/packet-type-aware.at \ tests/nsh.at \ - tests/drop-stats.at + tests/drop-stats.at \ + tests/learning-switch.at EXTRA_DIST += $(FUZZ_REGRESSION_TESTS) FUZZ_REGRESSION_TESTS = \ diff --git a/tests/learning-switch.at b/tests/learning-switch.at new file mode 100644 index 000000000..ac2fc1b80 --- /dev/null +++ b/tests/learning-switch.at @@ -0,0 +1,23 @@ +AT_BANNER([learning switch]) + +### ----------------------------------------------------------------- +### learning switch OpenFlow15 test case +### ----------------------------------------------------------------- + +AT_SETUP([learning switch - OpenFlow15]) +dnl Start ovs-testcontroller +AT_CHECK([ovs-testcontroller --no-chdir --detach punix:controller --pidfile -v ptcp:], [0], [ignore]) +dnl Start ovs +OVS_VSWITCHD_START([dnl + set bridge br0 datapath_type=dummy \ + protocols=OpenFlow15 -- \ + add-port br0 p1 -- set Interface p1 type=dummy ofport_request=1 -- \ + set-controller br0 tcp:127.0.0.1:6653]) +AT_CHECK([ + ovs-appctl netdev-dummy/receive p1 1e2ce92a669e3a6dd2099cab0800450000548a53400040011addc0a80a0ac0a80a1e08006f200a4d0001fc509a58000000002715020000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637 +], [0], [ignore]) +AT_CHECK([kill `cat ovs-testcontroller.pid`]) + +OVS_WAIT_UNTIL([! test -e controller]) +OVS_VSWITCHD_STOP(["/cannot find route for controller/d"]) +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index cf4e3eadf..9d77a9f51 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -77,3 +77,4 @@ m4_include([tests/packet-type-aware.at]) m4_include([tests/nsh.at]) m4_include([tests/drop-stats.at]) m4_include([tests/pytest.at]) +m4_include([tests/learning-switch.at])