MCLALLOC must be called at splimp
[unix-history] / usr / src / sys / net / route.c
index b7d594b..396b6d2 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- * Copyright (c) 1980 Regents of the University of California.
+ * Copyright (c) 1980, 1986 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)route.c     6.16 (Berkeley) %G%
+ *     @(#)route.c     7.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -135,7 +135,8 @@ rtredirect(dst, gateway, flags, src)
         */
        if ((rt && !equal(src, &rt->rt_gateway)) || ifa_ifwithaddr(gateway)) {
                rtstat.rts_badredirect++;
         */
        if ((rt && !equal(src, &rt->rt_gateway)) || ifa_ifwithaddr(gateway)) {
                rtstat.rts_badredirect++;
-               rtfree(rt);
+               if (rt)
+                       rtfree(rt);
                return;
        }
        /*
                return;
        }
        /*
@@ -150,7 +151,7 @@ rtredirect(dst, gateway, flags, src)
                rt = 0;
        }
        if (rt == 0) {
                rt = 0;
        }
        if (rt == 0) {
-               rtinit(dst, gateway, SIOCADDRT,
+               rtinit(dst, gateway, (int)SIOCADDRT,
                    (flags & RTF_HOST) | RTF_GATEWAY | RTF_DYNAMIC);
                rtstat.rts_dynamic++;
                return;
                    (flags & RTF_HOST) | RTF_GATEWAY | RTF_DYNAMIC);
                rtstat.rts_dynamic++;
                return;
@@ -165,7 +166,8 @@ rtredirect(dst, gateway, flags, src)
                         * Changing from route to net => route to host.
                         * Create new route, rather than smashing route to net.
                         */
                         * Changing from route to net => route to host.
                         * Create new route, rather than smashing route to net.
                         */
-                       rtinit(dst, gateway, SIOCADDRT, flags | RTF_DYNAMIC);
+                       rtinit(dst, gateway, (int)SIOCADDRT,
+                           flags | RTF_DYNAMIC);
                        rtstat.rts_dynamic++;
                } else {
                        /*
                        rtstat.rts_dynamic++;
                } else {
                        /*
@@ -271,9 +273,10 @@ rtrequest(req, entry)
                         * as our clue to the interface.  Otherwise
                         * we can use the local address.
                         */
                         * as our clue to the interface.  Otherwise
                         * we can use the local address.
                         */
+                       ifa = 0;
                        if (entry->rt_flags & RTF_HOST) 
                                ifa = ifa_ifwithdstaddr(&entry->rt_dst);
                        if (entry->rt_flags & RTF_HOST) 
                                ifa = ifa_ifwithdstaddr(&entry->rt_dst);
-                       else
+                       if (ifa == 0)
                                ifa = ifa_ifwithaddr(&entry->rt_gateway);
                } else {
                        /*
                                ifa = ifa_ifwithaddr(&entry->rt_gateway);
                } else {
                        /*