From 3301e79cd308291f1bea4a9855d12192c1f55a50 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 29 Apr 2009 15:42:59 -0700 Subject: [PATCH] secchan: Optimize no-change case in modify_flow(). --- secchan/ofproto.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/secchan/ofproto.c b/secchan/ofproto.c index 5b7e169f..8b194986 100644 --- a/secchan/ofproto.c +++ b/secchan/ofproto.c @@ -2497,9 +2497,16 @@ modify_flow(struct ofproto *p, const struct ofp_flow_mod *ofm, if (command == OFPFC_DELETE) { rule_remove(p, rule); } else { + size_t actions_len = n_actions * sizeof *rule->actions; + + if (n_actions == rule->n_actions + && !memcmp(ofm->actions, rule->actions, actions_len)) + { + return 0; + } + free(rule->actions); - rule->actions = xmemdup(ofm->actions, - n_actions * sizeof *rule->actions); + rule->actions = xmemdup(ofm->actions, actions_len); rule->n_actions = n_actions; if (rule->cr.wc.wildcards) { -- 2.30.2