Project

General

Profile

Download (9.4 KB) Statistics
| Branch: | Tag: | Revision:
1 94be2ccf Ermal Luçi
<?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 7ac5a4cb Scott Ullrich
/*
31
	pfSense_MODULE:	interfaces
32
*/
33
34
##|+PRIV
35
##|*IDENT=page-interfacess-lagg
36
##|*NAME=Interfaces: LAGG: Edit page
37
##|*DESCR=Edit Interface LAGG
38
##|*MATCH=interfaces_lagg_edit.php*
39
##|-PRIV
40 94be2ccf Ermal Luçi
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 6c6a618a Ermal Luçi
$portlist = get_interface_list();
49 94be2ccf Ermal Luçi
50 0a1eabbe Ermal
$realifchecklist = array();
51 d58d04c3 Ermal Luci
/* add LAGG interfaces */
52
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
53 0a1eabbe Ermal
        foreach ($config['laggs']['lagg'] as $lagg) {
54 3c692174 Ermal
                unset($portlist[$lagg['laggif']]);
55 0a1eabbe Ermal
		$laggiflist = explode(",", $lagg['members']);
56
		foreach ($laggiflist as $tmpif)
57
			$realifchecklist[get_real_interface($tmpif)] = $tmpif;
58
	}
59 d58d04c3 Ermal Luci
}
60
61 4318cee1 Ermal Luçi
$checklist = get_configured_interface_list(false, true);
62
foreach ($checklist as $tmpif)
63 85a5da13 Ermal Luçi
	$realifchecklist[get_real_interface($tmpif)] = $tmpif;
64 4318cee1 Ermal Luçi
65 94be2ccf Ermal Luçi
$id = $_GET['id'];
66
if (isset($_POST['id']))
67
	$id = $_POST['id'];
68
69
if (isset($id) && $a_laggs[$id]) {
70
	$pconfig['laggif'] = $a_laggs[$id]['laggif'];
71
	$pconfig['members'] = $a_laggs[$id]['members'];
72 d1f48a88 Ermal
	$laggiflist = explode(",", $a_laggs[$id]['members']);
73
	foreach ($laggiflist as $tmpif)
74
		unset($realifchecklist[get_real_interface($tmpif)]);
75 94be2ccf Ermal Luçi
	$pconfig['proto'] = $a_laggs[$id]['proto'];
76
	$pconfig['descr'] = $a_laggs[$id]['descr'];
77
}
78
79
if ($_POST) {
80
81
	unset($input_errors);
82
	$pconfig = $_POST;
83
84
	/* input validation */
85
	$reqdfields = explode(" ", "members proto");
86 1634524d Erik Fonnesbeck
	$reqdfieldsn = array(gettext("Member interfaces"), gettext("Lagg protocol"));
87 94be2ccf Ermal Luçi
88
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
89
90
	if (!$input_errors) {
91
		$lagg = array();
92 6c6a618a Ermal Luçi
		$lagg['members'] = implode(',', $_POST['members']);
93 94be2ccf Ermal Luçi
		$lagg['descr'] = $_POST['descr'];
94
		$lagg['laggif'] = $_POST['laggif'];
95 39fbee97 Ermal Lu?i
		$lagg['proto'] = $_POST['proto'];
96 4f4e85df Ermal
		if (isset($id) && $a_laggs[$id])
97
			$lagg['laggif'] = $a_laggs[$id]['laggif'];
98 94be2ccf Ermal Luçi
99
                $lagg['laggif'] = interface_lagg_configure($lagg);
100
                if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
101 f28e93d2 Carlos Eduardo Ramos
                        $input_errors[] = gettext("Error occured creating interface, please retry.");
102 94be2ccf Ermal Luçi
                else {
103
                        if (isset($id) && $a_laggs[$id])
104
                                $a_laggs[$id] = $lagg;
105
                        else
106
                                $a_laggs[] = $lagg;
107
108
                        write_config();
109
110 5efc5b6f Ermal Luçi
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
111
                        if ($confif <> "")
112 69e5a8be Ermal Luçi
                                interface_configure($confif);
113 5efc5b6f Ermal Luçi
114 94be2ccf Ermal Luçi
			header("Location: interfaces_lagg.php");
115
			exit;
116
		}
117
	}
118
}
119
120 baca83aa gnhb
$pgtitle = array(gettext("Interfaces"),gettext("LAGG"),gettext("Edit"));
121 94be2ccf Ermal Luçi
include("head.inc");
122
123
?>
124
125
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
126
<?php include("fbegin.inc"); ?>
127
<?php if ($input_errors) print_input_errors($input_errors); ?>
128
            <form action="interfaces_lagg_edit.php" method="post" name="iform" id="iform">
129
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
130
				<tr>
131 4cc39547 Vinicius Coque
					<td colspan="2" valign="top" class="listtopic"><?=gettext("LAGG configuration"); ?></td>
132 ae5b49b1 Scott Ullrich
				</tr>
133
				<tr>
134 f28e93d2 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
135 94be2ccf Ermal Luçi
                  <td width="78%" class="vtable">
136
                    <select name="members[]" multiple="true" size="4" class="formselect">
137
                      <?php
138
					  	foreach ($portlist as $ifn => $ifinfo) {
139 4318cee1 Ermal Luçi
							if (array_key_exists($ifn, $realifchecklist))
140
								continue;
141 94be2ccf Ermal Luçi
							echo "<option value=\"{$ifn}\"";
142
							if (stristr($pconfig['members'], $ifn))
143
								echo "selected";
144 6c6a618a Ermal Luçi
							echo ">". $ifn ."(".$ifinfo['mac'] .")</option>";
145 94be2ccf Ermal Luçi
						}
146
		      		?>
147
                    </select>
148
			<br/>
149 f28e93d2 Carlos Eduardo Ramos
			<span class="vexpl"><?=gettext("Choose the members that will be used for the link aggregation"); ?>.</span></td>
150 94be2ccf Ermal Luçi
                </tr>
151 4318cee1 Ermal Luçi
		<tr>
152 f28e93d2 Carlos Eduardo Ramos
                  <td valign="top" class="vncellreq"><?=gettext("Lag proto"); ?></td>
153 94be2ccf Ermal Luçi
                  <td class="vtable">
154
                    <select name="proto" class="formselect" id="proto">
155
		<?php
156
		 foreach (array("none", "lacp", "failover", "fec", "loadbalance", "roundrobin") as $proto) {
157
			echo "<option value=\"{$proto}\"";
158
			if ($proto == $pconfig['proto'])
159
				echo "selected";
160
			echo ">".strtoupper($proto)."</option>";
161
		}
162
		?>
163
                    </select>					
164
                    <br/>
165 0605bbe3 Ermal Luçi
                    <span class="vexpl">
166
		   <ul>
167
		<li>
168 f28e93d2 Carlos Eduardo Ramos
		    <b><?=gettext("failover"); ?></b><br/>      
169
			<?=gettext("Sends and receives traffic only through the master port.  If " .
170
                  "the master port becomes unavailable, the next active port is " .
171
                  "used.  The first interface added is the master port; any " .
172
                  "interfaces added after that are used as failover devices."); ?>
173 0605bbe3 Ermal Luçi
		</li><li>
174 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("fec"); ?></b><br/>          <?=gettext("Supports Cisco EtherChannel.  This is a static setup and " .
175
                  "does not negotiate aggregation with the peer or exchange " .
176
                  "frames to monitor the link."); ?>
177 0605bbe3 Ermal Luçi
		</li><li>
178 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("lacp"); ?></b><br/>         <?=gettext("Supports the IEEE 802.3ad Link Aggregation Control Protocol " .
179
                  "(LACP) and the Marker Protocol.  LACP will negotiate a set " .
180
                  "of aggregable links with the peer in to one or more Link " .
181
                  "Aggregated Groups.  Each LAG is composed of ports of the " .
182
                  "same speed, set to full-duplex operation.  The traffic will " .
183
                  "be balanced across the ports in the LAG with the greatest " .
184
                  "total speed, in most cases there will only be one LAG which " .
185
                  "contains all ports.  In the event of changes in physical " .
186
                  "connectivity, Link Aggregation will quickly converge to a " .
187
                  "new configuration."); ?>
188 0605bbe3 Ermal Luçi
		</li><li>
189 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("loadbalance"); ?></b><br/>  <?=gettext("Balances outgoing traffic across the active ports based on " .
190
                  "hashed protocol header information and accepts incoming " .
191
                  "traffic from any active port.  This is a static setup and " .
192
                  "does not negotiate aggregation with the peer or exchange " .
193
                  "frames to monitor the link.  The hash includes the Ethernet " .
194
                  "source and destination address, and, if available, the VLAN " .
195
                  "tag, and the IP source and destination address") ?>.
196 0605bbe3 Ermal Luçi
		</li><li>
197 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("roundrobin"); ?></b><br/>   <?=gettext("Distributes outgoing traffic using a round-robin scheduler " .
198
                  "through all active ports and accepts incoming traffic from " .
199
                  "any active port"); ?>.
200 0605bbe3 Ermal Luçi
		</li><li>
201 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("none"); ?></b><br/>         <?=gettext("This protocol is intended to do nothing: it disables any " .
202
                  "traffic without disabling the lagg interface itself"); ?>.
203 0605bbe3 Ermal Luçi
		</li>
204
	</ul>
205
	          </span></td>
206 94be2ccf Ermal Luçi
	    </tr>
207
		<tr>
208 f28e93d2 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
209 94be2ccf Ermal Luçi
                  <td width="78%" class="vtable">
210
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
211 f28e93d2 Carlos Eduardo Ramos
                    <br> <span class="vexpl"><?=gettext("You may enter a description here " .
212
                    "for your reference (not parsed)"); ?>.</span></td>
213 94be2ccf Ermal Luçi
                </tr>
214
                <tr>
215
                  <td width="22%" valign="top">&nbsp;</td>
216
                  <td width="78%">
217 dd5bf424 Scott Ullrich
				    <input type="hidden" name="laggif" value="<?=htmlspecialchars($pconfig['laggif']); ?>">
218 f28e93d2 Carlos Eduardo Ramos
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> <input type="button" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
219 94be2ccf Ermal Luçi
                    <?php if (isset($id) && $a_laggs[$id]): ?>
220 225a2f0b Scott Ullrich
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
221 94be2ccf Ermal Luçi
                    <?php endif; ?>
222
                  </td>
223
                </tr>
224
              </table>
225
</form>
226
<?php include("fend.inc"); ?>
227
</body>
228
</html>