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
This commit is contained in:
ozaki-r 2017-10-30 03:02:35 +00:00
parent a38c93c330
commit 80ccc52108
1 changed files with 26 additions and 10 deletions

View File

@ -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);
/* 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;
#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);
/*
* - _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;
}