Skip to content

Commit

Permalink
nexthop: Pass nh_config to replace_nexthop()
Browse files Browse the repository at this point in the history
Currently, replace assumes that the new group that is given is a
fully-formed object. But mpath groups really only have one attribute, and
that is the constituent next hop configuration. This may not be universally
true. From the usability perspective, it is desirable to allow the replace
operation to adjust just the constituent next hop configuration and leave
the group attributes as such intact.

But the object that keeps track of whether an attribute was or was not
given is the nh_config object, not the next hop or next-hop group. To allow
(selective) attribute updates during NH group replacement, propagate `cfg'
to replace_nexthop() and further to replace_nexthop_grp().

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Petr Machata authored and David S. Miller committed Mar 12, 2021
1 parent 1d5d0a0 commit 597f48e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions net/ipv4/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh)
}

static int replace_nexthop_grp(struct net *net, struct nexthop *old,
struct nexthop *new,
struct nexthop *new, const struct nh_config *cfg,
struct netlink_ext_ack *extack)
{
struct nh_group *oldg, *newg;
Expand Down Expand Up @@ -1276,7 +1276,8 @@ static void nexthop_replace_notify(struct net *net, struct nexthop *nh,
}

static int replace_nexthop(struct net *net, struct nexthop *old,
struct nexthop *new, struct netlink_ext_ack *extack)
struct nexthop *new, const struct nh_config *cfg,
struct netlink_ext_ack *extack)
{
bool new_is_reject = false;
struct nh_grp_entry *nhge;
Expand Down Expand Up @@ -1319,7 +1320,7 @@ static int replace_nexthop(struct net *net, struct nexthop *old,
}

if (old->is_group)
err = replace_nexthop_grp(net, old, new, extack);
err = replace_nexthop_grp(net, old, new, cfg, extack);
else
err = replace_nexthop_single(net, old, new, extack);

Expand Down Expand Up @@ -1361,7 +1362,7 @@ static int insert_nexthop(struct net *net, struct nexthop *new_nh,
} else if (new_id > nh->id) {
pp = &next->rb_right;
} else if (replace) {
rc = replace_nexthop(net, nh, new_nh, extack);
rc = replace_nexthop(net, nh, new_nh, cfg, extack);
if (!rc) {
new_nh = nh; /* send notification with old nh */
replace_notify = 1;
Expand Down

0 comments on commit 597f48e

Please sign in to comment.