mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 03:21:19 +00:00
util: virNetDevBandwidthManipulateFilter: use g_auto
Reduce the scope of the variable to avoid renaming it. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
6f8ac7bc46
commit
e1470a2295
@ -105,8 +105,7 @@ virNetDevBandwidthManipulateFilter(const char *ifname,
|
|||||||
bool create_new)
|
bool create_new)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *filter_id = NULL;
|
g_autofree char *filter_id = NULL;
|
||||||
virCommand *cmd = NULL;
|
|
||||||
unsigned char ifmac[VIR_MAC_BUFLEN];
|
unsigned char ifmac[VIR_MAC_BUFLEN];
|
||||||
char *mac[2] = {NULL, NULL};
|
char *mac[2] = {NULL, NULL};
|
||||||
|
|
||||||
@ -120,9 +119,9 @@ virNetDevBandwidthManipulateFilter(const char *ifname,
|
|||||||
filter_id = g_strdup_printf("800::%u", id);
|
filter_id = g_strdup_printf("800::%u", id);
|
||||||
|
|
||||||
if (remove_old) {
|
if (remove_old) {
|
||||||
|
g_autoptr(virCommand) cmd = virCommandNew(TC);
|
||||||
int cmd_ret = 0;
|
int cmd_ret = 0;
|
||||||
|
|
||||||
cmd = virCommandNew(TC);
|
|
||||||
virCommandAddArgList(cmd, "filter", "del", "dev", ifname,
|
virCommandAddArgList(cmd, "filter", "del", "dev", ifname,
|
||||||
"prio", "2", "handle", filter_id, "u32", NULL);
|
"prio", "2", "handle", filter_id, "u32", NULL);
|
||||||
|
|
||||||
@ -132,14 +131,13 @@ virNetDevBandwidthManipulateFilter(const char *ifname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (create_new) {
|
if (create_new) {
|
||||||
|
g_autoptr(virCommand) cmd = virCommandNew(TC);
|
||||||
virMacAddrGetRaw(ifmac_ptr, ifmac);
|
virMacAddrGetRaw(ifmac_ptr, ifmac);
|
||||||
|
|
||||||
mac[0] = g_strdup_printf("0x%02x%02x%02x%02x", ifmac[2],
|
mac[0] = g_strdup_printf("0x%02x%02x%02x%02x", ifmac[2],
|
||||||
ifmac[3], ifmac[4], ifmac[5]);
|
ifmac[3], ifmac[4], ifmac[5]);
|
||||||
mac[1] = g_strdup_printf("0x%02x%02x", ifmac[0], ifmac[1]);
|
mac[1] = g_strdup_printf("0x%02x%02x", ifmac[0], ifmac[1]);
|
||||||
|
|
||||||
virCommandFree(cmd);
|
|
||||||
cmd = virCommandNew(TC);
|
|
||||||
/* Okay, this not nice. But since libvirt does not necessarily track
|
/* Okay, this not nice. But since libvirt does not necessarily track
|
||||||
* interface IP address(es), and tc fw filter simply refuse to use
|
* interface IP address(es), and tc fw filter simply refuse to use
|
||||||
* ebtables marks, we need to use u32 selector to match MAC address.
|
* ebtables marks, we need to use u32 selector to match MAC address.
|
||||||
@ -160,8 +158,6 @@ virNetDevBandwidthManipulateFilter(const char *ifname,
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(mac[1]);
|
VIR_FREE(mac[1]);
|
||||||
VIR_FREE(mac[0]);
|
VIR_FREE(mac[0]);
|
||||||
VIR_FREE(filter_id);
|
|
||||||
virCommandFree(cmd);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user