mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
Adapt to VIR_STRDUP and VIR_STRNDUP in src/nwfilter/*
This commit is contained in:
parent
e3221e6421
commit
0ca51d5c9f
@ -133,11 +133,11 @@ struct _virNWFilterSnoopReq {
|
|||||||
virNWFilterTechDriverPtr techdriver;
|
virNWFilterTechDriverPtr techdriver;
|
||||||
char *ifname;
|
char *ifname;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
const char *linkdev;
|
char *linkdev;
|
||||||
enum virDomainNetType nettype;
|
enum virDomainNetType nettype;
|
||||||
char ifkey[VIR_IFKEY_LEN];
|
char ifkey[VIR_IFKEY_LEN];
|
||||||
virMacAddr macaddr;
|
virMacAddr macaddr;
|
||||||
const char *filtername;
|
char *filtername;
|
||||||
virNWFilterHashTablePtr vars;
|
virNWFilterHashTablePtr vars;
|
||||||
virNWFilterDriverStatePtr driver;
|
virNWFilterDriverStatePtr driver;
|
||||||
/* start and end of lease list, ordered by lease time */
|
/* start and end of lease list, ordered by lease time */
|
||||||
@ -1110,11 +1110,9 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac,
|
|||||||
* generate much more traffic than if we filtered by VM and
|
* generate much more traffic than if we filtered by VM and
|
||||||
* braodcast MAC as well
|
* braodcast MAC as well
|
||||||
*/
|
*/
|
||||||
if (!(ext_filter = strdup(filter))) {
|
if (VIR_STRDUP(ext_filter, filter) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
handle = pcap_create(ifname, pcap_errbuf);
|
handle = pcap_create(ifname, pcap_errbuf);
|
||||||
|
|
||||||
@ -1408,7 +1406,7 @@ virNWFilterDHCPSnoopThread(void *req0)
|
|||||||
fds[i].fd = pcap_fileno(pcapConf[i].handle);
|
fds[i].fd = pcap_fileno(pcapConf[i].handle);
|
||||||
}
|
}
|
||||||
tmp = virNetDevGetIndex(req->ifname, &ifindex);
|
tmp = virNetDevGetIndex(req->ifname, &ifindex);
|
||||||
threadkey = strdup(req->threadkey);
|
ignore_value(VIR_STRDUP(threadkey, req->threadkey));
|
||||||
worker = virThreadPoolNew(1, 1, 0,
|
worker = virThreadPoolNew(1, 1, 0,
|
||||||
virNWFilterDHCPDecodeWorker,
|
virNWFilterDHCPDecodeWorker,
|
||||||
req);
|
req);
|
||||||
@ -1631,15 +1629,17 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
|
|||||||
req->driver = driver;
|
req->driver = driver;
|
||||||
req->techdriver = techdriver;
|
req->techdriver = techdriver;
|
||||||
tmp = virNetDevGetIndex(ifname, &req->ifindex);
|
tmp = virNetDevGetIndex(ifname, &req->ifindex);
|
||||||
req->linkdev = linkdev ? strdup(linkdev) : NULL;
|
|
||||||
req->nettype = nettype;
|
req->nettype = nettype;
|
||||||
req->ifname = strdup(ifname);
|
|
||||||
virMacAddrSet(&req->macaddr, macaddr);
|
virMacAddrSet(&req->macaddr, macaddr);
|
||||||
req->filtername = strdup(filtername);
|
|
||||||
req->vars = virNWFilterHashTableCreate(0);
|
req->vars = virNWFilterHashTableCreate(0);
|
||||||
|
req->linkdev = NULL;
|
||||||
|
|
||||||
if (!req->ifname || !req->filtername || !req->vars || tmp < 0 ||
|
if (VIR_STRDUP(req->ifname, ifname) < 0 ||
|
||||||
(linkdev != NULL && req->linkdev == NULL)) {
|
VIR_STRDUP(req->filtername, filtername) < 0 ||
|
||||||
|
VIR_STRDUP(req->linkdev, linkdev) < 0)
|
||||||
|
goto exit_snoopreqput;
|
||||||
|
|
||||||
|
if (!req->vars || tmp < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto exit_snoopreqput;
|
goto exit_snoopreqput;
|
||||||
}
|
}
|
||||||
|
@ -221,8 +221,8 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
|
if (VIR_STRDUP(base, SYSCONFDIR "/libvirt") < 0)
|
||||||
goto out_of_memory;
|
goto error;
|
||||||
|
|
||||||
if (virAsprintf(&driverState->configDir,
|
if (virAsprintf(&driverState->configDir,
|
||||||
"%s/nwfilter", base) == -1)
|
"%s/nwfilter", base) == -1)
|
||||||
@ -454,9 +454,8 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
|
|||||||
nwfilterDriverLock(driver);
|
nwfilterDriverLock(driver);
|
||||||
for (i = 0 ; i < driver->nwfilters.count && got < nnames ; i++) {
|
for (i = 0 ; i < driver->nwfilters.count && got < nnames ; i++) {
|
||||||
virNWFilterObjLock(driver->nwfilters.objs[i]);
|
virNWFilterObjLock(driver->nwfilters.objs[i]);
|
||||||
if (!(names[got] = strdup(driver->nwfilters.objs[i]->def->name))) {
|
if (VIR_STRDUP(names[got], driver->nwfilters.objs[i]->def->name) < 0) {
|
||||||
virNWFilterObjUnlock(driver->nwfilters.objs[i]);
|
virNWFilterObjUnlock(driver->nwfilters.objs[i]);
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
got++;
|
got++;
|
||||||
|
@ -2982,7 +2982,7 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst,
|
|||||||
|
|
||||||
switch (protoidx) {
|
switch (protoidx) {
|
||||||
case L2_PROTO_MAC_IDX:
|
case L2_PROTO_MAC_IDX:
|
||||||
protostr = strdup("");
|
ignore_value(VIR_STRDUP(protostr, ""));
|
||||||
break;
|
break;
|
||||||
case L2_PROTO_STP_IDX:
|
case L2_PROTO_STP_IDX:
|
||||||
ignore_value(virAsprintf(&protostr, "-d " NWFILTER_MAC_BGA " "));
|
ignore_value(virAsprintf(&protostr, "-d " NWFILTER_MAC_BGA " "));
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "nwfilter_learnipaddr.h"
|
#include "nwfilter_learnipaddr.h"
|
||||||
#include "virnetdev.h"
|
#include "virnetdev.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
|
#include "virstring.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
||||||
|
|
||||||
@ -866,9 +867,7 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virMacAddrFormat(macaddr, vmmacaddr);
|
virMacAddrFormat(macaddr, vmmacaddr);
|
||||||
str_macaddr = strdup(vmmacaddr);
|
if (VIR_STRDUP(str_macaddr, vmmacaddr) < 0) {
|
||||||
if (!str_macaddr) {
|
|
||||||
virReportOOMError();
|
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
}
|
}
|
||||||
|
@ -705,11 +705,8 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
|
|||||||
if (virNWFilterHashTablePutAll(filterparams, ht) < 0)
|
if (virNWFilterHashTablePutAll(filterparams, ht) < 0)
|
||||||
goto err_free_ht;
|
goto err_free_ht;
|
||||||
|
|
||||||
req->filtername = strdup(filtername);
|
if (VIR_STRDUP(req->filtername, filtername) < 0)
|
||||||
if (req->filtername == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto err_free_ht;
|
goto err_free_ht;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStrcpyStatic(req->ifname, ifname) == NULL) {
|
if (virStrcpyStatic(req->ifname, ifname) == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
Loading…
Reference in New Issue
Block a user