Change in vdsm[master]: tc: list some information about filters
danken at redhat.com
danken at redhat.com
Fri Aug 17 20:56:08 UTC 2012
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 at 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 at redhat.com>
More information about the vdsm-patches
mailing list