From patchwork Fri Apr 28 15:34:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 677815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 642B4C7EE29 for ; Fri, 28 Apr 2023 15:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346485AbjD1PfK (ORCPT ); Fri, 28 Apr 2023 11:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346514AbjD1PfC (ORCPT ); Fri, 28 Apr 2023 11:35:02 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE881FFB; Fri, 28 Apr 2023 08:35:01 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SF3pBG013966; Fri, 28 Apr 2023 15:34:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=YVCRBRkfFPkGR8hzIXJZIFGAb7lsTnmbW9p0HfFiVb4=; b=j/30y37wb+GSCqfEURAF8YuuxUyRjOt7dmgFfcFiqwGuv3O3H9pVp1S4fl16OR/gPfMa ix30NithNwsbW6WoknxKgHbUjJXBJfjZOR9VU/hFRFofSuS6SABeDC6RS5T3IUT0FvDe IS6LlIvToeOVney14FKeNEl1zke4na8KiIFJN6kJd9sCT4tKgGaeOg3gNEWjRTCL5HX9 rBA+nzVNSBNig6Q3DLm5j1xZvYs2XxMVc2rT/hSkUME+z+Wf5NkGCXeCYyxiM9g8+fPw oyVZR0U+NNvx8uILA1+dAX77rjGNX2WcdcVfkvsQC3dE2TEw+gh1C2wGZEL+AyMDhv6d Tw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q460def5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:34:56 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33SE6V1p028202; Fri, 28 Apr 2023 15:34:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q461b4rnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:34:55 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33SFYqUC028134; Fri, 28 Apr 2023 15:34:54 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-188-60.vpn.oracle.com [10.175.188.60]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3q461b4rm0-2; Fri, 28 Apr 2023 15:34:54 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Maguire Subject: [PATCH v2 tracing 1/6] tracing: support > 8 byte array filter predicates Date: Fri, 28 Apr 2023 16:34:44 +0100 Message-Id: <1682696089-27937-2-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> References: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280125 X-Proofpoint-GUID: L4u-s7ivLQPx9SW7S1MLZl8zQFLl1SVw X-Proofpoint-ORIG-GUID: L4u-s7ivLQPx9SW7S1MLZl8zQFLl1SVw Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org For > 8 byte values, allow simple binary '==', '!=' predicates where the user passes in a hex ASCII representation of the desired value. The representation must match the field size exactly, and a simple memory comparison between predicate and actual value is carried out. For example: cd /sys/kernel/debug/tracing/events/tcp/tcp_receive_reset echo "saddr_v6 == 0x00000000000000000000000000000001" > filter Signed-off-by: Alan Maguire --- kernel/trace/trace_events_filter.c | 54 +++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 1dad64267878..64f1dfb72cb5 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -67,6 +67,7 @@ enum filter_pred_fn { FILTER_PRED_FN_FUNCTION, FILTER_PRED_FN_, FILTER_PRED_TEST_VISITED, + FILTER_PRED_FN_MEMCMP, }; struct filter_pred { @@ -622,8 +623,11 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, kfree(op_stack); kfree(inverts); if (prog_stack) { - for (i = 0; prog_stack[i].pred; i++) + for (i = 0; prog_stack[i].pred; i++) { + if (prog_stack[i].pred->fn_num == FILTER_PRED_FN_MEMCMP) + kfree((u8 *)(uintptr_t)(prog_stack[i].pred->val)); kfree(prog_stack[i].pred); + } kfree(prog_stack); } return ERR_PTR(ret); @@ -890,6 +894,14 @@ static int filter_pred_function(struct filter_pred *pred, void *event) return pred->op == OP_EQ ? ret : !ret; } +static int filter_pred_memcmp(struct filter_pred *pred, void *event) +{ + u8 *mem = (u8 *)(event + pred->offset); + u8 *cmp = (u8 *)(uintptr_t)(pred->val); + + return (memcmp(mem, cmp, pred->field->size) == 0) ^ pred->not; +} + /* * regex_match_foo - Basic regex callbacks * @@ -1353,6 +1365,8 @@ static int filter_pred_fn_call(struct filter_pred *pred, void *event) return filter_pred_function(pred, event); case FILTER_PRED_TEST_VISITED: return test_pred_visited_fn(pred, event); + case FILTER_PRED_FN_MEMCMP: + return filter_pred_memcmp(pred, event); default: return 0; } @@ -1370,6 +1384,7 @@ static int parse_pred(const char *str, void *data, unsigned long size; unsigned long ip; char num_buf[24]; /* Big enough to hold an address */ + u8 *pred_val; char *field_name; char *name; bool function = false; @@ -1631,6 +1646,43 @@ static int parse_pred(const char *str, void *data, /* go past the last quote */ i++; + } else if (str[i] == '0' && tolower(str[i + 1]) == 'x' && + field->size > 8) { + /* For sizes > 8 bytes, we store hex bytes for comparison; + * only '==' and '!=' are supported. + * To keep things simple, the predicate value must specify + * a value that matches the field size exactly, with leading + * 0s if necessary. + */ + if (pred->op != OP_EQ && pred->op != OP_NE) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); + goto err_free; + } + + /* skip required 0x */ + s += 2; + i += 2; + + while (isalnum(str[i])) + i++; + + len = i - s; + if (len != (field->size * 2)) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + s); + goto err_free; + } + + pred_val = kzalloc(field->size, GFP_KERNEL); + if (hex2bin(pred_val, str + s, field->size)) { + parse_error(pe, FILT_ERR_ILLEGAL_INTVAL, pos + s); + kfree(pred_val); + goto err_free; + } + pred->val = (u64)pred_val; + pred->fn_num = FILTER_PRED_FN_MEMCMP; + if (pred->op == OP_NE) + pred->not = 1; + } else if (isdigit(str[i]) || str[i] == '-') { /* Make sure the field is not a string */ From patchwork Fri Apr 28 15:34:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 677940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C24A0C7EE24 for ; Fri, 28 Apr 2023 15:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346474AbjD1PfI (ORCPT ); Fri, 28 Apr 2023 11:35:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346518AbjD1PfE (ORCPT ); Fri, 28 Apr 2023 11:35:04 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554301FFB; Fri, 28 Apr 2023 08:35:03 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SF3uCY001561; Fri, 28 Apr 2023 15:34:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=nOmEmDJvf0ujmg1ooMtHBJ58/BwYXKCo6GrTn2bVPdY=; b=rJkCevQdNa/NMda9eDmvgP5oSBz4rZnb6AAL7OXz6pmRn9TZrngmQO9Qjv156K/q/7JI zUmG7J6hj/7AeolrvHnhzJdivqdb8Yuz2fHiaUFOUyvp12XqAmoFtA0XdoMR2wOlkvBl qoGsp5gttejcVavebwViRY58ic9pTl4YqcUCh6hv4H/cK8bcW9yKL7aNZECjVkIoJrKn weebUmiTNOMPsAz7uC1PFdIglB9lKR6Niqgjk/5aueRh8v3GEOQXSLZqQtNN1HV5skDl KjfUHeXRAd/lo2U1vntcFq/5/pbv/0jvb5RUdLqTDSfuwZKEVMrgOzUm+Llek0S7rpu2 Xw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q47md6rcu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:34:58 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33SE4dKI028041; Fri, 28 Apr 2023 15:34:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q461b4rpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:34:57 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33SFYqUE028134; Fri, 28 Apr 2023 15:34:57 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-188-60.vpn.oracle.com [10.175.188.60]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3q461b4rm0-3; Fri, 28 Apr 2023 15:34:56 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Maguire Subject: [PATCH v2 tracing 2/6] tracing: support IPv4 address filter predicate Date: Fri, 28 Apr 2023 16:34:45 +0100 Message-Id: <1682696089-27937-3-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> References: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280125 X-Proofpoint-GUID: PFChNbtqyuwrdE_yijqNgJq5ob7yTXIL X-Proofpoint-ORIG-GUID: PFChNbtqyuwrdE_yijqNgJq5ob7yTXIL Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Support '==' and '!=' predicates for IPv4 address format; for example cd /sys/kernel/debug/tracing/events/tcp/tcp_receive_reset echo "saddr == 127.0.0.1" > filter Signed-off-by: Alan Maguire --- kernel/trace/trace_events_filter.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 64f1dfb72cb5..d8e08d3c3594 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -1384,6 +1384,7 @@ static int parse_pred(const char *str, void *data, unsigned long size; unsigned long ip; char num_buf[24]; /* Big enough to hold an address */ + char scratch[4]; /* Big enough to hold an IPv4 address */ u8 *pred_val; char *field_name; char *name; @@ -1646,6 +1647,24 @@ static int parse_pred(const char *str, void *data, /* go past the last quote */ i++; + } else if (field->size == 4 && + sscanf(&str[i], "%hhd.%hhd.%hhd.%hhd", + /* assume address in network byte order */ + &scratch[0], &scratch[1], &scratch[2], &scratch[3]) == 4) { + /* For IPv4 addresses, only '==' or '!=' are supported. */ + if (pred->op != OP_EQ && pred->op != OP_NE) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); + goto err_free; + } + while (isdigit(str[i]) || str[i] == '.') + i++; + pred_val = kzalloc(field->size, GFP_KERNEL); + memcpy(pred_val, scratch, field->size); + pred->val = (u64)pred_val; + pred->fn_num = FILTER_PRED_FN_MEMCMP; + if (pred->op == OP_NE) + pred->not = 1; + } else if (str[i] == '0' && tolower(str[i + 1]) == 'x' && field->size > 8) { /* For sizes > 8 bytes, we store hex bytes for comparison; From patchwork Fri Apr 28 15:34:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 677816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 522A8C77B7E for ; Fri, 28 Apr 2023 15:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346451AbjD1PfI (ORCPT ); Fri, 28 Apr 2023 11:35:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346529AbjD1PfG (ORCPT ); Fri, 28 Apr 2023 11:35:06 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986CC1FFB; Fri, 28 Apr 2023 08:35:05 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SF4GLx004440; Fri, 28 Apr 2023 15:35:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=HW9CMy3il/IRcCDBr4P2DexsA8A9u2fl1mPaG/1i0tU=; b=iPfW1RU3Kc9GmHndTABqPsOsZi7Zc+OGfprw1RwNAu0gXuupPwuZUGMKiZwQPggYPilJ szsHd2h1zS9vxNtYiRuur/dpbiwMbk9Fzv3mQGpYRtV71QLjoHa2VmQ8WHFJMXLlfG/j MogbS+vpnyDDXGSerT+JX8h5o1w7vUCzA/bk3bmpOd0jzQKOKyDVwRzJvp20bP6dZC2n EYKkAn+CrvyqchZMWg19OUXl6CkPsmk55+wSRVoy7RjsWKZDJfzOxwcbjA7cRDcPLcM/ NFpgvGqtXW6/iV7SvelTu2XGzD6ljU2RdXYUAemAYvr7e0/WTobNeVRbLIxuCt2xkRQL hw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q47faxjcq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:00 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33SE1TQU028199; Fri, 28 Apr 2023 15:35:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q461b4rqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:34:59 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33SFYqUG028134; Fri, 28 Apr 2023 15:34:59 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-188-60.vpn.oracle.com [10.175.188.60]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3q461b4rm0-4; Fri, 28 Apr 2023 15:34:59 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Maguire Subject: [PATCH v2 tracing 3/6] tracing: support IPv6 filter predicates Date: Fri, 28 Apr 2023 16:34:46 +0100 Message-Id: <1682696089-27937-4-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> References: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280125 X-Proofpoint-ORIG-GUID: XYPD5ShOdlBAgY4MyrfNSHTRnaCmXswa X-Proofpoint-GUID: XYPD5ShOdlBAgY4MyrfNSHTRnaCmXswa Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Support '==' and '!=' predicates for IPv6 addresses; for example cd /sys/kernel/debug/tracing/events/tcp/tcp_receive_reset echo "saddr_v6 == ::1" > filter or equivalently echo "saddr_v6 == 0:0:0:0:0:0:0:1" > filter Signed-off-by: Alan Maguire --- kernel/trace/trace_events_filter.c | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index d8e08d3c3594..e2521574f3c4 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -1665,6 +1665,79 @@ static int parse_pred(const char *str, void *data, if (pred->op == OP_NE) pred->not = 1; + } else if (field->size == 16 && + (str[i] == ':' || + (isalnum(str[i]) && tolower(str[i + 1]) != 'x'))) { + u8 j, gap_size, gap = 0, gap_count = 0, index = 0; + u16 tmp_v6addr[8] = {}; + u16 v6addr[8] = {}; + + /* For IPv6 addresses, only '==' or '!=' are supported. */ + if (pred->op != OP_EQ && pred->op != OP_NE) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); + goto err_free; + } + /* Store the u16s in the address string consecutively in + * tmp_v6addr while tracking the presence of a "::" (if any) + * in the IPv6 address string; we will use its location + * to determine how many u16s it represents (the gap_size + * below). Only one "::" is allowed in an IPv6 address + * string. + */ + while (isalnum(str[i]) || str[i] == ':') { + switch (str[i]) { + case ':': + i++; + /* mark "::" index by setting gap */ + if (str[i] == ':') { + gap = index; + gap_count++; + i++; + } + if (gap_count > 1) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, + pos + s); + goto err_free; + } + break; + default: + if (sscanf(&str[i], "%hx", &tmp_v6addr[index]) != 1) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, + pos + s); + goto err_free; + } + index++; + while (isalnum(str[i])) + i++; + break; + } + } + /* The gap_size here represents the number of u16s the "::" + * represents; for ::1 the gap size is 7, for feed::face + * it is 6, etc. + */ + gap_size = 8 - index; + index = 0; + for (j = 0; j < 8; ) { + if (gap_size > 0 && j == gap) { + j += gap_size; + } else { +#ifdef __BIG_ENDIAN + v6addr[j++] = tmp_v6addr[index]; +#else + v6addr[j++] = ((tmp_v6addr[index] & 0xff) << 8) + + ((tmp_v6addr[index] & 0xff00) >> 8); +#endif + index++; + } + } + pred_val = kzalloc(field->size, GFP_KERNEL); + memcpy(pred_val, v6addr, field->size); + pred->val = (u64)pred_val; + pred->fn_num = FILTER_PRED_FN_MEMCMP; + if (pred->op == OP_NE) + pred->not = 1; + } else if (str[i] == '0' && tolower(str[i + 1]) == 'x' && field->size > 8) { /* For sizes > 8 bytes, we store hex bytes for comparison; From patchwork Fri Apr 28 15:34:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 677814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96538C77B7E for ; Fri, 28 Apr 2023 15:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346534AbjD1PfM (ORCPT ); Fri, 28 Apr 2023 11:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346480AbjD1PfJ (ORCPT ); Fri, 28 Apr 2023 11:35:09 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955C22129; Fri, 28 Apr 2023 08:35:07 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SF3q0f013983; Fri, 28 Apr 2023 15:35:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=qbpAVpdqvJpRmYvk+bUcqyw6njxS1/sYaFkQUCMfQdk=; b=CLenxwekIbgNcwjL2VOX+x/KhP0mbXIQ4VKuxdudidCB8TZEt3ofxz7BwZq+7wF4zawF 1xS1m/MdV7WmK/Y2Fp3hz8uUgDLubY8VbvTnrb7lXbQowKFXvHR5VdzFRIGF8j0Nbh7j qO+2gnjxGK7un8EUvoocpc2lsLZZGfdwLJ2MRQedc3iuuU0e7hnvIXYgN5EHuY/wr49g /8h6kQCQvnZF/6T1PrvA6Sd/XJiGnl8pfQrDBzbdkQibKJlAIX3hIp+DtQY2hqOVpbNV GqI4q6ESCGuo8kSVchCoijTg8T4h4x6vG/1vlF0zcM1vAF/73DlihA8VCtm4nucAz3Fe gA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q460def67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:03 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33SE3UFh028277; Fri, 28 Apr 2023 15:35:02 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q461b4rsg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:02 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33SFYqUI028134; Fri, 28 Apr 2023 15:35:01 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-188-60.vpn.oracle.com [10.175.188.60]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3q461b4rm0-5; Fri, 28 Apr 2023 15:35:01 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Maguire Subject: [PATCH v2 tracing 4/6] tracing: support MAC address filter predicates Date: Fri, 28 Apr 2023 16:34:47 +0100 Message-Id: <1682696089-27937-5-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> References: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280125 X-Proofpoint-GUID: 2AAV9NyNJTjvbRe2sWOnRfnviscfQDvz X-Proofpoint-ORIG-GUID: 2AAV9NyNJTjvbRe2sWOnRfnviscfQDvz Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Support '==' and '!=' predicates for MAC address format; for example cd /sys/kernel/debug/tracing/events/cfg80211/rdev_get_key echo "mac_addr == de:ad:be:ef:de:ad" Signed-off-by: Alan Maguire --- kernel/trace/trace_events_filter.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index e2521574f3c4..f38023f490b1 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -1384,7 +1384,7 @@ static int parse_pred(const char *str, void *data, unsigned long size; unsigned long ip; char num_buf[24]; /* Big enough to hold an address */ - char scratch[4]; /* Big enough to hold an IPv4 address */ + char scratch[6]; /* Big enough to hold a MAC address */ u8 *pred_val; char *field_name; char *name; @@ -1738,6 +1738,24 @@ static int parse_pred(const char *str, void *data, if (pred->op == OP_NE) pred->not = 1; + } else if (field->size == 6 && + sscanf(&str[i], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", + &scratch[0], &scratch[1], &scratch[2], &scratch[3], + &scratch[4], &scratch[5]) == 6) { + /* For MAC addresses, only '==' or '!=' are supported. */ + if (pred->op != OP_EQ && pred->op != OP_NE) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); + goto err_free; + } + while (isalnum(str[i]) || str[i] == ':') + i++; + pred_val = kzalloc(field->size, GFP_KERNEL); + memcpy(pred_val, scratch, field->size); + pred->val = (u64)pred_val; + pred->fn_num = FILTER_PRED_FN_MEMCMP; + if (pred->op == OP_NE) + pred->not = 1; + } else if (str[i] == '0' && tolower(str[i + 1]) == 'x' && field->size > 8) { /* For sizes > 8 bytes, we store hex bytes for comparison; From patchwork Fri Apr 28 15:34:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 677938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E22EC7EE22 for ; Fri, 28 Apr 2023 15:35:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346542AbjD1PfP (ORCPT ); Fri, 28 Apr 2023 11:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346531AbjD1PfL (ORCPT ); Fri, 28 Apr 2023 11:35:11 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C1375244; Fri, 28 Apr 2023 08:35:10 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SF3p1x013972; Fri, 28 Apr 2023 15:35:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=A8n7IWYsz0evWA6hKev01ep+OFzLGkqSGTqbwsVvpIE=; b=1Dnp43vuzDmcpvc08SYw3ZjNKtJj8cVlMZ+vvxNyNXmTu5sE9Hq7kFCYLd6yAQoyg52d 9G6OE23+ZiqsdPvy4EwGPu3PFkm7LPb4gl57A4FWebagbmknJozZ6Y/LBJ73IyKh3ywt m0/Z/UG8bJPVSX/OHWnv8JRLMAxHZEnK2cyBvBvP624UXst9hv2JLjUayoc5/AP1M6No 6Q4ihR8/UheZqjA812x638Fr3V06tXZ8RjZGFV5Etgh5c4XUX0ltouqoK5VUIpqxYQN9 y+8+ZHAHgIjMQ9/VY2+yIa2BAzBK+Izvd/LGaoQ2ANkdecLmJBmDGvdpiTPScxR5Sp5t ag== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q460def6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:05 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33SE5fMg028161; Fri, 28 Apr 2023 15:35:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q461b4ru3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:05 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33SFYqUK028134; Fri, 28 Apr 2023 15:35:04 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-188-60.vpn.oracle.com [10.175.188.60]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3q461b4rm0-6; Fri, 28 Apr 2023 15:35:04 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Maguire Subject: [PATCH v2 tracing 5/6] selftests/ftrace: add test coverage for filter predicates Date: Fri, 28 Apr 2023 16:34:48 +0100 Message-Id: <1682696089-27937-6-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> References: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280125 X-Proofpoint-GUID: Dvlj8wiFgnu_z9HszsNHs87LfXHJmZDC X-Proofpoint-ORIG-GUID: Dvlj8wiFgnu_z9HszsNHs87LfXHJmZDC Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org add tests verifying filter predicates work for 1/2/4/8/16 byte values, IPv4, IPv6, MAC addresses and strings; use predicats at event and subsystem level. Signed-off-by: Alan Maguire --- .../selftests/ftrace/test.d/event/filter.tc | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/event/filter.tc diff --git a/tools/testing/selftests/ftrace/test.d/event/filter.tc b/tools/testing/selftests/ftrace/test.d/event/filter.tc new file mode 100644 index 000000000000..21d4715e2176 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/event/filter.tc @@ -0,0 +1,91 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: event tracing - enable filter predicates +# requires: set_event events/sched +# flags: + +do_reset() { + echo 0 > ${event}/enable + echo 0 > ${event}/filter + clear_trace +} + +fail() { #msg + echo $1 + exit_fail +} + +test_filter() { # event filter cmd + event=$1 + filter="$2" + cmd=$3 + findevent=`basename $event` + echo "$filter" > ${event}/filter + echo 1 > ${event}/enable + $cmd + count=`grep $findevent trace |wc -l` + if [ $count -lt 1 ]; then + fail "at least one $event should be recorded for '$filter'" + fi + do_reset +} + +# verify filter predicates at trace event/subsys level for +# - string (prev_comm) +# - 1-byte value (common_flags) +# - 2-byte value (common_type) +# - 4-byte value (next_pid) +# - 8-byte value (prev_state) + +for event in events/sched/sched_switch events/sched +do + for filter in "prev_comm == 'ftracetest'" \ + "common_flags != 0" \ + "common_type >= 0" \ + "next_pid > 0" \ + "prev_state != 0" + do + test_filter "$event" "$filter" "yield" + done +done + +# verify '==', '!=' filter predicates for IPv4 addresses at event/subsys +# level +for event in events/fib/fib_table_lookup events/fib ; do + for filter in "dst == 127.0.0.1" \ + "src != 127.0.0.1" + do + test_filter "$event" "$filter" "ping -c 1 127.0.0.1" + done +done + +# verify '==', '!=' filter predicates for IPv6 addresses/16-byte arrays +# at event/subsys level +for event in events/fib6/fib6_table_lookup events/fib6 ; do + for filter in "dst == 0x00000000000000000000000000000001" \ + "src != 0x00000000000000000000000000000001" \ + "dst == ::1" \ + "src != ::1" \ + "dst == 0:0:0:0:0:0:0:1" \ + "dst == 0000:0000:0000:0000:0000:0000:0000:00001" + do + test_filter "$event" "$filter" "ping -c 1 -6 ::1" + done +done + +set +e +modprobe cfg80211 +set -e + +if [[ -d events/cfg80211/rdev_get_key ]]; then + for event in events/cfg80211/rdev_get_key ; do + for filter in "mac_addr == de:ad:be:ef:de:ad" \ + "mac_addr != AB:CD:EF:01:23:45" + do + echo "$filter" > events/cfg80211/rdev_get_key/filter + echo 0 > events/cfg80211/rdev_get_key/filter + done + done +fi + +exit 0 From patchwork Fri Apr 28 15:34:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 677813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FA56C77B60 for ; Fri, 28 Apr 2023 15:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346255AbjD1PfR (ORCPT ); Fri, 28 Apr 2023 11:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346539AbjD1PfN (ORCPT ); Fri, 28 Apr 2023 11:35:13 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05DA2210C; Fri, 28 Apr 2023 08:35:12 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SF3oxp020054; Fri, 28 Apr 2023 15:35:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=RSxC4dWNE/2O3qu1GoLDyqzY8ygixzh0e37oJcbfFXY=; b=iE5bg7XhGAAl+xGcwP7EklzRB8jLyYEGDDv1PWq2bjXYArMTddijJXlsRkXULWl8fvYZ OsYz69q1GOeeLUEBcE9VC3BC0AhwyQsIESr3fIysJHbn8jRkkdWgPLndqyLsp/qs5Dw1 oGzovernceL5RcvS2iR1hzUy89KerdDBUqiLiQ0sX/s0EugMZ25cL/wclsk9lkS9D+om 1MlpnOZ6BlmIM1rbxttfZiGBHPqBnh/mRbXokZolrGeC+vsZamXM9CbZs7ijIQaTsc7a ysO2bWwMIOG8nBGf39BjfW5fbVttC/mI0Mvqd6JiuvSX/cEV7Duit7hOVavAMj27RxHs UA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q476u6ged-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:08 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33SE5vmh028177; Fri, 28 Apr 2023 15:35:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q461b4rvq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:07 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33SFYqUM028134; Fri, 28 Apr 2023 15:35:07 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-188-60.vpn.oracle.com [10.175.188.60]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3q461b4rm0-7; Fri, 28 Apr 2023 15:35:06 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Maguire Subject: [PATCH v2 tracing 6/6] tracing: document IPv4, IPv6, MAC address and > 8 byte numeric filtering support Date: Fri, 28 Apr 2023 16:34:49 +0100 Message-Id: <1682696089-27937-7-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> References: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280125 X-Proofpoint-GUID: jp-r6OidS0SqBkV1800aMVkzMX12rjV8 X-Proofpoint-ORIG-GUID: jp-r6OidS0SqBkV1800aMVkzMX12rjV8 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Document that only == and != predicates are supported for IPv4, IPv6 and MAC addresses. For values > 8 bytes in size, only == and != filter predicates are supported; document this also. Signed-off-by: Alan Maguire --- Documentation/trace/events.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/trace/events.rst b/Documentation/trace/events.rst index f5fcb8e1218f..6a75e4e256c9 100644 --- a/Documentation/trace/events.rst +++ b/Documentation/trace/events.rst @@ -182,10 +182,31 @@ The field-names available for use in filters can be found in the The relational-operators depend on the type of the field being tested: +For IPv4, IPv6 and MAC addresses, the available operators are: + +==, != + +For example + +"dst == 127.0.0.1" + +"src != ::1" + +"mac_addr == ab:cd:ef:12:34:56" + The operators available for numeric fields are: ==, !=, <, <=, >, >=, & +For numeric fields larger than 8 bytes, only + +==, != + +...are allowed, and values for comparison must match field size exactly. +For example, to match the "::1" IPv6 address: + +"dst == 0x00000000000000000000000000000001" + And for string fields they are: ==, !=, ~