All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxtables: define xtables_free_opts()
@ 2009-02-09 21:01 jamal
  2009-02-11 12:00 ` Patrick McHardy
  2009-02-11 15:17 ` Jan Engelhardt
  0 siblings, 2 replies; 4+ messages in thread
From: jamal @ 2009-02-09 21:01 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Jan Engelhardt, Pablo Neira Ayuso, netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 131 bytes --]


A user of the structure xtables_globals. Next goal is to attack
exit_error() so i can compile that basic program..

cheers,
jamal

[-- Attachment #2: iptv2-1 --]
[-- Type: text/plain, Size: 1611 bytes --]

commit 0d4663ae7dc54b5f4d28960dec4f7a1af4cd4d1a
Author: Jamal Hadi Salim <hadi@cyberus.ca>
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()
    
    Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>

diff --git a/include/xtables.h.in b/include/xtables.h.in
index 61dbc76..1d33394 100644
--- a/include/xtables.h.in
+++ b/include/xtables.h.in
@@ -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);
diff --git a/xtables.c b/xtables.c
index aad5e53..95be5f8 100644
--- a/xtables.c
+++ b/xtables.c
@@ -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")

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libxtables: define xtables_free_opts()
  2009-02-09 21:01 [PATCH] libxtables: define xtables_free_opts() jamal
@ 2009-02-11 12:00 ` Patrick McHardy
  2009-02-11 15:17 ` Jan Engelhardt
  1 sibling, 0 replies; 4+ messages in thread
From: Patrick McHardy @ 2009-02-11 12:00 UTC (permalink / raw)
  To: hadi; +Cc: Jan Engelhardt, Pablo Neira Ayuso, netfilter-devel

jamal wrote:
> A user of the structure xtables_globals. Next goal is to attack
> exit_error() so i can compile that basic program..

Also applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libxtables: define xtables_free_opts()
  2009-02-09 21:01 [PATCH] libxtables: define xtables_free_opts() jamal
  2009-02-11 12:00 ` Patrick McHardy
@ 2009-02-11 15:17 ` Jan Engelhardt
  2009-02-11 17:08   ` jamal
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Engelhardt @ 2009-02-11 15:17 UTC (permalink / raw)
  To: jamal; +Cc: Patrick McHardy, Pablo Neira Ayuso, netfilter-devel

On Monday 2009-02-09 22:01, jamal wrote:

>
>A user of the structure xtables_globals. Next goal is to attack
>exit_error() so i can compile that basic program..
>
>cheers,
>jamal
>

>+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;
>+	}
>+}
>+

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libxtables: define xtables_free_opts()
  2009-02-11 15:17 ` Jan Engelhardt
@ 2009-02-11 17:08   ` jamal
  0 siblings, 0 replies; 4+ messages in thread
From: jamal @ 2009-02-11 17:08 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Patrick McHardy, Pablo Neira Ayuso, netfilter-devel

On Wed, 2009-02-11 at 16:17 +0100, Jan Engelhardt wrote:
> On Monday 2009-02-09 22:01, jamal wrote:

> 
> >+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;
> >+	}
> >+}
> >+
> 
> 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.

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-11 17:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-09 21:01 [PATCH] libxtables: define xtables_free_opts() jamal
2009-02-11 12:00 ` Patrick McHardy
2009-02-11 15:17 ` Jan Engelhardt
2009-02-11 17:08   ` jamal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.