tech-net archive

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

incorrect route used in ip_forward()



Hi:

It looks like a spot was missed in the conversion to rtcache_*()
and an incorrect route is being consulted in one case.  The following
should restore the NetBSD 4 behaviour.  Any objections before I
commit?

Thanks.

-seanb
Index: sys/netinet/ip_input.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/ip_input.c,v
retrieving revision 1.273
diff -u -r1.273 ip_input.c
--- sys/netinet/ip_input.c      20 Aug 2008 18:35:20 -0000      1.273
+++ sys/netinet/ip_input.c      25 Aug 2008 20:16:07 -0000
@@ -1967,9 +1967,11 @@
                type = ICMP_UNREACH;
                code = ICMP_UNREACH_NEEDFRAG;
 
-               if ((rt = rtcache_validate(&ipforward_rt)) != NULL) {
+               if ((rt = rtcache_validate(&ipforward_rt)) != NULL)
+                       destmtu = rt->rt_ifp->if_mtu;
 
 #if defined(IPSEC) || defined(FAST_IPSEC)
+               {
                        /*
                         * If the packet is routed over IPsec tunnel, tell the
                         * originator the tunnel MTU.
@@ -1985,10 +1987,7 @@
                        sp = ipsec4_getpolicybyaddr(mcopy,
                            IPSEC_DIR_OUTBOUND, IP_FORWARDING,
                            &ipsecerror);
-#endif
 
-                       destmtu = rt->rt_ifp->if_mtu;
-#if defined(IPSEC) || defined(FAST_IPSEC)
                        if (sp != NULL) {
                                /* count IPsec header size */
                                ipsechdr = ipsec4_hdrsiz(mcopy,
@@ -2003,6 +2002,7 @@
                                 && sp->req->sav != NULL
                                 && sp->req->sav->sah != NULL) {
                                        ro = &sp->req->sav->sah->sa_route;
+                                       rt = rtcache_validate(ro);
                                        if (rt && rt->rt_ifp) {
                                                destmtu =
                                                    rt->rt_rmx.rmx_mtu ?
@@ -2018,8 +2018,8 @@
                                KEY_FREESP(&sp);
 #endif
                        }
-#endif /*defined(IPSEC) || defined(FAST_IPSEC)*/
                }
+#endif /*defined(IPSEC) || defined(FAST_IPSEC)*/
                IP_STATINC(IP_STAT_CANTFRAG);
                break;
 


Home | Main Index | Thread Index | Old Index