netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taehee Yoo <ap420073@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, xiyou.wangcong@gmail.com,
	netdev@vger.kernel.org, jwi@linux.ibm.com, kgraul@linux.ibm.com,
	hca@linux.ibm.com, gor@linux.ibm.com, borntraeger@de.ibm.com,
	mareklindner@neomailbox.ch, sw@simonwunderlich.de, a@unstable.cc,
	sven@narfation.org, yoshfuji@linux-ipv6.org, dsahern@kernel.org
Cc: Taehee Yoo <ap420073@gmail.com>
Subject: [PATCH net-next v2 3/7] mld: add a new delayed_work, mc_delrec_work
Date: Sat, 13 Feb 2021 17:51:48 +0000	[thread overview]
Message-ID: <20210213175148.28375-1-ap420073@gmail.com> (raw)

The goal of mc_delrec_work delayed work is to call mld_clear_delrec().
The mld_clear_delrec() is called under both data path and control path.
So, the context of mld_clear_delrec() can be atomic.
But this function accesses struct ifmcaddr6 and struct ip6_sf_list.
These structures are going to be protected by RTNL.
So, this function should be called in a sleepable context.

Suggested-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
v1 -> v2:
 - Separated from previous big one patch.

 include/net/if_inet6.h |  1 +
 net/ipv6/mcast.c       | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index bec372283ac0..5946b5d76f7b 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -182,6 +182,7 @@ struct inet6_dev {
 	struct delayed_work	mc_gq_work;	/* general query work */
 	struct delayed_work	mc_ifc_work;	/* interface change work */
 	struct delayed_work	mc_dad_work;	/* dad complete mc work */
+	struct delayed_work     mc_delrec_work; /* delete records work */
 
 	struct ifacaddr6	*ac_list;
 	rwlock_t		lock;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 1f7fd3fbb4b6..ca8ca6faca4e 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1067,6 +1067,22 @@ static void mld_dad_stop_work(struct inet6_dev *idev)
 		__in6_dev_put(idev);
 }
 
+static void mld_clear_delrec_start_work(struct inet6_dev *idev)
+{
+	write_lock_bh(&idev->lock);
+	if (!mod_delayed_work(mld_wq, &idev->mc_delrec_work, 0))
+		in6_dev_hold(idev);
+	write_unlock_bh(&idev->lock);
+}
+
+static void mld_clear_delrec_stop_work(struct inet6_dev *idev)
+{
+	write_lock_bh(&idev->lock);
+	if (cancel_delayed_work(&idev->mc_delrec_work))
+		__in6_dev_put(idev);
+	write_unlock_bh(&idev->lock);
+}
+
 /*
  *	IGMP handling (alias multicast ICMPv6 messages)
  */
@@ -1304,7 +1320,7 @@ static int mld_process_v1(struct inet6_dev *idev, struct mld_msg *mld,
 	/* cancel the interface change work */
 	mld_ifc_stop_work(idev);
 	/* clear deleted report items */
-	mld_clear_delrec(idev);
+	mld_clear_delrec_start_work(idev);
 
 	return 0;
 }
@@ -2120,6 +2136,18 @@ static void mld_dad_work(struct work_struct *work)
 	in6_dev_put(idev);
 }
 
+static void mld_clear_delrec_work(struct work_struct *work)
+{
+	struct inet6_dev *idev = container_of(to_delayed_work(work),
+			struct inet6_dev,
+			mc_delrec_work);
+
+	rtnl_lock();
+	mld_clear_delrec(idev);
+	rtnl_unlock();
+	in6_dev_put(idev);
+}
+
 static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,
 	const struct in6_addr *psfsrc)
 {
@@ -2553,6 +2581,7 @@ void ipv6_mc_down(struct inet6_dev *idev)
 	mld_gq_stop_work(idev);
 	mld_dad_stop_work(idev);
 	read_unlock_bh(&idev->lock);
+	mld_clear_delrec_stop_work(idev);
 }
 
 static void ipv6_mc_reset(struct inet6_dev *idev)
@@ -2593,6 +2622,7 @@ void ipv6_mc_init_dev(struct inet6_dev *idev)
 	idev->mc_ifc_count = 0;
 	INIT_DELAYED_WORK(&idev->mc_ifc_work, mld_ifc_work);
 	INIT_DELAYED_WORK(&idev->mc_dad_work, mld_dad_work);
+	INIT_DELAYED_WORK(&idev->mc_delrec_work, mld_clear_delrec_work);
 	ipv6_mc_reset(idev);
 	write_unlock_bh(&idev->lock);
 }
-- 
2.17.1


             reply	other threads:[~2021-02-13 17:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 17:51 Taehee Yoo [this message]
2021-02-13 19:18 ` [PATCH net-next v2 3/7] mld: add a new delayed_work, mc_delrec_work Cong Wang
2021-02-14 11:30   ` Taehee Yoo
2021-02-14 14:53   ` Taehee Yoo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210213175148.28375-1-ap420073@gmail.com \
    --to=ap420073@gmail.com \
    --cc=a@unstable.cc \
    --cc=borntraeger@de.ibm.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=jwi@linux.ibm.com \
    --cc=kgraul@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=mareklindner@neomailbox.ch \
    --cc=netdev@vger.kernel.org \
    --cc=sven@narfation.org \
    --cc=sw@simonwunderlich.de \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).