[ovs-dev] [bridge 04/15] bridge: Get rid of redundant bridge_get_local_iface() function.
Ethan Jackson
ethan at nicira.com
Mon Mar 21 19:55:45 UTC 2011
Looks Good.
On Mon, Mar 21, 2011 at 10:59 AM, Ben Pfaff <blp at nicira.com> wrote:
> Not only was this function redundant, it managed to spend O(n) time doing
> a task that should take only O(1)!
> ---
> vswitchd/bridge.c | 25 ++-----------------------
> 1 files changed, 2 insertions(+), 23 deletions(-)
>
> diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
> index 69eefaa..d07f591 100644
> --- a/vswitchd/bridge.c
> +++ b/vswitchd/bridge.c
> @@ -260,7 +260,6 @@ static void bridge_pick_local_hw_addr(struct bridge *,
> static uint64_t bridge_pick_datapath_id(struct bridge *,
> const uint8_t bridge_ea[ETH_ADDR_LEN],
> struct iface *hw_addr_iface);
> -static struct iface *bridge_get_local_iface(struct bridge *);
> static uint64_t dpid_from_hash(const void *, size_t nbytes);
>
> static unixctl_cb_func bridge_unixctl_fdb_show;
> @@ -760,7 +759,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
>
> /* Pick local port hardware address, datapath ID. */
> bridge_pick_local_hw_addr(br, ea, &hw_addr_iface);
> - local_iface = bridge_get_local_iface(br);
> + local_iface = iface_from_dp_ifidx(br, ODPP_LOCAL);
> if (local_iface) {
> int error = netdev_set_etheraddr(local_iface->netdev, ea);
> if (error) {
> @@ -1503,26 +1502,6 @@ bridge_flush(struct bridge *br)
> br->flush = true;
> mac_learning_flush(br->ml);
> }
> -
> -/* Returns the 'br' interface for the ODPP_LOCAL port, or null if 'br' has no
> - * such interface. */
> -static struct iface *
> -bridge_get_local_iface(struct bridge *br)
> -{
> - size_t i, j;
> -
> - for (i = 0; i < br->n_ports; i++) {
> - struct port *port = br->ports[i];
> - for (j = 0; j < port->n_ifaces; j++) {
> - struct iface *iface = port->ifaces[j];
> - if (iface->dp_ifidx == ODPP_LOCAL) {
> - return iface;
> - }
> - }
> - }
> -
> - return NULL;
> -}
>
> /* Bridge unixctl user interface functions. */
> static void
> @@ -1971,7 +1950,7 @@ bridge_configure_local_iface_netdev(struct bridge *br,
> struct in_addr ip;
>
> /* If there's no local interface or no IP address, give up. */
> - local_iface = bridge_get_local_iface(br);
> + local_iface = iface_from_dp_ifidx(br, ODPP_LOCAL);
> if (!local_iface || !c->local_ip || !inet_aton(c->local_ip, &ip)) {
> return;
> }
> --
> 1.7.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
More information about the dev
mailing list