Commit 58c77bf1 authored by David S. Miller's avatar David S. Miller

Merge branch 'ila-Cleanup'

Tom Herbert says:

====================
ila: Cleanup

Perform some cleanup in ILA code. This includes:

- Fix rhashtable walk for cases where nl dumps are done with muliple
  function calls. Add a skip index to skip over entries in
  a node that have been previously visitied. Call rhashtable_walk_peek
  to avoid dropping items between calls to ila_nl_dump.
- Call alloc_bucket_spinlocks to create bucket locks.
- Split out module initialization and netlink definitions into
  separate files.
- Add ILA_CMD_FLUSH netlink command to clear the ILA translation table.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 6d268910 b6e71bde
......@@ -30,6 +30,7 @@ enum {
ILA_CMD_ADD,
ILA_CMD_DEL,
ILA_CMD_GET,
ILA_CMD_FLUSH,
__ILA_CMD_MAX,
};
......
......@@ -4,4 +4,4 @@
obj-$(CONFIG_IPV6_ILA) += ila.o
ila-objs := ila_common.o ila_lwt.o ila_xlat.o
ila-objs := ila_main.o ila_common.o ila_lwt.o ila_xlat.o
......@@ -19,6 +19,7 @@
#include <linux/skbuff.h>
#include <linux/types.h>
#include <net/checksum.h>
#include <net/genetlink.h>
#include <net/ip.h>
#include <net/protocol.h>
#include <uapi/linux/ila.h>
......@@ -104,9 +105,31 @@ void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p,
void ila_init_saved_csum(struct ila_params *p);
struct ila_net {
struct {
struct rhashtable rhash_table;
spinlock_t *locks; /* Bucket locks for entry manipulation */
unsigned int locks_mask;
bool hooks_registered;
} xlat;
};
int ila_lwt_init(void);
void ila_lwt_fini(void);
int ila_xlat_init(void);
void ila_xlat_fini(void);
int ila_xlat_init_net(struct net *net);
void ila_xlat_exit_net(struct net *net);
int ila_xlat_nl_cmd_add_mapping(struct sk_buff *skb, struct genl_info *info);
int ila_xlat_nl_cmd_del_mapping(struct sk_buff *skb, struct genl_info *info);
int ila_xlat_nl_cmd_get_mapping(struct sk_buff *skb, struct genl_info *info);
int ila_xlat_nl_cmd_flush(struct sk_buff *skb, struct genl_info *info);
int ila_xlat_nl_dump_start(struct netlink_callback *cb);
int ila_xlat_nl_dump_done(struct netlink_callback *cb);
int ila_xlat_nl_dump(struct sk_buff *skb, struct netlink_callback *cb);
extern unsigned int ila_net_id;
extern struct genl_family ila_nl_family;
#endif /* __ILA_H */
......@@ -154,33 +154,3 @@ void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p,
iaddr->loc = p->locator;
}
static int __init ila_init(void)
{
int ret;
ret = ila_lwt_init();
if (ret)
goto fail_lwt;
ret = ila_xlat_init();
if (ret)
goto fail_xlat;
return 0;
fail_xlat:
ila_lwt_fini();
fail_lwt:
return ret;
}
static void __exit ila_fini(void)
{
ila_xlat_fini();
ila_lwt_fini();
}
module_init(ila_init);
module_exit(ila_fini);
MODULE_AUTHOR("Tom Herbert <tom@herbertland.com>");
MODULE_LICENSE("GPL");
// SPDX-License-Identifier: GPL-2.0
#include <net/genetlink.h>
#include <net/ila.h>
#include <net/netns/generic.h>
#include <uapi/linux/genetlink.h>
#include "ila.h"
static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = {
[ILA_ATTR_LOCATOR] = { .type = NLA_U64, },
[ILA_ATTR_LOCATOR_MATCH] = { .type = NLA_U64, },
[ILA_ATTR_IFINDEX] = { .type = NLA_U32, },
[ILA_ATTR_CSUM_MODE] = { .type = NLA_U8, },
[ILA_ATTR_IDENT_TYPE] = { .type = NLA_U8, },
};
static const struct genl_ops ila_nl_ops[] = {
{
.cmd = ILA_CMD_ADD,
.doit = ila_xlat_nl_cmd_add_mapping,
.policy = ila_nl_policy,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = ILA_CMD_DEL,
.doit = ila_xlat_nl_cmd_del_mapping,
.policy = ila_nl_policy,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = ILA_CMD_FLUSH,
.doit = ila_xlat_nl_cmd_flush,
.policy = ila_nl_policy,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = ILA_CMD_GET,
.doit = ila_xlat_nl_cmd_get_mapping,
.start = ila_xlat_nl_dump_start,
.dumpit = ila_xlat_nl_dump,
.done = ila_xlat_nl_dump_done,
.policy = ila_nl_policy,
},
};
unsigned int ila_net_id;
struct genl_family ila_nl_family __ro_after_init = {
.hdrsize = 0,
.name = ILA_GENL_NAME,
.version = ILA_GENL_VERSION,
.maxattr = ILA_ATTR_MAX,
.netnsok = true,
.parallel_ops = true,
.module = THIS_MODULE,
.ops = ila_nl_ops,
.n_ops = ARRAY_SIZE(ila_nl_ops),
};
static __net_init int ila_init_net(struct net *net)
{
int err;
err = ila_xlat_init_net(net);
if (err)
goto ila_xlat_init_fail;
return 0;
ila_xlat_init_fail:
return err;
}
static __net_exit void ila_exit_net(struct net *net)
{
ila_xlat_exit_net(net);
}
static struct pernet_operations ila_net_ops = {
.init = ila_init_net,
.exit = ila_exit_net,
.id = &ila_net_id,
.size = sizeof(struct ila_net),
};
static int __init ila_init(void)
{
int ret;
ret = register_pernet_device(&ila_net_ops);
if (ret)
goto register_device_fail;
ret = genl_register_family(&ila_nl_family);
if (ret)
goto register_family_fail;
ret = ila_lwt_init();
if (ret)
goto fail_lwt;
return 0;
fail_lwt:
genl_unregister_family(&ila_nl_family);
register_family_fail:
unregister_pernet_device(&ila_net_ops);
register_device_fail:
return ret;
}
static void __exit ila_fini(void)
{
ila_lwt_fini();
genl_unregister_family(&ila_nl_family);
unregister_pernet_device(&ila_net_ops);
}
module_init(ila_init);
module_exit(ila_fini);
MODULE_AUTHOR("Tom Herbert <tom@herbertland.com>");
MODULE_LICENSE("GPL");
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment