Project

General

Profile

Download (9.69 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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
/*
31
	pfSense_MODULE:	interfaces
32
*/
33

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

    
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
$portlist = get_interface_list();
49

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

    
61
$checklist = get_configured_interface_list(false, true);
62
foreach ($checklist as $tmpif)
63
	$realifchecklist[get_real_interface($tmpif)] = $tmpif;
64

    
65
$laggprotos = array("none", "lacp", "failover", "fec", "loadbalance", "roundrobin");
66

    
67
$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
	$laggiflist = explode(",", $a_laggs[$id]['members']);
75
	foreach ($laggiflist as $tmpif)
76
		unset($realifchecklist[get_real_interface($tmpif)]);
77
	$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
	$reqdfieldsn = array(gettext("Member interfaces"), gettext("Lagg protocol"));
89

    
90
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
91

    
92
	if (is_array($_POST['members'])) {
93
		foreach ($_POST['members'] as $member) {
94
			if (!does_interface_exist($member))
95
				$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
	if (!$input_errors) {
104
		$lagg = array();
105
		$lagg['members'] = implode(',', $_POST['members']);
106
		$lagg['descr'] = $_POST['descr'];
107
		$lagg['laggif'] = $_POST['laggif'];
108
		$lagg['proto'] = $_POST['proto'];
109
		if (isset($id) && $a_laggs[$id])
110
			$lagg['laggif'] = $a_laggs[$id]['laggif'];
111

    
112
		$lagg['laggif'] = interface_lagg_configure($lagg);
113
		if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
114
			$input_errors[] = gettext("Error occurred 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

    
121
			write_config();
122

    
123
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
124
			if ($confif <> "")
125
				interface_configure($confif);
126

    
127
			header("Location: interfaces_lagg.php");
128
			exit;
129
		}
130
	}
131
}
132

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