git://git.onelab.eu
/
sliver-openvswitch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9759479
)
ovs-brcompatd: Convert svecs to ssets.
author
Ben Pfaff
<blp@nicira.com>
Fri, 25 Mar 2011 22:21:18 +0000
(15:21 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Thu, 31 Mar 2011 23:42:01 +0000
(16:42 -0700)
vswitchd/ovs-brcompatd.c
patch
|
blob
|
history
diff --git
a/vswitchd/ovs-brcompatd.c
b/vswitchd/ovs-brcompatd.c
index
f874a4d
..
3234529
100644
(file)
--- a/
vswitchd/ovs-brcompatd.c
+++ b/
vswitchd/ovs-brcompatd.c
@@
-51,7
+51,7
@@
#include "poll-loop.h"
#include "process.h"
#include "signals.h"
#include "poll-loop.h"
#include "process.h"
#include "signals.h"
-#include "s
vec
.h"
+#include "s
set
.h"
#include "timeval.h"
#include "unixctl.h"
#include "util.h"
#include "timeval.h"
#include "unixctl.h"
#include "util.h"
@@
-230,7
+230,7
@@
execute_appctl_command(const char *unixctl_command, char **output)
}
static void
}
static void
-do_get_bridge_parts(const struct ovsrec_bridge *br, struct s
vec
*parts,
+do_get_bridge_parts(const struct ovsrec_bridge *br, struct s
set
*parts,
int vlan, bool break_down_bonds)
{
size_t i, j;
int vlan, bool break_down_bonds)
{
size_t i, j;
@@
-247,10
+247,10
@@
do_get_bridge_parts(const struct ovsrec_bridge *br, struct svec *parts,
if (break_down_bonds) {
for (j = 0; j < port->n_interfaces; j++) {
const struct ovsrec_interface *iface = port->interfaces[j];
if (break_down_bonds) {
for (j = 0; j < port->n_interfaces; j++) {
const struct ovsrec_interface *iface = port->interfaces[j];
- s
vec
_add(parts, iface->name);
+ s
set
_add(parts, iface->name);
}
} else {
}
} else {
- s
vec
_add(parts, port->name);
+ s
set
_add(parts, port->name);
}
}
}
}
}
}
@@
-263,7
+263,7
@@
do_get_bridge_parts(const struct ovsrec_bridge *br, struct svec *parts,
* reported. If 'vlan' > 0, only interfaces with implicit VLAN 'vlan' are
* reported. */
static void
* reported. If 'vlan' > 0, only interfaces with implicit VLAN 'vlan' are
* reported. */
static void
-get_bridge_ifaces(const struct ovsrec_bridge *br, struct s
vec
*ifaces,
+get_bridge_ifaces(const struct ovsrec_bridge *br, struct s
set
*ifaces,
int vlan)
{
do_get_bridge_parts(br, ifaces, vlan, true);
int vlan)
{
do_get_bridge_parts(br, ifaces, vlan, true);
@@
-276,7
+276,7
@@
get_bridge_ifaces(const struct ovsrec_bridge *br, struct svec *ifaces,
* only trunk ports or ports with implicit VLAN 0 are reported. If 'vlan' > 0,
* only port with implicit VLAN 'vlan' are reported. */
static void
* only trunk ports or ports with implicit VLAN 0 are reported. If 'vlan' > 0,
* only port with implicit VLAN 'vlan' are reported. */
static void
-get_bridge_ports(const struct ovsrec_bridge *br, struct s
vec
*ports,
+get_bridge_ports(const struct ovsrec_bridge *br, struct s
set
*ports,
int vlan)
{
do_get_bridge_parts(br, ports, vlan, false);
int vlan)
{
do_get_bridge_parts(br, ports, vlan, false);
@@
-813,9
+813,10
@@
handle_fdb_query_cmd(const struct ovsrec_open_vswitch *ovs,
const char *linux_name; /* Name used by brctl. */
const struct ovsrec_bridge *ovs_bridge; /* Bridge used by ovs-vswitchd. */
int br_vlan; /* VLAN tag. */
const char *linux_name; /* Name used by brctl. */
const struct ovsrec_bridge *ovs_bridge; /* Bridge used by ovs-vswitchd. */
int br_vlan; /* VLAN tag. */
- struct s
vec
ifaces;
+ struct s
set
ifaces;
struct ofpbuf query_data;
struct ofpbuf query_data;
+ const char *iface_name;
struct ofpbuf *reply;
char *unixctl_command;
uint64_t count, skip;
struct ofpbuf *reply;
char *unixctl_command;
uint64_t count, skip;
@@
-849,12
+850,11
@@
handle_fdb_query_cmd(const struct ovsrec_open_vswitch *ovs,
/* Fetch the MAC address for each interface on the bridge, so that we can
* fill in the is_local field in the response. */
/* Fetch the MAC address for each interface on the bridge, so that we can
* fill in the is_local field in the response. */
- s
vec
_init(&ifaces);
+ s
set
_init(&ifaces);
get_bridge_ifaces(ovs_bridge, &ifaces, br_vlan);
get_bridge_ifaces(ovs_bridge, &ifaces, br_vlan);
- local_macs = xmalloc(
ifaces.n
* sizeof *local_macs);
+ local_macs = xmalloc(
sset_count(&ifaces)
* sizeof *local_macs);
n_local_macs = 0;
n_local_macs = 0;
- for (i = 0; i < ifaces.n; i++) {
- const char *iface_name = ifaces.names[i];
+ SSET_FOR_EACH (iface_name, &ifaces) {
struct mac *mac = &local_macs[n_local_macs];
struct netdev *netdev;
struct mac *mac = &local_macs[n_local_macs];
struct netdev *netdev;
@@
-866,7
+866,7
@@
handle_fdb_query_cmd(const struct ovsrec_open_vswitch *ovs,
netdev_close(netdev);
}
}
netdev_close(netdev);
}
}
- s
vec
_destroy(&ifaces);
+ s
set
_destroy(&ifaces);
/* Parse the response from ovs-appctl and convert it to binary format to
* pass back to the kernel. */
/* Parse the response from ovs-appctl and convert it to binary format to
* pass back to the kernel. */
@@
-937,22
+937,17
@@
handle_fdb_query_cmd(const struct ovsrec_open_vswitch *ovs,
}
static void
}
static void
-send_ifindex_reply(uint32_t seq, struct s
vec
*ifaces)
+send_ifindex_reply(uint32_t seq, struct s
set
*ifaces)
{
struct ofpbuf *reply;
const char *iface;
size_t n_indices;
int *indices;
{
struct ofpbuf *reply;
const char *iface;
size_t n_indices;
int *indices;
- size_t i;
-
- /* Make sure that any given interface only occurs once. This shouldn't
- * happen, but who knows what people put into their configuration files. */
- svec_sort_unique(ifaces);
/* Convert 'ifaces' into ifindexes. */
n_indices = 0;
/* Convert 'ifaces' into ifindexes. */
n_indices = 0;
- indices = xmalloc(
ifaces->n
* sizeof *indices);
- S
VEC_FOR_EACH (i,
iface, ifaces) {
+ indices = xmalloc(
sset_count(ifaces)
* sizeof *indices);
+ S
SET_FOR_EACH (
iface, ifaces) {
int ifindex = if_nametoindex(iface);
if (ifindex) {
indices[n_indices++] = ifindex;
int ifindex = if_nametoindex(iface);
if (ifindex) {
indices[n_indices++] = ifindex;
@@
-973,7
+968,7
@@
static int
handle_get_bridges_cmd(const struct ovsrec_open_vswitch *ovs,
struct ofpbuf *buffer)
{
handle_get_bridges_cmd(const struct ovsrec_open_vswitch *ovs,
struct ofpbuf *buffer)
{
- struct s
vec
bridges;
+ struct s
set
bridges;
size_t i, j;
uint32_t seq;
size_t i, j;
uint32_t seq;
@@
-990,22
+985,22
@@
handle_get_bridges_cmd(const struct ovsrec_open_vswitch *ovs,
}
/* Get all the real bridges and all the fake ones. */
}
/* Get all the real bridges and all the fake ones. */
- s
vec
_init(&bridges);
+ s
set
_init(&bridges);
for (i = 0; i < ovs->n_bridges; i++) {
const struct ovsrec_bridge *br = ovs->bridges[i];
for (i = 0; i < ovs->n_bridges; i++) {
const struct ovsrec_bridge *br = ovs->bridges[i];
- s
vec
_add(&bridges, br->name);
+ s
set
_add(&bridges, br->name);
for (j = 0; j < br->n_ports; j++) {
const struct ovsrec_port *port = br->ports[j];
if (port->fake_bridge) {
for (j = 0; j < br->n_ports; j++) {
const struct ovsrec_port *port = br->ports[j];
if (port->fake_bridge) {
- s
vec
_add(&bridges, port->name);
+ s
set
_add(&bridges, port->name);
}
}
}
send_ifindex_reply(seq, &bridges);
}
}
}
send_ifindex_reply(seq, &bridges);
- s
vec
_destroy(&bridges);
+ s
set
_destroy(&bridges);
return 0;
}
return 0;
}
@@
-1020,7
+1015,7
@@
handle_get_ports_cmd(const struct ovsrec_open_vswitch *ovs,
const struct ovsrec_bridge *ovs_bridge;
int br_vlan;
const struct ovsrec_bridge *ovs_bridge;
int br_vlan;
- struct s
vec
ports;
+ struct s
set
ports;
int error;
int error;
@@
-1037,12
+1032,11
@@
handle_get_ports_cmd(const struct ovsrec_open_vswitch *ovs,
return error;
}
return error;
}
- s
vec
_init(&ports);
+ s
set
_init(&ports);
get_bridge_ports(ovs_bridge, &ports, br_vlan);
get_bridge_ports(ovs_bridge, &ports, br_vlan);
- svec_sort(&ports);
- svec_del(&ports, linux_name);
+ sset_find_and_delete(&ports, linux_name);
send_ifindex_reply(seq, &ports); /* XXX bonds won't show up */
send_ifindex_reply(seq, &ports); /* XXX bonds won't show up */
- s
vec
_destroy(&ports);
+ s
set
_destroy(&ports);
return 0;
}
return 0;
}