netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Leblond <eric@inl.fr>
To: netfilter-devel@vger.kernel.org
Cc: Eric Leblond <eric@inl.fr>
Subject: [PATCH 5/6] filter_MARK: code factorization.
Date: Wed, 22 Sep 2010 02:47:21 +0200	[thread overview]
Message-ID: <1285116442-32490-6-git-send-email-eric@inl.fr> (raw)
In-Reply-To: <1285116442-32490-1-git-send-email-eric@inl.fr>

This patch brings a light factorization in the decision making
process.

Signed-off-by: Eric Leblond <eric@inl.fr>
---
 filter/ulogd_filter_MARK.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/filter/ulogd_filter_MARK.c b/filter/ulogd_filter_MARK.c
index 1a7c2fd..85c146c 100644
--- a/filter/ulogd_filter_MARK.c
+++ b/filter/ulogd_filter_MARK.c
@@ -71,20 +71,18 @@ static struct ulogd_key mark_inp[] = {
 static int interp_mark(struct ulogd_pluginstance *pi)
 {
 	struct ulogd_key *inp = pi->input.keys;
-	if (pp_is_valid(inp, KEY_CT_MARK)) {
-		if ((ikey_get_u32(&inp[KEY_CT_MARK]) &
-			pi->config_kset->ces[MARK_MASK].u.value) !=
+	int index = 0;
+	if (pp_is_valid(inp, KEY_CT_MARK))
+		index = KEY_CT_MARK;
+	else if (pp_is_valid(inp, KEY_OOB_MARK))
+		index = KEY_OOB_MARK;
+	else
+		return ULOGD_IRET_OK;
+	if ((ikey_get_u32(&inp[index]) &
+				pi->config_kset->ces[MARK_MASK].u.value) !=
 			(u_int32_t) pi->config_kset->ces[MARK_MARK].u.value
-		   ) {
-			return ULOGD_IRET_STOP;
-		}
-	} else if (pp_is_valid(inp, KEY_OOB_MARK)) {
-		if ((ikey_get_u32(&inp[KEY_OOB_MARK]) &
-			pi->config_kset->ces[MARK_MASK].u.value) !=
-			(u_int32_t) pi->config_kset->ces[MARK_MARK].u.value
-		   ) {
-			return ULOGD_IRET_STOP;
-		}
+	   ) {
+		return ULOGD_IRET_STOP;
 	}
 	return ULOGD_IRET_OK;	
 }
-- 
1.6.1


  parent reply	other threads:[~2010-09-22  1:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22  0:47 [ULOGD PATCH 0/6] misc improvements and code cleaning Eric Leblond
2010-09-22  0:47 ` [PATCH 1/6] build: nfct and nflog can be disabled via configure option Eric Leblond
2010-09-30  9:58   ` Pablo Neira Ayuso
2010-09-22  0:47 ` [PATCH 2/6] ulogd.conf: Comment library dependant plugins Eric Leblond
2010-09-30  9:51   ` Pablo Neira Ayuso
2010-09-30 21:23     ` Eric Leblond
2010-09-22  0:47 ` [PATCH 3/6] build: add debug configure flag Eric Leblond
2010-09-30  9:50   ` Pablo Neira Ayuso
2010-09-30 21:22     ` Eric Leblond
2010-10-01 22:22       ` Jan Engelhardt
2010-10-03 10:15         ` Pablo Neira Ayuso
2010-09-22  0:47 ` [PATCH 4/6] ulogd.conf: add a complex but useful stack example Eric Leblond
2010-09-22  0:47 ` Eric Leblond [this message]
2010-09-22  0:47 ` [PATCH 6/6] ulogd: use snprintf instead of sprintf in printpkt Eric Leblond
2010-09-30  9:48   ` Pablo Neira Ayuso

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=1285116442-32490-6-git-send-email-eric@inl.fr \
    --to=eric@inl.fr \
    --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;
as well as URLs for NNTP newsgroup(s).