Module Name:    src
Committed By:   ozaki-r
Date:           Mon Oct 30 03:02:35 UTC 2017

Modified Files:
        src/sys/net/npf: npf_ctl.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/net/npf/npf_ctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/npf/npf_ctl.c
diff -u src/sys/net/npf/npf_ctl.c:1.48 src/sys/net/npf/npf_ctl.c:1.49
--- src/sys/net/npf/npf_ctl.c:1.48	Wed May 17 18:56:12 2017
+++ src/sys/net/npf/npf_ctl.c	Mon Oct 30 03:02:35 2017
@@ -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 @@ fail:
 	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);
-	prop_object_release(errdict);
-	error = 0;
+	/*
+	 * - _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);
+
 	return error;
 }
 

Reply via email to