2005-04-16 22:20:36 +00:00
|
|
|
#ifndef __LINUX_MROUTE_H
|
|
|
|
#define __LINUX_MROUTE_H
|
|
|
|
|
|
|
|
#include <linux/in.h>
|
2008-08-29 21:37:23 +00:00
|
|
|
#include <linux/pim.h>
|
2017-01-12 14:53:33 +00:00
|
|
|
#include <linux/rhashtable.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <net/sock.h>
|
2012-10-13 09:46:48 +00:00
|
|
|
#include <uapi/linux/mroute.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-06 05:32:31 +00:00
|
|
|
#ifdef CONFIG_IP_MROUTE
|
|
|
|
static inline int ip_mroute_opt(int opt)
|
|
|
|
{
|
2015-11-26 14:23:46 +00:00
|
|
|
return opt >= MRT_BASE && opt <= MRT_MAX;
|
2007-11-06 05:32:31 +00:00
|
|
|
}
|
|
|
|
|
2015-11-26 14:23:46 +00: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 07:51:22 +00:00
|
|
|
#else
|
2015-11-26 14:23:46 +00:00
|
|
|
static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
|
|
|
|
char __user *optval, unsigned int optlen)
|
2008-07-03 07:51:22 +00:00
|
|
|
{
|
|
|
|
return -ENOPROTOOPT;
|
|
|
|
}
|
|
|
|
|
2015-11-26 14:23:46 +00:00
|
|
|
static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
|
|
|
|
char __user *optval, int __user *optlen)
|
2008-07-03 07:51:22 +00:00
|
|
|
{
|
|
|
|
return -ENOPROTOOPT;
|
|
|
|
}
|
|
|
|
|
2015-11-26 14:23:46 +00:00
|
|
|
static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
|
2008-07-03 07:51:22 +00:00
|
|
|
{
|
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ip_mr_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-11-26 14:23:46 +00:00
|
|
|
|
|
|
|
static inline int ip_mroute_opt(int opt)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-03 07:51:22 +00:00
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-11-04 17:50:58 +00:00
|
|
|
struct vif_device {
|
2005-04-16 22:20:36 +00: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 01:39:29 +00:00
|
|
|
__be32 local,remote; /* Addresses(remote for tunnels)*/
|
2005-04-16 22:20:36 +00:00
|
|
|
int link; /* Physical interface index */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define VIFF_STATIC 0x8000
|
|
|
|
|
2015-11-26 14:23:47 +00:00
|
|
|
#define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
|
|
|
|
|
|
|
|
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 vif_device vif_table[MAXVIFS];
|
2017-01-12 14:53:33 +00:00
|
|
|
struct rhltable mfc_hash;
|
|
|
|
struct list_head mfc_cache_list;
|
2015-11-26 14:23:47 +00:00
|
|
|
int maxvif;
|
|
|
|
atomic_t cache_resolve_queue_len;
|
|
|
|
bool mroute_do_assert;
|
|
|
|
bool mroute_do_pim;
|
|
|
|
int mroute_reg_vif_num;
|
|
|
|
};
|
|
|
|
|
2015-11-26 14:23:45 +00:00
|
|
|
/* mfc_flags:
|
|
|
|
* MFC_STATIC - the entry was added statically (not by a routing daemon)
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
MFC_STATIC = BIT(0),
|
|
|
|
};
|
|
|
|
|
2017-01-12 14:53:33 +00:00
|
|
|
struct mfc_cache_cmp_arg {
|
|
|
|
__be32 mfc_mcastgrp;
|
|
|
|
__be32 mfc_origin;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct mfc_cache - multicast routing entries
|
|
|
|
* @mnode: rhashtable list
|
|
|
|
* @mfc_mcastgrp: destination multicast group address
|
|
|
|
* @mfc_origin: source address
|
|
|
|
* @cmparg: used for rhashtable comparisons
|
|
|
|
* @mfc_parent: source interface (iif)
|
|
|
|
* @mfc_flags: entry flags
|
|
|
|
* @expires: unresolved entry expire time
|
|
|
|
* @unresolved: unresolved cached skbs
|
|
|
|
* @last_assert: time of last assert
|
|
|
|
* @minvif: minimum VIF id
|
|
|
|
* @maxvif: maximum VIF id
|
|
|
|
* @bytes: bytes that have passed for this entry
|
|
|
|
* @pkt: packets that have passed for this entry
|
|
|
|
* @wrong_if: number of wrong source interface hits
|
|
|
|
* @lastuse: time of last use of the group (traffic or update)
|
|
|
|
* @ttls: OIF TTL threshold array
|
|
|
|
* @list: global entry list
|
|
|
|
* @rcu: used for entry destruction
|
|
|
|
*/
|
2009-11-04 17:50:58 +00:00
|
|
|
struct mfc_cache {
|
2017-01-12 14:53:33 +00:00
|
|
|
struct rhlist_head mnode;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
__be32 mfc_mcastgrp;
|
|
|
|
__be32 mfc_origin;
|
|
|
|
};
|
|
|
|
struct mfc_cache_cmp_arg cmparg;
|
|
|
|
};
|
|
|
|
vifi_t mfc_parent;
|
|
|
|
int mfc_flags;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
unsigned long expires;
|
2017-01-12 14:53:33 +00:00
|
|
|
struct sk_buff_head unresolved;
|
2005-04-16 22:20:36 +00:00
|
|
|
} unres;
|
|
|
|
struct {
|
|
|
|
unsigned long last_assert;
|
|
|
|
int minvif;
|
|
|
|
int maxvif;
|
|
|
|
unsigned long bytes;
|
|
|
|
unsigned long pkt;
|
|
|
|
unsigned long wrong_if;
|
2016-07-14 16:28:27 +00:00
|
|
|
unsigned long lastuse;
|
2017-01-12 14:53:33 +00:00
|
|
|
unsigned char ttls[MAXVIFS];
|
2005-04-16 22:20:36 +00:00
|
|
|
} res;
|
|
|
|
} mfc_un;
|
2017-01-12 14:53:33 +00:00
|
|
|
struct list_head list;
|
2010-10-01 16:15:08 +00:00
|
|
|
struct rcu_head rcu;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rtmsg;
|
2015-11-26 14:23:46 +00:00
|
|
|
int ipmr_get_route(struct net *net, struct sk_buff *skb,
|
|
|
|
__be32 saddr, __be32 daddr,
|
2017-01-07 01:39:06 +00:00
|
|
|
struct rtmsg *rtm, u32 portid);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|