diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2018-01-25 14:00:53 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-25 21:23:09 -0500 |
commit | baf6a07e040d8308165654c7f49ee9ee18cd89be (patch) | |
tree | 4ebce6a79ade544f6568d78491065a785cc8f63d /tools | |
parent | 2fb89a38d35bb6c935edb819d9096de455ce87cf (diff) |
selftests/bpf: check for chain-non-0 extack message
Make sure netdevsim doesn't allow offload of chains other than 0,
and that it reports the expected extack message.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/testing/selftests/bpf/test_offload.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py index 49f5ceeabfa6..e78aad0a68bb 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -430,13 +430,15 @@ class NetdevSim: return filters def cls_filter_op(self, op, qdisc="ingress", prio=None, handle=None, - cls="", params="", + chain=None, cls="", params="", fail=True, include_stderr=False): spec = "" if prio is not None: spec += " prio %d" % (prio) if handle: spec += " handle %s" % (handle) + if chain is not None: + spec += " chain %d" % (chain) return tc("filter {op} dev {dev} {qdisc} {spec} {cls} {params}"\ .format(op=op, dev=self['ifname'], qdisc=qdisc, spec=spec, @@ -444,7 +446,7 @@ class NetdevSim: fail=fail, include_stderr=include_stderr) def cls_bpf_add_filter(self, bpf, op="add", prio=None, handle=None, - da=False, verbose=False, + chain=None, da=False, verbose=False, skip_sw=False, skip_hw=False, fail=True, include_stderr=False): cls = "bpf " + bpf @@ -460,7 +462,7 @@ class NetdevSim: params += " skip_hw" return self.cls_filter_op(op=op, prio=prio, handle=handle, cls=cls, - params=params, + chain=chain, params=params, fail=fail, include_stderr=include_stderr) def set_ethtool_tc_offloads(self, enable, fail=True): @@ -679,6 +681,14 @@ try: args) sim.wait_for_flush() + start_test("Test non-0 chain offload...") + ret, _, err = sim.cls_bpf_add_filter(obj, chain=1, prio=1, handle=1, + skip_sw=True, + fail=False, include_stderr=True) + fail(ret == 0, "Offloaded a filter to chain other than 0") + check_extack(err, "Error: Driver supports only offload of chain 0.", args) + sim.tc_flush_filters() + start_test("Test TC replace...") sim.cls_bpf_add_filter(obj, prio=1, handle=1) sim.cls_bpf_add_filter(obj, op="replace", prio=1, handle=1) |