chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
core: convert log_unit_*() to log_unit_*_errno()
[elogind.git]
/
src
/
network
/
networkctl.c
diff --git
a/src/network/networkctl.c
b/src/network/networkctl.c
index bf95aa2c90332ab21fb43a733cce1a2633d1c6ee..2754ed8d3e2429328bbb44e56b6fb80e3a44522b 100644
(file)
--- a/
src/network/networkctl.c
+++ b/
src/network/networkctl.c
@@
-141,7
+141,7
@@
static int decode_and_sort_links(sd_rtnl_message *m, LinkInfo **ret) {
c++;
}
c++;
}
- qsort(links, c, sizeof(LinkInfo), link_info_compare);
+ qsort
_safe
(links, c, sizeof(LinkInfo), link_info_compare);
*ret = links;
links = NULL;
*ret = links;
links = NULL;
@@
-191,7
+191,7
@@
static int list_links(char **args, unsigned n) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
- log_error
("Failed to connect to netlink: %s", strerror(-r)
);
+ log_error
_errno(r, "Failed to connect to netlink: %m"
);
return r;
}
return r;
}
@@
-211,7
+211,7
@@
static int list_links(char **args, unsigned n) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
- log_error
("Failed to enumerate links: %s", strerror(-r)
);
+ log_error
_errno(r, "Failed to enumerate links: %m"
);
return r;
}
return r;
}
@@
-294,8
+294,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;
@@
-323,7
+323,7
@@
static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
- log_error
("Failed to query link: %s", strerror(-r)
);
+ log_error
_errno(r, "Failed to query link: %m"
);
return r;
}
return r;
}
@@
-371,7
+371,11
@@
static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
char *wildcard;
wildcard = strdup("*");
char *wildcard;
wildcard = strdup("*");
- strv_push(&domains, wildcard);
+ if (!wildcard)
+ return log_oom();
+
+ if (strv_consume(&domains, wildcard) < 0)
+ return log_oom();
}
sprintf(devid, "n%i", ifindex);
}
sprintf(devid, "n%i", ifindex);
@@
-380,6
+384,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");
@@
-392,11
+397,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);
@@
-423,7
+433,7
@@
static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
if (!strv_isempty(dns))
dump_list(" DNS: ", dns);
if (!strv_isempty(domains))
if (!strv_isempty(dns))
dump_list(" DNS: ", dns);
if (!strv_isempty(domains))
- dump_list("
Domains
: ", domains);
+ dump_list("
Domain
: ", domains);
if (!strv_isempty(ntp))
dump_list(" NTP: ", ntp);
if (!strv_isempty(ntp))
dump_list(" NTP: ", ntp);
@@
-438,7
+448,7
@@
static int link_status(char **args, unsigned n) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
- log_error
("Failed to connect to netlink: %s", strerror(-r)
);
+ log_error
_errno(r, "Failed to connect to netlink: %m"
);
return r;
}
return r;
}
@@
-450,7
+460,7
@@
static int link_status(char **args, unsigned n) {
if (n <= 1 && !arg_all) {
_cleanup_free_ char *operational_state = NULL;
if (n <= 1 && !arg_all) {
_cleanup_free_ char *operational_state = NULL;
- _cleanup_strv_free_ char **dns = NULL, **ntp = NULL;
+ _cleanup_strv_free_ char **dns = NULL, **ntp = NULL
, **domains = NULL
;
_cleanup_free_ struct local_address *addresses = NULL;
const char *on_color_operational, *off_color_operational;
int i, c;
_cleanup_free_ struct local_address *addresses = NULL;
const char *on_color_operational, *off_color_operational;
int i, c;
@@
-476,7
+486,11
@@
static int link_status(char **args, unsigned n) {
if (!strv_isempty(dns))
dump_list(" DNS: ", dns);
if (!strv_isempty(dns))
dump_list(" DNS: ", dns);
- sd_network_get_dns(&ntp);
+ sd_network_get_domains(&domains);
+ if (!strv_isempty(domains))
+ dump_list(" Domain: ", domains);
+
+ sd_network_get_ntp(&ntp);
if (!strv_isempty(ntp))
dump_list(" NTP: ", ntp);
if (!strv_isempty(ntp))
dump_list(" NTP: ", ntp);
@@
-500,7
+514,7
@@
static int link_status(char **args, unsigned n) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
- log_error
("Failed to enumerate links: %s", strerror(-r)
);
+ log_error
_errno(r, "Failed to enumerate links: %m"
);
return r;
}
return r;
}