]> www.infradead.org Git - users/jedix/linux-maple.git/commit
net: Don't register pernet_operations if only one of id or size is specified.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 31 Jul 2024 20:07:17 +0000 (13:07 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Aug 2024 21:38:44 +0000 (22:38 +0100)
commit768e4bb6a75e3c6a034df7c67edac20bd222857e
treedbf45faf8087ca30a2d44701ecd227122d8f1ec7
parent1ad001347fb1ca1f036144b42a6f1df6615e4104
net: Don't register pernet_operations if only one of id or size is specified.

We can allocate per-netns memory for struct pernet_operations by specifying
id and size.

register_pernet_operations() assigns an id to pernet_operations and later
ops_init() allocates the specified size of memory as net->gen->ptr[id].

If id is missing, no memory is allocated.  If size is not specified,
pernet_operations just wastes an entry of net->gen->ptr[] for every netns.

net_generic is available only when both id and size are specified, so let's
ensure that.

While we are at it, we add const to both fields.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/net_namespace.h
net/core/net_namespace.c