Modify code to have two spaces between functions, follow function more recent function formatting w/r/t args per line and function return type and name on separate lines. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/network/bridge_driver.c | 228 +++++++++++++++++++++++++++++++++----------- 1 file changed, 174 insertions(+), 54 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 3ba7018..e502bfe 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -91,6 +91,7 @@ VIR_LOG_INIT("network.bridge_driver"); static virNetworkDriverStatePtr network_driver; + static virNetworkDriverStatePtr networkGetDriver(void) { @@ -100,15 +101,21 @@ networkGetDriver(void) return network_driver; } -static void networkDriverLock(virNetworkDriverStatePtr driver) + +static void +networkDriverLock(virNetworkDriverStatePtr driver) { virMutexLock(&driver->lock); } -static void networkDriverUnlock(virNetworkDriverStatePtr driver) + + +static void +networkDriverUnlock(virNetworkDriverStatePtr driver) { virMutexUnlock(&driver->lock); } + static dnsmasqCapsPtr networkGetDnsmasqCaps(virNetworkDriverStatePtr driver) { @@ -119,6 +126,7 @@ networkGetDnsmasqCaps(virNetworkDriverStatePtr driver) return ret; } + static int networkDnsmasqCapsRefresh(virNetworkDriverStatePtr driver) { @@ -134,34 +142,50 @@ networkDnsmasqCapsRefresh(virNetworkDriverStatePtr driver) return 0; } -static int networkStateCleanup(void); -static int networkStartNetwork(virNetworkDriverStatePtr driver, - virNetworkObjPtr network); +static int +networkStateCleanup(void); + +static int +networkStartNetwork(virNetworkDriverStatePtr driver, + virNetworkObjPtr network); + +static int +networkShutdownNetwork(virNetworkDriverStatePtr driver, + virNetworkObjPtr network); + +static int +networkStartNetworkVirtual(virNetworkDriverStatePtr driver, + virNetworkObjPtr network); + +static int +networkShutdownNetworkVirtual(virNetworkDriverStatePtr driver, + virNetworkObjPtr network); -static int networkShutdownNetwork(virNetworkDriverStatePtr driver, - virNetworkObjPtr network); +static int +networkStartNetworkExternal(virNetworkObjPtr network); -static int networkStartNetworkVirtual(virNetworkDriverStatePtr driver, - virNetworkObjPtr network); +static int +networkShutdownNetworkExternal(virNetworkObjPtr network); -static int networkShutdownNetworkVirtual(virNetworkDriverStatePtr driver, - virNetworkObjPtr network); +static void +networkReloadFirewallRules(virNetworkDriverStatePtr driver); -static int networkStartNetworkExternal(virNetworkObjPtr network); +static void +networkRefreshDaemons(virNetworkDriverStatePtr driver); -static int networkShutdownNetworkExternal(virNetworkObjPtr network); +static int +networkPlugBandwidth(virNetworkObjPtr net, + virDomainNetDefPtr iface); -static void networkReloadFirewallRules(virNetworkDriverStatePtr driver); -static void networkRefreshDaemons(virNetworkDriverStatePtr driver); +static int +networkUnplugBandwidth(virNetworkObjPtr net, + virDomainNetDefPtr iface); -static int networkPlugBandwidth(virNetworkObjPtr net, - virDomainNetDefPtr iface); -static int networkUnplugBandwidth(virNetworkObjPtr net, - virDomainNetDefPtr iface); +static void +networkNetworkObjTaint(virNetworkObjPtr net, + virNetworkTaintFlags taint); -static void networkNetworkObjTaint(virNetworkObjPtr net, - virNetworkTaintFlags taint); static virNetworkObjPtr networkObjFromNetwork(virNetworkPtr net) @@ -181,6 +205,7 @@ networkObjFromNetwork(virNetworkPtr net) return network; } + static int networkRunHook(virNetworkObjPtr network, virDomainDefPtr dom, @@ -237,6 +262,7 @@ networkRunHook(virNetworkObjPtr network, return ret; } + static char * networkDnsmasqLeaseFileNameDefault(virNetworkDriverStatePtr driver, const char *netname) @@ -248,6 +274,7 @@ networkDnsmasqLeaseFileNameDefault(virNetworkDriverStatePtr driver, return leasefile; } + static char * networkDnsmasqLeaseFileNameCustom(virNetworkDriverStatePtr driver, const char *bridge) @@ -259,6 +286,7 @@ networkDnsmasqLeaseFileNameCustom(virNetworkDriverStatePtr driver, return leasefile; } + static char * networkDnsmasqConfigFileName(virNetworkDriverStatePtr driver, const char *netname) @@ -270,6 +298,7 @@ networkDnsmasqConfigFileName(virNetworkDriverStatePtr driver, return conffile; } + static char * networkRadvdPidfileBasename(const char *netname) { @@ -280,6 +309,7 @@ networkRadvdPidfileBasename(const char *netname) return pidfilebase; } + static char * networkRadvdConfigFileName(virNetworkDriverStatePtr driver, const char *netname) @@ -291,6 +321,7 @@ networkRadvdConfigFileName(virNetworkDriverStatePtr driver, return configfile; } + static char * networkMacMgrFileName(virNetworkDriverStatePtr driver, const char *bridge) @@ -302,6 +333,7 @@ networkMacMgrFileName(virNetworkDriverStatePtr driver, return filename; } + /* do needed cleanup steps and remove the network from the list */ static int networkRemoveInactive(virNetworkDriverStatePtr driver, @@ -379,6 +411,7 @@ networkRemoveInactive(virNetworkDriverStatePtr driver, return ret; } + static int networkMacMgrAdd(virNetworkDriverStatePtr driver, virNetworkObjPtr network, @@ -409,6 +442,7 @@ networkMacMgrAdd(virNetworkDriverStatePtr driver, return ret; } + static int networkMacMgrDel(virNetworkDriverStatePtr driver, virNetworkObjPtr network, @@ -439,6 +473,7 @@ networkMacMgrDel(virNetworkDriverStatePtr driver, return ret; } + static char * networkBridgeDummyNicName(const char *brname) { @@ -463,6 +498,7 @@ networkBridgeDummyNicName(const char *brname) return nicname; } + static int networkUpdateState(virNetworkObjPtr obj, void *opaque) @@ -563,10 +599,12 @@ networkAutostartConfig(virNetworkObjPtr net, return ret; } + #if HAVE_FIREWALLD static DBusHandlerResult firewalld_dbus_filter_bridge(DBusConnection *connection ATTRIBUTE_UNUSED, - DBusMessage *message, void *user_data) + DBusMessage *message, + void *user_data) { virNetworkDriverStatePtr driver = user_data; @@ -583,6 +621,7 @@ firewalld_dbus_filter_bridge(DBusConnection *connection ATTRIBUTE_UNUSED, } #endif + static int networkMigrateStateFiles(virNetworkDriverStatePtr driver) { @@ -668,6 +707,7 @@ networkMigrateStateFiles(virNetworkDriverStatePtr driver) return ret; } + /** * networkStateInitialize: * @@ -813,6 +853,7 @@ networkStateInitialize(bool privileged, goto cleanup; } + /** * networkStateAutoStart: * @@ -829,6 +870,7 @@ networkStateAutoStart(void) network_driver); } + /** * networkStateReload: * @@ -893,7 +935,9 @@ networkStateCleanup(void) * kill the specified pid/name, and wait a bit to make sure it's dead. */ static int -networkKillDaemon(pid_t pid, const char *daemonName, const char *networkName) +networkKillDaemon(pid_t pid, + const char *daemonName, + const char *networkName) { size_t i; int ret = -1; @@ -948,10 +992,10 @@ networkKillDaemon(pid_t pid, const char *daemonName, const char *networkName) return ret; } + /* the following does not build a file, it builds a list * which is later saved into a file */ - static int networkBuildDnsmasqDhcpHostsList(dnsmasqContext *dctx, virNetworkIPDefPtr ipdef) @@ -972,6 +1016,7 @@ networkBuildDnsmasqDhcpHostsList(dnsmasqContext *dctx, return 0; } + static int networkBuildDnsmasqHostsList(dnsmasqContext *dctx, virNetworkDNSDefPtr dnsdef) @@ -1489,6 +1534,7 @@ networkDnsmasqConfContents(virNetworkObjPtr network, return ret; } + /* build the dnsmasq command line */ static int ATTRIBUTE_NONNULL(3) networkBuildDhcpDaemonCommandLine(virNetworkDriverStatePtr driver, @@ -1547,6 +1593,7 @@ networkBuildDhcpDaemonCommandLine(virNetworkDriverStatePtr driver, return ret; } + static int networkStartDhcpDaemon(virNetworkDriverStatePtr driver, virNetworkObjPtr network) @@ -1637,6 +1684,7 @@ networkStartDhcpDaemon(virNetworkDriverStatePtr driver, return ret; } + /* networkRefreshDhcpDaemon: * Update dnsmasq config files, then send a SIGHUP so that it rereads * them. This only works for the dhcp-hostsfile and the @@ -1705,6 +1753,7 @@ networkRefreshDhcpDaemon(virNetworkDriverStatePtr driver, return ret; } + /* networkRestartDhcpDaemon: * * kill and restart dnsmasq, in order to update any config that is on @@ -1726,6 +1775,7 @@ networkRestartDhcpDaemon(virNetworkDriverStatePtr driver, return networkStartDhcpDaemon(driver, network); } + static char radvd1[] = " AdvOtherConfigFlag off;\n\n"; static char radvd2[] = " AdvAutonomous off;\n"; static char radvd3[] = " AdvOnLink on;\n" @@ -1733,7 +1783,8 @@ static char radvd3[] = " AdvOnLink on;\n" " AdvRouterAddr off;\n"; static int -networkRadvdConfContents(virNetworkObjPtr network, char **configstr) +networkRadvdConfContents(virNetworkObjPtr network, + char **configstr) { virBuffer configbuf = VIR_BUFFER_INITIALIZER; int ret = -1; @@ -1810,6 +1861,7 @@ networkRadvdConfContents(virNetworkObjPtr network, char **configstr) return ret; } + /* write file and return its name (which must be freed by caller) */ static int networkRadvdConfWrite(virNetworkDriverStatePtr driver, @@ -1851,6 +1903,7 @@ networkRadvdConfWrite(virNetworkDriverStatePtr driver, return ret; } + static int networkStartRadvd(virNetworkDriverStatePtr driver, virNetworkObjPtr network) @@ -1939,6 +1992,7 @@ networkStartRadvd(virNetworkDriverStatePtr driver, return ret; } + static int networkRefreshRadvd(virNetworkDriverStatePtr driver, virNetworkObjPtr network) @@ -1979,6 +2033,7 @@ networkRefreshRadvd(virNetworkDriverStatePtr driver, return kill(network->radvdPid, SIGHUP); } + #if 0 /* currently unused, so it causes a build error unless we #if it out */ static int @@ -2006,6 +2061,7 @@ networkRestartRadvd(virNetworkObjPtr network) } #endif /* #if 0 */ + static int networkRefreshDaemonsHelper(virNetworkObjPtr net, void *opaque) @@ -2031,6 +2087,7 @@ networkRefreshDaemonsHelper(virNetworkObjPtr net, return 0; } + /* SIGHUP/restart any dnsmasq or radvd daemons. * This should be called when libvirtd is restarted. */ @@ -2043,6 +2100,7 @@ networkRefreshDaemons(virNetworkDriverStatePtr driver) driver); } + static int networkReloadFirewallRulesHelper(virNetworkObjPtr net, void *opaque ATTRIBUTE_UNUSED) @@ -2067,6 +2125,7 @@ networkReloadFirewallRulesHelper(virNetworkObjPtr net, return 0; } + static void networkReloadFirewallRules(virNetworkDriverStatePtr driver) { @@ -2076,9 +2135,11 @@ networkReloadFirewallRules(virNetworkDriverStatePtr driver) NULL); } + /* Enable IP Forwarding. Return 0 for success, -1 for failure. */ static int -networkEnableIPForwarding(bool enableIPv4, bool enableIPv6) +networkEnableIPForwarding(bool enableIPv4, + bool enableIPv6) { int ret = 0; #ifdef HAVE_SYSCTLBYNAME @@ -2099,6 +2160,7 @@ networkEnableIPForwarding(bool enableIPv4, bool enableIPv6) return ret; } + static int networkSetIPv6Sysctls(virNetworkObjPtr network) { @@ -2167,6 +2229,7 @@ networkSetIPv6Sysctls(virNetworkObjPtr network) return ret; } + /* add an IP address to a bridge */ static int networkAddAddrToBridge(virNetworkObjPtr network, @@ -2262,6 +2325,7 @@ networkWaitDadFinish(virNetworkObjPtr network) return ret; } + static int networkStartNetworkVirtual(virNetworkDriverStatePtr driver, virNetworkObjPtr network) @@ -2479,6 +2543,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver, return -1; } + static int networkShutdownNetworkVirtual(virNetworkDriverStatePtr driver, virNetworkObjPtr network) @@ -2543,6 +2608,7 @@ networkStartNetworkBridge(virNetworkObjPtr network) return networkStartHandleMACTableManagerMode(network, NULL); } + static int networkShutdownNetworkBridge(virNetworkObjPtr network ATTRIBUTE_UNUSED) { @@ -2673,7 +2739,9 @@ networkStartNetworkExternal(virNetworkObjPtr network) return networkCreateInterfacePool(network->def); } -static int networkShutdownNetworkExternal(virNetworkObjPtr network ATTRIBUTE_UNUSED) + +static int +networkShutdownNetworkExternal(virNetworkObjPtr network ATTRIBUTE_UNUSED) { /* put anything here that needs to be done each time a network of * type BRIDGE, PRIVATE, VEPA, HOSTDEV or PASSTHROUGH is shutdown. On @@ -2683,6 +2751,7 @@ static int networkShutdownNetworkExternal(virNetworkObjPtr network ATTRIBUTE_UNU return 0; } + static int networkStartNetwork(virNetworkDriverStatePtr driver, virNetworkObjPtr network) @@ -2771,6 +2840,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver, return ret; } + static int networkShutdownNetwork(virNetworkDriverStatePtr driver, virNetworkObjPtr network) @@ -2829,8 +2899,9 @@ networkShutdownNetwork(virNetworkDriverStatePtr driver, } -static virNetworkPtr networkLookupByUUID(virConnectPtr conn, - const unsigned char *uuid) +static virNetworkPtr +networkLookupByUUID(virConnectPtr conn, + const unsigned char *uuid) { virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkObjPtr network; @@ -2856,8 +2927,10 @@ static virNetworkPtr networkLookupByUUID(virConnectPtr conn, return ret; } -static virNetworkPtr networkLookupByName(virConnectPtr conn, - const char *name) + +static virNetworkPtr +networkLookupByName(virConnectPtr conn, + const char *name) { virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkObjPtr network; @@ -2880,7 +2953,9 @@ static virNetworkPtr networkLookupByName(virConnectPtr conn, return ret; } -static int networkConnectNumOfNetworks(virConnectPtr conn) + +static int +networkConnectNumOfNetworks(virConnectPtr conn) { virNetworkDriverStatePtr driver = networkGetDriver(); int nactive; @@ -2896,9 +2971,11 @@ static int networkConnectNumOfNetworks(virConnectPtr conn) return nactive; } -static int networkConnectListNetworks(virConnectPtr conn, - char **const names, - int nnames) + +static int +networkConnectListNetworks(virConnectPtr conn, + char **const names, + int nnames) { virNetworkDriverStatePtr driver = networkGetDriver(); int got = 0; @@ -2914,7 +2991,9 @@ static int networkConnectListNetworks(virConnectPtr conn, return got; } -static int networkConnectNumOfDefinedNetworks(virConnectPtr conn) + +static int +networkConnectNumOfDefinedNetworks(virConnectPtr conn) { virNetworkDriverStatePtr driver = networkGetDriver(); int ninactive = 0; @@ -2930,7 +3009,11 @@ static int networkConnectNumOfDefinedNetworks(virConnectPtr conn) return ninactive; } -static int networkConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) + +static int +networkConnectListDefinedNetworks(virConnectPtr conn, + char **const names, + int nnames) { virNetworkDriverStatePtr driver = networkGetDriver(); int got = 0; @@ -2945,6 +3028,7 @@ static int networkConnectListDefinedNetworks(virConnectPtr conn, char **const na return got; } + static int networkConnectListAllNetworks(virConnectPtr conn, virNetworkPtr **nets, @@ -2966,6 +3050,7 @@ networkConnectListAllNetworks(virConnectPtr conn, return ret; } + static int networkConnectNetworkEventRegisterAny(virConnectPtr conn, virNetworkPtr net, @@ -2989,6 +3074,7 @@ networkConnectNetworkEventRegisterAny(virConnectPtr conn, return ret; } + static int networkConnectNetworkEventDeregisterAny(virConnectPtr conn, int callbackID) @@ -3010,7 +3096,9 @@ networkConnectNetworkEventDeregisterAny(virConnectPtr conn, return ret; } -static int networkIsActive(virNetworkPtr net) + +static int +networkIsActive(virNetworkPtr net) { virNetworkObjPtr obj; int ret = -1; @@ -3028,7 +3116,9 @@ static int networkIsActive(virNetworkPtr net) return ret; } -static int networkIsPersistent(virNetworkPtr net) + +static int +networkIsPersistent(virNetworkPtr net) { virNetworkObjPtr obj; int ret = -1; @@ -3097,7 +3187,6 @@ networkFindUnusedBridgeName(virNetworkObjListPtr nets, } - /* * networkValidateBridgeName() - if no bridge name is set, or if the * bridge name contains a %d (indicating that this is a template for @@ -3408,7 +3497,10 @@ networkValidate(virNetworkDriverStatePtr driver, return 0; } -static virNetworkPtr networkCreateXML(virConnectPtr conn, const char *xml) + +static virNetworkPtr +networkCreateXML(virConnectPtr conn, + const char *xml) { virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkDefPtr def; @@ -3456,7 +3548,10 @@ static virNetworkPtr networkCreateXML(virConnectPtr conn, const char *xml) return ret; } -static virNetworkPtr networkDefineXML(virConnectPtr conn, const char *xml) + +static virNetworkPtr +networkDefineXML(virConnectPtr conn, + const char *xml) { virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkDefPtr def = NULL; @@ -3509,6 +3604,7 @@ static virNetworkPtr networkDefineXML(virConnectPtr conn, const char *xml) return ret; } + static int networkUndefine(virNetworkPtr net) { @@ -3565,6 +3661,7 @@ networkUndefine(virNetworkPtr net) return ret; } + static int networkUpdate(virNetworkPtr net, unsigned int command, @@ -3739,7 +3836,9 @@ networkUpdate(virNetworkPtr net, return ret; } -static int networkCreate(virNetworkPtr net) + +static int +networkCreate(virNetworkPtr net) { virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkObjPtr network; @@ -3767,7 +3866,9 @@ static int networkCreate(virNetworkPtr net) return ret; } -static int networkDestroy(virNetworkPtr net) + +static int +networkDestroy(virNetworkPtr net) { virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkObjPtr network; @@ -3808,8 +3909,10 @@ static int networkDestroy(virNetworkPtr net) return ret; } -static char *networkGetXMLDesc(virNetworkPtr net, - unsigned int flags) + +static char * +networkGetXMLDesc(virNetworkPtr net, + unsigned int flags) { virNetworkObjPtr network; virNetworkDefPtr def; @@ -3835,7 +3938,10 @@ static char *networkGetXMLDesc(virNetworkPtr net, return ret; } -static char *networkGetBridgeName(virNetworkPtr net) { + +static char * +networkGetBridgeName(virNetworkPtr net) +{ virNetworkObjPtr network; char *bridge = NULL; @@ -3859,8 +3965,10 @@ static char *networkGetBridgeName(virNetworkPtr net) { return bridge; } -static int networkGetAutostart(virNetworkPtr net, - int *autostart) + +static int +networkGetAutostart(virNetworkPtr net, + int *autostart) { virNetworkObjPtr network; int ret = -1; @@ -3879,8 +3987,10 @@ static int networkGetAutostart(virNetworkPtr net, return ret; } -static int networkSetAutostart(virNetworkPtr net, - int autostart) + +static int +networkSetAutostart(virNetworkPtr net, + int autostart) { virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkObjPtr network; @@ -3942,6 +4052,7 @@ static int networkSetAutostart(virNetworkPtr net, return ret; } + static int networkGetDHCPLeases(virNetworkPtr network, const char *mac, @@ -4165,7 +4276,8 @@ static virStateDriver networkStateDriver = { .stateReload = networkStateReload, }; -int networkRegister(void) +int +networkRegister(void) { if (virSetSharedNetworkDriver(&networkDriver) < 0) return -1; @@ -4174,6 +4286,7 @@ int networkRegister(void) return 0; } + /********************************************************/ /* A unified function to log network connections and disconnections */ @@ -4211,6 +4324,7 @@ networkLogAllocation(virNetworkDefPtr netdef, } } + /* Private API to deal with logical switch capabilities. * These functions are exported so that other parts of libvirt can * call them, but are not part of the public API and not in the @@ -4639,6 +4753,7 @@ networkAllocateActualDevice(virDomainDefPtr dom, goto cleanup; } + /* networkNotifyActualDevice: * @dom: domain definition that @iface belongs to * @iface: the domain's NetDef with an "actual" device already filled in. @@ -4857,7 +4972,6 @@ networkNotifyActualDevice(virDomainDefPtr dom, } - /* networkReleaseActualDevice: * @dom: domain definition that @iface belongs to * @iface: a domain's NetDef (interface definition) @@ -5001,6 +5115,7 @@ networkReleaseActualDevice(virDomainDefPtr dom, goto cleanup; } + /* * networkGetNetworkAddress: * @netname: the name of a network @@ -5021,7 +5136,8 @@ networkReleaseActualDevice(virDomainDefPtr dom, * completely unsupported. */ int -networkGetNetworkAddress(const char *netname, char **netaddr) +networkGetNetworkAddress(const char *netname, + char **netaddr) { virNetworkDriverStatePtr driver = networkGetDriver(); int ret = -1; @@ -5098,6 +5214,7 @@ networkGetNetworkAddress(const char *netname, char **netaddr) return ret; } + /* networkGetActualType: * @dom: domain definition that @iface belongs to * @iface: the original NetDef from the domain @@ -5260,6 +5377,7 @@ networkCheckBandwidth(virNetworkObjPtr net, return ret; } + /** * networkNextClassID: * @net: network object @@ -5374,6 +5492,7 @@ networkPlugBandwidth(virNetworkObjPtr net, return ret; } + static int networkUnplugBandwidth(virNetworkObjPtr net, virDomainNetDefPtr iface) @@ -5426,6 +5545,7 @@ networkUnplugBandwidth(virNetworkObjPtr net, return ret; } + static void networkNetworkObjTaint(virNetworkObjPtr net, virNetworkTaintFlags taint) -- 2.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list