Commit Graph
168 Commits
Author SHA1 Message Date
Tobias WaldekranzandJoachim Wiberg 3ae4e1d9ca confd: Use printf attribute on relevant helpers
This let's the compiler catch format-specifier-to-argument mismatches.
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 31d5dbda8c confd: Split out libyang extensions to separate file 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg a79c6ec06c confd: Remove temporary interface configuration
This will be replaced by the "net do" implementation
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 80d9312e36 confd: Infer type when configuring physical interfaces 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg ed41b621d9 confd: Fix -Wformat-security warning 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg f40841e5e7 confd: Consistently use srx_require_modules
This allows confd to start without errors when modules are already
loaded.
2023-05-12 14:24:41 +02:00
Richard AlpeandJoachim Wiberg def761b067 src/confd: add basic user authentication support
This patch introduces basic user authentication support via sysrepo.

Namely it adds:
* The ability to create or delete a UNIX user.
* The ability to set or delete a UNIX user password.

The password needs to be hashed and in a UNIX shadow format, such as
"$ALG$SALT$HASH". We want to avoid the handling of clear text
passwords as much as possible. In the meanwhile, passwords
can be generated in the infix shell using mkpasswd.

CLI Examples:

Add a user:
configure> set system authentication user foo

Delete a user:
configure> delete system authentication user foo

Set a user password:
configure> set system authentication user foo password ...

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-05-10 09:50:53 +02:00
Richard AlpeandJoachim Wiberg 53ad138854 sys/confd: expose systemv functions in new header
Expose systemv() and systemv_silent() to confd code that includes
core.h or systemv.h explicitly.

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-05-10 09:50:53 +02:00
Joachim Wiberg 941a2d85aa src/confd: system() replacement without /bin/sh intermediary
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-30 19:49:27 +02:00
Joachim WibergandTobias Waldekranz 05d49f6cfc src/confd: set NETCONF specific motd as default
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-27 09:59:35 +02:00
Joachim WibergandTobias Waldekranz 461599e502 src/confd: hackish w/a to get 'initctl reload' for ietf-interfaces
This is very ugly, what we really want is that the commit_done_hook()
runs when *all* DONE events have been processed in all models.  The
side-effect of this hack is that the callback is run twice, both for
ietf-systm and ietf-interfaces if both are modified.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-27 09:59:35 +02:00
Joachim WibergandTobias Waldekranz 8b9504ffa5 src/confd: augment ietf-ip with an 'autoconf' setting also for IPv4
This patch adds a first Infix model to augment ietf-ip with a node,
similar to the IPv6 'autoconf' node, also for IPv4.  For IPv6 the
autoconf feature comes built-in, for IPv4 it is defined in RFC3927.

The setting behaves the same as for IPv6, but in the case of IPv4 we
enable avahi-autoipd per interface to acquire the 169.254/16 address.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-27 09:59:35 +02:00
Joachim WibergandTobias Waldekranz ae62c20d40 src/confd: minor, spellcheck
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-27 09:59:35 +02:00
Tobias WaldekranzandJoachim 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 WaldekranzandJoachim 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 WaldekranzandJoachim 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 WaldekranzandJoachim Wiberg 69d6bc6942 confd: Fix some build warnings 2023-04-21 19:03:15 +02:00
Tobias WaldekranzandJoachim 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 WaldekranzandJoachim Wiberg 7afc650bcf confd: Fix use of uninitialized value 2023-04-21 19:03:15 +02:00
Tobias WaldekranzandJoachim 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 WibergandTobias 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 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