Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet PR/25332: HIROSE yuuji: "fastroute(to)" in ipf.c...



details:   https://anonhg.NetBSD.org/src/rev/2f8397c3f509
branches:  trunk
changeset: 566436:2f8397c3f509
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 09 04:02:32 2004 +0000

description:
PR/25332: HIROSE yuuji: "fastroute(to)" in ipf.conf doesn't work; patch applied

diffstat:

 sys/netinet/ip_fil_netbsd.c |  48 ++++++++++++++++++++++----------------------
 1 files changed, 24 insertions(+), 24 deletions(-)

diffs (109 lines):

diff -r 5f881b9c6bdf -r 2f8397c3f509 sys/netinet/ip_fil_netbsd.c
--- a/sys/netinet/ip_fil_netbsd.c       Sun May 09 03:54:43 2004 +0000
+++ b/sys/netinet/ip_fil_netbsd.c       Sun May 09 04:02:32 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_fil_netbsd.c,v 1.5 2004/04/22 01:01:41 matt Exp $   */
+/*     $NetBSD: ip_fil_netbsd.c,v 1.6 2004/05/09 04:02:32 christos Exp $       */
 
 /*
  * Copyright (C) 1993-2003 by Darren Reed.
@@ -1001,6 +1001,10 @@
                }
        }
 #endif
+#ifdef USE_INET6
+       if (fin->fin_v == 6)
+               return ipfr_fastroute6(m0, mpp, fin, fdp);
+#endif
 
        hlen = fin->fin_hlen;
        ip = mtod(m0, struct ip *);
@@ -1012,10 +1016,6 @@
        m0->m_pkthdr.csuminfo = 0;
 #endif /* __NetBSD__ && M_CSUM_IPv4 */
 
-#ifdef USE_INET6
-       if (fin->fin_v == 6)
-               return ipfr_fastroute6(m0, mpp, fin, fdp);
-#endif
        /*
         * Route packet.
         */
@@ -1023,14 +1023,13 @@
        bzero((caddr_t)ro, sizeof (*ro));
        dst = (struct sockaddr_in *)&ro->ro_dst;
        dst->sin_family = AF_INET;
+       dst->sin_addr = ip->ip_dst;
 
        fr = fin->fin_fr;
        if (fdp)
                ifp = fdp->fd_ifp;
-       else {
+       else
                ifp = fin->fin_ifp;
-               dst->sin_addr = ip->ip_dst;
-       }
 
        if ((ifp == NULL) && (!fr || !(fr->fr_flags & FR_FASTROUTE))) {
                error = -2;
@@ -1045,27 +1044,26 @@
                if ((ifp != NULL) && (fdp == &fr->fr_tif))
                        return -1;
                dst->sin_addr = ip->ip_dst;
-       } else if (fdp) {
-               if (fdp->fd_ip.s_addr) {
+       } else if (fdp != NULL) {
+               if (fdp->fd_ip.s_addr != 0)
                        dst->sin_addr = fdp->fd_ip;
-                       ip->ip_dst = fdp->fd_ip;
-               } else
-                       dst->sin_addr = ip->ip_dst;
        }
 
        dst->sin_len = sizeof(*dst);
        rtalloc(ro);
-       if (!ifp) {
-               if (ro->ro_rt == 0 || (ifp = ro->ro_rt->rt_ifp) == 0) {
-                       if (in_localaddr(ip->ip_dst))
-                               error = EHOSTUNREACH;
-                       else
-                               error = ENETUNREACH;
-                       goto bad;
-               }
-               if (ro->ro_rt->rt_flags & RTF_GATEWAY)
-                       dst = (struct sockaddr_in *)&ro->ro_rt->rt_gateway;
+
+       if ((ifp == NULL) && (ro->ro_rt != NULL))
+               ifp = ro->ro_rt->rt_ifp;
+
+       if ((ro->ro_rt == NULL) || (ifp == NULL)) {
+               if (in_localaddr(ip->ip_dst))
+                       error = EHOSTUNREACH;
+               else
+                       error = ENETUNREACH;
+               goto bad;
        }
+       if (ro->ro_rt->rt_flags & RTF_GATEWAY)
+               dst = (struct sockaddr_in *)&ro->ro_rt->rt_gateway;
        if (ro->ro_rt)
                ro->ro_rt->rt_use++;
 
@@ -1074,8 +1072,9 @@
         * go back through output filtering and miss their chance to get
         * NAT'd and counted.
         */
-       fin->fin_ifp = ifp;
        if (fin->fin_out == 0) {
+               sifp = fin->fin_ifp;
+               fin->fin_ifp = ifp;
                fin->fin_out = 1;
                (void) fr_acctpkt(fin, NULL);
                fin->fin_fr = NULL;
@@ -1085,6 +1084,7 @@
                        (void) fr_checkstate(fin, &pass);
                }
                (void) fr_checknatout(fin, NULL);
+               fin->fin_ifp = sifp;
        } else
                ip->ip_sum = 0;
        /*



Home | Main Index | Thread Index | Old Index