forked from Minki/linux
dcb18f762f
Allow users of the FIB notification chain to receive a complete view of the IPv6 FIB rules upon registration to the chain. The integrity of the dump is ensured by a per-family sequence counter that is incremented (under RTNL) whenever a rule is added or deleted. All the sequence counters are read (under RTNL) and summed, prior and after the dump. In case the counters differ, then the dump is either restarted or the registration fails. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
56 lines
1.3 KiB
C
56 lines
1.3 KiB
C
#include <linux/notifier.h>
|
|
#include <linux/socket.h>
|
|
#include <linux/kernel.h>
|
|
#include <net/net_namespace.h>
|
|
#include <net/fib_notifier.h>
|
|
#include <net/netns/ipv6.h>
|
|
#include <net/ip6_fib.h>
|
|
|
|
int call_fib6_notifier(struct notifier_block *nb, struct net *net,
|
|
enum fib_event_type event_type,
|
|
struct fib_notifier_info *info)
|
|
{
|
|
info->family = AF_INET6;
|
|
return call_fib_notifier(nb, net, event_type, info);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
static unsigned int fib6_seq_read(struct net *net)
|
|
{
|
|
return fib6_rules_seq_read(net);
|
|
}
|
|
|
|
static int fib6_dump(struct net *net, struct notifier_block *nb)
|
|
{
|
|
return fib6_rules_dump(net, nb);
|
|
}
|
|
|
|
static const struct fib_notifier_ops fib6_notifier_ops_template = {
|
|
.family = AF_INET6,
|
|
.fib_seq_read = fib6_seq_read,
|
|
.fib_dump = fib6_dump,
|
|
};
|
|
|
|
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);
|
|
}
|