From 070b6f7f55f64ea6c2b495cd708ee730fc09f91c Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Wed, 26 Jul 2017 06:59:19 -0400 Subject: [PATCH] network: Move and rename networkMacMgrFileName Move networkMacMgrFileName into src/util/virmacmap.c and rename to virMacMapFileName. We're about to move some more MacMgr processing files into virnetworkobj and it doesn't make sense to have this helper in the driver or in virnetworkobj. Signed-off-by: John Ferlan --- src/libvirt_private.syms | 1 + src/network/bridge_driver.c | 24 +++++++----------------- src/util/virmacmap.c | 12 ++++++++++++ src/util/virmacmap.h | 4 ++++ 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6e4c3e83b9..d1b0ce5da2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2070,6 +2070,7 @@ virMacAddrSetRaw; # util/virmacmap.h virMacMapAdd; virMacMapDumpStr; +virMacMapFileName; virMacMapLookup; virMacMapNew; virMacMapRemove; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index fd0e6ca29f..de2e83c9f8 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -322,18 +322,6 @@ networkRadvdConfigFileName(virNetworkDriverStatePtr driver, } -static char * -networkMacMgrFileName(virNetworkDriverStatePtr driver, - const char *bridge) -{ - char *filename; - - ignore_value(virAsprintf(&filename, "%s/%s.macs", - driver->dnsmasqStateDir, bridge)); - return filename; -} - - /* do needed cleanup steps and remove the network from the list */ static int networkRemoveInactive(virNetworkDriverStatePtr driver, @@ -375,7 +363,7 @@ networkRemoveInactive(virNetworkDriverStatePtr driver, if (!(statusfile = virNetworkConfigFile(driver->stateDir, def->name))) goto cleanup; - if (!(macMapFile = networkMacMgrFileName(driver, def->bridge))) + if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir, def->bridge))) goto cleanup; /* dnsmasq */ @@ -427,7 +415,7 @@ networkMacMgrAdd(virNetworkDriverStatePtr driver, virMacAddrFormat(mac, macStr); - if (!(file = networkMacMgrFileName(driver, obj->def->bridge))) + if (!(file = virMacMapFileName(driver->dnsmasqStateDir, obj->def->bridge))) goto cleanup; if (virMacMapAdd(obj->macmap, domain, macStr) < 0) @@ -458,7 +446,7 @@ networkMacMgrDel(virNetworkDriverStatePtr driver, virMacAddrFormat(mac, macStr); - if (!(file = networkMacMgrFileName(driver, obj->def->bridge))) + if (!(file = virMacMapFileName(driver->dnsmasqStateDir, obj->def->bridge))) goto cleanup; if (virMacMapRemove(obj->macmap, domain, macStr) < 0) @@ -523,7 +511,8 @@ networkUpdateState(virNetworkObjPtr obj, if (!(obj->def->bridge && virNetDevExists(obj->def->bridge) == 1)) obj->active = 0; - if (!(macMapFile = networkMacMgrFileName(driver, obj->def->bridge))) + if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir, + obj->def->bridge))) goto cleanup; if (!(obj->macmap = virMacMapNew(macMapFile))) @@ -2380,7 +2369,8 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver, } } - if (!(macMapFile = networkMacMgrFileName(driver, obj->def->bridge)) || + if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir, + obj->def->bridge)) || !(obj->macmap = virMacMapNew(macMapFile))) goto err1; diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c index a9697e3d93..42890ba2ff 100644 --- a/src/util/virmacmap.c +++ b/src/util/virmacmap.c @@ -294,6 +294,18 @@ virMacMapWriteFileLocked(virMacMapPtr mgr, } +char * +virMacMapFileName(const char *dnsmasqStateDir, + const char *bridge) +{ + char *filename; + + ignore_value(virAsprintf(&filename, "%s/%s.macs", dnsmasqStateDir, bridge)); + + return filename; +} + + #define VIR_MAC_HASH_TABLE_SIZE 10 virMacMapPtr diff --git a/src/util/virmacmap.h b/src/util/virmacmap.h index 82da833004..e6f754e247 100644 --- a/src/util/virmacmap.h +++ b/src/util/virmacmap.h @@ -27,6 +27,10 @@ typedef struct virMacMap virMacMap; typedef virMacMap *virMacMapPtr; +char * +virMacMapFileName(const char *dnsmasqStateDir, + const char *bridge); + virMacMapPtr virMacMapNew(const char *file); int virMacMapAdd(virMacMapPtr mgr, -- GitLab