2008-04-03 08:22:53 +08:00
|
|
|
#ifndef __LINUX_MROUTE6_H
|
|
|
|
#define __LINUX_MROUTE6_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/sockios.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Based on the MROUTING 3.5 defines primarily to keep
|
|
|
|
* source compatibility with BSD.
|
|
|
|
*
|
|
|
|
* See the pim6sd code for the original history.
|
|
|
|
*
|
|
|
|
* Protocol Independent Multicast (PIM) data structures included
|
|
|
|
* Carlos Picoto (cap@di.fc.ul.pt)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MRT6_BASE 200
|
|
|
|
#define MRT6_INIT (MRT6_BASE) /* Activate the kernel mroute code */
|
|
|
|
#define MRT6_DONE (MRT6_BASE+1) /* Shutdown the kernel mroute */
|
|
|
|
#define MRT6_ADD_MIF (MRT6_BASE+2) /* Add a virtual interface */
|
|
|
|
#define MRT6_DEL_MIF (MRT6_BASE+3) /* Delete a virtual interface */
|
|
|
|
#define MRT6_ADD_MFC (MRT6_BASE+4) /* Add a multicast forwarding entry */
|
|
|
|
#define MRT6_DEL_MFC (MRT6_BASE+5) /* Delete a multicast forwarding entry */
|
|
|
|
#define MRT6_VERSION (MRT6_BASE+6) /* Get the kernel multicast version */
|
2008-04-03 08:22:54 +08:00
|
|
|
#define MRT6_ASSERT (MRT6_BASE+7) /* Activate PIM assert mode */
|
ipv6: ip6mr: support multiple tables
This patch adds support for multiple independant multicast routing instances,
named "tables".
Userspace multicast routing daemons can bind to a specific table instance by
issuing a setsockopt call using a new option MRT6_TABLE. The table number is
stored in the raw socket data and affects all following ip6mr setsockopt(),
getsockopt() and ioctl() calls. By default, a single table (RT6_TABLE_DFLT)
is created with a default routing rule pointing to it. Newly created pim6reg
devices have the table number appended ("pim6regX"), with the exception of
devices created in the default table, which are named just "pim6reg" for
compatibility reasons.
Packets are directed to a specific table instance using routing rules,
similar to how regular routing rules work. Currently iif, oif and mark
are supported as keys, source and destination addresses could be supported
additionally.
Example usage:
- bind pimd/xorp/... to a specific table:
uint32_t table = 123;
setsockopt(fd, SOL_IPV6, MRT6_TABLE, &table, sizeof(table));
- create routing rules directing packets to the new table:
# ip -6 mrule add iif eth0 lookup 123
# ip -6 mrule add oif eth0 lookup 123
Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-05-11 20:40:55 +08:00
|
|
|
#define MRT6_PIM (MRT6_BASE+8) /* enable PIM code */
|
|
|
|
#define MRT6_TABLE (MRT6_BASE+9) /* Specify mroute table ID */
|
2008-04-03 08:22:53 +08:00
|
|
|
|
|
|
|
#define SIOCGETMIFCNT_IN6 SIOCPROTOPRIVATE /* IP protocol privates */
|
|
|
|
#define SIOCGETSGCNT_IN6 (SIOCPROTOPRIVATE+1)
|
|
|
|
#define SIOCGETRPF (SIOCPROTOPRIVATE+2)
|
|
|
|
|
|
|
|
#define MAXMIFS 32
|
|
|
|
typedef unsigned long mifbitmap_t; /* User mode code depends on this lot */
|
|
|
|
typedef unsigned short mifi_t;
|
|
|
|
#define ALL_MIFS ((mifi_t)(-1))
|
|
|
|
|
|
|
|
#ifndef IF_SETSIZE
|
|
|
|
#define IF_SETSIZE 256
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef __u32 if_mask;
|
|
|
|
#define NIFBITS (sizeof(if_mask) * 8) /* bits per mask */
|
|
|
|
|
2011-12-13 23:07:49 +08:00
|
|
|
#if !defined(__KERNEL__)
|
|
|
|
#if !defined(DIV_ROUND_UP)
|
2008-04-03 08:22:53 +08:00
|
|
|
#define DIV_ROUND_UP(x,y) (((x) + ((y) - 1)) / (y))
|
|
|
|
#endif
|
2011-12-13 23:07:49 +08:00
|
|
|
#endif
|
2008-04-03 08:22:53 +08:00
|
|
|
|
|
|
|
typedef struct if_set {
|
|
|
|
if_mask ifs_bits[DIV_ROUND_UP(IF_SETSIZE, NIFBITS)];
|
|
|
|
} if_set;
|
|
|
|
|
|
|
|
#define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
|
|
|
|
#define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
|
|
|
|
#define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
|
|
|
|
#define IF_COPY(f, t) bcopy(f, t, sizeof(*(f)))
|
|
|
|
#define IF_ZERO(p) bzero(p, sizeof(*(p)))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Passed by mrouted for an MRT_ADD_MIF - again we use the
|
|
|
|
* mrouted 3.6 structures for compatibility
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct mif6ctl {
|
|
|
|
mifi_t mif6c_mifi; /* Index of MIF */
|
|
|
|
unsigned char mif6c_flags; /* MIFF_ flags */
|
|
|
|
unsigned char vifc_threshold; /* ttl limit */
|
make exported headers use strict posix types
A number of standard posix types are used in exported headers, which
is not allowed if __STRICT_KERNEL_NAMES is defined. In order to
get rid of the non-__STRICT_KERNEL_NAMES part and to make sane headers
the default, we have to change them all to safe types.
There are also still some leftovers in reiserfs_fs.h, elfcore.h
and coda.h, but these files have not compiled in user space for
a long time.
This leaves out the various integer types ({u_,u,}int{8,16,32,64}_t),
which we take care of separately.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Cc: netdev@vger.kernel.org
Cc: linux-ppp@vger.kernel.org
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-02-26 07:51:39 +08:00
|
|
|
__u16 mif6c_pifi; /* the index of the physical IF */
|
2008-04-03 08:22:53 +08:00
|
|
|
unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MIFF_REGISTER 0x1 /* register vif */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cache manipulation structures for mrouted and PIMd
|
|
|
|
*/
|
|
|
|
|
2009-11-05 01:50:58 +08:00
|
|
|
struct mf6cctl {
|
2008-04-03 08:22:53 +08:00
|
|
|
struct sockaddr_in6 mf6cc_origin; /* Origin of mcast */
|
|
|
|
struct sockaddr_in6 mf6cc_mcastgrp; /* Group in question */
|
|
|
|
mifi_t mf6cc_parent; /* Where it arrived */
|
|
|
|
struct if_set mf6cc_ifset; /* Where it is going */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Group count retrieval for pim6sd
|
|
|
|
*/
|
|
|
|
|
2009-11-05 01:50:58 +08:00
|
|
|
struct sioc_sg_req6 {
|
2008-04-03 08:22:53 +08:00
|
|
|
struct sockaddr_in6 src;
|
|
|
|
struct sockaddr_in6 grp;
|
|
|
|
unsigned long pktcnt;
|
|
|
|
unsigned long bytecnt;
|
|
|
|
unsigned long wrong_if;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To get vif packet counts
|
|
|
|
*/
|
|
|
|
|
2009-11-05 01:50:58 +08:00
|
|
|
struct sioc_mif_req6 {
|
2008-04-03 08:22:53 +08:00
|
|
|
mifi_t mifi; /* Which iface */
|
|
|
|
unsigned long icount; /* In packets */
|
|
|
|
unsigned long ocount; /* Out packets */
|
|
|
|
unsigned long ibytes; /* In bytes */
|
|
|
|
unsigned long obytes; /* Out bytes */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* That's all usermode folks
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2008-08-30 05:37:23 +08:00
|
|
|
#include <linux/pim.h>
|
2008-04-03 08:22:53 +08:00
|
|
|
#include <linux/skbuff.h> /* for struct sk_buff_head */
|
2008-12-11 08:07:08 +08:00
|
|
|
#include <net/net_namespace.h>
|
2008-04-03 08:22:53 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_IPV6_MROUTE
|
|
|
|
static inline int ip6_mroute_opt(int opt)
|
|
|
|
{
|
|
|
|
return (opt >= MRT6_BASE) && (opt <= MRT6_BASE + 10);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline int ip6_mroute_opt(int opt)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct sock;
|
|
|
|
|
2008-07-03 15:51:22 +08:00
|
|
|
#ifdef CONFIG_IPV6_MROUTE
|
2009-10-01 07:12:20 +08:00
|
|
|
extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
|
2008-04-03 08:22:53 +08:00
|
|
|
extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
|
|
|
|
extern int ip6_mr_input(struct sk_buff *skb);
|
|
|
|
extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
|
2011-02-04 09:59:32 +08:00
|
|
|
extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
|
2008-07-03 12:13:30 +08:00
|
|
|
extern int ip6_mr_init(void);
|
|
|
|
extern void ip6_mr_cleanup(void);
|
2008-07-03 15:51:22 +08:00
|
|
|
#else
|
|
|
|
static inline
|
|
|
|
int ip6_mroute_setsockopt(struct sock *sock,
|
2009-10-01 07:12:20 +08:00
|
|
|
int optname, char __user *optval, unsigned int optlen)
|
2008-07-03 15:51:22 +08:00
|
|
|
{
|
|
|
|
return -ENOPROTOOPT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
int ip6_mroute_getsockopt(struct sock *sock,
|
|
|
|
int optname, char __user *optval, int __user *optlen)
|
|
|
|
{
|
|
|
|
return -ENOPROTOOPT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
|
|
|
|
{
|
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ip6_mr_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ip6_mr_cleanup(void)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2008-04-03 08:22:53 +08:00
|
|
|
|
2009-11-05 01:50:58 +08:00
|
|
|
struct mif_device {
|
2008-04-03 08:22:53 +08: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 */
|
|
|
|
int link; /* Physical interface index */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define VIFF_STATIC 0x8000
|
|
|
|
|
2009-11-05 01:50:58 +08:00
|
|
|
struct mfc6_cache {
|
2010-05-11 20:40:51 +08:00
|
|
|
struct list_head list;
|
2008-04-03 08:22:53 +08:00
|
|
|
struct in6_addr mf6c_mcastgrp; /* Group the entry belongs to */
|
|
|
|
struct in6_addr mf6c_origin; /* Source of packet */
|
|
|
|
mifi_t mf6c_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;
|
|
|
|
unsigned char ttls[MAXMIFS]; /* TTL thresholds */
|
|
|
|
} res;
|
|
|
|
} mfc_un;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MFC_STATIC 1
|
|
|
|
#define MFC_NOTIFY 2
|
|
|
|
|
|
|
|
#define MFC6_LINES 64
|
|
|
|
|
|
|
|
#define MFC6_HASH(a, g) (((__force u32)(a)->s6_addr32[0] ^ \
|
|
|
|
(__force u32)(a)->s6_addr32[1] ^ \
|
|
|
|
(__force u32)(a)->s6_addr32[2] ^ \
|
|
|
|
(__force u32)(a)->s6_addr32[3] ^ \
|
|
|
|
(__force u32)(g)->s6_addr32[0] ^ \
|
|
|
|
(__force u32)(g)->s6_addr32[1] ^ \
|
|
|
|
(__force u32)(g)->s6_addr32[2] ^ \
|
|
|
|
(__force u32)(g)->s6_addr32[3]) % MFC6_LINES)
|
|
|
|
|
|
|
|
#define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
struct rtmsg;
|
2008-12-11 08:30:15 +08:00
|
|
|
extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
|
|
|
|
struct rtmsg *rtm, int nowait);
|
2008-04-03 08:22:53 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_IPV6_MROUTE
|
ipv6: ip6mr: support multiple tables
This patch adds support for multiple independant multicast routing instances,
named "tables".
Userspace multicast routing daemons can bind to a specific table instance by
issuing a setsockopt call using a new option MRT6_TABLE. The table number is
stored in the raw socket data and affects all following ip6mr setsockopt(),
getsockopt() and ioctl() calls. By default, a single table (RT6_TABLE_DFLT)
is created with a default routing rule pointing to it. Newly created pim6reg
devices have the table number appended ("pim6regX"), with the exception of
devices created in the default table, which are named just "pim6reg" for
compatibility reasons.
Packets are directed to a specific table instance using routing rules,
similar to how regular routing rules work. Currently iif, oif and mark
are supported as keys, source and destination addresses could be supported
additionally.
Example usage:
- bind pimd/xorp/... to a specific table:
uint32_t table = 123;
setsockopt(fd, SOL_IPV6, MRT6_TABLE, &table, sizeof(table));
- create routing rules directing packets to the new table:
# ip -6 mrule add iif eth0 lookup 123
# ip -6 mrule add oif eth0 lookup 123
Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-05-11 20:40:55 +08:00
|
|
|
extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb);
|
2008-04-03 08:22:53 +08:00
|
|
|
extern int ip6mr_sk_done(struct sock *sk);
|
|
|
|
#else
|
ipv6: ip6mr: support multiple tables
This patch adds support for multiple independant multicast routing instances,
named "tables".
Userspace multicast routing daemons can bind to a specific table instance by
issuing a setsockopt call using a new option MRT6_TABLE. The table number is
stored in the raw socket data and affects all following ip6mr setsockopt(),
getsockopt() and ioctl() calls. By default, a single table (RT6_TABLE_DFLT)
is created with a default routing rule pointing to it. Newly created pim6reg
devices have the table number appended ("pim6regX"), with the exception of
devices created in the default table, which are named just "pim6reg" for
compatibility reasons.
Packets are directed to a specific table instance using routing rules,
similar to how regular routing rules work. Currently iif, oif and mark
are supported as keys, source and destination addresses could be supported
additionally.
Example usage:
- bind pimd/xorp/... to a specific table:
uint32_t table = 123;
setsockopt(fd, SOL_IPV6, MRT6_TABLE, &table, sizeof(table));
- create routing rules directing packets to the new table:
# ip -6 mrule add iif eth0 lookup 123
# ip -6 mrule add oif eth0 lookup 123
Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-05-11 20:40:55 +08:00
|
|
|
static inline struct sock *mroute6_socket(struct net *net, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
static inline int ip6mr_sk_done(struct sock *sk)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-04-03 08:22:53 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure used to communicate from kernel to multicast router.
|
|
|
|
* We'll overlay the structure onto an MLD header (not an IPv6 heder like igmpmsg{}
|
|
|
|
* used for IPv4 implementation). This is because this structure will be passed via an
|
2011-03-31 09:57:33 +08:00
|
|
|
* IPv6 raw socket, on which an application will only receiver the payload i.e the data after
|
2008-04-03 08:22:53 +08:00
|
|
|
* the IPv6 header and all the extension headers. (See section 3 of RFC 3542)
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct mrt6msg {
|
|
|
|
#define MRT6MSG_NOCACHE 1
|
2008-04-03 08:22:54 +08:00
|
|
|
#define MRT6MSG_WRONGMIF 2
|
|
|
|
#define MRT6MSG_WHOLEPKT 3 /* used for use level encap */
|
2008-04-03 08:22:53 +08:00
|
|
|
__u8 im6_mbz; /* must be zero */
|
|
|
|
__u8 im6_msgtype; /* what type of message */
|
|
|
|
__u16 im6_mif; /* mif rec'd on */
|
|
|
|
__u32 im6_pad; /* padding for 64 bit arch */
|
|
|
|
struct in6_addr im6_src, im6_dst;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|