From: Ben Pfaff Date: Tue, 17 Mar 2009 17:53:22 +0000 (-0700) Subject: secchan: Simplify code by making rule_uninstall() update stats. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7297a931ecfb3e02c7a262342781bbae02412067;p=openvswitch secchan: Simplify code by making rule_uninstall() update stats. All the callers wanted to update the stats of the rule being uninstalled, or at least didn't mind, so this makes the code easier to read and maintain. --- diff --git a/secchan/ofproto.c b/secchan/ofproto.c index f778c0e4..3846ffbf 100644 --- a/secchan/ofproto.c +++ b/secchan/ofproto.c @@ -148,8 +148,7 @@ static bool rule_make_actions(struct ofproto *, struct rule *, bool revalidating); static void rule_install(struct ofproto *, struct rule *, struct odp_flow_stats *); -static void rule_uninstall(struct ofproto *, struct rule *, - struct odp_flow_stats *); +static void rule_uninstall(struct ofproto *, struct rule *); struct ofconn { struct list node; @@ -219,6 +218,7 @@ static uint64_t pick_fallback_dpid(void); static void send_packet_in_miss(struct ofpbuf *, void *ofproto); static void send_packet_in_action(struct ofpbuf *, void *ofproto); static void update_used(struct ofproto *); +static void update_stats(struct rule *, const struct odp_flow_stats *); static void expire_rule(struct cls_rule *, void *ofproto); static bool revalidate_rule(struct ofproto *p, struct rule *rule); static void revalidate_cb(struct cls_rule *rule_, void *p_); @@ -1393,20 +1393,17 @@ rule_install(struct ofproto *p, struct rule *rule, } static void -rule_uninstall(struct ofproto *p, struct rule *rule, - struct odp_flow_stats *stats) +rule_uninstall(struct ofproto *p, struct rule *rule) { assert(!rule->cr.wc.wildcards); - if (stats) { - memset(stats, 0, sizeof *stats); - } if (rule->installed) { struct odp_flow odp_flow; odp_flow.key = rule->cr.flow; odp_flow.actions = NULL; odp_flow.n_actions = 0; - if (!dpif_flow_del(&p->dpif, &odp_flow) && stats) { - *stats = odp_flow.stats; + if (!dpif_flow_del(&p->dpif, &odp_flow)) { + update_stats(rule->super && rule->super != UNKNOWN_SUPER + ? rule->super : rule, &odp_flow.stats); } rule->installed = false; } @@ -2398,7 +2395,7 @@ modify_flow(struct ofproto *p, const struct ofp_flow_mod *ofm, } if (command == OFPFC_DELETE) { if (!rule->cr.wc.wildcards) { - rule_uninstall(p, rule, NULL); + rule_uninstall(p, rule); } classifier_remove(&p->cls, &rule->cr); rule_destroy(rule); @@ -2808,7 +2805,7 @@ revalidate_rule(struct ofproto *p, struct rule *rule) struct rule *super; super = rule_from_cls_rule(classifier_lookup_wild(&p->cls, flow)); if (!super) { - rule_uninstall(p, rule, NULL); + rule_uninstall(p, rule); classifier_remove(&p->cls, &rule->cr); rule_destroy(rule); return false; @@ -2921,14 +2918,12 @@ expire_rule(struct cls_rule *cls_rule, void *p_) struct rule *subrule, *next_subrule; LIST_FOR_EACH_SAFE (subrule, next_subrule, struct rule, list, &rule->list) { - struct odp_flow_stats stats; - rule_uninstall(p, subrule, &stats); - update_stats(rule, &stats); + rule_uninstall(p, subrule); classifier_remove(&p->cls, &subrule->cr); rule_destroy(subrule); } } else { - rule_uninstall(p, rule, NULL); + rule_uninstall(p, rule); } }