From: Ben Pfaff Date: Tue, 10 Mar 2009 17:13:27 +0000 (-0700) Subject: secchan: New function ofproto_flush_flows() to flush all flows. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b981b920dd6fa73acbde42e0a86330aa05753b2b;p=openvswitch secchan: New function ofproto_flush_flows() to flush all flows. --- 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 {