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

Tom Gundersen tomegun at kemper.freedesktop.org
Wed Jul 23 00:29:30 PDT 2014


 src/libsystemd-network/dhcp6-protocol.h  |    1 -
 src/libsystemd-network/sd-dhcp6-client.c |    4 ----
 src/libsystemd/sd-rtnl/rtnl-message.c    |    5 +++--
 src/libsystemd/sd-rtnl/test-rtnl.c       |    2 +-
 src/network/networkd-link.c              |   16 ++++++++--------
 src/network/networkd-route.c             |   10 +++++++---
 src/network/networkd.h                   |    3 ++-
 src/systemd/sd-rtnl.h                    |    2 +-
 8 files changed, 22 insertions(+), 21 deletions(-)

New commits:
commit 6946f79d98430fccb1e0c947c135c807bc73a9c5
Author: Dan Williams <dcbw at redhat.com>
Date:   Tue Jul 22 17:18:14 2014 -0500

    dhcp-network: remove unused DHCP6_STATE_RS
    
    Probably a left-over from when router solicitations were
    requested in the DHCP6 code.  But since they are now separate,
    this state is no longer needed.

diff --git a/src/libsystemd-network/dhcp6-protocol.h b/src/libsystemd-network/dhcp6-protocol.h
index e9ae598..eaa6717 100644
--- a/src/libsystemd-network/dhcp6-protocol.h
+++ b/src/libsystemd-network/dhcp6-protocol.h
@@ -71,7 +71,6 @@ enum {
 
 enum DHCP6State {
         DHCP6_STATE_STOPPED                     = 0,
-        DHCP6_STATE_RS                          = 1,
         DHCP6_STATE_SOLICITATION                = 2,
         DHCP6_STATE_REQUEST                     = 3,
         DHCP6_STATE_BOUND                       = 4,
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 4f60578..13bed67 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -293,7 +293,6 @@ static int client_send_message(sd_dhcp6_client *client) {
                 break;
 
         case DHCP6_STATE_STOPPED:
-        case DHCP6_STATE_RS:
         case DHCP6_STATE_BOUND:
                 return -EINVAL;
         }
@@ -446,7 +445,6 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
                 break;
 
         case DHCP6_STATE_STOPPED:
-        case DHCP6_STATE_RS:
         case DHCP6_STATE_BOUND:
                 return 0;
         }
@@ -843,7 +841,6 @@ static int client_receive_message(sd_event_source *s, int fd, uint32_t revents,
                 break;
 
         case DHCP6_STATE_STOPPED:
-        case DHCP6_STATE_RS:
                 return 0;
         }
 
@@ -874,7 +871,6 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
 
         switch (state) {
         case DHCP6_STATE_STOPPED:
-        case DHCP6_STATE_RS:
         case DHCP6_STATE_SOLICITATION:
 
                 r = client_ensure_iaid(client);

commit 28cc555d8504c9429776aedbbe1fee7101258578
Author: Dan Williams <dcbw at redhat.com>
Date:   Tue Jul 22 16:54:47 2014 -0500

    networkd: set route protocol
    
    All routes added by networkd are currently set RTPROT_BOOT, which according
    to the kernel means "Route installed during boot" (rtnetlink.h).  But this
    is not always the case as networkd changes routing after boot too.  Since
    the kernel gives more detailed protocols, use them.
    
    With this patch, user-configured static routes now use RTPROT_STATIC (which
    they are) and DHCP routes use RTPROT_DHCP.  There is no define for IPv4LL
    yet, so those are installed as RTPROT_STATIC (though perhaps RTPROT_RA is
    better?).
    
    [tomegun: fixup
    src/network/networkd-link.c:972:33: error: too few arguments to function 'route_new_dynamic']

diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 7f2e398..c50d0ea 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -133,7 +133,8 @@ int sd_rtnl_message_route_set_scope(sd_rtnl_message *m, unsigned char scope) {
 }
 
 int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
-                              uint16_t nlmsg_type, int rtm_family) {
+                              uint16_t nlmsg_type, int rtm_family,
+                              unsigned char rtm_protocol) {
         struct rtmsg *rtm;
         int r;
 
@@ -154,7 +155,7 @@ int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
         rtm->rtm_scope = RT_SCOPE_UNIVERSE;
         rtm->rtm_type = RTN_UNICAST;
         rtm->rtm_table = RT_TABLE_MAIN;
-        rtm->rtm_protocol = RTPROT_BOOT;
+        rtm->rtm_protocol = rtm_protocol;
 
         return 0;
 }
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 082c9e4..4b6e533 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -132,7 +132,7 @@ static void test_route(void) {
         uint32_t index = 2, u32_data;
         int r;
 
-        r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET);
+        r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET, RTPROT_STATIC);
         if (r < 0) {
                 log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
                 return;
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 0a6f524..86d4b83 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -415,7 +415,7 @@ static int link_set_dhcp_routes(Link *link) {
         for (i = 0; i < n; i++) {
                 _cleanup_route_free_ Route *route = NULL;
 
-                r = route_new_dynamic(&route);
+                r = route_new_dynamic(&route, RTPROT_DHCP);
                 if (r < 0) {
                         log_error_link(link, "Could not allocate route: %s",
                                        strerror(-r));
@@ -481,7 +481,7 @@ static int link_enter_set_routes(Link *link) {
                 }
 
                 if (r != -ENOENT) {
-                        r = route_new_dynamic(&route);
+                        r = route_new_dynamic(&route, RTPROT_STATIC);
                         if (r < 0) {
                                 log_error_link(link, "Could not allocate route: %s",
                                                strerror(-r));
@@ -517,14 +517,14 @@ static int link_enter_set_routes(Link *link) {
                 }
 
                 if (r >= 0) {
-                        r = route_new_dynamic(&route);
+                        r = route_new_dynamic(&route, RTPROT_DHCP);
                         if (r < 0) {
                                 log_error_link(link, "Could not allocate route: %s",
                                                strerror(-r));
                                 return r;
                         }
 
-                        r = route_new_dynamic(&route_gw);
+                        r = route_new_dynamic(&route_gw, RTPROT_DHCP);
                         if (r < 0) {
                                 log_error_link(link, "Could not allocate route: %s",
                                                strerror(-r));
@@ -969,7 +969,7 @@ static int dhcp_lease_lost(Link *link) {
                         for (i = 0; i < n; i++) {
                                 _cleanup_route_free_ Route *route = NULL;
 
-                                r = route_new_dynamic(&route);
+                                r = route_new_dynamic(&route, RTPROT_UNSPEC);
                                 if (r >= 0) {
                                         route->family = AF_INET;
                                         route->in_addr.in = routes[i].gw_addr;
@@ -989,7 +989,7 @@ static int dhcp_lease_lost(Link *link) {
                         _cleanup_route_free_ Route *route_gw = NULL;
                         _cleanup_route_free_ Route *route = NULL;
 
-                        r = route_new_dynamic(&route_gw);
+                        r = route_new_dynamic(&route_gw, RTPROT_UNSPEC);
                         if (r >= 0) {
                                 route_gw->family = AF_INET;
                                 route_gw->dst_addr.in = gateway;
@@ -999,7 +999,7 @@ static int dhcp_lease_lost(Link *link) {
                                 route_drop(route_gw, link, &route_drop_handler);
                         }
 
-                        r = route_new_dynamic(&route);
+                        r = route_new_dynamic(&route, RTPROT_UNSPEC);
                         if (r >= 0) {
                                 route->family = AF_INET;
                                 route->in_addr.in = gateway;
@@ -1316,7 +1316,7 @@ static int ipv4ll_address_lost(Link *link) {
 
                 address_drop(address, link, &address_drop_handler);
 
-                r = route_new_dynamic(&route);
+                r = route_new_dynamic(&route, RTPROT_UNSPEC);
                 if (r < 0) {
                         log_error_link(link, "Could not allocate route: %s",
                                        strerror(-r));
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 8949299..00fd952 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -49,6 +49,7 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
 
         route->family = AF_UNSPEC;
         route->scope = RT_SCOPE_UNIVERSE;
+        route->protocol = RTPROT_STATIC;
 
         route->network = network;
 
@@ -65,7 +66,7 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
         return 0;
 }
 
-int route_new_dynamic(Route **ret) {
+int route_new_dynamic(Route **ret, unsigned char rtm_protocol) {
         _cleanup_route_free_ Route *route = NULL;
 
         route = new0(Route, 1);
@@ -74,6 +75,7 @@ int route_new_dynamic(Route **ret) {
 
         route->family = AF_UNSPEC;
         route->scope = RT_SCOPE_UNIVERSE;
+        route->protocol = rtm_protocol;
 
         *ret = route;
         route = NULL;
@@ -108,7 +110,8 @@ int route_drop(Route *route, Link *link,
         assert(route->family == AF_INET || route->family == AF_INET6);
 
         r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
-                                      RTM_DELROUTE, route->family);
+                                      RTM_DELROUTE, route->family,
+                                      route->protocol);
         if (r < 0) {
                 log_error("Could not create RTM_DELROUTE message: %s", strerror(-r));
                 return r;
@@ -181,7 +184,8 @@ int route_configure(Route *route, Link *link,
         assert(route->family == AF_INET || route->family == AF_INET6);
 
         r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
-                                      RTM_NEWROUTE, route->family);
+                                      RTM_NEWROUTE, route->family,
+                                      route->protocol);
         if (r < 0) {
                 log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
                 return r;
diff --git a/src/network/networkd.h b/src/network/networkd.h
index f1c7f20..7d291e5 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -137,6 +137,7 @@ struct Route {
         unsigned char dst_prefixlen;
         unsigned char scope;
         uint32_t metrics;
+        unsigned char protocol;  /* RTPROT_* */
 
         union in_addr_union in_addr;
         union in_addr_union dst_addr;
@@ -305,7 +306,7 @@ const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsig
 
 /* Route */
 int route_new_static(Network *network, unsigned section, Route **ret);
-int route_new_dynamic(Route **ret);
+int route_new_dynamic(Route **ret, unsigned char rtm_protocol);
 void route_free(Route *route);
 int route_configure(Route *route, Link *link, sd_rtnl_message_handler_t callback);
 int route_drop(Route *route, Link *link, sd_rtnl_message_handler_t callback);
diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h
index 5cd26d9..47bb232 100644
--- a/src/systemd/sd-rtnl.h
+++ b/src/systemd/sd-rtnl.h
@@ -72,7 +72,7 @@ int sd_rtnl_message_new_addr_update(sd_rtnl *rtnl, sd_rtnl_message **ret, int in
 int sd_rtnl_message_new_addr(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t msg_type, int index,
                              int family);
 int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t nlmsg_type,
-                              int rtm_family);
+                              int rtm_family, unsigned char rtm_protocol);
 
 sd_rtnl_message *sd_rtnl_message_ref(sd_rtnl_message *m);
 sd_rtnl_message *sd_rtnl_message_unref(sd_rtnl_message *m);



More information about the systemd-commits mailing list