Merge tag 'amd-drm-fixes-6.5-2023-07-12' of https://gitlab.freedesktop.org/agd5f...
[linux-block.git] / include / linux / mroute6.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
7bc570c8
YH
2#ifndef __LINUX_MROUTE6_H
3#define __LINUX_MROUTE6_H
4
7bc570c8 5
7c19a3d2 6#include <linux/pim.h>
7bc570c8 7#include <linux/skbuff.h> /* for struct sk_buff_head */
bd91b8bf 8#include <net/net_namespace.h>
607ca46e 9#include <uapi/linux/mroute6.h>
6853f21f 10#include <linux/mroute_base.h>
b43c6153 11#include <linux/sockptr.h>
d3c07e5b 12#include <net/fib_rules.h>
7bc570c8 13
7bc570c8
YH
14#ifdef CONFIG_IPV6_MROUTE
15static inline int ip6_mroute_opt(int opt)
16{
bbb923a4 17 return (opt >= MRT6_BASE) && (opt <= MRT6_MAX);
7bc570c8
YH
18}
19#else
20static inline int ip6_mroute_opt(int opt)
21{
22 return 0;
23}
24#endif
25
26struct sock;
27
e0835f8f 28#ifdef CONFIG_IPV6_MROUTE
b43c6153 29extern int ip6_mroute_setsockopt(struct sock *, int, sockptr_t, unsigned int);
6dadbe4b 30extern int ip6_mroute_getsockopt(struct sock *, int, sockptr_t, sockptr_t);
7bc570c8 31extern int ip6_mr_input(struct sk_buff *skb);
e2d57766 32extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
623d1a1a
WC
33extern int ip6_mr_init(void);
34extern void ip6_mr_cleanup(void);
e1d001fa 35int ip6mr_ioctl(struct sock *sk, int cmd, void *arg);
e0835f8f 36#else
b43c6153
CH
37static inline int ip6_mroute_setsockopt(struct sock *sock, int optname,
38 sockptr_t optval, unsigned int optlen)
e0835f8f
YH
39{
40 return -ENOPROTOOPT;
41}
42
43static inline
44int ip6_mroute_getsockopt(struct sock *sock,
6dadbe4b 45 int optname, sockptr_t optval, sockptr_t optlen)
e0835f8f
YH
46{
47 return -ENOPROTOOPT;
48}
49
50static inline
e1d001fa 51int ip6mr_ioctl(struct sock *sk, int cmd, void *arg)
e0835f8f
YH
52{
53 return -ENOIOCTLCMD;
54}
55
56static inline int ip6_mr_init(void)
57{
58 return 0;
59}
60
61static inline void ip6_mr_cleanup(void)
62{
63 return;
64}
65#endif
7bc570c8 66
d3c07e5b
YM
67#ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES
68bool ip6mr_rule_default(const struct fib_rule *rule);
69#else
70static inline bool ip6mr_rule_default(const struct fib_rule *rule)
71{
72 return true;
73}
74#endif
75
7bc570c8
YH
76#define VIFF_STATIC 0x8000
77
87c418bf
YM
78struct mfc6_cache_cmp_arg {
79 struct in6_addr mf6c_mcastgrp;
80 struct in6_addr mf6c_origin;
81};
82
d94d9fee 83struct mfc6_cache {
494fff56 84 struct mr_mfc _c;
87c418bf
YM
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 };
7bc570c8
YH
92};
93
7bc570c8
YH
94#define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
95
7bc570c8 96struct rtmsg;
8229efda 97extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
fd61c6ba 98 struct rtmsg *rtm, u32 portid);
7bc570c8
YH
99
100#ifdef CONFIG_IPV6_MROUTE
8571ab47 101bool mroute6_is_socket(struct net *net, struct sk_buff *skb);
7bc570c8 102extern int ip6mr_sk_done(struct sock *sk);
e1d001fa
BL
103static inline int ip6mr_sk_ioctl(struct sock *sk, unsigned int cmd,
104 void __user *arg)
105{
106 switch (cmd) {
107 /* These userspace buffers will be consumed by ip6mr_ioctl() */
108 case SIOCGETMIFCNT_IN6: {
109 struct sioc_mif_req6 buffer;
110
111 return sock_ioctl_inout(sk, cmd, arg, &buffer,
3a4f0edb 112 sizeof(buffer));
e1d001fa
BL
113 }
114 case SIOCGETSGCNT_IN6: {
3a4f0edb 115 struct sioc_sg_req6 buffer;
e1d001fa
BL
116
117 return sock_ioctl_inout(sk, cmd, arg, &buffer,
3a4f0edb 118 sizeof(buffer));
e1d001fa
BL
119 }
120 }
121
122 return 1;
123}
7bc570c8 124#else
8571ab47 125static inline bool mroute6_is_socket(struct net *net, struct sk_buff *skb)
d1db275d 126{
8571ab47 127 return false;
d1db275d
PM
128}
129static inline int ip6mr_sk_done(struct sock *sk)
130{
131 return 0;
132}
e1d001fa
BL
133
134static inline int ip6mr_sk_ioctl(struct sock *sk, unsigned int cmd,
135 void __user *arg)
136{
137 return 1;
138}
7bc570c8
YH
139#endif
140#endif