Skip to content

Commit 37e26ec

Browse files
committed
netfilter: nf_tables: remove busy mark and gc batch API
JIRA: https://issues.redhat.com/browse/RHEL-1720 JIRA: https://issues.redhat.com/browse/RHEL-1721 Upstream Status: commit a2dd023 commit a2dd023 Author: Pablo Neira Ayuso <[email protected]> Date: Wed Aug 9 15:00:36 2023 +0200 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]> Signed-off-by: Florian Westphal <[email protected]>
1 parent 65afc3d commit 37e26ec

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
@@ -562,7 +562,6 @@ struct nft_set *nft_set_lookup_global(const struct net *net,
562562

563563
struct nft_set_ext *nft_set_catchall_lookup(const struct net *net,
564564
const struct nft_set *set);
565-
void *nft_set_catchall_gc(const struct nft_set *set);
566565

567566
static inline unsigned long nft_set_gc_interval(const struct nft_set *set)
568567
{
@@ -779,62 +778,6 @@ void nft_set_elem_destroy(const struct nft_set *set, void *elem,
779778
void nf_tables_set_elem_destroy(const struct nft_ctx *ctx,
780779
const struct nft_set *set, void *elem);
781780

782-
/**
783-
* struct nft_set_gc_batch_head - nf_tables set garbage collection batch
784-
*
785-
* @rcu: rcu head
786-
* @set: set the elements belong to
787-
* @cnt: count of elements
788-
*/
789-
struct nft_set_gc_batch_head {
790-
struct rcu_head rcu;
791-
const struct nft_set *set;
792-
unsigned int cnt;
793-
};
794-
795-
#define NFT_SET_GC_BATCH_SIZE ((PAGE_SIZE - \
796-
sizeof(struct nft_set_gc_batch_head)) / \
797-
sizeof(void *))
798-
799-
/**
800-
* struct nft_set_gc_batch - nf_tables set garbage collection batch
801-
*
802-
* @head: GC batch head
803-
* @elems: garbage collection elements
804-
*/
805-
struct nft_set_gc_batch {
806-
struct nft_set_gc_batch_head head;
807-
void *elems[NFT_SET_GC_BATCH_SIZE];
808-
};
809-
810-
struct nft_set_gc_batch *nft_set_gc_batch_alloc(const struct nft_set *set,
811-
gfp_t gfp);
812-
void nft_set_gc_batch_release(struct rcu_head *rcu);
813-
814-
static inline void nft_set_gc_batch_complete(struct nft_set_gc_batch *gcb)
815-
{
816-
if (gcb != NULL)
817-
call_rcu(&gcb->head.rcu, nft_set_gc_batch_release);
818-
}
819-
820-
static inline struct nft_set_gc_batch *
821-
nft_set_gc_batch_check(const struct nft_set *set, struct nft_set_gc_batch *gcb,
822-
gfp_t gfp)
823-
{
824-
if (gcb != NULL) {
825-
if (gcb->head.cnt + 1 < ARRAY_SIZE(gcb->elems))
826-
return gcb;
827-
nft_set_gc_batch_complete(gcb);
828-
}
829-
return nft_set_gc_batch_alloc(set, gfp);
830-
}
831-
832-
static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb,
833-
void *elem)
834-
{
835-
gcb->elems[gcb->head.cnt++] = elem;
836-
}
837-
838781
struct nft_expr_ops;
839782
/**
840783
* struct nft_expr_type - nf_tables expression type
@@ -1498,47 +1441,12 @@ static inline void nft_set_elem_change_active(const struct net *net,
14981441

14991442
#endif /* IS_ENABLED(CONFIG_NF_TABLES) */
15001443

1501-
/*
1502-
* We use a free bit in the genmask field to indicate the element
1503-
* is busy, meaning it is currently being processed either by
1504-
* the netlink API or GC.
1505-
*
1506-
* Even though the genmask is only a single byte wide, this works
1507-
* because the extension structure if fully constant once initialized,
1508-
* so there are no non-atomic write accesses unless it is already
1509-
* marked busy.
1510-
*/
1511-
#define NFT_SET_ELEM_BUSY_MASK (1 << 2)
1512-
1513-
#if defined(__LITTLE_ENDIAN_BITFIELD)
1514-
#define NFT_SET_ELEM_BUSY_BIT 2
1515-
#elif defined(__BIG_ENDIAN_BITFIELD)
1516-
#define NFT_SET_ELEM_BUSY_BIT (BITS_PER_LONG - BITS_PER_BYTE + 2)
1517-
#else
1518-
#error
1519-
#endif
1520-
1521-
static inline int nft_set_elem_mark_busy(struct nft_set_ext *ext)
1522-
{
1523-
unsigned long *word = (unsigned long *)ext;
1524-
1525-
BUILD_BUG_ON(offsetof(struct nft_set_ext, genmask) != 0);
1526-
return test_and_set_bit(NFT_SET_ELEM_BUSY_BIT, word);
1527-
}
1528-
1529-
static inline void nft_set_elem_clear_busy(struct nft_set_ext *ext)
1530-
{
1531-
unsigned long *word = (unsigned long *)ext;
1532-
1533-
clear_bit(NFT_SET_ELEM_BUSY_BIT, word);
1534-
}
1535-
1536-
#define NFT_SET_ELEM_DEAD_MASK (1 << 3)
1444+
#define NFT_SET_ELEM_DEAD_MASK (1 << 2)
15371445

15381446
#if defined(__LITTLE_ENDIAN_BITFIELD)
1539-
#define NFT_SET_ELEM_DEAD_BIT 3
1447+
#define NFT_SET_ELEM_DEAD_BIT 2
15401448
#elif defined(__BIG_ENDIAN_BITFIELD)
1541-
#define NFT_SET_ELEM_DEAD_BIT (BITS_PER_LONG - BITS_PER_BYTE + 3)
1449+
#define NFT_SET_ELEM_DEAD_BIT (BITS_PER_LONG - BITS_PER_BYTE + 2)
15421450
#else
15431451
#error
15441452
#endif

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6038,29 +6038,6 @@ struct nft_set_ext *nft_set_catchall_lookup(const struct net *net,
60386038
}
60396039
EXPORT_SYMBOL_GPL(nft_set_catchall_lookup);
60406040

6041-
void *nft_set_catchall_gc(const struct nft_set *set)
6042-
{
6043-
struct nft_set_elem_catchall *catchall, *next;
6044-
struct nft_set_ext *ext;
6045-
void *elem = NULL;
6046-
6047-
list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
6048-
ext = nft_set_elem_ext(set, catchall->elem);
6049-
6050-
if (!nft_set_elem_expired(ext) ||
6051-
nft_set_elem_mark_busy(ext))
6052-
continue;
6053-
6054-
elem = catchall->elem;
6055-
list_del_rcu(&catchall->list);
6056-
kfree_rcu(catchall, rcu);
6057-
break;
6058-
}
6059-
6060-
return elem;
6061-
}
6062-
EXPORT_SYMBOL_GPL(nft_set_catchall_gc);
6063-
60646041
static int nft_setelem_catchall_insert(const struct net *net,
60656042
struct nft_set *set,
60666043
const struct nft_set_elem *elem,
@@ -6531,7 +6508,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
65316508
goto err_elem_free;
65326509
}
65336510

6534-
ext->genmask = nft_genmask_cur(ctx->net) | NFT_SET_ELEM_BUSY_MASK;
6511+
ext->genmask = nft_genmask_cur(ctx->net);
65356512

65366513
err = nft_setelem_insert(ctx->net, set, &elem, &ext2, flags);
65376514
if (err) {
@@ -6921,29 +6898,6 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
69216898
return err;
69226899
}
69236900

6924-
void nft_set_gc_batch_release(struct rcu_head *rcu)
6925-
{
6926-
struct nft_set_gc_batch *gcb;
6927-
unsigned int i;
6928-
6929-
gcb = container_of(rcu, struct nft_set_gc_batch, head.rcu);
6930-
for (i = 0; i < gcb->head.cnt; i++)
6931-
nft_set_elem_destroy(gcb->head.set, gcb->elems[i], true);
6932-
kfree(gcb);
6933-
}
6934-
6935-
struct nft_set_gc_batch *nft_set_gc_batch_alloc(const struct nft_set *set,
6936-
gfp_t gfp)
6937-
{
6938-
struct nft_set_gc_batch *gcb;
6939-
6940-
gcb = kzalloc(sizeof(*gcb), gfp);
6941-
if (gcb == NULL)
6942-
return gcb;
6943-
gcb->head.set = set;
6944-
return gcb;
6945-
}
6946-
69476901
/*
69486902
* Stateful objects
69496903
*/

0 commit comments

Comments
 (0)