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 | 3038 | struct nf_conn_help *help; |
| 3039 | 3039 | int err; |
| 3040 | 3040 | |
| 3041 | + help = nfct_help(ct); | |
| 3042 | + if (!help) | |
| 3043 | + return ERR_PTR(-EOPNOTSUPP); | |
| 3044 | + | |
| 3041 | 3045 | if (cda[CTA_EXPECT_CLASS] && helper) { |
| 3042 | 3046 | class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS])); |
| 3043 | 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 | 3051 | if (!exp) |
| 3048 | 3052 | return ERR_PTR(-ENOMEM); |
| 3049 | 3053 | |
| 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; | |
| 3064 | 3057 | } 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; | |
| 3070 | 3059 | } |
| 3071 | 3060 | if (cda[CTA_EXPECT_FN]) { |
| 3072 | 3061 | const char *name = nla_data(cda[CTA_EXPECT_FN]); |