|
|
9a3fa7 |
From 861155bef2343e0259469dc8e4acde60e2c6fb91 Mon Sep 17 00:00:00 2001
|
|
|
9a3fa7 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
9a3fa7 |
Date: Wed, 3 Apr 2019 20:29:38 +0200
|
|
|
9a3fa7 |
Subject: [PATCH] extensions: Initialize linear mapping of symbols in _init()
|
|
|
9a3fa7 |
of extension
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1657075
|
|
|
9a3fa7 |
Upstream Status: iptables commit 56aadc01b258e
|
|
|
9a3fa7 |
Conflicts: Whitespace change due to missing commit f7c26137b0d57
|
|
|
9a3fa7 |
("extensions: libipt_realm: Add translation to nft").
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
commit 56aadc01b258ef7849463723ab5ddc4885db22f6
|
|
|
9a3fa7 |
Author: Serhey Popovych <serhe.popovych@gmail.com>
|
|
|
9a3fa7 |
Date: Thu Mar 1 13:03:10 2018 +0200
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
extensions: Initialize linear mapping of symbols in _init() of extension
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
libxt_devgroup and libipt_realm currently unable to display symbolic
|
|
|
9a3fa7 |
names in save/print commands because linear mapping is not initialized.
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
It looks bit confusing as linear mapping initialization is done in init()
|
|
|
9a3fa7 |
of extension, which is expected to be called before any other function of
|
|
|
9a3fa7 |
extension.
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
However init is called only when '-m' option specified on command line,
|
|
|
9a3fa7 |
that is true only for insert, append, replace and destroy iptables
|
|
|
9a3fa7 |
commands.
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
Move initialization to extension _init() function before calling
|
|
|
9a3fa7 |
any function in extension.
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
Before:
|
|
|
9a3fa7 |
-------
|
|
|
9a3fa7 |
... src-group 0x1 dst-group 0x2
|
|
|
9a3fa7 |
... src-group 0x2 dst-group 0x1
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
After:
|
|
|
9a3fa7 |
------
|
|
|
9a3fa7 |
... src-group grp1 dst-group grp2
|
|
|
9a3fa7 |
... src-group grp2 dst-group grp1
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
|
|
|
9a3fa7 |
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
9a3fa7 |
---
|
|
|
9a3fa7 |
extensions/libipt_realm.c | 17 +++++++----------
|
|
|
9a3fa7 |
extensions/libxt_devgroup.c | 17 +++++++----------
|
|
|
9a3fa7 |
2 files changed, 14 insertions(+), 20 deletions(-)
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
diff --git a/extensions/libipt_realm.c b/extensions/libipt_realm.c
|
|
|
9a3fa7 |
index a8d9dda0c00c0..fffb1218db7a6 100644
|
|
|
9a3fa7 |
--- a/extensions/libipt_realm.c
|
|
|
9a3fa7 |
+++ b/extensions/libipt_realm.c
|
|
|
9a3fa7 |
@@ -28,17 +28,10 @@ static const struct xt_option_entry realm_opts[] = {
|
|
|
9a3fa7 |
XTOPT_TABLEEND,
|
|
|
9a3fa7 |
};
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
-/* array of realms from /etc/iproute2/rt_realms */
|
|
|
9a3fa7 |
+static const char f_realms[] = "/etc/iproute2/rt_realms";
|
|
|
9a3fa7 |
+/* array of realms from f_realms[] */
|
|
|
9a3fa7 |
static struct xtables_lmap *realms;
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
-static void realm_init(struct xt_entry_match *m)
|
|
|
9a3fa7 |
-{
|
|
|
9a3fa7 |
- const char file[] = "/etc/iproute2/rt_realms";
|
|
|
9a3fa7 |
- realms = xtables_lmap_init(file);
|
|
|
9a3fa7 |
- if (realms == NULL && errno != ENOENT)
|
|
|
9a3fa7 |
- fprintf(stderr, "Warning: %s: %s\n", file, strerror(errno));
|
|
|
9a3fa7 |
-}
|
|
|
9a3fa7 |
-
|
|
|
9a3fa7 |
static void realm_parse(struct xt_option_call *cb)
|
|
|
9a3fa7 |
{
|
|
|
9a3fa7 |
struct xt_realm_info *realminfo = cb->data;
|
|
|
9a3fa7 |
@@ -114,7 +107,6 @@ static struct xtables_match realm_mt_reg = {
|
|
|
9a3fa7 |
.size = XT_ALIGN(sizeof(struct xt_realm_info)),
|
|
|
9a3fa7 |
.userspacesize = XT_ALIGN(sizeof(struct xt_realm_info)),
|
|
|
9a3fa7 |
.help = realm_help,
|
|
|
9a3fa7 |
- .init = realm_init,
|
|
|
9a3fa7 |
.print = realm_print,
|
|
|
9a3fa7 |
.save = realm_save,
|
|
|
9a3fa7 |
.x6_parse = realm_parse,
|
|
|
9a3fa7 |
@@ -123,5 +115,10 @@ static struct xtables_match realm_mt_reg = {
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
void _init(void)
|
|
|
9a3fa7 |
{
|
|
|
9a3fa7 |
+ realms = xtables_lmap_init(f_realms);
|
|
|
9a3fa7 |
+ if (realms == NULL && errno != ENOENT)
|
|
|
9a3fa7 |
+ fprintf(stderr, "Warning: %s: %s\n", f_realms,
|
|
|
9a3fa7 |
+ strerror(errno));
|
|
|
9a3fa7 |
+
|
|
|
9a3fa7 |
xtables_register_match(&realm_mt_reg);
|
|
|
9a3fa7 |
}
|
|
|
9a3fa7 |
diff --git a/extensions/libxt_devgroup.c b/extensions/libxt_devgroup.c
|
|
|
9a3fa7 |
index fb1fcb51c1bb2..ebfa2aee80cf2 100644
|
|
|
9a3fa7 |
--- a/extensions/libxt_devgroup.c
|
|
|
9a3fa7 |
+++ b/extensions/libxt_devgroup.c
|
|
|
9a3fa7 |
@@ -31,17 +31,10 @@ static const struct xt_option_entry devgroup_opts[] = {
|
|
|
9a3fa7 |
XTOPT_TABLEEND,
|
|
|
9a3fa7 |
};
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
-/* array of devgroups from /etc/iproute2/group */
|
|
|
9a3fa7 |
+static const char f_devgroups[] = "/etc/iproute2/group";
|
|
|
9a3fa7 |
+/* array of devgroups from f_devgroups[] */
|
|
|
9a3fa7 |
static struct xtables_lmap *devgroups;
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
-static void devgroup_init(struct xt_entry_match *match)
|
|
|
9a3fa7 |
-{
|
|
|
9a3fa7 |
- const char file[] = "/etc/iproute2/group";
|
|
|
9a3fa7 |
- devgroups = xtables_lmap_init(file);
|
|
|
9a3fa7 |
- if (devgroups == NULL && errno != ENOENT)
|
|
|
9a3fa7 |
- fprintf(stderr, "Warning: %s: %s\n", file, strerror(errno));
|
|
|
9a3fa7 |
-}
|
|
|
9a3fa7 |
-
|
|
|
9a3fa7 |
static void devgroup_parse_groupspec(const char *arg, unsigned int *group,
|
|
|
9a3fa7 |
unsigned int *mask)
|
|
|
9a3fa7 |
{
|
|
|
9a3fa7 |
@@ -157,7 +150,6 @@ static struct xtables_match devgroup_mt_reg = {
|
|
|
9a3fa7 |
.family = NFPROTO_UNSPEC,
|
|
|
9a3fa7 |
.size = XT_ALIGN(sizeof(struct xt_devgroup_info)),
|
|
|
9a3fa7 |
.userspacesize = XT_ALIGN(sizeof(struct xt_devgroup_info)),
|
|
|
9a3fa7 |
- .init = devgroup_init,
|
|
|
9a3fa7 |
.help = devgroup_help,
|
|
|
9a3fa7 |
.print = devgroup_print,
|
|
|
9a3fa7 |
.save = devgroup_save,
|
|
|
9a3fa7 |
@@ -168,5 +160,10 @@ static struct xtables_match devgroup_mt_reg = {
|
|
|
9a3fa7 |
|
|
|
9a3fa7 |
void _init(void)
|
|
|
9a3fa7 |
{
|
|
|
9a3fa7 |
+ devgroups = xtables_lmap_init(f_devgroups);
|
|
|
9a3fa7 |
+ if (devgroups == NULL && errno != ENOENT)
|
|
|
9a3fa7 |
+ fprintf(stderr, "Warning: %s: %s\n", f_devgroups,
|
|
|
9a3fa7 |
+ strerror(errno));
|
|
|
9a3fa7 |
+
|
|
|
9a3fa7 |
xtables_register_match(&devgroup_mt_reg);
|
|
|
9a3fa7 |
}
|
|
|
9a3fa7 |
--
|
|
|
9a3fa7 |
2.21.0
|
|
|
9a3fa7 |
|