Source-Changes-HG archive

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

[src/trunk]: src/sys/net/npf Fix npfclt reload on rump kernels



details:   https://anonhg.NetBSD.org/src/rev/02793d226b1b
branches:  trunk
changeset: 827480:02793d226b1b
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Oct 30 03:02:35 2017 +0000

description:
Fix npfclt reload on rump kernels

It fails because npfctl cannot get an errno when it calls ioctl to the (rump)
kernel; npfctl (libnpf) expects that an errno is returned via proplib,
however, the rump library of npf doesn't so. It happens because of mishandlings
of complicate npf kernel options.

PR kern/52643

diffstat:

 sys/net/npf/npf_ctl.c |  34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diffs (57 lines):

diff -r bec975c17800 -r 02793d226b1b sys/net/npf/npf_ctl.c
--- a/sys/net/npf/npf_ctl.c     Mon Oct 30 01:25:27 2017 +0000
+++ b/sys/net/npf/npf_ctl.c     Mon Oct 30 03:02:35 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_ctl.c,v 1.48 2017/05/17 18:56:12 christos Exp $    */
+/*     $NetBSD: npf_ctl.c,v 1.49 2017/10/30 03:02:35 ozaki-r Exp $     */
 
 /*-
  * Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.48 2017/05/17 18:56:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.49 2017/10/30 03:02:35 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -630,15 +630,31 @@
        if (tblset) {
                npf_tableset_destroy(tblset);
        }
-       prop_object_release(npf_dict);
+#if defined(_NPF_TESTING) || defined(_NPF_STANDALONE)
+       /* Free only if allocated by prop_dictionary_copyin_ioctl_size. */
+       if (!npfctl_testing)
+#endif
+               prop_object_release(npf_dict);
 
-       /* Error report. */
-#if !defined(_NPF_TESTING) && !defined(_NPF_STANDALONE)
-       prop_dictionary_set_int32(errdict, "errno", error);
-       prop_dictionary_copyout_ioctl(pref, cmd, errdict);
+       /*
+        * - _NPF_STANDALONE doesn't require to set prop.
+        * - For _NPF_TESTING, if npfctl_testing, setting prop isn't needed,
+        *   otherwise it's needed.
+        */
+#ifndef _NPF_STANDALONE
+#ifdef _NPF_TESTING
+       if (!npfctl_testing) {
+#endif
+               /* Error report. */
+               prop_dictionary_set_int32(errdict, "errno", error);
+               prop_dictionary_copyout_ioctl(pref, cmd, errdict);
+               error = 0;
+#ifdef _NPF_TESTING
+       }
+#endif
+#endif /* _NPF_STANDALONE */
        prop_object_release(errdict);
-       error = 0;
-#endif
+
        return error;
 }
 



Home | Main Index | Thread Index | Old Index