Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdf00467 authored by David Ahern's avatar David Ahern Committed by David S. Miller
Browse files

net: Replace nhc_has_gw with nhc_gw_family



Allow the gateway in a fib_nh_common to be from a different address
family than the outer fib{6}_nh. To that end, replace nhc_has_gw with
nhc_gw_family and update users of nhc_has_gw to check nhc_gw_family.
Now nhc_family is used to know if the nh_common is part of a fib_nh
or fib6_nh (used for container_of to get to route family specific data),
and nhc_gw_family represents the address family for the gateway.

Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 71df5777
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4915,7 +4915,7 @@ static void mlxsw_sp_rt6_destroy(struct mlxsw_sp_rt6 *mlxsw_sp_rt6)
static bool mlxsw_sp_fib6_rt_can_mp(const struct fib6_info *rt)
{
	/* RTF_CACHE routes are ignored */
	return !(rt->fib6_flags & RTF_ADDRCONF) && rt->fib6_nh.fib_nh_has_gw;
	return !(rt->fib6_flags & RTF_ADDRCONF) && rt->fib6_nh.fib_nh_gw_family;
}

static struct fib6_info *
@@ -5055,7 +5055,7 @@ static void mlxsw_sp_nexthop6_fini(struct mlxsw_sp *mlxsw_sp,
static bool mlxsw_sp_rt6_is_gateway(const struct mlxsw_sp *mlxsw_sp,
				    const struct fib6_info *rt)
{
	return rt->fib6_nh.fib_nh_has_gw ||
	return rt->fib6_nh.fib_nh_gw_family ||
	       mlxsw_sp_nexthop6_ipip_type(mlxsw_sp, rt, NULL);
}

+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ static inline bool rt6_need_strict(const struct in6_addr *daddr)
static inline bool rt6_qualify_for_ecmp(const struct fib6_info *f6i)
{
	return !(f6i->fib6_flags & (RTF_ADDRCONF|RTF_DYNAMIC)) &&
		f6i->fib6_nh.fib_nh_has_gw;
		f6i->fib6_nh.fib_nh_gw_family;
}

void ip6_route_input(struct sk_buff *skb);
+3 −4
Original line number Diff line number Diff line
@@ -83,8 +83,8 @@ struct fib_nh_common {
	struct lwtunnel_state	*nhc_lwtstate;
	unsigned char		nhc_scope;
	u8			nhc_family;
	u8			nhc_has_gw:1,
				unused:7;
	u8			nhc_gw_family;

	union {
		__be32          ipv4;
		struct in6_addr ipv6;
@@ -112,8 +112,7 @@ struct fib_nh {
#define fib_nh_flags		nh_common.nhc_flags
#define fib_nh_lws		nh_common.nhc_lwtstate
#define fib_nh_scope		nh_common.nhc_scope
#define fib_nh_family		nh_common.nhc_family
#define fib_nh_has_gw		nh_common.nhc_has_gw
#define fib_nh_gw_family	nh_common.nhc_gw_family
#define fib_nh_gw4		nh_common.nhc_gw.ipv4
#define fib_nh_gw6		nh_common.nhc_gw.ipv6
#define fib_nh_weight		nh_common.nhc_weight
+2 −2
Original line number Diff line number Diff line
@@ -69,13 +69,13 @@ TRACE_EVENT(fib_table_lookup,
		__assign_str(name, dev ? dev->name : "-");

		if (nhc) {
			if (nhc->nhc_family == AF_INET) {
			if (nhc->nhc_gw_family == AF_INET) {
				p32 = (__be32 *) __entry->gw4;
				*p32 = nhc->nhc_gw.ipv4;

				in6 = (struct in6_addr *)__entry->gw6;
				*in6 = in6_zero;
			} else if (nhc->nhc_family == AF_INET6) {
			} else if (nhc->nhc_gw_family == AF_INET6) {
				p32 = (__be32 *) __entry->gw4;
				*p32 = 0;

+2 −2
Original line number Diff line number Diff line
@@ -4639,7 +4639,7 @@ static int bpf_ipv4_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
		return BPF_FIB_LKUP_RET_UNSUPP_LWT;

	dev = nhc->nhc_dev;
	if (nhc->nhc_has_gw)
	if (nhc->nhc_gw_family)
		params->ipv4_dst = nhc->nhc_gw.ipv4;

	params->rt_metric = res.fi->fib_priority;
@@ -4752,7 +4752,7 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
	if (f6i->fib6_nh.fib_nh_lws)
		return BPF_FIB_LKUP_RET_UNSUPP_LWT;

	if (f6i->fib6_nh.fib_nh_has_gw)
	if (f6i->fib6_nh.fib_nh_gw_family)
		*dst = f6i->fib6_nh.fib_nh_gw6;

	dev = f6i->fib6_nh.fib_nh_dev;
Loading