2005-04-17 02:20:36 +04:00
|
|
|
#ifndef __LINUX_MROUTE_H
|
|
|
|
#define __LINUX_MROUTE_H
|
|
|
|
|
|
|
|
#include <linux/in.h>
|
2008-08-30 01:37:23 +04:00
|
|
|
#include <linux/pim.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <net/sock.h>
|
2012-10-13 13:46:48 +04:00
|
|
|
#include <uapi/linux/mroute.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-11-06 08:32:31 +03:00
|
|
|
#ifdef CONFIG_IP_MROUTE
|
|
|
|
static inline int ip_mroute_opt(int opt)
|
|
|
|
{
|
2015-11-26 17:23:46 +03:00
|
|
|
return opt >= MRT_BASE && opt <= MRT_MAX;
|
2007-11-06 08:32:31 +03:00
|
|
|
}
|
|
|
|
|
2015-11-26 17:23:46 +03:00
|
|
|
int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
|
|
|
|
int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
|
|
|
|
int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
|
|
|
|
int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
|
|
|
|
int ip_mr_init(void);
|
2008-07-03 11:51:22 +04:00
|
|
|
#else
|
2015-11-26 17:23:46 +03:00
|
|
|
static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
|
|
|
|
char __user *optval, unsigned int optlen)
|
2008-07-03 11:51:22 +04:00
|
|
|
{
|
|
|
|
return -ENOPROTOOPT;
|
|
|
|
}
|
|
|
|
|
2015-11-26 17:23:46 +03:00
|
|
|
static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
|
|
|
|
char __user *optval, int __user *optlen)
|
2008-07-03 11:51:22 +04:00
|
|
|
{
|
|
|
|
return -ENOPROTOOPT;
|
|
|
|
}
|
|
|
|
|
2015-11-26 17:23:46 +03:00
|
|
|
static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
|
2008-07-03 11:51:22 +04:00
|
|
|
{
|
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ip_mr_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-11-26 17:23:46 +03:00
|
|
|
|
|
|
|
static inline int ip_mroute_opt(int opt)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-03 11:51:22 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2009-11-04 20:50:58 +03:00
|
|
|
struct vif_device {
|
2005-04-17 02:20:36 +04:00
|
|
|
struct net_device *dev; /* Device we are using */
|
|
|
|
unsigned long bytes_in,bytes_out;
|
|
|
|
unsigned long pkt_in,pkt_out; /* Statistics */
|
|
|
|
unsigned long rate_limit; /* Traffic shaping (NI) */
|
|
|
|
unsigned char threshold; /* TTL threshold */
|
|
|
|
unsigned short flags; /* Control flags */
|
2006-09-28 05:39:29 +04:00
|
|
|
__be32 local,remote; /* Addresses(remote for tunnels)*/
|
2005-04-17 02:20:36 +04:00
|
|
|
int link; /* Physical interface index */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define VIFF_STATIC 0x8000
|
|
|
|
|
2015-11-26 17:23:47 +03:00
|
|
|
#define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
|
|
|
|
#define MFC_LINES 64
|
|
|
|
|
|
|
|
struct mr_table {
|
|
|
|
struct list_head list;
|
|
|
|
possible_net_t net;
|
|
|
|
u32 id;
|
|
|
|
struct sock __rcu *mroute_sk;
|
|
|
|
struct timer_list ipmr_expire_timer;
|
|
|
|
struct list_head mfc_unres_queue;
|
|
|
|
struct list_head mfc_cache_array[MFC_LINES];
|
|
|
|
struct vif_device vif_table[MAXVIFS];
|
|
|
|
int maxvif;
|
|
|
|
atomic_t cache_resolve_queue_len;
|
|
|
|
bool mroute_do_assert;
|
|
|
|
bool mroute_do_pim;
|
|
|
|
int mroute_reg_vif_num;
|
|
|
|
};
|
|
|
|
|
2015-11-26 17:23:45 +03:00
|
|
|
/* mfc_flags:
|
|
|
|
* MFC_STATIC - the entry was added statically (not by a routing daemon)
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
MFC_STATIC = BIT(0),
|
|
|
|
};
|
|
|
|
|
2009-11-04 20:50:58 +03:00
|
|
|
struct mfc_cache {
|
2010-04-13 09:03:21 +04:00
|
|
|
struct list_head list;
|
2006-09-28 05:39:29 +04:00
|
|
|
__be32 mfc_mcastgrp; /* Group the entry belongs to */
|
|
|
|
__be32 mfc_origin; /* Source of packet */
|
2005-04-17 02:20:36 +04:00
|
|
|
vifi_t mfc_parent; /* Source interface */
|
|
|
|
int mfc_flags; /* Flags on line */
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
unsigned long expires;
|
|
|
|
struct sk_buff_head unresolved; /* Unresolved buffers */
|
|
|
|
} unres;
|
|
|
|
struct {
|
|
|
|
unsigned long last_assert;
|
|
|
|
int minvif;
|
|
|
|
int maxvif;
|
|
|
|
unsigned long bytes;
|
|
|
|
unsigned long pkt;
|
|
|
|
unsigned long wrong_if;
|
2016-07-14 19:28:27 +03:00
|
|
|
unsigned long lastuse;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned char ttls[MAXVIFS]; /* TTL thresholds */
|
|
|
|
} res;
|
|
|
|
} mfc_un;
|
2010-10-01 20:15:08 +04:00
|
|
|
struct rcu_head rcu;
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN
|
2006-09-28 05:39:29 +04:00
|
|
|
#define MFC_HASH(a,b) (((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
|
2005-04-17 02:20:36 +04:00
|
|
|
#else
|
2006-09-28 05:39:29 +04:00
|
|
|
#define MFC_HASH(a,b) ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
|
2015-11-26 17:23:46 +03:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct rtmsg;
|
2015-11-26 17:23:46 +03:00
|
|
|
int ipmr_get_route(struct net *net, struct sk_buff *skb,
|
|
|
|
__be32 saddr, __be32 daddr,
|
|
|
|
struct rtmsg *rtm, int nowait);
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|