Skip to content
Snippets Groups Projects
Commit 65e3060f authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

update drop VC messages broadcasted by neighbors instead of forwarding it

parent 441c0d66
No related branches found
No related tags found
No related merge requests found
......@@ -101,6 +101,20 @@ def manage_iptables(option, switch_name, queue_num):
return False
def drop_ebtables_rule(switch_name, mac_address):
"""
Run ebtables command with specified switch_name to drop bridge packets.
:param switch_name: The name of the switch interface, e.g., "br0"
:param mac_address: the output address to be dropped
"""
try:
subprocess.run(["sudo", "ebtables", "-I", "FORWARD", "--logical-in", switch_name, "-d", mac_address, "-j DROP"], check=True)
return True
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e}")
return False
def add_mangle_mark(bridge_name, inter_name, mark_value):
"""
Add a rule to the mangle table to mark packets from a specific interface.
......
......@@ -14,8 +14,10 @@ def process_packet(new_packet):
data = new_packet.get_payload()
pkt = Ether(data)
# Parse the raw data into a Scapy IP packet
pkt = IP(data)
# pkt = IP(data)
if pkt.haslayer(IP):
# print(f"IP Packet: {pkt.summary()}")
......@@ -70,7 +72,9 @@ def process_opportunistic_node(node_id):
if_utils.add_interface_to_bridge(if_utils.BR_CENTER_NAME, inter_name)
if_utils.map_bridge_outside[inter_num] = if_utils.BR_CENTER_NAME
# Insert iptables rule to mark traffic on interfaces ens$i
# Insert ebtables rule to drop VC messages to avoid broadcast neighbors' traffic
if_utils.drop_ebtables_rule(if_utils.BR_CENTER_NAME, "00:00:00:00:00:00")
# Insert iptables rule to mark traffic on interfaces ens$i and forward to NFqueue
if_utils.manage_iptables("-I", if_utils.BR_CENTER_NAME, 1)
for inter_num in range(if_utils.MIN_INTER_NUMBER, if_utils.MAX_INTER_NUMBER):
inter_name = if_utils.MARK_TO_INTERFACE[inter_num]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment