Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: rtnetlink: decouple rtnetlink address families from real address families

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>

+17 -19
-8
include/linux/fib_rules.h
··· 15 15 /* try to find source address in routing lookups */ 16 16 #define FIB_RULE_FIND_SADDR 0x00010000 17 17 18 - /* fib_rules families. values up to 127 are reserved for real address 19 - * families, values above 128 may be used arbitrarily. 20 - */ 21 - #define FIB_RULES_IPV4 AF_INET 22 - #define FIB_RULES_IPV6 AF_INET6 23 - #define FIB_RULES_DECNET AF_DECnet 24 - #define FIB_RULES_IPMR 128 25 - 26 18 struct fib_rule_hdr { 27 19 __u8 family; 28 20 __u8 dst_len;
+6
include/linux/rtnetlink.h
··· 7 7 #include <linux/if_addr.h> 8 8 #include <linux/neighbour.h> 9 9 10 + /* rtnetlink families. Values up to 127 are reserved for real address 11 + * families, values above 128 may be used arbitrarily. 12 + */ 13 + #define RTNL_FAMILY_IPMR 128 14 + #define RTNL_FAMILY_MAX 128 15 + 10 16 /**** 11 17 * Routing/neighbour discovery messages. 12 18 ****/
+7 -7
net/core/rtnetlink.c
··· 98 98 EXPORT_SYMBOL(lockdep_rtnl_is_held); 99 99 #endif /* #ifdef CONFIG_PROVE_LOCKING */ 100 100 101 - static struct rtnl_link *rtnl_msg_handlers[NPROTO]; 101 + static struct rtnl_link *rtnl_msg_handlers[RTNL_FAMILY_MAX + 1]; 102 102 103 103 static inline int rtm_msgindex(int msgtype) 104 104 { ··· 118 118 { 119 119 struct rtnl_link *tab; 120 120 121 - if (protocol < NPROTO) 121 + if (protocol <= RTNL_FAMILY_MAX) 122 122 tab = rtnl_msg_handlers[protocol]; 123 123 else 124 124 tab = NULL; ··· 133 133 { 134 134 struct rtnl_link *tab; 135 135 136 - if (protocol < NPROTO) 136 + if (protocol <= RTNL_FAMILY_MAX) 137 137 tab = rtnl_msg_handlers[protocol]; 138 138 else 139 139 tab = NULL; ··· 167 167 struct rtnl_link *tab; 168 168 int msgindex; 169 169 170 - BUG_ON(protocol < 0 || protocol >= NPROTO); 170 + BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX); 171 171 msgindex = rtm_msgindex(msgtype); 172 172 173 173 tab = rtnl_msg_handlers[protocol]; ··· 219 219 { 220 220 int msgindex; 221 221 222 - BUG_ON(protocol < 0 || protocol >= NPROTO); 222 + BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX); 223 223 msgindex = rtm_msgindex(msgtype); 224 224 225 225 if (rtnl_msg_handlers[protocol] == NULL) ··· 241 241 */ 242 242 void rtnl_unregister_all(int protocol) 243 243 { 244 - BUG_ON(protocol < 0 || protocol >= NPROTO); 244 + BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX); 245 245 246 246 kfree(rtnl_msg_handlers[protocol]); 247 247 rtnl_msg_handlers[protocol] = NULL; ··· 1384 1384 1385 1385 if (s_idx == 0) 1386 1386 s_idx = 1; 1387 - for (idx = 1; idx < NPROTO; idx++) { 1387 + for (idx = 1; idx <= RTNL_FAMILY_MAX; idx++) { 1388 1388 int type = cb->nlh->nlmsg_type-RTM_BASE; 1389 1389 if (idx < s_idx || idx == PF_PACKET) 1390 1390 continue;
+1 -1
net/decnet/dn_rules.c
··· 217 217 } 218 218 219 219 static const struct fib_rules_ops __net_initdata dn_fib_rules_ops_template = { 220 - .family = FIB_RULES_DECNET, 220 + .family = AF_DECnet, 221 221 .rule_size = sizeof(struct dn_fib_rule), 222 222 .addr_size = sizeof(u16), 223 223 .action = dn_fib_rule_action,
+1 -1
net/ipv4/fib_rules.c
··· 246 246 } 247 247 248 248 static const struct fib_rules_ops __net_initdata fib4_rules_ops_template = { 249 - .family = FIB_RULES_IPV4, 249 + .family = AF_INET, 250 250 .rule_size = sizeof(struct fib4_rule), 251 251 .addr_size = sizeof(u32), 252 252 .action = fib4_rule_action,
+1 -1
net/ipv4/ipmr.c
··· 217 217 } 218 218 219 219 static const struct fib_rules_ops __net_initdata ipmr_rules_ops_template = { 220 - .family = FIB_RULES_IPMR, 220 + .family = RTNL_FAMILY_IPMR, 221 221 .rule_size = sizeof(struct ipmr_rule), 222 222 .addr_size = sizeof(u32), 223 223 .action = ipmr_rule_action,
+1 -1
net/ipv6/fib6_rules.c
··· 238 238 } 239 239 240 240 static const struct fib_rules_ops __net_initdata fib6_rules_ops_template = { 241 - .family = FIB_RULES_IPV6, 241 + .family = AF_INET6, 242 242 .rule_size = sizeof(struct fib6_rule), 243 243 .addr_size = sizeof(struct in6_addr), 244 244 .action = fib6_rule_action,