svn commit: r192528 - head/sys/netinet
Robert Watson
rwatson at FreeBSD.org
Thu May 21 09:45:48 UTC 2009
Author: rwatson
Date: Thu May 21 09:45:47 2009
New Revision: 192528
URL: http://svn.freebsd.org/changeset/base/192528
Log:
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
Modified:
head/sys/netinet/ip_output.c
Modified: head/sys/netinet/ip_output.c
==============================================================================
--- head/sys/netinet/ip_output.c Thu May 21 07:55:25 2009 (r192527)
+++ head/sys/netinet/ip_output.c Thu May 21 09:45:47 2009 (r192528)
@@ -150,20 +150,25 @@ ip_output(struct mbuf *m, struct mbuf *o
#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;
}
More information about the svn-src-head
mailing list