This patch allows you to set the expectation class.
Unified · Split
| @@ -173,6 +173,7 @@ enum ctattr_expect { · 172 unmodified lines | ||
| 173 | 173 | CTA_EXPECT_HELP_NAME, |
| 174 | 174 | CTA_EXPECT_ZONE, |
| 175 | 175 | CTA_EXPECT_FLAGS, |
| 176 | + CTA_EXPECT_CLASS, | |
| 176 | 177 | __CTA_EXPECT_MAX |
| 177 | 178 | }; |
| 178 | 179 | #define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1) |
| @@ -1691,6 +1691,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 1690 unmodified lines | ||
| 1691 | 1691 | NLA_PUT_BE32(skb, CTA_EXPECT_TIMEOUT, htonl(timeout)); |
| 1692 | 1692 | NLA_PUT_BE32(skb, CTA_EXPECT_ID, htonl((unsigned long)exp)); |
| 1693 | 1693 | NLA_PUT_BE32(skb, CTA_EXPECT_FLAGS, htonl(exp->flags)); |
| 1694 | + NLA_PUT_BE32(skb, CTA_EXPECT_CLASS, htonl(exp->class)); | |
| 1694 | 1695 | help = nfct_help(master); |
| 1695 | 1696 | if (help) { |
| 1696 | 1697 | struct nf_conntrack_helper *helper; |
| @@ -1856,6 +1857,7 @@ static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { · 159 unmodified lines | ||
| 1856 | 1857 | [CTA_EXPECT_HELP_NAME] = { .type = NLA_NUL_STRING }, |
| 1857 | 1858 | [CTA_EXPECT_ZONE] = { .type = NLA_U16 }, |
| 1858 | 1859 | [CTA_EXPECT_FLAGS] = { .type = NLA_U32 }, |
| 1860 | + [CTA_EXPECT_CLASS] = { .type = NLA_U32 }, | |
| 1859 | 1861 | }; |
| 1860 | 1862 | |
| 1861 | 1863 | static int |
| @@ -2043,6 +2045,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 181 unmodified lines | ||
| 2043 | 2045 | struct nf_conn *ct; |
| 2044 | 2046 | struct nf_conn_help *help; |
| 2045 | 2047 | struct nf_conntrack_helper *helper = NULL; |
| 2048 | + u_int32_t class = 0; | |
| 2046 | 2049 | int err = 0; |
| 2047 | 2050 | |
| 2048 | 2051 | /* caller guarantees that those three CTA_EXPECT_* exist */ |
| @@ -2088,6 +2091,13 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 39 unmodified lines | ||
| 2088 | 2091 | } |
| 2089 | 2092 | } |
| 2090 | 2093 | |
| 2094 | + if (cda[CTA_EXPECT_CLASS] && helper) { | |
| 2095 | + class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS])); | |
| 2096 | + if (class > helper->expect_class_max) { | |
| 2097 | + err = -EINVAL; | |
| 2098 | + goto out; | |
| 2099 | + } | |
| 2100 | + } | |
| 2091 | 2101 | exp = nf_ct_expect_alloc(ct); |
| 2092 | 2102 | if (!exp) { |
| 2093 | 2103 | err = -ENOMEM; |
| @@ -2115,7 +2125,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 21 unmodified lines | ||
| 2115 | 2125 | exp->flags = 0; |
| 2116 | 2126 | } |
| 2117 | 2127 | |
| 2118 | − exp->class = 0; | |
| 2128 | + exp->class = class; | |
| 2119 | 2129 | exp->expectfn = NULL; |
| 2120 | 2130 | exp->master = ct; |
| 2121 | 2131 | exp->helper = helper; |