Project

General

Profile

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