From 9ce5cf73253ff0a77b034cf8b6cd4e3896ca248c Mon Sep 17 00:00:00 2001 From: Alexey Andriyanov Date: Sun, 13 Feb 2011 14:49:38 +0000 Subject: [PATCH] r4220 update: 802.1q: fixed pruning of mgmt vlan. produceUplinkPorts: added extra parameter '$object_id', added searchig for mgmt vlans save8021QPorts: added extra parameter to produceUplinkPorts call renderObject8021QPorts: idem exec8021QDeploy: idem recalc8021QPorts: idem, twice --- ChangeLog | 1 + wwwroot/inc/functions.php | 35 +++++++++++++++++++++++++++++++---- wwwroot/inc/interface.php | 2 +- wwwroot/inc/ophandlers.php | 2 +- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9974e4c..97ab6d69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 0.19.1 update: UI: rack lists are now reduced by common tags with object on Rackspace tab (FILTER_RACKLIST_BY_TAGS config var) + update: 802.1q: If switch has IP interface in some VLAN linked to IP subnet, this VLAN is not pruned from switch's uplink 0.19.0 2011-02-12 new feature: IPv6 support, except of LivePTR, NAT and SLB functionality (by Alexey Andriyanov) new feature: cable ID column for links (#328, by Giovani Zamboni and Jens Weibler) diff --git a/wwwroot/inc/functions.php b/wwwroot/inc/functions.php index 8d8f31ee..af266c99 100644 --- a/wwwroot/inc/functions.php +++ b/wwwroot/inc/functions.php @@ -3317,10 +3317,37 @@ function filter8021QChangeRequests } // take port list with order applied and return uplink ports in the same format -function produceUplinkPorts ($domain_vlanlist, $portlist) +function produceUplinkPorts ($domain_vlanlist, $portlist, $object_id) { $ret = array(); $employed = array(); + + // find VLANs for object's L3 allocations + $cell = spotEntity ('object', $object_id); + amplifyCell ($cell); + foreach (array ('ipv4', 'ipv6') as $family) + { + $seen_nets = array(); + foreach ($cell[$family] as $ip => $allocation) + { + if ($family == 'ipv6') + $ip = new IPv6Address ($ip); + if ($net_id = ($family == 'ipv6' ? getIPv6AddressNetworkId ($ip) : getIPv4AddressNetworkId ($ip))) + { + if (! isset($seen_nets[$net_id])) + $seen_nets[$net_id] = 1; + else + continue; + $net = spotEntity ("${family}net", $net_id); + amplifyCell ($net); + foreach ($net['8021q'] as $vlan) + if (! in_array ($vlan['vlan_id'], $employed)) + $employed[] = $vlan['vlan_id']; + + } + } + } + foreach ($domain_vlanlist as $vlan_id => $vlan) if ($vlan['vlan_type'] == 'compulsory') $employed[] = $vlan_id; @@ -3607,7 +3634,7 @@ function exec8021QDeploy ($object_id, $do_push) // Take new "desired" configuration and derive uplink port configuration // from it. Then cancel changes to immune VLANs and save resulting // changes (if any left). - $new_uplinks = filter8021QChangeRequests ($domain_vlanlist, $Dnew, produceUplinkPorts ($domain_vlanlist, $Dnew)); + $new_uplinks = filter8021QChangeRequests ($domain_vlanlist, $Dnew, produceUplinkPorts ($domain_vlanlist, $Dnew, $vswitch['object_id'])); $nsaved_uplinks += replace8021QPorts ('desired', $vswitch['object_id'], $Dnew, $new_uplinks); if ($nsaved + $nsaved_uplinks) { @@ -3844,7 +3871,7 @@ function recalc8021QPorts ($switch_id, $check_only = FALSE) $remote_before = $remote_order; if ($remote_order[$remote_pn]['vst_role'] == 'uplink') { - $remote_uplinks = filter8021QChangeRequests ($remote_domain_vlanlist, $remote_before, produceUplinkPorts ($remote_domain_vlanlist, $remote_order)); + $remote_uplinks = filter8021QChangeRequests ($remote_domain_vlanlist, $remote_before, produceUplinkPorts ($remote_domain_vlanlist, $remote_order, $remote_vswitch['object_id'])); $remote_port_order = $remote_uplinks[$remote_pn]; $new_order = produceDownlinkPort ($domain_vlanlist, $pn, array ($pn => $local_port_order), $remote_port_order); $local_port_order = $new_order[$pn]; // this updates $order @@ -3860,7 +3887,7 @@ function recalc8021QPorts ($switch_id, $check_only = FALSE) } // calculate local uplinks, store changes in $order - foreach (filter8021QChangeRequests ($domain_vlanlist, $before, produceUplinkPorts ($domain_vlanlist, $order)) as $pn => $portorder) + foreach (filter8021QChangeRequests ($domain_vlanlist, $before, produceUplinkPorts ($domain_vlanlist, $order, $vswitch['object_id'])) as $pn => $portorder) $order[$pn] = $portorder; // queue changes in D-config of local switch if ($changed = queueChangesToSwitch ($switch_id, $order, $before, $check_only)) diff --git a/wwwroot/inc/interface.php b/wwwroot/inc/interface.php index 39bb7e76..43275df4 100644 --- a/wwwroot/inc/interface.php +++ b/wwwroot/inc/interface.php @@ -8034,7 +8034,7 @@ function renderObject8021QPorts ($object_id) $desired_config = apply8021QOrder ($vswitch['template_id'], getStored8021QConfig ($object_id, 'desired')); $cached_config = getStored8021QConfig ($object_id, 'cached'); $desired_config = sortPortList ($desired_config); - $uplinks = filter8021QChangeRequests ($vdom['vlanlist'], $desired_config, produceUplinkPorts ($vdom['vlanlist'], $desired_config)); + $uplinks = filter8021QChangeRequests ($vdom['vlanlist'], $desired_config, produceUplinkPorts ($vdom['vlanlist'], $desired_config, $vswitch['object_id'])); echo '
'; // port list echo ''; diff --git a/wwwroot/inc/ophandlers.php b/wwwroot/inc/ophandlers.php index f51b4a21..450e217a 100644 --- a/wwwroot/inc/ophandlers.php +++ b/wwwroot/inc/ophandlers.php @@ -2452,7 +2452,7 @@ function save8021QPorts () $changes = authorize8021QChangeRequests ($before, $changes); foreach ($changes as $port_name => $port) $after[$port_name] = $port; - $new_uplinks = filter8021QChangeRequests ($domain_vlanlist, $after, produceUplinkPorts ($domain_vlanlist, $after)); + $new_uplinks = filter8021QChangeRequests ($domain_vlanlist, $after, produceUplinkPorts ($domain_vlanlist, $after, $vswitch['object_id'])); $npulled = replace8021QPorts ('desired', $vswitch['object_id'], $before, $changes); $nsaved_uplinks = replace8021QPorts ('desired', $vswitch['object_id'], $before, $new_uplinks); } -- 2.25.1