From: Jan Engelhardt <jengelh@medozas.de>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 3/6] netfilter: get rid of the grossness in netfilter.h
Date: Wed, 10 Feb 2010 18:39:03 +0100 [thread overview]
Message-ID: <1265823547-10358-4-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1265823547-10358-1-git-send-email-jengelh@medozas.de>
GCC is now smart enough to follow the inline trail correctly.
vmlinux size remain the same.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
include/linux/netfilter.h | 45 ++++++++++++++++++++++++++++-----------------
1 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 2f22816..7007945 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -196,25 +196,36 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
coders :)
*/
-/* This is gross, but inline doesn't cut it for avoiding the function
- call in fast path: gcc doesn't inline (needs value tracking?). --RR */
-
-/* HX: It's slightly less gross now. */
-
-#define NF_HOOK_THRESH(pf, hook, skb, indev, outdev, okfn, thresh) \
-({int __ret; \
-if ((__ret=nf_hook_thresh(pf, hook, (skb), indev, outdev, okfn, thresh)) == 1)\
- __ret = (okfn)(skb); \
-__ret;})
+static inline int
+NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sk_buff *skb,
+ struct net_device *in, struct net_device *out,
+ int (*okfn)(struct sk_buff *), int thresh)
+{
+ int ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, thresh);
+ if (ret == 1)
+ ret = okfn(skb);
+ return ret;
+}
-#define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) \
-({int __ret; \
-if ((cond) || (__ret = nf_hook_thresh(pf, hook, (skb), indev, outdev, okfn, INT_MIN)) == 1)\
- __ret = (okfn)(skb); \
-__ret;})
+static inline int
+NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sk_buff *skb,
+ struct net_device *in, struct net_device *out,
+ int (*okfn)(struct sk_buff *), bool cond)
+{
+ int ret = 1;
+ if (cond ||
+ (ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, INT_MIN) == 1))
+ ret = okfn(skb);
+ return ret;
+}
-#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) \
- NF_HOOK_THRESH(pf, hook, skb, indev, outdev, okfn, INT_MIN)
+static inline int
+NF_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,
+ struct net_device *in, struct net_device *out,
+ int (*okfn)(struct sk_buff *))
+{
+ return NF_HOOK_THRESH(pf, hook, skb, in, out, okfn, INT_MIN);
+}
/* Call setsockopt() */
int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
--
1.6.6.1
next prev parent reply other threads:[~2010-02-10 17:39 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-10 17:39 Code cleanups Jan Engelhardt
2010-02-10 17:39 ` [PATCH 1/6] netfilter: iptables: remove unused function arguments Jan Engelhardt
2010-02-10 17:39 ` [PATCH 2/6] netfilter: reduce NF_HOOK by one argument Jan Engelhardt
2010-02-10 17:39 ` Jan Engelhardt [this message]
2010-02-10 17:44 ` [PATCH 3/6] netfilter: get rid of the grossness in netfilter.h Patrick McHardy
2010-02-10 21:07 ` Jan Engelhardt
2010-02-11 9:02 ` Patrick McHardy
2010-02-10 17:39 ` [PATCH 4/6] netfilter: xtables: print details on size mismatch Jan Engelhardt
2010-02-10 17:39 ` [PATCH 5/6] netfilter: xtables: constify args in compat copying functions Jan Engelhardt
2010-02-10 17:39 ` [PATCH 6/6] netfilter: xtables: add const qualifiers Jan Engelhardt
2010-02-11 9:00 ` Patrick McHardy
2010-02-11 13:27 ` Jan Engelhardt
2010-02-11 16:06 ` Patrick McHardy
2010-02-11 16:22 ` Jan Engelhardt
2010-02-11 16:27 ` Patrick McHardy
2010-02-11 17:04 ` Jan Engelhardt
2010-02-10 21:10 ` Code cleanups Jan Engelhardt
2010-02-15 15:34 ` Patrick McHardy
2010-02-15 16:07 ` Jan Engelhardt
2010-02-15 16:23 ` Patrick McHardy
-- strict thread matches above, loose matches on Subject: below --
2009-11-03 18:04 Xtables cleanup patches Jan Engelhardt
2009-11-03 18:04 ` [PATCH 3/6] netfilter: get rid of the grossness in netfilter.h Jan Engelhardt
2009-11-04 7:59 ` Changli Gao
2009-11-04 12:28 ` Jan Engelhardt
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=1265823547-10358-4-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--cc=kaber@trash.net \
--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).