Project

General

Profile

Download (8.31 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
		$lagg['proto'] = $_POST['proto'];
79

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

    
89
                        write_config();
90

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

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

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

    
104
?>
105

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