]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
net: fib_rules: decouple address families from real address families
authorPatrick McHardy <kaber@trash.net>
Tue, 13 Apr 2010 05:03:17 +0000 (05:03 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 13 Apr 2010 21:49:31 +0000 (14:49 -0700)
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>
include/linux/fib_rules.h
net/core/rtnetlink.c
net/decnet/dn_rules.c
net/ipv4/fib_rules.c
net/ipv6/fib6_rules.c

index 51da65b68b8501cb2d25fe0064c2c6ff65e3d4e6..405e41139a4d04923d2dae344c61a9a06b4e894c 100644 (file)
 /* 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
+
 struct fib_rule_hdr {
        __u8            family;
        __u8            dst_len;
index bf919b6acea20a9f33ef5ad3c747b43b70a9f79a..78c85985cb30a754d58efa293799d3581639e2a3 100644 (file)
@@ -118,7 +118,11 @@ static rtnl_doit_func rtnl_get_doit(int protocol, int msgindex)
 {
        struct rtnl_link *tab;
 
-       tab = rtnl_msg_handlers[protocol];
+       if (protocol < NPROTO)
+               tab = rtnl_msg_handlers[protocol];
+       else
+               tab = NULL;
+
        if (tab == NULL || tab[msgindex].doit == NULL)
                tab = rtnl_msg_handlers[PF_UNSPEC];
 
@@ -129,7 +133,11 @@ static rtnl_dumpit_func rtnl_get_dumpit(int protocol, int msgindex)
 {
        struct rtnl_link *tab;
 
-       tab = rtnl_msg_handlers[protocol];
+       if (protocol < NPROTO)
+               tab = rtnl_msg_handlers[protocol];
+       else
+               tab = NULL;
+
        if (tab == NULL || tab[msgindex].dumpit == NULL)
                tab = rtnl_msg_handlers[PF_UNSPEC];
 
@@ -1444,9 +1452,6 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
                return 0;
 
        family = ((struct rtgenmsg *)NLMSG_DATA(nlh))->rtgen_family;
-       if (family >= NPROTO)
-               return -EAFNOSUPPORT;
-
        sz_idx = type>>2;
        kind = type&3;
 
index 1c8cc6d5b645b5ef16da1d9ccd14a4536e24a3ab..af28dcc2184494b5528c8ad0cade76e1f450219f 100644 (file)
@@ -217,7 +217,7 @@ static void dn_fib_rule_flush_cache(struct fib_rules_ops *ops)
 }
 
 static struct fib_rules_ops dn_fib_rules_ops_template = {
-       .family         = AF_DECnet,
+       .family         = FIB_RULES_DECNET,
        .rule_size      = sizeof(struct dn_fib_rule),
        .addr_size      = sizeof(u16),
        .action         = dn_fib_rule_action,
index a18355e1511105804f800a59b5f4c3b5eac77abc..3ec84fea5b71bbc85891b55ba8c30a38472a075c 100644 (file)
@@ -246,7 +246,7 @@ static void fib4_rule_flush_cache(struct fib_rules_ops *ops)
 }
 
 static struct fib_rules_ops fib4_rules_ops_template = {
-       .family         = AF_INET,
+       .family         = FIB_RULES_IPV4,
        .rule_size      = sizeof(struct fib4_rule),
        .addr_size      = sizeof(u32),
        .action         = fib4_rule_action,
index 92b2b7fb6c3d91131c2790113ab24240f32fc90d..8124f16f2ac2684e1c132eae686762e2848bae6e 100644 (file)
@@ -238,7 +238,7 @@ static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule)
 }
 
 static struct fib_rules_ops fib6_rules_ops_template = {
-       .family                 = AF_INET6,
+       .family                 = FIB_RULES_IPV6,
        .rule_size              = sizeof(struct fib6_rule),
        .addr_size              = sizeof(struct in6_addr),
        .action                 = fib6_rule_action,