Skip to content

Commit

Permalink
add checks for VLAN = 0 when creating an interface and getting config
Browse files Browse the repository at this point in the history
  • Loading branch information
gabi2 committed Jun 12, 2013
1 parent 6bba85b commit e97a8bb
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 6 deletions.
47 changes: 43 additions & 4 deletions src/FcoeClient.ycp
Expand Up @@ -257,7 +257,9 @@ map <string, boolean> service_start = $[ "fcoe":true,
// map containing information about networks cards and VLAN, FCoE and DCB status
list <map> network_interfaces = [];

// Returns the map containing all detected interfaces including
// Returns the map containing all detected interfaces (possibly including
// several entries for a network interface if several VLAN interfaces are
// detected)
global list <map> GetNetworkCards()
{
return network_interfaces;
Expand Down Expand Up @@ -410,7 +412,7 @@ global string GetFcoeVlanInterface ( string interface, string vlan_interface )
{
string vlan_device_name = "";

if ( TestMode() )
if ( TestMode() && vlan_interface != "2011" )
return interface + "." + vlan_interface;

string command = sformat( "sed -n 's/\\([^ ]*\\) *.*%1*.*%2/\\1/p' /proc/net/vlan/config",
Expand Down Expand Up @@ -722,6 +724,26 @@ global boolean ServiceStatus()
return ret;
}

//
// Check whether there are configured FCoE VLANs for the given network interface
// Return list of configured VLANs
//
global list IsConfigured( string device_name )
{
list configured_vlans = [];
list<map> interfaces = GetNetworkCards();

foreach ( map interface, interfaces, {
if ( device_name == interface["dev_name"]:"" &&
interface["fcoe_vlan"]:"" != NOT_CONFIGURED &&
interface["fcoe_vlan"]:"" != NOT_AVAILABLE )
{
configured_vlans = add( configured_vlans, interface["vlan_interface"]:"" );
}
} );
return configured_vlans;
}

// list <map> network_interfaces
//
// dev_name mac_addr device fcoe_vlan fcoe_enable dcb_required auto_vlan dcb_capable vlan_interface cfg_file
Expand Down Expand Up @@ -793,7 +815,8 @@ global boolean DetectNetworkCards()

if ( vlan == "0" )
{
// for VLAN interface "0" means start FCoE on network interface (without creating a VLAN)
// for VLAN interface "0" means start FCoE on network interface (without creating a VLAN
// which means there isn't an entry in /proc/net/vlan/config)
fcoe_vlan_interface = card["dev_name"]:"";
}
else // get FCoE VLAN interface from /proc/net/vlan/config
Expand Down Expand Up @@ -821,6 +844,21 @@ VLAN interface to get a valid configuration."), fcoe_vlan_interface) );
// the interface isn't configured
fcoe_vlan_interface = NOT_CONFIGURED;
}
else // add additionally check for VLAN = 0
{
// is FCoE really configured on interface itself or configured for a VLAN interface?
if ( vlan == "0" )
{
foreach ( string vlan_cfg_name, (list<string>) vlans, {
// no ifcfg-<if>.<vlan> written for vlan = 0 (see WriteSysconfigFiles() )
if ( FileUtils::Exists( sformat( "/etc/sysconfig/network/ifcfg-%1.%2",
card["dev_name"]:"", vlan_cfg_name ) ) )
{
fcoe_vlan_interface = NOT_CONFIGURED;
}
});
}
}
}
else
{
Expand Down Expand Up @@ -933,7 +971,8 @@ global boolean WriteSysconfigFiles( )
if ( card["fcoe_vlan"]:"" != FcoeClient::NOT_AVAILABLE && // FCoE VLAN is configured
card["fcoe_vlan"]:"" != FcoeClient::NOT_CONFIGURED )
{
// write ifcfg-<if>.>VLAN> only if VLAN was created
// write ifcfg-<if>.>VLAN> only if VLAN was created (not for VLAN = 0 which means
// FCoE is started on the network interface itself)
if ( card["vlan_interface"]:"" != "0" )
{
y2milestone( "Writing /etc/sysconfig/network/ifcfg-%1", card["fcoe_vlan"]:"" );
Expand Down
31 changes: 29 additions & 2 deletions src/complex.ycp
Expand Up @@ -303,6 +303,33 @@ symbol HandleInterfacesDialog( string id, map event )
map card = FcoeClient::GetCurrentNetworkCard();
y2milestone( "Selected card: %1", card );
string dev_name = card["dev_name"]:"";

list configured_vlans = FcoeClient::IsConfigured( dev_name );

if ( configured_vlans != [] )
{
y2milestone( "Configured VLANs on %1: %2", dev_name, configured_vlans );

if ( contains( configured_vlans, "0" ) )
{
// text of an error popup
Popup::Error( sformat( _("Cannot start FCoE on VLAN interface %1
because FCoE is already configured on
network interface %2 itself."), card["vlan_interface"]:"", dev_name ) );
return nil;
}
if ( card["vlan_interface"]:"" == "0" )
{
// text of an error popup
Popup::Error( sformat( _("Cannot start FCoE on network interface %1 itself
because FCoE is already configured on
VLAN interface(s) %2."), dev_name, configured_vlans ) );
return nil;
}
Popup::Warning( sformat( "FCoE VLAN interface(s) %1 already configured on %2.",
configured_vlans, dev_name ) );
}

string command = sformat( "fipvlan -c -s %1", dev_name );

map output = $[];
Expand All @@ -315,8 +342,8 @@ symbol HandleInterfacesDialog( string id, map event )
boolean ret = Popup::YesNoHeadline( _("Creating and Starting FCoE on Detected VLAN Device"),
// question to the user: really create and start FCoE
sformat( _("Do you really want to create a FCoE network
interface for discovered FCoE VLAN interface
on %1 and start the FCoE initiator?"), dev_name ) );
interface for discovered VLAN interface %1
on %2 and start the FCoE initiator?"), card["vlan_interface"]:"", dev_name ) );
if ( ret == true )
{
if ( Stage::initial() ) // first stage of installation - create and start FCoE VLAN interface
Expand Down

0 comments on commit e97a8bb

Please sign in to comment.