compat: Only create interface when configured to do so.
Add config option <compat_create_interfaces>: Denotes where or not to create interfaces when compat_* settings are active and it would be necessary to create an interface to be fully compliant. This could happen when inheriting bridge VLAN settings to an interface within a bridges bridge-ports setting but no interface stanza is found. Valid values are 0 and 1, the default is 1. Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
This commit is contained in:
		
							parent
							
								
									d86297f29c
								
							
						
					
					
						commit
						480fc5eecb
					
				
					 5 changed files with 27 additions and 1 deletions
				
			
		
							
								
								
									
										8
									
								
								dist/ifupdown-ng.conf.example
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								dist/ifupdown-ng.conf.example
									
										
									
									
										vendored
									
									
								
							|  | @ -17,6 +17,14 @@ allow_addon_scripts = 1 | ||||||
| # templates.  Valid values are 0 and 1, the default is 1. | # templates.  Valid values are 0 and 1, the default is 1. | ||||||
| allow_any_iface_as_template = 1 | allow_any_iface_as_template = 1 | ||||||
| 
 | 
 | ||||||
|  | # compat_create_interfaces: | ||||||
|  | # Denotes where or not to create interfaces when compat_* settings are | ||||||
|  | # active and it would be necessary to create an interface to be fully | ||||||
|  | # compliant.  This could happen when inheriting bridge VLAN settings to | ||||||
|  | # an interface within a bridges bridge-ports setting but no interface | ||||||
|  | # stanza is found.  Valid values are 0 and 1, the default is 1. | ||||||
|  | compat_create_interfaces = 1 | ||||||
|  | 
 | ||||||
| # compat_ifupdown2_bridge_ports_inherit_vlans: | # compat_ifupdown2_bridge_ports_inherit_vlans: | ||||||
| # In ifupdown2 <bridge-vids> as well as the <bridge-pvid> set on a bridge | # In ifupdown2 <bridge-vids> as well as the <bridge-pvid> set on a bridge | ||||||
| # interface will be inherited by all member ports if not set explicitly. | # interface will be inherited by all member ports if not set explicitly. | ||||||
|  |  | ||||||
|  | @ -60,6 +60,13 @@ Currently the following settings are supported in | ||||||
|   in order to require inheritance from specified templates. |   in order to require inheritance from specified templates. | ||||||
|   Valid values are `0` and `1`, the default is `1`. |   Valid values are `0` and `1`, the default is `1`. | ||||||
| 
 | 
 | ||||||
|  | * `compat_create_interfaces`: | ||||||
|  |   Denotes where or not to create interfaces when compat\_* settings are | ||||||
|  |   active and it would be necessary to create an interface to be fully | ||||||
|  |   compliant.  This could happen when inheriting bridge VLAN settings to | ||||||
|  |   an interface within a bridges bridge-ports setting but no interface | ||||||
|  |   stanza is found.  Valid values are `0` and `1`, the default is `1`. | ||||||
|  | 
 | ||||||
| * `compat_ifupdown2_bridge_ports_inherit_vlans`: In ifupdown2 `bridge-vids` | * `compat_ifupdown2_bridge_ports_inherit_vlans`: In ifupdown2 `bridge-vids` | ||||||
|   as well as the <bridge-pvid> set on a bridge interface will be inherited |   as well as the <bridge-pvid> set on a bridge interface will be inherited | ||||||
|   by all member ports if not set explicitly.  When set to `1` ifupdown-ng |   by all member ports if not set explicitly.  When set to `1` ifupdown-ng | ||||||
|  |  | ||||||
|  | @ -68,7 +68,7 @@ compat_ifupdown2_bridge_ports_inherit_vlans(struct lif_dict *collection) | ||||||
| 			if (entry) | 			if (entry) | ||||||
| 				bridge_port = entry->data; | 				bridge_port = entry->data; | ||||||
| 
 | 
 | ||||||
| 			else | 			else if (lif_config.compat_create_interfaces) | ||||||
| 			{ | 			{ | ||||||
| 				bridge_port = lif_interface_collection_find(collection, tokenp); | 				bridge_port = lif_interface_collection_find(collection, tokenp); | ||||||
| 				if (bridge_port == NULL) | 				if (bridge_port == NULL) | ||||||
|  | @ -78,6 +78,14 @@ compat_ifupdown2_bridge_ports_inherit_vlans(struct lif_dict *collection) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | 			/* We would have to creaet an interface, but shouldn't */ | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				fprintf(stderr, "compat: Missing interface stanza for bridge-port \"%s\" but should not create one.\n", | ||||||
|  | 				        tokenp); | ||||||
|  | 				continue; | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
| 			/* Maybe pimp bridge-pvid */ | 			/* Maybe pimp bridge-pvid */ | ||||||
| 			struct lif_dict_entry *port_pvid = lif_dict_find(&bridge_port->vars, "bridge-pvid"); | 			struct lif_dict_entry *port_pvid = lif_dict_find(&bridge_port->vars, "bridge-pvid"); | ||||||
| 			if (bridge_pvid && !port_pvid) | 			if (bridge_pvid && !port_pvid) | ||||||
|  |  | ||||||
|  | @ -21,6 +21,7 @@ | ||||||
| struct lif_config_file lif_config = { | struct lif_config_file lif_config = { | ||||||
| 	.allow_addon_scripts = true, | 	.allow_addon_scripts = true, | ||||||
| 	.allow_any_iface_as_template = true, | 	.allow_any_iface_as_template = true, | ||||||
|  | 	.compat_create_interfaces = true, | ||||||
| 	.compat_ifupdown2_bridge_ports_inherit_vlans = true, | 	.compat_ifupdown2_bridge_ports_inherit_vlans = true, | ||||||
| 	.implicit_template_conversion = true, | 	.implicit_template_conversion = true, | ||||||
| 	.use_hostname_for_dhcp = true, | 	.use_hostname_for_dhcp = true, | ||||||
|  | @ -48,6 +49,7 @@ set_bool_value(const char *key, const char *value, void *opaque) | ||||||
| static struct lif_config_handler handlers[] = { | static struct lif_config_handler handlers[] = { | ||||||
| 	{"allow_addon_scripts", set_bool_value, &lif_config.allow_addon_scripts}, | 	{"allow_addon_scripts", set_bool_value, &lif_config.allow_addon_scripts}, | ||||||
| 	{"allow_any_iface_as_template", set_bool_value, &lif_config.allow_any_iface_as_template}, | 	{"allow_any_iface_as_template", set_bool_value, &lif_config.allow_any_iface_as_template}, | ||||||
|  | 	{"compat_create_interfaces", set_bool_value, &lif_config.compat_create_interfaces}, | ||||||
| 	{"compat_ifupdown2_bridge_ports_inherit_vlans", set_bool_value, &lif_config.compat_ifupdown2_bridge_ports_inherit_vlans}, | 	{"compat_ifupdown2_bridge_ports_inherit_vlans", set_bool_value, &lif_config.compat_ifupdown2_bridge_ports_inherit_vlans}, | ||||||
| 	{"implicit_template_conversion", set_bool_value, &lif_config.implicit_template_conversion}, | 	{"implicit_template_conversion", set_bool_value, &lif_config.implicit_template_conversion}, | ||||||
| 	{"use_hostname_for_dhcp", set_bool_value, &lif_config.use_hostname_for_dhcp}, | 	{"use_hostname_for_dhcp", set_bool_value, &lif_config.use_hostname_for_dhcp}, | ||||||
|  |  | ||||||
|  | @ -21,6 +21,7 @@ | ||||||
| struct lif_config_file { | struct lif_config_file { | ||||||
| 	bool allow_addon_scripts; | 	bool allow_addon_scripts; | ||||||
| 	bool allow_any_iface_as_template; | 	bool allow_any_iface_as_template; | ||||||
|  | 	bool compat_create_interfaces; | ||||||
| 	bool compat_ifupdown2_bridge_ports_inherit_vlans; | 	bool compat_ifupdown2_bridge_ports_inherit_vlans; | ||||||
| 	bool implicit_template_conversion; | 	bool implicit_template_conversion; | ||||||
| 	bool use_hostname_for_dhcp; | 	bool use_hostname_for_dhcp; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue