Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt firewall-port to IPv6 #6099

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

benjamreis
Copy link
Contributor

No description provided.

@benjamreis benjamreis force-pushed the ipv6-firewall-port branch 5 times, most recently from 2b3f548 to 0291690 Compare November 5, 2024 10:05
Copy link
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

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

This generally looks good; would like @rosslagerwall to take a look at the handling o IP tables.

)
)
in
match pifs with [] -> raise Not_found | pif :: _ -> pif
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not comfortable with raising Not_found. This function should return an option and force the caller to handle this or raise a meaningful error here.

Copy link
Member

Choose a reason for hiding this comment

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

List.nth_opt pifs 0 would do this

@lindig
Copy link
Contributor

lindig commented Nov 11, 2024

@benjamreis any comments on our comments?

@benjamreis
Copy link
Contributor Author

@benjamreis any comments on our comments?

Hi yeah sorry - I was trying to apply your comments and tst them locally but I'm hitting wall after wall.
I'm not sure what to do when there's no mangamnt address to determine the IP family.

I'll rework the shell option handling but i hav a lot on my plate so I'm often interrupted during my development. I'll try to rcommit something asap

@benjamreis
Copy link
Contributor Author

What if instead getting the management address type from th XAPI I'd read in xnsource-inventory?

@benjamreis benjamreis force-pushed the ipv6-firewall-port branch 4 times, most recently from 9c0f446 to 962e8ce Compare November 13, 2024 09:05
@benjamreis
Copy link
Contributor Author

I don't understand the failure of the tests. Looks unrelated to my changes - should I rebase on a newer master? 🤔

@lindig
Copy link
Contributor

lindig commented Nov 13, 2024

Yes, always stay on top of master

Signed-off-by: Benjamin Reis <[email protected]>
@lindig lindig marked this pull request as ready for review November 14, 2024 09:12
@gthvn1
Copy link
Contributor

gthvn1 commented Nov 18, 2024

I don't understand the failure of the tests. Looks unrelated to my changes - should I rebase on a newer master? 🤔

👋, it is really strange. I tried to understand the issue and I noticed something that might help pinpoint the issue:
When I modify the function get_management_iface_primary_address_type to avoid calling the Xapi inventory lookup the test passes. It seems that the problem is tied to the addition of this lookup:

+let get_management_iface_primary_address_type =
+  Record_util.primary_address_type_of_string
+    (Xapi_inventory.lookup Xapi_inventory._management_address_type)

Using strace, I observed that with your patch, the test _build/default/ocaml/tests/test_bounded_psq.exe attempts to access /etc/xensource-inventory. After this, there are attempts to access temporary files like /etc/435s2f.tmp, which results in the reported error: Fatal error: exception Sys_error("/etc/128f1f.tmp: Permission denied").

Without your patch, these file accesses don’t occur during the test (still spotted using strace). This suggests that something related to the inventory lookup might not be mocked correctly in the test environment.

I don't understand enough how the tests are setup and why the lookup is causing this behavior but I hope my observations help clarify the issue or evoke some ideas from someone more familiar with the test setup!

Let me know if there is anything I can do to test further as I can run tests locally now.

@benjamreis
Copy link
Contributor Author

benjamreis commented Nov 19, 2024

It seems I'm missing a mock of the inventory file somewher for the tests but for the life of me I can't find anything... any leads would be very welcomed 😇

Beside that we noticed that the rules in iptables are different from the ones in ip6tables:

  • iptables uses ctstate: ACCEPT tcp anywhere anywhere ctstate NEW tcp dpt:http
  • ip6tables uses state: ACCEPT tcp anywhere anywhere state NEW tcp dpt:http

and so when calling firewall-port for ipv6 the rules is not removed because the chain given is with ctstate... and hen opening the port we get 2 lines with ctstate and state... so my question is should change the rule given to ip6tables in ipv6 or should the default ip6 rules should be migrated towards ctstate as well?

Thx for the help 🙏

@lindig
Copy link
Contributor

lindig commented Nov 20, 2024

I believe in the Git test environment /etc/xensource-inventory does not exist, hence Xapi_inventory.lookup Xapi_inventory._management_address_type does not work. @psafont This file only exists in a deployment. So it's probably necessary to adjust the test.

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