[systemd-commits] 5 commits - src/libsystemd-network src/network

Tom Gundersen tomegun at kemper.freedesktop.org
Sun Apr 20 10:57:45 PDT 2014


 src/libsystemd-network/sd-dhcp-client.c |    5 +
 src/network/networkd-link.c             |   94 ++++++++++++++++++++++++++------
 src/network/networkd.h                  |    1 
 3 files changed, 82 insertions(+), 18 deletions(-)

New commits:
commit 57bd6899b35b84d1f23809133ae45d29a87b2eaa
Author: Tom Gundersen <teg at jklm.no>
Date:   Sun Apr 20 19:49:00 2014 +0200

    networkd: link - add explicit unmanaged state

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index cf22778..392665a 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -141,6 +141,16 @@ static int link_enter_configured(Link *link) {
         return 0;
 }
 
+static void link_enter_unmanaged(Link *link) {
+        assert(link);
+
+        log_info_link(link, "unmanaged");
+
+        link->state = LINK_STATE_UNMANAGED;
+
+        link_save(link);
+}
+
 static void link_enter_failed(Link *link) {
         assert(link);
 
@@ -1471,8 +1481,11 @@ int link_initialized(Link *link, struct udev_device *device) {
         log_debug_link(link, "link initialized");
 
         r = network_get(link->manager, device, link->ifname, &link->mac, &network);
-        if (r < 0)
-                return r == -ENOENT ? 0 : r;
+        if (r == -ENOENT) {
+                link_enter_unmanaged(link);
+                return 0;
+        } else if (r < 0)
+                return r;
 
         r = network_apply(link->manager, network, link);
         if (r < 0)
@@ -1541,7 +1554,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
         assert(link->ifname);
         assert(m);
 
-        if (link->state == LINK_STATE_FAILED)
+        if (link->state == LINK_STATE_FAILED || link->state == LINK_STATE_UNMANAGED)
                 return 0;
 
         r = sd_rtnl_message_read_string(m, IFLA_IFNAME, &ifname);
@@ -1667,6 +1680,7 @@ static const char* const link_state_table[_LINK_STATE_MAX] = {
         [LINK_STATE_SETTING_ADDRESSES] = "configuring",
         [LINK_STATE_SETTING_ROUTES] = "configuring",
         [LINK_STATE_CONFIGURED] = "configured",
+        [LINK_STATE_UNMANAGED] = "unmanaged",
         [LINK_STATE_FAILED] = "failed",
 };
 
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 4a62fb8..f481dde 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -190,6 +190,7 @@ typedef enum LinkState {
         LINK_STATE_SETTING_ADDRESSES,
         LINK_STATE_SETTING_ROUTES,
         LINK_STATE_CONFIGURED,
+        LINK_STATE_UNMANAGED,
         LINK_STATE_FAILED,
         _LINK_STATE_MAX,
         _LINK_STATE_INVALID = -1

commit 4bb40e8125ae0a83a13cb8e020950975eeeb1ad2
Author: Tom Gundersen <teg at jklm.no>
Date:   Sun Apr 20 19:34:51 2014 +0200

    networkd: link - set mac addresses when starting clients
    
    MAC addreses are also set when NEWLINK messages are receieved, but only if the clients have
    already been initialized.

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 8c6bad4..cf22778 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1409,6 +1409,10 @@ static int link_configure(Link *link) {
                 if (r < 0)
                         return r;
 
+                r = sd_ipv4ll_set_mac(link->ipv4ll, &link->mac);
+                if (r < 0)
+                        return r;
+
                 r = sd_ipv4ll_set_index(link->ipv4ll, link->ifindex);
                 if (r < 0)
                         return r;
@@ -1427,6 +1431,10 @@ static int link_configure(Link *link) {
                 if (r < 0)
                         return r;
 
+                r = sd_dhcp_client_set_mac(link->dhcp_client, &link->mac);
+                if (r < 0)
+                        return r;
+
                 r = sd_dhcp_client_set_index(link->dhcp_client, link->ifindex);
                 if (r < 0)
                         return r;

commit 6317519517210f703e20dc846b31d018845244cd
Author: Tom Gundersen <teg at jklm.no>
Date:   Sun Apr 20 19:10:02 2014 +0200

    sd-dhcp-client: log ifindex and mac address when starting

diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 4892203..854c671 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <net/ethernet.h>
 #include <net/if_arp.h>
+#include <netinet/ether.h>
 #include <sys/param.h>
 #include <sys/ioctl.h>
 
@@ -1264,7 +1265,9 @@ int sd_dhcp_client_start(sd_dhcp_client *client) {
 
         r = client_start(client);
         if (r >= 0)
-                log_dhcp_client(client, "STARTED");
+                log_dhcp_client(client, "STARTED on ifindex %u with address %s",
+                                client->index,
+                                ether_ntoa(&client->client_id.mac_addr));
 
         return r;
 }

commit c6a1eb79a52a29ddb80bc2b58f44a86a33e9f027
Author: Tom Gundersen <teg at jklm.no>
Date:   Sun Apr 20 13:08:59 2014 +0200

    networkd: link - log changes in some common link flags

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index d241682..8c6bad4 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1059,7 +1059,9 @@ static int link_update_flags(Link *link, unsigned flags) {
 
         flags_added = (link->flags ^ flags) & flags;
         flags_removed = (link->flags ^ flags) & link->flags;
-        generic_flags = ~(IFF_UP | IFF_LOWER_UP | IFF_DORMANT);
+        generic_flags = ~(IFF_UP | IFF_LOWER_UP | IFF_DORMANT | IFF_DEBUG |
+                          IFF_MULTICAST | IFF_BROADCAST | IFF_PROMISC |
+                          IFF_NOARP | IFF_MASTER | IFF_SLAVE);
 
         /* consider link to have carrier when LOWER_UP and !DORMANT
 
@@ -1096,6 +1098,41 @@ static int link_update_flags(Link *link, unsigned flags) {
         else if (flags_removed & IFF_DORMANT)
                 log_debug_link(link, "link is not dormant");
 
+        if (flags_added & IFF_DEBUG)
+                log_debug_link(link, "debugging enabled in the kernel");
+        else if (flags_removed & IFF_DEBUG)
+                log_debug_link(link, "debugging disabled in the kernel");
+
+        if (flags_added & IFF_MULTICAST)
+                log_debug_link(link, "multicast enabled");
+        else if (flags_removed & IFF_MULTICAST)
+                log_debug_link(link, "multicast disabled");
+
+        if (flags_added & IFF_BROADCAST)
+                log_debug_link(link, "broadcast enabled");
+        else if (flags_removed & IFF_BROADCAST)
+                log_debug_link(link, "broadcast disabled");
+
+        if (flags_added & IFF_PROMISC)
+                log_debug_link(link, "promiscuous mode enabled");
+        else if (flags_removed & IFF_PROMISC)
+                log_debug_link(link, "promiscuous mode disabled");
+
+        if (flags_added & IFF_NOARP)
+                log_debug_link(link, "ARP protocol disabled");
+        else if (flags_removed & IFF_NOARP)
+                log_debug_link(link, "ARP protocol enabled");
+
+        if (flags_added & IFF_MASTER)
+                log_debug_link(link, "link is master");
+        else if (flags_removed & IFF_MASTER)
+                log_debug_link(link, "link is no longer master");
+
+        if (flags_added & IFF_SLAVE)
+                log_debug_link(link, "link is slave");
+        else if (flags_removed & IFF_SLAVE)
+                log_debug_link(link, "link is no longer slave");
+
         /* link flags are currently at most 18 bits, let's default to printing 20 */
         if (flags_added & generic_flags)
                 log_debug_link(link, "unknown link flags gained: %#.5x (ignoring)",

commit 75ee87c8c61817a94e520cf1ec564996b3781b89
Author: Tom Gundersen <teg at jklm.no>
Date:   Sun Apr 20 10:28:19 2014 +0200

    networkd: link - use IFF_DORMANT instead of IFF_RUNNING
    
    Should be no functional change, but avoids spurious log
    messages when in operstate UNKNOWN and !IFF_LOWER_UP.

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 39f2a59..d241682 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1059,17 +1059,18 @@ static int link_update_flags(Link *link, unsigned flags) {
 
         flags_added = (link->flags ^ flags) & flags;
         flags_removed = (link->flags ^ flags) & link->flags;
-        generic_flags = ~(IFF_UP | IFF_LOWER_UP | IFF_RUNNING);
+        generic_flags = ~(IFF_UP | IFF_LOWER_UP | IFF_DORMANT);
 
-        /* consider link to have carrier when both RUNNING and LOWER_UP, as RUNNING
-           may mean that the oper state is unknown, in which case we should fall back to
-           simply trust LOWER_UP, even thought that is less reliable
+        /* consider link to have carrier when LOWER_UP and !DORMANT
+
+           TODO: use proper operstates once we start supporting 802.1X
+
+           see Documentation/networking/operstates.txt in the kernel sources
          */
-        carrier_gained = ((flags_added & IFF_LOWER_UP) && (flags & IFF_RUNNING)) ||
-                         ((flags_added & IFF_RUNNING) && (flags & IFF_LOWER_UP));
-        carrier_lost = ((link->flags & (IFF_RUNNING | IFF_LOWER_UP)) ==
-                        (IFF_RUNNING | IFF_LOWER_UP)) &&
-                       (flags_removed & (IFF_LOWER_UP | IFF_RUNNING));
+        carrier_gained = (((flags_added & IFF_LOWER_UP) && !(flags & IFF_DORMANT)) ||
+                          ((flags_removed & IFF_DORMANT) && (flags & IFF_LOWER_UP)));
+        carrier_lost = ((link->flags & IFF_LOWER_UP) && !(link->flags & IFF_DORMANT)) &&
+                       ((flags_removed & IFF_LOWER_UP) || (flags_added & IFF_DORMANT));
 
         link->flags = flags;
 
@@ -1090,10 +1091,10 @@ static int link_update_flags(Link *link, unsigned flags) {
         else if (flags_removed & IFF_LOWER_UP)
                 log_debug_link(link, "link is lower down");
 
-        if (flags_added & IFF_RUNNING)
-                log_debug_link(link, "link is running");
-        else if (flags_removed & IFF_RUNNING)
-                log_debug_link(link, "link is not running");
+        if (flags_added & IFF_DORMANT)
+                log_debug_link(link, "link is dormant");
+        else if (flags_removed & IFF_DORMANT)
+                log_debug_link(link, "link is not dormant");
 
         /* link flags are currently at most 18 bits, let's default to printing 20 */
         if (flags_added & generic_flags)
@@ -1102,7 +1103,7 @@ static int link_update_flags(Link *link, unsigned flags) {
 
         if (flags_removed & generic_flags)
                 log_debug_link(link, "unknown link flags lost: %#.5x (ignoring)",
-                                flags_removed & generic_flags);
+                               flags_removed & generic_flags);
 
         if (carrier_gained) {
                 log_info_link(link, "gained carrier");



More information about the systemd-commits mailing list