aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-04-13 01:03:17 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-13 17:49:31 -0400
commit0f87b1dd01b51dc3c789f7a212656a4a87eee1bd (patch)
tree2ce87a26afecd5c0400a6e743534a402a6ca8aec
parent28bb17268b92b0c568f2496e5e631008f9108409 (diff)
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>
-rw-r--r--include/linux/fib_rules.h7
-rw-r--r--net/core/rtnetlink.c15
-rw-r--r--net/decnet/dn_rules.c2
-rw-r--r--net/ipv4/fib_rules.c2
-rw-r--r--net/ipv6/fib6_rules.c2
5 files changed, 20 insertions, 8 deletions
diff --git a/include/linux/fib_rules.h b/include/linux/fib_rules.h
index 51da65b68b85..405e41139a4d 100644
--- a/include/linux/fib_rules.h
+++ b/include/linux/fib_rules.h
@@ -15,6 +15,13 @@
15/* try to find source address in routing lookups */ 15/* try to find source address in routing lookups */
16#define FIB_RULE_FIND_SADDR 0x00010000 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
18struct fib_rule_hdr { 25struct fib_rule_hdr {
19 __u8 family; 26 __u8 family;
20 __u8 dst_len; 27 __u8 dst_len;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index bf919b6acea2..78c85985cb30 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -118,7 +118,11 @@ static rtnl_doit_func rtnl_get_doit(int protocol, int msgindex)
118{ 118{
119 struct rtnl_link *tab; 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 if (tab == NULL || tab[msgindex].doit == NULL) 126 if (tab == NULL || tab[msgindex].doit == NULL)
123 tab = rtnl_msg_handlers[PF_UNSPEC]; 127 tab = rtnl_msg_handlers[PF_UNSPEC];
124 128
@@ -129,7 +133,11 @@ static rtnl_dumpit_func rtnl_get_dumpit(int protocol, int msgindex)
129{ 133{
130 struct rtnl_link *tab; 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 if (tab == NULL || tab[msgindex].dumpit == NULL) 141 if (tab == NULL || tab[msgindex].dumpit == NULL)
134 tab = rtnl_msg_handlers[PF_UNSPEC]; 142 tab = rtnl_msg_handlers[PF_UNSPEC];
135 143
@@ -1444,9 +1452,6 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1444 return 0; 1452 return 0;
1445 1453
1446 family = ((struct rtgenmsg *)NLMSG_DATA(nlh))->rtgen_family; 1454 family = ((struct rtgenmsg *)NLMSG_DATA(nlh))->rtgen_family;
1447 if (family >= NPROTO)
1448 return -EAFNOSUPPORT;
1449
1450 sz_idx = type>>2; 1455 sz_idx = type>>2;
1451 kind = type&3; 1456 kind = type&3;
1452 1457
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index 1c8cc6d5b645..af28dcc21844 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -217,7 +217,7 @@ static void dn_fib_rule_flush_cache(struct fib_rules_ops *ops)
217} 217}
218 218
219static struct fib_rules_ops dn_fib_rules_ops_template = { 219static struct fib_rules_ops dn_fib_rules_ops_template = {
220 .family = AF_DECnet, 220 .family = FIB_RULES_DECNET,
221 .rule_size = sizeof(struct dn_fib_rule), 221 .rule_size = sizeof(struct dn_fib_rule),
222 .addr_size = sizeof(u16), 222 .addr_size = sizeof(u16),
223 .action = dn_fib_rule_action, 223 .action = dn_fib_rule_action,
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index a18355e15111..3ec84fea5b71 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -246,7 +246,7 @@ static void fib4_rule_flush_cache(struct fib_rules_ops *ops)
246} 246}
247 247
248static struct fib_rules_ops fib4_rules_ops_template = { 248static struct fib_rules_ops fib4_rules_ops_template = {
249 .family = AF_INET, 249 .family = FIB_RULES_IPV4,
250 .rule_size = sizeof(struct fib4_rule), 250 .rule_size = sizeof(struct fib4_rule),
251 .addr_size = sizeof(u32), 251 .addr_size = sizeof(u32),
252 .action = fib4_rule_action, 252 .action = fib4_rule_action,
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 92b2b7fb6c3d..8124f16f2ac2 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -238,7 +238,7 @@ static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule)
238} 238}
239 239
240static struct fib_rules_ops fib6_rules_ops_template = { 240static struct fib_rules_ops fib6_rules_ops_template = {
241 .family = AF_INET6, 241 .family = FIB_RULES_IPV6,
242 .rule_size = sizeof(struct fib6_rule), 242 .rule_size = sizeof(struct fib6_rule),
243 .addr_size = sizeof(struct in6_addr), 243 .addr_size = sizeof(struct in6_addr),
244 .action = fib6_rule_action, 244 .action = fib6_rule_action,