[ovs-dev] [bridge 12/15] bridge: Use pointer to "struct port", not "port_idx", for MAC learning.
Ben Pfaff
blp at nicira.com
Mon Mar 21 10:59:53 PDT 2011
This takes a step toward changing the data structure used for keeping
track of ports from an array to a more appropriate data structure.
---
vswitchd/bridge.c | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 28fcd36..e18e2ce 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1517,11 +1517,9 @@ bridge_unixctl_fdb_show(struct unixctl_conn *conn,
ds_put_cstr(&ds, " port VLAN MAC Age\n");
LIST_FOR_EACH (e, lru_node, &br->ml->lrus) {
- if (e->port.i < 0 || e->port.i >= br->n_ports) {
- continue;
- }
+ struct port *port = e->port.p;
ds_put_format(&ds, "%5d %4d "ETH_ADDR_FMT" %3d\n",
- port_get_an_iface(br->ports[e->port.i])->dp_ifidx,
+ port_get_an_iface(br->ports[port])->dp_ifidx,
e->vlan, ETH_ADDR_ARGS(e->mac), mac_entry_age(e));
}
unixctl_command_reply(conn, 200, ds_cstr(&ds));
@@ -2786,7 +2784,7 @@ update_learning_table(struct bridge *br, const struct flow *flow, int vlan,
}
mac_learning_touch(br->ml, mac);
- if (mac_entry_is_new(mac) || mac->port.i != in_port->port_idx) {
+ if (mac_entry_is_new(mac) || mac->port.p != in_port) {
/* The log messages here could actually be useful in debugging,
* so keep the rate limit relatively high. */
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(30, 300);
@@ -2795,7 +2793,7 @@ update_learning_table(struct bridge *br, const struct flow *flow, int vlan,
br->name, ETH_ADDR_ARGS(flow->dl_src),
in_port->name, vlan);
- mac->port.i = in_port->port_idx;
+ mac->port.p = in_port;
ofproto_revalidate(br->ofproto, mac_learning_change(br->ml, mac));
}
}
@@ -2901,7 +2899,7 @@ is_admissible(struct bridge *br, const struct flow *flow, bool have_packet,
* reflections on bond slaves. If this is the case, just drop the
* packet now. */
mac = mac_learning_lookup(br->ml, flow->dl_src, vlan, NULL);
- if (mac && mac->port.i != in_port->port_idx &&
+ if (mac && mac->port.p != in_port &&
(!is_gratuitous_arp(flow) || mac_entry_is_grat_arp_locked(mac))) {
return false;
}
@@ -2936,8 +2934,8 @@ process_flow(struct bridge *br, const struct flow *flow,
/* Determine output port. */
mac = mac_learning_lookup(br->ml, flow->dl_dst, vlan, tags);
- if (mac && mac->port.i >= 0 && mac->port.i < br->n_ports) {
- out_port = br->ports[mac->port.i];
+ if (mac) {
+ mac = mac->port.p;
} else if (!packet && !eth_addr_is_multicast(flow->dl_dst)) {
/* If we are revalidating but don't have a learning entry then
* eject the flow. Installing a flow that floods packets opens
@@ -3424,7 +3422,7 @@ bond_send_learning_packets(struct port *port)
struct flow flow;
int retval;
- if (e->port.i == port->port_idx) {
+ if (e->port.p == port) {
continue;
}
@@ -3600,7 +3598,7 @@ bond_unixctl_show(struct unixctl_conn *conn,
memcpy(flow.dl_src, me->mac, ETH_ADDR_LEN);
if (bond_hash_src(me->mac, me->vlan) == hash
- && me->port.i != port->port_idx
+ && me->port.p != port
&& choose_output_iface(port, &flow, me->vlan,
&dp_ifidx, &tags)
&& dp_ifidx == iface->dp_ifidx)
--
1.7.1
More information about the dev
mailing list