| 1 |
|
| # SNMP::Info::Layer3::Extreme - SNMP Interface to Extreme devices |
| 2 |
|
| # |
| 3 |
|
| # Copyright (c) 2012 Eric Miller |
| 4 |
|
| # |
| 5 |
|
| # Copyright (c) 2002,2003 Regents of the University of California |
| 6 |
|
| # All rights reserved. |
| 7 |
|
| # |
| 8 |
|
| # Redistribution and use in source and binary forms, with or without |
| 9 |
|
| # modification, are permitted provided that the following conditions are met: |
| 10 |
|
| # |
| 11 |
|
| # * Redistributions of source code must retain the above copyright notice, |
| 12 |
|
| # this list of conditions and the following disclaimer. |
| 13 |
|
| # * Redistributions in binary form must reproduce the above copyright |
| 14 |
|
| # notice, this list of conditions and the following disclaimer in the |
| 15 |
|
| # documentation and/or other materials provided with the distribution. |
| 16 |
|
| # * Neither the name of the University of California, Santa Cruz nor the |
| 17 |
|
| # names of its contributors may be used to endorse or promote products |
| 18 |
|
| # derived from this software without specific prior written permission. |
| 19 |
|
| # |
| 20 |
|
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 21 |
|
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 |
|
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 |
|
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 24 |
|
| # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 25 |
|
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 26 |
|
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 27 |
|
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 28 |
|
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 29 |
|
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 30 |
|
| # POSSIBILITY OF SUCH DAMAGE. |
| 31 |
|
| |
| 32 |
|
| package SNMP::Info::Layer3::Extreme; |
| 33 |
|
| |
| 34 |
|
| use strict; |
| 35 |
|
| use warnings; |
| 36 |
|
| use Exporter; |
| 37 |
|
| use SNMP::Info::Layer3; |
| 38 |
|
| use SNMP::Info::MAU; |
| 39 |
|
| use SNMP::Info::EDP; |
| 40 |
|
| |
| 41 |
|
| @SNMP::Info::Layer3::Extreme::ISA |
| 42 |
|
| = qw/SNMP::Info::Layer3 SNMP::Info::MAU |
| 43 |
|
| SNMP::Info::EDP Exporter/; |
| 44 |
|
| @SNMP::Info::Layer3::Extreme::EXPORT_OK = qw//; |
| 45 |
|
| |
| 46 |
|
| our ($VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE); |
| 47 |
|
| |
| 48 |
|
| $VERSION = '3.985003'; |
| 49 |
|
| |
| 50 |
|
| %MIBS = ( |
| 51 |
|
| %SNMP::Info::Layer3::MIBS, |
| 52 |
|
| %SNMP::Info::MAU::MIBS, |
| 53 |
|
| %SNMP::Info::EDP::MIBS, |
| 54 |
|
| 'EXTREME-BASE-MIB' => 'extremeAgent', |
| 55 |
|
| 'EXTREME-SYSTEM-MIB' => 'extremeSystem', |
| 56 |
|
| 'EXTREME-FDB-MIB' => 'extremeFdbMacFdbMacAddress', |
| 57 |
|
| 'EXTREME-VLAN-MIB' => 'extremeVlan', |
| 58 |
|
| 'EXTREME-POE-MIB' => 'extremePethSystemAdminEnable', |
| 59 |
|
| 'EXTREME-STP-EXTENSIONS-MIB' => 'extremeStpDomainBridgeId', |
| 60 |
|
| 'EXTREME-PORT-MIB' => 'extremePortLoadshare2Status', |
| 61 |
|
| 'EXTREME-MLAG-MIB' => 'extremeMlagPeerIP', |
| 62 |
|
| ); |
| 63 |
|
| |
| 64 |
|
| %GLOBALS = ( |
| 65 |
|
| %SNMP::Info::Layer3::GLOBALS, |
| 66 |
|
| %SNMP::Info::MAU::GLOBALS, |
| 67 |
|
| %SNMP::Info::EDP::GLOBALS, |
| 68 |
|
| 'serial1' => 'extremeSystemID.0', |
| 69 |
|
| 'temp' => 'extremeCurrentTemperature', |
| 70 |
|
| 'ps1_status_old' => 'extremePrimaryPowerOperational.0', |
| 71 |
|
| 'ps1_status_new' => 'extremePowerSupplyStatus.1', |
| 72 |
|
| 'ps2_status_old' => 'extremeRedundantPowerStatus.0', |
| 73 |
|
| 'ps2_status_new' => 'extremePowerSupplyStatus.2', |
| 74 |
|
| 'mac' => 'dot1dBaseBridgeAddress', |
| 75 |
|
| ); |
| 76 |
|
| |
| 77 |
|
| %FUNCS = ( |
| 78 |
|
| %SNMP::Info::Layer3::FUNCS, |
| 79 |
|
| %SNMP::Info::MAU::FUNCS, |
| 80 |
|
| %SNMP::Info::EDP::FUNCS, |
| 81 |
|
| 'fan_state' => 'extremeFanOperational', |
| 82 |
|
| # EXTREME-FDB-MIB:extremeFdbMacFdbTable |
| 83 |
|
| 'ex_fw_mac' => 'extremeFdbMacFdbMacAddress', |
| 84 |
|
| 'ex_fw_port' => 'extremeFdbMacFdbPortIfIndex', |
| 85 |
|
| 'ex_fw_status' => 'extremeFdbMacFdbStatus', |
| 86 |
|
| # EXTREME-VLAN-MIB:extremeVlanIfTable |
| 87 |
|
| 'ex_vlan_descr' => 'extremeVlanIfDescr', |
| 88 |
|
| 'ex_vlan_global_id' => 'extremeVlanIfGlobalIdentifier', |
| 89 |
|
| 'ex_vlan_id' => 'extremeVlanIfVlanId', |
| 90 |
|
| # EXTREME-VLAN-MIB:extremeVlanEncapsIfTable |
| 91 |
|
| 'ex_vlan_encap_tag' => 'extremeVlanEncapsIfTag', |
| 92 |
|
| # EXTREME-VLAN-MIB:extremeVlanOpaqueTable |
| 93 |
|
| 'ex_vlan_untagged' => 'extremeVlanOpaqueUntaggedPorts', |
| 94 |
|
| 'ex_vlan_tagged' => 'extremeVlanOpaqueTaggedPorts', |
| 95 |
|
| # EXTREME-POE-MIB::extremePethPseSlotTable |
| 96 |
|
| 'peth_power_watts' => 'extremePethSlotPowerLimit', |
| 97 |
|
| # EXTREME-POE-MIB::extremePethPsePortTable |
| 98 |
|
| 'peth_port_power' => 'extremePethPortMeasuredPower', |
| 99 |
|
| # EXTREME-STP-EXTENSIONS-MIB::extremeStpDomainTable |
| 100 |
|
| 'stp_i_time' => 'extremeStpDomainTimeSinceTopologyChange', |
| 101 |
|
| 'stp_i_ntop' => 'extremeStpDomainTopChanges', |
| 102 |
|
| 'stp_i_root' => 'extremeStpDomainDesignatedRoot', |
| 103 |
|
| 'stp_i_root_port' => 'extremeStpDomainRootPortIfIndex', |
| 104 |
|
| 'stp_i_priority' => 'extremeStpDomainBridgePriority', |
| 105 |
|
| 'ex_stp_i_mac' => 'extremeStpDomainBridgeId', |
| 106 |
|
| 'ex_stp_i_name' => 'extremeStpDomainStpdName', |
| 107 |
|
| 'ex_stp_i_tag' => 'extremeStpDomainStpdTag', |
| 108 |
|
| # EXTREME-STP-EXTENSIONS-MIB::extremeStpPortTable |
| 109 |
|
| 'stp_p_priority' => 'extremeStpPortPortPriority', |
| 110 |
|
| 'stp_p_state' => 'extremeStpPortPortState', |
| 111 |
|
| 'stp_p_enable' => 'extremeStpPortStpEnabled', |
| 112 |
|
| 'stp_p_cost' => 'extremeStpPortPathCost', |
| 113 |
|
| 'stp_p_root' => 'extremeStpPortDesignatedRoot', |
| 114 |
|
| 'stp_p_bridge' => 'extremeStpPortDesignatedBridge', |
| 115 |
|
| 'stp_p_port' => 'extremeStpPortDesignatedPort', |
| 116 |
|
| 'ex_stp_p_mode' => 'extremeStpPortPortMode', |
| 117 |
|
| # EXTREME-STP-EXTENSIONS-MIB::extremeStpVlanPortTable |
| 118 |
|
| 'ex_stp_vlan_mask' => 'extremeStpVlanPortPortMask', |
| 119 |
|
| # EXTREME-PORT-MIB::extremePortLoadshare2Table |
| 120 |
|
| 'ex_loadshare' => 'extremePortLoadshare2Status', |
| 121 |
|
| # EXTREME-MLAG-MIB::extremeMlagPeerTable |
| 122 |
|
| 'ex_mlag_peer_ip' => 'extremeMlagPeerIP', |
| 123 |
|
| 'ex_mlag_peer_status' => 'extremeMlagPeerCheckPointStatus', |
| 124 |
|
| 'ex_mlag_peer_lacp_mac' => 'extremeMlagPeerOperLacpMac', |
| 125 |
|
| # EXTREME-MLAG-MIB::extremeMlagPortTable |
| 126 |
|
| 'ex_mlag_port_id' => 'extremeMlagPortId', |
| 127 |
|
| 'ex_mlag_port_peer' => 'extremeMlagPortPeer', |
| 128 |
|
| 'ex_mlag_port_state' => 'extremeMlagPortLocalLinkStatus', |
| 129 |
|
| ); |
| 130 |
|
| |
| 131 |
|
| %MUNGE = ( |
| 132 |
|
| |
| 133 |
|
| # Inherit all the built in munging |
| 134 |
|
| %SNMP::Info::Layer3::MUNGE, |
| 135 |
|
| %SNMP::Info::MAU::MUNGE, |
| 136 |
|
| %SNMP::Info::EDP::MUNGE, |
| 137 |
|
| 'ex_fw_mac' => \&SNMP::Info::munge_mac, |
| 138 |
|
| 'ex_mlag_peer_ip' => \&SNMP::Info::munge_inetaddress, |
| 139 |
|
| 'ex_mlag_peer_lacp_mac' => \&SNMP::Info::munge_mac, |
| 140 |
|
| 'ps1_status_old' => \&munge_true_ok, |
| 141 |
|
| 'ps1_status_new' => \&munge_power_stat, |
| 142 |
|
| 'ps2_status_old' => \&munge_power_stat, |
| 143 |
|
| 'ps2_status_new' => \&munge_power_stat, |
| 144 |
|
| 'fan_state' => \&munge_true_ok, |
| 145 |
|
| 'ex_vlan_untagged' => \&SNMP::Info::munge_port_list, |
| 146 |
|
| 'ex_vlan_tagged' => \&SNMP::Info::munge_port_list, |
| 147 |
|
| 'ex_stp_i_mac' => \&SNMP::Info::munge_prio_mac, |
| 148 |
|
| 'stp_i_root' => \&SNMP::Info::munge_prio_mac, |
| 149 |
|
| 'stp_p_root' => \&SNMP::Info::munge_prio_mac, |
| 150 |
|
| 'stp_p_bridge' => \&SNMP::Info::munge_prio_mac, |
| 151 |
|
| 'stp_p_port' => \&SNMP::Info::munge_prio_port, |
| 152 |
|
| ); |
| 153 |
|
| |
| 154 |
|
| # Method OverRides |
| 155 |
|
| |
| 156 |
|
| *SNMP::Info::Layer3::Extreme::i_duplex = \&SNMP::Info::MAU::mau_i_duplex; |
| 157 |
|
| *SNMP::Info::Layer3::Extreme::i_duplex_admin |
| 158 |
|
| = \&SNMP::Info::MAU::mau_i_duplex_admin; |
| 159 |
|
| |
| 160 |
|
| # extremePortLoadshare2Table is indexed master.member; the master lists |
| 161 |
|
| # itself as a member, which agg_ports leaves out |
| 162 |
|
| sub agg_ports { |
| 163 |
|
| my $extreme = shift; |
| 164 |
|
| |
| 165 |
|
| my $loadshare = $extreme->ex_loadshare() || {}; |
| 166 |
|
| my %member_of; |
| 167 |
|
| foreach my $iid ( keys %$loadshare ) { |
| 168 |
|
| my ( $master, $member ) = split /\./, $iid; |
| 169 |
|
| next if !defined $member or $member eq $master; |
| 170 |
|
| $member_of{$member} = $master; |
| 171 |
|
| } |
| 172 |
|
| return \%member_of; |
| 173 |
|
| } |
| 174 |
|
| |
| 175 |
|
| sub _agg_ports_walked { return qw/ex_loadshare/ } |
| 176 |
|
| |
| 177 |
|
| # The peer table is indexed by the peer name, a string |
| 178 |
|
| sub _ex_mlag_peer_name { |
| 179 |
|
| my $iid = shift; |
| 180 |
|
| |
| 181 |
|
| return $iid unless $iid =~ /^\d+(?:\.\d+)+$/; |
| 182 |
|
| my ( $length, @codes ) = split /\./, $iid; |
| 183 |
|
| return $iid unless $length == scalar @codes; |
| 184 |
|
| return join '', map { chr } @codes; |
| 185 |
|
| } |
| 186 |
|
| |
| 187 |
|
| # EXOS 33.6 serves extremeMlagPeerIP as text ("192.0.2.2"), which the |
| 188 |
|
| # binary InetAddress munge reads as nothing |
| 189 |
|
| sub _ex_text_address { |
| 190 |
|
| my $raw = shift; |
| 191 |
|
| |
| 192 |
|
| return unless defined $raw; |
| 193 |
|
| return $raw if $raw =~ /^\d{1,3}(?:\.\d{1,3}){3}$/; |
| 194 |
|
| return $raw if $raw =~ /^[0-9a-fA-F:.]*:[0-9a-fA-F:.]*:[0-9a-fA-F:.]*$/; |
| 195 |
|
| return; |
| 196 |
|
| } |
| 197 |
|
| |
| 198 |
|
| sub _lag_vendor_walked { |
| 199 |
|
| return qw/ex_loadshare ex_mlag_peer_ip ex_mlag_peer_status |
| 200 |
|
| ex_mlag_peer_lacp_mac ex_mlag_port_id ex_mlag_port_peer |
| 201 |
|
| ex_mlag_port_state/; |
| 202 |
|
| } |
| 203 |
|
| |
| 204 |
|
| sub _lag_vendor_domains { |
| 205 |
|
| my $extreme = shift; |
| 206 |
|
| |
| 207 |
|
| my %columns = ( |
| 208 |
|
| peer => [ ex_mlag_peer_ip => 'extremeMlagPeerIP' ], |
| 209 |
|
| status => [ |
| 210 |
|
| ex_mlag_peer_status => 'extremeMlagPeerCheckPointStatus' |
| 211 |
|
| ], |
| 212 |
|
| system_mac => [ |
| 213 |
|
| ex_mlag_peer_lacp_mac => 'extremeMlagPeerOperLacpMac' |
| 214 |
|
| ], |
| 215 |
|
| ); |
| 216 |
|
| my $peers = $extreme->ex_mlag_peer_ip() || {}; |
| 217 |
|
| my $text_peers = $extreme->ex_mlag_peer_ip_raw() || {}; |
| 218 |
|
| my $domains = {}; |
| 219 |
|
| foreach my $iid ( keys %$peers ) { |
| 220 |
|
| my $domain = { kind => 'mlag', sources => {} }; |
| 221 |
|
| foreach my $field ( keys %columns ) { |
| 222 |
|
| my ( $method, $leaf ) = @{ $columns{$field} }; |
| 223 |
|
| $domain->{$field} = ( $extreme->$method() || {} )->{$iid}; |
| 224 |
|
| $domain->{$field} = _ex_text_address( $text_peers->{$iid} ) |
| 225 |
|
| if $field eq 'peer' and !$domain->{$field}; |
| 226 |
|
| $domain->{sources}{$field} = 'EXTREME-MLAG-MIB::' . $leaf |
| 227 |
|
| if defined $domain->{$field}; |
| 228 |
|
| } |
| 229 |
|
| $domains->{ _ex_mlag_peer_name($iid) } = $domain; |
| 230 |
|
| } |
| 231 |
|
| return $domains; |
| 232 |
|
| } |
| 233 |
|
| |
| 234 |
|
| sub _lag_vendor_groups { |
| 235 |
|
| my ( $extreme, $groups ) = @_; |
| 236 |
|
| |
| 237 |
|
| $extreme->_ex_loadshare_masters($groups); |
| 238 |
|
| $extreme->_ex_mlag_ports($groups); |
| 239 |
|
| return; |
| 240 |
|
| } |
| 241 |
|
| |
| 242 |
|
| # The master is a member of its own aggregate in lag_groups |
| 243 |
|
| sub _ex_loadshare_masters { |
| 244 |
|
| my ( $extreme, $groups ) = @_; |
| 245 |
|
| |
| 246 |
|
| my $loadshare = $extreme->ex_loadshare() || {}; |
| 247 |
|
| foreach my $iid ( keys %$loadshare ) { |
| 248 |
|
| my ( $master, $member ) = split /\./, $iid; |
| 249 |
|
| next if !defined $member or $member ne $master; |
| 250 |
|
| my $record = $groups->{$master} or next; |
| 251 |
|
| $extreme->_lag_place_members( $groups, $master, { $master => 1 }, |
| 252 |
|
| $record->{sources}{members} |
| 253 |
|
| || 'EXTREME-PORT-MIB::extremePortLoadshare2Status' ); |
| 254 |
|
| } |
| 255 |
|
| return; |
| 256 |
|
| } |
| 257 |
|
| |
| 258 |
|
| sub _ex_mlag_ports { |
| 259 |
|
| my ( $extreme, $groups ) = @_; |
| 260 |
|
| |
| 261 |
|
| my $ids = $extreme->ex_mlag_port_id() || {}; |
| 262 |
|
| my $peers = $extreme->ex_mlag_port_peer() || {}; |
| 263 |
|
| my $states = $extreme->ex_mlag_port_state() || {}; |
| 264 |
|
| foreach my $port ( keys %$ids ) { |
| 265 |
|
| my $aggregate = _ex_aggregate_of( $groups, $port ); |
| 266 |
|
| my $members = $aggregate ? $groups->{$aggregate}{members} : {}; |
| 267 |
|
| $aggregate |
| 268 |
|
| = $extreme->_ex_lone_mlag_port( $groups, $aggregate, $port ) |
| 269 |
|
| unless scalar keys %$members; |
| 270 |
|
| $groups->{$aggregate}{mc} = { |
| 271 |
|
| kind => 'mlag', |
| 272 |
|
| group => $ids->{$port}, |
| 273 |
|
| domain => $peers->{$port}, |
| 274 |
|
| state => $states->{$port}, |
| 275 |
|
| }; |
| 276 |
|
| $groups->{$aggregate}{sources}{mc} |
| 277 |
|
| = 'EXTREME-MLAG-MIB::extremeMlagPortId'; |
| 278 |
|
| } |
| 279 |
|
| return; |
| 280 |
|
| } |
| 281 |
|
| |
| 282 |
|
| # An MLAG port on a load sharing group of one, or on no load sharing group, |
| 283 |
|
| # is its own aggregate; it is keyed by the load sharing master when it has one |
| 284 |
|
| sub _ex_lone_mlag_port { |
| 285 |
|
| my ( $extreme, $groups, $aggregate, $port ) = @_; |
| 286 |
|
| |
| 287 |
|
| my $loadshare = $extreme->ex_loadshare() || {}; |
| 288 |
|
| my $key = $aggregate; |
| 289 |
|
| foreach my $iid ( keys %$loadshare ) { |
| 290 |
|
| my ( $master, $member ) = split /\./, $iid; |
| 291 |
|
| $key = $master if defined $member and $member eq $port; |
| 292 |
|
| } |
| 293 |
|
| $key = $port unless defined $key; |
| 294 |
|
| my $source = $key eq $port && !grep { /^\Q$key\E\./ } keys %$loadshare |
| 295 |
|
| ? 'EXTREME-MLAG-MIB::extremeMlagPortLocalPortIfIndex' |
| 296 |
|
| : 'EXTREME-PORT-MIB::extremePortLoadshare2Status'; |
| 297 |
|
| $extreme->_lag_place_members( $groups, $key, { $port => 1 }, $source ); |
| 298 |
|
| return $key; |
| 299 |
|
| } |
| 300 |
|
| |
| 301 |
|
| # The MLAG port is the aggregate's master or a single member of it |
| 302 |
|
| sub _ex_aggregate_of { |
| 303 |
|
| my ( $groups, $port ) = @_; |
| 304 |
|
| |
| 305 |
|
| return $port if $groups->{$port}; |
| 306 |
|
| foreach my $aggregate ( keys %$groups ) { |
| 307 |
|
| return $aggregate if $groups->{$aggregate}{members}{$port}; |
| 308 |
|
| } |
| 309 |
|
| return; |
| 310 |
|
| } |
| 311 |
|
| |
| 312 |
|
| sub model { |
| 313 |
|
| my $extreme = shift; |
| 314 |
|
| my $id = $extreme->id(); |
| 315 |
|
| |
| 316 |
|
| unless ( defined $id ) { |
| 317 |
|
| print |
| 318 |
|
| " SNMP::Info::Layer3::Extreme::model() - Device does not support sysObjectID\n" |
| 319 |
|
| if $extreme->debug(); |
| 320 |
|
| return; |
| 321 |
|
| } |
| 322 |
|
| |
| 323 |
|
| my $model = &SNMP::translateObj($id); |
| 324 |
|
| |
| 325 |
|
| return $id unless defined $model; |
| 326 |
|
| |
| 327 |
|
| return $model; |
| 328 |
|
| } |
| 329 |
|
| |
| 330 |
|
| sub vendor { |
| 331 |
|
| return 'extreme'; |
| 332 |
|
| } |
| 333 |
|
| |
| 334 |
|
| sub os { |
| 335 |
|
| my $extreme = shift; |
| 336 |
|
| my $desc = $extreme->description(); |
| 337 |
|
| |
| 338 |
|
| if ( $desc =~ /xos/i ) { |
| 339 |
|
| return 'xos'; |
| 340 |
|
| } |
| 341 |
|
| |
| 342 |
|
| return 'extremeware'; |
| 343 |
|
| } |
| 344 |
|
| |
| 345 |
|
| |
| 346 |
|
| sub os_ver { |
| 347 |
|
| my $extreme = shift; |
| 348 |
|
| my $descr = $extreme->description(); |
| 349 |
|
| return unless defined $descr; |
| 350 |
|
| |
| 351 |
|
| if ( $descr =~ m/Version\s+([^ ]+)/i ) { |
| 352 |
|
| return $1; |
| 353 |
|
| } |
| 354 |
|
| |
| 355 |
|
| return; |
| 356 |
|
| } |
| 357 |
|
| |
| 358 |
|
| # |
| 359 |
|
| # ifName is a nice concise port name on Extreme devices. |
| 360 |
|
| # Layer3.pm defaults to i_description, which is verbose |
| 361 |
|
| # and has spaces. However, ifName has the IP address |
| 362 |
|
| # assigned for router interfaces, so we use ifDescr |
| 363 |
|
| # for those. |
| 364 |
|
| sub interfaces { |
| 365 |
|
| my $extreme = shift; |
| 366 |
|
| my $partial = shift; |
| 367 |
|
| my $i_name = $extreme->orig_i_name($partial); |
| 368 |
|
| my $i_description = $extreme->orig_i_description($partial); |
| 369 |
|
| my $interfaces = {}; |
| 370 |
|
| foreach my $idx ( keys %$i_name ) { |
| 371 |
|
| if ( $i_name->{$idx} =~ /\([0-9.]+\)/ ) { |
| 372 |
|
| $interfaces->{$idx} = $i_description->{$idx}; |
| 373 |
|
| } |
| 374 |
|
| else { |
| 375 |
|
| $interfaces->{$idx} = $i_name->{$idx}; |
| 376 |
|
| } |
| 377 |
|
| } |
| 378 |
|
| return $interfaces; |
| 379 |
|
| } |
| 380 |
|
| |
| 381 |
|
| # |
| 382 |
|
| # Ignore VLAN meta-interfaces and loopback |
| 383 |
|
| sub i_ignore { |
| 384 |
|
| my $extreme = shift; |
| 385 |
|
| my $partial = shift; |
| 386 |
|
| |
| 387 |
|
| my $i_description = $extreme->i_description($partial) || {}; |
| 388 |
|
| |
| 389 |
|
| my %i_ignore; |
| 390 |
|
| foreach my $if ( keys %$i_description ) { |
| 391 |
|
| if ( $i_description->{$if} |
| 392 |
|
| =~ /^(802.1Q Encapsulation Tag \d+|VLAN \d+|lo\d+|VirtualRouter\d+)/i ) |
| 393 |
|
| { |
| 394 |
|
| $i_ignore{$if}++; |
| 395 |
|
| } |
| 396 |
|
| } |
| 397 |
|
| return \%i_ignore; |
| 398 |
|
| } |
| 399 |
|
| |
| 400 |
|
| # When we use the extreme_fw_* objects, we're not using BRIDGE-MIB. |
| 401 |
|
| # Either way, Extreme uses a 1:1 mapping of bridge interface ID to |
| 402 |
|
| # ifIndex. |
| 403 |
|
| sub bp_index { |
| 404 |
|
| my $extreme = shift; |
| 405 |
|
| |
| 406 |
|
| my $bindex = $extreme->SUPER::bp_index(); |
| 407 |
|
| return $bindex if (keys %$bindex); |
| 408 |
|
| |
| 409 |
|
| my $if_index = $extreme->i_index(); |
| 410 |
|
| |
| 411 |
|
| my %bp_index; |
| 412 |
|
| foreach my $iid ( keys %$if_index ) { |
| 413 |
|
| $bp_index{$iid} = $iid; |
| 414 |
|
| } |
| 415 |
|
| return \%bp_index; |
| 416 |
|
| } |
| 417 |
|
| |
| 418 |
|
| sub munge_true_ok { |
| 419 |
|
| my $val = shift; |
| 420 |
|
| return unless defined($val); |
| 421 |
|
| return "OK" if ( $val eq 'true' ); |
| 422 |
|
| return "Not OK" if ( $val eq 'false' ); |
| 423 |
|
| return $val; |
| 424 |
|
| } |
| 425 |
|
| |
| 426 |
|
| sub munge_power_stat { |
| 427 |
|
| my $val = shift; |
| 428 |
|
| return unless defined($val); |
| 429 |
|
| $val =~ s/^present//; |
| 430 |
|
| $val =~ s/^not/Not /i; |
| 431 |
|
| return $val; |
| 432 |
|
| } |
| 433 |
|
| |
| 434 |
|
| sub ps1_status { |
| 435 |
|
| my $extreme = shift; |
| 436 |
|
| my $ps1_status = $extreme->ps1_status_new(); |
| 437 |
|
| return $ps1_status || $extreme->ps1_status_old(); |
| 438 |
|
| } |
| 439 |
|
| |
| 440 |
|
| sub ps2_status { |
| 441 |
|
| my $extreme = shift; |
| 442 |
|
| my $ps2_status = $extreme->ps2_status_new(); |
| 443 |
|
| return $ps2_status || $extreme->ps2_status_old(); |
| 444 |
|
| } |
| 445 |
|
| |
| 446 |
|
| sub fan { |
| 447 |
|
| my $extreme = shift; |
| 448 |
|
| my $fan_state = $extreme->fan_state(); |
| 449 |
|
| my $ret = ""; |
| 450 |
|
| my $s = ""; |
| 451 |
|
| foreach my $i ( sort { $a <=> $b } keys %$fan_state ) { |
| 452 |
|
| $ret .= $s . $i . ": " . $fan_state->{$i}; |
| 453 |
|
| $s = ", "; |
| 454 |
|
| } |
| 455 |
|
| return if ( $s eq "" ); |
| 456 |
|
| return $ret; |
| 457 |
|
| } |
| 458 |
|
| |
| 459 |
|
| # For xos based VLAN functions we need to know how the ports are indexed |
| 460 |
|
| # default is slot * 1000, but some older switches start at 1 |
| 461 |
|
| sub _slot_factor { |
| 462 |
|
| my $extreme = shift; |
| 463 |
|
| |
| 464 |
|
| my $index = $extreme->i_index(); |
| 465 |
|
| |
| 466 |
|
| return 1 if (exists $index->{1} && $index->{1} == 1); |
| 467 |
|
| return 1000; |
| 468 |
|
| } |
| 469 |
|
| |
| 470 |
|
| # Some versions of the Extreme firmware have vendor-specific tables |
| 471 |
|
| # for this; those are ex_fw_*(). Some don't have these tables, |
| 472 |
|
| # we use the BRIDGE-MIB tables if available then the ex_fw_*() methods. |
| 473 |
|
| sub fw_mac { |
| 474 |
|
| my $extreme = shift; |
| 475 |
|
| |
| 476 |
|
| my $fw_m = $extreme->SUPER::fw_mac(); |
| 477 |
|
| return $fw_m if (keys %$fw_m); |
| 478 |
|
| |
| 479 |
|
| return $extreme->ex_fw_mac(); |
| 480 |
|
| } |
| 481 |
|
| |
| 482 |
|
| sub fw_port { |
| 483 |
|
| my $extreme = shift; |
| 484 |
|
| |
| 485 |
|
| my $fw_p = $extreme->SUPER::fw_port(); |
| 486 |
|
| return $fw_p if (keys %$fw_p); |
| 487 |
|
| |
| 488 |
|
| return $extreme->ex_fw_port(); |
| 489 |
|
| } |
| 490 |
|
| |
| 491 |
|
| sub fw_status { |
| 492 |
|
| my $extreme = shift; |
| 493 |
|
| |
| 494 |
|
| my $fw_s = $extreme->SUPER::fw_status(); |
| 495 |
|
| return $fw_s if (keys %$fw_s); |
| 496 |
|
| |
| 497 |
|
| return $extreme->ex_fw_status(); |
| 498 |
|
| } |
| 499 |
|
| |
| 500 |
|
| # Mapping the virtual VLAN interfaces: |
| 501 |
|
| # The virtual VLAN interfaces in extremeVlanIfTable |
| 502 |
|
| # are the higher layer above the interfaces that are |
| 503 |
|
| # untagged, and also above an interface in |
| 504 |
|
| # extremeVlanEncapsIfTable that does the encapsulation. |
| 505 |
|
| # Note that it's possible to have a VLAN defined that |
| 506 |
|
| # does not have a tag, if it has all native interfaces. |
| 507 |
|
| # To represent this, we use a negative version of the |
| 508 |
|
| # internal VLAN ID (the deprecated extremeVlanIfGlobalIdentifier) |
| 509 |
|
| sub _if2tag { |
| 510 |
|
| my $extreme = shift; |
| 511 |
|
| my $partial = shift; |
| 512 |
|
| my $stack = shift || $extreme->ifStackStatus($partial); |
| 513 |
|
| my $encap_tag = $extreme->ex_vlan_encap_tag(); |
| 514 |
|
| my $vlan_descr = $extreme->ex_vlan_descr(); |
| 515 |
|
| |
| 516 |
|
| my $stackmap = {}; |
| 517 |
|
| foreach my $idx ( keys %$stack ) { |
| 518 |
|
| my ( $higher, $lower ) = split( /\./, $idx ); |
| 519 |
|
| $stackmap->{$higher}->{$lower} = $stack->{$idx}; |
| 520 |
|
| } |
| 521 |
|
| |
| 522 |
|
| my %if2tag = (); |
| 523 |
|
| my $missed = 0; |
| 524 |
|
| foreach my $if ( keys %$vlan_descr ) { |
| 525 |
|
| $if2tag{$if} = -1; |
| 526 |
|
| foreach my $tagif ( keys %$encap_tag ) { |
| 527 |
|
| if ( defined( $stackmap->{$if}->{$tagif} ) |
| 528 |
|
| && $stackmap->{$if}->{$tagif} eq 'active' ) |
| 529 |
|
| { |
| 530 |
|
| $if2tag{$if} = $encap_tag->{$tagif}; |
| 531 |
|
| } |
| 532 |
|
| } |
| 533 |
|
| if ( $if2tag{$if} == -1 ) { |
| 534 |
|
| $missed++; |
| 535 |
|
| } |
| 536 |
|
| } |
| 537 |
|
| if ($missed) { |
| 538 |
|
| my $global_id = $extreme->ex_vlan_id(); |
| 539 |
|
| foreach my $if ( keys %if2tag ) { |
| 540 |
|
| $if2tag{$if} = -$global_id->{$if} |
| 541 |
|
| if ( $if2tag{$if} == -1 && defined( $global_id->{$if} ) ); |
| 542 |
|
| } |
| 543 |
|
| } |
| 544 |
|
| return \%if2tag; |
| 545 |
|
| } |
| 546 |
|
| |
| 547 |
|
| # No partial support in v_name or v_index, because the obvious partial |
| 548 |
|
| # is the VLAN ID and the index here is the ifIndex of |
| 549 |
|
| # the VLAN interface. |
| 550 |
|
| sub v_name { |
| 551 |
|
| my $extreme = shift; |
| 552 |
|
| |
| 553 |
|
| my $names = $extreme->ex_vlan_descr() || {}; |
| 554 |
|
| return $names if scalar keys %$names; |
| 555 |
|
| return $extreme->qb_v_name() || {}; |
| 556 |
|
| } |
| 557 |
|
| |
| 558 |
|
| sub v_index { |
| 559 |
|
| my $extreme = shift; |
| 560 |
|
| |
| 561 |
|
| my $names = $extreme->ex_vlan_descr() || {}; |
| 562 |
|
| return $extreme->SUPER::v_index() unless scalar keys %$names; |
| 563 |
|
| return $extreme->ex_vlan_id || $extreme->_if2tag(); |
| 564 |
|
| } |
| 565 |
|
| |
| 566 |
|
| sub i_vlan { |
| 567 |
|
| my $extreme = shift; |
| 568 |
|
| my $partial = shift; |
| 569 |
|
| |
| 570 |
|
| # Some devices support Q-Bridge, if so short circuit and return it |
| 571 |
|
| my $q_bridge = $extreme->SUPER::i_vlan($partial); |
| 572 |
|
| return $q_bridge if (keys %$q_bridge); |
| 573 |
|
| |
| 574 |
|
| # Next we try extremeVlanOpaqueTable |
| 575 |
|
| my $xos = $extreme->_xos_i_vlan($partial); |
| 576 |
|
| return $xos if (keys %$xos); |
| 577 |
|
| |
| 578 |
|
| # Try older ifStack method |
| 579 |
|
| my $extremeware = $extreme->_extremeware_i_vlan($partial); |
| 580 |
|
| return $extremeware if (keys %$extremeware); |
| 581 |
|
| |
| 582 |
|
| return; |
| 583 |
|
| } |
| 584 |
|
| |
| 585 |
|
| sub _xos_i_vlan { |
| 586 |
|
| my $extreme = shift; |
| 587 |
|
| my $partial = shift; |
| 588 |
|
| |
| 589 |
|
| my $index = $extreme->i_index(); |
| 590 |
|
| my $vlans = $extreme->ex_vlan_id() || {}; |
| 591 |
|
| my $slotx = $extreme->_slot_factor() || 1000; |
| 592 |
|
| my $u_ports = $extreme->ex_vlan_untagged() || {}; |
| 593 |
|
| |
| 594 |
|
| my $i_vlan = {}; |
| 595 |
|
| foreach my $idx ( keys %$u_ports ) { |
| 596 |
|
| next unless ( defined $u_ports->{$idx} ); |
| 597 |
|
| my $portlist = $u_ports->{$idx}; |
| 598 |
|
| my $ret = []; |
| 599 |
|
| |
| 600 |
|
| my ( $vlan_if, $slot ) = $idx =~ /^(\d+)\.(\d+)/; |
| 601 |
|
| my $vlan = $vlans->{$vlan_if} || ''; |
| 602 |
|
| |
| 603 |
|
| # Convert portlist bit array to bp_index array |
| 604 |
|
| for ( my $i = 0; $i <= $#$portlist; $i++ ) { |
| 605 |
|
| push( @{$ret}, ( $slotx * $slot + $i + 1 ) ) |
| 606 |
|
| if ( @$portlist[$i] ); |
| 607 |
|
| } |
| 608 |
|
| |
| 609 |
|
| #Create HoA ifIndex -> VLAN array |
| 610 |
|
| foreach my $port ( @{$ret} ) { |
| 611 |
|
| my $ifindex = $index->{$port}; |
| 612 |
|
| next unless ( defined($ifindex) ); # shouldn't happen |
| 613 |
|
| next if ( defined $partial and $ifindex !~ /^$partial$/ ); |
| 614 |
|
| $i_vlan->{$ifindex} = $vlan; |
| 615 |
|
| } |
| 616 |
|
| } |
| 617 |
|
| return $i_vlan; |
| 618 |
|
| } |
| 619 |
|
| |
| 620 |
|
| sub _extremeware_i_vlan { |
| 621 |
|
| my $extreme = shift; |
| 622 |
|
| my $partial = shift; |
| 623 |
|
| my $stack = $extreme->ifStackStatus($partial); |
| 624 |
|
| my $encap_tag = $extreme->ex_vlan_encap_tag(); |
| 625 |
|
| my $vlan_descr = $extreme->ex_vlan_descr(); |
| 626 |
|
| my $stackmap = {}; |
| 627 |
|
| foreach my $idx ( keys %$stack ) { |
| 628 |
|
| my ( $higher, $lower ) = split( /\./, $idx ); |
| 629 |
|
| $stackmap->{$higher}->{$lower} = $stack->{$idx}; |
| 630 |
|
| } |
| 631 |
|
| my $if2tag = $extreme->_if2tag( $partial, $stack ); |
| 632 |
|
| |
| 633 |
|
| # |
| 634 |
|
| # Now that we've done all that mapping work, we can map the |
| 635 |
|
| # ifStack indexes. |
| 636 |
|
| my %i_vlan = (); |
| 637 |
|
| foreach my $if ( keys %$if2tag ) { |
| 638 |
|
| foreach my $lowif ( keys %{ $stackmap->{$if} } ) { |
| 639 |
|
| $i_vlan{$lowif} = $if2tag->{$if}; |
| 640 |
|
| } |
| 641 |
|
| } |
| 642 |
|
| return \%i_vlan; |
| 643 |
|
| } |
| 644 |
|
| |
| 645 |
|
| sub i_vlan_membership { |
| 646 |
|
| my $extreme = shift; |
| 647 |
|
| my $partial = shift; |
| 648 |
|
| |
| 649 |
|
| # Some devices support Q-Bridge, if so short circuit and return it |
| 650 |
|
| my $q_bridge = $extreme->SUPER::i_vlan_membership($partial); |
| 651 |
|
| return $q_bridge if (ref {} eq ref $q_bridge and scalar keys %$q_bridge); |
| 652 |
|
| |
| 653 |
|
| # Next we try extremeVlanOpaqueTable |
| 654 |
|
| my $xos = $extreme->_xos_i_vlan_membership($partial); |
| 655 |
|
| return $xos if (ref {} eq ref $xos and scalar keys %$xos); |
| 656 |
|
| |
| 657 |
|
| # Try older ifStack method |
| 658 |
|
| my $extremeware = $extreme->_extremeware_i_vlan_membership($partial); |
| 659 |
|
| return $extremeware if (ref {} eq ref $extremeware and scalar keys %$extremeware); |
| 660 |
|
| |
| 661 |
|
| return; |
| 662 |
|
| } |
| 663 |
|
| |
| 664 |
|
| sub _xos_i_vlan_membership { |
| 665 |
|
| my $extreme = shift; |
| 666 |
|
| my $partial = shift; |
| 667 |
|
| |
| 668 |
|
| my $index = $extreme->i_index(); |
| 669 |
|
| my $vlans = $extreme->ex_vlan_id(); |
| 670 |
|
| my $slotx = $extreme->_slot_factor() || 1000; |
| 671 |
|
| my $u_ports = $extreme->ex_vlan_untagged() || {}; |
| 672 |
|
| my $t_ports = $extreme->ex_vlan_tagged() || {}; |
| 673 |
|
| |
| 674 |
|
| my $i_vlan_membership = {}; |
| 675 |
|
| foreach my $idx ( keys %$u_ports ) { |
| 676 |
|
| next unless ( defined $u_ports->{$idx} ); |
| 677 |
|
| my $u_portlist = $u_ports->{$idx}; |
| 678 |
|
| my $t_portlist = $t_ports->{$idx}; |
| 679 |
|
| my $ret = []; |
| 680 |
|
| |
| 681 |
|
| my ( $vlan_if, $slot ) = $idx =~ /^(\d+)\.(\d+)/; |
| 682 |
|
| my $vlan = $vlans->{$vlan_if} || ''; |
| 683 |
|
| |
| 684 |
|
| foreach my $portlist ( $u_portlist, $t_portlist ) { |
| 685 |
|
| |
| 686 |
|
| # Convert portlist bit array to bp_index array |
| 687 |
|
| for ( my $i = 0; $i <= $#$portlist; $i++ ) { |
| 688 |
|
| push( @{$ret}, ( $slotx * $slot + $i + 1 ) ) |
| 689 |
|
| if ( @$portlist[$i] ); |
| 690 |
|
| } |
| 691 |
|
| } |
| 692 |
|
| |
| 693 |
|
| #Create HoA ifIndex -> VLAN array |
| 694 |
|
| foreach my $port ( @{$ret} ) { |
| 695 |
|
| my $ifindex = $index->{$port}; |
| 696 |
|
| next unless ( defined($ifindex) ); # shouldn't happen |
| 697 |
|
| next if ( defined $partial and $ifindex !~ /^$partial$/ ); |
| 698 |
|
| push( @{ $i_vlan_membership->{$ifindex} }, $vlan ); |
| 699 |
|
| } |
| 700 |
|
| } |
| 701 |
|
| return $i_vlan_membership; |
| 702 |
|
| } |
| 703 |
|
| |
| 704 |
|
| sub _extremeware_i_vlan_membership { |
| 705 |
|
| my $extreme = shift; |
| 706 |
|
| my $partial = shift; |
| 707 |
|
| my $stack = $extreme->ifStackStatus($partial); |
| 708 |
|
| my $encap_tag = $extreme->ex_vlan_encap_tag(); |
| 709 |
|
| my $vlan_descr = $extreme->ex_vlan_descr(); |
| 710 |
|
| my $stackmap = {}; |
| 711 |
|
| foreach my $idx ( keys %$stack ) { |
| 712 |
|
| my ( $higher, $lower ) = split( /\./, $idx ); |
| 713 |
|
| $stackmap->{$higher}->{$lower} = $stack->{$idx}; |
| 714 |
|
| } |
| 715 |
|
| my $if2tag = $extreme->_if2tag( $partial, $stack ); |
| 716 |
|
| |
| 717 |
|
| # |
| 718 |
|
| # Now that we've done all that mapping work, we can map the |
| 719 |
|
| # ifStack indexes. |
| 720 |
|
| my %i_vlan_membership = (); |
| 721 |
|
| foreach my $if ( keys %$if2tag ) { |
| 722 |
|
| foreach my $lowif ( keys %{ $stackmap->{$if} } ) { |
| 723 |
|
| push( @{ $i_vlan_membership{$lowif} }, $if2tag->{$if} ); |
| 724 |
|
| } |
| 725 |
|
| } |
| 726 |
|
| |
| 727 |
|
| # |
| 728 |
|
| # Now add all the tagged ports. |
| 729 |
|
| foreach my $if ( keys %$encap_tag ) { |
| 730 |
|
| foreach my $lowif ( keys %{ $stackmap->{$if} } ) { |
| 731 |
|
| push( @{ $i_vlan_membership{$lowif} }, $encap_tag->{$if} ); |
| 732 |
|
| } |
| 733 |
|
| } |
| 734 |
|
| return \%i_vlan_membership; |
| 735 |
|
| } |
| 736 |
|
| |
| 737 |
|
| sub i_vlan_membership_untagged { |
| 738 |
|
| my $extreme = shift; |
| 739 |
|
| my $partial = shift; |
| 740 |
|
| |
| 741 |
|
| # Some devices support Q-Bridge, if so short circuit and return it |
| 742 |
|
| my $q_bridge = $extreme->SUPER::i_vlan_membership_untagged($partial); |
| 743 |
|
| return $q_bridge if (ref {} eq ref $q_bridge and scalar keys %$q_bridge); |
| 744 |
|
| |
| 745 |
|
| # Next we try extremeVlanOpaqueTable |
| 746 |
|
| my $xos = $extreme->_xos_i_vlan_membership_untagged($partial); |
| 747 |
|
| return $xos if (ref {} eq ref $xos and scalar keys %$xos); |
| 748 |
|
| |
| 749 |
|
| # Try older ifStack method |
| 750 |
|
| my $extremeware = $extreme->_extremeware_i_vlan_membership_untagged($partial); |
| 751 |
|
| return $extremeware if (ref {} eq ref $extremeware and scalar keys %$extremeware); |
| 752 |
|
| |
| 753 |
|
| return; |
| 754 |
|
| } |
| 755 |
|
| |
| 756 |
|
| sub _xos_i_vlan_membership_untagged { |
| 757 |
|
| my $extreme = shift; |
| 758 |
|
| my $partial = shift; |
| 759 |
|
| |
| 760 |
|
| my $index = $extreme->i_index(); |
| 761 |
|
| my $vlans = $extreme->ex_vlan_id(); |
| 762 |
|
| my $slotx = $extreme->_slot_factor() || 1000; |
| 763 |
|
| my $u_ports = $extreme->ex_vlan_untagged() || {}; |
| 764 |
|
| |
| 765 |
|
| my $i_vlan_membership = {}; |
| 766 |
|
| foreach my $idx ( keys %$u_ports ) { |
| 767 |
|
| next unless ( defined $u_ports->{$idx} ); |
| 768 |
|
| my $u_portlist = $u_ports->{$idx}; |
| 769 |
|
| my $ret = []; |
| 770 |
|
| |
| 771 |
|
| my ( $vlan_if, $slot ) = $idx =~ /^(\d+)\.(\d+)/; |
| 772 |
|
| my $vlan = $vlans->{$vlan_if} || ''; |
| 773 |
|
| |
| 774 |
|
| foreach my $portlist ( $u_portlist ) { |
| 775 |
|
| |
| 776 |
|
| # Convert portlist bit array to bp_index array |
| 777 |
|
| for ( my $i = 0; $i <= $#$portlist; $i++ ) { |
| 778 |
|
| push( @{$ret}, ( $slotx * $slot + $i + 1 ) ) |
| 779 |
|
| if ( @$portlist[$i] ); |
| 780 |
|
| } |
| 781 |
|
| } |
| 782 |
|
| |
| 783 |
|
| #Create HoA ifIndex -> VLAN array |
| 784 |
|
| foreach my $port ( @{$ret} ) { |
| 785 |
|
| my $ifindex = $index->{$port}; |
| 786 |
|
| next unless ( defined($ifindex) ); # shouldn't happen |
| 787 |
|
| next if ( defined $partial and $ifindex !~ /^$partial$/ ); |
| 788 |
|
| push( @{ $i_vlan_membership->{$ifindex} }, $vlan ); |
| 789 |
|
| } |
| 790 |
|
| } |
| 791 |
|
| return $i_vlan_membership; |
| 792 |
|
| } |
| 793 |
|
| |
| 794 |
|
| # Assuming Cisco-like trunk behavior that native VLAN is transmitted untagged |
| 795 |
|
| sub _extremeware_i_vlan_membership_untagged { |
| 796 |
|
| my $extreme = shift; |
| 797 |
|
| my $partial = shift; |
| 798 |
|
| |
| 799 |
|
| my $vlans = $extreme->_extremeware_i_vlan($partial); |
| 800 |
|
| my $i_vlan_membership = {}; |
| 801 |
|
| foreach my $port (keys %$vlans) { |
| 802 |
|
| my $vlan = $vlans->{$port}; |
| 803 |
|
| push( @{ $i_vlan_membership->{$port} }, $vlan ); |
| 804 |
|
| } |
| 805 |
|
| |
| 806 |
|
| return $i_vlan_membership; |
| 807 |
|
| } |
| 808 |
|
| |
| 809 |
|
| # VLAN management. |
| 810 |
|
| # See extreme-vlan.mib for a detailed description of |
| 811 |
|
| # Extreme's use of ifStackTable and EXTREME-VLAN-MIB. |
| 812 |
|
| # EXOS no longer has those tables, so it is managed through Q-BRIDGE-MIB. |
| 813 |
|
| |
| 814 |
|
| sub _has_vlan_encaps { |
| 815 |
|
| my $extreme = shift; |
| 816 |
|
| my $encap_tag = $extreme->ex_vlan_encap_tag() || {}; |
| 817 |
|
| return scalar keys %$encap_tag; |
| 818 |
|
| } |
| 819 |
|
| |
| 820 |
|
| sub set_i_vlan { |
| 821 |
|
| my $extreme = shift; |
| 822 |
|
| return $extreme->_qb_set_i_vlan( 0, @_ ) |
| 823 |
|
| unless $extreme->_has_vlan_encaps(); |
| 824 |
|
| return $extreme->_extreme_set_i_vlan( 0, @_ ); |
| 825 |
|
| } |
| 826 |
|
| |
| 827 |
|
| sub set_i_pvid { |
| 828 |
|
| my $extreme = shift; |
| 829 |
|
| return $extreme->_qb_set_i_vlan( 1, @_ ) |
| 830 |
|
| unless $extreme->_has_vlan_encaps(); |
| 831 |
|
| return $extreme->_extreme_set_i_vlan( 1, @_ ); |
| 832 |
|
| } |
| 833 |
|
| |
| 834 |
|
| sub _qb_bridge_port { |
| 835 |
|
| my ( $extreme, $ifindex ) = @_; |
| 836 |
|
| my $bp_index = $extreme->bp_index() || {}; |
| 837 |
|
| my %if_bp = reverse %$bp_index; |
| 838 |
|
| |
| 839 |
|
| my $bp = $if_bp{$ifindex}; |
| 840 |
|
| $extreme->error_throw( |
| 841 |
|
| "ifIndex $ifindex is not a bridge port, so its VLANs cannot be set") |
| 842 |
|
| unless defined $bp; |
| 843 |
|
| return $bp; |
| 844 |
|
| } |
| 845 |
|
| |
| 846 |
|
| sub _qb_port_in_list { |
| 847 |
|
| my ( $extreme, $method, $vlan_id, $bp ) = @_; |
| 848 |
|
| my $lists = $extreme->$method() || {}; |
| 849 |
|
| my $list = $lists->{$vlan_id} || []; |
| 850 |
|
| return $list->[ $bp - 1 ]; |
| 851 |
|
| } |
| 852 |
|
| |
| 853 |
|
| sub _qb_port_is_tagged { |
| 854 |
|
| my ( $extreme, $vlan_id, $bp ) = @_; |
| 855 |
|
| return |
| 856 |
|
| unless $extreme->_qb_port_in_list( 'qb_v_egress', $vlan_id, $bp ); |
| 857 |
|
| return !$extreme->_qb_port_in_list( 'qb_v_untagged', $vlan_id, $bp ); |
| 858 |
|
| } |
| 859 |
|
| |
| 860 |
|
| sub _qb_set_egress { |
| 861 |
|
| my ( $extreme, $vlan_id, $bp, $member ) = @_; |
| 862 |
|
| my $egress = $extreme->qb_v_egress() || {}; |
| 863 |
|
| |
| 864 |
|
| unless ( defined $egress->{$vlan_id} ) { |
| 865 |
|
| $extreme->error_throw( |
| 866 |
|
| "VLAN $vlan_id does not exist in dot1qVlanStaticEgressPorts; create it on the device first" |
| 867 |
|
| ); |
| 868 |
|
| return; |
| 869 |
|
| } |
| 870 |
|
| my $portlist = $extreme->modify_port_list( [ @{ $egress->{$vlan_id} } ], |
| 871 |
|
| $bp - 1, $member ); |
| 872 |
|
| return $extreme->set_qb_v_egress( $portlist, $vlan_id ); |
| 873 |
|
| } |
| 874 |
|
| |
| 875 |
|
| # Writing dot1qPvid moves the port's untagged membership to the new VLAN. |
| 876 |
|
| # A VLAN already tagged on the port would stay tagged, leaving the port |
| 877 |
|
| # with no untagged VLAN, so set_i_vlan removes the tag first. |
| 878 |
|
| sub _qb_set_i_vlan { |
| 879 |
|
| my ( $extreme, $is_pvid, $vlan_id, $ifindex ) = @_; |
| 880 |
|
| my $bp = $extreme->_qb_bridge_port($ifindex); |
| 881 |
|
| return unless defined $bp; |
| 882 |
|
| |
| 883 |
|
| if ( $extreme->_qb_port_is_tagged( $vlan_id, $bp ) ) { |
| 884 |
|
| if ($is_pvid) { |
| 885 |
|
| $extreme->error_throw( |
| 886 |
|
| "VLAN $vlan_id is tagged on ifIndex $ifindex and cannot also be its PVID; use set_i_vlan to make it the untagged VLAN" |
| 887 |
|
| ); |
| 888 |
|
| return; |
| 889 |
|
| } |
| 890 |
|
| return unless $extreme->_qb_set_egress( $vlan_id, $bp, '0' ); |
| 891 |
|
| } |
| 892 |
|
| return $extreme->set_qb_i_vlan( $vlan_id, $bp ); |
| 893 |
|
| } |
| 894 |
|
| |
| 895 |
|
| sub _qb_set_i_vlan_tagged { |
| 896 |
|
| my ( $extreme, $member, $vlan_id, $ifindex ) = @_; |
| 897 |
|
| my $bp = $extreme->_qb_bridge_port($ifindex); |
| 898 |
|
| return unless defined $bp; |
| 899 |
|
| |
| 900 |
|
| if ( $extreme->_qb_port_in_list( 'qb_v_untagged', $vlan_id, $bp ) ) { |
| 901 |
|
| $extreme->error_throw( |
| 902 |
|
| "VLAN $vlan_id is untagged on ifIndex $ifindex; use set_i_vlan to change the untagged VLAN" |
| 903 |
|
| ); |
| 904 |
|
| return; |
| 905 |
|
| } |
| 906 |
|
| return $extreme->_qb_set_egress( $vlan_id, $bp, $member ); |
| 907 |
|
| } |
| 908 |
|
| |
| 909 |
|
| # set_i_vlan implicitly turns off any encapsulation |
| 910 |
|
| # set_i_pvid retains any encapsulation |
| 911 |
|
| # otherwise they do the same: set the unencapsulated |
| 912 |
|
| # vlan ID. |
| 913 |
|
| # First arg to _set_i_vlan is whether or not to turn |
| 914 |
|
| # off any encapsulation. |
| 915 |
|
| sub _extreme_set_i_vlan { |
| 916 |
|
| my $extreme = shift; |
| 917 |
|
| my ( $is_pvid, $vlan_id, $ifindex ) = @_; |
| 918 |
|
| my $encap_tag = $extreme->ex_vlan_encap_tag(); |
| 919 |
|
| |
| 920 |
|
| # The inverted stack MIB would make this easier, since |
| 921 |
|
| # we need to find the vlan interface |
| 922 |
|
| # that's stacked above $ifindex. |
| 923 |
|
| my $cur_stack = $extreme->ifStackStatus(); |
| 924 |
|
| |
| 925 |
|
| # |
| 926 |
|
| # create inverted stack |
| 927 |
|
| my $invstack; |
| 928 |
|
| foreach my $idx ( keys %$cur_stack ) { |
| 929 |
|
| my ( $higher, $lower ) = split( /\./, $idx ); |
| 930 |
|
| $invstack->{$lower}->{$higher} = $cur_stack->{$idx}; |
| 931 |
|
| } |
| 932 |
|
| |
| 933 |
|
| # create vlan tag -> encap interface map |
| 934 |
|
| my %encapif = reverse %$encap_tag; |
| 935 |
|
| |
| 936 |
|
| # now find encap interface from tag |
| 937 |
|
| my $encapidx = $encapif{$vlan_id}; |
| 938 |
|
| if ( !defined($encapidx) ) { |
| 939 |
|
| $extreme->error_throw( |
| 940 |
|
| "can't map $vlan_id to encapsulation interface"); |
| 941 |
|
| return; |
| 942 |
|
| } |
| 943 |
|
| |
| 944 |
|
| # now find vlan interface stacked above encap |
| 945 |
|
| my @abovevlan = keys %{ $invstack->{$encapidx} }; |
| 946 |
|
| if ( @abovevlan != 1 ) { |
| 947 |
|
| $extreme->error_throw( |
| 948 |
|
| "can't map encap interface $encapidx for $vlan_id to encapsulation interface" |
| 949 |
|
| ); |
| 950 |
|
| return; |
| 951 |
|
| } |
| 952 |
|
| my $vlanidx = $abovevlan[0]; |
| 953 |
|
| my $rv; |
| 954 |
|
| |
| 955 |
|
| # Delete old VLAN mapping |
| 956 |
|
| foreach my $oldidx ( keys %{ $invstack->{$ifindex} } ) { |
| 957 |
|
| if ( $is_pvid && defined( $encap_tag->{$oldidx} ) ) { |
| 958 |
|
| next; # Don't delete tagged mappings |
| 959 |
|
| } |
| 960 |
|
| $rv = $extreme->set_ifStackStatus( "destroy", |
| 961 |
|
| $oldidx . "." . $ifindex ); |
| 962 |
|
| unless ($rv) { |
| 963 |
|
| $extreme->error_throw( |
| 964 |
|
| "Unable to remove $ifindex from old VLAN index $oldidx"); |
| 965 |
|
| return; |
| 966 |
|
| } |
| 967 |
|
| } |
| 968 |
|
| |
| 969 |
|
| # Add new VLAN mapping |
| 970 |
|
| $rv = $extreme->set_ifStackStatus( "createAndGo", |
| 971 |
|
| $vlanidx . "." . $ifindex ); |
| 972 |
|
| unless ($rv) { |
| 973 |
|
| $extreme->error_throw( |
| 974 |
|
| "Unable to add new VLAN index $vlanidx to ifIndex $ifindex"); |
| 975 |
|
| return; |
| 976 |
|
| } |
| 977 |
|
| |
| 978 |
|
| # XXX invalidate cache of ifstack? |
| 979 |
|
| # XXX Info.pm library function for this? |
| 980 |
|
| # XXX set_ should do invalidation? |
| 981 |
|
| # $store = $extreme->store(); delete $store->{ifStackStatus}; $extreme->store($store); |
| 982 |
|
| # $extreme->{_ifStackStatus} = 0; |
| 983 |
|
| return $rv; |
| 984 |
|
| } |
| 985 |
|
| |
| 986 |
|
| sub set_remove_i_vlan_tagged { |
| 987 |
|
| my $extreme = shift; |
| 988 |
|
| return $extreme->_qb_set_i_vlan_tagged( '0', @_ ) |
| 989 |
|
| unless $extreme->_has_vlan_encaps(); |
| 990 |
|
| |
| 991 |
|
| my ( $vlan_id, $ifindex ) = @_; |
| 992 |
|
| my $encap_tag = $extreme->ex_vlan_encap_tag(); |
| 993 |
|
| |
| 994 |
|
| # create vlan tag -> encap interface map |
| 995 |
|
| my %encapif = reverse %$encap_tag; |
| 996 |
|
| |
| 997 |
|
| # now find encap interface from tag |
| 998 |
|
| my $encapidx = $encapif{$vlan_id}; |
| 999 |
|
| if ( !defined($encapidx) ) { |
| 1000 |
|
| $extreme->error_throw( |
| 1001 |
|
| "can't map $vlan_id to encapsulation interface"); |
| 1002 |
|
| return; |
| 1003 |
|
| } |
| 1004 |
|
| my $rv = $extreme->set_ifStackStatus( "destroy", |
| 1005 |
|
| $encapidx . "." . $ifindex ); |
| 1006 |
|
| unless ($rv) { |
| 1007 |
|
| $extreme->error_throw( |
| 1008 |
|
| "Unable to delete VLAN encap ifIndex $encapidx for VLAN $vlan_id from ifIndex $ifindex" |
| 1009 |
|
| ); |
| 1010 |
|
| return; |
| 1011 |
|
| } |
| 1012 |
|
| |
| 1013 |
|
| # invalidate cache of ifstack? |
| 1014 |
|
| return $rv; |
| 1015 |
|
| } |
| 1016 |
|
| |
| 1017 |
|
| sub set_add_i_vlan_tagged { |
| 1018 |
|
| my $extreme = shift; |
| 1019 |
|
| return $extreme->_qb_set_i_vlan_tagged( '1', @_ ) |
| 1020 |
|
| unless $extreme->_has_vlan_encaps(); |
| 1021 |
|
| |
| 1022 |
|
| my ( $vlan_id, $ifindex ) = @_; |
| 1023 |
|
| my $encap_tag = $extreme->ex_vlan_encap_tag(); |
| 1024 |
|
| |
| 1025 |
|
| # create vlan tag -> encap interface map |
| 1026 |
|
| my %encapif = reverse %$encap_tag; |
| 1027 |
|
| |
| 1028 |
|
| # now find encap interface from tag |
| 1029 |
|
| my $encapidx = $encapif{$vlan_id}; |
| 1030 |
|
| if ( !defined($encapidx) ) { |
| 1031 |
|
| $extreme->error_throw( |
| 1032 |
|
| "can't map $vlan_id to encapsulation interface"); |
| 1033 |
|
| return; |
| 1034 |
|
| } |
| 1035 |
|
| my $rv = $extreme->set_ifStackStatus( "createAndGo", |
| 1036 |
|
| $encapidx . "." . $ifindex ); |
| 1037 |
|
| unless ($rv) { |
| 1038 |
|
| $extreme->error_throw( |
| 1039 |
|
| "Unable to add VLAN encap ifIndex $encapidx for VLAN $vlan_id to ifIndex $ifindex" |
| 1040 |
|
| ); |
| 1041 |
|
| return; |
| 1042 |
|
| } |
| 1043 |
|
| |
| 1044 |
|
| # invalidate cache of ifstack? |
| 1045 |
|
| return $rv; |
| 1046 |
|
| } |
| 1047 |
|
| |
| 1048 |
|
| # LLDP uses the bridge index rather than ifIndex |
| 1049 |
|
| sub lldp_if { |
| 1050 |
|
| my $extreme = shift; |
| 1051 |
|
| my $partial = shift; |
| 1052 |
|
| |
| 1053 |
|
| my $addr = $extreme->lldp_rem_pid($partial) || {}; |
| 1054 |
|
| my $b_index = $extreme->bp_index() || {}; |
| 1055 |
|
| #my %r_i_descr = reverse %$i_descr; |
| 1056 |
|
| |
| 1057 |
|
| my %lldp_if; |
| 1058 |
|
| foreach my $key ( keys %$addr ) { |
| 1059 |
|
| my @aOID = split( '\.', $key ); |
| 1060 |
|
| my $port = $aOID[1]; |
| 1061 |
|
| next unless $port; |
| 1062 |
|
| |
| 1063 |
|
| my $idx = $b_index->{$port}; |
| 1064 |
|
| |
| 1065 |
|
| $lldp_if{$key} = $idx; |
| 1066 |
|
| } |
| 1067 |
|
| return \%lldp_if; |
| 1068 |
|
| } |
| 1069 |
|
| |
| 1070 |
|
| # extremeStpDomainStpdInstance not accessible, so we need to extract from iid |
| 1071 |
|
| sub stp_i_id { |
| 1072 |
|
| my $extreme = shift; |
| 1073 |
|
| my $partial = shift; |
| 1074 |
|
| |
| 1075 |
|
| my $stp_i_roots = $extreme->stp_i_root($partial); |
| 1076 |
|
| |
| 1077 |
|
| my %stp_i_id; |
| 1078 |
|
| foreach my $iid ( keys %$stp_i_roots ) { |
| 1079 |
|
| $stp_i_id{$iid} = $iid; |
| 1080 |
|
| } |
| 1081 |
|
| return \%stp_i_id; |
| 1082 |
|
| } |
| 1083 |
|
| |
| 1084 |
|
| # extremeStpDomainBridgeId returns priority and mac, |
| 1085 |
|
| # for cross class compatibility we just need mac |
| 1086 |
|
| sub stp_i_mac { |
| 1087 |
|
| my $extreme = shift; |
| 1088 |
|
| my $partial = shift; |
| 1089 |
|
| |
| 1090 |
|
| my $stp_i_bids = $extreme->ex_stp_i_mac($partial); |
| 1091 |
|
| |
| 1092 |
|
| my %stp_i_mac; |
| 1093 |
|
| foreach my $iid ( keys %$stp_i_bids ) { |
| 1094 |
|
| my $mac = $stp_i_bids->{$iid}; |
| 1095 |
|
| next unless $mac; |
| 1096 |
|
| |
| 1097 |
|
| $mac =~ s/^([0-9A-F][0-9A-F]:){2}//; |
| 1098 |
|
| |
| 1099 |
|
| $stp_i_mac{$iid} = $mac; |
| 1100 |
|
| } |
| 1101 |
|
| return \%stp_i_mac; |
| 1102 |
|
| } |
| 1103 |
|
| |
| 1104 |
|
| # Break up the extremeStpPortEntry INDEX into Stpd Instance and IfIndex. |
| 1105 |
|
| sub _ex_stpport_index { |
| 1106 |
|
| my $idx = shift; |
| 1107 |
|
| my ( $id, $ifindex ) = split( /\./, $idx); |
| 1108 |
|
| return ($id, $ifindex); |
| 1109 |
|
| } |
| 1110 |
|
| |
| 1111 |
|
| # extremeStpPortPortIfIndex not-accessible, extract from iid |
| 1112 |
|
| sub stp_p_id { |
| 1113 |
|
| my $extreme = shift; |
| 1114 |
|
| my $partial = shift; |
| 1115 |
|
| |
| 1116 |
|
| my $stp_port = $extreme->stp_p_root($partial); |
| 1117 |
|
| my $stp_p_id = {}; |
| 1118 |
|
| foreach my $idx ( keys %$stp_port ) { |
| 1119 |
|
| my ( $id, $ifindex ) = _ex_stpport_index($idx); |
| 1120 |
|
| $stp_p_id->{$idx} = $ifindex; |
| 1121 |
|
| } |
| 1122 |
|
| return $stp_p_id; |
| 1123 |
|
| } |
| 1124 |
|
| |
| 1125 |
|
| # extremeStpDomainStpdInstance not-accessible, extract from iid |
| 1126 |
|
| sub stp_p_stg_id { |
| 1127 |
|
| my $extreme = shift; |
| 1128 |
|
| my $partial = shift; |
| 1129 |
|
| |
| 1130 |
|
| my $stp_port = $extreme->stp_p_root($partial); |
| 1131 |
|
| my $stp_p_stg_id = {}; |
| 1132 |
|
| foreach my $idx ( keys %$stp_port ) { |
| 1133 |
|
| my ( $id, $ifindex ) = _ex_stpport_index($idx); |
| 1134 |
|
| $stp_p_stg_id->{$idx} = $id; |
| 1135 |
|
| } |
| 1136 |
|
| return $stp_p_stg_id; |
| 1137 |
|
| } |
| 1138 |
|
| |
| 1139 |
|
| # stp_p_state here is extremeStpPortTable, keyed <instance>.<ifIndex>, which |
| 1140 |
|
| # matches no bp_index key, so read BRIDGE-MIB directly. |
| 1141 |
|
| sub i_stp_state { |
| 1142 |
|
| my $extreme = shift; |
| 1143 |
|
| my $partial = shift; |
| 1144 |
|
| |
| 1145 |
|
| my $bp_index = $extreme->bp_index($partial); |
| 1146 |
|
| my $stp_p_state = $extreme->dot1dStpPortState($partial); |
| 1147 |
|
| |
| 1148 |
|
| my %i_stp_state; |
| 1149 |
|
| |
| 1150 |
|
| foreach my $index ( keys %$stp_p_state ) { |
| 1151 |
|
| my $state = $stp_p_state->{$index}; |
| 1152 |
|
| my $iid = $bp_index->{$index}; |
| 1153 |
|
| next unless defined $iid; |
| 1154 |
|
| next unless defined $state; |
| 1155 |
|
| $i_stp_state{$iid} = $state; |
| 1156 |
|
| } |
| 1157 |
|
| |
| 1158 |
|
| return \%i_stp_state; |
| 1159 |
|
| } |
| 1160 |
|
| |
| 1161 |
|
| # Keeps the base from reporting the default tree: on EXOS the domains are |
| 1162 |
|
| # the trees |
| 1163 |
|
| sub _stp_default_is_common { return 0; } |
| 1164 |
|
| |
| 1165 |
|
| # dot1dStpVersion: RSTP-MIB names 0 and 2 only, so 3 (MSTP) comes back bare |
| 1166 |
|
| my %ex_stp_version = ( |
| 1167 |
|
| 0 => 'stp', |
| 1168 |
|
| 'stpCompatible' => 'stp', |
| 1169 |
|
| 2 => 'rstp', |
| 1170 |
|
| 'rstp' => 'rstp', |
| 1171 |
|
| 3 => 'mstp', |
| 1172 |
|
| ); |
| 1173 |
|
| |
| 1174 |
|
| sub _ex_stp_version { |
| 1175 |
|
| my $extreme = shift; |
| 1176 |
|
| |
| 1177 |
|
| my $version = $extreme->dot1dStpVersion(); |
| 1178 |
|
| return unless defined $version; |
| 1179 |
|
| return $ex_stp_version{$version}; |
| 1180 |
|
| } |
| 1181 |
|
| |
| 1182 |
|
| sub _ex_stp_pvst_instances { |
| 1183 |
|
| my $extreme = shift; |
| 1184 |
|
| |
| 1185 |
|
| my $modes = $extreme->ex_stp_p_mode() || {}; |
| 1186 |
|
| my %pvst; |
| 1187 |
|
| foreach my $idx ( keys %$modes ) { |
| 1188 |
|
| next unless ( $modes->{$idx} || '' ) eq 'pvstp'; |
| 1189 |
|
| my ($inst) = _ex_stpport_index($idx); |
| 1190 |
|
| $pvst{$inst} = 1; |
| 1191 |
|
| } |
| 1192 |
|
| return \%pvst; |
| 1193 |
|
| } |
| 1194 |
|
| |
| 1195 |
|
| sub hasMSTP { |
| 1196 |
|
| my $extreme = shift; |
| 1197 |
|
| return ( $extreme->_ex_stp_version() || '' ) eq 'mstp' ? 1 : 0; |
| 1198 |
|
| } |
| 1199 |
|
| |
| 1200 |
|
| sub hasRSTP { |
| 1201 |
|
| my $extreme = shift; |
| 1202 |
|
| return ( $extreme->_ex_stp_version() || '' ) eq 'rstp' ? 1 : 0; |
| 1203 |
|
| } |
| 1204 |
|
| |
| 1205 |
|
| sub hasPVST { |
| 1206 |
|
| my $extreme = shift; |
| 1207 |
|
| return keys %{ $extreme->_ex_stp_pvst_instances() } ? 1 : 0; |
| 1208 |
|
| } |
| 1209 |
|
| |
| 1210 |
|
| sub hasSTP { |
| 1211 |
|
| my $extreme = shift; |
| 1212 |
|
| |
| 1213 |
|
| return 0 unless ( $extreme->_ex_stp_version() || '' ) eq 'stp'; |
| 1214 |
|
| my $names = $extreme->ex_stp_i_name() || {}; |
| 1215 |
|
| my $pvst = $extreme->_ex_stp_pvst_instances(); |
| 1216 |
|
| return ( grep { !$pvst->{$_} } keys %$names ) ? 1 : 0; |
| 1217 |
|
| } |
| 1218 |
|
| |
| 1219 |
|
| sub stp_protocols { |
| 1220 |
|
| my $extreme = shift; |
| 1221 |
|
| |
| 1222 |
|
| my @protocols = grep { |
| 1223 |
|
| my $method = 'has' . uc $_; |
| 1224 |
|
| $extreme->$method(); |
| 1225 |
|
| } qw/stp rstp mstp pvst/; |
| 1226 |
|
| return unless @protocols; |
| 1227 |
|
| return \@protocols; |
| 1228 |
|
| } |
| 1229 |
|
| |
| 1230 |
|
| sub stp_trees { |
| 1231 |
|
| my $extreme = shift; |
| 1232 |
|
| |
| 1233 |
|
| return unless $extreme->_stp_default_context_ok(); |
| 1234 |
|
| return $extreme->{_stp_trees} if $extreme->{_stp_trees}; |
| 1235 |
|
| |
| 1236 |
|
| my $names = $extreme->ex_stp_i_name() || {}; |
| 1237 |
|
| return {} unless keys %$names; |
| 1238 |
|
| |
| 1239 |
|
| my $tags = $extreme->ex_stp_i_tag() || {}; |
| 1240 |
|
| my $bids = $extreme->ex_stp_i_mac() || {}; |
| 1241 |
|
| my $roots = $extreme->stp_i_root() || {}; |
| 1242 |
|
| my $pvst = $extreme->_ex_stp_pvst_instances(); |
| 1243 |
|
| my $version = $extreme->_ex_stp_version() || ''; |
| 1244 |
|
| my $device_protocol |
| 1245 |
|
| = ( keys %$names == 1 and length $version ) ? $version : undef; |
| 1246 |
|
| my $measured = ( $extreme->os() || '' ) eq 'xos' ? 1 : 0; |
| 1247 |
|
| |
| 1248 |
|
| my %trees; |
| 1249 |
|
| foreach my $inst ( keys %$names ) { |
| 1250 |
|
| my $tree = { |
| 1251 |
|
| type => 'domain', |
| 1252 |
|
| id => $inst, |
| 1253 |
|
| name => $names->{$inst}, |
| 1254 |
|
| protocol => $pvst->{$inst} ? 'pvst' |
| 1255 |
|
| : $version eq 'stp' ? 'stp' |
| 1256 |
|
| : $device_protocol, |
| 1257 |
|
| measured => $measured, |
| 1258 |
|
| ports_complete => 1, |
| 1259 |
|
| contexts => [ { kind => 'none' } ], |
| 1260 |
|
| bridge => scalar SNMP::Info::Bridge::_stp_decode_bridge_id( |
| 1261 |
|
| $bids->{$inst} ), |
| 1262 |
|
| root => scalar SNMP::Info::Bridge::_stp_decode_bridge_id( |
| 1263 |
|
| $roots->{$inst} ), |
| 1264 |
|
| }; |
| 1265 |
|
| $tree->{vlan} = $tags->{$inst} if $tags->{$inst}; |
| 1266 |
|
| $trees{"domain.$inst"} = $tree; |
| 1267 |
|
| } |
| 1268 |
|
| $extreme->{_stp_trees} = \%trees; |
| 1269 |
|
| return $extreme->{_stp_trees}; |
| 1270 |
|
| } |
| 1271 |
|
| |
| 1272 |
|
| sub stp_tree_ports { |
| 1273 |
|
| my $extreme = shift; |
| 1274 |
|
| my $tree_key = shift; |
| 1275 |
|
| |
| 1276 |
|
| my $trees = $extreme->stp_trees() || {}; |
| 1277 |
|
| my $tree = defined $tree_key ? $trees->{$tree_key} : undef; |
| 1278 |
|
| unless ($tree) { |
| 1279 |
|
| my $key = defined $tree_key ? $tree_key : 'undef'; |
| 1280 |
|
| $extreme->error_throw( |
| 1281 |
|
| "SNMP::Info::Layer3::Extreme::stp_tree_ports() has no tree" |
| 1282 |
|
| . " '$key'. Pass a key from stp_trees(), read in the default" |
| 1283 |
|
| . " context.\n" ); |
| 1284 |
|
| return; |
| 1285 |
|
| } |
| 1286 |
|
| |
| 1287 |
|
| my $states = $extreme->stp_p_state() || {}; |
| 1288 |
|
| my $enable = $extreme->stp_p_enable() || {}; |
| 1289 |
|
| my $d_bridge = $extreme->stp_p_bridge() || {}; |
| 1290 |
|
| my $d_port = $extreme->stp_p_port() || {}; |
| 1291 |
|
| |
| 1292 |
|
| my %tree_ports; |
| 1293 |
|
| foreach my $idx ( keys %$states ) { |
| 1294 |
|
| my ( $inst, $ifindex ) = _ex_stpport_index($idx); |
| 1295 |
|
| next unless $inst eq $tree->{id}; |
| 1296 |
|
| $tree_ports{$ifindex} = { |
| 1297 |
|
| tree_type => $tree->{type}, |
| 1298 |
|
| tree_id => $tree->{id}, |
| 1299 |
|
| state => $states->{$idx}, |
| 1300 |
|
| role => undef, |
| 1301 |
|
| role_raw => undef, |
| 1302 |
|
| enabled => |
| 1303 |
|
| scalar SNMP::Info::Bridge::_stp_enabled( $enable->{$idx} ), |
| 1304 |
|
| designated_bridge => |
| 1305 |
|
| scalar SNMP::Info::Bridge::_stp_decode_bridge_id( |
| 1306 |
|
| $d_bridge->{$idx} ), |
| 1307 |
|
| designated_port => scalar SNMP::Info::Bridge::_stp_decode_port_id( |
| 1308 |
|
| $d_port->{$idx} ), |
| 1309 |
|
| }; |
| 1310 |
|
| } |
| 1311 |
|
| return \%tree_ports; |
| 1312 |
|
| } |
| 1313 |
|
| |
| 1314 |
|
| sub stp_trees_complete { |
| 1315 |
|
| my $extreme = shift; |
| 1316 |
|
| |
| 1317 |
|
| my $trees = $extreme->stp_trees() || {}; |
| 1318 |
|
| return 0 if $extreme->_stp_walk_incomplete('ex_stp_i_name'); |
| 1319 |
|
| return keys %$trees ? 1 : 0; |
| 1320 |
|
| } |
| 1321 |
|
| |
| 1322 |
|
| # extremeStpVlanPortTable is indexed <vlan ifIndex>.<domain instance> |
| 1323 |
|
| sub stp_vlan_map { |
| 1324 |
|
| my $extreme = shift; |
| 1325 |
|
| |
| 1326 |
|
| my $rows = $extreme->ex_stp_vlan_mask() || {}; |
| 1327 |
|
| my $vlan_ids = $extreme->ex_vlan_id() || {}; |
| 1328 |
|
| |
| 1329 |
|
| my %map; |
| 1330 |
|
| foreach my $idx ( keys %$rows ) { |
| 1331 |
|
| my ( $vlan_if, $inst ) = split /\./, $idx; |
| 1332 |
|
| my $vlan = $vlan_ids->{$vlan_if}; |
| 1333 |
|
| next unless defined $vlan; |
| 1334 |
|
| $map{$vlan} = "domain.$inst"; |
| 1335 |
|
| } |
| 1336 |
|
| return unless keys %map; |
| 1337 |
|
| return \%map; |
| 1338 |
|
| } |
| 1339 |
|
| |
| 1340 |
|
| # EXOS serves mplsL3VpnConfiguredVrfs 0 and no VRF row while VRs and VRFs |
| 1341 |
|
| # are configured: they answer only as SNMPv3 contexts, so a zero from that |
| 1342 |
|
| # MIB is no evidence of none |
| 1343 |
|
| sub vrf_instances_complete { |
| 1344 |
|
| my $extreme = shift; |
| 1345 |
|
| |
| 1346 |
|
| my $complete = $extreme->SUPER::vrf_instances_complete(@_); |
| 1347 |
|
| return $complete unless $complete and ( $extreme->os() || '' ) eq 'xos'; |
| 1348 |
|
| return; |
| 1349 |
|
| } |
| 1350 |
|
| |
| 1351 |
|
| sub _exos_vrf_context { return ( $_[0]->os() || '' ) eq 'xos' ? 1 : 0; } |
| 1352 |
|
| |
| 1353 |
|
| # Each EXOS virtual router is an SNMPv3 context named like it; there is no |
| 1354 |
|
| # v2c form. |
| 1355 |
|
| sub _context_kinds { |
| 1356 |
|
| my ( $extreme, $feature ) = @_; |
| 1357 |
|
| |
| 1358 |
|
| return |
| 1359 |
|
| unless ( $feature // '' ) eq 'vrf' and $extreme->_exos_vrf_context(); |
| 1360 |
|
| return ['vrf']; |
| 1361 |
|
| } |
| 1362 |
|
| |
| 1363 |
|
| sub _snmp_context { |
| 1364 |
|
| my ( $extreme, $kind, $id ) = @_; |
| 1365 |
|
| |
| 1366 |
|
| return unless ( $kind // '' ) eq 'vrf' and $extreme->_exos_vrf_context(); |
| 1367 |
|
| return if !defined $id or $id eq q() or $id eq 'default'; |
| 1368 |
|
| return { kind => 'vrf', id => $id, v2c => undef, v3 => $id }; |
| 1369 |
|
| } |
| 1370 |
|
| |
| 1371 |
|
| # Each virtual router reads in its own context, named for it. EXOS serves |
| 1372 |
|
| # the same address table in every context and scopes only routes and |
| 1373 |
|
| # neighbors, so the ports of a context are those its routes use. |
| 1374 |
|
| sub _vrf_context_filters { return $_[0]->_exos_vrf_context(); } |
| 1375 |
|
| sub _vrf_context_is_instance_name { return $_[0]->_exos_vrf_context(); } |
| 1376 |
|
| sub _vrf_context_ports_from_routes { return $_[0]->_exos_vrf_context(); } |
| 1377 |
|
| sub _vrf_subnets_from_routes { return $_[0]->_exos_vrf_context(); } |
| 1378 |
|
| |
| 1379 |
|
| # EXOS puts a VLAN's IPv4 routes on its router interface, ifName |
| 1380 |
|
| # "<vlan> rtif(<address>)", and the VLAN's addresses on the interface named |
| 1381 |
|
| # "<vlan>", so a router interface adds its VLAN's. EXOS forbids two VLANs of |
| 1382 |
|
| # one name. ifName decides membership, so it counts toward the read. |
| 1383 |
|
| sub _vrf_route_ports { |
| 1384 |
|
| my ( $extreme, $name ) = @_; |
| 1385 |
|
| |
| 1386 |
|
| my $ports = $extreme->SUPER::_vrf_route_ports($name); |
| 1387 |
|
| return $ports unless $extreme->_exos_vrf_context(); |
| 1388 |
|
| |
| 1389 |
|
| my $if_names = $extreme->_vrf_column( 'orig_i_name', $name, 'i_name' ); |
| 1390 |
|
| my %port_named |
| 1391 |
|
| = map { $if_names->{$_} => $_ } sort { $a <=> $b } keys %$if_names; |
| 1392 |
|
| foreach my $port ( keys %$ports ) { |
| 1393 |
|
| my ($vlan) = ( $if_names->{$port} // q{} ) =~ /^(.+) rtif\(/ |
| 1394 |
|
| or next; |
| 1395 |
|
| $ports->{ $port_named{$vlan} } = $name if exists $port_named{$vlan}; |
| 1396 |
|
| } |
| 1397 |
|
| return $ports; |
| 1398 |
|
| } |
| 1399 |
|
| |
| 1400 |
|
| 1; |
| 1401 |
|
| |
| 1402 |
|
| __END__ |