]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/mroute.h
cpufreq: Rename cpufreq_can_do_remote_dvfs()
[mirror_ubuntu-bionic-kernel.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>
478e4c2f 9#include <net/fib_rules.h>
4d65b948 10#include <net/fib_notifier.h>
607ca46e 11#include <uapi/linux/mroute.h>
1da177e4 12
6a9fb947
PE
13#ifdef CONFIG_IP_MROUTE
14static inline int ip_mroute_opt(int opt)
15{
520191bb 16 return opt >= MRT_BASE && opt <= MRT_MAX;
6a9fb947 17}
6a9fb947 18
520191bb
NA
19int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
20int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
21int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
22int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
23int ip_mr_init(void);
478e4c2f 24bool ipmr_rule_default(const struct fib_rule *rule);
e0835f8f 25#else
520191bb
NA
26static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
27 char __user *optval, unsigned int optlen)
e0835f8f
YH
28{
29 return -ENOPROTOOPT;
30}
31
520191bb
NA
32static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
33 char __user *optval, int __user *optlen)
e0835f8f
YH
34{
35 return -ENOPROTOOPT;
36}
37
520191bb 38static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
e0835f8f
YH
39{
40 return -ENOIOCTLCMD;
41}
42
43static inline int ip_mr_init(void)
44{
45 return 0;
46}
520191bb
NA
47
48static inline int ip_mroute_opt(int opt)
49{
50 return 0;
51}
478e4c2f
YG
52
53static inline bool ipmr_rule_default(const struct fib_rule *rule)
54{
55 return true;
56}
e0835f8f 57#endif
1da177e4 58
d94d9fee 59struct vif_device {
1da177e4 60 struct net_device *dev; /* Device we are using */
5d8b3e69 61 struct netdev_phys_item_id dev_parent_id; /* Device parent ID */
1da177e4
LT
62 unsigned long bytes_in,bytes_out;
63 unsigned long pkt_in,pkt_out; /* Statistics */
64 unsigned long rate_limit; /* Traffic shaping (NI) */
65 unsigned char threshold; /* TTL threshold */
66 unsigned short flags; /* Control flags */
114c7844 67 __be32 local,remote; /* Addresses(remote for tunnels)*/
1da177e4
LT
68 int link; /* Physical interface index */
69};
70
4d65b948
YG
71struct vif_entry_notifier_info {
72 struct fib_notifier_info info;
73 struct net_device *dev;
74 vifi_t vif_index;
75 unsigned short vif_flags;
76 u32 tb_id;
77};
78
1da177e4
LT
79#define VIFF_STATIC 0x8000
80
5ea1f132 81#define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
5ea1f132
NA
82
83struct mr_table {
84 struct list_head list;
85 possible_net_t net;
86 u32 id;
87 struct sock __rcu *mroute_sk;
88 struct timer_list ipmr_expire_timer;
89 struct list_head mfc_unres_queue;
5ea1f132 90 struct vif_device vif_table[MAXVIFS];
8fb472c0
NA
91 struct rhltable mfc_hash;
92 struct list_head mfc_cache_list;
5ea1f132
NA
93 int maxvif;
94 atomic_t cache_resolve_queue_len;
95 bool mroute_do_assert;
96 bool mroute_do_pim;
97 int mroute_reg_vif_num;
98};
99
06bd6c03
NA
100/* mfc_flags:
101 * MFC_STATIC - the entry was added statically (not by a routing daemon)
c7c0bbea 102 * MFC_OFFLOAD - the entry was offloaded to the hardware
06bd6c03
NA
103 */
104enum {
105 MFC_STATIC = BIT(0),
c7c0bbea 106 MFC_OFFLOAD = BIT(1),
06bd6c03
NA
107};
108
8fb472c0
NA
109struct mfc_cache_cmp_arg {
110 __be32 mfc_mcastgrp;
111 __be32 mfc_origin;
112};
113
114/**
115 * struct mfc_cache - multicast routing entries
116 * @mnode: rhashtable list
117 * @mfc_mcastgrp: destination multicast group address
118 * @mfc_origin: source address
119 * @cmparg: used for rhashtable comparisons
120 * @mfc_parent: source interface (iif)
121 * @mfc_flags: entry flags
122 * @expires: unresolved entry expire time
123 * @unresolved: unresolved cached skbs
124 * @last_assert: time of last assert
125 * @minvif: minimum VIF id
126 * @maxvif: maximum VIF id
127 * @bytes: bytes that have passed for this entry
128 * @pkt: packets that have passed for this entry
129 * @wrong_if: number of wrong source interface hits
130 * @lastuse: time of last use of the group (traffic or update)
131 * @ttls: OIF TTL threshold array
310ebbba 132 * @refcount: reference count for this entry
8fb472c0
NA
133 * @list: global entry list
134 * @rcu: used for entry destruction
135 */
d94d9fee 136struct mfc_cache {
8fb472c0
NA
137 struct rhlist_head mnode;
138 union {
139 struct {
140 __be32 mfc_mcastgrp;
141 __be32 mfc_origin;
142 };
143 struct mfc_cache_cmp_arg cmparg;
144 };
145 vifi_t mfc_parent;
146 int mfc_flags;
1da177e4
LT
147
148 union {
149 struct {
150 unsigned long expires;
8fb472c0 151 struct sk_buff_head unresolved;
1da177e4
LT
152 } unres;
153 struct {
154 unsigned long last_assert;
155 int minvif;
156 int maxvif;
157 unsigned long bytes;
158 unsigned long pkt;
159 unsigned long wrong_if;
43b9e127 160 unsigned long lastuse;
8fb472c0 161 unsigned char ttls[MAXVIFS];
310ebbba 162 refcount_t refcount;
1da177e4
LT
163 } res;
164 } mfc_un;
8fb472c0 165 struct list_head list;
a8c9486b 166 struct rcu_head rcu;
1da177e4
LT
167};
168
4d65b948
YG
169struct mfc_entry_notifier_info {
170 struct fib_notifier_info info;
171 struct mfc_cache *mfc;
172 u32 tb_id;
173};
174
1da177e4 175struct rtmsg;
520191bb
NA
176int ipmr_get_route(struct net *net, struct sk_buff *skb,
177 __be32 saddr, __be32 daddr,
9f09eaea 178 struct rtmsg *rtm, u32 portid);
310ebbba
YG
179
180#ifdef CONFIG_IP_MROUTE
181void ipmr_cache_free(struct mfc_cache *mfc_cache);
182#else
183static inline void ipmr_cache_free(struct mfc_cache *mfc_cache)
184{
185}
186#endif
187
188static inline void ipmr_cache_put(struct mfc_cache *c)
189{
190 if (refcount_dec_and_test(&c->mfc_un.res.refcount))
191 ipmr_cache_free(c);
192}
193static inline void ipmr_cache_hold(struct mfc_cache *c)
194{
195 refcount_inc(&c->mfc_un.res.refcount);
196}
197
1da177e4 198#endif