]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: use up_or_down() at several more places
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 11 Jun 2025 05:14:26 +0000 (14:14 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 11 Jun 2025 16:16:08 +0000 (17:16 +0100)
src/network/networkd-setlink.c

index 0ab7fb14d33b330c8cd68b22473b249a35080d21..bdde9d6c254c2829a036d63d43b42633c86b56e7 100644 (file)
@@ -1061,6 +1061,10 @@ static int link_up_dsa_slave(Link *link) {
         return 1;
 }
 
+static const char* up_or_down(bool up) {
+        return up ? "up" : "down";
+}
+
 static int link_up_or_down_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, void *userdata) {
         bool on_activate, up;
         int r;
@@ -1076,7 +1080,7 @@ static int link_up_or_down_handler(sd_netlink *rtnl, sd_netlink_message *m, Requ
         if (r == -ENETDOWN && up && link_up_dsa_slave(link) > 0)
                 log_link_message_debug_errno(link, m, r, "Could not bring up dsa slave, retrying again after dsa master becomes up");
         else if (r < 0)
-                log_link_message_warning_errno(link, m, r, "Could not bring %s interface, ignoring", up ? "up" : "down");
+                log_link_message_warning_errno(link, m, r, "Could not bring %s interface, ignoring", up_or_down(up));
 
         r = link_call_getlink(link, get_link_update_flag_handler);
         if (r < 0) {
@@ -1094,10 +1098,6 @@ static int link_up_or_down_handler(sd_netlink *rtnl, sd_netlink_message *m, Requ
         return 0;
 }
 
-static const char *up_or_down(bool up) {
-        return up ? "up" : "down";
-}
-
 static int link_up_or_down(Link *link, bool up, Request *req) {
         _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
         int r;
@@ -1292,7 +1292,7 @@ static int link_up_or_down_now_handler(sd_netlink *rtnl, sd_netlink_message *m,
 
         r = sd_netlink_message_get_errno(m);
         if (r < 0)
-                log_link_message_warning_errno(link, m, r, "Could not bring %s interface, ignoring", up ? "up" : "down");
+                log_link_message_warning_errno(link, m, r, "Could not bring %s interface, ignoring", up_or_down(up));
 
         r = link_call_getlink(link, get_link_update_flag_handler);
         if (r < 0) {
@@ -1320,7 +1320,7 @@ int link_up_or_down_now(Link *link, bool up) {
         assert(link->manager);
         assert(link->manager->rtnl);
 
-        log_link_debug(link, "Bringing link %s", up ? "up" : "down");
+        log_link_debug(link, "Bringing link %s", up_or_down(up));
 
         r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
         if (r < 0)