summaryrefslogtreecommitdiffstats
path: root/libxtables
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@inai.de>2012-09-27 23:48:25 +0200
committerJan Engelhardt <jengelh@inai.de>2012-09-29 23:14:44 +0200
commitc436dad7cfdd80ca4a05ceed556c39babc266f55 (patch)
tree7b91b28f5ef3f735e18c08fbcf7beeb1eae5fe1f /libxtables
parent50f19190a60ff7d69e88406a71a2f27e09008566 (diff)
iptables: support for match aliases
This patch allows for match names listed on the command line to be rewritten to new names and revisions, like we did for targets before. Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Diffstat (limited to 'libxtables')
-rw-r--r--libxtables/xtables.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index a2b24c5a..82c3643b 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -848,6 +848,8 @@ void xtables_register_match(struct xtables_match *me)
exit(1);
}
+ if (me->real_name == NULL)
+ me->real_name = me->name;
if (me->x6_options != NULL)
xtables_option_metavalidate(me->name, me->x6_options);
if (me->extra_opts != NULL)
@@ -903,8 +905,10 @@ xtables_mt_prefer(bool a_alias, unsigned int a_rev, unsigned int a_fam,
static int xtables_match_prefer(const struct xtables_match *a,
const struct xtables_match *b)
{
- return xtables_mt_prefer(false, a->revision, a->family,
- false, b->revision, b->family);
+ return xtables_mt_prefer(a->name != a->real_name,
+ a->revision, a->family,
+ b->name != b->real_name,
+ b->revision, b->family);
}
static int xtables_target_prefer(const struct xtables_target *a,
@@ -938,11 +942,11 @@ static void xtables_fully_register_pending_match(struct xtables_match *me)
/* Now we have two (or more) options, check compatibility. */
if (compare > 0 &&
- compatible_match_revision(old->name, old->revision))
+ compatible_match_revision(old->real_name, old->revision))
return;
/* See if new match can be used. */
- if (!compatible_match_revision(me->name, me->revision))
+ if (!compatible_match_revision(me->real_name, me->revision))
return;
/* Delete old one. */