From b981b920dd6fa73acbde42e0a86330aa05753b2b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 10 Mar 2009 10:13:27 -0700 Subject: [PATCH] secchan: New function ofproto_flush_flows() to flush all flows. --- secchan/ofproto.c | 28 ++++++++++++++++++++++++++-- secchan/ofproto.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/secchan/ofproto.c b/secchan/ofproto.c index 0ee8346e..0d7b9756 100644 --- a/secchan/ofproto.c +++ b/secchan/ofproto.c @@ -113,6 +113,7 @@ struct rule { union ofp_action *actions; }; +static void rule_free(struct rule *); static void rule_destroy(struct rule *); static struct rule *rule_from_cls_rule(const struct cls_rule *); static void rule_make_actions(struct ofproto *, @@ -856,6 +857,23 @@ ofproto_delete_flow(struct ofproto *ofproto, const flow_t *flow, * out a netflow message? */ } } + +static void +destroy_rule(struct cls_rule *rule_, void *ofproto_) +{ + struct rule *rule = rule_from_cls_rule(rule_); + struct ofproto *ofproto = ofproto_; + + classifier_remove(&ofproto->cls, &rule->cr); + rule_free(rule); +} + +void +ofproto_flush_flows(struct ofproto *ofproto) +{ + classifier_for_each(&ofproto->cls, CLS_INC_ALL, destroy_rule, ofproto); + dpif_flow_flush(&ofproto->dpif); +} static void reinit_ports(struct ofproto *p) @@ -1166,6 +1184,13 @@ rule_from_cls_rule(const struct cls_rule *cls_rule) return cls_rule ? CONTAINER_OF(cls_rule, struct rule, cr) : NULL; } +static void +rule_free(struct rule *rule) +{ + free(rule->actions); + free(rule); +} + static void rule_destroy(struct rule *rule) { @@ -1177,8 +1202,7 @@ rule_destroy(struct rule *rule) } else if (rule->super != UNKNOWN_SUPER) { list_remove(&rule->list); } - free(rule->actions); - free(rule); + rule_free(rule); } static bool diff --git a/secchan/ofproto.h b/secchan/ofproto.h index 50245a99..8f977a7a 100644 --- a/secchan/ofproto.h +++ b/secchan/ofproto.h @@ -102,6 +102,7 @@ void ofproto_set_actions(struct ofproto *, const flow_t *, const union ofp_action *, size_t n_actions); void ofproto_delete_flow(struct ofproto *, const flow_t *, uint32_t wildcards, uint16_t priority); +void ofproto_flush_flows(struct ofproto *); /* Hooks for vswitchd. */ struct ofhooks { -- 2.30.2