Commit 43333bb7 authored by Robert Ricci's avatar Robert Ricci
Browse files

Fix for fixed interfaces: move the code that filters interfaces whose

name's don't match from resolve_link() to find_best_link() - the latter
returns only one link of each type, so it's too late to find the right
interface by the time we get back out to resolve_link(). Also fixed
a built-in assmption about the 'direction' that physical links go in.
The old code (explicity) assumed that links to from node to switch - now
we flip around our comparison if the directions of the links do not
match.

This was a bugger, even though it didn't involve much code, since the
'flipping' involves a 'parity' issue - it's really easy to mess up the
parity in several places and get it to work under *some* circumstances.

As a side effect, added some more information to the plink strucutre.
This turned out to not be necessary for the solution I finally came
up with - it was part of an earlier, abandoned one. But, it's probably
good information to have around in the future.
parent bdce88fa
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2007 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -267,8 +267,8 @@ int parse_ptop(tb_pgraph &PG, tb_sgraph &SG, istream& i)
for (int cur = 0;cur<num;++cur) {
pedge pe = (add_edge(srcv,dstv,PG)).first;
tb_plink *pl = new
tb_plink(name,tb_plink::PLINK_NORMAL,link_type,srcmac,dstmac,
srciface,dstiface);
tb_plink(name,tb_plink::PLINK_NORMAL,link_type,src,dst,
srcmac,dstmac, srciface,dstiface);
put(pedge_pmap,pe,pl);
pl->delay_info.bandwidth = ibw;
pl->delay_info.delay = idelay;
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2007 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -320,9 +320,11 @@ public:
typedef enum {PLINK_NORMAL,PLINK_INTERSWITCH,PLINK_LAN} plinkType;
typedef hash_set<fstring> type_set;
tb_plink(fstring _name, plinkType _is_type, fstring _type, fstring _srcmac, fstring
_dstmac, fstring _srciface, fstring _dstiface)
: name(_name), srcmac(_srcmac), dstmac(_dstmac), is_type(_is_type),
tb_plink(fstring _name, plinkType _is_type, fstring _type, fstring _srcnode,
fstring _dstnode, fstring _srcmac, fstring _dstmac,
fstring _srciface, fstring _dstiface)
: name(_name), srcnode(_srcnode), dstnode(_dstnode), srcmac(_srcmac),
dstmac(_dstmac), is_type(_is_type),
srciface(_srciface), dstiface(_dstiface),
delay_info(), bw_used(0), emulated(0), nonemulated(0),
penalty(0.0), fixends(false), current_endpoints(), current_count(0),
......@@ -331,6 +333,7 @@ public:
}
fstring name; // the name
fstring srcnode, dstnode; // source and destination node names
fstring srcmac,dstmac; // source and destination MAC addresses.
fstring srciface, dstiface; // source and destination interface names
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2007 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -59,7 +59,7 @@ extern tb_sgraph SG; // switch fabric
void score_link(pedge pe,vedge ve,tb_pnode *src_pnode,tb_pnode *dst_pnode);
void unscore_link(pedge pe,vedge ve,tb_pnode *src_pnode,tb_pnode *dst_pnode);
bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
pedge &out_edge);
pedge &out_edge,bool is_src, bool is_dst);
int find_interswitch_path(pvertex src_pv,pvertex dest_pv,
int bandwidth,pedge_path &out_path,
pvertex_list &out_switches);
......@@ -192,7 +192,7 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
pedge pe;
// Direct link
if (find_best_link(dest_pv,pv,vlink,pe)) {
if (find_best_link(pv,dest_pv,vlink,pe,true,true)) {
tb_link_info info(tb_link_info::LINK_DIRECT);
info.plinks.push_back(pe);
resolutions.push_back(info);
......@@ -231,7 +231,7 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
}
if (first_link) {
if (!find_best_link(pv,*switch_it,vlink,first)) {
if (!find_best_link(pv,*switch_it,vlink,first,true,false)) {
SDEBUG(cerr << " intraswitch failed - no link first" <<
endl;)
// No link to this switch
......@@ -240,7 +240,7 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
}
if (second_link) {
if (!find_best_link(dest_pv,*switch_it,vlink,second)) {
if (!find_best_link(*switch_it,dest_pv,vlink,second,false,true)) {
// No link to this switch
SDEBUG(cerr << " intraswitch failed - no link second" <<
endl;)
......@@ -306,8 +306,7 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
}
if (first_link) {
if
(!find_best_link(pv,*source_switch_it,vlink,first)) {
if (!find_best_link(pv,*source_switch_it,vlink,first,true,false)) {
// No link to this switch
SDEBUG(cerr << " interswitch failed - no first link"
<< endl;)
......@@ -316,7 +315,7 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
}
if (second_link) {
if (!find_best_link(dest_pv,*dest_switch_it,vlink,second)) {
if (!find_best_link(*dest_switch_it,dest_pv,vlink,second,false,true)) {
// No link to tshis switch
SDEBUG(cerr << " interswitch failed - no second link" << endl;)
continue;
......@@ -446,44 +445,10 @@ void resolve_link(vvertex vv, pvertex pv, tb_vnode *vnode, tb_pnode *pnode,
vlink,pnode,dest_pnode,flipped);
/*
* If they have asked for a specific interface, filter out any
* resolutions that don't have it
* Note: The fixed interface code has been moved to find_best_link
*/
if (vlink->fix_src_iface) {
resolution_vector::iterator rit;
for (rit = resolutions.begin(); rit != resolutions.end();) {
pedge link = (*rit).plinks.front();
tb_plink *plink = get(pedge_pmap,link);
if (plink->srciface != vlink->src_iface) {
// Doesn't match, remove it!
total_weight -= resolution_cost(rit->type_used);
rit = resolutions.erase(rit);
} else {
rit++;
}
}
}
if (vlink->fix_dst_iface) {
resolution_vector::iterator rit;
for (rit = resolutions.begin(); rit != resolutions.end();) {
pedge link = (*rit).plinks.back();
tb_plink *plink = get(pedge_pmap,link);
// Yes, this really is srciface
// XXX: This only works because we always have the node as the 'source'
// of a plink! Shouldn't depend on this!
if (plink->srciface != vlink->dst_iface) {
// Doesn't match, remove it!
total_weight -= resolution_cost(rit->type_used);
rit = resolutions.erase(rit);
} else {
rit++;
}
}
}
int n_resolutions = resolutions.size();
//int resolution_index = n_resolutions - 1;
int resolution_index = n_resolutions;
/*
......@@ -1354,7 +1319,7 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed, bool skip
}
bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
pedge &out_edge)
pedge &out_edge, bool is_src, bool is_dst)
{
pvertex dest_pv;
double best_distance = 1000.0;
......@@ -1373,12 +1338,43 @@ bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
dest_pv = source(*pedge_it,PG);
if (dest_pv == switch_pv) {
tb_plink *plink = get(pedge_pmap,*pedge_it);
tb_pnode *dest_pnode = get(pvertex_pmap,dest_pv);
// Skip any links whose type is wrong (ie. doesn't match the vlink)
if (plink->types.find(vlink->type) == plink->types.end()) {
continue;
}
// Skip any links that don't match fixed-interface requirements. We only
// do this if we're trying to map the source and/or destination of the
// vlink
if (is_src && vlink->fix_src_iface) {
bool flipped;
if (plink->srcnode == pnode->name) {
flipped = false;
} else {
flipped = true;
}
if ((flipped? plink->dstiface : plink->srciface)
!= vlink->src_iface) {
continue;
}
}
if (is_dst && vlink->fix_dst_iface) {
bool flipped;
if (plink->dstnode == dest_pnode->name) {
flipped = false;
} else {
flipped = true;
}
if ((flipped? plink->srciface : plink->dstiface)
!= vlink->dst_iface) {
continue;
}
}
}
// Get delay characteristics - NOTE: Currently does not actually do
// anything
tb_delay_info physical_delay;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment