[ovs-dev] [branch-1.10] ofproto-dpif.c: Modify vsp_realdev_to_vlandev() function

Alex Wang alexw at nicira.com
Wed Jun 5 19:53:42 UTC 2013


Looks good to me. Thanks~


On Wed, Jun 5, 2013 at 12:36 PM, Ben Pfaff <blp at nicira.com> wrote:

> On Wed, Jun 05, 2013 at 10:46:13AM -0700, Alex Wang wrote:
> > Hey Ben,
> >
> > I found in that the "send_packet()" function in branch-1.10 also invokes
> > the "realdev_to_vlandev()" function. So there needs another fix in
> > branch-1.10.
>
> OK, how about like this, then.
>
> --8<--------------------------cut here-------------------------->8--
>
> From: Alex Wang <alexw at nicira.com>
> Date: Wed, 5 Jun 2013 12:34:01 -0700
> Subject: [PATCH] ofproto-dpif.c: Modify vsp_realdev_to_vlandev() function
>
> Commit 52a90c29 (Implement new "VLAN splinters" feature) passed in OpenFlow
> port number to vsp_realdev_to_vlandev() function which asks for datapath
> port
> number.
>
> This patch fixes this bug by making the vsp_realdev_to_vlandev() function
> take in and return OpenFlow port number.
>
> Signed-off-by: Alex Wang <alexw at nicira.com>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
>  ofproto/ofproto-dpif.c |   47
> +++++++++++++++++++++++++++--------------------
>  1 files changed, 27 insertions(+), 20 deletions(-)
>
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index bf8a601..8c8487a 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -570,8 +570,9 @@ struct vlan_splinter {
>      int vid;
>  };
>
> -static uint32_t vsp_realdev_to_vlandev(const struct ofproto_dpif *,
> -                                       uint32_t realdev, ovs_be16
> vlan_tci);
> +static uint16_t vsp_realdev_to_vlandev(const struct ofproto_dpif *,
> +                                       uint16_t realdev_ofp_port,
> +                                       ovs_be16 vlan_tci);
>  static bool vsp_adjust_flow(const struct ofproto_dpif *, struct flow *);
>  static void vsp_remove(struct ofport_dpif *);
>  static void vsp_add(struct ofport_dpif *, uint16_t realdev_ofp_port, int
> vid);
> @@ -5752,9 +5753,13 @@ send_packet(const struct ofport_dpif *ofport,
> struct ofpbuf *packet)
>          odp_put_tunnel_action(&flow.tunnel, &odp_actions);
>          odp_put_skb_mark_action(flow.skb_mark, &odp_actions);
>      } else {
> -        odp_port = vsp_realdev_to_vlandev(ofproto, ofport->odp_port,
> -                                          flow.vlan_tci);
> -        if (odp_port != ofport->odp_port) {
> +        uint16_t vlandev_port;
> +        vlandev_port = vsp_realdev_to_vlandev(ofproto,
> ofport->up.ofp_port,
> +                                              flow.vlan_tci);
> +        if (vlandev_port == ofport->up.ofp_port) {
> +            odp_port = ofport->odp_port;
> +        } else {
> +            odp_port = ofp_port_to_odp_port(ofproto, vlandev_port);
>              eth_pop_vlan(packet);
>              flow.vlan_tci = htons(0);
>          }
> @@ -6035,9 +6040,13 @@ compose_output_action__(struct action_xlate_ctx
> *ctx, uint16_t ofp_port,
>          commit_odp_tunnel_action(&ctx->flow, &ctx->base_flow,
>                                   ctx->odp_actions);
>      } else {
> -        out_port = vsp_realdev_to_vlandev(ctx->ofproto, odp_port,
> -                                          ctx->flow.vlan_tci);
> -        if (out_port != odp_port) {
> +        uint16_t vlandev_port;
> +        vlandev_port = vsp_realdev_to_vlandev(ctx->ofproto, ofp_port,
> +                                              ctx->flow.vlan_tci);
> +        if (vlandev_port == ofp_port) {
> +            out_port = odp_port;
> +        } else {
> +            out_port = ofp_port_to_odp_port(ctx->ofproto, vlandev_port);
>              ctx->flow.vlan_tci = htons(0);
>          }
>          ctx->flow.skb_mark &= ~IPSEC_MARK;
> @@ -8434,33 +8443,31 @@ hash_realdev_vid(uint16_t realdev_ofp_port, int
> vid)
>      return hash_2words(realdev_ofp_port, vid);
>  }
>
> -/* Returns the ODP port number of the Linux VLAN device that corresponds
> to
> - * 'vlan_tci' on the network device with port number 'realdev_odp_port' in
> - * 'ofproto'.  For example, given 'realdev_odp_port' of eth0 and
> 'vlan_tci' 9,
> - * it would return the port number of eth0.9.
> +/* Returns the OFP port number of the Linux VLAN device that corresponds
> to
> + * 'vlan_tci' on the network device with port number 'realdev_ofp_port' in
> + * 'struct ofport_dpif'.  For example, given 'realdev_ofp_port' of eth0
> and
> + * 'vlan_tci' 9, it would return the port number of eth0.9.
>   *
> - * Unless VLAN splinters are enabled for port 'realdev_odp_port', this
> - * function just returns its 'realdev_odp_port' argument. */
> -static uint32_t
> + * Unless VLAN splinters are enabled for port 'realdev_ofp_port', this
> + * function just returns its 'realdev_ofp_port' argument. */
> +static uint16_t
>  vsp_realdev_to_vlandev(const struct ofproto_dpif *ofproto,
> -                       uint32_t realdev_odp_port, ovs_be16 vlan_tci)
> +                       uint16_t realdev_ofp_port, ovs_be16 vlan_tci)
>  {
>      if (!hmap_is_empty(&ofproto->realdev_vid_map)) {
> -        uint16_t realdev_ofp_port;
>          int vid = vlan_tci_to_vid(vlan_tci);
>          const struct vlan_splinter *vsp;
>
> -        realdev_ofp_port = odp_port_to_ofp_port(ofproto,
> realdev_odp_port);
>          HMAP_FOR_EACH_WITH_HASH (vsp, realdev_vid_node,
>                                   hash_realdev_vid(realdev_ofp_port, vid),
>                                   &ofproto->realdev_vid_map) {
>              if (vsp->realdev_ofp_port == realdev_ofp_port
>                  && vsp->vid == vid) {
> -                return ofp_port_to_odp_port(ofproto,
> vsp->vlandev_ofp_port);
> +                return vsp->vlandev_ofp_port;
>              }
>          }
>      }
> -    return realdev_odp_port;
> +    return realdev_ofp_port;
>  }
>
>  static struct vlan_splinter *
> --
> 1.7.2.5
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20130605/88b874e3/attachment-0003.html>


More information about the dev mailing list