From nobody Thu May 05 19:14:51 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C05D61ACA35A; Thu, 5 May 2022 19:14:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KvNgJ0XxTz4msn; Thu, 5 May 2022 19:14:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651778092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EmGhQjmkSl6dQj1cbajFaxJ9ta+HtyaZIP0/VfOrBB0=; b=iI8WWVdzZIr0BiPbAvyLf76Iwtji3scTS4YFEslMMJr5nrMamzgnrTolB3Eg/6Nos9HM+j q/VyZ6NJupM5t9ssWCBs9wdyNc2R3Fr5L4ByWvYf8HEHc9agrVBUE6dcvDoPh9CCpadw84 0dtxAOc6sdgs85IMjlarWtp+4gdVLTzfuuQJnwZWfzbJY1vVIplc+M19WhOZt5g/G+HJoP RpW2JTRc9azcsFNVCNXLwjXyQxAfKl5tu9mEF41mMZuCVsU9j/JiH5++gUrB6Mzr3GaeFC B7WEhWfw49tPYXpomU/Ir81HliFxPhrEntSmX4EJP31U+MP35Qx9RQNWTIh3kA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D272F550A; Thu, 5 May 2022 19:14:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 245JEpYN090299; Thu, 5 May 2022 19:14:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 245JEpBv090298; Thu, 5 May 2022 19:14:51 GMT (envelope-from git) Date: Thu, 5 May 2022 19:14:51 GMT Message-Id: <202205051914.245JEpBv090298@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 8ef7beb29edd - main - dummynet: use m_rcvif_serialize/restore when queueing packets List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8ef7beb29edd1afc4931424eadb0e1c6a7f3c364 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651778092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EmGhQjmkSl6dQj1cbajFaxJ9ta+HtyaZIP0/VfOrBB0=; b=PQzC4dDpMzkD2yA0L59IIGOyYwWr1sFo/NEDfFiYiUCXgo1lITk5EY5u0EMOM2drUDoWz3 rAdZqELfVUgbaue0H5xvB4SMrsqZEiakYKpGjIe4TWx9/zZGESCYmi+q8dClJhQGuePc22 fSfXZA5/RGX9ULyk0BhKv75SBt6TgOJeLRvlPfGcajtkQHs+eJy3QfDIdrtJcyt10+oIix oo4NZMcZ8qgJTqX7KOIJdOnZxWXzT8ARempNEmJkR0zXlkEWhzoZ9nGKA33HfM2CzmggBs VGYACxId3Hm59Cq7Cpnsko3fuggQsTKlTj78iePmVkmqeG2mT8sKVoPp8AjDFg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651778092; a=rsa-sha256; cv=none; b=beY7gY4vhJY61ZNoeKP6fZL1pC80zeZ+jXZIhsHm4Pf4jm9Z8NAn8NArAEP4qq3qN9EcmW 9OnJkReppUxIuimmzo6ZKNv+Xou+OtFJpDeRqxaIeiScV/FX/FDWOp6MbTJ8PDOtagMZCg McdOwxxywtHheXOXGlCdqhDdanSqkm0OR0Kx2Mm/Oh3VBktmjvlzJOiZ8Wyk9SAwkaFCpJ zAM74mvvEbM46ttbRfLhdI2c6hFfVB0JDBRe3NnP/DCu4jo7dqsnY8WtGc9ZCKeZis7rrc eCtNNxk+FuCv1wfr9YTZ7azTv8HIDC31va2LEQtwKUKxNY50tdP7baFl/i/j/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=8ef7beb29edd1afc4931424eadb0e1c6a7f3c364 commit 8ef7beb29edd1afc4931424eadb0e1c6a7f3c364 Author: Gleb Smirnoff AuthorDate: 2022-01-27 05:58:50 +0000 Commit: Ed Maste CommitDate: 2022-05-05 18:38:07 +0000 dummynet: use m_rcvif_serialize/restore when queueing packets This fixed panic with interface being removed while packet was sitting on a queue. This allows to pass all dummynet tests including forthcoming dummynet:ipfw_interface_removal and dummynet:pf_interface_removal and demonstrates use of m_rcvif_serialize() and m_rcvif_restore(). Reviewed by: kp Differential revision: https://reviews.freebsd.org/D33267 (cherry picked from commit 165746f4e4bf54c5902a103c2d4a3455e651c58f) --- sys/netpfil/ipfw/dn_aqm_codel.c | 8 +++++++- sys/netpfil/ipfw/dn_aqm_pie.c | 8 +++++++- sys/netpfil/ipfw/dn_sched.h | 10 +++++++++- sys/netpfil/ipfw/dn_sched_fq_codel.h | 9 +++++++-- sys/netpfil/ipfw/dn_sched_fq_pie.c | 8 +++++++- sys/netpfil/ipfw/ip_dn_io.c | 10 +++++++++- 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm_codel.c b/sys/netpfil/ipfw/dn_aqm_codel.c index 79c6afd8b635..2f6d145485c6 100644 --- a/sys/netpfil/ipfw/dn_aqm_codel.c +++ b/sys/netpfil/ipfw/dn_aqm_codel.c @@ -192,8 +192,9 @@ struct mbuf * codel_extract_head(struct dn_queue *q, aqm_time_t *pkt_ts) { struct m_tag *mtag; - struct mbuf *m = q->mq.head; + struct mbuf *m; +next: m = q->mq.head; if (m == NULL) return m; q->mq.head = m->m_nextpkt; @@ -213,6 +214,11 @@ codel_extract_head(struct dn_queue *q, aqm_time_t *pkt_ts) *pkt_ts = *(aqm_time_t *)(mtag + 1); m_tag_delete(m,mtag); } + if (m->m_pkthdr.rcvif != NULL && + __predict_false(m_rcvif_restore(m) == NULL)) { + m_freem(m); + goto next; + } return m; } diff --git a/sys/netpfil/ipfw/dn_aqm_pie.c b/sys/netpfil/ipfw/dn_aqm_pie.c index 3b80d6e94d38..5c97568b751e 100644 --- a/sys/netpfil/ipfw/dn_aqm_pie.c +++ b/sys/netpfil/ipfw/dn_aqm_pie.c @@ -328,8 +328,9 @@ static struct mbuf * pie_extract_head(struct dn_queue *q, aqm_time_t *pkt_ts, int getts) { struct m_tag *mtag; - struct mbuf *m = q->mq.head; + struct mbuf *m; +next: m = q->mq.head; if (m == NULL) return m; q->mq.head = m->m_nextpkt; @@ -351,6 +352,11 @@ pie_extract_head(struct dn_queue *q, aqm_time_t *pkt_ts, int getts) m_tag_delete(m,mtag); } } + if (m->m_pkthdr.rcvif != NULL && + __predict_false(m_rcvif_restore(m) == NULL)) { + m_freem(m); + goto next; + } return m; } diff --git a/sys/netpfil/ipfw/dn_sched.h b/sys/netpfil/ipfw/dn_sched.h index 5c506c1d30ac..ef7242cd7355 100644 --- a/sys/netpfil/ipfw/dn_sched.h +++ b/sys/netpfil/ipfw/dn_sched.h @@ -170,7 +170,10 @@ int ipdn_bound_var(int *v, int dflt, int lo, int hi, const char *msg); static __inline struct mbuf* dn_dequeue(struct dn_queue *q) { - struct mbuf *m = q->mq.head; + struct mbuf *m; + +next: + m = q->mq.head; if (m == NULL) return NULL; #ifdef NEW_AQM @@ -190,6 +193,11 @@ dn_dequeue(struct dn_queue *q) } if (q->ni.length == 0) /* queue is now idle */ q->q_time = V_dn_cfg.curr_time; + if (m->m_pkthdr.rcvif != NULL && + __predict_false(m_rcvif_restore(m) == NULL)) { + m_freem(m); + goto next; + } return m; } diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.h b/sys/netpfil/ipfw/dn_sched_fq_codel.h index 2f82a63ca093..b84dfe7579fb 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.h +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.h @@ -138,8 +138,9 @@ fq_update_stats(struct fq_codel_flow *q, struct fq_codel_si *si, int len, __inline static struct mbuf * fq_codel_extract_head(struct fq_codel_flow *q, aqm_time_t *pkt_ts, struct fq_codel_si *si) { - struct mbuf *m = q->mq.head; + struct mbuf *m; +next: m = q->mq.head; if (m == NULL) return m; q->mq.head = m->m_nextpkt; @@ -159,7 +160,11 @@ fq_codel_extract_head(struct fq_codel_flow *q, aqm_time_t *pkt_ts, struct fq_cod *pkt_ts = *(aqm_time_t *)(mtag + 1); m_tag_delete(m,mtag); } - + if (m->m_pkthdr.rcvif != NULL && + __predict_false(m_rcvif_restore(m) == NULL)) { + m_freem(m); + goto next; + } return m; } diff --git a/sys/netpfil/ipfw/dn_sched_fq_pie.c b/sys/netpfil/ipfw/dn_sched_fq_pie.c index 65a6dd74b92f..f6bb4b6fe6de 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_pie.c +++ b/sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -338,8 +338,9 @@ __inline static struct mbuf * fq_pie_extract_head(struct fq_pie_flow *q, aqm_time_t *pkt_ts, struct fq_pie_si *si, int getts) { - struct mbuf *m = q->mq.head; + struct mbuf *m; +next: m = q->mq.head; if (m == NULL) return m; q->mq.head = m->m_nextpkt; @@ -361,6 +362,11 @@ fq_pie_extract_head(struct fq_pie_flow *q, aqm_time_t *pkt_ts, m_tag_delete(m,mtag); } } + if (m->m_pkthdr.rcvif != NULL && + __predict_false(m_rcvif_restore(m) == NULL)) { + m_freem(m); + goto next; + } return m; } diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 11ad498505f4..824e7450fb8f 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -500,6 +500,8 @@ dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop) goto drop; if (f->plr && random() < f->plr) goto drop; + if (m->m_pkthdr.rcvif != NULL) + m_rcvif_serialize(m); #ifdef NEW_AQM /* Call AQM enqueue function */ if (q->fs->aqmfp) @@ -548,7 +550,11 @@ transmit_event(struct mq *q, struct delay_line *dline, uint64_t now) break; dline->mq.head = m->m_nextpkt; dline->mq.count--; - mq_append(q, m); + if (m->m_pkthdr.rcvif != NULL && + __predict_false(m_rcvif_restore(m) == NULL)) + m_freem(m); + else + mq_append(q, m); } if (m != NULL) { dline->oid.subtype = 1; /* in heap */ @@ -617,6 +623,8 @@ serve_sched(struct mq *q, struct dn_sch_inst *si, uint64_t now) si->credit -= len_scaled; /* Move packet in the delay line */ dn_tag_get(m)->output_time = V_dn_cfg.curr_time + s->link.delay ; + if (m->m_pkthdr.rcvif != NULL) + m_rcvif_serialize(m); mq_append(&si->dline.mq, m); }