[systemd-commits] 3 commits - src/libsystemd src/network src/resolve src/systemd

Tom Gundersen tomegun at kemper.freedesktop.org
Wed Aug 13 13:56:21 PDT 2014


 src/libsystemd/sd-network/sd-network.c  |   10 +++++-----
 src/network/networkctl.c                |   12 ++++++------
 src/network/networkd-link.c             |    8 ++++----
 src/network/networkd-link.h             |    4 ++--
 src/network/networkd-manager.c          |    2 +-
 src/network/networkd-wait-online-link.c |    4 ++--
 src/resolve/resolved-link.c             |    6 +++---
 src/systemd/sd-network.h                |   20 +++++++++++++-------
 8 files changed, 36 insertions(+), 30 deletions(-)

New commits:
commit 438ca2bbd4dc1de6193ec61f3c12e19cded7921d
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Aug 13 22:55:49 2014 +0200

    sd-networkd: rename link_get_state to link_get_setup_state
    
    Suggested by Kay and Lennart.

diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
index f8f48b0..97d041a 100644
--- a/src/libsystemd/sd-network/sd-network.c
+++ b/src/libsystemd/sd-network/sd-network.c
@@ -92,7 +92,7 @@ _public_ int sd_network_get_ntp(char ***ret) {
         return network_get_strv("NTP", ret);
 }
 
-_public_ int sd_network_link_get_state(int ifindex, char **state) {
+_public_ int sd_network_link_get_setup_state(int ifindex, char **state) {
         _cleanup_free_ char *s = NULL, *p = NULL;
         int r;
 
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 6fb9e62..f83c1f3 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -198,7 +198,7 @@ static int list_links(char **args, unsigned n) {
                  char devid[2 + DECIMAL_STR_MAX(int)];
                 _cleanup_free_ char *t = NULL;
 
-                sd_network_link_get_state(links[i].ifindex, &state);
+                sd_network_link_get_setup_state(links[i].ifindex, &state);
                 sd_network_link_get_operational_state(links[i].ifindex, &operational_state);
 
                 sprintf(devid, "n%i", links[i].ifindex);
@@ -340,7 +340,7 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
 
         sd_rtnl_message_read_u32(reply, IFLA_MTU, &mtu);
 
-        sd_network_link_get_state(ifindex, &state);
+        sd_network_link_get_setup_state(ifindex, &state);
         sd_network_link_get_operational_state(ifindex, &operational_state);
 
         sd_network_link_get_dns(ifindex, &dns);
diff --git a/src/network/networkd-wait-online-link.c b/src/network/networkd-wait-online-link.c
index 1670bee..f23c7ce 100644
--- a/src/network/networkd-wait-online-link.c
+++ b/src/network/networkd-wait-online-link.c
@@ -131,7 +131,7 @@ int link_update_monitor(Link *l) {
         free(l->state);
         l->state = NULL;
 
-        sd_network_link_get_state(l->ifindex, &l->state);
+        sd_network_link_get_setup_state(l->ifindex, &l->state);
 
         return 0;
 }
diff --git a/src/systemd/sd-network.h b/src/systemd/sd-network.h
index dede7ae..47731c2 100644
--- a/src/systemd/sd-network.h
+++ b/src/systemd/sd-network.h
@@ -64,7 +64,7 @@ int sd_network_get_dns(char ***addr);
  * reperesentations of IP addresses */
 int sd_network_get_ntp(char ***addr);
 
-/* Get state from ifindex.
+/* Get setup state from ifindex.
  * Possible states:
  *   pending: udev is still processing the link, we don't yet know if we will manage it
  *   failed: networkd failed to manage the link
@@ -75,7 +75,7 @@ int sd_network_get_ntp(char ***addr);
  * Possible return codes:
  *   -ENODATA: networkd is not aware of the link
  */
-int sd_network_link_get_state(int ifindex, char **state);
+int sd_network_link_get_setup_state(int ifindex, char **state);
 
 /* Get operatinal state from ifindex.
  * Possible states:

commit d3df0e3982777fd5de8cffaa585eba0af3773c08
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Aug 13 22:44:35 2014 +0200

    sd-network: rename operstates 'down' -> 'off' and 'up' -> 'no-carrier'
    
    Suggested by Lennart and Kay.

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 398e8ba..908d834 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1657,9 +1657,9 @@ static void link_update_operstate(Link *link) {
                         /* no useful addresses found */
                         link->operstate = LINK_OPERSTATE_CARRIER;
         } else if (link->flags & IFF_UP)
-                link->operstate = LINK_OPERSTATE_UP;
+                link->operstate = LINK_OPERSTATE_NO_CARRIER;
         else
-                link->operstate = LINK_OPERSTATE_DOWN;
+                link->operstate = LINK_OPERSTATE_OFF;
 }
 
 int link_save(Link *link) {
@@ -1793,8 +1793,8 @@ static const char* const link_state_table[_LINK_STATE_MAX] = {
 DEFINE_STRING_TABLE_LOOKUP(link_state, LinkState);
 
 static const char* const link_operstate_table[_LINK_OPERSTATE_MAX] = {
-        [LINK_OPERSTATE_DOWN] = "down",
-        [LINK_OPERSTATE_UP] = "up",
+        [LINK_OPERSTATE_OFF] = "off",
+        [LINK_OPERSTATE_NO_CARRIER] = "no-carrier",
         [LINK_OPERSTATE_DORMANT] = "dormant",
         [LINK_OPERSTATE_CARRIER] = "carrier",
         [LINK_OPERSTATE_DEGRADED] = "degraded",
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index 6d58fa1..0f73ec7 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -37,8 +37,8 @@ typedef enum LinkState {
 } LinkState;
 
 typedef enum LinkOperationalState {
-        LINK_OPERSTATE_DOWN,
-        LINK_OPERSTATE_UP,
+        LINK_OPERSTATE_OFF,
+        LINK_OPERSTATE_NO_CARRIER,
         LINK_OPERSTATE_DORMANT,
         LINK_OPERSTATE_CARRIER,
         LINK_OPERSTATE_DEGRADED,
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index ff6c71d..e3d72ed 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -456,7 +456,7 @@ int manager_save(Manager *m) {
         Iterator i;
         _cleanup_free_ char *temp_path = NULL;
         _cleanup_fclose_ FILE *f = NULL;
-        LinkOperationalState operstate = LINK_OPERSTATE_DOWN;
+        LinkOperationalState operstate = LINK_OPERSTATE_OFF;
         const char *operstate_str;
         int r;
 
diff --git a/src/systemd/sd-network.h b/src/systemd/sd-network.h
index 49034e8..dede7ae 100644
--- a/src/systemd/sd-network.h
+++ b/src/systemd/sd-network.h
@@ -78,7 +78,13 @@ int sd_network_get_ntp(char ***addr);
 int sd_network_link_get_state(int ifindex, char **state);
 
 /* Get operatinal state from ifindex.
- * Possible states: down, up, dormant, carrier, degraded, routable
+ * Possible states:
+ *   off: the device is powered down
+ *   no-carrier: the device is powered up, but it does not yet have a carrier
+ *   dormant: the device has a carrier, but is not yet ready for normal traffic
+ *   carrier: the link has a carrier
+ *   degraded: the link has carrier and addresses valid on the local link configured
+ *   routable: the link has carrier and routable address configured
  * Possible return codes:
  *   -ENODATA: networkd is not aware of the link
  */

commit d6731e4c7964ee2860d4f5abdb0b52acd7a66960
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Aug 13 22:37:45 2014 +0200

    sd-network: /_get_link_/_link_get_/
    
    The link is the 'object', so make this in line with our usual naming convention.
    
    Suggested by Kay and Lennart.

diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
index 1039a2c..f8f48b0 100644
--- a/src/libsystemd/sd-network/sd-network.c
+++ b/src/libsystemd/sd-network/sd-network.c
@@ -92,7 +92,7 @@ _public_ int sd_network_get_ntp(char ***ret) {
         return network_get_strv("NTP", ret);
 }
 
-_public_ int sd_network_get_link_state(int ifindex, char **state) {
+_public_ int sd_network_link_get_state(int ifindex, char **state) {
         _cleanup_free_ char *s = NULL, *p = NULL;
         int r;
 
@@ -116,7 +116,7 @@ _public_ int sd_network_get_link_state(int ifindex, char **state) {
         return 0;
 }
 
-_public_ int sd_network_get_link_operational_state(int ifindex, char **state) {
+_public_ int sd_network_link_get_operational_state(int ifindex, char **state) {
         _cleanup_free_ char *s = NULL, *p = NULL;
         int r;
 
@@ -140,7 +140,7 @@ _public_ int sd_network_get_link_operational_state(int ifindex, char **state) {
         return 0;
 }
 
-_public_ int sd_network_get_link_llmnr(int ifindex, char **llmnr) {
+_public_ int sd_network_link_get_llmnr(int ifindex, char **llmnr) {
         _cleanup_free_ char *s = NULL, *p = NULL;
         int r;
 
@@ -198,11 +198,11 @@ static int network_get_link_strv(const char *key, int ifindex, char ***ret) {
         return r;
 }
 
-_public_ int sd_network_get_link_dns(int ifindex, char ***ret) {
+_public_ int sd_network_link_get_dns(int ifindex, char ***ret) {
         return network_get_link_strv("DNS", ifindex, ret);
 }
 
-_public_ int sd_network_get_link_ntp(int ifindex, char ***ret) {
+_public_ int sd_network_link_get_ntp(int ifindex, char ***ret) {
         return network_get_link_strv("NTP", ifindex, ret);
 }
 
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 9c4c1b7..6fb9e62 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -198,8 +198,8 @@ static int list_links(char **args, unsigned n) {
                  char devid[2 + DECIMAL_STR_MAX(int)];
                 _cleanup_free_ char *t = NULL;
 
-                sd_network_get_link_state(links[i].ifindex, &state);
-                sd_network_get_link_operational_state(links[i].ifindex, &operational_state);
+                sd_network_link_get_state(links[i].ifindex, &state);
+                sd_network_link_get_operational_state(links[i].ifindex, &operational_state);
 
                 sprintf(devid, "n%i", links[i].ifindex);
                 d = udev_device_new_from_device_id(udev, devid);
@@ -340,11 +340,11 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
 
         sd_rtnl_message_read_u32(reply, IFLA_MTU, &mtu);
 
-        sd_network_get_link_state(ifindex, &state);
-        sd_network_get_link_operational_state(ifindex, &operational_state);
+        sd_network_link_get_state(ifindex, &state);
+        sd_network_link_get_operational_state(ifindex, &operational_state);
 
-        sd_network_get_link_dns(ifindex, &dns);
-        sd_network_get_link_ntp(ifindex, &ntp);
+        sd_network_link_get_dns(ifindex, &dns);
+        sd_network_link_get_ntp(ifindex, &ntp);
 
         sprintf(devid, "n%i", ifindex);
         d = udev_device_new_from_device_id(udev, devid);
diff --git a/src/network/networkd-wait-online-link.c b/src/network/networkd-wait-online-link.c
index 47fb0c0..1670bee 100644
--- a/src/network/networkd-wait-online-link.c
+++ b/src/network/networkd-wait-online-link.c
@@ -126,12 +126,12 @@ int link_update_monitor(Link *l) {
         free(l->operational_state);
         l->operational_state = NULL;
 
-        sd_network_get_link_operational_state(l->ifindex, &l->operational_state);
+        sd_network_link_get_operational_state(l->ifindex, &l->operational_state);
 
         free(l->state);
         l->state = NULL;
 
-        sd_network_get_link_state(l->ifindex, &l->state);
+        sd_network_link_get_state(l->ifindex, &l->state);
 
         return 0;
 }
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index 7dcaf18..fea52d9 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -157,7 +157,7 @@ static int link_update_dns_servers(Link *l) {
 
         assert(l);
 
-        r = sd_network_get_link_dns(l->ifindex, &nameservers);
+        r = sd_network_link_get_dns(l->ifindex, &nameservers);
         if (r < 0)
                 goto clear;
 
@@ -201,7 +201,7 @@ static int link_update_llmnr_support(Link *l) {
 
         assert(l);
 
-        r = sd_network_get_link_llmnr(l->ifindex, &b);
+        r = sd_network_link_get_llmnr(l->ifindex, &b);
         if (r < 0)
                 goto clear;
 
@@ -251,7 +251,7 @@ bool link_relevant(Link *l, int family) {
         if ((l->flags & (IFF_UP|IFF_LOWER_UP|IFF_MULTICAST)) != (IFF_UP|IFF_LOWER_UP|IFF_MULTICAST))
                 return false;
 
-        sd_network_get_link_operational_state(l->ifindex, &state);
+        sd_network_link_get_operational_state(l->ifindex, &state);
         if (state && !STR_IN_SET(state, "unknown", "degraded", "routable"))
                 return false;
 
diff --git a/src/systemd/sd-network.h b/src/systemd/sd-network.h
index 6bba5cf..49034e8 100644
--- a/src/systemd/sd-network.h
+++ b/src/systemd/sd-network.h
@@ -75,28 +75,28 @@ int sd_network_get_ntp(char ***addr);
  * Possible return codes:
  *   -ENODATA: networkd is not aware of the link
  */
-int sd_network_get_link_state(int ifindex, char **state);
+int sd_network_link_get_state(int ifindex, char **state);
 
 /* Get operatinal state from ifindex.
  * Possible states: down, up, dormant, carrier, degraded, routable
  * Possible return codes:
  *   -ENODATA: networkd is not aware of the link
  */
-int sd_network_get_link_operational_state(int ifindex, char **state);
+int sd_network_link_get_operational_state(int ifindex, char **state);
 
 /* Get DNS entries for a given link. These are string representations of
  * IP addresses */
-int sd_network_get_link_dns(int ifindex, char ***addr);
+int sd_network_link_get_dns(int ifindex, char ***addr);
 
 /* Get NTP entries for a given link. These are domain names or string
  * reperesentations of IP addresses */
-int sd_network_get_link_ntp(int ifindex, char ***addr);
+int sd_network_link_get_ntp(int ifindex, char ***addr);
 
 /* Indicates whether or not LLMNR should be enabled for the link
  * Possible levels of support: yes, no, resolve
  * Possible return codes:
  *   -ENODATA: networkd is not aware of the link*/
-int sd_network_get_link_llmnr(int ifindex, char **llmnr);
+int sd_network_link_get_llmnr(int ifindex, char **llmnr);
 
 /* Monitor object */
 typedef struct sd_network_monitor sd_network_monitor;



More information about the systemd-commits mailing list