From 738be5f561404ebede3708aab31b2acf8a84d286 Mon Sep 17 00:00:00 2001 From: Srinivas Girigowda Date: Tue, 25 Aug 2020 21:11:26 -0700 Subject: [PATCH] qcacmn: qdf: Introduce QDF_FULL_MAC_FMT and QDF_FULL_MAC_REF The idea behind introducing these macros is, if the feature CONFIG_WLAN_TRACE_HIDE_MAC_ADDRESS is enabled, then the requirement is to hide 2nd, 3rd and 4th octet of the MAC address in the kernel logs and driver logs. But other management interfaces like ioctl, debugfs, sysfs, wext, unit test code or non-production simulator sw (iot_sim) should continue to log the full mac address. If the developer directly introduces %pM in the code, it becomes difficult to catch this in the code review and may end up breaking the feature CONFIG_WLAN_TRACE_HIDE_MAC_ADDRESS if enabled. Hence the plan is to introduce meaningful macros to help code audit easy and with the help of automation, block the developer from directly introducing %pM in the code. Change-Id: Id28663eb6e750febba07ed9bdad168187df3248f CRs-Fixed: 2763028 --- qdf/inc/qdf_types.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/qdf/inc/qdf_types.h b/qdf/inc/qdf_types.h index 5955e03b87a0..e274fde2dfb8 100644 --- a/qdf/inc/qdf_types.h +++ b/qdf/inc/qdf_types.h @@ -821,6 +821,23 @@ QDF_STATUS qdf_int64_parse(const char *int_str, int64_t *out_int); QDF_STATUS qdf_uint64_parse(const char *int_str, uint64_t *out_int); #define QDF_MAC_ADDR_SIZE 6 + +/** + * If the feature CONFIG_WLAN_TRACE_HIDE_MAC_ADDRESS is enabled, + * then the requirement is to hide 2nd, 3rd and 4th octet of the + * MAC address in the kernel logs and driver logs. + * But other management interfaces like ioctl, debugfs, sysfs, + * wext, unit test code or non-production simulator sw (iot_sim) + * should continue to log the full mac address. + * + * Developers must use QDF_FULL_MAC_FMT instead of "%pM", + * as this macro helps avoid accidentally breaking the feature + * CONFIG_WLAN_TRACE_HIDE_MAC_ADDRESS if enabled and code auditing + * becomes easy. + */ +#define QDF_FULL_MAC_FMT "%pM" +#define QDF_FULL_MAC_REF(a) (a) + #define QDF_MAC_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x" #define QDF_MAC_ADDR_ARRAY(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]