[systemd-commits] 3 commits - src/libsystemd src/libsystemd-network src/network src/shared units/systemd-fsck-root.service.in
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Aug 15 04:20:26 PDT 2014
src/libsystemd-network/sd-dhcp-client.c | 3 ++-
src/libsystemd/sd-rtnl/test-rtnl.c | 3 ++-
src/network/networkctl.c | 11 +++++++----
src/shared/socket-util.c | 19 +++++++++++++++++++
src/shared/socket-util.h | 5 +++++
units/systemd-fsck-root.service.in | 1 -
6 files changed, 35 insertions(+), 7 deletions(-)
New commits:
commit db73295accbec0c6513817f0a64a92018592bb26
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Aug 15 13:18:50 2014 +0200
util: never use ether_ntoa(), since it formats with %x, not %02x, which makes ethernet addresses look funny
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index f5910d9..8a9887d 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -1420,6 +1420,7 @@ static int client_receive_message_raw(sd_event_source *s, int fd,
}
int sd_dhcp_client_start(sd_dhcp_client *client) {
+ char buffer[ETHER_ADDR_TO_STRING_MAX];
int r;
assert_return(client, -EINVAL);
@@ -1435,7 +1436,7 @@ int sd_dhcp_client_start(sd_dhcp_client *client) {
if (r >= 0)
log_dhcp_client(client, "STARTED on ifindex %u with address %s",
client->index,
- ether_ntoa(&client->client_id.mac_addr));
+ ether_addr_to_string(&client->client_id.mac_addr, buffer));
return r;
}
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 4b6e533..46b5bb2 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -34,6 +34,7 @@
static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
_cleanup_rtnl_message_unref_ sd_rtnl_message *message;
const char *mac = "98:fe:94:3f:c6:18", *name = "test";
+ char buffer[ETHER_ADDR_TO_STRING_MAX];
unsigned int mtu = 1450, mtu_out;
const char *name_out;
struct ether_addr mac_out;
@@ -51,7 +52,7 @@ static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
assert_se(streq(name, name_out));
assert_se(sd_rtnl_message_read_ether_addr(message, IFLA_ADDRESS, &mac_out) >= 0);
- assert_se(streq(mac, ether_ntoa(&mac_out)));
+ assert_se(streq(mac, ether_addr_to_string(&mac_out, buffer)));
assert_se(sd_rtnl_message_read_u32(message, IFLA_MTU, &mtu_out) >= 0);
assert_se(mtu == mtu_out);
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 620bc46..33fe8bf 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -33,6 +33,7 @@
#include "udev-util.h"
#include "arphrd-list.h"
#include "local-addresses.h"
+#include "socket-util.h"
static bool arg_no_pager = false;
static bool arg_legend = true;
@@ -402,8 +403,10 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
if (model)
printf(" Model: %s\n", model);
- if (have_mac)
- printf(" HW Address: %s\n", ether_ntoa(&e));
+ if (have_mac) {
+ char ea[ETHER_ADDR_TO_STRING_MAX];
+ printf(" HW Address: %s\n", ether_addr_to_string(&e, ea));
+ }
if (mtu > 0)
printf(" MTU: %u\n", mtu);
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 38729a2..e3e54e8 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -727,3 +727,22 @@ bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b
return false;
}
+
+char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR_TO_STRING_MAX]) {
+ assert(addr);
+ assert(buffer);
+
+ /* Like ether_ntoa() but uses %02x instead of %x to print
+ * ethernet addresses, which makes them look less funny. Also,
+ * doesn't use a static buffer. */
+
+ sprintf(buffer, "%02x:%02x:%02x:%02x:%02x:%02x",
+ addr->ether_addr_octet[0],
+ addr->ether_addr_octet[1],
+ addr->ether_addr_octet[2],
+ addr->ether_addr_octet[3],
+ addr->ether_addr_octet[4],
+ addr->ether_addr_octet[5]);
+
+ return buffer;
+}
diff --git a/src/shared/socket-util.h b/src/shared/socket-util.h
index 0b4998d..07d0aff 100644
--- a/src/shared/socket-util.h
+++ b/src/shared/socket-util.h
@@ -23,6 +23,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/ether.h>
#include <sys/un.h>
#include <asm/types.h>
#include <linux/netlink.h>
@@ -111,3 +112,7 @@ int netlink_family_to_string_alloc(int b, char **s);
int netlink_family_from_string(const char *s) _pure_;
bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b);
+
+#define ETHER_ADDR_TO_STRING_MAX (3*6)
+
+char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR_TO_STRING_MAX]);
commit c22bf27beea56516d8f83784759fb30495e058d7
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Aug 15 12:57:46 2014 +0200
unit: remove spurious newline
diff --git a/units/systemd-fsck-root.service.in b/units/systemd-fsck-root.service.in
index 4162983..26cce51 100644
--- a/units/systemd-fsck-root.service.in
+++ b/units/systemd-fsck-root.service.in
@@ -11,7 +11,6 @@ Documentation=man:systemd-fsck-root.service(8)
DefaultDependencies=no
After=systemd-readahead-collect.service systemd-readahead-replay.service
Before=local-fs.target shutdown.target
-
ConditionPathIsReadWrite=!/
[Service]
commit 3e3db0ee860025ad663b13b0ace4e6d627611332
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Aug 15 12:57:33 2014 +0200
networkctl: increase column width for link type to 18, to accomodate for 'ieee80211_radiotap'
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 25097bb..620bc46 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -215,7 +215,7 @@ static int list_links(char **args, unsigned n) {
}
if (arg_legend)
- printf("%3s %-16s %-10s %-11s %-10s\n", "IDX", "LINK", "TYPE", "OPERATIONAL", "SETUP");
+ printf("%3s %-16s %-18s %-11s %-10s\n", "IDX", "LINK", "TYPE", "OPERATIONAL", "SETUP");
c = decode_and_sort_links(reply, &links);
if (c < 0)
@@ -240,7 +240,7 @@ static int list_links(char **args, unsigned n) {
link_get_type_string(links[i].iftype, d, &t);
- printf("%3i %-16s %-10s %s%-11s%s %s%-10s%s\n",
+ printf("%3i %-16s %-18s %s%-11s%s %s%-10s%s\n",
links[i].ifindex, links[i].name, strna(t),
on_color_operational, strna(operational_state), off_color_operational,
on_color_setup, strna(setup_state), off_color_setup);
More information about the systemd-commits
mailing list