@@ -30,7 +30,7 @@ struct packetHeaders {
3030 uint32_t seqN ;
3131 uint32_t ackN ;
3232 uint8_t connStatus ;
33- };
33+ } __attribute__(( packed )) ;
3434
3535struct horusKey {
3636#if _SRCIP
@@ -69,14 +69,13 @@ enum {
6969
7070BPF_TABLE ("extern" , int , struct packetHeaders , packet , 1 );
7171
72- // TODO 1024 -> const
73- BPF_TABLE ("hash" , struct horusKey , struct horusValue , horusTable , 1024 );
72+ BPF_TABLE ("hash" , struct horusKey , struct horusValue , horusTable , _MAX_RULE_SIZE_FOR_HORUS );
7473
7574BPF_TABLE ("extern" , int , int , forwardingDecision , 1 );
7675
7776// Per-CPU maps used to keep counter of HORUS rules
78- BPF_TABLE ("percpu_array" , int , u64 , pkts_horus , 1024 );
79- BPF_TABLE ("percpu_array" , int , u64 , bytes_horus , 1024 );
77+ BPF_TABLE ("percpu_array" , int , u64 , pkts_horus , _MAX_RULE_SIZE_FOR_HORUS );
78+ BPF_TABLE ("percpu_array" , int , u64 , bytes_horus , _MAX_RULE_SIZE_FOR_HORUS );
8079
8180static __always_inline void incrementHorusCounters (u32 ruleID , u32 bytes ) {
8281 u64 * value ;
@@ -133,18 +132,18 @@ static int handle_rx(struct CTXTYPE *ctx, struct pkt_metadata *md) {
133132 struct horusValue * value ;
134133 value = horusTable .lookup (& key );
135134
136- pcn_log (ctx , LOG_DEBUG , "HORUS key : %x. pkt : %x " , key . srcIp , pkt -> srcIp );
135+ pcn_log (ctx , LOG_DEBUG , "Horus srcIp : %I dstIp : %I " , pkt -> srcIp , pkt -> dstIp );
137136 if (value == NULL ) {
138137 // Miss, goto pipleline
139138 goto PIPELINE ;
140139 } else {
141140 // Independently from the final action (ACCEPT or DROP)
142141 // I have to update the counters
143- if (value -> ruleID <= 1024 ) {
142+ if (value -> ruleID < _MAX_RULE_SIZE_FOR_HORUS ) {
144143 pcn_log (ctx , LOG_DEBUG , "HORUS RuleID: %d" , value -> ruleID );
145144 incrementHorusCounters (value -> ruleID , md -> packet_len );
146145 } else {
147- pcn_log (ctx , LOG_DEBUG , "HORUS RuleID is greater than 1024 " );
146+ pcn_log (ctx , LOG_DEBUG , "HORUS RuleID is greater than _MAX_RULE_SIZE_FOR_HORUS " );
148147 goto PIPELINE ;
149148 }
150149
@@ -165,4 +164,4 @@ PIPELINE:;
165164 pcn_log (ctx , LOG_DEBUG , "HORUS Lookup MISS. Goto PIPELINE. " );
166165 call_bpf_program (ctx , _CHAINSELECTOR );
167166 return RX_DROP ;
168- }
167+ }
0 commit comments