Projet

Général

Profil

Télécharger (9,75 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / interfaces_lagg_edit.php @ 7e736f38

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
if (is_numericint($_GET['id']))
68
	$id = $_GET['id'];
69
if (isset($_POST['id']) && is_numericint($_POST['id']))
70
	$id = $_POST['id'];
71

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

    
82
if ($_POST) {
83

    
84
	unset($input_errors);
85
	$pconfig = $_POST;
86

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

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

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

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

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

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

    
122
			write_config();
123

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

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

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

    
138
?>
139

    
140
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
141
<?php include("fbegin.inc"); ?>
142
<?php if ($input_errors) print_input_errors($input_errors); ?>
143
            <form action="interfaces_lagg_edit.php" method="post" name="iform" id="iform">
144
              <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces lagg edit">
145
				<tr>
146
					<td colspan="2" valign="top" class="listtopic"><?=gettext("LAGG configuration"); ?></td>
147
				</tr>
148
				<tr>
149
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
150
                  <td width="78%" class="vtable">
151
                    <select name="members[]" multiple="multiple" size="4" class="formselect">
152
                      <?php
153
						foreach ($portlist as $ifn => $ifinfo) {
154
							if (array_key_exists($ifn, $realifchecklist))
155
								continue;
156
							echo "<option value=\"{$ifn}\"";
157
							if (stristr($pconfig['members'], $ifn))
158
								echo " selected=\"selected\"";
159
							echo ">". $ifn ."(".$ifinfo['mac'] .")</option>";
160
						}
161
				?>
162
                    </select>
163
			<br/>
164
			<span class="vexpl"><?=gettext("Choose the members that will be used for the link aggregation"); ?>.</span></td>
165
                </tr>
166
		<tr>
167
                  <td valign="top" class="vncellreq"><?=gettext("Lag proto"); ?></td>
168
                  <td class="vtable">
169
                    <select name="proto" class="formselect" id="proto">
170
		<?php
171
		foreach ($laggprotos as $proto) {
172
			echo "<option value=\"{$proto}\"";
173
			if ($proto == $pconfig['proto'])
174
				echo " selected=\"selected\"";
175
			echo ">".strtoupper($proto)."</option>";
176
		}
177
		?>
178
                    </select>
179
                    <br/>
180
		   <ul class="vexpl">
181
		<li>
182
		    <b><?=gettext("failover"); ?></b><br/>
183
			<?=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
		</li><li>
188
     <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
		</li><li>
192
     <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
		</li><li>
203
     <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
		</li><li>
211
     <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
		</li><li>
215
     <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
		</li>
218
	</ul>
219
	          </td>
220
	    </tr>
221
		<tr>
222
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
223
                  <td width="78%" class="vtable">
224
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
225
                    <br/> <span class="vexpl"><?=gettext("You may enter a description here " .
226
                    "for your reference (not parsed)"); ?>.</span></td>
227
                </tr>
228
                <tr>
229
                  <td width="22%" valign="top">&nbsp;</td>
230
                  <td width="78%">
231
				    <input type="hidden" name="laggif" value="<?=htmlspecialchars($pconfig['laggif']); ?>" />
232
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> <input type="button" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
233
                    <?php if (isset($id) && $a_laggs[$id]): ?>
234
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
235
                    <?php endif; ?>
236
                  </td>
237
                </tr>
238
              </table>
239
</form>
240
<?php include("fend.inc"); ?>
241
</body>
242
</html>
(104-104/246)