core: don't use flags for nm_system_apply_ip[46]_config
nm_platform_*_sync() functions check the cached kernel configuration items (addresses, routes) before adding addresses to the kernel. Therefore we don't need to be so careful about pushing NetworkManager configuration to the kernel. This patch helps to avoid having to compare nm_ip[46]_config objects, which should only be created when a configuration change is being performed.
This commit is contained in:
@@ -4344,7 +4344,7 @@ nm_device_set_ip4_config (NMDevice *self,
|
||||
priv->ip4_config = g_object_ref (new_config);
|
||||
|
||||
if (commit)
|
||||
success = nm_system_apply_ip4_config (ip_ifindex, new_config, nm_device_get_priority (self), diff);
|
||||
success = nm_system_apply_ip4_config (ip_ifindex, new_config, nm_device_get_priority (self));
|
||||
|
||||
if (success || !commit) {
|
||||
/* Export over D-Bus */
|
||||
@@ -4401,7 +4401,7 @@ nm_device_set_ip6_config (NMDevice *self,
|
||||
priv->ip6_config = g_object_ref (new_config);
|
||||
|
||||
if (commit)
|
||||
success = nm_system_apply_ip6_config (ip_ifindex, new_config, nm_device_get_priority (self), diff);
|
||||
success = nm_system_apply_ip6_config (ip_ifindex, new_config, nm_device_get_priority (self));
|
||||
|
||||
if (success || !commit) {
|
||||
/* Export over D-Bus */
|
||||
|
@@ -1625,8 +1625,7 @@ vpn_connection_deactivated (NMPolicy *policy, NMVPNConnection *vpn)
|
||||
if (parent_ip4) {
|
||||
if (!nm_system_apply_ip4_config (nm_device_get_ip_ifindex (parent),
|
||||
parent_ip4,
|
||||
nm_device_get_priority (parent),
|
||||
NM_IP4_COMPARE_FLAG_ADDRESSES | NM_IP4_COMPARE_FLAG_ROUTES)) {
|
||||
nm_device_get_priority (parent))) {
|
||||
nm_log_err (LOGD_VPN, "failed to re-apply VPN parent device IPv4 addresses and routes.");
|
||||
}
|
||||
}
|
||||
@@ -1646,8 +1645,7 @@ vpn_connection_deactivated (NMPolicy *policy, NMVPNConnection *vpn)
|
||||
if (parent_ip6) {
|
||||
if (!nm_system_apply_ip6_config (nm_device_get_ip_ifindex (parent),
|
||||
parent_ip6,
|
||||
nm_device_get_priority (parent),
|
||||
NM_IP6_COMPARE_FLAG_ADDRESSES | NM_IP6_COMPARE_FLAG_ROUTES)) {
|
||||
nm_device_get_priority (parent))) {
|
||||
nm_log_err (LOGD_VPN, "failed to re-apply VPN parent device IPv6 addresses and routes.");
|
||||
}
|
||||
}
|
||||
|
@@ -144,17 +144,16 @@ nm_system_add_ip4_vpn_gateway_route (NMDevice *parent_device, guint32 vpn_gw)
|
||||
*
|
||||
*/
|
||||
gboolean
|
||||
nm_system_apply_ip4_config (int ifindex,
|
||||
NMIP4Config *config,
|
||||
int priority,
|
||||
NMIP4ConfigCompareFlags flags)
|
||||
nm_system_apply_ip4_config (int ifindex, NMIP4Config *config, int priority)
|
||||
{
|
||||
int mtu = nm_ip4_config_get_mtu (config);
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (config != NULL, FALSE);
|
||||
|
||||
if (flags & NM_IP4_COMPARE_FLAG_ADDRESSES) {
|
||||
/* Addresses */
|
||||
{
|
||||
int count = nm_ip4_config_get_num_addresses (config);
|
||||
NMIP4Address *config_address;
|
||||
GArray *addresses = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP4Address), count);
|
||||
@@ -172,7 +171,8 @@ nm_system_apply_ip4_config (int ifindex,
|
||||
g_array_unref (addresses);
|
||||
}
|
||||
|
||||
if (flags & NM_IP4_COMPARE_FLAG_ROUTES) {
|
||||
/* Routes */
|
||||
{
|
||||
int count = nm_ip4_config_get_num_routes (config);
|
||||
NMIP4Route *config_route;
|
||||
GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP4Route), count);
|
||||
@@ -205,10 +205,9 @@ nm_system_apply_ip4_config (int ifindex,
|
||||
g_array_unref (routes);
|
||||
}
|
||||
|
||||
if (flags & NM_IP4_COMPARE_FLAG_MTU) {
|
||||
if (nm_ip4_config_get_mtu (config))
|
||||
nm_platform_link_set_mtu (ifindex, nm_ip4_config_get_mtu (config));
|
||||
}
|
||||
/* MTU */
|
||||
if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
|
||||
nm_platform_link_set_mtu (ifindex, mtu);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -323,15 +322,15 @@ nm_system_add_ip6_vpn_gateway_route (NMDevice *parent_device,
|
||||
gboolean
|
||||
nm_system_apply_ip6_config (int ifindex,
|
||||
NMIP6Config *config,
|
||||
int priority,
|
||||
NMIP6ConfigCompareFlags flags)
|
||||
int priority)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (config != NULL, FALSE);
|
||||
|
||||
if (flags & NM_IP6_COMPARE_FLAG_ADDRESSES) {
|
||||
/* Addresses */
|
||||
{
|
||||
int count = nm_ip6_config_get_num_addresses (config);
|
||||
NMIP6Address *config_address;
|
||||
GArray *addresses = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP6Address), count);
|
||||
@@ -349,7 +348,8 @@ nm_system_apply_ip6_config (int ifindex,
|
||||
g_array_unref (addresses);
|
||||
}
|
||||
|
||||
if (flags & NM_IP6_COMPARE_FLAG_ROUTES) {
|
||||
/* Routes */
|
||||
{
|
||||
int count = nm_ip6_config_get_num_routes (config);
|
||||
NMIP6Route *config_route;
|
||||
GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP6Route), count);
|
||||
|
@@ -34,13 +34,11 @@ NMPlatformIP6Route *nm_system_add_ip6_vpn_gateway_route (NMDevice *parent_device
|
||||
|
||||
gboolean nm_system_apply_ip4_config (int ifindex,
|
||||
NMIP4Config *config,
|
||||
int priority,
|
||||
NMIP4ConfigCompareFlags flags);
|
||||
int priority);
|
||||
|
||||
gboolean nm_system_apply_ip6_config (int ifindex,
|
||||
NMIP6Config *config,
|
||||
int priority,
|
||||
NMIP6ConfigCompareFlags flags);
|
||||
int priority);
|
||||
|
||||
gboolean nm_system_apply_bonding_config (const char *iface,
|
||||
NMSettingBond *s_bond);
|
||||
|
@@ -609,14 +609,12 @@ nm_vpn_connection_apply_config (NMVPNConnection *connection)
|
||||
nm_platform_link_set_up (priv->ip_ifindex);
|
||||
|
||||
if (priv->ip4_config) {
|
||||
if (!nm_system_apply_ip4_config (priv->ip_ifindex, priv->ip4_config,
|
||||
0, NM_IP4_COMPARE_FLAG_ALL))
|
||||
if (!nm_system_apply_ip4_config (priv->ip_ifindex, priv->ip4_config, 0))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->ip6_config) {
|
||||
if (!nm_system_apply_ip6_config (priv->ip_ifindex, priv->ip6_config,
|
||||
0, NM_IP6_COMPARE_FLAG_ALL))
|
||||
if (!nm_system_apply_ip6_config (priv->ip_ifindex, priv->ip6_config, 0))
|
||||
/* FIXME: remove ip4 config */
|
||||
return FALSE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user