[libvirt] Re: [PATCH] Add virFileWriteStr()

Mark McLoughlin markmc at redhat.com
Sun Feb 22 11:14:55 UTC 2009


On Fri, 2009-02-13 at 12:06 +0000, Mark McLoughlin wrote:

>  static int
>  networkEnableIpForwarding(void)
>  {
...
> -    return 1;
> -
> -#undef PROC_IP_FORWARD
> +    return virFileWriteStr("/proc/sys/net/ipv4/ip_forward", "1\n");

networkEnableIpForwarding() used to return 1 on success, now it is
returning zero. I'm commiting the change below to fix it.

Cheers,
Mark.

diff --git a/src/network_driver.c b/src/network_driver.c
index b256e3d..3c765c8 100644
--- a/src/network_driver.c
+++ b/src/network_driver.c
@@ -794,7 +794,7 @@ networkRemoveIptablesRules(struct network_driver *driver,
     iptablesSaveRules(driver->iptables);
 }
 
-/* Enable IP Forwarding. Return 0 for success, nonzero for failure. */
+/* Enable IP Forwarding. Return 0 for success, -1 for failure. */
 static int
 networkEnableIpForwarding(void)
 {
@@ -853,7 +853,7 @@ static int networkStartNetworkDaemon(virConnectPtr conn,
         goto err_delbr1;
 
     if (network->def->forwardType != VIR_NETWORK_FORWARD_NONE &&
-        !networkEnableIpForwarding()) {
+        networkEnableIpForwarding() < 0) {
         virReportSystemError(conn, errno, "%s",
                              _("failed to enable IP forwarding"));
         goto err_delbr2;




More information about the libvir-list mailing list