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

Add support for VXLAN tunnels (LP: #1764716) #288

Merged
merged 14 commits into from
Aug 16, 2022
Merged

Conversation

slyon
Copy link
Collaborator

@slyon slyon commented Jul 14, 2022

Description

Adding support for VXLAN tunnels using the sd-networkd and NetworkManager backends.
It builds upon #272 (squashed & rebased), extracted VXLAN bits. Applied on top of #285.
Schema according to (internal) spec FO042.

The first 3 commits e83ea89 6d3597e 02c4f00 are pretty much unrelated to this PR. Those are drive-by fixes that I had been tracking in a separate branch, but the diff is fairly small, so I thought it'd make sense to include them into this PR instead of doing an extra one just for this.

Example:

network:
  ethernets:
    lo:
      addresses: [ 192.168.10.10/32 ]
  tunnels:
    vx1:
      mode: vxlan
      id: 1
      link: lo
      mtu: 8950
      accept-ra: no
      neigh-suppress: true
      mac-learning: false
      port: 4789
      local: 192.168.10.10
  bridges:
    br1:
      interfaces: [ vx1 ]

Checklist

  • Runs make check successfully.
  • Retains 100% code coverage (make check-coverage).
  • New/changed keys in YAML format are documented.
  • (Optional) Adds example YAML for new feature.
  • (Optional) Closes an open bug in Launchpad. LP#1764716

@slyon slyon changed the title Add support for VRF devices (LP: #1764716) Add support for VXLAN tunnels (LP: #1764716) Jul 14, 2022
@slyon slyon force-pushed the slyon/vxlan-support branch 2 times, most recently from 00990fb to 4316e9b Compare July 20, 2022 10:09
@slyon slyon force-pushed the slyon/vxlan-support branch 4 times, most recently from 7bafdf6 to 1b2916b Compare July 28, 2022 12:36
@slyon slyon marked this pull request as ready for review July 28, 2022 12:42
@slyon
Copy link
Collaborator Author

slyon commented Jul 28, 2022

I think this is shaping up nicely for review now. @netdever may I ask for your review, please, as you have been the original author of this work, especially if the neigh-suppress part is still functioning as expected?

I've mostly rebased it on top of the new origin/main branch (like using NetplanTristate types), transformed your work from introducing a new vxlans interface type to using an additional tunnels.mode = vxlan tunnel type and adopted the YAML schema a bit. The new YAML schema is pre-approved according to (internal) spec FO042.

@slyon slyon requested a review from schopin-pro July 28, 2022 12:58
@netdever
Copy link

Awesome work! We're very excited for this. One quick note that at least in your example yml above, the mode parameter is missing, and this will result in an error:

/etc/netplan/50-cloud-init.yaml:57:13: Error in network definition: vx1: missing 'mode' property for tunnel
            id: 1

Regarding neigh-suppress, this must be present under the Bridge heading in the .network file when using systemd-networkd, otherwise it has no effect.

[Bridge]
NeighborSuppression=True

I initially handled this with:

    if (def->neigh_suppress) {
        g_string_append_printf(network, "\n[Bridge]\n");
        g_string_append_printf(network, "NeighborSuppression=%s\n", def->neigh_suppress ? "True" : "False");
    }

@slyon
Copy link
Collaborator Author

slyon commented Aug 1, 2022

@netdever
Copy link

netdever commented Aug 1, 2022

I have verified that neigh-suppress is now working as expected. This all looks good to me!

root@lab1:/home/ubuntu/netplan# cat /run/systemd/network/10-netplan-vx1.network | grep Neighbor -B1
[Bridge]
NeighborSuppression=true
root@lab1:/home/ubuntu/netplan# ip -d link show dev vx1 | grep -Po 'neigh_suppress \w+'
neigh_suppress on

Copy link
Contributor

@schopin-pro schopin-pro left a comment

Choose a reason for hiding this comment

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

Solid work!

I have a few nitpicks here and there, and I'd really like to see the ABI question addressed before approving this PR. ("addressed" can very well be "not a problem, moving on", of course ;-) )

src/parse.c Show resolved Hide resolved
src/parse.c Outdated Show resolved Hide resolved
doc/netplan-yaml.md Show resolved Hide resolved
src/names.c Outdated Show resolved Hide resolved
src/names.h Show resolved Hide resolved
src/parse.c Outdated Show resolved Hide resolved
src/abi.h Outdated Show resolved Hide resolved
src/parse.c Show resolved Hide resolved
src/validation.c Outdated Show resolved Hide resolved
V2: optimize using g_hash_table_lookup_extended()
V2: constant array size, using NETPLAN_INFINIBAND_MODE_MAX_
@slyon
Copy link
Collaborator Author

slyon commented Aug 9, 2022

Solid work!

I have a few nitpicks here and there, and I'd really like to see the ABI question addressed before approving this PR. ("addressed" can very well be "not a problem, moving on", of course ;-) )

Thank you for the quality review!
I rebased on top of origin/main and addressed all of your comments, could you please double-check my "V2" commits (especially 6e8bc56)?

@slyon slyon requested a review from schopin-pro August 9, 2022 15:25
Copy link
Contributor

@schopin-pro schopin-pro left a comment

Choose a reason for hiding this comment

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

Sadly, there's an issue with the bitfield name macro that needs to be solved before merging :/

src/names.c Outdated Show resolved Hide resolved
src/abi.h Outdated Show resolved Hide resolved
src/nm.c Show resolved Hide resolved
slyon and others added 5 commits August 11, 2022 15:47
V2: tightly pack flag names arrays & loop through them incrementally
V3: improve NAME_FUNCTION_FLAGS input validation

flags fixup
V2:
+ handle VXLAN postprocessing (assignment of implicit values) at the end of the
  parsing stage, instead in validation statge
+ use NetplanVxlan private struct, independently of the legacy ABI

Co-authored-by: Lukas Märdian <[email protected]>
V2: use NetplanVxlan private struct, independently of the legacy ABI

Co-authored-by: Lukas Märdian <[email protected]>
V2: use NetplanVxlan private struct, independently of the legacy ABI
@slyon
Copy link
Collaborator Author

slyon commented Aug 11, 2022

TA! I updated 055a6e0 (V3), added 72774d8 and ae582f2

My initial idea was to use link as an universal/multi-purpose field for different types, but I think it makes sense to have the link filed as part of the NetplanVxlan struct and making it exclusive to VXLAN, especially if its only allocated if needed. It's easier to grasp this way, so I implemented that in ae582f2.

Could you have another look, especially about the dirty tracking in handle_vxlan_id_ref?

@slyon slyon requested a review from schopin-pro August 11, 2022 15:35
@slyon
Copy link
Collaborator Author

slyon commented Aug 16, 2022

Could you have another look, especially about the dirty tracking in handle_vxlan_id_ref?

Thinking about it... dirty tracking doesn't make too much sense for the handle_netdef/vxlan_id_ref handlers, does it? Either we have a ID reference set, or not. So the default value is no value. So I think we can probably drop the mark_data_as_dirty() call in both of those handlers.

@schopin-pro
Copy link
Contributor

Considering that the point of the dirty tracking is to be able to differentiate between default value and user input that happens to be the same as the default, the mechanism wouldn't work when said value is null, since the null handling would erase the user input before it hits the parsing code. So there's no need to do dirty tracking there.

Furthermore, does it actually make sense to have a vxlan entry without upstream link?

@slyon
Copy link
Collaborator Author

slyon commented Aug 16, 2022

Furthermore, does it actually make sense to have a vxlan entry without upstream link?

Yes, there is a concept of "Independent" VXLAN interfaces: https://systemd.network/systemd.netdev.html#Independent=

Copy link
Contributor

@schopin-pro schopin-pro left a comment

Choose a reason for hiding this comment

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

LGTM :)

@schopin-pro
Copy link
Contributor

I'd say leave the dirty tracking in place. While I think it isn't used (yet?), it doesn't hurt either and has the merits of being consistent with other data.

@slyon slyon merged commit 0b14ed0 into main Aug 16, 2022
@slyon slyon deleted the slyon/vxlan-support branch August 16, 2022 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants