summaryrefslogtreecommitdiff
path: root/src/nm-ip6-config.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-07-27 16:28:02 +0200
committerThomas Haller <thaller@redhat.com>2020-07-31 08:53:05 +0200
commitba9c15028694ff84781b1bbab2dbaa3a706ef444 (patch)
tree66cf4bc972ee3ec8818400d82dc4181fdf7b43bb /src/nm-ip6-config.c
parent8225785956d2f809eed9e10fd5b5c11e30fb1699 (diff)
downloadNetworkManager-ba9c15028694ff84781b1bbab2dbaa3a706ef444.tar.gz
core: inline _add_local_route_from_addr[46] helper function
In this case, the functions are only called once. Having a helper function that has no clear, unique purpose does not necessarily make the code simpler. Also, NMIP[46]Config is going to change completely. It will thereby move this code (and change it). Doing that is simpler, if we see all the relevant parts in one place.
Diffstat (limited to 'src/nm-ip6-config.c')
-rw-r--r--src/nm-ip6-config.c72
1 files changed, 29 insertions, 43 deletions
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
index 00865734c5..cf7aa59f0d 100644
--- a/src/nm-ip6-config.c
+++ b/src/nm-ip6-config.c
@@ -364,46 +364,6 @@ nm_ip6_config_update_routes_metric (NMIP6Config *self, gint64 metric)
g_object_thaw_notify (G_OBJECT (self));
}
-static void
-_add_multicast_route6 (NMIP6Config *self, int ifindex)
-{
- nm_auto_nmpobj NMPObject *r = NULL;
- NMPlatformIP6Route *route;
-
- r = nmp_object_new (NMP_OBJECT_TYPE_IP6_ROUTE, NULL);
- route = NMP_OBJECT_CAST_IP6_ROUTE (r);
- route->ifindex = ifindex;
- route->network.s6_addr[0] = 0xffu;
- route->plen = 8;
- route->table_coerced = nm_platform_route_table_coerce (RT_TABLE_LOCAL);
- route->type_coerced = nm_platform_route_type_coerce (RTN_UNICAST);
- route->metric = 256;
-
- _add_route (self, r, NULL, NULL);
-}
-
-static void
-_add_local_route_from_addr6 (NMIP6Config * self,
- const NMPlatformIP6Address *addr,
- int ifindex,
- guint32 route_table,
- gboolean is_vrf)
-{
- nm_auto_nmpobj NMPObject *r = NULL;
- NMPlatformIP6Route * route;
-
- r = nmp_object_new (NMP_OBJECT_TYPE_IP6_ROUTE, NULL);
- route = NMP_OBJECT_CAST_IP6_ROUTE (r);
- route->ifindex = ifindex;
- route->network = addr->address;
- route->plen = 128;
- route->type_coerced = nm_platform_route_type_coerce (RTN_LOCAL);
- route->metric = 0;
- route->table_coerced = nm_platform_route_table_coerce (is_vrf ? route_table : RT_TABLE_LOCAL);
-
- _add_route (self, r, NULL, NULL);
-}
-
void
nm_ip6_config_add_dependent_routes (NMIP6Config *self,
guint32 route_table,
@@ -426,7 +386,21 @@ nm_ip6_config_add_dependent_routes (NMIP6Config *self,
* For manually added IPv6 routes, add the device routes explicitly. */
/* Pre-generate multicast route */
- _add_multicast_route6 (self, ifindex);
+ {
+ nm_auto_nmpobj NMPObject *r = NULL;
+ NMPlatformIP6Route *route;
+
+ r = nmp_object_new (NMP_OBJECT_TYPE_IP6_ROUTE, NULL);
+ route = NMP_OBJECT_CAST_IP6_ROUTE (r);
+ route->ifindex = ifindex;
+ route->network.s6_addr[0] = 0xffu;
+ route->plen = 8;
+ route->table_coerced = nm_platform_route_table_coerce (RT_TABLE_LOCAL);
+ route->type_coerced = nm_platform_route_type_coerce (RTN_UNICAST);
+ route->metric = 256;
+
+ _add_route (self, r, NULL, NULL);
+ }
nm_ip_config_iter_ip6_address_for_each (&iter, self, &my_addr) {
NMPlatformIP6Route *route;
@@ -436,8 +410,20 @@ nm_ip6_config_add_dependent_routes (NMIP6Config *self,
if (my_addr->external)
continue;
- /* Pre-generate local route added by kernel */
- _add_local_route_from_addr6 (self, my_addr, ifindex, route_table, is_vrf);
+ {
+ nm_auto_nmpobj NMPObject *r = NULL;
+
+ /* Pre-generate local route added by kernel */
+ r = nmp_object_new (NMP_OBJECT_TYPE_IP6_ROUTE, NULL);
+ route = NMP_OBJECT_CAST_IP6_ROUTE (r);
+ route->ifindex = ifindex;
+ route->network = my_addr->address;
+ route->plen = 128;
+ route->type_coerced = nm_platform_route_type_coerce (RTN_LOCAL);
+ route->metric = 0;
+ route->table_coerced = nm_platform_route_table_coerce (is_vrf ? route_table : RT_TABLE_LOCAL);
+ _add_route (self, r, NULL, NULL);
+ }
if (NM_FLAGS_HAS (my_addr->n_ifa_flags, IFA_F_NOPREFIXROUTE))
continue;