Skip to content

Commit

Permalink
nat: T6365: use interface_exists() over netifaces.interfaces()
Browse files Browse the repository at this point in the history
  • Loading branch information
c-po committed May 22, 2024
1 parent 3870247 commit e1fd176
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/conf_mode/nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import os

from sys import exit
from netifaces import interfaces

from vyos.base import Warning
from vyos.config import Config
Expand All @@ -30,6 +29,7 @@
from vyos.utils.process import cmd
from vyos.utils.process import run
from vyos.utils.network import is_addr_assigned
from vyos.utils.network import interface_exists
from vyos import ConfigError

from vyos import airbag
Expand Down Expand Up @@ -153,8 +153,8 @@ def verify(nat):
if interface_name not in 'any':
if interface_name.startswith('!'):
interface_name = interface_name[1:]
if interface_name not in interfaces():
Warning(f'NAT interface "{interface_name}" for source NAT rule "{rule}" does not exist!')
if interface_exists(interface_name):
Warning(f'Interface "{interface_name}" for source NAT rule "{rule}" does not exist!')
else:
group_name = config['outbound_interface']['group']
if group_name[0] == '!':
Expand Down Expand Up @@ -190,8 +190,8 @@ def verify(nat):
if interface_name not in 'any':
if interface_name.startswith('!'):
interface_name = interface_name[1:]
if interface_name not in interfaces():
Warning(f'NAT interface "{interface_name}" for destination NAT rule "{rule}" does not exist!')
if interface_exists(interface_name):
Warning(f'Interface "{interface_name}" for destination NAT rule "{rule}" does not exist!')
else:
group_name = config['inbound_interface']['group']
if group_name[0] == '!':
Expand Down

0 comments on commit e1fd176

Please sign in to comment.