Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5ad8163b
authored
Jul 24, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring flow rules
parent
facd15a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
networkdriver.py
+25
-8
No files found.
networkdriver.py
View file @
5ad8163b
...
@@ -34,6 +34,17 @@ def delete(vm):
...
@@ -34,6 +34,17 @@ def delete(vm):
port_delete
(
network
)
port_delete
(
network
)
def
build_flow_rule
():
def
ban_dhcp_server
(
network
,
port_number
):
cmd_list
=
[
'add-flow'
,
network
.
bridge
,
'in_port=
%(port_number)
s,dl_src=
%(mac)
s,udp,tp_dst=68,
\
priority=43000,actions=drop'
%
{
'port_number'
:
port_number
,
'mac'
:
network
.
mac
}]
return
cmd_list
def
port_create
(
network
):
def
port_create
(
network
):
'''
'''
add-port BRIDGE PORT
add-port BRIDGE PORT
...
@@ -58,12 +69,7 @@ def port_create(network):
...
@@ -58,12 +69,7 @@ def port_create(network):
# Set Flow rules to avoid mac or IP spoofing
# Set Flow rules to avoid mac or IP spoofing
# Set flow rule 1 (dhcp server ban)
# Set flow rule 1 (dhcp server ban)
cmd_list
=
[
'add-flow'
,
network
.
bridge
,
ofctl_command_execute
(
ban_dhcp_server
(
network
,
port_number
))
'in_port=
%(port_number)
s,dl_src=
%(mac)
s,udp,tp_dst=68,
\
priority=43000,actions=drop'
%
{
'port_number'
:
port_number
,
'mac'
:
network
.
mac
}]
ofctl_command_execute
(
cmd_list
)
# Set flow rules 2 (ipv4 filter)
# Set flow rules 2 (ipv4 filter)
cmd_list
=
[
'add-flow'
,
network
.
bridge
,
cmd_list
=
[
'add-flow'
,
network
.
bridge
,
'in_port=
%(port_number)
s,dl_src=
%(mac)
s,ip,
\
'in_port=
%(port_number)
s,dl_src=
%(mac)
s,ip,
\
...
@@ -103,8 +109,19 @@ def port_create(network):
...
@@ -103,8 +109,19 @@ def port_create(network):
def
port_delete
(
network
):
def
port_delete
(
network
):
cmd_list
=
[
'del-port'
,
network
.
name
]
ovs_command_execute
(
cmd_list
)
# Getting network FlowPortNumber
port_number
=
get_fport_for_network
(
network
)
# Delete flow
cmd_list
=
[
'del-flows'
,
network
.
bridge
,
'in_port=
%(port_number)
s,dl_src=
%(mac)
s,udp,tp_dst=68'
%
{
'port_number'
:
port_number
,
'mac'
:
network
.
mac
}]
ofctl_command_execute
(
cmd_list
)
# Delete port
# cmd_list = ['del-port', network.name]
# ovs_command_execute(cmd_list)
def
get_fport_for_network
(
network
):
def
get_fport_for_network
(
network
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment