From patchwork Thu Dec 21 14:22:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Balogh X-Patchwork-Id: 851949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.onmicrosoft.com header.i=@ericsson.onmicrosoft.com header.b="aeNYqrSK"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z2Yl22XvLz9s7v for ; Fri, 22 Dec 2017 01:22:54 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CEBD8BE1; Thu, 21 Dec 2017 14:22:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id BBB28BC2 for ; Thu, 21 Dec 2017 14:22:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id BCE56431 for ; Thu, 21 Dec 2017 14:22:48 +0000 (UTC) X-AuditID: c1b4fb30-11d5e9c000006bc7-79-5a3bc3b634ec Received: from ESESSHC001.ericsson.se (Unknown_Domain [153.88.183.21]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id BF.6B.27591.6B3CB3A5; Thu, 21 Dec 2017 15:22:47 +0100 (CET) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.21) with Microsoft SMTP Server (TLS) id 14.3.352.0; Thu, 21 Dec 2017 15:22:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.onmicrosoft.com; s=selector1-ericsson-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=s+C5bSNqpMfZKkZEbdtcEjFQvK+KkS7qNPNjWCkL8X0=; b=aeNYqrSKH8gBoHvmdI5QdUTYFChovibeRhqmBO9JJq1jyx3ygaUTmTIzCLZQylD/iszd+MDYbBaznXzDS6TSbyDKTPDExi9xrsr7ar2URzwPW1Z7OycSFYDm0+eHCiANAWTFNFdfq0ovDc5kiytuok+WipzZZgyqFwBr3gpZ0nM= Received: from HE1PR07MB3082.eurprd07.prod.outlook.com (10.170.244.156) by HE1PR0702MB3835.eurprd07.prod.outlook.com (52.133.7.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.10; Thu, 21 Dec 2017 14:22:44 +0000 Received: from HE1PR07MB3082.eurprd07.prod.outlook.com ([fe80::ac54:19dd:a3ad:964f]) by HE1PR07MB3082.eurprd07.prod.outlook.com ([fe80::ac54:19dd:a3ad:964f%13]) with mapi id 15.20.0345.013; Thu, 21 Dec 2017 14:22:43 +0000 From: =?iso-8859-1?q?Zolt=E1n_Balogh?= To: "'dev@openvswitch.org'" Thread-Topic: [PATCH] xlate: fix xport lookup for recirc Thread-Index: AdN6Zm0k+hbsEJpcQ7eDbLr6BCt5zgAAH5Uw Date: Thu, 21 Dec 2017 14:22:43 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [188.142.160.91] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR0702MB3835; 6:UILA2LV/h1/RFvE+N2vQ/c9kQbd1rgEwK6ydmitscR3NtAvopEelWaml3eBpijmD1FwNki62GDZehFvhH1Urqp7b2wOXyFEX6r9A6DHmzXk0PTDov+4LQsul9NfOcJ+Q9q/lJ7OMdNbK87FQaIfYVAIPsrAgy1kEeRiXF++blLIuxyFqqDFavL+zSv8UBumGSVtFjnns2NrGt2QST9kiUbemEPwjND+Xn9/r93fK0Z5v2hIMupFUSVHxe2pzKMt9xLZsNzRykQTMCKnk4bp+FDTzV/AtnBkgEJ+9vWg/W9hfcE3/30Ynn324dxME+Rw2DYvkHc9JOV+zvY/O3zBH7p8p4ut5uVxeD8y9ftXWiaY=; 5:p0cLmONZHLd+38Q1Ku8p1PR8o8SAO581VvVlc5ulzsp+h7Ur/iDchvSy2fPI93WoX9sIV8xxHf5VWeT/utsR71I4IdljIU+OriiEXDvh2ZrVTUsDeH0mqCUnVRASrtuvQXmlhbUBNvuLEWhl/YgcIWMrI5FkprOgL2mcLi75mc8=; 24:vFqbxvjZ2/z89ODW6Xy3wTRxH8x+fb5Eb3gaPNkSHbR6Pc5pjJiWOKmzLtSiwtOtitLUtmIjLzhXUP4koz6xpe8k2oHP4xgW9GP2KZhvLvc=; 7:ocYFdrt/qpELJczwrCExA9yVnvBxbfQZzdlLCa2J8AkVoAkoyEMbEGopOg71y7gRT4b+fP+4qqL5eQ9d7q75knOwMLP6sOJcz/FOlfM4ND0iXDFt0GgUaL2gl1gBamnjpSLZft/A7O7HuxQ0aj0TKP7T6orcA+i7qqMI57xuef/YLMKeIVkHmbnNdXhYk/nKwiphjhjA3L/V7PppOlKhS9N1OJyYOhb3yn94ZQqdTVYkPVUJ21VRylnX3rHEqmaL x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10009020)(376002)(346002)(39380400002)(366004)(39860400002)(396003)(199004)(189003)(99286004)(316002)(25786009)(33656002)(2900100001)(3660700001)(107886003)(4326008)(6436002)(102836004)(3280700002)(74316002)(76176011)(2940100002)(8936002)(97736004)(2906002)(106356001)(7696005)(3846002)(478600001)(5660300001)(68736007)(81156014)(9686003)(305945005)(14454004)(7736002)(81166006)(55016002)(8676002)(6116002)(53936002)(86362001)(105586002)(2950100002)(66066001)(6916009)(5250100002)(59450400001)(6506007)(491001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0702MB3835; H:HE1PR07MB3082.eurprd07.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: d36fc019-2f40-499d-01ee-08d5487e4d0f x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(3008031)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:HE1PR0702MB3835; x-ms-traffictypediagnostic: HE1PR0702MB3835: authentication-results: spf=none (sender IP is ) smtp.mailfrom=zoltan.balogh@ericsson.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(37575265505322); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231023)(944501027)(6041268)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:HE1PR0702MB3835; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR0702MB3835; x-forefront-prvs: 0528942FD8 received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: d36fc019-2f40-499d-01ee-08d5487e4d0f X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Dec 2017 14:22:43.7920 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0702MB3835 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRmVeSWpSXmKPExsUyM2K7qO72w9ZRBofOs1gcPb2H2YHR49nN /4wBjFFcNimpOZllqUX6dglcGZvv7WItuGxa0d9whrGB8YhGFyMnh4SAicSB4ycYuxi5OIQE DjNKzL24iAXCOcEoMfFhNzuIwyLQyyxxeMs+NojMDCaJN9NeQDmPGSXaJ31iBRnGJuAscX33 SzYQW0TAUOLSpJNgcWYBPYlD6xtYQGxhAWOJedenQNVYSPT+38wIYRtJNCy4wgxiswioSqyY 1MgEYvMKxEjc3zAJbI4QkN3XuQeshlMgVmLGxl6wXkYBMYnvp9YwQewSl7j1ZD4TxHMCEkv2 nGeGsEUlXj7+xwphK0n0zT8MVSMrcWl+NzgAJASOsEu8mneeBSJhLNE1YQ8rROIAq8TsnRDb JAR8JZ5t/wbVsYNR4uvK5VAdOhIXdi9kgjgpVmJ6azfQmxxA8XyJHf21EKaVxLwzsRCt65kl 1j99zziBUW8WksNnQQPsxtQpbBC2tsSyha+ZZ4EDQ1Di5MwnLAsYWVYxihanFiflphsZ6aUW ZSYXF+fn6eWllmxiBKaJg1t+G+xgfPnc8RCjAAejEg/v7Z3WUUKsiWXFlbmHGCU4mJVEeA8v AQrxpiRWVqUW5ccXleakFh9ilOZgURLnPenJGyUkkJ5YkpqdmlqQWgSTZeLglGpgDM86a2Z0 +pZlSF2G4+yTEdJWVcKuh+d9Kfyx5e/MoslhrtoX+CSvZLS3tDJHxb2/rPR4fzT/j8KH2rOY N76SuyznNvd0A8f/K2cWJX8V/XyhqudZwM7jh5XPX9pR/eb+YYeoXnNuy+mbV8o8Drk5N56H ZcqdGYvu/pv9M0N9y5wdme81ORk3XFBiKc5INNRiLipOBADXYGooDwMAAA== X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] xlate: fix xport lookup for recirc X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Xlate_lookup and xlate_lookup_ofproto_() provides in_port and ofproto based on xport determined using flow, which is extracted from packet. The lookup can happen due to recirculation as well. It can happen, that packet_type has been modified during xlate before recirculation is triggered, so the lookup fails or delivers wrong xport. This can be worked around by propagating xport to ctx->xin after the very first lookup and store it in frozen state of the recirculation. So, when lookup is performed due to recirculation, the xport can be retrieved from the frozen state. Signed-off-by: Zoltan Balogh CC: Jan Scheurich --- ofproto/ofproto-dpif-rid.c | 4 +++- ofproto/ofproto-dpif-rid.h | 1 + ofproto/ofproto-dpif-upcall.c | 2 ++ ofproto/ofproto-dpif-xlate.c | 30 ++++++++++++++++++++++++++++++ ofproto/ofproto-dpif-xlate.h | 3 +++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-rid.c b/ofproto/ofproto-dpif-rid.c index fc5700489..79de90520 100644 --- a/ofproto/ofproto-dpif-rid.c +++ b/ofproto/ofproto-dpif-rid.c @@ -158,7 +158,8 @@ frozen_state_equal(const struct frozen_state *a, const struct frozen_state *b) && ofpacts_equal(a->ofpacts, a->ofpacts_len, b->ofpacts, b->ofpacts_len) && ofpacts_equal(a->action_set, a->action_set_len, - b->action_set, b->action_set_len)); + b->action_set, b->action_set_len) + && a->xport_in == b->xport_in); } /* Lockless RCU protected lookup. If node is needed accross RCU quiescent @@ -285,6 +286,7 @@ recirc_alloc_id(struct ofproto_dpif *ofproto) .ipv6_dst = in6addr_any, }, .in_port = OFPP_NONE }, + .xport_in = NULL, }; return recirc_alloc_id__(&state, frozen_state_hash(&state))->id; } diff --git a/ofproto/ofproto-dpif-rid.h b/ofproto/ofproto-dpif-rid.h index 19fc27c7c..f02221094 100644 --- a/ofproto/ofproto-dpif-rid.h +++ b/ofproto/ofproto-dpif-rid.h @@ -143,6 +143,7 @@ struct frozen_state { size_t stack_size; mirror_mask_t mirrors; /* Mirrors already output. */ bool conntracked; /* Conntrack occurred prior to freeze. */ + const struct xport *xport_in; /* Port packet was received on. */ /* Actions to be translated when thawing. */ struct ofpact *ofpacts; diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 02cf5415b..92a92d288 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -236,6 +236,8 @@ struct upcall { const struct nlattr *out_tun_key; /* Datapath output tunnel key. */ uint64_t odp_actions_stub[1024 / 8]; /* Stub for odp_actions. */ + + const struct xport *xport_in; /* Port the packet was received on. */ }; /* Ukeys must transition through these states using transition_ukey(). */ diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 9b3a2f28a..c9fb32338 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1362,12 +1362,36 @@ xlate_lookup_ofproto_(const struct dpif_backer *backer, const struct flow *flow, struct xlate_cfg *xcfg = ovsrcu_get(struct xlate_cfg *, &xcfgp); const struct xport *xport; + /* If packet is recirculated, xport can be retrieved from frozen state. */ + if (flow->recirc_id) { + const struct recirc_id_node *recirc_id_node; + + recirc_id_node = recirc_id_node_find(flow->recirc_id); + + if (OVS_UNLIKELY(!recirc_id_node)) { + return NULL; + } + + /* If recirculation was initiated due to bond (in_port = OFPP_NONE), + * xport cannot be retrieved from frozen state. */ + if (recirc_id_node->state.metadata.in_port != OFPP_NONE) { + xport = recirc_id_node->state.xport_in; + /* Verify, if xport is valid. */ + if (xport && hmap_contains(&xcfg->xports, &xport->hmap_node) && + xport->xbridge && xport->xbridge->ofproto) { + goto out; + } + } + } + xport = xport_lookup(xcfg, tnl_port_should_receive(flow) ? tnl_port_receive(flow) : odp_port_to_ofport(backer, flow->in_port.odp_port)); if (OVS_UNLIKELY(!xport)) { return NULL; } + +out: *xportp = xport; if (ofp_in_port) { *ofp_in_port = xport->ofp_port; @@ -4623,6 +4647,7 @@ finish_freezing__(struct xlate_ctx *ctx, uint8_t table) .stack_size = ctx->stack.size, .mirrors = ctx->mirrors, .conntracked = ctx->conntracked, + .xport_in = ctx->xin->xport_in, .ofpacts = ctx->frozen_actions.data, .ofpacts_len = ctx->frozen_actions.size, .action_set = ctx->action_set.data, @@ -6613,6 +6638,7 @@ xlate_in_init(struct xlate_in *xin, struct ofproto_dpif *ofproto, xin->odp_actions = odp_actions; xin->in_packet_out = false; xin->recirc_queue = NULL; + xin->xport_in = NULL; /* Do recirc lookup. */ xin->frozen_state = NULL; @@ -7040,6 +7066,9 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout) * flow->in_port is the ultimate input port of the packet.) */ struct xport *in_port = get_ofp_port(xbridge, ctx.base_flow.in_port.ofp_port); + if (in_port && !in_port->peer) { + ctx.xin->xport_in = in_port; + } if (flow->packet_type != htonl(PT_ETH) && in_port && in_port->pt_mode == NETDEV_PT_LEGACY_L3 && ctx.table_id == 0) { @@ -7279,6 +7308,7 @@ xlate_resume(struct ofproto_dpif *ofproto, .stack_size = pin->stack_size, .mirrors = pin->mirrors, .conntracked = pin->conntracked, + .xport_in = NULL, /* When there are no actions, xlate_actions() will search the flow * table. We don't want it to do that (we want it to resume), so diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h index 39542de2b..932ebc492 100644 --- a/ofproto/ofproto-dpif-xlate.h +++ b/ofproto/ofproto-dpif-xlate.h @@ -162,6 +162,9 @@ struct xlate_in { /* ofproto/trace maintains this queue to trace flows that require * recirculation. */ struct ovs_list *recirc_queue; + + /* Non-patch port packet was received on.*/ + const struct xport *xport_in; }; void xlate_ofproto_set(struct ofproto_dpif *, const char *name, struct dpif *,