Both existing callers calculated 'may_learn' as 'stats->n_packets > 0', so it was redundant. Because xlate_push_stats() is now entirely a no-op if 'stats->n_packets' is 0, we can now delete the tests entirely from the cases that previously only ran if 'may_learn'.
Signed-off-by: Ben Pfaff <b...@nicira.com> --- ofproto/ofproto-dpif-upcall.c | 17 ++++++++--------- ofproto/ofproto-dpif-xlate.c | 13 ++++--------- ofproto/ofproto-dpif-xlate.h | 5 ++--- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 5f1d6d5..b5e1253 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1283,7 +1283,7 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey, long long int last_used; int error; size_t i; - bool may_learn, ok; + bool ok; ok = false; xoutp = NULL; @@ -1312,9 +1312,8 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey, goto exit; } - may_learn = push.n_packets > 0; if (ukey->xcache && !udpif->need_revalidate) { - xlate_push_stats(ukey->xcache, may_learn, &push); + xlate_push_stats(ukey->xcache, &push); ok = true; goto exit; } @@ -1339,9 +1338,11 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey, xlate_in_init(&xin, ofproto, &flow, ofp_in_port, NULL, push.tcp_flags, NULL); - xin.resubmit_stats = push.n_packets ? &push : NULL; + if (push.n_packets) { + xin.resubmit_stats = &push; + xin.may_learn = true; + } xin.xcache = ukey->xcache; - xin.may_learn = may_learn; xin.skip_wildcards = !udpif->need_revalidate; xlate_actions(&xin, &xout); xoutp = &xout; @@ -1443,13 +1444,11 @@ push_dump_ops__(struct udpif *udpif, struct dump_op *ops, size_t n_ops) struct netflow *netflow; ofp_port_t ofp_in_port; struct flow flow; - bool may_learn; int error; - may_learn = push->n_packets > 0; ovs_mutex_lock(&op->ukey->mutex); if (op->ukey->xcache) { - xlate_push_stats(op->ukey->xcache, may_learn, push); + xlate_push_stats(op->ukey->xcache, push); ovs_mutex_unlock(&op->ukey->mutex); continue; } @@ -1469,7 +1468,7 @@ push_dump_ops__(struct udpif *udpif, struct dump_op *ops, size_t n_ops) xlate_in_init(&xin, ofproto, &flow, ofp_in_port, NULL, push->tcp_flags, NULL); xin.resubmit_stats = push->n_packets ? push : NULL; - xin.may_learn = may_learn; + xin.may_learn = push->n_packets > 0; xin.skip_wildcards = true; xlate_actions_for_side_effects(&xin); diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index ccf0991..4ad74e3 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4285,7 +4285,7 @@ xlate_cache_normal(struct ofproto_dpif *ofproto, struct flow *flow, int vlan) /* Push stats and perform side effects of flow translation. */ void -xlate_push_stats(struct xlate_cache *xcache, bool may_learn, +xlate_push_stats(struct xlate_cache *xcache, const struct dpif_flow_stats *stats) { struct xc_entry *entry; @@ -4317,16 +4317,11 @@ xlate_push_stats(struct xlate_cache *xcache, bool may_learn, stats->n_packets, stats->n_bytes); break; case XC_LEARN: - if (may_learn) { - ofproto_dpif_flow_mod(entry->u.learn.ofproto, - entry->u.learn.fm); - } + ofproto_dpif_flow_mod(entry->u.learn.ofproto, entry->u.learn.fm); break; case XC_NORMAL: - if (may_learn) { - xlate_cache_normal(entry->u.normal.ofproto, - entry->u.normal.flow, entry->u.normal.vlan); - } + xlate_cache_normal(entry->u.normal.ofproto, entry->u.normal.flow, + entry->u.normal.vlan); break; case XC_FIN_TIMEOUT: xlate_fin_timeout__(entry->u.fin.rule, stats->tcp_flags, diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h index 7394249..834c22b 100644 --- a/ofproto/ofproto-dpif-xlate.h +++ b/ofproto/ofproto-dpif-xlate.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc. +/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -189,8 +189,7 @@ void xlate_out_copy(struct xlate_out *dst, const struct xlate_out *src); int xlate_send_packet(const struct ofport_dpif *, struct ofpbuf *); struct xlate_cache *xlate_cache_new(void); -void xlate_push_stats(struct xlate_cache *, bool may_learn, - const struct dpif_flow_stats *); +void xlate_push_stats(struct xlate_cache *, const struct dpif_flow_stats *); void xlate_cache_clear(struct xlate_cache *); void xlate_cache_delete(struct xlate_cache *); -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev