ip6mr: Align hash implementation to ipmr
[linux-2.6-microblaze.git] / include / linux / mroute6.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_MROUTE6_H
3 #define __LINUX_MROUTE6_H
4
5
6 #include <linux/pim.h>
7 #include <linux/skbuff.h>       /* for struct sk_buff_head */
8 #include <net/net_namespace.h>
9 #include <uapi/linux/mroute6.h>
10 #include <linux/mroute_base.h>
11 #include <linux/rhashtable.h>
12
13 #ifdef CONFIG_IPV6_MROUTE
14 static inline int ip6_mroute_opt(int opt)
15 {
16         return (opt >= MRT6_BASE) && (opt <= MRT6_MAX);
17 }
18 #else
19 static inline int ip6_mroute_opt(int opt)
20 {
21         return 0;
22 }
23 #endif
24
25 struct sock;
26
27 #ifdef CONFIG_IPV6_MROUTE
28 extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
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);
32 extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
33 extern int ip6_mr_init(void);
34 extern void ip6_mr_cleanup(void);
35 #else
36 static inline
37 int ip6_mroute_setsockopt(struct sock *sock,
38                           int optname, char __user *optval, unsigned int optlen)
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
66
67 #define VIFF_STATIC 0x8000
68
69 struct mfc6_cache_cmp_arg {
70         struct in6_addr mf6c_mcastgrp;
71         struct in6_addr mf6c_origin;
72 };
73
74 struct mfc6_cache {
75         struct rhlist_head mnode;
76         union {
77                 struct {
78                         struct in6_addr mf6c_mcastgrp;
79                         struct in6_addr mf6c_origin;
80                 };
81                 struct mfc6_cache_cmp_arg cmparg;
82         };
83         mifi_t mf6c_parent;                     /* Source interface             */
84         int mfc_flags;                          /* Flags on line                */
85
86         union {
87                 struct {
88                         unsigned long expires;
89                         struct sk_buff_head unresolved; /* Unresolved buffers           */
90                 } unres;
91                 struct {
92                         unsigned long last_assert;
93                         int minvif;
94                         int maxvif;
95                         unsigned long bytes;
96                         unsigned long pkt;
97                         unsigned long wrong_if;
98                         unsigned long lastuse;
99                         unsigned char ttls[MAXMIFS];    /* TTL thresholds               */
100                 } res;
101         } mfc_un;
102         struct list_head list;
103         struct rcu_head rcu;
104 };
105
106 #define MFC_STATIC              1
107 #define MFC_NOTIFY              2
108
109 #define MFC_ASSERT_THRESH (3*HZ)                /* Maximal freq. of asserts */
110
111 struct rtmsg;
112 extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
113                            struct rtmsg *rtm, u32 portid);
114
115 #ifdef CONFIG_IPV6_MROUTE
116 bool mroute6_is_socket(struct net *net, struct sk_buff *skb);
117 extern int ip6mr_sk_done(struct sock *sk);
118 #else
119 static inline bool mroute6_is_socket(struct net *net, struct sk_buff *skb)
120 {
121         return false;
122 }
123 static inline int ip6mr_sk_done(struct sock *sk)
124 {
125         return 0;
126 }
127 #endif
128 #endif