Revision 420dacfe
Added by Kristof Provost over 2 years ago
src/etc/inc/interfaces.inc | ||
---|---|---|
492 | 492 |
return; |
493 | 493 |
} |
494 | 494 |
|
495 |
$fd = fopen("{$g['tmp_path']}/netgraphcmd", "w");
|
|
495 |
exec("/sbin/ifconfig {$vlanif} vlanproto 802.1ad > /dev/null 2>&1");
|
|
496 | 496 |
|
497 |
/* make sure the parent is converted to ng_vlan(4) and is up */
|
|
497 |
/* make sure the parent is up */ |
|
498 | 498 |
interfaces_bring_up($qinqif); |
499 | 499 |
|
500 |
$ngif = str_replace(".", "_", $vlanif); |
|
501 |
if (!empty($vlanif) && does_interface_exist($vlanif)) { |
|
502 |
exec("/usr/sbin/ngctl shutdown {$ngif}qinq: > /dev/null 2>&1"); |
|
503 |
exec("/usr/sbin/ngctl msg {$ngif}qinq: gettable > /dev/null 2>&1", $result); |
|
504 |
if (empty($result)) { |
|
505 |
fwrite($fd, "mkpeer {$ngif}: vlan lower downstream\n"); |
|
506 |
fwrite($fd, "name {$ngif}:lower {$ngif}qinq\n"); |
|
507 |
fwrite($fd, "connect {$ngif}: {$ngif}qinq: upper nomatch\n"); |
|
508 |
} |
|
509 |
} else { |
|
510 |
fwrite($fd, "mkpeer {$ngif}: vlan lower downstream\n"); |
|
511 |
fwrite($fd, "name {$ngif}:lower {$ngif}qinq\n"); |
|
512 |
fwrite($fd, "connect {$ngif}: {$ngif}qinq: upper nomatch\n"); |
|
513 |
} |
|
514 |
|
|
515 | 500 |
/* invalidate interface cache */ |
516 | 501 |
if ($flush) { |
517 | 502 |
get_interface_arr(true); |
... | ... | |
523 | 508 |
|
524 | 509 |
$macaddr = get_interface_mac($qinqif); |
525 | 510 |
if (!empty($qinq['members'])) { |
526 |
$qinqcmdbuf = ""; |
|
527 | 511 |
$members = explode(" ", $qinq['members']); |
528 | 512 |
foreach ($members as $qtag) { |
529 | 513 |
$qinq2 = array(); |
530 | 514 |
$qinq2['tag'] = $qtag; |
531 | 515 |
$qinq2['if'] = $vlanif; |
532 |
interface_qinq2_configure($qinq2, $qinqcmdbuf, $macaddr, |
|
533 |
false); |
|
516 |
interface_qinq2_configure($qinq2, $macaddr); |
|
534 | 517 |
unset($qinq2); |
535 | 518 |
} |
536 |
if (strlen($qinqcmdbuf) > 0) { |
|
537 |
fwrite($fd, $qinqcmdbuf); |
|
538 |
} |
|
539 | 519 |
} |
540 | 520 |
|
541 |
fclose($fd); |
|
542 |
mwexec("/usr/sbin/ngctl -f {$g['tmp_path']}/netgraphcmd > /dev/null 2>&1"); |
|
543 |
|
|
544 | 521 |
interfaces_bring_up($qinqif); |
545 | 522 |
if (!empty($qinq['members'])) { |
546 | 523 |
$members = explode(" ", $qinq['members']); |
... | ... | |
574 | 551 |
} |
575 | 552 |
} |
576 | 553 |
|
577 |
function interface_qinq2_configure(&$qinq, &$cmdbuf, $macaddr, $flush = true) {
|
|
554 |
function interface_qinq2_configure(&$qinq, $macaddr) {
|
|
578 | 555 |
if (!is_array($qinq)) { |
579 | 556 |
log_error(sprintf(gettext("QinQ compat VLAN: called with wrong options. Problems with config!%s"), "\n")); |
580 | 557 |
return; |
... | ... | |
594 | 571 |
return; |
595 | 572 |
} |
596 | 573 |
|
597 |
exec("/usr/sbin/ngctl shutdown {$ngif}h{$tag}: > /dev/null 2>&1"); |
|
598 |
$cmdbuf .= "mkpeer {$ngif}qinq: eiface {$ngif}{$tag} ether\n"; |
|
599 |
$cmdbuf .= "name {$ngif}qinq:{$ngif}{$tag} {$ngif}h{$tag}\n"; |
|
600 |
$cmdbuf .= "msg {$ngif}qinq: addfilter { vlan={$tag} hook=\"{$ngif}{$tag}\" }\n"; |
|
601 |
$cmdbuf .= "msg {$ngif}h{$tag}: setifname \"{$vlanif}\"\n"; |
|
602 |
$cmdbuf .= "msg {$ngif}h{$tag}: set {$macaddr}\n"; |
|
603 |
|
|
604 |
/* invalidate interface cache */ |
|
605 |
if ($flush) { |
|
606 |
get_interface_arr(true); |
|
607 |
} |
|
574 |
exec("/sbin/ifconfig vlan create vlandev {$if} vlan {$tag} name {$vlanif}"); |
|
608 | 575 |
|
609 | 576 |
return $vlanif; |
610 | 577 |
} |
src/usr/local/www/interfaces_qinq.php | ||
---|---|---|
57 | 57 |
if (empty($input_errors)) { |
58 | 58 |
$qinq =& $a_qinqs[$id]; |
59 | 59 |
|
60 |
$ngif = str_replace(".", "_", $qinq['vlanif']); |
|
61 | 60 |
$delmembers = explode(" ", $qinq['members']); |
62 | 61 |
foreach ($delmembers as $tag) { |
63 |
mwexec("/usr/sbin/ngctl shutdown {$ngif}h{$tag}: > /dev/null 2>&1");
|
|
62 |
exec("/sbin/ifconfig {$qinq['vlanif']}.{$tag} destroy");
|
|
64 | 63 |
} |
65 |
mwexec("/usr/sbin/ngctl shutdown {$ngif}qinq: > /dev/null 2>&1"); |
|
66 |
mwexec("/usr/sbin/ngctl shutdown {$ngif}: > /dev/null 2>&1"); |
|
67 | 64 |
pfSense_interface_destroy($qinq['vlanif']); |
68 | 65 |
unset($a_qinqs[$id]); |
69 | 66 |
|
src/usr/local/www/interfaces_qinq_edit.php | ||
---|---|---|
184 | 184 |
$addmembers = array_diff($nmembers, $omembers); |
185 | 185 |
|
186 | 186 |
if ((count($delmembers) > 0) || (count($addmembers) > 0)) { |
187 |
$parent = $qinqentry['vlanif']; |
|
187 | 188 |
foreach ($delmembers as $tag) { |
188 |
$ngif = str_replace(".", "_", $qinqentry['vlanif']); |
|
189 |
exec("/usr/sbin/ngctl shutdown {$ngif}h{$tag}: > /dev/null 2>&1"); |
|
190 |
exec("/usr/sbin/ngctl msg {$ngif}qinq: delfilter \\\"{$ngif}{$tag}\\\" > /dev/null 2>&1"); |
|
189 |
exec("/sbin/ifconfig {$parent}.{$tag} destroy"); |
|
191 | 190 |
} |
192 | 191 |
|
193 |
$qinqcmdbuf = ""; |
|
194 | 192 |
foreach ($addmembers as $member) { |
195 | 193 |
$qinq = array(); |
196 | 194 |
$qinq['if'] = $qinqentry['vlanif']; |
197 | 195 |
$qinq['tag'] = $member; |
198 | 196 |
$macaddr = get_interface_mac($qinqentry['vlanif']); |
199 |
interface_qinq2_configure($qinq, $qinqcmdbuf, $macaddr); |
|
200 |
} |
|
201 |
|
|
202 |
if (strlen($qinqcmdbuf) > 0) { |
|
203 |
$fd = fopen("{$g['tmp_path']}/netgraphcmd", "w"); |
|
204 |
if ($fd) { |
|
205 |
fwrite($fd, $qinqcmdbuf); |
|
206 |
fclose($fd); |
|
207 |
mwexec("/usr/sbin/ngctl -f {$g['tmp_path']}/netgraphcmd > /dev/null 2>&1"); |
|
208 |
} |
|
197 |
interface_qinq2_configure($qinq, $macaddr); |
|
209 | 198 |
} |
210 | 199 |
} |
211 | 200 |
$a_qinqs[$id] = $qinqentry; |
Also available in: Unified diff
qinq: use if_vlan rather than netgraph
if_vlan now supports QinQ, so use that rather than netgraph. This is
expected to perform better, removes a subsystem dependency and
simplifies the php code as well.
Note that this is not possible on stable/12.