From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 04:38:40 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FC53106566B; Tue, 30 Dec 2008 04:38:40 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F4BF8FC1F; Tue, 30 Dec 2008 04:38:40 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBU4ceF5076136; Tue, 30 Dec 2008 04:38:40 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU4ceDK076135; Tue, 30 Dec 2008 04:38:40 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300438.mBU4ceDK076135@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 04:38:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186585 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 04:38:40 -0000 Author: kmacy Date: Tue Dec 30 04:38:39 2008 New Revision: 186585 URL: http://svn.freebsd.org/changeset/base/186585 Log: make ipv4 forwarding flowtable aware Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Tue Dec 30 04:22:47 2008 (r186584) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Tue Dec 30 04:38:39 2008 (r186585) @@ -1350,6 +1350,7 @@ ip_forward(struct mbuf *m, int srcrt) struct in_addr dest; struct route ro; int error, type = 0, code = 0, mtu = 0; + int flerror; if (m->m_flags & (M_BCAST|M_MCAST) || in_canforward(ip->ip_dst) == 0) { V_ipstat.ips_cantforward++; @@ -1367,8 +1368,12 @@ ip_forward(struct mbuf *m, int srcrt) #ifdef IPSTEALTH } #endif + flerror = flowtable_lookup(ipv4_forward_ft, m, &ro); + if (flerror == 0) + ia = ifatoia(ro.ro_rt->rt_ifa); + else + ia = ip_rtaddr(ip->ip_dst, M_GETFIB(m)); - ia = ip_rtaddr(ip->ip_dst, M_GETFIB(m)); if (!srcrt && ia == NULL) { icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0); return; @@ -1428,13 +1433,16 @@ ip_forward(struct mbuf *m, int srcrt) struct sockaddr_in *sin; struct rtentry *rt; - bzero(&ro, sizeof(ro)); - sin = (struct sockaddr_in *)&ro.ro_dst; - sin->sin_family = AF_INET; - sin->sin_len = sizeof(*sin); - sin->sin_addr = ip->ip_dst; - in_rtalloc_ign(&ro, 0, M_GETFIB(m)); - + if (flerror != 0) { + + bzero(&ro, sizeof(ro)); + sin = (struct sockaddr_in *)&ro.ro_dst; + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_addr = ip->ip_dst; + in_rtalloc_ign(&ro, 0, M_GETFIB(m)); + } + rt = ro.ro_rt; if (rt && (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 && @@ -1453,7 +1461,7 @@ ip_forward(struct mbuf *m, int srcrt) code = ICMP_REDIRECT_HOST; } } - if (rt) + if (rt && (flerror != 0)) RTFREE(rt); } @@ -1461,13 +1469,14 @@ ip_forward(struct mbuf *m, int srcrt) * Try to cache the route MTU from ip_output so we can consider it for * the ICMP_UNREACH_NEEDFRAG "Next-Hop MTU" field described in RFC1191. */ - bzero(&ro, sizeof(ro)); + if (flerror != 0) + bzero(&ro, sizeof(ro)); error = ip_output(m, NULL, &ro, IP_FORWARDING, NULL, NULL); if (error == EMSGSIZE && ro.ro_rt) mtu = ro.ro_rt->rt_rmx.rmx_mtu; - if (ro.ro_rt) + if (ro.ro_rt && flerror != 0) RTFREE(ro.ro_rt); if (error)