Commit 27cc006a authored by Leigh B Stoller's avatar Leigh B Stoller

Randomize tags when reserving one of a block.

parent 67ecb016
......@@ -67,6 +67,7 @@ use Compress::Zlib;
use File::Temp qw(tempfile);
use MIME::Base64;
use Errno;
use List::Util qw(shuffle);
# Configure variables
my $TB = "@prefix@";
......@@ -2173,7 +2174,7 @@ sub ReserveVlanTags($)
#
my $vlanid = $vlan->lanid();
my $tag = undef;
my @tmp = @tags;
my @tmp = shuffle(@tags);
while (@tmp) {
$tag = pop(@tmp);
if ($vlan->ReserveVlanTag($tag, 1)) {
......
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LGPL
#
......@@ -47,6 +47,7 @@ use English;
use Getopt::Long;
use emutil;
use strict;
use List::Util qw(shuffle);
# Optional alternate version of libraries.
use lib '@prefix@/lib/snmpit_test';
......@@ -2820,6 +2821,8 @@ sub doReserveVlanTags($$@) {
#
if (exists($optvlantags{$vlanid})) {
@tags = @{ $optvlantags{$vlanid} };
# Shuffle for better handling.
@tags = shuffle(@tags);
}
elsif ($vlan->GetReservedVlanTag()) {
# Wanted any tag, but lan has a tag.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment