chiark / gitweb /
s/commandline/command line/g
[elogind.git] / src / network / networkd-route.c
index 77c2daddc50f052339062812b332aa2263d83606..10d8cd902a8c16147eb52bb4aa0d01781054ed1b 100644 (file)
@@ -22,6 +22,7 @@
 #include <net/if.h>
 
 #include "networkd.h"
+#include "networkd-link.h"
 
 #include "utf8.h"
 #include "util.h"
@@ -143,6 +144,17 @@ int route_drop(Route *route, Link *link,
                 }
         }
 
+        if (!in_addr_is_null(route->family, &route->prefsrc_addr)) {
+                if (route->family == AF_INET)
+                        r = sd_rtnl_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in);
+                else if (route->family == AF_INET6)
+                        r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6);
+                if (r < 0) {
+                        log_error("Could not append RTA_PREFSRC attribute: %s", strerror(-r));
+                        return r;
+                }
+        }
+
         r = sd_rtnl_message_route_set_scope(req, route->scope);
         if (r < 0) {
                 log_error("Could not set scope: %s", strerror(-r));
@@ -217,6 +229,17 @@ int route_configure(Route *route, Link *link,
                 }
         }
 
+        if (!in_addr_is_null(route->family, &route->prefsrc_addr)) {
+                if (route->family == AF_INET)
+                        r = sd_rtnl_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in);
+                else if (route->family == AF_INET6)
+                        r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6);
+                if (r < 0) {
+                        log_error("Could not append RTA_PREFSRC attribute: %s", strerror(-r));
+                        return r;
+                }
+        }
+
         r = sd_rtnl_message_route_set_scope(req, route->scope);
         if (r < 0) {
                 log_error("Could not set scope: %s", strerror(-r));