mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-13 15:30:09 +00:00
network: followup: move graceful require SDN out from subs
As "require" is evaluated on module load only once, we either have it or not, so move it to the top to avoid code duplication Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
c02d6d1c96
commit
35f2791ffa
@ -13,6 +13,12 @@ use Net::IP;
|
||||
use POSIX qw(ECONNREFUSED);
|
||||
use Socket qw(NI_NUMERICHOST NI_NUMERICSERV);
|
||||
|
||||
my $have_sdn;
|
||||
eval {
|
||||
require PVE::Network::SDN::Zones;
|
||||
$have_sdn = 1;
|
||||
};
|
||||
|
||||
# host network related utility functions
|
||||
|
||||
our $PHYSICAL_NIC_RE = qr/(?:eth\d+|en[^:.]+|ib\d+)/;
|
||||
@ -272,12 +278,6 @@ my $activate_interface = sub {
|
||||
sub tap_create {
|
||||
my ($iface, $bridge) = @_;
|
||||
|
||||
my $have_sdn;
|
||||
eval {
|
||||
require PVE::Network::SDN::Zones;
|
||||
$have_sdn = 1;
|
||||
};
|
||||
|
||||
if ($have_sdn) {
|
||||
my ($bridgesdn, undef) = PVE::Network::SDN::Zones::get_bridge_vlan($bridge);
|
||||
$bridge = $bridgesdn if $bridgesdn;
|
||||
@ -297,12 +297,6 @@ sub tap_create {
|
||||
sub veth_create {
|
||||
my ($veth, $vethpeer, $bridge, $mac) = @_;
|
||||
|
||||
my $have_sdn;
|
||||
eval {
|
||||
require PVE::Network::SDN::Zones;
|
||||
$have_sdn = 1;
|
||||
};
|
||||
|
||||
if ($have_sdn) {
|
||||
my ($bridgesdn, undef) = PVE::Network::SDN::Zones::get_bridge_vlan($bridge);
|
||||
$bridge = $bridgesdn if $bridgesdn;
|
||||
@ -399,12 +393,6 @@ my $cleanup_firewall_bridge = sub {
|
||||
sub tap_plug {
|
||||
my ($iface, $bridge, $tag, $firewall, $trunks, $rate) = @_;
|
||||
|
||||
my $have_sdn;
|
||||
eval {
|
||||
require PVE::Network::SDN::Zones;
|
||||
$have_sdn = 1;
|
||||
};
|
||||
|
||||
if ($have_sdn) {
|
||||
my ($bridgesdn, $tag) = PVE::Network::SDN::Zones::get_bridge_vlan($bridge);
|
||||
$bridge = $bridgesdn if $bridgesdn;
|
||||
|
Loading…
Reference in New Issue
Block a user