Commit Graph
345 Commits
Author SHA1 Message Date
Matt Layher 4591eccfc7 network: use varlink for networkctl check_netns_match()
Use varlink to detect networkd's network namespace when executing
networkctl rather than the D-Bus interface.

Signed-off-by: Matt Layher <mdlayher@gmail.com>
2023-12-23 04:25:13 +09:00
Mike Yuan 28bb29cbb4 networkctl: introduce verb mask and unmask
Suggested in https://github.com/systemd/systemd/pull/29928#discussion_r1386626565
2023-12-20 12:46:46 +08:00
Mike Yuan 15fde154f8 networkctl: split out networkctl-config-file.[ch] 2023-12-20 12:46:43 +08:00
Matteo Croce e22ad53d5c dbus-wait-for-jobs: change 'quiet' flag to enum
Change the 'quiet' flag to `bus_wait_for_jobs()` to an enum, so we can
select with more granularity the type of information logged.
2023-12-19 04:52:41 -08:00
Yu Watanabe 0500f755fc networkctl: fix typo
Follow-up for 2b98926f98.
2023-12-10 14:25:33 +09:00
Mike Yuan 2b98926f98 networkctl: introduce --runtime for editing network config under /run/ 2023-12-02 17:04:57 +08:00
Mike Yuan 7050f7419b networkctl: drop one assertion
If there're no existing drop-ins, the assertions
are unnecessarily triggered.
2023-12-02 17:04:57 +08:00
Mike Yuan e9b7408eb9 networkctl: use RET_GATHER more 2023-12-02 17:04:56 +08:00
Lennart Poettering 3cc7a9fd25 udev-util: add generic device_get_{vendor,model}_string() helpers
We chck the same props in various places, add a single implementation of
a call to inquire this.
2023-11-13 16:24:17 +01:00
Zbigniew Jędrzejewski-Szmek 063c838206 analyze/cat-config: add switch to print only "interesting" parts of config files
When looking at configuration, often a user wants to suppress the comments and
just look at the parts that actually configure something, roughly equivalent to
  systemd-analyze cat-config … | rg -v '^(#|;|$)
This switch implements this natively, skipping lines that start with a comment
character or only contain whitespace.

For formats that have section headers, section headers are skipped, if only
followed by stuff that would be skipped. (The last section header is printed
when we're about to print some actual output.)

Note that the caller doesn't know if the format has headers or not. We do format
type detection in pretty-print.c. So the caller only specifies tldr=true|false, and
conf_files_cat() figures out if the format has headers and whether those should
be handled specially.

The comments that show the file name are always printed, even if all of the file
is suppressed.

This is a partial answer to the discussions in
https://github.com/systemd/systemd/pull/28919,
https://github.com/systemd/systemd/pull/29248. If the default config is shown in
config files, the user can conveniently use '--tldr' to show the relevant parts.
2023-10-24 15:59:34 +02:00
Mike Yuan 8fff78a1dd networkctl: use proper vertical table for status
Also modernize macro definition and error handling.
2023-10-10 23:28:28 +01:00
Yu Watanabe 955fc5d8ab tree-wide: add missing sigbus handling 2023-10-07 11:13:27 +02:00
Frantisek Sumsal 8bdece7479 network: fix fetching link properties
This fixes regression introduced in 5a0c810462 with which all requests
for link properties ended up with EINVAL as we kept hitting
the signature_is_single() assert in sd_bus_get_property().
2023-07-18 23:08:19 +02:00
Yu Watanabe 52ee8ecf07 networkctl: urlify captive portal entry 2023-07-06 14:55:58 +09:00
Ronan Pigott e469d2a2ed networkctl: show captive portal configuration in link status 2023-07-02 01:13:43 -07:00
Frantisek Sumsal 5de8264b0d networkctl: fix a potential memory leak
Resolves: CID#1512516
Follow-up to 96bab8fd63.
2023-05-23 16:50:18 +09:00
Mike Yuan 96bab8fd63 networkctl: add verb edit and cat to operate on network configs
This adds two verbs, edit and cat, to networkctl for
operating on network configs (namely .network, .netdev
and .link files). Specially, if the config name is
prefixed by @, it will be treated as network interface
name, and operations will be performed on config files
associated with the link.

Closes #26906
2023-05-21 15:48:57 +08:00
Mike Yuan d260875f78 networkctl: mark some verbs as online only 2023-05-21 15:46:25 +08:00
Mike Yuan 8dfc3bf597 networkctl: fix a typo in log message 2023-05-21 15:46:25 +08:00
Mike Yuan 43449ca327 networkctl: add missing asserts 2023-05-21 15:46:25 +08:00
Mike Yuan 6c6930077c networkctl: check netns only if networkd is running 2023-05-21 15:46:22 +08:00
Mike Yuan 5a0c810462 networkctl: use sd_bus_get_property 2023-04-01 21:51:07 +08:00
Mike Yuan 61c84edff8 networkctl: style improvements 2023-04-01 21:51:07 +08:00
Mike Yuan 7db07767d5 networkctl: use FOREACH_ARRAY more 2023-04-01 20:47:49 +08:00
Mike Yuan 445f0d8b47 networkctl: acquire bus only when necessary 2023-04-01 19:56:26 +08:00
Daan De Meyer a2640646f1 network: Show network and link file dropins in networkctl status
Fixes #24428
2023-01-12 13:44:52 +09:00
Zbigniew Jędrzejewski-Szmek 254d1313ae tree-wide: use -EBADF for fd initialization
-1 was used everywhere, but -EBADF or -EBADFD started being used in various
places. Let's make things consistent in the new style.

Note that there are two candidates:
EBADF 9 Bad file descriptor
EBADFD 77 File descriptor in bad state

Since we're initializating the fd, we're just assigning a value that means
"no fd yet", so it's just a bad file descriptor, and the first errno fits
better. If instead we had a valid file descriptor that became invalid because
of some operation or state change, the other errno would fit better.

In some places, initialization is dropped if unnecessary.
2022-12-19 15:00:57 +01:00
Zbigniew Jędrzejewski-Szmek d6b4d1c7c4 basic: move version() to build.h+c 2022-11-08 13:41:14 +01:00
Yu Watanabe f1d07d83ab networkctl: use table_add_string_line() at one more place 2022-09-27 10:41:21 +09:00
Yu Watanabe 8f60c998ab networkctl: handle all errors in sd_network_link_get_setup_state() as "unmanaged"
We have already ignored all errors in other fields.
2022-09-27 10:41:13 +09:00
Yu Watanabe f8d7c0c55e networkctl: re-order entries in status command
Also fixes "Speed:" field, which may show empty value.
2022-09-23 11:20:26 +09:00
Yu Watanabe 3874765735 networkctl: use "-" for empty LLDP entries 2022-09-23 10:39:42 +09:00
Zbigniew Jędrzejewski-Szmek c8b62cf600 shared/format-table: use enum instead of Table.empty_string
All users were setting this to some static string (usually "-"), so let's
simplify things by not doing strdup, but instead limiting callers to a fixed
set of values. In preparation for the next commit, the function is renamed from
"empty" to "replacement", because it'll be used for more than empty fields. I
didn't do the whole string-table setup, because it's all used internally in one
file and this way we can immediately assert if an invalid value is passed in.

Some callers were (void)ing the error, others were ignoring it, and others
propagating. It's nicer to remove the boilerplate.
2022-09-22 10:16:05 +02:00
Zbigniew Jędrzejewski-Szmek 5515f2169c networkctl: use "-" for empty fields
This looks nicer. Some fields were already using "-" as fallback, e.g. Speed,
so this makes things more consistent too.
2022-09-21 14:48:28 +02:00
Jan Janssen c0f86d66f3 tree-wide: Use correct format specifiers
gcc will complain about all these with -Wformat-signedness.
2022-08-30 12:03:28 +02:00
Zbigniew Jędrzejewski-Szmek 24c0f38591 sd-netlink: rename sd_netlink_message_request_dump to sd_netlink_message_set_request_dump 2022-08-19 11:52:25 +02:00
Zbigniew Jędrzejewski-Szmek 78cca583fe sd-netlink: rename sd_netlink_inc_rcvbuf → sd_netlink_increase_rxbuf
We have RxBufferSize= and TxBufferSize= in .link files. Let's use the same
abbreviation here. OTOH, "inc" could be short for "increment" or "increase",
let's avoid that.
2022-06-30 11:02:13 +02:00
Marc Kleine-Budde 25ed7633b1 networkctl: fix output of "status": replace "Queue Length" by "Number of Queues"
Commit 0307afc681 ("networkctl: add support to display Transmit/Recieve queue
length (#12633)") added the display of the number of RX and TX Queues to the
output of `networkctl status $DEV`. However the row description says "Queue
Length".

This patch fixes the output by replacing "Queue Length" by "Number of Queues".

Fixes: 0307afc681 ("networkctl: add support to display Transmit/Recieve queue length (#12633)")
2022-06-18 10:44:42 +09:00
Zbigniew Jędrzejewski-Szmek 94a779628a networkctl: assume that we can always print local networking addresses
IN6_ADDR_TO_STRING(…) always returns something, so we can simplify the code a
lot. Also, let's not do step-wise concatenation, but instead handle everything
with one str_extendf() call.
2022-06-06 09:52:52 +02:00
Yu Watanabe 1246d09705 networkctl: show error message provided through dbus
Prompted by #23416.
2022-05-21 15:01:09 +01:00
Yu Watanabe 05e022a913 networkctl: fix units for bond parameters
Fixes RHBZ#2086166 (https://bugzilla.redhat.com/show_bug.cgi?id=2086166).
2022-05-17 22:35:18 +09:00
Simon Ellmann 27cd31c0b2 networkctl: obey --full with lldp command
Do not ellipsize output when -l or --full is handed to networkctl lldp.

Fixes #22806.
2022-04-15 17:51:26 +02:00
Yu Watanabe de010b0b2e strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
2022-03-19 08:33:33 +09:00
Yu Watanabe 430f07f4f8 networkctl: show netdev kind 2022-02-17 21:15:27 +09:00
Zbigniew Jędrzejewski-Szmek 100433e05a networkctl: use xsprintf a bit more 2022-01-14 16:24:27 +09:00
Zbigniew Jędrzejewski-Szmek d821e40ca9 networkctl: open the bus just once
We'd connect to the bus twice: the first time to check networkd namespace,
and then the second time to do the deed we were asked to do. It's nicer
to open the bus just once, for efficience and also to avoid the open call
in all functions.

An ASSERT_PTR helper is added:
- sd_bus *bus = userdata;
  ...
- assert(bus);
+ sd_bus *bus = ASSERT_PTR(userdata);
  ...

It can be used in other place too, but I'm leaving that for a later
refactoring.
2022-01-14 16:24:04 +09:00
Zbigniew Jędrzejewski-Szmek 718ca77232 shared/json: use int64_t instead of intmax_t
We were already asserting that the intmax_t and uintmax_t types
are the same as int64_t and uint64_t. Pretty much everywhere in
the code base we use the latter types. In principle intmax_t could
be something different on some new architecture, and then the code would
fail to compile or behave differently. We actually do not want the code
to behave differently on those architectures, because that'd break
interoperability. So let's just use int64_t/uint64_t since that's what
we indend to use.
2021-11-18 01:34:31 +01:00
Yu Watanabe 49c351a8ac networkctl: read permanent hardware address from netlink message 2021-11-13 08:53:33 +09:00
Yu Watanabe ed9fa69f1c ethtool-util: introduce ethtool_get_permanent_hw_addr()
And replaces all ethtool_get_permanent_macaddr() with it.
2021-11-13 08:53:33 +09:00
Yu Watanabe 57ae8cd812 networkctl: introduce dump_hw_address() 2021-11-13 08:53:33 +09:00