/*-1* Copyright (c) 2022 Alexander V. Chernikov <[email protected]>2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11* 3. Neither the name of the University nor the names of its contributors12* may be used to endorse or promote products derived from this software13* without specific prior written permission.14*15* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _NETLINK_NETLINK_DEBUG_H_29#define _NETLINK_NETLINK_DEBUG_H_3031#ifdef _KERNEL3233#define _DEBUG_SYSCTL_OID _net_netlink_debug34#include <net/route/route_debug.h>3536SYSCTL_DECL(_net_netlink_debug);3738/*39* Generic debug40* [nl_domain] func_name: debug text41*/42#define NL_LOG RT_LOG4344/*45* Logging for events specific for particular process46* Example: [nl_domain] PID 4834 fdump_sa: unsupported family: 4547*/48#define NL_RAW_PID_LOG(_l, _pid, _fmt, ...) \49NL_RAW_PID_LOG_##_l(_l, _pid, _fmt, ## __VA_ARGS__)50#define _NL_RAW_PID_LOG(_l, _pid, _fmt, ...) \51if (_DEBUG_PASS_MSG(_l)) { \52_output("[" DEBUG_PREFIX_NAME "] PID %u %s: " _fmt "\n", _pid, \53__func__, ##__VA_ARGS__); \54}5556#define NLP_LOG(_l, _nlp, _fmt, ...) \57NL_RAW_PID_LOG_##_l(_l, nlp_get_pid(_nlp), _fmt, ## __VA_ARGS__)5859#if DEBUG_MAX_LEVEL>=LOG_DEBUG360#define NL_RAW_PID_LOG_LOG_DEBUG3 _NL_RAW_PID_LOG61#else62#define NL_RAW_PID_LOG_LOG_DEBUG3(_l, _pid, _fmt, ...)63#endif64#if DEBUG_MAX_LEVEL>=LOG_DEBUG265#define NL_RAW_PID_LOG_LOG_DEBUG2 _NL_RAW_PID_LOG66#else67#define NL_RAW_PID_LOG_LOG_DEBUG2(_l, _pid, _fmt, ...)68#endif69#if DEBUG_MAX_LEVEL>=LOG_DEBUG70#define NL_RAW_PID_LOG_LOG_DEBUG _NL_RAW_PID_LOG71#else72#define NL_RAW_PID_LOG_LOG_DEBUG(_l, _pid, _fmt, ...)73#endif74#if DEBUG_MAX_LEVEL>=LOG_INFO75#define NL_RAW_PID_LOG_LOG_INFO _NL_RAW_PID_LOG76#else77#define NL_RAW_PID_LOG_LOG_INFO(_l, _pid, _fmt, ...)78#endif79#define NL_RAW_PID_LOG_LOG_NOTICE _NL_RAW_PID_LOG80#define NL_RAW_PID_LOG_LOG_ERR _NL_RAW_PID_LOG81#define NL_RAW_PID_LOG_LOG_WARNING _NL_RAW_PID_LOG8283#endif /* _KERNEL */84#endif /* !_NETLINK_NETLINK_DEBUG_H_ */858687