diff --git a/.gitignore b/.gitignore index a737e1b..82c44e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ SOURCES/nmstate-1.4.4.tar.gz SOURCES/nmstate-vendor-1.4.4.tar.xz -SOURCES/nmstate.gpg diff --git a/.nmstate.metadata b/.nmstate.metadata index 3fc3882..e49bbc8 100644 --- a/.nmstate.metadata +++ b/.nmstate.metadata @@ -1,3 +1,2 @@ 17340fe66e024e69e4c051e6a1bbd3d1974ca4ed SOURCES/nmstate-1.4.4.tar.gz 91a01d73ca8db5e882defaabc7529e97f4dd596a SOURCES/nmstate-vendor-1.4.4.tar.xz -b01a236c478366b0248688f02d299cb29168a080 SOURCES/nmstate.gpg diff --git a/SOURCES/BZ_2213554-ip-Support-static-route-with-auto-ip.patch b/SOURCES/BZ_2213554-ip-Support-static-route-with-auto-ip.patch new file mode 100644 index 0000000..3ce9892 --- /dev/null +++ b/SOURCES/BZ_2213554-ip-Support-static-route-with-auto-ip.patch @@ -0,0 +1,122 @@ +From 7c80a3acdb67eb09c3dcbeee7138315b3f855c7f Mon Sep 17 00:00:00 2001 +From: Gris Ge +Date: Fri, 19 May 2023 18:12:54 +0800 +Subject: [PATCH] ip: Support static route with auto ip + +Supporting assigning static route to interface with auto ip. For +example: + +```yml +--- +interfaces: + - name: eth1 + type: ethernet + state: up + ipv4: + dhcp: true + enabled: true + ipv6: + dhcp: true + autoconf: true + enabled: true +routes: + config: + - destination: 198.51.100.0/24 + metric: 150 + next-hop-address: 192.0.2.1 + next-hop-interface: eth1 + table-id: 254 + - destination: 2001:db8:2::/64 + metric: 151 + next-hop-address: 2001:db8:1::2 + next-hop-interface: eth1 +``` + +Integration test case included and been marked as tier1. + +Signed-off-by: Gris Ge +--- + libnmstate/route.py | 52 ++++++++++++++++++++++----------------------- + 1 file changed, 26 insertions(+), 26 deletions(-) + +diff --git a/libnmstate/route.py b/libnmstate/route.py +index d3734279..c92cbbb6 100644 +--- a/libnmstate/route.py ++++ b/libnmstate/route.py +@@ -1,21 +1,4 @@ +-# +-# Copyright (c) 2020 Red Hat, Inc. +-# +-# This file is part of nmstate +-# +-# This program is free software: you can redistribute it and/or modify +-# it under the terms of the GNU Lesser General Public License as published by +-# the Free Software Foundation, either version 2.1 of the License, or +-# (at your option) any later version. +-# +-# This program is distributed in the hope that it will be useful, +-# but WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-# GNU Lesser General Public License for more details. +-# +-# You should have received a copy of the GNU Lesser General Public License +-# along with this program. If not, see . +-# ++# SPDX-License-Identifier: LGPL-2.1-or-later + + from collections import defaultdict + import logging +@@ -146,13 +129,6 @@ class RouteEntry(StateEntry): + f"Route {self.to_dict()} next hop to down/absent interface" + ) + return False +- if iface.is_dynamic( +- Interface.IPV6 if self.is_ipv6 else Interface.IPV4 +- ): +- self._invalid_reason = ( +- f"Route {self.to_dict()} next hop to interface with dynamic IP" +- ) +- return False + if self.is_ipv6: + if not iface.is_ipv6_enabled(): + self._invalid_reason = ( +@@ -194,7 +170,10 @@ class RouteState: + rt = RouteEntry(entry) + self._cur_routes[rt.next_hop_interface].add(rt) + if not ifaces or rt.is_valid(ifaces): +- self._routes[rt.next_hop_interface].add(rt) ++ # When user converting static IP to auto IP, we should ++ # not merge current static routes besides desired ones. ++ if not iface_switch_from_static_to_auto_ip(ifaces, rt): ++ self._routes[rt.next_hop_interface].add(rt) + else: + logging.debug( + f"The current route {entry} has been discarded due" +@@ -299,3 +278,24 @@ class RouteState: + {Route.KEY: {Route.CONFIG: cur_routes_info}}, + ) + ) ++ ++ ++def iface_switch_from_static_to_auto_ip(ifaces, rt): ++ iface_name = rt.next_hop_interface ++ if not iface_name or not ifaces: ++ return False ++ ++ if is_ipv6_address(rt.destination): ++ family = Interface.IPV6 ++ else: ++ family = Interface.IPV4 ++ ++ cur_iface = ifaces.get_cur_iface(iface_name, None) ++ des_iface = ifaces.get_iface(iface_name, None) ++ if ( ++ cur_iface ++ and des_iface ++ and not cur_iface.is_dynamic(family) ++ and des_iface.is_dynamic(family) ++ ): ++ return True +-- +2.41.0 + diff --git a/SOURCES/nmstate.gpg b/SOURCES/nmstate.gpg new file mode 100644 index 0000000..9c0f9a4 --- /dev/null +++ b/SOURCES/nmstate.gpg @@ -0,0 +1,51 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBGRA/64BEADubtKFxtanzR3/oa3+/krHUWFcPhUvJNl9kuHY5YykyLG8O8L9 +un+pKm/PedPowDxAPaPR+mNpwgPLdC3F7uByrWRJsOpJpWQkuOTFvet/5CMBlRFl +ZdD/whnDBNCVtZrPppsedmmGja77iK15fL1DsNDH2tzIjoa1Ftt1yMmRA1JC8w2Q +EKPZ4qkLqXyt2kMatSp/RNIdUK91j22Qxba8ADKq9ATi6kewLRlrE1wHpwN91HZz +y8L6IMSgFHEhk4skp+rHsJGRvj9oZRi26zZYybllzuclscu7cfCYfHMXHf+5WSMm +c5+eT+iS4LEFy1srxYP3AlrdyNOQgXXqYULupR9lMpbrFR7+A5cFH2wAMWIPQcP/ +L9HjJrmratu5RA+p5rll/cFmoE01qCfhTQG+LZf+FwmXpCx/sTEbucIJsURD74RQ +PE5OeyVfzwMA0JuCAtv4zozpO1u1AbK8RAZN/38zV+sXo5J52jZFD4a+4S6zZQo9 +zcEWMI2UI7u5zxrNeFPD99gCCVeo46G0sSxO2F2XGodSDTZ6tT+6iRTsp/VMUvH1 +okHoZJMmXe/ti9oePoEtSGoPF2Jr1lynAbJQ01ndA/ZZ9TfQETkiFb/tTShzcAKJ +3+s1auR4l+GHrPhW3rOWm/SchQNc4OEygGiCLrrSvrnjG72GnFuroYlcSwARAQAB +tBhHcmlzIEdlIDxmZ2VAcmVkaGF0LmNvbT6JAlQEEwEIAD4WIQRI/W+uUVp3tIQ2 +ghyHiVZ7hxXOvAUCZED/rgIbAwUJB4TOAAULCQgHAgYVCgkICwIEFgIDAQIeAQIX +gAAKCRCHiVZ7hxXOvGUMD/4gRI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1OQ7/55IChT137OnVHRENP8HaGmRZYhxwLsI +=PdCG +-----END PGP PUBLIC KEY BLOCK----- diff --git a/SPECS/nmstate.spec b/SPECS/nmstate.spec index 850d056..5d8be53 100644 --- a/SPECS/nmstate.spec +++ b/SPECS/nmstate.spec @@ -4,7 +4,7 @@ Name: nmstate Version: 1.4.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Declarative network manager API License: LGPLv2+ URL: https://github.com/%{srcname}/%{srcname} @@ -14,6 +14,7 @@ Source2: https://www.nmstate.io/nmstate.gpg Source3: %{url}/releases/download/v%{version}/%{srcname}-vendor-%{version}.tar.xz # Patches 0X are reserved to downstream only Patch0: BZ_2132570-nm-reverse-IPv6-order-before-adding-them-to-setting.patch +Patch10: BZ_2213554-ip-Support-static-route-with-auto-ip.patch BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: gnupg2 @@ -148,9 +149,12 @@ popd /sbin/ldconfig %changelog -* Wed Jul 26 2023 MSVSphere Packaging Team - 1.4.4-1 +* Wed Jul 26 2023 MSVSphere Packaging Team - 1.4.4-2 - Rebuilt for MSVSphere 8.8 +* Mon Jun 12 2023 Gris Ge - 1.4.4-2 +- Support static route with auto ip. RHBZ#2213554 + * Mon Apr 24 2023 Gris Ge - 1.4.4-1 - Upgrade to 1.4.4. RHBZ#2186178