Skip to contentSkip to conversation

nexthop: Fix fdb labeling for groups

PATCH Applied David Ahern 3 participants 3 messages Jun 9, 2020 – Jun 10, 2020

Subsystems (3)
lore
Share & tools
lore

David Ahern

author maintainer
#0 lore raw

PATCH v2 1/1 nexthop: 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.

v2
- propagate fdb_nh in remove_nh_grp_entry

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    | 82 ++++++++++++++++++++++++++-----------------
 3 files changed, 66 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 +49 -33

227 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

From: David Ahern <[email protected]>
Date: Mon, 8 Jun 2020 20:54:43 -0600

Quoted 8 lines

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.

Quoted 6 lines

v2
- propagate fdb_nh in remove_nh_grp_entry

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

Applied, thanks David.

Acked-by on v2 1/1
#2 lore raw
In reply to David Ahern
Quoted 9 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 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.

Quoted 6 lines

v2
- propagate fdb_nh in remove_nh_grp_entry

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

nice cleanups. Thanks David.

looks like the patches were just applied, FWIW,