Project

General

Profile

Download (9.32 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 94be2ccf Ermal Luçi
97
                $lagg['laggif'] = interface_lagg_configure($lagg);
98
                if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
99 f28e93d2 Carlos Eduardo Ramos
                        $input_errors[] = gettext("Error occured creating interface, please retry.");
100 94be2ccf Ermal Luçi
                else {
101
                        if (isset($id) && $a_laggs[$id])
102
                                $a_laggs[$id] = $lagg;
103
                        else
104
                                $a_laggs[] = $lagg;
105
106
                        write_config();
107
108 5efc5b6f Ermal Luçi
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
109
                        if ($confif <> "")
110 69e5a8be Ermal Luçi
                                interface_configure($confif);
111 5efc5b6f Ermal Luçi
112 94be2ccf Ermal Luçi
			header("Location: interfaces_lagg.php");
113
			exit;
114
		}
115
	}
116
}
117
118 f6a2c6ab Carlos Eduardo Ramos
$pgtitle = array(gettext("Firewall"),gettext("LAGG"),gettext("Edit"));
119 94be2ccf Ermal Luçi
include("head.inc");
120
121
?>
122
123
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
124
<?php include("fbegin.inc"); ?>
125
<?php if ($input_errors) print_input_errors($input_errors); ?>
126
            <form action="interfaces_lagg_edit.php" method="post" name="iform" id="iform">
127
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
128
				<tr>
129 4cc39547 Vinicius Coque
					<td colspan="2" valign="top" class="listtopic"><?=gettext("LAGG configuration"); ?></td>
130 ae5b49b1 Scott Ullrich
				</tr>
131
				<tr>
132 f28e93d2 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
133 94be2ccf Ermal Luçi
                  <td width="78%" class="vtable">
134
                    <select name="members[]" multiple="true" size="4" class="formselect">
135
                      <?php
136
					  	foreach ($portlist as $ifn => $ifinfo) {
137 4318cee1 Ermal Luçi
							if (array_key_exists($ifn, $realifchecklist))
138
								continue;
139 94be2ccf Ermal Luçi
							echo "<option value=\"{$ifn}\"";
140
							if (stristr($pconfig['members'], $ifn))
141
								echo "selected";
142 6c6a618a Ermal Luçi
							echo ">". $ifn ."(".$ifinfo['mac'] .")</option>";
143 94be2ccf Ermal Luçi
						}
144
		      		?>
145
                    </select>
146
			<br/>
147 f28e93d2 Carlos Eduardo Ramos
			<span class="vexpl"><?=gettext("Choose the members that will be used for the link aggregation"); ?>.</span></td>
148 94be2ccf Ermal Luçi
                </tr>
149 4318cee1 Ermal Luçi
		<tr>
150 f28e93d2 Carlos Eduardo Ramos
                  <td valign="top" class="vncellreq"><?=gettext("Lag proto"); ?></td>
151 94be2ccf Ermal Luçi
                  <td class="vtable">
152
                    <select name="proto" class="formselect" id="proto">
153
		<?php
154
		 foreach (array("none", "lacp", "failover", "fec", "loadbalance", "roundrobin") as $proto) {
155
			echo "<option value=\"{$proto}\"";
156
			if ($proto == $pconfig['proto'])
157
				echo "selected";
158
			echo ">".strtoupper($proto)."</option>";
159
		}
160
		?>
161
                    </select>					
162
                    <br/>
163 0605bbe3 Ermal Luçi
                    <span class="vexpl">
164
		   <ul>
165
		<li>
166 f28e93d2 Carlos Eduardo Ramos
		    <b><?=gettext("failover"); ?></b><br/>      
167
			<?=gettext("Sends and receives traffic only through the master port.  If " .
168
                  "the master port becomes unavailable, the next active port is " .
169
                  "used.  The first interface added is the master port; any " .
170
                  "interfaces added after that are used as failover devices."); ?>
171 0605bbe3 Ermal Luçi
		</li><li>
172 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("fec"); ?></b><br/>          <?=gettext("Supports Cisco EtherChannel.  This is a static setup and " .
173
                  "does not negotiate aggregation with the peer or exchange " .
174
                  "frames to monitor the link."); ?>
175 0605bbe3 Ermal Luçi
		</li><li>
176 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("lacp"); ?></b><br/>         <?=gettext("Supports the IEEE 802.3ad Link Aggregation Control Protocol " .
177
                  "(LACP) and the Marker Protocol.  LACP will negotiate a set " .
178
                  "of aggregable links with the peer in to one or more Link " .
179
                  "Aggregated Groups.  Each LAG is composed of ports of the " .
180
                  "same speed, set to full-duplex operation.  The traffic will " .
181
                  "be balanced across the ports in the LAG with the greatest " .
182
                  "total speed, in most cases there will only be one LAG which " .
183
                  "contains all ports.  In the event of changes in physical " .
184
                  "connectivity, Link Aggregation will quickly converge to a " .
185
                  "new configuration."); ?>
186 0605bbe3 Ermal Luçi
		</li><li>
187 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("loadbalance"); ?></b><br/>  <?=gettext("Balances outgoing traffic across the active ports based on " .
188
                  "hashed protocol header information and accepts incoming " .
189
                  "traffic from any active port.  This is a static setup and " .
190
                  "does not negotiate aggregation with the peer or exchange " .
191
                  "frames to monitor the link.  The hash includes the Ethernet " .
192
                  "source and destination address, and, if available, the VLAN " .
193
                  "tag, and the IP source and destination address") ?>.
194 0605bbe3 Ermal Luçi
		</li><li>
195 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("roundrobin"); ?></b><br/>   <?=gettext("Distributes outgoing traffic using a round-robin scheduler " .
196
                  "through all active ports and accepts incoming traffic from " .
197
                  "any active port"); ?>.
198 0605bbe3 Ermal Luçi
		</li><li>
199 f28e93d2 Carlos Eduardo Ramos
     <b><?=gettext("none"); ?></b><br/>         <?=gettext("This protocol is intended to do nothing: it disables any " .
200
                  "traffic without disabling the lagg interface itself"); ?>.
201 0605bbe3 Ermal Luçi
		</li>
202
	</ul>
203
	          </span></td>
204 94be2ccf Ermal Luçi
	    </tr>
205
		<tr>
206 f28e93d2 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
207 94be2ccf Ermal Luçi
                  <td width="78%" class="vtable">
208
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
209 f28e93d2 Carlos Eduardo Ramos
                    <br> <span class="vexpl"><?=gettext("You may enter a description here " .
210
                    "for your reference (not parsed)"); ?>.</span></td>
211 94be2ccf Ermal Luçi
                </tr>
212
                <tr>
213
                  <td width="22%" valign="top">&nbsp;</td>
214
                  <td width="78%">
215 dd5bf424 Scott Ullrich
				    <input type="hidden" name="laggif" value="<?=htmlspecialchars($pconfig['laggif']); ?>">
216 f28e93d2 Carlos Eduardo Ramos
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> <input type="button" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
217 94be2ccf Ermal Luçi
                    <?php if (isset($id) && $a_laggs[$id]): ?>
218 225a2f0b Scott Ullrich
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
219 94be2ccf Ermal Luçi
                    <?php endif; ?>
220
                  </td>
221
                </tr>
222
              </table>
223
</form>
224
<?php include("fend.inc"); ?>
225
</body>
226
</html>