1 |
94be2ccf
|
Ermal Luçi
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
interfaces_lagg_edit.php
|
5 |
|
|
|
6 |
29aef6c4
|
Jim Thompson
|
Copyright (C) 2013-2014 Electric Sheep Fencing, LP
|
7 |
1d7ba683
|
ayvis
|
Copyright (C) 2008 Ermal Luçi
|
8 |
94be2ccf
|
Ermal Luçi
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
7ac5a4cb
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: interfaces
|
33 |
|
|
*/
|
34 |
|
|
|
35 |
|
|
##|+PRIV
|
36 |
7997ed44
|
Renato Botelho
|
##|*IDENT=page-interfaces-lagg-edit
|
37 |
7ac5a4cb
|
Scott Ullrich
|
##|*NAME=Interfaces: LAGG: Edit page
|
38 |
7997ed44
|
Renato Botelho
|
##|*DESCR=Allow access to the 'Interfaces: LAGG: Edit' page.
|
39 |
7ac5a4cb
|
Scott Ullrich
|
##|*MATCH=interfaces_lagg_edit.php*
|
40 |
|
|
##|-PRIV
|
41 |
94be2ccf
|
Ermal Luçi
|
|
42 |
|
|
require("guiconfig.inc");
|
43 |
|
|
|
44 |
62424bdb
|
Renato Botelho
|
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_lagg.php');
|
45 |
|
|
|
46 |
94be2ccf
|
Ermal Luçi
|
if (!is_array($config['laggs']['lagg']))
|
47 |
|
|
$config['laggs']['lagg'] = array();
|
48 |
|
|
|
49 |
|
|
$a_laggs = &$config['laggs']['lagg'];
|
50 |
|
|
|
51 |
6c6a618a
|
Ermal Luçi
|
$portlist = get_interface_list();
|
52 |
94be2ccf
|
Ermal Luçi
|
|
53 |
0a1eabbe
|
Ermal
|
$realifchecklist = array();
|
54 |
d58d04c3
|
Ermal Luci
|
/* add LAGG interfaces */
|
55 |
|
|
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
|
56 |
f5e81794
|
Renato Botelho
|
foreach ($config['laggs']['lagg'] as $lagg) {
|
57 |
|
|
unset($portlist[$lagg['laggif']]);
|
58 |
0a1eabbe
|
Ermal
|
$laggiflist = explode(",", $lagg['members']);
|
59 |
|
|
foreach ($laggiflist as $tmpif)
|
60 |
|
|
$realifchecklist[get_real_interface($tmpif)] = $tmpif;
|
61 |
|
|
}
|
62 |
d58d04c3
|
Ermal Luci
|
}
|
63 |
|
|
|
64 |
4318cee1
|
Ermal Luçi
|
$checklist = get_configured_interface_list(false, true);
|
65 |
|
|
foreach ($checklist as $tmpif)
|
66 |
85a5da13
|
Ermal Luçi
|
$realifchecklist[get_real_interface($tmpif)] = $tmpif;
|
67 |
4318cee1
|
Ermal Luçi
|
|
68 |
0e22dda5
|
Ermal
|
$laggprotos = array("none", "lacp", "failover", "fec", "loadbalance", "roundrobin");
|
69 |
|
|
|
70 |
e41ec584
|
Renato Botelho
|
if (is_numericint($_GET['id']))
|
71 |
|
|
$id = $_GET['id'];
|
72 |
|
|
if (isset($_POST['id']) && is_numericint($_POST['id']))
|
73 |
94be2ccf
|
Ermal Luçi
|
$id = $_POST['id'];
|
74 |
|
|
|
75 |
|
|
if (isset($id) && $a_laggs[$id]) {
|
76 |
|
|
$pconfig['laggif'] = $a_laggs[$id]['laggif'];
|
77 |
|
|
$pconfig['members'] = $a_laggs[$id]['members'];
|
78 |
d1f48a88
|
Ermal
|
$laggiflist = explode(",", $a_laggs[$id]['members']);
|
79 |
|
|
foreach ($laggiflist as $tmpif)
|
80 |
|
|
unset($realifchecklist[get_real_interface($tmpif)]);
|
81 |
94be2ccf
|
Ermal Luçi
|
$pconfig['proto'] = $a_laggs[$id]['proto'];
|
82 |
|
|
$pconfig['descr'] = $a_laggs[$id]['descr'];
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
if ($_POST) {
|
86 |
|
|
|
87 |
|
|
unset($input_errors);
|
88 |
|
|
$pconfig = $_POST;
|
89 |
|
|
|
90 |
|
|
/* input validation */
|
91 |
|
|
$reqdfields = explode(" ", "members proto");
|
92 |
1634524d
|
Erik Fonnesbeck
|
$reqdfieldsn = array(gettext("Member interfaces"), gettext("Lagg protocol"));
|
93 |
94be2ccf
|
Ermal Luçi
|
|
94 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
95 |
94be2ccf
|
Ermal Luçi
|
|
96 |
0e22dda5
|
Ermal
|
if (is_array($_POST['members'])) {
|
97 |
|
|
foreach ($_POST['members'] as $member) {
|
98 |
cdad45cd
|
bcyrill
|
if (!does_interface_exist($member))
|
99 |
0e22dda5
|
Ermal
|
$input_errors[] = gettext("Interface supplied as member is invalid");
|
100 |
|
|
}
|
101 |
|
|
} else if (!does_interface_exist($_POST['members']))
|
102 |
|
|
$input_errors[] = gettext("Interface supplied as member is invalid");
|
103 |
|
|
|
104 |
|
|
if (!in_array($_POST['proto'], $laggprotos))
|
105 |
|
|
$input_errors[] = gettext("Protocol supplied is invalid");
|
106 |
|
|
|
107 |
94be2ccf
|
Ermal Luçi
|
if (!$input_errors) {
|
108 |
|
|
$lagg = array();
|
109 |
6c6a618a
|
Ermal Luçi
|
$lagg['members'] = implode(',', $_POST['members']);
|
110 |
94be2ccf
|
Ermal Luçi
|
$lagg['descr'] = $_POST['descr'];
|
111 |
|
|
$lagg['laggif'] = $_POST['laggif'];
|
112 |
39fbee97
|
Ermal Lu?i
|
$lagg['proto'] = $_POST['proto'];
|
113 |
4f4e85df
|
Ermal
|
if (isset($id) && $a_laggs[$id])
|
114 |
|
|
$lagg['laggif'] = $a_laggs[$id]['laggif'];
|
115 |
94be2ccf
|
Ermal Luçi
|
|
116 |
f5e81794
|
Renato Botelho
|
$lagg['laggif'] = interface_lagg_configure($lagg);
|
117 |
|
|
if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
|
118 |
ab9dc5be
|
Chris Buechler
|
$input_errors[] = gettext("Error occurred creating interface, please retry.");
|
119 |
f5e81794
|
Renato Botelho
|
else {
|
120 |
|
|
if (isset($id) && $a_laggs[$id])
|
121 |
|
|
$a_laggs[$id] = $lagg;
|
122 |
|
|
else
|
123 |
|
|
$a_laggs[] = $lagg;
|
124 |
94be2ccf
|
Ermal Luçi
|
|
125 |
f5e81794
|
Renato Botelho
|
write_config();
|
126 |
94be2ccf
|
Ermal Luçi
|
|
127 |
5efc5b6f
|
Ermal Luçi
|
$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
|
128 |
f5e81794
|
Renato Botelho
|
if ($confif <> "")
|
129 |
|
|
interface_configure($confif);
|
130 |
5efc5b6f
|
Ermal Luçi
|
|
131 |
94be2ccf
|
Ermal Luçi
|
header("Location: interfaces_lagg.php");
|
132 |
|
|
exit;
|
133 |
|
|
}
|
134 |
|
|
}
|
135 |
|
|
}
|
136 |
|
|
|
137 |
baca83aa
|
gnhb
|
$pgtitle = array(gettext("Interfaces"),gettext("LAGG"),gettext("Edit"));
|
138 |
b32dd0a6
|
jim-p
|
$shortcut_section = "interfaces";
|
139 |
94be2ccf
|
Ermal Luçi
|
include("head.inc");
|
140 |
|
|
|
141 |
|
|
?>
|
142 |
|
|
|
143 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
144 |
|
|
<?php include("fbegin.inc"); ?>
|
145 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
146 |
|
|
<form action="interfaces_lagg_edit.php" method="post" name="iform" id="iform">
|
147 |
4787b359
|
Colin Fleming
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces lagg edit">
|
148 |
94be2ccf
|
Ermal Luçi
|
<tr>
|
149 |
4cc39547
|
Vinicius Coque
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("LAGG configuration"); ?></td>
|
150 |
ae5b49b1
|
Scott Ullrich
|
</tr>
|
151 |
|
|
<tr>
|
152 |
f28e93d2
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
|
153 |
94be2ccf
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
154 |
4787b359
|
Colin Fleming
|
<select name="members[]" multiple="multiple" size="4" class="formselect">
|
155 |
94be2ccf
|
Ermal Luçi
|
<?php
|
156 |
f5e81794
|
Renato Botelho
|
foreach ($portlist as $ifn => $ifinfo) {
|
157 |
4318cee1
|
Ermal Luçi
|
if (array_key_exists($ifn, $realifchecklist))
|
158 |
|
|
continue;
|
159 |
94be2ccf
|
Ermal Luçi
|
echo "<option value=\"{$ifn}\"";
|
160 |
|
|
if (stristr($pconfig['members'], $ifn))
|
161 |
4787b359
|
Colin Fleming
|
echo " selected=\"selected\"";
|
162 |
6c6a618a
|
Ermal Luçi
|
echo ">". $ifn ."(".$ifinfo['mac'] .")</option>";
|
163 |
94be2ccf
|
Ermal Luçi
|
}
|
164 |
f5e81794
|
Renato Botelho
|
?>
|
165 |
94be2ccf
|
Ermal Luçi
|
</select>
|
166 |
1d7ba683
|
ayvis
|
<br />
|
167 |
f28e93d2
|
Carlos Eduardo Ramos
|
<span class="vexpl"><?=gettext("Choose the members that will be used for the link aggregation"); ?>.</span></td>
|
168 |
94be2ccf
|
Ermal Luçi
|
</tr>
|
169 |
4318cee1
|
Ermal Luçi
|
<tr>
|
170 |
f28e93d2
|
Carlos Eduardo Ramos
|
<td valign="top" class="vncellreq"><?=gettext("Lag proto"); ?></td>
|
171 |
94be2ccf
|
Ermal Luçi
|
<td class="vtable">
|
172 |
|
|
<select name="proto" class="formselect" id="proto">
|
173 |
|
|
<?php
|
174 |
0e22dda5
|
Ermal
|
foreach ($laggprotos as $proto) {
|
175 |
94be2ccf
|
Ermal Luçi
|
echo "<option value=\"{$proto}\"";
|
176 |
|
|
if ($proto == $pconfig['proto'])
|
177 |
4787b359
|
Colin Fleming
|
echo " selected=\"selected\"";
|
178 |
94be2ccf
|
Ermal Luçi
|
echo ">".strtoupper($proto)."</option>";
|
179 |
|
|
}
|
180 |
|
|
?>
|
181 |
f5e81794
|
Renato Botelho
|
</select>
|
182 |
1d7ba683
|
ayvis
|
<br />
|
183 |
4787b359
|
Colin Fleming
|
<ul class="vexpl">
|
184 |
0605bbe3
|
Ermal Luçi
|
<li>
|
185 |
1d7ba683
|
ayvis
|
<b><?=gettext("failover"); ?></b><br />
|
186 |
f28e93d2
|
Carlos Eduardo Ramos
|
<?=gettext("Sends and receives traffic only through the master port. If " .
|
187 |
|
|
"the master port becomes unavailable, the next active port is " .
|
188 |
|
|
"used. The first interface added is the master port; any " .
|
189 |
|
|
"interfaces added after that are used as failover devices."); ?>
|
190 |
0605bbe3
|
Ermal Luçi
|
</li><li>
|
191 |
1d7ba683
|
ayvis
|
<b><?=gettext("fec"); ?></b><br /> <?=gettext("Supports Cisco EtherChannel. This is a static setup and " .
|
192 |
f28e93d2
|
Carlos Eduardo Ramos
|
"does not negotiate aggregation with the peer or exchange " .
|
193 |
|
|
"frames to monitor the link."); ?>
|
194 |
0605bbe3
|
Ermal Luçi
|
</li><li>
|
195 |
1d7ba683
|
ayvis
|
<b><?=gettext("lacp"); ?></b><br /> <?=gettext("Supports the IEEE 802.3ad Link Aggregation Control Protocol " .
|
196 |
f28e93d2
|
Carlos Eduardo Ramos
|
"(LACP) and the Marker Protocol. LACP will negotiate a set " .
|
197 |
|
|
"of aggregable links with the peer in to one or more Link " .
|
198 |
|
|
"Aggregated Groups. Each LAG is composed of ports of the " .
|
199 |
|
|
"same speed, set to full-duplex operation. The traffic will " .
|
200 |
|
|
"be balanced across the ports in the LAG with the greatest " .
|
201 |
|
|
"total speed, in most cases there will only be one LAG which " .
|
202 |
|
|
"contains all ports. In the event of changes in physical " .
|
203 |
|
|
"connectivity, Link Aggregation will quickly converge to a " .
|
204 |
|
|
"new configuration."); ?>
|
205 |
0605bbe3
|
Ermal Luçi
|
</li><li>
|
206 |
1d7ba683
|
ayvis
|
<b><?=gettext("loadbalance"); ?></b><br /> <?=gettext("Balances outgoing traffic across the active ports based on " .
|
207 |
f28e93d2
|
Carlos Eduardo Ramos
|
"hashed protocol header information and accepts incoming " .
|
208 |
|
|
"traffic from any active port. This is a static setup and " .
|
209 |
|
|
"does not negotiate aggregation with the peer or exchange " .
|
210 |
|
|
"frames to monitor the link. The hash includes the Ethernet " .
|
211 |
|
|
"source and destination address, and, if available, the VLAN " .
|
212 |
|
|
"tag, and the IP source and destination address") ?>.
|
213 |
0605bbe3
|
Ermal Luçi
|
</li><li>
|
214 |
1d7ba683
|
ayvis
|
<b><?=gettext("roundrobin"); ?></b><br /> <?=gettext("Distributes outgoing traffic using a round-robin scheduler " .
|
215 |
f28e93d2
|
Carlos Eduardo Ramos
|
"through all active ports and accepts incoming traffic from " .
|
216 |
|
|
"any active port"); ?>.
|
217 |
0605bbe3
|
Ermal Luçi
|
</li><li>
|
218 |
1d7ba683
|
ayvis
|
<b><?=gettext("none"); ?></b><br /> <?=gettext("This protocol is intended to do nothing: it disables any " .
|
219 |
f28e93d2
|
Carlos Eduardo Ramos
|
"traffic without disabling the lagg interface itself"); ?>.
|
220 |
0605bbe3
|
Ermal Luçi
|
</li>
|
221 |
|
|
</ul>
|
222 |
4787b359
|
Colin Fleming
|
</td>
|
223 |
94be2ccf
|
Ermal Luçi
|
</tr>
|
224 |
|
|
<tr>
|
225 |
f28e93d2
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
|
226 |
94be2ccf
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
227 |
4787b359
|
Colin Fleming
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
|
228 |
1d7ba683
|
ayvis
|
<br /> <span class="vexpl"><?=gettext("You may enter a description here " .
|
229 |
f28e93d2
|
Carlos Eduardo Ramos
|
"for your reference (not parsed)"); ?>.</span></td>
|
230 |
94be2ccf
|
Ermal Luçi
|
</tr>
|
231 |
|
|
<tr>
|
232 |
|
|
<td width="22%" valign="top"> </td>
|
233 |
|
|
<td width="78%">
|
234 |
4787b359
|
Colin Fleming
|
<input type="hidden" name="laggif" value="<?=htmlspecialchars($pconfig['laggif']); ?>" />
|
235 |
62424bdb
|
Renato Botelho
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
|
236 |
|
|
<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
|
237 |
94be2ccf
|
Ermal Luçi
|
<?php if (isset($id) && $a_laggs[$id]): ?>
|
238 |
4787b359
|
Colin Fleming
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
239 |
94be2ccf
|
Ermal Luçi
|
<?php endif; ?>
|
240 |
|
|
</td>
|
241 |
|
|
</tr>
|
242 |
|
|
</table>
|
243 |
|
|
</form>
|
244 |
|
|
<?php include("fend.inc"); ?>
|
245 |
|
|
</body>
|
246 |
|
|
</html>
|