? cscope.out ? netinet/tt Index: conf/GENERIC =================================================================== RCS file: /cvs/src/sys/conf/GENERIC,v retrieving revision 1.134 diff -u -p -r1.134 GENERIC --- conf/GENERIC 15 Jun 2007 23:01:42 -0000 1.134 +++ conf/GENERIC 25 Sep 2007 12:40:40 -0000 @@ -7,7 +7,7 @@ option DDB # in-kernel debugger #option DDB_SAFE_CONSOLE # allow break into ddb during boot -#makeoptions DEBUG="-g" # compile full symbol table +makeoptions DEBUG="-g" # compile full symbol table #makeoptions PROF="-pg" # build profiled kernel #option GPROF # kernel profiling, kgmon(8) option DIAGNOSTIC # internal consistency checks Index: dev/pci/if_bnx.c =================================================================== RCS file: /cvs/src/sys/dev/pci/if_bnx.c,v retrieving revision 1.54 diff -u -p -r1.54 if_bnx.c --- dev/pci/if_bnx.c 28 Aug 2007 18:34:38 -0000 1.54 +++ dev/pci/if_bnx.c 25 Sep 2007 12:40:41 -0000 @@ -756,6 +756,9 @@ bnx_attach_fail: DBPRINT(sc, BNX_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); } +int bnxscaletx = 2; +int bnxscalerx = 2; + void bnx_attachhook(void *xsc) { @@ -813,15 +816,15 @@ bnx_attachhook(void *xsc) sc->bnx_rx_ticks_int = 0; sc->bnx_rx_ticks = 0; #else - sc->bnx_tx_quick_cons_trip_int = 20; - sc->bnx_tx_quick_cons_trip = 20; - sc->bnx_tx_ticks_int = 80; - sc->bnx_tx_ticks = 80; - - sc->bnx_rx_quick_cons_trip_int = 6; - sc->bnx_rx_quick_cons_trip = 6; - sc->bnx_rx_ticks_int = 18; - sc->bnx_rx_ticks = 18; + sc->bnx_tx_quick_cons_trip_int = 20 * bnxscaletx; + sc->bnx_tx_quick_cons_trip = 20 * bnxscaletx; + sc->bnx_tx_ticks_int = 80 * bnxscaletx; + sc->bnx_tx_ticks = 80 * bnxscaletx; + + sc->bnx_rx_quick_cons_trip_int = 6 * bnxscalerx; + sc->bnx_rx_quick_cons_trip = 6 * bnxscalerx; + sc->bnx_rx_ticks_int = 18 * bnxscalerx; + sc->bnx_rx_ticks = 18 * bnxscalerx; #endif /* Update statistics once every second. */ Index: kern/uipc_mbuf.c =================================================================== RCS file: /cvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.85 diff -u -p -r1.85 uipc_mbuf.c --- kern/uipc_mbuf.c 20 Jul 2007 09:59:19 -0000 1.85 +++ kern/uipc_mbuf.c 25 Sep 2007 12:40:41 -0000 @@ -199,6 +199,7 @@ m_gethdr(int nowait, int type) m->m_pkthdr.pf.tag = 0; m->m_pkthdr.pf.flags = 0; m->m_pkthdr.pf.routed = 0; + m->m_pkthdr.pf_st_in = 0; } splx(s); return (m); Index: net/if_trunk.c =================================================================== RCS file: /cvs/src/sys/net/if_trunk.c,v retrieving revision 1.36 diff -u -p -r1.36 if_trunk.c --- net/if_trunk.c 15 Sep 2007 16:43:51 -0000 1.36 +++ net/if_trunk.c 25 Sep 2007 12:40:41 -0000 @@ -258,11 +258,12 @@ trunk_capabilities(struct trunk_softc *t SLIST_FOREACH(tp, &tr->tr_ports, tp_entries) cap &= tp->tp_capabilities; - if (tr->tr_ifflags & IFF_DEBUG) { +// if (tr->tr_ifflags & IFF_DEBUG) { printf("%s: capabilities 0x%08x\n", tr->tr_ifname, cap == ~0 ? priv : (cap | priv)); - } +// } + printf("%s: returning %08x (cap: %08x, priv: %08x)\n", tr->tr_ifname, (cap == ~0 ? priv : (cap | priv)), cap, priv); return (cap == ~0 ? priv : (cap | priv)); } @@ -695,7 +696,7 @@ trunk_ioctl(struct ifnet *ifp, u_long cm error = ENETRESET; break; case SIOCSIFMTU: - if (ifr->ifr_mtu > ETHERMTU) { + if (ifr->ifr_mtu > ETHERMTU + 4) { error = EINVAL; break; } Index: net/pf.c =================================================================== RCS file: /cvs/src/sys/net/pf.c,v retrieving revision 1.559 diff -u -p -r1.559 pf.c --- net/pf.c 18 Sep 2007 18:45:59 -0000 1.559 +++ net/pf.c 25 Sep 2007 12:40:41 -0000 @@ -178,7 +178,7 @@ int pf_test_state_icmp(struct pf_stat struct pfi_kif *, struct mbuf *, int, void *, struct pf_pdesc *, u_short *); int pf_test_state_other(struct pf_state **, int, - struct pfi_kif *, struct pf_pdesc *); + struct pfi_kif *, struct pf_pdesc *, struct mbuf *); int pf_match_tag(struct mbuf *, struct pf_rule *, int *); void pf_step_into_anchor(int *, struct pf_ruleset **, int, struct pf_rule **, struct pf_rule **, int *); @@ -233,7 +233,12 @@ struct pf_pool_limit pf_pool_limits[PF_L #define STATE_LOOKUP() \ do { \ - *state = pf_find_state(kif, &key, direction); \ + if (direction == PF_OUT && (m->m_flags & M_PKTHDR) && \ + m->m_pkthdr.pf_st_in != NULL \ + && (*state = m->m_pkthdr.pf_st_in->pf_st_out) != NULL) \ + pf_status.lcounters[LCNT_OVERLOAD_TABLE]++; \ + else \ + *state = pf_find_state(kif, &key, direction); \ if (*state == NULL || (*state)->timeout == PFTM_PURGE) \ return (PF_DROP); \ if (direction == PF_OUT && \ @@ -1030,6 +1035,10 @@ pf_free_state(struct pf_state *cur) TAILQ_REMOVE(&state_list, cur, entry_list); if (cur->tag) pf_tag_unref(cur->tag); + if (cur->ro.ro_rt) { + RTFREE(cur->ro.ro_rt); + cur->ro.ro_rt = NULL; + } pool_put(&pf_state_pl, cur); pf_status.fcounters[FCNT_STATE_REMOVALS]++; pf_status.states--; @@ -4732,7 +4741,7 @@ pf_test_state_icmp(struct pf_state **sta int pf_test_state_other(struct pf_state **state, int direction, struct pfi_kif *kif, - struct pf_pdesc *pd) + struct pf_pdesc *pd, struct mbuf *m) { struct pf_state_peer *src, *dst; struct pf_state_key_cmp key; @@ -5392,6 +5401,8 @@ pf_check_proto_cksum(struct mbuf *m, int return (0); } +int pf_cachedoutstate = 0; + #ifdef INET int pf_test(int dir, struct ifnet *ifp, struct mbuf **m0, @@ -5560,7 +5571,7 @@ pf_test(int dir, struct ifnet *ifp, stru } default: - action = pf_test_state_other(&s, dir, kif, &pd); + action = pf_test_state_other(&s, dir, kif, &pd, m); if (action == PF_PASS) { #if NPFSYNC pfsync_update_state(s); @@ -5696,6 +5707,16 @@ done: } else if (r->rt) /* pf_route can free the mbuf causing *m0 to become NULL */ pf_route(m0, r, dir, kif->pfik_ifp, s, &pd); + else if (dir == PF_IN && action == PF_PASS) { + /* save the "input" state so that we can cache the outgoing + * route to be used in ip_forward */ + KASSERT(m->m_flags & M_PKTHDR); + m->m_pkthdr.pf_st_in = s; + } else if (dir == PF_OUT && action == PF_PASS && + m->m_pkthdr.pf_st_in != NULL) { + pf_cachedoutstate++; + m->m_pkthdr.pf_st_in->pf_st_out = s; + } return (action); } @@ -5935,7 +5956,7 @@ pf_test6(int dir, struct ifnet *ifp, str } default: - action = pf_test_state_other(&s, dir, kif, &pd); + action = pf_test_state_other(&s, dir, kif, &pd, m); if (action == PF_PASS) { #if NPFSYNC pfsync_update_state(s); Index: net/pfvar.h =================================================================== RCS file: /cvs/src/sys/net/pfvar.h,v retrieving revision 1.257 diff -u -p -r1.257 pfvar.h --- net/pfvar.h 31 Aug 2007 12:37:50 -0000 1.257 +++ net/pfvar.h 25 Sep 2007 12:40:41 -0000 @@ -756,6 +756,8 @@ struct pf_state { #define PFSTATE_NOSYNC 0x01 #define PFSTATE_FROMSYNC 0x02 #define PFSTATE_STALE 0x04 + struct route ro; + struct pf_state *pf_st_out; }; /* Index: netinet/ip_input.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_input.c,v retrieving revision 1.153 diff -u -p -r1.153 ip_input.c --- netinet/ip_input.c 10 Sep 2007 23:05:39 -0000 1.153 +++ netinet/ip_input.c 25 Sep 2007 12:40:41 -0000 @@ -1386,6 +1386,12 @@ int inetctlerrmap[PRC_NCMDS] = { * The srcrt parameter indicates whether the packet is being forwarded * via a source route. */ +int ip_rt_found = 0; +int ip_rt_nocache = 0; +int ip_rt_used = 0; +int ip_rt_changed = 0; +int ip_rt_changed2 = 0; + void ip_forward(m, srcrt) struct mbuf *m; @@ -1394,6 +1400,7 @@ ip_forward(m, srcrt) struct ip *ip = mtod(m, struct ip *); struct sockaddr_in *sin; struct rtentry *rt; + struct route *ro; int error, type = 0, code = 0, destmtu = 0, rtableid = 0; struct mbuf *mcopy; n_long dest; @@ -1418,6 +1425,7 @@ ip_forward(m, srcrt) rtableid = m->m_pkthdr.pf.rtableid; #endif +#if 0 sin = satosin(&ipforward_rt.ro_dst); if ((rt = ipforward_rt.ro_rt) == 0 || ip->ip_dst.s_addr != sin->sin_addr.s_addr || @@ -1425,19 +1433,41 @@ ip_forward(m, srcrt) if (ipforward_rt.ro_rt) { RTFREE(ipforward_rt.ro_rt); ipforward_rt.ro_rt = 0; +#endif + KASSERT(m->m_flags & M_PKTHDR); + if (m->m_pkthdr.pf_st_in != NULL) { + ro = &m->m_pkthdr.pf_st_in->ro; +// KASSERT(ro); + ip_rt_found++; + } else { + ro = &ipforward_rt; + ip_rt_nocache++; + } + sin = satosin(&ro->ro_dst); + if ((rt = ro->ro_rt) == 0 || + ip->ip_dst.s_addr != sin->sin_addr.s_addr || + rtableid != ipforward_rtableid /* XXX */) { + ip_rt_changed++; + if (ro->ro_rt) { + if (ro != &ipforward_rt) + ip_rt_changed2++; +// printf("path changed?\n"); + RTFREE(ro->ro_rt); + ro->ro_rt = 0; } sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); sin->sin_addr = ip->ip_dst; - rtalloc_mpath(&ipforward_rt, &ip->ip_src.s_addr, rtableid); - if (ipforward_rt.ro_rt == 0) { + rtalloc_mpath(ro, &ip->ip_src.s_addr, rtableid); + if (ro->ro_rt == 0) { icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest, 0); return; } ipforward_rtableid = rtableid; - rt = ipforward_rt.ro_rt; - } + rt = ro->ro_rt; + } else + ip_rt_used++; /* * Save at most 68 bytes of the packet in case @@ -1482,7 +1512,7 @@ ip_forward(m, srcrt) } } - error = ip_output(m, (struct mbuf *)NULL, &ipforward_rt, + error = ip_output(m, (struct mbuf *)NULL, ro, (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), (void *)NULL, (void *)NULL); if (error) @@ -1517,13 +1547,11 @@ ip_forward(m, srcrt) code = ICMP_UNREACH_NEEDFRAG; #ifdef IPSEC - if (ipforward_rt.ro_rt) { - struct rtentry *rt = ipforward_rt.ro_rt; - + if (rt) { if (rt->rt_rmx.rmx_mtu) destmtu = rt->rt_rmx.rmx_mtu; else - destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu; + destmtu = rt->rt_ifp->if_mtu; } #endif /*IPSEC*/ ipstat.ips_cantfrag++; Index: sys/mbuf.h =================================================================== RCS file: /cvs/src/sys/sys/mbuf.h,v retrieving revision 1.93 diff -u -p -r1.93 mbuf.h --- sys/mbuf.h 19 Sep 2007 18:19:10 -0000 1.93 +++ sys/mbuf.h 25 Sep 2007 12:40:42 -0000 @@ -95,6 +95,7 @@ struct pkthdr { int len; /* total packet length */ int csum_flags; /* checksum flags */ struct pkthdr_pf pf; + struct pf_state *pf_st_in; }; /* description of external storage mapped into mbuf, valid if M_EXT set */