Skip to content

Commit a2dd023

Browse files
committed
netfilter: nf_tables: remove busy mark and gc batch API
Ditch it, it has been replace it by the GC transaction API and it has no clients anymore. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent c92db30 commit a2dd023

File tree

2 files changed

+4
-142
lines changed

2 files changed

+4
-142
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ struct nft_set *nft_set_lookup_global(const struct net *net,
599599

600600
struct nft_set_ext *nft_set_catchall_lookup(const struct net *net,
601601
const struct nft_set *set);
602-
void *nft_set_catchall_gc(const struct nft_set *set);
603602

604603
static inline unsigned long nft_set_gc_interval(const struct nft_set *set)
605604
{
@@ -816,62 +815,6 @@ void nft_set_elem_destroy(const struct nft_set *set, void *elem,
816815
void nf_tables_set_elem_destroy(const struct nft_ctx *ctx,
817816
const struct nft_set *set, void *elem);
818817

819-
/**
820-
* struct nft_set_gc_batch_head - nf_tables set garbage collection batch
821-
*
822-
* @rcu: rcu head
823-
* @set: set the elements belong to
824-
* @cnt: count of elements
825-
*/
826-
struct nft_set_gc_batch_head {
827-
struct rcu_head rcu;
828-
const struct nft_set *set;
829-
unsigned int cnt;
830-
};
831-
832-
#define NFT_SET_GC_BATCH_SIZE ((PAGE_SIZE - \
833-
sizeof(struct nft_set_gc_batch_head)) / \
834-
sizeof(void *))
835-
836-
/**
837-
* struct nft_set_gc_batch - nf_tables set garbage collection batch
838-
*
839-
* @head: GC batch head
840-
* @elems: garbage collection elements
841-
*/
842-
struct nft_set_gc_batch {
843-
struct nft_set_gc_batch_head head;
844-
void *elems[NFT_SET_GC_BATCH_SIZE];
845-
};
846-
847-
struct nft_set_gc_batch *nft_set_gc_batch_alloc(const struct nft_set *set,
848-
gfp_t gfp);
849-
void nft_set_gc_batch_release(struct rcu_head *rcu);
850-
851-
static inline void nft_set_gc_batch_complete(struct nft_set_gc_batch *gcb)
852-
{
853-
if (gcb != NULL)
854-
call_rcu(&gcb->head.rcu, nft_set_gc_batch_release);
855-
}
856-
857-
static inline struct nft_set_gc_batch *
858-
nft_set_gc_batch_check(const struct nft_set *set, struct nft_set_gc_batch *gcb,
859-
gfp_t gfp)
860-
{
861-
if (gcb != NULL) {
862-
if (gcb->head.cnt + 1 < ARRAY_SIZE(gcb->elems))
863-
return gcb;
864-
nft_set_gc_batch_complete(gcb);
865-
}
866-
return nft_set_gc_batch_alloc(set, gfp);
867-
}
868-
869-
static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb,
870-
void *elem)
871-
{
872-
gcb->elems[gcb->head.cnt++] = elem;
873-
}
874-
875818
struct nft_expr_ops;
876819
/**
877820
* struct nft_expr_type - nf_tables expression type
@@ -1560,47 +1503,12 @@ static inline void nft_set_elem_change_active(const struct net *net,
15601503

15611504
#endif /* IS_ENABLED(CONFIG_NF_TABLES) */
15621505

1563-
/*
1564-
* We use a free bit in the genmask field to indicate the element
1565-
* is busy, meaning it is currently being processed either by
1566-
* the netlink API or GC.
1567-
*
1568-
* Even though the genmask is only a single byte wide, this works
1569-
* because the extension structure if fully constant once initialized,
1570-
* so there are no non-atomic write accesses unless it is already
1571-
* marked busy.
1572-
*/
1573-
#define NFT_SET_ELEM_BUSY_MASK (1 << 2)
1574-
1575-
#if defined(__LITTLE_ENDIAN_BITFIELD)
1576-
#define NFT_SET_ELEM_BUSY_BIT 2
1577-
#elif defined(__BIG_ENDIAN_BITFIELD)
1578-
#define NFT_SET_ELEM_BUSY_BIT (BITS_PER_LONG - BITS_PER_BYTE + 2)
1579-
#else
1580-
#error
1581-
#endif
1582-
1583-
static inline int nft_set_elem_mark_busy(struct nft_set_ext *ext)
1584-
{
1585-
unsigned long *word = (unsigned long *)ext;
1586-
1587-
BUILD_BUG_ON(offsetof(struct nft_set_ext, genmask) != 0);
1588-
return test_and_set_bit(NFT_SET_ELEM_BUSY_BIT, word);
1589-
}
1590-
1591-
static inline void nft_set_elem_clear_busy(struct nft_set_ext *ext)
1592-
{
1593-
unsigned long *word = (unsigned long *)ext;
1594-
1595-
clear_bit(NFT_SET_ELEM_BUSY_BIT, word);
1596-
}
1597-
1598-
#define NFT_SET_ELEM_DEAD_MASK (1 << 3)
1506+
#define NFT_SET_ELEM_DEAD_MASK (1 << 2)
15991507

16001508
#if defined(__LITTLE_ENDIAN_BITFIELD)
1601-
#define NFT_SET_ELEM_DEAD_BIT 3
1509+
#define NFT_SET_ELEM_DEAD_BIT 2
16021510
#elif defined(__BIG_ENDIAN_BITFIELD)
1603-
#define NFT_SET_ELEM_DEAD_BIT (BITS_PER_LONG - BITS_PER_BYTE + 3)
1511+
#define NFT_SET_ELEM_DEAD_BIT (BITS_PER_LONG - BITS_PER_BYTE + 2)
16041512
#else
16051513
#error
16061514
#endif

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6296,29 +6296,6 @@ struct nft_set_ext *nft_set_catchall_lookup(const struct net *net,
62966296
}
62976297
EXPORT_SYMBOL_GPL(nft_set_catchall_lookup);
62986298

6299-
void *nft_set_catchall_gc(const struct nft_set *set)
6300-
{
6301-
struct nft_set_elem_catchall *catchall, *next;
6302-
struct nft_set_ext *ext;
6303-
void *elem = NULL;
6304-
6305-
list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
6306-
ext = nft_set_elem_ext(set, catchall->elem);
6307-
6308-
if (!nft_set_elem_expired(ext) ||
6309-
nft_set_elem_mark_busy(ext))
6310-
continue;
6311-
6312-
elem = catchall->elem;
6313-
list_del_rcu(&catchall->list);
6314-
kfree_rcu(catchall, rcu);
6315-
break;
6316-
}
6317-
6318-
return elem;
6319-
}
6320-
EXPORT_SYMBOL_GPL(nft_set_catchall_gc);
6321-
63226299
static int nft_setelem_catchall_insert(const struct net *net,
63236300
struct nft_set *set,
63246301
const struct nft_set_elem *elem,
@@ -6789,7 +6766,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
67896766
goto err_elem_free;
67906767
}
67916768

6792-
ext->genmask = nft_genmask_cur(ctx->net) | NFT_SET_ELEM_BUSY_MASK;
6769+
ext->genmask = nft_genmask_cur(ctx->net);
67936770

67946771
err = nft_setelem_insert(ctx->net, set, &elem, &ext2, flags);
67956772
if (err) {
@@ -7181,29 +7158,6 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
71817158
return err;
71827159
}
71837160

7184-
void nft_set_gc_batch_release(struct rcu_head *rcu)
7185-
{
7186-
struct nft_set_gc_batch *gcb;
7187-
unsigned int i;
7188-
7189-
gcb = container_of(rcu, struct nft_set_gc_batch, head.rcu);
7190-
for (i = 0; i < gcb->head.cnt; i++)
7191-
nft_set_elem_destroy(gcb->head.set, gcb->elems[i], true);
7192-
kfree(gcb);
7193-
}
7194-
7195-
struct nft_set_gc_batch *nft_set_gc_batch_alloc(const struct nft_set *set,
7196-
gfp_t gfp)
7197-
{
7198-
struct nft_set_gc_batch *gcb;
7199-
7200-
gcb = kzalloc(sizeof(*gcb), gfp);
7201-
if (gcb == NULL)
7202-
return gcb;
7203-
gcb->head.set = set;
7204-
return gcb;
7205-
}
7206-
72077161
/*
72087162
* Stateful objects
72097163
*/

0 commit comments

Comments
 (0)