[ovs-dev] [PATCH] vswitchd: Do not choose generated MAC address for local port.

Justin Pettit jpettit at nicira.com
Mon Dec 14 21:01:29 UTC 2009


Looks good.  eth_addr_is_vif() isn't used anywhere else, so I think it can be safely removed.  Then again, leaving it doesn't cause any harm, either...

--Justin


On Dec 14, 2009, at 12:56 PM, Ben Pfaff wrote:

> ovs-vswitchd needs to choose a sensible MAC address for the local port of
> a bridge.  Until now, the algorithm has ignored certain interfaces, in
> particular internal interfaces and those with the MAC addresses that
> indicate that they are probably Xen VIFs.  The goal is to choose a physical
> interface's MAC address because this is more stable and more likely to
> be meaningful to the outside world.  Stability, in turn, is important
> because the MAC address of the local port is used as the default datapath
> ID for OpenFlow connections.
> 
> This existing algorithm was too specialized to work well with the new
> kinds of ports that we have been introducing in OVS.  In particular,
> GRE ports could be chosen as the MAC address.  This commit changes the
> algorithm for choosing the local port MAC address.  Now it ignores any
> interface that has the "local" bit set in its MAC address, which
> catches GRE ports.  The new rule also catches the VIF and internal
> port cases, so this commit also deletes those special cases.
> 
> Jesse Gross suggested this revised heuristic.
> 
> CC: Jeremy Stribling <strib at nicira.com>
> ---
> vswitchd/bridge.c |   15 ++++++---------
> 1 files changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
> index c7aff74..2b4a3f0 100644
> --- a/vswitchd/bridge.c
> +++ b/vswitchd/bridge.c
> @@ -794,9 +794,8 @@ bridge_pick_local_hw_addr(struct bridge *br, uint8_t ea[ETH_ADDR_LEN],
>         }
>     }
> 
> -    /* Otherwise choose the minimum MAC address among all of the interfaces.
> -     * (Xen uses FE:FF:FF:FF:FF:FF for virtual interfaces so this will get the
> -     * MAC of the physical interface in such an environment.) */
> +    /* Otherwise choose the minimum non-local MAC address among all of the
> +     * interfaces. */
>     memset(ea, 0xff, sizeof ea);
>     for (i = 0; i < br->n_ports; i++) {
>         struct port *port = br->ports[i];
> @@ -837,11 +836,8 @@ bridge_pick_local_hw_addr(struct bridge *br, uint8_t ea[ETH_ADDR_LEN],
>             }
> 
>             /* The local port doesn't count (since we're trying to choose its
> -             * MAC address anyway).  Other internal ports don't count because
> -             * we really want a physical MAC if we can get it, and internal
> -             * ports typically have randomly generated MACs. */
> -            if (iface->dp_ifidx == ODPP_LOCAL
> -                || !strcmp(iface->cfg->type, "internal")) {
> +             * MAC address anyway). */
> +            if (iface->dp_ifidx == ODPP_LOCAL) {
>                 continue;
>             }
> 
> @@ -857,6 +853,7 @@ bridge_pick_local_hw_addr(struct bridge *br, uint8_t ea[ETH_ADDR_LEN],
> 
>         /* Compare against our current choice. */
>         if (!eth_addr_is_multicast(iface_ea) &&
> +            !eth_addr_is_local(iface_ea) &&
>             !eth_addr_is_reserved(iface_ea) &&
>             !eth_addr_is_zero(iface_ea) &&
>             memcmp(iface_ea, ea, ETH_ADDR_LEN) < 0)
> @@ -865,7 +862,7 @@ bridge_pick_local_hw_addr(struct bridge *br, uint8_t ea[ETH_ADDR_LEN],
>             *hw_addr_iface = iface;
>         }
>     }
> -    if (eth_addr_is_multicast(ea) || eth_addr_is_vif(ea)) {
> +    if (eth_addr_is_multicast(ea)) {
>         memcpy(ea, br->default_ea, ETH_ADDR_LEN);
>         *hw_addr_iface = NULL;
>         VLOG_WARN("bridge %s: using default bridge Ethernet "
> -- 
> 1.6.3.3
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list