Consolidate and clean up the first section of ip_output.c in light of the

last year or two's work on routing:

- Combine iproute initialization and flowtable lookup blocks, eliminating
  unnecessary tests for known-zero'd iproute fields.

- Add a comment indicating (a) why the route entry returned by the
  flowtable is considered stable and (b) that the flowtable lookup must
  occur after the setup of the mbuf flow ID.

- Assert the inpcb lock before any use of inpcb fields.

Reviewed by:	kmacy
This commit is contained in:
Robert Watson 2009-05-21 09:45:47 +00:00
parent c3e8a58723
commit 62e1ba833c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=192528

View File

@ -150,20 +150,25 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
#endif
M_ASSERTPKTHDR(m);
if (ro == NULL) {
ro = &iproute;
bzero(ro, sizeof (*ro));
}
if (inp != NULL) {
M_SETFIB(m, inp->inp_inc.inc_fibnum);
INP_LOCK_ASSERT(inp);
M_SETFIB(m, inp->inp_inc.inc_fibnum);
if (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) {
m->m_pkthdr.flowid = inp->inp_flowid;
m->m_flags |= M_FLOWID;
}
}
if ((ro == &iproute) && (ro->ro_rt == NULL) && (ro->ro_lle == NULL)) {
if (ro == NULL) {
ro = &iproute;
bzero(ro, sizeof (*ro));
/*
* The flow table returns route entries valid for up to 30
* seconds; we rely on the remainder of ip_output() taking no
* longer than that long for the stability of ro_rt. The
* flow ID assignment must have happened before this point.
*/
if (flowtable_lookup(ip_ft, m, ro) == 0)
nortfree = 1;
}