Commit Graph
147 Commits
Author SHA1 Message Date
Joachim WibergandTobias Waldekranz cd00a3d2be package/net: new package
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 64804bee5d src/net: add missing deps when moving between generations
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 1c99e92312 src/net: finalize bridge-lag.sh test, add step remove; vlan1 and br0
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 3edd4c7dff src/net: let init_next_gen init new generation with ifaces
The (optional) interface list represent the expected state in the new
generation.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz c99b5c659a src/net: add test to verify moving port from lag to bridge
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 61c5724da7 src/net: update basic bridge test with new create_bridge() API
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz afb82a52e4 src/net: test; factor out state file creation from create_iface()
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 19ed88ac9e src/net: silence noisy "skipping" debug logs for missing scripts
Not really needed unless you're doing changes to the net tool itself.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 9aeb35c73b src/net: rename helper fn create_ng -> init_next_gen
This function is responsible for initializing the necessary files for
the next net generation.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 4c7813f996 src/net: new test, advanced bridge with lag and a top VLAN interface
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 7945207989 src/net: fix interface creation/attach order in generation generator
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 45c6b704f9 src/net: must close each pipe before exectuing the next pipe action
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 2de8ff052d src/net: factor out pipe identification and debug each piped command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz e6834c5db6 src/net: new test, basic bridge
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz a26dd9c19f src/net: install tests to target /usr/share/net
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz f84b4803d9 src/net: fix bugs in 'net up|down' uncovered by first test
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 48fba80baf src/net: finalize first test, three indep ifaces in two generations
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 6b3eaa05e5 src/net: refactor test into lib.sh and <test>.sh
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz f180bcae24 src/net: convert to GNU Configure & Build system
- Simplify build process, including cross compilation
 - Add basic test framework, available as `make check`

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz da56f8d653 src/net: first automated test case, run with unshare
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 0f337a4b13 src/net: increased debugging of basics
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz ad1c3fb777 src/net: 'do' is a reserved keyword in shell scripts add 'apply' too
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 0ec3448858 src/net: refactor, reuse existing linked list also for 'do' command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 997e536081 src/net: add support for acting as a multicall binary (ifup/ifdown)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 75a1b231da src/net: add commands; do, up/down with optional ifname(s)
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 32db1fe3d0 src/net: refactor filtering of forbidden names
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz f2472d6474 src/net: minor cleanup
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz a80a8eeee5 src/net: fix bug in savedep(), trashed interface path argument
This caused the critical run() function to run action scripts properly.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 9a895dcd47 src/net: fix bug in test, lag0 remains a dep for br0 even in gen 1
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 6eb6324477 src/net: rename action scripts as per review
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 47c3448774 src/net: calculate and run teardown in reverse dependency order
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>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz 0f7d931541 src/net: new test, also drop lo and use same interfaces as in figure
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim WibergandTobias Waldekranz a2fbc9e2f8 src/net: ovarhaul script naming ip-link.up/ip-addr.up -> ip.init etc
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-20 21:14:54 +02:00
Joachim Wiberg dfda11f9ce Follow-up to 025a877, import new iana-if-type version
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg 15010acc3a src/confd: set default loopback addresses
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg 4f09f2b51e src/confd: refactor, simplify ietf-system:system-state
We now have our own srx_set_item() that hides a lot of the complexity.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg a8227a3ab9 src/confd: standardize on 'fail:' as cleanup label on failure
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg 4fe6a2aba7 src/confd: initial operational data support for ietf-interfaces
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg 5fe77fdbee src/confd: add missing free() of data from lyd_print_mem()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg 34d8cf2fdb src/confd: add missing calls to release context in ieft-system
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg a061242119 src/confd: minor refactor, add convenience macro REGISTER_OPER()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg f080ebd341 src/confd: add support for ipv6 in ietf-interfaces
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg 36d4e1b92b src/confd: refactor srx_val.c to use sr_get_items() to silence log
Calling sr_get_time() for an xpath that has no data causes sysrepo to
always log the access as an error.  With sr_get_items() it is left to
the callee to determine if the missing data should cause an error.

This patch is a refactor that silences the syslog message and also
fixes one or tow memory leaks.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg fdb8e56461 src/confd: fix invalid xpath, 'enabled' not available per address
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg abe8ecb3d3 src/confd: fix invalid use of fopenf() in write*f() wrappers
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg dabfe7bc20 src/confd: drop developer debug messages
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg 2e73d643ed src/confd: add support for ietf-ip:ipv4/forwarding
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg a7306d0c06 src/confd: refactor, add first file function helper: writesf()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg 8296f75893 src/confd: optionally use netmask instead of prefix-length
Some users still prefer the old netmask style to set up an interface.
This patch enables the corresponding model feature and checks for a
netmask only if prefix-length is unset.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00
Joachim Wiberg ac0b0d520f src/confd: refactor srx_get_bool() to create srx_enabled()
All value functions, except the new srx_enabled(), now return clear
error indication, with the value as a separate argument.

The srx_enabled() predicate function is for cases where the default
value is disabled and code checks enable a subsystem or flag.  I.e.,
when an error can safely be returned as 'false'.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-17 14:09:24 +02:00