Project

General

Profile

Download (9.35 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_lagg_edit.php
5

    
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	Copyright (C) 2008 Ermal Luçi
8
	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
/*
32
	pfSense_MODULE:	interfaces
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-interfaces-lagg-edit
37
##|*NAME=Interfaces: LAGG: Edit page
38
##|*DESCR=Allow access to the 'Interfaces: LAGG: Edit' page.
39
##|*MATCH=interfaces_lagg_edit.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43

    
44
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_lagg.php');
45

    
46
if (!is_array($config['laggs']['lagg'])) {
47
	$config['laggs']['lagg'] = array();
48
}
49

    
50
$a_laggs = &$config['laggs']['lagg'];
51

    
52
$portlist = get_interface_list();
53

    
54
$realifchecklist = array();
55
/* add LAGG interfaces */
56
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
57
	foreach ($config['laggs']['lagg'] as $lagg) {
58
		unset($portlist[$lagg['laggif']]);
59
		$laggiflist = explode(",", $lagg['members']);
60
		foreach ($laggiflist as $tmpif) {
61
			$realifchecklist[get_real_interface($tmpif)] = $tmpif;
62
		}
63
	}
64
}
65

    
66
$checklist = get_configured_interface_list(false, true);
67
foreach ($checklist as $tmpif) {
68
	$realifchecklist[get_real_interface($tmpif)] = $tmpif;
69
}
70

    
71
$laggprotos = array("none", "lacp", "failover", "fec", "loadbalance", "roundrobin");
72

    
73
if (is_numericint($_GET['id'])) {
74
	$id = $_GET['id'];
75
}
76
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
77
	$id = $_POST['id'];
78
}
79

    
80
if (isset($id) && $a_laggs[$id]) {
81
	$pconfig['laggif'] = $a_laggs[$id]['laggif'];
82
	$pconfig['members'] = $a_laggs[$id]['members'];
83
	$laggiflist = explode(",", $a_laggs[$id]['members']);
84
	foreach ($laggiflist as $tmpif) {
85
		unset($realifchecklist[get_real_interface($tmpif)]);
86
	}
87
	$pconfig['proto'] = $a_laggs[$id]['proto'];
88
	$pconfig['descr'] = $a_laggs[$id]['descr'];
89
}
90

    
91
if ($_POST) {
92

    
93
	unset($input_errors);
94
	$pconfig = $_POST;
95

    
96
	/* input validation */
97
	$reqdfields = explode(" ", "members proto");
98
	$reqdfieldsn = array(gettext("Member interfaces"), gettext("Lagg protocol"));
99

    
100
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
101

    
102
	if (is_array($_POST['members'])) {
103
		foreach ($_POST['members'] as $member) {
104
			if (!does_interface_exist($member)) {
105
				$input_errors[] = gettext("Interface supplied as member is invalid");
106
			}
107
		}
108
	} else if (!does_interface_exist($_POST['members'])) {
109
		$input_errors[] = gettext("Interface supplied as member is invalid");
110
	}
111

    
112
	if (!in_array($_POST['proto'], $laggprotos)) {
113
		$input_errors[] = gettext("Protocol supplied is invalid");
114
	}
115

    
116
	if (!$input_errors) {
117
		$lagg = array();
118
		$lagg['members'] = implode(',', $_POST['members']);
119
		$lagg['descr'] = $_POST['descr'];
120
		$lagg['laggif'] = $_POST['laggif'];
121
		$lagg['proto'] = $_POST['proto'];
122
		if (isset($id) && $a_laggs[$id]) {
123
			$lagg['laggif'] = $a_laggs[$id]['laggif'];
124
		}
125

    
126
		$lagg['laggif'] = interface_lagg_configure($lagg);
127
		if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg")) {
128
			$input_errors[] = gettext("Error occurred creating interface, please retry.");
129
		} else {
130
			if (isset($id) && $a_laggs[$id]) {
131
				$a_laggs[$id] = $lagg;
132
			} else {
133
				$a_laggs[] = $lagg;
134
			}
135

    
136
			write_config();
137

    
138
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
139
			if ($confif <> "") {
140
				interface_configure($confif);
141
			}
142

    
143
			header("Location: interfaces_lagg.php");
144
			exit;
145
		}
146
	}
147
}
148

    
149
$pgtitle = array(gettext("Interfaces"), gettext("LAGG"), gettext("Edit"));
150
$shortcut_section = "interfaces";
151
include("head.inc");
152

    
153
?>
154

    
155
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
156
<?php include("fbegin.inc"); ?>
157
<?php if ($input_errors) print_input_errors($input_errors); ?>
158
<form action="interfaces_lagg_edit.php" method="post" name="iform" id="iform">
159
	<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces lagg edit">
160
		<tr>
161
			<td colspan="2" valign="top" class="listtopic"><?=gettext("LAGG configuration"); ?></td>
162
		</tr>
163
		<tr>
164
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
165
			<td width="78%" class="vtable">
166
				<select name="members[]" multiple="multiple" size="4" class="formselect">
167
<?php
168
		foreach ($portlist as $ifn => $ifinfo) {
169
			if (array_key_exists($ifn, $realifchecklist)) {
170
				continue;
171
			}
172
			echo "<option value=\"{$ifn}\"";
173
			if (stristr($pconfig['members'], $ifn)) {
174
				echo " selected=\"selected\"";
175
			}
176
			echo ">". $ifn ."(".$ifinfo['mac'] .")</option>";
177
		}
178
?>
179
				</select>
180
				<br />
181
				<span class="vexpl"><?=gettext("Choose the members that will be used for the link aggregation"); ?>.</span>
182
			</td>
183
		</tr>
184
		<tr>
185
			<td valign="top" class="vncellreq"><?=gettext("Lag proto"); ?></td>
186
			<td class="vtable">
187
				<select name="proto" class="formselect" id="proto">
188
<?php
189
		foreach ($laggprotos as $proto) {
190
			echo "<option value=\"{$proto}\"";
191
			if ($proto == $pconfig['proto']) {
192
				echo " selected=\"selected\"";
193
			}
194
			echo ">".strtoupper($proto)."</option>";
195
		}
196
?>
197
				</select>
198
				<br />
199
				<ul class="vexpl">
200
					<li>
201
						<b><?=gettext("failover"); ?></b><br />
202
						<?=gettext("Sends and receives traffic only through the master port.  If " .
203
						"the master port becomes unavailable, the next active port is " .
204
						"used.  The first interface added is the master port; any " .
205
						"interfaces added after that are used as failover devices."); ?>
206
					</li>
207
					<li>
208
						<b><?=gettext("fec"); ?></b><br />
209
						<?=gettext("Supports Cisco EtherChannel.  This is a static setup and " .
210
						"does not negotiate aggregation with the peer or exchange " .
211
						"frames to monitor the link."); ?>
212
					</li>
213
					<li>
214
						<b><?=gettext("lacp"); ?></b><br />
215
						<?=gettext("Supports the IEEE 802.3ad Link Aggregation Control Protocol " .
216
						"(LACP) and the Marker Protocol.  LACP will negotiate a set " .
217
						"of aggregable links with the peer in to one or more Link " .
218
						"Aggregated Groups.  Each LAG is composed of ports of the " .
219
						"same speed, set to full-duplex operation.  The traffic will " .
220
						"be balanced across the ports in the LAG with the greatest " .
221
						"total speed, in most cases there will only be one LAG which " .
222
						"contains all ports.  In the event of changes in physical " .
223
						"connectivity, Link Aggregation will quickly converge to a " .
224
						"new configuration."); ?>
225
					</li>
226
					<li>
227
						<b><?=gettext("loadbalance"); ?></b><br /> 
228
						<?=gettext("Balances outgoing traffic across the active ports based on " .
229
						"hashed protocol header information and accepts incoming " .
230
						"traffic from any active port.  This is a static setup and " .
231
						"does not negotiate aggregation with the peer or exchange " .
232
						"frames to monitor the link.  The hash includes the Ethernet " .
233
						"source and destination address, and, if available, the VLAN " .
234
						"tag, and the IP source and destination address") ?>.
235
					</li>
236
					<li>
237
						<b><?=gettext("roundrobin"); ?></b><br />
238
						<?=gettext("Distributes outgoing traffic using a round-robin scheduler " .
239
						"through all active ports and accepts incoming traffic from " .
240
						"any active port"); ?>.
241
					</li>
242
					<li>
243
						<b><?=gettext("none"); ?></b><br />
244
						<?=gettext("This protocol is intended to do nothing: it disables any " .
245
						"traffic without disabling the lagg interface itself"); ?>.
246
					</li>
247
				</ul>
248
			</td>
249
		</tr>
250
		<tr>
251
			<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
252
			<td width="78%" class="vtable">
253
				<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
254
				<br />
255
				<span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</span>
256
			</td>
257
		</tr>
258
		<tr>
259
			<td width="22%" valign="top">&nbsp;</td>
260
			<td width="78%">
261
				<input type="hidden" name="laggif" value="<?=htmlspecialchars($pconfig['laggif']); ?>" />
262
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
263
				<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
264
			<?php if (isset($id) && $a_laggs[$id]): ?>
265
				<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
266
			<?php endif; ?>
267
			</td>
268
		</tr>
269
	</table>
270
</form>
271
<?php include("fend.inc"); ?>
272
</body>
273
</html>
(106-106/252)