migrate kernel parameters to a static sysctl.conf file and the special proxy0 device...
[nodeconfig.git] / PlanetLabConf / sysctl-ip_forward.php
diff --git a/PlanetLabConf/sysctl-ip_forward.php b/PlanetLabConf/sysctl-ip_forward.php
new file mode 100755 (executable)
index 0000000..1cc7e5b
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+//
+// $Id$
+//
+
+// Get admin API handle
+require_once 'plc_api.php';
+global $adm;
+
+$ip_forward = 0;
+
+// Look up the node
+// backwards compatibility with the old 4.2 API
+global $__PLC_API_VERSION;
+if ( ! method_exists ($adm,"GetInterfaces"))
+  $__PLC_API_VERSION = 4.2;
+else
+  $__PLC_API_VERSION = 4.3;
+
+if ($__PLC_API_VERSION==4.2)
+  $interfaces = $adm->GetNodeNetworks(array('ip' => $_SERVER['REMOTE_ADDR']));
+else
+  $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
+
+if (!empty($interfaces)) {
+  $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
+  if (!empty($nodes)) {
+    $node = $nodes[0];
+    if ($__PLC_API_VERSION==4.2)
+      $interfaces = $adm->GetInterfaces($node['nodenetwork_ids']);
+    else
+      $interfaces = $adm->GetInterfaces($node['interface_ids']);
+
+    foreach ($interfaces as $interface) {
+      // Nodes with proxy socket interfaces need to be able to forward
+      // between the fake proxy0 interface and the real interface.
+      if ($interface['method'] == 'proxy') {
+       $ip_forward = 1;
+       break;
+      }
+    }
+  }
+}
+
+?>
+
+# $Id$
+#
+# sysctl configuration file to optionally enable/disable IP forwarding
+#
+# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
+# sysctl.conf(5) for more details.
+#
+# This file is generated by NodeManager Configuration Files... 
+# do not manually edit
+#
+
+# Controls IP packet forwarding
+net.ipv4.ip_forward = <?php echo $ip_forward; ?>