Blob Blame History Raw
From 14551813a0b729ee00cd7f56a06312035e78e304 Mon Sep 17 00:00:00 2001
From: Gris Ge <fge@redhat.com>
Date: Wed, 28 Oct 2020 12:36:45 +0800
Subject: [PATCH] vrf: Allow vrf port to hold IP information

According to https://www.kernel.org/doc/Documentation/networking/vrf.txt
the vrf port is allowed to hold IP address.

Integration test case included.

Signed-off-by: Gris Ge <fge@redhat.com>
---
 libnmstate/ifaces/base_iface.py |  6 +++++-
 tests/integration/vrf_test.py   | 36 +++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/libnmstate/ifaces/base_iface.py b/libnmstate/ifaces/base_iface.py
index ae54245..156aece 100644
--- a/libnmstate/ifaces/base_iface.py
+++ b/libnmstate/ifaces/base_iface.py
@@ -233,6 +233,7 @@ class BaseIface:
             if (
                 ip_state.is_enabled
                 and self.controller
+                and self.controller_type != InterfaceType.VRF
                 and not self.can_have_ip_as_port
             ):
                 raise NmstateValueError(
@@ -279,7 +280,10 @@ class BaseIface:
     def set_controller(self, controller_iface_name, controller_type):
         self._info[BaseIface.CONTROLLER_METADATA] = controller_iface_name
         self._info[BaseIface.CONTROLLER_TYPE_METADATA] = controller_type
-        if not self.can_have_ip_as_port:
+        if (
+            not self.can_have_ip_as_port
+            and controller_type != InterfaceType.VRF
+        ):
             for family in (Interface.IPV4, Interface.IPV6):
                 self._info[family] = {InterfaceIP.ENABLED: False}
 
-- 
2.25.4