mirror of
				https://github.com/CumulusNetworks/ifupdown2.git
				synced 2024-05-06 15:54:50 +00:00 
			
		
		
		
	Remove upper device check warnings + implicitly follow upperifaces when
a logical interface comes up
Ticket: CM-2493
Reviewed By:
Testing Done: Tested ifup, ifdown in bond bridge setup
Also, implicitly pick up the upperifaces (even when user has not
specified --with-depends) for logical interfaces.
This is because when a logical interface goes down/deleted, kernel
impilicity deletes its upperifaces. so its better to implicitly bring
up upperifaces.
example
bridge name    bridge id        STP enabled    interfaces
br0        8000.7072cf8c2fca    yes        bond1
                            bond2
br2000        8000.7072cf8c2fca    yes        bond1.2000
                            bond2.2000
br2001        8000.7072cf8c2fca    yes        bond1.2001
                            bond2.2001
bridge name    bridge id        STP enabled    interfaces
br0        8000.000000000000    yes
br2000        8000.000000000000    yes
br2001        8000.000000000000    yes
bridge name    bridge id        STP enabled    interfaces
br0        8000.7072cf8c2fca    yes        bond1
                            bond2
br2000        8000.7072cf8c2fca    yes        bond1.2000
                            bond2.2000
br2001        8000.7072cf8c2fca    yes        bond1.2001
                            bond2.2001
			
			
This commit is contained in:
		
							
								
								
									
										22
									
								
								pkg/iface.py
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								pkg/iface.py
									
									
									
									
									
								
							@@ -291,17 +291,21 @@ class iface():
 | 
			
		||||
        else:
 | 
			
		||||
            return _tickmark
 | 
			
		||||
 | 
			
		||||
    def is_different(self, dstiface):
 | 
			
		||||
        if self.name != dstiface.name: return True
 | 
			
		||||
        if self.addr_family != dstiface.addr_family: return True
 | 
			
		||||
        if self.addr_method != dstiface.addr_method: return True
 | 
			
		||||
        if self.auto != dstiface.auto: return True
 | 
			
		||||
        if self.classes != dstiface.classes: return True
 | 
			
		||||
    def compare(self, dstiface):
 | 
			
		||||
        """ Compares two objects
 | 
			
		||||
 | 
			
		||||
        Returns True if object self is same as dstiface and False otherwise """
 | 
			
		||||
 | 
			
		||||
        if self.name != dstiface.name: return False
 | 
			
		||||
        if self.addr_family != dstiface.addr_family: return False
 | 
			
		||||
        if self.addr_method != dstiface.addr_method: return False
 | 
			
		||||
        if self.auto != dstiface.auto: return False
 | 
			
		||||
        if self.classes != dstiface.classes: return False
 | 
			
		||||
        if any(True for k in self.config if k not in dstiface.config):
 | 
			
		||||
            return True
 | 
			
		||||
            return False
 | 
			
		||||
        if any(True for k,v in self.config.items()
 | 
			
		||||
                    if v != dstiface.config.get(k)): return True
 | 
			
		||||
        return False
 | 
			
		||||
                    if v != dstiface.config.get(k)): return False
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def __getstate__(self):
 | 
			
		||||
        odict = self.__dict__.copy()
 | 
			
		||||
 
 | 
			
		||||
@@ -803,7 +803,7 @@ class ifupdownMain(ifupdownBase):
 | 
			
		||||
                for objidx in range(0, len(lastifaceobjlist)):
 | 
			
		||||
                    oldobj = lastifaceobjlist[objidx]
 | 
			
		||||
                    newobj = newifaceobjlist[objidx]
 | 
			
		||||
                    if newobj.is_different(oldobj):
 | 
			
		||||
                    if not newobj.compare(oldobj):
 | 
			
		||||
                        ifacedownlist.append(ifname)
 | 
			
		||||
                        continue
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -118,7 +118,12 @@ class ifaceScheduler():
 | 
			
		||||
                           followdependents=False):
 | 
			
		||||
        """ Check if conflicting upper ifaces are around and warn if required
 | 
			
		||||
 | 
			
		||||
        Returns False if this interface needs to be skipped, else return True """
 | 
			
		||||
        Returns False if this interface needs to be skipped,
 | 
			
		||||
        else return True """
 | 
			
		||||
 | 
			
		||||
        # XXX: simply return for now, the warnings this function prints
 | 
			
		||||
        # are very confusing. Get rid of this function soon
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
        if 'up' in ops[0] and followdependents:
 | 
			
		||||
            return True
 | 
			
		||||
@@ -161,8 +166,8 @@ class ifaceScheduler():
 | 
			
		||||
            raise Exception('%s: not found' %ifacename)
 | 
			
		||||
 | 
			
		||||
        for ifaceobj in ifaceobjs:
 | 
			
		||||
            if not cls._check_upperifaces(ifupdownobj, ifaceobj, ops, parent,
 | 
			
		||||
                                          followdependents):
 | 
			
		||||
            if not cls._check_upperifaces(ifupdownobj, ifaceobj,
 | 
			
		||||
                                          ops, parent, followdependents):
 | 
			
		||||
                return
 | 
			
		||||
            if order == ifaceSchedulerFlags.INORDER:
 | 
			
		||||
                # If inorder, run the iface first and then its dependents
 | 
			
		||||
@@ -300,10 +305,17 @@ class ifaceScheduler():
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        if not ifupdownobj.ALL or not followdependents or len(ifacenames) == 1:
 | 
			
		||||
            # If there is any interface that does exist, maybe it is a
 | 
			
		||||
            # logical interface and we have to followupperifaces
 | 
			
		||||
            followupperifaces = (True if
 | 
			
		||||
                                    [i for i in ifacenames
 | 
			
		||||
                                            if not ifupdownobj.link_exists(i)]
 | 
			
		||||
                                    else False)
 | 
			
		||||
            cls.run_iface_list(ifupdownobj, ifacenames, ops,
 | 
			
		||||
                                  parent=None,order=order,
 | 
			
		||||
                                  followdependents=followdependents)
 | 
			
		||||
            if not ifupdownobj.ALL and followdependents and 'up' in ops[0]:
 | 
			
		||||
            if (not ifupdownobj.ALL and
 | 
			
		||||
                    (followdependents or followupperifaces) and 'up' in ops[0]):
 | 
			
		||||
                # If user had given a set of interfaces to bring up
 | 
			
		||||
                # try and execute 'up' on the upperifaces
 | 
			
		||||
                ifupdownobj.logger.info('running upperifaces if available')
 | 
			
		||||
 
 | 
			
		||||
@@ -75,6 +75,13 @@ class stateManager():
 | 
			
		||||
        if not old_ifaceobjs:
 | 
			
		||||
            self.ifaceobjdict[ifaceobj.name] = [ifaceobj]
 | 
			
		||||
        else:
 | 
			
		||||
            # If it matches any of the object, return
 | 
			
		||||
            if any(o.compare(ifaceobj) for o in old_ifaceobjs):
 | 
			
		||||
                return
 | 
			
		||||
            # If it does not match any of the objects, and if
 | 
			
		||||
            # all objs in the list came from the pickled file,
 | 
			
		||||
            # then reset the list and add this object as a fresh one,
 | 
			
		||||
            # else append to the list
 | 
			
		||||
            if old_ifaceobjs[0].flags & iface._PICKLED:
 | 
			
		||||
                del self.ifaceobjdict[ifaceobj.name]
 | 
			
		||||
                self.ifaceobjdict[ifaceobj.name] = [ifaceobj]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user