/* 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;
 
 {
        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];
 
 {
        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];
 
                return 0;
 
        family = ((struct rtgenmsg *)NLMSG_DATA(nlh))->rtgen_family;
-       if (family >= NPROTO)
-               return -EAFNOSUPPORT;
-
        sz_idx = type>>2;
        kind = type&3;
 
 
 }
 
 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,
 
 }
 
 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,
 
 }
 
 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,