user-space expectation support updates
Subsystems (2)
[email protected]
maintainerPATCH 1/1 user-space expectation support updates
From: Pablo Neira Ayuso <[email protected]>
Hi!
This patch was posted in april 2011, it seem it got lost during the discussion:
http://www.spinics.net/lists/netfilter-devel/msg17992.html
http://www.spinics.net/lists/netfilter-devel/msg17993.html
This reworks the user-space expectation support.
I'm resending this to get it into net-net.
Nobody has been using this support so far. I plan to start working on some user-space daemon (or extension for conntrackd) to allow to implement helpers in user-space by beginning 2012.
Pablo Neira Ayuso (1):
netfilter: rework user-space expectation helper support
include/linux/netfilter/nf_conntrack_common.h | 4 ++ include/linux/netfilter/xt_CT.h | 3 +- include/net/netfilter/nf_conntrack_expect.h | 1 - net/netfilter/nf_conntrack_expect.c | 63 ++++++++---------------- net/netfilter/nf_conntrack_helper.c | 12 +++++ net/netfilter/nf_conntrack_netlink.c | 5 ++- net/netfilter/xt_CT.c | 8 ++- 7 files changed, 48 insertions(+), 48 deletions(-)
Signature · 1 line
1.7.2.5
[email protected]
maintainerPATCH 1/1 netfilter: rework user-space expectation helper support
From: Pablo Neira Ayuso <[email protected]>
This partially reworks bc01befdcf3e40979eb518085a075cbf0aacede0 which added userspace expectation support.
This patch removes the nf_ct_userspace_expect_list since now we force to use the new iptables CT target feature to add the helper extension for conntracks that have attached expectations from userspace.
A new version of the proof-of-concept code to implement userspace helpers from userspace is available at:
http://people.netfilter.org/pablo/userspace-conntrack-helpers/nf-ftp-helper-POC.tar.bz2
This patch modifies the CT target to allow to set the conntrack's userspace helper status flags. This flag is used to tell the conntrack system to explicitly allocate the helper extension.
This helper extension is useful to link the userspace expectations with the master conntrack that is being tracked from one userspace helper.
This feature fixes a problem in the current approach of the userspace helper support. Basically, if the master conntrack that has got a userspace expectation vanishes, the expectations point to one invalid memory address. Thus, triggering an oops in the expectation deletion event path.
I decided not to add a new revision of the CT target because I only needed to add a new flag for it. I'll document in this issue in the iptables manpage. I have also changed the return value from EINVAL to EOPNOTSUPP if one flag not supported is specified. Thus, in the future adding new features that only require a new flag can be added without a new revision.
--- include/linux/netfilter/nf_conntrack_common.h | 4 ++ include/linux/netfilter/xt_CT.h | 3 +- include/net/netfilter/nf_conntrack_expect.h | 1 - net/netfilter/nf_conntrack_expect.c | 63 ++++++++---------------- net/netfilter/nf_conntrack_helper.c | 12 +++++ net/netfilter/nf_conntrack_netlink.c | 5 ++- net/netfilter/xt_CT.c | 8 ++- 7 files changed, 48 insertions(+), 48 deletions(-)
include/linux/netfilter/nf_conntrack_common.h +4 -0
@@ -83,6 +83,10 @@ enum ip_conntrack_status {/* Conntrack is a fake untracked entry */ IPS_UNTRACKED_BIT =12 ,IPS_UNTRACKED = (1 <<IPS_UNTRACKED_BIT ), + +/* Conntrack has a userspace helper. */ +IPS_USERSPACE_HELPER_BIT =13 , + IPS_USERSPACE_HELPER = (1 << IPS_USERSPACE_HELPER_BIT), };/* Connection tracking event types */
include/linux/netfilter/xt_CT.h +2 -1
@@ -3,7 +3,8 @@#include <linux/types.h> -#define XT_CT_NOTRACK 0x1 +#define XT_CT_NOTRACK 0x1 +#define XT_CT_USERSPACE_HELPER 0x2struct xt_ct_target_info {__u16 flags;
include/net/netfilter/nf_conntrack_expect.h +0 -1
@@ -91,7 +91,6 @@ static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp)void nf_ct_remove_expectations (struct nf_conn *ct);void nf_ct_unexpect_related (struct nf_conntrack_expect *exp); -void nf_ct_remove_userspace_expectations (void );/* Allocate space for an expectation: this is mandatory before calling nf_ct_expect_related. You will have to call put afterwards. */
net/netfilter/nf_conntrack_expect.c +21 -42
134 lines not on this page · raw message
net/netfilter/nf_conntrack_helper.c +12 -0
@@ -121,6 +121,18 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,int ret =0 ;if (tmpl !=NULL ) { +/* we've got a userspace helper. */ +if (tmpl->status &IPS_USERSPACE_HELPER ) { + help =nf_ct_helper_ext_add (ct, flags); +if (help ==NULL ) { + ret = -ENOMEM ; + goto out; + } +rcu_assign_pointer (help->helper,NULL ); +__set_bit (IPS_USERSPACE_HELPER_BIT , &ct->status); + ret =0 ; + goto out; + } help =nfct_help (tmpl);if (help !=NULL ) helper = help->helper;
net/netfilter/nf_conntrack_netlink.c +4 -1
@@ -2040,6 +2040,10 @@ ctnetlink_create_expect(struct net *net, u16 zone, } help =nfct_help (ct);if (!help) { + err = -EOPNOTSUPP ; + goto out; + } +if (test_bit (IPS_USERSPACE_HELPER_BIT , &ct->status)) {if (!cda[CTA_EXPECT_TIMEOUT ]) { err = -EINVAL ; goto out;
@@ -2264,7 +2268,6 @@ static void __exit ctnetlink_exit(void) {pr_info ("ctnetlink: unregistering from nfnetlink.\n" ); -nf_ct_remove_userspace_expectations ();unregister_pernet_subsys (&ctnetlink_net_ops);nfnetlink_subsys_unregister (&ctnl_exp_subsys);nfnetlink_subsys_unregister (&ctnl_subsys);
net/netfilter/xt_CT.c +5 -3
@@ -62,8 +62,8 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par)int ret =0 ;u8 proto; -if (info->flags & ~XT_CT_NOTRACK ) -return -EINVAL ; +if (info->flags & ~(XT_CT_NOTRACK |XT_CT_USERSPACE_HELPER )) +return -EOPNOTSUPP ;if (info->flags &XT_CT_NOTRACK ) { ct =nf_ct_untracked_get ();
@@ -92,7 +92,9 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par) GFP_KERNEL)) goto err3; -if (info->helper[0 ]) { +if (info->flags &XT_CT_USERSPACE_HELPER ) { +__set_bit (IPS_USERSPACE_HELPER_BIT , &ct->status); + }else if (info->helper[0 ]) { ret = -ENOENT ; proto =xt_ct_find_proto (par);if (!proto) {
Signature · 1 line
1.7.2.5