]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: take more route information into hash func
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 9 Sep 2019 15:17:28 +0000 (00:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 17 Sep 2019 12:53:42 +0000 (21:53 +0900)
src/network/networkd-dhcp4.c
src/network/networkd-route.c
src/network/networkd-route.h

index c5644f844b805e585c7ab386286beb80a36e63fe..d9951abe247fd1eb0af8106dc6cdcb12b49fb741 100644 (file)
@@ -181,7 +181,7 @@ static int link_set_dhcp_routes(Link *link) {
                  * the addresses now, let's not configure the routes either. */
                 return 0;
 
-        r = set_ensure_allocated(&link->dhcp_routes, &route_full_hash_ops);
+        r = set_ensure_allocated(&link->dhcp_routes, &route_hash_ops);
         if (r < 0)
                 return log_oom();
 
index c95737e7abdb9b87f8208384bf6f8b56cb905e8d..b6da560afe57f974886065578d81fbc97ffb5af1 100644 (file)
@@ -154,68 +154,6 @@ static void route_hash_func(const Route *route, struct siphash *state) {
 
         siphash24_compress(&route->family, sizeof(route->family), state);
 
-        switch (route->family) {
-        case AF_INET:
-        case AF_INET6:
-                /* Equality of routes are given by the 4-touple
-                   (dst_prefix,dst_prefixlen,tos,priority,table) */
-                siphash24_compress(&route->dst, FAMILY_ADDRESS_SIZE(route->family), state);
-                siphash24_compress(&route->dst_prefixlen, sizeof(route->dst_prefixlen), state);
-                siphash24_compress(&route->tos, sizeof(route->tos), state);
-                siphash24_compress(&route->priority, sizeof(route->priority), state);
-                siphash24_compress(&route->table, sizeof(route->table), state);
-
-                break;
-        default:
-                /* treat any other address family as AF_UNSPEC */
-                break;
-        }
-}
-
-static int route_compare_func(const Route *a, const Route *b) {
-        int r;
-
-        r = CMP(a->family, b->family);
-        if (r != 0)
-                return r;
-
-        switch (a->family) {
-        case AF_INET:
-        case AF_INET6:
-                r = CMP(a->dst_prefixlen, b->dst_prefixlen);
-                if (r != 0)
-                        return r;
-
-                r = CMP(a->tos, b->tos);
-                if (r != 0)
-                        return r;
-
-                r = CMP(a->priority, b->priority);
-                if (r != 0)
-                        return r;
-
-                r = CMP(a->table, b->table);
-                if (r != 0)
-                        return r;
-
-                r = memcmp(&a->dst, &b->dst, FAMILY_ADDRESS_SIZE(a->family));
-                if (r != 0)
-                        return r;
-
-                return memcmp(&a->gw, &b->gw, FAMILY_ADDRESS_SIZE(a->family));
-        default:
-                /* treat any other address family as AF_UNSPEC */
-                return 0;
-        }
-}
-
-DEFINE_PRIVATE_HASH_OPS(route_hash_ops, Route, route_hash_func, route_compare_func);
-
-static void route_full_hash_func(const Route *route, struct siphash *state) {
-        assert(route);
-
-        siphash24_compress(&route->family, sizeof(route->family), state);
-
         switch (route->family) {
         case AF_INET:
         case AF_INET6:
@@ -240,7 +178,7 @@ static void route_full_hash_func(const Route *route, struct siphash *state) {
         }
 }
 
-static int route_full_compare_func(const Route *a, const Route *b) {
+static int route_compare_func(const Route *a, const Route *b) {
         int r;
 
         r = CMP(a->family, b->family);
@@ -302,10 +240,10 @@ static int route_full_compare_func(const Route *a, const Route *b) {
 }
 
 DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
-                route_full_hash_ops,
+                route_hash_ops,
                 Route,
-                route_full_hash_func,
-                route_full_compare_func,
+                route_hash_func,
+                route_compare_func,
                 route_free);
 
 bool route_equal(Route *r1, Route *r2) {
index a24684362543925ce6eff34c8863868ab3129a88..89d54020db82465df71feccda373b477ee91d4a8 100644 (file)
@@ -49,7 +49,7 @@ struct Route {
         LIST_FIELDS(Route, routes);
 };
 
-extern const struct hash_ops route_full_hash_ops;
+extern const struct hash_ops route_hash_ops;
 
 int route_new(Route **ret);
 void route_free(Route *route);