Commit d9bf2729 authored by Mike Hibler's avatar Mike Hibler
Browse files

Put in DB query to obtain veth vlan tag

parent 491db35a
......@@ -1401,15 +1401,18 @@ COMMAND_PROTOTYPE(doifconfig)
* Find all the veth interfaces.
*/
res = mydb_query("select v.veth_id,v.IP,v.mac,i.mac,v.mask,v.rtabid, "
" vl.vname "
" vl.vname,vll.idx "
" from veth_interfaces as v "
"left join interfaces as i on "
" i.node_id=v.node_id and i.iface=v.iface "
"left join virt_lans as vl on "
" vl.pid='%s' and vl.eid='%s' and "
" vl.vnode='%s' and vl.ip=v.IP "
"left join virt_lan_lans as vll on "
" vll.pid=vl.pid and vll.eid=vl.eid and "
" vll.vname=vl.vname "
"where v.node_id='%s' and %s",
7, reqp->pid, reqp->eid, reqp->nickname,
8, reqp->pid, reqp->eid, reqp->nickname,
reqp->pnodeid, buf);
if (!res) {
error("IFCONFIG: %s: DB Error getting veth interfaces!\n",
......@@ -1428,7 +1431,6 @@ COMMAND_PROTOTYPE(doifconfig)
}
while (nrows) {
char *bufp = buf;
char *mask;
row = mysql_fetch_row(res);
if (vers >= 16) {
......@@ -1440,11 +1442,10 @@ COMMAND_PROTOTYPE(doifconfig)
* no underlying phys interface (say, colocated nodes in a
* link).
*/
mask = CHECKMASK(row[4]);
bufp += OUTPUT(bufp, ebufp - bufp,
"IFACETYPE=veth "
"INET=%s MASK=%s ID=%s VMAC=%s PMAC=%s",
row[1], mask, row[0], row[2],
row[1], CHECKMASK(row[4]), row[0], row[2],
row[3] ? row[3] : "none");
if (vers >= 14) {
......@@ -1464,19 +1465,7 @@ COMMAND_PROTOTYPE(doifconfig)
* XXX right now we compute this from the subnet.
*/
if (vers >= 20) {
unsigned short vtag;
struct in_addr tip, tmask;
in_addr_t addr;
int bits;
inet_aton(row[1], &tip);
inet_aton(mask, &tmask);
addr = ntohl(tmask.s_addr);
for (bits = 0; (addr & (1 << bits)) == 0; bits++)
;
vtag = (ntohl(tip.s_addr) >> bits) & 0xFFFF;
bufp += OUTPUT(bufp, ebufp - bufp, " VTAG=%d", vtag);
bufp += OUTPUT(bufp, ebufp - bufp, " VTAG=%s", row[7]);
}
OUTPUT(bufp, ebufp - bufp, "\n");
......
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