Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 2 | #ifndef __LINUX_MROUTE6_H |
| 3 | #define __LINUX_MROUTE6_H |
| 4 | |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 5 | |
David S. Miller | 7c19a3d | 2008-08-29 14:37:23 -0700 | [diff] [blame] | 6 | #include <linux/pim.h> |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 7 | #include <linux/skbuff.h> /* for struct sk_buff_head */ |
Benjamin Thery | bd91b8b | 2008-12-10 16:07:08 -0800 | [diff] [blame] | 8 | #include <net/net_namespace.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 9 | #include <uapi/linux/mroute6.h> |
Yuval Mintz | 6853f21 | 2018-02-28 23:29:29 +0200 | [diff] [blame] | 10 | #include <linux/mroute_base.h> |
Yuval Mintz | d3c07e5 | 2018-03-26 15:01:35 +0300 | [diff] [blame] | 11 | #include <net/fib_rules.h> |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 12 | |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 13 | #ifdef CONFIG_IPV6_MROUTE |
| 14 | static inline int ip6_mroute_opt(int opt) |
| 15 | { |
Nicolas Dichtel | bbb923a | 2013-01-21 06:00:25 +0000 | [diff] [blame] | 16 | return (opt >= MRT6_BASE) && (opt <= MRT6_MAX); |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 17 | } |
| 18 | #else |
| 19 | static inline int ip6_mroute_opt(int opt) |
| 20 | { |
| 21 | return 0; |
| 22 | } |
| 23 | #endif |
| 24 | |
| 25 | struct sock; |
| 26 | |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 27 | #ifdef CONFIG_IPV6_MROUTE |
David S. Miller | b705884 | 2009-09-30 16:12:20 -0700 | [diff] [blame] | 28 | extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 29 | extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); |
| 30 | extern int ip6_mr_input(struct sk_buff *skb); |
| 31 | extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); |
David S. Miller | e2d5776 | 2011-02-03 17:59:32 -0800 | [diff] [blame] | 32 | extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); |
Wang Chen | 623d1a1 | 2008-07-03 12:13:30 +0800 | [diff] [blame] | 33 | extern int ip6_mr_init(void); |
| 34 | extern void ip6_mr_cleanup(void); |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 35 | #else |
| 36 | static inline |
| 37 | int ip6_mroute_setsockopt(struct sock *sock, |
David S. Miller | b705884 | 2009-09-30 16:12:20 -0700 | [diff] [blame] | 38 | int optname, char __user *optval, unsigned int optlen) |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 39 | { |
| 40 | return -ENOPROTOOPT; |
| 41 | } |
| 42 | |
| 43 | static inline |
| 44 | int ip6_mroute_getsockopt(struct sock *sock, |
| 45 | int optname, char __user *optval, int __user *optlen) |
| 46 | { |
| 47 | return -ENOPROTOOPT; |
| 48 | } |
| 49 | |
| 50 | static inline |
| 51 | int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg) |
| 52 | { |
| 53 | return -ENOIOCTLCMD; |
| 54 | } |
| 55 | |
| 56 | static inline int ip6_mr_init(void) |
| 57 | { |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | static inline void ip6_mr_cleanup(void) |
| 62 | { |
| 63 | return; |
| 64 | } |
| 65 | #endif |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 66 | |
Yuval Mintz | d3c07e5 | 2018-03-26 15:01:35 +0300 | [diff] [blame] | 67 | #ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES |
| 68 | bool ip6mr_rule_default(const struct fib_rule *rule); |
| 69 | #else |
| 70 | static inline bool ip6mr_rule_default(const struct fib_rule *rule) |
| 71 | { |
| 72 | return true; |
| 73 | } |
| 74 | #endif |
| 75 | |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 76 | #define VIFF_STATIC 0x8000 |
| 77 | |
Yuval Mintz | 87c418b | 2018-02-28 23:29:31 +0200 | [diff] [blame] | 78 | struct mfc6_cache_cmp_arg { |
| 79 | struct in6_addr mf6c_mcastgrp; |
| 80 | struct in6_addr mf6c_origin; |
| 81 | }; |
| 82 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 83 | struct mfc6_cache { |
Yuval Mintz | 494fff5 | 2018-02-28 23:29:34 +0200 | [diff] [blame] | 84 | struct mr_mfc _c; |
Yuval Mintz | 87c418b | 2018-02-28 23:29:31 +0200 | [diff] [blame] | 85 | union { |
| 86 | struct { |
| 87 | struct in6_addr mf6c_mcastgrp; |
| 88 | struct in6_addr mf6c_origin; |
| 89 | }; |
| 90 | struct mfc6_cache_cmp_arg cmparg; |
| 91 | }; |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 92 | }; |
| 93 | |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 94 | #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */ |
| 95 | |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 96 | struct rtmsg; |
Benjamin Thery | 8229efd | 2008-12-10 16:30:15 -0800 | [diff] [blame] | 97 | extern int ip6mr_get_route(struct net *net, struct sk_buff *skb, |
David Ahern | fd61c6b | 2017-01-17 15:51:07 -0800 | [diff] [blame] | 98 | struct rtmsg *rtm, u32 portid); |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 99 | |
| 100 | #ifdef CONFIG_IPV6_MROUTE |
Yuval Mintz | 8571ab4 | 2018-02-28 23:29:30 +0200 | [diff] [blame] | 101 | bool mroute6_is_socket(struct net *net, struct sk_buff *skb); |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 102 | extern int ip6mr_sk_done(struct sock *sk); |
| 103 | #else |
Yuval Mintz | 8571ab4 | 2018-02-28 23:29:30 +0200 | [diff] [blame] | 104 | static inline bool mroute6_is_socket(struct net *net, struct sk_buff *skb) |
Patrick McHardy | d1db275 | 2010-05-11 14:40:55 +0200 | [diff] [blame] | 105 | { |
Yuval Mintz | 8571ab4 | 2018-02-28 23:29:30 +0200 | [diff] [blame] | 106 | return false; |
Patrick McHardy | d1db275 | 2010-05-11 14:40:55 +0200 | [diff] [blame] | 107 | } |
| 108 | static inline int ip6mr_sk_done(struct sock *sk) |
| 109 | { |
| 110 | return 0; |
| 111 | } |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 112 | #endif |
| 113 | #endif |