Source-Changes-HG archive

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

[src/trunk]: src/sys/net Fix PR7946 (neighbor discovery tries to block at int...



details:   https://anonhg.NetBSD.org/src/rev/e1b33e2889a5
branches:  trunk
changeset: 477065:e1b33e2889a5
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sat Oct 09 18:55:30 1999 +0000

description:
Fix PR7946 (neighbor discovery tries to block at interrupt level).
stack-allocate a sockaddr_storage for the temporary sockaddr rather
than putting it in an mbuf.

neighbor discovery wants to delete expired ifa's from a timeout
handler.  allowing rtinit(RTM_DELETE, ...) to run at interrupt level
allows this to work.
i think we can afford the extra ~128 bytes of stack depth ..

diffstat:

 sys/net/route.c |  24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diffs (60 lines):

diff -r a2f9379b2171 -r e1b33e2889a5 sys/net/route.c
--- a/sys/net/route.c   Sat Oct 09 16:11:16 1999 +0000
+++ b/sys/net/route.c   Sat Oct 09 18:55:30 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.28 1999/10/09 08:13:00 erh Exp $   */
+/*     $NetBSD: route.c,v 1.29 1999/10/09 18:55:30 sommerfeld Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -578,7 +578,7 @@
 }
 
 /*
- * Set up a routing table entry, normally
+ * Set up or tear down a routing table entry, normally
  * for an interface.
  */
 int
@@ -587,34 +587,28 @@
        int cmd, flags;
 {
        register struct rtentry *rt;
-       register struct sockaddr *dst;
-       register struct sockaddr *deldst;
-       struct mbuf *m = 0;
+       register struct sockaddr *dst, *odst;
+       struct sockaddr_storage deldst;
        struct rtentry *nrt = 0;
        int error;
 
        dst = flags & RTF_HOST ? ifa->ifa_dstaddr : ifa->ifa_addr;
        if (cmd == RTM_DELETE) {
                if ((flags & RTF_HOST) == 0 && ifa->ifa_netmask) {
-                       m = m_get(M_WAIT, MT_SONAME);
-                       deldst = mtod(m, struct sockaddr *);
-                       rt_maskedcopy(dst, deldst, ifa->ifa_netmask);
-                       dst = deldst;
+                       /* Delete subnet route for this interface */
+                       odst = dst;
+                       dst = (struct sockaddr *)&deldst;
+                       rt_maskedcopy(odst, dst, ifa->ifa_netmask);
                }
                if ((rt = rtalloc1(dst, 0)) != NULL) {
                        rt->rt_refcnt--;
-                       if (rt->rt_ifa != ifa) {
-                               if (m)
-                                       (void) m_free(m);
+                       if (rt->rt_ifa != ifa)
                                return (flags & RTF_HOST ? EHOSTUNREACH
                                                        : ENETUNREACH);
-                       }
                }
        }
        error = rtrequest(cmd, dst, ifa->ifa_addr, ifa->ifa_netmask,
                        flags | ifa->ifa_flags, &nrt);
-       if (m)
-               (void) m_free(m);
        if (cmd == RTM_DELETE && error == 0 && (rt = nrt)) {
                rt_newaddrmsg(cmd, ifa, error, nrt);
                if (rt->rt_refcnt <= 0) {



Home | Main Index | Thread Index | Old Index