@@ -254,6 +254,64 @@ write_routes_nm(const NetplanNetDefinition* def, GKeyFile *kf, gint family, GErr
254
254
j ++ ;
255
255
}
256
256
}
257
+
258
+ return TRUE;
259
+ }
260
+
261
+ STATIC gboolean
262
+ write_ip_rules_nm (const NetplanNetDefinition * def , GKeyFile * kf , gint family , GError * * error )
263
+ {
264
+ const gchar * group = NULL ;
265
+ gchar * tmp_key = NULL ;
266
+ GString * tmp_val = NULL ;
267
+
268
+ if (family == AF_INET )
269
+ group = "ipv4" ;
270
+ else if (family == AF_INET6 )
271
+ group = "ipv6" ;
272
+ g_assert (group != NULL );
273
+
274
+ if (def -> ip_rules != NULL ) {
275
+ for (unsigned i = 0 , j = 1 ; i < def -> ip_rules -> len ; ++ i ) {
276
+ const NetplanIPRule * cur_rule = g_array_index (def -> ip_rules , NetplanIPRule * , i );
277
+
278
+ if (cur_rule -> family != family )
279
+ continue ;
280
+
281
+ /* NetworkManager requires that priority be specified. This is
282
+ * also in-line with the iproute2 guidance that "Each rule should
283
+ * have an explicitly set unique priority value"[1].
284
+ * [1]http://www.policyrouting.org/iproute2.doc.html#ss9.6.1 */
285
+ if (cur_rule -> priority == NETPLAN_IP_RULE_PRIO_UNSPEC ) {
286
+ g_set_error (error , NETPLAN_BACKEND_ERROR , NETPLAN_ERROR_UNSUPPORTED ,
287
+ "ERROR: %s: The priority setting is mandatory for NetworkManager routing-policy\n" , def -> id );
288
+ return FALSE;
289
+ }
290
+
291
+ tmp_key = g_strdup_printf ("routing-rule%u" , j );
292
+ tmp_val = g_string_sized_new (200 );
293
+
294
+ g_string_printf (tmp_val , "priority %u" , cur_rule -> priority );
295
+
296
+ if (cur_rule -> from )
297
+ g_string_append_printf (tmp_val , " from %s" , cur_rule -> from );
298
+ if (cur_rule -> to )
299
+ g_string_append_printf (tmp_val , " to %s" , cur_rule -> to );
300
+ if (cur_rule -> tos != NETPLAN_IP_RULE_TOS_UNSPEC )
301
+ g_string_append_printf (tmp_val , " tos %u" , cur_rule -> tos );
302
+ if (cur_rule -> fwmark != NETPLAN_IP_RULE_FW_MARK_UNSPEC )
303
+ g_string_append_printf (tmp_val , " fwmark %u" , cur_rule -> fwmark );
304
+ if (cur_rule -> table != NETPLAN_ROUTE_TABLE_UNSPEC )
305
+ g_string_append_printf (tmp_val , " table %u" , cur_rule -> table );
306
+
307
+ g_key_file_set_string (kf , group , tmp_key , tmp_val -> str );
308
+ g_free (tmp_key );
309
+ g_string_free (tmp_val , TRUE);
310
+
311
+ j ++ ;
312
+ }
313
+ }
314
+
257
315
return TRUE;
258
316
}
259
317
@@ -457,6 +515,7 @@ write_wifi_auth_parameters(const NetplanAuthenticationSettings* auth, GKeyFile *
457
515
case NETPLAN_AUTH_KEY_MANAGEMENT_NONE :
458
516
break ;
459
517
case NETPLAN_AUTH_KEY_MANAGEMENT_WPA_PSK :
518
+ case NETPLAN_AUTH_KEY_MANAGEMENT_WPA_PSKSHA256 :
460
519
g_key_file_set_string (kf , "wifi-security" , "key-mgmt" , "wpa-psk" );
461
520
break ;
462
521
case NETPLAN_AUTH_KEY_MANAGEMENT_WPA_EAP :
@@ -716,6 +775,8 @@ write_nm_conf_access_point(const NetplanNetDefinition* def, const char* rootdir,
716
775
g_key_file_set_uint64 (kf , "vrf" , "table" , def -> vrf_table );
717
776
if (!write_routes_nm (def , kf , AF_INET , error ) || !write_routes_nm (def , kf , AF_INET6 , error ))
718
777
return FALSE;
778
+ if (!write_ip_rules_nm (def , kf , AF_INET , error ) || !write_ip_rules_nm (def , kf , AF_INET6 , error ))
779
+ return FALSE;
719
780
}
720
781
721
782
if (def -> type == NETPLAN_DEF_TYPE_VETH && def -> veth_peer_link ) {
@@ -871,6 +932,8 @@ write_nm_conf_access_point(const NetplanNetDefinition* def, const char* rootdir,
871
932
write_search_domains (def , "ipv4" , kf );
872
933
if (!write_routes_nm (def , kf , AF_INET , error ))
873
934
return FALSE;
935
+ if (!write_ip_rules_nm (def , kf , AF_INET , error ))
936
+ return FALSE;
874
937
}
875
938
876
939
if (!def -> dhcp4_overrides .use_routes ) {
@@ -917,6 +980,9 @@ write_nm_conf_access_point(const NetplanNetDefinition* def, const char* rootdir,
917
980
if (!write_routes_nm (def , kf , AF_INET6 , error ))
918
981
return FALSE;
919
982
983
+ if (!write_ip_rules_nm (def , kf , AF_INET6 , error ))
984
+ return FALSE;
985
+
920
986
if (!def -> dhcp6_overrides .use_routes ) {
921
987
g_key_file_set_boolean (kf , "ipv6" , "ignore-auto-routes" , TRUE);
922
988
g_key_file_set_boolean (kf , "ipv6" , "never-default" , TRUE);
0 commit comments