Skip to content

Commit c4cbe4a

Browse files
ffmanceraummakynes
authored andcommitted
netfilter: nft_connlimit: add support to object update operation
This is useful to update the limit or flags without clearing the connections tracked. Use READ_ONCE() on packetpath as it can be modified on controlplane. Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 69894e5 commit c4cbe4a

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

net/netfilter/nft_connlimit.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static inline void nft_connlimit_do_eval(struct nft_connlimit *priv,
4444

4545
count = READ_ONCE(priv->list->count);
4646

47-
if ((count > priv->limit) ^ priv->invert) {
47+
if ((count > READ_ONCE(priv->limit)) ^ READ_ONCE(priv->invert)) {
4848
regs->verdict.code = NFT_BREAK;
4949
return;
5050
}
@@ -131,6 +131,16 @@ static int nft_connlimit_obj_init(const struct nft_ctx *ctx,
131131
return nft_connlimit_do_init(ctx, tb, priv);
132132
}
133133

134+
static void nft_connlimit_obj_update(struct nft_object *obj,
135+
struct nft_object *newobj)
136+
{
137+
struct nft_connlimit *newpriv = nft_obj_data(newobj);
138+
struct nft_connlimit *priv = nft_obj_data(obj);
139+
140+
WRITE_ONCE(priv->limit, newpriv->limit);
141+
WRITE_ONCE(priv->invert, newpriv->invert);
142+
}
143+
134144
static void nft_connlimit_obj_destroy(const struct nft_ctx *ctx,
135145
struct nft_object *obj)
136146
{
@@ -160,6 +170,7 @@ static const struct nft_object_ops nft_connlimit_obj_ops = {
160170
.init = nft_connlimit_obj_init,
161171
.destroy = nft_connlimit_obj_destroy,
162172
.dump = nft_connlimit_obj_dump,
173+
.update = nft_connlimit_obj_update,
163174
};
164175

165176
static struct nft_object_type nft_connlimit_obj_type __read_mostly = {

0 commit comments

Comments
 (0)