Skip to content

Commit 3e90ebd

Browse files
kaberummakynes
authored andcommitted
netfilter: ip_set: rename nfnl_dereference()/nfnl_set()
The next patch will introduce a nfnl_dereference() macro that actually checks that the appropriate mutex is held and therefore needs a subsystem argument. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent d2bf2f3 commit 3e90ebd

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

‎net/netfilter/ipset/ip_set_core.c‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ MODULE_DESCRIPTION("core IP set support");
5454
MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_IPSET);
5555

5656
/* When the nfnl mutex is held: */
57-
#define nfnl_dereference(p) \
57+
#define ip_set_dereference(p) \
5858
rcu_dereference_protected(p, 1)
59-
#define nfnl_set(inst, id) \
60-
nfnl_dereference((inst)->ip_set_list)[id]
59+
#define ip_set(inst, id) \
60+
ip_set_dereference((inst)->ip_set_list)[id]
6161

6262
/*
6363
* The set types are implemented in modules and registered set types
@@ -640,7 +640,7 @@ ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index)
640640
return IPSET_INVALID_ID;
641641

642642
nfnl_lock(NFNL_SUBSYS_IPSET);
643-
set = nfnl_set(inst, index);
643+
set = ip_set(inst, index);
644644
if (set)
645645
__ip_set_get(set);
646646
else
@@ -666,7 +666,7 @@ ip_set_nfnl_put(struct net *net, ip_set_id_t index)
666666

667667
nfnl_lock(NFNL_SUBSYS_IPSET);
668668
if (!inst->is_deleted) { /* already deleted from ip_set_net_exit() */
669-
set = nfnl_set(inst, index);
669+
set = ip_set(inst, index);
670670
if (set != NULL)
671671
__ip_set_put(set);
672672
}
@@ -734,7 +734,7 @@ find_set_and_id(struct ip_set_net *inst, const char *name, ip_set_id_t *id)
734734

735735
*id = IPSET_INVALID_ID;
736736
for (i = 0; i < inst->ip_set_max; i++) {
737-
set = nfnl_set(inst, i);
737+
set = ip_set(inst, i);
738738
if (set != NULL && STREQ(set->name, name)) {
739739
*id = i;
740740
break;
@@ -760,7 +760,7 @@ find_free_id(struct ip_set_net *inst, const char *name, ip_set_id_t *index,
760760

761761
*index = IPSET_INVALID_ID;
762762
for (i = 0; i < inst->ip_set_max; i++) {
763-
s = nfnl_set(inst, i);
763+
s = ip_set(inst, i);
764764
if (s == NULL) {
765765
if (*index == IPSET_INVALID_ID)
766766
*index = i;
@@ -883,7 +883,7 @@ ip_set_create(struct sock *ctnl, struct sk_buff *skb,
883883
if (!list)
884884
goto cleanup;
885885
/* nfnl mutex is held, both lists are valid */
886-
tmp = nfnl_dereference(inst->ip_set_list);
886+
tmp = ip_set_dereference(inst->ip_set_list);
887887
memcpy(list, tmp, sizeof(struct ip_set *) * inst->ip_set_max);
888888
rcu_assign_pointer(inst->ip_set_list, list);
889889
/* Make sure all current packets have passed through */
@@ -900,7 +900,7 @@ ip_set_create(struct sock *ctnl, struct sk_buff *skb,
900900
* Finally! Add our shiny new set to the list, and be done.
901901
*/
902902
pr_debug("create: '%s' created with index %u!\n", set->name, index);
903-
nfnl_set(inst, index) = set;
903+
ip_set(inst, index) = set;
904904

905905
return ret;
906906

@@ -925,10 +925,10 @@ ip_set_setname_policy[IPSET_ATTR_CMD_MAX + 1] = {
925925
static void
926926
ip_set_destroy_set(struct ip_set_net *inst, ip_set_id_t index)
927927
{
928-
struct ip_set *set = nfnl_set(inst, index);
928+
struct ip_set *set = ip_set(inst, index);
929929

930930
pr_debug("set: %s\n", set->name);
931-
nfnl_set(inst, index) = NULL;
931+
ip_set(inst, index) = NULL;
932932

933933
/* Must call it without holding any lock */
934934
set->variant->destroy(set);
@@ -962,15 +962,15 @@ ip_set_destroy(struct sock *ctnl, struct sk_buff *skb,
962962
read_lock_bh(&ip_set_ref_lock);
963963
if (!attr[IPSET_ATTR_SETNAME]) {
964964
for (i = 0; i < inst->ip_set_max; i++) {
965-
s = nfnl_set(inst, i);
965+
s = ip_set(inst, i);
966966
if (s != NULL && s->ref) {
967967
ret = -IPSET_ERR_BUSY;
968968
goto out;
969969
}
970970
}
971971
read_unlock_bh(&ip_set_ref_lock);
972972
for (i = 0; i < inst->ip_set_max; i++) {
973-
s = nfnl_set(inst, i);
973+
s = ip_set(inst, i);
974974
if (s != NULL)
975975
ip_set_destroy_set(inst, i);
976976
}
@@ -1020,7 +1020,7 @@ ip_set_flush(struct sock *ctnl, struct sk_buff *skb,
10201020

10211021
if (!attr[IPSET_ATTR_SETNAME]) {
10221022
for (i = 0; i < inst->ip_set_max; i++) {
1023-
s = nfnl_set(inst, i);
1023+
s = ip_set(inst, i);
10241024
if (s != NULL)
10251025
ip_set_flush_set(s);
10261026
}
@@ -1074,7 +1074,7 @@ ip_set_rename(struct sock *ctnl, struct sk_buff *skb,
10741074

10751075
name2 = nla_data(attr[IPSET_ATTR_SETNAME2]);
10761076
for (i = 0; i < inst->ip_set_max; i++) {
1077-
s = nfnl_set(inst, i);
1077+
s = ip_set(inst, i);
10781078
if (s != NULL && STREQ(s->name, name2)) {
10791079
ret = -IPSET_ERR_EXIST_SETNAME2;
10801080
goto out;
@@ -1134,8 +1134,8 @@ ip_set_swap(struct sock *ctnl, struct sk_buff *skb,
11341134

11351135
write_lock_bh(&ip_set_ref_lock);
11361136
swap(from->ref, to->ref);
1137-
nfnl_set(inst, from_id) = to;
1138-
nfnl_set(inst, to_id) = from;
1137+
ip_set(inst, from_id) = to;
1138+
ip_set(inst, to_id) = from;
11391139
write_unlock_bh(&ip_set_ref_lock);
11401140

11411141
return 0;
@@ -1157,7 +1157,7 @@ ip_set_dump_done(struct netlink_callback *cb)
11571157
struct ip_set_net *inst = (struct ip_set_net *)cb->args[IPSET_CB_NET];
11581158
if (cb->args[IPSET_CB_ARG0]) {
11591159
pr_debug("release set %s\n",
1160-
nfnl_set(inst, cb->args[IPSET_CB_INDEX])->name);
1160+
ip_set(inst, cb->args[IPSET_CB_INDEX])->name);
11611161
__ip_set_put_byindex(inst,
11621162
(ip_set_id_t) cb->args[IPSET_CB_INDEX]);
11631163
}
@@ -1254,7 +1254,7 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
12541254
dump_type, dump_flags, cb->args[IPSET_CB_INDEX]);
12551255
for (; cb->args[IPSET_CB_INDEX] < max; cb->args[IPSET_CB_INDEX]++) {
12561256
index = (ip_set_id_t) cb->args[IPSET_CB_INDEX];
1257-
set = nfnl_set(inst, index);
1257+
set = ip_set(inst, index);
12581258
if (set == NULL) {
12591259
if (dump_type == DUMP_ONE) {
12601260
ret = -ENOENT;
@@ -1332,7 +1332,7 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
13321332
release_refcount:
13331333
/* If there was an error or set is done, release set */
13341334
if (ret || !cb->args[IPSET_CB_ARG0]) {
1335-
pr_debug("release set %s\n", nfnl_set(inst, index)->name);
1335+
pr_debug("release set %s\n", ip_set(inst, index)->name);
13361336
__ip_set_put_byindex(inst, index);
13371337
cb->args[IPSET_CB_ARG0] = 0;
13381338
}
@@ -1887,7 +1887,7 @@ ip_set_sockfn_get(struct sock *sk, int optval, void __user *user, int *len)
18871887
find_set_and_id(inst, req_get->set.name, &id);
18881888
req_get->set.index = id;
18891889
if (id != IPSET_INVALID_ID)
1890-
req_get->family = nfnl_set(inst, id)->family;
1890+
req_get->family = ip_set(inst, id)->family;
18911891
nfnl_unlock(NFNL_SUBSYS_IPSET);
18921892
goto copy;
18931893
}
@@ -1901,7 +1901,7 @@ ip_set_sockfn_get(struct sock *sk, int optval, void __user *user, int *len)
19011901
goto done;
19021902
}
19031903
nfnl_lock(NFNL_SUBSYS_IPSET);
1904-
set = nfnl_set(inst, req_get->set.index);
1904+
set = ip_set(inst, req_get->set.index);
19051905
strncpy(req_get->set.name, set ? set->name : "",
19061906
IPSET_MAXNAMELEN);
19071907
nfnl_unlock(NFNL_SUBSYS_IPSET);
@@ -1960,7 +1960,7 @@ ip_set_net_exit(struct net *net)
19601960
inst->is_deleted = 1; /* flag for ip_set_nfnl_put */
19611961

19621962
for (i = 0; i < inst->ip_set_max; i++) {
1963-
set = nfnl_set(inst, i);
1963+
set = ip_set(inst, i);
19641964
if (set != NULL)
19651965
ip_set_destroy_set(inst, i);
19661966
}

0 commit comments

Comments
 (0)