Skip to content

Commit

Permalink
vswitchd: Add bond hashes to /proc/net/bonding compatibility layer.
Browse files Browse the repository at this point in the history
The Citrix QA scripts require the bond hashes and their assigned devices
to be noted in /proc/net/bonding.  We weren't doing that, so this commit
adds them.

Bug NIC-16.
  • Loading branch information
blp committed Jul 30, 2009
1 parent acf827c commit 2aebae8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions vswitchd/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -2903,6 +2903,7 @@ port_update_bonding(struct port *port)
static void
port_update_bond_compat(struct port *port)
{
struct compat_bond_hash compat_hashes[BOND_MASK + 1];
struct compat_bond bond;
size_t i;

Expand All @@ -2913,6 +2914,20 @@ port_update_bond_compat(struct port *port)
bond.up = false;
bond.updelay = port->updelay;
bond.downdelay = port->downdelay;

bond.n_hashes = 0;
bond.hashes = compat_hashes;
if (port->bond_hash) {
const struct bond_entry *e;
for (e = port->bond_hash; e <= &port->bond_hash[BOND_MASK]; e++) {
if (e->iface_idx >= 0 && e->iface_idx < port->n_ifaces) {
struct compat_bond_hash *cbh = &bond.hashes[bond.n_hashes++];
cbh->hash = e - port->bond_hash;
cbh->netdev_name = port->ifaces[e->iface_idx]->name;
}
}
}

bond.n_slaves = port->n_ifaces;
bond.slaves = xmalloc(port->n_ifaces * sizeof *bond.slaves);
for (i = 0; i < port->n_ifaces; i++) {
Expand All @@ -2926,6 +2941,7 @@ port_update_bond_compat(struct port *port)
}
memcpy(slave->mac, iface->mac, ETH_ADDR_LEN);
}

proc_net_compat_update_bond(port->name, &bond);
free(bond.slaves);
}
Expand Down
6 changes: 6 additions & 0 deletions vswitchd/proc-net-compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ proc_net_compat_update_bond(const char *name, const struct compat_bond *bond)
"\n"
"Source load balancing info:\n",
bond->up ? "up" : "down", bond->updelay, bond->downdelay);

for (i = 0; i < bond->n_hashes; i++) {
const struct compat_bond_hash *cbh = &bond->hashes[i];
ds_put_format(&ds, " [%03d] = %s\n", cbh->hash, cbh->netdev_name);
}

for (i = 0; i < bond->n_slaves; i++) {
const struct compat_bond_slave *slave = &bond->slaves[i];
ds_put_format(
Expand Down
9 changes: 9 additions & 0 deletions vswitchd/proc-net-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ struct compat_bond {
bool up;
int updelay;
int downdelay;

int n_hashes;
struct compat_bond_hash *hashes;

int n_slaves;
struct compat_bond_slave *slaves;
};

struct compat_bond_hash {
int hash;
const char *netdev_name;
};

struct compat_bond_slave {
const char *name;
bool up;
Expand Down

0 comments on commit 2aebae8

Please sign in to comment.