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

Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kaber/ipmr-2.6

+112 -32
-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 ****/
+1 -1
include/net/fib_rules.h
··· 104 104 return frh->table; 105 105 } 106 106 107 - extern struct fib_rules_ops *fib_rules_register(struct fib_rules_ops *, struct net *); 107 + extern struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *, struct net *); 108 108 extern void fib_rules_unregister(struct fib_rules_ops *); 109 109 extern void fib_rules_cleanup_ops(struct fib_rules_ops *); 110 110
+1 -1
net/core/fib_rules.c
··· 122 122 } 123 123 124 124 struct fib_rules_ops * 125 - fib_rules_register(struct fib_rules_ops *tmpl, struct net *net) 125 + fib_rules_register(const struct fib_rules_ops *tmpl, struct net *net) 126 126 { 127 127 struct fib_rules_ops *ops; 128 128 int err;
+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; ··· 1385 1385 1386 1386 if (s_idx == 0) 1387 1387 s_idx = 1; 1388 - for (idx = 1; idx < NPROTO; idx++) { 1388 + for (idx = 1; idx <= RTNL_FAMILY_MAX; idx++) { 1389 1389 int type = cb->nlh->nlmsg_type-RTM_BASE; 1390 1390 if (idx < s_idx || idx == PF_PACKET) 1391 1391 continue;
+2 -2
net/decnet/dn_rules.c
··· 216 216 dn_rt_cache_flush(-1); 217 217 } 218 218 219 - static struct fib_rules_ops dn_fib_rules_ops_template = { 220 - .family = FIB_RULES_DECNET, 219 + static const struct fib_rules_ops __net_initdata dn_fib_rules_ops_template = { 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,
+2 -2
net/ipv4/fib_rules.c
··· 245 245 rt_cache_flush(ops->fro_net, -1); 246 246 } 247 247 248 - static struct fib_rules_ops fib4_rules_ops_template = { 249 - .family = FIB_RULES_IPV4, 248 + static const struct fib_rules_ops __net_initdata fib4_rules_ops_template = { 249 + .family = AF_INET, 250 250 .rule_size = sizeof(struct fib4_rule), 251 251 .addr_size = sizeof(u32), 252 252 .action = fib4_rule_action,
+91 -9
net/ipv4/ipmr.c
··· 128 128 int local); 129 129 static int ipmr_cache_report(struct mr_table *mrt, 130 130 struct sk_buff *pkt, vifi_t vifi, int assert); 131 - static int ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, 132 - struct mfc_cache *c, struct rtmsg *rtm); 131 + static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, 132 + struct mfc_cache *c, struct rtmsg *rtm); 133 133 static void ipmr_expire_process(unsigned long arg); 134 134 135 135 #ifdef CONFIG_IP_MROUTE_MULTIPLE_TABLES ··· 216 216 return 0; 217 217 } 218 218 219 - static struct fib_rules_ops ipmr_rules_ops_template = { 220 - .family = FIB_RULES_IPMR, 219 + static const struct fib_rules_ops __net_initdata ipmr_rules_ops_template = { 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, ··· 831 831 if (ip_hdr(skb)->version == 0) { 832 832 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr)); 833 833 834 - if (ipmr_fill_mroute(mrt, skb, c, NLMSG_DATA(nlh)) > 0) { 834 + if (__ipmr_fill_mroute(mrt, skb, c, NLMSG_DATA(nlh)) > 0) { 835 835 nlh->nlmsg_len = (skb_tail_pointer(skb) - 836 836 (u8 *)nlh); 837 837 } else { ··· 1904 1904 } 1905 1905 #endif 1906 1906 1907 - static int 1908 - ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, struct mfc_cache *c, 1909 - struct rtmsg *rtm) 1907 + static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, 1908 + struct mfc_cache *c, struct rtmsg *rtm) 1910 1909 { 1911 1910 int ct; 1912 1911 struct rtnexthop *nhp; ··· 1993 1994 1994 1995 if (!nowait && (rtm->rtm_flags&RTM_F_NOTIFY)) 1995 1996 cache->mfc_flags |= MFC_NOTIFY; 1996 - err = ipmr_fill_mroute(mrt, skb, cache, rtm); 1997 + err = __ipmr_fill_mroute(mrt, skb, cache, rtm); 1997 1998 read_unlock(&mrt_lock); 1998 1999 return err; 2000 + } 2001 + 2002 + static int ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, 2003 + u32 pid, u32 seq, struct mfc_cache *c) 2004 + { 2005 + struct nlmsghdr *nlh; 2006 + struct rtmsg *rtm; 2007 + 2008 + nlh = nlmsg_put(skb, pid, seq, RTM_NEWROUTE, sizeof(*rtm), NLM_F_MULTI); 2009 + if (nlh == NULL) 2010 + return -EMSGSIZE; 2011 + 2012 + rtm = nlmsg_data(nlh); 2013 + rtm->rtm_family = RTNL_FAMILY_IPMR; 2014 + rtm->rtm_dst_len = 32; 2015 + rtm->rtm_src_len = 32; 2016 + rtm->rtm_tos = 0; 2017 + rtm->rtm_table = mrt->id; 2018 + NLA_PUT_U32(skb, RTA_TABLE, mrt->id); 2019 + rtm->rtm_type = RTN_MULTICAST; 2020 + rtm->rtm_scope = RT_SCOPE_UNIVERSE; 2021 + rtm->rtm_protocol = RTPROT_UNSPEC; 2022 + rtm->rtm_flags = 0; 2023 + 2024 + NLA_PUT_BE32(skb, RTA_SRC, c->mfc_origin); 2025 + NLA_PUT_BE32(skb, RTA_DST, c->mfc_mcastgrp); 2026 + 2027 + if (__ipmr_fill_mroute(mrt, skb, c, rtm) < 0) 2028 + goto nla_put_failure; 2029 + 2030 + return nlmsg_end(skb, nlh); 2031 + 2032 + nla_put_failure: 2033 + nlmsg_cancel(skb, nlh); 2034 + return -EMSGSIZE; 2035 + } 2036 + 2037 + static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb) 2038 + { 2039 + struct net *net = sock_net(skb->sk); 2040 + struct mr_table *mrt; 2041 + struct mfc_cache *mfc; 2042 + unsigned int t = 0, s_t; 2043 + unsigned int h = 0, s_h; 2044 + unsigned int e = 0, s_e; 2045 + 2046 + s_t = cb->args[0]; 2047 + s_h = cb->args[1]; 2048 + s_e = cb->args[2]; 2049 + 2050 + read_lock(&mrt_lock); 2051 + ipmr_for_each_table(mrt, net) { 2052 + if (t < s_t) 2053 + goto next_table; 2054 + if (t > s_t) 2055 + s_h = 0; 2056 + for (h = s_h; h < MFC_LINES; h++) { 2057 + list_for_each_entry(mfc, &mrt->mfc_cache_array[h], list) { 2058 + if (e < s_e) 2059 + goto next_entry; 2060 + if (ipmr_fill_mroute(mrt, skb, 2061 + NETLINK_CB(cb->skb).pid, 2062 + cb->nlh->nlmsg_seq, 2063 + mfc) < 0) 2064 + goto done; 2065 + next_entry: 2066 + e++; 2067 + } 2068 + e = s_e = 0; 2069 + } 2070 + s_h = 0; 2071 + next_table: 2072 + t++; 2073 + } 2074 + done: 2075 + read_unlock(&mrt_lock); 2076 + 2077 + cb->args[2] = e; 2078 + cb->args[1] = h; 2079 + cb->args[0] = t; 2080 + 2081 + return skb->len; 1999 2082 } 2000 2083 2001 2084 #ifdef CONFIG_PROC_FS ··· 2436 2355 goto add_proto_fail; 2437 2356 } 2438 2357 #endif 2358 + rtnl_register(RTNL_FAMILY_IPMR, RTM_GETROUTE, NULL, ipmr_rtm_dumproute); 2439 2359 return 0; 2440 2360 2441 2361 #ifdef CONFIG_IP_PIMSM_V2
+2 -2
net/ipv6/fib6_rules.c
··· 237 237 + nla_total_size(16); /* src */ 238 238 } 239 239 240 - static struct fib_rules_ops fib6_rules_ops_template = { 241 - .family = FIB_RULES_IPV6, 240 + static const struct fib_rules_ops __net_initdata fib6_rules_ops_template = { 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,