1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_MROUTE_H
3 #define __LINUX_MROUTE_H
7 #include <linux/rhashtable.h>
9 #include <uapi/linux/mroute.h>
11 #ifdef CONFIG_IP_MROUTE
12 static inline int ip_mroute_opt(int opt
)
14 return opt
>= MRT_BASE
&& opt
<= MRT_MAX
;
17 int ip_mroute_setsockopt(struct sock
*, int, char __user
*, unsigned int);
18 int ip_mroute_getsockopt(struct sock
*, int, char __user
*, int __user
*);
19 int ipmr_ioctl(struct sock
*sk
, int cmd
, void __user
*arg
);
20 int ipmr_compat_ioctl(struct sock
*sk
, unsigned int cmd
, void __user
*arg
);
23 static inline int ip_mroute_setsockopt(struct sock
*sock
, int optname
,
24 char __user
*optval
, unsigned int optlen
)
29 static inline int ip_mroute_getsockopt(struct sock
*sock
, int optname
,
30 char __user
*optval
, int __user
*optlen
)
35 static inline int ipmr_ioctl(struct sock
*sk
, int cmd
, void __user
*arg
)
40 static inline int ip_mr_init(void)
45 static inline int ip_mroute_opt(int opt
)
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 */
58 __be32 local
,remote
; /* Addresses(remote for tunnels)*/
59 int link
; /* Physical interface index */
62 #define VIFF_STATIC 0x8000
64 #define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
67 struct list_head list
;
70 struct sock __rcu
*mroute_sk
;
71 struct timer_list ipmr_expire_timer
;
72 struct list_head mfc_unres_queue
;
73 struct vif_device vif_table
[MAXVIFS
];
74 struct rhltable mfc_hash
;
75 struct list_head mfc_cache_list
;
77 atomic_t cache_resolve_queue_len
;
78 bool mroute_do_assert
;
80 int mroute_reg_vif_num
;
84 * MFC_STATIC - the entry was added statically (not by a routing daemon)
90 struct mfc_cache_cmp_arg
{
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
117 struct rhlist_head mnode
;
123 struct mfc_cache_cmp_arg cmparg
;
130 unsigned long expires
;
131 struct sk_buff_head unresolved
;
134 unsigned long last_assert
;
139 unsigned long wrong_if
;
140 unsigned long lastuse
;
141 unsigned char ttls
[MAXVIFS
];
144 struct list_head list
;
149 int ipmr_get_route(struct net
*net
, struct sk_buff
*skb
,
150 __be32 saddr
, __be32 daddr
,
151 struct rtmsg
*rtm
, u32 portid
);