summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-05-06 13:01:18 -0300
committerRenato Botelho <garga@FreeBSD.org>2013-05-06 13:01:18 -0300
commit02203e6d4aa10f7240f20c3908f8379ec9e24434 (patch)
treef0b660e239389c81a73f0caf0c433fe2c3a14cc9
parent94597308b577d625990785a34a2e4d9fd788bb78 (diff)
downloadpfsense-02203e6d4aa10f7240f20c3908f8379ec9e24434.zip
pfsense-02203e6d4aa10f7240f20c3908f8379ec9e24434.tar.gz
Fix IPv6 Prefix ID default value
. Always initialize it to 0 when it's undefined . Remove unecessary initializations and checks . Bump config version to 9.5 . Write an upgrade config function to initialize old configs properly
-rw-r--r--conf.default/config.xml2
-rw-r--r--etc/inc/globals.inc2
-rw-r--r--etc/inc/interfaces.inc9
-rw-r--r--etc/inc/upgrade_config.inc12
-rwxr-xr-xusr/local/www/interfaces.php41
5 files changed, 31 insertions, 35 deletions
diff --git a/conf.default/config.xml b/conf.default/config.xml
index 9e564ed..71ded00 100644
--- a/conf.default/config.xml
+++ b/conf.default/config.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- pfSense default system configuration -->
<pfsense>
- <version>9.4</version>
+ <version>9.5</version>
<lastchange></lastchange>
<theme>pfsense_ng</theme>
<sysctl>
diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc
index 9267058..79a5964 100644
--- a/etc/inc/globals.inc
+++ b/etc/inc/globals.inc
@@ -71,7 +71,7 @@ $g = array(
"disablecrashreporter" => false,
"crashreporterurl" => "http://crashreporter.pfsense.org/crash_reporter.php",
"debug" => false,
- "latest_config" => "9.4",
+ "latest_config" => "9.5",
"nopkg_platforms" => array("cdrom"),
"minimum_ram_warning" => "101",
"minimum_ram_warning_text" => "128 MB",
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index d497bd9..a618323 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -3141,9 +3141,6 @@ function interface_track6_6rd_configure($interface = "lan", $lancfg) {
if (empty($lancfg['track6-interface']))
return;
- if (!is_numeric($lancfg['track6-prefix-id']))
- $lancfg['track6-prefix-id'] = 0;
-
$wancfg = $config['interfaces'][$lancfg['track6-interface']];
if (empty($wancfg)) {
log_error("Interface {$interface} tracking non-existant interface {$lancfg['track6-interface']}");
@@ -3211,9 +3208,6 @@ function interface_track6_6to4_configure($interface = "lan", $lancfg) {
return;
}
- if (!is_numeric($lancfg['track6-prefix-id']))
- $lancfg['track6-prefix-id'] = 0;
-
$ip4address = get_interface_ip($lancfg['track6-interface']);
if (!is_ipaddrv4($ip4address) || is_private_ip($ip4address)) {
log_error("The interface IPv4 '{$ip4address}' address on interface '{$lancfg['track6-interface']}' is not public, not configuring 6RD tunnel");
@@ -3265,9 +3259,6 @@ function interface_track6_dhcp6_configure($interface = "lan", $lancfg) {
if (empty($lancfg['track6-interface']))
return;
- if (!is_numeric($lancfg['track6-prefix-id']))
- $lancfg['track6-prefix-id'] = 0;
-
$wancfg = $config['interfaces'][$lancfg['track6-interface']];
if (empty($wancfg)) {
log_error("Interface {$interface} tracking non-existant interface {$lancfg['track6-interface']}");
diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc
index b607ab4..c17deee 100644
--- a/etc/inc/upgrade_config.inc
+++ b/etc/inc/upgrade_config.inc
@@ -3074,4 +3074,16 @@ function upgrade_093_to_094() {
}
}
+function upgrade_094_to_095() {
+ global $config;
+
+ if (!isset($config['interfaces']) || !is_array($config['interfaces']))
+ return;
+
+ foreach ($config['interfaces'] as $iface => $cfg)
+ if (isset($cfg['ipaddrv6']) && ($cfg['ipaddrv6'] == "track6"))
+ if (!isset($cfg['track6-prefix-id']) || ($cfg['track6-prefix-id'] == ""))
+ $config['interfaces'][$iface]['track6-prefix-id'] = 0;
+}
+
?>
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php
index 2d402f3..14b3003 100755
--- a/usr/local/www/interfaces.php
+++ b/usr/local/www/interfaces.php
@@ -225,12 +225,11 @@ switch($wancfg['ipaddrv6']) {
case "track6":
$pconfig['type6'] = "track6";
$pconfig['track6-interface'] = $wancfg['track6-interface'];
- $pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
- if ($wancfg['track6-prefix-id'] == "" || $wancfg['track6-prefix-id'] == "none") {
- $pconfig['track6-prefix-id--hex'] = "";
- } else {
- $pconfig['track6-prefix-id--hex'] = sprintf("%x", $wancfg['track6-prefix-id']);
- }
+ if ($wancfg['track6-prefix-id'] == "")
+ $pconfig['track6-prefix-id'] = 0;
+ else
+ $pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
+ $pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
break;
case "6rd":
$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
@@ -402,13 +401,10 @@ if ($_POST['apply']) {
unset($input_errors);
$pconfig = $_POST;
- if ($pconfig['track6-prefix-id--hex'] === "") {
- $pconfig['track6-prefix-id'] = "none";
- } else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
+ if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
- } else {
- $pconfig['track6-prefix-id'] = "none";
- }
+ else
+ $pconfig['track6-prefix-id'] = 0;
conf_mount_rw();
/* filter out spaces from descriptions */
@@ -900,13 +896,12 @@ if ($_POST['apply']) {
case "track6":
$wancfg['ipaddrv6'] = "track6";
$wancfg['track6-interface'] = $_POST['track6-interface'];
- if ($_POST['track6-prefix-id--hex'] === "") {
- $wancfg['track6-prefix-id'] = "none";
- } else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
+ if ($_POST['track6-prefix-id--hex'] === "")
+ $wancfg['track6-prefix-id'] = 0;
+ else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
- } else {
- $wancfg['track6-prefix-id'] = "none";
- }
+ else
+ $wancfg['track6-prefix-id'] = 0;
break;
case "none":
break;
@@ -1894,17 +1889,15 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"),
<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
<td width="78%" class="vtable">
<?php
- if ($pconfig['track6-prefix-id'] == "none" || $pconfig['track6-prefix-id'] == "") {
- $track6_prefix_id_hex = "";
- } else {
- $track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
- }
+ if ($pconfig['track6-prefix-id'] == "")
+ $pconfig['track6-prefix-id'] = 0;
+ $track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
?>
<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
<br />
<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
<br />
- <?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, or leave blank."), 0, $ipv6_num_prefix_ids - 1); ?>
+ <?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, default value is 0."), 0, $ipv6_num_prefix_ids - 1); ?>
</td>
</tr>
<tr>
OpenPOWER on IntegriCloud