From 98d166f0d1ec235a677a54303c67dc1e9f046951 Mon Sep 17 00:00:00 2001 From: Sosutha Date: Wed, 13 Mar 2024 12:37:51 +0530 Subject: [PATCH] tc struct fields addition and memory initialization (#4524) * Addition of fields in table key value structure in tc backend * Memory initialization of key structure * Updated testcase outputs --- backends/tc/ebpfCodeGen.cpp | 20 ++++++- backends/tc/runtime/pna.h | 3 + .../calculator_control_blocks.c | 8 ++- .../checksum_control_blocks.c | 8 ++- .../const_entries_range_mask_control_blocks.c | 8 ++- .../default_action_example_control_blocks.c | 16 ++++-- ...ault_action_with_param_01_control_blocks.c | 16 ++++-- ...default_action_with_param_control_blocks.c | 16 ++++-- ...default_hit_const_example_control_blocks.c | 8 ++- .../drop_packet_example_control_blocks.c | 8 ++- .../global_action_example_01_control_blocks.c | 16 ++++-- .../global_action_example_02_control_blocks.c | 16 ++++-- .../ipip_control_blocks.c | 8 ++- .../matchtype_control_blocks.c | 32 ++++++++--- .../mix_matchtype_example_control_blocks.c | 32 ++++++++--- ...ultiple_tables_example_01_control_blocks.c | 56 ++++++++++++++----- ...ultiple_tables_example_02_control_blocks.c | 56 ++++++++++++++----- .../name_annotation_example_control_blocks.c | 16 ++++-- .../noaction_example_01_control_blocks.c | 16 ++++-- .../noaction_example_02_control_blocks.c | 16 ++++-- ...ummask_annotation_example_control_blocks.c | 8 ++- .../send_to_port_example_control_blocks.c | 8 ++- .../set_entry_timer_example_control_blocks.c | 16 ++++-- .../simple_exact_example_control_blocks.c | 8 ++- .../simple_lpm_example_control_blocks.c | 8 ++- .../simple_ternary_example_control_blocks.c | 8 ++- .../size_param_example_control_blocks.c | 16 ++++-- ...c_type_annotation_example_control_blocks.c | 16 ++++-- .../test_ipv6_example_control_blocks.c | 8 ++- 29 files changed, 357 insertions(+), 114 deletions(-) diff --git a/backends/tc/ebpfCodeGen.cpp b/backends/tc/ebpfCodeGen.cpp index 830d4a8246f..31b2c831840 100644 --- a/backends/tc/ebpfCodeGen.cpp +++ b/backends/tc/ebpfCodeGen.cpp @@ -826,6 +826,18 @@ void EBPFTablePNA::emitValueStructStructure(EBPF::CodeBuilder *builder) { builder->append("unsigned int action;"); builder->newline(); + builder->emitIndent(); + builder->append("u32 hit:1,"); + builder->newline(); + + builder->emitIndent(); + builder->append("is_default_miss_act:1,"); + builder->newline(); + + builder->emitIndent(); + builder->append("is_default_hit_act:1;"); + builder->newline(); + if (isTernaryTable()) { builder->emitIndent(); builder->append("__u32 priority;"); @@ -1501,7 +1513,11 @@ void ControlBodyTranslatorPNA::processApply(const P4::ApplyMethod *method) { builder->emitIndent(); builder->appendLine("};"); builder->emitIndent(); - builder->appendFormat("struct %s %s = {}", table->keyTypeName.c_str(), keyname.c_str()); + builder->appendFormat("struct %s %s", table->keyTypeName.c_str(), keyname.c_str()); + builder->endOfStatement(true); + builder->emitIndent(); + builder->appendFormat("__builtin_memset(&%s, 0, sizeof(%s))", keyname.c_str(), + keyname.c_str()); builder->endOfStatement(true); unsigned int keysize = tcIR->getTableKeysize(tblId); builder->emitIndent(); @@ -1605,7 +1621,7 @@ void ControlBodyTranslatorPNA::processApply(const P4::ApplyMethod *method) { builder->append(" else "); builder->blockStart(); builder->emitIndent(); - builder->appendFormat("%s = 1", control->hitVariable.c_str()); + builder->appendFormat("%s = value->hit", control->hitVariable.c_str()); builder->endOfStatement(true); builder->blockEnd(true); diff --git a/backends/tc/runtime/pna.h b/backends/tc/runtime/pna.h index c4589574757..7ba50faeee4 100644 --- a/backends/tc/runtime/pna.h +++ b/backends/tc/runtime/pna.h @@ -105,6 +105,9 @@ struct p4tc_table_entry_act_bpf_params__local { struct __attribute__((__packed__)) p4tc_table_entry_act_bpf { u32 act_id; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; u8 params[124]; }; diff --git a/testdata/p4tc_samples_outputs/calculator_control_blocks.c b/testdata/p4tc_samples_outputs/calculator_control_blocks.c index f6b4c710f8c..4273130c8b3 100644 --- a/testdata/p4tc_samples_outputs/calculator_control_blocks.c +++ b/testdata/p4tc_samples_outputs/calculator_control_blocks.c @@ -19,6 +19,9 @@ struct __attribute__((__packed__)) MainControlImpl_calculate_key { #define MAINCONTROLIMPL_CALCULATE_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_calculate_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -72,7 +75,8 @@ if (/* hdr->p4calc.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_calculate_key key = {}; + struct MainControlImpl_calculate_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 8; key.field0 = hdr->p4calc.op; struct p4tc_table_entry_act_bpf *act_bpf; @@ -85,7 +89,7 @@ if (/* hdr->p4calc.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/checksum_control_blocks.c b/testdata/p4tc_samples_outputs/checksum_control_blocks.c index f7bf2be6257..c38f6838fd7 100644 --- a/testdata/p4tc_samples_outputs/checksum_control_blocks.c +++ b/testdata/p4tc_samples_outputs/checksum_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) ingress_nh_table_key { #define INGRESS_NH_TABLE_ACT_NOACTION 0 struct __attribute__((__packed__)) ingress_nh_table_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -60,7 +63,8 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct ingress_nh_table_key key = {}; + struct ingress_nh_table_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.srcAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -73,7 +77,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/const_entries_range_mask_control_blocks.c b/testdata/p4tc_samples_outputs/const_entries_range_mask_control_blocks.c index e4e92178eb5..43948d2fc96 100644 --- a/testdata/p4tc_samples_outputs/const_entries_range_mask_control_blocks.c +++ b/testdata/p4tc_samples_outputs/const_entries_range_mask_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_t_range_key { #define MAINCONTROLIMPL_T_RANGE_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_t_range_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -58,7 +61,8 @@ static __always_inline int process(struct __sk_buff *skb, struct Header_t *h, st .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_t_range_key key = {}; + struct MainControlImpl_t_range_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 8; key.field0 = h->h.r; struct p4tc_table_entry_act_bpf *act_bpf; @@ -71,7 +75,7 @@ static __always_inline int process(struct __sk_buff *skb, struct Header_t *h, st /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/default_action_example_control_blocks.c b/testdata/p4tc_samples_outputs/default_action_example_control_blocks.c index db36a1f74f2..34dae6cd171 100644 --- a/testdata/p4tc_samples_outputs/default_action_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/default_action_example_control_blocks.c @@ -16,6 +16,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -38,6 +41,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -83,7 +89,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 64; key.field0 = hdr->ipv4.dstAddr; key.field1 = skb->ifindex; @@ -97,7 +104,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -131,7 +138,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -146,7 +154,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/default_action_with_param_01_control_blocks.c b/testdata/p4tc_samples_outputs/default_action_with_param_01_control_blocks.c index ec49d583490..64825e1d5c3 100644 --- a/testdata/p4tc_samples_outputs/default_action_with_param_01_control_blocks.c +++ b/testdata/p4tc_samples_outputs/default_action_with_param_01_control_blocks.c @@ -16,6 +16,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -37,6 +40,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -83,7 +89,8 @@ static __always_inline int process(struct __sk_buff *skb, struct headers_t *hdr, .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 64; key.field0 = hdr->ipv4.dstAddr; key.field1 = skb->ifindex; @@ -97,7 +104,7 @@ static __always_inline int process(struct __sk_buff *skb, struct headers_t *hdr, /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -131,7 +138,8 @@ static __always_inline int process(struct __sk_buff *skb, struct headers_t *hdr, .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -146,7 +154,7 @@ static __always_inline int process(struct __sk_buff *skb, struct headers_t *hdr, /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/default_action_with_param_control_blocks.c b/testdata/p4tc_samples_outputs/default_action_with_param_control_blocks.c index 22d8dba79de..7815a4be4e5 100644 --- a/testdata/p4tc_samples_outputs/default_action_with_param_control_blocks.c +++ b/testdata/p4tc_samples_outputs/default_action_with_param_control_blocks.c @@ -16,6 +16,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -38,6 +41,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -83,7 +89,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 64; key.field0 = hdr->ipv4.dstAddr; key.field1 = skb->ifindex; @@ -97,7 +104,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -131,7 +138,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -146,7 +154,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/default_hit_const_example_control_blocks.c b/testdata/p4tc_samples_outputs/default_hit_const_example_control_blocks.c index 030749a7586..bc89cb8bd61 100644 --- a/testdata/p4tc_samples_outputs/default_hit_const_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/default_hit_const_example_control_blocks.c @@ -20,6 +20,9 @@ struct MainControlImpl_set_ct_options_key_mask { #define MAINCONTROLIMPL_SET_CT_OPTIONS_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_set_ct_options_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; __u32 priority; union { struct { @@ -68,7 +71,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_set_ct_options_key key = {}; + struct MainControlImpl_set_ct_options_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 8; key.field0 = hdr->tcp.flags; struct p4tc_table_entry_act_bpf *act_bpf; @@ -81,7 +85,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/drop_packet_example_control_blocks.c b/testdata/p4tc_samples_outputs/drop_packet_example_control_blocks.c index 7982640a80a..707c641f106 100644 --- a/testdata/p4tc_samples_outputs/drop_packet_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/drop_packet_example_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_key { #define MAINCONTROLIMPL_IPV4_TBL_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -60,7 +63,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_key key = {}; + struct MainControlImpl_ipv4_tbl_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -73,7 +77,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/global_action_example_01_control_blocks.c b/testdata/p4tc_samples_outputs/global_action_example_01_control_blocks.c index ba344055f17..71696a8ba34 100644 --- a/testdata/p4tc_samples_outputs/global_action_example_01_control_blocks.c +++ b/testdata/p4tc_samples_outputs/global_action_example_01_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) ingress_nh_table2_key { #define INGRESS_NH_TABLE2_ACT_NOACTION 0 struct __attribute__((__packed__)) ingress_nh_table2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -36,6 +39,9 @@ struct __attribute__((__packed__)) ingress_nh_table_key { #define INGRESS_NH_TABLE_ACT_NOACTION 0 struct __attribute__((__packed__)) ingress_nh_table_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -81,7 +87,8 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct ingress_nh_table_key key = {}; + struct ingress_nh_table_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.srcAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -94,7 +101,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -130,7 +137,8 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct ingress_nh_table2_key key = {}; + struct ingress_nh_table2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.srcAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -143,7 +151,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/global_action_example_02_control_blocks.c b/testdata/p4tc_samples_outputs/global_action_example_02_control_blocks.c index ac79caa03dc..614e5c4efa9 100644 --- a/testdata/p4tc_samples_outputs/global_action_example_02_control_blocks.c +++ b/testdata/p4tc_samples_outputs/global_action_example_02_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) ingress_nh_table2_key { #define INGRESS_NH_TABLE2_ACT_NOACTION 0 struct __attribute__((__packed__)) ingress_nh_table2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -37,6 +40,9 @@ struct __attribute__((__packed__)) ingress_nh_table_key { #define INGRESS_NH_TABLE_ACT_NOACTION 0 struct __attribute__((__packed__)) ingress_nh_table_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -82,7 +88,8 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct ingress_nh_table_key key = {}; + struct ingress_nh_table_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.srcAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -95,7 +102,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -131,7 +138,8 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct ingress_nh_table2_key key = {}; + struct ingress_nh_table2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.srcAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -144,7 +152,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/ipip_control_blocks.c b/testdata/p4tc_samples_outputs/ipip_control_blocks.c index 6f0474f07b6..3c8b6fbafcd 100644 --- a/testdata/p4tc_samples_outputs/ipip_control_blocks.c +++ b/testdata/p4tc_samples_outputs/ipip_control_blocks.c @@ -16,6 +16,9 @@ struct __attribute__((__packed__)) Main_fwd_table_key { #define MAIN_FWD_TABLE_ACT_NOACTION 0 struct __attribute__((__packed__)) Main_fwd_table_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -67,7 +70,8 @@ if (/* hdr->outer.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct Main_fwd_table_key key = {}; + struct Main_fwd_table_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = skb->ifindex; struct p4tc_table_entry_act_bpf *act_bpf; @@ -80,7 +84,7 @@ if (/* hdr->outer.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/matchtype_control_blocks.c b/testdata/p4tc_samples_outputs/matchtype_control_blocks.c index 8c9394cb148..7dd7b0f7c00 100644 --- a/testdata/p4tc_samples_outputs/matchtype_control_blocks.c +++ b/testdata/p4tc_samples_outputs/matchtype_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -41,6 +44,9 @@ struct MainControlImpl_ipv4_tbl_2_key_mask { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; __u32 priority; union { struct { @@ -62,6 +68,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_3_key { #define MAINCONTROLIMPL_IPV4_TBL_3_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_3_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -84,6 +93,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_4_key { #define MAINCONTROLIMPL_IPV4_TBL_4_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_4_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -129,7 +141,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -142,7 +155,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -176,7 +189,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -191,7 +205,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -225,7 +239,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 3 }; - struct MainControlImpl_ipv4_tbl_3_key key = {}; + struct MainControlImpl_ipv4_tbl_3_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.srcAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -238,7 +253,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -272,7 +287,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 4 }; - struct MainControlImpl_ipv4_tbl_4_key key = {}; + struct MainControlImpl_ipv4_tbl_4_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -287,7 +303,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/mix_matchtype_example_control_blocks.c b/testdata/p4tc_samples_outputs/mix_matchtype_example_control_blocks.c index 8753274d468..18ffa961b8c 100644 --- a/testdata/p4tc_samples_outputs/mix_matchtype_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/mix_matchtype_example_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -41,6 +44,9 @@ struct MainControlImpl_ipv4_tbl_2_key_mask { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; __u32 priority; union { struct { @@ -67,6 +73,9 @@ struct MainControlImpl_ipv4_tbl_3_key_mask { #define MAINCONTROLIMPL_IPV4_TBL_3_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_3_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; __u32 priority; union { struct { @@ -90,6 +99,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_4_key { #define MAINCONTROLIMPL_IPV4_TBL_4_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_4_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -135,7 +147,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -148,7 +161,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -182,7 +195,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -197,7 +211,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -231,7 +245,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 3 }; - struct MainControlImpl_ipv4_tbl_3_key key = {}; + struct MainControlImpl_ipv4_tbl_3_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 40; key.field0 = hdr->ipv4.srcAddr; key.field1 = hdr->ipv4.protocol; @@ -245,7 +260,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -279,7 +294,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 4 }; - struct MainControlImpl_ipv4_tbl_4_key key = {}; + struct MainControlImpl_ipv4_tbl_4_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -294,7 +310,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/multiple_tables_example_01_control_blocks.c b/testdata/p4tc_samples_outputs/multiple_tables_example_01_control_blocks.c index 152e489e7a7..20bd2bd9ddf 100644 --- a/testdata/p4tc_samples_outputs/multiple_tables_example_01_control_blocks.c +++ b/testdata/p4tc_samples_outputs/multiple_tables_example_01_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -37,6 +40,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -59,6 +65,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_3_key { #define MAINCONTROLIMPL_IPV4_TBL_3_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_3_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -81,6 +90,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_4_key { #define MAINCONTROLIMPL_IPV4_TBL_4_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_4_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -99,6 +111,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_5_key { #define MAINCONTROLIMPL_IPV4_TBL_5_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_5_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -122,6 +137,9 @@ struct __attribute__((__packed__)) MainControlImpl_set_all_options_key { #define MAINCONTROLIMPL_SET_ALL_OPTIONS_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_set_all_options_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -158,6 +176,9 @@ struct MainControlImpl_set_ct_options_key_mask { #define MAINCONTROLIMPL_SET_CT_OPTIONS_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_set_ct_options_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; __u32 priority; union { struct { @@ -205,7 +226,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -218,7 +240,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -254,7 +276,8 @@ if (hdr->ipv4.protocol == 6 && (hdr->tcp.srcPort > 0)) { .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -269,7 +292,7 @@ if (hdr->ipv4.protocol == 6 && (hdr->tcp.srcPort > 0)) { /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -305,7 +328,8 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { .pipeid = p4tc_filter_fields.pipeid, .tblid = 3 }; - struct MainControlImpl_ipv4_tbl_3_key key = {}; + struct MainControlImpl_ipv4_tbl_3_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 67; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -320,7 +344,7 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -356,7 +380,8 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { .pipeid = p4tc_filter_fields.pipeid, .tblid = 4 }; - struct MainControlImpl_ipv4_tbl_4_key key = {}; + struct MainControlImpl_ipv4_tbl_4_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 77; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -371,7 +396,7 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -407,7 +432,8 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { .pipeid = p4tc_filter_fields.pipeid, .tblid = 5 }; - struct MainControlImpl_ipv4_tbl_5_key key = {}; + struct MainControlImpl_ipv4_tbl_5_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 13; key.field0 = hdr->ipv4.fragOffset; struct p4tc_table_entry_act_bpf *act_bpf; @@ -420,7 +446,7 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -441,7 +467,8 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { .pipeid = p4tc_filter_fields.pipeid, .tblid = 6 }; - struct MainControlImpl_set_ct_options_key key = {}; + struct MainControlImpl_set_ct_options_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 8; key.field0 = hdr->tcp.flags; struct p4tc_table_entry_act_bpf *act_bpf; @@ -454,7 +481,7 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -487,7 +514,8 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { .pipeid = p4tc_filter_fields.pipeid, .tblid = 7 }; - struct MainControlImpl_set_all_options_key key = {}; + struct MainControlImpl_set_all_options_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 64; key.field0 = hdr->ipv4.srcAddr; key.field1 = hdr->tcp.srcPort; @@ -503,7 +531,7 @@ if (hdr->ipv4.protocol != 4 || (hdr->tcp.srcPort <= 3)) { /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ 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 e85f1b94f21..5eb402e93db 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 @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -37,6 +40,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -59,6 +65,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_3_key { #define MAINCONTROLIMPL_IPV4_TBL_3_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_3_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -80,6 +89,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_4_key { #define MAINCONTROLIMPL_IPV4_TBL_4_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_4_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -97,6 +109,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_5_key { #define MAINCONTROLIMPL_IPV4_TBL_5_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_5_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -120,6 +135,9 @@ struct __attribute__((__packed__)) MainControlImpl_set_all_options_key { #define MAINCONTROLIMPL_SET_ALL_OPTIONS_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_set_all_options_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -155,6 +173,9 @@ struct MainControlImpl_set_ct_options_key_mask { #define MAINCONTROLIMPL_SET_CT_OPTIONS_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_set_ct_options_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; __u32 priority; union { struct { @@ -202,7 +223,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -215,7 +237,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -252,7 +274,8 @@ if (hdr->ipv4.protocol != 6) { .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -267,7 +290,7 @@ if (hdr->ipv4.protocol != 6) { /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -304,7 +327,8 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) .pipeid = p4tc_filter_fields.pipeid, .tblid = 3 }; - struct MainControlImpl_ipv4_tbl_3_key key = {}; + struct MainControlImpl_ipv4_tbl_3_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 67; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -319,7 +343,7 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -355,7 +379,8 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) .pipeid = p4tc_filter_fields.pipeid, .tblid = 4 }; - struct MainControlImpl_ipv4_tbl_4_key key = {}; + struct MainControlImpl_ipv4_tbl_4_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 77; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -370,7 +395,7 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -406,7 +431,8 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) .pipeid = p4tc_filter_fields.pipeid, .tblid = 5 }; - struct MainControlImpl_ipv4_tbl_5_key key = {}; + struct MainControlImpl_ipv4_tbl_5_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 13; key.field0 = hdr->ipv4.fragOffset; struct p4tc_table_entry_act_bpf *act_bpf; @@ -419,7 +445,7 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -440,7 +466,8 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) .pipeid = p4tc_filter_fields.pipeid, .tblid = 6 }; - struct MainControlImpl_set_ct_options_key key = {}; + struct MainControlImpl_set_ct_options_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 8; key.field0 = hdr->tcp.flags; struct p4tc_table_entry_act_bpf *act_bpf; @@ -453,7 +480,7 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -486,7 +513,8 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) .pipeid = p4tc_filter_fields.pipeid, .tblid = 7 }; - struct MainControlImpl_set_all_options_key key = {}; + struct MainControlImpl_set_all_options_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 64; key.field0 = hdr->ipv4.srcAddr; key.field1 = hdr->tcp.srcPort; @@ -502,7 +530,7 @@ if (hdr->ipv4.protocol == 6 || ((hdr->ipv4.version > 1) && (hdr->ipv4.ihl <= 2)) /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/name_annotation_example_control_blocks.c b/testdata/p4tc_samples_outputs/name_annotation_example_control_blocks.c index 05aa35446a5..590d94e76dc 100644 --- a/testdata/p4tc_samples_outputs/name_annotation_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/name_annotation_example_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -37,6 +40,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -82,7 +88,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -95,7 +102,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -129,7 +136,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -144,7 +152,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/noaction_example_01_control_blocks.c b/testdata/p4tc_samples_outputs/noaction_example_01_control_blocks.c index b737dc8667b..9c52d162b7f 100644 --- a/testdata/p4tc_samples_outputs/noaction_example_01_control_blocks.c +++ b/testdata/p4tc_samples_outputs/noaction_example_01_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -37,6 +40,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -82,7 +88,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -95,7 +102,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -129,7 +136,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 67; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -144,7 +152,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/noaction_example_02_control_blocks.c b/testdata/p4tc_samples_outputs/noaction_example_02_control_blocks.c index cf628fa093e..cb9602e7014 100644 --- a/testdata/p4tc_samples_outputs/noaction_example_02_control_blocks.c +++ b/testdata/p4tc_samples_outputs/noaction_example_02_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -33,6 +36,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -73,7 +79,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -86,7 +93,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -120,7 +127,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 3; key.field0 = hdr->ipv4.flags; struct p4tc_table_entry_act_bpf *act_bpf; @@ -133,7 +141,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ 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 5a9cf8261ca..e2f64bdfaa0 100644 --- a/testdata/p4tc_samples_outputs/nummask_annotation_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/nummask_annotation_example_control_blocks.c @@ -16,6 +16,9 @@ struct __attribute__((__packed__)) MainControlImpl_set_ct_options_key { #define MAINCONTROLIMPL_SET_CT_OPTIONS_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_set_ct_options_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -63,7 +66,8 @@ if (((u32)skb->ifindex == 2 && /* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_set_ct_options_key key = {}; + struct MainControlImpl_set_ct_options_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 8; key.field0 = (hdr->tcp.flags); struct p4tc_table_entry_act_bpf *act_bpf; @@ -76,7 +80,7 @@ if (((u32)skb->ifindex == 2 && /* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/send_to_port_example_control_blocks.c b/testdata/p4tc_samples_outputs/send_to_port_example_control_blocks.c index a5a44ef048e..598148233bd 100644 --- a/testdata/p4tc_samples_outputs/send_to_port_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/send_to_port_example_control_blocks.c @@ -17,6 +17,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_key { #define MAINCONTROLIMPL_IPV4_TBL_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -62,7 +65,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_key key = {}; + struct MainControlImpl_ipv4_tbl_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -77,7 +81,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/set_entry_timer_example_control_blocks.c b/testdata/p4tc_samples_outputs/set_entry_timer_example_control_blocks.c index 9799a406fce..495b2120f0c 100644 --- a/testdata/p4tc_samples_outputs/set_entry_timer_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/set_entry_timer_example_control_blocks.c @@ -16,6 +16,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -37,6 +40,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -81,7 +87,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 64; key.field0 = hdr->ipv4.dstAddr; key.field1 = skb->ifindex; @@ -95,7 +102,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -135,7 +142,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 72; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -150,7 +158,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/simple_exact_example_control_blocks.c b/testdata/p4tc_samples_outputs/simple_exact_example_control_blocks.c index 91fb742ac0f..108a07a2cbe 100644 --- a/testdata/p4tc_samples_outputs/simple_exact_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/simple_exact_example_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) ingress_nh_table_key { #define INGRESS_NH_TABLE_ACT_NOACTION 0 struct __attribute__((__packed__)) ingress_nh_table_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -60,7 +63,8 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct ingress_nh_table_key key = {}; + struct ingress_nh_table_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.srcAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -73,7 +77,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/simple_lpm_example_control_blocks.c b/testdata/p4tc_samples_outputs/simple_lpm_example_control_blocks.c index 446bbb8100a..470266d3632 100644 --- a/testdata/p4tc_samples_outputs/simple_lpm_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/simple_lpm_example_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) ingress_nh_table_key { #define INGRESS_NH_TABLE_ACT_NOACTION 0 struct __attribute__((__packed__)) ingress_nh_table_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -60,7 +63,8 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct ingress_nh_table_key key = {}; + struct ingress_nh_table_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = bpf_htonl(hdr->ipv4.srcAddr); struct p4tc_table_entry_act_bpf *act_bpf; @@ -73,7 +77,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/simple_ternary_example_control_blocks.c b/testdata/p4tc_samples_outputs/simple_ternary_example_control_blocks.c index 9e9c34f1926..99ec72ee893 100644 --- a/testdata/p4tc_samples_outputs/simple_ternary_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/simple_ternary_example_control_blocks.c @@ -20,6 +20,9 @@ struct ingress_nh_table_key_mask { #define INGRESS_NH_TABLE_ACT_NOACTION 0 struct __attribute__((__packed__)) ingress_nh_table_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; __u32 priority; union { struct { @@ -66,7 +69,8 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct ingress_nh_table_key key = {}; + struct ingress_nh_table_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 64; key.field0 = hdr->ipv4.srcAddr; key.field1 = hdr->ipv4.dstAddr; @@ -80,7 +84,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/size_param_example_control_blocks.c b/testdata/p4tc_samples_outputs/size_param_example_control_blocks.c index af7755a2667..9b8ee703ae7 100644 --- a/testdata/p4tc_samples_outputs/size_param_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/size_param_example_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -37,6 +40,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT_NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -82,7 +88,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -95,7 +102,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -129,7 +136,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 67; key.field0 = hdr->ipv4.dstAddr; key.field1 = hdr->ipv4.srcAddr; @@ -144,7 +152,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/tc_type_annotation_example_control_blocks.c b/testdata/p4tc_samples_outputs/tc_type_annotation_example_control_blocks.c index e673a5fa76d..3c27cb4828c 100644 --- a/testdata/p4tc_samples_outputs/tc_type_annotation_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/tc_type_annotation_example_control_blocks.c @@ -15,6 +15,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_key { #define MAINCONTROLIMPL_IPV4_TBL_1_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_1_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -34,6 +37,9 @@ struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_key { #define MAINCONTROLIMPL_IPV4_TBL_2_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_ipv4_tbl_2_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -74,7 +80,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_ipv4_tbl_1_key key = {}; + struct MainControlImpl_ipv4_tbl_1_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 32; key.field0 = hdr->ipv4.dstAddr; struct p4tc_table_entry_act_bpf *act_bpf; @@ -87,7 +94,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ @@ -122,7 +129,8 @@ if (/* hdr->ipv4.isValid() */ .pipeid = p4tc_filter_fields.pipeid, .tblid = 2 }; - struct MainControlImpl_ipv4_tbl_2_key key = {}; + struct MainControlImpl_ipv4_tbl_2_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 3; key.field0 = hdr->ipv4.flags; struct p4tc_table_entry_act_bpf *act_bpf; @@ -135,7 +143,7 @@ if (/* hdr->ipv4.isValid() */ /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */ diff --git a/testdata/p4tc_samples_outputs/test_ipv6_example_control_blocks.c b/testdata/p4tc_samples_outputs/test_ipv6_example_control_blocks.c index 9fc5798d242..4f1aacb0fb8 100644 --- a/testdata/p4tc_samples_outputs/test_ipv6_example_control_blocks.c +++ b/testdata/p4tc_samples_outputs/test_ipv6_example_control_blocks.c @@ -14,6 +14,9 @@ struct __attribute__((__packed__)) MainControlImpl_tbl_default_key { #define MAINCONTROLIMPL_TBL_DEFAULT_ACT__NOACTION 0 struct __attribute__((__packed__)) MainControlImpl_tbl_default_value { unsigned int action; + u32 hit:1, + is_default_miss_act:1, + is_default_hit_act:1; union { struct { } _NoAction; @@ -55,7 +58,8 @@ static __always_inline int process(struct __sk_buff *skb, struct headers_t *hdr, .pipeid = p4tc_filter_fields.pipeid, .tblid = 1 }; - struct MainControlImpl_tbl_default_key key = {}; + struct MainControlImpl_tbl_default_key key; + __builtin_memset(&key, 0, sizeof(key)); key.keysz = 128; __builtin_memcpy(&(key.field0[0]), &(hdr->ipv6.srcAddr[0]), 16); struct p4tc_table_entry_act_bpf *act_bpf; @@ -68,7 +72,7 @@ static __always_inline int process(struct __sk_buff *skb, struct headers_t *hdr, /* miss; find default action */ hit = 0; } else { - hit = 1; + hit = value->hit; } if (value != NULL) { /* run action */