Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/perfused - Add debug santity checks



details:   https://anonhg.NetBSD.org/src/rev/ce71efa211f4
branches:  trunk
changeset: 757733:ce71efa211f4
user:      manu <manu%NetBSD.org@localhost>
date:      Mon Sep 20 06:45:38 2010 +0000

description:
- Add debug santity checks
- Do not request peer creds anymore once we have them.

diffstat:

 usr.sbin/perfused/msg.c      |  18 ++++++++++++++++--
 usr.sbin/perfused/perfused.c |  10 +++++++++-
 2 files changed, 25 insertions(+), 3 deletions(-)

diffs (84 lines):

diff -r 7d286cf19c36 -r ce71efa211f4 usr.sbin/perfused/msg.c
--- a/usr.sbin/perfused/msg.c   Mon Sep 20 03:52:45 2010 +0000
+++ b/usr.sbin/perfused/msg.c   Mon Sep 20 06:45:38 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: msg.c,v 1.6 2010/09/15 01:51:44 manu Exp $ */
+/*  $NetBSD: msg.c,v 1.7 2010/09/20 06:45:38 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -483,7 +483,6 @@
 #if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
        peek = MSG_PEEK;
 #endif
-
        offset = puffs_framebuf_telloff(pufbuf);
 
        /*
@@ -509,6 +508,11 @@
                        /* NOTREACHED */
                        break;
                default:
+#if defined(PERFUSE_DEBUG) && (PERFUSE_SOCKTYPE == SOCK_DGRAM)
+                       if (readen != remain)
+                               DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
+                                     __func__, readen, remain);
+#endif
                        break;
                }
 
@@ -566,6 +570,11 @@
                        /* NOTREACHED */
                        break;
                default:
+#if defined(PERFUSE_DEBUG) && (PERFUSE_SOCKTYPE == SOCK_DGRAM)
+                       if (readen != remain)
+                               DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
+                                     __func__, readen, remain);
+#endif
                        break;
                }
 
@@ -615,6 +624,11 @@
                        /* NOTREACHED */
                        break;
                default:
+#if defined(PERFUSE_DEBUG) && (PERFUSE_SOCKTYPE == SOCK_DGRAM)
+                       if (written != remain)
+                               DERRX(EX_SOFTWARE, "%s: short send %zd/%zd",
+                                     __func__, written, remain);
+#endif
                        break;
                }
 
diff -r 7d286cf19c36 -r ce71efa211f4 usr.sbin/perfused/perfused.c
--- a/usr.sbin/perfused/perfused.c      Mon Sep 20 03:52:45 2010 +0000
+++ b/usr.sbin/perfused/perfused.c      Mon Sep 20 06:45:38 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfused.c,v 1.8 2010/09/15 01:51:44 manu Exp $ */
+/*  $NetBSD: perfused.c,v 1.9 2010/09/20 06:45:38 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -100,6 +100,7 @@
 {
        struct perfuse_mount_out *pmo;
        struct sockcred cred;
+       int opt;
        char *cp;
        char *source = NULL;
        char *target = NULL;
@@ -117,6 +118,13 @@
                exit(EX_PROTOCOL);
        }
 
+       /*
+        * We do not need peer creds beyond this point
+        */
+       opt = 0;
+       if (setsockopt(fd, 0, LOCAL_CREDS, &opt, sizeof(opt)) != 0)
+               DWARN("%s: setsockopt LOCAL_CREDS failed", __func__);
+       
 #ifdef PERFUSE_DEBUG
        if (perfuse_diagflags & PDF_MISC)
                DPRINTF("perfuse lengths: source = %"PRId32", "



Home | Main Index | Thread Index | Old Index