History

netfilter: ctnetlink: Expectations must have a conntrack helper area

The expect check function __nf_ct_expect_check() asks the master_help is necessary. So it is unnecessary to go ahead in ctnetlink_alloc_expect when there is no help. Actually the commit bc01befdcf3e ("netfilter: ctnetlink: add support for user-space expectation helpers") permits ctnetlink create one expect even though there is no master help. But the latter commit 3d058d7bc2c5 ("netfilter: rework user-space expectation helper support") disables it again.

Gao Feng committed 9 years ago

Commit 2c62e0b1 parent 6e699861 file · +8 −19Browse files

Unified · Split

net/netfilter/nf_conntrack_netlink.c+8−19
@@ -3038,6 +3038,10 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, · 3037 unmodified lines
30383038 struct nf_conn_help *help;
30393039 int err;
30403040
3041+ help = nfct_help(ct);
3042+ if (!help)
3043+ return ERR_PTR(-EOPNOTSUPP);
3044+
30413045 if (cda[CTA_EXPECT_CLASS] && helper) {
30423046 class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS]));
30433047 if (class > helper->expect_class_max)
@@ -3047,26 +3051,11 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, · 3 unmodified lines
30473051 if (!exp)
30483052 return ERR_PTR(-ENOMEM);
30493053
3050− help = nfct_help(ct);
3051− if (!help) {
3052− if (!cda[CTA_EXPECT_TIMEOUT]) {
3053− err = -EINVAL;
3054− goto err_out;
3055− }
3056− exp->timeout.expires =
3057− jiffies + ntohl(nla_get_be32(cda[CTA_EXPECT_TIMEOUT])) * HZ;
3058−
3059− exp->flags = NF_CT_EXPECT_USERSPACE;
3060− if (cda[CTA_EXPECT_FLAGS]) {
3061− exp->flags |=
3062− ntohl(nla_get_be32(cda[CTA_EXPECT_FLAGS]));
3063− }
3054+ if (cda[CTA_EXPECT_FLAGS]) {
3055+ exp->flags = ntohl(nla_get_be32(cda[CTA_EXPECT_FLAGS]));
3056+ exp->flags &= ~NF_CT_EXPECT_USERSPACE;
30643057 } else {
3065− if (cda[CTA_EXPECT_FLAGS]) {
3066− exp->flags = ntohl(nla_get_be32(cda[CTA_EXPECT_FLAGS]));
3067− exp->flags &= ~NF_CT_EXPECT_USERSPACE;
3068− } else
3069− exp->flags = 0;
3058+ exp->flags = 0;
30703059 }
30713060 if (cda[CTA_EXPECT_FN]) {
30723061 const char *name = nla_data(cda[CTA_EXPECT_FN]);