Commit a6e036b2 authored by Pedro Oliveira's avatar Pedro Oliveira

fix membership removal of interface (IGMP/MLD)

parent 83a7946a
......@@ -124,16 +124,16 @@ class Kernel(metaclass=ABCMeta):
def _create_membership_interface_object(self, interface_name, index):
raise NotImplementedError
def remove_interface(self, interface_name, igmp:bool=False, pim:bool=False):
def remove_interface(self, interface_name, membership: bool = False, pim: bool = False):
with self.interface_lock:
pim_interface = self.pim_interface.get(interface_name)
membership_interface = self.membership_interface.get(interface_name)
if (igmp and not membership_interface) or (pim and not pim_interface) or (not igmp and not pim):
if (membership and not membership_interface) or (pim and not pim_interface) or (not membership and not pim):
return
if pim:
pim_interface = self.pim_interface.pop(interface_name)
pim_interface.remove()
elif igmp:
elif membership:
membership_interface = self.membership_interface.pop(interface_name)
membership_interface.remove()
......
......@@ -42,11 +42,16 @@ def add_membership_interface(interface_name, ipv4=True, ipv6=False):
kernel_v6.create_membership_interface(interface_name=interface_name)
def remove_interface(interface_name, pim=False, igmp=False, ipv4=True, ipv6=False):
def remove_interface(interface_name, pim=False, membership=False, ipv4=True, ipv6=False):
if interface_name == "*":
for interface_name in netifaces.interfaces():
remove_interface(interface_name, pim, membership, ipv4, ipv6)
return
if ipv4 and kernel is not None:
kernel.remove_interface(interface_name, pim=pim, igmp=igmp)
kernel.remove_interface(interface_name, pim=pim, membership=membership)
if ipv6 and kernel_v6 is not None:
kernel_v6.remove_interface(interface_name, pim=pim, mld=igmp)
kernel_v6.remove_interface(interface_name, pim=pim, membership=membership)
def list_neighbors(ipv4=False, ipv6=False):
......@@ -181,8 +186,10 @@ def list_routing_state(ipv4=False, ipv6=False):
def stop():
remove_interface("*", pim=True, igmp=True, ipv4=True, ipv6=True)
remove_interface("*", pim=True, membership=True, ipv4=True, ipv6=True)
if kernel is not None:
kernel.exit()
if kernel_v6 is not None:
kernel_v6.exit()
unicast_routing.stop()
......
......@@ -86,10 +86,10 @@ class MyDaemon(Daemon):
Main.remove_interface(args.remove_interface[0], pim=True, ipv4=args.ipv4, ipv6=args.ipv6)
connection.shutdown(socket.SHUT_RDWR)
elif 'remove_interface_igmp' in args and args.remove_interface_igmp:
Main.remove_interface(args.remove_interface_igmp[0], igmp=True, ipv4=True, ipv6=False)
Main.remove_interface(args.remove_interface_igmp[0], membership=True, ipv4=True, ipv6=False)
connection.shutdown(socket.SHUT_RDWR)
elif 'remove_interface_mld' in args and args.remove_interface_mld:
Main.remove_interface(args.remove_interface_mld[0], igmp=True, ipv4=False, ipv6=True)
Main.remove_interface(args.remove_interface_mld[0], membership=True, ipv4=False, ipv6=True)
connection.shutdown(socket.SHUT_RDWR)
elif 'stop' in args and args.stop:
Main.stop()
......
......@@ -194,7 +194,7 @@ class UnicastRouting(object):
print(if_name + ": " + operation)
UnicastRouting.lock.release()
if operation == 'DOWN':
Main.kernel.remove_interface(if_name, igmp=True, pim=True)
Main.kernel.remove_interface(if_name, membership=True, pim=True)
subnet = ipaddress.ip_network("0.0.0.0/0")
Main.kernel.notify_unicast_changes(subnet)
'''
......
......@@ -12,7 +12,7 @@ setup(
description="PIM-DM protocol",
long_description=open("README.md", "r").read(),
long_description_content_type="text/markdown",
keywords="PIM-DM Multicast Routing Protocol Dense-Mode Router RFC3973",
keywords="PIM-DM Multicast Routing Protocol Dense-Mode Router RFC3973 IPv4 IPv6",
version="1.1",
url="http://github.com/pedrofran12/pim_dm",
author="Pedro Oliveira",
......
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