mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
ipv4: ipmr: 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 MRT_TABLE. The table number is
stored in the raw socket data and affects all following ipmr setsockopt(),
getsockopt() and ioctl() calls. By default, a single table (RT_TABLE_DEFAULT)
is created with a default routing rule pointing to it. Newly created pimreg
devices have the table number appended ("pimregX"), with the exception of
devices created in the default table, which are named just "pimreg" 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, IPPROTO_IP, MRT_TABLE, &table, sizeof(table));
- create routing rules directing packets to the new table:
# ip mrule add iif eth0 lookup 123
# ip mrule add oif eth0 lookup 123
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
0c12295a74
commit
f0ad0860d0
@@ -21,6 +21,7 @@
|
||||
#define FIB_RULES_IPV4 AF_INET
|
||||
#define FIB_RULES_IPV6 AF_INET6
|
||||
#define FIB_RULES_DECNET AF_DECnet
|
||||
#define FIB_RULES_IPMR 128
|
||||
|
||||
struct fib_rule_hdr {
|
||||
__u8 family;
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
#define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */
|
||||
#define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */
|
||||
#define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */
|
||||
#define MRT_PIM (MRT_BASE+8) /* enable PIM code */
|
||||
#define MRT_PIM (MRT_BASE+8) /* enable PIM code */
|
||||
#define MRT_TABLE (MRT_BASE+9) /* Specify mroute table ID */
|
||||
|
||||
#define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
|
||||
#define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
|
||||
|
||||
@@ -59,7 +59,12 @@ struct netns_ipv4 {
|
||||
atomic_t rt_genid;
|
||||
|
||||
#ifdef CONFIG_IP_MROUTE
|
||||
#ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
|
||||
struct mr_table *mrt;
|
||||
#else
|
||||
struct list_head mr_tables;
|
||||
struct fib_rules_ops *mr_rules_ops;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -61,6 +61,7 @@ struct raw_sock {
|
||||
/* inet_sock has to be the first member */
|
||||
struct inet_sock inet;
|
||||
struct icmp_filter filter;
|
||||
u32 ipmr_table;
|
||||
};
|
||||
|
||||
static inline struct raw_sock *raw_sk(const struct sock *sk)
|
||||
|
||||
@@ -250,6 +250,20 @@ config IP_MROUTE
|
||||
<file:Documentation/networking/multicast.txt>. If you haven't heard
|
||||
about it, you don't need it.
|
||||
|
||||
config IP_MROUTE_MULTIPLE_TABLES
|
||||
bool "IP: multicast policy routing"
|
||||
depends on IP_ADVANCED_ROUTER
|
||||
select FIB_RULES
|
||||
help
|
||||
Normally, a multicast router runs a userspace daemon and decides
|
||||
what to do with a multicast packet based on the source and
|
||||
destination addresses. If you say Y here, the multicast router
|
||||
will also be able to take interfaces and packet marks into
|
||||
account and run multiple instances of userspace daemons
|
||||
simultaneously, each one handling a single table.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config IP_PIMSM_V1
|
||||
bool "IP: PIM-SM version 1 support"
|
||||
depends on IP_MROUTE
|
||||
|
||||
399
net/ipv4/ipmr.c
399
net/ipv4/ipmr.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user