MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ff_veth_attach

Function ff_veth_attach

lib/ff_veth.c:997–1036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

995}
996
997void *
998ff_veth_attach(struct ff_port_cfg *cfg)
999{
1000 struct ff_veth_softc *sc = NULL;
1001 int error;
1002
1003 sc = malloc(sizeof(struct ff_veth_softc), M_DEVBUF, M_WAITOK);
1004 if (NULL == sc) {
1005 printf("ff_veth_softc allocation failed\n");
1006 goto fail;
1007 }
1008 memset(sc, 0, sizeof(struct ff_veth_softc));
1009
1010 if(cfg->ifname){
1011 snprintf(sc->host_ifname, sizeof(sc->host_ifname), "%s", cfg->ifname);
1012 } else {
1013 snprintf(sc->host_ifname, sizeof(sc->host_ifname), ff_IF_NAME, cfg->port_id);
1014 }
1015
1016 error = ff_veth_config(sc, cfg);
1017 if (0 != error) {
1018 goto fail;
1019 }
1020
1021 if (0 != ff_veth_setup_interface(sc, cfg)) {
1022 goto fail;
1023 }
1024
1025 return sc->host_ctx;
1026
1027fail:
1028 if (sc) {
1029 if (sc->host_ctx)
1030 ff_dpdk_deregister_if(sc->host_ctx);
1031
1032 free(sc, M_DEVBUF);
1033 }
1034
1035 return NULL;
1036}
1037
1038int
1039ff_veth_detach(void *arg)

Callers 1

ff_dpdk_if_upFunction · 0.85

Calls 8

mallocFunction · 0.85
memsetFunction · 0.85
snprintfFunction · 0.85
ff_veth_configFunction · 0.85
ff_veth_setup_interfaceFunction · 0.85
ff_dpdk_deregister_ifFunction · 0.85
printfFunction · 0.70
freeFunction · 0.70

Tested by

no test coverage detected