Skip to content
Permalink
Browse files

Improved slave candidates list creation - exclude bonded devices.

For bridge device all bonded devices are excluded. For bond device
all devices bonded in another bond are excluded.
  • Loading branch information...
mchf committed Apr 12, 2013
1 parent 9e95eca commit 627e62602db64390c75ce9719c3240889caae0a9
Showing with 23 additions and 3 deletions.
  1. +23 −3 src/modules/LanItems.ycp
@@ -481,6 +481,8 @@ global list<string> GetItemModules(string default_module){
return mods;
}

map<string, string> BuildBondIndex();

/**
* Searches map of known devices and decides if referenced lan item
* can be enslaved in a bond device
@@ -492,11 +494,12 @@ global list<string> GetItemModules(string default_module){
boolean IsBondable( integer itemId)
{
boolean ret = true;
string devname = GetDeviceName( itemId);
map<string, string> bonded = BuildBondIndex();

// check if the device is L2 capable
if( Arch::s390() )
{
string devname = GetDeviceName( itemId);
map<string, any> s390_config = s390_ReadQethConfig( devname);

// only devices with L2 support can be enslaved in bond. See bnc#719881
@@ -505,6 +508,13 @@ boolean IsBondable( integer itemId)

map<string, any> ifcfg = GetDeviceMap( itemId);

string bondMaster = bonded[ devname]:"";
if( !IsEmptyString( bondMaster) && ( GetDeviceName( current) != bondMaster) )
{
y2debug( "IsBondable: excluding lan item (%1: %2) for %3 - is already bonded", itemId, devname, GetDeviceName( current) );
return false;
}

if( ifcfg == nil)
{
return ret;
@@ -526,12 +536,22 @@ boolean IsBridgeable( integer itemId)
{
map< string, any> ifcfg = GetDeviceMap( itemId);

// no netconfig configuration has been found so nothing
// blocks using the device as bridge slave
if( ifcfg == nil)
{
return true;
}

string devname = GetDeviceName( itemId);
map<string, string> bonded = BuildBondIndex();

if( bonded[ devname]:nil != nil)
{
y2debug( "IsBridgeable: excluding lan item (%1: %2) - is bonded", itemId, devname);
return false;
}

string devtype = GetDeviceType( itemId);

// exclude forbidden configurations
@@ -560,14 +580,14 @@ boolean IsBridgeable( integer itemId)
*/
global list< integer> GetSlaveCandidates( boolean( integer) validator)
{
list< integer> result = [];

if( validator == nil)
{
y2error( "GetSlaveCandidates: needs a validator.");
return [];
}

list< integer> result = [];

foreach(integer itemId, any attribs, Items,
{
if( ( current != itemId) && validator( itemId))

0 comments on commit 627e626

Please sign in to comment.
You can’t perform that action at this time.