Skip to content

Net do#12

Merged
wkz merged 36 commits intomainfrom
net-do
Apr 20, 2023
Merged

Net do#12
wkz merged 36 commits intomainfrom
net-do

Conversation

@troglobit
Copy link
Copy Markdown
Contributor

@troglobit troglobit commented Apr 13, 2023

Progress

  • script/command file naming: foo.init, foo.exit
  • add support for reverse-depends teardown
  • add support for net [up | down] [ifname ...]
  • more test cases, and actual test verification, not just ocular

@troglobit troglobit requested a review from wkz April 13, 2023 10:11
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
When taking down a network setup, it needs to be deconstructed using the
foo.exit rules of the previous generation, and in reverse dependency
order.

This patch adds support for generating the deps when bringing up the
network setup, and saving an rdeps file in that generation, which can
be used later when moving leafs between nodes.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Naming the actions after their executing entity, e.g., foo.sh when it is
executed by /bin/sh, is a tried and true paradigm.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This caused the critical run() function to run action scripts properly.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Calling net prevsiouly meant `net do`, the new separation is to be able
to add `net up` and `net down` commands, with optional interface args.

The idea is to support the same semantics as `ifup -a` of `ifup foo`.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Run with unshare, as so:

    make clean; make; cd test/
    unshare -mrun ./three-independent.sh

This sets up a test directory in /tmp/net, creates three independtent
interface configs for dummy interfaces.  Activates the config with a
call to `net -vd apply`, and then verifies the result using a mix of
ip link/addr and jq magic.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
 - Simplify build process, including cross compilation
 - Add basic test framework, available as `make check`

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Host tools and target are often out of sync, sometimes because we need
to run a newer version of iproute2 with more features.  By installing
tests to target we can still verify basic functionality, provided the
tests verify their dependencies and exit 77 (SKIP).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
For instance, when adding ip command to the ip pipe we need the kernel
to execute those commands before the bridge command pipe is executed.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The net tool traverses the graph and executes the scripts et al in
postorder, i.e., all leaves are evaluated first before the parent's
script is run.  Hence, attaching ports to a bridge or link aggregate
is the responsibility of the parent, not the leaves.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This function is responsible for initializing the necessary files for
the next net generation.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Not really needed unless you're doing changes to the net tool itself.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
With more advanced interface types we cannot use create_iface() to set
up the file structure in new generations.  This commit adds a _data()
function that should be used instead.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The (optional) interface list represent the expected state in the new
generation.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The init_next_gen() function moves us to the next generation, as well as
intialize all data files for expected interfaces in that generation.

However, bridge and lag interfaces have dependendcies that need to be
moved as well.  It is only the test author that knows the expected new
state, so this function only sets up the desired state, without ever
looking at what any previous generation looked like.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
@troglobit troglobit marked this pull request as ready for review April 20, 2023 13:15
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
@wkz wkz merged commit 81c7939 into main Apr 20, 2023
@troglobit troglobit deleted the net-do branch April 24, 2023 06:04
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