From 911e749ddf4125c44c776124c8b4c214b8adddf8 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sun, 14 Sep 2014 22:04:57 +0100 Subject: vyatta-cfg: display openvpn interface descriptions after they reset When OpenVPN tunnels are taken down and recreated by the OpenVPN process, any previously set descriptions on the interfaces are missing. This is caused by the fact that the ifalias for that interface isn't readded when the interface is recreated. This patch updates the interface_description function so that it either returns the current value of ifalias if it's set on the interface, or uses the value set in the active config if it's present. Bug #7 http://bugzilla.vyos.net/show_bug.cgi?id=7 Bug #313 http://bugzilla.vyos.net/show_bug.cgi?id=313 --- lib/Vyatta/Misc.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Vyatta/Misc.pm b/lib/Vyatta/Misc.pm index 6b90a9c..2a5c880 100755 --- a/lib/Vyatta/Misc.pm +++ b/lib/Vyatta/Misc.pm @@ -519,7 +519,24 @@ sub interface_description { my $description = <$ifalias>; close $ifalias; - chomp $description if $description; + + # If the interface has a description set then just use that, if not then check + # the active config to see if one is configured there. Used for interfaces + # that can be destroyed and recreated during opertion, but then don't have + # their description reset. + + if ($description){ + chomp $description; + } else { + my $intf = new Vyatta::Interface($name); + my $config = new Vyatta::Config; + + $config->setLevel( $intf->path() ); + + if ($config->existsOrig('description')) { + $description = $config->returnOrigValue('description'); + } + } return $description; } -- cgit v1.2.3