Project

General

Profile

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