chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
udev: strings in C are NUL-terminated anyway, no need to add a second NUL...
[elogind.git]
/
src
/
network
/
networkctl.c
diff --git
a/src/network/networkctl.c
b/src/network/networkctl.c
index 2a7a1daf0f3b26ed05aa8071fe322b9bf55e9c9e..53516638dcc2f4d62d78cb0d6d37d8fb7e2a5ce3 100644
(file)
--- a/
src/network/networkctl.c
+++ b/
src/network/networkctl.c
@@
-190,16
+190,12
@@
static int list_links(char **args, unsigned n) {
pager_open_if_enabled();
r = sd_rtnl_open(&rtnl, 0);
pager_open_if_enabled();
r = sd_rtnl_open(&rtnl, 0);
- if (r < 0) {
- log_error("Failed to connect to netlink: %s", strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to connect to netlink: %m");
udev = udev_new();
udev = udev_new();
- if (!udev) {
- log_error("Failed to connect to udev: %m");
- return -errno;
- }
+ if (!udev)
+ return log_error_errno(errno, "Failed to connect to udev: %m");
r = sd_rtnl_message_new_link(rtnl, &req, RTM_GETLINK, 0);
if (r < 0)
r = sd_rtnl_message_new_link(rtnl, &req, RTM_GETLINK, 0);
if (r < 0)
@@
-210,10
+206,8
@@
static int list_links(char **args, unsigned n) {
return rtnl_log_create_error(r);
r = sd_rtnl_call(rtnl, req, 0, &reply);
return rtnl_log_create_error(r);
r = sd_rtnl_call(rtnl, req, 0, &reply);
- if (r < 0) {
- log_error("Failed to enumerate links: %s", strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to enumerate links: %m");
if (arg_legend)
printf("%3s %-16s %-18s %-11s %-10s\n", "IDX", "LINK", "TYPE", "OPERATIONAL", "SETUP");
if (arg_legend)
printf("%3s %-16s %-18s %-11s %-10s\n", "IDX", "LINK", "TYPE", "OPERATIONAL", "SETUP");
@@
-294,8
+288,8
@@
static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
_cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL, *reply = NULL;
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
char devid[2 + DECIMAL_STR_MAX(int)];
_cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL, *reply = NULL;
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
char devid[2 + DECIMAL_STR_MAX(int)];
- _cleanup_free_ char *t = NULL;
- const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL;
+ _cleanup_free_ char *t = NULL
, *network = NULL
;
+ const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL
, *link = NULL
;
const char *on_color_operational, *off_color_operational,
*on_color_setup, *off_color_setup;
struct ether_addr e;
const char *on_color_operational, *off_color_operational,
*on_color_setup, *off_color_setup;
struct ether_addr e;
@@
-322,10
+316,8
@@
static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
return rtnl_log_create_error(r);
r = sd_rtnl_call(rtnl, req, 0, &reply);
return rtnl_log_create_error(r);
r = sd_rtnl_call(rtnl, req, 0, &reply);
- if (r < 0) {
- log_error("Failed to query link: %s", strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to query link: %m");
r = sd_rtnl_message_link_get_ifindex(reply, &ifindex);
if (r < 0)
r = sd_rtnl_message_link_get_ifindex(reply, &ifindex);
if (r < 0)
@@
-384,6
+376,7
@@
static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
link_get_type_string(iftype, d, &t);
if (d) {
link_get_type_string(iftype, d, &t);
if (d) {
+ link = udev_device_get_property_value(d, "ID_NET_LINK_FILE");
driver = udev_device_get_property_value(d, "ID_NET_DRIVER");
path = udev_device_get_property_value(d, "ID_PATH");
driver = udev_device_get_property_value(d, "ID_NET_DRIVER");
path = udev_device_get_property_value(d, "ID_PATH");
@@
-396,11
+389,16
@@
static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
model = udev_device_get_property_value(d, "ID_MODEL");
}
model = udev_device_get_property_value(d, "ID_MODEL");
}
+ sd_network_link_get_network_file(ifindex, &network);
printf("%s%s%s %i: %s\n", on_color_operational, draw_special_char(DRAW_BLACK_CIRCLE), off_color_operational, ifindex, name);
printf("%s%s%s %i: %s\n", on_color_operational, draw_special_char(DRAW_BLACK_CIRCLE), off_color_operational, ifindex, name);
- printf(" Type: %s\n"
+ printf(" Link File: %s\n"
+ "Network File: %s\n"
+ " Type: %s\n"
" State: %s%s%s (%s%s%s)\n",
" State: %s%s%s (%s%s%s)\n",
+ strna(link),
+ strna(network),
strna(t),
on_color_operational, strna(operational_state), off_color_operational,
on_color_setup, strna(setup_state), off_color_setup);
strna(t),
on_color_operational, strna(operational_state), off_color_operational,
on_color_setup, strna(setup_state), off_color_setup);
@@
-441,16
+439,12
@@
static int link_status(char **args, unsigned n) {
int r;
r = sd_rtnl_open(&rtnl, 0);
int r;
r = sd_rtnl_open(&rtnl, 0);
- if (r < 0) {
- log_error("Failed to connect to netlink: %s", strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to connect to netlink: %m");
udev = udev_new();
udev = udev_new();
- if (!udev) {
- log_error("Failed to connect to udev: %m");
- return -errno;
- }
+ if (!udev)
+ return log_error_errno(errno, "Failed to connect to udev: %m");
if (n <= 1 && !arg_all) {
_cleanup_free_ char *operational_state = NULL;
if (n <= 1 && !arg_all) {
_cleanup_free_ char *operational_state = NULL;
@@
-484,7
+478,7
@@
static int link_status(char **args, unsigned n) {
if (!strv_isempty(domains))
dump_list(" Domain: ", domains);
if (!strv_isempty(domains))
dump_list(" Domain: ", domains);
- sd_network_get_
dns
(&ntp);
+ sd_network_get_
ntp
(&ntp);
if (!strv_isempty(ntp))
dump_list(" NTP: ", ntp);
if (!strv_isempty(ntp))
dump_list(" NTP: ", ntp);
@@
-507,10
+501,8
@@
static int link_status(char **args, unsigned n) {
return rtnl_log_create_error(r);
r = sd_rtnl_call(rtnl, req, 0, &reply);
return rtnl_log_create_error(r);
r = sd_rtnl_call(rtnl, req, 0, &reply);
- if (r < 0) {
- log_error("Failed to enumerate links: %s", strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to enumerate links: %m");
c = decode_and_sort_links(reply, &links);
if (c < 0)
c = decode_and_sort_links(reply, &links);
if (c < 0)