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

Configure Feed

Select the types of activity you want to include in your feed.

net: move add ct helper function to nf_conntrack_helper for ovs and tc

Move ovs_ct_add_helper from openvswitch to nf_conntrack_helper and
rename as nf_ct_add_helper, so that it can be used in TC act_ct in
the next patch.

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Xin Long and committed by
Paolo Abeni
f96cba2e ca71277f

+38 -39
+2
include/net/netfilter/nf_conntrack_helper.h
··· 117 117 118 118 int nf_ct_helper(struct sk_buff *skb, struct nf_conn *ct, 119 119 enum ip_conntrack_info ctinfo, u16 proto); 120 + int nf_ct_add_helper(struct nf_conn *ct, const char *name, u8 family, 121 + u8 proto, bool nat, struct nf_conntrack_helper **hp); 120 122 121 123 void nf_ct_helper_destroy(struct nf_conn *ct); 122 124
+31
net/netfilter/nf_conntrack_helper.c
··· 309 309 } 310 310 EXPORT_SYMBOL_GPL(nf_ct_helper); 311 311 312 + int nf_ct_add_helper(struct nf_conn *ct, const char *name, u8 family, 313 + u8 proto, bool nat, struct nf_conntrack_helper **hp) 314 + { 315 + struct nf_conntrack_helper *helper; 316 + struct nf_conn_help *help; 317 + int ret = 0; 318 + 319 + helper = nf_conntrack_helper_try_module_get(name, family, proto); 320 + if (!helper) 321 + return -EINVAL; 322 + 323 + help = nf_ct_helper_ext_add(ct, GFP_KERNEL); 324 + if (!help) { 325 + nf_conntrack_helper_put(helper); 326 + return -ENOMEM; 327 + } 328 + #if IS_ENABLED(CONFIG_NF_NAT) 329 + if (nat) { 330 + ret = nf_nat_helper_try_module_get(name, family, proto); 331 + if (ret) { 332 + nf_conntrack_helper_put(helper); 333 + return ret; 334 + } 335 + } 336 + #endif 337 + rcu_assign_pointer(help->helper, helper); 338 + *hp = helper; 339 + return ret; 340 + } 341 + EXPORT_SYMBOL_GPL(nf_ct_add_helper); 342 + 312 343 /* appropriate ct lock protecting must be taken by caller */ 313 344 static int unhelp(struct nf_conn *ct, void *me) 314 345 {
+5 -39
net/openvswitch/conntrack.c
··· 1291 1291 return 0; 1292 1292 } 1293 1293 1294 - static int ovs_ct_add_helper(struct ovs_conntrack_info *info, const char *name, 1295 - const struct sw_flow_key *key, bool log) 1296 - { 1297 - struct nf_conntrack_helper *helper; 1298 - struct nf_conn_help *help; 1299 - int ret = 0; 1300 - 1301 - helper = nf_conntrack_helper_try_module_get(name, info->family, 1302 - key->ip.proto); 1303 - if (!helper) { 1304 - OVS_NLERR(log, "Unknown helper \"%s\"", name); 1305 - return -EINVAL; 1306 - } 1307 - 1308 - help = nf_ct_helper_ext_add(info->ct, GFP_KERNEL); 1309 - if (!help) { 1310 - nf_conntrack_helper_put(helper); 1311 - return -ENOMEM; 1312 - } 1313 - 1314 - #if IS_ENABLED(CONFIG_NF_NAT) 1315 - if (info->nat) { 1316 - ret = nf_nat_helper_try_module_get(name, info->family, 1317 - key->ip.proto); 1318 - if (ret) { 1319 - nf_conntrack_helper_put(helper); 1320 - OVS_NLERR(log, "Failed to load \"%s\" NAT helper, error: %d", 1321 - name, ret); 1322 - return ret; 1323 - } 1324 - } 1325 - #endif 1326 - rcu_assign_pointer(help->helper, helper); 1327 - info->helper = helper; 1328 - return ret; 1329 - } 1330 - 1331 1294 #if IS_ENABLED(CONFIG_NF_NAT) 1332 1295 static int parse_nat(const struct nlattr *attr, 1333 1296 struct ovs_conntrack_info *info, bool log) ··· 1624 1661 } 1625 1662 1626 1663 if (helper) { 1627 - err = ovs_ct_add_helper(&ct_info, helper, key, log); 1628 - if (err) 1664 + err = nf_ct_add_helper(ct_info.ct, helper, ct_info.family, 1665 + key->ip.proto, ct_info.nat, &ct_info.helper); 1666 + if (err) { 1667 + OVS_NLERR(log, "Failed to add %s helper %d", helper, err); 1629 1668 goto err_free_ct; 1669 + } 1630 1670 } 1631 1671 1632 1672 err = ovs_nla_add_action(sfa, OVS_ACTION_ATTR_CT, &ct_info,