From patchwork Mon Apr 24 06:01:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wan Junjie X-Patchwork-Id: 1772685 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::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=Wask5U4A; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4Q4ZJH2dXvz23hs for ; Mon, 24 Apr 2023 16:01:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 274FA408E1; Mon, 24 Apr 2023 06:01:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 274FA408E1 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=Wask5U4A X-Virus-Scanned: amavisd-new at osuosl.org 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 Zj3AvOlKQUro; Mon, 24 Apr 2023 06:01:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 4049F401F1; Mon, 24 Apr 2023 06:01:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4049F401F1 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 16A8AC0037; Mon, 24 Apr 2023 06:01:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id AE347C002A for ; Mon, 24 Apr 2023 06:01:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 79B78410AB for ; Mon, 24 Apr 2023 06:01:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 79B78410AB Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=Wask5U4A 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 AK76ll6Kxz02 for ; Mon, 24 Apr 2023 06:01:10 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org DD8AE410AF Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by smtp4.osuosl.org (Postfix) with ESMTPS id DD8AE410AF for ; Mon, 24 Apr 2023 06:01:09 +0000 (UTC) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-63b781c9787so1306779b3a.1 for ; Sun, 23 Apr 2023 23:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682316068; x=1684908068; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=hZ57Etwigta4nXlr8Rjqd4zGbHwTZlte7cBBjXuXi0U=; b=Wask5U4A4D34UeowaVIMHtJeyHnjWWmRgRWudo1KEexY11YABZaWeS+S9v/8Vu+sz9 ECu78uFaH2zA3MyzJbKU2AxBtKRq72XdYKGigLjgtFr3qUYAl4HjKDQDsXatJusUvpgw Tcszkjc/iCEatzDjKoKXkj5YZhf/L8hhv8haobbD686tKijcj5HXRFSsndmd/VgraOp9 EQJUhOp4RpJOz+MEj/m/JUOkwoBZBmt5vnzv/n6ZHMtKX0fMh2Q9M4O0OXV2HtKfxcBM zHGKkmiDcjlWjVR2GGXQQvRodOERJMhspebQNFhLBVNcw4MtDy40YenWxGHPjlDE9Ipz cXyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682316068; x=1684908068; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hZ57Etwigta4nXlr8Rjqd4zGbHwTZlte7cBBjXuXi0U=; b=W6e4xSDQ8/8ZziVUK+eY2fTijB4jXmbxXIwCGspszeJOLHBFNGiDF1kE7aIT8JJIVZ OTkpwQKnXSbZdnm63kJCmbt52UCG/Y1hm5J5fvBXnXKkHbTjYqypV2BEs2CJErt0SgU/ HEvt5z1h8v657VKx2rZ0s251bZpT064h1XTLsirTfQZua7dKZn68b+kdY0dK3gtKJ5hf o1E77VhBoo3ss9r1PSFuyMzqE2DouVOsXlhhcrtM6eDAaGav96gLDlPLrRLUyW9fBtPH wwRmtJguPvF6AmACsv9O5ZJV46pmiD1Y9rLOQemrhu/4N42ZC1FvGjiz8n5NAxCFPcrk oPdg== X-Gm-Message-State: AAQBX9cY75785EnjqttQli2W2FDRwKdoXyYu4ZlGbY3PAJ3BZH/YYMqr qUxdnWdAFadUcupKtigu9fiyjENW7otZ74sAuiCNLg== X-Google-Smtp-Source: AKy350Zx6oF4c/PVwcXwB/2EiHL+xeXRBDAVb2zcM0sbrXcTP+2pnMSImY67aCSIz8pmPV6l4AGB9Q== X-Received: by 2002:a17:902:da88:b0:1a2:175a:6153 with SMTP id j8-20020a170902da8800b001a2175a6153mr16138305plx.1.1682316068439; Sun, 23 Apr 2023 23:01:08 -0700 (PDT) Received: from C02Z10J4LVCK.bytedance.net ([139.177.225.246]) by smtp.gmail.com with ESMTPSA id s22-20020a170902989600b001a043e84bf0sm5831338plp.209.2023.04.23.23.01.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 23:01:07 -0700 (PDT) To: dev@openvswitch.org Date: Mon, 24 Apr 2023 14:01:03 +0800 Message-Id: <20230424060103.33586-1-wanjunjie@bytedance.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH] ovs-ofctl: skip invalid flows for replace-flows 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: Wan Junjie via dev From: Wan Junjie Reply-To: Wan Junjie Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" ovs-save will do replace-flows for ovs restart. For some reason, ovs could have an invalid action, like invalid meter. Then adding flows will be stopped at the position of the first invalid flow. This could happen when ovs restart and vm related resource allocatting or destructing at the same time. This patch will skip the invalid flows and continue the process so all valid flows will be added during the ovs restart. An destructed vm will not affect those normal vm traffic. Signed-off-by: Wan Junjie --- include/openvswitch/vconn.h | 2 +- lib/vconn.c | 23 ++++++++++++++--------- utilities/ovs-ofctl.c | 19 +++++++++++++------ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/include/openvswitch/vconn.h b/include/openvswitch/vconn.h index 5f69c732b..781c59075 100644 --- a/include/openvswitch/vconn.h +++ b/include/openvswitch/vconn.h @@ -57,7 +57,7 @@ int vconn_recv_xid(struct vconn *, ovs_be32 xid, struct ofpbuf **); int vconn_transact(struct vconn *, struct ofpbuf *, struct ofpbuf **); int vconn_transact_noreply(struct vconn *, struct ofpbuf *, struct ofpbuf **); int vconn_transact_multiple_noreply(struct vconn *, struct ovs_list *requests, - struct ofpbuf **replyp); + struct ovs_list *replies); int vconn_transact_multipart(struct vconn *, struct ovs_list *request, struct ovs_list *replies); diff --git a/lib/vconn.c b/lib/vconn.c index b55676227..a5f6177ec 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -926,23 +926,28 @@ vconn_transact_noreply(struct vconn *vconn, struct ofpbuf *request, /* vconn_transact_noreply() for a list of "struct ofpbuf"s, sent one by one. * All of the requests on 'requests' are always destroyed, regardless of the * return value. */ -int -vconn_transact_multiple_noreply(struct vconn *vconn, struct ovs_list *requests, - struct ofpbuf **replyp) -{ +int vconn_transact_multiple_noreply(struct vconn *vconn, + struct ovs_list *requests, + struct ovs_list *replies) { struct ofpbuf *request; + int error = 0; LIST_FOR_EACH_POP (request, list_node, requests) { - int error; + struct ofpbuf *reply; + + error = vconn_transact_noreply(vconn, request, &reply); - error = vconn_transact_noreply(vconn, request, replyp); - if (error || *replyp) { - ofpbuf_list_delete(requests); + if (error && !reply) { return error; } + if (reply) { + ovs_list_push_back(replies, &reply->list_node); + } } - *replyp = NULL; + if (!ovs_list_is_empty(replies)) { + return error; + } return 0; } diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 24d0941cf..a84551672 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -715,18 +715,25 @@ dump_trivial_transaction(const char *vconn_name, enum ofpraw ofpraw) static void transact_multiple_noreply(struct vconn *vconn, struct ovs_list *requests) { + struct ovs_list replies; struct ofpbuf *reply; - run(vconn_transact_multiple_noreply(vconn, requests, &reply), + ovs_list_init(&replies); + + run(vconn_transact_multiple_noreply(vconn, requests, &replies), "talking to %s", vconn_get_name(vconn)); - if (reply) { + + if (ovs_list_is_empty(&replies)) { + return; + } + + LIST_FOR_EACH_POP (reply, list_node, &replies) { ofp_print(stderr, reply->data, reply->size, ports_to_show(vconn_get_name(vconn)), - tables_to_show(vconn_get_name(vconn)), - verbosity + 2); - exit(1); + tables_to_show(vconn_get_name(vconn)), verbosity + 2); + ofpbuf_delete(reply); } - ofpbuf_delete(reply); + exit(1); } /* Frees the error messages as they are printed. */