~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/ipv4/fib_notifier.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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/ip_fib.h>
 10 
 11 int call_fib4_notifier(struct notifier_block *nb,
 12                        enum fib_event_type event_type,
 13                        struct fib_notifier_info *info)
 14 {
 15         info->family = AF_INET;
 16         return call_fib_notifier(nb, event_type, info);
 17 }
 18 
 19 int call_fib4_notifiers(struct net *net, enum fib_event_type event_type,
 20                         struct fib_notifier_info *info)
 21 {
 22         ASSERT_RTNL();
 23 
 24         info->family = AF_INET;
 25         net->ipv4.fib_seq++;
 26         return call_fib_notifiers(net, event_type, info);
 27 }
 28 
 29 static unsigned int fib4_seq_read(struct net *net)
 30 {
 31         ASSERT_RTNL();
 32 
 33         return net->ipv4.fib_seq + fib4_rules_seq_read(net);
 34 }
 35 
 36 static int fib4_dump(struct net *net, struct notifier_block *nb,
 37                      struct netlink_ext_ack *extack)
 38 {
 39         int err;
 40 
 41         err = fib4_rules_dump(net, nb, extack);
 42         if (err)
 43                 return err;
 44 
 45         return fib_notify(net, nb, extack);
 46 }
 47 
 48 static const struct fib_notifier_ops fib4_notifier_ops_template = {
 49         .family         = AF_INET,
 50         .fib_seq_read   = fib4_seq_read,
 51         .fib_dump       = fib4_dump,
 52         .owner          = THIS_MODULE,
 53 };
 54 
 55 int __net_init fib4_notifier_init(struct net *net)
 56 {
 57         struct fib_notifier_ops *ops;
 58 
 59         net->ipv4.fib_seq = 0;
 60 
 61         ops = fib_notifier_ops_register(&fib4_notifier_ops_template, net);
 62         if (IS_ERR(ops))
 63                 return PTR_ERR(ops);
 64         net->ipv4.notifier_ops = ops;
 65 
 66         return 0;
 67 }
 68 
 69 void __net_exit fib4_notifier_exit(struct net *net)
 70 {
 71         fib_notifier_ops_unregister(net->ipv4.notifier_ops);
 72 }
 73 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php