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

netfilter: introduce nf_conntrack_helper_put helper function

And convert module_put invocation to nf_conntrack_helper_put, this is
prepared for the followup patch, which will add a refcnt for cthelper,
so we can reject the deleting request when cthelper is in use.

Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Liping Zhang and committed by
Pablo Neira Ayuso
d91fc59c d110a394

+15 -7
+2
include/net/netfilter/nf_conntrack_helper.h
··· 79 79 struct nf_conntrack_helper *nf_conntrack_helper_try_module_get(const char *name, 80 80 u16 l3num, 81 81 u8 protonum); 82 + void nf_conntrack_helper_put(struct nf_conntrack_helper *helper); 83 + 82 84 void nf_ct_helper_init(struct nf_conntrack_helper *helper, 83 85 u16 l3num, u16 protonum, const char *name, 84 86 u16 default_port, u16 spec_port, u32 id,
+6
net/netfilter/nf_conntrack_helper.c
··· 181 181 } 182 182 EXPORT_SYMBOL_GPL(nf_conntrack_helper_try_module_get); 183 183 184 + void nf_conntrack_helper_put(struct nf_conntrack_helper *helper) 185 + { 186 + module_put(helper->me); 187 + } 188 + EXPORT_SYMBOL_GPL(nf_conntrack_helper_put); 189 + 184 190 struct nf_conn_help * 185 191 nf_ct_helper_ext_add(struct nf_conn *ct, 186 192 struct nf_conntrack_helper *helper, gfp_t gfp)
+2 -2
net/netfilter/nft_ct.c
··· 826 826 struct nft_ct_helper_obj *priv = nft_obj_data(obj); 827 827 828 828 if (priv->helper4) 829 - module_put(priv->helper4->me); 829 + nf_conntrack_helper_put(priv->helper4); 830 830 if (priv->helper6) 831 - module_put(priv->helper6->me); 831 + nf_conntrack_helper_put(priv->helper6); 832 832 } 833 833 834 834 static void nft_ct_helper_obj_eval(struct nft_object *obj,
+3 -3
net/netfilter/xt_CT.c
··· 96 96 97 97 help = nf_ct_helper_ext_add(ct, helper, GFP_KERNEL); 98 98 if (help == NULL) { 99 - module_put(helper->me); 99 + nf_conntrack_helper_put(helper); 100 100 return -ENOMEM; 101 101 } 102 102 ··· 263 263 err4: 264 264 help = nfct_help(ct); 265 265 if (help) 266 - module_put(help->helper->me); 266 + nf_conntrack_helper_put(help->helper); 267 267 err3: 268 268 nf_ct_tmpl_free(ct); 269 269 err2: ··· 346 346 if (ct) { 347 347 help = nfct_help(ct); 348 348 if (help) 349 - module_put(help->helper->me); 349 + nf_conntrack_helper_put(help->helper); 350 350 351 351 nf_ct_netns_put(par->net, par->family); 352 352
+2 -2
net/openvswitch/conntrack.c
··· 1123 1123 1124 1124 help = nf_ct_helper_ext_add(info->ct, helper, GFP_KERNEL); 1125 1125 if (!help) { 1126 - module_put(helper->me); 1126 + nf_conntrack_helper_put(helper); 1127 1127 return -ENOMEM; 1128 1128 } 1129 1129 ··· 1584 1584 static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info) 1585 1585 { 1586 1586 if (ct_info->helper) 1587 - module_put(ct_info->helper->me); 1587 + nf_conntrack_helper_put(ct_info->helper); 1588 1588 if (ct_info->ct) 1589 1589 nf_ct_tmpl_free(ct_info->ct); 1590 1590 }