diff mbox

[ovs-dev,2/3] ovn-northd: Avoid redundant lookup of logical router port peer.

Message ID 1468944433-3515-3-git-send-email-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff July 19, 2016, 4:07 p.m. UTC
An ovn_port keeps track of its peer in its 'peer' member, but the code
updated by this commit instead did a redundant lookup of the peer.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 ovn/northd/ovn-northd.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Gurucharan Shetty July 22, 2016, 2:18 p.m. UTC | #1
On 19 July 2016 at 09:07, Ben Pfaff <blp@ovn.org> wrote:

> An ovn_port keeps track of its peer in its 'peer' member, but the code
> updated by this commit instead did a redundant lookup of the peer.
>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
>
Acked-by: Gurucharan Shetty <guru@ovn.org>


> ---
>  ovn/northd/ovn-northd.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
> index 9047635..8418f53 100644
> --- a/ovn/northd/ovn-northd.c
> +++ b/ovn/northd/ovn-northd.c
> @@ -2618,21 +2618,16 @@ build_lrouter_flows(struct hmap *datapaths, struct
> hmap *ports,
>               *
>               * The packet is still in peer's logical pipeline. So the
> match
>               * should be on peer's outport. */
> -            if (op->nbr->peer) {
> -                struct ovn_port *peer = ovn_port_find(ports,
> op->nbr->peer);
> -                if (!peer) {
> -                    continue;
> -                }
> -
> +            if (op->peer && op->peer->nbr) {
>                  ds_clear(&match);
>                  ds_put_format(&match, "outport == %s && reg0 == ",
> -                              peer->json_key);
> +                              op->peer->json_key);
>                  op_put_networks(&match, op, false);
>
>                  ds_clear(&actions);
>                  ds_put_format(&actions, "eth.dst = %s; next;",
>                                op->lrp_networks.ea_s);
> -                ovn_lflow_add(lflows, peer->od, S_ROUTER_IN_ARP_RESOLVE,
> +                ovn_lflow_add(lflows, op->peer->od,
> S_ROUTER_IN_ARP_RESOLVE,
>                                100, ds_cstr(&match), ds_cstr(&actions));
>              }
>          } else if (op->od->n_router_ports && strcmp(op->nbs->type,
> "router")) {
> --
> 2.1.3
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
Ben Pfaff July 22, 2016, 6:16 p.m. UTC | #2
On Fri, Jul 22, 2016 at 07:18:04AM -0700, Guru Shetty wrote:
> On 19 July 2016 at 09:07, Ben Pfaff <blp@ovn.org> wrote:
> 
> > An ovn_port keeps track of its peer in its 'peer' member, but the code
> > updated by this commit instead did a redundant lookup of the peer.
> >
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> >
> Acked-by: Gurucharan Shetty <guru@ovn.org>

Thanks for the reviews.  I applied these to master.
diff mbox

Patch

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 9047635..8418f53 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -2618,21 +2618,16 @@  build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
              *
              * The packet is still in peer's logical pipeline. So the match
              * should be on peer's outport. */
-            if (op->nbr->peer) {
-                struct ovn_port *peer = ovn_port_find(ports, op->nbr->peer);
-                if (!peer) {
-                    continue;
-                }
-
+            if (op->peer && op->peer->nbr) {
                 ds_clear(&match);
                 ds_put_format(&match, "outport == %s && reg0 == ",
-                              peer->json_key);
+                              op->peer->json_key);
                 op_put_networks(&match, op, false);
 
                 ds_clear(&actions);
                 ds_put_format(&actions, "eth.dst = %s; next;",
                               op->lrp_networks.ea_s);
-                ovn_lflow_add(lflows, peer->od, S_ROUTER_IN_ARP_RESOLVE,
+                ovn_lflow_add(lflows, op->peer->od, S_ROUTER_IN_ARP_RESOLVE,
                               100, ds_cstr(&match), ds_cstr(&actions));
             }
         } else if (op->od->n_router_ports && strcmp(op->nbs->type, "router")) {