LCOV - code coverage report
Current view: top level - net/ipv4 - fib_notifier.c (source / functions) Hit Total Coverage
Test: gcov_data_raspi2_real_modules_combined.info Lines: 11 26 42.3 %
Date: 2020-09-30 20:25:40 Functions: 2 6 33.3 %
Branches: 2 12 16.7 %

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

Generated by: LCOV version 1.14