- hmapx_swap(&srcs, &mirror->srcs);
- hmapx_destroy(&srcs);
-
- hmapx_swap(&dsts, &mirror->dsts);
- hmapx_destroy(&dsts);
-
- free(mirror->vlans);
- mirror->vlans = vlan_bitmap_clone(s->src_vlans);
-
- mirror->out = out;
- mirror->out_vlan = out_vlan;
-
- /* Update bundles. */
- mirror_bit = MIRROR_MASK_C(1) << mirror->idx;
- HMAP_FOR_EACH (bundle, hmap_node, &mirror->ofproto->bundles) {
- if (hmapx_contains(&mirror->srcs, bundle)) {
- bundle->src_mirrors |= mirror_bit;
- } else {
- bundle->src_mirrors &= ~mirror_bit;
- }
-
- if (hmapx_contains(&mirror->dsts, bundle)) {
- bundle->dst_mirrors |= mirror_bit;
- } else {
- bundle->dst_mirrors &= ~mirror_bit;
- }
-
- if (mirror->out == bundle) {
- bundle->mirror_out |= mirror_bit;
- } else {
- bundle->mirror_out &= ~mirror_bit;
- }
- }
-
- ofproto->backer->need_revalidate = REV_RECONFIGURE;
- ofproto->has_mirrors = true;
- mac_learning_flush(ofproto->ml,
- &ofproto->backer->revalidate_set);
- mirror_update_dups(ofproto);
-
- return 0;
-}
-
-static void
-mirror_destroy(struct ofmirror *mirror)
-{
- struct ofproto_dpif *ofproto;
- mirror_mask_t mirror_bit;
- struct ofbundle *bundle;
- int i;
-
- if (!mirror) {
- return;
- }
-
- ofproto = mirror->ofproto;
- ofproto->backer->need_revalidate = REV_RECONFIGURE;
- mac_learning_flush(ofproto->ml, &ofproto->backer->revalidate_set);
-
- mirror_bit = MIRROR_MASK_C(1) << mirror->idx;
- HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
- bundle->src_mirrors &= ~mirror_bit;
- bundle->dst_mirrors &= ~mirror_bit;
- bundle->mirror_out &= ~mirror_bit;
- }
-
- hmapx_destroy(&mirror->srcs);
- hmapx_destroy(&mirror->dsts);
- free(mirror->vlans);
-
- ofproto->mirrors[mirror->idx] = NULL;
- free(mirror->name);
- free(mirror);
-
- mirror_update_dups(ofproto);
-
- ofproto->has_mirrors = false;
- for (i = 0; i < MAX_MIRRORS; i++) {
- if (ofproto->mirrors[i]) {
- ofproto->has_mirrors = true;
- break;
- }
- }
+ error = mirror_set(ofproto->mbridge, aux, s->name, srcs, s->n_srcs, dsts,
+ s->n_dsts, s->src_vlans,
+ bundle_lookup(ofproto, s->out_bundle), s->out_vlan);
+ free(srcs);
+ free(dsts);
+ return error;