Cleanup route_output() a bit.

MFC after:	1 month
This commit is contained in:
melifaro 2014-04-27 10:20:37 +00:00
parent bf1b5f8b0c
commit 29b944e3ac

View File

@ -530,6 +530,7 @@ route_output(struct mbuf *m, struct socket *so)
struct ifnet *ifp = NULL; struct ifnet *ifp = NULL;
union sockaddr_union saun; union sockaddr_union saun;
sa_family_t saf = AF_UNSPEC; sa_family_t saf = AF_UNSPEC;
struct rawcb *rp = NULL;
fibnum = so->so_fibnum; fibnum = so->so_fibnum;
@ -819,22 +820,14 @@ report:
} }
flush: flush:
if (rtm) { if (rt != NULL)
if (error)
rtm->rtm_errno = error;
else
rtm->rtm_flags |= RTF_DONE;
}
if (rt) /* XXX can this be true? */
RTFREE(rt); RTFREE(rt);
{
struct rawcb *rp = NULL;
/* /*
* Check to see if we don't want our own messages. * Check to see if we don't want our own messages.
*/ */
if ((so->so_options & SO_USELOOPBACK) == 0) { if ((so->so_options & SO_USELOOPBACK) == 0) {
if (V_route_cb.any_count <= 1) { if (V_route_cb.any_count <= 1) {
if (rtm) if (rtm != NULL)
Free(rtm); Free(rtm);
m_freem(m); m_freem(m);
return (error); return (error);
@ -842,6 +835,7 @@ flush:
/* There is another listener, so construct message */ /* There is another listener, so construct message */
rp = sotorawcb(so); rp = sotorawcb(so);
} }
if (rtm != NULL) { if (rtm != NULL) {
#ifdef INET6 #ifdef INET6
if (rti_need_deembed) { if (rti_need_deembed) {
@ -859,6 +853,11 @@ flush:
} }
} }
#endif #endif
if (error != 0)
rtm->rtm_errno = error;
else
rtm->rtm_flags |= RTF_DONE;
m_copyback(m, 0, rtm->rtm_msglen, (caddr_t)rtm); m_copyback(m, 0, rtm->rtm_msglen, (caddr_t)rtm);
if (m->m_pkthdr.len < rtm->rtm_msglen) { if (m->m_pkthdr.len < rtm->rtm_msglen) {
m_freem(m); m_freem(m);
@ -867,7 +866,7 @@ flush:
m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len); m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len);
Free(rtm); Free(rtm);
} }
if (m) { if (m != NULL) {
M_SETFIB(m, fibnum); M_SETFIB(m, fibnum);
m->m_flags |= RTS_FILTER_FIB; m->m_flags |= RTS_FILTER_FIB;
if (rp) { if (rp) {
@ -882,7 +881,7 @@ flush:
} else } else
rt_dispatch(m, saf); rt_dispatch(m, saf);
} }
}
return (error); return (error);
} }