Project

General

Profile

Download (9.62 KB) Statistics
| Branch: | Tag: | Revision:
1 94be2ccf Ermal Luçi
<?php
2
/* $Id$ */
3
/*
4
	interfaces_lagg_edit.php
5
6
	Copyright (C) 2008 Ermal Lu?i
7
	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
##|*IDENT=page-interfacess-lagg
36
##|*NAME=Interfaces: LAGG: Edit page
37
##|*DESCR=Edit Interface LAGG
38
##|*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 94be2ccf Ermal Luçi
$id = $_GET['id'];
68
if (isset($_POST['id']))
69
	$id = $_POST['id'];
70
71
if (isset($id) && $a_laggs[$id]) {
72
	$pconfig['laggif'] = $a_laggs[$id]['laggif'];
73
	$pconfig['members'] = $a_laggs[$id]['members'];
74 d1f48a88 Ermal
	$laggiflist = explode(",", $a_laggs[$id]['members']);
75
	foreach ($laggiflist as $tmpif)
76
		unset($realifchecklist[get_real_interface($tmpif)]);
77 94be2ccf Ermal Luçi
	$pconfig['proto'] = $a_laggs[$id]['proto'];
78
	$pconfig['descr'] = $a_laggs[$id]['descr'];
79
}
80
81
if ($_POST) {
82
83
	unset($input_errors);
84
	$pconfig = $_POST;
85
86
	/* input validation */
87
	$reqdfields = explode(" ", "members proto");
88 1634524d Erik Fonnesbeck
	$reqdfieldsn = array(gettext("Member interfaces"), gettext("Lagg protocol"));
89 94be2ccf Ermal Luçi
90
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
91
92 0e22dda5 Ermal
	if (is_array($_POST['members'])) {
93
		foreach ($_POST['members'] as $member) {
94 cdad45cd bcyrill
			if (!does_interface_exist($member))
95 0e22dda5 Ermal
				$input_errors[] = gettext("Interface supplied as member is invalid");
96
		}
97
	} else if (!does_interface_exist($_POST['members']))
98
		$input_errors[] = gettext("Interface supplied as member is invalid");
99
100
	if (!in_array($_POST['proto'], $laggprotos))
101
		$input_errors[] = gettext("Protocol supplied is invalid");
102
103 94be2ccf Ermal Luçi
	if (!$input_errors) {
104
		$lagg = array();
105 6c6a618a Ermal Luçi
		$lagg['members'] = implode(',', $_POST['members']);
106 94be2ccf Ermal Luçi
		$lagg['descr'] = $_POST['descr'];
107
		$lagg['laggif'] = $_POST['laggif'];
108 39fbee97 Ermal Lu?i
		$lagg['proto'] = $_POST['proto'];
109 4f4e85df Ermal
		if (isset($id) && $a_laggs[$id])
110
			$lagg['laggif'] = $a_laggs[$id]['laggif'];
111 94be2ccf Ermal Luçi
112 f5e81794 Renato Botelho
		$lagg['laggif'] = interface_lagg_configure($lagg);
113
		if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
114
			$input_errors[] = gettext("Error occured creating interface, please retry.");
115
		else {
116
			if (isset($id) && $a_laggs[$id])
117
				$a_laggs[$id] = $lagg;
118
			else
119
				$a_laggs[] = $lagg;
120 94be2ccf Ermal Luçi
121 f5e81794 Renato Botelho
			write_config();
122 94be2ccf Ermal Luçi
123 5efc5b6f Ermal Luçi
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
124 f5e81794 Renato Botelho
			if ($confif <> "")
125
				interface_configure($confif);
126 5efc5b6f Ermal Luçi
127 94be2ccf Ermal Luçi
			header("Location: interfaces_lagg.php");
128
			exit;
129
		}
130
	}
131
}
132
133 baca83aa gnhb
$pgtitle = array(gettext("Interfaces"),gettext("LAGG"),gettext("Edit"));
134 b32dd0a6 jim-p
$shortcut_section = "interfaces";
135 94be2ccf Ermal Luçi
include("head.inc");
136
137
?>
138
139
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
140
<?php include("fbegin.inc"); ?>
141
<?php if ($input_errors) print_input_errors($input_errors); ?>
142
            <form action="interfaces_lagg_edit.php" method="post" name="iform" id="iform">
143
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
144
				<tr>
145 4cc39547 Vinicius Coque
					<td colspan="2" valign="top" class="listtopic"><?=gettext("LAGG configuration"); ?></td>
146 ae5b49b1 Scott Ullrich
				</tr>
147
				<tr>
148 f28e93d2 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
149 94be2ccf Ermal Luçi
                  <td width="78%" class="vtable">
150
                    <select name="members[]" multiple="true" size="4" class="formselect">
151
                      <?php
152 f5e81794 Renato Botelho
						foreach ($portlist as $ifn => $ifinfo) {
153 4318cee1 Ermal Luçi
							if (array_key_exists($ifn, $realifchecklist))
154
								continue;
155 94be2ccf Ermal Luçi
							echo "<option value=\"{$ifn}\"";
156
							if (stristr($pconfig['members'], $ifn))
157
								echo "selected";
158 6c6a618a Ermal Luçi
							echo ">". $ifn ."(".$ifinfo['mac'] .")</option>";
159 94be2ccf Ermal Luçi
						}
160 f5e81794 Renato Botelho
				?>
161 94be2ccf Ermal Luçi
                    </select>
162
			<br/>
163 f28e93d2 Carlos Eduardo Ramos
			<span class="vexpl"><?=gettext("Choose the members that will be used for the link aggregation"); ?>.</span></td>
164 94be2ccf Ermal Luçi
                </tr>
165 4318cee1 Ermal Luçi
		<tr>
166 f28e93d2 Carlos Eduardo Ramos
                  <td valign="top" class="vncellreq"><?=gettext("Lag proto"); ?></td>
167 94be2ccf Ermal Luçi
                  <td class="vtable">
168
                    <select name="proto" class="formselect" id="proto">
169
		<?php
170 0e22dda5 Ermal
		foreach ($laggprotos as $proto) {
171 94be2ccf Ermal Luçi
			echo "<option value=\"{$proto}\"";
172
			if ($proto == $pconfig['proto'])
173
				echo "selected";
174
			echo ">".strtoupper($proto)."</option>";
175
		}
176
		?>
177 f5e81794 Renato Botelho
                    </select>
178 94be2ccf Ermal Luçi
                    <br/>
179 0605bbe3 Ermal Luçi
                    <span class="vexpl">
180
		   <ul>
181
		<li>
182 f5e81794 Renato Botelho
		    <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 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("fec"); ?></b><br/>          <?=gettext("Supports Cisco EtherChannel.  This is a static setup and " .
189
                  "does not negotiate aggregation with the peer or exchange " .
190
                  "frames to monitor the link."); ?>
191 0605bbe3 Ermal Luçi
		</li><li>
192 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("lacp"); ?></b><br/>         <?=gettext("Supports the IEEE 802.3ad Link Aggregation Control Protocol " .
193
                  "(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 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("loadbalance"); ?></b><br/>  <?=gettext("Balances outgoing traffic across the active ports based on " .
204
                  "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 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("roundrobin"); ?></b><br/>   <?=gettext("Distributes outgoing traffic using a round-robin scheduler " .
212
                  "through all active ports and accepts incoming traffic from " .
213
                  "any active port"); ?>.
214 0605bbe3 Ermal Luçi
		</li><li>
215 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("none"); ?></b><br/>         <?=gettext("This protocol is intended to do nothing: it disables any " .
216
                  "traffic without disabling the lagg interface itself"); ?>.
217 0605bbe3 Ermal Luçi
		</li>
218
	</ul>
219
	          </span></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
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
225 f28e93d2 Carlos Eduardo Ramos
                    <br> <span class="vexpl"><?=gettext("You may enter a description here " .
226
                    "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 dd5bf424 Scott Ullrich
				    <input type="hidden" name="laggif" value="<?=htmlspecialchars($pconfig['laggif']); ?>">
232 f28e93d2 Carlos Eduardo Ramos
                    <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 225a2f0b Scott Ullrich
                    <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>