Project

General

Profile

Download (9.92 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / interfaces_lagg_edit.php @ a1b66bec

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-interfaces-lagg-edit
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
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_lagg.php');
44

    
45
if (!is_array($config['laggs']['lagg']))
46
	$config['laggs']['lagg'] = array();
47

    
48
$a_laggs = &$config['laggs']['lagg'];
49

    
50
$portlist = get_interface_list();
51

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

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

    
67
$laggprotos = array("none", "lacp", "failover", "fec", "loadbalance", "roundrobin");
68

    
69
if (is_numericint($_GET['id']))
70
	$id = $_GET['id'];
71
if (isset($_POST['id']) && is_numericint($_POST['id']))
72
	$id = $_POST['id'];
73

    
74
if (isset($id) && $a_laggs[$id]) {
75
	$pconfig['laggif'] = $a_laggs[$id]['laggif'];
76
	$pconfig['members'] = $a_laggs[$id]['members'];
77
	$laggiflist = explode(",", $a_laggs[$id]['members']);
78
	foreach ($laggiflist as $tmpif)
79
		unset($realifchecklist[get_real_interface($tmpif)]);
80
	$pconfig['proto'] = $a_laggs[$id]['proto'];
81
	$pconfig['descr'] = $a_laggs[$id]['descr'];
82
}
83

    
84
if ($_POST) {
85

    
86
	unset($input_errors);
87
	$pconfig = $_POST;
88

    
89
	/* input validation */
90
	$reqdfields = explode(" ", "members proto");
91
	$reqdfieldsn = array(gettext("Member interfaces"), gettext("Lagg protocol"));
92

    
93
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
94

    
95
	if (is_array($_POST['members'])) {
96
		foreach ($_POST['members'] as $member) {
97
			if (!does_interface_exist($member))
98
				$input_errors[] = gettext("Interface supplied as member is invalid");
99
		}
100
	} else if (!does_interface_exist($_POST['members']))
101
		$input_errors[] = gettext("Interface supplied as member is invalid");
102

    
103
	if (!in_array($_POST['proto'], $laggprotos))
104
		$input_errors[] = gettext("Protocol supplied is invalid");
105

    
106
	if (!$input_errors) {
107
		$lagg = array();
108
		$lagg['members'] = implode(',', $_POST['members']);
109
		$lagg['descr'] = $_POST['descr'];
110
		$lagg['laggif'] = $_POST['laggif'];
111
		$lagg['proto'] = $_POST['proto'];
112
		if (isset($id) && $a_laggs[$id])
113
			$lagg['laggif'] = $a_laggs[$id]['laggif'];
114

    
115
		$lagg['laggif'] = interface_lagg_configure($lagg);
116
		if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
117
			$input_errors[] = gettext("Error occurred creating interface, please retry.");
118
		else {
119
			if (isset($id) && $a_laggs[$id])
120
				$a_laggs[$id] = $lagg;
121
			else
122
				$a_laggs[] = $lagg;
123

    
124
			write_config();
125

    
126
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
127
			if ($confif <> "")
128
				interface_configure($confif);
129

    
130
			header("Location: interfaces_lagg.php");
131
			exit;
132
		}
133
	}
134
}
135

    
136
$pgtitle = array(gettext("Interfaces"),gettext("LAGG"),gettext("Edit"));
137
$shortcut_section = "interfaces";
138
include("head.inc");
139

    
140
?>
141

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