Re: [PATCH net-next 8/8] net: ipv6: RTM_GETROUTE: return matched fib result when requested
From: Roopa Prabhu <hidden>
Date: 2017-05-25 15:54:58
On Wed, May 24, 2017 at 7:35 PM, David Ahern [off-list ref] wrote:
Since you have to do a v2 ... On 5/24/17 12:19 PM, Roopa Prabhu wrote:quoted
@@ -3622,6 +3623,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, memset(&fl6, 0, sizeof(fl6)); rtm = nlmsg_data(nlh); fl6.flowlabel = ip6_make_flowinfo(rtm->rtm_tos, 0); + fibmatch = (rtm->rtm_flags & RTM_F_FIB_MATCH) ? true : false;this is typically done as !!(rtm->rtm_flags & RTM_F_FIB_MATCH)
ack,
quoted
if (tb[RTA_SRC]) { if (nla_len(tb[RTA_SRC]) < sizeof(struct in6_addr))@@ -3667,12 +3669,27 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, if (!ipv6_addr_any(&fl6.saddr)) flags |= RT6_LOOKUP_F_HAS_SADDR; - rt = (struct rt6_info *)ip6_route_input_lookup(net, dev, &fl6, - flags); + if (!fibmatch) + rt = (struct rt6_info *)ip6_route_input_lookup(net, dev, + &fl6, + flags); } else { fl6.flowi6_oif = oif; - rt = (struct rt6_info *)ip6_route_output(net, NULL, &fl6); + if (!fibmatch) + rt = (struct rt6_info *)ip6_route_output_flags(net, + NULL, + &fl6, 0); + } + + if (fibmatch) { + rt = (struct rt6_info *)ip6_route_lookup(net, &fl6, 0); + if (rt->dst.error) { + err = rt->dst.error; + ip6_rt_put(rt); + goto errout; + } +I'd prefer to see the typecasts go away and use container_of to go from dst_entry to rt6_info. I realize some of this is movement of existing code, but better to clean up as we go.
ack. But that is pretty much all of ipv6 code. so, seems better done with an incremental cleanup patch. thanks for the review.