From 6f666f0a62fb98fcab800be813141f44dd1ab8a7 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sat, 7 Sep 2019 15:30:53 +0200
Subject: bonding: T1614: bugfix in validate - enslave failed

Forgot to exclude our current bond interface in the search for duplicate
interface enslavement.
---
 src/conf_mode/interface-bonding.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

(limited to 'src')

diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py
index cd4c447ac..dc0363fb7 100755
--- a/src/conf_mode/interface-bonding.py
+++ b/src/conf_mode/interface-bonding.py
@@ -272,11 +272,14 @@ def verify(bond):
 
     conf = Config()
     for intf in bond['member']:
-        # a bond member is only allowed to be assigned to any one bond
-        for tmp in conf.list_nodes('interfaces bonding'):
+        # a bonding member interface is only allowed to be assigned to one bond!
+        all_bonds = conf.list_nodes('interfaces bonding')
+        # We do not need to check our own bond
+        all_bonds.remove(bond['intf'])
+        for tmp in all_bonds:
             if conf.exists('interfaces bonding ' + tmp + ' member interface ' + intf):
                 raise ConfigError('can not enslave interface {} which already ' \
-                                  'belongs to bond {}'.format(intf, tmp))
+                                  'belongs to {}'.format(intf, tmp))
 
         # we can not add disabled slave interfaces to our bond
         if conf.exists('interfaces ethernet ' + intf + ' disable'):
-- 
cgit v1.2.3