Skip to content

Commit 50cb876

Browse files
dsaherndavem330
authored andcommitted
vxlan: Remove access to nexthop group struct
vxlan driver should be using helpers to access nexthop struct internals. Remove open check if whether nexthop is multipath in favor of the existing nexthop_is_multipath helper. Add a new helper, nexthop_has_v4, to cover the need to check has_v4 in a group. Fixes: 1274e1c ("vxlan: ecmp support for mac fdb entries") Cc: Roopa Prabhu <[email protected]> Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ce9ac05 commit 50cb876

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

drivers/net/vxlan.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,6 @@ static int vxlan_fdb_nh_update(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb,
857857
u32 nhid, struct netlink_ext_ack *extack)
858858
{
859859
struct nexthop *old_nh = rtnl_dereference(fdb->nh);
860-
struct nh_group *nhg;
861860
struct nexthop *nh;
862861
int err = -EINVAL;
863862

@@ -881,23 +880,22 @@ static int vxlan_fdb_nh_update(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb,
881880
goto err_inval;
882881
}
883882

884-
nhg = rtnl_dereference(nh->nh_grp);
885-
if (!nh->is_group || !nhg->mpath) {
883+
if (!nexthop_is_multipath(nh)) {
886884
NL_SET_ERR_MSG(extack, "Nexthop is not a multipath group");
887885
goto err_inval;
888886
}
889887

890888
/* check nexthop group family */
891889
switch (vxlan->default_dst.remote_ip.sa.sa_family) {
892890
case AF_INET:
893-
if (!nhg->has_v4) {
891+
if (!nexthop_has_v4(nh)) {
894892
err = -EAFNOSUPPORT;
895893
NL_SET_ERR_MSG(extack, "Nexthop group family not supported");
896894
goto err_inval;
897895
}
898896
break;
899897
case AF_INET6:
900-
if (nhg->has_v4) {
898+
if (nexthop_has_v4(nh)) {
901899
err = -EAFNOSUPPORT;
902900
NL_SET_ERR_MSG(extack, "Nexthop group family not supported");
903901
goto err_inval;

include/net/nexthop.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ static inline bool nexthop_is_fdb(const struct nexthop *nh)
151151
}
152152
}
153153

154+
static inline bool nexthop_has_v4(const struct nexthop *nh)
155+
{
156+
if (nh->is_group) {
157+
struct nh_group *nh_grp;
158+
159+
nh_grp = rcu_dereference_rtnl(nh->nh_grp);
160+
return nh_grp->has_v4;
161+
}
162+
return false;
163+
}
164+
154165
static inline bool nexthop_is_multipath(const struct nexthop *nh)
155166
{
156167
if (nh->is_group) {

0 commit comments

Comments
 (0)