libxtables: define xtables_free_opts()
PATCH 1/1 libxtables: define xtables_free_opts()
A user of the structure xtables_globals. Next goal is to attack exit_error() so i can compile that basic program..
cheers,
jamal
commit 0d4663ae7dc54b5f4d28960dec4f7a1af4cd4d1a
Author: Jamal Hadi Salim <[email protected]> Date: Mon Feb 9 15:33:29 2009 -0500
Introduce xtables_free_opts() an xtables variant of free_opts() which uses xtables_globals already set by xtables_set_params(). The end goal is to have all internal references in xtables.c use xtables_free_opts() instead of depending on external defined free_opts()
include/xtables.h.in +1 -0
@@ -204,6 +204,7 @@ extern void *xtables_malloc(size_t); extern int xtables_insmod(const char *, const char *, bool); extern int xtables_load_ko(const char *, bool); int xtables_set_params(struct xtables_globals *xtp); +void xtables_free_opts(int reset_offset, struct option *original_opts); extern struct xtables_match *xtables_find_match(const char *name, enum xtables_tryload, struct xtables_rule_match **match);
xtables.c +11 -0
@@ -68,6 +68,17 @@ int xtables_set_params(struct xtables_globals *xtp)return 0 ; } +void xtables_free_opts (int reset_offset,struct option *original_opts) +{ +if (xt_params->opts != original_opts) { +if (original_opts) +free (xt_params->opts); + xt_params->opts = original_opts; +if (reset_offset) + xt_params->option_offset =0 ; + } +} +/** * xtables_afinfo - protocol family dependent information * @kmod: kernel module basename (e.g. "ip_tables")
Quoted 2 lines · jamal
A user of the structure
xtables_globals. Next goal is to attackexit_error()so i can compile that basic program..
Also applied, thanks.
Quoted 9 lines · jamal
A user of the structure
xtables_globals. Next goal is to attackexit_error()so i can compile that basic program..cheers,
jamalxtables.c +1
-0+void xtables_free_opts (int reset_offset,struct option *original_opts)
xtables.c int xtables_set_params(struct xtables_globals *xtp) · line 81
Quoted 10 lines
xtables.c +10
-0+{ +if (xt_params->opts != original_opts) { +if (original_opts) +free (xt_params->opts); + xt_params->opts = original_opts; +if (reset_offset) + xt_params->option_offset =0 ; + } +} +
While this may have been just moved from iptables.c or so (where? I do not see any deletions or conversions of code that is supposed to make use of xtables_free_opts!) this function needs some comments to explain just why it is supposed to be doing this.
Quoted 12 lines · Jan Engelhardt
Quoted 9 lines · jamal
xtables.c +9
-0+void xtables_free_opts (int reset_offset,struct option *original_opts) +{ +if (xt_params->opts != original_opts) { +if (original_opts) +free (xt_params->opts); + xt_params->opts = original_opts; +if (reset_offset) + xt_params->option_offset =0 ; + }
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+} +While this may have been just moved from
iptables.cor so (where? I do not see any deletions or conversions of code that is supposed to make use ofxtables_free_opts!) this function needs some comments to explain just why it is supposed to be doing this.
I use it in a version of tc/m_xt.c i am working on but hadnt made the changes to iptables and friends at this point. I do that in later patches and did change it back to the original version in the "merge_options" patch; so in the new version it looks like regular free_opts(). So now it looks like:
-----
void xtables_free_opts(int reset_offset)
{
if (xt_params->opts != xt_params->orig_opts) {
free(xt_params->opts);
xt_params->opts = xt_params->orig_opts;
if (reset_offset)
xt_params->option_offset = 0;
}
}-------------
cheers,
jamal