@@ -100,7 +100,10 @@ type_str(const NetplanNetDefinition* def)
100
100
g_assert (def -> backend_settings .passthrough != NULL );
101
101
GHashTable * passthrough = def -> backend_settings .passthrough ;
102
102
GHashTable * connection = g_hash_table_lookup (passthrough , "connection" );
103
- return g_hash_table_lookup (connection , "type" );
103
+ if (connection ) {
104
+ return g_hash_table_lookup (connection , "type" );
105
+ }
106
+ return NULL ;
104
107
// LCOV_EXCL_START
105
108
default :
106
109
g_assert_not_reached ();
@@ -634,6 +637,12 @@ write_nm_conf_access_point(const NetplanNetDefinition* def, const char* rootdir,
634
637
else
635
638
g_assert (ap == NULL );
636
639
640
+ nm_type = type_str (def );
641
+ if (def -> type == NETPLAN_DEF_TYPE_NM && nm_type == NULL ) {
642
+ g_set_error (error , NETPLAN_BACKEND_ERROR , NETPLAN_ERROR_UNSUPPORTED , "ERROR: %s: NetworkManager connection type undefined\n" , def -> id );
643
+ return FALSE;
644
+ }
645
+
637
646
if (def -> type == NETPLAN_DEF_TYPE_VLAN && def -> sriov_vlan_filter ) {
638
647
g_debug ("%s is defined as a hardware SR-IOV filtered VLAN, postponing creation" , def -> id );
639
648
return TRUE;
@@ -653,7 +662,6 @@ write_nm_conf_access_point(const NetplanNetDefinition* def, const char* rootdir,
653
662
g_key_file_set_string (kf , "connection" , "id" , nd_nm_id );
654
663
}
655
664
656
- nm_type = type_str (def );
657
665
if (nm_type && def -> type != NETPLAN_DEF_TYPE_NM )
658
666
g_key_file_set_string (kf , "connection" , "type" , nm_type );
659
667
@@ -1082,11 +1090,21 @@ netplan_state_finish_nm_write(
1082
1090
GString * tmp = NULL ;
1083
1091
guint unmanaged = nd -> backend == NETPLAN_BACKEND_NM ? 0 : 1 ;
1084
1092
1093
+ if (nd -> type == NETPLAN_DEF_TYPE_NM_PLACEHOLDER_ || nd -> backend == NETPLAN_BACKEND_OVS ) {
1094
+ iter = iter -> next ;
1095
+ continue ;
1096
+ }
1097
+
1098
+ nm_type = type_str (nd );
1099
+ if (nd -> type == NETPLAN_DEF_TYPE_NM && nm_type == NULL ) {
1100
+ /* Will happen when errors are ignored */
1101
+ iter = iter -> next ;
1102
+ continue ;
1103
+ }
1104
+
1085
1105
g_autofree char * netdef_id = _netplan_scrub_string (nd -> id );
1086
1106
/* Special case: manage or ignore any device of given type on empty "match: {}" stanza */
1087
1107
if (nd -> has_match && !nd -> match .driver && !nd -> match .mac && !nd -> match .original_name ) {
1088
- nm_type = type_str (nd );
1089
- g_assert (nm_type != NULL );
1090
1108
g_string_append_printf (nm_conf , "[device-netplan.%s.%s]\nmatch-device=type:%s\n"
1091
1109
"managed=%d\n\n" , netplan_def_type_name (nd -> type ),
1092
1110
netdef_id , nm_type , !unmanaged );
0 commit comments