2017-08-03 11:28:16 +00:00
|
|
|
#include <linux/notifier.h>
|
|
|
|
#include <linux/socket.h>
|
|
|
|
#include <linux/kernel.h>
|
2017-09-01 09:15:17 +00:00
|
|
|
#include <linux/export.h>
|
2017-08-03 11:28:16 +00:00
|
|
|
#include <net/net_namespace.h>
|
|
|
|
#include <net/fib_notifier.h>
|
|
|
|
#include <net/netns/ipv6.h>
|
|
|
|
#include <net/ip6_fib.h>
|
|
|
|
|
2019-10-03 09:49:27 +00:00
|
|
|
int call_fib6_notifier(struct notifier_block *nb,
|
2017-08-03 11:28:16 +00:00
|
|
|
enum fib_event_type event_type,
|
|
|
|
struct fib_notifier_info *info)
|
|
|
|
{
|
|
|
|
info->family = AF_INET6;
|
2019-10-03 09:49:27 +00:00
|
|
|
return call_fib_notifier(nb, event_type, info);
|
2017-08-03 11:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int call_fib6_notifiers(struct net *net, enum fib_event_type event_type,
|
|
|
|
struct fib_notifier_info *info)
|
|
|
|
{
|
|
|
|
info->family = AF_INET6;
|
|
|
|
return call_fib_notifiers(net, event_type, info);
|
|
|
|
}
|
|
|
|
|
2024-10-09 18:44:05 +00:00
|
|
|
static unsigned int fib6_seq_read(const struct net *net)
|
2017-08-03 11:28:16 +00:00
|
|
|
{
|
2017-08-03 11:28:19 +00:00
|
|
|
return fib6_tables_seq_read(net) + fib6_rules_seq_read(net);
|
2017-08-03 11:28:16 +00:00
|
|
|
}
|
|
|
|
|
2019-10-03 09:49:30 +00:00
|
|
|
static int fib6_dump(struct net *net, struct notifier_block *nb,
|
|
|
|
struct netlink_ext_ack *extack)
|
2017-08-03 11:28:16 +00:00
|
|
|
{
|
2017-08-03 11:28:19 +00:00
|
|
|
int err;
|
|
|
|
|
2019-10-03 09:49:30 +00:00
|
|
|
err = fib6_rules_dump(net, nb, extack);
|
2017-08-03 11:28:19 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2019-10-03 09:49:30 +00:00
|
|
|
return fib6_tables_dump(net, nb, extack);
|
2017-08-03 11:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct fib_notifier_ops fib6_notifier_ops_template = {
|
|
|
|
.family = AF_INET6,
|
|
|
|
.fib_seq_read = fib6_seq_read,
|
|
|
|
.fib_dump = fib6_dump,
|
2017-09-01 09:15:17 +00:00
|
|
|
.owner = THIS_MODULE,
|
2017-08-03 11:28:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int __net_init fib6_notifier_init(struct net *net)
|
|
|
|
{
|
|
|
|
struct fib_notifier_ops *ops;
|
|
|
|
|
|
|
|
ops = fib_notifier_ops_register(&fib6_notifier_ops_template, net);
|
|
|
|
if (IS_ERR(ops))
|
|
|
|
return PTR_ERR(ops);
|
|
|
|
net->ipv6.notifier_ops = ops;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __net_exit fib6_notifier_exit(struct net *net)
|
|
|
|
{
|
|
|
|
fib_notifier_ops_unregister(net->ipv6.notifier_ops);
|
|
|
|
}
|