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 static & lacp link aggragetes #873

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Add support for static & lacp link aggragetes #873

wants to merge 15 commits into from

Conversation

troglobit
Copy link
Contributor

Description

WIP

Checklist

Tick relevant boxes, this PR is-a or has-a:

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe):

@troglobit troglobit force-pushed the lag branch 2 times, most recently from bbec2cb to 2a39a38 Compare December 16, 2024 14:20
Copy link
Contributor

@wkz wkz left a comment

Choose a reason for hiding this comment

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

Superb! 🔥

Comment on lines +1 to +8
#!/bin/sh
# Initialize speed/duplex of virtio interfaces
# For virtual test systems (lacp tests)

ifaces=$(ip -d -json link show | jq -r '.[] | select(.parentbus == "virtio") | .ifname')
for iface in $ifaces; do
ethtool -s "$iface" speed 1000 duplex full
done
Copy link
Contributor

Choose a reason for hiding this comment

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

Very interesting! 👀

Wasn't this the whole raison d'être for the ethernet/etherlike split?

Autoneg-support can be detected using ethtool, so that should not be a problem to avoid on these interfaces. Since we can set the speed, shouldn't we get rid of etherlike all together?

Then you could set the speed to whatever you want in the config instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I honestly don't remember all the details for the split, put this thing in here honestly as green goblin for you 🤣

But you're right, and it brushed my mind when I did this. I can have a look at that later as a separate cleanup task. Adding an issue as reminder to self rn.

src/confd/yang/infix-if-lag.yang Outdated Show resolved Hide resolved
src/confd/yang/infix-if-lag.yang Outdated Show resolved Hide resolved
src/confd/yang/infix-if-lag.yang Outdated Show resolved Hide resolved
src/confd/yang/infix-if-lag.yang Outdated Show resolved Hide resolved
src/confd/yang/infix-if-lag.yang Outdated Show resolved Hide resolved
Comment on lines +616 to +595
err = lag_gen_ports(net, dif, cif, ip);
if (err)
goto err_close_ip;

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move this, along with bridge_port_gen(), to a netdag_gen_iface_lower() or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly. Need to zoom out on the whole refactor you've made and take it all in, for real. There's also a master detection we could improve on a bit at the same time.

Comment on lines +78 to +82
/* infix-if-lag.c */
int lag_gen_ports(struct dagger *net, struct lyd_node *dif, struct lyd_node *cif, FILE *ip);
int netdag_gen_lag(sr_session_ctx_t *session, struct dagger *net, struct lyd_node *dif,
struct lyd_node *cif, FILE *ip, int add);

Copy link
Contributor

Choose a reason for hiding this comment

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

To be consistent with the bridge code (after the refactor), I suggest lag_gen() and lag_port_gen()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, yep!

Comment on lines +61 to +66
fprintf(ip, "link set %s down master %s\n", ifname, lagname);

/* We depend on lag to exist before we can set master ... */
err = dagger_add_dep(net, ifname, lagname);
if (err)
ERROR("%s: unable to add dep to %s", ifname, lagname);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just like when detaching the port from the LAG, attaching needs to happen in the init action of the LAG, not in the LAG port. Have a look att gen_join_leave() in the new infix-if-bridge-port.c - I think you can almost copy-paste it to use for LAG ports as well.

Then: you can reverse the dependency. I.e., the LAG depends on all of its ports being setup before we can create the LAG itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahaa, now I finally understand what you were talking about last week! Yeah, that makes much more sense when the lag does the attaching. 👍

Comment on lines +153 to +197
if (add) {
struct lyd_node *node, *cifs;

cifs = lydx_get_descendant(lyd_parent(cif), "interfaces", "interface", NULL);
LYX_LIST_FOR_EACH(cifs, node, "interface")
err += lag_gen_ports(net, NULL, node, ip);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not taken care of by netdag_gen_iface()'s call to lag_gen_ports()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not when netdag_must_del() is triggered, this is the passage when we re-attach unmodified ports when recreating a lag that has had its mode changed.

But you're half right, at initial creation when the lag members are modified as well, this will cause duplicate setups. That's why the code must be idempotent, including the dagger changes I made. I could not see any other way of fixing this chicken and egg problem.

I'll add a comment about this in the code here for future readers.

The speed/duplex of a virtio interface is not eenforced in any way.  The
driver initializes them to unknown/unkown:

https://github.com/torvalds/linux/blob/dccbe2047a5b0859de24bf463dae9eeea8e01c1e/drivers/net/virtio_net.c#L5375-L5381

It is however possible to set them since there are kernel subsystems
that rely on them, e.g., miimon in the bond driver, which in turn is
required for use with the 802.3ad (lacp) mode.

If we do not initialize speed/duplex the miimon will complain in the log
on virtual test systems every second:

Dec 13 22:34:08 laggy kernel: lag0: (slave e1): failed to get link speed/duplex

Signed-off-by: Joachim Wiberg <[email protected]>
Signed-off-by: Joachim Wiberg <[email protected]>
Some callbacks may run twice, e.g., lag_gen_ports().  Check if the link
already exists, and is the same, then we can exit silently.  However, in
case the link exists and does *not* point to the same target, we log an
error with current target for the post mortem.

Signed-off-by: Joachim Wiberg <[email protected]>
This commit adds two SVGs for previewing the virtual test topologies.

quad: fix a lot of copy-paste mistakes, rename nodes and ports to their
      correct names.  Replace shell comments with C++ style comments,
      not all tools, e.g., dotty, support shell comments.  The neato
      absolute positioning has also been fixed to make it possible to
      see all the edges, to facilitate this the used ports have been
      swapped around a abit.  Colors are used according to the schema
      agreed on for tests.  Finally, a second link for lag tests have
      been added between dut2 and dut3.

dual: add coloring similar to quad.

Signed-off-by: Joachim Wiberg <[email protected]>
Verify connectivity from host to the second DUT via the first, over a
link aggregate.  The lag starts in static mode and then changes to an
LACP aggregate.  This verifies not just basic aggregate functionality,
but also changing mode, which is quite tricky to get right.

Signed-off-by: Joachim Wiberg <[email protected]>
 - YANG model, fold in groupings, add enums
 - Add LACP system priorty, actor/partner key, partner mac, etc.

Signed-off-by: Joachim Wiberg <[email protected]>
When reading lag status, like LACP actor system prio, port key,
etc., we need CAP_NET_ADMIN.  See net/bonding/bond_netlink.c

Signed-off-by: Joachim Wiberg <[email protected]>
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.

2 participants