Blame view
net/ipv4/fib_notifier.c
1.56 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
c0243892c ipv4: fib: Move F... |
2 3 |
#include <linux/rtnetlink.h> #include <linux/notifier.h> |
04b1d4e50 net: core: Make t... |
4 |
#include <linux/socket.h> |
c0243892c ipv4: fib: Move F... |
5 |
#include <linux/kernel.h> |
864150dfa net: Add module r... |
6 |
#include <linux/export.h> |
c0243892c ipv4: fib: Move F... |
7 |
#include <net/net_namespace.h> |
04b1d4e50 net: core: Make t... |
8 |
#include <net/fib_notifier.h> |
c0243892c ipv4: fib: Move F... |
9 10 |
#include <net/netns/ipv4.h> #include <net/ip_fib.h> |
04b1d4e50 net: core: Make t... |
11 12 13 |
int call_fib4_notifier(struct notifier_block *nb, struct net *net, enum fib_event_type event_type, struct fib_notifier_info *info) |
c0243892c ipv4: fib: Move F... |
14 |
{ |
04b1d4e50 net: core: Make t... |
15 16 |
info->family = AF_INET; return call_fib_notifier(nb, net, event_type, info); |
c0243892c ipv4: fib: Move F... |
17 |
} |
04b1d4e50 net: core: Make t... |
18 19 |
int call_fib4_notifiers(struct net *net, enum fib_event_type event_type, struct fib_notifier_info *info) |
c0243892c ipv4: fib: Move F... |
20 |
{ |
04b1d4e50 net: core: Make t... |
21 22 23 |
ASSERT_RTNL(); info->family = AF_INET; |
c0243892c ipv4: fib: Move F... |
24 |
net->ipv4.fib_seq++; |
04b1d4e50 net: core: Make t... |
25 |
return call_fib_notifiers(net, event_type, info); |
c0243892c ipv4: fib: Move F... |
26 |
} |
04b1d4e50 net: core: Make t... |
27 |
static unsigned int fib4_seq_read(struct net *net) |
c0243892c ipv4: fib: Move F... |
28 |
{ |
04b1d4e50 net: core: Make t... |
29 |
ASSERT_RTNL(); |
c0243892c ipv4: fib: Move F... |
30 |
|
1b2a44408 net: fib_rules: I... |
31 |
return net->ipv4.fib_seq + fib4_rules_seq_read(net); |
c0243892c ipv4: fib: Move F... |
32 |
} |
04b1d4e50 net: core: Make t... |
33 |
static int fib4_dump(struct net *net, struct notifier_block *nb) |
c0243892c ipv4: fib: Move F... |
34 |
{ |
1b2a44408 net: fib_rules: I... |
35 36 37 38 39 |
int err; err = fib4_rules_dump(net, nb); if (err) return err; |
04b1d4e50 net: core: Make t... |
40 41 42 |
fib_notify(net, nb); return 0; |
c0243892c ipv4: fib: Move F... |
43 |
} |
04b1d4e50 net: core: Make t... |
44 45 46 47 |
static const struct fib_notifier_ops fib4_notifier_ops_template = { .family = AF_INET, .fib_seq_read = fib4_seq_read, .fib_dump = fib4_dump, |
864150dfa net: Add module r... |
48 |
.owner = THIS_MODULE, |
04b1d4e50 net: core: Make t... |
49 |
}; |
c0243892c ipv4: fib: Move F... |
50 |
|
04b1d4e50 net: core: Make t... |
51 52 53 |
int __net_init fib4_notifier_init(struct net *net) { struct fib_notifier_ops *ops; |
c0243892c ipv4: fib: Move F... |
54 |
|
04b1d4e50 net: core: Make t... |
55 |
net->ipv4.fib_seq = 0; |
c0243892c ipv4: fib: Move F... |
56 |
|
04b1d4e50 net: core: Make t... |
57 58 59 60 |
ops = fib_notifier_ops_register(&fib4_notifier_ops_template, net); if (IS_ERR(ops)) return PTR_ERR(ops); net->ipv4.notifier_ops = ops; |
c0243892c ipv4: fib: Move F... |
61 |
|
04b1d4e50 net: core: Make t... |
62 |
return 0; |
c0243892c ipv4: fib: Move F... |
63 |
} |
c0243892c ipv4: fib: Move F... |
64 |
|
04b1d4e50 net: core: Make t... |
65 |
void __net_exit fib4_notifier_exit(struct net *net) |
c0243892c ipv4: fib: Move F... |
66 |
{ |
04b1d4e50 net: core: Make t... |
67 |
fib_notifier_ops_unregister(net->ipv4.notifier_ops); |
c0243892c ipv4: fib: Move F... |
68 |
} |