Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <net/net_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <net/fib_notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <net/netns/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <net/ip6_fib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) int call_fib6_notifier(struct notifier_block *nb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 		       enum fib_event_type event_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 		       struct fib_notifier_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	info->family = AF_INET6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	return call_fib_notifier(nb, event_type, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) int call_fib6_notifiers(struct net *net, enum fib_event_type event_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 			struct fib_notifier_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	info->family = AF_INET6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	return call_fib_notifiers(net, event_type, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static unsigned int fib6_seq_read(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	return fib6_tables_seq_read(net) + fib6_rules_seq_read(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static int fib6_dump(struct net *net, struct notifier_block *nb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		     struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	err = fib6_rules_dump(net, nb, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	return fib6_tables_dump(net, nb, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static const struct fib_notifier_ops fib6_notifier_ops_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	.family		= AF_INET6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	.fib_seq_read	= fib6_seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	.fib_dump	= fib6_dump,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int __net_init fib6_notifier_init(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	struct fib_notifier_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	ops = fib_notifier_ops_register(&fib6_notifier_ops_template, net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	if (IS_ERR(ops))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		return PTR_ERR(ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	net->ipv6.notifier_ops = ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void __net_exit fib6_notifier_exit(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	fib_notifier_ops_unregister(net->ipv6.notifier_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }