Introducing P4TC
Subsystems (7)
Jamal Hadi Salim
maintainerv4 cover Introducing P4TC
We are seeking community feedback on P4TC patches.
Please do note that ~50% of LOC are testcases.
Changes In RFC Version 2
-------------------------
Version 2 is the initial integration of the eBPF datapath.
We took into consideration suggestions provided to use eBPF and put effort into analyzing eBPF as datapath which involved extensive testing.
We implemented 6 approaches with eBPF and ran performance analysis and presented our results at the P4 2023 workshop in Santa Clara[see: 1, 3] on each of the 6 vs the scriptable P4TC and concluded that 2 of the approaches are sensible (4 if you account for XDP or TC separately).
Conclusions from the exercise: We lose the simple operational model we had prior to integrating eBPF. We do gain performance in most cases when the datapath is less compute-bound.
For more discussion on our requirements vs journeying the eBPF path please scroll down to "Restating Our Requirements" and "Challenges".
This patch set presented two modes.
mode1: the parser is entirely based on eBPF - whereas the rest of the SW datapath stays as _scriptable_ as in Version 1.
mode2: All of the kernel s/w datapath (including parser) is in eBPF.
The key ingredient for eBPF, that we did not have access to in the past, is kfunc (it made a big difference for us to reconsider eBPF).
In V2 the two modes are mutually exclusive (IOW, you get to choose one or the other via Kconfig).
Changes In RFC Version 3
-------------------------
These patches are still in a little bit of flux as we adjust to integrating eBPF. So there are small constructs that are used in V1 and 2 but no longer used in this version. We will make a V4 which will remove those. The changes from V2 are as follows:
1) Feedback we got in V2 is to try stick to one of the two modes. In this version we are taking one more step and going the path of mode2 vs v2 where we had 2 modes.
2) The P4 Register extern is no longer standalone. Instead, as part of integrating into eBPF we introduce another kfunc which encapsulates Register as part of the extern interface.
3) We have improved our CICD to include tools pointed to us by Simon. See "Testing" further below. Thanks to Simon for that and other issues he caught. Simon, we discussed on issue [7] but decided to keep that log since we think it is useful.
4) A lot of small cleanups. Thanks Marcelo. There are two things we need to re-discuss though; see: [5], [6].
5) We removed the need for a range of IDs for dynamic actions. Thanks Jakub.
6) Clarify ambiguity caused by smatch in an if(A) else if(B) condition. We are guaranteed that either A or B must exist; however, lets make smatch happy. Thanks to Simon and Dan Carpenter.
Changes In RFC Version 4
-------------------------
1) More integration from scriptable to eBPF. Small bug fixes.
2) More streamlining support of externs via kfunc (one additional kfunc).
3) Removed per-cpu scratchpad per Toke's suggestion and instead use XDP metadata.
There is more eBPF integration coming. One thing we looked at but is not in this patchset but should be in the next is use of eBPF link in our loading (see "challenge #1" further below).
What is P4?
-----------
The Programming Protocol-independent Packet Processors (P4) is an open source, domain-specific programming language for specifying data plane behavior.
The P4 ecosystem includes an extensive range of deployments, products, projects and services, etc. For Details, visit: https://p4.org/
__What is P4TC?__
P4TC is an implementation of P4 building on top of many years of Linux TC experiences. On why P4 - see small treatise here:[4].
There have been many discussions and meetings since about 2015 in regards to P4 over TC [2] and we are finally proving the naysayers that we do get stuff done!
A lot more of the P4TC motivation is captured at:
https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md
XXX: To be updated to describe integration with eBPF as datapath.
**In this patch series we focus on s/w datapath only**.
__P4TC Workflow__
These patches enable kernel and user space code change _independency_ for any new P4 program that describes a new datapath. The workflow is as follows:
1) A developer writes a P4 program, "myprog"
2) Compiles it using the P4C compiler[8]. The compiler generates 3 outputs:
a) shell script(s) which form template definitions for the different P4 objects "myprog" utilizes (tables, externs, actions etc).
b) the parser and the rest of the datapath are generated
in eBPF and need to be compiled into binaries.
c) A json introspection file used for control plane (by iproute2/tc).
3) The developer (or operator) executes the shell script(s) to manifest the functional s/w equivalent of "myprog" into the kernel.
4) The developer (or operator) instantiates "myprog" via the tc P4 filter to ingress/egress (depending on P4 arch) of one or more netdevs/ports.
Example1: parser is an action:
"tc filter add block 22 ingress protocol any prio 1 p4 pname myprog \
action bpf obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"
Example2: parser explicitly bound and rest of dpath as an action:
"tc filter add block 22 ingress protocol any prio 1 p4 pname myprog \
prog tc obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"
Example3: parser is at XDP, rest of dpath as an action:
"tc filter add block 22 ingress protocol any prio 1 p4 pname myprog \
prog xdp obj $PARSER.o section parser/xdp-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"
Example4: parser+prog at XDP:
"tc filter add block 22 ingress protocol any prio 1 p4 pname myprog \
prog xdp obj $PROGNAME.o section p4prog/xdp"
see individual patches for more examples tc vs xdp etc. Also see section on "challenges".
Once "myprog" is instantiated one can start updating table entries that are associated with "myprog". Example:
tc p4runtime create myprog/mytable dstAddr 10.0.1.2/32 \
action send_to_port param port eno1
A packet arriving on ingress of any of the ports on block 22 will first be exercised via the (eBPF) parser to find the headers pointing to the ip destination address.
The remainder eBPF datapath uses the result dstAddr as a key to (kfunc) lookup myprog's mytable which returns the action params which are then used to execute the action in the eBPF datapath (eventually sending out packets to eno1). On a miss, mytable's default miss action is executed.
__Description of Patches__
P4TC is designed to have no impact on the core code for other users of TC. IOW, you can compile it out or as a module and if you dont use it then there should be no impact on your performance.
We do make core kernel changes. Patch #1 introduces new "dynamic" actions that can be created on "the fly" based on the P4 program requirement. This patch makes a small incision into act_api which shouldnt affect the performance (or functionality) of the existing actions. Patches 2-7 are minimalist enablers for P4TC and have no effect the classical tc action.
The core P4TC code implements several P4 objects.
1) Patch #8 introduces P4 data types which are consumed by the rest of the code
2) Patch #9 introduces the concept of templating Pipelines. i.e CRUD commands for P4 pipelines.
3) Patch #10 introduces the concept of P4 header fields and associated CRUD template commands.
4) Patch #11 introduces the concept of action templates and associated CRUD commands.
5) Patch #12 introduces the concept of P4 table templates and associated CRUD commands for tables
6) Patch #13 introduces table entries and associated CRUD commands.
7) Patch #14 introduces interaction of eBPF to P4TC domain via kfunc.
8) Patch #15 introduces the TC classifier P4 used at runtime.
9) Patch #16 introduces extern interfacing (both template and runtime).
10) Patches #17-21 are control tests for the different objects (we left out some for brevity.
__Testing__
Speaking of testing - we have ~300 tdc test cases. This number is growing and we are adjusting to accommodate for eBPF.
These tests are run on our CICD system on pull requests and after commits are approved. The CICD does a lot of other tests (more since v2, thanks to Simon's input)including:
checkpatch, sparse, smatch, coccinelle, 32 bit and 64 bit builds tested on both X86, ARM 64 and emulated BE via qemu s390. We trigger performance testing in the CICD to catch performance regressions (currently only on the control path, but in the future for the datapath).
Syzkaller runs 24/7 on dedicated hardware, originally we focussed only on memory sanitizer but recently added support for concurrency sanitizer. Before main releases we ensure each patch will compile on its own to help in git bisect and run the xmas tree tool. We eventually put the code via coverity.
In addition we are working on a tool that will take a P4 program, run it through the compiler, and generate permutations of traffic patterns via symbolic execution that will test both positive and negative datapath code paths. The test generator tool is still work in progress and will be generated by the P4 compiler.
Note: We have other code that test parallelization etc which we are trying to find a fit for in the kernel tree.
__Restating Our Requirements__
Our original intention was to target the TC crowd for both s/w and h/w offload. Essentially developers and ops people deploying TC based infra.
More importantly the original intent for P4TC was to enable _ops folks_ more than devs (given code is being generated).
With TC we get whole "familiar" package of match-action pipeline abstraction++:
from the control plane to the tooling infra, netlink messaging to s/w and h/w symbiosis, the autonomous kernel control, etc. The advantage is that we have a singular vendor-neutral interface via the kernel using well understood mechanisms based on deployment experience.
1) Supporting expressibility of universe set of P4 progs
It is a must to support 100% of all possible P4 programs. In the past the eBPF verifier had to be worked around and even then there are cases where we couldnt avoid path explosion when branching is involved. Kfunc-ing solves these issues for us. Note, there are still challenges running all potential P4 programs at the XDP level - the solution to that is to have the compiler generate XDP based code only if it possible to map it to that layer.
2) Support for P4 HW and SW equivalence.
This feature continues to work even in the presence of eBPF as the s/w datapath. There are cases of square-hole-round-peg scenarios but those are implementation issues we can live with.
3) Operational usability
By maintaining the TC control plane (even in presence of eBPF datapath) runtime aspects remain unchanged. So for our target audience of folks who have deployed tc including offloads - the comfort zone is unchanged.
There is some loss in operational usability because we now have more knobs:
the extra compilation, loading and syncing of binaries, etc. IOW, I can no longer just ship someone a shell script in an email to say go run this and "myprog" will just work.
4) Operational and development Debuggability
If something goes wrong, the tc craftsperson is now required to have additional knowledge of eBPF code and process. This applies to both the operational person as well as someone who wrote a driver. We dont believe this is solvable.
5) Opportunity for rapid prototyping of new ideas
During the P4TC development phase something that came naturally was to often handcode the template scripts because the compiler backend (which is P4 arch specific) wasnt ready to generate certain things. Then you would read back the template and diff to ensure the kernel didnt get something wrong. So this started as a debug feature. During development, we wrote scripts that covered a range of P4 architectures(PSA, V1, etc) which required no kernel code changes.
In its basic form it boils down to the old adage of a niche DSL script vs a compiled general purpose language such as eBPF. Given our target audience who know P4/TC, and understand our hooks, the shell script whose command set is more aligned to P4 is a natural fit compared to handcoding eBPF.
Over time the debug feature morphed into: a) start by handcoding scripts then
b) read it back and then c) generate the P4 code.
It means one could start with the template scripts outside of the constraints of a P4 architecture spec(PNA/PSA) or even within a P4 architecture then test some ideas and eventually feed back the concepts to the compiler authors or modify or create a new P4 architecture and share with the P4 standards folks.
To summarize in presence of eBPF: The debugging idea is still alive. One could dump, with proper tooling(bpftool for example), the loaded eBPF code and be able to check for differences.
The concept of going back from whats in the kernel to P4 is a lot more difficult to implement mostly due to scoping of DSL vs general purpose. It may be lost. We have been thinking of ways to use BTF and embedding annotations in the eBPF code and binary but more thought is required and we welcome suggestions.
6) Performance
It is clear you gain better performance for the datapath with eBPF. Refer to our results for the tests we did[1].
Note: for computationally complex programs this value diminishes i.e the gap between XDP and TC eBPF or even in some cases scriptable approach is not prominent; however, we do acknowledge there is an observable performance gain as expected (compiled vs interpreted approach).
__Challenges__
1) When we have either the parser or part/whole of s/w datapath running in XDP then we need to make sure that the instantiation at the TC level is aware. For this we reason we need a mechanism for ensuring that the XDP program stays alive. Unfortunately we dont have a clean way of doing this at the moment i.e the program could be removed under us. It would be useful to have a refcount mechanism where the program cant be unbound from a port/netdev. Andrii Nakryiko made a suggestion to use bpf link for XDP which we are going to try out.
2) Concept of tc block in XDP is tedious to implement.
3) Right now we are using "packed" construct to enforce alignment in kfunc data exchange; but we're wondering if there is potential to use BTF to understand parameters and their offsets and encode this information at the compiler level.
4) At the moment we are creating a static buffer of 128B to retrieve the action parameters. If you have a lot of table entries and individual(non-shared) action instances with actions that require very little (or no) param space a lot of memory is wasted. There may also be cases where 128B may not be enough; (likely this is something we can teach the P4C compiler). If we can have dynamic pointers instead for kfunc fixed length parametrization then this issue is resolvable.
5) See "Restating Our Requirements" #5.
We would really appreciate ideas/suggestions, etc.
__References__
[1]https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf [2]https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md#historical-perspective-for-p4tc [3]https://2023p4workshop.sched.com/event/1KsAe/p4tc-linux-kernel-p4-implementation-approaches-and-evaluation [4]https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md#so-why-p4-and-how-does-p4-help-here [5]https://lore.kernel.org/netdev/[email protected]/T/#mf59be7abc5df3473cff3879c8cc3e2369c0640a6 [6]https://lore.kernel.org/netdev/[email protected]/T/#m783cfd79e9d755cf0e7afc1a7d5404635a5b1919 [7]https://lore.kernel.org/netdev/[email protected]/T/#ma8c84df0f7043d17b98f3d67aab0f4904c600469 [8]https://github.com/p4lang/p4c/tree/main/backends/tc
Jamal Hadi Salim (22):
net: sched: act_api: Add dynamic actions IDR
net/sched: act_api: increase action kind string length net/sched: act_api: add init_ops to struct tc_action_op net/sched: act_api: export generic tc action searcher net/sched: act_api: add struct p4tc_action_ops as a parameter to
lookup callback
net: introduce rcu_replace_pointer_rtnl
rtnl: add helper to check if group has listeners
p4tc: add P4 data types
p4tc: add pipeline create, get, update, delete
p4tc: add header field create, get, delete, flush and dump
p4tc: add action template create, update, delete, get, flush and dump
p4tc: add table create, update, delete, get, flush and dump
p4tc: add table entry create, update, get, delete, flush and dump
p4tc: add set of P4TC table read kfuncs
p4tc: add P4 classifier
p4tc: Add P4 extern interface
selftests: tc-testing: add JSON introspection file directory for P4TC
selftests: tc-testing: add P4TC pipeline control path tdc tests
selftests: tc-testing: add P4TC action templates tdc tests
selftests: tc-testing: add P4TC table control path tdc tests
selftests: tc-testing: add P4TC table entries control path tdc tests
MAINTAINERS: add p4tc entry
MAINTAINERS | 14 + include/linux/bitops.h | 1 + include/linux/rtnetlink.h | 19 + include/net/act_api.h | 20 +- include/net/p4tc.h | 643 ++ include/net/p4tc_ext_api.h | 98 + include/net/p4tc_types.h | 87 + include/net/tc_act/p4tc.h | 25 + include/uapi/linux/p4tc.h | 375 ++ include/uapi/linux/p4tc_ext.h | 39 + include/uapi/linux/pkt_cls.h | 20 + include/uapi/linux/rtnetlink.h | 14 + net/sched/Kconfig | 21 + net/sched/Makefile | 3 + net/sched/act_api.c | 158 +- net/sched/cls_api.c | 2 +- net/sched/cls_p4.c | 508 ++ net/sched/p4tc/Makefile | 8 + net/sched/p4tc/p4tc_action.c | 1726 +++++ net/sched/p4tc/p4tc_bpf.c | 196 + net/sched/p4tc/p4tc_ext.c | 2103 +++++++ net/sched/p4tc/p4tc_hdrfield.c | 591 ++ net/sched/p4tc/p4tc_parser_api.c | 146 + net/sched/p4tc/p4tc_pipeline.c | 694 ++ net/sched/p4tc/p4tc_runtime_api.c | 148 + net/sched/p4tc/p4tc_table.c | 1449 +++++ net/sched/p4tc/p4tc_tbl_entry.c | 2108 +++++++ net/sched/p4tc/p4tc_tmpl_api.c | 604 ++ net/sched/p4tc/p4tc_tmpl_ext.c | 2429 +++++++ net/sched/p4tc/p4tc_types.c | 1255 ++++ net/sched/p4tc/trace.c | 10 + net/sched/p4tc/trace.h | 44 + security/selinux/nlmsgtab.c | 8 +- .../introspection-examples/example_pipe.json | 92 + .../tc-tests/p4tc/action_templates.json | 3929 ++++++++++++ .../tc-testing/tc-tests/p4tc/pipeline.json | 1448 +++++ .../tc-testing/tc-tests/p4tc/table.json | 5597 +++++++++++++++++ .../tc-tests/p4tc/table_entries.json | 4269 +++++++++++++ 38 files changed, 30873 insertions(+), 28 deletions(-) create mode 100644 include/net/p4tc.h create mode 100644 include/net/p4tc_ext_api.h create mode 100644 include/net/p4tc_types.h create mode 100644 include/net/tc_act/p4tc.h create mode 100644 include/uapi/linux/p4tc.h create mode 100644 include/uapi/linux/p4tc_ext.h create mode 100644 net/sched/cls_p4.c create mode 100644 net/sched/p4tc/Makefile create mode 100644 net/sched/p4tc/p4tc_action.c create mode 100644 net/sched/p4tc/p4tc_bpf.c create mode 100644 net/sched/p4tc/p4tc_ext.c create mode 100644 net/sched/p4tc/p4tc_hdrfield.c create mode 100644 net/sched/p4tc/p4tc_parser_api.c create mode 100644 net/sched/p4tc/p4tc_pipeline.c create mode 100644 net/sched/p4tc/p4tc_runtime_api.c create mode 100644 net/sched/p4tc/p4tc_table.c create mode 100644 net/sched/p4tc/p4tc_tbl_entry.c create mode 100644 net/sched/p4tc/p4tc_tmpl_api.c create mode 100644 net/sched/p4tc/p4tc_tmpl_ext.c create mode 100644 net/sched/p4tc/p4tc_types.c create mode 100644 net/sched/p4tc/trace.c create mode 100644 net/sched/p4tc/trace.h create mode 100644 tools/testing/selftests/tc-testing/introspection-examples/example_pipe.json create mode 100644 tools/testing/selftests/tc-testing/tc-tests/p4tc/action_templates.json create mode 100644 tools/testing/selftests/tc-testing/tc-tests/p4tc/pipeline.json create mode 100644 tools/testing/selftests/tc-testing/tc-tests/p4tc/table.json create mode 100644 tools/testing/selftests/tc-testing/tc-tests/p4tc/table_entries.json
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 1/22 net: sched: act_api: Add dynamic actions IDR
Kernel native actions kinds, such as gact, etc, have a predefined action ID that is statically defined; example TCA_ID_GACT (0x2) for gact. In P4 we would require to generate new actions "on the fly" based on the P4 program requirement. Doing this in a list, like act_base does, would require us to us to reimplement all of the ID generation that we get for free with IDRs, so we chose to stick with an IDR for this. We could've simply converted act_base into an IDR and used the same structure to store kernel native and dynamic actions. However dynamic action kinds, like the pipeline they are attached to, must be per net namespace, as opposed to native action kinds which are global. For that reason, we chose to create a separate structure to store dynamic actions.
--- include/net/act_api.h | 6 +- net/sched/act_api.c | 130 ++++++++++++++++++++++++++++++++++++++---- net/sched/cls_api.c | 2 +- 3 files changed, 123 insertions(+), 15 deletions(-)
include/net/act_api.h +4 -2
@@ -198,8 +198,10 @@ int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index,int tcf_idr_release (struct tc_action *a,bool bind);int tcf_register_action (struct tc_action_ops *a,struct pernet_operations *ops); +int tcf_register_dyn_action (struct net *net,struct tc_action_ops *act);int tcf_unregister_action (struct tc_action_ops *a,struct pernet_operations *ops); +int tcf_unregister_dyn_action (struct net *net,struct tc_action_ops *act);int tcf_action_destroy (struct tc_action *actions[],int bind);int tcf_action_exec (struct sk_buff *skb,struct tc_action **actions,int nr_actions,struct tcf_result *res);
@@ -207,8 +209,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,struct nlattr *est, struct tc_action *actions[], int init_res[], size_t *attr_size, u32 flags, u32 fl_flags, struct netlink_ext_ack *extack); -struct tc_action_ops *tc_action_load_ops (struct nlattr *nla,bool police, -bool rtnl_held, +struct tc_action_ops *tc_action_load_ops (struct net *net,struct nlattr *nla, +bool police,bool rtnl_held,struct netlink_ext_ack *extack); struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est,
net/sched/act_api.c +118 -12
226 lines not on this page · raw message
net/sched/cls_api.c +1 -1
@@ -3271,7 +3271,7 @@ int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **if (exts->police && tb[exts->police]) {struct tc_action_ops *a_o; - a_o =tc_action_load_ops (tb[exts->police], true, + a_o =tc_action_load_ops (net, tb[exts->police], true, !(flags &TCA_ACT_FLAGS_NO_RTNL ), extack);if (IS_ERR (a_o))
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 2/22 net/sched: act_api: increase action kind string length
In reply to Jamal Hadi SalimIncrease action kind string length from IFNAMSIZ to 64
The new P4TC dynamic actions, created via templates, will have longer names of format: "pipeline_name/act_name". IFNAMSIZ is currently 16 and is most of the times undersized for the above format.
So, to conform to this new format, we increase the maximum name length to account for this extra string (pipeline name) and the '/' character.
--- include/net/act_api.h | 2 +- include/uapi/linux/pkt_cls.h | 1 + net/sched/act_api.c | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-)
include/net/act_api.h +1 -1
@@ -105,7 +105,7 @@ typedef void (*tc_action_priv_destructor)(void *priv);struct tc_action_ops {struct list_head head; -char kind[IFNAMSIZ ]; +char kind[ACTNAMSIZ ];enum tca_id id;/* identifier should match kind */ unsigned int net_id;size_t size;
include/uapi/linux/pkt_cls.h +1 -0
@@ -6,6 +6,7 @@#include <linux/pkt_sched.h> #define TC_COOKIE_MAX_SIZE 16 +#define ACTNAMSIZ 64/* Action attributes */ enum {
net/sched/act_api.c +3 -3
@@ -479,7 +479,7 @@ static size_t tcf_action_shared_attrs_size(const struct tc_action *act)rcu_read_unlock ();return nla_total_size (0 )/* action number nested */ - +nla_total_size (IFNAMSIZ )/* TCA_ACT_KIND */ + +nla_total_size (ACTNAMSIZ )/* TCA_ACT_KIND */ + cookie_len/* TCA_ACT_COOKIE */ +nla_total_size (sizeof (struct nla_bitfield32 ))/* TCA_ACT_HW_STATS */ +nla_total_size (0 )/* TCA_ACT_STATS nested */
@@ -1404,7 +1404,7 @@ struct tc_action_ops *tc_action_load_ops(struct net *net, struct nlattr *nla, {struct nlattr *tb[TCA_ACT_MAX +1 ];struct tc_action_ops *a_o; -char act_name[IFNAMSIZ ]; +char act_name[ACTNAMSIZ ];struct nlattr *kind;int err;
@@ -1419,7 +1419,7 @@ struct tc_action_ops *tc_action_load_ops(struct net *net, struct nlattr *nla,NL_SET_ERR_MSG (extack,"TC action kind must be specified" );return ERR_PTR (err); } -if (nla_strscpy (act_name, kind,IFNAMSIZ ) <0 ) { +if (nla_strscpy (act_name, kind,ACTNAMSIZ ) <0 ) {NL_SET_ERR_MSG (extack,"TC action name too long" );return ERR_PTR (err); }
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 3/22 net/sched: act_api: add init_ops to struct tc_action_op
In reply to Jamal Hadi SalimThe initialisation of P4TC action instances require access to a struct p4tc_act (which appears in later patches) to help us to retrieve information like the dynamic action parameters etc. In order to retrieve struct p4tc_act we need the pipeline name or id and the action name or id. Also recall that P4TC action IDs are dynamic and are net namespace specific. The init callback from tc_action_ops parameters had no way of supplying us that information. To solve this issue, we decided to create a new tc_action_ops callback (init_ops), that provides us with the tc_action_ops struct which then provides us with the pipeline and action name. In addition we add a new refcount to struct tc_action_ops called dyn_ref, which accounts for how many action instances we have of a specific dynamic action.
--- include/net/act_api.h | 6 ++++++ net/sched/act_api.c | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-)
include/net/act_api.h +6 -0
@@ -108,6 +108,7 @@ struct tc_action_ops {char kind[ACTNAMSIZ ];enum tca_id id;/* identifier should match kind */ unsigned int net_id; +refcount_t dyn_ref;size_t size;struct module *owner; int (*act)(struct sk_buff *, const struct tc_action *,
@@ -119,6 +120,11 @@ struct tc_action_ops { struct nlattr *est, struct tc_action **act, struct tcf_proto *tp, u32 flags, struct netlink_ext_ack *extack); +/* This should be merged with the original init action */ +int (*init_ops)(struct net *net,struct nlattr *nla, +struct nlattr *est,struct tc_action **act, +struct tcf_proto *tp,struct tc_action_ops *ops, +u32 flags,struct netlink_ext_ack *extack); int (*walk)(struct net *, struct sk_buff *, struct netlink_callback *, int, const struct tc_action_ops *,
net/sched/act_api.c +11 -3
@@ -1007,7 +1007,7 @@ int tcf_register_action(struct tc_action_ops *act,struct tc_action_ops *a;int ret; -if (!act->act || !act->dump || !act->init) +if (!act->act || !act->dump || (!act->init && !act->init_ops))return -EINVAL ;/* We have to register pernet ops before making the action ops visible,
@@ -1495,8 +1495,16 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, } } - err = a_o->init (net, tb[TCA_ACT_OPTIONS ], est, &a, tp, - userflags.value | flags, extack); +/* When we arrive here we guarantee that a_o->init or +* a_o->init_ops exist. +*/ +if (a_o->init) + err = a_o->init (net, tb[TCA_ACT_OPTIONS ], est, &a, tp, + userflags.value | flags, extack); +else + err = a_o->init_ops (net, tb[TCA_ACT_OPTIONS ], est, &a, + tp, a_o, userflags.value | flags, + extack); }else { err = a_o->init (net, nla, est, &a, tp, userflags.value | flags, extack);
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 4/22 net/sched: act_api: export generic tc action searcher
In reply to Jamal Hadi SalimIn P4TC we need to query the tc actions directly in a net namespace. Therefore export __tcf_idr_search().
--- include/net/act_api.h | 2 ++ net/sched/act_api.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-)
include/net/act_api.h +2 -0
@@ -190,6 +190,8 @@ int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,const struct tc_action_ops *ops, struct netlink_ext_ack *extack);int tcf_idr_search (struct tc_action_net *tn,struct tc_action **a,u32 index); +int __tcf_idr_search (struct net *net,const struct tc_action_ops *ops, +struct tc_action **a,u32 index);int tcf_idr_create (struct tc_action_net *tn,u32 index,struct nlattr *est,struct tc_action **a,const struct tc_action_ops *ops,int bind,bool cpustats,u32 flags);
net/sched/act_api.c +3 -3
@@ -722,9 +722,8 @@ static int __tcf_generic_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops, extack); } -static int __tcf_idr_search (struct net *net, -const struct tc_action_ops *ops, -struct tc_action **a,u32 index) +int __tcf_idr_search (struct net *net,const struct tc_action_ops *ops, +struct tc_action **a,u32 index) {struct tc_action_net *tn =net_generic (net, ops->net_id);
@@ -733,6 +732,7 @@ static int __tcf_idr_search(struct net *net,return tcf_idr_search (tn, a, index); } +EXPORT_SYMBOL (__tcf_idr_search);static int tcf_idr_delete_index (struct tcf_idrinfo *idrinfo,u32 index) {
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 5/22 net/sched: act_api: add struct p4tc_action_ops as a parameter to lookup callback
In reply to Jamal Hadi SalimFor P4TC dynamic actions, we require information from struct tc_action_ops, specifically the action kind, to find and locate the dynamic action information for the lookup operation.
--- include/net/act_api.h | 3 ++- net/sched/act_api.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
include/net/act_api.h +2 -1
@@ -115,7 +115,8 @@ struct tc_action_ops { struct tcf_result *); /* called under RCU BH lock*/int (*dump)(struct sk_buff *,struct tc_action *,int ,int );void (*cleanup)(struct tc_action *); -int (*lookup)(struct net *net,struct tc_action **a,u32 index); +int (*lookup)(struct net *net,const struct tc_action_ops *ops, +struct tc_action **a,u32 index); int (*init)(struct net *net, struct nlattr *nla, struct nlattr *est, struct tc_action **act, struct tcf_proto *tp,
net/sched/act_api.c +1 -1
@@ -728,7 +728,7 @@ int __tcf_idr_search(struct net *net, const struct tc_action_ops *ops,struct tc_action_net *tn =net_generic (net, ops->net_id);if (unlikely (ops->lookup)) -return ops->lookup (net, a, index); +return ops->lookup (net, ops, a, index);return tcf_idr_search (tn, a, index); }
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 6/22 net: introduce rcu_replace_pointer_rtnl
In reply to Jamal Hadi SalimWe use rcu_replace_pointer(rcu_ptr, ptr, lockdep_rtnl_is_held()) throughout the P4TC infrastructure code.
It may be useful for other use cases, so we create a helper.
--- include/linux/rtnetlink.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/linux/rtnetlink.h +12 -0
@@ -62,6 +62,18 @@ static inline bool lockdep_rtnl_is_held(void)#define rcu_dereference_rtnl (p) \ rcu_dereference_check(p, lockdep_rtnl_is_held()) +/** +* rcu_replace_pointer_rtnl - replace an RCU pointer under rtnl_lock, returning +* its old value +* @rcu_ptr: RCU pointer, whose old value is returned +* @ptr: regular pointer +* +* Perform a replacement under rtnl_lock, where @rcu_ptr is an RCU-annotated +* pointer. The old value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr +*/ +#define rcu_replace_pointer_rtnl (rcu_ptr, ptr) \ + rcu_replace_pointer(rcu_ptr, ptr, lockdep_rtnl_is_held()) +/** * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL * @p: The pointer to read, prior to dereferencing
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 7/22 rtnl: add helper to check if group has listeners
In reply to Jamal Hadi SalimAs of today, rtnl code creates a new skb and unconditionally fills and broadcasts it to the relevant group. For most operations this is okay and doesn't waste resources in general.
For P4TC, it's interesting to know if the TC group has any listeners when adding/updating/deleting table entries as we can optimize for the most likely case it contains none. This not only improves our processing speed, it also reduces pressure on the system memory as we completely avoid the broadcast skb allocation.
--- include/linux/rtnetlink.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/linux/rtnetlink.h +7 -0
@@ -142,4 +142,11 @@ extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,extern void rtnl_offload_xstats_notify (struct net_device *dev); +static inline int rtnl_has_listeners (const struct net *net,u32 group) +{ +struct sock *rtnl = net->rtnl; + +return netlink_has_listeners (rtnl, group); +} +#endif /* __LINUX_RTNETLINK_H */
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 8/22 p4tc: add P4 data types
In reply to Jamal Hadi SalimIntroduce abstraction that represents P4 data types.
This also introduces the Kconfig and Makefile which later patches use. Types could be little, host or big endian definitions. The abstraction also supports defining:
a) bitstrings using annotations in control that look like "bitX" where X is the number of bits defined in a type
b) bitslices such that one can define in control bit8[0-3] and bit16[4-9]. A 4-bit slice from bits 0-3 and a 6-bit slice from bits 4-9 respectively.
Each type has a bitsize, a name (for debugging purposes), an ID and methods/ops. The P4 types will be used by headers, dynamic actions nd other part of P4TC.
Each type has four ops:
- validate_p4t: Which validates if a given value of a specific type meets valid boundary conditions.
- create_bitops: Which, given a bitsize, bitstart and bitend allocates and returns a mask and a shift value. For example, if we have type bit8[3-3] meaning bitstart = 3 and bitend = 3, we'll create a mask which would only give us the fourth bit of a bit8 value, that is, 0x08. Since we are interested in the fourth bit, the bit shift value will be 3.
- host_read : Which reads the value of a given type and transforms it to host order
- host_write : Which writes a provided host order value and transforms it to the type's native order
--- include/net/p4tc_types.h | 87 +++ include/uapi/linux/p4tc.h | 40 ++ net/sched/Kconfig | 8 + net/sched/Makefile | 2 + net/sched/p4tc/Makefile | 3 + net/sched/p4tc/p4tc_types.c | 1255 +++++++++++++++++++++++++++++++++++ 6 files changed, 1395 insertions(+) create mode 100644 include/net/p4tc_types.h create mode 100644 include/uapi/linux/p4tc.h create mode 100644 net/sched/p4tc/Makefile create mode 100644 net/sched/p4tc/p4tc_types.c
include/net/p4tc_types.h new file +87 -0
@@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_P4TYPES_H +#define __NET_P4TYPES_H + +#include <linux/netlink.h> +#include <linux/pkt_cls.h> +#include <linux/types.h> + +#include <uapi/linux/p4tc.h> + +#define P4T_MAX_BITSZ 128 + +struct p4tc_type_mask_shift { +void *mask; +u8 shift; +}; + +struct p4tc_type ; +struct p4tc_type_ops { +int (*validate_p4t)(struct p4tc_type *container,void *value,u16 startbit, +u16 endbit,struct netlink_ext_ack *extack); +struct p4tc_type_mask_shift *(*create_bitops)(u16 bitsz, +u16 bitstart, +u16 bitend, +struct netlink_ext_ack *extack); +void (*host_read)(struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift,void *sval, +void *dval); +void (*host_write)(struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift,void *sval, +void *dval); +void (*print)(struct net *net,struct p4tc_type *container, +const char *prefix,void *val); +}; + +#define P4T_MAX_STR_SZ 32 +struct p4tc_type { +char name[P4T_MAX_STR_SZ ]; +const struct p4tc_type_ops *ops; +size_t container_bitsz; +size_t bitsz; +int typeid; +}; + +struct p4tc_type *p4type_find_byid (int id); +bool p4tc_is_type_unsigned (int typeid); + +void p4t_copy (struct p4tc_type_mask_shift *dst_mask_shift, +struct p4tc_type *dst_t,void *dstv, +struct p4tc_type_mask_shift *src_mask_shift, +struct p4tc_type *src_t,void *srcv); +int p4t_cmp (struct p4tc_type_mask_shift *dst_mask_shift, +struct p4tc_type *dst_t,void *dstv, +struct p4tc_type_mask_shift *src_mask_shift, +struct p4tc_type *src_t,void *srcv); +void p4t_release (struct p4tc_type_mask_shift *mask_shift); + +int p4tc_register_types (void ); +void p4tc_unregister_types (void ); + +#ifdef CONFIG_RETPOLINE +void __p4tc_type_host_read (const struct p4tc_type_ops *ops, +struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift,void *sval, +void *dval); +void __p4tc_type_host_write (const struct p4tc_type_ops *ops, +struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift,void *sval, +void *dval); +#else +static inline void __p4tc_type_host_read (const struct p4tc_type_ops *ops, +struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift, +void *sval,void *dval) +{ +return ops->host_read (container, mask_shift, sval, dval); +} +static inline void __p4tc_type_host_write (const struct p4tc_type_ops *ops, +struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift, +void *sval,void *dval) +{ +return ops->host_write (container, mask_shift, sval, dval); +} +#endif + +#endif
include/uapi/linux/p4tc.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_P4TC_H +#define __LINUX_P4TC_H + +#define P4TC_MAX_KEYSZ 512 + +enum { +P4T_UNSPEC , +P4T_U8 =1 , +P4T_U16 =2 , +P4T_U32 =3 , +P4T_U64 =4 , +P4T_STRING =5 , +P4T_FLAG =6 , +P4T_MSECS =7 , +P4T_NESTED =8 , +P4T_NESTED_ARRAY =9 , +P4T_NUL_STRING =10 , +P4T_BINARY =11 , +P4T_S8 =12 , +P4T_S16 =13 , +P4T_S32 =14 , +P4T_S64 =15 , +P4T_BITFIELD32 =16 , +P4T_MACADDR =17 , +P4T_IPV4ADDR , +P4T_BE16 , +P4T_BE32 , +P4T_BE64 , +P4T_U128 , +P4T_S128 , +P4T_PATH , +P4T_BOOL , +P4T_DEV , +P4T_KEY , + __P4T_MAX, +}; +#define P4T_MAX (__P4T_MAX - 1) + +#endif
net/sched/Kconfig +8 -0
@@ -676,6 +676,14 @@ config NET_EMATCH_IPT To compile this code as a module, choose M here: the module will be called em_ipt. +config NET_P4_TC + bool "P4 TC support" + select NET_CLS_ACT + help + Say Y here if you want to use P4 features on top of TC. + The concept of Pipelines, Tables, metadata will be enabled + with this option. + config NET_CLS_ACT bool "Actions" select NET_CLS
net/sched/Makefile +2 -0
@@ -82,3 +82,5 @@ obj-$(CONFIG_NET_EMATCH_TEXT) += em_text.o obj-$(CONFIG_NET_EMATCH_CANID) += em_canid.o obj-$(CONFIG_NET_EMATCH_IPSET) += em_ipset.o obj-$(CONFIG_NET_EMATCH_IPT) += em_ipt.o + +obj-$(CONFIG_NET_P4_TC) += p4tc/
net/sched/p4tc/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y := p4tc_types.o
net/sched/p4tc/p4tc_types.c new file +1255 -0
1,255 lines not on this page · raw message
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 9/22 p4tc: add pipeline create, get, update, delete
In reply to Jamal Hadi Salim__Introducing P4 TC Pipeline__
This commit introduces P4 TC pipelines, which emulate the semantics of a P4 program/pipeline using the TC infrastructure.
One can refer to P4 programs/pipelines using their names or their specific pipeline ids (pipeid)
CRUD (Create, Read/get, Update and Delete) commands apply on a pipeline.
As an example, to create a P4 program/pipeline named aP4proggie with a single table in its pipeline, one would use the following command from user space tc:
tc p4template create pipeline/aP4proggie numtables 1
Note that, in the above command, the numtables is set as 1; the default is 0 because it is feasible to have a P4 program with no tables at all.
The kernel issues each pipeline a pipeline ID which could be referenced. The control plane can specify an ID of choice, for example:
tc p4template create pipeline/aP4proggie pipeid 1 numtables 1
Typically there is no good reason to specify the pipeid, but the choice is offered to the user.
To Read pipeline aP4proggie attributes, one would retrieve those details as follows:
tc p4template get pipeline/[aP4proggie] [pipeid 1]
To Update aP4proggie pipeline from 1 to 10 tables, one would use the following command:
tc p4template update pipeline/[aP4proggie] [pipeid 1] numtables 10
Note that, in the above command, one could use the P4 program/pipeline name, id or both to specify which P4 program/pipeline to update.
To Delete a P4 program/pipeline named aP4proggie with a pipeid of 1, one would use the following command:
tc p4template del pipeline/[aP4proggie] [pipeid 1]
Note that, in the above command, one could use the P4 program/pipeline name, id or both to specify which P4 program/pipeline to delete
If one wished to dump all the created P4 programs/pipelines, one would use the following command:
tc p4template get pipeline/
__Pipeline Lifetime__
After Create is issued, one can Read/get, Update and Delete; however the pipeline can only be put to use after it is "sealed". To seal a pipeline, one would issue the following command:
tc p4template update pipeline/aP4proggie state ready
Once the pipeline is sealed it cannot updated. It can be deleted and read.
After a pipeline is sealed it can be put to use via the TC P4 classifier. For example:
tc filter add dev $DEV ingress protocol any prio 6 p4 pname aP4proggie
Instantiates aP4proggie in the ingress of $DEV. One could also attach it to a block of ports (example tc block 22) as such:
tc filter add block 22 ingress protocol any prio 6 p4 pname aP4proggie
Once the pipeline is attached to a device or block it cannot be deleted. It becomes Read-only from the control plane/user space.
The pipeline can be deleted when there are no longer any users left.
--- include/net/p4tc.h | 116 +++++++ include/uapi/linux/p4tc.h | 64 ++++ include/uapi/linux/rtnetlink.h | 7 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_pipeline.c | 597 +++++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_tmpl_api.c | 575 +++++++++++++++++++++++++++++++ security/selinux/nlmsgtab.c | 5 +- 7 files changed, 1364 insertions(+), 2 deletions(-) create mode 100644 include/net/p4tc.h create mode 100644 net/sched/p4tc/p4tc_pipeline.c create mode 100644 net/sched/p4tc/p4tc_tmpl_api.c
include/net/p4tc.h new file +116 -0
@@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_P4TC_H +#define __NET_P4TC_H + +#include <uapi/linux/p4tc.h> +#include <linux/workqueue.h> +#include <net/sch_generic.h> +#include <net/net_namespace.h> +#include <linux/refcount.h> +#include <linux/rhashtable.h> +#include <linux/rhashtable-types.h> + +#define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT +#define P4TC_DEFAULT_MAX_RULES 1 +#define P4TC_PATH_MAX 3 + +#define P4TC_KERNEL_PIPEID 0 + +#define P4TC_PID_IDX 0 + +struct p4tc_dump_ctx { +u32 ids[P4TC_PATH_MAX ]; +}; + +struct p4tc_template_common ; + +struct p4tc_nl_pname { +char *data; +bool passed; +}; + +struct p4tc_pipeline ; +struct p4tc_template_ops { +void (*init)(void ); +struct p4tc_template_common *(*cu)(struct net *net,struct nlmsghdr *n, +struct nlattr *nla, +struct p4tc_nl_pname *nl_pname, +u32 *ids, +struct netlink_ext_ack *extack); +int (*put)(struct p4tc_pipeline *pipeline, +struct p4tc_template_common *tmpl, +struct netlink_ext_ack *extack); +int (*gd)(struct net *net,struct sk_buff *skb,struct nlmsghdr *n, +struct nlattr *nla,struct p4tc_nl_pname *nl_pname,u32 *ids, +struct netlink_ext_ack *extack); +int (*fill_nlmsg)(struct net *net,struct sk_buff *skb, +struct p4tc_template_common *tmpl, +struct netlink_ext_ack *extack); +int (*dump)(struct sk_buff *skb,struct p4tc_dump_ctx *ctx, +struct nlattr *nla,char **p_name,u32 *ids, +struct netlink_ext_ack *extack); +int (*dump_1)(struct sk_buff *skb,struct p4tc_template_common *common); +}; + +struct p4tc_template_common { +char name[TEMPLATENAMSZ ]; +struct p4tc_template_ops *ops; +u32 p_id; +u32 PAD0; +}; + +extern const struct p4tc_template_ops p4tc_pipeline_ops; + +struct p4tc_pipeline { +struct p4tc_template_common common; +struct rcu_head rcu; +struct net *net; +refcount_t p_ctrl_ref; +u16 num_tables; +u16 curr_tables; +u8 p_state; +}; + +struct p4tc_pipeline_net { +struct idr pipeline_idr; +}; + +int tcf_p4_tmpl_generic_dump (struct sk_buff *skb,struct p4tc_dump_ctx *ctx, +struct idr *idr,int idx, +struct netlink_ext_ack *extack); + +struct p4tc_pipeline *tcf_pipeline_find_byany (struct net *net, +const char *p_name, +const u32 pipeid, +struct netlink_ext_ack *extack); +struct p4tc_pipeline *tcf_pipeline_find_byid (struct net *net,const u32 pipeid); +struct p4tc_pipeline *tcf_pipeline_find_get (struct net *net,const char *p_name, +const u32 pipeid, +struct netlink_ext_ack *extack); + +static inline bool tcf_pipeline_get (struct p4tc_pipeline *pipeline) +{ +return refcount_inc_not_zero (&pipeline->p_ctrl_ref); +} + +void tcf_pipeline_put (struct p4tc_pipeline *pipeline); +struct p4tc_pipeline * +tcf_pipeline_find_byany_unsealed (struct net *net,const char *p_name, +const u32 pipeid, +struct netlink_ext_ack *extack); + +static inline int p4tc_action_destroy (struct tc_action **acts) +{ +int ret =0 ; + +if (acts) { + ret =tcf_action_destroy (acts,TCA_ACT_UNBIND ); +kfree (acts); + } + +return ret; +} + +#define to_pipeline (t) ((struct p4tc_pipeline *)t) + +#endif
include/uapi/linux/p4tc.h +64 -0
76 lines not on this page · raw message
include/uapi/linux/rtnetlink.h +7 -0
@@ -194,6 +194,13 @@ enum { RTM_GETTUNNEL,#define RTM_GETTUNNEL RTM_GETTUNNEL + RTM_CREATEP4TEMPLATE = 124, +#define RTM_CREATEP4TEMPLATE RTM_CREATEP4TEMPLATE + RTM_DELP4TEMPLATE, +#define RTM_DELP4TEMPLATE RTM_DELP4TEMPLATE + RTM_GETP4TEMPLATE, +#define RTM_GETP4TEMPLATE RTM_GETP4TEMPLATE + __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
net/sched/p4tc/Makefile +1 -1
@@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 -obj-y := p4tc_types.o +obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o
net/sched/p4tc/p4tc_pipeline.c new file +597 -0
597 lines not on this page · raw message
net/sched/p4tc/p4tc_tmpl_api.c new file +575 -0
575 lines not on this page · raw message
security/selinux/nlmsgtab.c +4 -1
@@ -94,6 +94,9 @@ static const struct nlmsg_perm nlmsg_route_perms[] = { { RTM_NEWTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, { RTM_DELTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, { RTM_GETTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_READ }, + { RTM_CREATEP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, + { RTM_DELP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, + { RTM_GETP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_READ }, }; static const struct nlmsg_perm nlmsg_tcpdiag_perms[] = {
@@ -176,7 +179,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)* structures at the top of this file with the new mappings * before updating the BUILD_BUG_ON() macro! */ -BUILD_BUG_ON (RTM_MAX != (RTM_NEWTUNNEL +3 )); +BUILD_BUG_ON (RTM_MAX != (RTM_CREATEP4TEMPLATE +3 )); err =nlmsg_perm (nlmsg_type, perm, nlmsg_route_perms,sizeof (nlmsg_route_perms));break ;
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 10/22 p4tc: add header field create, get, delete, flush and dump
In reply to Jamal Hadi SalimThis commit allows control to create, get, delete, flush and dump header field objects. The created header fields are retrieved at runtime by the parser. From a control plane interaction, a header field can only be created once the appropriate parser is instantiated.
Header fields are part of a pipeline and a parser instance and header fields can only be created in an unsealed pipeline.
To create a header field, the user must issue the equivalent of the following command:
tc p4template create hdrfield/myprog/myparser/ipv4/dstAddr hdrfieldid 4 \
type ipv4
where myprog is the name of a pipeline, myparser is a name of a parser instance, ipv4/dstAddr is the name of header field which is of type ipv4.
To delete a header field, the user must issue the equivalent of the following command:
tc p4template delete hdrfield/myprog/myparser/ipv4/dstAddr
where myprog is the name of pipeline, myparser is a name of a parser instance, ipv4/dstAddr is the name of header field to be deleted.
To retrieve meta-information from a header field, such as length, position and type, the user must issue the equivalent of the following command:
tc p4template get hdrfield/myprog/myparser/ipv4/dstAddr
where myprog is the name of pipeline, myparser is a name of a parser instance, ipv4/dstAddr is the name of header field to be deleted.
The user can also dump all the header fields available in a parser instance using the equivalent of the following command:
tc p4template get hdrfield/myprog/myparser/
With that, the user will get all the header field names available in a specific parser instance.
The user can also flush all the header fields available in a parser instance using the equivalent of the following command:
tc p4template del hdrfield/myprog/myparser/
Header fields do not support update operations.
--- include/net/p4tc.h | 53 +++ include/uapi/linux/p4tc.h | 21 ++ net/sched/p4tc/Makefile | 3 +- net/sched/p4tc/p4tc_hdrfield.c | 591 +++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_parser_api.c | 146 ++++++++ net/sched/p4tc/p4tc_pipeline.c | 5 + net/sched/p4tc/p4tc_tmpl_api.c | 19 + 7 files changed, 837 insertions(+), 1 deletion(-) create mode 100644 net/sched/p4tc/p4tc_hdrfield.c create mode 100644 net/sched/p4tc/p4tc_parser_api.c
include/net/p4tc.h +53 -0
@@ -17,6 +17,10 @@#define P4TC_KERNEL_PIPEID 0#define P4TC_PID_IDX 0 +#define P4TC_PARSEID_IDX 1 +#define P4TC_HDRFIELDID_IDX 2 + +#define P4TC_HDRFIELD_IS_VALIDITY_BIT 0x1struct p4tc_dump_ctx {u32 ids[P4TC_PATH_MAX ];
@@ -65,6 +69,7 @@ struct p4tc_pipeline {struct p4tc_template_common common;struct rcu_head rcu;struct net *net; +struct p4tc_parser *parser;refcount_t p_ctrl_ref;u16 num_tables;u16 curr_tables;
@@ -111,6 +116,54 @@ static inline int p4tc_action_destroy(struct tc_action **acts)return ret; } +struct p4tc_parser { +char parser_name[PARSERNAMSIZ ]; +struct idr hdr_fields_idr; +refcount_t parser_ref; +u32 parser_inst_id; +}; + +struct p4tc_hdrfield { +struct p4tc_template_common common; +struct p4tc_parser *parser; +u32 parser_inst_id; +u32 hdrfield_id; +refcount_t hdrfield_ref; +u16 startbit; +u16 endbit; +u8 datatype;/* T_XXX */ +u8 flags;/* P4TC_HDRFIELD_FLAGS_* */ +}; + +extern const struct p4tc_template_ops p4tc_hdrfield_ops; + +struct p4tc_parser *tcf_parser_create (struct p4tc_pipeline *pipeline, +const char *parser_name, +u32 parser_inst_id, +struct netlink_ext_ack *extack); + +struct p4tc_parser *tcf_parser_find_byid (struct p4tc_pipeline *pipeline, +const u32 parser_inst_id); +struct p4tc_parser *tcf_parser_find_byany (struct p4tc_pipeline *pipeline, +const char *parser_name, +u32 parser_inst_id, +struct netlink_ext_ack *extack); +int tcf_parser_del (struct net *net,struct p4tc_pipeline *pipeline, +struct p4tc_parser *parser,struct netlink_ext_ack *extack); + +struct p4tc_hdrfield *tcf_hdrfield_find_byid (struct p4tc_parser *parser, +const u32 hdrfield_id); +struct p4tc_hdrfield *tcf_hdrfield_find_byany (struct p4tc_parser *parser, +const char *hdrfield_name, +u32 hdrfield_id, +struct netlink_ext_ack *extack); +struct p4tc_hdrfield *tcf_hdrfield_get (struct p4tc_parser *parser, +const char *hdrfield_name, +u32 hdrfield_id, +struct netlink_ext_ack *extack); +void tcf_hdrfield_put_ref (struct p4tc_hdrfield *hdrfield); +#define to_pipeline (t) ((struct p4tc_pipeline *)t) +#define to_hdrfield (t) ((struct p4tc_hdrfield *)t)#endif
include/uapi/linux/p4tc.h +21 -0
@@ -19,9 +19,12 @@ struct p4tcmsg {#define P4TC_MSGBATCH_SIZE 16#define P4TC_MAX_KEYSZ 512 +#define HEADER_MAX_LEN 512#define TEMPLATENAMSZ 256#define PIPELINENAMSIZ TEMPLATENAMSZ +#define PARSERNAMSIZ TEMPLATENAMSZ +#define HDRFIELDNAMSIZ TEMPLATENAMSZ/* Root attributes */ enum {
@@ -46,6 +49,7 @@ enum {enum {P4TC_OBJ_UNSPEC ,P4TC_OBJ_PIPELINE , +P4TC_OBJ_HDR_FIELD , __P4TC_OBJ_MAX, };#define P4TC_OBJ_MAX __P4TC_OBJ_MAX
@@ -55,6 +59,7 @@ enum {P4TC_UNSPEC ,P4TC_PATH ,P4TC_PARAMS , +P4TC_COUNT , __P4TC_MAX, };#define P4TC_MAX __P4TC_MAX
@@ -98,6 +103,22 @@ enum { };#define P4T_MAX (__P4T_MAX - 1) +struct p4tc_hdrfield_ty { +__u16 startbit; +__u16 endbit; +__u8 datatype;/* P4T_* */ +}; + +/* Header field attributes */ +enum { +P4TC_HDRFIELD_UNSPEC , +P4TC_HDRFIELD_DATA , +P4TC_HDRFIELD_NAME , +P4TC_HDRFIELD_PARSER_NAME , + __P4TC_HDRFIELD_MAX +}; +#define P4TC_HDRFIELD_MAX (__P4TC_HDRFIELD_MAX - 1) +#define P4TC_RTA (r) \ ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct p4tcmsg))))
net/sched/p4tc/Makefile +2 -1
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o +obj-y := p4tc_types.o p4tc_pipeline.o p4tc_tmpl_api.o \ + p4tc_parser_api.o p4tc_hdrfield.o
net/sched/p4tc/p4tc_hdrfield.c new file +591 -0
591 lines not on this page · raw message
net/sched/p4tc/p4tc_parser_api.c new file +146 -0
146 lines not on this page · raw message
net/sched/p4tc/p4tc_pipeline.c +5 -0
@@ -98,6 +98,9 @@ static void tcf_pipeline_teardown(struct p4tc_pipeline *pipeline,idr_remove (&pipe_net->pipeline_idr, pipeline->common.p_id); +if (pipeline->parser) +tcf_parser_del (net, pipeline, pipeline->parser, extack); +/* If we are on netns cleanup we can't touch the pipeline_idr. * On pre_exit we will destroy the idr but never call into teardown * if filters are active which makes pipeline pointers dangle until
@@ -247,6 +250,8 @@ static struct p4tc_pipeline *tcf_pipeline_create(struct net *net,else pipeline->num_tables =P4TC_DEFAULT_NUM_TABLES ; + pipeline->parser =NULL ; + pipeline->p_state =P4TC_STATE_NOT_READY ; pipeline->net = net;
net/sched/p4tc/p4tc_tmpl_api.c +19 -0
@@ -42,6 +42,7 @@ static bool obj_is_valid(u32 obj) {switch (obj) {case P4TC_OBJ_PIPELINE : +case P4TC_OBJ_HDR_FIELD :return true;default :return false;
@@ -50,6 +51,7 @@ static bool obj_is_valid(u32 obj)static const struct p4tc_template_ops *p4tc_ops[P4TC_OBJ_MAX ] = { [P4TC_OBJ_PIPELINE ] = &p4tc_pipeline_ops, + [P4TC_OBJ_HDR_FIELD ] = &p4tc_hdrfield_ops, }; int tcf_p4_tmpl_generic_dump(struct sk_buff *skb, struct p4tc_dump_ctx *ctx,
@@ -124,6 +126,12 @@ static int tc_ctl_p4_tmpl_gd_1(struct net *net, struct sk_buff *skb, ids[P4TC_PID_IDX ] = t->pipeid; +if (tb[P4TC_PATH ]) { +const u32 *arg_ids =nla_data (tb[P4TC_PATH ]); + +memcpy (&ids[P4TC_PID_IDX +1 ], arg_ids,nla_len (tb[P4TC_PATH ])); + } + op = (struct p4tc_template_ops *)p4tc_ops[t->obj]; ret = op->gd (net, skb, n, tb[P4TC_PARAMS ], nl_pname, ids, extack);
@@ -310,6 +318,12 @@ tcf_p4_tmpl_cu_1(struct sk_buff *skb, struct net *net, struct nlmsghdr *n, ids[P4TC_PID_IDX ] = t->pipeid; +if (tb[P4TC_PATH ]) { +const u32 *arg_ids =nla_data (tb[P4TC_PATH ]); + +memcpy (&ids[P4TC_PID_IDX +1 ], arg_ids,nla_len (tb[P4TC_PATH ])); + } + op = (struct p4tc_template_ops *)p4tc_ops[t->obj]; tmpl = op->cu (net, n, tb[P4TC_PARAMS ], nl_pname, ids, extack);if (IS_ERR (tmpl))
@@ -496,6 +510,11 @@ static int tc_ctl_p4_tmpl_dump_1(struct sk_buff *skb, struct nlattr *arg, root =nla_nest_start (skb,P4TC_ROOT ); ids[P4TC_PID_IDX ] = t->pipeid; +if (tb[P4TC_PATH ]) { +const u32 *arg_ids =nla_data (tb[P4TC_PATH ]); + +memcpy (&ids[P4TC_PID_IDX +1 ], arg_ids,nla_len (tb[P4TC_PATH ])); + } op = (struct p4tc_template_ops *)p4tc_ops[t->obj]; ret = op->dump (skb, ctx, tb[P4TC_PARAMS ], &p_name, ids, extack);
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 11/22 p4tc: add action template create, update, delete, get, flush and dump
In reply to Jamal Hadi SalimThis commit allows users to create, update, delete, get, flush and dump dynamic actions based on P4 action definition.
At the moment dynamic actions are tied to P4 programs only and cannot be used outside of a P4 program definition.
Visualize the following action in a P4 program:
action ipv4_forward(bit<48> dstAddr, bit<8> port)
{
standard_metadata.egress_spec = port;
hdr.ethernet.srcAddr = hdr.ethernet.dstAddr;
hdr.ethernet.dstAddr = dstAddr;
hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
}which is invoked on a P4 table match as such:
table mytable {
key = {
hdr.ipv4.dstAddr: lpm;
}
actions = {
ipv4_forward;
drop;
NoAction;
}
size = 1024;
}We don't have an equivalent built in "ipv4_forward" action in TC. So we create this action dynamically.
The mechanics of dynamic actions follow the CRUD semantics.
___DYNAMIC CREATION___
In this stage we issue the creation command for the dynamic action which specifies the action name, its ID, parameters and the parameter types. So for the ipv4_forward action, the creation would look something like this:
tc p4template create action/aP4proggie/ipv4_forward \
param dstAddr type macaddr id 1 param port type dev id 2
Note1: Although the P4 program defined dstAddr as type bit48 we use our type called macaddr (likewise for port) - see commit on p4 types for details.
Note that in the template creation op we usually just specify the action name, the parameters and their respective types. Also see that we specify a pipeline name during the template creation command. As an example, the above command creates an action template that is bounded to pipeline/program named aP4proggie.
___ACTION_ACTIVATION___
Once we provided all the necessary information for the new dynamic action, we can go to the final stage, which is action activation. In this stage, we activate the dynamic action and make it available for instantiation. To activate the action template, we issue the following command:
tc p4template update action aP4proggie/ipv4_forward state active
After the above the command, the action is ready to be instantiated.
___RUNTIME___
This next section deals with the runtime part of action templates, which handle action template instantiation and binding.
To instantiate a new action from a template, we use the following command:
tc actions add action aP4proggie/ipv4_forward \
param dstAddr AA:BB:CC:DD:EE:FF param port eth0 index 1
Observe these are the same semantics as what tc today already provides with a caveat that we have a keyword "param" to precede the appropriate parameters - as such specifying the index is optional (kernel provides one when unspecified).
As previously stated, we refer to the action by it's "full name" (pipeline_name/action_name). Here we are creating an instance of the ipv4_forward action specifying as parameter values AA:BB:CC:DD:EE:FF for dstAddr and eth0 for port. We can create as many instances for action templates as we wish.
To bind the above instantiated action to a table entry, you can do use the same classical approach used to bind ordinary actions to filters, for example:
tc p4runtime create aP4proggie/table/mycontrol/mytable srcAddr 10.10.10.0/24 \
action ipv4_forward index 1
The above command will bind our newly instantiated action to a table entry which is executed if there's a match.
Of course one could have created the table entry as:
tc p4runtime create aP4proggie/table/mycontrol/mytable srcAddr 10.10.10.0/24 \
action ipv4_forward param dstAddr AA:BB:CC:DD:EE:FF param port eth0
Actions from other control blocks might be referenced as the action index is per pipeline.
___OTHER_CONTROL_COMMANDS___
The lifetime of the dynamic action is tied to its pipeline.
As with all pipeline components, write operations to action templates, such as create, update and delete, can only be executed if the pipeline is not sealed. Read/get can be issued even after the pipeline is sealed.
If, after we are done with our action template we want to delete it, we should issue the following command:
tc p4template del action/aP4proggie/ipv4_forward
If we had created more action templates and wanted to flush all of the action templates from pipeline aP4proggie, one would use the following command:
tc p4template del action/aP4proggie/
After creating or updating a dynamic actions, if one wishes to verify that the dynamic action was created correctly, one would use the following command:
tc p4template get action/aP4proggie/ipv4_forward
The above command will display the relevant data for the action, such as parameter names, types, etc.
If one wanted to check which action templates were associated to a specific pipeline, one could use the following command:
tc p4template get action/aP4proggie/
Note that this command will only display the name of these action templates. To verify their specific details, one should use the get command, which was previously described.
--- include/net/act_api.h | 1 + include/net/p4tc.h | 133 +++ include/net/tc_act/p4tc.h | 25 + include/uapi/linux/p4tc.h | 42 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_action.c | 1725 ++++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 15 +- net/sched/p4tc/p4tc_tmpl_api.c | 2 + 8 files changed, 1942 insertions(+), 3 deletions(-) create mode 100644 include/net/tc_act/p4tc.h create mode 100644 net/sched/p4tc/p4tc_action.c
include/net/act_api.h +1 -0
@@ -68,6 +68,7 @@ struct tc_action {#define TCA_ACT_FLAGS_REPLACE (1U << (TCA_ACT_FLAGS_USER_BITS + 2))#define TCA_ACT_FLAGS_NO_RTNL (1U << (TCA_ACT_FLAGS_USER_BITS + 3))#define TCA_ACT_FLAGS_AT_INGRESS (1U << (TCA_ACT_FLAGS_USER_BITS + 4)) +#define TCA_ACT_FLAGS_FROM_P4TC (1U << (TCA_ACT_FLAGS_USER_BITS + 5))/* Update lastuse only if needed, to avoid dirtying a cache line. * We use a temp variable to avoid fetching jiffies twice.
include/net/p4tc.h +133 -0
183 lines not on this page · raw message
include/net/tc_act/p4tc.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_TC_ACT_P4_H +#define __NET_TC_ACT_P4_H + +#include <net/pkt_cls.h> +#include <net/act_api.h> + +struct tcf_p4act_params { +struct tcf_exts exts; +struct idr params_idr; +struct p4tc_act_param **params_array; +struct rcu_head rcu; +u32 num_params; +}; + +struct tcf_p4act { +struct tc_action common; +/* Params IDR reference passed during runtime */ +struct tcf_p4act_params __rcu *params; +u32 p_id; +u32 act_id; +}; +#define to_p4act (a) ((struct tcf_p4act *)a) + +#endif /* __NET_TC_ACT_P4_H */
include/uapi/linux/p4tc.h +42 -0
66 lines not on this page · raw message
net/sched/p4tc/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-y := p4tc_types.o p4tc_pipeline.o p4tc_tmpl_api.o \ - p4tc_parser_api.o p4tc_hdrfield.o + p4tc_parser_api.o p4tc_hdrfield.o p4tc_action.o
net/sched/p4tc/p4tc_action.c new file +1725 -0
1,725 lines not on this page · raw message
net/sched/p4tc/p4tc_pipeline.c +13 -2
@@ -74,6 +74,8 @@ static const struct nla_policy tc_pipeline_policy[P4TC_PIPELINE_MAX + 1] = {static void tcf_pipeline_destroy (struct p4tc_pipeline *pipeline) { +idr_destroy (&pipeline->p_act_idr); +kfree (pipeline); }
@@ -95,8 +97,12 @@ static void tcf_pipeline_teardown(struct p4tc_pipeline *pipeline,struct net *net = pipeline->net;struct p4tc_pipeline_net *pipe_net =net_generic (net, pipeline_net_id);struct net *pipeline_net =maybe_get_net (net); +unsigned long iter_act_id; +struct p4tc_act *act; +unsigned long tmp; -idr_remove (&pipe_net->pipeline_idr, pipeline->common.p_id); +idr_for_each_entry_ul (&pipeline->p_act_idr, act, tmp, iter_act_id) + act->common.ops->put (pipeline, &act->common, extack);if (pipeline->parser)tcf_parser_del (net, pipeline, pipeline->parser, extack);
@@ -252,6 +258,10 @@ static struct p4tc_pipeline *tcf_pipeline_create(struct net *net, pipeline->parser =NULL ; +idr_init (&pipeline->p_act_idr); + + pipeline->num_created_acts =0 ; + pipeline->p_state =P4TC_STATE_NOT_READY ; pipeline->net = net;
@@ -494,7 +504,8 @@ static int tcf_pipeline_gd(struct net *net, struct sk_buff *skb,return PTR_ERR (pipeline); tmpl = (struct p4tc_template_common *)pipeline; -if (tcf_pipeline_fill_nlmsg (net, skb, tmpl, extack) <0 ) + ret =tcf_pipeline_fill_nlmsg (net, skb, tmpl, extack); +if (ret <0 )return -1 ;if (!ids[P4TC_PID_IDX ])
net/sched/p4tc/p4tc_tmpl_api.c +2 -0
@@ -43,6 +43,7 @@ static bool obj_is_valid(u32 obj)switch (obj) {case P4TC_OBJ_PIPELINE :case P4TC_OBJ_HDR_FIELD : +case P4TC_OBJ_ACT :return true;default :return false;
@@ -52,6 +53,7 @@ static bool obj_is_valid(u32 obj)static const struct p4tc_template_ops *p4tc_ops[P4TC_OBJ_MAX ] = { [P4TC_OBJ_PIPELINE ] = &p4tc_pipeline_ops, [P4TC_OBJ_HDR_FIELD ] = &p4tc_hdrfield_ops, + [P4TC_OBJ_ACT ] = &p4tc_act_ops, }; int tcf_p4_tmpl_generic_dump(struct sk_buff *skb, struct p4tc_dump_ctx *ctx,
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 12/22 p4tc: add table create, update, delete, get, flush and dump
In reply to Jamal Hadi SalimThis commit introduces code to create and maintain P4 tables within a P4 program from user space and the next patch will have the code for maintaining entries in the table.
As with all other P4TC objects, tables conform to CRUD operations and it's important to note that write operations, such as create, update and delete, can only be made if the pipeline is not sealed.
Per the P4 specification, tables prefix their name with the control block (although this could be overridden by P4 annotations).
As an example, if one were to create a table named table1 in a pipeline named myprog1, on control block "mycontrol", one would use the following command:
tc p4template create table/myprog1/mycontrol/table1 tblid 1 \
keysz 32 nummasks 8 tentries 8192
Above says that we are creating a table (table1) attached to pipeline myprog1 on control block mycontrol. Table1's key size is 32 bits wide and it can have up to 8 associted masks and 8192 entries. The table id for table1 is 1. The table id is typically provided by the compiler.
Parameters such as nummasks (number of masks this table may have) and tentries (maximum number of entries this table may have) may also be omitted in which case 8 masks and 256 entries will be assumed.
If one were to retrieve the table named table1 (before or after the pipeline is sealed) one would use the following command:
tc p4template get table/myprog1/mycontrol/table1
If one were to dump all the tables from a pipeline named myprog1, one would use the following command:
tc p4template get table/myprog1
If one were to update table1 (before the pipeline is sealed) one would use the following command:
tc p4template update table/myprog1/mycontrol/table1 ....
If one were to delete table1 (before the pipeline is sealed) one would use the following command:
tc p4template del table/myprog1/mycontrol/table1
If one were to flush all the tables from a pipeline named myprog1, control block "mycontrol" one would use the following command:
tc p4template del table/myprog1/mycontrol/
___Table Permissions___
Tables can have permissions which apply to all the entries in the specified table. Permissions are defined for both what the control plane (user space) is allowed to do as well as datapath.
The permissions field is a 16bit value which will hold CRUDX (create, read, update, delete and execute) permissions for control and data path. Bits 9-5 will have the CRUDX values for control and bits 4-0 will have CRUDX values for data path. By default each table has the following permissions:
CRUD--R--X
Which means the control plane can perform CRUD operations whereas the data path can only Read and execute on the entries.
The user can override these permissions when creating the table or when updating.
For example, the following command will create a table which will not allow the datapath to create, update or delete entries but give full CRUD permissions for the control plane.
$TC p4template create table/aP4proggie/cb/tname tblid 1 keysz 64 type lpm permissions 0x349 ...
Recall that these permissions come in the form of CRUDXCRUDX, where the first CRUDX block is for control and the last is for data path.
So 0x349 is equivalent to CR-D--R--X
If we were to do a get with the following command:
$TC p4template get table/aP4proggie/cb/tname
The output would be the following:
pipeline name aP4proggie pipeline id 22
table id 1
table name cb/tname
key_sz 64
max entries 256
masks 8
table entries 0
permissions CR-D--R--X
Note, the permissions concept is more powerful than classical const definition currently taken by P4 which makes everything in a table read-only.
___Initial Table Entries___
Templating can create initial table entries. For example:
tc p4template update table/myprog/cb/tname \
entry srcAddr 10.10.10.10/24 dstAddr 1.1.1.0/24 prio 17
In this command we are "updating" table cb/tname with a new entry. This entry has as its key srcAddr concatenated with dstAddr
(both IPv4 addresses) and prio 17.
If one was to read back the entry by issuing the following command:
tc p4template get myprog/table/cb/tname
They would get:
pipeline id 22
table id 1
table name cb/tname
key_sz 64
max entries 256
masks 8
table entries 1
permissions CRUD--R--X
entry:
entry priority 17[permissions-RUD--R--X]
entry key
srcAddr id:1 size:32b type:ipv4 exact fieldval 10.10.10.10/32 dstAddr id:2 size:32b type:ipv4 exact fieldval 1.1.1.0/24
___Table Actions List___
P4 tables allow certain actions but not other to be part of match entry on a table or as default actions when there is a miss.
We also allow flags for each of the actions in this list that specify if the action can be added only as a table entry (tableonly), or only as a default action (defaultonly). If no flags are specified, it is assumed that the action can be used in both contexts.
In P4TC we extend the concept of default action - which in P4 is mapped to "a default miss action". Our extension is to add a "hit action" which is executed every time there is a hit.
The default miss action will be executed whenever a table lookup doesn't match any of the entries.
Both default hit and default miss are optional.
An example of specifying a default miss action is as follows:
tc p4template update table/myprog/cb/mytable \
default_miss_action permissions 0x109 action dropThe above will drop packets if the entry is not found in mytable. Note the above makes the default action a const. Meaning the control plane can neither replace it nor delete it.
tc p4template update table/myprog/mytable \
default_hit_action permissions 0x30F action ok
Whereas the above allows a default hit action to accept the packet. The permission 0x30F (binary 1100001111) means we have only Create and Read permissions in the control plane and Read, Update, Delete and eXecute permissions in the data plane. This means, for example, that now we can only delete the default hit action from the data plane.
Note: above permissions dont seem very practical and merely shown to exemplify permission usage.
--- include/net/p4tc.h | 80 ++ include/net/p4tc_types.h | 2 +- include/uapi/linux/p4tc.h | 102 +++ net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_pipeline.c | 23 +- net/sched/p4tc/p4tc_table.c | 1369 ++++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_tmpl_api.c | 2 + 7 files changed, 1571 insertions(+), 9 deletions(-) create mode 100644 net/sched/p4tc/p4tc_table.c
include/net/p4tc.h +80 -0
@@ -15,10 +15,17 @@#define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT#define P4TC_DEFAULT_MAX_RULES 1#define P4TC_PATH_MAX 3 +#define P4TC_MAX_TENTRIES (2 << 23) +#define P4TC_DEFAULT_TENTRIES 256 +#define P4TC_MAX_TMASKS 1024 +#define P4TC_DEFAULT_TMASKS 8 + +#define P4TC_MAX_PERMISSION (GENMASK(P4TC_PERM_MAX_BIT, 0))#define P4TC_KERNEL_PIPEID 0#define P4TC_PID_IDX 0 +#define P4TC_TBLID_IDX 1#define P4TC_AID_IDX 1#define P4TC_PARSEID_IDX 1#define P4TC_HDRFIELDID_IDX 2
@@ -72,6 +79,7 @@ extern const struct p4tc_template_ops p4tc_pipeline_ops;struct p4tc_pipeline {struct p4tc_template_common common;struct idr p_act_idr; +struct idr p_tbl_idr;struct rcu_head rcu;struct net *net;struct p4tc_parser *parser;
@@ -111,6 +119,11 @@ tcf_pipeline_find_byany_unsealed(struct net *net, const char *p_name,const u32 pipeid, struct netlink_ext_ack *extack); +static inline bool pipeline_sealed (struct p4tc_pipeline *pipeline) +{ +return pipeline->p_state ==P4TC_STATE_READY ; +} +static inline int p4tc_action_destroy (struct tc_action **acts) {int ret =0 ;
@@ -123,6 +136,54 @@ static inline int p4tc_action_destroy(struct tc_action **acts)return ret; } +#define P4TC_CONTROL_PERMISSIONS (GENMASK(9, 5)) +#define P4TC_DATA_PERMISSIONS (GENMASK(4, 0)) + +#define P4TC_TABLE_PERMISSIONS \ + ((GENMASK(P4TC_CTRL_PERM_C_BIT, P4TC_CTRL_PERM_D_BIT)) | \ + P4TC_DATA_PERM_R | P4TC_DATA_PERM_X) + +#define P4TC_PERMISSIONS_UNINIT (1 << P4TC_PERM_MAX_BIT) + +struct p4tc_table_defact { +struct tc_action **default_acts; +/* Will have 2 5 bits blocks containing CRUDX (Create, read, update, +* delete, execute) permissions for control plane and data plane. +* The first 5 bits are for control and the next five are for data plane. +* |crudxcrudx| if we were to denote it as UNIX permission flags. +*/ +__u16 permissions; +struct rcu_head rcu; +}; + +struct p4tc_table_perm { +__u16 permissions; +struct rcu_head rcu; +}; + +struct p4tc_table { +struct p4tc_template_common common; +struct list_head tbl_acts_list; +struct idr tbl_masks_idr; +struct idr tbl_prio_idr; +struct rhltable tbl_entries; +struct p4tc_table_defact __rcu *tbl_default_hitact; +struct p4tc_table_defact __rcu *tbl_default_missact; +struct p4tc_table_perm __rcu *tbl_permissions; +struct p4tc_table_entry_mask __rcu **tbl_masks_array; +unsigned long __rcu *tbl_free_masks_bitmap; +spinlock_t tbl_masks_idr_lock; +u32 tbl_keysz; +u32 tbl_id; +u32 tbl_max_entries; +u32 tbl_max_masks; +u32 tbl_curr_num_masks; +refcount_t tbl_ctrl_ref; +u16 tbl_type; +}; + +extern const struct p4tc_template_ops p4tc_table_ops; +struct p4tc_ipv4_param_value {u32 value;u32 mask;
@@ -165,6 +226,12 @@ struct p4tc_act {refcount_t a_ref; }; +struct p4tc_table_act { +struct list_head node; +struct tc_action_ops *ops; +u8 flags; +}; +extern const struct p4tc_template_ops p4tc_act_ops;struct p4tc_parser {
@@ -250,6 +317,18 @@ struct p4tc_act_param *tcf_param_find_byany(struct p4tc_act *act,const u32 param_id, struct netlink_ext_ack *extack); +struct p4tc_table *tcf_table_find_byany (struct p4tc_pipeline *pipeline, +const char *tblname,const u32 tbl_id, +struct netlink_ext_ack *extack); +struct p4tc_table *tcf_table_find_byid (struct p4tc_pipeline *pipeline, +const u32 tbl_id); +int tcf_table_try_set_state_ready (struct p4tc_pipeline *pipeline, +struct netlink_ext_ack *extack); +struct p4tc_table *tcf_table_find_get (struct p4tc_pipeline *pipeline, +const char *tblname,const u32 tbl_id, +struct netlink_ext_ack *extack); +void tcf_table_put_ref (struct p4tc_table *table); + struct p4tc_parser *tcf_parser_create(struct p4tc_pipeline *pipeline, const char *parser_name, u32 parser_inst_id,
@@ -298,5 +377,6 @@ int generic_dump_param_value(struct sk_buff *skb, struct p4tc_type *type,#define to_pipeline (t) ((struct p4tc_pipeline *)t)#define to_hdrfield (t) ((struct p4tc_hdrfield *)t)#define to_act (t) ((struct p4tc_act *)t) +#define to_table (t) ((struct p4tc_table *)t)#endif
include/net/p4tc_types.h +1 -1
@@ -8,7 +8,7 @@#include <uapi/linux/p4tc.h> -#define P4T_MAX_BITSZ 128 +#define P4T_MAX_BITSZ P4TC_MAX_KEYSZstruct p4tc_type_mask_shift {void *mask;
include/uapi/linux/p4tc.h +102 -0
120 lines not on this page · raw message
net/sched/p4tc/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-y := p4tc_types.o p4tc_pipeline.o p4tc_tmpl_api.o \ - p4tc_parser_api.o p4tc_hdrfield.o p4tc_action.o + p4tc_parser_api.o p4tc_hdrfield.o p4tc_action.o p4tc_table.o
net/sched/p4tc/p4tc_pipeline.c +16 -7
@@ -75,6 +75,7 @@ static const struct nla_policy tc_pipeline_policy[P4TC_PIPELINE_MAX + 1] = {static void tcf_pipeline_destroy (struct p4tc_pipeline *pipeline) {idr_destroy (&pipeline->p_act_idr); +idr_destroy (&pipeline->p_tbl_idr);kfree (pipeline); }
@@ -97,9 +98,13 @@ static void tcf_pipeline_teardown(struct p4tc_pipeline *pipeline,struct net *net = pipeline->net;struct p4tc_pipeline_net *pipe_net =net_generic (net, pipeline_net_id);struct net *pipeline_net =maybe_get_net (net); -unsigned long iter_act_id; +unsigned long iter_act_id, tmp; +struct p4tc_table *table;struct p4tc_act *act; -unsigned long tmp; +unsigned long tbl_id; + +idr_for_each_entry_ul (&pipeline->p_tbl_idr, table, tmp, tbl_id) + table->common.ops->put (pipeline, &table->common, extack);idr_for_each_entry_ul (&pipeline->p_act_idr, act, tmp, iter_act_id) act->common.ops->put (pipeline, &act->common, extack);
@@ -153,21 +158,22 @@ static int __tcf_pipeline_put(struct p4tc_pipeline *pipeline,static inline int pipeline_try_set_state_ready (struct p4tc_pipeline *pipeline,struct netlink_ext_ack *extack) { +int ret; +if (pipeline->curr_tables != pipeline->num_tables) {NL_SET_ERR_MSG (extack,"Must have all table defined to update state to ready" );return -EINVAL ; } + ret =tcf_table_try_set_state_ready (pipeline, extack); +if (ret <0 ) +return ret; + pipeline->p_state =P4TC_STATE_READY ;return true; } -static inline bool pipeline_sealed (struct p4tc_pipeline *pipeline) -{ -return pipeline->p_state ==P4TC_STATE_READY ; -} -struct p4tc_pipeline *tcf_pipeline_find_byid (struct net *net,const u32 pipeid) {struct p4tc_pipeline_net *pipe_net;
@@ -260,6 +266,9 @@ static struct p4tc_pipeline *tcf_pipeline_create(struct net *net,idr_init (&pipeline->p_act_idr); +idr_init (&pipeline->p_tbl_idr); + pipeline->curr_tables =0 ; + pipeline->num_created_acts =0 ; pipeline->p_state =P4TC_STATE_NOT_READY ;
net/sched/p4tc/p4tc_table.c new file +1369 -0
1,369 lines not on this page · raw message
net/sched/p4tc/p4tc_tmpl_api.c +2 -0
@@ -44,6 +44,7 @@ static bool obj_is_valid(u32 obj)case P4TC_OBJ_PIPELINE :case P4TC_OBJ_HDR_FIELD :case P4TC_OBJ_ACT : +case P4TC_OBJ_TABLE :return true;default :return false;
@@ -54,6 +55,7 @@ static const struct p4tc_template_ops *p4tc_ops[P4TC_OBJ_MAX] = { [P4TC_OBJ_PIPELINE] = &p4tc_pipeline_ops, [P4TC_OBJ_HDR_FIELD] = &p4tc_hdrfield_ops, [P4TC_OBJ_ACT] = &p4tc_act_ops, + [P4TC_OBJ_TABLE] = &p4tc_table_ops, }; int tcf_p4_tmpl_generic_dump(struct sk_buff *skb, struct p4tc_dump_ctx *ctx,
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 13/22 p4tc: add table entry create, update, get, delete, flush and dump
In reply to Jamal Hadi SalimTables are conceptually similar to TCAMs and this implementation could be labelled as an "algorithmic" TCAM. Tables have a key of a specific size, maximum number of entries and masks allowed. The basic P4 key types are supported (exact, LPM, ternary, and ranges) although the kernel side is oblivious of all that and sees only bit blobs which it masks before a lookup is performed.
This commit allows users to create, update, delete, get, flush and dump table _entries_ (templates were described in earlier patch).
For example, a user issuing the following command:
tc p4runtime create myprog/table/cb/tname \
dstAddr 10.10.10.0/24 srcAddr 192.168.0.0/16 prio 16 \
action send param port port1
indicates we are creating a table entry in table "tname" on a pipeline named "myprog"
User space tc will create a key which has a value of 0x0a0a0a00c0a00000 (10.10.10.0 concatenated with 192.168.0.0) and a mask value of 0xffffff00ffff0000 (/24 concatenated with /16) that will be sent to the kernel. In addition a priority field of 16 is passed to the kernel as well as the action definition.
The priority field is needed to disambiguate in case two entries match. In that case, the kernel will choose the one with lowest priority number.
Note that table entries can only be created once the pipeline template is sealed.
If the user wanted to, for example, add an action to our just created entry, they'd issue the following command:
tc p4runtime update myprog/table/cb/tname srcAddr 10.10.10.0/24 \
dstAddr 192.168.0.0/16 prio 16 action send param port port5
In this case, the user needs to specify the pipeline name, the table name, the key and the priority, so that we can locate the table entry.
If the user wanted to, for example, get the table entry that we just updated, they'd issue the following command:
tc p4runtime get myprog/table/cb/tname srcAddr 10.10.10.0/24 \
dstAddr 192.168.0.0/16 prio 16
Note that, again, we need to specify the pipeline name, the table name, the key and the priority, so that we can locate the table entry.
If the user wanted to delete the table entry we created, they'd issue the following command:
tc p4runtime del myprog/table/cb/tname srcAddr 10.10.10.0/24 \
dstAddr 192.168.0.0/16 prio 16
Note that, again, we need to specify the pipeline name, the table name, the key and the priority, so that we can
locate the table entry.
We can also flush all the table entries from a specific table. To flush the table entries of table tname ane pipeline ptables, the user would issue the following command:
tc p4runtime del myprog/table/cb/tname
We can also dump all the table entries from a specific table . To dump the table entries of table tname and pipeline myprog, the user would issue the following command:
tc p4runtime get myprog/table/cb/tname
__Table Entry Permissions__
Table entries can have permissions specified when they are being added.
Caveat: we are doing a lot more than what P4 defines because we feel it is necessary.
Table entry permissions build on the table permissions provided when a table is created via the template (see earlier patch).
We have two types of permissions: Control path vs datapath. The template definition can set either one. For example, one could allow for adding table entries by the datapath in case of PNA add-on-miss is needed. By default tables entries have control plane RUD, meaning the control plane can Read, Update or Delete entries. By default, as well, the control plane can create new entries unless specified otherwise by the template.
Lets see an example of defining a table "tname" at template time:
tc p4template create table/ptables/cb/tname tblid 1 keysz 64 \
permissions 0x3C9 ...
Above is setting the table tname's permission to be 0x3C9 is equivalent to CRUD--R--X meaning:
The control plane can Create, Read, Update, Delete The datapath can only Read and Execute table entries. If one was to dump this table with:
tc p4template get table/ptables/cb/tname
The output would be the following:
pipeline name ptables id 22
table id 1
table name cb/tnamekey_sz 64
max entries 256
masks 8
table entries 0
permissions CRUD--R--X
The expressed permissions above are probably the most practical for most use cases.
__Constant Tables And P4-programmed Defined Entries__
If one wanted to restrict the table to be an equivalent to a "const" then the permissions would be set to be: -R----R--X
In such a case, typically the P4 program will have some entries defined (see the famous P4 calc example). The "initial entries" specified in the P4 program will have to be added by the template (as generated by the compiler), as such:
tc p4template update table/ptables/cb/tname \
entry srcAddr 10.10.10.10/24 dstAddr 1.1.1.0/24 prio 17
This table cannot be updated at runtime. Any attempt to add an entry of a table which is read-only at runtime will get a permission denied response back from the kernel.
Note: If one was to create an equivalent for PNA add-on-miss feature for this table, then the template would issue table permissions as: -R---CR--X PNA doesn't specify whether the datapath can also delete or update entries, but if it did then more appropriate permissions will be: -R----XCRUDX
__Mix And Match of RW vs Constant Entries__
Lets look at other scenarios; lets say the table has CRUD--R--X permissions as defined by the template...
At runtime the user could add entries which are "const" - by specifying the entry's permission as -R---R--X example:
tc p4runtime create ptables/table/cb/tname srcAddr 10.10.10.10/24 \
dstAddr 1.1.1.0/24 prio 17 permissions 0x109 action drop
or not specify permissions at all as such:
tc p4runtime create ptables/table/cb/tname srcAddr 10.10.10.10/24 \
dstAddr 1.1.1.0/24 prio 17 \
action drop
in which case the table's permissions defined at template time( CRUD--R--X) are assumed; meaning the table entry can be deleted or updated by the control plane.
__Entries permissions Allowed On A Table Entry Creation At Runtime__
When an entry is added with expressed permissions it has at most to have what the template table definition expressed but could ask for less permission. For example, assuming a table with templated specified permissions of CR-D--R--X:
An entry created at runtime with permission of -R----R--X is allowed but an entry with -RUD--R--X will be rejected.
--- include/net/p4tc.h | 88 +- include/uapi/linux/p4tc.h | 44 +- include/uapi/linux/rtnetlink.h | 7 + net/sched/p4tc/Makefile | 3 +- net/sched/p4tc/p4tc_pipeline.c | 1 + net/sched/p4tc/p4tc_runtime_api.c | 139 ++ net/sched/p4tc/p4tc_table.c | 52 +- net/sched/p4tc/p4tc_tbl_entry.c | 2044 +++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_tmpl_api.c | 4 +- security/selinux/nlmsgtab.c | 5 +- 10 files changed, 2378 insertions(+), 9 deletions(-) create mode 100644 net/sched/p4tc/p4tc_runtime_api.c create mode 100644 net/sched/p4tc/p4tc_tbl_entry.c
include/net/p4tc.h +87 -1
@@ -145,6 +145,8 @@ static inline int p4tc_action_destroy(struct tc_action **acts)#define P4TC_PERMISSIONS_UNINIT (1 << P4TC_PERM_MAX_BIT) +#define P4TC_MAX_PARAM_DATA_SIZE 124 +struct p4tc_table_defact {struct tc_action **default_acts;/* Will have 2 5 bits blocks containing CRUDX (Create, read, update,
@@ -165,8 +167,9 @@ struct p4tc_table {struct p4tc_template_common common;struct list_head tbl_acts_list;struct idr tbl_masks_idr; -struct idr tbl_prio_idr; +struct ida tbl_prio_idr;struct rhltable tbl_entries; +struct p4tc_table_entry *tbl_const_entry;struct p4tc_table_defact __rcu *tbl_default_hitact;struct p4tc_table_defact __rcu *tbl_default_missact;struct p4tc_table_perm __rcu *tbl_permissions;
@@ -178,8 +181,10 @@ struct p4tc_table {u32 tbl_max_entries;u32 tbl_max_masks;u32 tbl_curr_num_masks; +refcount_t tbl_entries_ref;refcount_t tbl_ctrl_ref;u16 tbl_type; +u16 PAD0 ; };extern const struct p4tc_template_ops p4tc_table_ops;
@@ -234,6 +239,71 @@ struct p4tc_table_act {extern const struct p4tc_template_ops p4tc_act_ops; +extern const struct rhashtable_params entry_hlt_params; + +struct p4tc_table_entry ; +struct p4tc_table_entry_work { +struct work_struct work; +struct p4tc_pipeline *pipeline; +struct p4tc_table_entry *entry; +}; + +struct p4tc_table_entry_key { +u32 keysz; +/* Key start */ +u32 maskid; +unsigned char fa_key[]__aligned(8) ; +}; + +struct p4tc_table_entry_value { +u32 prio; +int num_acts; +struct tc_action **acts; +refcount_t entries_ref; +u32 permissions; +struct p4tc_table_entry_tm __rcu *tm; +struct p4tc_table_entry_work *entry_work; +}; + +struct p4tc_table_entry_mask { +struct rcu_head rcu; +u32 sz; +u32 mask_index; +refcount_t mask_ref; +u32 mask_id; +unsigned char fa_value[]__aligned(8) ; +}; + +struct p4tc_table_entry { +struct rcu_head rcu; +struct rhlist_head ht_node; +struct p4tc_table_entry_key key; +/* fallthrough: key data + value */ +}; + +#define P4TC_KEYSZ_BYTES (bits) (round_up(BITS_TO_BYTES(bits), 8)) + +static inline void *p4tc_table_entry_value (struct p4tc_table_entry *entry) +{ +return entry->key.fa_key +P4TC_KEYSZ_BYTES (entry->key.keysz); +} + +static inline struct p4tc_table_entry_work * +p4tc_table_entry_work (struct p4tc_table_entry *entry) +{ +struct p4tc_table_entry_value *value =p4tc_table_entry_value (entry); + +return value->entry_work; +} + +extern const struct nla_policy p4tc_root_policy[P4TC_ROOT_MAX +1 ]; +extern const struct nla_policy p4tc_policy[P4TC_MAX +1 ]; + +int __tcf_table_entry_del (struct p4tc_pipeline *pipeline, +struct p4tc_table *table, +struct p4tc_table_entry_key *key, +struct p4tc_table_entry_mask *mask,u32 prio); +struct p4tc_parser {char parser_name[PARSERNAMSIZ ];struct idr hdr_fields_idr;
@@ -329,6 +399,22 @@ struct p4tc_table *tcf_table_find_get(struct p4tc_pipeline *pipeline, struct netlink_ext_ack *extack);void tcf_table_put_ref (struct p4tc_table *table); +void tcf_table_entry_destroy_hash (void *ptr,void *arg); + +struct p4tc_table_entry * +tcf_table_const_entry_cu (struct net *net,struct nlattr *arg, +struct p4tc_pipeline *pipeline, +struct p4tc_table *table, +struct netlink_ext_ack *extack); +int p4tc_tbl_entry_doit (struct net *net,struct sk_buff *skb, +struct nlmsghdr *n,int cmd, +struct netlink_ext_ack *extack); +int p4tc_tbl_entry_dumpit (struct net *net,struct sk_buff *skb, +struct netlink_callback *cb, +struct nlattr *arg,char *p_name); +int p4tc_tbl_entry_fill (struct sk_buff *skb,struct p4tc_table *table, +struct p4tc_table_entry *entry,u32 tbl_id); + struct p4tc_parser *tcf_parser_create(struct p4tc_pipeline *pipeline, const char *parser_name, u32 parser_inst_id,
include/uapi/linux/p4tc.h +43 -1
62 lines not on this page · raw message
include/uapi/linux/rtnetlink.h +7 -0
@@ -201,6 +201,13 @@ enum { RTM_GETP4TEMPLATE,#define RTM_GETP4TEMPLATE RTM_GETP4TEMPLATE + RTM_P4TC_CREATE = 128, +#define RTM_P4TC_CREATE RTM_P4TC_CREATE + RTM_P4TC_DEL, +#define RTM_P4TC_DEL RTM_P4TC_DEL + RTM_P4TC_GET, +#define RTM_P4TC_GET RTM_P4TC_GET + __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
net/sched/p4tc/Makefile +2 -1
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 obj-y := p4tc_types.o p4tc_pipeline.o p4tc_tmpl_api.o \ - p4tc_parser_api.o p4tc_hdrfield.o p4tc_action.o p4tc_table.o + p4tc_parser_api.o p4tc_hdrfield.o p4tc_action.o p4tc_table.o \ + p4tc_tbl_entry.o p4tc_runtime_api.o
net/sched/p4tc/p4tc_pipeline.c +1 -0
@@ -276,6 +276,7 @@ static struct p4tc_pipeline *tcf_pipeline_create(struct net *net, pipeline->net = net;refcount_set (&pipeline->p_ctrl_ref,1 ); +refcount_set (&pipeline->p_hdrs_used,1 ); pipeline->common.ops = (struct p4tc_template_ops *)&p4tc_pipeline_ops;
net/sched/p4tc/p4tc_runtime_api.c new file +139 -0
139 lines not on this page · raw message
net/sched/p4tc/p4tc_table.c +49 -3
103 lines not on this page · raw message
net/sched/p4tc/p4tc_tbl_entry.c new file +2044 -0
2,044 lines not on this page · raw message
net/sched/p4tc/p4tc_tmpl_api.c +2 -2
@@ -27,12 +27,12 @@#include <net/netlink.h> #include <net/flow_offload.h> -static const struct nla_policy p4tc_root_policy[P4TC_ROOT_MAX +1 ] = { +const struct nla_policy p4tc_root_policy[P4TC_ROOT_MAX +1 ] = { [P4TC_ROOT ] = { .type =NLA_NESTED }, [P4TC_ROOT_PNAME ] = { .type =NLA_STRING , .len =PIPELINENAMSIZ }, }; -static const struct nla_policy p4tc_policy[P4TC_MAX +1 ] = { +const struct nla_policy p4tc_policy[P4TC_MAX +1 ] = { [P4TC_PATH ] = { .type =NLA_BINARY , .len =P4TC_PATH_MAX *sizeof (u32) }, [P4TC_PARAMS ] = { .type =NLA_NESTED },
security/selinux/nlmsgtab.c +4 -1
@@ -97,6 +97,9 @@ static const struct nlmsg_perm nlmsg_route_perms[] = { { RTM_CREATEP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, { RTM_DELP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, { RTM_GETP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_READ }, + { RTM_P4TC_CREATE, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, + { RTM_P4TC_DEL, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, + { RTM_P4TC_GET, NETLINK_ROUTE_SOCKET__NLMSG_READ }, }; static const struct nlmsg_perm nlmsg_tcpdiag_perms[] = {
@@ -179,7 +182,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)* structures at the top of this file with the new mappings * before updating the BUILD_BUG_ON() macro! */ -BUILD_BUG_ON (RTM_MAX != (RTM_CREATEP4TEMPLATE +3 )); +BUILD_BUG_ON (RTM_MAX != (RTM_P4TC_CREATE +3 )); err =nlmsg_perm (nlmsg_type, perm, nlmsg_route_perms,sizeof (nlmsg_route_perms));break ;
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 14/22 p4tc: add set of P4TC table read kfuncs
In reply to Jamal Hadi SalimWe add an initial set of kfuncs to allow interactions from eBPF programs to the P4TC domain.
- bpf_skb_p4tc_tbl_read: Used to lookup a table entry from a BPF program installed in TC. To find the table entry we take in an skb, the pipeline ID, the table ID, a key and a key size.
We use the skb to get the network namespace structure where all the pipelines are stored. After that we use the pipeline ID and the table ID, to find the table. We then use the key to search for the entry. We return an entry on success and NULL on failure.
- bpf_xdp_p4tc_tbl_read: Used to lookup a table entry from a BPF program installed in XDP. To find the table entry we take in an skb, the pipeline ID, the table ID, a key and a key size.
We use struct xdp_md to get the network namespace structure where all the pipelines are stored. After that we use the pipeline ID and the table ID, to find the table. We then use the key to search for the entry. We return an entry on success and NULL on failure.
To load the eBPF program that uses the bpf_skb_p4tc_tbl_read kfunc into TC, we issue the following command:
tc filter add dev $P0 ingress protocol any prio 1 p4 pname redirect_srcip \
action bpf obj $PROGNAME.o section p4prog/tc
To load the eBPF program that uses the bpf_xdp_p4tc_tbl_read into XDP, we first need to load it into XDP using, for example, the ip command:
ip link set $P0 xdp obj $PROGNAME.o section p4prog/xdp verbose
Then we pin it:
bpftool prog pin id $ID pin /tmp/
After that we create the P4 filter and reference the XDP program:
tc filter add dev $P0 ingress protocol any prio 1 p4 pname redirect_srcip \
action bpf obj $PROGNAME.o section p4prog/tc
Note that we also specify a "prog_cookie", which is used to verify whether the eBPF program has executed or not before we reach the P4 classifier. The eBPF program sets this cookie by using the kfunc bpf_p4tc_set_cookie.
--- include/linux/bitops.h | 1 + include/net/p4tc.h | 42 ++++++++++- net/sched/Kconfig | 1 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_action.c | 1 + net/sched/p4tc/p4tc_bpf.c | 121 ++++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 43 ++++++++++++ net/sched/p4tc/p4tc_table.c | 19 +++++ net/sched/p4tc/p4tc_tbl_entry.c | 66 ++++++++++++++++- net/sched/p4tc/p4tc_tmpl_api.c | 2 + 10 files changed, 295 insertions(+), 3 deletions(-) create mode 100644 net/sched/p4tc/p4tc_bpf.c
include/linux/bitops.h +1 -0
@@ -19,6 +19,7 @@#define BITS_TO_LONGS (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(long))#define BITS_TO_U64 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))#define BITS_TO_U32 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u32)) +#define BITS_TO_U16 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u16))#define BITS_TO_BYTES (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(char))extern unsigned int __sw_hweight8 (unsigned int w);
include/net/p4tc.h +41 -1
85 lines not on this page · raw message
net/sched/Kconfig +1 -0
@@ -678,6 +678,7 @@ config NET_EMATCH_IPT config NET_P4_TC bool "P4 TC support" + depends on DEBUG_INFO_BTF select NET_CLS_ACT help Say Y here if you want to use P4 features on top of TC.
net/sched/p4tc/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-y := p4tc_types.o p4tc_pipeline.o p4tc_tmpl_api.o \ p4tc_parser_api.o p4tc_hdrfield.o p4tc_action.o p4tc_table.o \ - p4tc_tbl_entry.o p4tc_runtime_api.o + p4tc_tbl_entry.o p4tc_runtime_api.o p4tc_bpf.o
net/sched/p4tc/p4tc_action.c +1 -0
@@ -28,6 +28,7 @@#include <net/p4tc.h> #include <net/sch_generic.h> #include <net/sock.h> +#include <net/tc_act/p4tc.h> static LIST_HEAD (dynact_list);
net/sched/p4tc/p4tc_bpf.c new file +121 -0
121 lines not on this page · raw message
net/sched/p4tc/p4tc_pipeline.c +43 -0
55 lines not on this page · raw message
net/sched/p4tc/p4tc_table.c +19 -0
@@ -244,6 +244,7 @@ static inline void p4tc_table_defact_destroy(struct p4tc_table_defact *defact) {if (defact) {p4tc_action_destroy (defact->default_acts); +kfree (defact->defact_bpf);kfree (defact); } }
@@ -341,6 +342,7 @@ static inline int _tcf_table_put(struct net *net, struct nlattr **tb,rhltable_free_and_destroy (&table->tbl_entries, tcf_table_entry_destroy_hash, table); +p4tc_tbl_cache_remove (net, table);idr_destroy (&table->tbl_masks_idr);ida_destroy (&table->tbl_prio_idr);
@@ -478,6 +480,7 @@ static int tcf_table_init_default_act(struct net *net, struct nlattr **tb, }if (tb[P4TC_TABLE_DEFAULT_ACTION ]) { +struct p4tc_table_entry_act_bpf *act_bpf;struct tc_action **default_acts;if (!p4tc_ctrl_update_ok (curr_permissions)) {
@@ -506,6 +509,15 @@ static int tcf_table_init_default_act(struct net *net, struct nlattr **tb, ret = -EINVAL ; goto default_act_free; } + act_bpf =tcf_table_entry_create_act_bpf (default_acts[0 ], + extack); +if (IS_ERR (act_bpf)) { +tcf_action_destroy (default_acts,TCA_ACT_UNBIND ); +kfree (default_acts); + ret = -EINVAL ; + goto default_act_free; + } + (*default_act)->defact_bpf = act_bpf; (*default_act)->default_acts = default_acts; }
@@ -955,6 +967,10 @@ static struct p4tc_table *tcf_table_create(struct net *net, struct nlattr **tb, goto defaultacts_destroy; } + ret =p4tc_tbl_cache_insert (net, pipeline->common.p_id, table); +if (ret <0 ) + goto entries_hashtable_destroy; + pipeline->curr_tables +=1 ; table->common.ops = (struct p4tc_template_ops *)&p4tc_table_ops;
@@ -962,6 +978,9 @@ static struct p4tc_table *tcf_table_create(struct net *net, struct nlattr **tb,return table; +entries_hashtable_destroy: +rhltable_destroy (&table->tbl_entries); + defaultacts_destroy:p4tc_table_defact_destroy (table->tbl_default_missact);p4tc_table_defact_destroy (table->tbl_default_hitact);
net/sched/p4tc/p4tc_tbl_entry.c +65 -1
101 lines not on this page · raw message
net/sched/p4tc/p4tc_tmpl_api.c +2 -0
@@ -592,6 +592,8 @@ static int __init p4tc_template_init(void) op->init (); } +register_p4tc_tbl_bpf (); +return 0 ; }
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 15/22 p4tc: add P4 classifier
In reply to Jamal Hadi SalimIntroduce P4 tc classifier. A tc filter instantiated on this classifier is used to bind a P4 pipeline to one or more netdev ports. To use P4 classifier you must specify a pipeline name that will be associated to this filter. That pipeline must have already been created via a template. For example, if we were to add a filter to ingress of network interface device eth0 and associate it to P4 pipeline simple_l3 we'd issue the following command:
tc filter add dev lo parent ffff: protocol any prio 6 p4 pname simple_l3
The filter itself has the following steps:
================================1 PARSING================================
The parser is implemented in ebpf residing either at the TC or XDP level.
Note: the different headers and their IDs are already described in the templating definition and the generated ebpf code.
The parser could be a separate progman or integrated into the ebpf program. For example, when we have a separate parser program which is loaded into XDP, we first need to load it into XDP using with the ip command:
ip link set $P0 xdp obj $PROGNAME.o section parser/xdp verbose
Then we pin it:
bpftool prog pin id $ID pin /tmp/
After that we create the P4 filter and reference the XDP program:
$TC filter add dev $P0 ingress protocol ip prio 1 p4 pname redirect_srcip \
prog xdp pinned /tmp/xdp_parser prog_cookie 22
Note that we also specify a the "prog_cookie", which is used to verify whether the eBPF program has executed or not before we reach the P4 classifier. The eBPF program sets this cookie by using the kfunc bpf_p4tc_set_cookie.
=============================FILTER ACTIONS=============================
Filter actions will be where the eBPF program that implements the remaining P4 program components, aside from the parser, will reside in the form of a TC BPF action. Of course, the user can choose to not specify a separate eBPF program as a parser and simply implement all the P4 program components in one eBPF program, which will be the filter action.
The filter will return the op code returned by this action.
--- include/uapi/linux/pkt_cls.h | 19 ++ net/sched/Kconfig | 12 + net/sched/Makefile | 1 + net/sched/cls_p4.c | 508 +++++++++++++++++++++++++++++++++++ net/sched/p4tc/Makefile | 4 +- net/sched/p4tc/trace.c | 10 + net/sched/p4tc/trace.h | 44 +++ 7 files changed, 597 insertions(+), 1 deletion(-) create mode 100644 net/sched/cls_p4.c create mode 100644 net/sched/p4tc/trace.c create mode 100644 net/sched/p4tc/trace.h
include/uapi/linux/pkt_cls.h +19 -0
@@ -723,6 +723,25 @@ enum {#define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1) +/* P4 classifier */ + +enum { +TCA_P4_UNSPEC , +TCA_P4_CLASSID , +TCA_P4_ACT , +TCA_P4_PNAME , +TCA_P4_PIPEID , +TCA_P4_PROG_FD , +TCA_P4_PROG_NAME , +TCA_P4_PROG_TYPE , +TCA_P4_PROG_COOKIE , +TCA_P4_PROG_ID , +TCA_P4_PAD , + __TCA_P4_MAX, +}; + +#define TCA_P4_MAX (__TCA_P4_MAX - 1) +/* Extended Matches */ struct tcf_ematch_tree_hdr {
net/sched/Kconfig +12 -0
@@ -566,6 +566,18 @@ config NET_CLS_MATCHALL To compile this code as a module, choose M here: the module will be called cls_matchall. +config NET_CLS_P4 + tristate "P4 classifier" + select NET_CLS + select NET_P4_TC + help + If you say Y here, you will be able to bind a P4 pipeline + program. You will need to install P4 templates scripts successfully to + use this feature. + + To compile this code as a module, choose M here: the module will + be called cls_p4. + config NET_EMATCH bool "Extended Matches" select NET_CLS
net/sched/Makefile +1 -0
@@ -73,6 +73,7 @@ obj-$(CONFIG_NET_CLS_CGROUP) += cls_cgroup.o obj-$(CONFIG_NET_CLS_BPF) += cls_bpf.o obj-$(CONFIG_NET_CLS_FLOWER) += cls_flower.o obj-$(CONFIG_NET_CLS_MATCHALL) += cls_matchall.o +obj-$(CONFIG_NET_CLS_P4) += cls_p4.o obj-$(CONFIG_NET_EMATCH) += ematch.o obj-$(CONFIG_NET_EMATCH_CMP) += em_cmp.o obj-$(CONFIG_NET_EMATCH_NBYTE) += em_nbyte.o
net/sched/cls_p4.c new file +508 -0
508 lines not on this page · raw message
net/sched/p4tc/Makefile +3 -1
@@ -1,5 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 +CFLAGS_trace.o := -I$(src) + obj-y := p4tc_types.o p4tc_pipeline.o p4tc_tmpl_api.o \ p4tc_parser_api.o p4tc_hdrfield.o p4tc_action.o p4tc_table.o \ - p4tc_tbl_entry.o p4tc_runtime_api.o p4tc_bpf.o + p4tc_tbl_entry.o p4tc_runtime_api.o p4tc_bpf.o trace.o
net/sched/p4tc/trace.c new file +10 -0
@@ -0,0 +1,10 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +#include <net/p4tc.h> + +#ifndef __CHECKER__ + +#define CREATE_TRACE_POINTS +#include "trace.h" +EXPORT_TRACEPOINT_SYMBOL_GPL (p4_classify); +#endif
net/sched/p4tc/trace.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 16/22 p4tc: Add P4 extern interface
In reply to Jamal Hadi SalimP4 externs are an abstraction in the language to call for extending language functionality. For example, the function that sends a packet to a specific port (send_to_port) in P4 PNA is an extern.
Externs can be seen as classes, which have constructors and methods. Take, for example, the Register extern definition:
extern Register<T> {
Register(@tc_numel bit<32> size);
@tc_md_read T read(@tc_key bit<32> index);
@tc_md_write void write(@tc_key bit<32> index, @tc_data T value);
}@ControlPath {
@tc_key bit<32> index;
@tc_data T value;
}
}Which can then be instantiated within a P4 program as:
Register<bit<32>>(128) reg1; Register<bit<16>>(1024) reg2;
Will be abstracted into the template by the P4C compiler for "reg1" as follows:
tc p4template create extern/register extid 10 numinstances 2 tc p4template create extern_inst/aP4Proggie/register/reg1 instid 1 \
method read method_id 1 param index type bit32 \
method write method_id 2 param index type bit32 param value type bit32 \control_path tc_key index type bit32 tc_data value type bit32 \
numelemens 128 default_value 22
=========================EXTERN RUNTIME COMMANDS=========================
Once we seal the pipeline, the index values will be assigned to the default value specified on the template as "default_value". After sealing, we can update the runtime instance element with the value 33, as is done below:
$TC p4runtime update aP4proggie/extern/register/reg1 tc_key index 2 \tc_data value 33
We can also get its value:
$TC p4runtime get aP4proggie/extern/register/reg1 tc_key index 2
Which will yield the following output:
total exts 0
extern order 1:
tc_key index id 1 type bit32 value: 1
tc_data value id 2 type bit32 value: 33
We can also dump all of the elements in this register:
$TC p4runtime get aP4proggie/extern/register/reg1
Note that the only valid runtime operations are get and update.
=========================EXTERN P4 Runtime =========================
The generated ebpf code invokes the externs in the P4TC domain using the md_read or md_write kfuncs, for example:
if the P4 program had this invocation:
tmp1 = reg1.read(index1);
Then equivalent generated ebpf code is as follows:
param.pipe_id = aP4Proggie_ID;
param.ext_id = EXTERN_REGISTER;
param.inst_id = EXTERN_REGISTER_INSTANCE_ID1;
param.index = index1;
param.param_id = EXTERN_REGISTER_PARAM_ID;bpf_p4tc_extern_md_read_skb(skb, &res, ¶m);
tmp1 = (u32 *)res.params;
--- include/net/p4tc.h | 135 ++ include/net/p4tc_ext_api.h | 98 ++ include/uapi/linux/p4tc.h | 64 + include/uapi/linux/p4tc_ext.h | 39 + net/sched/p4tc/Makefile | 3 +- net/sched/p4tc/p4tc_bpf.c | 77 +- net/sched/p4tc/p4tc_ext.c | 2103 +++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 30 +- net/sched/p4tc/p4tc_runtime_api.c | 9 + net/sched/p4tc/p4tc_table.c | 19 +- net/sched/p4tc/p4tc_tmpl_api.c | 4 + net/sched/p4tc/p4tc_tmpl_ext.c | 2429 +++++++++++++++++++++++++++++ 12 files changed, 5005 insertions(+), 5 deletions(-) create mode 100644 include/net/p4tc_ext_api.h create mode 100644 include/uapi/linux/p4tc_ext.h create mode 100644 net/sched/p4tc/p4tc_ext.c create mode 100644 net/sched/p4tc/p4tc_tmpl_ext.c
include/net/p4tc.h +135 -0
@@ -11,6 +11,7 @@#include <linux/rhashtable-types.h> #include <net/tc_act/p4tc.h> #include <net/p4tc_types.h> +#include <linux/bpf.h> #define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT#define P4TC_DEFAULT_MAX_RULES 1
@@ -19,6 +20,10 @@#define P4TC_DEFAULT_TENTRIES 256#define P4TC_MAX_TMASKS 1024#define P4TC_DEFAULT_TMASKS 8 +#define P4TC_DEFAULT_NUM_EXT_INSTS 1 +#define P4TC_MAX_NUM_EXT_INSTS (1 << 10) +#define P4TC_DEFAULT_NUM_EXT_INST_ELEMS 1 +#define P4TC_MAX_NUM_EXT_INST_ELEMS (1 << 10)#define P4TC_MAX_PERMISSION (GENMASK(P4TC_PERM_MAX_BIT, 0))
@@ -29,6 +34,8 @@#define P4TC_AID_IDX 1#define P4TC_PARSEID_IDX 1#define P4TC_HDRFIELDID_IDX 2 +#define P4TC_TMPL_EXT_IDX 1 +#define P4TC_TMPL_EXT_INST_IDX 2#define P4TC_HDRFIELD_IS_VALIDITY_BIT 0x1
@@ -80,10 +87,15 @@ struct p4tc_pipeline {struct p4tc_template_common common;struct idr p_act_idr;struct idr p_tbl_idr; +/* IDR where the externs are stored globally in the root pipeline */ +struct idr p_ext_idr; +/* IDR where the per user pipeline data related to externs is stored */ +struct idr user_ext_idr;struct rcu_head rcu;struct net *net;struct p4tc_parser *parser;u32 num_created_acts; +u32 num_created_ext_elems;refcount_t p_ctrl_ref;u16 num_tables;u16 curr_tables;
@@ -170,6 +182,27 @@ struct p4tc_table_entry_act_bpf {u8 params[P4TC_MAX_PARAM_DATA_SIZE ]; } __packed; +#define P4TC_EXT_FLAGS_UNSPEC 0x0 +#define P4TC_EXT_FLAGS_CONTROL_READ 0x1 +#define P4TC_EXT_FLAGS_CONTROL_WRITE 0x2 + +struct p4tc_ext_bpf_params { +u32 pipe_id; +u32 ext_id; +u32 inst_id; +u32 index; +u32 method_id; +u32 param_id; +u8 in_params[128 ];/* extern specific params if any */ +}; + +struct p4tc_ext_bpf_res { +u32 ext_id; +u32 index_id; +u32 verdict; +u8 out_params[128 ];/* specific values if any */ +}; +struct p4tc_table_defact {struct tc_action **default_acts;struct p4tc_table_entry_act_bpf *defact_bpf;
@@ -434,6 +467,7 @@ struct p4tc_table *tcf_table_find_byid(struct p4tc_pipeline *pipeline, const u32 tbl_id);int tcf_table_try_set_state_ready (struct p4tc_pipeline *pipeline,struct netlink_ext_ack *extack); +void tcf_table_put_mask_array (struct p4tc_pipeline *pipeline);struct p4tc_table *tcf_table_find_get (struct p4tc_pipeline *pipeline,const char *tblname,const u32 tbl_id,struct netlink_ext_ack *extack);
@@ -500,9 +534,110 @@ extern const struct p4tc_act_param_ops param_ops[P4T_MAX + 1];int generic_dump_param_value (struct sk_buff *skb,struct p4tc_type *type,struct p4tc_act_param *param); +struct p4tc_user_pipeline_extern { +char ext_name[EXTERNNAMSIZ ]; +struct idr e_inst_idr; +struct p4tc_tmpl_extern *tmpl_ext; +void (*free)(struct p4tc_user_pipeline_extern *pipe_ext, +struct idr *tmpl_exts_idr); +u32 ext_id; +refcount_t ext_ref; +refcount_t curr_insts_num; +}; + +struct p4tc_tmpl_extern { +struct p4tc_template_common common; +struct idr params_idr; +char mod_name[MODULE_NAME_LEN ]; +const struct p4tc_extern_ops *ops; +u32 ext_id; +u32 num_params; +u32 max_num_insts; +refcount_t tmpl_ref; +}; + +struct p4tc_extern_method { +char method_name[METHODNAMSIZ ]; +struct idr params_idr; +struct rcu_head rcu; +u32 method_id; +u32 num_params; +}; + +struct p4tc_extern_inst_common { +struct idr methods_idr; +struct idr control_params_idr; +struct idr control_elems_idr; +u32 num_control_params; +u32 num_elems; +u32 num_methods; +}; + +struct p4tc_ext_bpf_params_exec { +u8 *data;/* extern specific params if any */ +u32 index; +u32 method_id; +}; + +struct p4tc_extern_inst { +struct p4tc_template_common common; +struct p4tc_extern_inst_common *inst_common; +const struct p4tc_extern_ops *ops; +struct p4tc_user_pipeline_extern *pipe_ext; +u32 ext_id; +u32 ext_inst_id; +u32 max_num_elems; +refcount_t curr_num_elems; +refcount_t inst_ref; +bool is_scalar; +}; + +int p4tc_pipeline_create_extern_net (struct p4tc_tmpl_extern *tmpl_ext); +int p4tc_pipeline_del_extern_net (struct p4tc_tmpl_extern *tmpl_ext); +struct p4tc_user_pipeline_extern * +p4tc_tmpl_extern_net_find_byid (struct net *net,const u32 ext_id); +struct p4tc_extern_inst * +p4tc_ext_inst_find_bynames (struct net *net,struct p4tc_pipeline *pipeline, +const char *extname,const char *instname, +struct netlink_ext_ack *extack); +struct p4tc_extern_inst * +p4tc_ext_inst_get_byids (struct net *net,struct p4tc_pipeline **pipeline, +const u32 pipe_id, +struct p4tc_user_pipeline_extern **pipe_ext, +const u32 ext_id,const u32 inst_id); +struct p4tc_extern_ops *p4tc_extern_ops_get (char *kind); +void p4tc_extern_ops_put (const struct p4tc_extern_ops *ops); + +int __bpf_p4tc_extern_md_write (struct net *net, +struct p4tc_ext_bpf_params *params); +int __bpf_p4tc_extern_md_read (struct net *net, +struct p4tc_ext_bpf_res *res, +struct p4tc_ext_bpf_params *params); + +int p4tc_register_extern (struct p4tc_extern_ops *ext); +int p4tc_unregister_extern (struct p4tc_extern_ops *ext); + +extern const struct p4tc_template_ops p4tc_tmpl_ext_ops; +extern const struct p4tc_template_ops p4tc_tmpl_ext_inst_ops; + +struct p4tc_extern_param { +char name[EXTPARAMNAMSIZ ]; +struct rcu_head rcu; +void *value; +struct p4tc_type *type; +struct p4tc_type_mask_shift *mask_shift; +u32 id; +u32 index; +u8 flags; +}; +#define to_pipeline (t) ((struct p4tc_pipeline *)t)#define to_hdrfield (t) ((struct p4tc_hdrfield *)t)#define to_act (t) ((struct p4tc_act *)t)#define to_table (t) ((struct p4tc_table *)t) +#define to_extern (t) ((struct p4tc_tmpl_extern *)t) +#define to_extern_inst (t) ((struct p4tc_extern_inst *)t) + +#endif
include/net/p4tc_ext_api.h new file +98 -0
98 lines not on this page · raw message
include/uapi/linux/p4tc.h +64 -0
100 lines not on this page · raw message
include/uapi/linux/p4tc_ext.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_P4TC_EXT_H +#define __LINUX_P4TC_EXT_H + +#include <linux/types.h> +#include <linux/pkt_sched.h> + +#define P4TC_EXT_NAMSIZ 64 + +/* Extern attributes */ +enum { +P4TC_EXT_UNSPEC , +P4TC_EXT_INST_NAME , +P4TC_EXT_KIND , +P4TC_EXT_PARAMS , +P4TC_EXT_KEY , +P4TC_EXT_FCNT , +P4TC_EXT_PAD , +P4TC_EXT_FLAGS , + __P4TC_EXT_MAX +}; + +#define P4TC_EXT_ID_DYN 0x01 +#define P4TC_EXT_ID_MAX 1023 + +/* See other P4TC_EXT_FLAGS_ * flags in include/net/act_api.h. */ +#define P4TC_EXT_FLAGS_NO_PERCPU_STATS (1 << 0)/* Don't use percpu allocator +* for externs stats. +*/ +#define P4TC_EXT_FLAGS_SKIP_HW (1 << 1)/* don't offload action to HW */ +#define P4TC_EXT_FLAGS_SKIP_SW (1 << 2)/* don't use action in SW */ + +#define P4TC_EXT_FLAG_LARGE_DUMP_ON (1 << 0) + +#define P4TC_EXT_MAX __P4TC_EXT_MAX +#define P4TC_EXT_REPLACE 1 +#define P4TC_EXT_NOREPLACE 0 + +#endif
net/sched/p4tc/Makefile +2 -1
@@ -4,4 +4,5 @@ CFLAGS_trace.o := -I$(src) obj-y := p4tc_types.o p4tc_pipeline.o p4tc_tmpl_api.o \ p4tc_parser_api.o p4tc_hdrfield.o p4tc_action.o p4tc_table.o \ - p4tc_tbl_entry.o p4tc_runtime_api.o p4tc_bpf.o trace.o + p4tc_tbl_entry.o p4tc_runtime_api.o p4tc_bpf.o trace.o p4tc_ext.o \ + p4tc_tmpl_ext.o
net/sched/p4tc/p4tc_bpf.c +76 -1
106 lines not on this page · raw message
net/sched/p4tc/p4tc_ext.c new file +2103 -0
2,103 lines not on this page · raw message
net/sched/p4tc/p4tc_pipeline.c +29 -1
@@ -27,6 +27,7 @@#include <net/netlink.h> #include <net/flow_offload.h> #include <net/p4tc_types.h> +#include <net/p4tc_ext_api.h> static unsigned int pipeline_net_id;static struct p4tc_pipeline *root_pipeline;
@@ -99,6 +100,7 @@ static void __net_exit pipeline_exit_net(struct net *net)__tcf_pipeline_put (pipeline, &pipeline->common,NULL ); }idr_destroy (&pipe_net->pipeline_idr); +rtnl_unlock (); }
@@ -119,6 +121,7 @@ static void tcf_pipeline_destroy(struct p4tc_pipeline *pipeline) {idr_destroy (&pipeline->p_act_idr);idr_destroy (&pipeline->p_tbl_idr); +idr_destroy (&pipeline->user_ext_idr);kfree (pipeline); }
@@ -141,7 +144,8 @@ static void tcf_pipeline_teardown(struct p4tc_pipeline *pipeline,struct net *net = pipeline->net;struct p4tc_pipeline_net *pipe_net =net_generic (net, pipeline_net_id);struct net *pipeline_net =maybe_get_net (net); -unsigned long iter_act_id, tmp; +struct p4tc_user_pipeline_extern *pipe_ext; +unsigned long iter_act_id, ext_id, tmp;struct p4tc_table *table;struct p4tc_act *act;unsigned long tbl_id;
@@ -152,6 +156,17 @@ static void tcf_pipeline_teardown(struct p4tc_pipeline *pipeline,idr_for_each_entry_ul (&pipeline->p_act_idr, act, tmp, iter_act_id) act->common.ops->put (pipeline, &act->common, extack); +idr_for_each_entry_ul (&pipeline->user_ext_idr, pipe_ext, tmp, ext_id) { +unsigned long tmp_in, inst_id; +struct p4tc_extern_inst *inst; + +idr_for_each_entry_ul (&pipe_ext->e_inst_idr, inst, tmp_in, inst_id) { + inst->common.ops->put (pipeline, &inst->common, extack); + } + + pipe_ext->free (pipe_ext, &pipeline->user_ext_idr); + } +if (pipeline->parser)tcf_parser_del (net, pipeline, pipeline->parser, extack);
@@ -213,8 +228,16 @@ static inline int pipeline_try_set_state_ready(struct p4tc_pipeline *pipeline,if (ret <0 )return ret; + ret =p4tc_extern_inst_init_elems (&pipeline->user_ext_idr); +if (ret <0 ) + goto unset_table_state_ready; + pipeline->p_state =P4TC_STATE_READY ;return true; + +unset_table_state_ready: +tcf_table_put_mask_array (pipeline); +return ret; }struct p4tc_pipeline *tcf_pipeline_find_byid (struct net *net,const u32 pipeid)
@@ -311,6 +334,9 @@ static struct p4tc_pipeline *tcf_pipeline_create(struct net *net,idr_init (&pipeline->p_tbl_idr); pipeline->curr_tables =0 ; +idr_init (&pipeline->p_tbl_idr); + +idr_init (&pipeline->user_ext_idr); pipeline->num_created_acts =0 ;
@@ -636,6 +662,8 @@ static void __tcf_pipeline_init(void)strscpy (root_pipeline->common.name,"kernel" ,PIPELINENAMSIZ ); +idr_init (&root_pipeline->p_ext_idr); + root_pipeline->common.ops = (struct p4tc_template_ops *)&p4tc_pipeline_ops;
net/sched/p4tc/p4tc_runtime_api.c +9 -0
@@ -27,11 +27,13 @@#include <net/p4tc.h> #include <net/netlink.h> #include <net/flow_offload.h> +#include <net/p4tc_ext_api.h> static int tc_ctl_p4_root (struct sk_buff *skb,struct nlmsghdr *n,int cmd,struct netlink_ext_ack *extack) {struct p4tcmsg *t = (struct p4tcmsg *)nlmsg_data (n); +int ret;switch (t->obj) {case P4TC_OBJ_RUNTIME_TABLE : {
@@ -45,6 +47,11 @@ static int tc_ctl_p4_root(struct sk_buff *skb, struct nlmsghdr *n, int cmd,return p4tc_tbl_entry_doit (net, skb, n, cmd, extack); } +case P4TC_OBJ_RUNTIME_EXTERN : +rtnl_lock (); + ret =p4tc_ctl_extern (skb, n, cmd, extack); +rtnl_unlock (); +return ret;default :NL_SET_ERR_MSG (extack,"Unknown P4 runtime object type" );return -EOPNOTSUPP ;
@@ -116,6 +123,8 @@ static int tc_ctl_p4_dump(struct sk_buff *skb, struct netlink_callback *cb)return p4tc_tbl_entry_dumpit (net, skb, cb, tb[P4TC_ROOT ], p_name); } +case P4TC_OBJ_RUNTIME_EXTERN : +return p4tc_ctl_extern_dump (skb, cb, tb, p_name);default : NL_SET_ERR_MSG_FMT(cb->extack, "Unknown p4 runtime object type %u\n",
net/sched/p4tc/p4tc_table.c +17 -2
@@ -263,6 +263,22 @@ static void tcf_table_acts_list_destroy(struct list_head *acts_list) } } +static void __tcf_table_put_mask_array (struct p4tc_table *table) +{ +kfree (table->tbl_masks_array); +bitmap_free (table->tbl_free_masks_bitmap); +} + +void tcf_table_put_mask_array (struct p4tc_pipeline *pipeline) +{ +struct p4tc_table *table; +unsigned long tmp, id; + +idr_for_each_entry_ul (&pipeline->p_tbl_idr, table, tmp, id) { +__tcf_table_put_mask_array (table); + } +} + static inline int _tcf_table_put(struct net *net, struct nlattr **tb, struct p4tc_pipeline *pipeline, struct p4tc_table *table,
@@ -353,8 +369,7 @@ static inline int _tcf_table_put(struct net *net, struct nlattr **tb,idr_remove (&pipeline->p_tbl_idr, table->tbl_id); pipeline->curr_tables -=1 ; -kfree (table->tbl_masks_array); -bitmap_free (table->tbl_free_masks_bitmap); +__tcf_table_put_mask_array (table);kfree (table);
net/sched/p4tc/p4tc_tmpl_api.c +4 -0
@@ -45,6 +45,8 @@ static bool obj_is_valid(u32 obj)case P4TC_OBJ_HDR_FIELD :case P4TC_OBJ_ACT :case P4TC_OBJ_TABLE : +case P4TC_OBJ_EXT : +case P4TC_OBJ_EXT_INST :return true;default :return false;
@@ -56,6 +58,8 @@ static const struct p4tc_template_ops *p4tc_ops[P4TC_OBJ_MAX] = { [P4TC_OBJ_HDR_FIELD] = &p4tc_hdrfield_ops, [P4TC_OBJ_ACT] = &p4tc_act_ops, [P4TC_OBJ_TABLE] = &p4tc_table_ops, + [P4TC_OBJ_EXT] = &p4tc_tmpl_ext_ops, + [P4TC_OBJ_EXT_INST] = &p4tc_tmpl_ext_inst_ops, }; int tcf_p4_tmpl_generic_dump(struct sk_buff *skb, struct p4tc_dump_ctx *ctx,
net/sched/p4tc/p4tc_tmpl_ext.c new file +2429 -0
205 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Jamal Hadi Salim
maintainerRFC PATCH v4 17/22 selftests: tc-testing: add JSON introspection file directory for P4TC
In reply to Jamal Hadi SalimAdd JSON introspection directory where we'll store the introspection files necessary when adding table entries in P4TC.
Also add a sample JSON introspection file (ptables.json) which will be needed by the P4TC table entries test.
--- .../introspection-examples/example_pipe.json | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tools/testing/selftests/tc-testing/introspection-examples/example_pipe.json
tools/testing/selftests/tc-testing/introspection-examples/example_pipe.json new file +92 -0
@@ -0,0 +1,92 @@ +{ + "schema_version" : "1.0.0", + "pipeline_name" : "example_pipe", + "id" : 22, + "tables" : [ + { + "name" : "cb/tname", + "id" : 1, + "tentries" : 2048, + "nummask" : 8, + "keysize" : 64, + "keyid" : 1, + "keyfields" : [ + { + "id" : 1, + "name" : "srcAddr", + "type" : "ipv4", + "match_type" : "exact", + "bitwidth" : 32 + }, + { + "id" : 2, + "name" : "dstAddr", + "type" : "ipv4", + "match_type" : "exact", + "bitwidth" : 32 + } + ], + "actions" : [ + ] + }, + { + "name" : "cb/tname2", + "id" : 2, + "tentries" : 2048, + "nummask" : 8, + "keysize" : 32, + "keyid" : 1, + "keyfields" : [ + { + "id" : 1, + "name" : "srcPort", + "type" : "be16", + "match_type" : "exact", + "bitwidth" : 16 + }, + { + "id" : 2, + "name" : "dstPort", + "type" : "be16", + "match_type" : "exact", + "bitwidth" : 16 + } + ], + "actions" : [ + ] + }, + { + "name" : "cb/tname3", + "id" : 3, + "tentries" : 2048, + "nummask" : 8, + "keysize" : 104, + "keyid" : 1, + "keyfields" : [ + { + "id" : 1, + "name" : "randomKey1", + "type" : "bit8", + "match_type" : "exact", + "bitwidth" : 8 + }, + { + "id" : 2, + "name" : "randomKey2", + "type" : "bit32", + "match_type" : "exact", + "bitwidth" : 32 + }, + { + "id" : 3, + "name" : "randomKey3", + "type" : "bit64", + "match_type" : "exact", + "bitwidth" : 64 + } + ], + "actions" : [ + ] + } + ] +}
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 18/22 selftests: tc-testing: add P4TC pipeline control path tdc tests
In reply to Jamal Hadi SalimIntroduce first tdc tests for P4TC pipeline, which are focused on the control path. We test pipeline create, update, delete and dump.
Here is a basic description of what we test for each operation:
Create:
- Create valid pipeline
- Try to create pipeline without specifying mandatory arguments
- Create pipeline without specifying optional arguments and check optional values after creation
- Try to create pipeline passing invalid values for numttypes
- Try to create pipeline passing invalid values for maxrules
- Try to create pipeline with same name twice
- Try to create pipeline with same id twice
- Create pipeline with pipeline id == INX_MAX (2147483647) and check for overflow warning when traversing pipeline IDR
- Create pipeline with name length > PIPELINENAMSIZ
Update:
- Update pipeline with valid values for numttypes, maxrules, preactions and postactions
- Try to update pipeline with invalid values for maxrules and numttypes
- Try to seal pipeline which is not ready
- Check action bind and ref values after pipeline preaction update
- Check action bind and ref values after pipeline postaction update
Delete:
- Delete pipeline by name
- Delete pipeline by id
- Delete inexistent pipeline by name
- Delete inexistent pipeline by id
- Try to flush pipelines
- Check action bind and ref values after pipeline deletion
Dump:
- Dump pipeline IDR
- Dump pipeline IDR when amount of pipelines > P4TC_MAXMSG_COUNT (16)
--- .../tc-testing/tc-tests/p4tc/pipeline.json | 1448 +++++++++++++++++ 1 file changed, 1448 insertions(+) create mode 100644 tools/testing/selftests/tc-testing/tc-tests/p4tc/pipeline.json
tools/testing/selftests/tc-testing/tc-tests/p4tc/pipeline.json new file +1448 -0
@@ -0,0 +1,1448 @@ +[ + { + "id": "2c2f", + "name": "Create valid pipeline", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 2, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "8a18", + "name": "Try to create pipeline without name", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ pipeid 22 numtables 2", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchPattern": "Error: Pipeline name not found.*", + "teardown": [ + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "b103", + "name": "Create pipeline without numtables", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables pipeid 22", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 0, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "ceff", + "name": "Create pipeline with numtables = 0", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables pipeid 22 numtables 0", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 0, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "7a5a", + "name": "Try to create pipeline with numtables > 32", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables pipeid 22 numtables 33", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchPattern": "Error: Pipeline name not found.*", + "teardown": [ + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "5dd2", + "name": "Create pipeline with numtables = 32", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables pipeid 1 numtables 32", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 1, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 32, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "571e", + "name": "Create pipeline with numtables = 256", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables pipeid 1 numtables 2", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 1, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 2, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "f6f8", + "name": "Try to create pipeline with same name twice", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables pipeid 22 numtables 4", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 0, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "8e88", + "name": "Update numtables in existing pipeline", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update pipeline/ptables numtables 4", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 1, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 4, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "9e27", + "name": "Update numtables with 0", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update pipeline/ pipeid 1 numtables 0", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 1, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 0, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "01a3", + "name": "Try to update numtables with 33", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update pipeline/ pipeid 1 numtables 33", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 1, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 0, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "db08", + "name": "Try to seal pipeline which is not ready", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 1 numtables 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update pipeline/ pipeid 1 state ready", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 1, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 1, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "26", + "name": "Delete pipeline by name", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del pipeline/ptables", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchPattern": "Error: Pipeline name not found.*", + "teardown": [ + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "8855", + "name": "Delete pipeline by id", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 42", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del pipeline/ pipeid 42", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ pipeid 42", + "matchCount": "1", + "matchPattern": "Error: Unable to find pipeline by id.*", + "teardown": [ + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "757e", + "name": "Try to delete inexistent pipeline by name", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [], + "cmdUnderTest": "$TC p4template del pipeline/ptables", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchPattern": "Error: Pipeline name not found.*", + "teardown": [] + }, + { + "id": "4bff", + "name": "Try to delete inexistent pipeline by id", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [], + "cmdUnderTest": "$TC p4template del pipeline/ pipeid 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ pipeid 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find pipeline by id.*", + "teardown": [] + }, + { + "id": "15b3", + "name": "Try to flush pipelines", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 42", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del pipeline/", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 42, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 0, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "6051", + "name": "Dump pipeline list", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC actions add action pass index 3", + 0 + ], + [ + "$TC actions add action pass index 4", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 42", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables2 pipeid 22", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/", + "matchCount": "1", + "matchJSON": [ + { + "obj": "pipeline" + }, + { + "templates": [ + { + "pname": "ptables2" + }, + { + "pname": "ptables" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC p4template del pipeline/ptables2", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "0944", + "name": "Check action bind and ref after pipeline deletion", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 42", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del pipeline/ pipeid 42", + "expExitCode": "0", + "verifyCmd": "$TC -j actions ls action gact", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 2 + }, + { + "actions": [ + { + "kind": "gact", + "index": 1, + "ref": 1, + "bind": 0 + }, + { + "kind": "gact", + "index": 2, + "ref": 1, + "bind": 0 + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "6c15", + "name": "Try to create pipeline with same pipeid twice", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables2 pipeid 22 numtables 4", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "pipeline" + }, + { + "templates": [ + { + "pnumtables": 0, + "pstate": "not ready" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "e32a", + "name": "Dump pipeline when amount of pipelines > P4TC_MSGBATCH_SIZE", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ], + [ + "$TC actions add action pass index 3", + 0 + ], + [ + "$TC actions add action pass index 4", + 0 + ], + [ + "$TC actions add action pass index 5", + 0 + ], + [ + "$TC actions add action pass index 6", + 0 + ], + [ + "$TC actions add action pass index 7", + 0 + ], + [ + "$TC actions add action pass index 8", + 0 + ], + [ + "$TC p4template create pipeline/ptables", + 0 + ], + [ + "$TC p4template create pipeline/ptables2", + 0 + ], + [ + "$TC p4template create pipeline/ptables3", + 0 + ], + [ + "$TC p4template create pipeline/ptables4", + 0 + ], + [ + "$TC p4template create pipeline/ptables5", + 0 + ], + [ + "$TC p4template create pipeline/ptables6", + 0 + ], + [ + "$TC p4template create pipeline/ptables7", + 0 + ], + [ + "$TC p4template create pipeline/ptables8", + 0 + ], + [ + "$TC p4template create pipeline/ptables9", + 0 + ], + [ + "$TC p4template create pipeline/ptables10", + 0 + ], + [ + "$TC p4template create pipeline/ptables11", + 0 + ], + [ + "$TC p4template create pipeline/ptables12", + 0 + ], + [ + "$TC p4template create pipeline/ptables13", + 0 + ], + [ + "$TC p4template create pipeline/ptables14", + 0 + ], + [ + "$TC p4template create pipeline/ptables15", + 0 + ], + [ + "$TC p4template create pipeline/ptables16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables17 pipeid 2147483647", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/", + "matchCount": "1", + "matchJSON": [ + { + "obj": "pipeline" + }, + { + "templates": [ + { + "pname": "ptables" + }, + { + "pname": "ptables2" + }, + { + "pname": "ptables3" + }, + { + "pname": "ptables4" + }, + { + "pname": "ptables5" + }, + { + "pname": "ptables6" + }, + { + "pname": "ptables7" + }, + { + "pname": "ptables8" + }, + { + "pname": "ptables9" + }, + { + "pname": "ptables10" + }, + { + "pname": "ptables11" + }, + { + "pname": "ptables12" + }, + { + "pname": "ptables13" + }, + { + "pname": "ptables14" + }, + { + "pname": "ptables15" + }, + { + "pname": "ptables16" + } + ] + }, + { + "obj": "pipeline" + }, + { + "templates": [ + { + "pname": "ptables17" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC p4template del pipeline/ptables2", + 0 + ], + [ + "$TC p4template del pipeline/ptables3", + 0 + ], + [ + "$TC p4template del pipeline/ptables4", + 0 + ], + [ + "$TC p4template del pipeline/ptables5", + 0 + ], + [ + "$TC p4template del pipeline/ptables6", + 0 + ], + [ + "$TC p4template del pipeline/ptables7", + 0 + ], + [ + "$TC p4template del pipeline/ptables8", + 0 + ], + [ + "$TC p4template del pipeline/ptables9", + 0 + ], + [ + "$TC p4template del pipeline/ptables10", + 0 + ], + [ + "$TC p4template del pipeline/ptables11", + 0 + ], + [ + "$TC p4template del pipeline/ptables12", + 0 + ], + [ + "$TC p4template del pipeline/ptables13", + 0 + ], + [ + "$TC p4template del pipeline/ptables14", + 0 + ], + [ + "$TC p4template del pipeline/ptables15", + 0 + ], + [ + "$TC p4template del pipeline/ptables16", + 0 + ], + [ + "$TC p4template del pipeline/ptables17", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "398c", + "name": "Test overflow in pipeid when we search for inexistent pipeline and we have pipeid 2147483647 in idr", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/ptables pipeid 2147483647", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get pipeline/ptables2", + "matchCount": "1", + "matchPattern": "Error: Pipeline name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "cd4e", + "name": "Try to create pipeline without name or id", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ptables", + "matchCount": "1", + "matchPattern": "Error: Pipeline name not found.*", + "teardown": [ + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "6356", + "name": "Create pipeline with name length > PIPELINENAMSIZ", + "category": [ + "p4tc", + "template", + "pipeline" + ], + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0 + ], + [ + "$TC actions add action drop index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create pipeline/7eozFYyaqVCD7H0xS3M5sMnluUqPgZewfSLnYPf4s3k0lbx8lKoR32zSqiGsh84qJ32vnLPdl7f2XcUh5yIdEP7uJy2C3iPtyU7159s9CMB0EtTAlWTVz4U1jkQ5h2advwp3KCVsZ1jlGgStoJL2op5ZxoThTSUQLR61a5RNDovoSFcq86Brh6oW9DSmTbN6SYygbG3JLnEHzRC5hh0jGmJKHq5ivBK9Y9FlNZQXC9wVwX4qTFAd8ITUTj2Au2Jg1 pipeid 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get pipeline/ pipeid 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find pipeline by id.*", + "teardown": [ + [ + "$TC actions flush action gact", + 0 + ] + ] + } +]
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH v4 19/22 selftests: tc-testing: add P4TC action templates tdc tests
In reply to Jamal Hadi SalimIntroduce tdc tests for P4TC table types, which are focused on the control path. We test table type create, update, delete, flush and dump.
Here is a basic description of what we test for each operation:
Create:
- Create valid action template
- Create action templates with all possible param types
- Try to create action template with param of invalid type
- Create valid action template and instantiate action of new kind
- Try to create action template with name > IFNAMSIZ
- Try to create action template with param type > ACTPARAMNAMSIZ
- Create action template with more than one param
- Create action template with no params
- Try to create action template with same ID twice
- Try to create action template with same name twice
- Try to create action template with two params and one of unknown type
- Create valid action template, instantiate it and update the instance
- Create valid action template, create two instances of it and dump
- Create action template, add instance and bind action to filter
- Create action template, add instance, bind action to filter and send packet
Update:
- Update action template with actions
- Update action template with all param types
- Try to add new param during update
- Update action template param by id
- Try to update inexistent action template by id
- Try to update inexistent action template by name
Delete:
- Delete action template by name
- Delete action template by id
- Try to delete inexistent action template by name
- Try to delete inexistent action template by id
- Try to delete action template without supplying pipeline name or id
- Flush action templates
- Try to flush action templates without supplying pipeline name or id
Dump:
- Dump action template IDR using pipeline name to find pipeline
- Dump action template IDR using pipeline id to find pipeline
- Try to dump action templates IDR without specifying pipeline name or id
- Dump action templates IDR which has more than P4TC_MAXMSG_COUNT (16) elements
--- .../tc-tests/p4tc/action_templates.json | 3929 +++++++++++++++++ 1 file changed, 3929 insertions(+) create mode 100644 tools/testing/selftests/tc-testing/tc-tests/p4tc/action_templates.json
tools/testing/selftests/tc-testing/tc-tests/p4tc/action_templates.json new file +3929 -0
@@ -0,0 +1,3929 @@ +[ + { + "id": "c494", + "name": "Create valid action template with param type bit32", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit32", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "4964", + "name": "Create valid action template with param type bit8", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type bit8", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit8", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "2ed6", + "name": "Create valid action template with param type bit16", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type bit16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit16", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "ec54", + "name": "Create valid action template with param type bit64", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type bit64", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit64", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "6c74", + "name": "Create valid action template with param type mac", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type macaddr", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "macaddr", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "bf9c", + "name": "Create valid action template with param type ipv4", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type ipv4", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "ipv4", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "03f3", + "name": "Create valid action template with param type bit32 and create an instance of action", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit32", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ] + ], + "cmdUnderTest": "$TC actions add action ptables/test param param1 type bit32 id 1 4294967295", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "bit32", + "value": 4294967295, + "id": 1 + } + ], + "index": 1, + "ref": 1, + "bind": 0, + "not_in_hw": true + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "80f5", + "name": "Create valid action template with param type bit32 and try to add it to table_acts_list of another pipeline", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit32", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ], + [ + "$TC p4template create pipeline/ptables2 pipeid 23 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables2/cb/tname tblid 22 keysz 16 table_acts act name ptables/test", + "expExitCode": "255", + "verifyCmd": "$TC p4template get table/ptables2/cb/tname", + "matchCount": "1", + "matchPattern": "Error: Table name not found", + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template del pipeline/ptables2", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "782e", + "name": "Create valid action template with param type bit8 and create an instance of action", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit8", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ] + ], + "cmdUnderTest": "$TC actions add action ptables/test param param1 type bit8 id 1 255", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "bit8", + "value": 255, + "id": 1 + } + ], + "index": 1, + "ref": 1, + "bind": 0, + "not_in_hw": true + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "e250", + "name": "Create valid action template with param type bit16 and create an instance of action", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit16", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ] + ], + "cmdUnderTest": "$TC actions add action ptables/test param param1 type bit16 id 1 65535", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "bit16", + "value": 65535, + "id": 1 + } + ], + "index": 1, + "ref": 1, + "bind": 0, + "not_in_hw": true + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "99b7", + "name": "Create valid action template with param type bit64 and create an instance of action", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit64", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ] + ], + "cmdUnderTest": "$TC actions add action ptables/test param param1 type bit64 id 1 4294967295", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "bit64", + "value": 4294967295, + "id": 1 + } + ], + "index": 1, + "ref": 1, + "bind": 0, + "not_in_hw": true + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "367c", + "name": "Create valid action template with param type mac and create an instance of action", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type macaddr", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ] + ], + "cmdUnderTest": "$TC actions add action ptables/test param param1 type macaddr id 1 AA:BB:CC:DD:EE:FF", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "macaddr", + "value": "aa:bb:cc:dd:ee:ff", + "id": 1 + } + ], + "index": 1, + "ref": 1, + "bind": 0, + "not_in_hw": true + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "315c", + "name": "Create valid action template with param type ipv4 and create an instance of action", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type ipv4", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ] + ], + "cmdUnderTest": "$TC actions add action ptables/test param param1 type ipv4 id 1 10.10.10.0/24", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "ipv4", + "value": "10.10.10.0/24", + "id": 1 + } + ], + "index": 1, + "ref": 1, + "bind": 0, + "not_in_hw": true + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "62b1", + "name": "Create valid action template with two params", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type bit32 param param2 type bit16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit32", + "id": 1 + }, + { + "name": "param2", + "type": "bit16", + "id": 2 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "73a5", + "name": "Create valid action template with no params", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "c403", + "name": "Try to create action template with param of unknown type", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type notvalid", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchPattern": "Error: Action name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "d21f", + "name": "Try to create action template with two params and one of unknown type", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type bit32 param param2 type notvalid", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchPattern": "Error: Action name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "164e", + "name": "Try to create action template with same name twice", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit32", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test param param1 type bit64", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit32", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "de27", + "name": "Try to create action template with same id twice", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test2 actid 1 param param1 type bit64", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit32", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "b711", + "name": "Try to create action template with name > IFNAMSIZ", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/CMPCQGOzcLG8HILTQxsQYKfDg4zQQdtmNfosyAhQxhqDTC8cg10QediAAzIMvel2Y actid 1 param param1 type bit32", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find action by id.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "17f3", + "name": "Try to create action template with param name > ACTPARAMNAMSIZ", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test actid 1 param oDXNP48egpqbhrFfRZxEMcJu4p2932zuTVO7ab81kXaYsLfJJWx1qF4QbohzvlLfBgS7j2Xo5wR3jQ9yuRARyFMNvGilXoufpvvwr8Z5bBaD8H80Lav8LleO5Qss5CjmE8l34Vomvn7LEEfeRTAzOCbPew7L2DuoQz2JQtyGFsZ8dEORnjFaZBZ6CGDPh68strQiFwEHUs6lUpbIxhxB6xarZGpwktZOyascnZLbc901mqrx96gnx939LpDkaNLij type bit32", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find action by id.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "5bbe", + "name": "Update action template param type to bit16", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/test param param1 type bit16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit16", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "e596", + "name": "Update action template param type to bit8", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/test param param1 type bit8", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit8", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "b74b", + "name": "Update action template param type to bit64", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/test param param1 type bit64", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit64", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "5d74", + "name": "Update action template param type to ipv4", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/test param param1 type ipv4", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "ipv4", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "3b81", + "name": "Update action template param type to mac", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/test param param1 type macaddr", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "macaddr", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "cc31", + "name": "Try to add new param during update", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/test param param1 type bit16 param param2 type bit8", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit32", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "03b7", + "name": "Update action template param by id", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32 id 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/test param param1 type bit16 id 1", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchJSON": [ + { + "obj": "action template", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "aname": "ptables/test", + "actid": 1, + "params": [ + { + "name": "param1", + "type": "bit16", + "id": 1 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "c695", + "name": "Try to update inexistent action template by id", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/ actid 1 param param1 type bit16 id 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/ actid 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find action by id.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "86ef", + "name": "Try to update inexistent action template by name", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update action/ptables/test param param1 type bit16 id 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get action/ptables/test", + "matchCount": "1", + "matchPattern": "Error: Action name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "636f", + "name": "Create valid action template with param type bit32, create an instance of action and update it", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit32", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ], + [ + "$TC actions add action ptables/test param param1 type bit32 id 1 4294967295 index 1", + 0 + ] + ], + "cmdUnderTest": "$TC actions replace action ptables/test param param1 type bit32 id 1 22 index 1", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "bit32", + "value": 22, + "id": 1 + } + ], + "index": 1, + "ref": 1, + "bind": 0, + "not_in_hw": true + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "f13d", + "name": "Create valid action template with param type bit32, create an instance of action and delete it", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit32", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ], + [ + "$TC actions add action ptables/test param param1 type bit32 id 1 4294967295 index 1", + 0 + ] + ], + "cmdUnderTest": "$TC actions del action ptables/test index 1", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchPattern": "Error: TC action with specified index not found.*", + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template update action/ptables/test state inactive", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "11f8", + "name": "Create valid action template with two params, create an instance of action and delete it", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit32 param param2 type bit32", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ], + [ + "$TC actions add action ptables/test param param1 type bit32 4294967295 param param2 type bit32 22 index 1", + 0 + ] + ], + "cmdUnderTest": "$TC actions del action ptables/test index 1", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchPattern": "Error: TC action with specified index not found.*", + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template update action/ptables/test state inactive", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "cccb", + "name": "Create valid action template with no params, create an instance of action and delete it", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ], + [ + "$TC actions add action ptables/test index 1", + 0 + ] + ], + "cmdUnderTest": "$TC actions del action ptables/test index 1", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/test index 1", + "matchCount": "1", + "matchPattern": "Error: TC action with specified index not found.*", + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template update action/ptables/test state inactive", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "8523", + "name": "Create valid action template with param type bit32, create two instances of action and dump", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit32", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ], + [ + "$TC actions add action ptables/test param param1 type bit32 id 1 4294967295 index 1", + 0 + ] + ], + "cmdUnderTest": "$TC actions add action ptables/test param param1 type bit32 id 1 42 index 2", + "expExitCode": "0", + "verifyCmd": "$TC -j actions ls action ptables/test", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 2 + }, + { + "actions": [ + { + "order": 0, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "bit32", + "value": 4294967295, + "id": 1 + } + ], + "index": 1, + "ref": 1, + "bind": 0, + "not_in_hw": true + }, + { + "order": 1, + "kind": "ptables/test", + "params": [ + { + "name": "param1", + "type": "bit32", + "value": 42, + "id": 1 + } + ], + "index": 2, + "ref": 1, + "bind": 0, + "not_in_hw": true + } + ] + } + ], + "teardown": [ + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template update action/ptables/test state inactive", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "cc14", + "name": "Create action template, add instance and try to bind action to filter", + "category": [ + "p4tc", + "template" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32 id 1", + 0 + ], + [ + "$TC p4template update action/ptables/test state active", + 0 + ], + [ + "$TC actions add action ptables/test param param1 type bit32 id 1 4294967295", + 0 + ], + [ + "$TC qdisc add dev $DEV1 ingress", + 0 + ] + ], + "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 prio 65535 protocol ip matchall action ptables/test index 1", + "expExitCode": "2", + "verifyCmd": "$TC -j filter get dev $DEV1 parent ffff: handle 1 prio 65535 protocol ip matchall", + "matchCount": "1", + "matchPattern": "Error: Cannot find specified filter chain.*", + "teardown": [ + [ + "$TC qdisc del dev $DEV1 ingress; sleep 1", + 0 + ], + [ + "$TC actions flush action ptables/test", + 0 + ], + [ + "$TC p4template update action/ptables/test state inactive", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "e3e4", + "name": "Dump action templates using pname to find pipeline", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ], + [ + "$TC p4template create action/ptables/test2 actid 2 param param1 type bit64", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test3 param param1 type bit64", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ptables/", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "action template" + }, + { + "templates": [ + { + "aname": "ptables/test" + }, + { + "aname": "ptables/test2" + }, + { + "aname": "ptables/test3" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "25bc", + "name": "Dump action templates using pipeid to find pipeline", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ], + [ + "$TC p4template create action/ptables/test2 actid 2 param param1 type bit64", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test3 param param1 type bit64", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/ pipeid 22", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "action template" + }, + { + "templates": [ + { + "aname": "ptables/test" + }, + { + "aname": "ptables/test2" + }, + { + "aname": "ptables/test3" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "f1e1", + "name": "Dump action templates without specifying pipeid or pname", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test actid 1 param param1 type bit32", + 0 + ], + [ + "$TC p4template create action/ptables/test2 actid 2 param param1 type bit64", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create action/ptables/test3 param param1 type bit64", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get action/", + "matchCount": "1", + "matchPattern": "Error: Must specify pipeline name or id.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "dc67", + "name": "Dump action templates IDR with more than P4TC_MAXMSG_COUNT elements", + "category": [ + "p4tc", + "template" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create action/ptables/test param param1 type bit32", + 0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Jamal Hadi Salim
maintainerRFC PATCH v4 20/22 selftests: tc-testing: add P4TC table control path tdc tests
In reply to Jamal Hadi SalimIntroduce tdc tests for P4TC table, which are focused on the control path. We test table create, update, delete, flush and dump.
Here is a basic description of what we test for each operation:
Create:
- Create valid table
- Try to create table without specifying mandatory arguments
- Create table without specifying optional arguments and check optional values after creation
- Try to create table passing invalid arguments
- Try to create table with same name twice
- Try to create table with same id twice
- Create a table with table id == INX_MAX (2147483647) and check for overflow warning when traversing table IDR
- Try to create table with name length > TTYPENAMSIZ
- Try to create table without specifying pipeline name or id
- Create valid table with more than one key
- Try to create table adding more than P4TC_MAXPARSE_KEYS keys
- Create table and update pipeline state
- Create table, update pipeline state and try to update pipeline after pipeline is sealed
- Create table, update pipeline state and try to update table type after pipeline is sealed
- Create table with keys with more than one action
Update:
- Update table with valid argument values
- Try to update table with invalid argument values
- Try to update table without specifying table name or id
- Try to update table without specifying pipeline name or id
- Try to update table with invalid values
- Check action bind and ref values after table's key's action
- Check action bind and ref values after table's postaction update
- Update table and add new key without specifying id
- Try to update table adding more P4TC_MAXPARSE_KEYS keys
- Update table key with more than one action
- Try to create more table then numtclass in pipeline
Delete:
- Delete table by name
- Delete table by id
- Delete nonexistent table by name
- Delete nonexistent table by id
- Try to delete table without supplying pipeline name or id
- Flush table
- Try to flush table without supplying pipeline name or id
- Check action bind and ref values after table deletion
Dump:
- Dump table IDR using pipeline name to find pipeline
- Dump table IDR using pipeline id to find pipeline
- Try to dump table IDR without specifying pipeline name or id
- Dump table IDR which has more than P4TC_MAXMSG_COUNT (16) elements
--- .../tc-testing/tc-tests/p4tc/table.json | 5597 +++++++++++++++++ 1 file changed, 5597 insertions(+) create mode 100644 tools/testing/selftests/tc-testing/tc-tests/p4tc/table.json
tools/testing/selftests/tc-testing/tc-tests/p4tc/table.json new file +5597 -0
@@ -0,0 +1,5597 @@ +[ + { + "id": "60b7", + "name": "Create valid table", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 1, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "4765", + "name": "Try to create table without name", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/ keysz 16", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Error: Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "3d3c", + "name": "Try to create table without keysz", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Error: Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "b48a", + "name": "Try to create table with keysz zero", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 0", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "cc89", + "name": "Try to create table with keysz > P4TC_MAX_KEYSZ", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 513", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "efba", + "name": "Try to create table with tentries > P4TC_MAX_TENTRIES", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 16 tentries 16777217", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "a24a", + "name": "Create table with tentries = P4TC_MAX_TENTRIES", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16 tentries 16777216", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 16777216, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "67b7", + "name": "Try to create table with tentries zero", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 16 tentries 0", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "e8e8", + "name": "Try to create table with nummasks > P4TC_MAX_TMASKS", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 16 tmasks 1025", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "6b5b", + "name": "Create table wth nummasks = P4TC_MAX_TMASKS", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16 nummasks 128", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 128 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "615c", + "name": "Try to create table with nummasks zero", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 16 nummasks 0", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "ef97", + "name": "Create table with specific tt_id", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname tblid 42 keysz 16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 42, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "7a0f", + "name": "Try to create table same name twice", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 16", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 1, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "bd8d", + "name": "Try to create table same id twice", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname2 tblid 22 keysz 16", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/ tblid 22", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "eeaf", + "name": "Try to create table without supplying pipeline name or id", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ tblid 1 keysz 16", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "f35d", + "name": "Create table without supplying keys", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname keysz 16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 1, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "b3c9", + "name": "Try to create table with name size > TCLASSNAMSIZ", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/7eozFYyaqVCD7H0xS3M5sMnluUqPgZewfSLnYPf4s3k0lbx8lKoR32zSqiGsh84qJ32vnLPdl7f2XcUh5yIdEP7uJy2C3iPtyU7159s9CMB0EtTAlWTVz4U1jkQ5h2advwp3KCVsZ1jlGgStoJL2op5ZxoThTSUQLR61a5RNDovoSFcq86Brh6oW9DSmTbN6SYygbG3JLnEHzRC5hh0jGmJKHq5ivBK9Y9FlNZQXC9wVwX4qTFAd8ITUTj2Au2Jg1 keysz 16", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "40b0", + "name": "Create table with tblid of 4 bytes", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action gact pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action gact pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname tblid 2147483647 keysz 16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/ tblid 2147483647", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "table" + }, + { + "templates": [ + { + "tblid": 2147483647, + "tname": "cb/tname" + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "eea7", + "name": "Update table's key size specifying table name", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/cb/tname keysz 32", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 32, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "5d07", + "name": "Update table's key size specifying table id", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ pipeid 22 tblid 22 keysz 32", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 32, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "46f5", + "name": "Try to update table's key size with zero", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 keysz 0", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "8306", + "name": "Try to update table's key size with > P4TC_MAX_KEYSZ", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 keysz 513", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "0d12", + "name": "Update table's with key size = P4TC_MAX_KEYSZ", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 keysz 512", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 512, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "67c0", + "name": "Try to update table tentries with zero", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 tentries 0", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "dfd1", + "name": "Try to update table wth tentries > P4TC_MAX_TENTRIES", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 tentries 16777217", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "36e3", + "name": "Update table with tentries = P4TC_MAX_TENTRIES", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 tentries 16777216", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 16777216, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "5c80", + "name": "Try to update table masks with zero", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 nummasks 0", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "011b", + "name": "Try to update table with nummasks > P4TC_MAX_TMASKS", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 nummasks 1025", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "102b", + "name": "Update table with nummasks = P4TC_MAX_TMASKS", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template update table/ptables/ tblid 22 nummasks 128", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 128 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "a7f3", + "name": "Delete table by name", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del table/ptables/cb/tname", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Error: Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "9524", + "name": "Delete table by id", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del table/ptables/ tblid 22", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/ tblid 22", + "matchCount": "1", + "matchPattern": "Error: Unable to find table by id.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "c41b", + "name": "Try to delete inexistent table by name", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del table/ptables/cb/tname2", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "faca", + "name": "Try to delete inexistent table by id", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del table/ptables/ tblid 44", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/ tblid 22", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "6da7", + "name": "Try to delete table without supplying pipeline name or id", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del table/ tblid 22", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/ tblid 22", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "a844", + "name": "Flush table", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname2 tblid 42 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del table/ptables/", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Error: Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "7f88", + "name": "Try to flush table without supplying pipeline name or id", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname tblid 22 keysz 16", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname2 tblid 42 keysz 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4template del table/", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 16, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "778c", + "name": "Create table with key size > P4TC_MAX_KEYSZ", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname tblid 22 keysz 513", + "expExitCode": "255", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchPattern": "Error: Table name not found.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "64ed", + "name": "Create table with key size = P4TC_MAX_KEYSZ", + "category": [ + "p4tc", + "template", + "table" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action drop index 2", + 0, + 1, + 255 + ], + [ + "$TC actions add action ok index 3", + 0, + 1, + 255 + ], + [ + "$TC actions add action reclassify index 4", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4template create table/ptables/cb/tname tblid 22 keysz 512", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "obj": "table", + "pname": "ptables", + "pipeid": 22 + }, + { + "templates": [ + { + "tblid": 22, + "tname": "cb/tname", + "keysz": 512, + "max_entries": 256, + "masks": 8 + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "508b", + "name": "Create table and update pipeline state", + "category": [ + "p4tc", + "template",
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Jamal Hadi Salim
maintainerRFC PATCH v4 21/22 selftests: tc-testing: add P4TC table entries control path tdc tests
In reply to Jamal Hadi SalimIntroduce tdc tests for P4TC table entries, which are focused on the control path. We test table instance create, update, delete, flush and dump.
Create:
- Create valid table entry with all possible key types
- Try to create table entry without specifying mandatory arguments
- Try to create table entry passing invalid arguments
- Try to create table entry with same key and prio twice
- Try to create table entry without sealing the pipeline
- Try to create table entry with action of unknown kind
- Try to exceed max table entries count
Update:
- Try to update table entry with action of inexistent kind
- Try to update table entry with action of unknown kind
- Update table entry with new action
- Create table entry with action and then update table entry with another action
- Create table entry with action, update table entry with another action and check action's refs and binds
- Create table entry without action and then update table entry with another action
- Try to update inexistent table entry
Delete:
- Delete table entry
- Try to delete inexistent table entry
- Try to delete table entry without specifying mandatory arguments
- Delete table entry specifying IDs for the pipeline and its components (table class and table instance)
- Delete table entry specifying names for the pipeline and its components (table class and table instance)
- Delete table entry with action and check action's refs and binds
Flush:
- Flush table entries
- Flush table entries specifying IDS for pipeline and its components (table class and table instance)
- Flush table entries specifying names for pipeline and its components (table class and table instance)
- Try to flush table entries without specifying mandatory arguments
Dump:
- Dump table entries
- Dump table entries specifying IDS for pipeline and its components (table class and table instance)
- Dump table entries specifying names for pipeline and its components (table class and table instance)
- Try to dump table entries without specifying mandatory arguments
- Dump table instance with zero table entries
- Dump table instance with more than P4TC_MAXMSG_COUNT entries
--- .../tc-tests/p4tc/table_entries.json | 4269 +++++++++++++++++ 1 file changed, 4269 insertions(+) create mode 100644 tools/testing/selftests/tc-testing/tc-tests/p4tc/table_entries.json
tools/testing/selftests/tc-testing/tc-tests/p4tc/table_entries.json new file +4269 -0
@@ -0,0 +1,4269 @@ +[ + { + "id": "4bfd", + "name": "Create valid table entry with args bit16", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname2 tblid 2 keysz 32 ", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 2, + "prio": 16, + "key": [ + { + "keyfield": "srcPort", + "id": 1, + "width": 16, + "type": "bit16", + "match_type": "exact", + "fieldval": 80 + }, + { + "keyfield": "dstPort", + "id": 2, + "width": 16, + "type": "bit16", + "match_type": "exact", + "fieldval": 443 + } + ], + "create_whodunnit": "tc", + "permissions": "-RUD--R--X" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "d574", + "name": "Create valid table entry with args and check entries count", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname2 tblid 2 keysz 32 ", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16", + "expExitCode": "0", + "verifyCmd": "$TC -j p4template get table/ptables/cb/tname2", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22, + "obj": "table" + }, + { + "templates": [ + { + "tname": "cb/tname2", + "keysz": 32, + "max_entries": 256, + "masks": 8, + "entries": 1 + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "6c21", + "name": "Create valid table entry with args ipv4", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64 ", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 17", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 17", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 1, + "prio": 17, + "key": [ + { + "keyfield": "srcAddr", + "id": 1, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "10.10.10.0/24" + }, + { + "keyfield": "dstAddr", + "id": 2, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "192.168.0.0/16" + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 17", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "a486", + "name": "Create valid table entry with args bit8, bit32, bit64", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 type exact", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 3, + "prio": 1, + "key": [ + { + "keyfield": "randomKey1", + "id": 1, + "width": 8, + "type": "bit8", + "match_type": "exact", + "fieldval": 255 + }, + { + "keyfield": "randomKey2", + "id": 2, + "width": 32, + "type": "bit32", + "match_type": "exact", + "fieldval": 92 + }, + { + "keyfield": "randomKey3", + "id": 3, + "width": 64, + "type": "bit64", + "match_type": "exact", + "fieldval": 127 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "13d9", + "name": "Try to create table entry without table name or id", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 ", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/ randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "0b7c", + "name": "Try to create table entry without specifying any keys", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 ", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname3 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "c2e7", + "name": "Create table entry without specifying priority", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 3, + "prio": 1, + "key": [ + { + "keyfield": "randomKey1", + "id": 1, + "width": 8, + "type": "bit8", + "match_type": "exact", + "fieldval": 255 + }, + { + "keyfield": "randomKey2", + "id": 2, + "width": 32, + "type": "bit32", + "match_type": "exact", + "fieldval": 92 + }, + { + "keyfield": "randomKey3", + "id": 3, + "width": 64, + "type": "bit64", + "match_type": "exact", + "fieldval": 127 + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC -j p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "dff1", + "name": "Try to get table entry without specifying priority", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create action/ptables/cb/send_nh actid 1 param smac type macaddr id 1 param dmac type macaddr id 2", + 0 + ], + [ + "$TC p4template update action/ptables/cb/send_nh state active", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 table_acts act name ptables/cb/send_nh flags tableonly", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1 action send_nh param smac b8:ce:f6:4b:68:35 param dmac ac:1f:6b:e4:ff:93", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 2 action send_nh index 1", + "expExitCode": "0", + "verifyCmd": "$TC p4 get ptables/table/cb/tname3/ randomKey1 255 randomKey2 92 randomKey3 127", + "matchCount": "1", + "matchPattern": "Error: Must specify table entry priority.*", + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 2", + 0 + ], + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "9a1e", + "name": "Try to create more table entries than allowed", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64 tentries 1", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "2095", + "name": "Try to create more table entries than allowed after delete", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64 tentries 3", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 17", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 18", + 0 + ], + [ + "$TC p4 del ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 18", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 18", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "4e6a", + "name": "Try to create more table entries than allowed after flush", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64 tentries 1", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ], + [ + "$TC p4 del ptables/table/cb/tname", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "65a2", + "name": "Create two entries with same key and different priorities and check first one", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.1.0/16 prio 15", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 1, + "prio": 16, + "key": [ + { + "keyfield": "srcAddr", + "id": 1, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "10.10.10.0/24" + }, + { + "keyfield": "dstAddr", + "id": 2, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "192.168.0.0/16" + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "a49c", + "name": "Create two entries with same key and different priorities and check second one", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.169.0.0/16 prio 15", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.169.0.0/16 prio 15", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 1, + "prio": 15, + "key": [ + { + "keyfield": "srcAddr", + "id": 1, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "10.10.10.0/24" + }, + { + "keyfield": "dstAddr", + "id": 2, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "192.169.0.0/16" + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "2314", + "name": "Try to create same entry twice", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.1.0/16 prio 16", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 1, + "prio": 16, + "key": [ + { + "keyfield": "srcAddr", + "id": 1, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "10.10.10.0/24" + }, + { + "keyfield": "dstAddr", + "id": 2, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "192.168.0.0/16" + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "7d41", + "name": "Try to create table entry in unsealed pipeline", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "d732", + "name": "Try to create table entry with action of inexistent kind", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname2 tblid 2 keysz 32", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16 action noexist index 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "525a", + "name": "Try to update table entry with action of inexistent kind", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname2 tblid 2 keysz 32", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4 update ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16 action noexist index 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname2 srcPort 80 dstPort 443 prio 16", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 2, + "prio": 16, + "key": [ + { + "keyfield": "srcPort", + "id": 1, + "width": 16, + "type": "bit16", + "match_type": "exact", + "fieldval": 80 + }, + { + "keyfield": "dstPort", + "id": 2, + "width": 16, + "type": "bit16", + "match_type": "exact", + "fieldval": 443 + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname2", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "ee04", + "name": "Update table entry and add action", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create action/ptables/cb/send_nh actid 1 param smac type macaddr id 1 param dmac type macaddr id 2", + 0 + ], + [ + "$TC p4template update action/ptables/cb/send_nh state active", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 table_acts act name ptables/cb/send_nh flags tableonly", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 update ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1 action send_nh param smac b8:ce:f6:4b:68:35 param dmac ac:1f:6b:e4:ff:93 index 1", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 3, + "prio": 1, + "key": [ + { + "keyfield": "randomKey1", + "id": 1, + "width": 8, + "type": "bit8", + "match_type": "exact", + "fieldval": 255 + }, + { + "keyfield": "randomKey2", + "id": 2, + "width": 32, + "type": "bit32", + "match_type": "exact", + "fieldval": 92 + }, + { + "keyfield": "randomKey3", + "id": 3, + "width": 64, + "type": "bit64", + "match_type": "exact", + "fieldval": 127 + } + ], + "create_whodunnit": "tc", + "update_whodunnit": "tc", + "actions": { + "actions": [ + { + "order": 1, + "kind": "ptables/cb/send_nh", + "index": 1, + "ref": 1, + "bind": 1, + "params": [ + { + "name": "smac", + "id": 1, + "type": "macaddr", + "value": "ac:1f:6b:e4:ff:93" + }, + { + "name": "dmac", + "id": 2, + "type": "macaddr", + "value": "b8:ce:f6:4b:68:35" + } + ] + } + ] + } + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "10b5", + "name": "Update table entry and replace action", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create action/ptables/cb/send_nh actid 1 param smac type macaddr id 1 param dmac type macaddr id 2", + 0 + ], + [ + "$TC p4template update action/ptables/cb/send_nh state active", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 table_acts act name ptables/cb/send_nh flags tableonly", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1 action send_nh param smac b8:ce:f6:4b:68:34 param dmac ac:1f:6b:e4:ff:92", + 0 + ] + ], + "cmdUnderTest": "$TC p4 update ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1 action send_nh param smac b8:ce:f6:4b:68:35 param dmac ac:1f:6b:e4:ff:93", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 3, + "prio": 1, + "key": [ + { + "keyfield": "randomKey1", + "id": 1, + "width": 8, + "type": "bit8", + "match_type": "exact", + "fieldval": 255 + }, + { + "keyfield": "randomKey2", + "id": 2, + "width": 32, + "type": "bit32", + "match_type": "exact", + "fieldval": 92 + }, + { + "keyfield": "randomKey3", + "id": 3, + "width": 64, + "type": "bit64", + "match_type": "exact", + "fieldval": 127 + } + ], + "create_whodunnit": "tc", + "update_whodunnit": "tc", + "actions": { + "actions": [ + { + "order": 1, + "kind": "ptables/cb/send_nh", + "index": 2, + "ref": 1, + "bind": 1, + "params": [ + { + "name": "smac", + "id": 1, + "type": "macaddr", + "value": "ac:1f:6b:e4:ff:93" + }, + { + "name": "dmac", + "id": 2, + "type": "macaddr", + "value": "b8:ce:f6:4b:68:35" + } + ] + } + ] + } + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "2d50", + "name": "Update table entry, replace action and check for action refs and binds", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create action/ptables/cb/send_nh actid 1 param smac type macaddr id 1 param dmac type macaddr id 2", + 0 + ], + [ + "$TC p4template update action/ptables/cb/send_nh state active", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 table_acts act name ptables/cb/send_nh flags tableonly", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC actions add action ptables/cb/send_nh param smac b8:ce:f6:4b:68:35 param dmac ac:1f:6b:e4:ff:93 index 1", + 0 + ], + [ + "$TC p4runtime create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1 action send_nh index 1", + 0 + ], + [ + "$TC actions add action ptables/cb/send_nh param smac b8:ce:f6:4b:68:34 param dmac ac:1f:6b:e4:ff:92 index 2", + 0 + ] + ], + "cmdUnderTest": "$TC p4runtime update ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1 action send_nh index 2; sleep 1;", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/cb/send_nh index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/cb/send_nh", + "index": 1, + "ref": 1, + "bind": 0, + "params": [ + { + "name": "smac", + "id": 1, + "type": "macaddr", + "value": "ac:1f:6b:e4:ff:93" + }, + { + "name": "dmac", + "id": 2, + "type": "macaddr", + "value": "b8:ce:f6:4b:68:35" + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "99ef", + "name": "Try to update inexistent table entry", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 update ptables/table/cb/tname3 randomKey1 255 randomKey2 1 randomKey3 127 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 3, + "prio": 1, + "key": [ + { + "keyfield": "randomKey1", + "id": 1, + "width": 8, + "type": "bit8", + "match_type": "exact", + "fieldval": 255 + }, + { + "keyfield": "randomKey2", + "id": 2, + "width": 32, + "type": "bit32", + "match_type": "exact", + "fieldval": 92 + }, + { + "keyfield": "randomKey3", + "id": 3, + "width": 64, + "type": "bit64", + "match_type": "exact", + "fieldval": 127 + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "8868", + "name": "Try to update table entry without specifying priority", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create action/ptables/cb/send_nh actid 1 param smac type macaddr id 1 param dmac type macaddr id 2", + 0 + ], + [ + "$TC p4template update action/ptables/cb/send_nh state active", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 table_acts act name ptables/cb/send_nh flags tableonly", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 update ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 action send_nh", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 3, + "prio": 1, + "key": [ + { + "keyfield": "randomKey1", + "id": 1, + "width": 8, + "type": "bit8", + "match_type": "exact", + "fieldval": 255 + }, + { + "keyfield": "randomKey2", + "id": 2, + "width": 32, + "type": "bit32", + "match_type": "exact", + "fieldval": 92 + }, + { + "keyfield": "randomKey3", + "id": 3, + "width": 64, + "type": "bit64", + "match_type": "exact", + "fieldval": 127 + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "339a", + "name": "Try to update table entry without specifying table name or id", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 update ptables/table/ randomKey1 255 randomKey2 92 randomKey3 127 prio 1 action gact index 2", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 3, + "prio": 1, + "key": [ + { + "keyfield": "randomKey1", + "id": 1, + "width": 8, + "type": "bit8", + "match_type": "exact", + "fieldval": 255 + }, + { + "keyfield": "randomKey2", + "id": 2, + "width": 32, + "type": "bit32", + "match_type": "exact", + "fieldval": 92 + }, + { + "keyfield": "randomKey3", + "id": 3, + "width": 64, + "type": "bit64", + "match_type": "exact", + "fieldval": 127 + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "3962", + "name": "Delete table entry", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "fcc7", + "name": "Try to delete table entry without specyfing tblid or table name", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 del ptables/table/ randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3/ randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 3, + "prio": 1, + "key": [ + { + "keyfield": "randomKey1", + "id": 1, + "width": 8, + "type": "bit8", + "match_type": "exact", + "fieldval": 255 + }, + { + "keyfield": "randomKey2", + "id": 2, + "width": 32, + "type": "bit32", + "match_type": "exact", + "fieldval": 92 + }, + { + "keyfield": "randomKey3", + "id": 3, + "width": 64, + "type": "bit64", + "match_type": "exact", + "fieldval": 127 + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "e79d", + "name": "Try to delete table entry without specifying prio", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 2", + "expExitCode": "0", + "verifyCmd": "$TC p4 del ptables/table/cb/tname3/ randomKey1 255 randomKey2 92 randomKey3 127", + "matchCount": "1", + "matchPattern": "Error: Must specify table entry priority.*", + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 2", + 0 + ], + [ + "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "c5be", + "name": "Delete table entry with action and check action's refs and binds", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create action/ptables/cb/send_nh actid 1 param smac type macaddr id 1 param dmac type macaddr id 2", + 0 + ], + [ + "$TC p4template update action/ptables/cb/send_nh state active", + 0 + ], + [ + "$TC actions add action ptables/cb/send_nh param smac b8:ce:f6:4b:68:35 param dmac ac:1f:6b:e4:ff:93 index 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104 table_acts act name ptables/cb/send_nh flags tableonly", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1 action send_nh index 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1; sleep 1", + "expExitCode": "0", + "verifyCmd": "$TC -j actions get action ptables/cb/send_nh index 1", + "matchCount": "1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "ptables/cb/send_nh", + "index": 1, + "ref": 1, + "bind": 0, + "params": [ + { + "name": "smac", + "id": 1, + "type": "macaddr", + "value": "ac:1f:6b:e4:ff:93" + }, + { + "name": "dmac", + "id": 2, + "type": "macaddr", + "value": "b8:ce:f6:4b:68:35" + } + ] + } + ] + } + ], + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "4ac6", + "name": "Try to delete inexistent table entry", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname3 tblid 3 keysz 104", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 del ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname3 randomKey1 255 randomKey2 92 randomKey3 127 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "24a1", + "name": "Flush table entries", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 del ptables/table/cb/tname", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "9770", + "name": "Flush table entries using table name", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 del ptables/table/cb/tname", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "matchCount": "1", + "matchPattern": "Error: Unable to find entry.*", + "teardown": [ + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "c5b9", + "name": "Flush table entries without specifying table name or id", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + 0 + ] + ], + "cmdUnderTest": "$TC p4 del ptables/table/", + "expExitCode": "255", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 1, + "prio": 1, + "key": [ + { + "keyfield": "srcAddr", + "id": 1, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "10.10.10.0/24" + }, + { + "keyfield": "dstAddr", + "id": 2, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "192.168.56.0/24" + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "03f7", + "name": "Dump table entries", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/cb/tname", + "matchCount": "1", + "matchJSON": [ + { + "pname": "ptables", + "pipeid": 22 + }, + { + "entries": [ + { + "tblid": 1, + "prio": 1, + "key": [ + { + "keyfield": "srcAddr", + "id": 1, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "10.10.10.0/24" + }, + { + "keyfield": "dstAddr", + "id": 2, + "width": 32, + "type": "ipv4", + "match_type": "exact", + "fieldval": "192.168.56.0/24" + } + ], + "create_whodunnit": "tc" + } + ] + } + ], + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + }, + { + "id": "0caa", + "name": "Try to dump table entries without specifying table name or id", + "category": [ + "p4tc", + "entries" + ], + "setup": [ + [ + "$TC p4template del pipeline/ptables", + 0, + 1, + 255 + ], + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 1", + 0, + 1, + 255 + ], + [ + "$TC actions add action pass index 2", + 0, + 1, + 255 + ], + [ + "$TC p4template create pipeline/ptables pipeid 22 numtables 1", + 0 + ], + [ + "$TC p4template create table/ptables/cb/tname type lpm tblid 1 keysz 64", + 0 + ], + [ + "$TC p4template update pipeline/ptables state ready", + 0 + ], + [ + "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.0.0/16 prio 16", + 0 + ] + ], + "cmdUnderTest": "$TC p4 create ptables/table/cb/tname srcAddr 10.10.10.0/24 dstAddr 192.168.56.0/24 prio 1", + "expExitCode": "0", + "verifyCmd": "$TC -j p4 get ptables/table/", + "matchCount": "1", + "matchPattern": "Error: Must specify table name or id.*", + "teardown": [ + [ + "$TC p4 del ptables/table/cb/tname", + 0 + ], + [ + "$TC p4template del pipeline/ptables", + 0 + ], + [ + "$TC actions flush action gact", + 0 + ] + ] + },
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Jamal Hadi Salim
maintainerRFC PATCH v4 22/22 MAINTAINERS: add p4tc entry
In reply to Jamal Hadi SalimP4TC is currently maintained by Mojatatu Networks.
--- MAINTAINERS | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
MAINTAINERS +14 -0
@@ -15782,6 +15782,20 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git F: Documentation/filesystems/overlayfs.rst F: fs/overlayfs/ +P4TC +M: Victor Nogueira <[email protected]> +M: Jamal Hadi Salim <[email protected]> +M: Pedro Tammela <[email protected]> +L: [email protected] +S: Supported +F: include/net/p4tc.h +F: include/net/p4tc_types.h +F: include/net/tc_act/p4tc.h +F: include/uapi/linux/p4tc.h +F: net/sched/cls_p4.c +F: net/sched/p4tc/ +F: tools/testing/selftests/tc-testing/tc-tests/p4tc/ + P54 WIRELESS DRIVER M: Christian Lamparter <[email protected]> L: [email protected]
Signature · 1 line
2.34.1