Commit Graph
331 Commits
Author SHA1 Message Date
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
Zbigniew Jędrzejewski-Szmek 7368e69bc7 Merge pull request #21271 from yuwata/ether-addr-util-helper-functions
ether-addr-util: introduce several helper functions
2021-11-09 10:02:55 +01:00
Yu Watanabe 4eef6fad31 netif-util: rename link_get_type_string() -> net_get_type_string() 2021-11-09 08:24:10 +09:00
Yu Watanabe b5cc5591fa netif-util: move several functions from network-util.[ch] to shared/netif-util.[ch]
These functions are not relevant to sd-network, and only used by
networkd, networkctl, and udevd.
2021-11-09 08:24:10 +09:00
Yu Watanabe de0f157984 ether-addr-util: make hw_addr_is_null() return true also for all zero address
This fixes the following error:
---
systemd-networkd[1449490]: ip6tnl0: Saved hardware address: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
systemd-networkd[1449490]: ip6tnl0: Failed to manage link by its new hardware address, ignoring: File exists
---
2021-11-09 08:20:51 +09:00
Zbigniew Jędrzejewski-Szmek 384c2c3239 Make pager_open() return void 2021-11-03 15:24:56 +01:00
Dimitri Papadopoulos ba669952b2 Typos found by codespell 2021-10-20 22:20:18 +09:00
Yu Watanabe 01afd0f7f5 tree-wide: make format_ifname() or friends return negative errno on failure
Also,
- drop unnecessary +1 from buffer size, as IF_NAMESIZE or IFNAMSIZ
  includes the nul at the end.
- format_ifname() does not update buffer on failure,
- introduces format_ifname_alloc(), FORMAT_IFNAME(), and their friends.
2021-09-29 03:37:06 +09:00
Yu Watanabe 3a2ee8554e sd-lldp: rename sd-lldp.[ch] -> sd-lldp-rx.[ch] 2021-09-27 23:55:11 +09:00
Zbigniew Jędrzejewski-Szmek 04499a70fb Drop the text argument from assert_not_reached()
In general we almost never hit those asserts in production code, so users see
them very rarely, if ever. But either way, we just need something that users
can pass to the developers.

We have quite a few of those asserts, and some have fairly nice messages, but
many are like "WTF?" or "???" or "unexpected something". The error that is
printed includes the file location, and function name. In almost all functions
there's at most one assert, so the function name alone is enough to identify
the failure for a developer. So we don't get much extra from the message, and
we might just as well drop them.

Dropping them makes our code a tiny bit smaller, and most importantly, improves
development experience by making it easy to insert such an assert in the code
without thinking how to phrase the argument.
2021-08-03 10:05:10 +02:00
Zbigniew Jędrzejewski-Szmek 46e23f9a8d tree-wide: add FORMAT_BYTES_FULL() 2021-07-09 11:11:25 +02:00
Yu Watanabe 3b955af56f networkctl: drop unused member in struct VxLanInfo 2021-06-26 08:39:25 +09:00
Dan Streetman 003015af5a networkctl: add field 'Required For Online' 2021-06-24 08:32:21 -04:00
Yu Watanabe 0ac655a63b tree-wide: use sd_device_new_from_ifindex/ifname() 2021-06-12 03:19:08 +09:00
Yu Watanabe f6e491547d netlink: move resolve_ifname() or friends to netlink-util.[ch] 2021-06-12 03:19:08 +09:00