All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netfilter-devel@lists.netfilter.org, Patrick McHardy <kaber@trash.net>
Subject: [NETFILTER 09/09]: xt_conntrack: add compat support
Date: Thu, 10 May 2007 15:41:22 +0200 (MEST)	[thread overview]
Message-ID: <20070510134039.8559.90741.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20070510134027.8559.40540.sendpatchset@localhost.localdomain>

[NETFILTER]: xt_conntrack: add compat support

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 18a31ce74f45310a1133fadd17f36b879fd0221b
tree 2b0e1102cbb2625a350309348ac0b15a7b54db5d
parent e319b2005352790a24e1a91dc1af4b2f8643a876
author Patrick McHardy <kaber@trash.net> Thu, 10 May 2007 15:39:08 +0200
committer Patrick McHardy <kaber@trash.net> Thu, 10 May 2007 15:39:08 +0200

 net/netfilter/xt_conntrack.c |   54 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index f4ea8fe..189ded5 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -134,12 +134,66 @@ static void destroy(const struct xt_match *match, void *matchinfo)
 	nf_ct_l3proto_module_put(match->family);
 }
 
+#ifdef CONFIG_COMPAT
+struct compat_xt_conntrack_info
+{
+	compat_uint_t			statemask;
+	compat_uint_t			statusmask;
+	struct ip_conntrack_old_tuple	tuple[IP_CT_DIR_MAX];
+	struct in_addr			sipmsk[IP_CT_DIR_MAX];
+	struct in_addr			dipmsk[IP_CT_DIR_MAX];
+	compat_ulong_t			expires_min;
+	compat_ulong_t			expires_max;
+	u_int8_t			flags;
+	u_int8_t			invflags;
+};
+
+static void compat_from_user(void *dst, void *src)
+{
+	struct compat_xt_conntrack_info *cm = src;
+	struct xt_conntrack_info m = {
+		.statemask	= cm->statemask,
+		.statusmask	= cm->statusmask,
+		.expires_min	= cm->expires_min,
+		.expires_max	= cm->expires_max,
+		.flags		= cm->flags,
+		.invflags	= cm->invflags,
+	};
+	memcpy(m.tuple, cm->tuple, sizeof(m.tuple));
+	memcpy(m.sipmsk, cm->sipmsk, sizeof(m.sipmsk));
+	memcpy(m.dipmsk, cm->dipmsk, sizeof(m.dipmsk));
+	memcpy(dst, &m, sizeof(m));
+}
+
+static int compat_to_user(void __user *dst, void *src)
+{
+	struct xt_conntrack_info *m = src;
+	struct compat_xt_conntrack_info cm = {
+		.statemask	= m->statemask,
+		.statusmask	= m->statusmask,
+		.expires_min	= m->expires_min,
+		.expires_max	= m->expires_max,
+		.flags		= m->flags,
+		.invflags	= m->invflags,
+	};
+	memcpy(cm.tuple, m->tuple, sizeof(cm.tuple));
+	memcpy(cm.sipmsk, m->sipmsk, sizeof(cm.sipmsk));
+	memcpy(cm.dipmsk, m->dipmsk, sizeof(cm.dipmsk));
+	return copy_to_user(dst, &cm, sizeof(cm)) ? -EFAULT : 0;
+}
+#endif
+
 static struct xt_match conntrack_match = {
 	.name		= "conntrack",
 	.match		= match,
 	.checkentry	= checkentry,
 	.destroy	= destroy,
 	.matchsize	= sizeof(struct xt_conntrack_info),
+#ifdef CONFIG_COMPAT
+	.compatsize	= sizeof(struct compat_xt_conntrack_info),
+	.compat_from_user = compat_from_user,
+	.compat_to_user	= compat_to_user,
+#endif
 	.family		= AF_INET,
 	.me		= THIS_MODULE,
 };

  parent reply	other threads:[~2007-05-10 13:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy
2007-05-10 13:41 ` [NETFILTER 01/09]: Clean up table initialization Patrick McHardy
2007-05-10 21:14   ` David Miller
2007-05-10 13:41 ` [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding Patrick McHardy
2007-05-10 21:14   ` David Miller
2007-05-10 13:41 ` [NETFILTER 03/09]: nf_conntrack: Removes duplicated declarations Patrick McHardy
2007-05-10 21:15   ` David Miller
2007-05-10 13:41 ` [NETFILTER 04/09]: nf_conntrack: Removes unused destroy operation of l3proto Patrick McHardy
2007-05-10 21:15   ` David Miller
2007-05-10 13:41 ` [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper Patrick McHardy
2007-05-10 21:16   ` David Miller
2007-05-10 13:41 ` [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing Patrick McHardy
2007-05-10 21:16   ` David Miller
2007-05-10 13:41 ` [NETFILTER 07/09]: iptable_{filter, mangle}: more descriptive "happy cracking" message Patrick McHardy
2007-05-10 21:17   ` [NETFILTER 07/09]: iptable_{filter,mangle}: " David Miller
2007-05-11  0:44     ` Patrick McHardy
2007-05-10 13:41 ` [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets Patrick McHardy
2007-05-10 21:17   ` David Miller
2007-05-10 13:41 ` Patrick McHardy [this message]
2007-05-10 21:18   ` [NETFILTER 09/09]: xt_conntrack: add compat support David Miller

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=20070510134039.8559.90741.sendpatchset@localhost.localdomain \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=netfilter-devel@lists.netfilter.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 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.