Project

General

Profile

Bug #14083 ยป diff.txt

patch - Marcos M, 05/11/2024 12:11 AM

 
1
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc
2
index 67aa569c3f..d2a5b5bcc8 100644
3
--- a/src/etc/inc/interfaces.inc
4
+++ b/src/etc/inc/interfaces.inc
5
@@ -341,12 +341,18 @@ function interface_has_clones($if) {
6
 	return (FALSE);
7
 }
8
 
9
-function interfaces_vlan_configure($parentif = "") {
10
+/**
11
+ * Configure the child VLAN interfaces for a parent interface.
12
+ * 
13
+ * @param bool $skip_parent_mtu Skip setting the parent interface's MTU
14
+ */
15
+function interfaces_vlan_configure($parentif = "", $skip_parent_mtu = false) {
16
 	$dhcp6c_list = array();
17
 
18
 	$vlans = config_get_path('vlans/vlan');
19
 	if (is_array($vlans) && count($vlans)) {
20
-		if (platform_booting()) {
21
+		if (platform_booting() && !$skip_parent_mtu) {
22
+			// Shows this only once while a parent interface is already being configured
23
 			echo gettext("Configuring VLAN interfaces...");
24
 		}
25
 		foreach ($vlans as $vlan) {
26
@@ -365,20 +371,26 @@ function interfaces_vlan_configure($parentif = "") {
27
 			}
28
 
29
 			/* XXX: Maybe we should report any errors?! */
30
-			interface_vlan_configure($vlan, false);
31
+			interface_vlan_configure($vlan, false, $skip_parent_mtu);
32
 		}
33
 		foreach ($dhcp6c_list as $if => $vlan) {
34
-			interface_vlan_configure($vlan, false);
35
+			interface_vlan_configure($vlan, false, $skip_parent_mtu);
36
 		}
37
 		/* Invalidate cache */
38
 		get_interface_arr(true);
39
-		if (platform_booting()) {
40
+		if (platform_booting() && !$skip_parent_mtu) {
41
+			// Shows this only once while a parent interface is already being configured
42
 			echo gettext("done.") . "\n";
43
 		}
44
 	}
45
 }
46
 
47
-function interface_vlan_configure(&$vlan, $flush = true) {
48
+/**
49
+ * Configure a VLAN interface.
50
+ * 
51
+ * @param bool $skip_parent_mtu Skip setting the parent interface's MTU
52
+ */
53
+function interface_vlan_configure(&$vlan, $flush = true, $skip_parent_mtu = false) {
54
 	if (!is_array($vlan)) {
55
 		log_error(gettext("VLAN: called with wrong options. Problems with config!"));
56
 		return(NULL);
57
@@ -450,7 +462,7 @@ function interface_vlan_configure(&$vlan, $flush = true) {
58
 	$assignedif = convert_real_interface_to_friendly_interface_name($vlanif);
59
 	if ($assignedif) {
60
 		if (config_path_enabled("interfaces/{$assignedif}")) {
61
-			interface_configure($assignedif, true);
62
+			interface_configure($assignedif, true, false, $skip_parent_mtu);
63
 		}
64
 	}
65
 
66
@@ -998,7 +1010,7 @@ function interface_lagg_configure($lagg, $flush = true) {
67
 	if ($lagg_mtu == 0) {
68
 		foreach (config_get_path('interfaces', []) as $tmpinterface) {
69
 			if ($tmpinterface['if'] == $lagg['laggif'] &&
70
-			    !empty($tmpinterface['mtu'])) {
71
+			    isset($tmpinterface['enable']) && !empty($tmpinterface['mtu'])) {
72
 				$lagg_mtu = $tmpinterface['mtu'];
73
 				break;
74
 			}
75
@@ -1055,7 +1067,7 @@ function interface_lagg_configure($lagg, $flush = true) {
76
 
77
 	interfaces_bring_up($laggif);
78
 	// after the lagg is recreated, its VLANs must be reconfigured
79
-	interfaces_vlan_configure($laggif);
80
+	interfaces_vlan_configure($laggif, true);
81
 
82
 	return $laggif;
83
 }
84
@@ -4014,7 +4026,12 @@ function interface_mtu_wanted_for_pppoe($realif) {
85
 	return $mtu;
86
 }
87
 
88
-function interface_configure($interface = "wan", $reloadall = false, $linkupevent = false) {
89
+/**
90
+ * Applies the configured settings for an interface.
91
+ * 
92
+ * @param bool $skip_parent_mtu Skip setting the parent interface's MTU
93
+ */
94
+function interface_configure($interface = "wan", $reloadall = false, $linkupevent = false, $skip_parent_mtu = false) {
95
 	global $g;
96
 	global $interface_sn_arr_cache, $interface_ip_arr_cache;
97
 	global $interface_snv6_arr_cache, $interface_ipv6_arr_cache;
98
@@ -4215,8 +4232,9 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
99
 		else
100
 			$mtu = $wantedmtu;
101
 
102
-		/* Set the parent MTU. */
103
-		if (get_interface_mtu($mtuhwif) < $mtu)
104
+		/* Set the parent MTU. Avoid looping when a parent lagg interface
105
+		   is being configured - see #14083 */
106
+		if ((get_interface_mtu($mtuhwif) < $mtu) && !$skip_parent_mtu)
107
 			set_interface_mtu($mtuhwif, $mtu);
108
 		/* Set the VLAN MTU. */
109
 		if (get_interface_mtu($mtuif) != $mtu)
    (1-1/1)