Tobias Waldekranz and Joachim Wiberg
dcf3c5fe97
confd: Infer the interface type for common patterns
...
When a new interface is create, but the type is not specified, try to
infer the type from the interface name.
2023-04-21 19:03:15 +02:00
Tobias Waldekranz and Joachim Wiberg
54200eaba9
confd: Add wrapper for sr_set_item
...
This allows the xpath to be built using format string.
2023-04-21 19:03:15 +02:00
Tobias Waldekranz and Joachim Wiberg
2259e108e4
confd: Rename srx_set_item -> lydx_new_path
...
Since this function wraps lyd_new_path.
This allows us to write a wrapper for sr_set_item, using the expected
name.
2023-04-21 19:03:15 +02:00
Tobias Waldekranz and Joachim Wiberg
69d6bc6942
confd: Fix some build warnings
2023-04-21 19:03:15 +02:00
Tobias Waldekranz and Joachim Wiberg
62e4a733d0
confd: Honor CFLAGS coming in from configure
...
This makes it easy to create unoptimized debug builds, for example.
2023-04-21 19:03:15 +02:00
Tobias Waldekranz and Joachim Wiberg
7afc650bcf
confd: Fix use of uninitialized value
2023-04-21 19:03:15 +02:00
Tobias Waldekranz and Joachim Wiberg
9969987347
confd: Skip extraneous calls to sr_unsubscribe
...
core.c will always take care of this if any initialization fails.
2023-04-21 19:03:15 +02:00
Joachim Wiberg and Tobias Waldekranz
81c7939a0d
src/net: update docs with new admin-state control file
...
Signed-off-by: Joachim Wiberg <troglobit@gmail.com >
2023-04-20 21:14:54 +02:00
Joachim Wiberg and Tobias Waldekranz
cd00a3d2be
package/net: new package
...
Signed-off-by: Joachim Wiberg <troglobit@gmail.com >
2023-04-20 21:14:54 +02:00
Joachim Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias Waldekranz
f2472d6474
src/net: minor cleanup
...
Signed-off-by: Joachim Wiberg <troglobit@gmail.com >
2023-04-20 21:14:54 +02:00
Joachim Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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 Wiberg and Tobias 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