From nobody Fri Dec 27 13:42:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732310294899819.9573975460244; Fri, 22 Nov 2024 13:18:14 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 470991385; Fri, 22 Nov 2024 16:18:14 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1DE7A149E; Fri, 22 Nov 2024 16:16:54 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id DC2AA13EC; Fri, 22 Nov 2024 16:16:47 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 32F7013E0 for ; Fri, 22 Nov 2024 16:16:47 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-3Uz1G39VNqyCRwxfxvlP1g-1; Fri, 22 Nov 2024 16:16:45 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BEB6719560BA for ; Fri, 22 Nov 2024 21:16:44 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.88.88]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9DD9030000DF; Fri, 22 Nov 2024 21:16:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732310206; 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=0BotkBzZlPrV0JQUF6elKbXWCrFwrMqgnh1GlHm6eCI=; b=FZGrCZsHQZTae7a2G8BnW7LOyHIlikAYT0rb3M4SdVNc/rMKFhSLfB5Zrb73JFPykLb7K8 msICWcL/kcWK6Ko4RTmIrOFvKGw5BPxdcmNM+uD3wwBdZtz0VOUVc/aIZ2rwNlo62ZykGU n5SOyKR1qFJyB01RrzwS1xeTJikxSdI= X-MC-Unique: 3Uz1G39VNqyCRwxfxvlP1g-1 X-Mimecast-MFC-AGG-ID: 3Uz1G39VNqyCRwxfxvlP1g From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 2/5] util: put the command that adds a tx filter qdisc into a separate function Date: Fri, 22 Nov 2024 16:16:36 -0500 Message-ID: <20241122211639.615518-3-laine@redhat.com> In-Reply-To: <20241122211639.615518-1-laine@redhat.com> References: <20241122211639.615518-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: xgcoikpEtNp0isHcuyhEvZGY9FEGdjgldu6q-NQBkik_1732310204 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QDGQDIVMWFZ4OHI7MFJP3MHYY7HC5JTY X-Message-ID-Hash: QDGQDIVMWFZ4OHI7MFJP3MHYY7HC5JTY X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: mprivozn@redhat.com, psutter@redhat.com, abologna@redhat.com, egarver@redhat.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732310296938116600 Content-Type: text/plain; charset="utf-8"; x-default="true" virNetDevBandwidthSet() adds a queue discipline (qdisc) for each interface that it will need to add tc transmit filters to, and the filters are then attached to the qdisc. There are other circumstances where some other function will need to add tc transmit filters to an interface (in particular an upcoming patch to the network driver nftables backend that will use a tc tx filter to fix the checksum of dhcp packets), so that function will also need a qdisc for the tx filter. To assure both always use exactly the same qdisc, this patch puts the command that adds the tx filter qdisc into a separate helper function that can (and will) be called from either place Signed-off-by: Laine Stump --- src/libvirt_private.syms | 1 + src/util/virnetdevbandwidth.c | 30 +++++++++++++++++++++++++----- src/util/virnetdevbandwidth.h | 3 +++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5b9b44ef96..90a7c6fa01 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2874,6 +2874,7 @@ virNetDevVFInterfaceStats; =20 =20 # util/virnetdevbandwidth.h +virNetDevBandWidthAddTxFilterParentQdisc; virNetDevBandwidthClear; virNetDevBandwidthCopy; virNetDevBandwidthEqual; diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index d62a85a06c..09c10e9a15 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -258,11 +258,7 @@ virNetDevBandwidthSet(const char *ifname, if (tx->burst) burst =3D g_strdup_printf("%llukb", tx->burst); =20 - cmd =3D virCommandNew(TC); - virCommandAddArgList(cmd, "qdisc", "add", "dev", ifname, "root", - "handle", "1:", "htb", "default", - hierarchical_class ? "2" : "1", NULL); - if (virCommandRun(cmd, NULL) < 0) + if (virNetDevBandWidthAddTxFilterParentQdisc(ifname, hierarchical_= class) < 0) goto cleanup; =20 /* If we are creating a hierarchical class, all non guaranteed tra= ffic @@ -786,3 +782,27 @@ virNetDevBandwidthSetRootQDisc(const char *ifname, =20 return 0; } + +/** + * virNetDevBandwidthAddTxFilterParentQdisc: + * @ifname: name of interface that needs a qdisc to attach tx filters to + * @hierarchical_class: true if hierarchical classes will be used on this = interface + * + * Add a root Qdisc (Queueing Discipline) for attaching Tx filters to + * @ifname. + * + * returns 0 on success, -1 on failure + */ +int +virNetDevBandWidthAddTxFilterParentQdisc(const char *ifname, + bool hierarchical_class) +{ + g_autoptr(virCommand) cmd =3D NULL; + + cmd =3D virCommandNew(TC); + virCommandAddArgList(cmd, "qdisc", "add", "dev", ifname, "root", + "handle", "1:", "htb", "default", + hierarchical_class ? "2" : "1", NULL); + + return virCommandRun(cmd, NULL); +} diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h index 68344016c5..74cc3d4b65 100644 --- a/src/util/virnetdevbandwidth.h +++ b/src/util/virnetdevbandwidth.h @@ -79,3 +79,6 @@ int virNetDevBandwidthUpdateFilter(const char *ifname, int virNetDevBandwidthSetRootQDisc(const char *ifname, const char *qdisc) G_NO_INLINE; + +int virNetDevBandWidthAddTxFilterParentQdisc(const char *ifname, + bool hierarchical_class); --=20 2.47.0