Commit 2d3916f3 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

ipv6: fix skb drops in igmp6_event_query() and igmp6_event_report()

While investigating on why a synchronize_net() has been added recently
in ipv6_mc_down(), I found that igmp6_event_query() and igmp6_event_report()
might drop skbs in some cases.

Discussion about removing synchronize_net() from ipv6_mc_down()
will happen in a different thread.

Fixes: f185de28 ("mld: add new workqueues for process mld events")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Taehee Yoo <ap420073@gmail.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20220303173728.937869-1-eric.dumazet@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e1bec7fa
...@@ -475,9 +475,9 @@ int igmp6_late_init(void); ...@@ -475,9 +475,9 @@ int igmp6_late_init(void);
void igmp6_cleanup(void); void igmp6_cleanup(void);
void igmp6_late_cleanup(void); void igmp6_late_cleanup(void);
int igmp6_event_query(struct sk_buff *skb); void igmp6_event_query(struct sk_buff *skb);
int igmp6_event_report(struct sk_buff *skb); void igmp6_event_report(struct sk_buff *skb);
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
......
...@@ -1371,27 +1371,23 @@ static void mld_process_v2(struct inet6_dev *idev, struct mld2_query *mld, ...@@ -1371,27 +1371,23 @@ static void mld_process_v2(struct inet6_dev *idev, struct mld2_query *mld,
} }
/* called with rcu_read_lock() */ /* called with rcu_read_lock() */
int igmp6_event_query(struct sk_buff *skb) void igmp6_event_query(struct sk_buff *skb)
{ {
struct inet6_dev *idev = __in6_dev_get(skb->dev); struct inet6_dev *idev = __in6_dev_get(skb->dev);
if (!idev) if (!idev || idev->dead)
return -EINVAL; goto out;
if (idev->dead) {
kfree_skb(skb);
return -ENODEV;
}
spin_lock_bh(&idev->mc_query_lock); spin_lock_bh(&idev->mc_query_lock);
if (skb_queue_len(&idev->mc_query_queue) < MLD_MAX_SKBS) { if (skb_queue_len(&idev->mc_query_queue) < MLD_MAX_SKBS) {
__skb_queue_tail(&idev->mc_query_queue, skb); __skb_queue_tail(&idev->mc_query_queue, skb);
if (!mod_delayed_work(mld_wq, &idev->mc_query_work, 0)) if (!mod_delayed_work(mld_wq, &idev->mc_query_work, 0))
in6_dev_hold(idev); in6_dev_hold(idev);
skb = NULL;
} }
spin_unlock_bh(&idev->mc_query_lock); spin_unlock_bh(&idev->mc_query_lock);
out:
return 0; kfree_skb(skb);
} }
static void __mld_query_work(struct sk_buff *skb) static void __mld_query_work(struct sk_buff *skb)
...@@ -1542,27 +1538,23 @@ static void mld_query_work(struct work_struct *work) ...@@ -1542,27 +1538,23 @@ static void mld_query_work(struct work_struct *work)
} }
/* called with rcu_read_lock() */ /* called with rcu_read_lock() */
int igmp6_event_report(struct sk_buff *skb) void igmp6_event_report(struct sk_buff *skb)
{ {
struct inet6_dev *idev = __in6_dev_get(skb->dev); struct inet6_dev *idev = __in6_dev_get(skb->dev);
if (!idev) if (!idev || idev->dead)
return -EINVAL; goto out;
if (idev->dead) {
kfree_skb(skb);
return -ENODEV;
}
spin_lock_bh(&idev->mc_report_lock); spin_lock_bh(&idev->mc_report_lock);
if (skb_queue_len(&idev->mc_report_queue) < MLD_MAX_SKBS) { if (skb_queue_len(&idev->mc_report_queue) < MLD_MAX_SKBS) {
__skb_queue_tail(&idev->mc_report_queue, skb); __skb_queue_tail(&idev->mc_report_queue, skb);
if (!mod_delayed_work(mld_wq, &idev->mc_report_work, 0)) if (!mod_delayed_work(mld_wq, &idev->mc_report_work, 0))
in6_dev_hold(idev); in6_dev_hold(idev);
skb = NULL;
} }
spin_unlock_bh(&idev->mc_report_lock); spin_unlock_bh(&idev->mc_report_lock);
out:
return 0; kfree_skb(skb);
} }
static void __mld_report_work(struct sk_buff *skb) static void __mld_report_work(struct sk_buff *skb)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment