On Thu, May 04, 2017 at 01:53:31AM -0700, Andy Zhou wrote:
> On Wed, May 3, 2017 at 8:45 AM, Ben Pfaff <[email protected]> wrote:
> > This makes ovn-trace commands easier to type.
> >
> > Signed-off-by: Ben Pfaff <[email protected]>
> > ---
> >  ovn/utilities/ovn-trace.c | 44 ++++++++++++++++++++++++++++++++++++--------
> >  1 file changed, 36 insertions(+), 8 deletions(-)
> >
> > diff --git a/ovn/utilities/ovn-trace.c b/ovn/utilities/ovn-trace.c
> > index 860fd4b26be0..7ad7839a4a1a 100644
> > --- a/ovn/utilities/ovn-trace.c
> > +++ b/ovn/utilities/ovn-trace.c
> > @@ -352,6 +352,7 @@ struct ovntrace_datapath {
> >
> >  struct ovntrace_port {
> >      struct ovntrace_datapath *dp;
> > +    struct uuid uuid;
> >      char *name;
> >      char *type;
> >      uint16_t tunnel_key;
> > @@ -429,15 +430,15 @@ ovntrace_datapath_find_by_sb_uuid(const struct uuid 
> > *sb_uuid)
> >  static const struct ovntrace_datapath *
> >  ovntrace_datapath_find_by_name(const char *name)
> >  {
> > -    struct uuid uuid;
> > -    bool is_uuid = uuid_from_string(&uuid, name);
> > -
> >      struct ovntrace_datapath *dp;
> >      HMAP_FOR_EACH (dp, sb_uuid_node, &datapaths) {
> > -        if (!strcmp(name, dp->name)
> > -            || (is_uuid
> > -                && (uuid_equals(&uuid, &dp->sb_uuid) ||
> > -                    uuid_equals(&uuid, &dp->nb_uuid)))) {
> > +        if (!strcmp(name, dp->name)) {
> > +            return dp;
> > +        }
> > +    }
> > +    HMAP_FOR_EACH (dp, sb_uuid_node, &datapaths) {
> > +        if (uuid_is_partial_match(&dp->sb_uuid, name) >= 4 ||
> > +            uuid_is_partial_match(&dp->nb_uuid, name) >= 4) {
> Should we check for multiple matches?

You're right.

I added code for that here and in ovntrace_port_lookup_by_name().

> > +static const struct ovntrace_port *
> > +ovntrace_port_lookup_by_name(const char *name)
> > +{
> > +    const struct ovntrace_port *port = shash_find_data(&ports, name);
> > +    if (port) {
> > +        return port;
> > +    }
> > +
> > +    if (uuid_is_partial_string(name) >= 4) {
> > +        struct shash_node *node;
> > +        SHASH_FOR_EACH (node, &ports) {
> > +            const struct ovntrace_port *port = node->data;
> > +
> > +            struct uuid name_uuid;
> > +            if (uuid_is_partial_match(&port->uuid, name) >= 4
> > +                || (uuid_from_string(&name_uuid, port->name)
> > +                    && uuid_is_partial_match(&name_uuid, name) >= 4)) {
> > +                return port;
> > +            }
> > +        }
> It seems we don't need the two >=4 check for the
> uuid_is_partial_match(), because
> the uuid_is_partial_string(name) >=4.

You're right.  I dropped the >=4 parts.

Thanks,

Ben.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to