Conversation
mbertrone
commented
Jun 11, 2019
- avoid incompatibility with conntrack rules
- increase horus max size
- use attribute packed to avoid memory alignment issues
ea7aca6 to
4e86738
Compare
| for (auto const &rule : rules) { | ||
| i++; | ||
| fromRuleToHorusKeyValue(rule, key, value); | ||
| if (i > HorusConst::MAX_RULE_SIZE_FOR_HORUS) |
There was a problem hiding this comment.
Shouldn't this be >=?
There was a problem hiding this comment.
It should be >, but since I reworked the cycle to avoid confusion >= works now.
| fromRuleToHorusKeyValue(rule, key, value); | ||
| if (i > HorusConst::MAX_RULE_SIZE_FOR_HORUS) | ||
| break; | ||
| if(fromRuleToHorusKeyValue(rule, key, value)) { |
There was a problem hiding this comment.
What about refactoring a little bit this?
if (!fromRuleToHorusKeyValue(rule, key,value)
break;
That else and return at the end is quite difficult to read.
There was a problem hiding this comment.
Thanks for the suggestion. I agree it is more clear.
| // matching the pattern, at ruleset begin | ||
| const uint8_t MIN_RULE_SIZE_FOR_HORUS = 1; | ||
| const uint8_t MAX_RULE_SIZE_FOR_HORUS = -1; // not used | ||
| const uint8_t MAX_RULE_SIZE_FOR_HORUS = 2048; // not used |
There was a problem hiding this comment.
Is this still not used?
There was a problem hiding this comment.
Forgot to remove this comment.
There was a problem hiding this comment.
I just got a compilation warning here, 2048 is too big for a uint8_t, I really don't know how this is working.
There was a problem hiding this comment.
@sebymiano Isn't something you already fixed on some of your branch?
There was a problem hiding this comment.
I just changed it to uint32_t to remove the compilation warning but I haven't tested it.
I guess it should be ok to change.
There was a problem hiding this comment.
@mauriciovasquezbernal @frisso @sebymiano It was my mistake during code alignment (the code is correct in the firewall, not in iptables).
I've opened a PR for that #163
| // Independently from the final action (ACCEPT or DROP) | ||
| // I have to update the counters | ||
| if (value->ruleID <= 1024) { | ||
| if (value->ruleID <= _MAX_RULE_SIZE_FOR_HORUS) { |
There was a problem hiding this comment.
I think here the test has to be <=.
The range of ruleID is [0, _MAX_RULE_SIZE_FOR_HORUS - 1]
There was a problem hiding this comment.
The test has to be <
There was a problem hiding this comment.
I meant <, this is very easy to get confused :D
Signed-off-by: Matteo Bertrone <m.bertrone@gmail.com>
4e86738 to
cad34be
Compare
|
@mauriciovasquezbernal I force-pushed an updated version according to your comments. |
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
LGTM, thanks Matteo.