Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Patrick McHardy and committed by
Pablo Neira Ayuso
3e90ebd3 d2bf2f34

+23 -23
+23 -23
net/netfilter/ipset/ip_set_core.c
··· 54 54 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_IPSET); 55 55 56 56 /* When the nfnl mutex is held: */ 57 - #define nfnl_dereference(p) \ 57 + #define ip_set_dereference(p) \ 58 58 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] 61 61 62 62 /* 63 63 * The set types are implemented in modules and registered set types ··· 640 640 return IPSET_INVALID_ID; 641 641 642 642 nfnl_lock(NFNL_SUBSYS_IPSET); 643 - set = nfnl_set(inst, index); 643 + set = ip_set(inst, index); 644 644 if (set) 645 645 __ip_set_get(set); 646 646 else ··· 666 666 667 667 nfnl_lock(NFNL_SUBSYS_IPSET); 668 668 if (!inst->is_deleted) { /* already deleted from ip_set_net_exit() */ 669 - set = nfnl_set(inst, index); 669 + set = ip_set(inst, index); 670 670 if (set != NULL) 671 671 __ip_set_put(set); 672 672 } ··· 734 734 735 735 *id = IPSET_INVALID_ID; 736 736 for (i = 0; i < inst->ip_set_max; i++) { 737 - set = nfnl_set(inst, i); 737 + set = ip_set(inst, i); 738 738 if (set != NULL && STREQ(set->name, name)) { 739 739 *id = i; 740 740 break; ··· 760 760 761 761 *index = IPSET_INVALID_ID; 762 762 for (i = 0; i < inst->ip_set_max; i++) { 763 - s = nfnl_set(inst, i); 763 + s = ip_set(inst, i); 764 764 if (s == NULL) { 765 765 if (*index == IPSET_INVALID_ID) 766 766 *index = i; ··· 883 883 if (!list) 884 884 goto cleanup; 885 885 /* 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); 887 887 memcpy(list, tmp, sizeof(struct ip_set *) * inst->ip_set_max); 888 888 rcu_assign_pointer(inst->ip_set_list, list); 889 889 /* Make sure all current packets have passed through */ ··· 900 900 * Finally! Add our shiny new set to the list, and be done. 901 901 */ 902 902 pr_debug("create: '%s' created with index %u!\n", set->name, index); 903 - nfnl_set(inst, index) = set; 903 + ip_set(inst, index) = set; 904 904 905 905 return ret; 906 906 ··· 925 925 static void 926 926 ip_set_destroy_set(struct ip_set_net *inst, ip_set_id_t index) 927 927 { 928 - struct ip_set *set = nfnl_set(inst, index); 928 + struct ip_set *set = ip_set(inst, index); 929 929 930 930 pr_debug("set: %s\n", set->name); 931 - nfnl_set(inst, index) = NULL; 931 + ip_set(inst, index) = NULL; 932 932 933 933 /* Must call it without holding any lock */ 934 934 set->variant->destroy(set); ··· 962 962 read_lock_bh(&ip_set_ref_lock); 963 963 if (!attr[IPSET_ATTR_SETNAME]) { 964 964 for (i = 0; i < inst->ip_set_max; i++) { 965 - s = nfnl_set(inst, i); 965 + s = ip_set(inst, i); 966 966 if (s != NULL && s->ref) { 967 967 ret = -IPSET_ERR_BUSY; 968 968 goto out; ··· 970 970 } 971 971 read_unlock_bh(&ip_set_ref_lock); 972 972 for (i = 0; i < inst->ip_set_max; i++) { 973 - s = nfnl_set(inst, i); 973 + s = ip_set(inst, i); 974 974 if (s != NULL) 975 975 ip_set_destroy_set(inst, i); 976 976 } ··· 1020 1020 1021 1021 if (!attr[IPSET_ATTR_SETNAME]) { 1022 1022 for (i = 0; i < inst->ip_set_max; i++) { 1023 - s = nfnl_set(inst, i); 1023 + s = ip_set(inst, i); 1024 1024 if (s != NULL) 1025 1025 ip_set_flush_set(s); 1026 1026 } ··· 1074 1074 1075 1075 name2 = nla_data(attr[IPSET_ATTR_SETNAME2]); 1076 1076 for (i = 0; i < inst->ip_set_max; i++) { 1077 - s = nfnl_set(inst, i); 1077 + s = ip_set(inst, i); 1078 1078 if (s != NULL && STREQ(s->name, name2)) { 1079 1079 ret = -IPSET_ERR_EXIST_SETNAME2; 1080 1080 goto out; ··· 1134 1134 1135 1135 write_lock_bh(&ip_set_ref_lock); 1136 1136 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; 1139 1139 write_unlock_bh(&ip_set_ref_lock); 1140 1140 1141 1141 return 0; ··· 1157 1157 struct ip_set_net *inst = (struct ip_set_net *)cb->args[IPSET_CB_NET]; 1158 1158 if (cb->args[IPSET_CB_ARG0]) { 1159 1159 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); 1161 1161 __ip_set_put_byindex(inst, 1162 1162 (ip_set_id_t) cb->args[IPSET_CB_INDEX]); 1163 1163 } ··· 1254 1254 dump_type, dump_flags, cb->args[IPSET_CB_INDEX]); 1255 1255 for (; cb->args[IPSET_CB_INDEX] < max; cb->args[IPSET_CB_INDEX]++) { 1256 1256 index = (ip_set_id_t) cb->args[IPSET_CB_INDEX]; 1257 - set = nfnl_set(inst, index); 1257 + set = ip_set(inst, index); 1258 1258 if (set == NULL) { 1259 1259 if (dump_type == DUMP_ONE) { 1260 1260 ret = -ENOENT; ··· 1332 1332 release_refcount: 1333 1333 /* If there was an error or set is done, release set */ 1334 1334 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); 1336 1336 __ip_set_put_byindex(inst, index); 1337 1337 cb->args[IPSET_CB_ARG0] = 0; 1338 1338 } ··· 1887 1887 find_set_and_id(inst, req_get->set.name, &id); 1888 1888 req_get->set.index = id; 1889 1889 if (id != IPSET_INVALID_ID) 1890 - req_get->family = nfnl_set(inst, id)->family; 1890 + req_get->family = ip_set(inst, id)->family; 1891 1891 nfnl_unlock(NFNL_SUBSYS_IPSET); 1892 1892 goto copy; 1893 1893 } ··· 1901 1901 goto done; 1902 1902 } 1903 1903 nfnl_lock(NFNL_SUBSYS_IPSET); 1904 - set = nfnl_set(inst, req_get->set.index); 1904 + set = ip_set(inst, req_get->set.index); 1905 1905 strncpy(req_get->set.name, set ? set->name : "", 1906 1906 IPSET_MAXNAMELEN); 1907 1907 nfnl_unlock(NFNL_SUBSYS_IPSET); ··· 1960 1960 inst->is_deleted = 1; /* flag for ip_set_nfnl_put */ 1961 1961 1962 1962 for (i = 0; i < inst->ip_set_max; i++) { 1963 - set = nfnl_set(inst, i); 1963 + set = ip_set(inst, i); 1964 1964 if (set != NULL) 1965 1965 ip_set_destroy_set(inst, i); 1966 1966 }