Project

General

Profile

Download (8.27 KB) Statistics
| Branch: | Tag: | Revision:
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
require("guiconfig.inc");
32

    
33
if (!is_array($config['laggs']['lagg']))
34
	$config['laggs']['lagg'] = array();
35

    
36
$a_laggs = &$config['laggs']['lagg'];
37

    
38
$portlist = get_interface_list();
39

    
40
/* add LAGG interfaces */
41
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
42
        foreach ($config['laggs']['lagg'] as $lagg)
43
                $portlist[$lagg['laggif']] = $lagg;
44
}
45

    
46
$checklist = get_configured_interface_list(false, true);
47
$realifchecklist = array();
48
foreach ($checklist as $tmpif)
49
	$realifchecklist[get_real_interface($tmpif)] = $tmpif;
50

    
51
$id = $_GET['id'];
52
if (isset($_POST['id']))
53
	$id = $_POST['id'];
54

    
55
if (isset($id) && $a_laggs[$id]) {
56
	$pconfig['laggif'] = $a_laggs[$id]['laggif'];
57
	$pconfig['members'] = $a_laggs[$id]['members'];
58
	$pconfig['proto'] = $a_laggs[$id]['proto'];
59
	$pconfig['descr'] = $a_laggs[$id]['descr'];
60
}
61

    
62
if ($_POST) {
63

    
64
	unset($input_errors);
65
	$pconfig = $_POST;
66

    
67
	/* input validation */
68
	$reqdfields = explode(" ", "members proto");
69
	$reqdfieldsn = explode(",", "Member interfaces, Lagg protocol");
70

    
71
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
72

    
73
	if (!$input_errors) {
74
		$lagg = array();
75
		$lagg['members'] = implode(',', $_POST['members']);
76
		$lagg['descr'] = $_POST['descr'];
77
		$lagg['laggif'] = $_POST['laggif'];
78

    
79
                $lagg['laggif'] = interface_lagg_configure($lagg);
80
                if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
81
                        $input_errors[] = "Error occured creating interface, please retry.";
82
                else {
83
                        if (isset($id) && $a_laggs[$id])
84
                                $a_laggs[$id] = $lagg;
85
                        else
86
                                $a_laggs[] = $lagg;
87

    
88
                        write_config();
89

    
90
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
91
                        if ($confif <> "")
92
                                interface_configure($confif);
93

    
94
			header("Location: interfaces_lagg.php");
95
			exit;
96
		}
97
	}
98
}
99

    
100
$pgtitle = array("Firewall","LAGG","Edit");
101
include("head.inc");
102

    
103
?>
104

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