blob: c4a45859f586d485ffd581eaca15ad55f217b10c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +09002#ifndef __LINUX_MROUTE6_H
3#define __LINUX_MROUTE6_H
4
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +09005
David S. Miller7c19a3d2008-08-29 14:37:23 -07006#include <linux/pim.h>
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +09007#include <linux/skbuff.h> /* for struct sk_buff_head */
Benjamin Therybd91b8b2008-12-10 16:07:08 -08008#include <net/net_namespace.h>
David Howells607ca462012-10-13 10:46:48 +01009#include <uapi/linux/mroute6.h>
Yuval Mintz6853f212018-02-28 23:29:29 +020010#include <linux/mroute_base.h>
Yuval Mintzd3c07e52018-03-26 15:01:35 +030011#include <net/fib_rules.h>
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090012
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090013#ifdef CONFIG_IPV6_MROUTE
14static inline int ip6_mroute_opt(int opt)
15{
Nicolas Dichtelbbb923a2013-01-21 06:00:25 +000016 return (opt >= MRT6_BASE) && (opt <= MRT6_MAX);
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090017}
18#else
19static inline int ip6_mroute_opt(int opt)
20{
21 return 0;
22}
23#endif
24
25struct sock;
26
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090027#ifdef CONFIG_IPV6_MROUTE
David S. Millerb7058842009-09-30 16:12:20 -070028extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090029extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
30extern int ip6_mr_input(struct sk_buff *skb);
31extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
David S. Millere2d57762011-02-03 17:59:32 -080032extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
Wang Chen623d1a12008-07-03 12:13:30 +080033extern int ip6_mr_init(void);
34extern void ip6_mr_cleanup(void);
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090035#else
36static inline
37int ip6_mroute_setsockopt(struct sock *sock,
David S. Millerb7058842009-09-30 16:12:20 -070038 int optname, char __user *optval, unsigned int optlen)
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090039{
40 return -ENOPROTOOPT;
41}
42
43static inline
44int ip6_mroute_getsockopt(struct sock *sock,
45 int optname, char __user *optval, int __user *optlen)
46{
47 return -ENOPROTOOPT;
48}
49
50static inline
51int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
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
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090066
Yuval Mintzd3c07e52018-03-26 15:01:35 +030067#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
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090076#define VIFF_STATIC 0x8000
77
Yuval Mintz87c418b2018-02-28 23:29:31 +020078struct mfc6_cache_cmp_arg {
79 struct in6_addr mf6c_mcastgrp;
80 struct in6_addr mf6c_origin;
81};
82
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080083struct mfc6_cache {
Yuval Mintz494fff52018-02-28 23:29:34 +020084 struct mr_mfc _c;
Yuval Mintz87c418b2018-02-28 23:29:31 +020085 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 Hideaki7bc570c2008-04-03 09:22:53 +090092};
93
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090094#define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
95
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090096struct rtmsg;
Benjamin Thery8229efd2008-12-10 16:30:15 -080097extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
David Ahernfd61c6b2017-01-17 15:51:07 -080098 struct rtmsg *rtm, u32 portid);
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090099
100#ifdef CONFIG_IPV6_MROUTE
Yuval Mintz8571ab42018-02-28 23:29:30 +0200101bool mroute6_is_socket(struct net *net, struct sk_buff *skb);
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +0900102extern int ip6mr_sk_done(struct sock *sk);
103#else
Yuval Mintz8571ab42018-02-28 23:29:30 +0200104static inline bool mroute6_is_socket(struct net *net, struct sk_buff *skb)
Patrick McHardyd1db2752010-05-11 14:40:55 +0200105{
Yuval Mintz8571ab42018-02-28 23:29:30 +0200106 return false;
Patrick McHardyd1db2752010-05-11 14:40:55 +0200107}
108static inline int ip6mr_sk_done(struct sock *sk)
109{
110 return 0;
111}
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +0900112#endif
113#endif