mroute.h 3.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4
#ifndef __LINUX_MROUTE_H
#define __LINUX_MROUTE_H

#include <linux/in.h>
5
#include <linux/pim.h>
L
Linus Torvalds 已提交
6
#include <net/sock.h>
7
#include <uapi/linux/mroute.h>
L
Linus Torvalds 已提交
8

9 10 11
#ifdef CONFIG_IP_MROUTE
static inline int ip_mroute_opt(int opt)
{
12
	return opt >= MRT_BASE && opt <= MRT_MAX;
13 14
}

15 16 17 18 19
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);
20
#else
21 22
static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
				       char __user *optval, unsigned int optlen)
23 24 25 26
{
	return -ENOPROTOOPT;
}

27 28
static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
				       char __user *optval, int __user *optlen)
29 30 31 32
{
	return -ENOPROTOOPT;
}

33
static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
34 35 36 37 38 39 40 41
{
	return -ENOIOCTLCMD;
}

static inline int ip_mr_init(void)
{
	return 0;
}
42 43 44 45 46

static inline int ip_mroute_opt(int opt)
{
	return 0;
}
47
#endif
L
Linus Torvalds 已提交
48

E
Eric Dumazet 已提交
49
struct vif_device {
L
Linus Torvalds 已提交
50 51 52 53 54 55
	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 		*/
A
Al Viro 已提交
56
	__be32		local,remote;		/* Addresses(remote for tunnels)*/
L
Linus Torvalds 已提交
57 58 59 60 61
	int		link;			/* Physical interface index	*/
};

#define VIFF_STATIC 0x8000

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#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;
};

81 82 83 84 85 86 87
/* mfc_flags:
 * MFC_STATIC - the entry was added statically (not by a routing daemon)
 */
enum {
	MFC_STATIC = BIT(0),
};

E
Eric Dumazet 已提交
88
struct mfc_cache {
89
	struct list_head list;
A
Al Viro 已提交
90 91
	__be32 mfc_mcastgrp;			/* Group the entry belongs to 	*/
	__be32 mfc_origin;			/* Source of packet 		*/
L
Linus Torvalds 已提交
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
	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;
107
			unsigned long lastuse;
L
Linus Torvalds 已提交
108 109 110
			unsigned char ttls[MAXVIFS];	/* TTL thresholds		*/
		} res;
	} mfc_un;
111
	struct rcu_head	rcu;
L
Linus Torvalds 已提交
112 113 114
};

#ifdef __BIG_ENDIAN
A
Al Viro 已提交
115
#define MFC_HASH(a,b)	(((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
L
Linus Torvalds 已提交
116
#else
A
Al Viro 已提交
117
#define MFC_HASH(a,b)	((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
118
#endif
L
Linus Torvalds 已提交
119 120

struct rtmsg;
121 122
int ipmr_get_route(struct net *net, struct sk_buff *skb,
		   __be32 saddr, __be32 daddr,
123
		   struct rtmsg *rtm, u32 portid);
L
Linus Torvalds 已提交
124
#endif