/** * virNetDevVethDelete: * @veth: name for one end of veth pair * * This will delete both veth devices in a pair. Only one end needs to * be specified. The ip command will identify and delete the other veth * device as well. * ip link del veth * * Returns 0 on success or -1 in case of error */ int virNetDevVethDelete(const char *veth) { virCommandPtr cmd = virCommandNewArgList("ip", "link", "del", veth, NULL); int status; int ret = -1; if (virCommandRun(cmd, &status) < 0) goto cleanup; if (status != 0) { if (!virNetDevExists(veth)) { VIR_DEBUG("Device %s already deleted (by kernel namespace cleanup)", veth); ret = 0; goto cleanup; } virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to delete veth device %s"), veth); goto cleanup; } ret = 0; cleanup: virCommandFree(cmd); return ret; }
int virNWFilterTerminateLearnReq(const char *ifname) { int rc = -1; int ifindex; virNWFilterIPAddrLearnReqPtr req; /* It's possible that it's already been removed as a result of * virNWFilterDeregisterLearnReq during learnIPAddressThread() exit */ if (virNetDevExists(ifname) != 1) { virResetLastError(); return 0; } if (virNetDevGetIndex(ifname, &ifindex) < 0) { virResetLastError(); return rc; } IFINDEX2STR(ifindex_str, ifindex); virMutexLock(&pendingLearnReqLock); req = virHashLookup(pendingLearnReq, ifindex_str); if (req) { rc = 0; req->terminate = true; } virMutexUnlock(&pendingLearnReqLock); return rc; }