Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-2.6-block.git] / include / linux / mroute.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2#ifndef __LINUX_MROUTE_H
3#define __LINUX_MROUTE_H
4
1da177e4 5#include <linux/in.h>
7c19a3d2 6#include <linux/pim.h>
8fb472c0 7#include <linux/rhashtable.h>
1da177e4 8#include <net/sock.h>
607ca46e 9#include <uapi/linux/mroute.h>
1da177e4 10
6a9fb947
PE
11#ifdef CONFIG_IP_MROUTE
12static inline int ip_mroute_opt(int opt)
13{
520191bb 14 return opt >= MRT_BASE && opt <= MRT_MAX;
6a9fb947 15}
6a9fb947 16
520191bb
NA
17int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
18int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
19int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
20int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
21int ip_mr_init(void);
e0835f8f 22#else
520191bb
NA
23static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
24 char __user *optval, unsigned int optlen)
e0835f8f
YH
25{
26 return -ENOPROTOOPT;
27}
28
520191bb
NA
29static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
30 char __user *optval, int __user *optlen)
e0835f8f
YH
31{
32 return -ENOPROTOOPT;
33}
34
520191bb 35static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
e0835f8f
YH
36{
37 return -ENOIOCTLCMD;
38}
39
40static inline int ip_mr_init(void)
41{
42 return 0;
43}
520191bb
NA
44
45static inline int ip_mroute_opt(int opt)
46{
47 return 0;
48}
e0835f8f 49#endif
1da177e4 50
d94d9fee 51struct vif_device {
1da177e4
LT
52 struct net_device *dev; /* Device we are using */
53 unsigned long bytes_in,bytes_out;
54 unsigned long pkt_in,pkt_out; /* Statistics */
55 unsigned long rate_limit; /* Traffic shaping (NI) */
56 unsigned char threshold; /* TTL threshold */
57 unsigned short flags; /* Control flags */
114c7844 58 __be32 local,remote; /* Addresses(remote for tunnels)*/
1da177e4
LT
59 int link; /* Physical interface index */
60};
61
62#define VIFF_STATIC 0x8000
63
5ea1f132 64#define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
5ea1f132
NA
65
66struct mr_table {
67 struct list_head list;
68 possible_net_t net;
69 u32 id;
70 struct sock __rcu *mroute_sk;
71 struct timer_list ipmr_expire_timer;
72 struct list_head mfc_unres_queue;
5ea1f132 73 struct vif_device vif_table[MAXVIFS];
8fb472c0
NA
74 struct rhltable mfc_hash;
75 struct list_head mfc_cache_list;
5ea1f132
NA
76 int maxvif;
77 atomic_t cache_resolve_queue_len;
78 bool mroute_do_assert;
79 bool mroute_do_pim;
80 int mroute_reg_vif_num;
81};
82
06bd6c03
NA
83/* mfc_flags:
84 * MFC_STATIC - the entry was added statically (not by a routing daemon)
85 */
86enum {
87 MFC_STATIC = BIT(0),
88};
89
8fb472c0
NA
90struct mfc_cache_cmp_arg {
91 __be32 mfc_mcastgrp;
92 __be32 mfc_origin;
93};
94
95/**
96 * struct mfc_cache - multicast routing entries
97 * @mnode: rhashtable list
98 * @mfc_mcastgrp: destination multicast group address
99 * @mfc_origin: source address
100 * @cmparg: used for rhashtable comparisons
101 * @mfc_parent: source interface (iif)
102 * @mfc_flags: entry flags
103 * @expires: unresolved entry expire time
104 * @unresolved: unresolved cached skbs
105 * @last_assert: time of last assert
106 * @minvif: minimum VIF id
107 * @maxvif: maximum VIF id
108 * @bytes: bytes that have passed for this entry
109 * @pkt: packets that have passed for this entry
110 * @wrong_if: number of wrong source interface hits
111 * @lastuse: time of last use of the group (traffic or update)
112 * @ttls: OIF TTL threshold array
113 * @list: global entry list
114 * @rcu: used for entry destruction
115 */
d94d9fee 116struct mfc_cache {
8fb472c0
NA
117 struct rhlist_head mnode;
118 union {
119 struct {
120 __be32 mfc_mcastgrp;
121 __be32 mfc_origin;
122 };
123 struct mfc_cache_cmp_arg cmparg;
124 };
125 vifi_t mfc_parent;
126 int mfc_flags;
1da177e4
LT
127
128 union {
129 struct {
130 unsigned long expires;
8fb472c0 131 struct sk_buff_head unresolved;
1da177e4
LT
132 } unres;
133 struct {
134 unsigned long last_assert;
135 int minvif;
136 int maxvif;
137 unsigned long bytes;
138 unsigned long pkt;
139 unsigned long wrong_if;
43b9e127 140 unsigned long lastuse;
8fb472c0 141 unsigned char ttls[MAXVIFS];
1da177e4
LT
142 } res;
143 } mfc_un;
8fb472c0 144 struct list_head list;
a8c9486b 145 struct rcu_head rcu;
1da177e4
LT
146};
147
1da177e4 148struct rtmsg;
520191bb
NA
149int ipmr_get_route(struct net *net, struct sk_buff *skb,
150 __be32 saddr, __be32 daddr,
9f09eaea 151 struct rtmsg *rtm, u32 portid);
1da177e4 152#endif