From: Petr Machata Date: Thu, 28 Jan 2021 12:49:18 +0000 (+0100) Subject: nexthop: Dispatch notifier init()/fini() by group type X-Git-Tag: accepted/tizen/unified/20230118.172025~7901^2~214^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da230501f2c95a39eaa0856afd0122d35bda9e5d;p=platform%2Fkernel%2Flinux-rpi.git nexthop: Dispatch notifier init()/fini() by group type After there are several next-hop group types, initialization and finalization of notifier type needs to reflect the actual type. Transform nh_notifier_grp_info_init() and _fini() to make extending them easier. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel Reviewed-by: David Ahern Signed-off-by: Jakub Kicinski --- diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 12f812b..7149b12 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -86,10 +86,9 @@ static void nh_notifier_single_info_fini(struct nh_notifier_info *info) kfree(info->nh); } -static int nh_notifier_grp_info_init(struct nh_notifier_info *info, - const struct nexthop *nh) +static int nh_notifier_mp_info_init(struct nh_notifier_info *info, + struct nh_group *nhg) { - struct nh_group *nhg = rtnl_dereference(nh->nh_grp); u16 num_nh = nhg->num_nh; int i; @@ -114,9 +113,23 @@ static int nh_notifier_grp_info_init(struct nh_notifier_info *info, return 0; } -static void nh_notifier_grp_info_fini(struct nh_notifier_info *info) +static int nh_notifier_grp_info_init(struct nh_notifier_info *info, + const struct nexthop *nh) { - kfree(info->nh_grp); + struct nh_group *nhg = rtnl_dereference(nh->nh_grp); + + if (nhg->mpath) + return nh_notifier_mp_info_init(info, nhg); + return -EINVAL; +} + +static void nh_notifier_grp_info_fini(struct nh_notifier_info *info, + const struct nexthop *nh) +{ + struct nh_group *nhg = rtnl_dereference(nh->nh_grp); + + if (nhg->mpath) + kfree(info->nh_grp); } static int nh_notifier_info_init(struct nh_notifier_info *info, @@ -134,7 +147,7 @@ static void nh_notifier_info_fini(struct nh_notifier_info *info, const struct nexthop *nh) { if (nh->is_group) - nh_notifier_grp_info_fini(info); + nh_notifier_grp_info_fini(info, nh); else nh_notifier_single_info_fini(info); }