Skip to contentSkip to conversation

nexthops: Fix fdb labeling for groups

PATCH Superseded David Ahern 2 participants 2 messages Jun 9, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

David Ahern

author maintainer
#0 lore raw

PATCH 1/1 nexthops: Fix fdb labeling for groups

fdb nexthops are marked with a flag. For standalone nexthops, a flag was added to the nh_info struct. For groups that flag was added to struct nexthop when it should have been added to the group information. Fix by removing the flag from the nexthop struct and adding a flag to nh_group that mirrors nh_info and is really only a caching of the individual types. Add a helper, nexthop_is_fdb, for use by the vxlan code and fixup the internal code to use the flag from either nh_info or nh_group.

Fixes 38428d68719c ("nexthop: support for fdb ecmp nexthops")
Cc Roopa Prabhu <[email protected]>

---
Roopa: you have not submitted the iproute2 patch, so I can not run the fdb selftests added to fib_nexthops.sh

 drivers/net/vxlan.c   |  2 +-
 include/net/nexthop.h | 17 ++++++++-
 net/ipv4/nexthop.c    | 81 +++++++++++++++++++++++++------------------
 3 files changed, 65 insertions(+), 35 deletions(-)
drivers/net/vxlan.c +1 -1
index 5bb448ae6c9c..24ea689516e4 100644
@@ -876,7 +876,7 @@ static int vxlan_fdb_nh_update(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb,
 			nh = NULL;
 			goto err_inval;
 		}
-		if (!nh->is_fdb_nh) {
+		if (!nexthop_is_fdb(nh)) {
 			NL_SET_ERR_MSG(extack, "Nexthop is not a fdb nexthop");
 			goto err_inval;
 		}
include/net/nexthop.h +16 -1
index e4b55b43e907..3f9e0ca2dc4d 100644
@@ -76,6 +76,7 @@ struct nh_group {
 	struct nh_group		*spare; /* spare group for removals */
 	u16			num_nh;
 	bool			mpath;
+	bool			fdb_nh;
 	bool			has_v4;
 	struct nh_grp_entry	nh_entries[];
 };
@@ -93,7 +94,6 @@ struct nexthop {
 	u8			protocol;   /* app managing this nh */
 	u8			nh_flags;
 	bool			is_group;
-	bool			is_fdb_nh;
 
 	refcount_t		refcnt;
 	struct rcu_head		rcu;
@@ -136,6 +136,21 @@ static inline bool nexthop_cmp(const struct nexthop *nh1,
 	return nh1 == nh2;
 }
 
+static inline bool nexthop_is_fdb(const struct nexthop *nh)
+{
+	if (nh->is_group) {
+		const struct nh_group *nh_grp;
+
+		nh_grp = rcu_dereference_rtnl(nh->nh_grp);
+		return nh_grp->fdb_nh;
+	} else {
+		const struct nh_info *nhi;
+
+		nhi = rcu_dereference_rtnl(nh->nh_info);
+		return nhi->fdb_nh;
+	}
+}
+
 static inline bool nexthop_is_multipath(const struct nexthop *nh)
 {
 	if (nh->is_group) {
net/ipv4/nexthop.c +48 -33

220 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · David Ahern

fdb nexthops are marked with a flag. For standalone nexthops, a flag was added to the nh_info struct. For groups that flag was added to struct nexthop when it should have been added to the group information. Fix by removing the flag from the nexthop struct and adding a flag to nh_group

I forgot to propagate the change in remove_nh_grp_entry. Will send a v2.