networkReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup)
{
VIR_INFO("Reloading iptables rules");
- if (networkPreReloadFirewallRules(startup) < 0)
- return;
+ networkPreReloadFirewallRules(startup);
virNetworkObjListForEach(driver->networks,
networkReloadFirewallRulesHelper,
NULL);
#define PROC_NET_ROUTE "/proc/net/route"
-int networkPreReloadFirewallRules(bool startup)
+static virErrorPtr errInit;
+
+void networkPreReloadFirewallRules(bool startup)
{
- int ret = iptablesSetupPrivateChains();
- if (ret < 0)
- return -1;
+ int rc;
+
+ /* We create global rules upfront as we don't want
+ * the perf hit of conditionally figuring out whether
+ * to create them each time a network is started.
+ *
+ * Any errors here are saved to be reported at time
+ * of starting the network though as that makes them
+ * more likely to be seen by a human
+ */
+ rc = iptablesSetupPrivateChains();
+ if (rc < 0) {
+ errInit = virSaveLastError();
+ virResetLastError();
+ }
/*
* If this is initial startup, and we just created the
* rules will be present. Thus we can safely just tell it
* to always delete from the builin chain
*/
- if (startup && ret == 1)
+ if (startup && rc == 1)
iptablesSetDeletePrivate(false);
-
- return 0;
}
virFirewallPtr fw = NULL;
int ret = -1;
+ if (errInit) {
+ virSetError(errInit);
+ return -1;
+ }
+
if (def->bridgeZone) {
/* if a firewalld zone has been specified, fail/log an error
typedef struct _virNetworkDriverState virNetworkDriverState;
typedef virNetworkDriverState *virNetworkDriverStatePtr;
-int networkPreReloadFirewallRules(bool startup);
+void networkPreReloadFirewallRules(bool startup);
void networkPostReloadFirewallRules(bool startup);
int networkCheckRouteCollision(virNetworkDefPtr def);