Skip to content

Conversation

@benjamreis
Copy link
Contributor

  • New pif helper: get_non_link_ipv6 to get the 1st non link IPv6 of a PIF

  • Use the helper in migrate_receive and get_primary_address used in host evacuation to have a valid IPv6 of the destination host

@benjamreis benjamreis changed the title Filter our link IPv6 when migrating VMs Filter out link IPv6 when migrating VMs Feb 21, 2024
@benjamreis benjamreis force-pushed the filter-out-local-ipv6 branch from 3f588db to 6cc2339 Compare February 21, 2024 15:28
- New pif helper: `get_non_link_ipv6` to get
the 1st non link IPv6 of a PIF

- Use the helper in `migrate_receive` and `get_primary_address`
used in host evacuation to have a valid IPv6 of the destination host

Co-authored-by: Pau Ruiz Safont <psafont@users.noreply.github.com>
Signed-off-by: Benjamin Reis <benjamin.reis@vates.tech>
@benjamreis benjamreis force-pushed the filter-out-local-ipv6 branch from 944e700 to c31eb14 Compare February 21, 2024 16:03
@benjamreis benjamreis requested a review from psafont February 21, 2024 16:07
)
| `IPv6 ->
List.nth_opt (Db.PIF.get_IPv6 ~__context ~self:pif) 0
List.nth_opt (get_non_link_ipv6 ~__context ~pif) 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of this and would prefer to match over this and proper error handling for the [] case (which should never happen but will be difficult to find if it does).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, my understanding is that no IPv6 would result in [""] instead of an empty list so i'm not sure what error could be thrown here.

Copy link
Contributor

Choose a reason for hiding this comment

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

You want throw a failtwith __LOC__ if you think this can never happen. But we want to make it easy to find the location if it does happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After reviewing the code, i'm not sure throwing here is better. For me, the get_non_link helper is used to have reachable IPv6 from the outside and thus can return an empty list in the case there's none.
Then we mimic the IPv4 case above:

    match Db.PIF.get_IP ~__context ~self:pif with "" -> None | ip -> Some ip

And then it's up to the caller to decide if None is an error case or not like here: https://github.com/xapi-project/xen-api/blob/master/ocaml/xapi/xapi_network_attach_helpers.ml#L109-L114

@psafont psafont merged commit 4a2c1bf into xapi-project:master Mar 4, 2024
@psafont psafont deleted the filter-out-local-ipv6 branch March 4, 2024 17:01
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.

3 participants