Skip to content

Commit

Permalink
selftests/bpf: check for chain-non-0 extack message
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Jan 26, 2018
1 parent 2fb89a3 commit baf6a07
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tools/testing/selftests/bpf/test_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,21 +430,23 @@ def tc_show_ingress(self, expected=None):
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,
cls=cls, params=params),
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
Expand All @@ -460,7 +462,7 @@ def cls_bpf_add_filter(self, bpf, op="add", prio=None, handle=None,
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):
Expand Down Expand Up @@ -679,6 +681,14 @@ def test_spurios_extack(sim, obj, skip_hw, needle):
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)
Expand Down

0 comments on commit baf6a07

Please sign in to comment.