diff --git a/config/puppet-modules/puppet-network/debian/deb_folder/patches/0006-Use-prefix_len-for-default-routes.patch b/config/puppet-modules/puppet-network/debian/deb_folder/patches/0006-Use-prefix_len-for-default-routes.patch new file mode 100644 index 000000000..ca4cf15ee --- /dev/null +++ b/config/puppet-modules/puppet-network/debian/deb_folder/patches/0006-Use-prefix_len-for-default-routes.patch @@ -0,0 +1,35 @@ +From c26d6507ef7db08738073b8b11ff5ce4c2851c32 Mon Sep 17 00:00:00 2001 +From: Andre Kantek +Date: Tue, 13 Sep 2022 11:10:11 -0300 +Subject: [PATCH] Use prefix_len for default routes + +Signed-off-by: Andre Fernando Zanella Kantek +--- + lib/puppet/provider/network_route/routes.rb | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/puppet/provider/network_route/routes.rb b/lib/puppet/provider/network_route/routes.rb +index 0874b1d..ec2d1fe 100644 +--- a/lib/puppet/provider/network_route/routes.rb ++++ b/lib/puppet/provider/network_route/routes.rb +@@ -76,7 +76,7 @@ Puppet::Type.type(:network_route).provide(:routes) do + if route[0] == 'default' + name = 'default' + route_hash[name][:network] = 'default' +- route_hash[name][:netmask] = '0.0.0.0' ++ route_hash[name][:netmask] = '0' + else + # use the CIDR version of the target as :name + name = "#{route[0]}/#{IPAddr.new(route[1]).to_i.to_s(2).count('1')}" +@@ -105,7 +105,7 @@ Puppet::Type.type(:network_route).provide(:routes) do + raise Puppet::Error, "#{provider.name} is missing the required parameter 'gateway'." if provider.gateway.nil? + raise Puppet::Error, "#{provider.name} is missing the required parameter 'interface'." if provider.interface.nil? + +- netmask = (provider.name == 'default' ? '0.0.0.0' : provider.netmask) ++ netmask = (provider.name == 'default' ? '0' : provider.netmask) + + contents << "#{provider.network} #{netmask} #{provider.gateway} #{provider.interface}" + contents << (provider.options == :absent ? "\n" : " #{provider.options}\n") +-- +2.17.1 + diff --git a/config/puppet-modules/puppet-network/debian/deb_folder/patches/series b/config/puppet-modules/puppet-network/debian/deb_folder/patches/series index 3883cb55a..363e9edde 100644 --- a/config/puppet-modules/puppet-network/debian/deb_folder/patches/series +++ b/config/puppet-modules/puppet-network/debian/deb_folder/patches/series @@ -2,4 +2,5 @@ 0002-set-provider-mode-when-formatting-interfaces-file.patch 0003-set-routes-file-to-var-run-network-scripts.puppet.patch 0004-Save-dir-path-variable-with-distinct-names.patch -0005-Add-options-content-to-routes-file.patch \ No newline at end of file +0005-Add-options-content-to-routes-file.patch +0006-Use-prefix_len-for-default-routes.patch \ No newline at end of file diff --git a/networking/ifupdown-extra/debian/deb_patches/0004-Handle-default-route-creation.patch b/networking/ifupdown-extra/debian/deb_patches/0004-Handle-default-route-creation.patch new file mode 100644 index 000000000..6c76861a4 --- /dev/null +++ b/networking/ifupdown-extra/debian/deb_patches/0004-Handle-default-route-creation.patch @@ -0,0 +1,152 @@ +From 946aea4142d5d0acea03c3f72509fd2285f7f73f Mon Sep 17 00:00:00 2001 +From: Andre Kantek +Date: Tue, 13 Sep 2022 11:02:35 -0300 +Subject: [PATCH] Handle default route creation + +Signed-off-by: Andre Kantek +--- + debian/ifupdown-extra.networking-routes.init | 34 ++++++++++++++------ + if-up-scripts/static-routes | 30 ++++++++++++----- + 2 files changed, 46 insertions(+), 18 deletions(-) + +diff --git a/debian/ifupdown-extra.networking-routes.init b/debian/ifupdown-extra.networking-routes.init +index db1254d..e9097d1 100755 +--- a/debian/ifupdown-extra.networking-routes.init ++++ b/debian/ifupdown-extra.networking-routes.init +@@ -81,6 +81,20 @@ function get_prefix_length { + fi + } + ++# if route is default, remove prefix_len ++function get_linux_network { ++ network=$1 ++ netmask=$2 ++ local prefix_len ++ local linux_network ++ prefix_len=$(get_prefix_length ${netmask}) ++ linux_network="${network}${prefix_len}" ++ if [ "${network}" == "default" ]; then ++ linux_network="${network}" ++ fi ++ echo "${linux_network}" ++} ++ + # Functions to read the route file and process it + + +@@ -118,19 +132,19 @@ del_global_routes() { + cat $ROUTEFILE | egrep "^[^#].*$" | + while read network netmask gateway interface ; do + if [ -n "$interface" ] && [ -n "$network" ] && [ -n "$netmask" ] && [ -n "$gateway" ] ; then +- local prefix_len +- prefix_len=$(get_prefix_length ${netmask}) ++ local linux_network ++ linux_network=$(get_linux_network ${network} ${netmask}) + if [ "$gateway" != "reject" ] ; then + [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Deleting global route for $network / $netmask through gateway $gateway" + if [ "$interface" != "any" ] ; then +- run_route del ${network}${prefix_len} via ${gateway} dev ${interface} ++ run_route del ${linux_network} via ${gateway} dev ${interface} + else +- run_route del ${network}${prefix_len} via ${gateway} ++ run_route del ${linux_network} via ${gateway} + fi + [ $? -ne 0 ] && ret=$? + else + [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Deleting reject route for $network / $netmask" +- run_route del ${network}${prefix_len} reject ++ run_route del ${linux_network} reject + [ $? -ne 0 ] && ret=$? + fi + +@@ -147,19 +161,19 @@ add_global_routes() { + cat $ROUTEFILE | egrep "^[^#].*$" | + while read network netmask gateway interface ; do + if [ -n "$interface" ] && [ -n "$network" ] && [ -n "$netmask" ] && [ -n "$gateway" ] ; then +- local prefix_len +- prefix_len=$(get_prefix_length ${netmask}) ++ local linux_network ++ linux_network=$(get_linux_network ${network} ${netmask}) + if [ "$gateway" != "reject" ] ; then + [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Adding global route for $network / $netmask through gateway $gateway" + if [ "$interface" != "any" ] ; then +- run_route add ${network}${prefix_len} via ${gateway} dev ${interface} ++ run_route add ${linux_network} via ${gateway} dev ${interface} + else +- run_route add ${network}${prefix_len} via ${gateway} ++ run_route add ${linux_network} via ${gateway} + fi + [ $? -ne 0 ] && ret=$? + else + [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Adding global reject route for $network / $netmask" +- run_route add ${network}${prefix_len} reject ++ run_route add ${linux_network} reject + [ $? -ne 0 ] && ret=$? + fi + +diff --git a/if-up-scripts/static-routes b/if-up-scripts/static-routes +index 867303d..1341f43 100755 +--- a/if-up-scripts/static-routes ++++ b/if-up-scripts/static-routes +@@ -85,6 +85,20 @@ function get_prefix_length { + fi + } + ++# if route is default, remove prefix_len ++function get_linux_network { ++ network=$1 ++ netmask=$2 ++ local prefix_len ++ local linux_network ++ prefix_len=$(get_prefix_length ${netmask}) ++ linux_network="${network}${prefix_len}" ++ if [ "${network}" == "default" ]; then ++ linux_network="${network}" ++ fi ++ echo "${linux_network}" ++} ++ + del_static_routes() { + # NOTE: We actually don't have to remove routes if downing an interface + # since they will be removed nevertheless. In any case, this +@@ -93,14 +107,14 @@ del_static_routes() { + cat $ROUTEFILE | egrep "^[^#].*[[:space:]]${IFACE}[[:space:]]*$" | + while read network netmask gateway interface ; do + if [ -n "$interface" ] && [ -n "$network" ] && [ -n "$netmask" ] && [ -n "$gateway" ] ; then +- local prefix_len +- prefix_len=$(get_prefix_length ${netmask}) ++ local linux_network ++ linux_network=$(get_linux_network ${network} ${netmask}) + if [ "$gateway" != "reject" ] ; then + [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Deleting route for $network / $netmask through gateway $gateway at $interface" +- ip route del ${network}${prefix_len} via ${gateway} dev ${interface} ++ ip route del ${linux_network} via ${gateway} dev ${interface} + else + [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Deleting reject route for $network / $netmask when bringing up $interface" +- ip route del ${network}${prefix_len} reject ++ ip route del ${linux_network} reject + fi + + else +@@ -113,14 +127,14 @@ add_static_routes() { + cat $ROUTEFILE | egrep "^[^#].*[[:space:]]${IFACE}[[:space:]]*$" | + while read network netmask gateway interface ; do + if [ -n "$interface" ] && [ -n "$network" ] && [ -n "$netmask" ] && [ -n "$gateway" ] ; then +- local prefix_len +- prefix_len=$(get_prefix_length ${netmask}) ++ local linux_network ++ linux_network=$(get_linux_network ${network} ${netmask}) + if [ "$gateway" != "reject" ] && [ "$gateway" != "blackhole" ] ; then + [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Adding route for $network / $netmask through gateway $gateway at $interface" +- ip route add ${network}${prefix_len} via ${gateway} dev ${interface} ++ ip route add ${linux_network} via ${gateway} dev ${interface} + else + [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Adding reject/blackhole route for $network / $netmask when bringing up $interface" +- ip route add blackhole ${network}${prefix_len} ++ ip route add blackhole ${linux_network} + fi + + else +-- +2.17.1 + diff --git a/networking/ifupdown-extra/debian/deb_patches/series b/networking/ifupdown-extra/debian/deb_patches/series index 0f8624545..20194697b 100644 --- a/networking/ifupdown-extra/debian/deb_patches/series +++ b/networking/ifupdown-extra/debian/deb_patches/series @@ -1,3 +1,4 @@ 0001-Accept-netmask-or-prefix-length-on-etc-network-route.patch 0002-Install-00check-network-cable-in-the-correct-spot.patch 0003-ignore-IFACE-all-for-ifupdown-scripts.patch +0004-Handle-default-route-creation.patch \ No newline at end of file