Project

General

Profile

Download (9.4 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
	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

    
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
$portlist = get_interface_list();
49

    
50
$realifchecklist = array();
51
/* add LAGG interfaces */
52
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
53
        foreach ($config['laggs']['lagg'] as $lagg) {
54
                unset($portlist[$lagg['laggif']]);
55
		$laggiflist = explode(",", $lagg['members']);
56
		foreach ($laggiflist as $tmpif)
57
			$realifchecklist[get_real_interface($tmpif)] = $tmpif;
58
	}
59
}
60

    
61
$checklist = get_configured_interface_list(false, true);
62
foreach ($checklist as $tmpif)
63
	$realifchecklist[get_real_interface($tmpif)] = $tmpif;
64

    
65
$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
	$laggiflist = explode(",", $a_laggs[$id]['members']);
73
	foreach ($laggiflist as $tmpif)
74
		unset($realifchecklist[get_real_interface($tmpif)]);
75
	$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
	$reqdfieldsn = array(gettext("Member interfaces"), gettext("Lagg protocol"));
87

    
88
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
89

    
90
	if (!$input_errors) {
91
		$lagg = array();
92
		$lagg['members'] = implode(',', $_POST['members']);
93
		$lagg['descr'] = $_POST['descr'];
94
		$lagg['laggif'] = $_POST['laggif'];
95
		$lagg['proto'] = $_POST['proto'];
96
		if (isset($id) && $a_laggs[$id])
97
			$lagg['laggif'] = $a_laggs[$id]['laggif'];
98

    
99
                $lagg['laggif'] = interface_lagg_configure($lagg);
100
                if ($lagg['laggif'] == "" || !stristr($lagg['laggif'], "lagg"))
101
                        $input_errors[] = gettext("Error occured creating interface, please retry.");
102
                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
			$confif = convert_real_interface_to_friendly_interface_name($lagg['laggif']);
111
                        if ($confif <> "")
112
                                interface_configure($confif);
113

    
114
			header("Location: interfaces_lagg.php");
115
			exit;
116
		}
117
	}
118
}
119

    
120
$pgtitle = array(gettext("Interfaces"),gettext("LAGG"),gettext("Edit"));
121
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
					<td colspan="2" valign="top" class="listtopic"><?=gettext("LAGG configuration"); ?></td>
132
				</tr>
133
				<tr>
134
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Parent interface"); ?></td>
135
                  <td width="78%" class="vtable">
136
                    <select name="members[]" multiple="true" size="4" class="formselect">
137
                      <?php
138
					  	foreach ($portlist as $ifn => $ifinfo) {
139
							if (array_key_exists($ifn, $realifchecklist))
140
								continue;
141
							echo "<option value=\"{$ifn}\"";
142
							if (stristr($pconfig['members'], $ifn))
143
								echo "selected";
144
							echo ">". $ifn ."(".$ifinfo['mac'] .")</option>";
145
						}
146
		      		?>
147
                    </select>
148
			<br/>
149
			<span class="vexpl"><?=gettext("Choose the members that will be used for the link aggregation"); ?>.</span></td>
150
                </tr>
151
		<tr>
152
                  <td valign="top" class="vncellreq"><?=gettext("Lag proto"); ?></td>
153
                  <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
                    <span class="vexpl">
166
		   <ul>
167
		<li>
168
		    <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
		</li><li>
174
     <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
		</li><li>
178
     <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
		</li><li>
189
     <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
		</li><li>
197
     <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
		</li><li>
201
     <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
		</li>
204
	</ul>
205
	          </span></td>
206
	    </tr>
207
		<tr>
208
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
209
                  <td width="78%" class="vtable">
210
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
211
                    <br> <span class="vexpl"><?=gettext("You may enter a description here " .
212
                    "for your reference (not parsed)"); ?>.</span></td>
213
                </tr>
214
                <tr>
215
                  <td width="22%" valign="top">&nbsp;</td>
216
                  <td width="78%">
217
				    <input type="hidden" name="laggif" value="<?=htmlspecialchars($pconfig['laggif']); ?>">
218
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> <input type="button" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
219
                    <?php if (isset($id) && $a_laggs[$id]): ?>
220
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
221
                    <?php endif; ?>
222
                  </td>
223
                </tr>
224
              </table>
225
</form>
226
<?php include("fend.inc"); ?>
227
</body>
228
</html>
(95-95/225)