Looks good,

Ethan

On Fri, Aug 19, 2011 at 15:28, Ben Pfaff <b...@nicira.com> wrote:
> This allows a command like "test-openflowd --enable-dummy dummy@br0
> --ports=dummy@eth0,dummy@eth1,dummy@eth2" to create a dummy datapath with
> a number of dummy ports.  This is more useful for testing than a dummy
> datapath with just an internal port, since output to "flood" and "normal"
> has less pathological results.
> ---
>  lib/netdev.c           |   19 +++++++++++++++++++
>  lib/netdev.h           |    2 ++
>  tests/test-openflowd.c |    6 +++++-
>  3 files changed, 26 insertions(+), 1 deletions(-)
>
> diff --git a/lib/netdev.c b/lib/netdev.c
> index 12ac81d..d198743 100644
> --- a/lib/netdev.c
> +++ b/lib/netdev.c
> @@ -359,6 +359,25 @@ netdev_enumerate(struct sset *sset)
>     return error;
>  }
>
> +/* Parses 'netdev_name_', which is of the form [type@]name into its component
> + * pieces.  'name' and 'type' must be freed by the caller. */
> +void
> +netdev_parse_name(const char *netdev_name_, char **name, char **type)
> +{
> +    char *netdev_name = xstrdup(netdev_name_);
> +    char *separator;
> +
> +    separator = strchr(netdev_name, '@');
> +    if (separator) {
> +        *separator = '\0';
> +        *type = netdev_name;
> +        *name = xstrdup(separator + 1);
> +    } else {
> +        *name = netdev_name;
> +        *type = xstrdup("system");
> +    }
> +}
> +
>  /* Attempts to set up 'netdev' for receiving packets with netdev_recv().
>  * Returns 0 if successful, otherwise a positive errno value.  EOPNOTSUPP
>  * indicates that the network device does not implement packet reception
> diff --git a/lib/netdev.h b/lib/netdev.h
> index 13d2ee7..1971e7c 100644
> --- a/lib/netdev.h
> +++ b/lib/netdev.h
> @@ -92,6 +92,8 @@ bool netdev_is_open(const char *name);
>
>  int netdev_enumerate(struct sset *);
>
> +void netdev_parse_name(const char *netdev_name, char **name, char **type);
> +
>  /* Options. */
>  int netdev_set_config(struct netdev *, const struct shash *args);
>  int netdev_get_config(const struct netdev *, struct shash *);
> diff --git a/tests/test-openflowd.c b/tests/test-openflowd.c
> index 016e1cb..3cc3a75 100644
> --- a/tests/test-openflowd.c
> +++ b/tests/test-openflowd.c
> @@ -123,12 +123,16 @@ main(int argc, char *argv[])
>     /* Add ports to the datapath if requested by the user. */
>     SSET_FOR_EACH (port, &s.ports) {
>         struct netdev *netdev;
> +        char *name, *type;
>
> -        error = netdev_open(port, "system", &netdev);
> +        netdev_parse_name(port, &name, &type);
> +        error = netdev_open(name, type, &netdev);
>         if (error) {
>             VLOG_FATAL("%s: failed to open network device (%s)",
>                        port, strerror(error));
>         }
> +        free(name);
> +        free(type);
>
>         error = ofproto_port_add(ofproto, netdev, NULL);
>         if (error) {
> --
> 1.7.4.4
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to