generic: sync genlmsg_mcast patch with upstream with kernel 6.6.59+

This commit is contained in:
coolsnowwolf 2024-11-21 12:10:10 +08:00
parent 71196b2724
commit 418c887452
2 changed files with 2 additions and 160 deletions

View File

@ -147,7 +147,7 @@ Signed-off-by: Sasha Levin <sashal@kernel.org>
genlmsg_end(msg, hdr);
+#if (LINUX_VERSION_IS_GEQ(6,1,115) && LINUX_VERSION_IS_LESS(6,1,999)) || ((LINUX_VERSION_IS_GEQ(5,15,170) && LINUX_VERSION_IS_LESS(5,15,999)))
+#if (LINUX_VERSION_IS_GEQ(6,1,115) && LINUX_VERSION_IS_LESS(6,1,999)) || ((LINUX_VERSION_IS_GEQ(5,15,170) && LINUX_VERSION_IS_LESS(5,15,999))) || LINUX_VERSION_IS_GEQ(6,6,59)
+ genlmsg_multicast_allns(&nl80211_fam, msg, 0,
+ NL80211_MCGRP_REGULATORY);
+#else
@ -163,7 +163,7 @@ Signed-off-by: Sasha Levin <sashal@kernel.org>
genlmsg_end(msg, hdr);
+#if (LINUX_VERSION_IS_GEQ(6,1,115) && LINUX_VERSION_IS_LESS(6,1,999)) || ((LINUX_VERSION_IS_GEQ(5,15,170) && LINUX_VERSION_IS_LESS(5,15,999)))
+#if (LINUX_VERSION_IS_GEQ(6,1,115) && LINUX_VERSION_IS_LESS(6,1,999)) || ((LINUX_VERSION_IS_GEQ(5,15,170) && LINUX_VERSION_IS_LESS(5,15,999))) || LINUX_VERSION_IS_GEQ(6,6,59)
+ genlmsg_multicast_allns(&nl80211_fam, msg, 0,
+ NL80211_MCGRP_REGULATORY);
+#else

View File

@ -1,158 +0,0 @@
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -2130,7 +2130,7 @@ static int tcmu_netlink_event_send(struc
}
ret = genlmsg_multicast_allns(&tcmu_genl_family, skb, 0,
- TCMU_MCGRP_CONFIG);
+ TCMU_MCGRP_CONFIG, GFP_KERNEL);
/* Wait during an add as the listener may not be up yet */
if (ret == 0 ||
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -478,12 +478,13 @@ static inline int genlmsg_multicast(cons
* @skb: netlink message as socket buffer
* @portid: own netlink portid to avoid sending to yourself
* @group: offset of multicast group in groups array
+ * @flags: allocation flags
*
* This function must hold the RTNL or rcu_read_lock().
*/
int genlmsg_multicast_allns(const struct genl_family *family,
struct sk_buff *skb, u32 portid,
- unsigned int group);
+ unsigned int group, gfp_t flags);
/**
* genlmsg_unicast - unicast a netlink message
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -115,7 +115,7 @@ static int l2tp_tunnel_notify(struct gen
NLM_F_ACK, tunnel, cmd);
if (ret >= 0) {
- ret = genlmsg_multicast_allns(family, msg, 0, 0);
+ ret = genlmsg_multicast_allns(family, msg, 0, 0, GFP_ATOMIC);
/* We don't care if no one is listening */
if (ret == -ESRCH)
ret = 0;
@@ -143,7 +143,7 @@ static int l2tp_session_notify(struct ge
NLM_F_ACK, session, cmd);
if (ret >= 0) {
- ret = genlmsg_multicast_allns(family, msg, 0, 0);
+ ret = genlmsg_multicast_allns(family, msg, 0, 0, GFP_ATOMIC);
/* We don't care if no one is listening */
if (ret == -ESRCH)
ret = 0;
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -1355,11 +1355,15 @@ static int genl_ctrl_event(int event, co
if (IS_ERR(msg))
return PTR_ERR(msg);
- if (!family->netnsok)
+ if (!family->netnsok) {
genlmsg_multicast_netns(&genl_ctrl, &init_net, msg, 0,
0, GFP_KERNEL);
- else
- genlmsg_multicast_allns(&genl_ctrl, msg, 0, 0);
+ } else {
+ rcu_read_lock();
+ genlmsg_multicast_allns(&genl_ctrl, msg, 0,
+ 0, GFP_ATOMIC);
+ rcu_read_unlock();
+ }
return 0;
}
@@ -1748,23 +1752,23 @@ problem:
core_initcall(genl_init);
-static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group)
+static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
+ gfp_t flags)
{
struct sk_buff *tmp;
struct net *net, *prev = NULL;
bool delivered = false;
int err;
- rcu_read_lock();
for_each_net_rcu(net) {
if (prev) {
- tmp = skb_clone(skb, GFP_ATOMIC);
+ tmp = skb_clone(skb, flags);
if (!tmp) {
err = -ENOMEM;
goto error;
}
err = nlmsg_multicast(prev->genl_sock, tmp,
- portid, group, GFP_ATOMIC);
+ portid, group, flags);
if (!err)
delivered = true;
else if (err != -ESRCH)
@@ -1773,31 +1777,27 @@ static int genlmsg_mcast(struct sk_buff
prev = net;
}
- err = nlmsg_multicast(prev->genl_sock, skb, portid, group, GFP_ATOMIC);
-
- rcu_read_unlock();
+ err = nlmsg_multicast(prev->genl_sock, skb, portid, group, flags);
if (!err)
delivered = true;
else if (err != -ESRCH)
return err;
return delivered ? 0 : -ESRCH;
error:
- rcu_read_unlock();
-
kfree_skb(skb);
return err;
}
int genlmsg_multicast_allns(const struct genl_family *family,
struct sk_buff *skb, u32 portid,
- unsigned int group)
+ unsigned int group, gfp_t flags)
{
if (WARN_ON_ONCE(group >= family->n_mcgrps))
return -EINVAL;
group = family->mcgrp_offset + group;
- return genlmsg_mcast(skb, portid, group);
+ return genlmsg_mcast(skb, portid, group, flags);
}
EXPORT_SYMBOL(genlmsg_multicast_allns);
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -17905,8 +17905,10 @@ void nl80211_common_reg_change_event(enu
genlmsg_end(msg, hdr);
+ rcu_read_lock();
genlmsg_multicast_allns(&nl80211_fam, msg, 0,
- NL80211_MCGRP_REGULATORY);
+ NL80211_MCGRP_REGULATORY, GFP_ATOMIC);
+ rcu_read_unlock();
return;
@@ -18603,8 +18605,10 @@ void nl80211_send_beacon_hint_event(stru
genlmsg_end(msg, hdr);
+ rcu_read_lock();
genlmsg_multicast_allns(&nl80211_fam, msg, 0,
- NL80211_MCGRP_REGULATORY);
+ NL80211_MCGRP_REGULATORY, GFP_ATOMIC);
+ rcu_read_unlock();
return;