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.
Unified · Split
| @@ -3038,6 +3038,10 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, · 3037 unmodified lines | |||
| 3038 | struct nf_conn_help *help; | 3038 | struct nf_conn_help *help; |
| 3039 | int err; | 3039 | int err; |
| 3040 | 3040 | ||
| 3041 | help = nfct_help(ct); | ||
| 3042 | if (!help) | ||
| 3043 | return ERR_PTR(-EOPNOTSUPP); | ||
| 3044 | |||
| 3041 | if (cda[CTA_EXPECT_CLASS] && helper) { | 3045 | if (cda[CTA_EXPECT_CLASS] && helper) { |
| 3042 | class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS])); | 3046 | class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS])); |
| 3043 | if (class > helper->expect_class_max) | 3047 | 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 | |||
| 3047 | if (!exp) | 3051 | if (!exp) |
| 3048 | return ERR_PTR(-ENOMEM); | 3052 | return ERR_PTR(-ENOMEM); |
| 3049 | 3053 | ||
| 3050 | help = nfct_help(ct); | 3054 | if (cda[CTA_EXPECT_FLAGS]) { |
| 3051 | if (!help) { | 3055 | exp->flags = ntohl(nla_get_be32(cda[CTA_EXPECT_FLAGS])); |
| 3052 | if (!cda[CTA_EXPECT_TIMEOUT]) { | 3056 | exp->flags &= ~NF_CT_EXPECT_USERSPACE; |
| 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 | } | ||
| 3064 | } else { | 3057 | } else { |
| 3065 | if (cda[CTA_EXPECT_FLAGS]) { | 3058 | exp->flags = 0; |
| 3066 | exp->flags = ntohl(nla_get_be32(cda[CTA_EXPECT_FLAGS])); | ||
| 3067 | exp->flags &= ~NF_CT_EXPECT_USERSPACE; | ||
| 3068 | } else | ||
| 3069 | exp->flags = 0; | ||
| 3070 | } | 3059 | } |
| 3071 | if (cda[CTA_EXPECT_FN]) { | 3060 | if (cda[CTA_EXPECT_FN]) { |
| 3072 | const char *name = nla_data(cda[CTA_EXPECT_FN]); | 3061 | const char *name = nla_data(cda[CTA_EXPECT_FN]); |