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: 88671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1016730vqo; Fri, 28 Apr 2023 08:37:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LfgYdNAfVLp3OAV9rJW4Uy5nNVpgWXHOhkL/UWugfHr6qwoejA7ixDRBJFqu1B03DXgK3 X-Received: by 2002:a05:6a20:c701:b0:ec:8859:7aa7 with SMTP id hi1-20020a056a20c70100b000ec88597aa7mr1204638pzb.62.1682696219932; Fri, 28 Apr 2023 08:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696219; cv=none; d=google.com; s=arc-20160816; b=HWCXBIhSVkSg44PtKatWRQRpp1287Xbqqt1lkVZT+zvN1vfGlTHryS4GChpxyaAq96 jz+XyQxvG7m9mFyCyOR4hn9cjMBKS2soNwYiJ+DfosvfEPSZjH3q1NwTv7T9Uuucolv5 6gifDJo+mp5LUZ3Qv2FLW0HmNc6896rAqThKR9K9OHwZKKXsorC9x99hvOOS0WjRr9+Q 3hbcy1QY662QEbyHso0yVv25mOQz5pRTFD9+N9iA6sXk+ZcHQsx0hSlHcFZDcBbg/iaG vrqaWamaMQnAgIeqWyDg+GFe9JVMy4+v8R70qAzNJV4Treb8woHAhBbnkAGEQ0JztRUB cD/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=YVCRBRkfFPkGR8hzIXJZIFGAb7lsTnmbW9p0HfFiVb4=; b=E2qb+PJ2wvaFBWNeyxcusMl34imascI2iJGCCUoGphl3QDs8ERlLfureAOfpp4aLfm PTbWnA05fA7Np7FQiBWdV6o5RvJcHCyjuKVtGPy0B/zOiaDcBYXVaElGWqy8Zfm8fDEi RW4sRGcMAhK+/Il5P/R29xfzEfiy3nRzYFJaiPZWLZCAX0o3QOHk6ZSbAztsjDbZHRdU kKwEzQeQeGpKNoLgJQA40kKMrOm5Oi7HVHFjyZ/SRXt/enngif3MC7n9f0gDKmJJt2FF c/BI5eQo9RLphAMMQgNaAJO+eCavpsxH5yfRwo+Js0/7AeNyCzM6/ZVcIWKv8c5DRMFy P0Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="j/30y37w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w68-20020a626247000000b0063b87f60f7bsi21601153pfb.48.2023.04.28.08.36.47; Fri, 28 Apr 2023 08:36:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="j/30y37w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346533AbjD1PfM (ORCPT + 99 others); Fri, 28 Apr 2023 11:35:12 -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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764434871256562206?= X-GMAIL-MSGID: =?utf-8?q?1764434871256562206?= 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: 88672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1016876vqo; Fri, 28 Apr 2023 08:37:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70sTEkq9CuAAOw5oPDGlYUskKRZ50h3M55eK+8zzGmG7yrx3BkB4N1Ty+G4pUF31zohn4x X-Received: by 2002:a17:903:2312:b0:1a6:82a7:6e60 with SMTP id d18-20020a170903231200b001a682a76e60mr6201216plh.47.1682696233418; Fri, 28 Apr 2023 08:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696233; cv=none; d=google.com; s=arc-20160816; b=gRIh98LGz+4NCdcR+7+pRBDvzpOWcK1qWWGKnFPjHoHBZli7ZkNlpdu2+8vgedCS6O GivGJi77vYuBzJlm472YQ4J+FGnvJNSTCEzT/Pwxr8908uKkCpXQTOfqwU5J4wXfVz2R 1NO0XR8rUAjjiMn0C0jopj3bQKuXPjBTjO/wV6rg+4xKtnb0FtURJfxFCX+qq6BlIDkn 7QGqM8rLxnpKaoo1fff1poNQYWmLsGB7OA1D8maFp3TDvHfZZvME8wyjtgIfBndk4htM v/iJbS7Lv3khrr8ZdTh7/osvCxca2ZMh9QhDIxxMehskSc/uZ+dLvFjs5YIPVdCTSJKf 47QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=nOmEmDJvf0ujmg1ooMtHBJ58/BwYXKCo6GrTn2bVPdY=; b=DKcIf2FBlqy+hYlCQZxUeQwQBM/6NA4NnhQ1W4IXxm4Y8Ykpj0g/7Hs4gS05xGtTAe 88cWhV/FiYsqPmvPuyyBfTsGqN2G8zbctsOV4AUBrwtowTY/123CbnHOgYKxhZOXg/vN da+sORy9HVWVvtc0dsJojz/a82wFePj7Wd6P3+H6i1BSVtCehO8ZZDoLvDtDrgHIBod8 UJ9AONLxXnafbgAvQa3fhJ4yhvuctb12y+JrlN11DqGXRmHd2zMo6RTgxkdKvESnkXgy FaRnYoqqFkl2uobajSdTF/NcKsHqXa5+cvA/yZPbM1mSAHan+1oTd8luWNfuBPHk9TN/ 6/4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=rJkCevQd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a170903125100b001a6ce2cdb20si13672764plh.244.2023.04.28.08.37.01; Fri, 28 Apr 2023 08:37:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=rJkCevQd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346472AbjD1PfR (ORCPT + 99 others); Fri, 28 Apr 2023 11:35:17 -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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764434885619413822?= X-GMAIL-MSGID: =?utf-8?q?1764434885619413822?= 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: 88674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1017578vqo; Fri, 28 Apr 2023 08:38:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JYM8qFvjh1p/HBJREeZDhUtXWMCgU0dxHGehzARAIQOJy4qBwOPPa2m39TZPuk00viYbl X-Received: by 2002:a17:90b:3a85:b0:247:85d2:808f with SMTP id om5-20020a17090b3a8500b0024785d2808fmr11704745pjb.12.1682696307451; Fri, 28 Apr 2023 08:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696307; cv=none; d=google.com; s=arc-20160816; b=UnUPwd16tUr6ttltvX9e2sU5G3kIMou18OhNnd+1afiD742rFX+NcEmHzIJYhIFEh2 d8SJo0MfPcmTGymgeAiUvaHPYGPCUhRAmk3JVeZnfOE7fgQvRiJYWkSE+wR69NXu3NAt eASBkw5hqKNat0p0FPtOFUELdRJ1b6F0fl6FVYBY09GSfqJ6iK8tXhrL/3dJlUHwUafm 3Rh+aNwAw3Dp7XGMBafdvO9ZUH05OejGSzex4Ht2naBE28lOFB7KywhLj7WJ22seBfPK 51/ZkeZIcZ1DOLiIZzLnD251vF3vGDt4r7RR9hZvtqjO9YausoX9A5ruRA000pIJc/+v F6YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=HW9CMy3il/IRcCDBr4P2DexsA8A9u2fl1mPaG/1i0tU=; b=YxjNDmEdTzsXzKL6aTbHl/K9zTLUZhBeXiPnpMz5la12DUNmrR1zoli7frOt4OM5Tr EbdXTvw1pJeMrnjl7DRLNnhI9Jz+d6m17gI/9HAT5qQTx3ov1cbN0Hu113vYysvAyLXS hFtCw075Zo/yBN4rP5hBD0W9TraAMwr9ELVBzVIjvSEQ8AwRLeIchhwo1Q4D2fjXm10o DCnp/lNpUizvccEJEAaSpeLtup8HrQpte7E7tl6WVmgifmcq5J/Jfh0e5Imc7ncEbXqX TaH3Y4CUGtgj4GnLFLe7dqEpp/z+ckEnQHmwc1xucbzUIuSCZSQ2j+7ohzcaSH2Xn7sA awlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=iPfW1RU3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x11-20020a17090abc8b00b00240aff612f9si23824356pjr.140.2023.04.28.08.38.14; Fri, 28 Apr 2023 08:38:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=iPfW1RU3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346493AbjD1Pf0 (ORCPT + 99 others); Fri, 28 Apr 2023 11:35:26 -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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764434963438630470?= X-GMAIL-MSGID: =?utf-8?q?1764434963438630470?= 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: 88673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1016951vqo; Fri, 28 Apr 2023 08:37:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZDNKIyGtrRFNGMn2IKLatj2NggSZnzUzTFiz61+Ue7GnVfZLk1cqpkeTa+24sQfnxLkFl X-Received: by 2002:a17:902:7c85:b0:1a6:46f2:4365 with SMTP id y5-20020a1709027c8500b001a646f24365mr5468722pll.30.1682696242978; Fri, 28 Apr 2023 08:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696242; cv=none; d=google.com; s=arc-20160816; b=qoZeg2xUMXSHo68GKa/DZgZljh7UumBsg4lpcKcCoEOZNYhJsuLSl8cdDHu6DptLb4 2RjJwM700kYHMZ2veI/ygVtNZxcH5U+XgRtsLwKMYjLj3JM19QrOVKwHtdHc0e2174uM NTRyu9j+/qqpWIvLERCIynOOeEJn3/MpU20kTvUVKNex0mhqvnWp17g4zSJxrnAEK3f4 wF0N1KHP0dvEz8O9SZHQoiEtXPaYnaBJyq1moKQYEPSfRdZlbrnyNtTckWnS8GnZnCG9 BULkXScDUxHpInceeC5SD6p3h7SfTulPg8HY+EX3W0o3FPR+LdM0af6FmEBvVFzs31yb Tbsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=qbpAVpdqvJpRmYvk+bUcqyw6njxS1/sYaFkQUCMfQdk=; b=KN7cEO+d10agO/J2meqnCjneplAL2S40jJQpazI7wGJadABpc9nRBR2Uvz+Z/U5Dcn 8nIUHEUy9n0IeuUBgjyNUaJecCb0oKWITc66UCdjsKR61ajagVQ+P+QyHeJw/98BD+FQ UoiRoSSLdailht/sW3ffkWqLDCTPteZwY8bDRcn4L3buNbXuNw5yRf4UqGBP9N6A6ojC c83TKgM8YeqC9tXaLWykBXVRU+PcEZtRolqGLgwpDdhCRFxJYnUuiOCNPbqE2PWfQ+h9 M4HmqbH9W5Pn1lIpnjqque9m7XacJX6XSD8pvSJLSJMp1p4CiqMsMnlDe7N3gXvqUuWg HQgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=CLenxwek; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk16-20020a17090308d000b001a216572122si22244836plb.285.2023.04.28.08.37.08; Fri, 28 Apr 2023 08:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=CLenxwek; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346463AbjD1Pf2 (ORCPT + 99 others); Fri, 28 Apr 2023 11:35:28 -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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764434895414263465?= X-GMAIL-MSGID: =?utf-8?q?1764434895414263465?= 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: 88675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1017625vqo; Fri, 28 Apr 2023 08:38:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YMb61pCwsjB4VsMbzg2Kw2zOZU9fsBC1veuDr3aJ0IXML47wGhc4w8eUtQii9ZmaHEwl9 X-Received: by 2002:a17:902:9898:b0:1a6:961e:fcfe with SMTP id s24-20020a170902989800b001a6961efcfemr5022075plp.30.1682696313052; Fri, 28 Apr 2023 08:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696313; cv=none; d=google.com; s=arc-20160816; b=noJD4Ry2VOVRJE79DcJTXUuocwAGaeaBH4hQrat37K4udmEASlTwfn15BvMGzRwg/b GBO6Q76KEQgsD9b9BNr0IuvoSmIDggLHJJJOMIG9veepPZKVacqHp5rGeH7PcJY2yyt7 x4/rHQsUmLcyejmVNSG5OEhf+lOudslUqZakxFd/AA290bvVGR+jnyO6P/OG/kJ0OF4F wr1dPwaMW9W4wddWMkjCps7Q63yOoqlEv7qjcuom8Yh5lBus6XrQ/p3FU2+lb0ABcMGT lrFUa0rL6upQfdocYfAvJgppTel3wOfuXD20jbezkwY/58IOUR7udcbwk/fcVZKYQoPa 8QnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=A8n7IWYsz0evWA6hKev01ep+OFzLGkqSGTqbwsVvpIE=; b=LpxpUCm8VCWhbuekzZHqLTseZoComLwsWQbonE7VFujZ6SE/THIIsyHTWaac3uwxjn tnypkxaPl5zrT8qZfi1KCy1JEjjA+M96ZTHgVH8ZvJoo8RuQsucGN/TNAlvYbUUs6Ve3 ebia/VOU08ZLHfy0ysFoKG0C513fLQ23neBVjBVr+w+6BMFE8qs6HrniAndk7RdJAuJM pZOPJAj/cskMPC7wrMZLy49QBBL7dB4a0kDQ/4nIRWdEqk58XgCf8yHYTXI81rFe4vEs 8LLWkeXwM6YBvQf2dHpkq6V57gBw9PooOw7yofKw3t5U8fkWtyfZ7NNV+hrJu8Il/ZWV 3KwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=1Dnp43vu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 126-20020a630184000000b00524cf94760csi19907626pgb.335.2023.04.28.08.38.20; Fri, 28 Apr 2023 08:38:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=1Dnp43vu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346116AbjD1Pfb (ORCPT + 99 others); Fri, 28 Apr 2023 11:35:31 -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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764434969405916103?= X-GMAIL-MSGID: =?utf-8?q?1764434969405916103?= 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: 88676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1017748vqo; Fri, 28 Apr 2023 08:38:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VnkBBpBBwQ6kw5CkQmXLVzwAvcQpHyv4L29ZcdxiwGz0tOb+ZhKhUjsxOlvsR+AOYgt5l X-Received: by 2002:a17:90b:17c1:b0:247:862d:a224 with SMTP id me1-20020a17090b17c100b00247862da224mr5892729pjb.27.1682696327103; Fri, 28 Apr 2023 08:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696327; cv=none; d=google.com; s=arc-20160816; b=m3VK05nhGfF7rVteHqpkxdx9IlA9jIisFD/WipnjqbUPKxphwok2/f08XGLWQKqY6f Rr25ElJCeML3vGWEE6UkMOQjId3gXaXbSKXIM1qCok8u2twlwcC4M3R+EAq4TaALaXeX slwj+JB+B6IhxzzW93rxssAAUa9apz4WGEjfA0rCK2NqnHJDqE2snoI05lX15tS2KvEZ tJ4/kisb0XdzMlmiObhC+vAvRZ24MMzC7oa6VWC1Ue/mJhJrzupTUxJx04Zzs5i01KjO jOjaI69IvqYqUXyzXmo5V5bAGKXw+TOG7xcGPjFmxW6lqLopsiz+U35bEZvIBoXiIHiv Wv+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=RSxC4dWNE/2O3qu1GoLDyqzY8ygixzh0e37oJcbfFXY=; b=WYnw5lRUVN7MiZ3YJD5gKCtASnYb5Hl+O1TXp7orZi+J1Ay2u6gdLWtVt7W5VTHunk NnyYKiUHAMWDwWaw2gyAN29JTxgNBPZPhmMnDXXOBuFxT4CKWRzMQyibzTmejEGW7LvL xORgzDNMkmGvV7Q/G6ACEiczap+t7mQWwaC4Y48zMCO/Bf5uZszZL7Ot0WI9Rrg0Dmld 0AGPQy7stW4v5J1p3pm09XP86WnHlsQchiZvYMWMEcGshsGlij2ufBW/MKBBYBj1hSdb KZ9YI7sbBERYvwukOV3miNPw2USsvAW0A55ETURm+i6bsojCiTYYzXUALv0J359P0tiV OVfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=iE5bg7Xh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nk15-20020a17090b194f00b00247023fdbcbsi23597007pjb.186.2023.04.28.08.38.34; Fri, 28 Apr 2023 08:38:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=iE5bg7Xh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346491AbjD1Pfg (ORCPT + 99 others); Fri, 28 Apr 2023 11:35:36 -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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764434983419656484?= X-GMAIL-MSGID: =?utf-8?q?1764434983419656484?= 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: ==, !=, ~