Decouple rtnetlink address families from real address families in socket.h to
be able to add rtnetlink interfaces to code that is not a real address family
without increasing AF_MAX/NPROTO.
This will be used to add support for multicast route dumping from all tables
as the proc interface can't be extended to support anything but the main table
without breaking compatibility.
This partialy undoes the patch to introduce independant families for routing
rules and converts ipmr routing rules to a new rtnetlink family. Similar to
that patch, values up to 127 are reserved for real address families, values
above that may be used arbitrarily.
Signed-off-by: Patrick McHardy <kaber@trash.net>
/* try to find source address in routing lookups */
#define FIB_RULE_FIND_SADDR 0x00010000
/* try to find source address in routing lookups */
#define FIB_RULE_FIND_SADDR 0x00010000
-/* fib_rules families. values up to 127 are reserved for real address
- * families, values above 128 may be used arbitrarily.
- */
-#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;
__u8 dst_len;
struct fib_rule_hdr {
__u8 family;
__u8 dst_len;
#include <linux/if_addr.h>
#include <linux/neighbour.h>
#include <linux/if_addr.h>
#include <linux/neighbour.h>
+/* rtnetlink families. Values up to 127 are reserved for real address
+ * families, values above 128 may be used arbitrarily.
+ */
+#define RTNL_FAMILY_IPMR 128
+#define RTNL_FAMILY_MAX 128
+
/****
* Routing/neighbour discovery messages.
****/
/****
* Routing/neighbour discovery messages.
****/
EXPORT_SYMBOL(lockdep_rtnl_is_held);
#endif /* #ifdef CONFIG_PROVE_LOCKING */
EXPORT_SYMBOL(lockdep_rtnl_is_held);
#endif /* #ifdef CONFIG_PROVE_LOCKING */
-static struct rtnl_link *rtnl_msg_handlers[NPROTO];
+static struct rtnl_link *rtnl_msg_handlers[RTNL_FAMILY_MAX + 1];
static inline int rtm_msgindex(int msgtype)
{
static inline int rtm_msgindex(int msgtype)
{
+ if (protocol <= RTNL_FAMILY_MAX)
tab = rtnl_msg_handlers[protocol];
else
tab = NULL;
tab = rtnl_msg_handlers[protocol];
else
tab = NULL;
+ if (protocol <= RTNL_FAMILY_MAX)
tab = rtnl_msg_handlers[protocol];
else
tab = NULL;
tab = rtnl_msg_handlers[protocol];
else
tab = NULL;
struct rtnl_link *tab;
int msgindex;
struct rtnl_link *tab;
int msgindex;
- BUG_ON(protocol < 0 || protocol >= NPROTO);
+ BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
msgindex = rtm_msgindex(msgtype);
tab = rtnl_msg_handlers[protocol];
msgindex = rtm_msgindex(msgtype);
tab = rtnl_msg_handlers[protocol];
- BUG_ON(protocol < 0 || protocol >= NPROTO);
+ BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
msgindex = rtm_msgindex(msgtype);
if (rtnl_msg_handlers[protocol] == NULL)
msgindex = rtm_msgindex(msgtype);
if (rtnl_msg_handlers[protocol] == NULL)
*/
void rtnl_unregister_all(int protocol)
{
*/
void rtnl_unregister_all(int protocol)
{
- BUG_ON(protocol < 0 || protocol >= NPROTO);
+ BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
kfree(rtnl_msg_handlers[protocol]);
rtnl_msg_handlers[protocol] = NULL;
kfree(rtnl_msg_handlers[protocol]);
rtnl_msg_handlers[protocol] = NULL;
if (s_idx == 0)
s_idx = 1;
if (s_idx == 0)
s_idx = 1;
- for (idx = 1; idx < NPROTO; idx++) {
+ for (idx = 1; idx <= RTNL_FAMILY_MAX; idx++) {
int type = cb->nlh->nlmsg_type-RTM_BASE;
if (idx < s_idx || idx == PF_PACKET)
continue;
int type = cb->nlh->nlmsg_type-RTM_BASE;
if (idx < s_idx || idx == PF_PACKET)
continue;
}
static const struct fib_rules_ops __net_initdata dn_fib_rules_ops_template = {
}
static const struct fib_rules_ops __net_initdata dn_fib_rules_ops_template = {
- .family = FIB_RULES_DECNET,
.rule_size = sizeof(struct dn_fib_rule),
.addr_size = sizeof(u16),
.action = dn_fib_rule_action,
.rule_size = sizeof(struct dn_fib_rule),
.addr_size = sizeof(u16),
.action = dn_fib_rule_action,
}
static const struct fib_rules_ops __net_initdata fib4_rules_ops_template = {
}
static const struct fib_rules_ops __net_initdata fib4_rules_ops_template = {
- .family = FIB_RULES_IPV4,
.rule_size = sizeof(struct fib4_rule),
.addr_size = sizeof(u32),
.action = fib4_rule_action,
.rule_size = sizeof(struct fib4_rule),
.addr_size = sizeof(u32),
.action = fib4_rule_action,
}
static const struct fib_rules_ops __net_initdata ipmr_rules_ops_template = {
}
static const struct fib_rules_ops __net_initdata ipmr_rules_ops_template = {
- .family = FIB_RULES_IPMR,
+ .family = RTNL_FAMILY_IPMR,
.rule_size = sizeof(struct ipmr_rule),
.addr_size = sizeof(u32),
.action = ipmr_rule_action,
.rule_size = sizeof(struct ipmr_rule),
.addr_size = sizeof(u32),
.action = ipmr_rule_action,
}
static const struct fib_rules_ops __net_initdata fib6_rules_ops_template = {
}
static const struct fib_rules_ops __net_initdata fib6_rules_ops_template = {
- .family = FIB_RULES_IPV6,
.rule_size = sizeof(struct fib6_rule),
.addr_size = sizeof(struct in6_addr),
.action = fib6_rule_action,
.rule_size = sizeof(struct fib6_rule),
.addr_size = sizeof(struct in6_addr),
.action = fib6_rule_action,