child-sa: Sort traffic selectors after adding CHILD_SA policies
authorMartin Willi <martin@revosec.ch>
Thu, 19 Feb 2015 17:03:08 +0000 (18:03 +0100)
committerMartin Willi <martin@revosec.ch>
Fri, 20 Feb 2015 12:34:48 +0000 (13:34 +0100)
Having traffic selectors sorted properly makes comparing them much simpler.

src/libcharon/sa/child_sa.c

index 6f5e046..2028aba 100644 (file)
@@ -799,12 +799,15 @@ METHOD(child_sa_t, add_policies, status_t,
                array_insert(this->my_ts, ARRAY_TAIL, my_ts->clone(my_ts));
        }
        enumerator->destroy(enumerator);
+       array_sort(this->my_ts, (void*)traffic_selector_cmp, NULL);
+
        enumerator = other_ts_list->create_enumerator(other_ts_list);
        while (enumerator->enumerate(enumerator, &other_ts))
        {
                array_insert(this->other_ts, ARRAY_TAIL, other_ts->clone(other_ts));
        }
        enumerator->destroy(enumerator);
+       array_sort(this->other_ts, (void*)traffic_selector_cmp, NULL);
 
        if (this->config->install_policy(this->config))
        {