Skip to content

Commit faebe54

Browse files
idoschgregkh
authored andcommitted
nexthop: Emit a notification when a single nexthop is replaced
[ Upstream commit 8c09c9f ] 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: 390b3a3 ("nexthop: Forbid FDB status change while nexthop is in a group") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent afd05e5 commit faebe54

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

net/ipv4/nexthop.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,12 +1009,22 @@ static int replace_nexthop_single(struct net *net, struct nexthop *old,
10091009
struct netlink_ext_ack *extack)
10101010
{
10111011
struct nh_info *oldi, *newi;
1012+
int err;
10121013

10131014
if (new->is_group) {
10141015
NL_SET_ERR_MSG(extack, "Can not replace a nexthop with a nexthop group.");
10151016
return -EINVAL;
10161017
}
10171018

1019+
err = call_nexthop_notifiers(net, NEXTHOP_EVENT_REPLACE, new, extack);
1020+
if (err)
1021+
return err;
1022+
1023+
/* Hardware flags were set on 'old' as 'new' is not in the red-black
1024+
* tree. Therefore, inherit the flags from 'old' to 'new'.
1025+
*/
1026+
new->nh_flags |= old->nh_flags & (RTNH_F_OFFLOAD | RTNH_F_TRAP);
1027+
10181028
oldi = rtnl_dereference(old->nh_info);
10191029
newi = rtnl_dereference(new->nh_info);
10201030

0 commit comments

Comments
 (0)