Dan Kenigsberg has uploaded a new change for review.
Change subject: tc: list some information about filters ......................................................................
tc: list some information about filters
`tc filter show dev <dev> parent <parent>` lists all information about currently-defined tc filters for <dev> and <parent>.
This patch extracts very little information about each filter that we recognize.
Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Signed-off-by: Dan Kenigsberg danken@redhat.com --- M tests/tcTests.py A tests/tc_filter_show.out M vdsm/tc.py 3 files changed, 46 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/98/7298/1
diff --git a/tests/tcTests.py b/tests/tcTests.py index 14104a8..c8facd2 100644 --- a/tests/tcTests.py +++ b/tests/tcTests.py @@ -194,6 +194,12 @@ self.assertRaises(tc.TrafficControlException, tc.qdisc_del, self._bridge.devName + "A", 'ingress')
+ def test_filters(self): + out = file('tc_filter_show.out').read() + self.assertEqual(tuple(tc.filters('bridge', 'parent', out=out)), + (tc.Filter('tap1', '49149'), + tc.Filter('tap2', '49150'))) +
class TestPortMirror(TestCaseBase):
diff --git a/tests/tc_filter_show.out b/tests/tc_filter_show.out new file mode 100644 index 0000000..9dbda2b --- /dev/null +++ b/tests/tc_filter_show.out @@ -0,0 +1,14 @@ +filter protocol ip pref 49149 u32 +filter protocol ip pref 49149 u32 fh 803: ht divisor 1 +filter protocol ip pref 49149 u32 fh 803::800 order 2048 key ht 803 bkt 0 terminal flowid ??? + match 00000000/00000000 at 0 + action order 1: mirred (Egress Mirror to device tap1) pipe + index 18 ref 1 bind 1 + +filter protocol ip pref 49150 u32 +filter protocol ip pref 49150 u32 fh 802: ht divisor 1 +filter protocol ip pref 49150 u32 fh 802::800 order 2048 key ht 802 bkt 0 terminal flowid ??? + match 00000000/00000000 at 0 + action order 33: mirred (Egress Mirror to device tap2) pipe + index 17 ref 1 bind 1 + diff --git a/vdsm/tc.py b/vdsm/tc.py index 4ebd0e6..835ae2c 100644 --- a/vdsm/tc.py +++ b/vdsm/tc.py @@ -19,6 +19,7 @@ #
from subprocess import list2cmdline +from collections import namedtuple
import storage.misc from vdsm.constants import EXT_TC, EXT_IFCONFIG @@ -86,3 +87,28 @@ promisc = '-promisc' command = [EXT_IFCONFIG, dev, promisc] _process_request(command) + + +Filter = namedtuple('Filter', 'target prio') + + +def filters(bridge, parent, out=None): + "Return a (very) limitted information about tc filters on bridge dev" + + if out is None: + out = _process_request([EXT_TC, 'filter', 'show', 'dev', bridge, + 'parent', parent]) + + prio = target = None + for line in out.splitlines(): + if line.startswith('filter protocol ip pref '): + prio = line.split()[4] + if line.startswith('\taction order '): + elems = line.split() + if elems[3] == 'mirred' and elems[4] == '(Egress': + target = elems[-2][:-1] + if line == ' ': + if prio is not None and target is not None: + yield Filter(target, prio) + else: + prio = target = None
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.info/job/patch_vdsm_unit_tests/497/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Antoni Segura Puimedon has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 1: I would prefer that you didn't submit this
(2 inline comments)
Just for the elif/continue thing, the docstring is just that I find it helpful to know if I expect a list or a generator.
.................................................... File vdsm/tc.py Line 92: Filter = namedtuple('Filter', 'target prio') Line 93: Line 94: Line 95: def filters(bridge, parent, out=None): Line 96: "Return a (very) limitted information about tc filters on bridge dev" Maybe it could be mentioned in the docstring that what is returned is a generators: "Return a generator that provides (very) limited information for each of the tc filters on the bridge device." Line 97: Line 98: if out is None: Line 99: out = _process_request([EXT_TC, 'filter', 'show', 'dev', bridge, Line 100: 'parent', parent])
Line 102: prio = target = None Line 103: for line in out.splitlines(): Line 104: if line.startswith('filter protocol ip pref '): Line 105: prio = line.split()[4] Line 106: if line.startswith('\taction order '): In case the previous if branch proved to be true, doing this check is unnecessary, we could do an 'elif' or put a continue in the previous line. (the same applies to line 110. Line 107: elems = line.split() Line 108: if elems[3] == 'mirred' and elems[4] == '(Egress': Line 109: target = elems[-2][:-1] Line 110: if line == ' ':
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 2:
Build Failed
http://jenkins.ovirt.info/job/patch_vdsm_unit_tests/595/ : FAILURE
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Antoni Segura Puimedon has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 2: (1 inline comment)
Only small typo. The rest looks good to me, even though it took me a moment to realize the intent yielding the last entry by adding a bogus extra line containing HEADER+X.
.................................................... File vdsm/tc.py Line 93: Line 94: Line 95: def filters(dev, parent, out=None): Line 96: """ Line 97: Return a (very) limitted information about tc filters on dev s/limitted/limited/ Line 98: Line 99: Function returns a generator of Filter objects. Line 100: """ Line 101:
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Antoni Segura Puimedon has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 3: Looks good to me, but someone else must approve
I'll verify the unit test asap as well.
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 3:
Build Successful
http://jenkins.ovirt.info/job/patch_vdsm_unit_tests/612/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Antoni Segura Puimedon has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 3: Verified
Unit tests work without any issue.
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Antoni Segura Puimedon has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 4: Verified; Looks good to me, but someone else must approve
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 4:
Build Successful
http://jenkins.ovirt.info/job/patch_vdsm_unit_tests/621/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has posted comments on this change.
Change subject: tc: list some information about filters ......................................................................
Patch Set 4: Looks good to me, approved
let's start pushing this long series in..
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has submitted this change and it was merged.
Change subject: tc: list some information about filters ......................................................................
tc: list some information about filters
`tc filter show dev <dev> parent <parent>` lists all information about currently-defined tc filters for <dev> and <parent>.
This patch extracts very little information about each filter that we recognize.
Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Signed-off-by: Dan Kenigsberg danken@redhat.com --- M tests/tcTests.py A tests/tc_filter_show.out M vdsm/tc.py 3 files changed, 76 insertions(+), 0 deletions(-)
Approvals: Antoni Segura Puimedon: Verified; Looks good to me, but someone else must approve Dan Kenigsberg: Looks good to me, approved
-- To view, visit http://gerrit.ovirt.org/7298 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I22953e6d09f846cae18d15a54cd6e5c9e4519e20 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Antoni Segura Puimedon asegurap@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Igor Lvovsky ilvovsky@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
vdsm-patches@lists.fedorahosted.org