From 77a341a458d604287f46180db1facbdb540cd139 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Fri, 6 Dec 2013 11:39:29 -0200 Subject: [PATCH] Add a knob to prefer IPv4 over IPv6, it fixes #2833 --- etc/inc/util.inc | 10 ++++++++++ etc/rc.bootup | 3 +++ usr/local/www/system_advanced_network.php | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 6e91eb61ab..69fcbf527a 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -2064,4 +2064,14 @@ function get_current_theme() { return $theme; } +/* Define what is preferred, IPv4 or IPv6 */ +function prefer_ipv4_or_ipv6() { + global $config; + + if (isset($config['system']['prefer_ipv4'])) + mwexec("/etc/rc.d/ip6addrctl prefer_ipv4"); + else + mwexec("/etc/rc.d/ip6addrctl prefer_ipv6"); +} + ?> diff --git a/etc/rc.bootup b/etc/rc.bootup index 89a2be722a..f391a27d1c 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -409,6 +409,9 @@ upnp_start(); /* If powerd is enabled, lets launch it */ activate_powerd(); +/* Set preferred protocol */ +prefer_ipv4_or_ipv6(); + /* Remove the old shutdown binary if we kept it. */ if (file_exists("/sbin/shutdown.old")) @unlink("/sbin/shutdown.old"); diff --git a/usr/local/www/system_advanced_network.php b/usr/local/www/system_advanced_network.php index 82b5661c04..28450ad699 100644 --- a/usr/local/www/system_advanced_network.php +++ b/usr/local/www/system_advanced_network.php @@ -51,6 +51,7 @@ require_once("shaper.inc"); $pconfig['ipv6nat_enable'] = isset($config['diag']['ipv6nat']['enable']); $pconfig['ipv6nat_ipaddr'] = $config['diag']['ipv6nat']['ipaddr']; $pconfig['ipv6allow'] = isset($config['system']['ipv6allow']); +$pconfig['prefer_ipv4'] = isset($config['system']['prefer_ipv4']); $pconfig['polling_enable'] = isset($config['system']['polling']); $pconfig['sharednet'] = $config['system']['sharednet']; $pconfig['disablechecksumoffloading'] = isset($config['system']['disablechecksumoffloading']); @@ -88,6 +89,12 @@ if ($_POST) { unset($config['system']['ipv6allow']); } + if($_POST['prefer_ipv4'] == "yes") { + $config['system']['prefer_ipv4'] = true; + } else { + unset($config['system']['prefer_ipv4']); + } + if($_POST['sharednet'] == "yes") { $config['system']['sharednet'] = true; system_disable_arp_wrong_if(); @@ -136,6 +143,9 @@ if ($_POST) { // Configure flowtable support from filter.inc flowtable_configure(); + // Set preferred protocol + prefer_ipv4_or_ipv6(); + $retval = filter_configure(); if(stristr($retval, "error") <> true) $savemsg = get_std_save_message(gettext($retval)); @@ -227,6 +237,16 @@ function enable_change(enable_over) { + + + + /> +
+
+ +