Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GNS3_unikernel_testbed
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NGUYEN Do Duc Anh
GNS3_unikernel_testbed
Commits
65e3060f
Commit
65e3060f
authored
5 months ago
by
NGUYEN Do Duc Anh
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ubuntu_base/if_utils.py
+14
-0
14 additions, 0 deletions
ubuntu_base/if_utils.py
ubuntu_base/opportunistic_node.py
+6
-2
6 additions, 2 deletions
ubuntu_base/opportunistic_node.py
with
20 additions
and
2 deletions
ubuntu_base/if_utils.py
+
14
−
0
View file @
65e3060f
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
ubuntu_base/opportunistic_node.py
+
6
−
2
View file @
65e3060f
...
...
@@ -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
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment