From: Ben Pfaff Date: Wed, 29 Apr 2009 22:43:24 +0000 (-0700) Subject: secchan: Factor common code into new function rule_update_actions(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8482b928318d7054bbd2c28a71dd2daf35a0817;p=openvswitch secchan: Factor common code into new function rule_update_actions(). rule_update() was only called in two places, and each time it was done in the same way, so factor this out into a single new function rule_update_actions(). --- diff --git a/secchan/ofproto.c b/secchan/ofproto.c index 8b194986..12b7bc12 100644 --- a/secchan/ofproto.c +++ b/secchan/ofproto.c @@ -1492,17 +1492,20 @@ rule_install(struct ofproto *p, struct rule *rule, } static void -rule_update(struct ofproto *p, struct rule *rule) +rule_update_actions(struct ofproto *ofproto, struct rule *rule) { + bool actions_changed = rule_make_actions(ofproto, rule, NULL); if (rule->may_install) { if (rule->installed) { - dpif_flow_set_actions(&p->dpif, &rule->cr.flow, - rule->odp_actions, rule->n_odp_actions); + if (actions_changed) { + dpif_flow_set_actions(&ofproto->dpif, &rule->cr.flow, + rule->odp_actions, rule->n_odp_actions); + } } else { - rule_install(p, rule, NULL); + rule_install(ofproto, rule, NULL); } } else { - rule_uninstall(p, rule); + rule_uninstall(ofproto, rule); } } @@ -2512,11 +2515,7 @@ modify_flow(struct ofproto *p, const struct ofp_flow_mod *ofm, if (rule->cr.wc.wildcards) { p->need_revalidate = true; } else { - if (rule_make_actions(p, rule, NULL)) { - rule_update(p, rule); - } else if (rule->installed && !rule->may_install) { - rule_uninstall(p, rule); - } + rule_update_actions(p, rule); } } @@ -2921,11 +2920,7 @@ revalidate_rule(struct ofproto *p, struct rule *rule) } } - if (rule_make_actions(p, rule, NULL)) { - rule_update(p, rule); - } else if (rule->installed && !rule->may_install) { - rule_uninstall(p, rule); - } + rule_update_actions(p, rule); return true; }