From patchwork Wed Apr 6 14:10:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Moreno?= X-Patchwork-Id: 1613968 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=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X5wv7SIH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 4KYRJC1Bx9z9sFq for ; Thu, 7 Apr 2022 00:11:06 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5320541849; Wed, 6 Apr 2022 14:11:04 +0000 (UTC) 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 xodfQT_38E8C; Wed, 6 Apr 2022 14:11:02 +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 B6B93408D7; Wed, 6 Apr 2022 14:11:01 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7EAB3C0031; Wed, 6 Apr 2022 14:11:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id D3D37C0083 for ; Wed, 6 Apr 2022 14:10:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B56F383313 for ; Wed, 6 Apr 2022 14:10:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 jba12VxC51DB for ; Wed, 6 Apr 2022 14:10:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id BB5DE83104 for ; Wed, 6 Apr 2022 14:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649254257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wemYu5V87RvC1EUvgcc2h+0if9oyiG1WYTr/dNFC1Rc=; b=X5wv7SIHZ+OmDZdvXM0JjV5xkchI6sJ3fvNtpCOPi7r2+3CgEIAC1STWn8U88GV6Dfgaw8 Y0G6P5IJMw8Qp74TVaQRpo2kP35/wjn4FRUDIlXO7xfOOiZJvD0prN7FeYgjyWoKkSTvCD V2lLFuDkrCbn4PdbcSZVecCtFk+zUZ8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-L4FzAHVfOoSw53SgANf5bA-1; Wed, 06 Apr 2022 10:10:55 -0400 X-MC-Unique: L4FzAHVfOoSw53SgANf5bA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C29891CBE5 for ; Wed, 6 Apr 2022 14:10:55 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.193.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31EE5515A42; Wed, 6 Apr 2022 14:10:54 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Wed, 6 Apr 2022 16:10:39 +0200 Message-Id: <20220406141041.2336574-2-amorenoz@redhat.com> In-Reply-To: <20220406141041.2336574-1-amorenoz@redhat.com> References: <20220406141041.2336574-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn 1/3] treewide: bump ovs and fix problematic loops 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 minimum changes to adapt to new ovs are: - adapt to changes made in inet_parse_active function by passing an extra NULL argument - fix those places where next variable was being used inside *_SAFE iterators since. Now the next variable might not always be safe to use so extra checks are needed. Signed-off-by: Adrian Moreno --- controller/ofctrl.c | 7 ++++++- lib/actions.c | 2 +- lib/expr.c | 31 ++++++++++++++++++------------- lib/ovn-util.c | 2 +- ovs | 2 +- utilities/ovn-nbctl.c | 6 +++--- utilities/ovn-trace.c | 8 +++++--- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/controller/ofctrl.c b/controller/ofctrl.c index a7c2d2011..17d40a708 100644 --- a/controller/ofctrl.c +++ b/controller/ofctrl.c @@ -943,7 +943,12 @@ link_installed_to_desired(struct installed_flow *i, struct desired_flow *d) break; } } - ovs_list_insert(&f->installed_ref_list_node, &d->installed_ref_list_node); + if (!f) { + ovs_list_insert(&i->desired_refs, &d->installed_ref_list_node); + } else { + ovs_list_insert(&f->installed_ref_list_node, + &d->installed_ref_list_node); + } d->installed_flow = i; return installed_flow_get_active(i) == d; } diff --git a/lib/actions.c b/lib/actions.c index 7fe80f458..a3cf747db 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -2440,7 +2440,7 @@ validate_empty_lb_backends(struct action_context *ctx, switch (o->option->code) { case EMPTY_LB_VIP: - if (!inet_parse_active(c->string, 0, &ss, false)) { + if (!inet_parse_active(c->string, 0, &ss, false, NULL)) { lexer_error(ctx->lexer, "Invalid load balancer VIP '%s'", c->string); return; diff --git a/lib/expr.c b/lib/expr.c index 47ef6108e..058390a16 100644 --- a/lib/expr.c +++ b/lib/expr.c @@ -211,16 +211,17 @@ expr_combine(enum expr_type type, struct expr *a, struct expr *b) } static void -expr_insert_andor(struct expr *andor, struct expr *before, struct expr *new) +expr_insert_andor(struct expr *andor, struct ovs_list *before, + struct expr *new) { if (new->type == andor->type) { if (andor->type == EXPR_T_AND) { /* Conjunction junction, what's your function? */ } - ovs_list_splice(&before->node, new->andor.next, &new->andor); + ovs_list_splice(before, new->andor.next, &new->andor); expr_destroy(new); } else { - ovs_list_insert(&before->node, &new->node); + ovs_list_insert(before, &new->node); } } @@ -2101,7 +2102,8 @@ expr_annotate__(struct expr *expr, const struct shash *symtab, expr_destroy(expr); return NULL; } - expr_insert_andor(expr, next, new_sub); + expr_insert_andor(expr, next ? &next->node : &expr->andor, + new_sub); } *errorp = NULL; return expr; @@ -2301,7 +2303,7 @@ expr_evaluate_condition(struct expr *expr, struct expr *e = expr_evaluate_condition(sub, is_chassis_resident, c_aux); e = expr_fix(e); - expr_insert_andor(expr, next, e); + expr_insert_andor(expr, next ? &next->node : &expr->andor, e); } return expr_fix(expr); @@ -2334,7 +2336,8 @@ expr_simplify(struct expr *expr) case EXPR_T_OR: LIST_FOR_EACH_SAFE (sub, next, node, &expr->andor) { ovs_list_remove(&sub->node); - expr_insert_andor(expr, next, expr_simplify(sub)); + expr_insert_andor(expr, next ? &next->node : &expr->andor, + expr_simplify(sub)); } return expr_fix(expr); @@ -2444,12 +2447,13 @@ crush_and_string(struct expr *expr, const struct expr_symbol *symbol) * EXPR_T_OR with EXPR_T_CMP subexpressions. */ struct expr *sub, *next = NULL; LIST_FOR_EACH_SAFE (sub, next, node, &expr->andor) { + struct ovs_list *next_list = next ? &next->node : &expr->andor; ovs_list_remove(&sub->node); struct expr *new = crush_cmps(sub, symbol); switch (new->type) { case EXPR_T_CMP: if (!singleton) { - ovs_list_insert(&next->node, &new->node); + ovs_list_insert(next_list, &new->node); singleton = new; } else { bool match = !strcmp(new->cmp.string, singleton->cmp.string); @@ -2463,7 +2467,7 @@ crush_and_string(struct expr *expr, const struct expr_symbol *symbol) case EXPR_T_AND: OVS_NOT_REACHED(); case EXPR_T_OR: - ovs_list_insert(&next->node, &new->node); + ovs_list_insert(next_list, &new->node); break; case EXPR_T_BOOLEAN: if (!new->boolean) { @@ -2559,7 +2563,7 @@ crush_and_numeric(struct expr *expr, const struct expr_symbol *symbol) case EXPR_T_AND: OVS_NOT_REACHED(); case EXPR_T_OR: - ovs_list_insert(&next->node, &new->node); + ovs_list_insert(next ? &next->node : &expr->andor, &new->node); break; case EXPR_T_BOOLEAN: if (!new->boolean) { @@ -2725,7 +2729,8 @@ crush_or(struct expr *expr, const struct expr_symbol *symbol) * is now a disjunction of cmps over the same symbol. */ LIST_FOR_EACH_SAFE (sub, next, node, &expr->andor) { ovs_list_remove(&sub->node); - expr_insert_andor(expr, next, crush_cmps(sub, symbol)); + expr_insert_andor(expr, next ? &next->node : &expr->andor, + crush_cmps(sub, symbol)); } expr = expr_fix(expr); if (expr->type != EXPR_T_OR) { @@ -2886,8 +2891,7 @@ expr_normalize_and(struct expr *expr) struct expr *a, *b; LIST_FOR_EACH_SAFE (a, b, node, &expr->andor) { - if (&b->node == &expr->andor - || a->type != EXPR_T_CMP || b->type != EXPR_T_CMP + if (!b || a->type != EXPR_T_CMP || b->type != EXPR_T_CMP || a->cmp.symbol != b->cmp.symbol) { continue; } else if (a->cmp.symbol->width @@ -2964,7 +2968,8 @@ expr_normalize_or(struct expr *expr) } expr_destroy(new); } else { - expr_insert_andor(expr, next, new); + expr_insert_andor(expr, next ? &next->node : &expr->andor, + new); } } else { ovs_assert(sub->type == EXPR_T_CMP || diff --git a/lib/ovn-util.c b/lib/ovn-util.c index a6bb5f03e..81f18d6df 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -735,7 +735,7 @@ ip_address_and_port_from_lb_key(const char *key, char **ip_address, uint16_t *port, int *addr_family) { struct sockaddr_storage ss; - if (!inet_parse_active(key, 0, &ss, false)) { + if (!inet_parse_active(key, 0, &ss, false, NULL)) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); VLOG_WARN_RL(&rl, "bad ip address or port for load balancer key %s", key); diff --git a/ovs b/ovs index 498cedc48..b16270e69 160000 --- a/ovs +++ b/ovs @@ -1 +1 @@ -Subproject commit 498cedc483f3239c839c55b4d9f2261b61fb6ace +Subproject commit b16270e69b9c72284fe6f0ab186ce17e41d7af7a diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index 7bcc2c66a..7fcfa50d4 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -2856,7 +2856,7 @@ nbctl_lb_add(struct ctl_context *ctx) } struct sockaddr_storage ss_vip; - if (!inet_parse_active(lb_vip, 0, &ss_vip, false)) { + if (!inet_parse_active(lb_vip, 0, &ss_vip, false, NULL)) { ctl_error(ctx, "%s: should be an IP address (or an IP address " "and a port number with : as a separator).", lb_vip); return; @@ -2886,7 +2886,7 @@ nbctl_lb_add(struct ctl_context *ctx) struct sockaddr_storage ss_dst; if (lb_vip_port) { - if (!inet_parse_active(token, -1, &ss_dst, false)) { + if (!inet_parse_active(token, -1, &ss_dst, false, NULL)) { ctl_error(ctx, "%s: should be an IP address and a port " "number with : as a separator.", token); goto out; @@ -3032,7 +3032,7 @@ lb_info_add_smap(const struct nbrec_load_balancer *lb, const struct smap_node *node = nodes[i]; struct sockaddr_storage ss; - if (!inet_parse_active(node->key, 0, &ss, false)) { + if (!inet_parse_active(node->key, 0, &ss, false, NULL)) { continue; } diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c index 4b652828d..9822618ae 100644 --- a/utilities/ovn-trace.c +++ b/utilities/ovn-trace.c @@ -214,7 +214,7 @@ static void parse_lb_option(const char *s) { struct sockaddr_storage ss; - if (!inet_parse_active(s, 0, &ss, false)) { + if (!inet_parse_active(s, 0, &ss, false, NULL)) { ovs_fatal(0, "%s: bad address", s); } @@ -1388,7 +1388,8 @@ ovntrace_node_prune_summary(struct ovs_list *nodes) sub->type == OVNTRACE_NODE_TABLE) { /* Replace 'sub' by its children, if any, */ ovs_list_remove(&sub->node); - ovs_list_splice(&next->node, sub->subs.next, &sub->subs); + ovs_list_splice(next ? &next->node : nodes, sub->subs.next, + &sub->subs); ovntrace_node_destroy(sub); } } @@ -1432,7 +1433,8 @@ ovntrace_node_prune_hard(struct ovs_list *nodes) sub->type == OVNTRACE_NODE_OUTPUT) { /* Replace 'sub' by its children, if any, */ ovs_list_remove(&sub->node); - ovs_list_splice(&next->node, sub->subs.next, &sub->subs); + ovs_list_splice(next ? &next->node : nodes, sub->subs.next, + &sub->subs); ovntrace_node_destroy(sub); } }