Commit 235db86c authored by Leigh B Stoller's avatar Leigh B Stoller

Fix bug that was causing reserved vlantags to be left behind, causing

snmmpit to fail at seemingly random times. Also add an update script
to delete the stale tags.
parent 35f1deaa
#
# Fix for bug that was causing reserved_vlantags to be left behind.
# Delete those stale tags here.
#
use strict;
use libdb;
use Lan;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
my $query_result =
DBQueryFatal("select r.lanid,r.tag from reserved_vlantags as r ".
"left join lans as l on l.lanid=r.lanid ".
"where l.lanid is null");
while (my ($lanid,$tag) = $query_result->fetchrow_array()) {
print "Deleting stale reserved vlan tag ($tag) for lan $lanid ...\n";
VLan::ClearReservedVlanTag($lanid);
}
return 0;
}
...@@ -2237,7 +2237,7 @@ sub syncVlansFromTables($$) { ...@@ -2237,7 +2237,7 @@ sub syncVlansFromTables($$) {
} }
VLan->RecordVLanDeletion($vlanid) == 0 VLan->RecordVLanDeletion($vlanid) == 0
or goto bad; or goto bad;
VLan->ClearReservedVlanTag($vlanid) == 0 clearReservedVlanTag($vlanid) == 0
or goto bad; or goto bad;
} }
} }
...@@ -2756,7 +2756,7 @@ sub doSyncVlansWithDB($) { ...@@ -2756,7 +2756,7 @@ sub doSyncVlansWithDB($) {
elsif (VLan->RecordVLanDeletion($vlan_id)) { elsif (VLan->RecordVLanDeletion($vlan_id)) {
$errors++; $errors++;
} }
elsif (VLan->ClearReservedVlanTag($vlan_id)) { elsif (clearReservedVlanTag($vlan_id)) {
$errors++; $errors++;
} }
} }
...@@ -3227,8 +3227,8 @@ sub doDeleteVlan($@) { ...@@ -3227,8 +3227,8 @@ sub doDeleteVlan($@) {
VLan->RecordVLanDeletion($vlan_id) == 0 VLan->RecordVLanDeletion($vlan_id) == 0
or $errors++; or $errors++;
VLan->ClearReservedVlanTag($vlan_id) == 0 or $errors++ clearReservedVlanTag($vlan_id) == 0 or $errors++
if ($opt{C} || (ref($vlan) && $vlan->IsInternal())); if ($opt{C} || (ref($vlan) && $vlan->IsManual()));
next next
if (!ref($vlan)); if (!ref($vlan));
......
...@@ -2274,7 +2274,7 @@ sub syncVlansFromTables($$) { ...@@ -2274,7 +2274,7 @@ sub syncVlansFromTables($$) {
} }
VLan->RecordVLanDeletion($vlanid) == 0 VLan->RecordVLanDeletion($vlanid) == 0
or goto bad; or goto bad;
VLan->ClearReservedVlanTag($vlanid) == 0 clearReservedVlanTag($vlanid) == 0
or goto bad; or goto bad;
} }
} }
...@@ -2799,7 +2799,7 @@ sub doSyncVlansWithDB($) { ...@@ -2799,7 +2799,7 @@ sub doSyncVlansWithDB($) {
elsif (VLan->RecordVLanDeletion($vlan_id)) { elsif (VLan->RecordVLanDeletion($vlan_id)) {
$errors++; $errors++;
} }
elsif (VLan->ClearReservedVlanTag($vlan_id)) { elsif (clearReservedVlanTag($vlan_id)) {
$errors++; $errors++;
} }
} }
...@@ -3335,8 +3335,8 @@ sub doDeleteVlan($@) { ...@@ -3335,8 +3335,8 @@ sub doDeleteVlan($@) {
VLan->RecordVLanDeletion($vlan_id) == 0 VLan->RecordVLanDeletion($vlan_id) == 0
or $errors++; or $errors++;
VLan->ClearReservedVlanTag($vlan_id) == 0 or $errors++ clearReservedVlanTag($vlan_id) == 0 or $errors++
if ($opt{C} || (ref($vlan) && $vlan->IsInternal())); if ($opt{C} || (ref($vlan) && $vlan->IsManual()));
next next
if (!ref($vlan)); if (!ref($vlan));
......
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