From patchwork Wed Apr 3 07:11:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuhao zhou X-Patchwork-Id: 1919053 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=QCf1WCiZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V8bXc1sf2z23v3 for ; Wed, 3 Apr 2024 18:12:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9AFA260D66; Wed, 3 Apr 2024 07:11:54 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id xWT8jQPXUWrn; Wed, 3 Apr 2024 07:11:53 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 809B860C19 Authentication-Results: smtp3.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=QCf1WCiZ Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 809B860C19; Wed, 3 Apr 2024 07:11:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 706CDC008E; Wed, 3 Apr 2024 07:11:53 +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 9B6E1C0037 for ; Wed, 3 Apr 2024 07:11:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A768D414D8 for ; Wed, 3 Apr 2024 07:11:46 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id SSuptuClZe7q for ; Wed, 3 Apr 2024 07:11:43 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::42c; helo=mail-pf1-x42c.google.com; envelope-from=zhouyuhao.philozhou@bytedance.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org B0F15414C3 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B0F15414C3 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=QCf1WCiZ Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by smtp4.osuosl.org (Postfix) with ESMTPS id B0F15414C3 for ; Wed, 3 Apr 2024 07:11:43 +0000 (UTC) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6e46dcd8feaso2777499b3a.2 for ; Wed, 03 Apr 2024 00:11:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1712128302; x=1712733102; darn=openvswitch.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Kuk5x9LDduQO0c2oJNes144Dx2MCPHtXdymNE7mLqzg=; b=QCf1WCiZPbr1W9G8hrVsRHE00PcCT+c9vbWyP82sXm5O4yH04Vy4XLNlvhk9vsTCZx 5ugYUdnBNVT/AqRStH1GjxpoRe00xCZftGEgr8uv+3CXU04a/uQVbBLKY6TgMG9b6K+i yXKR5AmIPF6IqFx49Xr2FdqhtjapC+VNVS3/84Y+UsnGf56v0o7Gv8QEt5jKyM84mmGI 4gP+nAG3w5ZmCXTsKZ3o/Qc6WTPzzw2Saqe/Kk2koD2fasi83nFhsSkqUsSYv+bCxmDZ eE/5b0SEkgTvKcpHUtsRrYB6gNaSGkzGAZwe0Lc2lTN0HbTchxeKuxgcYyG9fNglSTEL Uibw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712128302; x=1712733102; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Kuk5x9LDduQO0c2oJNes144Dx2MCPHtXdymNE7mLqzg=; b=uJlAyYFMynG+L0hkAW0IcgVjGB0Ln6OTnGRBKXTApUKZvGhmDVxE3MV8IkYEf0Rn3H ei77Nt7rNuk6YZRK83rHfBsfgygW1Mcy7c6J98t3Gwl7EUxHj6k1qtPTZb2EuuyQwlrt yhNJvtgrP1dvb2kO/f7bcHjv745XhcDdWOLwP5wdpQ49XK5x2uM2PtV+Nt5OTGxOwLBK qArIOKbOu+JoI1uUOxgjSUqtTQlyu9e4ab8aMdx44AbYgs7HKSNtvUXJPS0EjgpRcY7U SWFQcR/nVv55FL7eJ4sdS3EQQndF6cTBtvAN120YbKGEGW6nFlfremnb5YBaKUzJROac Fgow== X-Gm-Message-State: AOJu0YwHgsCS4e2kcaNGOUslHR79L7v+9HSu4ST5XvtrGWdOhspheKRU CHXo2gAEAr3B0XDoUKJjZiECQMit/GHu5+lU64KZBmcrZw2ADCqejBQer72PrYrHPdAKv49p/Qs = X-Google-Smtp-Source: AGHT+IH3MZIHqQkMtcbidtxD68ejQoRRDx3/2Y0tFuzHTlJNmPomZt3tE1AwFKR+qdNShYxuMUPIrQ== X-Received: by 2002:a05:6a00:138a:b0:6ea:7a14:2e20 with SMTP id t10-20020a056a00138a00b006ea7a142e20mr16266680pfg.3.1712128302543; Wed, 03 Apr 2024 00:11:42 -0700 (PDT) Received: from X5TXGW7TL2.bytedance.net ([61.213.176.10]) by smtp.gmail.com with ESMTPSA id d25-20020aa78699000000b006ea858ea901sm10986504pfo.210.2024.04.03.00.11.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Apr 2024 00:11:42 -0700 (PDT) To: dev@openvswitch.org Date: Wed, 3 Apr 2024 15:11:36 +0800 Message-Id: <20240403071136.45174-1-zhouyuhao.philozhou@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 Cc: "zhouyuhao.philozhou" Subject: [ovs-dev] [PATCH] [PATCH v2] ofproto: Fix mod flow table name not to take effect. 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: Yuhao zhou via dev From: Yuhao zhou Reply-To: Yuhao zhou Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: "zhouyuhao.philozhou" When mod a flow table's name with table's prefix name, there will be no change. Because when check whether the new and old name are the same, only compare the length of the new name. Case: table 10: "good" There will be no change if mod the table's name with "g" "go" "goo". Signed-off-by: zhouyuhao.philozhou --- V1 -> V2: 1. Add oftable_may_set_name name len check. 2. Use OFP_MAX_TABLE_NAME_LEN as length of strncmp. Signed-off-by: zhouyuhao.philozhou --- ofproto/ofproto.c | 9 ++++----- tests/ofproto.at | 12 ++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 122a06f30..f6facae56 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -9289,11 +9289,12 @@ oftable_destroy(struct oftable *table) static void oftable_set_name(struct oftable *table, const char *name, int level) { - int len = name ? strnlen(name, OFP_MAX_TABLE_NAME_LEN) : 0; if (level >= table->name_level) { if (name) { if (name[0]) { - if (!table->name || strncmp(name, table->name, len)) { + if (!table->name || strncmp(name, table->name, + OFP_MAX_TABLE_NAME_LEN)) { + int len = strnlen(name, OFP_MAX_TABLE_NAME_LEN); free(table->name); table->name = xmemdup0(name, len); } @@ -9318,10 +9319,8 @@ oftable_may_set_name(const struct oftable *table, const char *name, int level) return (level >= table->name_level || !name || !table->name - || !strncmp(name, table->name, - strnlen(name, OFP_MAX_TABLE_NAME_LEN))); + || !strncmp(name, table->name,OFP_MAX_TABLE_NAME_LEN)); } - /* oftables support a choice of two policies when adding a rule would cause the * number of flows in the table to exceed the configured maximum number: either * they can refuse to add the new flow or they can evict some existing flow. diff --git a/tests/ofproto.at b/tests/ofproto.at index 2889f81fb..09c57b292 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -2523,6 +2523,18 @@ AT_CHECK([ovs-ofctl -O OpenFlow15 dump-table-features br0 |grep '^ table'], table 253: ]) +# Make sure that the new name is old table's name prefix can also take effect. +AT_CHECK([ovs-ofctl -O OpenFlow13 mod-table br0 3 name:thr]) +AT_CHECK([ovs-ofctl -O OpenFlow15 dump-table-features br0 |grep '^ table'], + [0], [dnl + table 0 ("zero"): + table 1 ("one"): ditto + table 2: ditto + table 3 ("thr"): ditto + tables 4...252: ditto + table 253: +]) + OVS_VSWITCHD_STOP AT_CLEANUP