Commit 0f87b1dd01b51dc3c789f7a212656a4a87eee1bd
Committed by
David S. Miller
1 parent
28bb17268b
Exists in
master
and in
39 other branches
net: fib_rules: decouple address families from real address families
Decouple the address family values used for fib_rules from the real address families in socket.h. This allows to use fib_rules for code that is not a real address family without increasing AF_MAX/NPROTO. Values up to 127 are reserved for real address families and map directly to the corresponding AF value, values starting from 128 are for other uses. rtnetlink is changed to invoke the AF_UNSPEC dumpit/doit handlers for these families. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 5 changed files with 20 additions and 8 deletions Side-by-side Diff
include/linux/fib_rules.h
... | ... | @@ -15,6 +15,13 @@ |
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 | + | |
18 | 25 | struct fib_rule_hdr { |
19 | 26 | __u8 family; |
20 | 27 | __u8 dst_len; |
net/core/rtnetlink.c
... | ... | @@ -118,7 +118,11 @@ |
118 | 118 | { |
119 | 119 | struct rtnl_link *tab; |
120 | 120 | |
121 | - tab = rtnl_msg_handlers[protocol]; | |
121 | + if (protocol < NPROTO) | |
122 | + tab = rtnl_msg_handlers[protocol]; | |
123 | + else | |
124 | + tab = NULL; | |
125 | + | |
122 | 126 | if (tab == NULL || tab[msgindex].doit == NULL) |
123 | 127 | tab = rtnl_msg_handlers[PF_UNSPEC]; |
124 | 128 | |
... | ... | @@ -129,7 +133,11 @@ |
129 | 133 | { |
130 | 134 | struct rtnl_link *tab; |
131 | 135 | |
132 | - tab = rtnl_msg_handlers[protocol]; | |
136 | + if (protocol < NPROTO) | |
137 | + tab = rtnl_msg_handlers[protocol]; | |
138 | + else | |
139 | + tab = NULL; | |
140 | + | |
133 | 141 | if (tab == NULL || tab[msgindex].dumpit == NULL) |
134 | 142 | tab = rtnl_msg_handlers[PF_UNSPEC]; |
135 | 143 | |
... | ... | @@ -1444,9 +1452,6 @@ |
1444 | 1452 | return 0; |
1445 | 1453 | |
1446 | 1454 | family = ((struct rtgenmsg *)NLMSG_DATA(nlh))->rtgen_family; |
1447 | - if (family >= NPROTO) | |
1448 | - return -EAFNOSUPPORT; | |
1449 | - | |
1450 | 1455 | sz_idx = type>>2; |
1451 | 1456 | kind = type&3; |
1452 | 1457 |
net/decnet/dn_rules.c
net/ipv4/fib_rules.c
net/ipv6/fib6_rules.c