DSCP packet marking support in Linuxbridge agent
Linuxbridge agent uses iptable rules in POSTROUTING chain
in the mangle table to mark outgoing packets with the
DSCP mark value configured by the user in QoS policy.
DocImpact: DSCP Marking rule support is extended to the
Linuxbridge L2 agent
Closes-Bug: #1644369
Change-Id: I47e44cb2e67ab73bd5ee0aa4cca47cb3d07e43f3
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
import re
|
||||
|
||||
from neutron.agent.linux import async_process
|
||||
from neutron.agent.linux import iptables_manager
|
||||
from neutron.common import utils as common_utils
|
||||
|
||||
|
||||
@@ -38,6 +39,15 @@ def extract_mod_nw_tos_action(flows):
|
||||
return tos_mark
|
||||
|
||||
|
||||
def extract_dscp_value_from_iptables_rules(rules):
|
||||
pattern = (r"^-A neutron-linuxbri-qos-.* -j DSCP "
|
||||
"--set-dscp (?P<dscp_value>0x[A-Fa-f0-9]+)$")
|
||||
for rule in rules:
|
||||
m = re.match(pattern, rule)
|
||||
if m:
|
||||
return int(m.group("dscp_value"), 16)
|
||||
|
||||
|
||||
def wait_until_bandwidth_limit_rule_applied(bridge, port_vif, rule):
|
||||
def _bandwidth_limit_rule_applied():
|
||||
bw_rule = bridge.get_egress_bw_limit_for_port(port_vif)
|
||||
@@ -49,7 +59,7 @@ def wait_until_bandwidth_limit_rule_applied(bridge, port_vif, rule):
|
||||
common_utils.wait_until_true(_bandwidth_limit_rule_applied)
|
||||
|
||||
|
||||
def wait_until_dscp_marking_rule_applied(bridge, port_vif, rule):
|
||||
def wait_until_dscp_marking_rule_applied_ovs(bridge, port_vif, rule):
|
||||
def _dscp_marking_rule_applied():
|
||||
port_num = bridge.get_port_ofport(port_vif)
|
||||
|
||||
@@ -64,6 +74,20 @@ def wait_until_dscp_marking_rule_applied(bridge, port_vif, rule):
|
||||
common_utils.wait_until_true(_dscp_marking_rule_applied)
|
||||
|
||||
|
||||
def wait_until_dscp_marking_rule_applied_linuxbridge(
|
||||
namespace, port_vif, expected_rule):
|
||||
|
||||
iptables = iptables_manager.IptablesManager(
|
||||
namespace=namespace)
|
||||
|
||||
def _dscp_marking_rule_applied():
|
||||
mangle_rules = iptables.get_rules_for_table("mangle")
|
||||
dscp_mark = extract_dscp_value_from_iptables_rules(mangle_rules)
|
||||
return dscp_mark == expected_rule
|
||||
|
||||
common_utils.wait_until_true(_dscp_marking_rule_applied)
|
||||
|
||||
|
||||
def wait_for_dscp_marked_packet(sender_vm, receiver_vm, dscp_mark):
|
||||
cmd = ["tcpdump", "-i", receiver_vm.port.name, "-nlt"]
|
||||
if dscp_mark:
|
||||
|
||||
Reference in New Issue
Block a user