Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux-2.6-microblaze.git] / include / linux / mroute.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_MROUTE_H
3 #define __LINUX_MROUTE_H
4
5 #include <linux/in.h>
6 #include <linux/pim.h>
7 #include <net/fib_rules.h>
8 #include <net/fib_notifier.h>
9 #include <uapi/linux/mroute.h>
10 #include <linux/mroute_base.h>
11
12 #ifdef CONFIG_IP_MROUTE
13 static inline int ip_mroute_opt(int opt)
14 {
15         return opt >= MRT_BASE && opt <= MRT_MAX;
16 }
17
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);
23 bool ipmr_rule_default(const struct fib_rule *rule);
24 #else
25 static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
26                                        char __user *optval, unsigned int optlen)
27 {
28         return -ENOPROTOOPT;
29 }
30
31 static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
32                                        char __user *optval, int __user *optlen)
33 {
34         return -ENOPROTOOPT;
35 }
36
37 static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
38 {
39         return -ENOIOCTLCMD;
40 }
41
42 static inline int ip_mr_init(void)
43 {
44         return 0;
45 }
46
47 static inline int ip_mroute_opt(int opt)
48 {
49         return 0;
50 }
51
52 static inline bool ipmr_rule_default(const struct fib_rule *rule)
53 {
54         return true;
55 }
56 #endif
57
58 struct vif_entry_notifier_info {
59         struct fib_notifier_info info;
60         struct net_device *dev;
61         vifi_t vif_index;
62         unsigned short vif_flags;
63         u32 tb_id;
64 };
65
66 #define VIFF_STATIC 0x8000
67
68 struct mfc_cache_cmp_arg {
69         __be32 mfc_mcastgrp;
70         __be32 mfc_origin;
71 };
72
73 /**
74  * struct mfc_cache - multicast routing entries
75  * @_c: Common multicast routing information; has to be first [for casting]
76  * @mfc_mcastgrp: destination multicast group address
77  * @mfc_origin: source address
78  * @cmparg: used for rhashtable comparisons
79  */
80 struct mfc_cache {
81         struct mr_mfc _c;
82         union {
83                 struct {
84                         __be32 mfc_mcastgrp;
85                         __be32 mfc_origin;
86                 };
87                 struct mfc_cache_cmp_arg cmparg;
88         };
89 };
90
91 struct mfc_entry_notifier_info {
92         struct fib_notifier_info info;
93         struct mfc_cache *mfc;
94         u32 tb_id;
95 };
96
97 struct rtmsg;
98 int ipmr_get_route(struct net *net, struct sk_buff *skb,
99                    __be32 saddr, __be32 daddr,
100                    struct rtmsg *rtm, u32 portid);
101
102 #ifdef CONFIG_IP_MROUTE
103 void ipmr_cache_free(struct mfc_cache *mfc_cache);
104 #else
105 static inline void ipmr_cache_free(struct mfc_cache *mfc_cache)
106 {
107 }
108 #endif
109
110 static inline void ipmr_cache_put(struct mfc_cache *c)
111 {
112         if (refcount_dec_and_test(&c->_c.mfc_un.res.refcount))
113                 ipmr_cache_free(c);
114 }
115 static inline void ipmr_cache_hold(struct mfc_cache *c)
116 {
117         refcount_inc(&c->_c.mfc_un.res.refcount);
118 }
119
120 #endif