From d794a110478866311416bf73e2a5239253aead40 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Wed, 22 Dec 2010 10:43:05 +0100 Subject: Restore mode did not work for IPv6 (reported by Elie Rosenblum) The set cache stored the default family (INET) instead of the set family, therefore restore mode for IPv6 did not work. The set cache fixed and message aggregation reworked. --- lib/types.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib/types.c') diff --git a/lib/types.c b/lib/types.c index 1bd4274..69dac6a 100644 --- a/lib/types.c +++ b/lib/types.c @@ -276,10 +276,9 @@ found: } #define set_family_and_type(data, match, family) do { \ - if (family == AF_UNSPEC && match->family != AF_UNSPEC) { \ + if (family == AF_UNSPEC && match->family != AF_UNSPEC) \ family = match->family == AF_INET46 ? AF_INET : match->family;\ - ipset_data_set(data, IPSET_OPT_FAMILY, &family);\ - } \ + ipset_data_set(data, IPSET_OPT_FAMILY, &family); \ ipset_data_set(data, IPSET_OPT_TYPE, match); \ } while (0) @@ -293,7 +292,7 @@ adt_type_get(struct ipset_session *session) const struct ipset_type *match; const char *setname, *typename; const uint8_t *revision; - uint8_t family; + uint8_t family = AF_UNSPEC; int ret; data = ipset_session_data(session); @@ -304,8 +303,9 @@ adt_type_get(struct ipset_session *session) /* Check existing sets in cache */ for (s = setlist; s != NULL; s = s->next) { if (STREQ(setname, s->name)) { - match = s->type; - goto found; + ipset_data_set(data, IPSET_OPT_FAMILY, &s->family); + ipset_data_set(data, IPSET_OPT_TYPE, s->type); + return s->type; } } @@ -342,7 +342,6 @@ adt_type_get(struct ipset_session *session) family == AF_INET6 ? "inet6" : "unspec", *revision); -found: set_family_and_type(data, match, family); return match; @@ -396,7 +395,7 @@ ipset_type_check(struct ipset_session *session) const struct ipset_type *t, *match = NULL; struct ipset_data *data; const char *typename; - uint8_t family, revision; + uint8_t family = AF_UNSPEC, revision; assert(session); data = ipset_session_data(session); -- cgit v1.2.3