rxrpc: Show some more information through /proc files
[linux/fpc-iii.git] / net / ipv4 / fib_notifier.c
blobb804ccbdb241e6a801ae29cf0664c6a23c0c8d48
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/rtnetlink.h>
3 #include <linux/notifier.h>
4 #include <linux/socket.h>
5 #include <linux/kernel.h>
6 #include <linux/export.h>
7 #include <net/net_namespace.h>
8 #include <net/fib_notifier.h>
9 #include <net/netns/ipv4.h>
10 #include <net/ip_fib.h>
12 int call_fib4_notifier(struct notifier_block *nb, struct net *net,
13 enum fib_event_type event_type,
14 struct fib_notifier_info *info)
16 info->family = AF_INET;
17 return call_fib_notifier(nb, net, event_type, info);
20 int call_fib4_notifiers(struct net *net, enum fib_event_type event_type,
21 struct fib_notifier_info *info)
23 ASSERT_RTNL();
25 info->family = AF_INET;
26 net->ipv4.fib_seq++;
27 return call_fib_notifiers(net, event_type, info);
30 static unsigned int fib4_seq_read(struct net *net)
32 ASSERT_RTNL();
34 return net->ipv4.fib_seq + fib4_rules_seq_read(net);
37 static int fib4_dump(struct net *net, struct notifier_block *nb)
39 int err;
41 err = fib4_rules_dump(net, nb);
42 if (err)
43 return err;
45 fib_notify(net, nb);
47 return 0;
50 static const struct fib_notifier_ops fib4_notifier_ops_template = {
51 .family = AF_INET,
52 .fib_seq_read = fib4_seq_read,
53 .fib_dump = fib4_dump,
54 .owner = THIS_MODULE,
57 int __net_init fib4_notifier_init(struct net *net)
59 struct fib_notifier_ops *ops;
61 net->ipv4.fib_seq = 0;
63 ops = fib_notifier_ops_register(&fib4_notifier_ops_template, net);
64 if (IS_ERR(ops))
65 return PTR_ERR(ops);
66 net->ipv4.notifier_ops = ops;
68 return 0;
71 void __net_exit fib4_notifier_exit(struct net *net)
73 fib_notifier_ops_unregister(net->ipv4.notifier_ops);