From: Jan Engelhardt <jengelh@medozas.de>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 2/4] netfilter: xtables: give xt_ecn its own name
Date: Thu, 9 Jun 2011 22:23:54 +0200 [thread overview]
Message-ID: <1307651037-20520-3-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1307651037-20520-1-git-send-email-jengelh@medozas.de>
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
include/linux/netfilter/xt_ecn.h | 12 +++++-----
include/linux/netfilter_ipv4/ipt_ecn.h | 11 +++++++++-
net/netfilter/xt_ecn.c | 34 ++++++++++++++++----------------
3 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/include/linux/netfilter/xt_ecn.h b/include/linux/netfilter/xt_ecn.h
index 065c1a5..7158fca 100644
--- a/include/linux/netfilter/xt_ecn.h
+++ b/include/linux/netfilter/xt_ecn.h
@@ -12,16 +12,16 @@
#include <linux/types.h>
#include <linux/netfilter/xt_dscp.h>
-#define IPT_ECN_IP_MASK (~XT_DSCP_MASK)
+#define XT_ECN_IP_MASK (~XT_DSCP_MASK)
-#define IPT_ECN_OP_MATCH_IP 0x01
-#define IPT_ECN_OP_MATCH_ECE 0x10
-#define IPT_ECN_OP_MATCH_CWR 0x20
+#define XT_ECN_OP_MATCH_IP 0x01
+#define XT_ECN_OP_MATCH_ECE 0x10
+#define XT_ECN_OP_MATCH_CWR 0x20
-#define IPT_ECN_OP_MATCH_MASK 0xce
+#define XT_ECN_OP_MATCH_MASK 0xce
/* match info */
-struct ipt_ecn_info {
+struct xt_ecn_info {
__u8 operation;
__u8 invert;
__u8 ip_ect;
diff --git a/include/linux/netfilter_ipv4/ipt_ecn.h b/include/linux/netfilter_ipv4/ipt_ecn.h
index b1124ec..0e0c063 100644
--- a/include/linux/netfilter_ipv4/ipt_ecn.h
+++ b/include/linux/netfilter_ipv4/ipt_ecn.h
@@ -2,5 +2,14 @@
#define _IPT_ECN_H
#include <linux/netfilter/xt_ecn.h>
+#define ipt_ecn_info xt_ecn_info
-#endif /* _IPT_ECN_H */
+enum {
+ IPT_ECN_IP_MASK = XT_ECN_IP_MASK,
+ IPT_ECN_OP_MATCH_IP = XT_ECN_OP_MATCH_IP,
+ IPT_ECN_OP_MATCH_ECE = XT_ECN_OP_MATCH_ECE,
+ IPT_ECN_OP_MATCH_CWR = XT_ECN_OP_MATCH_CWR,
+ IPT_ECN_OP_MATCH_MASK = XT_ECN_OP_MATCH_MASK,
+};
+
+#endif /* IPT_ECN_H */
diff --git a/net/netfilter/xt_ecn.c b/net/netfilter/xt_ecn.c
index 2c198f5..3ebb3dc 100644
--- a/net/netfilter/xt_ecn.c
+++ b/net/netfilter/xt_ecn.c
@@ -15,8 +15,8 @@
#include <linux/tcp.h>
#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_ecn.h>
#include <linux/netfilter_ipv4/ip_tables.h>
-#include <linux/netfilter_ipv4/ipt_ecn.h>
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
MODULE_DESCRIPTION("Xtables: Explicit Congestion Notification (ECN) flag match for IPv4");
@@ -24,14 +24,14 @@ MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_ecn");
static inline bool match_ip(const struct sk_buff *skb,
- const struct ipt_ecn_info *einfo)
+ const struct xt_ecn_info *einfo)
{
- return ((ip_hdr(skb)->tos & IPT_ECN_IP_MASK) == einfo->ip_ect) ^
- !!(einfo->invert & IPT_ECN_OP_MATCH_IP);
+ return ((ip_hdr(skb)->tos & XT_ECN_IP_MASK) == einfo->ip_ect) ^
+ !!(einfo->invert & XT_ECN_OP_MATCH_IP);
}
static inline bool match_tcp(const struct sk_buff *skb,
- const struct ipt_ecn_info *einfo,
+ const struct xt_ecn_info *einfo,
bool *hotdrop)
{
struct tcphdr _tcph;
@@ -46,8 +46,8 @@ static inline bool match_tcp(const struct sk_buff *skb,
return false;
}
- if (einfo->operation & IPT_ECN_OP_MATCH_ECE) {
- if (einfo->invert & IPT_ECN_OP_MATCH_ECE) {
+ if (einfo->operation & XT_ECN_OP_MATCH_ECE) {
+ if (einfo->invert & XT_ECN_OP_MATCH_ECE) {
if (th->ece == 1)
return false;
} else {
@@ -56,8 +56,8 @@ static inline bool match_tcp(const struct sk_buff *skb,
}
}
- if (einfo->operation & IPT_ECN_OP_MATCH_CWR) {
- if (einfo->invert & IPT_ECN_OP_MATCH_CWR) {
+ if (einfo->operation & XT_ECN_OP_MATCH_CWR) {
+ if (einfo->invert & XT_ECN_OP_MATCH_CWR) {
if (th->cwr == 1)
return false;
} else {
@@ -71,13 +71,13 @@ static inline bool match_tcp(const struct sk_buff *skb,
static bool ecn_mt(const struct sk_buff *skb, struct xt_action_param *par)
{
- const struct ipt_ecn_info *info = par->matchinfo;
+ const struct xt_ecn_info *info = par->matchinfo;
- if (info->operation & IPT_ECN_OP_MATCH_IP)
+ if (info->operation & XT_ECN_OP_MATCH_IP)
if (!match_ip(skb, info))
return false;
- if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR)) {
+ if (info->operation & (XT_ECN_OP_MATCH_ECE | XT_ECN_OP_MATCH_CWR)) {
if (!match_tcp(skb, info, &par->hotdrop))
return false;
}
@@ -87,16 +87,16 @@ static bool ecn_mt(const struct sk_buff *skb, struct xt_action_param *par)
static int ecn_mt_check(const struct xt_mtchk_param *par)
{
- const struct ipt_ecn_info *info = par->matchinfo;
+ const struct xt_ecn_info *info = par->matchinfo;
const struct ipt_ip *ip = par->entryinfo;
- if (info->operation & IPT_ECN_OP_MATCH_MASK)
+ if (info->operation & XT_ECN_OP_MATCH_MASK)
return -EINVAL;
- if (info->invert & IPT_ECN_OP_MATCH_MASK)
+ if (info->invert & XT_ECN_OP_MATCH_MASK)
return -EINVAL;
- if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR) &&
+ if (info->operation & (XT_ECN_OP_MATCH_ECE | XT_ECN_OP_MATCH_CWR) &&
(ip->proto != IPPROTO_TCP || ip->invflags & IPT_INV_PROTO)) {
pr_info("cannot match TCP bits in rule for non-tcp packets\n");
return -EINVAL;
@@ -109,7 +109,7 @@ static struct xt_match ecn_mt_reg __read_mostly = {
.name = "ecn",
.family = NFPROTO_IPV4,
.match = ecn_mt,
- .matchsize = sizeof(struct ipt_ecn_info),
+ .matchsize = sizeof(struct xt_ecn_info),
.checkentry = ecn_mt_check,
.me = THIS_MODULE,
};
--
1.7.3.4
next prev parent reply other threads:[~2011-06-09 20:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-09 20:23 xt_ecn in smaller pieces Jan Engelhardt
2011-06-09 20:23 ` [PATCH 1/4] netfilter: xtables: move ipt_ecn to xt_ecn Jan Engelhardt
2011-06-16 15:21 ` Patrick McHardy
2011-06-16 15:31 ` Jan Engelhardt
2011-06-16 15:34 ` Patrick McHardy
2011-06-16 15:43 ` Jan Engelhardt
2011-06-30 15:38 ` Jan Engelhardt
2011-06-30 16:35 ` Patrick McHardy
2011-06-09 20:23 ` Jan Engelhardt [this message]
2011-06-09 20:23 ` [PATCH 3/4] netfilter: xtables: add an IPv6 capable version of the ECN match Jan Engelhardt
2011-06-09 20:23 ` [PATCH 4/4] netfilter: xtables: collapse conditions in xt_ecn Jan Engelhardt
-- strict thread matches above, loose matches on Subject: below --
2011-12-27 15:27 xt_ecn revisited Jan Engelhardt
2011-12-27 15:27 ` [PATCH 2/4] netfilter: xtables: give xt_ecn its own name Jan Engelhardt
2011-12-27 18:57 xt_ecn, with descriptions Jan Engelhardt
2011-12-27 18:57 ` [PATCH 2/4] netfilter: xtables: give xt_ecn its own name 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=1307651037-20520-3-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).