]> git.baikalelectronics.ru Git - kernel.git/commit
nexthops: don't modify published nexthop groups
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Tue, 26 May 2020 18:56:15 +0000 (12:56 -0600)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 May 2020 23:06:06 +0000 (16:06 -0700)
commit3ba0cac7e31a456b2d4575cdee82d13c6b359a05
tree0dfe49406024d9c4bbc3ad76c5c2d8a6527bd65f
parente3040d5b44019525121a7eeb8fec4a3cfab169e8
nexthops: don't modify published nexthop groups

We must avoid modifying published nexthop groups while they might be
in use, otherwise we might see NULL ptr dereferences. In order to do
that we allocate 2 nexthoup group structures upon nexthop creation
and swap between them when we have to delete an entry. The reason is
that we can't fail nexthop group removal, so we can't handle allocation
failure thus we move the extra allocation on creation where we can
safely fail and return ENOMEM.

Fixes: 6e9d1ef54f91 ("nexthop: Add support for nexthop groups")
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/nexthop.h
net/ipv4/nexthop.c