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> |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 10 | |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 11 | #ifdef CONFIG_IPV6_MROUTE |
| 12 | static inline int ip6_mroute_opt(int opt) |
| 13 | { |
Nicolas Dichtel | bbb923a | 2013-01-21 06:00:25 +0000 | [diff] [blame] | 14 | return (opt >= MRT6_BASE) && (opt <= MRT6_MAX); |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 15 | } |
| 16 | #else |
| 17 | static inline int ip6_mroute_opt(int opt) |
| 18 | { |
| 19 | return 0; |
| 20 | } |
| 21 | #endif |
| 22 | |
| 23 | struct sock; |
| 24 | |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 25 | #ifdef CONFIG_IPV6_MROUTE |
David S. Miller | b705884 | 2009-09-30 16:12:20 -0700 | [diff] [blame] | 26 | extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 27 | extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); |
| 28 | extern int ip6_mr_input(struct sk_buff *skb); |
| 29 | 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] | 30 | 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] | 31 | extern int ip6_mr_init(void); |
| 32 | extern void ip6_mr_cleanup(void); |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 33 | #else |
| 34 | static inline |
| 35 | int ip6_mroute_setsockopt(struct sock *sock, |
David S. Miller | b705884 | 2009-09-30 16:12:20 -0700 | [diff] [blame] | 36 | int optname, char __user *optval, unsigned int optlen) |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 37 | { |
| 38 | return -ENOPROTOOPT; |
| 39 | } |
| 40 | |
| 41 | static inline |
| 42 | int ip6_mroute_getsockopt(struct sock *sock, |
| 43 | int optname, char __user *optval, int __user *optlen) |
| 44 | { |
| 45 | return -ENOPROTOOPT; |
| 46 | } |
| 47 | |
| 48 | static inline |
| 49 | int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg) |
| 50 | { |
| 51 | return -ENOIOCTLCMD; |
| 52 | } |
| 53 | |
| 54 | static inline int ip6_mr_init(void) |
| 55 | { |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | static inline void ip6_mr_cleanup(void) |
| 60 | { |
| 61 | return; |
| 62 | } |
| 63 | #endif |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 64 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 65 | struct mif_device { |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 66 | struct net_device *dev; /* Device we are using */ |
| 67 | unsigned long bytes_in,bytes_out; |
| 68 | unsigned long pkt_in,pkt_out; /* Statistics */ |
| 69 | unsigned long rate_limit; /* Traffic shaping (NI) */ |
| 70 | unsigned char threshold; /* TTL threshold */ |
| 71 | unsigned short flags; /* Control flags */ |
| 72 | int link; /* Physical interface index */ |
| 73 | }; |
| 74 | |
| 75 | #define VIFF_STATIC 0x8000 |
| 76 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 77 | struct mfc6_cache { |
Patrick McHardy | f30a7784 | 2010-05-11 14:40:51 +0200 | [diff] [blame] | 78 | struct list_head list; |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 79 | struct in6_addr mf6c_mcastgrp; /* Group the entry belongs to */ |
| 80 | struct in6_addr mf6c_origin; /* Source of packet */ |
| 81 | mifi_t mf6c_parent; /* Source interface */ |
| 82 | int mfc_flags; /* Flags on line */ |
| 83 | |
| 84 | union { |
| 85 | struct { |
| 86 | unsigned long expires; |
| 87 | struct sk_buff_head unresolved; /* Unresolved buffers */ |
| 88 | } unres; |
| 89 | struct { |
| 90 | unsigned long last_assert; |
| 91 | int minvif; |
| 92 | int maxvif; |
| 93 | unsigned long bytes; |
| 94 | unsigned long pkt; |
| 95 | unsigned long wrong_if; |
Nikolay Aleksandrov | 43b9e12 | 2016-07-14 19:28:27 +0300 | [diff] [blame] | 96 | unsigned long lastuse; |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 97 | unsigned char ttls[MAXMIFS]; /* TTL thresholds */ |
| 98 | } res; |
| 99 | } mfc_un; |
| 100 | }; |
| 101 | |
| 102 | #define MFC_STATIC 1 |
| 103 | #define MFC_NOTIFY 2 |
| 104 | |
| 105 | #define MFC6_LINES 64 |
| 106 | |
| 107 | #define MFC6_HASH(a, g) (((__force u32)(a)->s6_addr32[0] ^ \ |
| 108 | (__force u32)(a)->s6_addr32[1] ^ \ |
| 109 | (__force u32)(a)->s6_addr32[2] ^ \ |
| 110 | (__force u32)(a)->s6_addr32[3] ^ \ |
| 111 | (__force u32)(g)->s6_addr32[0] ^ \ |
| 112 | (__force u32)(g)->s6_addr32[1] ^ \ |
| 113 | (__force u32)(g)->s6_addr32[2] ^ \ |
| 114 | (__force u32)(g)->s6_addr32[3]) % MFC6_LINES) |
| 115 | |
| 116 | #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */ |
| 117 | |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 118 | struct rtmsg; |
Benjamin Thery | 8229efd | 2008-12-10 16:30:15 -0800 | [diff] [blame] | 119 | extern int ip6mr_get_route(struct net *net, struct sk_buff *skb, |
David Ahern | fd61c6b | 2017-01-17 15:51:07 -0800 | [diff] [blame] | 120 | struct rtmsg *rtm, u32 portid); |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 121 | |
| 122 | #ifdef CONFIG_IPV6_MROUTE |
Patrick McHardy | d1db275 | 2010-05-11 14:40:55 +0200 | [diff] [blame] | 123 | extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb); |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 124 | extern int ip6mr_sk_done(struct sock *sk); |
| 125 | #else |
Patrick McHardy | d1db275 | 2010-05-11 14:40:55 +0200 | [diff] [blame] | 126 | static inline struct sock *mroute6_socket(struct net *net, struct sk_buff *skb) |
| 127 | { |
| 128 | return NULL; |
| 129 | } |
| 130 | static inline int ip6mr_sk_done(struct sock *sk) |
| 131 | { |
| 132 | return 0; |
| 133 | } |
YOSHIFUJI Hideaki | 7bc570c | 2008-04-03 09:22:53 +0900 | [diff] [blame] | 134 | #endif |
| 135 | #endif |