pmc: Use the proper create/destroy API for network interfaces.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
master
Richard Cochran 2020-02-10 20:59:21 -08:00
parent 812e0df4b8
commit 66dc3167e3
1 changed files with 12 additions and 7 deletions

View File

@ -313,6 +313,7 @@ struct pmc {
struct PortIdentity target; struct PortIdentity target;
struct transport *transport; struct transport *transport;
struct interface *iface;
struct fdarray fdarray; struct fdarray fdarray;
int zero_length_gets; int zero_length_gets;
}; };
@ -322,11 +323,8 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
UInteger8 domain_number, UInteger8 transport_specific, UInteger8 domain_number, UInteger8 transport_specific,
int zero_datalen) int zero_datalen)
{ {
struct interface iface;
struct pmc *pmc; struct pmc *pmc;
memset(&iface, 0, sizeof(iface));
pmc = calloc(1, sizeof *pmc); pmc = calloc(1, sizeof *pmc);
if (!pmc) if (!pmc)
return NULL; return NULL;
@ -350,18 +348,24 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
goto failed; goto failed;
} }
interface_set_name(&iface, iface_name); pmc->iface = interface_create(iface_name);
interface_ensure_tslabel(&iface); if (!pmc->iface) {
pr_err("failed to create interface");
goto failed;
}
interface_ensure_tslabel(pmc->iface);
if (transport_open(pmc->transport, &iface, if (transport_open(pmc->transport, pmc->iface,
&pmc->fdarray, TS_SOFTWARE)) { &pmc->fdarray, TS_SOFTWARE)) {
pr_err("failed to open transport"); pr_err("failed to open transport");
goto failed; goto no_trans_open;
} }
pmc->zero_length_gets = zero_datalen ? 1 : 0; pmc->zero_length_gets = zero_datalen ? 1 : 0;
return pmc; return pmc;
no_trans_open:
interface_destroy(pmc->iface);
failed: failed:
if (pmc->transport) if (pmc->transport)
transport_destroy(pmc->transport); transport_destroy(pmc->transport);
@ -372,6 +376,7 @@ failed:
void pmc_destroy(struct pmc *pmc) void pmc_destroy(struct pmc *pmc)
{ {
transport_close(pmc->transport, &pmc->fdarray); transport_close(pmc->transport, &pmc->fdarray);
interface_destroy(pmc->iface);
transport_destroy(pmc->transport); transport_destroy(pmc->transport);
free(pmc); free(pmc);
} }