diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-05-21 09:45:47 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-05-21 09:45:47 +0000 |
commit | 5389d28839955310ce59bac13d686191b38821fd (patch) | |
tree | 63afd182320ff3bc3abd61ae4ea374b28159ca91 /sys/netinet | |
parent | a5ab91191fe8ddca45603099442b778727c6589a (diff) | |
download | FreeBSD-src-5389d28839955310ce59bac13d686191b38821fd.zip FreeBSD-src-5389d28839955310ce59bac13d686191b38821fd.tar.gz |
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
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/ip_output.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 35905e8..6e4f879 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -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; } |