--- /sys/net/if_loop.c 2010-06-02 17:47:35.000000000 +0200 +++ if_loop.c 2011-03-06 03:00:22.000000000 +0100 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)if_loop.c 8.2 (Berkeley) 1/9/95 - * $FreeBSD: src/sys/net/if_loop.c,v 1.140.2.2 2010/05/31 22:18:42 rwatson Exp $ + * $FreeBSD: src/sys/net/if_loop.c,v 1.140.2.2.4.1 2010/12/21 17:09:25 kensmith Exp $ */ /* @@ -58,9 +58,15 @@ #include #include +#define LO_FLOWID + #ifdef INET #include #include +#ifdef LO_FLOWID +#include +#include +#endif #endif #ifdef IPX @@ -207,6 +213,28 @@ DECLARE_MODULE(if_lo, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); +#ifdef LO_FLOWID +static u_int +losimflowid(struct mbuf *m) +{ + u_int flowid = 0; +#ifdef INET + struct ip *ip = NULL; + struct tcphdr *th; + + ip = mtod(m, struct ip *); + flowid = ip->ip_src.s_addr ^ ip->ip_dst.s_addr; + + if (ip->ip_p == IPPROTO_TCP) { + /* XXX: th offset may not be correct */ + th = (struct tcphdr *)((caddr_t)ip + (ip->ip_hl << 2)); + flowid |= (th->th_dport << 16) | th->th_sport; + } +#endif + return (flowid); +} +#endif + int looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct route *ro) @@ -252,6 +280,10 @@ m->m_pkthdr.csum_flags = LO_CSUM_SET; } m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES; +#ifdef LO_FLOWID + m->m_flags |= M_FLOWID; + m->m_pkthdr.flowid = losimflowid(m); +#endif case AF_INET6: case AF_IPX: case AF_APPLETALK: