From patchwork Wed Apr 2 16:27:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 14036249 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 909C3191F66 for ; Wed, 2 Apr 2025 16:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743611285; cv=none; b=T+cBiszzfvBBmw4hUucQ6DtxA5VJbUWZud5niQrFX1KkyijKcl2tjBVmdh//a5Jj9gq9LfOhdVGRU8hy7rHmdfRSR+D/eEtc3dveCqB4V0wkZOWjrP73zloxZ/4LpUNjxKUZP63xF0o3TDTHRM4ydHJBGBWqwn4HL+zkEVM5MgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743611285; c=relaxed/simple; bh=0bssNN+MKMwfQMOFSfuZWruweQvD9Vp7pQOxvE9FyAc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lh9uuV4XwCUYnr/ythvtEEUOXx3ggE3fwtgraqusFhqsTYY2vjEUWmr8eEgRqVnUc97Mq8NmGD9zJeAeNiJ9cPudb1cOaoZ4omkYoLsDyPOJyOyixNbQEPuhL2/FJBlAisNjrbuQf7rGXdJW3H2NLKto5a2wxWwvx/RX7ZZeRaA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=k+WY7gj6; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="k+WY7gj6" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-224192ff68bso336205ad.1 for ; Wed, 02 Apr 2025 09:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743611283; x=1744216083; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Vy9reO5sSke0/0ENYRrqrhCelECLBO3q4PK9Gtebwhs=; b=k+WY7gj6CnDH2iJ87OMyjxVDNy4GM59vZJ9WmESdnFdkNMMdBXtuvJVU3KtRXxeU2w SEzJ3Kr4tO1d8P3Ixm24x4mRfRv73od4HYJcEE39mKyWLqcDarWskdT+Uv+veYs5FLma cyEwqY9mpcYDqFWRo1QD0nZ+avWTAMLJbIRkgCJMuy/N/W/Lr1bZx+xGObkm4KUey1HW c8En6NWCcIGjW9tN4NsYsy52cj8MK5JESy1f/bwjs6cr9gEdq01+EnlVyFxR7g+Z20z5 d+6JfJZ4kxNUA6paZ6BFR2XjDz0j4yAb3Ai+visAsI9SJ8SD45gNaWhQ2/FoYw65265f vw0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743611283; x=1744216083; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Vy9reO5sSke0/0ENYRrqrhCelECLBO3q4PK9Gtebwhs=; b=hj2RudErsCsP8yRlNv15Ybo4almPgOJyROBYTwNlrITJJTNorQVGT6RChilAoNRl5D rUzkwJqL5kQR13zEbqwvE+voN6Cz3Vk10csJa8okbJVn0lcR6XSOYfTfU4VAhEbnN4nx HREHnaA7nxMx8ixrbmhch6lxnkkA2co0UmqXH+RwG7sZcMOd8JQUW4JmzSVbQg/Zqwco jxP+PIUXhQ71t4iWt88zyIciA/DSe4upF3YrZJinHbDBp7ZFxZUNd0xoo1WKpPSD9352 axB43xSQvcA8MUImU359oXD/cQo7rBjI4QyyKiX+QVupdnOWN8p92NJx5Sx60heM2gGf oyhw== X-Forwarded-Encrypted: i=1; AJvYcCVFfqH8nOcc/D8ABxswHBpqBpKzGmtLaA5FyHdM9aarIWYqCjf5qRxFQrDGRXAR54Y29TuKyCw=@vger.kernel.org X-Gm-Message-State: AOJu0YxeRQVEV+zE+vA7gUnLy5XOPw1F4kdCbDTjdIMG+Pwsrbkypw+1 erVH2uBlxCHN8j757ZNUlrEF9GppmV89yotEp/fm6BFFdM8gcXMKtgiThTquwH1GN5BMvmus4A= = X-Google-Smtp-Source: AGHT+IEppDEhXNEnJuuguSyXa29zHUAVxWcgUUPya9ABXzsuDn/hla1s/pdM9tUk5JYU8lrMptyQMBiB8Q== X-Received: from pfbfn20.prod.google.com ([2002:a05:6a00:2fd4:b0:739:8c87:ed18]) (user=tavip job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:db12:b0:220:c813:dfce with SMTP id d9443c01a7336-2296c839967mr40085235ad.39.1743611282821; Wed, 02 Apr 2025 09:28:02 -0700 (PDT) Date: Wed, 2 Apr 2025 09:27:48 -0700 In-Reply-To: <20250402162750.1671155-1-tavip@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250402162750.1671155-1-tavip@google.com> X-Mailer: git-send-email 2.49.0.472.ge94155a9ec-goog Message-ID: <20250402162750.1671155-2-tavip@google.com> Subject: [PATCH net v2 1/3] net_sched: sch_sfq: use a temporary work area for validating configuration From: Octavian Purdila To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org, Octavian Purdila X-Patchwork-Delegate: kuba@kernel.org Many configuration parameters have influence on others (e.g. divisor -> flows -> limit, depth -> limit) and so it is difficult to correctly do all of the validation before applying the configuration. And if a validation error is detected late it is difficult to roll back a partially applied configuration. To avoid these issues use a temporary work area to update and validate the configuration and only then apply the configuration to the internal state. Signed-off-by: Octavian Purdila --- net/sched/sch_sfq.c | 58 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 65d5b59da583..1af06cd5034a 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -631,6 +631,16 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt, struct red_parms *p = NULL; struct sk_buff *to_free = NULL; struct sk_buff *tail = NULL; + /* work area for validating changes before committing them */ + int limit; + unsigned int divisor; + unsigned int maxflows; + int perturb_period; + unsigned int quantum; + u8 headdrop; + u8 maxdepth; + u8 flags; + if (opt->nla_len < nla_attr_size(sizeof(*ctl))) return -EINVAL; @@ -656,36 +666,60 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt, NL_SET_ERR_MSG_MOD(extack, "invalid limit"); return -EINVAL; } + sch_tree_lock(sch); + + /* copy configuration to work area */ + limit = q->limit; + divisor = q->divisor; + headdrop = q->headdrop; + maxdepth = q->maxdepth; + maxflows = q->maxflows; + perturb_period = q->perturb_period; + quantum = q->quantum; + flags = q->flags; + + /* update and validate configuration */ if (ctl->quantum) - q->quantum = ctl->quantum; - WRITE_ONCE(q->perturb_period, ctl->perturb_period * HZ); + quantum = ctl->quantum; + perturb_period = ctl->perturb_period * HZ; if (ctl->flows) - q->maxflows = min_t(u32, ctl->flows, SFQ_MAX_FLOWS); + maxflows = min_t(u32, ctl->flows, SFQ_MAX_FLOWS); if (ctl->divisor) { - q->divisor = ctl->divisor; - q->maxflows = min_t(u32, q->maxflows, q->divisor); + divisor = ctl->divisor; + maxflows = min_t(u32, maxflows, divisor); } if (ctl_v1) { if (ctl_v1->depth) - q->maxdepth = min_t(u32, ctl_v1->depth, SFQ_MAX_DEPTH); + maxdepth = min_t(u32, ctl_v1->depth, SFQ_MAX_DEPTH); if (p) { - swap(q->red_parms, p); - red_set_parms(q->red_parms, + red_set_parms(p, ctl_v1->qth_min, ctl_v1->qth_max, ctl_v1->Wlog, ctl_v1->Plog, ctl_v1->Scell_log, NULL, ctl_v1->max_P); } - q->flags = ctl_v1->flags; - q->headdrop = ctl_v1->headdrop; + flags = ctl_v1->flags; + headdrop = ctl_v1->headdrop; } if (ctl->limit) { - q->limit = min_t(u32, ctl->limit, q->maxdepth * q->maxflows); - q->maxflows = min_t(u32, q->maxflows, q->limit); + limit = min_t(u32, ctl->limit, maxdepth * maxflows); + maxflows = min_t(u32, maxflows, limit); } + /* commit configuration, no return from this point further */ + q->limit = limit; + q->divisor = divisor; + q->headdrop = headdrop; + q->maxdepth = maxdepth; + q->maxflows = maxflows; + WRITE_ONCE(q->perturb_period, perturb_period); + q->quantum = quantum; + q->flags = flags; + if (p) + swap(q->red_parms, p); + qlen = sch->q.qlen; while (sch->q.qlen > q->limit) { dropped += sfq_drop(sch, &to_free); From patchwork Wed Apr 2 16:27:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 14036250 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 415F91D79A0 for ; Wed, 2 Apr 2025 16:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743611286; cv=none; b=VHSfHEyfMOIWX9Bzi+I/WA2NZjx3Y/u7/bmo/tTSgxraJjqAN0JNJPx//9DRYcZxct+0sqKTxAjDL3/YKkUrHNqUq6AX77UOoCcxOXdJCv+w0IPLMuadVljaN6NIvzFBLPN8imxneH/k6YUIaXQgBZ72us1QU+tiEQwworPdzDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743611286; c=relaxed/simple; bh=D7UVCsXvD8YRTDPaHE9hjbe9eGISg4Hv/4Muj760f/w=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tl6TMz7VnxJVq+kYFABacWk5q1je1s32BGywVdvVBxRUtUBs2S4eZ5gbJriJSf/qw30SK1eXoGurunOJWZnniwwSfCOKVK5QA8oAhW2/foNJXWVzCwGTSshdinseqc/9ajbIXOsBMAEE3ZJ1tYgRtMygoXaQHLPBZJB+VBQHG+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SIlEvBaS; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SIlEvBaS" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-736c0306242so350317b3a.1 for ; Wed, 02 Apr 2025 09:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743611284; x=1744216084; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=bAsTAjyHyMhUQ0J+FFaMDsSJV48wWPy7H90qasJ9GVk=; b=SIlEvBaSZxQP5p/mWGhwPxX5nCdds0pZiHcaS9ZlJKvwMZS5tLviyJZSqTJxigZplJ s/wdrQzkMurwlvD69GsKGTdHfdjtnnl6u0/AOmaARsd/D9S1I/RYaThxXXXWcrB3JOF5 AXAVQeBOwrNiTCv2oKjxzjfl9055JrLPa0ZeOgWsCFcnkiA7gCO5/41C/b4QPKZ6Dh4T tohk3+Crj5hSwrStbjeH64ZrtSs4535Xw06r91OPNCT4qNYAINqINSnd0VeD3fHJsbiN nO1ka9kHkZov4Dykok6X8Bgw95auMARk1aiyNClY0FTzBbDNjSurSL4IjfmiHUW1Geje fIcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743611284; x=1744216084; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bAsTAjyHyMhUQ0J+FFaMDsSJV48wWPy7H90qasJ9GVk=; b=pduAmhffvjGEQmy6LZBXibIt/X+MIdPzTqqtuR1quV/8Dr7oNIzoUcasKhhtrO4Xac MaJWLTQOt8+WrX0VrPQvjRTIPHO65Vhe3CVdqN/Hhj6Z04ZSia6b7kXww3hJumA0Xjh+ VmLhB4YPZVHUz4bzNfoJmqmuOsltaTSDgV0pU8ieywDgdSuVmVZFWvXDKVp1rnDqy5ao FAk7xpHjrwe5zUb5elnWhr/cGt88AmD1BPhmszAiOT0KvBp7XS2zf1qtWEoVqm7BSYCu I/m5w7K4X1LYf8kijxIqkY5K9aM59EORMQHJE6dd7ScPN9t8goTDW6cSte+YdbIxBsiP y7Bw== X-Forwarded-Encrypted: i=1; AJvYcCU+aPgf3CpYCXKWklyHOu8DMvmEoA+w9+3YWHPxFoD4rXdxhIEgE5Y7Z3141rVJljkTEyGhuXg=@vger.kernel.org X-Gm-Message-State: AOJu0YyFR0F+CsNq++Hk0u9iYX/r4k32fI0f/oTwA+Fpu1h6kSi/1Mk+ /kteS4wlo/51eKaTe3dRIJEtKZFCRZFksoWCy48o71YHBeE1S8GMtktmXrVDlETTj1b2U0gAkA= = X-Google-Smtp-Source: AGHT+IHVuUf9ItDd/ojh6QPVVLXRawy3hiGZmQM0wy2ZzaXB44gBTR5XArM2P0mjQOrmQBZxU6ZNVN9yHQ== X-Received: from pfbfb8.prod.google.com ([2002:a05:6a00:2d88:b0:736:adf0:d154]) (user=tavip job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3cc9:b0:736:4cde:5c0e with SMTP id d2e1a72fcca58-739803923c7mr23251750b3a.10.1743611284536; Wed, 02 Apr 2025 09:28:04 -0700 (PDT) Date: Wed, 2 Apr 2025 09:27:49 -0700 In-Reply-To: <20250402162750.1671155-1-tavip@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250402162750.1671155-1-tavip@google.com> X-Mailer: git-send-email 2.49.0.472.ge94155a9ec-goog Message-ID: <20250402162750.1671155-3-tavip@google.com> Subject: [PATCH net v2 2/3] net_sched: sch_sfq: move the limit validation From: Octavian Purdila To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org, Octavian Purdila , syzbot X-Patchwork-Delegate: kuba@kernel.org It is not sufficient to directly validate the limit on the data that the user passes as it can be updated based on how the other parameters are changed. Move the check at the end of the configuration update process to also catch scenarios where the limit is indirectly updated, for example with the following configurations: tc qdisc add dev dummy0 handle 1: root sfq limit 2 flows 1 depth 1 tc qdisc add dev dummy0 handle 1: root sfq limit 2 flows 1 divisor 1 This fixes the following syzkaller reported crash: ------------[ cut here ]------------ UBSAN: array-index-out-of-bounds in net/sched/sch_sfq.c:203:6 index 65535 is out of range for type 'struct sfq_head[128]' CPU: 1 UID: 0 PID: 3037 Comm: syz.2.16 Not tainted 6.14.0-rc2-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x201/0x300 lib/dump_stack.c:120 ubsan_epilogue lib/ubsan.c:231 [inline] __ubsan_handle_out_of_bounds+0xf5/0x120 lib/ubsan.c:429 sfq_link net/sched/sch_sfq.c:203 [inline] sfq_dec+0x53c/0x610 net/sched/sch_sfq.c:231 sfq_dequeue+0x34e/0x8c0 net/sched/sch_sfq.c:493 sfq_reset+0x17/0x60 net/sched/sch_sfq.c:518 qdisc_reset+0x12e/0x600 net/sched/sch_generic.c:1035 tbf_reset+0x41/0x110 net/sched/sch_tbf.c:339 qdisc_reset+0x12e/0x600 net/sched/sch_generic.c:1035 dev_reset_queue+0x100/0x1b0 net/sched/sch_generic.c:1311 netdev_for_each_tx_queue include/linux/netdevice.h:2590 [inline] dev_deactivate_many+0x7e5/0xe70 net/sched/sch_generic.c:1375 Reported-by: syzbot Fixes: 10685681bafc ("net_sched: sch_sfq: don't allow 1 packet limit") Signed-off-by: Octavian Purdila --- net/sched/sch_sfq.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 1af06cd5034a..d731013ec851 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -662,10 +662,6 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt, if (!p) return -ENOMEM; } - if (ctl->limit == 1) { - NL_SET_ERR_MSG_MOD(extack, "invalid limit"); - return -EINVAL; - } sch_tree_lock(sch); @@ -707,6 +703,12 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt, limit = min_t(u32, ctl->limit, maxdepth * maxflows); maxflows = min_t(u32, maxflows, limit); } + if (limit == 1) { + sch_tree_unlock(sch); + kfree(p); + NL_SET_ERR_MSG_MOD(extack, "invalid limit"); + return -EINVAL; + } /* commit configuration, no return from this point further */ q->limit = limit; From patchwork Wed Apr 2 16:27:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 14036251 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2DA51DB15F for ; Wed, 2 Apr 2025 16:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743611289; cv=none; b=HuPxi4sYDY+h4EnOpj/2+vh3zfab9J9HbT+qKrDeB78Z42cpHzHbCvF2xjMSSpGUuXCe2mznJM5lwCHityduKQksRpKn2G6Ce/TwDxM7yTUarUrcsdnSwPwDY6zvEkRA0yJtpfxjjaucohai5bDhJ0kfMAlTywoItlCVHKmmvZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743611289; c=relaxed/simple; bh=le48TpsLIXgwRUE7JK2oXHpEVjkDjeIk8bkxcrTUacQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=P6QKcOXWp+PiziRUaHN2EfsD+UW5dL8q0Peq4ebJCtvTAlqZBcocfkEdwDYKJWhFVU9+OC3L79Mwjag9fTdZJNsiUsM8AUD4jLmDUpAhCRci6qZETkWA3RVjiqTesz6s94jovexIVJtP1MjNG+vSSMeNW3ilnQ8YtUOetY/M9KQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=xcv05iNM; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xcv05iNM" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3032f4eacd8so11161265a91.3 for ; Wed, 02 Apr 2025 09:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743611286; x=1744216086; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WR5OMrXI1sfyljYWNGyiK+AjZvbJe/Y00ticFJRI05Y=; b=xcv05iNMADgtqon5MfnnhG+NtGn5odpF6BWzdTXQWLSBYLhvujYIwoFfG7VFJ0gbwd MKty76BH+2ac1pKebSTldQtRzVld05XuW5bjRiY4vRactUlzOLo3Dx2XUIzb2Po3UFx5 A+uAFszlS0blACJQwSbfP7xYjWKOionnmNhSOTCBKYUjQxaKz92YTL5cfa3NvZByR31q S2c3Cd1p52xP+WXQL4CxS9oafnBAV2RYYcOANd5moClT7nhRK/ujE/w4iwuf28AabJCn aYmRwxC9hI2adur2FkVXm2rOC4HxLRBqMleSyfuyuSJ5+z7eHfArfUo86/zKNx5aMDeT 5huw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743611286; x=1744216086; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WR5OMrXI1sfyljYWNGyiK+AjZvbJe/Y00ticFJRI05Y=; b=ixlJlCktKwYRd4R+fJxOBxi0M3z6Z4v4G58mMxeyBUqd3OxJmQoJr2YcV6X4RE2ok9 fUjx/9xDQ0XIDB823pPErGor37rqV0SX6DcYbff8z4F2F2UKjnWDsHcWGkmJR95b/DCW AfeyMGju4jzdMVjoh2TxRWIYEVK1eXQ1LLFoH1RnnkK6KS5bK5N7j7vVJBBWS2vz1Od5 IZsuVoVpoe8Q+A4d4RQfQYimgCnOQBlwq4JDhDYZNKkq81aFpcK++zREza5ntXl8SyVH FvSQ5HI8u4RdMShYWKgmaJPi53rqUNbV7BCaJnb3zzThi5uaLOu0g64d4Uoy4F8QXx18 Ps0g== X-Forwarded-Encrypted: i=1; AJvYcCXPj7lr1kruUO67aQ+iYCE/O+e36RAQhnVoY3v8TZOPI4qwc8zRIHI1o2O5aeP5JxXWmurMfX4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8xAX/704mqBpgZNoiE3XIAFJCxiGsZoyZ7sNgLCGkIIjx6+/q 1SaEv7vzv0klCqkJRUjHo4N8azKuNODD9EtoQnlWZnG+Aa+FdQGrPam8c9/VgOGt2LZ8h7Eb1A= = X-Google-Smtp-Source: AGHT+IGDaiMq0FcBeFolYyJvVt1nniMip0rSXoze+gTClkjtz+wbObgNoSNr04Kru88H1XJrjlLLejpg1w== X-Received: from pjtd10.prod.google.com ([2002:a17:90b:4a:b0:2fa:e9b:33b7]) (user=tavip job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:e183:b0:2ff:5357:1c7f with SMTP id 98e67ed59e1d1-3053215a3e5mr26898614a91.30.1743611285949; Wed, 02 Apr 2025 09:28:05 -0700 (PDT) Date: Wed, 2 Apr 2025 09:27:50 -0700 In-Reply-To: <20250402162750.1671155-1-tavip@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250402162750.1671155-1-tavip@google.com> X-Mailer: git-send-email 2.49.0.472.ge94155a9ec-goog Message-ID: <20250402162750.1671155-4-tavip@google.com> Subject: [PATCH net v2 3/3] selftests/tc-testing: sfq: check that a derived limit of 1 is rejected From: Octavian Purdila To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org, Octavian Purdila X-Patchwork-Delegate: kuba@kernel.org Because the limit is updated indirectly when other parameters are updated, there are cases where even though the user requests a limit of 2 it can actually be set to 1. Add the following test cases to check that the kernel rejects them: - limit 2 depth 1 flows 1 - limit 2 depth 1 divisor 1 Signed-off-by: Octavian Purdila --- .../tc-testing/tc-tests/qdiscs/sfq.json | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json index 50e8d72781cb..28c6ce6da7db 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json @@ -228,5 +228,41 @@ "matchCount": "0", "teardown": [ ] + }, + { + "id": "7f8f", + "name": "Check that a derived limit of 1 is rejected (limit 2 depth 1 flows 1)", + "category": [ + "qdisc", + "sfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [], + "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root sfq limit 2 depth 1 flows 1", + "expExitCode": "2", + "verifyCmd": "$TC qdisc show dev $DUMMY", + "matchPattern": "sfq", + "matchCount": "0", + "teardown": [] + }, + { + "id": "5168", + "name": "Check that a derived limit of 1 is rejected (limit 2 depth 1 divisor 1)", + "category": [ + "qdisc", + "sfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [], + "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root sfq limit 2 depth 1 divisor 1", + "expExitCode": "2", + "verifyCmd": "$TC qdisc show dev $DUMMY", + "matchPattern": "sfq", + "matchCount": "0", + "teardown": [] } ]