From d59aba31a6b7c2417c8126e47571a5dd1f0fb78d80b529c7701be243f9673e81 Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Wed, 25 Mar 2020 19:41:57 +0000 Subject: [PATCH 1/3] - Update cloud-init-write-routes.patch (bsc#1165296) + Add the default gateway to the ifroute config file when specified as part of the subnet configuration + Fix typo to properly extrakt provided netmask data (bsc#1163178) OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=165 --- cloud-init-write-routes.patch | 11 +++++++++-- cloud-init.changes | 8 ++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cloud-init-write-routes.patch b/cloud-init-write-routes.patch index 92573e8..275faf1 100644 --- a/cloud-init-write-routes.patch +++ b/cloud-init-write-routes.patch @@ -8,7 +8,7 @@ from cloudinit import helpers from cloudinit import log as logging -@@ -172,7 +173,53 @@ class Distro(distros.Distro): +@@ -172,7 +173,60 @@ class Distro(distros.Distro): util.write_file(out_fn, str(conf), 0o644) def _write_network_config(self, netconfig): @@ -32,13 +32,20 @@ + subnets = config.get('subnets', []) + config_routes = '' + for subnet in subnets: ++ # Render the default gateway if it is present ++ gateway = subnet.get('gateway') ++ if gateway: ++ config_routes += ' '.join( ++ ['default', gateway, '-', '-\n'] ++ ) ++ # Render subnet routes + routes = subnet.get('routes', []) + for route in routes: + dest = route.get('destination') + if dest in default_nets: + dest = 'default' + if dest != 'default': -+ netmask = route.get('genmask') ++ netmask = route.get('netmask') + if netmask: + prefix = mask_to_net_prefix(netmask) + dest += '/' + str(prefix) diff --git a/cloud-init.changes b/cloud-init.changes index d02fec8..4315ca8 100644 --- a/cloud-init.changes +++ b/cloud-init.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Mar 25 18:31:32 UTC 2020 - Robert Schweikert + +- Update cloud-init-write-routes.patch (bsc#1165296) + + Add the default gateway to the ifroute config file when specified + as part of the subnet configuration + + Fix typo to properly extrakt provided netmask data (bsc#1163178) + ------------------------------------------------------------------- Thu Feb 13 14:07:50 UTC 2020 - Robert Schweikert From 62128da3ea4f390b85e2d37574f2242fa4ada68f8247ed6b73df8d3e1a994756 Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Thu, 26 Mar 2020 17:22:08 +0000 Subject: [PATCH 2/3] - Update cloud-init-write-routes.patch + Still need to consider the "network" configuration uption for the v1 config implementation. Fixes regression introduced with update from Wed Feb 12 19:30:42 OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=166 --- cloud-init-write-routes.patch | 2 +- cloud-init.changes | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cloud-init-write-routes.patch b/cloud-init-write-routes.patch index 275faf1..910bd3c 100644 --- a/cloud-init-write-routes.patch +++ b/cloud-init-write-routes.patch @@ -41,7 +41,7 @@ + # Render subnet routes + routes = subnet.get('routes', []) + for route in routes: -+ dest = route.get('destination') ++ dest = route.get('destination') or route.get('network') + if dest in default_nets: + dest = 'default' + if dest != 'default': diff --git a/cloud-init.changes b/cloud-init.changes index 4315ca8..0893642 100644 --- a/cloud-init.changes +++ b/cloud-init.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Mar 26 17:20:12 UTC 2020 - Robert Schweikert + +- Update cloud-init-write-routes.patch + + Still need to consider the "network" configuration uption + for the v1 config implementation. Fixes regression + introduced with update from Wed Feb 12 19:30:42 + ------------------------------------------------------------------- Wed Mar 25 18:31:32 UTC 2020 - Robert Schweikert From f618f6b3f1b9bea939efb024e9cf653c95b7c5bed902f9ed7a2a57140b621555 Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Fri, 27 Mar 2020 12:40:41 +0000 Subject: [PATCH 3/3] - Update cloud-init-write-routes.patch + In cases where the config contains 2 or more default gateway specifications for an interface only write the first default route, log warning message about skipped routes + Avoid writing invalid route specification if neither the network nor destination is specified in the route configuration OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=167 --- cloud-init-write-routes.patch | 29 +++++++++++++++++++---------- cloud-init.changes | 10 ++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/cloud-init-write-routes.patch b/cloud-init-write-routes.patch index 910bd3c..d7d52fc 100644 --- a/cloud-init-write-routes.patch +++ b/cloud-init-write-routes.patch @@ -8,7 +8,7 @@ from cloudinit import helpers from cloudinit import log as logging -@@ -172,7 +173,60 @@ class Distro(distros.Distro): +@@ -172,7 +173,69 @@ class Distro(distros.Distro): util.write_file(out_fn, str(conf), 0o644) def _write_network_config(self, netconfig): @@ -31,6 +31,7 @@ + if_name = config.get('name') + subnets = config.get('subnets', []) + config_routes = '' ++ has_default_route = False + for subnet in subnets: + # Render the default gateway if it is present + gateway = subnet.get('gateway') @@ -38,11 +39,12 @@ + config_routes += ' '.join( + ['default', gateway, '-', '-\n'] + ) ++ has_default_route = True + # Render subnet routes + routes = subnet.get('routes', []) + for route in routes: + dest = route.get('destination') or route.get('network') -+ if dest in default_nets: ++ if not dest or dest in default_nets: + dest = 'default' + if dest != 'default': + netmask = route.get('netmask') @@ -51,19 +53,26 @@ + dest += '/' + str(prefix) + if '/' not in dest: + LOG.warning( -+ 'Route destination has no prefix "%s"', dest ++ 'Skipping route; has no prefix "%s"', dest + ) ++ continue ++ if dest == 'default' and has_default_route: ++ LOG.warning( ++ '%s already has default route, skipping "%s"', ++ if_name, ' '.join([dest, gateway, '-', '-']) ++ ) ++ continue ++ if dest == 'default' and not has_default_route: ++ has_default_route = True + gateway = route.get('gateway') ++ if not gateway: ++ LOG.warning( ++ 'Missing gateway for "%s", skipping', dest ++ ) ++ continue + config_routes += ' '.join( + [dest, gateway, '-', '-\n'] + ) -+ if not config_routes: -+ dest = 'default' -+ gateway = subnet.get('gateway') -+ if gateway: -+ config_routes += ' '.join( -+ [dest, gateway, '-', '-\n'] -+ ) + if config_routes: + route_file = '/etc/sysconfig/network/ifroute-%s' % if_name + util.write_file(route_file, config_routes) diff --git a/cloud-init.changes b/cloud-init.changes index 0893642..4f57ad3 100644 --- a/cloud-init.changes +++ b/cloud-init.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Fri Mar 27 12:21:00 UTC 2020 - Robert Schweikert + +- Update cloud-init-write-routes.patch + + In cases where the config contains 2 or more default gateway + specifications for an interface only write the first default route, + log warning message about skipped routes + + Avoid writing invalid route specification if neither the network + nor destination is specified in the route configuration + ------------------------------------------------------------------- Thu Mar 26 17:20:12 UTC 2020 - Robert Schweikert