[ovs-dev] [branch 2.12] ovn-controller: Encode the virtual port key in vport_bind action in network byte order

Justin Pettit jpettit at ovn.org
Thu Aug 8 17:09:48 UTC 2019


Thanks.  I merged this into branch-2.12.

--Justin

> On Aug 5, 2019, at 11:54 PM, nusiddiq at redhat.com wrote:
> 
> From: Numan Siddique <nusiddiq at redhat.com>
> 
> The commit [1] encoded the vport key using uint32_t and the test case
> "action parsing" is failing for s380 arch.
> 
> This patch fixes this issue by encoding the vport key in the network byte
> order.
> 
> [1] - 054f4c85c413("Add a new logical switch port type - 'virtual'")
> Fixes: 054f4c85c413("Add a new logical switch port type - 'virtual'")
> 
> Signed-off-by: Numan Siddique <nusiddiq at redhat.com>
> Signed-off-by: Numan Siddique <nusiddiq at redhat.com>
> Acked-by: Dumitru Ceara <dceara at redhat.com>
> Signed-off-by: Mark Michelson <mmichels at redhat.com>
> 
> (cherry-picked from ovn commit - 3c39d74444e21f6c24acfc9f934ee01263fa0dc3)
> ---
> ovn/controller/pinctrl.c | 11 ++++++-----
> ovn/lib/actions.c        |  3 ++-
> tests/ovn.at             |  2 +-
> 3 files changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
> index 357050eb5..e443449f5 100644
> --- a/ovn/controller/pinctrl.c
> +++ b/ovn/controller/pinctrl.c
> @@ -4489,16 +4489,17 @@ pinctrl_handle_bind_vport(
>     uint32_t vport_parent_key = md->regs[MFF_LOG_INPORT - MFF_REG0];
> 
>     /* Get the virtual port key from the userdata buffer. */
> -    uint32_t *vport_key = ofpbuf_try_pull(userdata, sizeof *vport_key);
> +    ovs_be32 *vp_key = ofpbuf_try_pull(userdata, sizeof *vp_key);
> 
> -    if (!vport_key) {
> +    if (!vp_key) {
>         return;
>     }
> 
> -    uint32_t hash = hash_2words(dp_key, *vport_key);
> +    uint32_t vport_key = ntohl(*vp_key);
> +    uint32_t hash = hash_2words(dp_key, vport_key);
> 
>     struct put_vport_binding *vpb
> -        = pinctrl_find_put_vport_binding(dp_key, *vport_key, hash);
> +        = pinctrl_find_put_vport_binding(dp_key, vport_key, hash);
>     if (!vpb) {
>         if (hmap_count(&put_vport_bindings) >= 1000) {
>             COVERAGE_INC(pinctrl_drop_put_vport_binding);
> @@ -4510,7 +4511,7 @@ pinctrl_handle_bind_vport(
>     }
> 
>     vpb->dp_key = dp_key;
> -    vpb->vport_key = *vport_key;
> +    vpb->vport_key = vport_key;
>     vpb->vport_parent_key = vport_parent_key;
> 
>     notify_pinctrl_main();
> diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c
> index 66916a837..b0cb3490b 100644
> --- a/ovn/lib/actions.c
> +++ b/ovn/lib/actions.c
> @@ -2645,7 +2645,8 @@ encode_BIND_VPORT(const struct ovnact_bind_vport *vp,
>     size_t oc_offset = encode_start_controller_op(ACTION_OPCODE_BIND_VPORT,
>                                                   false, NX_CTLR_NO_METER,
>                                                   ofpacts);
> -    ofpbuf_put(ofpacts, &vport_key, sizeof(uint32_t));
> +    ovs_be32 vp_key = htonl(vport_key);
> +    ofpbuf_put(ofpacts, &vp_key, sizeof(ovs_be32));
>     encode_finish_controller_op(oc_offset, ofpacts);
>     encode_restore_args(args, ARRAY_SIZE(args), ofpacts);
> }
> diff --git a/tests/ovn.at b/tests/ovn.at
> index 5d6c90c5f..92307c158 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -1371,7 +1371,7 @@ reg0[0] = check_pkt_larger(foo);
> # bind_vport
> # lsp1's port key is 0x11.
> bind_vport("lsp1", inport);
> -    encodes as controller(userdata=00.00.00.11.00.00.00.00.11.00.00.00)
> +    encodes as controller(userdata=00.00.00.11.00.00.00.00.00.00.00.11)
> # lsp2 doesn't exist. So it should be encoded as drop.
> bind_vport("lsp2", inport);
>     encodes as drop
> -- 
> 2.21.0
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev



More information about the dev mailing list