Merge "Fix a error when l3-agent gets filter id for ip"
This commit is contained in:
commit
dac03f4f9e
@ -63,6 +63,7 @@ class FloatingIPTcCommandBase(ip_lib.IPDevice):
|
|||||||
if not filters_output:
|
if not filters_output:
|
||||||
raise exceptions.FilterIDForIPNotFound(ip=ip)
|
raise exceptions.FilterIDForIPNotFound(ip=ip)
|
||||||
filter_lines = filters_output.split('\n')
|
filter_lines = filters_output.split('\n')
|
||||||
|
filter_id = None
|
||||||
for line in filter_lines:
|
for line in filter_lines:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
m = FILTER_ID_REGEX.match(line)
|
m = FILTER_ID_REGEX.match(line)
|
||||||
@ -73,7 +74,7 @@ class FloatingIPTcCommandBase(ip_lib.IPDevice):
|
|||||||
if not line.startswith('match'):
|
if not line.startswith('match'):
|
||||||
continue
|
continue
|
||||||
parts = line.split(" ")
|
parts = line.split(" ")
|
||||||
if ip + '/32' in parts:
|
if ip + '/32' in parts and filter_id:
|
||||||
filterids_for_ip.append(filter_id)
|
filterids_for_ip.append(filter_id)
|
||||||
if len(filterids_for_ip) > 1:
|
if len(filterids_for_ip) > 1:
|
||||||
raise exceptions.MultipleFilterIDForIPFound(ip=ip)
|
raise exceptions.MultipleFilterIDForIPFound(ip=ip)
|
||||||
|
@ -133,6 +133,26 @@ QDISC_IDS = {constants.INGRESS_DIRECTION: INGRESS_QSIC_ID,
|
|||||||
TC_QDISCS = [{'handle': '1:', 'qdisc_type': 'htb', 'parent': 'root'},
|
TC_QDISCS = [{'handle': '1:', 'qdisc_type': 'htb', 'parent': 'root'},
|
||||||
{'handle': 'ffff:', 'qdisc_type': 'ingress', 'parent': 'ingress'}]
|
{'handle': 'ffff:', 'qdisc_type': 'ingress', 'parent': 'ingress'}]
|
||||||
|
|
||||||
|
TC_FILTERS_ADD_BY_OTHERS_BASE = (
|
||||||
|
'filter protocol %(protocol)s u32 %(chain_name)s \n'
|
||||||
|
'filter protocol %(protocol)s u32 %(chain_name)s fh 800: ht divisor 1 \n'
|
||||||
|
'filter protocol %(protocol)s u32 %(chain_name)s fh %(filter_id1)s order '
|
||||||
|
'2048 key ht 800 bkt 0 flowid :1 not_in_hw (rule hit 0 success 0) \n'
|
||||||
|
'match %(matches)s at 16 (success 0 ) \n'
|
||||||
|
'police 0x3 rate 3000Kbit burst 3Mb mtu 64Kb action drop overhead 0b '
|
||||||
|
'linklayer ethernet \n'
|
||||||
|
'ref 1 bind 1 installed 22 sec used 22 sec \n'
|
||||||
|
'\n'
|
||||||
|
' Sent 111 bytes 222 pkts (dropped 0, overlimits 0)\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
TC_FILTERS_ADD_BY_OTHERS_FOR_ALL_PROTOCOL = TC_FILTERS_ADD_BY_OTHERS_BASE % {
|
||||||
|
"protocol": "all",
|
||||||
|
"chain_name": "chain 1 ",
|
||||||
|
"filter_id1": FILETER_ID_1,
|
||||||
|
"matches": "c0a8dc06/ffffffff"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TestFloatingIPTcCommandBase(base.BaseTestCase):
|
class TestFloatingIPTcCommandBase(base.BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -227,6 +247,15 @@ class TestFloatingIPTcCommandBase(base.BaseTestCase):
|
|||||||
def test__get_filterid_for_ip_not_found_with_chain(self):
|
def test__get_filterid_for_ip_not_found_with_chain(self):
|
||||||
self._test__get_filterid_for_ip_not_found(TC_EGRESS_FILTERS_WITH_CHAIN)
|
self._test__get_filterid_for_ip_not_found(TC_EGRESS_FILTERS_WITH_CHAIN)
|
||||||
|
|
||||||
|
def test__get_filterid_for_ip_with_additional_filters(self):
|
||||||
|
with mock.patch.object(tc_lib.FloatingIPTcCommandBase,
|
||||||
|
'_get_filters') as get_filters:
|
||||||
|
get_filters.return_value = \
|
||||||
|
TC_FILTERS_ADD_BY_OTHERS_FOR_ALL_PROTOCOL
|
||||||
|
self.assertRaises(exceptions.FilterIDForIPNotFound,
|
||||||
|
self.tc._get_filterid_for_ip,
|
||||||
|
INGRESS_QSIC_ID, "192.168.220.6")
|
||||||
|
|
||||||
def test__del_filter_by_id(self):
|
def test__del_filter_by_id(self):
|
||||||
self.tc._del_filter_by_id(INGRESS_QSIC_ID, FLOATING_IP_1)
|
self.tc._del_filter_by_id(INGRESS_QSIC_ID, FLOATING_IP_1)
|
||||||
self.execute.assert_called_once_with(
|
self.execute.assert_called_once_with(
|
||||||
|
Loading…
Reference in New Issue
Block a user