1 #ifndef __LINUX_MROUTE_H
2 #define __LINUX_MROUTE_H
6 #include <linux/rhashtable.h>
8 #include <net/fib_rules.h>
9 #include <net/fib_notifier.h>
10 #include <uapi/linux/mroute.h>
12 #ifdef CONFIG_IP_MROUTE
13 static inline int ip_mroute_opt(int opt)
15 return opt >= MRT_BASE && opt <= MRT_MAX;
18 int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
19 int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
20 int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
21 int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
23 bool ipmr_rule_default(const struct fib_rule *rule);
25 static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
26 char __user *optval, unsigned int optlen)
31 static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
32 char __user *optval, int __user *optlen)
37 static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
42 static inline int ip_mr_init(void)
47 static inline int ip_mroute_opt(int opt)
52 static inline bool ipmr_rule_default(const struct fib_rule *rule)
59 struct net_device *dev; /* Device we are using */
60 struct netdev_phys_item_id dev_parent_id; /* Device parent ID */
61 unsigned long bytes_in,bytes_out;
62 unsigned long pkt_in,pkt_out; /* Statistics */
63 unsigned long rate_limit; /* Traffic shaping (NI) */
64 unsigned char threshold; /* TTL threshold */
65 unsigned short flags; /* Control flags */
66 __be32 local,remote; /* Addresses(remote for tunnels)*/
67 int link; /* Physical interface index */
70 struct vif_entry_notifier_info {
71 struct fib_notifier_info info;
72 struct net_device *dev;
74 unsigned short vif_flags;
78 #define VIFF_STATIC 0x8000
80 #define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
83 struct list_head list;
86 struct sock __rcu *mroute_sk;
87 struct timer_list ipmr_expire_timer;
88 struct list_head mfc_unres_queue;
89 struct vif_device vif_table[MAXVIFS];
90 struct rhltable mfc_hash;
91 struct list_head mfc_cache_list;
93 atomic_t cache_resolve_queue_len;
94 bool mroute_do_assert;
96 int mroute_reg_vif_num;
100 * MFC_STATIC - the entry was added statically (not by a routing daemon)
101 * MFC_OFFLOAD - the entry was offloaded to the hardware
105 MFC_OFFLOAD = BIT(1),
108 struct mfc_cache_cmp_arg {
114 * struct mfc_cache - multicast routing entries
115 * @mnode: rhashtable list
116 * @mfc_mcastgrp: destination multicast group address
117 * @mfc_origin: source address
118 * @cmparg: used for rhashtable comparisons
119 * @mfc_parent: source interface (iif)
120 * @mfc_flags: entry flags
121 * @expires: unresolved entry expire time
122 * @unresolved: unresolved cached skbs
123 * @last_assert: time of last assert
124 * @minvif: minimum VIF id
125 * @maxvif: maximum VIF id
126 * @bytes: bytes that have passed for this entry
127 * @pkt: packets that have passed for this entry
128 * @wrong_if: number of wrong source interface hits
129 * @lastuse: time of last use of the group (traffic or update)
130 * @ttls: OIF TTL threshold array
131 * @refcount: reference count for this entry
132 * @list: global entry list
133 * @rcu: used for entry destruction
136 struct rhlist_head mnode;
142 struct mfc_cache_cmp_arg cmparg;
149 unsigned long expires;
150 struct sk_buff_head unresolved;
153 unsigned long last_assert;
158 unsigned long wrong_if;
159 unsigned long lastuse;
160 unsigned char ttls[MAXVIFS];
164 struct list_head list;
168 struct mfc_entry_notifier_info {
169 struct fib_notifier_info info;
170 struct mfc_cache *mfc;
175 int ipmr_get_route(struct net *net, struct sk_buff *skb,
176 __be32 saddr, __be32 daddr,
177 struct rtmsg *rtm, u32 portid);
179 #ifdef CONFIG_IP_MROUTE
180 void ipmr_cache_free(struct mfc_cache *mfc_cache);
182 static inline void ipmr_cache_free(struct mfc_cache *mfc_cache)
187 static inline void ipmr_cache_put(struct mfc_cache *c)
189 if (refcount_dec_and_test(&c->mfc_un.res.refcount))
192 static inline void ipmr_cache_hold(struct mfc_cache *c)
194 refcount_inc(&c->mfc_un.res.refcount);