Commit d9da4033 authored by Leigh Stoller's avatar Leigh Stoller

Merge branch 'master' of git-public.flux.utah.edu:/flux/git/emulab-devel

parents e618f653 e674c892
......@@ -584,8 +584,8 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg,
tb_plink *phys_link =
new tb_plink(componentId.c_str(),
tb_plink::PLINK_NORMAL, str_first_type.c_str(),
srcMac.c_str(), dstMac.c_str(),
shortNames[src_iface], shortNames[dst_iface]);
src_pnode->name, srcMac.c_str(), shortNames[src_iface],
dst_pnode->name, dstMac.c_str(), shortNames[dst_iface]);
phys_link->delay_info.bandwidth = bandwidth;
phys_link->delay_info.delay = latency;
......
......@@ -269,8 +269,8 @@ int parse_ptop(tb_pgraph &pg, tb_sgraph &sg, istream& input)
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,srcnode->name,srcmac,
srciface,dstnode->name,dstmac,dstiface);
put(pedge_pmap,pe,pl);
pl->delay_info.bandwidth = ibw;
pl->delay_info.delay = idelay;
......
......@@ -407,8 +407,9 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg) {
// other stuff if I remove them... bummer!
tb_plink *phys_link =
new tb_plink(name.c(), tb_plink::PLINK_NORMAL, str_first_type,
"(null)", "(null)", src_iface.c(), dst_iface.c());
src_pnode->name, "(null)", src_iface.c(),
dst_pnode->name, "(null)", dst_iface.c());
phys_link->delay_info.bandwidth = bandwidth.i();
phys_link->delay_info.delay = latency.i();
phys_link->delay_info.loss = packet_loss.d();
......
......@@ -360,10 +360,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)
tb_plink(fstring _name, plinkType _is_type, fstring _type, fstring _srcnode, fstring _srcmac,
fstring _srciface, fstring _dstnode, fstring _dstmac, fstring _dstiface)
: name(_name), srcmac(_srcmac), dstmac(_dstmac), is_type(_is_type),
srciface(_srciface), dstiface(_dstiface),
srcnode(_srcnode), dstnode(_dstnode),
delay_info(), bw_used(0), emulated(0), nonemulated(0),
penalty(0.0), fixends(false), current_endpoints(), current_count(0),
vedge_counts() {
......@@ -371,6 +372,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
......
......@@ -60,7 +60,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, bool flipped, bool check_src_iface,
pedge &out_edge, bool check_src_iface,
bool check_dst_iface);
int find_interswitch_path(pvertex src_pv,pvertex dest_pv,
int bandwidth,pedge_path &out_path,
......@@ -250,13 +250,25 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
pedge pe;
// Direct link (have to check both interfaces if they are fixed)
if (find_best_link(dest_pv,pv,vlink,pe,flipped,true,true)) {
if (find_best_link(dest_pv,pv,vlink,pe,true,true)) {
tb_link_info info(tb_link_info::LINK_DIRECT);
info.plinks.push_back(pe);
resolutions.push_back(info);
total_weight += LINK_RESOLVE_DIRECT;
SDEBUG(cerr << " added a direct_link " << pe << endl);
}
/*
* IMPORTANT NOTE ABOUT find_best_link -
*
* We have to tell it whether it is supposed to check the source of the
* vlink, the dest of the vlink, or both, for fixed interfaces. Of course, we
* only want to check the 'node' side, not the switch side, of interswitch
* and intraswitch paths. Of course, which end we're looking at depends on
* the order we're traversing the vlink - the flipped variable. This is why
* you see 'flipped' and '!flipped' passed to find_best_link() below.
*/
// Intraswitch link
pedge first,second;
for (pvertex_set::iterator switch_it = pnode->switches.begin();
......@@ -291,9 +303,8 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
if (first_link) {
SDEBUG(cerr << " intraswitch: finding first link" << endl;)
// Check only whether the source interface is fixed - this is the
// first link in a multi-hop path
if (!find_best_link(pv,*switch_it,vlink,first,flipped,true,false)) {
// See note above
if (!find_best_link(pv,*switch_it,vlink,first,!flipped,flipped)) {
SDEBUG(cerr << " intraswitch failed - no link first" <<
endl;)
// No link to this switch
......@@ -302,11 +313,9 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
}
if (second_link) {
// Check only whether the dest interface is fixed - this is the
// last link in a multi-hop path
SDEBUG(cerr << " intraswitch: finding second link (" << ")" << endl;)
if (!find_best_link(dest_pv,*switch_it,vlink,second,!flipped,
false,true)) {
// See note above
if (!find_best_link(dest_pv,*switch_it,vlink,second,flipped,!flipped)) {
// No link to this switch
SDEBUG(cerr << " intraswitch failed - no link second" <<
endl;)
......@@ -375,10 +384,8 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
// Get link objects
if (first_link) {
// Check only whether the source interface is fixed - this is the
// first link in a multi-hop path
if (!find_best_link(pv,*source_switch_it,vlink,first,flipped,
true,false)) {
// See note above
if (!find_best_link(pv,*source_switch_it,vlink,first,!flipped,flipped)) {
// No link to this switch
SDEBUG(cerr << " interswitch failed - no first link"
<< endl;)
......@@ -387,11 +394,9 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
}
if (second_link) {
// Check only whether the dest interface is fixed - this is the
// last link in a multi-hop path
if (!find_best_link(dest_pv,*dest_switch_it,vlink,second,!flipped,
false,true)) {
// No link to tshis switch
// See note above
if (!find_best_link(dest_pv,*dest_switch_it,vlink,second,flipped,!flipped)) {
// No link to this switch
SDEBUG(cerr << " interswitch failed - no second link" << endl;)
continue;
}
......@@ -1483,8 +1488,19 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed, bool skip
return 0;
}
/*
* Find the best link between two physical nodes, making sure it matches the
* requirements of the given vlink. Returns results in the out_edge parameter
* NOTE: assumes the caller has done enough bookkeeping to know whether the
* source and dest interfaces need to be checked for fixed interfaces - that
* is: check_src_iface should be set if:
* this is a direct link OR
* we're mapping the end of an inter or intra switch link that connects to
* the 'source' vnode in the vlink structure
* Similar rules apply to check_dst_iface
*/
bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
pedge &out_edge, bool flipped, bool check_src_iface,
pedge &out_edge, bool check_src_iface,
bool check_dst_iface)
{
pvertex dest_pv;
......@@ -1507,58 +1523,62 @@ bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
continue;
}
// XXX: Not 100% sure it's better to do this inside find_best_link rather
// than in the caller
if (flipped) {
// If the endpoints are flipped, then we need to flip our notion of
// which ones need to be compared.
bool tmp = check_src_iface;
check_src_iface = check_dst_iface;
check_dst_iface = tmp;
SDEBUG(cerr << " find_best_link: flipping interface comparisons" << endl;)
}
SDEBUG(cerr << " find_best_link: fix_src_iface = " <<
vlink->fix_src_iface << " check_src_iface = " << check_src_iface
<< " fix_dst_iface = " << vlink->fix_dst_iface
<< " check_dst_iface = " << check_dst_iface
<< " flipped = " << flipped << endl);
<< " check_dst_iface = " << check_dst_iface << endl;)
// Whether we check the 'source' or 'destination' on the vlink against
// the phyisical link's source interface depends on whether the
// interface order in the in the pedge matches the interface order in
// the vlink
bool plink_order_reversed;
tb_vnode *src_vnode = get(vvertex_pmap,vlink->src);
tb_pnode *src_pnode = get(pvertex_pmap,src_vnode->assignment);
if (src_pnode->name != plink->srcnode) {
SDEBUG(cerr << " find_best_link: plink and vlink in " <<
"different order (" << src_pnode->name << " != " <<
plink->srcnode << ")" << endl;)
plink_order_reversed = true;
} else {
SDEBUG(cerr << " find_best_link: plink and vlink in " <<
"same order (" << src_pnode->name << " == " <<
plink->srcnode << ")" << endl;)
plink_order_reversed = false;
}
// If the vlink has a fixed source interface, and it doesn't match
// this plink, skip it
if (vlink->fix_src_iface && check_src_iface) {
// Whether we check the 'source' or 'destination' on the vlink against
// the phyisical link's source interface depends on whether we're
// traversing the link if forward or reverse (flipped) order
// fstring compare_iface = vlink->src_iface;
fstring compare_iface = (flipped? vlink->dst_iface : vlink->src_iface);
if (plink->srciface != compare_iface) {
// The interface name we compare to on the plink depends on wether it
// goes in the same 'direction' as the vlink
fstring compare_iface = (plink_order_reversed? plink->dstiface : plink->srciface);
if (vlink->src_iface != compare_iface) {
SDEBUG(cerr << " find_best_link (" << vlink->name <<
"): Fix source: " << plink->srciface << " != " <<
"): Fix source: " << vlink->src_iface << " != " <<
compare_iface << endl);
continue;
} else {
SDEBUG(cerr << " find_best_link (" << vlink->name <<
"): Fix source: " << plink->srciface << " == " <<
"): Fix source: " << vlink->src_iface << " == " <<
compare_iface << endl);
}
}
// Same for destination
// 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 (vlink->fix_dst_iface && check_dst_iface) {
// fstring compare_iface = vlink->dst_iface;
fstring compare_iface = (flipped? vlink->src_iface : vlink->dst_iface);
if (plink->srciface != compare_iface) {
// The interface name we compare to on the plink depends on wether it
// goes in the same 'direction' as the vlink
fstring compare_iface = (plink_order_reversed? plink->srciface : plink->dstiface);
if (vlink->dst_iface != compare_iface) {
SDEBUG(cerr << " find_best_link (" << vlink->name <<
"): Fix dst: " << plink->srciface << " != " <<
"): Fix dst: " << vlink->dst_iface << " != " <<
compare_iface << endl);
continue;
} else {
SDEBUG(cerr << " find_best_link (" << vlink->name <<
"): Fix dst: " << plink->srciface << " == " <<
"): Fix dst: " << vlink->dst_iface << " == " <<
compare_iface << endl);
}
}
......
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