From nobody Mon Feb 9 21:03:01 2026 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 1732591633378377.87303057752115; Mon, 25 Nov 2024 19:27:13 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id CCB491A82; Mon, 25 Nov 2024 22:27:12 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 20FE218A0; Mon, 25 Nov 2024 22:25:12 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4206818B7; Mon, 25 Nov 2024 22:25:07 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 E7CF218AD for ; Mon, 25 Nov 2024 22:24:58 -0500 (EST) Received: from mx-prod-mc-01.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-383--iUdxT1oN06CEYC47mD5-A-1; Mon, 25 Nov 2024 22:24:56 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A97921956096 for ; Tue, 26 Nov 2024 03:24:55 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.88.88]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8B086195DF81; Tue, 26 Nov 2024 03:24:54 +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=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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=1732591498; 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=AoJ+CsxYk1sS+UEo6K6T1JmOXNnrtNnZxMO/t+0UbR4=; b=FBMQu06ha23k0aBfap8IR9EAiFXJLKxkk8Thhy4TyRrybmg2cqdOfq9reBM65kxneH9I/h egYZp5vjR14ZACNDIB3H94QIU3xVDWQLZ5zsvIvXDhdqNPmk1KElihwdVdxKdJoO1Rbi9K F6KZYazIZKJD2crie+PXVJWfa7/8NO8= X-MC-Unique: -iUdxT1oN06CEYC47mD5-A-1 X-Mimecast-MFC-AGG-ID: -iUdxT1oN06CEYC47mD5-A From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v2 3/6] util: put the command that adds a tx filter qdisc into a separate function Date: Mon, 25 Nov 2024 22:24:46 -0500 Message-ID: <20241126032449.912167-4-laine@redhat.com> In-Reply-To: <20241126032449.912167-1-laine@redhat.com> References: <20241126032449.912167-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mvx_qbqrC9O2_I7xKh-sBbbD_omjY_9UwhmK1ZH1QF4_1732591495 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5QAMR2LK5GLG6MMYFZ7PNHPST7RVS27F X-Message-ID-Hash: 5QAMR2LK5GLG6MMYFZ7PNHPST7RVS27F 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: egarver@redhat.com, mprivozn@redhat.com, psutter@redhat.com, abologna@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: 1732591634729019100 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 9c48844c5d..90eebe6576 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -266,11 +266,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 @@ -794,3 +790,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 69c204389c..080d509d6e 100644 --- a/src/util/virnetdevbandwidth.h +++ b/src/util/virnetdevbandwidth.h @@ -84,3 +84,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