Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-21 Thread Takashi YAMAMOTO
i don't have any problem with Xiao's approach.
just wanted to make sure alternatives considered.

wrt implementation, Xiao, can you rebase it?

On Fri, Apr 22, 2016 at 3:39 AM, Ben Pfaff  wrote:

> Yamamoto-san, I could really use your opinion here: do you think that
> this should be done differently?  If you do, then I will not accept it.
> But if you do not feel strongly about it, then I'll start properly
> reviewing it.
>
> Thanks,
>
> Ben.
>
> On Mon, Apr 18, 2016 at 07:05:52PM +0800, Xiao Liang wrote:
> > On Mon, Apr 18, 2016 at 5:46 PM, Takashi YAMAMOTO 
> wrote:
> > > for some reasons you want to change of_name without re-creating a port?
> > > why? (just curious)
> > >
> >
> > I don't have special use cases, just for convenience.
> >
> > >
> > > On Mon, Apr 18, 2016 at 4:19 PM, Xiao Liang 
> wrote:
> > >>
> > >> By introducing of_name, ovs_name serves as a key of ports which is
> > >> shared by ofproto and netdev. It's easier to find and convert ports
> > >> back and forth. of_name and kernel_name could be configured (if
> > >> supported) independently of each other.
> > >>
> > >> On Mon, Apr 18, 2016 at 11:43 AM, Takashi YAMAMOTO 
> > >> wrote:
> > >> > let me explain what netdev-bsd does first.
> > >> > on some platform "tap" interfaces are always named automatically by
> > >> > kernel
> > >> > itself
> > >> > and there's no way to rename them.  say, they always will have names
> > >> > like
> > >> > "tap0".
> > >> > so if you does "ovs-vsctl add-port br0 foo",
> > >> >   ovs_name = "foo"
> > >> >   kernel_name = "tap0"
> > >> >
> > >> > now, you are going to add another name for openflow. let's call it
> > >> > of_name.
> > >> > eg. "ovs-vsctl add-port br0 foo -- set int foo ofname=wan",
> > >> >   of_name = "wan"
> > >> >   ovs_name = "foo"
> > >> >   kernel_name = "tap0"
> > >> >
> > >> > while i don't have strong opinions either ways,
> > >> > i'm not sure why you want to use different names for of_name and
> > >> > ovs_name
> > >> > in the first place.  eg. what's wrong with "ovs-vsctl add-port br0
> wan".
> > >> > can you explain a little?
> > >> >
> > >> > On Mon, Apr 18, 2016 at 10:37 AM, Xiao Liang 
> > >> > wrote:
> > >> >>
> > >> >> Hi Ben, Yamamoto-san,
> > >> >>
> > >> >> Kindly remind you of this thread. Would like to hear your
> preference
> > >> >> on the way to implement this feature.
> > >> >>
> > >> >> On Mon, Apr 11, 2016 at 11:18 PM, Ben Pfaff  wrote:
> > >> >> > On Mon, Apr 11, 2016 at 04:30:04PM +0800, Xiao Liang wrote:
> > >> >> >> On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto
> > >> >> >>  wrote:
> > >> >> >> > hi,
> > >> >> >> >
> > >> >> >> > have you considered the opposite way?
> > >> >> >> > ie. have an ability to specify the device name.
> > >> >> >> >
> > >> >> >> > netdev-bsd already has a distinction between "kernel name" and
> > >> >> >> > "ovs
> > >> >> >> > name".
> > >> >> >> >
> > >> >> >>
> > >> >> >> Hi,
> > >> >> >>
> > >> >> >> I'm not familiar with netdev-bsd code, but I think this approach
> > >> >> >> will
> > >> >> >> make ports more difficult to manage and need much more effort.
> > >> >> >
> > >> >> > Yamamoto-san: thanks for bringing this up.  I'm going to wait
> for you
> > >> >> > and Xiao to talk this through a bit before continuing review.
> > >> >> ___
> > >> >> dev mailing list
> > >> >> dev@openvswitch.org
> > >> >> http://openvswitch.org/mailman/listinfo/dev
> > >> >
> > >> >
> > >
> > >
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-21 Thread Ben Pfaff
Yamamoto-san, I could really use your opinion here: do you think that
this should be done differently?  If you do, then I will not accept it.
But if you do not feel strongly about it, then I'll start properly
reviewing it.

Thanks,

Ben.

On Mon, Apr 18, 2016 at 07:05:52PM +0800, Xiao Liang wrote:
> On Mon, Apr 18, 2016 at 5:46 PM, Takashi YAMAMOTO  wrote:
> > for some reasons you want to change of_name without re-creating a port?
> > why? (just curious)
> >
> 
> I don't have special use cases, just for convenience.
> 
> >
> > On Mon, Apr 18, 2016 at 4:19 PM, Xiao Liang  wrote:
> >>
> >> By introducing of_name, ovs_name serves as a key of ports which is
> >> shared by ofproto and netdev. It's easier to find and convert ports
> >> back and forth. of_name and kernel_name could be configured (if
> >> supported) independently of each other.
> >>
> >> On Mon, Apr 18, 2016 at 11:43 AM, Takashi YAMAMOTO 
> >> wrote:
> >> > let me explain what netdev-bsd does first.
> >> > on some platform "tap" interfaces are always named automatically by
> >> > kernel
> >> > itself
> >> > and there's no way to rename them.  say, they always will have names
> >> > like
> >> > "tap0".
> >> > so if you does "ovs-vsctl add-port br0 foo",
> >> >   ovs_name = "foo"
> >> >   kernel_name = "tap0"
> >> >
> >> > now, you are going to add another name for openflow. let's call it
> >> > of_name.
> >> > eg. "ovs-vsctl add-port br0 foo -- set int foo ofname=wan",
> >> >   of_name = "wan"
> >> >   ovs_name = "foo"
> >> >   kernel_name = "tap0"
> >> >
> >> > while i don't have strong opinions either ways,
> >> > i'm not sure why you want to use different names for of_name and
> >> > ovs_name
> >> > in the first place.  eg. what's wrong with "ovs-vsctl add-port br0 wan".
> >> > can you explain a little?
> >> >
> >> > On Mon, Apr 18, 2016 at 10:37 AM, Xiao Liang 
> >> > wrote:
> >> >>
> >> >> Hi Ben, Yamamoto-san,
> >> >>
> >> >> Kindly remind you of this thread. Would like to hear your preference
> >> >> on the way to implement this feature.
> >> >>
> >> >> On Mon, Apr 11, 2016 at 11:18 PM, Ben Pfaff  wrote:
> >> >> > On Mon, Apr 11, 2016 at 04:30:04PM +0800, Xiao Liang wrote:
> >> >> >> On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto
> >> >> >>  wrote:
> >> >> >> > hi,
> >> >> >> >
> >> >> >> > have you considered the opposite way?
> >> >> >> > ie. have an ability to specify the device name.
> >> >> >> >
> >> >> >> > netdev-bsd already has a distinction between "kernel name" and
> >> >> >> > "ovs
> >> >> >> > name".
> >> >> >> >
> >> >> >>
> >> >> >> Hi,
> >> >> >>
> >> >> >> I'm not familiar with netdev-bsd code, but I think this approach
> >> >> >> will
> >> >> >> make ports more difficult to manage and need much more effort.
> >> >> >
> >> >> > Yamamoto-san: thanks for bringing this up.  I'm going to wait for you
> >> >> > and Xiao to talk this through a bit before continuing review.
> >> >> ___
> >> >> dev mailing list
> >> >> dev@openvswitch.org
> >> >> http://openvswitch.org/mailman/listinfo/dev
> >> >
> >> >
> >
> >
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-18 Thread Xiao Liang
On Mon, Apr 18, 2016 at 5:46 PM, Takashi YAMAMOTO  wrote:
> for some reasons you want to change of_name without re-creating a port?
> why? (just curious)
>

I don't have special use cases, just for convenience.

>
> On Mon, Apr 18, 2016 at 4:19 PM, Xiao Liang  wrote:
>>
>> By introducing of_name, ovs_name serves as a key of ports which is
>> shared by ofproto and netdev. It's easier to find and convert ports
>> back and forth. of_name and kernel_name could be configured (if
>> supported) independently of each other.
>>
>> On Mon, Apr 18, 2016 at 11:43 AM, Takashi YAMAMOTO 
>> wrote:
>> > let me explain what netdev-bsd does first.
>> > on some platform "tap" interfaces are always named automatically by
>> > kernel
>> > itself
>> > and there's no way to rename them.  say, they always will have names
>> > like
>> > "tap0".
>> > so if you does "ovs-vsctl add-port br0 foo",
>> >   ovs_name = "foo"
>> >   kernel_name = "tap0"
>> >
>> > now, you are going to add another name for openflow. let's call it
>> > of_name.
>> > eg. "ovs-vsctl add-port br0 foo -- set int foo ofname=wan",
>> >   of_name = "wan"
>> >   ovs_name = "foo"
>> >   kernel_name = "tap0"
>> >
>> > while i don't have strong opinions either ways,
>> > i'm not sure why you want to use different names for of_name and
>> > ovs_name
>> > in the first place.  eg. what's wrong with "ovs-vsctl add-port br0 wan".
>> > can you explain a little?
>> >
>> > On Mon, Apr 18, 2016 at 10:37 AM, Xiao Liang 
>> > wrote:
>> >>
>> >> Hi Ben, Yamamoto-san,
>> >>
>> >> Kindly remind you of this thread. Would like to hear your preference
>> >> on the way to implement this feature.
>> >>
>> >> On Mon, Apr 11, 2016 at 11:18 PM, Ben Pfaff  wrote:
>> >> > On Mon, Apr 11, 2016 at 04:30:04PM +0800, Xiao Liang wrote:
>> >> >> On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto
>> >> >>  wrote:
>> >> >> > hi,
>> >> >> >
>> >> >> > have you considered the opposite way?
>> >> >> > ie. have an ability to specify the device name.
>> >> >> >
>> >> >> > netdev-bsd already has a distinction between "kernel name" and
>> >> >> > "ovs
>> >> >> > name".
>> >> >> >
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> I'm not familiar with netdev-bsd code, but I think this approach
>> >> >> will
>> >> >> make ports more difficult to manage and need much more effort.
>> >> >
>> >> > Yamamoto-san: thanks for bringing this up.  I'm going to wait for you
>> >> > and Xiao to talk this through a bit before continuing review.
>> >> ___
>> >> dev mailing list
>> >> dev@openvswitch.org
>> >> http://openvswitch.org/mailman/listinfo/dev
>> >
>> >
>
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-18 Thread Takashi YAMAMOTO
for some reasons you want to change of_name without re-creating a port?
why? (just curious)

On Mon, Apr 18, 2016 at 4:19 PM, Xiao Liang  wrote:

> By introducing of_name, ovs_name serves as a key of ports which is
> shared by ofproto and netdev. It's easier to find and convert ports
> back and forth. of_name and kernel_name could be configured (if
> supported) independently of each other.
>
> On Mon, Apr 18, 2016 at 11:43 AM, Takashi YAMAMOTO 
> wrote:
> > let me explain what netdev-bsd does first.
> > on some platform "tap" interfaces are always named automatically by
> kernel
> > itself
> > and there's no way to rename them.  say, they always will have names like
> > "tap0".
> > so if you does "ovs-vsctl add-port br0 foo",
> >   ovs_name = "foo"
> >   kernel_name = "tap0"
> >
> > now, you are going to add another name for openflow. let's call it
> of_name.
> > eg. "ovs-vsctl add-port br0 foo -- set int foo ofname=wan",
> >   of_name = "wan"
> >   ovs_name = "foo"
> >   kernel_name = "tap0"
> >
> > while i don't have strong opinions either ways,
> > i'm not sure why you want to use different names for of_name and ovs_name
> > in the first place.  eg. what's wrong with "ovs-vsctl add-port br0 wan".
> > can you explain a little?
> >
> > On Mon, Apr 18, 2016 at 10:37 AM, Xiao Liang 
> wrote:
> >>
> >> Hi Ben, Yamamoto-san,
> >>
> >> Kindly remind you of this thread. Would like to hear your preference
> >> on the way to implement this feature.
> >>
> >> On Mon, Apr 11, 2016 at 11:18 PM, Ben Pfaff  wrote:
> >> > On Mon, Apr 11, 2016 at 04:30:04PM +0800, Xiao Liang wrote:
> >> >> On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto
> >> >>  wrote:
> >> >> > hi,
> >> >> >
> >> >> > have you considered the opposite way?
> >> >> > ie. have an ability to specify the device name.
> >> >> >
> >> >> > netdev-bsd already has a distinction between "kernel name" and "ovs
> >> >> > name".
> >> >> >
> >> >>
> >> >> Hi,
> >> >>
> >> >> I'm not familiar with netdev-bsd code, but I think this approach will
> >> >> make ports more difficult to manage and need much more effort.
> >> >
> >> > Yamamoto-san: thanks for bringing this up.  I'm going to wait for you
> >> > and Xiao to talk this through a bit before continuing review.
> >> ___
> >> dev mailing list
> >> dev@openvswitch.org
> >> http://openvswitch.org/mailman/listinfo/dev
> >
> >
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-18 Thread Xiao Liang
By introducing of_name, ovs_name serves as a key of ports which is
shared by ofproto and netdev. It's easier to find and convert ports
back and forth. of_name and kernel_name could be configured (if
supported) independently of each other.

On Mon, Apr 18, 2016 at 11:43 AM, Takashi YAMAMOTO  wrote:
> let me explain what netdev-bsd does first.
> on some platform "tap" interfaces are always named automatically by kernel
> itself
> and there's no way to rename them.  say, they always will have names like
> "tap0".
> so if you does "ovs-vsctl add-port br0 foo",
>   ovs_name = "foo"
>   kernel_name = "tap0"
>
> now, you are going to add another name for openflow. let's call it of_name.
> eg. "ovs-vsctl add-port br0 foo -- set int foo ofname=wan",
>   of_name = "wan"
>   ovs_name = "foo"
>   kernel_name = "tap0"
>
> while i don't have strong opinions either ways,
> i'm not sure why you want to use different names for of_name and ovs_name
> in the first place.  eg. what's wrong with "ovs-vsctl add-port br0 wan".
> can you explain a little?
>
> On Mon, Apr 18, 2016 at 10:37 AM, Xiao Liang  wrote:
>>
>> Hi Ben, Yamamoto-san,
>>
>> Kindly remind you of this thread. Would like to hear your preference
>> on the way to implement this feature.
>>
>> On Mon, Apr 11, 2016 at 11:18 PM, Ben Pfaff  wrote:
>> > On Mon, Apr 11, 2016 at 04:30:04PM +0800, Xiao Liang wrote:
>> >> On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto
>> >>  wrote:
>> >> > hi,
>> >> >
>> >> > have you considered the opposite way?
>> >> > ie. have an ability to specify the device name.
>> >> >
>> >> > netdev-bsd already has a distinction between "kernel name" and "ovs
>> >> > name".
>> >> >
>> >>
>> >> Hi,
>> >>
>> >> I'm not familiar with netdev-bsd code, but I think this approach will
>> >> make ports more difficult to manage and need much more effort.
>> >
>> > Yamamoto-san: thanks for bringing this up.  I'm going to wait for you
>> > and Xiao to talk this through a bit before continuing review.
>> ___
>> dev mailing list
>> dev@openvswitch.org
>> http://openvswitch.org/mailman/listinfo/dev
>
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-17 Thread Takashi YAMAMOTO
let me explain what netdev-bsd does first.
on some platform "tap" interfaces are always named automatically by kernel
itself
and there's no way to rename them.  say, they always will have names like
"tap0".
so if you does "ovs-vsctl add-port br0 foo",
  ovs_name = "foo"
  kernel_name = "tap0"

now, you are going to add another name for openflow. let's call it of_name.
eg. "ovs-vsctl add-port br0 foo -- set int foo ofname=wan",
  of_name = "wan"
  ovs_name = "foo"
  kernel_name = "tap0"

while i don't have strong opinions either ways,
i'm not sure why you want to use different names for of_name and ovs_name
in the first place.  eg. what's wrong with "ovs-vsctl add-port br0 wan".
can you explain a little?

On Mon, Apr 18, 2016 at 10:37 AM, Xiao Liang  wrote:

> Hi Ben, Yamamoto-san,
>
> Kindly remind you of this thread. Would like to hear your preference
> on the way to implement this feature.
>
> On Mon, Apr 11, 2016 at 11:18 PM, Ben Pfaff  wrote:
> > On Mon, Apr 11, 2016 at 04:30:04PM +0800, Xiao Liang wrote:
> >> On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto <
> yamam...@midokura.com> wrote:
> >> > hi,
> >> >
> >> > have you considered the opposite way?
> >> > ie. have an ability to specify the device name.
> >> >
> >> > netdev-bsd already has a distinction between "kernel name" and "ovs
> name".
> >> >
> >>
> >> Hi,
> >>
> >> I'm not familiar with netdev-bsd code, but I think this approach will
> >> make ports more difficult to manage and need much more effort.
> >
> > Yamamoto-san: thanks for bringing this up.  I'm going to wait for you
> > and Xiao to talk this through a bit before continuing review.
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-17 Thread Xiao Liang
Hi Ben, Yamamoto-san,

Kindly remind you of this thread. Would like to hear your preference
on the way to implement this feature.

On Mon, Apr 11, 2016 at 11:18 PM, Ben Pfaff  wrote:
> On Mon, Apr 11, 2016 at 04:30:04PM +0800, Xiao Liang wrote:
>> On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto  
>> wrote:
>> > hi,
>> >
>> > have you considered the opposite way?
>> > ie. have an ability to specify the device name.
>> >
>> > netdev-bsd already has a distinction between "kernel name" and "ovs name".
>> >
>>
>> Hi,
>>
>> I'm not familiar with netdev-bsd code, but I think this approach will
>> make ports more difficult to manage and need much more effort.
>
> Yamamoto-san: thanks for bringing this up.  I'm going to wait for you
> and Xiao to talk this through a bit before continuing review.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-11 Thread Ben Pfaff
On Mon, Apr 11, 2016 at 04:30:04PM +0800, Xiao Liang wrote:
> On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto  
> wrote:
> > hi,
> >
> > have you considered the opposite way?
> > ie. have an ability to specify the device name.
> >
> > netdev-bsd already has a distinction between "kernel name" and "ovs name".
> >
> 
> Hi,
> 
> I'm not familiar with netdev-bsd code, but I think this approach will
> make ports more difficult to manage and need much more effort.

Yamamoto-san: thanks for bringing this up.  I'm going to wait for you
and Xiao to talk this through a bit before continuing review.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-11 Thread Xiao Liang
On Mon, Apr 11, 2016 at 3:42 PM, Takashi Yamamoto  wrote:
> hi,
>
> have you considered the opposite way?
> ie. have an ability to specify the device name.
>
> netdev-bsd already has a distinction between "kernel name" and "ovs name".
>

Hi,

I'm not familiar with netdev-bsd code, but I think this approach will
make ports more difficult to manage and need much more effort.

Thanks,
Xiao

> On Mon, Apr 11, 2016 at 4:23 PM, Xiao Liang  wrote:
>> Add new column "ofname" in Interface table to configure port name reported
>> to controllers with OpenFlow protocol, thus decouple OpenFlow port name from
>> device name.
>>
>> For example:
>> # ovs-vsctl set Interface eth0 ofname=wan
>> # ovs-vsctl set Interface eth1 ofname=lan0
>> then controllers can recognize ports by their names.
>>
>> Signed-off-by: Xiao Liang 
>> ---
>> v2: Added test for ofname
>> Increased db schema version
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-11 Thread Takashi Yamamoto
hi,

have you considered the opposite way?
ie. have an ability to specify the device name.

netdev-bsd already has a distinction between "kernel name" and "ovs name".

On Mon, Apr 11, 2016 at 4:23 PM, Xiao Liang  wrote:
> Add new column "ofname" in Interface table to configure port name reported
> to controllers with OpenFlow protocol, thus decouple OpenFlow port name from
> device name.
>
> For example:
> # ovs-vsctl set Interface eth0 ofname=wan
> # ovs-vsctl set Interface eth1 ofname=lan0
> then controllers can recognize ports by their names.
>
> Signed-off-by: Xiao Liang 
> ---
> v2: Added test for ofname
> Increased db schema version
> ---
>  lib/db-ctl-base.h  |  2 +-
>  ofproto/ofproto-provider.h |  1 +
>  ofproto/ofproto.c  | 67 
> --
>  ofproto/ofproto.h  |  9 ++-
>  tests/ofproto.at   | 60 +
>  utilities/checkpatch.py|  2 +-
>  utilities/ovs-vsctl.c  |  1 +
>  vswitchd/bridge.c  | 10 +--
>  vswitchd/vswitch.ovsschema |  6 +++--
>  vswitchd/vswitch.xml   | 14 ++
>  10 files changed, 163 insertions(+), 9 deletions(-)
>
> diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h
> index f8f576b..5bd62d5 100644
> --- a/lib/db-ctl-base.h
> +++ b/lib/db-ctl-base.h
> @@ -177,7 +177,7 @@ struct weak_ref_table {
>  struct cmd_show_table {
>  const struct ovsdb_idl_table_class *table;
>  const struct ovsdb_idl_column *name_column;
> -const struct ovsdb_idl_column *columns[3]; /* Seems like a good number. 
> */
> +const struct ovsdb_idl_column *columns[4]; /* Seems like a good number. 
> */
>  const struct weak_ref_table wref_table;
>  };
>
> diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
> index 9373a2c..c34047c 100644
> --- a/ofproto/ofproto-provider.h
> +++ b/ofproto/ofproto-provider.h
> @@ -84,6 +84,7 @@ struct ofproto {
>  struct hmap ports;  /* Contains "struct ofport"s. */
>  struct shash port_by_name;
>  struct simap ofp_requests;  /* OpenFlow port number requests. */
> +struct smap ofp_names;  /* OpenFlow port names. */
>  uint16_t alloc_port_no; /* Last allocated OpenFlow port number. */
>  uint16_t max_ports; /* Max possible OpenFlow port num, plus one. 
> */
>  struct hmap ofport_usage;   /* Map ofport to last used time. */
> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index 6e74e5e..a47d139 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -549,6 +549,7 @@ ofproto_create(const char *datapath_name, const char 
> *datapath_type,
>  hmap_init(>ofport_usage);
>  shash_init(>port_by_name);
>  simap_init(>ofp_requests);
> +smap_init(>ofp_names);
>  ofproto->max_ports = ofp_to_u16(OFPP_MAX);
>  ofproto->eviction_group_timer = LLONG_MIN;
>  ofproto->tables = NULL;
> @@ -1545,6 +1546,7 @@ ofproto_destroy__(struct ofproto *ofproto)
>  hmap_destroy(>ofport_usage);
>  shash_destroy(>port_by_name);
>  simap_destroy(>ofp_requests);
> +smap_destroy(>ofp_names);
>
>  OFPROTO_FOR_EACH_TABLE (table, ofproto) {
>  oftable_destroy(table);
> @@ -1944,7 +1946,7 @@ ofproto_port_open_type(const char *datapath_type, const 
> char *port_type)
>   * 'ofp_portp' is non-null). */
>  int
>  ofproto_port_add(struct ofproto *ofproto, struct netdev *netdev,
> - ofp_port_t *ofp_portp)
> + ofp_port_t *ofp_portp, const char *ofp_name)
>  {
>  ofp_port_t ofp_port = ofp_portp ? *ofp_portp : OFPP_NONE;
>  int error;
> @@ -1955,6 +1957,9 @@ ofproto_port_add(struct ofproto *ofproto, struct netdev 
> *netdev,
>
>  simap_put(>ofp_requests, netdev_name,
>ofp_to_u16(ofp_port));
> +if (ofp_name) {
> +smap_replace(>ofp_names, netdev_name, ofp_name);
> +}
>  error = update_port(ofproto, netdev_name);
>  }
>  if (ofp_portp) {
> @@ -2008,6 +2013,8 @@ ofproto_port_del(struct ofproto *ofproto, ofp_port_t 
> ofp_port)
>  simap_delete(>ofp_requests, ofp_request_node);
>  }
>
> +smap_remove(>ofp_names, name);
> +
>  error = ofproto->ofproto_class->port_del(ofproto, ofp_port);
>  if (!error && ofport) {
>  /* 'name' is the netdev's name and update_port() is going to close 
> the
> @@ -2284,6 +2291,7 @@ ofport_open(struct ofproto *ofproto,
>  {
>  enum netdev_flags flags;
>  struct netdev *netdev;
> +const char *ofp_name;
>  int error;
>
>  error = netdev_open(ofproto_port->name, ofproto_port->type, );
> @@ -2306,7 +2314,13 @@ ofport_open(struct ofproto *ofproto,
>  }
>  pp->port_no = ofproto_port->ofp_port;
>  netdev_get_etheraddr(netdev, >hw_addr);
> -ovs_strlcpy(pp->name, ofproto_port->name, sizeof pp->name);
> +
> +ofp_name = smap_get(>ofp_names, ofproto_port->name);
> +if (!ofp_name) {
> +   

[ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-11 Thread Xiao Liang
Add new column "ofname" in Interface table to configure port name reported
to controllers with OpenFlow protocol, thus decouple OpenFlow port name from
device name.

For example:
# ovs-vsctl set Interface eth0 ofname=wan
# ovs-vsctl set Interface eth1 ofname=lan0
then controllers can recognize ports by their names.

Signed-off-by: Xiao Liang 
---
v2: Added test for ofname
Increased db schema version
Updated NEWS
---
 NEWS   |  1 +
 lib/db-ctl-base.h  |  2 +-
 ofproto/ofproto-provider.h |  1 +
 ofproto/ofproto.c  | 67 --
 ofproto/ofproto.h  |  9 ++-
 tests/ofproto.at   | 60 +
 utilities/checkpatch.py|  2 +-
 utilities/ovs-vsctl.c  |  1 +
 vswitchd/bridge.c  | 10 +--
 vswitchd/vswitch.ovsschema |  6 +++--
 vswitchd/vswitch.xml   | 14 ++
 11 files changed, 164 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index ea7f3a1..156781c 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Post-v2.5.0
now implemented.  Only flow mod and port mod messages are supported
in bundles.
  * New OpenFlow extension NXM_NX_MPLS_TTL to provide access to MPLS TTL.
+ * Port name can now be set with "ofname" column in the Interface table.
- ovs-ofctl:
  * queue-get-config command now allows a queue ID to be specified.
  * '--bundle' option can now be used with OpenFlow 1.3.
diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h
index f8f576b..5bd62d5 100644
--- a/lib/db-ctl-base.h
+++ b/lib/db-ctl-base.h
@@ -177,7 +177,7 @@ struct weak_ref_table {
 struct cmd_show_table {
 const struct ovsdb_idl_table_class *table;
 const struct ovsdb_idl_column *name_column;
-const struct ovsdb_idl_column *columns[3]; /* Seems like a good number. */
+const struct ovsdb_idl_column *columns[4]; /* Seems like a good number. */
 const struct weak_ref_table wref_table;
 };
 
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index 9373a2c..c34047c 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -84,6 +84,7 @@ struct ofproto {
 struct hmap ports;  /* Contains "struct ofport"s. */
 struct shash port_by_name;
 struct simap ofp_requests;  /* OpenFlow port number requests. */
+struct smap ofp_names;  /* OpenFlow port names. */
 uint16_t alloc_port_no; /* Last allocated OpenFlow port number. */
 uint16_t max_ports; /* Max possible OpenFlow port num, plus one. */
 struct hmap ofport_usage;   /* Map ofport to last used time. */
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 6e74e5e..a47d139 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -549,6 +549,7 @@ ofproto_create(const char *datapath_name, const char 
*datapath_type,
 hmap_init(>ofport_usage);
 shash_init(>port_by_name);
 simap_init(>ofp_requests);
+smap_init(>ofp_names);
 ofproto->max_ports = ofp_to_u16(OFPP_MAX);
 ofproto->eviction_group_timer = LLONG_MIN;
 ofproto->tables = NULL;
@@ -1545,6 +1546,7 @@ ofproto_destroy__(struct ofproto *ofproto)
 hmap_destroy(>ofport_usage);
 shash_destroy(>port_by_name);
 simap_destroy(>ofp_requests);
+smap_destroy(>ofp_names);
 
 OFPROTO_FOR_EACH_TABLE (table, ofproto) {
 oftable_destroy(table);
@@ -1944,7 +1946,7 @@ ofproto_port_open_type(const char *datapath_type, const 
char *port_type)
  * 'ofp_portp' is non-null). */
 int
 ofproto_port_add(struct ofproto *ofproto, struct netdev *netdev,
- ofp_port_t *ofp_portp)
+ ofp_port_t *ofp_portp, const char *ofp_name)
 {
 ofp_port_t ofp_port = ofp_portp ? *ofp_portp : OFPP_NONE;
 int error;
@@ -1955,6 +1957,9 @@ ofproto_port_add(struct ofproto *ofproto, struct netdev 
*netdev,
 
 simap_put(>ofp_requests, netdev_name,
   ofp_to_u16(ofp_port));
+if (ofp_name) {
+smap_replace(>ofp_names, netdev_name, ofp_name);
+}
 error = update_port(ofproto, netdev_name);
 }
 if (ofp_portp) {
@@ -2008,6 +2013,8 @@ ofproto_port_del(struct ofproto *ofproto, ofp_port_t 
ofp_port)
 simap_delete(>ofp_requests, ofp_request_node);
 }
 
+smap_remove(>ofp_names, name);
+
 error = ofproto->ofproto_class->port_del(ofproto, ofp_port);
 if (!error && ofport) {
 /* 'name' is the netdev's name and update_port() is going to close the
@@ -2284,6 +2291,7 @@ ofport_open(struct ofproto *ofproto,
 {
 enum netdev_flags flags;
 struct netdev *netdev;
+const char *ofp_name;
 int error;
 
 error = netdev_open(ofproto_port->name, ofproto_port->type, );
@@ -2306,7 +2314,13 @@ ofport_open(struct ofproto *ofproto,
 }
 pp->port_no = ofproto_port->ofp_port;
 netdev_get_etheraddr(netdev, >hw_addr);
-ovs_strlcpy(pp->name, ofproto_port->name, sizeof pp->name);
+
+

[ovs-dev] [PATCH v2] Add configurable OpenFlow port name.

2016-04-11 Thread Xiao Liang
Add new column "ofname" in Interface table to configure port name reported
to controllers with OpenFlow protocol, thus decouple OpenFlow port name from
device name.

For example:
# ovs-vsctl set Interface eth0 ofname=wan
# ovs-vsctl set Interface eth1 ofname=lan0
then controllers can recognize ports by their names.

Signed-off-by: Xiao Liang 
---
v2: Added test for ofname
Increased db schema version
---
 lib/db-ctl-base.h  |  2 +-
 ofproto/ofproto-provider.h |  1 +
 ofproto/ofproto.c  | 67 --
 ofproto/ofproto.h  |  9 ++-
 tests/ofproto.at   | 60 +
 utilities/checkpatch.py|  2 +-
 utilities/ovs-vsctl.c  |  1 +
 vswitchd/bridge.c  | 10 +--
 vswitchd/vswitch.ovsschema |  6 +++--
 vswitchd/vswitch.xml   | 14 ++
 10 files changed, 163 insertions(+), 9 deletions(-)

diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h
index f8f576b..5bd62d5 100644
--- a/lib/db-ctl-base.h
+++ b/lib/db-ctl-base.h
@@ -177,7 +177,7 @@ struct weak_ref_table {
 struct cmd_show_table {
 const struct ovsdb_idl_table_class *table;
 const struct ovsdb_idl_column *name_column;
-const struct ovsdb_idl_column *columns[3]; /* Seems like a good number. */
+const struct ovsdb_idl_column *columns[4]; /* Seems like a good number. */
 const struct weak_ref_table wref_table;
 };
 
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index 9373a2c..c34047c 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -84,6 +84,7 @@ struct ofproto {
 struct hmap ports;  /* Contains "struct ofport"s. */
 struct shash port_by_name;
 struct simap ofp_requests;  /* OpenFlow port number requests. */
+struct smap ofp_names;  /* OpenFlow port names. */
 uint16_t alloc_port_no; /* Last allocated OpenFlow port number. */
 uint16_t max_ports; /* Max possible OpenFlow port num, plus one. */
 struct hmap ofport_usage;   /* Map ofport to last used time. */
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 6e74e5e..a47d139 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -549,6 +549,7 @@ ofproto_create(const char *datapath_name, const char 
*datapath_type,
 hmap_init(>ofport_usage);
 shash_init(>port_by_name);
 simap_init(>ofp_requests);
+smap_init(>ofp_names);
 ofproto->max_ports = ofp_to_u16(OFPP_MAX);
 ofproto->eviction_group_timer = LLONG_MIN;
 ofproto->tables = NULL;
@@ -1545,6 +1546,7 @@ ofproto_destroy__(struct ofproto *ofproto)
 hmap_destroy(>ofport_usage);
 shash_destroy(>port_by_name);
 simap_destroy(>ofp_requests);
+smap_destroy(>ofp_names);
 
 OFPROTO_FOR_EACH_TABLE (table, ofproto) {
 oftable_destroy(table);
@@ -1944,7 +1946,7 @@ ofproto_port_open_type(const char *datapath_type, const 
char *port_type)
  * 'ofp_portp' is non-null). */
 int
 ofproto_port_add(struct ofproto *ofproto, struct netdev *netdev,
- ofp_port_t *ofp_portp)
+ ofp_port_t *ofp_portp, const char *ofp_name)
 {
 ofp_port_t ofp_port = ofp_portp ? *ofp_portp : OFPP_NONE;
 int error;
@@ -1955,6 +1957,9 @@ ofproto_port_add(struct ofproto *ofproto, struct netdev 
*netdev,
 
 simap_put(>ofp_requests, netdev_name,
   ofp_to_u16(ofp_port));
+if (ofp_name) {
+smap_replace(>ofp_names, netdev_name, ofp_name);
+}
 error = update_port(ofproto, netdev_name);
 }
 if (ofp_portp) {
@@ -2008,6 +2013,8 @@ ofproto_port_del(struct ofproto *ofproto, ofp_port_t 
ofp_port)
 simap_delete(>ofp_requests, ofp_request_node);
 }
 
+smap_remove(>ofp_names, name);
+
 error = ofproto->ofproto_class->port_del(ofproto, ofp_port);
 if (!error && ofport) {
 /* 'name' is the netdev's name and update_port() is going to close the
@@ -2284,6 +2291,7 @@ ofport_open(struct ofproto *ofproto,
 {
 enum netdev_flags flags;
 struct netdev *netdev;
+const char *ofp_name;
 int error;
 
 error = netdev_open(ofproto_port->name, ofproto_port->type, );
@@ -2306,7 +2314,13 @@ ofport_open(struct ofproto *ofproto,
 }
 pp->port_no = ofproto_port->ofp_port;
 netdev_get_etheraddr(netdev, >hw_addr);
-ovs_strlcpy(pp->name, ofproto_port->name, sizeof pp->name);
+
+ofp_name = smap_get(>ofp_names, ofproto_port->name);
+if (!ofp_name) {
+ofp_name = ofproto_port->name;
+}
+ovs_strlcpy(pp->name, ofp_name, sizeof pp->name);
+
 netdev_get_flags(netdev, );
 pp->config = flags & NETDEV_UP ? 0 : OFPUTIL_PC_PORT_DOWN;
 pp->state = netdev_get_carrier(netdev) ? 0 : OFPUTIL_PS_LINK_DOWN;
@@ -8010,3 +8024,52 @@ ofproto_port_set_realdev(struct ofproto *ofproto, 
ofp_port_t vlandev_ofp_port,
 }
 return error;
 }
+
+const char *
+ofproto_port_get_ofpname(struct ofproto *ofproto, ofp_port_t