mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Added a new check to check whether an network interface is in promiscuous mode
This commit is contained in:
parent
039d4c95d9
commit
be279295b6
1 changed files with 9 additions and 0 deletions
|
@ -1440,6 +1440,15 @@ class LinuxNetwork(Network):
|
||||||
path = os.path.join(path, 'bonding', 'all_slaves_active')
|
path = os.path.join(path, 'bonding', 'all_slaves_active')
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
interfaces[device]['all_slaves_active'] = open(path).read() == '1'
|
interfaces[device]['all_slaves_active'] = open(path).read() == '1'
|
||||||
|
#Check whether a interface is in promiscuous mode
|
||||||
|
if os.path.exists(os.path.join(path,'flags')):
|
||||||
|
promisc_mode = False
|
||||||
|
# The second byte indicates whether the interface is in promiscuous mode.
|
||||||
|
# 1 = promisc
|
||||||
|
# 0 = no promisc
|
||||||
|
data = int(open(os.path.join(path, 'flags')).read().strip(),16)
|
||||||
|
promisc_mode = (data & 0x0100 > 0)
|
||||||
|
interfaces[device]['promisc'] = promisc_mode
|
||||||
ip_path = module.get_bin_path("ip")
|
ip_path = module.get_bin_path("ip")
|
||||||
output = subprocess.Popen([ip_path, 'addr', 'show', device], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
|
output = subprocess.Popen([ip_path, 'addr', 'show', device], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
|
||||||
for line in output.split('\n'):
|
for line in output.split('\n'):
|
||||||
|
|
Loading…
Reference in a new issue