Skip to content

pcn-iptables: fix horus module#151

Merged
frisso merged 1 commit intomasterfrom
pr/fix_iptables_horus
Jun 13, 2019
Merged

pcn-iptables: fix horus module#151
frisso merged 1 commit intomasterfrom
pr/fix_iptables_horus

Conversation

@mbertrone
Copy link
Copy Markdown
Contributor

  • avoid incompatibility with conntrack rules
  • increase horus max size
  • use attribute packed to avoid memory alignment issues

@mbertrone mbertrone requested a review from a team as a code owner June 11, 2019 07:50
@mbertrone mbertrone force-pushed the pr/fix_iptables_horus branch from ea7aca6 to 4e86738 Compare June 11, 2019 13:54
Comment thread src/services/pcn-iptables/src/Utils.cpp Outdated
for (auto const &rule : rules) {
i++;
fromRuleToHorusKeyValue(rule, key, value);
if (i > HorusConst::MAX_RULE_SIZE_FOR_HORUS)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be >=?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be >, but since I reworked the cycle to avoid confusion >= works now.

Comment thread src/services/pcn-iptables/src/Utils.cpp Outdated
fromRuleToHorusKeyValue(rule, key, value);
if (i > HorusConst::MAX_RULE_SIZE_FOR_HORUS)
break;
if(fromRuleToHorusKeyValue(rule, key, value)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I agree it is more clear.

Comment thread src/services/pcn-iptables/src/defines.h Outdated
// 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still not used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove this comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just got a compilation warning here, 2048 is too big for a uint8_t, I really don't know how this is working.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebymiano Isn't something you already fixed on some of your branch?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here the test has to be <=.
The range of ruleID is [0, _MAX_RULE_SIZE_FOR_HORUS - 1]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test has to be <

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant <, this is very easy to get confused :D

Signed-off-by: Matteo Bertrone <m.bertrone@gmail.com>
@mbertrone mbertrone force-pushed the pr/fix_iptables_horus branch from 4e86738 to cad34be Compare June 13, 2019 13:55
@mbertrone
Copy link
Copy Markdown
Contributor Author

@mauriciovasquezbernal I force-pushed an updated version according to your comments.
Thanks for reviewing it.

Copy link
Copy Markdown
Contributor

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Matteo.

@frisso frisso merged commit 0c26a38 into master Jun 13, 2019
@frisso frisso deleted the pr/fix_iptables_horus branch June 14, 2019 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants