diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2012-12-03 20:13:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-12-04 13:08:11 -0500 |
commit | 1eb99af52c4bc705f4042f37f255975acfc738f2 (patch) | |
tree | 7ccdd3e0185a44644cb68d9e3e1f6c46cab71943 /net/ipv6 | |
parent | 9a68ac72a44ecb6d4dc4a7cadf45e1a2cd183885 (diff) |
ipmr/ip6mr: allow to get unresolved cache via netlink
/proc/net/ip[6]_mr_cache allows to get all mfc entries, even if they are put in
the unresolved list (mfc[6]_unres_queue). But only the table RT_TABLE_DEFAULT is
displayed.
This patch adds the parsing of the unresolved list when the dump is made via
rtnetlink, hence each table can be checked.
In IPv6, we set rtm_type in ip6mr_fill_mroute(), because in case of unresolved
mfc __ip6mr_fill_mroute() will not set it. In IPv4, it is already done.
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ip6mr.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index d51b91122866..93a769891b72 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c | |||
@@ -2235,6 +2235,7 @@ static int ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, | |||
2235 | { | 2235 | { |
2236 | struct nlmsghdr *nlh; | 2236 | struct nlmsghdr *nlh; |
2237 | struct rtmsg *rtm; | 2237 | struct rtmsg *rtm; |
2238 | int err; | ||
2238 | 2239 | ||
2239 | nlh = nlmsg_put(skb, portid, seq, RTM_NEWROUTE, sizeof(*rtm), NLM_F_MULTI); | 2240 | nlh = nlmsg_put(skb, portid, seq, RTM_NEWROUTE, sizeof(*rtm), NLM_F_MULTI); |
2240 | if (nlh == NULL) | 2241 | if (nlh == NULL) |
@@ -2248,6 +2249,7 @@ static int ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, | |||
2248 | rtm->rtm_table = mrt->id; | 2249 | rtm->rtm_table = mrt->id; |
2249 | if (nla_put_u32(skb, RTA_TABLE, mrt->id)) | 2250 | if (nla_put_u32(skb, RTA_TABLE, mrt->id)) |
2250 | goto nla_put_failure; | 2251 | goto nla_put_failure; |
2252 | rtm->rtm_type = RTN_MULTICAST; | ||
2251 | rtm->rtm_scope = RT_SCOPE_UNIVERSE; | 2253 | rtm->rtm_scope = RT_SCOPE_UNIVERSE; |
2252 | if (c->mfc_flags & MFC_STATIC) | 2254 | if (c->mfc_flags & MFC_STATIC) |
2253 | rtm->rtm_protocol = RTPROT_STATIC; | 2255 | rtm->rtm_protocol = RTPROT_STATIC; |
@@ -2258,7 +2260,9 @@ static int ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, | |||
2258 | if (nla_put(skb, RTA_SRC, 16, &c->mf6c_origin) || | 2260 | if (nla_put(skb, RTA_SRC, 16, &c->mf6c_origin) || |
2259 | nla_put(skb, RTA_DST, 16, &c->mf6c_mcastgrp)) | 2261 | nla_put(skb, RTA_DST, 16, &c->mf6c_mcastgrp)) |
2260 | goto nla_put_failure; | 2262 | goto nla_put_failure; |
2261 | if (__ip6mr_fill_mroute(mrt, skb, c, rtm) < 0) | 2263 | err = __ip6mr_fill_mroute(mrt, skb, c, rtm); |
2264 | /* do not break the dump if cache is unresolved */ | ||
2265 | if (err < 0 && err != -ENOENT) | ||
2262 | goto nla_put_failure; | 2266 | goto nla_put_failure; |
2263 | 2267 | ||
2264 | return nlmsg_end(skb, nlh); | 2268 | return nlmsg_end(skb, nlh); |
@@ -2301,6 +2305,22 @@ next_entry: | |||
2301 | } | 2305 | } |
2302 | e = s_e = 0; | 2306 | e = s_e = 0; |
2303 | } | 2307 | } |
2308 | spin_lock_bh(&mfc_unres_lock); | ||
2309 | list_for_each_entry(mfc, &mrt->mfc6_unres_queue, list) { | ||
2310 | if (e < s_e) | ||
2311 | goto next_entry2; | ||
2312 | if (ip6mr_fill_mroute(mrt, skb, | ||
2313 | NETLINK_CB(cb->skb).portid, | ||
2314 | cb->nlh->nlmsg_seq, | ||
2315 | mfc) < 0) { | ||
2316 | spin_unlock_bh(&mfc_unres_lock); | ||
2317 | goto done; | ||
2318 | } | ||
2319 | next_entry2: | ||
2320 | e++; | ||
2321 | } | ||
2322 | spin_unlock_bh(&mfc_unres_lock); | ||
2323 | e = s_e = 0; | ||
2304 | s_h = 0; | 2324 | s_h = 0; |
2305 | next_table: | 2325 | next_table: |
2306 | t++; | 2326 | t++; |