mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
util: put the command that adds a tx filter qdisc into a separate function
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 <laine@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
250435546a
commit
35a5bf25d1
@ -2875,6 +2875,7 @@ virNetDevVFInterfaceStats;
|
||||
|
||||
|
||||
# util/virnetdevbandwidth.h
|
||||
virNetDevBandWidthAddTxFilterParentQdisc;
|
||||
virNetDevBandwidthClear;
|
||||
virNetDevBandwidthCopy;
|
||||
virNetDevBandwidthEqual;
|
||||
|
@ -266,11 +266,7 @@ virNetDevBandwidthSet(const char *ifname,
|
||||
if (tx->burst)
|
||||
burst = g_strdup_printf("%llukb", tx->burst);
|
||||
|
||||
cmd = 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;
|
||||
|
||||
/* If we are creating a hierarchical class, all non guaranteed traffic
|
||||
@ -794,3 +790,27 @@ virNetDevBandwidthSetRootQDisc(const char *ifname,
|
||||
|
||||
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 = NULL;
|
||||
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "qdisc", "add", "dev", ifname, "root",
|
||||
"handle", "1:", "htb", "default",
|
||||
hierarchical_class ? "2" : "1", NULL);
|
||||
|
||||
return virCommandRun(cmd, NULL);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user