From 375c3c20ac882bcd9134b507d014133e03259c55 Mon Sep 17 00:00:00 2001 From: Mouse Date: Thu, 15 Feb 2024 12:35:56 +0000 Subject: [PATCH 1/2] Try to handle pna_main_input_metadata_t fields better --- backends/tc/ebpfCodeGen.cpp | 39 +++++++++++++++++-------------------- backends/tc/ebpfCodeGen.h | 1 + 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/backends/tc/ebpfCodeGen.cpp b/backends/tc/ebpfCodeGen.cpp index bad1d02229..caf624e1e5 100644 --- a/backends/tc/ebpfCodeGen.cpp +++ b/backends/tc/ebpfCodeGen.cpp @@ -1323,6 +1323,23 @@ ControlBodyTranslatorPNA::ControlBodyTranslatorPNA(const EBPF::EBPFControlPSA *c EBPF::ControlBodyTranslator(control), tcIR(tcIR) {} +bool ControlBodyTranslatorPNA::preorder(const IR::Member *m) { + if ((m->expr != nullptr) && (m->expr->type != nullptr)) { + if (auto st = m->expr->type->to()) { + if (st->name == "pna_main_input_metadata_t") { + if (m->member.name == "input_port") { + builder->append("skb->ifindex"); + return false; + } else { + ::error(ErrorType::ERR_UNSUPPORTED_ON_TARGET, + "%1%: this metadata field is not supported", m); + } + } + } + } + return CodeGenInspector::preorder(m); +} + ControlBodyTranslatorPNA::ControlBodyTranslatorPNA(const EBPF::EBPFControlPSA *control, const ConvertToBackendIR *tcIR, const EBPF::EBPFTablePSA *table) @@ -1335,17 +1352,6 @@ cstring ControlBodyTranslatorPNA::getParamName(const IR::PathExpression *expr) { return expr->path->name.name; } -bool ControlBodyTranslatorPNA::checkPnaPortMem(const IR::Member *m) { - if (m->expr != nullptr && m->expr->type != nullptr) { - if (auto str_type = m->expr->type->to()) { - if (str_type->name == "pna_main_input_metadata_t" && m->member.name == "input_port") { - return true; - } - } - } - return false; -} - void ControlBodyTranslatorPNA::processFunction(const P4::ExternFunction *function) { if (function->expr->method->toString() == "send_to_port" || function->expr->method->toString() == "drop_packet") { @@ -1360,12 +1366,7 @@ void ControlBodyTranslatorPNA::processFunction(const P4::ExternFunction *functio for (auto a : *function->expr->arguments) { if (!first) builder->append(", "); first = false; - if (a->expression->is() && - checkPnaPortMem(a->expression->to())) { - builder->append("skb->ifindex"); - } else { - visit(a); - } + visit(a); } builder->append(")"); return; @@ -1482,16 +1483,12 @@ void ControlBodyTranslatorPNA::processApply(const P4::ApplyMethod *method) { } } - auto mem = c->expression->to(); builder->emitIndent(); if (memcpy) { builder->appendFormat("__builtin_memcpy(&(%s.%s[0]), &(", keyname.c_str(), fieldName.c_str()); table->codeGen->visit(c->expression); builder->appendFormat("[0]), %d)", scalar->bytesRequired()); - } else if (mem && checkPnaPortMem(mem)) { - builder->appendFormat("%s.%s = ", keyname.c_str(), fieldName.c_str()); - builder->append("skb->ifindex"); } else { builder->appendFormat("%s.%s = ", keyname.c_str(), fieldName.c_str()); if (isLPMKeyBigEndian) builder->appendFormat("%s(", swap.c_str()); diff --git a/backends/tc/ebpfCodeGen.h b/backends/tc/ebpfCodeGen.h index f7fce9e12f..b5a9cc95a4 100644 --- a/backends/tc/ebpfCodeGen.h +++ b/backends/tc/ebpfCodeGen.h @@ -319,6 +319,7 @@ class ControlBodyTranslatorPNA : public EBPF::ControlBodyTranslator { virtual cstring getParamName(const IR::PathExpression *); bool preorder(const IR::AssignmentStatement *a) override; void processMethod(const P4::ExternMethod *method) override; + bool preorder(const IR::Member *) override; }; // Similar to class ActionTranslationVisitorPSA in backends/ebpf/psa/ebpfPsaControl.h From 2e7a19c2a76856e3d8fcde15907859f73451c188 Mon Sep 17 00:00:00 2001 From: Mouse Date: Thu, 15 Feb 2024 12:41:23 +0000 Subject: [PATCH 2/2] Add support for parser errors in tc backend --- backends/tc/ebpfCodeGen.cpp | 21 +++++++++++++++++++ backends/tc/ebpfCodeGen.h | 1 + backends/tc/runtime/pna.h | 1 + .../calculator_control_blocks.c | 10 ++++----- .../p4tc_samples_outputs/calculator_parser.c | 1 + .../p4tc_samples_outputs/checksum_parser.c | 1 + .../const_entries_range_mask_parser.c | 1 + .../default_action_example_parser.c | 1 + .../default_hit_const_example_parser.c | 1 + .../drop_packet_example_parser.c | 1 + .../global_action_example_01_parser.c | 1 + .../global_action_example_02_parser.c | 1 + testdata/p4tc_samples_outputs/hash1_parser.c | 1 + testdata/p4tc_samples_outputs/ipip_parser.c | 1 + .../p4tc_samples_outputs/matchtype_parser.c | 1 + .../mix_matchtype_example_parser.c | 1 + .../multiple_tables_example_01_parser.c | 1 + ...ultiple_tables_example_02_control_blocks.c | 6 +++--- .../multiple_tables_example_02_parser.c | 1 + .../name_annotation_example_parser.c | 1 + .../no_table_example_control_blocks.c | 2 +- .../no_table_example_parser.c | 1 + .../noaction_example_01_parser.c | 1 + .../noaction_example_02_parser.c | 1 + ...ummask_annotation_example_control_blocks.c | 2 +- .../nummask_annotation_example_parser.c | 1 + .../send_to_port_example_parser.c | 1 + .../set_entry_timer_example_parser.c | 1 + .../simple_exact_example_parser.c | 1 + .../simple_lpm_example_parser.c | 1 + .../simple_ternary_example_parser.c | 1 + .../size_param_example_parser.c | 1 + .../tc_type_annotation_example_parser.c | 1 + .../test_ipv6_example_parser.c | 1 + 34 files changed, 60 insertions(+), 10 deletions(-) diff --git a/backends/tc/ebpfCodeGen.cpp b/backends/tc/ebpfCodeGen.cpp index caf624e1e5..d2feac2f60 100644 --- a/backends/tc/ebpfCodeGen.cpp +++ b/backends/tc/ebpfCodeGen.cpp @@ -514,6 +514,24 @@ void EBPFPnaParser::emit(EBPF::CodeBuilder *builder) { builder->blockEnd(true); } +void EBPFPnaParser::emitRejectState(EBPF::CodeBuilder *builder) { + builder->emitIndent(); + builder->appendFormat("if (%s == 0) ", program->errorVar.c_str()); + builder->blockStart(); + builder->target->emitTraceMessage( + builder, "Parser: Explicit transition to reject state, dropping packet.."); + builder->emitIndent(); + builder->appendFormat("return %s", builder->target->abortReturnCode().c_str()); + builder->endOfStatement(true); + builder->blockEnd(true); + builder->emitIndent(); + builder->appendFormat("compiler_meta__->parser_error = %s", program->errorVar.c_str()); + builder->endOfStatement(true); + builder->emitIndent(); + builder->appendFormat("goto %s", IR::ParserState::accept.c_str()); + builder->endOfStatement(true); +} + // This code is similar to compileExtractField function in PsaStateTranslationVisitor. // Handled TC "macaddr" annotation. void PnaStateTranslationVisitor::compileExtractField(const IR::Expression *expr, @@ -1330,6 +1348,9 @@ bool ControlBodyTranslatorPNA::preorder(const IR::Member *m) { if (m->member.name == "input_port") { builder->append("skb->ifindex"); return false; + } else if (m->member.name == "parser_error") { + builder->append("compiler_meta__->parser_error"); + return false; } else { ::error(ErrorType::ERR_UNSUPPORTED_ON_TARGET, "%1%: this metadata field is not supported", m); diff --git a/backends/tc/ebpfCodeGen.h b/backends/tc/ebpfCodeGen.h index b5a9cc95a4..3b48a52704 100644 --- a/backends/tc/ebpfCodeGen.h +++ b/backends/tc/ebpfCodeGen.h @@ -130,6 +130,7 @@ class EBPFPnaParser : public EBPF::EBPFPsaParser { EBPFPnaParser(const EBPF::EBPFProgram *program, const IR::ParserBlock *block, const P4::TypeMap *typeMap); void emit(EBPF::CodeBuilder *builder) override; + void emitRejectState(EBPF::CodeBuilder *) override; DECLARE_TYPEINFO(EBPFPnaParser, EBPF::EBPFPsaParser); }; diff --git a/backends/tc/runtime/pna.h b/backends/tc/runtime/pna.h index 51b2545cda..cb89b3a4c7 100644 --- a/backends/tc/runtime/pna.h +++ b/backends/tc/runtime/pna.h @@ -78,6 +78,7 @@ struct pna_global_metadata { PortId_t egress_port; enum MirrorType mirror_type; MirrorSlotId_t mirror_slot_id; + ParserError_t parser_error; MirrorSessionId_t mirror_session_id; __u8 mark; bool pass_to_kernel; // internal metadata, forces sending packet up to kernel stack diff --git a/testdata/p4tc_samples_outputs/calculator_control_blocks.c b/testdata/p4tc_samples_outputs/calculator_control_blocks.c index c8ee1fbfac..f80f5913d0 100644 --- a/testdata/p4tc_samples_outputs/calculator_control_blocks.c +++ b/testdata/p4tc_samples_outputs/calculator_control_blocks.c @@ -92,7 +92,7 @@ if (/* hdr->p4calc.isValid() */ tmp_5 = hdr->ethernet.dstAddr; hdr->ethernet.dstAddr = hdr->ethernet.srcAddr; hdr->ethernet.srcAddr = tmp_5; - /* send_to_port(istd.input_port) */ + /* send_to_port(skb->ifindex) */ compiler_meta__->drop = false; send_to_port(skb->ifindex); } @@ -103,7 +103,7 @@ if (/* hdr->p4calc.isValid() */ tmp_5 = hdr->ethernet.dstAddr; hdr->ethernet.dstAddr = hdr->ethernet.srcAddr; hdr->ethernet.srcAddr = tmp_5; - /* send_to_port(istd.input_port) */ + /* send_to_port(skb->ifindex) */ compiler_meta__->drop = false; send_to_port(skb->ifindex); } @@ -114,7 +114,7 @@ if (/* hdr->p4calc.isValid() */ tmp_5 = hdr->ethernet.dstAddr; hdr->ethernet.dstAddr = hdr->ethernet.srcAddr; hdr->ethernet.srcAddr = tmp_5; - /* send_to_port(istd.input_port) */ + /* send_to_port(skb->ifindex) */ compiler_meta__->drop = false; send_to_port(skb->ifindex); } @@ -125,7 +125,7 @@ if (/* hdr->p4calc.isValid() */ tmp_5 = hdr->ethernet.dstAddr; hdr->ethernet.dstAddr = hdr->ethernet.srcAddr; hdr->ethernet.srcAddr = tmp_5; - /* send_to_port(istd.input_port) */ + /* send_to_port(skb->ifindex) */ compiler_meta__->drop = false; send_to_port(skb->ifindex); } @@ -136,7 +136,7 @@ if (/* hdr->p4calc.isValid() */ tmp_5 = hdr->ethernet.dstAddr; hdr->ethernet.dstAddr = hdr->ethernet.srcAddr; hdr->ethernet.srcAddr = tmp_5; - /* send_to_port(istd.input_port) */ + /* send_to_port(skb->ifindex) */ compiler_meta__->drop = false; send_to_port(skb->ifindex); } diff --git a/testdata/p4tc_samples_outputs/calculator_parser.c b/testdata/p4tc_samples_outputs/calculator_parser.c index 1cbf8ba5e9..e839bf5ed2 100644 --- a/testdata/p4tc_samples_outputs/calculator_parser.c +++ b/testdata/p4tc_samples_outputs/calculator_parser.c @@ -205,6 +205,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/checksum_parser.c b/testdata/p4tc_samples_outputs/checksum_parser.c index 4c24bbb430..3f7efa603d 100644 --- a/testdata/p4tc_samples_outputs/checksum_parser.c +++ b/testdata/p4tc_samples_outputs/checksum_parser.c @@ -144,6 +144,7 @@ ck_0_state; goto accept; if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/const_entries_range_mask_parser.c b/testdata/p4tc_samples_outputs/const_entries_range_mask_parser.c index 62f87670ae..6006749c1d 100644 --- a/testdata/p4tc_samples_outputs/const_entries_range_mask_parser.c +++ b/testdata/p4tc_samples_outputs/const_entries_range_mask_parser.c @@ -60,6 +60,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct Header_t *h, if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/default_action_example_parser.c b/testdata/p4tc_samples_outputs/default_action_example_parser.c index 9ddfa9cd4b..f9d8e7f763 100644 --- a/testdata/p4tc_samples_outputs/default_action_example_parser.c +++ b/testdata/p4tc_samples_outputs/default_action_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/default_hit_const_example_parser.c b/testdata/p4tc_samples_outputs/default_hit_const_example_parser.c index f8947ae9c9..68fe734a93 100644 --- a/testdata/p4tc_samples_outputs/default_hit_const_example_parser.c +++ b/testdata/p4tc_samples_outputs/default_hit_const_example_parser.c @@ -156,6 +156,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/drop_packet_example_parser.c b/testdata/p4tc_samples_outputs/drop_packet_example_parser.c index b37fb820be..cd3e32d46b 100644 --- a/testdata/p4tc_samples_outputs/drop_packet_example_parser.c +++ b/testdata/p4tc_samples_outputs/drop_packet_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/global_action_example_01_parser.c b/testdata/p4tc_samples_outputs/global_action_example_01_parser.c index 2874b52a51..4515b8da67 100644 --- a/testdata/p4tc_samples_outputs/global_action_example_01_parser.c +++ b/testdata/p4tc_samples_outputs/global_action_example_01_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct my_ingress_h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/global_action_example_02_parser.c b/testdata/p4tc_samples_outputs/global_action_example_02_parser.c index a0cc59e0ef..8b63e9eb53 100644 --- a/testdata/p4tc_samples_outputs/global_action_example_02_parser.c +++ b/testdata/p4tc_samples_outputs/global_action_example_02_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct my_ingress_h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/hash1_parser.c b/testdata/p4tc_samples_outputs/hash1_parser.c index 3ebcb483ea..5302a7c0c0 100644 --- a/testdata/p4tc_samples_outputs/hash1_parser.c +++ b/testdata/p4tc_samples_outputs/hash1_parser.c @@ -87,6 +87,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct my_ingress_h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/ipip_parser.c b/testdata/p4tc_samples_outputs/ipip_parser.c index 0f6d72cac3..fbdc779b23 100644 --- a/testdata/p4tc_samples_outputs/ipip_parser.c +++ b/testdata/p4tc_samples_outputs/ipip_parser.c @@ -162,6 +162,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/matchtype_parser.c b/testdata/p4tc_samples_outputs/matchtype_parser.c index 5321d5ec13..0eed1c5bf4 100644 --- a/testdata/p4tc_samples_outputs/matchtype_parser.c +++ b/testdata/p4tc_samples_outputs/matchtype_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/mix_matchtype_example_parser.c b/testdata/p4tc_samples_outputs/mix_matchtype_example_parser.c index 6e66c6ef73..be8f972143 100644 --- a/testdata/p4tc_samples_outputs/mix_matchtype_example_parser.c +++ b/testdata/p4tc_samples_outputs/mix_matchtype_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/multiple_tables_example_01_parser.c b/testdata/p4tc_samples_outputs/multiple_tables_example_01_parser.c index ea377c0342..750eebea21 100644 --- a/testdata/p4tc_samples_outputs/multiple_tables_example_01_parser.c +++ b/testdata/p4tc_samples_outputs/multiple_tables_example_01_parser.c @@ -156,6 +156,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/multiple_tables_example_02_control_blocks.c b/testdata/p4tc_samples_outputs/multiple_tables_example_02_control_blocks.c index 31509f10df..4d0bf4cf09 100644 --- a/testdata/p4tc_samples_outputs/multiple_tables_example_02_control_blocks.c +++ b/testdata/p4tc_samples_outputs/multiple_tables_example_02_control_blocks.c @@ -324,7 +324,7 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) switch (value->action) { case MAINCONTROLIMPL_IPV4_TBL_3_ACT_MAINCONTROLIMPL_SENDTOPORT: { -/* send_to_port(istd.input_port) */ +/* send_to_port(skb->ifindex) */ compiler_meta__->drop = false; send_to_port(skb->ifindex); } @@ -377,7 +377,7 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) switch (value->action) { case MAINCONTROLIMPL_IPV4_TBL_4_ACT_MAINCONTROLIMPL_SENDTOPORT: { -/* send_to_port(istd.input_port) */ +/* send_to_port(skb->ifindex) */ compiler_meta__->drop = false; send_to_port(skb->ifindex); } @@ -539,7 +539,7 @@ if (hdr->ipv4.protocol != 6) { break; case MAINCONTROLIMPL_SET_ALL_OPTIONS_ACT_MAINCONTROLIMPL_SENDTOPORT: { -/* send_to_port(istd.input_port) */ +/* send_to_port(skb->ifindex) */ compiler_meta__->drop = false; send_to_port(skb->ifindex); } diff --git a/testdata/p4tc_samples_outputs/multiple_tables_example_02_parser.c b/testdata/p4tc_samples_outputs/multiple_tables_example_02_parser.c index 9c9808bf1e..9b02f88552 100644 --- a/testdata/p4tc_samples_outputs/multiple_tables_example_02_parser.c +++ b/testdata/p4tc_samples_outputs/multiple_tables_example_02_parser.c @@ -156,6 +156,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/name_annotation_example_parser.c b/testdata/p4tc_samples_outputs/name_annotation_example_parser.c index 74fbc57d8a..1cabee812b 100644 --- a/testdata/p4tc_samples_outputs/name_annotation_example_parser.c +++ b/testdata/p4tc_samples_outputs/name_annotation_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/no_table_example_control_blocks.c b/testdata/p4tc_samples_outputs/no_table_example_control_blocks.c index 0ee302cf1a..2522339afa 100644 --- a/testdata/p4tc_samples_outputs/no_table_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/no_table_example_control_blocks.c @@ -28,7 +28,7 @@ static __always_inline int process(struct __sk_buff *skb, struct headers_t *hdr, { u8 hit; { -if ((u32)istd.input_port == 4) { +if ((u32)skb->ifindex == 4) { hdr->udp.src_port = (hdr->udp.src_port + 1); } } diff --git a/testdata/p4tc_samples_outputs/no_table_example_parser.c b/testdata/p4tc_samples_outputs/no_table_example_parser.c index 43afdc8466..e5a27847a0 100644 --- a/testdata/p4tc_samples_outputs/no_table_example_parser.c +++ b/testdata/p4tc_samples_outputs/no_table_example_parser.c @@ -131,6 +131,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/noaction_example_01_parser.c b/testdata/p4tc_samples_outputs/noaction_example_01_parser.c index 9ee97f1665..4c143f24ec 100644 --- a/testdata/p4tc_samples_outputs/noaction_example_01_parser.c +++ b/testdata/p4tc_samples_outputs/noaction_example_01_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/noaction_example_02_parser.c b/testdata/p4tc_samples_outputs/noaction_example_02_parser.c index f73bea5d4c..55e5ae113a 100644 --- a/testdata/p4tc_samples_outputs/noaction_example_02_parser.c +++ b/testdata/p4tc_samples_outputs/noaction_example_02_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/nummask_annotation_example_control_blocks.c b/testdata/p4tc_samples_outputs/nummask_annotation_example_control_blocks.c index a3324ef549..a210796b0b 100644 --- a/testdata/p4tc_samples_outputs/nummask_annotation_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/nummask_annotation_example_control_blocks.c @@ -49,7 +49,7 @@ static __always_inline int process(struct __sk_buff *skb, struct headers_t *hdr, { u8 hit; { -if (((u32)istd.input_port == 2 && /* hdr->ipv4.isValid() */ +if (((u32)skb->ifindex == 2 && /* hdr->ipv4.isValid() */ hdr->ipv4.ebpf_valid) && /* hdr->tcp.isValid() */ hdr->tcp.ebpf_valid) { /* set_ct_options_0.apply() */ diff --git a/testdata/p4tc_samples_outputs/nummask_annotation_example_parser.c b/testdata/p4tc_samples_outputs/nummask_annotation_example_parser.c index c8e58a75e2..3c514e277c 100644 --- a/testdata/p4tc_samples_outputs/nummask_annotation_example_parser.c +++ b/testdata/p4tc_samples_outputs/nummask_annotation_example_parser.c @@ -156,6 +156,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/send_to_port_example_parser.c b/testdata/p4tc_samples_outputs/send_to_port_example_parser.c index edf89cc1c2..9348f03a0f 100644 --- a/testdata/p4tc_samples_outputs/send_to_port_example_parser.c +++ b/testdata/p4tc_samples_outputs/send_to_port_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/set_entry_timer_example_parser.c b/testdata/p4tc_samples_outputs/set_entry_timer_example_parser.c index 5fd7450298..0450b42c15 100644 --- a/testdata/p4tc_samples_outputs/set_entry_timer_example_parser.c +++ b/testdata/p4tc_samples_outputs/set_entry_timer_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/simple_exact_example_parser.c b/testdata/p4tc_samples_outputs/simple_exact_example_parser.c index b6e987911e..3efcec825f 100644 --- a/testdata/p4tc_samples_outputs/simple_exact_example_parser.c +++ b/testdata/p4tc_samples_outputs/simple_exact_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct my_ingress_h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/simple_lpm_example_parser.c b/testdata/p4tc_samples_outputs/simple_lpm_example_parser.c index e14de9b75a..cf57fd1eb3 100644 --- a/testdata/p4tc_samples_outputs/simple_lpm_example_parser.c +++ b/testdata/p4tc_samples_outputs/simple_lpm_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct my_ingress_h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/simple_ternary_example_parser.c b/testdata/p4tc_samples_outputs/simple_ternary_example_parser.c index 5fbf60a089..01c7ad4a85 100644 --- a/testdata/p4tc_samples_outputs/simple_ternary_example_parser.c +++ b/testdata/p4tc_samples_outputs/simple_ternary_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct my_ingress_h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/size_param_example_parser.c b/testdata/p4tc_samples_outputs/size_param_example_parser.c index b75b872f4e..0db7eaf560 100644 --- a/testdata/p4tc_samples_outputs/size_param_example_parser.c +++ b/testdata/p4tc_samples_outputs/size_param_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/tc_type_annotation_example_parser.c b/testdata/p4tc_samples_outputs/tc_type_annotation_example_parser.c index 9dedf29604..0b9f6a2c72 100644 --- a/testdata/p4tc_samples_outputs/tc_type_annotation_example_parser.c +++ b/testdata/p4tc_samples_outputs/tc_type_annotation_example_parser.c @@ -108,6 +108,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; } diff --git a/testdata/p4tc_samples_outputs/test_ipv6_example_parser.c b/testdata/p4tc_samples_outputs/test_ipv6_example_parser.c index c187515e8d..d6e9d8da4d 100644 --- a/testdata/p4tc_samples_outputs/test_ipv6_example_parser.c +++ b/testdata/p4tc_samples_outputs/test_ipv6_example_parser.c @@ -126,6 +126,7 @@ static __always_inline int run_parser(struct __sk_buff *skb, struct headers_t *h if (ebpf_errorCode == 0) { return TC_ACT_SHOT; } + compiler_meta__->parser_error = ebpf_errorCode; goto accept; }