From patchwork Mon Apr 4 06:47:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 1612894 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.a=rsa-sha256 header.s=selector1 header.b=e//aMjBY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KX1YZ4TXyz9sGJ for ; Mon, 4 Apr 2022 16:47:46 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2120E82BE5; Mon, 4 Apr 2022 06:47:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u-8tYKq79Tf4; Mon, 4 Apr 2022 06:47:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 201DD82AA9; Mon, 4 Apr 2022 06:47:42 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 00250C001D; Mon, 4 Apr 2022 06:47:41 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3A5D5C0012 for ; Mon, 4 Apr 2022 06:47:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 28A63404C7 for ; Mon, 4 Apr 2022 06:47:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=ericsson.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2yjb21jNrMcp for ; Mon, 4 Apr 2022 06:47:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03on0615.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe08::615]) by smtp2.osuosl.org (Postfix) with ESMTPS id D3E4D40102 for ; Mon, 4 Apr 2022 06:47:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M2B8R3yISZo2B+V5skq63yI3VUsxyS3bcEUjdSu2Mp4EKLCCgtGFZCRlNEtUTddh8cAtjeJwW/89NGZia8ruqYpZlqStl22EbIPNnRw8Vlu+w5kfBC7nSRe4Cg2oH4TkkYzrWa3cLc16IMQUJK37JruwSAGf/StB2ZrV/EZG8QaNGhBkpvEA5OYNWs5LCJYX9rWpnIBeqtPUgpEP5UGANiEQ1jtUdkUfqEKuOoX0drj577gccgDmbM69qFGG1fp5E/nLybJPtphjHDL6xc/r7IkKT86trbluSKhQrfI8ARHTzINYAioTn0q39RQulkLyZV78f+f08ecsKvS3Y2bcLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ejhRU9xGdjE3WxDPHc28Dnsy/Aflns0YonigCaL/eSw=; b=B2RIGdcvKqz74xxjtlQssVykQC2SkUBCdOBcqBGYVIdTCWKSkLHo7I/9w+9wpZi6ItYiRdyX1HG1B7aDlI5N+oZ3s/daLNxs4vsZSvVvJtmcUGicNGSgkHyGy8SiCQhx7YNkdyzeZ2eU52K2nkRP4I/7Chbw/5Q8uamPEOel47GgeCHt94XHbU5ErGhS21GBkCK7nLw9xpzB/GwA0ZkuqkXEIIVrPYoBHc0udQBo76bhOICvnyp/wSfv4u3ghR4AdYykMDJ2eS/JX3QGN1QQTqEGePT06qjtT/eo+sJ4IQt27rq5id3iBBRP8AYsucG5+Lf9x5rhBloPyHMLkag+Tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ericsson.com; dmarc=pass action=none header.from=ericsson.com; dkim=pass header.d=ericsson.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ejhRU9xGdjE3WxDPHc28Dnsy/Aflns0YonigCaL/eSw=; b=e//aMjBYJksWXvexSHDUEb1lotu61x5vzcLc9NcKP/awJrR9iUqRgjEdKPFwEeFqHfIwEFbdJbAQpWjJhrtjEVwT5ZxKH8tfLheuyNV7HI0ywtJpC4UUQ+9+hwybnoLnL7tGkx6V9CfPcrnq+zeOjxJ8Vqj+1A/5wpW7kAo4jN4= Received: from PR3PR07MB8292.eurprd07.prod.outlook.com (2603:10a6:102:17f::11) by HE1PR07MB4348.eurprd07.prod.outlook.com (2603:10a6:7:a0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Mon, 4 Apr 2022 06:47:33 +0000 Received: from PR3PR07MB8292.eurprd07.prod.outlook.com ([fe80::fc57:b630:5f7e:a56b]) by PR3PR07MB8292.eurprd07.prod.outlook.com ([fe80::fc57:b630:5f7e:a56b%3]) with mapi id 15.20.5144.016; Mon, 4 Apr 2022 06:47:33 +0000 To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v2] ofproto-xlate: Fix crash when forwarding packet between legacy_l3 tunnels Thread-Index: AQHYR6neZm7CYBpJ4keF6bJo/Sf/56zfT3cg Date: Mon, 4 Apr 2022 06:47:32 +0000 Message-ID: References: <20220403222617.31688-1-jan.scheurich@web.de> In-Reply-To: <20220403222617.31688-1-jan.scheurich@web.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ericsson.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 978c2981-9c5e-48fd-97f5-08da1606ff0c x-ms-traffictypediagnostic: HE1PR07MB4348:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WueU2ph/v9bIUndrhZqWnYFyTI1pC4l20RMsXaGJsaUBtg6XFWdVTyuyECay92Tlzbxu/qxEmF09ugS06d5HGtKj3V8mp0K2HwudNs/nMuaPv7uFpOqbLmB9R8cRseNLkS1gpegEuu+jxjCd72QGBrCqMpQ/LoXN5JbtEAzpD/AWWPpm0jGUpd3TtYe//ctHCXDFbyhAJxJvwVnv8S9LvBHF8t1R/+WNJUB/CHW9Isfw4z/UUT09yDIfdzG9Dbihe5BIOBqDGgJkH/K2waibnnjL9f9gAtgYG4bXvx1hunYGDGauHU8FjoauA9JCPzboavIlsxcoEg5DDUosvZ1e2piJizKn8W6PFJXitFXgnuz3h/Z7uWNrbVbx7EO5T8b7Y43TEO4hvvEqzgpEf8Vm/ogXVeInvW0xHO+FlG7XQfsFS1GTnCz4GyLwJAD8uSzk+8MLAJAMAvjZsi6UERooryhILwR1mzZ/APZckWCYgYO+yWMVEKMf105mviFfAsTIzmjJt4B10Ut0zgGfv+Sfb6A+i8ISey21TzXdwAUXdJvMs+eEykQghewuP3aeSIBF1NX3aOFxuO0iJLY/AKBEsKWXv6J7YxxIsmOFH4EW31PXXNA08dJTbnfFimv7dFr7m1ylZjlvS/6n9h1GKUXjs4u8Hzuo7jL7EdFS8LlKhUK0PRPWHRm1CCpBtYpRBPdTanaVzuyskXWsCJDK1x9colQLiiuD/eFYHE7CQir0y5pi8kGgkgKb1wCRUezAmMZP x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PR3PR07MB8292.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(38070700005)(86362001)(82960400001)(66556008)(38100700002)(122000001)(76116006)(66446008)(64756008)(66946007)(8676002)(66476007)(316002)(55016003)(6916009)(71200400001)(8936002)(52536014)(5660300002)(186003)(83380400001)(2906002)(44832011)(508600001)(9686003)(7696005)(6506007)(33656002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 2 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?BEQYHAnsWaetDzyQI3A1hUW2AEWG?= =?utf-8?q?Dg7OV9dPXexF9iNF3sS+NH+qZEwv+cQCVV2C87FwUK+ecVWr2arVEyMxq7riJbSGW?= =?utf-8?q?+LbqH1en3zGqHYhdIahHCgq4D88uAzZu9P5/ipokNxotb0ZcU/qsXE8DCu0z9oaHT?= =?utf-8?q?ofGYLIa6sXPtMKw4ak9CoWuISQeNfLo2cT9txFUw/EIV1BMohpW32qWkWx1vabGEx?= =?utf-8?q?GRoVjUzA0U/j3yP5vqCPtq0E+Ok66ARwtcjqAqB4KbPKOIxy4EbDb6DigTn71DGLD?= =?utf-8?q?lcNJD/NPMJoZ/t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49KnL8xzUeRY/+5ToURDBt3xffatE96/UkRs1OzWo0gmPDXn3pWr0z?= =?utf-8?q?PgKKwtNtZTtl2VX2zQx2oMl2dUdLHUeFdt7fKxP7quAk8jYvSjKpfW94vedxLvQYG?= =?utf-8?q?GFAw+XvtT5K0qL8exhMFHj5ULEnoI7uzGAwDuWpPJwCUGEVyCPboTgDCz379i4YdL?= =?utf-8?q?ywS738cjOwkAzvU1yx7dp6vrW7TcctYECb3jDD582EHFxDHTaARyJEE66x8ff6bQ+?= =?utf-8?q?eNP0kF/yTheo5r0H/9z3ZdYYTJmromA6qQZ0A9meQFSR97oJ568AgDk1+ce3SE1jY?= =?utf-8?q?xg6UPSgRXXPix8dI/pf+e1lHZp/tSuCiggbhONB2cBGYBN7+Hf++iQ5qbYTI0VdMv?= =?utf-8?q?uCHXAV9B7a0cGdSeWSAlT2QXSEz7dlpjGXnQMllkII6G9UF0Lay58MLAroa3xMpC/?= =?utf-8?q?s1uCeUbyYclbMUSjB3BWjTS/AWXQKHSXWevNzmBD8sj6/GBvKNbDSGjoC+dWKcmt6?= =?utf-8?q?q0eC27PKMC3aiN1QICqNXEFSrb/NvcfLlX9Of47Xhy9kvxG/sw/a54CIWlkqLS1y5?= =?utf-8?q?J7ka4N6dMfsocMjlU?= x-ms-exchange-antispam-messagedata-1: p1kA+s1nczS8ASH6yXFwdfxjl3/ocqoxFTc= MIME-Version: 1.0 X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PR3PR07MB8292.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 978c2981-9c5e-48fd-97f5-08da1606ff0c X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2022 06:47:32.6602 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: q5OXoey6Fvq+g2iocDoki2b/NLL1nuGy5Iv5hCwLwiUjEsMrh1YqJb8nX1/VBkBls5Bu4/bKdNdZ1qt1DJs0KIcE7BYh2en2HjC0x8Ro8Ms= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR07MB4348 Subject: [ovs-dev] [PATCH v2] ofproto-xlate: Fix crash when forwarding packet between legacy_l3 tunnels 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: , X-Patchwork-Original-From: Jan Scheurich via dev From: Jan Scheurich Reply-To: Jan Scheurich Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Jan Scheurich A packet received from a tunnel port with legacy_l3 packet-type (e.g. lisp, L3 gre, gtpu) is conceptually wrapped in a dummy Ethernet header for processing in an OF pipeline that is not packet-type-aware. Before transmission of the packet to another legacy_l3 tunnel port, the dummy Ethernet header is stripped again. In ofproto-xlate, wrapping in the dummy Ethernet header is done by simply changing the packet_type to PT_ETH. The generation of the push_eth datapath action is deferred until the packet's flow changes need to be committed, for example at output to a normal port. The deferred Ethernet encapsulation is marked in the pending_encap flag. This patch fixes a bug in the translation of the output action to a legacy_l3 tunnel port, where the packet_type of the flow is reverted from PT_ETH to PT_IPV4 or PT_IPV6 (depending on the dl_type) to remove its Ethernet header without clearing the pending_encap flag if it was set. At the subsequent commit of the flow changes, the unexpected combination of pending_encap == true with an PT_IPV4 or PT_IPV6 packet_type hit the OVS_NOT_REACHED() abortion clause. The pending_encap is now cleared in this situation. Reported-By: Dincer Beken Signed-off-By: Jan Scheurich Signed-off-By: Dincer Beken v1->v2: A specific test has been added to tunnel-push-pop.at to verify the correct behavior. --- ofproto/ofproto-dpif-xlate.c | 4 ++++ tests/tunnel-push-pop.at | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) -- 2.25.1 diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index cc9c1c628..1843a5d66 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4195,6 +4195,10 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, if (xport->pt_mode == NETDEV_PT_LEGACY_L3) { flow->packet_type = PACKET_TYPE_BE(OFPHTN_ETHERTYPE, ntohs(flow->dl_type)); + if (ctx->pending_encap) { + /* The Ethernet header was not actually added yet. */ + ctx->pending_encap = false; + } } } diff --git a/tests/tunnel-push-pop.at b/tests/tunnel-push-pop.at index 57589758f..70462d905 100644 --- a/tests/tunnel-push-pop.at +++ b/tests/tunnel-push-pop.at @@ -546,6 +546,28 @@ AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port [[37]]' | sort], [0], [dnl port 7: rx pkts=5, bytes=434, drop=?, errs=?, frame=?, over=?, crc=? ]) +dnl Send out packets received from L3GRE tunnel back to L3GRE tunnel +AT_CHECK([ovs-ofctl del-flows int-br]) AT_CHECK([ovs-ofctl add-flow +int-br "in_port=7,actions=set_field:3->in_port,7"]) +AT_CHECK([ovs-vsctl -- set Interface br0 options:pcap=br0.pcap]) + +AT_CHECK([ovs-appctl netdev-dummy/receive p0 +'aa55aa550000001b213cab6408004500007079464000402fba630101025c0101025820 +000800000001c845000054ba200000400184861e0000011e00000200004227e75400030 +af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f20212223 +2425262728292a2b2c2d2e2f3031323334353637']) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 +'aa55aa550000001b213cab6408004500007079464000402fba630101025c0101025820 +000800000001c845000054ba200000400184861e0000011e00000200004227e75400030 +af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f20212223 +2425262728292a2b2c2d2e2f3031323334353637']) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 +'aa55aa550000001b213cab6408004500007079464000402fba630101025c0101025820 +000800000001c845000054ba200000400184861e0000011e00000200004227e75400030 +af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f20212223 +2425262728292a2b2c2d2e2f3031323334353637']) + +ovs-appctl time/warp 1000 + +AT_CHECK([ovs-pcap p0.pcap > p0.pcap.txt 2>&1]) AT_CHECK([tail -6 +p0.pcap.txt], [0], [dnl +aa55aa550000001b213cab6408004500007079464000402fba630101025c01010258200 +00800000001c845000054ba200000400184861e0000011e00000200004227e75400030a +f3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232 +425262728292a2b2c2d2e2f3031323334353637 +001b213cab64aa55aa55000008004500007000004000402f33aa010102580101025c200 +00800000001c845000054ba200000400184861e0000011e00000200004227e75400030a +f3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232 +425262728292a2b2c2d2e2f3031323334353637 +aa55aa550000001b213cab6408004500007079464000402fba630101025c01010258200 +00800000001c845000054ba200000400184861e0000011e00000200004227e75400030a +f3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232 +425262728292a2b2c2d2e2f3031323334353637 +001b213cab64aa55aa55000008004500007000004000402f33aa010102580101025c200 +00800000001c845000054ba200000400184861e0000011e00000200004227e75400030a +f3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232 +425262728292a2b2c2d2e2f3031323334353637 +aa55aa550000001b213cab6408004500007079464000402fba630101025c01010258200 +00800000001c845000054ba200000400184861e0000011e00000200004227e75400030a +f3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232 +425262728292a2b2c2d2e2f3031323334353637 +001b213cab64aa55aa55000008004500007000004000402f33aa010102580101025c200 +00800000001c845000054ba200000400184861e0000011e00000200004227e75400030a +f3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232 +425262728292a2b2c2d2e2f3031323334353637 +]) + + dnl Check decapsulation of Geneve packet with options AT_CAPTURE_FILE([ofctl_monitor.log]) AT_CHECK([ovs-ofctl monitor int-br 65534 --detach --no-chdir --pidfile 2> ofctl_monitor.log])