summaryrefslogtreecommitdiffstats
path: root/include/net/nexthop.h
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2020-05-26 20:56:18 +0200
committerDavid S. Miller <davem@davemloft.net>2020-05-27 01:06:07 +0200
commit1fd1c768f3624a5e66766e7b4ddb9b607cd834a5 (patch)
treeb70ecc0b84cb9c9db0c4e40ba2af7f12eacdf969 /include/net/nexthop.h
parentipv4: Refactor nhc evaluation in fib_table_lookup (diff)
downloadlinux-1fd1c768f3624a5e66766e7b4ddb9b607cd834a5.tar.xz
linux-1fd1c768f3624a5e66766e7b4ddb9b607cd834a5.zip
ipv4: nexthop version of fib_info_nh_uses_dev
Similar to the last path, need to fix fib_info_nh_uses_dev for external nexthops to avoid referencing multiple nh_grp structs. Move the device check in fib_info_nh_uses_dev to a helper and create a nexthop version that is called if the fib_info uses an external nexthop. Fixes: 430a049190de ("nexthop: Add support for nexthop groups") Signed-off-by: David Ahern <dsahern@gmail.com> Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/nexthop.h')
-rw-r--r--include/net/nexthop.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index 9414ae46fc1c..8c9f1a718859 100644
--- a/include/net/nexthop.h
+++ b/include/net/nexthop.h
@@ -266,6 +266,31 @@ struct fib_nh_common *nexthop_get_nhc_lookup(const struct nexthop *nh,
return NULL;
}
+static inline bool nexthop_uses_dev(const struct nexthop *nh,
+ const struct net_device *dev)
+{
+ struct nh_info *nhi;
+
+ if (nh->is_group) {
+ struct nh_group *nhg = rcu_dereference(nh->nh_grp);
+ int i;
+
+ for (i = 0; i < nhg->num_nh; i++) {
+ struct nexthop *nhe = nhg->nh_entries[i].nh;
+
+ nhi = rcu_dereference(nhe->nh_info);
+ if (nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev))
+ return true;
+ }
+ } else {
+ nhi = rcu_dereference(nh->nh_info);
+ if (nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev))
+ return true;
+ }
+
+ return false;
+}
+
static inline unsigned int fib_info_num_path(const struct fib_info *fi)
{
if (unlikely(fi->nh))