Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef __LINUX_MROUTE_H |
| 3 | #define __LINUX_MROUTE_H |
| 4 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/in.h> |
David S. Miller | 7c19a3d | 2008-08-29 14:37:23 -0700 | [diff] [blame] | 6 | #include <linux/pim.h> |
Yotam Gigi | 478e4c2 | 2017-09-27 08:23:16 +0200 | [diff] [blame] | 7 | #include <net/fib_rules.h> |
Yotam Gigi | 4d65b94 | 2017-09-27 08:23:13 +0200 | [diff] [blame] | 8 | #include <net/fib_notifier.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 9 | #include <uapi/linux/mroute.h> |
Yuval Mintz | 6853f21 | 2018-02-28 23:29:29 +0200 | [diff] [blame] | 10 | #include <linux/mroute_base.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Pavel Emelyanov | 6a9fb94 | 2007-11-05 21:32:31 -0800 | [diff] [blame] | 12 | #ifdef CONFIG_IP_MROUTE |
| 13 | static inline int ip_mroute_opt(int opt) |
| 14 | { |
Nikolay Aleksandrov | 520191b | 2015-11-26 15:23:46 +0100 | [diff] [blame] | 15 | return opt >= MRT_BASE && opt <= MRT_MAX; |
Pavel Emelyanov | 6a9fb94 | 2007-11-05 21:32:31 -0800 | [diff] [blame] | 16 | } |
Pavel Emelyanov | 6a9fb94 | 2007-11-05 21:32:31 -0800 | [diff] [blame] | 17 | |
Nikolay Aleksandrov | 520191b | 2015-11-26 15:23:46 +0100 | [diff] [blame] | 18 | int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); |
| 19 | int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); |
| 20 | int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); |
| 21 | int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); |
| 22 | int ip_mr_init(void); |
Yotam Gigi | 478e4c2 | 2017-09-27 08:23:16 +0200 | [diff] [blame] | 23 | bool ipmr_rule_default(const struct fib_rule *rule); |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 24 | #else |
Nikolay Aleksandrov | 520191b | 2015-11-26 15:23:46 +0100 | [diff] [blame] | 25 | static inline int ip_mroute_setsockopt(struct sock *sock, int optname, |
| 26 | char __user *optval, unsigned int optlen) |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 27 | { |
| 28 | return -ENOPROTOOPT; |
| 29 | } |
| 30 | |
Nikolay Aleksandrov | 520191b | 2015-11-26 15:23:46 +0100 | [diff] [blame] | 31 | static inline int ip_mroute_getsockopt(struct sock *sock, int optname, |
| 32 | char __user *optval, int __user *optlen) |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 33 | { |
| 34 | return -ENOPROTOOPT; |
| 35 | } |
| 36 | |
Nikolay Aleksandrov | 520191b | 2015-11-26 15:23:46 +0100 | [diff] [blame] | 37 | static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 38 | { |
| 39 | return -ENOIOCTLCMD; |
| 40 | } |
| 41 | |
| 42 | static inline int ip_mr_init(void) |
| 43 | { |
| 44 | return 0; |
| 45 | } |
Nikolay Aleksandrov | 520191b | 2015-11-26 15:23:46 +0100 | [diff] [blame] | 46 | |
| 47 | static inline int ip_mroute_opt(int opt) |
| 48 | { |
| 49 | return 0; |
| 50 | } |
Yotam Gigi | 478e4c2 | 2017-09-27 08:23:16 +0200 | [diff] [blame] | 51 | |
| 52 | static inline bool ipmr_rule_default(const struct fib_rule *rule) |
| 53 | { |
| 54 | return true; |
| 55 | } |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 56 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #define VIFF_STATIC 0x8000 |
| 59 | |
Nikolay Aleksandrov | 8fb472c | 2017-01-12 15:53:33 +0100 | [diff] [blame] | 60 | struct mfc_cache_cmp_arg { |
| 61 | __be32 mfc_mcastgrp; |
| 62 | __be32 mfc_origin; |
| 63 | }; |
| 64 | |
| 65 | /** |
| 66 | * struct mfc_cache - multicast routing entries |
Yuval Mintz | 494fff5 | 2018-02-28 23:29:34 +0200 | [diff] [blame] | 67 | * @_c: Common multicast routing information; has to be first [for casting] |
Nikolay Aleksandrov | 8fb472c | 2017-01-12 15:53:33 +0100 | [diff] [blame] | 68 | * @mfc_mcastgrp: destination multicast group address |
| 69 | * @mfc_origin: source address |
| 70 | * @cmparg: used for rhashtable comparisons |
Nikolay Aleksandrov | 8fb472c | 2017-01-12 15:53:33 +0100 | [diff] [blame] | 71 | */ |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 72 | struct mfc_cache { |
Yuval Mintz | 494fff5 | 2018-02-28 23:29:34 +0200 | [diff] [blame] | 73 | struct mr_mfc _c; |
Nikolay Aleksandrov | 8fb472c | 2017-01-12 15:53:33 +0100 | [diff] [blame] | 74 | union { |
| 75 | struct { |
| 76 | __be32 mfc_mcastgrp; |
| 77 | __be32 mfc_origin; |
| 78 | }; |
| 79 | struct mfc_cache_cmp_arg cmparg; |
| 80 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | struct rtmsg; |
Nikolay Aleksandrov | 520191b | 2015-11-26 15:23:46 +0100 | [diff] [blame] | 84 | int ipmr_get_route(struct net *net, struct sk_buff *skb, |
| 85 | __be32 saddr, __be32 daddr, |
David Ahern | 9f09eae | 2017-01-06 17:39:06 -0800 | [diff] [blame] | 86 | struct rtmsg *rtm, u32 portid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | #endif |