Project

General

Profile

Download (10.1 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
if (isset($_POST['referer'])) {
45
	$referer = $_POST['referer'];
46
} else {
47
	$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_lagg.php');
48
}
49

    
50
if (!is_array($config['laggs']['lagg']))
51
	$config['laggs']['lagg'] = array();
52

    
53
$a_laggs = &$config['laggs']['lagg'];
54

    
55
$portlist = get_interface_list();
56

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

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

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

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

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

    
89
if ($_POST) {
90

    
91
	unset($input_errors);
92
	$pconfig = $_POST;
93

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

    
98
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
99

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

    
108
	if (!in_array($_POST['proto'], $laggprotos))
109
		$input_errors[] = gettext("Protocol supplied is invalid");
110

    
111
	if (!$input_errors) {
112
		$lagg = array();
113
		$lagg['members'] = implode(',', $_POST['members']);
114
		$lagg['descr'] = $_POST['descr'];
115
		$lagg['laggif'] = $_POST['laggif'];
116
		$lagg['proto'] = $_POST['proto'];
117
		if (isset($id) && $a_laggs[$id])
118
			$lagg['laggif'] = $a_laggs[$id]['laggif'];
119

    
120
		$lagg['laggif'] = interface_lagg_configure($lagg);
121
		if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
122
			$input_errors[] = gettext("Error occurred creating interface, please retry.");
123
		else {
124
			if (isset($id) && $a_laggs[$id])
125
				$a_laggs[$id] = $lagg;
126
			else
127
				$a_laggs[] = $lagg;
128

    
129
			write_config();
130

    
131
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
132
			if ($confif <> "")
133
				interface_configure($confif);
134

    
135
			header("Location: interfaces_lagg.php");
136
			exit;
137
		}
138
	}
139
}
140

    
141
$pgtitle = array(gettext("Interfaces"),gettext("LAGG"),gettext("Edit"));
142
$shortcut_section = "interfaces";
143
include("head.inc");
144

    
145
?>
146

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