[systemd-commits] 4 commits - src/libsystemd src/libsystemd-network src/network
Tom Gundersen
tomegun at kemper.freedesktop.org
Wed Mar 5 02:53:38 PST 2014
src/libsystemd-network/sd-dhcp-client.c | 9 +++++
src/libsystemd/sd-rtnl/rtnl-message.c | 12 +++----
src/libsystemd/sd-rtnl/test-rtnl.c | 2 +
src/network/networkd-link.c | 52 ++++++++++++++++++++++++++++----
4 files changed, 63 insertions(+), 12 deletions(-)
New commits:
commit 69629de9c820dd41fffb1bf9b69d6d5b319c19c9
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Mar 5 11:53:26 2014 +0100
networkd: listen to changes to the MAC address
Bridges will change their MAC address when other devices are enslaved. We need
the correct MAC address to acquire a DHCP lease, so take note of it whenever
it changes.
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 61e257c..416eb56 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1345,11 +1345,32 @@ int link_update(Link *link, sd_rtnl_message *m) {
}
while (sd_rtnl_message_read(m, &type, &data) > 0) {
- if (type == IFLA_MTU && link->network->dhcp &&
- link->network->dhcp_mtu && !link->original_mtu) {
- link->original_mtu = *(uint16_t *) data;
- log_debug_link(link, "saved original MTU: %" PRIu16,
- link->original_mtu);
+ switch(type) {
+ case IFLA_MTU:
+ if (link->network->dhcp && link->network->dhcp_mtu &&
+ !link->original_mtu) {
+ link->original_mtu = *(uint16_t *) data;
+ log_debug_link(link, "saved original MTU: %"
+ PRIu16, link->original_mtu);
+ }
+
+ break;
+ case IFLA_ADDRESS:
+ if (memcmp(&link->mac.ether_addr_octet, &data,
+ ETH_ALEN)) {
+ memcpy(&link->mac, data, ETH_ALEN);
+
+ log_debug_link(link, "updated MAC address: "
+ "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
+ link->mac.ether_addr_octet[0],
+ link->mac.ether_addr_octet[1],
+ link->mac.ether_addr_octet[2],
+ link->mac.ether_addr_octet[3],
+ link->mac.ether_addr_octet[4],
+ link->mac.ether_addr_octet[5]);
+ }
+
+ break;
}
}
commit 3b35ade3fd015482a450fe20edb7c7b7ccbbb803
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Mar 5 11:47:38 2014 +0100
sd-rtnl: do not blindly enter containers in message_read()
We need a separate container_enter() function, which will be part of a largerg
API change. For now, just fix message_read().
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 95dccc2..41a6e4e 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -778,7 +778,7 @@ int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data)
if (!RTA_OK(NEXT_RTA(m), remaining_size))
return 0;
- /* if we read a container, enter it and return its type */
+ /* if we read a container, return its type, but do not enter it*/
r = sd_rtnl_message_get_type(m, &rtm_type);
if (r < 0)
return r;
@@ -790,14 +790,12 @@ int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data)
NEXT_RTA(m)->rta_type == IFLA_LINKINFO) ||
(m->n_containers == 1 &&
GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO &&
- NEXT_RTA(m)->rta_type == IFLA_INFO_DATA))) {
+ NEXT_RTA(m)->rta_type == IFLA_INFO_DATA)))
*data = NULL;
- PUSH_CONTAINER(m, NEXT_RTA(m));
- UPDATE_RTA(m, RTA_DATA(NEXT_RTA(m)));
- } else {
+ else
*data = RTA_DATA(NEXT_RTA(m));
- UPDATE_RTA(m, RTA_NEXT(NEXT_RTA(m), remaining_size));
- }
+
+ UPDATE_RTA(m, RTA_NEXT(NEXT_RTA(m), remaining_size));
return 1;
}
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index dd74e76..1016bb6 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -302,6 +302,7 @@ static void test_container(void) {
assert_se(sd_rtnl_message_read(m, &type, &data) >= 0);
assert_se(type == IFLA_LINKINFO);
assert_se(data == NULL);
+/*
assert_se(sd_rtnl_message_read(m, &type, &data) >= 0);
assert_se(type == IFLA_INFO_KIND);
assert_se(streq("kind", (char *)data));
@@ -318,6 +319,7 @@ static void test_container(void) {
assert_se(streq("kind", (char *)data));
assert_se(sd_rtnl_message_read(m, &type, &data) == 0);
assert_se(sd_rtnl_message_exit_container(m) >= 0);
+*/
assert_se(sd_rtnl_message_exit_container(m) == -EINVAL);
}
commit 02ec5cd78a148c2c05c0d6e5016ae04570a9ef97
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Mar 5 11:07:15 2014 +0100
sd-dhcp-client: log the MAC address we are using
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index b6810a9..07b27d5 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -143,6 +143,15 @@ int sd_dhcp_client_set_mac(sd_dhcp_client *client,
assert_return(client, -EINVAL);
assert_return(client->state == DHCP_STATE_INIT, -EBUSY);
+ log_dhcp_client(client, "set MAC address to "
+ "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
+ 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]);
+
memcpy(&client->mac_addr, addr, ETH_ALEN);
return 0;
commit 0ad6148e87cd1348be81d9e83c4364a09dab2c29
Author: Mark Oteiza <mvoteiza at udel.edu>
Date: Wed Mar 5 10:41:13 2014 +0100
networkd: restore logic for enslaving to a master bonding interface
This partially reverts commit 54abf46, which unintentionally removed the
enslaving support for bonding interfaces
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index c10d947..61e257c 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1194,6 +1194,27 @@ static int link_enter_enslave(Link *link) {
link->enslaving ++;
}
+ if (link->network->bond) {
+ log_struct_link(LOG_DEBUG, link,
+ "MESSAGE=%s: enslaving by '%s'",
+ link->ifname, link->network->bond->name,
+ NETDEV(link->network->bond),
+ NULL);
+
+ r = netdev_enslave(link->network->bond, link, &enslave_handler);
+ if (r < 0) {
+ log_struct_link(LOG_WARNING, link,
+ "MESSAGE=%s: could not enslave by '%s': %s",
+ link->ifname, link->network->bond->name, strerror(-r),
+ NETDEV(link->network->bond),
+ NULL);
+ link_enter_failed(link);
+ return r;
+ }
+
+ link->enslaving ++;
+ }
+
HASHMAP_FOREACH(vlan, link->network->vlans, i) {
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%s: enslaving by '%s'",
More information about the systemd-commits
mailing list