diff options
| author | Ido Schimmel <idosch@nvidia.com> | 2020-11-04 15:30:31 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-10-02 13:35:46 +0200 |
| commit | faebe54467862ec93e0e47c9438c41df9e09647d (patch) | |
| tree | ae4d7e18d5101c288c83f39166e79fe52e0a7418 | |
| parent | afd05e5028fee25922daef00bdd178e5aabb23ce (diff) | |
| download | linux-faebe54467862ec93e0e47c9438c41df9e09647d.tar.gz linux-faebe54467862ec93e0e47c9438c41df9e09647d.tar.bz2 linux-faebe54467862ec93e0e47c9438c41df9e09647d.zip | |
nexthop: Emit a notification when a single nexthop is replaced
[ Upstream commit 8c09c9f9d846cdd8a92604c591132985b04fd1d6 ]
The notification is emitted after all the validation checks were
performed, but before the new configuration (i.e., 'struct nh_info') is
pointed at by the old shell (i.e., 'struct nexthop'). This prevents the
need to perform rollback in case the notification is vetoed.
The next patch will also emit a replace notification for all the nexthop
groups in which the nexthop is used.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 390b3a300d78 ("nexthop: Forbid FDB status change while nexthop is in a group")
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | net/ipv4/nexthop.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 3063aa1914b1..d2b338b35722 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -1009,12 +1009,22 @@ static int replace_nexthop_single(struct net *net, struct nexthop *old, struct netlink_ext_ack *extack) { struct nh_info *oldi, *newi; + int err; if (new->is_group) { NL_SET_ERR_MSG(extack, "Can not replace a nexthop with a nexthop group."); return -EINVAL; } + err = call_nexthop_notifiers(net, NEXTHOP_EVENT_REPLACE, new, extack); + if (err) + return err; + + /* Hardware flags were set on 'old' as 'new' is not in the red-black + * tree. Therefore, inherit the flags from 'old' to 'new'. + */ + new->nh_flags |= old->nh_flags & (RTNH_F_OFFLOAD | RTNH_F_TRAP); + oldi = rtnl_dereference(old->nh_info); newi = rtnl_dereference(new->nh_info); |
