Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] net: multicast: account memberships and device records to memcg
@ 2026-12-05  8:18 Yingjie Wang
  2026-12-05  8:19 ` [PATCH net-next v2 1/3] net: multicast: keep source filter state when adding a source fails Yingjie Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yingjie Wang @ 2026-12-05  8:18 UTC (permalink / raw)
  To: netdev@vger.kernel.org
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
	Binbin Deng, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song, cgroups@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org

Multicast memberships, their source filters and the device records
they create are not charged to memory cgroups, so a task can keep a
lot of kernel memory outside its memory.max limit.  In a QEMU guest,
an unprivileged user with default sysctls joined 58,500 IPv6 groups
from 25 sockets on one interface; slab grew by about 40 MiB while the
user's cgroup was charged less than 2 MiB.

Patch 1 makes adding a source to a socket filter fail without changing
state.  The allocation of the source list can already fail today, when
the socket's optmem_max budget is used up, and then leaves the filter
in INCLUDE mode with no sources.  Patches 2 and 3 charge the socket
and the device allocations.  What a join still leaves uncharged is the
link-layer address entry and the two copies of it that the rx mode
work keeps; on the dummy device used here, that is about as much again
as what is now charged.

Changes in v2:
- Rebased on net-next and sent there, without Fixes and stable tags.
  The EADDRNOTAVAIL fix from v1 patch 1 is already in net-next as
  commit 2f14be6c9b9e ("ipv4/ipv6: preserve multicast filters after a
  failed source leave").
- Patch 1: allocate the source list first and update the device in one
  call, instead of switching the mode up front and rolling it back;
  keep ignoring -ESRCH (Sashiko).
- Patch 2: drop the IPV6_2292PKTOPTIONS change.  The copies made for
  TCP children in softirq context would stay uncharged (Sashiko), so
  that needs a different fix.
- Patch 3: also charge IPv4 group records and deleted group records,
  and pass the gfp flags to mld_add_delrec(), so that address
  configuration and link events stay uncharged (Sashiko).
v1: https://lore.kernel.org/r/cover.1795102467.git.x-professor@outlook.com

Patch 1 overlaps with the pending "igmp: use copy-on-write RCU updates
in ip_mc_source()" [1]; I can rebase on it if it goes in first.

Tested in x86_64 QEMU guests on net-next d5cf954cebe4, with and without
this series:
 - W=1 builds of the kernel, of the affected objects after each patch,
   and with allmodconfig, i386 and CONFIG_IP_MULTICAST=n;
 - the optmem_max case from patch 1, as uid 1000: 4/4 -> 0/4 group
   datagrams on the base, 4/4 -> 4/4 with the series;
 - slab fault injection on the source list and source entry
   allocations: the base reports success with the source missing from
   the device filter, the series returns ENOBUFS and keeps the filter
   and the membership;
 - MCAST_BLOCK_SOURCE with gsr_interface 0 while the route for the
   group uses a different device, normal IPv4 and IPv6 source join/leave
   sequences, and leaving a source that was never added behave the
   same on both kernels; so do the IGMPv3 and MLDv2 records sent when
   an any-source membership becomes INCLUDE {S};
 - with memory.max at 16 MiB: the IPv6 joins above, IPv4 joins and IPv4
   source filters in a user and network namespace, and IPv4 and IPv6
   join/leave loops with a 10 minute report interval ran without a
   memory.max event on the base, and were stopped by the memcg OOM
   killer with the series.  The join/leave loops kept up to about 14
   (IPv4) and 17 (IPv6) MiB of deleted group records at a time; with
   IGMPv2 or MLDv1, which keep no such records, the same loops stayed
   below 3 MiB;
 - 200,000 join/leave cycles in a non-root memory cgroup, in IGMPv2 and
   MLDv1 mode to leave out deleted records, were not slower with the
   series (five runs each; a coarse timing that includes namespace
   setup).
No warnings, BUG reports or splats in the guest consoles.  Kernel
selftests were not run.

[1] https://lore.kernel.org/r/20261119125112.540125-1-18983559317@163.com

Yingjie Wang (3):
  net: multicast: keep source filter state when adding a source fails
  net: multicast: account socket memberships and source lists to memcg
  net: multicast: account device records created by sockets to memcg

 include/net/addrconf.h   |   3 +-
 net/ipv4/igmp.c          | 120 +++++++++++++++++++++++----------------
 net/ipv4/ip_sockglue.c   |  33 ++++++-----
 net/ipv6/addrconf.c      |   2 +-
 net/ipv6/ipv6_sockglue.c |  11 +++-
 net/ipv6/mcast.c         |  97 ++++++++++++++++++-------------
 6 files changed, 159 insertions(+), 107 deletions(-)


base-commit: d5cf954cebe4f175dfd834e1dc471a3aa203ec7d
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next v2 1/3] net: multicast: keep source filter state when adding a source fails
  2026-12-05  8:18 [PATCH net-next v2 0/3] net: multicast: account memberships and device records to memcg Yingjie Wang
@ 2026-12-05  8:19 ` Yingjie Wang
  2026-12-05  8:19 ` [PATCH net-next v2 2/3] net: multicast: account socket memberships and source lists to memcg Yingjie Wang
  2026-12-05  8:19 ` [PATCH net-next v2 3/3] net: multicast: account device records created by sockets " Yingjie Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Yingjie Wang @ 2026-12-05  8:19 UTC (permalink / raw)
  To: netdev@vger.kernel.org
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
	Binbin Deng, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song, cgroups@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org

When a source is added to a membership that has no source filter yet,
ip_mc_source() and ip6_mc_source() first move the socket's reference on
the device group to the requested filter mode, then allocate the socket
source list, and only then add the source to the device.  The mode
switch is not undone when the allocation fails, and errors from adding
the source to the device are ignored.

The source list comes from sock_kmalloc(), which fails once the
socket's optmem_max budget is used up.  An unprivileged IPv6 socket can
use it up with about 2,300 memberships.  MCAST_JOIN_SOURCE_GROUP on an
any-source membership of that socket then returns ENOBUFS but leaves
the filter in INCLUDE mode with no sources, so the socket stops
receiving the group: in a QEMU guest it received 4 of 4 datagrams
before the call and 0 of 4 after it.  If adding the source to the
device fails, the call succeeds, but the device filter does not have
the source.  MCAST_JOIN_SOURCE_GROUP and IP_ADD_SOURCE_MEMBERSHIP also
keep a membership they created when the source cannot be added.  The
next patches charge these allocations to the memory cgroup, which makes
such failures more likely.

Allocate the source list before changing any state.  Add the source to
the device and, for a membership without a filter, take the reference on
the new mode in the same ip_mc_add_src() or ip6_mc_add_src() call; both
undo their own changes on failure.  Drop the reference on the old mode
only after that succeeds.  Return an error from the device update except
-ESRCH, which means that the device has no entry for the group.  That
happens for example when an IPv6 request with gsr_interface 0 resolves
to a different device than the membership's, and such calls have always
succeeded.  Drop a membership created by the same setsockopt() call if
the source cannot be added.

Removing a source that was never added is already handled by
commit 2f14be6c9b9e ("ipv4/ipv6: preserve multicast filters after a
failed source leave").

The device side of this was found with slab fault injection while
testing the next patches.

Signed-off-by: Yingjie Wang <x-professor@outlook.com>
---
With this change, the MCAST_JOIN_SOURCE_GROUP case above still fails
with ENOBUFS, but the filter stays in EXCLUDE mode and the group is
still received (4/4 before and after).  Injected allocation failures for
IPv4 and IPv6 return ENOBUFS and leave the filter and the membership
unchanged.  MCAST_BLOCK_SOURCE with gsr_interface 0 still succeeds when
the route for the group uses a different device than the membership's.
The IGMPv3 and MLDv2 records sent when an any-source membership becomes
INCLUDE {S} are the same as before.

 net/ipv4/igmp.c          | 80 +++++++++++++++++++++++-----------------
 net/ipv4/ip_sockglue.c   | 33 ++++++++++-------
 net/ipv6/ipv6_sockglue.c | 11 +++++-
 net/ipv6/mcast.c         | 30 +++++++++------
 4 files changed, 94 insertions(+), 60 deletions(-)

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 7c69bdaaedd5..446c49db1adf 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2498,7 +2498,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
 	struct ip_mc_socklist *pmc;
 	struct in_device *in_dev = NULL;
 	struct inet_sock *inet = inet_sk(sk);
-	struct ip_sf_socklist *psl;
+	struct ip_sf_socklist *newpsl = NULL, *psl;
 	struct net *net = sock_net(sk);
 	int leavegroup = 0;
 	int i, j, rv;
@@ -2534,17 +2534,9 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
 		goto done;	/* err = -EADDRNOTAVAIL */
 
 	/* if a source filter was set, must be the same mode as before */
-	if (pmc->sflist) {
-		if (pmc->sfmode != omode) {
-			err = -EINVAL;
-			goto done;
-		}
-	} else if (pmc->sfmode != omode) {
-		/* allow mode switches for empty-set filters */
-		ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 0, NULL, 0);
-		ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, pmc->sfmode, 0,
-			NULL, 0);
-		pmc->sfmode = omode;
+	if (pmc->sflist && pmc->sfmode != omode) {
+		err = -EINVAL;
+		goto done;
 	}
 
 	if (!add) {
@@ -2580,8 +2572,16 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
 		err = -ENOBUFS;
 		goto done;
 	}
+	rv = 1;	/* > 0 for insert logic below if sl_count is 0 */
+	for (i = 0; psl && i < psl->sl_count; i++) {
+		rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
+			    sizeof(__be32));
+		if (rv == 0)
+			break;
+	}
+	if (rv == 0)		/* address already there is an error */
+		goto done;
 	if (!psl || psl->sl_count == psl->sl_max) {
-		struct ip_sf_socklist *newpsl;
 		int count = IP_SFBLOCK;
 
 		if (psl)
@@ -2593,10 +2593,36 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
 			goto done;
 		}
 		newpsl->sl_max = count;
-		newpsl->sl_count = count - IP_SFBLOCK;
+		newpsl->sl_count = psl ? psl->sl_count : 0;
+		for (j = 0; j < newpsl->sl_count; j++)
+			newpsl->sl_addr[j] = psl->sl_addr[j];
+		for (j = newpsl->sl_count - 1; j >= i; j--)
+			newpsl->sl_addr[j + 1] = newpsl->sl_addr[j];
+		newpsl->sl_addr[i] = mreqs->imr_sourceaddr;
+		newpsl->sl_count++;
+	}
+
+	/* update the interface list; an empty filter takes the new mode
+	 * together with its first source
+	 */
+	err = ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
+			    &mreqs->imr_sourceaddr, pmc->sfmode == omode);
+	/* -ESRCH: no device entry for the group, update the socket only */
+	if (err && err != -ESRCH) {
+		if (newpsl)
+			sock_kfree_s(sk, newpsl,
+				     struct_size(newpsl, sl_addr,
+						 newpsl->sl_max));
+		goto done;
+	}
+	if (pmc->sfmode != omode) {
+		ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, pmc->sfmode, 0,
+			      NULL, 0);
+		pmc->sfmode = omode;
+	}
+
+	if (newpsl) {
 		if (psl) {
-			for (i = 0; i < psl->sl_count; i++)
-				newpsl->sl_addr[i] = psl->sl_addr[i];
 			/* decrease mem now to avoid the memleak warning */
 			atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
 				   &sk->sk_omem_alloc);
@@ -2604,25 +2630,13 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
 		rcu_assign_pointer(pmc->sflist, newpsl);
 		if (psl)
 			kfree_rcu(psl, rcu);
-		psl = newpsl;
-	}
-	rv = 1;	/* > 0 for insert logic below if sl_count is 0 */
-	for (i = 0; i < psl->sl_count; i++) {
-		rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
-			sizeof(__be32));
-		if (rv == 0)
-			break;
+	} else {
+		for (j = psl->sl_count - 1; j >= i; j--)
+			psl->sl_addr[j + 1] = psl->sl_addr[j];
+		psl->sl_addr[i] = mreqs->imr_sourceaddr;
+		psl->sl_count++;
 	}
-	if (rv == 0)		/* address already there is an error */
-		goto done;
-	for (j = psl->sl_count-1; j >= i; j--)
-		psl->sl_addr[j+1] = psl->sl_addr[j];
-	psl->sl_addr[i] = mreqs->imr_sourceaddr;
-	psl->sl_count++;
 	err = 0;
-	/* update the interface list */
-	ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
-		&mreqs->imr_sourceaddr, 1);
 done:
 	if (leavegroup)
 		err = ip_mc_leave_group(sk, &imr);
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 90d0b5bee68b..c5ff545612e2 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -723,7 +723,9 @@ static int do_mcast_group_source(struct sock *sk, int optname,
 {
 	struct group_source_req greqs;
 	struct ip_mreq_source mreqs;
+	struct ip_mreqn joined = {};
 	struct sockaddr_in *psin;
+	bool drop_group = false;
 	int omode, add, err;
 
 	err = copy_group_source_from_sockptr(&greqs, optval, optlen);
@@ -747,23 +749,24 @@ static int do_mcast_group_source(struct sock *sk, int optname,
 		omode = MCAST_EXCLUDE;
 		add = 0;
 	} else if (optname == MCAST_JOIN_SOURCE_GROUP) {
-		struct ip_mreqn mreq;
-
 		psin = (struct sockaddr_in *)&greqs.gsr_group;
-		mreq.imr_multiaddr = psin->sin_addr;
-		mreq.imr_address.s_addr = 0;
-		mreq.imr_ifindex = greqs.gsr_interface;
-		err = ip_mc_join_group_ssm(sk, &mreq, MCAST_INCLUDE);
+		joined.imr_multiaddr = psin->sin_addr;
+		joined.imr_ifindex = greqs.gsr_interface;
+		err = ip_mc_join_group_ssm(sk, &joined, MCAST_INCLUDE);
 		if (err && err != -EADDRINUSE)
 			return err;
-		greqs.gsr_interface = mreq.imr_ifindex;
+		drop_group = !err;
+		greqs.gsr_interface = joined.imr_ifindex;
 		omode = MCAST_INCLUDE;
 		add = 1;
 	} else /* MCAST_LEAVE_SOURCE_GROUP */ {
 		omode = MCAST_INCLUDE;
 		add = 0;
 	}
-	return ip_mc_source(add, omode, sk, &mreqs, greqs.gsr_interface);
+	err = ip_mc_source(add, omode, sk, &mreqs, greqs.gsr_interface);
+	if (err && drop_group)
+		ip_mc_leave_group(sk, &joined);
+	return err;
 }
 
 static int ip_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen)
@@ -1286,7 +1289,9 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname,
 	case IP_ADD_SOURCE_MEMBERSHIP:
 	case IP_DROP_SOURCE_MEMBERSHIP:
 	{
+		struct ip_mreqn joined = {};
 		struct ip_mreq_source mreqs;
+		bool drop_group = false;
 		int omode, add;
 
 		if (optlen != sizeof(struct ip_mreq_source))
@@ -1302,14 +1307,12 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname,
 			omode = MCAST_EXCLUDE;
 			add = 0;
 		} else if (optname == IP_ADD_SOURCE_MEMBERSHIP) {
-			struct ip_mreqn mreq;
-
-			mreq.imr_multiaddr.s_addr = mreqs.imr_multiaddr;
-			mreq.imr_address.s_addr = mreqs.imr_interface;
-			mreq.imr_ifindex = 0;
-			err = ip_mc_join_group_ssm(sk, &mreq, MCAST_INCLUDE);
+			joined.imr_multiaddr.s_addr = mreqs.imr_multiaddr;
+			joined.imr_address.s_addr = mreqs.imr_interface;
+			err = ip_mc_join_group_ssm(sk, &joined, MCAST_INCLUDE);
 			if (err && err != -EADDRINUSE)
 				break;
+			drop_group = !err;
 			omode = MCAST_INCLUDE;
 			add = 1;
 		} else /* IP_DROP_SOURCE_MEMBERSHIP */ {
@@ -1317,6 +1320,8 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname,
 			add = 0;
 		}
 		err = ip_mc_source(add, omode, sk, &mreqs, 0);
+		if (err && drop_group)
+			ip_mc_leave_group(sk, &joined);
 		break;
 	}
 	case MCAST_JOIN_GROUP:
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 48dcd2487907..bde66915acbf 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -145,6 +145,7 @@ static int do_ipv6_mcast_group_source(struct sock *sk, int optname,
 		sockptr_t optval, int optlen)
 {
 	struct group_source_req greqs;
+	bool drop_group = false;
 	int omode, add;
 	int ret;
 
@@ -173,13 +174,21 @@ static int do_ipv6_mcast_group_source(struct sock *sk, int optname,
 		/* prior join w/ different source is ok */
 		if (retv && retv != -EADDRINUSE)
 			return retv;
+		drop_group = !retv;
 		omode = MCAST_INCLUDE;
 		add = 1;
 	} else /* MCAST_LEAVE_SOURCE_GROUP */ {
 		omode = MCAST_INCLUDE;
 		add = 0;
 	}
-	return ip6_mc_source(add, omode, sk, &greqs);
+	ret = ip6_mc_source(add, omode, sk, &greqs);
+	if (ret && drop_group) {
+		struct sockaddr_in6 *psin6;
+
+		psin6 = (struct sockaddr_in6 *)&greqs.gsr_group;
+		ipv6_sock_mc_drop(sk, greqs.gsr_interface, &psin6->sin6_addr);
+	}
+	return ret;
 }
 
 static int ipv6_set_mcast_msfilter(struct sock *sk, sockptr_t optval,
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 03138d1d850d..da456f006f85 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -400,16 +400,9 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
 		goto done;	/* err = -EADDRNOTAVAIL */
 
 	/* if a source filter was set, must be the same mode as before */
-	if (rcu_access_pointer(pmc->sflist)) {
-		if (pmc->sfmode != omode) {
-			err = -EINVAL;
-			goto done;
-		}
-	} else if (pmc->sfmode != omode) {
-		/* allow mode switches for empty-set filters */
-		ip6_mc_add_src(idev, group, omode, 0, NULL, 0);
-		ip6_mc_del_src(idev, group, pmc->sfmode, 0, NULL, 0);
-		pmc->sfmode = omode;
+	if (psl && pmc->sfmode != omode) {
+		err = -EINVAL;
+		goto done;
 	}
 
 	if (!add) {
@@ -485,8 +478,21 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
 	}
 	newpsl->sl_addr[i - 1] = *source;
 
-	/* update the interface list */
-	ip6_mc_add_src(idev, group, omode, 1, source, 1);
+	/* update the interface list; an empty filter takes the new mode
+	 * together with its first source
+	 */
+	err = ip6_mc_add_src(idev, group, omode, 1, source,
+			     pmc->sfmode == omode);
+	/* -ESRCH: no device entry for the group, update the socket only */
+	if (err && err != -ESRCH) {
+		sock_kfree_s(sk, newpsl,
+			     struct_size(newpsl, sl_addr, newpsl->sl_max));
+		goto done;
+	}
+	if (pmc->sfmode != omode) {
+		ip6_mc_del_src(idev, group, pmc->sfmode, 0, NULL, 0);
+		pmc->sfmode = omode;
+	}
 
 	if (psl)
 		atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next v2 2/3] net: multicast: account socket memberships and source lists to memcg
  2026-12-05  8:18 [PATCH net-next v2 0/3] net: multicast: account memberships and device records to memcg Yingjie Wang
  2026-12-05  8:19 ` [PATCH net-next v2 1/3] net: multicast: keep source filter state when adding a source fails Yingjie Wang
@ 2026-12-05  8:19 ` Yingjie Wang
  2026-12-05  8:19 ` [PATCH net-next v2 3/3] net: multicast: account device records created by sockets " Yingjie Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Yingjie Wang @ 2026-12-05  8:19 UTC (permalink / raw)
  To: netdev@vger.kernel.org
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
	Binbin Deng, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song, cgroups@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org

The IPv4 and IPv6 multicast memberships of a socket and their source
filter lists are allocated with sock_kmalloc().  It limits them with
the socket's optmem_max budget, but does not charge them to the memory
cgroup.  IPv6 has no other limit on the number of memberships, so an
unprivileged task can keep up to optmem_max (128 KiB by default) of
them per socket outside its memory.max limit.

Use GFP_KERNEL_ACCOUNT for these allocations.

sock_kmalloc() itself is left alone: it also serves short-lived
buffers, such as control messages in sendmsg(), and allocations made
in softirq context.  Other long-lived sock_kmalloc() users, such as
TCP-MD5 and TCP-AO keys, IPv6 anycast memberships and IPv6 extension
header options, are not changed here.

The device records that the same joins create are handled in the next
patch, which also has the measurements.

Signed-off-by: Yingjie Wang <x-professor@outlook.com>
---
 net/ipv4/igmp.c  | 6 +++---
 net/ipv6/mcast.c | 9 +++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 446c49db1adf..1ed7192e7cd6 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2388,7 +2388,7 @@ static int __ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr,
 	err = -ENOBUFS;
 	if (count >= READ_ONCE(net->ipv4.sysctl_igmp_max_memberships))
 		goto done;
-	iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL);
+	iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL_ACCOUNT);
 	if (!iml)
 		goto done;
 
@@ -2587,7 +2587,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
 		if (psl)
 			count += psl->sl_max;
 		newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, count),
-				      GFP_KERNEL);
+				      GFP_KERNEL_ACCOUNT);
 		if (!newpsl) {
 			err = -ENOBUFS;
 			goto done;
@@ -2691,7 +2691,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
 	if (msf->imsf_numsrc) {
 		newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr,
 						      msf->imsf_numsrc),
-				      GFP_KERNEL);
+				      GFP_KERNEL_ACCOUNT);
 		if (!newpsl) {
 			err = -ENOBUFS;
 			goto done;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index da456f006f85..a9f2e474fad0 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -213,7 +213,8 @@ static int __ipv6_sock_mc_join(struct sock *sk, int ifindex,
 			return -EADDRINUSE;
 	}
 
-	mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist), GFP_KERNEL);
+	mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist),
+			      GFP_KERNEL_ACCOUNT);
 	if (!mc_lst)
 		return -ENOMEM;
 
@@ -427,7 +428,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
 		} else {
 			newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr,
 							      psl->sl_count - 1),
-					      GFP_KERNEL);
+					      GFP_KERNEL_ACCOUNT);
 			if (!newpsl) {
 				atomic_add(struct_size(psl, sl_addr, psl->sl_max),
 					   &sk->sk_omem_alloc);
@@ -465,7 +466,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
 
 	i = psl ? psl->sl_count + 1 : 1;
 	newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, i),
-			      GFP_KERNEL);
+			      GFP_KERNEL_ACCOUNT);
 	if (!newpsl) {
 		err = -ENOBUFS;
 		goto done;
@@ -559,7 +560,7 @@ int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf,
 	if (gsf->gf_numsrc) {
 		newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr,
 						      gsf->gf_numsrc),
-				      GFP_KERNEL);
+				      GFP_KERNEL_ACCOUNT);
 		if (!newpsl) {
 			err = -ENOBUFS;
 			goto done;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next v2 3/3] net: multicast: account device records created by sockets to memcg
  2026-12-05  8:18 [PATCH net-next v2 0/3] net: multicast: account memberships and device records to memcg Yingjie Wang
  2026-12-05  8:19 ` [PATCH net-next v2 1/3] net: multicast: keep source filter state when adding a source fails Yingjie Wang
  2026-12-05  8:19 ` [PATCH net-next v2 2/3] net: multicast: account socket memberships and source lists to memcg Yingjie Wang
@ 2026-12-05  8:19 ` Yingjie Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Yingjie Wang @ 2026-12-05  8:19 UTC (permalink / raw)
  To: netdev@vger.kernel.org
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
	Binbin Deng, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song, cgroups@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org

Socket joins, source filters and leaves also create device records:
IPv4 and IPv6 group records, their source entries, and records of
deleted groups and sources, which are kept until the state change
reports for them have been sent.  None of them are charged to the
memory cgroup.  Every group a socket joins can pin a group record, and
an unprivileged IPv6 socket can join thousands of groups.

In a QEMU guest, an unprivileged user with default sysctls joined
58,500 IPv6 groups from 25 sockets on one interface; slab grew by about
40 MiB while the user's cgroup was charged less than 2 MiB.  About
19 MiB of that were group and membership records; most of the rest
were link-layer address entries, see below.  In a user and network
namespace, loops that join and leave distinct IPv4 or IPv6 groups kept
up to about 14 or 17 MiB of deleted group records at a time, also
uncharged.

Charge these records when a socket operation creates them:

 - IPv4: ____ip_mc_inc_group() returns an error now, so that a socket
   join fails with ENOBUFS when the group record cannot be allocated,
   instead of leaving a membership without a device entry.  Socket
   leaves and closes pass GFP_KERNEL_ACCOUNT down to the deleted group
   record.  Source entries and deleted source records keep GFP_ATOMIC,
   which they need under the group's spinlock, and add __GFP_ACCOUNT.
   GFP_ATOMIC includes __GFP_HIGH, so these charges are forced and can
   leave memory.current above memory.max for a while.
 - IPv6: mca_alloc() and mld_add_delrec() take the gfp flags from their
   callers, as igmpv3_add_delrec() does for IPv4.  Socket joins and
   leaves pass GFP_KERNEL_ACCOUNT; address configuration, ndisc, the
   bridge and link events keep GFP_KERNEL.  Source entries and deleted
   source records use GFP_KERNEL_ACCOUNT.

Source entries only exist for socket source filters and are charged to
the task that changes the filter.  A record is charged to the task that
creates it, even if other sockets share it later, and a group created
by address configuration stays uncharged when a socket joins it.  A
deleted record that cannot be charged is not created, as already
happens when its allocation fails, and its state change report is then
not sent.  Link-layer addresses added with dev_mc_add(), and the copies
of them that the rx mode work keeps, are not charged.

Signed-off-by: Yingjie Wang <x-professor@outlook.com>
---
With memory.max set to 16 MiB, the IPv6 joins above, IPv4 joins and
IPv4 source filters in a user and network namespace with raised
multicast limits, and the join/leave loops ran on the base kernel
without a memory.max event; with this change the memcg OOM killer
stopped all of them.  The IPv4 source filters reached a memory.peak of
about 28 MiB because of the forced charges.

 include/net/addrconf.h |  3 ++-
 net/ipv4/igmp.c        | 34 +++++++++++++++----------
 net/ipv6/addrconf.c    |  2 +-
 net/ipv6/mcast.c       | 58 ++++++++++++++++++++++++------------------
 4 files changed, 57 insertions(+), 40 deletions(-)

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 0ec4db881404..5be6f30e8877 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -273,7 +273,8 @@ bool inet6_mc_check(const struct sock *sk, const struct in6_addr *mc_addr,
 		    const struct in6_addr *src_addr);
 
 int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr);
-int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr);
+int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr,
+		      gfp_t gfp);
 int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr);
 void ipv6_mc_up(struct inet6_dev *idev);
 void ipv6_mc_down(struct inet6_dev *idev);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 1ed7192e7cd6..eb48c940397a 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1574,8 +1574,8 @@ static void inet_ifmcaddr_notify(struct net_device *dev,
 /*
  *	A socket has joined a multicast group on device dev.
  */
-static void ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
-				unsigned int mode, gfp_t gfp)
+static int ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
+			       unsigned int mode, gfp_t gfp)
 {
 	struct ip_mc_list __rcu **mc_hash;
 	struct ip_mc_list *im;
@@ -1602,12 +1602,12 @@ static void ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
 	if  (im) {
 		WRITE_ONCE(im->users, im->users + 1);
 		ip_mc_add_src(in_dev, &addr, mode, 0, NULL, 0);
-		goto out;
+		return 0;
 	}
 
 	im = kzalloc_obj(*im, gfp);
 	if (!im)
-		goto out;
+		return -ENOBUFS;
 
 	WRITE_ONCE(im->users, 1);
 	im->interface = in_dev;
@@ -1637,8 +1637,7 @@ static void ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
 	inet_ifmcaddr_notify(in_dev->dev, im, RTM_NEWMULTICAST);
 	if (!in_dev->dead)
 		ip_rt_multicast_event(in_dev);
-out:
-	return;
+	return 0;
 }
 
 void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr, gfp_t gfp)
@@ -2062,7 +2061,9 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
 #ifdef CONFIG_IP_MULTICAST
 		if (psf->sf_oldin &&
 		    !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) {
-			struct ip_sf_list *dpsf = kmalloc_obj(*dpsf, GFP_ATOMIC);
+			struct ip_sf_list *dpsf;
+
+			dpsf = kmalloc_obj(*dpsf, GFP_ATOMIC | __GFP_ACCOUNT);
 
 			if (dpsf) {
 				*dpsf = *psf;
@@ -2162,7 +2163,7 @@ static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode,
 		psf_prev = psf;
 	}
 	if (!psf) {
-		psf = kzalloc_obj(*psf, GFP_ATOMIC);
+		psf = kzalloc_obj(*psf, GFP_ATOMIC | __GFP_ACCOUNT);
 		if (!psf)
 			return -ENOBUFS;
 		psf->sf_inaddr = *psfsrc;
@@ -2244,7 +2245,8 @@ static int sf_setstate(struct ip_mc_list *pmc)
 					break;
 			}
 			if (!dpsf) {
-				dpsf = kmalloc_obj(*dpsf, GFP_ATOMIC);
+				dpsf = kmalloc_obj(*dpsf,
+						   GFP_ATOMIC | __GFP_ACCOUNT);
 				if (!dpsf)
 					continue;
 				*dpsf = *psf;
@@ -2392,13 +2394,17 @@ static int __ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr,
 	if (!iml)
 		goto done;
 
+	err = ____ip_mc_inc_group(in_dev, addr, mode, GFP_KERNEL_ACCOUNT);
+	if (err) {
+		sock_kfree_s(sk, iml, sizeof(*iml));
+		goto done;
+	}
+
 	memcpy(&iml->multi, imr, sizeof(*imr));
 	iml->next_rcu = inet->mc_list;
 	iml->sflist = NULL;
 	iml->sfmode = mode;
 	rcu_assign_pointer(inet->mc_list, iml);
-	____ip_mc_inc_group(in_dev, addr, mode, GFP_KERNEL);
-	err = 0;
 done:
 	return err;
 }
@@ -2477,7 +2483,7 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
 		*imlp = iml->next_rcu;
 
 		if (in_dev)
-			ip_mc_dec_group(in_dev, group);
+			__ip_mc_dec_group(in_dev, group, GFP_KERNEL_ACCOUNT);
 
 		/* decrease mem now to avoid the memleak warning */
 		atomic_sub(sizeof(*iml), &sk->sk_omem_alloc);
@@ -2923,7 +2929,9 @@ void ip_mc_drop_socket(struct sock *sk)
 		in_dev = inetdev_by_index(net, iml->multi.imr_ifindex);
 		(void) ip_mc_leave_src(sk, iml, in_dev);
 		if (in_dev)
-			ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr);
+			__ip_mc_dec_group(in_dev,
+					  iml->multi.imr_multiaddr.s_addr,
+					  GFP_KERNEL_ACCOUNT);
 		/* decrease mem now to avoid the memleak warning */
 		atomic_sub(sizeof(*iml), &sk->sk_omem_alloc);
 		kfree_rcu(iml, rcu);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 0c4f0a0ad451..ab06970229a9 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2314,7 +2314,7 @@ void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)
 		return;
 
 	addrconf_addr_solict_mult(addr, &maddr);
-	__ipv6_dev_mc_dec(idev, &maddr);
+	__ipv6_dev_mc_dec(idev, &maddr, GFP_KERNEL);
 }
 
 static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index a9f2e474fad0..be648c768ecb 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -74,7 +74,7 @@ static struct workqueue_struct *mld_wq;
 static struct in6_addr mld2_all_mcr = MLD2_ALL_MCR_INIT;
 
 static void igmp6_join_group(struct ifmcaddr6 *ma);
-static void igmp6_leave_group(struct ifmcaddr6 *ma);
+static void igmp6_leave_group(struct ifmcaddr6 *ma, gfp_t gfp);
 static void mld_mca_work(struct work_struct *work);
 
 static void mld_ifc_event(struct inet6_dev *idev);
@@ -91,7 +91,8 @@ static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca,
 static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
 			    struct inet6_dev *idev);
 static int __ipv6_dev_mc_inc(struct net_device *dev,
-			     const struct in6_addr *addr, unsigned int mode);
+			     const struct in6_addr *addr, unsigned int mode,
+			     gfp_t gfp);
 
 #define MLD_QRV_DEFAULT		2
 /* RFC3810, 9.2. Query Interval */
@@ -232,7 +233,7 @@ static int __ipv6_sock_mc_join(struct sock *sk, int ifindex,
 	RCU_INIT_POINTER(mc_lst->sflist, NULL);
 
 	/* now add/increase the group membership on the device */
-	err = __ipv6_dev_mc_inc(dev, addr, mode);
+	err = __ipv6_dev_mc_inc(dev, addr, mode, GFP_KERNEL_ACCOUNT);
 
 	dev_put(dev);
 
@@ -275,7 +276,8 @@ static void __ipv6_sock_mc_drop(struct sock *sk, struct ipv6_mc_socklist *mc_lst
 		ip6_mc_leave_src(sk, mc_lst, idev);
 
 		if (idev) {
-			__ipv6_dev_mc_dec(idev, &mc_lst->addr);
+			__ipv6_dev_mc_dec(idev, &mc_lst->addr,
+					  GFP_KERNEL_ACCOUNT);
 			in6_dev_put(idev);
 		}
 
@@ -739,7 +741,7 @@ static void igmp6_group_added(struct ifmcaddr6 *mc)
 	mld_ifc_event(mc->idev);
 }
 
-static void igmp6_group_dropped(struct ifmcaddr6 *mc)
+static void igmp6_group_dropped(struct ifmcaddr6 *mc, gfp_t gfp)
 {
 	struct net_device *dev = mc->idev->dev;
 	/* RTNL might not be held: dev->type and dev->addr_len can change.
@@ -763,14 +765,15 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)
 		return;
 
 	if (!mc->idev->dead)
-		igmp6_leave_group(mc);
+		igmp6_leave_group(mc, gfp);
 
 	if (cancel_delayed_work(&mc->mca_work))
 		refcount_dec(&mc->mca_refcnt);
 }
 
 /* deleted ifmcaddr6 manipulation */
-static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
+static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im,
+			   gfp_t gfp)
 {
 	struct ifmcaddr6 *pmc;
 
@@ -782,7 +785,7 @@ static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
 	 * for deleted items allows change reports to use common code with
 	 * non-deleted or query-response MCA's.
 	 */
-	pmc = kzalloc_obj(*pmc);
+	pmc = kzalloc_obj(*pmc, gfp);
 	if (!pmc)
 		return;
 
@@ -906,13 +909,13 @@ static void ma_put(struct ifmcaddr6 *mc)
 
 static struct ifmcaddr6 *mca_alloc(struct inet6_dev *idev,
 				   const struct in6_addr *addr,
-				   unsigned int mode)
+				   unsigned int mode, gfp_t gfp)
 {
 	struct ifmcaddr6 *mc;
 
 	mc_assert_locked(idev);
 
-	mc = kzalloc_obj(*mc);
+	mc = kzalloc_obj(*mc, gfp);
 	if (!mc)
 		return NULL;
 
@@ -975,7 +978,8 @@ static void inet6_ifmcaddr_notify(struct net_device *dev,
  *	device multicast group inc (add if not found)
  */
 static int __ipv6_dev_mc_inc(struct net_device *dev,
-			     const struct in6_addr *addr, unsigned int mode)
+			     const struct in6_addr *addr, unsigned int mode,
+			     gfp_t gfp)
 {
 	struct inet6_dev *idev;
 	struct ifmcaddr6 *mc;
@@ -1003,7 +1007,7 @@ static int __ipv6_dev_mc_inc(struct net_device *dev,
 		}
 	}
 
-	mc = mca_alloc(idev, addr, mode);
+	mc = mca_alloc(idev, addr, mode, gfp);
 	if (!mc) {
 		mutex_unlock(&idev->mc_lock);
 		in6_dev_put(idev);
@@ -1023,14 +1027,15 @@ static int __ipv6_dev_mc_inc(struct net_device *dev,
 
 int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr)
 {
-	return __ipv6_dev_mc_inc(dev, addr, MCAST_EXCLUDE);
+	return __ipv6_dev_mc_inc(dev, addr, MCAST_EXCLUDE, GFP_KERNEL);
 }
 EXPORT_SYMBOL(ipv6_dev_mc_inc);
 
 /*
  * device multicast group del
  */
-int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr)
+int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr,
+		      gfp_t gfp)
 {
 	struct ifmcaddr6 *ma, __rcu **map;
 
@@ -1047,7 +1052,7 @@ int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr)
 				rcu_assign_pointer(*map,
 						   mc_dereference(ma->next, idev));
 
-				igmp6_group_dropped(ma);
+				igmp6_group_dropped(ma, gfp);
 				inet6_ifmcaddr_notify(idev->dev, ma,
 						      RTM_DELMULTICAST);
 				ip6_mc_clear_src(ma);
@@ -1074,7 +1079,7 @@ int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr)
 	if (!idev)
 		return -ENODEV;
 
-	err = __ipv6_dev_mc_dec(idev, addr);
+	err = __ipv6_dev_mc_dec(idev, addr, GFP_KERNEL);
 	in6_dev_put(idev);
 
 	return err;
@@ -2396,7 +2401,9 @@ static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,
 
 		if (psf->sf_oldin && !(pmc->mca_flags & MAF_NOREPORT) &&
 		    !mld_in_v1_mode(idev)) {
-			struct ip6_sf_list *dpsf = kmalloc_obj(*dpsf);
+			struct ip6_sf_list *dpsf;
+
+			dpsf = kmalloc_obj(*dpsf, GFP_KERNEL_ACCOUNT);
 
 			if (dpsf) {
 				*dpsf = *psf;
@@ -2481,7 +2488,7 @@ static int ip6_mc_add1_src(struct ifmcaddr6 *pmc, int sfmode,
 		psf_prev = psf;
 	}
 	if (!psf) {
-		psf = kzalloc_obj(*psf);
+		psf = kzalloc_obj(*psf, GFP_KERNEL_ACCOUNT);
 		if (!psf)
 			return -ENOBUFS;
 
@@ -2566,7 +2573,7 @@ static int sf_setstate(struct ifmcaddr6 *pmc)
 				    &psf->sf_addr))
 					break;
 			if (!dpsf) {
-				dpsf = kmalloc_obj(*dpsf);
+				dpsf = kmalloc_obj(*dpsf, GFP_KERNEL_ACCOUNT);
 				if (!dpsf)
 					continue;
 				*dpsf = *psf;
@@ -2725,7 +2732,7 @@ static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
 	return err;
 }
 
-static void igmp6_leave_group(struct ifmcaddr6 *ma)
+static void igmp6_leave_group(struct ifmcaddr6 *ma, gfp_t gfp)
 {
 	mc_assert_locked(ma->idev);
 
@@ -2735,7 +2742,7 @@ static void igmp6_leave_group(struct ifmcaddr6 *ma)
 				ICMPV6_MGM_REDUCTION);
 		}
 	} else {
-		mld_add_delrec(ma->idev, ma);
+		mld_add_delrec(ma->idev, ma, gfp);
 		mld_ifc_event(ma->idev);
 	}
 }
@@ -2811,7 +2818,7 @@ void ipv6_mc_unmap(struct inet6_dev *idev)
 
 	mutex_lock(&idev->mc_lock);
 	for_each_mc_mclock(idev, i)
-		igmp6_group_dropped(i);
+		igmp6_group_dropped(i, GFP_KERNEL);
 	mutex_unlock(&idev->mc_lock);
 }
 
@@ -2828,7 +2835,7 @@ void ipv6_mc_down(struct inet6_dev *idev)
 	mutex_lock(&idev->mc_lock);
 	/* Withdraw multicast list */
 	for_each_mc_mclock(idev, i)
-		igmp6_group_dropped(i);
+		igmp6_group_dropped(i, GFP_KERNEL);
 	mutex_unlock(&idev->mc_lock);
 
 	/* Should stop work after group drop. or we will
@@ -2912,10 +2919,11 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev)
 	 * addrconf.c has NULL'd out dev->ip6_ptr so in6_dev_get() will
 	 * fail.
 	 */
-	__ipv6_dev_mc_dec(idev, &in6addr_linklocal_allnodes);
+	__ipv6_dev_mc_dec(idev, &in6addr_linklocal_allnodes, GFP_KERNEL);
 
 	if (idev->cnf.forwarding)
-		__ipv6_dev_mc_dec(idev, &in6addr_linklocal_allrouters);
+		__ipv6_dev_mc_dec(idev, &in6addr_linklocal_allrouters,
+				  GFP_KERNEL);
 
 	mutex_lock(&idev->mc_lock);
 	while ((i = mc_dereference(idev->mc_list, idev))) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-05  8:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05  8:18 [PATCH net-next v2 0/3] net: multicast: account memberships and device records to memcg Yingjie Wang
2026-12-05  8:19 ` [PATCH net-next v2 1/3] net: multicast: keep source filter state when adding a source fails Yingjie Wang
2026-12-05  8:19 ` [PATCH net-next v2 2/3] net: multicast: account socket memberships and source lists to memcg Yingjie Wang
2026-12-05  8:19 ` [PATCH net-next v2 3/3] net: multicast: account device records created by sockets " Yingjie Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox