On Mon, Jan 23, 2017 at 01:18:05AM +0100, Claudio Jeker wrote:
> Last bit for now. This is changing the reporting madness. It moves it in
> its own function which is called after the big switch statement.
> If you hit a bad error in the switch the code should eiter goto fail or
> flush.
> The new function rt_report is actually constructing the rt message out of
> a rtentry. It does not magically update the message that was passed in
> from userland. I think this is much safer and works better.
OK bluhm@
> +rt_report(struct rtentry *rt, u_char type, int seq, int tableid)
...
> + ifp = if_get(rt->rt_ifidx);
> + if (ifp != NULL) {
> + info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl);
> + info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
> + if (ifp->if_flags & IFF_POINTOPOINT)
> + info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr;
> + }
> + if_put(ifp);
The if_put() could be in the if (ifp != NULL) block.
> flush:
> + if (rt)
> + rtfree(rt);
rtfree() checks (rt != NULL) itself.