Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
143
Issues
143
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
emulab
emulab-devel
Commits
1270ab88
Commit
1270ab88
authored
Sep 01, 2010
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git-public.flux.utah.edu:/flux/git/emulab-devel
parents
415f7db4
645a8bd3
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
748 additions
and
472 deletions
+748
-472
install/ports/emulab-boss/Makefile
install/ports/emulab-boss/Makefile
+5
-0
tbsetup/libvtop.pm.in
tbsetup/libvtop.pm.in
+3
-0
tbsetup/nsverify/GNUmakefile.in
tbsetup/nsverify/GNUmakefile.in
+14
-32
tbsetup/nsverify/ns-2.34.patch
tbsetup/nsverify/ns-2.34.patch
+100
-0
tbsetup/nsverify/ns-fetch.sh
tbsetup/nsverify/ns-fetch.sh
+60
-0
tbsetup/nsverify/tclcl-1.19.patch
tbsetup/nsverify/tclcl-1.19.patch
+26
-0
tbsetup/snmpit.in
tbsetup/snmpit.in
+24
-23
tbsetup/snmpit_cisco.pm
tbsetup/snmpit_cisco.pm
+128
-82
tbsetup/snmpit_hp.pm
tbsetup/snmpit_hp.pm
+137
-73
tbsetup/snmpit_nortel.pm
tbsetup/snmpit_nortel.pm
+195
-248
tbsetup/snmpit_stack.pm
tbsetup/snmpit_stack.pm
+5
-0
tmcd/common/config/rc.mkelab
tmcd/common/config/rc.mkelab
+44
-12
tmcd/tmcd.c
tmcd/tmcd.c
+2
-2
tools/git/gitmail
tools/git/gitmail
+5
-0
No files found.
install/ports/emulab-boss/Makefile
View file @
1270ab88
...
...
@@ -86,6 +86,10 @@ LIB_DEPENDS= gd.4:${PORTSDIR}/graphics/gd \
snmp.4:
${PORTSDIR}
/net-mgmt/net-snmp4
\
ulsshxmlrpcpp.0:
${PORTSDIR}
/misc/ulsshxmlrpcpp
.if
${OSMAJOR}
>=
6
LIB_DEPENDS
+=
xerces-c.27:
${PORTSDIR}
/textproc/xerces-c2
.
endif
#
# Until/unless the pubsub Makefile is changed, we must include libelvin.
# This is because the pubsub libraries have to be built with ELVIN_COMPAT
...
...
@@ -197,3 +201,4 @@ vars:
@
echo
"BUILD_DEPENDS=
$(BUILD_DEPENDS)
"
@
echo
"LIB_DEPENDS=
$(LIB_DEPENDS)
"
@
echo
"RUN_DEPENDS=
$(RUN_DEPENDS)
"
@
echo
"PERL_VER/ARCH=
${PERL_VER}
/
${PERL_ARCH}
"
tbsetup/libvtop.pm.in
View file @
1270ab88
...
...
@@ -2798,6 +2798,9 @@ sub GenVirtLans($)
if
($
emulated
)
{
$
others
->{
'emulated'
}
=
1
;
}
if
($
layer
==
1
)
{
$
protocol
=
"wire"
;
}
if
($
trivial_ok
)
{
$
others
->{
'trivial_ok'
}
=
1
;
...
...
tbsetup/nsverify/GNUmakefile.in
View file @
1270ab88
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# Copyright (c) 2006
-2010
University of Utah and the Flux Group.
# All rights reserved.
#
...
...
@@ -12,12 +12,12 @@ TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../..
SUBDIR = tbsetup/nsverify
NS_VERSION=2.29
NS_TAR_VERSION=2.29.2
TCLCL_VERSION=1.17
NS_SRC_TARBALL=ns-allinone-$(NS_TAR_VERSION).tar.gz
# XXX these need to be in synch with ns-fetch.sh
NS_VERSION=2.34
TCLCL_VERSION=1.19
NS_SRC_TARBALL=ns-allinone-$(NS_VERSION).tar.gz
LOCALPKGHOST = @OUTERBOSS_NODENAME@
PKGHOST = www.emulab.net
FETCH = fetch -m
include $(OBJDIR)/Makeconf
...
...
@@ -46,31 +46,9 @@ post-install:
chmod u+s $(INSTALL_LIBEXECDIR)/verify-ns
ns-allinone-$(NS_VERSION):
@if test -f /share/tarballs/$(NS_SRC_TARBALL); then \
echo "Unpacking $(NS_SRC_TARBALL)"; \
tar xfz /share/tarballs/$(NS_SRC_TARBALL); \
else \
( echo "Downloading $(NS_SRC_TARBALL)"; \
if [ -n "$(LOCALPKGHOST)" ]; then \
$(FETCH) http://$(LOCALPKGHOST)/downloads/$(NS_SRC_TARBALL);\
fi ; \
if [ ! -s $(NS_SRC_TARBALL) ]; then \
$(FETCH) http://$(PKGHOST)/downloads/$(NS_SRC_TARBALL); \
fi ;\
echo "Unpacking $(NS_SRC_TARBALL)"; \
tar xfz $(NS_SRC_TARBALL); ) \
fi
patch-ns-$(NS_VERSION):
patch -d ns-allinone-$(NS_VERSION)/ns-$(NS_VERSION) \
< $(SRCDIR)/ns-$(NS_VERSION).patch
if test -e $(SRCDIR)/tclcl-$(TCLCL_VERSION).patch; then \
patch -d ns-allinone-$(NS_VERSION)/tclcl-$(TCLCL_VERSION) \
< $(SRCDIR)/tclcl-$(TCLCL_VERSION).patch; \
fi
touch $@
nstb: ns-allinone-$(NS_VERSION) patch-ns-$(NS_VERSION)
$(SRCDIR)/ns-fetch.sh $(SRCDIR) $(NS_SRC_TARBALL) $(LOCALPKGHOST)
nstb: ns-allinone-$(NS_VERSION)
@cd $</tclcl-$(TCLCL_VERSION); \
./configure --with-tcl=/usr/local; \
$(MAKE)
...
...
@@ -79,7 +57,7 @@ nstb: ns-allinone-$(NS_VERSION) patch-ns-$(NS_VERSION)
$(MAKE)
cp $</ns-$(NS_VERSION)/ns $@
control-install: nstb \
control-install:
$(LIB_STUFF) $(LIBEXEC_STUFF)
nstb \
$(addprefix $(INSTALL_LIBDIR)/nsverify/, $(LIB_STUFF)) \
$(addprefix $(INSTALL_LIBEXECDIR)/nsverify/, $(LIBEXEC_STUFF) nstb)
...
...
@@ -104,3 +82,7 @@ $(INSTALL_DIR)/opsdir/libexec/nsverify/%: %
$(INSTALL) $< $@
clean:
rm -f $(LIB_STUFF) $(LIBEXEC_STUFF) $(BOSSLIBEXEC)
reallyclean:
rm -rf ns-allinone-$(NS_VERSION) $(NS_SRC_TARBALL)
tbsetup/nsverify/ns-2.34.patch
0 → 100644
View file @
1270ab88
diff -ur ./aomdv/aomdv.cc ../../ns-allinone-2.34-patched/ns-2.34/aomdv/aomdv.cc
--- ./aomdv/aomdv.cc 2009-06-14 10:35:44.000000000 -0700
+++ ../../ns-allinone-2.34-patched/ns-2.34/aomdv/aomdv.cc 2009-12-21 18:59:34.000000000 -0800
@@ -86,6 +86,7 @@
#include <aomdv/aomdv_packet.h>
#include <random.h>
#include <cmu-trace.h>
+#include <sys/socket.h>
//#include <energy-model.h>
#define max(a,b) ( (a) > (b) ? (a) : (b) )
diff -ur ./tcl/lan/vlan.tcl ../../ns-allinone-2.34-patched/ns-2.34/tcl/lan/vlan.tcl
--- ./tcl/lan/vlan.tcl 2009-06-14 10:35:40.000000000 -0700
+++ ../../ns-allinone-2.34-patched/ns-2.34/tcl/lan/vlan.tcl 2009-12-21 18:56:42.000000000 -0800
@@ -143,8 +143,12 @@
$src add-neighbor $self
set sid [$src id]
- set link_($sid:$id_) [new Vlink $ns_ $self $src $self $bw 0]
- set link_($id_:$sid) [new Vlink $ns_ $self $self $src $bw 0]
+ set link_($sid:$id_) [new Vlink $ns_ $self $src $self $bw $delay]
+ set link_($id_:$sid) [new Vlink $ns_ $self $self $src $bw $delay]
+
+ # linktest: add to the linktest set of links.
+ $ns_ addLTLink $sid:$id_
+ $ns_ addLTLink $id_:$sid
$src add-oif [$link_($sid:$id_) head] $link_($sid:$id_)
$src add-iif [[$nif set iface_] label] $link_($id_:$sid)
@@ -520,6 +524,12 @@
$lan addNode $nodelist $bw $delay $llType $ifqType $macType \
$phyType $mactrace $ifqLen
+ # linktest renaming
+ $self instvar id_counter
+ $lan set tbaltname_ tblan-lan[incr id_counter]
+ global last_lan
+ real_set last_lan $lan
+
return $lan
}
diff -ur ./tcl/lib/ns-lib.tcl ../../ns-allinone-2.34-patched/ns-2.34/tcl/lib/ns-lib.tcl
--- ./tcl/lib/ns-lib.tcl 2009-06-14 10:35:41.000000000 -0700
+++ ../../ns-allinone-2.34-patched/ns-2.34/tcl/lib/ns-lib.tcl 2009-12-21 18:56:42.000000000 -0800
@@ -261,6 +261,11 @@
$self multicast $args
}
eval $self next $args
+
+ # linktest renaming
+ $self set id_counter 0
+ global last_sim
+ real_set last_sim $self
}
Simulator instproc nullagent {} {
@@ -587,6 +592,13 @@
$node set ns_ $self
$self check-node-num
+
+ # linktest renaming
+ $self instvar id_counter
+ $node set tbaltname_ tbnode-n[incr id_counter]
+ global last_host
+ real_set last_host $node
+
return $node
}
@@ -1232,6 +1244,28 @@
$n1 set-neighbor [$n2 id]
$n2 set-neighbor [$n1 id]
}
+
+ ### linktest -- set up DupLink class to return
+ set dup [new Duplink]
+ $dup set from $link_($i1:$i2)
+ $dup set to $link_($i2:$i1)
+
+ # add the duplink ref to the simplex links.
+ $link_($i1:$i2) set linkRef_ $dup
+ $link_($i2:$i1) set linkRef_ $dup
+
+ # and add to the linktest list of links.
+ $self addLTLink $i1:$i2 $type
+ $self addLTLink $i2:$i1 $type
+
+ $self instvar id_counter
+ $dup set tbaltname_ tblink-l[incr id_counter]
+
+ # naming
+ global last_link
+ real_set last_link $dup
+
+ return $dup
}
Simulator instproc duplex-intserv-link { n1 n2 bw pd sched signal adc args } {
tbsetup/nsverify/ns-fetch.sh
0 → 100755
View file @
1270ab88
#!/bin/sh
version
=
2.34
tclversion
=
1.19
srcurl
=
"http://heanet.dl.sourceforge.net/project/nsnam/allinone/ns-allinone-
$version
"
tarball
=
"ns-allinone-
$version
.tar.gz"
if
[
-x
/usr/bin/fetch
]
;
then
fetch
=
/usr/bin/fetch
elif
[
-x
/usr/bin/wget
]
;
then
fetch
=
/usr/bin/wget
else
echo
"ERROR: ns-fetch.sh: need either 'fetch' or 'wget' installed"
exit
1
fi
if
[
-n
"
$1
"
]
;
then
srcdir
=
$1
;
else
srcdir
=
$PWD
;
fi
if
[
-n
"
$2
"
]
;
then
tarball
=
$2
;
fi
if
[
-n
"
$3
"
]
;
then
host
=
$3
;
else
host
=
www.emulab.net
;
fi
# XXX do not use $PWD as it can be set wrong due to an old (<3.82) gmake bug
dir
=
`
pwd
`
if
[
!
-d
$dir
/ns-allinone-
$version
]
;
then
if
[
!
-f
"
$tarball
"
]
;
then
cd
$dir
# since this is such a big bubba, grab from /share rather than http
if
[
-f
/share/tarballs/
$tarball
]
;
then
echo
"Using NFS cached version ..."
tarball
=
/share/tarballs/
$tarball
else
echo
"Downloading ns source from
$host
to
$dir
..."
$fetch
http://
$host
/
$tarball
if
[
$?
-ne
0
]
;
then
echo
"Failed..."
echo
"Downloading ns source from
$srcurl
to
$dir
..."
$fetch
$srcurl
/
$tarball
||
{
echo
"ERROR: ns-fetch:
$fetch
failed"
exit
1
}
fi
fi
fi
echo
"Unpacking/patching ns-
$version
source ..."
tar
xzof
$tarball
||
{
echo
"ERROR: ns-fetch.sh: tar failed"
exit
1
}
patch
-d
ns-allinone-
$version
/ns-
$version
<
$srcdir
/ns-
$version
.patch
||
{
echo
"ERROR: ns-fetch.sh: patch failed"
exit
1
}
if
[
-e
$srcdir
/tclcl-
$tclversion
.patch
]
;
then
\
echo
"Patching tclcl-
$tclversion
..."
patch
-d
ns-allinone-
$version
/tclcl-
$tclversion
\
<
$srcdir
/tclcl-
$tclversion
.patch
;
\
fi
find
.
-name
'*.orig'
-exec
rm
-f
'{}'
\;
fi
exit
0
tbsetup/nsverify/tclcl-1.19.patch
0 → 100644
View file @
1270ab88
diff -ur ./conf/configure.in.tcl ../../ns-allinone-2.34-patched/tclcl-1.19/conf/configure.in.tcl
--- ./conf/configure.in.tcl 2009-06-14 10:35:03.000000000 -0700
+++ ../../ns-allinone-2.34-patched/tclcl-1.19/conf/configure.in.tcl 2009-12-21 18:10:39.000000000 -0800
@@ -99,6 +99,9 @@
$d/include/tcl$TCL_HI_VERS \
$d/include/tcl$TCL_VERS \
$d/include/tcl$TCL_ALT_VERS \
+ $d/include/tcl$TCL_HI_VERS/generic \
+ $d/include/tcl$TCL_VERS/generic \
+ $d/include/tcl$TCL_ALT_VERS/generic \
$d/include \
/usr/local/include \
"
diff -ur ./configure ../../ns-allinone-2.34-patched/tclcl-1.19/configure
--- ./configure 2009-06-14 10:35:03.000000000 -0700
+++ ../../ns-allinone-2.34-patched/tclcl-1.19/configure 2009-12-21 18:15:38.000000000 -0800
@@ -6014,6 +6014,9 @@
$d/include/tcl$TCL_HI_VERS \
$d/include/tcl$TCL_VERS \
$d/include/tcl$TCL_ALT_VERS \
+ $d/include/tcl$TCL_HI_VERS/generic \
+ $d/include/tcl$TCL_VERS/generic \
+ $d/include/tcl$TCL_ALT_VERS/generic \
$d/include \
/usr/local/include \
"
tbsetup/snmpit.in
View file @
1270ab88
...
...
@@ -1061,28 +1061,28 @@ sub doListVlans ($) {
# We need to 'coallate' the results from each stack by putting together
# the results from each stack, based on the VLAN identifier
#
if
(
$ELABINELAB
)
{
#
# Sklower deliberately uglified this. The intent is that eventually
# $stack->listVlans() will call a $<remotedevobj>->listVlans() and
# it will just work. For now, we dup the code.
#
@vlanList
=
RemoteDoList
();
foreach
my
$vlan
(
@vlanList
)
{
my
(
$id
,
$ddep
,
$memberref
)
=
@$vlan
;
$
{
$vlans
{
$id
}}[
0
]
=
$ddep
;
push
@
{
$
{
$vlans
{
$id
}}[
1
]},
@$memberref
;
}
}
else
{
foreach
my
$stack
(
@$stacks
)
{
@vlanList
=
$stack
->
listVlans
();
foreach
my
$vlan
(
@vlanList
)
{
my
(
$id
,
$ddep
,
$memberref
)
=
@$vlan
;
$
{
$vlans
{
$id
}}[
0
]
=
$ddep
;
push
@
{
$
{
$vlans
{
$id
}}[
1
]},
@$memberref
;
}
if
(
$ELABINELAB
)
{
#
# Sklower deliberately uglified this. The intent is that eventually
# $stack->listVlans() will call a $<remotedevobj>->listVlans() and
# it will just work. For now, we dup the code.
#
@vlanList
=
RemoteDoList
();
foreach
my
$vlan
(
@vlanList
)
{
my
(
$id
,
$ddep
,
$memberref
)
=
@$vlan
;
$
{
$vlans
{
$id
}}[
0
]
=
$ddep
;
push
@
{
$
{
$vlans
{
$id
}}[
1
]},
@$memberref
;
}
}
else
{
foreach
my
$stack
(
@$stacks
)
{
@vlanList
=
$stack
->
listVlans
();
foreach
my
$vlan
(
@vlanList
)
{
my
(
$id
,
$ddep
,
$memberref
)
=
@$vlan
;
$
{
$vlans
{
$id
}}[
0
]
=
$ddep
;
push
@
{
$
{
$vlans
{
$id
}}[
1
]},
@$memberref
;
}
}
}
}
#
# less code to do this for snmpit.proxy than for it to popen snmpit
...
...
@@ -1142,8 +1142,9 @@ $vlan_id,$ddep, $pideid, $vname, $members
my
$vlan
=
VLan
->
Lookup
(
$vlan_id
);
if
(
!
defined
(
$vlan
))
{
&debug
("
No such VLAN
$vlan_id
in lans table
\n
");
next
if
(
$opt
{
l
}
==
1
);
# Only print unknown VLANs if -l was given twice, or the
# -O option was given
next
unless
(
$opt
{
l
}
>
1
||
$opt
{
O
});
$vname
=
$vlan_id
;
$experiment
=
undef
;
}
...
...
tbsetup/snmpit_cisco.pm
View file @
1270ab88
...
...
@@ -56,11 +56,6 @@ my $PORT_FORMAT_IFINDEX = 1;
my
$PORT_FORMAT_MODPORT
=
2
;
my
$PORT_FORMAT_NODEPORT
=
3
;
#
# used by vlanTrunkUtil()
#
my
(
$VOP_CLEAR
,
$VOP_SET
,
$VOP_CLEARALL
,
$VOP_CHECK
)
=
(
0
,
1
,
2
,
3
);
#
# Creates a new object.
#
...
...
@@ -113,6 +108,17 @@ sub new($$$;$) {
return
undef
;
}
#
# Cisco considers anything over 1k an 'extended' VLAN. There are some
# issues with supporing these on certain devices, so we want to know if
# we'll ever be called on to make VLANs in the extended range.
#
if
(
$self
->
{
MAX_VLAN
}
>
1000
)
{
$self
->
{
EXTENDED_VLANS
}
=
1
;
}
else
{
$self
->
{
EXTENDED_VLANS
}
=
0
;
}
if
(
$community
)
{
# Allow this to over-ride the default
$self
->
{
COMMUNITY
}
=
$community
;
}
else
{
...
...
@@ -948,16 +954,15 @@ sub createVlan($$;$$$) {
}
#
#
Either add or remove the given ports from the given VLAN. The VLAN is given
#
as a cisco-specific
VLAN number
#
Put the given ports in the given VLAN. The VLAN is given as a cisco-specific
# VLAN number
#
# usage:
opPortVlan($self, $remove
, $vlan_number, @ports)
# usage:
setPortVlan($self
, $vlan_number, @ports)
# returns 0 on sucess.
# returns the number of failed ports on failure.
#
sub
opPortVlan
($
$$@)
{
sub
setPortVlan
(
$$@)
{
my
$self
=
shift
;
my
$remove
=
shift
;
my
$vlan_number
=
shift
;
my
@ports
=
@_
;
...
...
@@ -1038,16 +1043,11 @@ sub opPortVlan($$$@) {
$errors
++
;
next
;
}
my
$snmpvar
=
[
$PortVlanMemb
,
$index
,
(
$remove
?
1
:
$vlan_number
),
'
INTEGER
'];
my
$snmpvar
=
[
$PortVlanMemb
,
$index
,
$vlan_number
,'
INTEGER
'];
#
# Check to see if we are already in a VLAN
#
$retval
=
snmpitGet
(
$self
->
{
SESS
},[
$PortVlanMemb
,
$index
]);
if
(
$remove
&&
(
$retval
ne
$vlan_number
))
{
$errors
++
;
next
;
}
if
((
$retval
ne
"
NOSUCHINSTANCE
")
&&
("
$retval
"
ne
"
$vlan_number
")
&&
("
$retval
"
ne
"
1
"))
{
$BumpedVlans
{
$retval
}
=
1
;
...
...
@@ -1060,8 +1060,7 @@ sub opPortVlan($$$@) {
#
# We're here if it a trunk
#
$retval
=
$self
->
setVlansOnTrunk
(
$port
,
!
$remove
,
$vlan_number
);
next
if
(
$retval
);
# should not enable or disable existing trunks
$retval
=
$self
->
setVlansOnTrunk
(
$port
,
1
,
$vlan_number
);
}
if
(
!
$retval
)
{
$errors
++
;
...
...
@@ -1075,7 +1074,7 @@ sub opPortVlan($$$@) {
# Ports going into VLAN 1 are being taken out of circulation, so we
# disable them. Otherwise, we need to make sure they get enabled.
#
if
(
(
$vlan_number
==
1
)
||
$remove
)
{
if
(
$vlan_number
==
1
)
{
$self
->
debug
("
Disabling
"
.
join
('
,
',
@okports
)
.
"
...
");
if
(
my
$rv
=
$self
->
portControl
("
disable
",
@okports
)
)
{
print
STDERR
"
Port disable had
$rv
failures.
\n
";
...
...
@@ -1101,19 +1100,6 @@ sub opPortVlan($$$@) {
return
$errors
;
}
#
# Put the given ports in the given VLAN. The VLAN is given as a cisco-specific
# VLAN number
#
# usage: setPortVlan($self, $vlan_number, @ports)
# returns 0 on sucess.
# returns the number of failed ports on failure.
#
sub
setPortVlan
($$@)
{
my
(
$self
,
$vlan_number
,
@ports
)
=
@_
;
return
opPortVlan
(
$self
,
0
,
$vlan_number
,
@ports
);
}
#
# Remove all ports from the given VLANs, which are given as Cisco-specific
# VLAN numbers
...
...
@@ -1125,7 +1111,6 @@ sub setPortVlan($$@) {
sub
removePortsFromVlan
($@)
{
my
$self
=
shift
;
my
@vlan_numbers
=
@_
;
my
$errors
=
0
;
#
# Make sure the VLANs actually exist
...
...
@@ -1133,8 +1118,7 @@ sub removePortsFromVlan($@) {
foreach
my
$vlan_number
(
@vlan_numbers
)
{
if
(
!
$self
->
vlanNumberExists
(
$vlan_number
))
{
print
STDERR
"
ERROR: VLAN
$vlan_number
does not exist
\n
";
$errors
++
;
next
;
return
1
;
}
}
...
...
@@ -1153,49 +1137,23 @@ sub removePortsFromVlan($@) {
}
elsif
(
$self
->
{
OSTYPE
}
eq
"
IOS
")
{
$VlanPortVlan
=
"
vmVlan
";
#index is ifIndex
}
my
%
ports
;
my
@
ports
;
#
# Walk the tree to find VLAN membership
#
my
(
$rows
)
=
snmpitBulkwalkFatal
(
$self
->
{
SESS
},[
$VlanPortVlan
]);
foreach
my
$rowref
(
@$rows
)
{
my
(
$name
,
$
ifIndex
,
$port_vlan_number
)
=
@$rowref
;
$self
->
debug
("
Got
$name
$
ifIndex
$port_vlan_number
\n
");
my
(
$name
,
$
modport
,
$port_vlan_number
)
=
@$rowref
;
$self
->
debug
("
Got
$name
$
modport
$port_vlan_number
\n
");
if
(
$vlan_numbers
{
$port_vlan_number
})
{
push
@
{
$ports
{
$port_vlan_number
}},
$ifIndex
;
push
@
ports
,
$modport
;
}
}
my
%trunks
;
#
# Walk trunks for the VLAN members
#
(
$rows
)
=
snmpitBulkwalkFatal
(
$self
->
{
SESS
},["
vlanTrunkPortDynamicStatus
"]);
foreach
my
$rowref
(
@$rows
)
{
my
(
$name
,
$ifIndex
,
$status
)
=
@$rowref
;
$self
->
debug
("
Got
$name
$ifIndex
$status
\n
",
3
);
if
(
$status
ne
"
trunking
")
{
next
;}
# Get the allowed VLANs on this trunk
my
@trunklans
=
$self
->
vlanTrunkUtil
(
$VOP_CHECK
,
$ifIndex
,
@vlan_numbers
);
foreach
my
$vlan_number
(
@trunklans
)
{
$self
->
debug
("
got vlan
$vlan_number
on trunk
$ifIndex
\n
",
3
);
push
@
{
$trunks
{
$vlan_number
}},
$ifIndex
;
}
}
while
(
my
(
$number
,
$plist
)
=
each
%trunks
)
{
foreach
my
$ifIndex
(
@$plist
)
{
$errors
+=
!
$self
->
setVlansOnTrunk
(
$ifIndex
,
0
,
$number
);
}
}
$self
->
debug
("
About to remove ports
"
.
join
("
,
",(
%ports
))
.
"
\n
");
if
(
%ports
)
{
while
(
my
(
$port_vlan_number
,
$plist
)
=
each
%ports
)
{
$errors
+=
$self
->
opPortVlan
(
1
,
$port_vlan_number
,
@$plist
);
}
return
$errors
;
$self
->
debug
("
About to remove ports
"
.
join
("
,
",
@ports
)
.
"
\n
");
if
(
@ports
)
{
return
$self
->
setPortVlan
(
1
,
@ports
);
}
else
{
return
0
;
}
...
...
@@ -1203,7 +1161,7 @@ sub removePortsFromVlan($@) {
#
# Remove some ports from the given VLAN, which are given as Cisco-specific
# VLAN numbers.
# VLAN numbers.
Do not specify trunked ports here.
#
# usage: removeSomePortsFromVlan(self,int vlan, ports)
# returns 0 on sucess.
...
...
@@ -1214,7 +1172,55 @@ sub removeSomePortsFromVlan($$@) {
my
$vlan_number
=
shift
;
my
@ports
=
@_
;
return
opPortVlan
(
$self
,
1
,
$vlan_number
,
@ports
);
#
# Make sure the VLANs actually exist
#
if
(
!
$self
->
vlanNumberExists
(
$vlan_number
))
{
print
STDERR
"
ERROR: VLAN
$vlan_number
does not exist
\n
";
return
1
;
}
#
# Make a hash of the ports for easy lookup later.
#
my
%ports
=
();
@ports
{
@ports
}
=
@ports
;
#
# Get a list of the ports in the VLAN
#
my
$VlanPortVlan
;
if
(
$self
->
{
OSTYPE
}
eq
"
CatOS
")
{
$VlanPortVlan
=
"
vlanPortVlan
";
#index is ifIndex
}
elsif
(
$self
->
{
OSTYPE
}
eq
"
IOS
")
{
$VlanPortVlan
=
"
vmVlan
";
#index is ifIndex
}
my
@remports
;
#
# Walk the tree to find VLAN membership
#
my
(
$rows
)
=
snmpitBulkwalkFatal
(
$self
->
{
SESS
},[
$VlanPortVlan
]);
foreach
my
$rowref
(
@$rows
)
{
my
(
$name
,
$modport
,
$port_vlan_number
)
=
@$rowref
;
my
(
$trans
)
=
convertPortFormat
(
$PORT_FORMAT_NODEPORT
,
$modport
);
if
(
!
defined
$trans
)
{
$trans
=
"";
# Guard against some uninitialized value warnings
}
$self
->
debug
("
Got
$name
$modport
(
$trans
)
$port_vlan_number
\n
");
push
(
@remports
,
$modport
)
if
("
$port_vlan_number
"
eq
"
$vlan_number
"
&&
exists
(
$ports
{
$trans
}));
}
$self
->
debug
("
About to remove ports
"
.
join
("
,
",
@remports
)
.
"
\n
");
if
(
@remports
)
{
return
$self
->
setPortVlan
(
1
,
@remports
);
}
else
{
return
0
;
}
}
#
...
...
@@ -1233,7 +1239,6 @@ sub removeVlan($@) {
my
$errors
=
0
;
removePortsFromVlan
(
$self
,
@vlan_numbers
);
foreach
my
$vlan_number
(
@vlan_numbers
)
{
#
# Need to lock the VLAN edit buffer
...
...
@@ -1392,6 +1397,7 @@ my %vtrunkOIDS = (
# precompute 1k 0 bits as bitfield
my
$p1k
=
pack
("
x128
");
my
(
$VOP_CLEAR
,
$VOP_SET
,
$VOP_CLEARALL
,
$VOP_CHECK
)
=
(
0
,
1
,
2
,
3
);
#
# vlanTrunkUtil($self, $op, $ifIndex, @vlans)
...
...
@@ -1403,8 +1409,17 @@ sub vlanTrunkUtil($$$$) {
my
(
$bitfield
,
%vranges
,
@result
);
if
(
$op
==
$VOP_CLEARALL
)
{
@result
=
@vlans
=
(
1
,
1025
,
2049
,
3073
);
}
if
(
$op
==
$VOP_CLEARALL
)
{
#
# Clear the 'extended range' VLANs iff they might be used on this
# switch
#
if
(
$self
->
{
EXTENDED_VLANS
})
{
@result
=
@vlans
=
(
1
,
1025
,
2049
,
3073
);
}
else
{
@result
=
@vlans
=
(
1
);
}
}
foreach
my
$vlan
(
@vlans
)
{
push
@
{
$vranges
{(
$vlan
>>
10
)
&
3
}},
$vlan
;
}
...
...
@@ -1735,8 +1750,11 @@ sub getChannelIfIndex($@) {
# single port channel.
#
if
(
!
$ifindex
)
{
if
(
@ifIndexes
==
1
)
{
$ifindex
=
$ifIndexes
[
0
];
}
}
return
$ifindex
;
}
...
...
@@ -1764,7 +1782,6 @@ sub setVlansOnTrunk($$$$) {
}
my
(
$ifIndex
)
=
$self
->
convertPortFormat
(
$PORT_FORMAT_IFINDEX
,
$port
);
$ifIndex
=
$self
->
getChannelIfIndex
(
$ifIndex
);
@vlan_numbers
=
$self
->
vlanTrunkUtil
(
$value
,
$ifIndex
,
@vlan_numbers
);
return
(
scalar
(
@vlan_numbers
)
!=
0
);