[ovs-dev] [PATCH 1/2] ofproto: Consistently use netdev's name instead of ofp_phy_port name.

Ethan Jackson ethan at nicira.com
Thu Apr 21 18:28:50 UTC 2011


Seems fine to me.

Ethan

On Wed, Apr 20, 2011 at 1:47 PM, Ben Pfaff <blp at nicira.com> wrote:
> There are at least two ways to get an ofport's name: from the netdev using
> netdev_get_name() or from the ofp_phy_port's 'name' member.  Some code used
> one, some used the other.  This switches all relevant code to use only
> netdev_get_name(), because the 'name' member in ofp_phy_port is
> fixed-length and thus a long name could be truncated.
>
> This isn't a problem under Linux since the maximum length of a network
> device's name under Linux is the same as the field width in ofp_phy_port.
> ---
>  ofproto/ofproto.c |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index 69639ac..a6ad933 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -913,7 +913,7 @@ int
>  ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
>  {
>     struct ofport *ofport = get_port(ofproto, odp_port);
> -    const char *name = ofport ? ofport->opp.name : "<unknown>";
> +    const char *name = ofport ? netdev_get_name(ofport->netdev) : "<unknown>";
>     int error;
>
>     error = dpif_port_del(ofproto->dpif, odp_port);
> @@ -921,8 +921,8 @@ ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
>         VLOG_ERR("%s: failed to remove port %"PRIu16" (%s) interface (%s)",
>                  dpif_name(ofproto->dpif), odp_port, name, strerror(error));
>     } else if (ofport) {
> -        /* 'name' is ofport->opp.name and update_port() is going to destroy
> -         * 'ofport'.  Just in case update_port() refers to 'name' after it
> +        /* 'name' is the netdev's name and update_port() is going to close the
> +         * netdev.  Just in case update_port() refers to 'name' after it
>          * destroys 'ofport', make a copy of it around the update_port()
>          * call. */
>         char *devname = xstrdup(name);
> @@ -1049,7 +1049,7 @@ reinit_ports(struct ofproto *p)
>
>     sset_init(&devnames);
>     HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
> -        sset_add(&devnames, ofport->opp.name);
> +        sset_add(&devnames, netdev_get_name(ofport->netdev));
>     }
>     DPIF_PORT_FOR_EACH (&dpif_port, &dump, p->dpif) {
>         sset_add(&devnames, dpif_port.name);
> @@ -1139,7 +1139,7 @@ ofport_equal(const struct ofport *a_, const struct ofport *b_)
>  static void
>  ofport_install(struct ofproto *p, struct ofport *ofport)
>  {
> -    const char *netdev_name = ofport->opp.name;
> +    const char *netdev_name = netdev_get_name(ofport->netdev);
>
>     netdev_monitor_add(p->netdev_monitor, ofport->netdev);
>     hmap_insert(&p->ports, &ofport->hmap_node, hash_int(ofport->odp_port, 0));
> @@ -1155,7 +1155,8 @@ ofport_remove(struct ofproto *p, struct ofport *ofport)
>     netdev_monitor_remove(p->netdev_monitor, ofport->netdev);
>     hmap_remove(&p->ports, &ofport->hmap_node);
>     shash_delete(&p->port_by_name,
> -                 shash_find(&p->port_by_name, ofport->opp.name));
> +                 shash_find(&p->port_by_name,
> +                            netdev_get_name(ofport->netdev)));
>     if (p->sflow) {
>         ofproto_sflow_del_port(p->sflow, ofport->odp_port);
>     }
> --
> 1.7.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list