From: Phil Sutter <phil@nwl.cc>
To: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH 2/3] ebtables: Simplify ebt_add_{match,watcher}
Date: Tue, 5 Nov 2024 21:35:42 +0100 [thread overview]
Message-ID: <20241105203543.10545-2-phil@nwl.cc> (raw)
In-Reply-To: <20241105203543.10545-1-phil@nwl.cc>
Now that extension options are parsed after these functions return, no
modifications need to be carried over to the clone and undone in the
original.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
iptables/xtables-eb.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
index 06386cd90830c..86c33b4e7dcb6 100644
--- a/iptables/xtables-eb.c
+++ b/iptables/xtables-eb.c
@@ -371,23 +371,17 @@ struct xtables_match *ebt_add_match(struct xtables_match *m,
struct iptables_command_state *cs)
{
struct xtables_rule_match **rule_matches = &cs->matches;
- struct xtables_match *newm;
struct ebt_match *newnode, **matchp;
- struct xt_entry_match *m2;
+ struct xtables_match *newm;
newm = xtables_find_match(m->name, XTF_LOAD_MUST_SUCCEED, rule_matches);
if (newm == NULL)
xtables_error(OTHER_PROBLEM,
"Unable to add match %s", m->name);
- m2 = xtables_calloc(1, newm->m->u.match_size);
- memcpy(m2, newm->m, newm->m->u.match_size);
- memset(newm->m->data, 0, newm->size);
+ newm->m = xtables_calloc(1, m->m->u.match_size);
+ memcpy(newm->m, m->m, m->m->u.match_size);
xs_init_match(newm);
- newm->m = m2;
-
- newm->mflags = m->mflags;
- m->mflags = 0;
/* glue code for watchers */
newnode = xtables_calloc(1, sizeof(struct ebt_match));
@@ -409,17 +403,13 @@ struct xtables_target *ebt_add_watcher(struct xtables_target *watcher,
clone = xtables_malloc(sizeof(struct xtables_target));
memcpy(clone, watcher, sizeof(struct xtables_target));
- clone->udata = NULL;
- clone->tflags = watcher->tflags;
clone->next = clone;
+ clone->udata = NULL;
+ xs_init_target(clone);
clone->t = xtables_calloc(1, watcher->t->u.target_size);
memcpy(clone->t, watcher->t, watcher->t->u.target_size);
- memset(watcher->t->data, 0, watcher->size);
- xs_init_target(watcher);
- watcher->tflags = 0;
-
newnode = xtables_calloc(1, sizeof(struct ebt_match));
newnode->u.watcher = clone;
--
2.47.0
next prev parent reply other threads:[~2024-11-05 20:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-05 20:35 [iptables PATCH 1/3] ebtables: Clone extensions before modifying them Phil Sutter
2024-11-05 20:35 ` Phil Sutter [this message]
2024-11-05 20:35 ` [iptables PATCH 3/3] tests: shell: Test ebtables-restore deleting among matches Phil Sutter
2024-11-05 22:03 ` [iptables PATCH 1/3] ebtables: Clone extensions before modifying them Florian Westphal
2024-11-05 23:03 ` Phil Sutter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241105203543.10545-2-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox