Skip to content

Commit

Permalink
pmc: Use the proper create/destroy API for network interfaces.
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
  • Loading branch information
richardcochran committed Mar 4, 2020
1 parent 812e0df commit 66dc316
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pmc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ struct pmc {
struct PortIdentity target;

struct transport *transport;
struct interface *iface;
struct fdarray fdarray;
int zero_length_gets;
};
Expand All @@ -322,11 +323,8 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
UInteger8 domain_number, UInteger8 transport_specific,
int zero_datalen)
{
struct interface iface;
struct pmc *pmc;

memset(&iface, 0, sizeof(iface));

pmc = calloc(1, sizeof *pmc);
if (!pmc)
return NULL;
Expand All @@ -350,18 +348,24 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
goto failed;
}

interface_set_name(&iface, iface_name);
interface_ensure_tslabel(&iface);
pmc->iface = interface_create(iface_name);
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)) {
pr_err("failed to open transport");
goto failed;
goto no_trans_open;
}
pmc->zero_length_gets = zero_datalen ? 1 : 0;

return pmc;

no_trans_open:
interface_destroy(pmc->iface);
failed:
if (pmc->transport)
transport_destroy(pmc->transport);
Expand All @@ -372,6 +376,7 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
void pmc_destroy(struct pmc *pmc)
{
transport_close(pmc->transport, &pmc->fdarray);
interface_destroy(pmc->iface);
transport_destroy(pmc->transport);
free(pmc);
}
Expand Down

0 comments on commit 66dc316

Please sign in to comment.