Commit b75ed8b1 authored by David Ahern's avatar David Ahern Committed by David S. Miller

ipv4: Rename fib_nh entries

Rename fib_nh entries that will be moved to a fib_nh_common struct.
Specifically, the device, oif, gateway, flags, scope, lwtstate,
nh_weight and nh_upper_bound are common with all nexthop definitions.
In the process shorten fib_nh_lwtstate to fib_nh_lws to avoid really
long lines.

Rename only; no functional change intended.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 572bf4dd
...@@ -122,7 +122,7 @@ static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev, ...@@ -122,7 +122,7 @@ static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev,
/* Handle add/replace event */ /* Handle add/replace event */
if (fi->fib_nhs == 1) { if (fi->fib_nhs == 1) {
if (__mlx5_lag_is_active(ldev)) { if (__mlx5_lag_is_active(ldev)) {
struct net_device *nh_dev = fi->fib_nh[0].nh_dev; struct net_device *nh_dev = fi->fib_nh[0].fib_nh_dev;
int i = mlx5_lag_dev_get_netdev_idx(ldev, nh_dev); int i = mlx5_lag_dev_get_netdev_idx(ldev, nh_dev);
mlx5_lag_set_port_affinity(ldev, ++i); mlx5_lag_set_port_affinity(ldev, ++i);
...@@ -134,10 +134,10 @@ static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev, ...@@ -134,10 +134,10 @@ static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev,
return; return;
/* Verify next hops are ports of the same hca */ /* Verify next hops are ports of the same hca */
if (!(fi->fib_nh[0].nh_dev == ldev->pf[0].netdev && if (!(fi->fib_nh[0].fib_nh_dev == ldev->pf[0].netdev &&
fi->fib_nh[1].nh_dev == ldev->pf[1].netdev) && fi->fib_nh[1].fib_nh_dev == ldev->pf[1].netdev) &&
!(fi->fib_nh[0].nh_dev == ldev->pf[1].netdev && !(fi->fib_nh[0].fib_nh_dev == ldev->pf[1].netdev &&
fi->fib_nh[1].nh_dev == ldev->pf[0].netdev)) { fi->fib_nh[1].fib_nh_dev == ldev->pf[0].netdev)) {
mlx5_core_warn(ldev->pf[0].dev, "Multipath offload require two ports of the same HCA\n"); mlx5_core_warn(ldev->pf[0].dev, "Multipath offload require two ports of the same HCA\n");
return; return;
} }
...@@ -167,7 +167,7 @@ static void mlx5_lag_fib_nexthop_event(struct mlx5_lag *ldev, ...@@ -167,7 +167,7 @@ static void mlx5_lag_fib_nexthop_event(struct mlx5_lag *ldev,
/* nh added/removed */ /* nh added/removed */
if (event == FIB_EVENT_NH_DEL) { if (event == FIB_EVENT_NH_DEL) {
int i = mlx5_lag_dev_get_netdev_idx(ldev, fib_nh->nh_dev); int i = mlx5_lag_dev_get_netdev_idx(ldev, fib_nh->fib_nh_dev);
if (i >= 0) { if (i >= 0) {
i = (i + 1) % 2 + 1; /* peer port */ i = (i + 1) % 2 + 1; /* peer port */
......
...@@ -3610,7 +3610,7 @@ static bool mlxsw_sp_nexthop4_ipip_type(const struct mlxsw_sp *mlxsw_sp, ...@@ -3610,7 +3610,7 @@ static bool mlxsw_sp_nexthop4_ipip_type(const struct mlxsw_sp *mlxsw_sp,
const struct fib_nh *fib_nh, const struct fib_nh *fib_nh,
enum mlxsw_sp_ipip_type *p_ipipt) enum mlxsw_sp_ipip_type *p_ipipt)
{ {
struct net_device *dev = fib_nh->nh_dev; struct net_device *dev = fib_nh->fib_nh_dev;
return dev && return dev &&
fib_nh->nh_parent->fib_type == RTN_UNICAST && fib_nh->nh_parent->fib_type == RTN_UNICAST &&
...@@ -3637,7 +3637,7 @@ static int mlxsw_sp_nexthop4_type_init(struct mlxsw_sp *mlxsw_sp, ...@@ -3637,7 +3637,7 @@ static int mlxsw_sp_nexthop4_type_init(struct mlxsw_sp *mlxsw_sp,
struct fib_nh *fib_nh) struct fib_nh *fib_nh)
{ {
const struct mlxsw_sp_ipip_ops *ipip_ops; const struct mlxsw_sp_ipip_ops *ipip_ops;
struct net_device *dev = fib_nh->nh_dev; struct net_device *dev = fib_nh->fib_nh_dev;
struct mlxsw_sp_ipip_entry *ipip_entry; struct mlxsw_sp_ipip_entry *ipip_entry;
struct mlxsw_sp_rif *rif; struct mlxsw_sp_rif *rif;
int err; int err;
...@@ -3681,18 +3681,18 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp, ...@@ -3681,18 +3681,18 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_nexthop *nh, struct mlxsw_sp_nexthop *nh,
struct fib_nh *fib_nh) struct fib_nh *fib_nh)
{ {
struct net_device *dev = fib_nh->nh_dev; struct net_device *dev = fib_nh->fib_nh_dev;
struct in_device *in_dev; struct in_device *in_dev;
int err; int err;
nh->nh_grp = nh_grp; nh->nh_grp = nh_grp;
nh->key.fib_nh = fib_nh; nh->key.fib_nh = fib_nh;
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
nh->nh_weight = fib_nh->nh_weight; nh->nh_weight = fib_nh->fib_nh_weight;
#else #else
nh->nh_weight = 1; nh->nh_weight = 1;
#endif #endif
memcpy(&nh->gw_addr, &fib_nh->nh_gw, sizeof(fib_nh->nh_gw)); memcpy(&nh->gw_addr, &fib_nh->fib_nh_gw4, sizeof(fib_nh->fib_nh_gw4));
err = mlxsw_sp_nexthop_insert(mlxsw_sp, nh); err = mlxsw_sp_nexthop_insert(mlxsw_sp, nh);
if (err) if (err)
return err; return err;
...@@ -3705,7 +3705,7 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp, ...@@ -3705,7 +3705,7 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp,
in_dev = __in_dev_get_rtnl(dev); in_dev = __in_dev_get_rtnl(dev);
if (in_dev && IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) && if (in_dev && IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) &&
fib_nh->nh_flags & RTNH_F_LINKDOWN) fib_nh->fib_nh_flags & RTNH_F_LINKDOWN)
return 0; return 0;
err = mlxsw_sp_nexthop4_type_init(mlxsw_sp, nh, fib_nh); err = mlxsw_sp_nexthop4_type_init(mlxsw_sp, nh, fib_nh);
...@@ -3804,7 +3804,7 @@ static void mlxsw_sp_nexthop_rif_gone_sync(struct mlxsw_sp *mlxsw_sp, ...@@ -3804,7 +3804,7 @@ static void mlxsw_sp_nexthop_rif_gone_sync(struct mlxsw_sp *mlxsw_sp,
static bool mlxsw_sp_fi_is_gateway(const struct mlxsw_sp *mlxsw_sp, static bool mlxsw_sp_fi_is_gateway(const struct mlxsw_sp *mlxsw_sp,
const struct fib_info *fi) const struct fib_info *fi)
{ {
return fi->fib_nh->nh_scope == RT_SCOPE_LINK || return fi->fib_nh->fib_nh_scope == RT_SCOPE_LINK ||
mlxsw_sp_nexthop4_ipip_type(mlxsw_sp, fi->fib_nh, NULL); mlxsw_sp_nexthop4_ipip_type(mlxsw_sp, fi->fib_nh, NULL);
} }
...@@ -3966,7 +3966,7 @@ mlxsw_sp_fib4_entry_offload_set(struct mlxsw_sp_fib_entry *fib_entry) ...@@ -3966,7 +3966,7 @@ mlxsw_sp_fib4_entry_offload_set(struct mlxsw_sp_fib_entry *fib_entry)
fib_entry->type == MLXSW_SP_FIB_ENTRY_TYPE_BLACKHOLE || fib_entry->type == MLXSW_SP_FIB_ENTRY_TYPE_BLACKHOLE ||
fib_entry->type == MLXSW_SP_FIB_ENTRY_TYPE_IPIP_DECAP || fib_entry->type == MLXSW_SP_FIB_ENTRY_TYPE_IPIP_DECAP ||
fib_entry->type == MLXSW_SP_FIB_ENTRY_TYPE_NVE_DECAP) { fib_entry->type == MLXSW_SP_FIB_ENTRY_TYPE_NVE_DECAP) {
nh_grp->nexthops->key.fib_nh->nh_flags |= RTNH_F_OFFLOAD; nh_grp->nexthops->key.fib_nh->fib_nh_flags |= RTNH_F_OFFLOAD;
return; return;
} }
...@@ -3974,9 +3974,9 @@ mlxsw_sp_fib4_entry_offload_set(struct mlxsw_sp_fib_entry *fib_entry) ...@@ -3974,9 +3974,9 @@ mlxsw_sp_fib4_entry_offload_set(struct mlxsw_sp_fib_entry *fib_entry)
struct mlxsw_sp_nexthop *nh = &nh_grp->nexthops[i]; struct mlxsw_sp_nexthop *nh = &nh_grp->nexthops[i];
if (nh->offloaded) if (nh->offloaded)
nh->key.fib_nh->nh_flags |= RTNH_F_OFFLOAD; nh->key.fib_nh->fib_nh_flags |= RTNH_F_OFFLOAD;
else else
nh->key.fib_nh->nh_flags &= ~RTNH_F_OFFLOAD; nh->key.fib_nh->fib_nh_flags &= ~RTNH_F_OFFLOAD;
} }
} }
...@@ -3992,7 +3992,7 @@ mlxsw_sp_fib4_entry_offload_unset(struct mlxsw_sp_fib_entry *fib_entry) ...@@ -3992,7 +3992,7 @@ mlxsw_sp_fib4_entry_offload_unset(struct mlxsw_sp_fib_entry *fib_entry)
for (i = 0; i < nh_grp->count; i++) { for (i = 0; i < nh_grp->count; i++) {
struct mlxsw_sp_nexthop *nh = &nh_grp->nexthops[i]; struct mlxsw_sp_nexthop *nh = &nh_grp->nexthops[i];
nh->key.fib_nh->nh_flags &= ~RTNH_F_OFFLOAD; nh->key.fib_nh->fib_nh_flags &= ~RTNH_F_OFFLOAD;
} }
} }
......
...@@ -2288,11 +2288,11 @@ static int ofdpa_port_fib_ipv4(struct ofdpa_port *ofdpa_port, __be32 dst, ...@@ -2288,11 +2288,11 @@ static int ofdpa_port_fib_ipv4(struct ofdpa_port *ofdpa_port, __be32 dst,
nh = fi->fib_nh; nh = fi->fib_nh;
nh_on_port = (fi->fib_dev == ofdpa_port->dev); nh_on_port = (fi->fib_dev == ofdpa_port->dev);
has_gw = !!nh->nh_gw; has_gw = !!nh->fib_nh_gw4;
if (has_gw && nh_on_port) { if (has_gw && nh_on_port) {
err = ofdpa_port_ipv4_nh(ofdpa_port, flags, err = ofdpa_port_ipv4_nh(ofdpa_port, flags,
nh->nh_gw, &index); nh->fib_nh_gw4, &index);
if (err) if (err)
return err; return err;
...@@ -2749,7 +2749,7 @@ static int ofdpa_fib4_add(struct rocker *rocker, ...@@ -2749,7 +2749,7 @@ static int ofdpa_fib4_add(struct rocker *rocker,
fen_info->tb_id, 0); fen_info->tb_id, 0);
if (err) if (err)
return err; return err;
fen_info->fi->fib_nh->nh_flags |= RTNH_F_OFFLOAD; fen_info->fi->fib_nh->fib_nh_flags |= RTNH_F_OFFLOAD;
return 0; return 0;
} }
...@@ -2764,7 +2764,7 @@ static int ofdpa_fib4_del(struct rocker *rocker, ...@@ -2764,7 +2764,7 @@ static int ofdpa_fib4_del(struct rocker *rocker,
ofdpa_port = ofdpa_port_dev_lower_find(fen_info->fi->fib_dev, rocker); ofdpa_port = ofdpa_port_dev_lower_find(fen_info->fi->fib_dev, rocker);
if (!ofdpa_port) if (!ofdpa_port)
return 0; return 0;
fen_info->fi->fib_nh->nh_flags &= ~RTNH_F_OFFLOAD; fen_info->fi->fib_nh->fib_nh_flags &= ~RTNH_F_OFFLOAD;
return ofdpa_port_fib_ipv4(ofdpa_port, htonl(fen_info->dst), return ofdpa_port_fib_ipv4(ofdpa_port, htonl(fen_info->dst),
fen_info->dst_len, fen_info->fi, fen_info->dst_len, fen_info->fi,
fen_info->tb_id, OFDPA_OP_FLAG_REMOVE); fen_info->tb_id, OFDPA_OP_FLAG_REMOVE);
...@@ -2791,7 +2791,7 @@ static void ofdpa_fib4_abort(struct rocker *rocker) ...@@ -2791,7 +2791,7 @@ static void ofdpa_fib4_abort(struct rocker *rocker)
rocker); rocker);
if (!ofdpa_port) if (!ofdpa_port)
continue; continue;
flow_entry->fi->fib_nh->nh_flags &= ~RTNH_F_OFFLOAD; flow_entry->fi->fib_nh->fib_nh_flags &= ~RTNH_F_OFFLOAD;
ofdpa_flow_tbl_del(ofdpa_port, OFDPA_OP_FLAG_REMOVE, ofdpa_flow_tbl_del(ofdpa_port, OFDPA_OP_FLAG_REMOVE,
flow_entry); flow_entry);
} }
......
...@@ -77,26 +77,26 @@ struct fnhe_hash_bucket { ...@@ -77,26 +77,26 @@ struct fnhe_hash_bucket {
#define FNHE_RECLAIM_DEPTH 5 #define FNHE_RECLAIM_DEPTH 5
struct fib_nh { struct fib_nh {
struct net_device *nh_dev; struct net_device *fib_nh_dev;
struct hlist_node nh_hash; struct hlist_node nh_hash;
struct fib_info *nh_parent; struct fib_info *nh_parent;
unsigned int nh_flags; unsigned int fib_nh_flags;
unsigned char nh_scope; unsigned char fib_nh_scope;
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
int nh_weight; int fib_nh_weight;
atomic_t nh_upper_bound; atomic_t fib_nh_upper_bound;
#endif #endif
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
__u32 nh_tclassid; __u32 nh_tclassid;
#endif #endif
int nh_oif; int fib_nh_oif;
__be32 nh_gw; __be32 fib_nh_gw4;
__be32 nh_saddr; __be32 nh_saddr;
int nh_saddr_genid; int nh_saddr_genid;
struct rtable __rcu * __percpu *nh_pcpu_rth_output; struct rtable __rcu * __percpu *nh_pcpu_rth_output;
struct rtable __rcu *nh_rth_input; struct rtable __rcu *nh_rth_input;
struct fnhe_hash_bucket __rcu *nh_exceptions; struct fnhe_hash_bucket __rcu *nh_exceptions;
struct lwtunnel_state *nh_lwtstate; struct lwtunnel_state *fib_nh_lws;
}; };
/* /*
...@@ -125,7 +125,7 @@ struct fib_info { ...@@ -125,7 +125,7 @@ struct fib_info {
int fib_nhs; int fib_nhs;
struct rcu_head rcu; struct rcu_head rcu;
struct fib_nh fib_nh[0]; struct fib_nh fib_nh[0];
#define fib_dev fib_nh[0].nh_dev #define fib_dev fib_nh[0].fib_nh_dev
}; };
...@@ -180,9 +180,9 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh); ...@@ -180,9 +180,9 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
atomic_read(&(net)->ipv4.dev_addr_genid)) ? \ atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
FIB_RES_NH(res).nh_saddr : \ FIB_RES_NH(res).nh_saddr : \
fib_info_update_nh_saddr((net), &FIB_RES_NH(res))) fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
#define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw) #define FIB_RES_GW(res) (FIB_RES_NH(res).fib_nh_gw4)
#define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev) #define FIB_RES_DEV(res) (FIB_RES_NH(res).fib_nh_dev)
#define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif) #define FIB_RES_OIF(res) (FIB_RES_NH(res).fib_nh_oif)
#define FIB_RES_PREFSRC(net, res) ((res).fi->fib_prefsrc ? : \ #define FIB_RES_PREFSRC(net, res) ((res).fi->fib_prefsrc ? : \
FIB_RES_SADDR(net, res)) FIB_RES_SADDR(net, res))
......
...@@ -63,13 +63,16 @@ TRACE_EVENT(fib_table_lookup, ...@@ -63,13 +63,16 @@ TRACE_EVENT(fib_table_lookup,
} }
if (nh) { if (nh) {
struct net_device *dev;
p32 = (__be32 *) __entry->saddr; p32 = (__be32 *) __entry->saddr;
*p32 = nh->nh_saddr; *p32 = nh->nh_saddr;
p32 = (__be32 *) __entry->gw; p32 = (__be32 *) __entry->gw;
*p32 = nh->nh_gw; *p32 = nh->fib_nh_gw4;
__assign_str(name, nh->nh_dev ? nh->nh_dev->name : "-"); dev = nh->fib_nh_dev;
__assign_str(name, dev ? dev->name : "-");
} else { } else {
p32 = (__be32 *) __entry->saddr; p32 = (__be32 *) __entry->saddr;
*p32 = 0; *p32 = 0;
......
...@@ -4634,12 +4634,12 @@ static int bpf_ipv4_fib_lookup(struct net *net, struct bpf_fib_lookup *params, ...@@ -4634,12 +4634,12 @@ static int bpf_ipv4_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
nh = &res.fi->fib_nh[res.nh_sel]; nh = &res.fi->fib_nh[res.nh_sel];
/* do not handle lwt encaps right now */ /* do not handle lwt encaps right now */
if (nh->nh_lwtstate) if (nh->fib_nh_lws)
return BPF_FIB_LKUP_RET_UNSUPP_LWT; return BPF_FIB_LKUP_RET_UNSUPP_LWT;
dev = nh->nh_dev; dev = nh->fib_nh_dev;
if (nh->nh_gw) if (nh->fib_nh_gw4)
params->ipv4_dst = nh->nh_gw; params->ipv4_dst = nh->fib_nh_gw4;
params->rt_metric = res.fi->fib_priority; params->rt_metric = res.fi->fib_priority;
......
...@@ -324,16 +324,16 @@ bool fib_info_nh_uses_dev(struct fib_info *fi, const struct net_device *dev) ...@@ -324,16 +324,16 @@ bool fib_info_nh_uses_dev(struct fib_info *fi, const struct net_device *dev)
for (ret = 0; ret < fi->fib_nhs; ret++) { for (ret = 0; ret < fi->fib_nhs; ret++) {
struct fib_nh *nh = &fi->fib_nh[ret]; struct fib_nh *nh = &fi->fib_nh[ret];
if (nh->nh_dev == dev) { if (nh->fib_nh_dev == dev) {
dev_match = true; dev_match = true;
break; break;
} else if (l3mdev_master_ifindex_rcu(nh->nh_dev) == dev->ifindex) { } else if (l3mdev_master_ifindex_rcu(nh->fib_nh_dev) == dev->ifindex) {
dev_match = true; dev_match = true;
break; break;
} }
} }
#else #else
if (fi->fib_nh[0].nh_dev == dev) if (fi->fib_nh[0].fib_nh_dev == dev)
dev_match = true; dev_match = true;
#endif #endif
...@@ -390,7 +390,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, ...@@ -390,7 +390,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
dev_match = fib_info_nh_uses_dev(res.fi, dev); dev_match = fib_info_nh_uses_dev(res.fi, dev);
if (dev_match) { if (dev_match) {
ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST; ret = FIB_RES_NH(res).fib_nh_scope >= RT_SCOPE_HOST;
return ret; return ret;
} }
if (no_addr) if (no_addr)
...@@ -402,7 +402,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, ...@@ -402,7 +402,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
ret = 0; ret = 0;
if (fib_lookup(net, &fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE) == 0) { if (fib_lookup(net, &fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE) == 0) {
if (res.type == RTN_UNICAST) if (res.type == RTN_UNICAST)
ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST; ret = FIB_RES_NH(res).fib_nh_scope >= RT_SCOPE_HOST;
} }
return ret; return ret;
......
...@@ -210,10 +210,10 @@ void fib_nh_release(struct net *net, struct fib_nh *fib_nh) ...@@ -210,10 +210,10 @@ void fib_nh_release(struct net *net, struct fib_nh *fib_nh)
if (fib_nh->nh_tclassid) if (fib_nh->nh_tclassid)
net->ipv4.fib_num_tclassid_users--; net->ipv4.fib_num_tclassid_users--;
#endif #endif
if (fib_nh->nh_dev) if (fib_nh->fib_nh_dev)
dev_put(fib_nh->nh_dev); dev_put(fib_nh->fib_nh_dev);
lwtstate_put(fib_nh->nh_lwtstate); lwtstate_put(fib_nh->fib_nh_lws);
free_nh_exceptions(fib_nh); free_nh_exceptions(fib_nh);
rt_fibinfo_free_cpus(fib_nh->nh_pcpu_rth_output); rt_fibinfo_free_cpus(fib_nh->nh_pcpu_rth_output);
rt_fibinfo_free(&fib_nh->nh_rth_input); rt_fibinfo_free(&fib_nh->nh_rth_input);
...@@ -253,7 +253,7 @@ void fib_release_info(struct fib_info *fi) ...@@ -253,7 +253,7 @@ void fib_release_info(struct fib_info *fi)
if (fi->fib_prefsrc) if (fi->fib_prefsrc)
hlist_del(&fi->fib_lhash); hlist_del(&fi->fib_lhash);
change_nexthops(fi) { change_nexthops(fi) {
if (!nexthop_nh->nh_dev) if (!nexthop_nh->fib_nh_dev)
continue; continue;
hlist_del(&nexthop_nh->nh_hash); hlist_del(&nexthop_nh->nh_hash);
} endfor_nexthops(fi) } endfor_nexthops(fi)
...@@ -268,17 +268,17 @@ static inline int nh_comp(const struct fib_info *fi, const struct fib_info *ofi) ...@@ -268,17 +268,17 @@ static inline int nh_comp(const struct fib_info *fi, const struct fib_info *ofi)
const struct fib_nh *onh = ofi->fib_nh; const struct fib_nh *onh = ofi->fib_nh;
for_nexthops(fi) { for_nexthops(fi) {
if (nh->nh_oif != onh->nh_oif || if (nh->fib_nh_oif != onh->fib_nh_oif ||
nh->nh_gw != onh->nh_gw || nh->fib_nh_gw4 != onh->fib_nh_gw4 ||
nh->nh_scope != onh->nh_scope || nh->fib_nh_scope != onh->fib_nh_scope ||
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
nh->nh_weight != onh->nh_weight || nh->fib_nh_weight != onh->fib_nh_weight ||
#endif #endif
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
nh->nh_tclassid != onh->nh_tclassid || nh->nh_tclassid != onh->nh_tclassid ||
#endif #endif
lwtunnel_cmp_encap(nh->nh_lwtstate, onh->nh_lwtstate) || lwtunnel_cmp_encap(nh->fib_nh_lws, onh->fib_nh_lws) ||
((nh->nh_flags ^ onh->nh_flags) & ~RTNH_COMPARE_MASK)) ((nh->fib_nh_flags ^ onh->fib_nh_flags) & ~RTNH_COMPARE_MASK))
return -1; return -1;
onh++; onh++;
} endfor_nexthops(fi); } endfor_nexthops(fi);
...@@ -303,7 +303,7 @@ static inline unsigned int fib_info_hashfn(const struct fib_info *fi) ...@@ -303,7 +303,7 @@ static inline unsigned int fib_info_hashfn(const struct fib_info *fi)
val ^= (__force u32)fi->fib_prefsrc; val ^= (__force u32)fi->fib_prefsrc;
val ^= fi->fib_priority; val ^= fi->fib_priority;
for_nexthops(fi) { for_nexthops(fi) {
val ^= fib_devindex_hashfn(nh->nh_oif); val ^= fib_devindex_hashfn(nh->fib_nh_oif);
} endfor_nexthops(fi) } endfor_nexthops(fi)
return (val ^ (val >> 7) ^ (val >> 12)) & mask; return (val ^ (val >> 7) ^ (val >> 12)) & mask;
...@@ -352,9 +352,9 @@ int ip_fib_check_default(__be32 gw, struct net_device *dev) ...@@ -352,9 +352,9 @@ int ip_fib_check_default(__be32 gw, struct net_device *dev)
hash = fib_devindex_hashfn(dev->ifindex); hash = fib_devindex_hashfn(dev->ifindex);
head = &fib_info_devhash[hash]; head = &fib_info_devhash[hash];
hlist_for_each_entry(nh, head, nh_hash) { hlist_for_each_entry(nh, head, nh_hash) {
if (nh->nh_dev == dev && if (nh->fib_nh_dev == dev &&
nh->nh_gw == gw && nh->fib_nh_gw4 == gw &&
!(nh->nh_flags & RTNH_F_DEAD)) { !(nh->fib_nh_flags & RTNH_F_DEAD)) {
spin_unlock(&fib_info_lock); spin_unlock(&fib_info_lock);
return 0; return 0;
} }
...@@ -389,10 +389,10 @@ static inline size_t fib_nlmsg_size(struct fib_info *fi) ...@@ -389,10 +389,10 @@ static inline size_t fib_nlmsg_size(struct fib_info *fi)
/* grab encap info */ /* grab encap info */
for_nexthops(fi) { for_nexthops(fi) {
if (nh->nh_lwtstate) { if (nh->fib_nh_lws) {
/* RTA_ENCAP_TYPE */ /* RTA_ENCAP_TYPE */
nh_encapsize += lwtunnel_get_encap_size( nh_encapsize += lwtunnel_get_encap_size(
nh->nh_lwtstate); nh->fib_nh_lws);
/* RTA_ENCAP */ /* RTA_ENCAP */
nh_encapsize += nla_total_size(2); nh_encapsize += nla_total_size(2);
} }
...@@ -443,7 +443,7 @@ static int fib_detect_death(struct fib_info *fi, int order, ...@@ -443,7 +443,7 @@ static int fib_detect_death(struct fib_info *fi, int order,
struct neighbour *n; struct neighbour *n;
int state = NUD_NONE; int state = NUD_NONE;
n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].nh_gw, fi->fib_dev); n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].fib_nh_gw4, fi->fib_dev);
if (n) { if (n) {
state = n->nud_state; state = n->nud_state;
neigh_release(n); neigh_release(n);
...@@ -486,12 +486,12 @@ int fib_nh_init(struct net *net, struct fib_nh *nh, ...@@ -486,12 +486,12 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
if (err) if (err)
goto lwt_failure; goto lwt_failure;
nh->nh_lwtstate = lwtstate_get(lwtstate); nh->fib_nh_lws = lwtstate_get(lwtstate);
} }
nh->nh_oif = cfg->fc_oif; nh->fib_nh_oif = cfg->fc_oif;
nh->nh_gw = cfg->fc_gw; nh->fib_nh_gw4 = cfg->fc_gw;
nh->nh_flags = cfg->fc_flags; nh->fib_nh_flags = cfg->fc_flags;
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
nh->nh_tclassid = cfg->fc_flow; nh->nh_tclassid = cfg->fc_flow;
...@@ -499,7 +499,7 @@ int fib_nh_init(struct net *net, struct fib_nh *nh, ...@@ -499,7 +499,7 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
net->ipv4.fib_num_tclassid_users++; net->ipv4.fib_num_tclassid_users++;
#endif #endif
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
nh->nh_weight = nh_weight; nh->fib_nh_weight = nh_weight;
#endif #endif
return 0; return 0;
...@@ -587,12 +587,12 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, ...@@ -587,12 +587,12 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
} endfor_nexthops(fi); } endfor_nexthops(fi);
ret = -EINVAL; ret = -EINVAL;
if (cfg->fc_oif && fi->fib_nh->nh_oif != cfg->fc_oif) { if (cfg->fc_oif && fi->fib_nh->fib_nh_oif != cfg->fc_oif) {
NL_SET_ERR_MSG(extack, NL_SET_ERR_MSG(extack,
"Nexthop device index does not match RTA_OIF"); "Nexthop device index does not match RTA_OIF");
goto errout; goto errout;
} }
if (cfg->fc_gw && fi->fib_nh->nh_gw != cfg->fc_gw) { if (cfg->fc_gw && fi->fib_nh->fib_nh_gw4 != cfg->fc_gw) {
NL_SET_ERR_MSG(extack, NL_SET_ERR_MSG(extack,
"Nexthop gateway does not match RTA_GATEWAY"); "Nexthop gateway does not match RTA_GATEWAY");
goto errout; goto errout;
...@@ -619,32 +619,32 @@ static void fib_rebalance(struct fib_info *fi) ...@@ -619,32 +619,32 @@ static void fib_rebalance(struct fib_info *fi)
total = 0; total = 0;
for_nexthops(fi) { for_nexthops(fi) {
if (nh->nh_flags & RTNH_F_DEAD) if (nh->fib_nh_flags & RTNH_F_DEAD)
continue; continue;
if (ip_ignore_linkdown(nh->nh_dev) && if (ip_ignore_linkdown(nh->fib_nh_dev) &&
nh->nh_flags & RTNH_F_LINKDOWN) nh->fib_nh_flags & RTNH_F_LINKDOWN)
continue; continue;
total += nh->nh_weight; total += nh->fib_nh_weight;
} endfor_nexthops(fi); } endfor_nexthops(fi);
w = 0; w = 0;
change_nexthops(fi) { change_nexthops(fi) {
int upper_bound; int upper_bound;
if (nexthop_nh->nh_flags & RTNH_F_DEAD) { if (nexthop_nh->fib_nh_flags & RTNH_F_DEAD) {
upper_bound = -1; upper_bound = -1;
} else if (ip_ignore_linkdown(nexthop_nh->nh_dev) && } else if (ip_ignore_linkdown(nexthop_nh->fib_nh_dev) &&
nexthop_nh->nh_flags & RTNH_F_LINKDOWN) { nexthop_nh->fib_nh_flags & RTNH_F_LINKDOWN) {
upper_bound = -1; upper_bound = -1;
} else { } else {
w += nexthop_nh->nh_weight; w += nexthop_nh->fib_nh_weight;
upper_bound = DIV_ROUND_CLOSEST_ULL((u64)w << 31, upper_bound = DIV_ROUND_CLOSEST_ULL((u64)w << 31,
total) - 1; total) - 1;
} }
atomic_set(&nexthop_nh->nh_upper_bound, upper_bound); atomic_set(&nexthop_nh->fib_nh_upper_bound, upper_bound);
} endfor_nexthops(fi); } endfor_nexthops(fi);
} }
#else /* CONFIG_IP_ROUTE_MULTIPATH */ #else /* CONFIG_IP_ROUTE_MULTIPATH */
...@@ -677,7 +677,7 @@ static int fib_encap_match(u16 encap_type, ...@@ -677,7 +677,7 @@ static int fib_encap_match(u16 encap_type,
ret = lwtunnel_build_state(encap_type, encap, AF_INET, ret = lwtunnel_build_state(encap_type, encap, AF_INET,
cfg, &lwtstate, extack); cfg, &lwtstate, extack);
if (!ret) { if (!ret) {
result = lwtunnel_cmp_encap(lwtstate, nh->nh_lwtstate); result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws);
lwtstate_free(lwtstate); lwtstate_free(lwtstate);
} }
...@@ -706,8 +706,8 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, ...@@ -706,8 +706,8 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
cfg->fc_flow != fi->fib_nh->nh_tclassid) cfg->fc_flow != fi->fib_nh->nh_tclassid)
return 1; return 1;
#endif #endif
if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->nh_oif) && if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->fib_nh_oif) &&
(!cfg->fc_gw || cfg->fc_gw == fi->fib_nh->nh_gw)) (!cfg->fc_gw || cfg->fc_gw == fi->fib_nh->fib_nh_gw4))
return 0; return 0;
return 1; return 1;
} }
...@@ -725,7 +725,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, ...@@ -725,7 +725,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
if (!rtnh_ok(rtnh, remaining)) if (!rtnh_ok(rtnh, remaining))
return -EINVAL; return -EINVAL;
if (rtnh->rtnh_ifindex && rtnh->rtnh_ifindex != nh->nh_oif) if (rtnh->rtnh_ifindex && rtnh->rtnh_ifindex != nh->fib_nh_oif)
return 1; return 1;
attrlen = rtnh_attrlen(rtnh); attrlen = rtnh_attrlen(rtnh);
...@@ -733,7 +733,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, ...@@ -733,7 +733,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
struct nlattr *nla, *attrs = rtnh_attrs(rtnh); struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
nla = nla_find(attrs, attrlen, RTA_GATEWAY); nla = nla_find(attrs, attrlen, RTA_GATEWAY);
if (nla && nla_get_in_addr(nla) != nh->nh_gw) if (nla && nla_get_in_addr(nla) != nh->fib_nh_gw4)
return 1; return 1;
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
nla = nla_find(attrs, attrlen, RTA_FLOW); nla = nla_find(attrs, attrlen, RTA_FLOW);
...@@ -840,10 +840,10 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh, ...@@ -840,10 +840,10 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh,
struct net_device *dev; struct net_device *dev;
net = cfg->fc_nlinfo.nl_net; net = cfg->fc_nlinfo.nl_net;
if (nh->nh_gw) { if (nh->fib_nh_gw4) {
struct fib_result res; struct fib_result res;
if (nh->nh_flags & RTNH_F_ONLINK) { if (nh->fib_nh_flags & RTNH_F_ONLINK) {
unsigned int addr_type; unsigned int addr_type;
if (cfg->fc_scope >= RT_SCOPE_LINK) { if (cfg->fc_scope >= RT_SCOPE_LINK) {
...@@ -851,7 +851,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh, ...@@ -851,7 +851,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh,
"Nexthop has invalid scope"); "Nexthop has invalid scope");
return -EINVAL; return -EINVAL;
} }
dev = __dev_get_by_index(net, nh->nh_oif); dev = __dev_get_by_index(net, nh->fib_nh_oif);
if (!dev) { if (!dev) {
NL_SET_ERR_MSG(extack, "Nexthop device required for onlink"); NL_SET_ERR_MSG(extack, "Nexthop device required for onlink");
return -ENODEV; return -ENODEV;
...@@ -861,26 +861,27 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh, ...@@ -861,26 +861,27 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh,
"Nexthop device is not up"); "Nexthop device is not up");
return -ENETDOWN; return -ENETDOWN;
} }
addr_type = inet_addr_type_dev_table(net, dev, nh->nh_gw); addr_type = inet_addr_type_dev_table(net, dev,
nh->fib_nh_gw4);
if (addr_type != RTN_UNICAST) { if (addr_type != RTN_UNICAST) {
NL_SET_ERR_MSG(extack, NL_SET_ERR_MSG(extack,
"Nexthop has invalid gateway"); "Nexthop has invalid gateway");
return -EINVAL; return -EINVAL;
} }
if (!netif_carrier_ok(dev)) if (!netif_carrier_ok(dev))
nh->nh_flags |= RTNH_F_LINKDOWN; nh->fib_nh_flags |= RTNH_F_LINKDOWN;
nh->nh_dev = dev; nh->fib_nh_dev = dev;
dev_hold(dev); dev_hold(dev);
nh->nh_scope = RT_SCOPE_LINK; nh->fib_nh_scope = RT_SCOPE_LINK;
return 0; return 0;
} }
rcu_read_lock(); rcu_read_lock();
{ {
struct fib_table *tbl = NULL; struct fib_table *tbl = NULL;
struct flowi4 fl4 = { struct flowi4 fl4 = {
.daddr = nh->nh_gw, .daddr = nh->fib_nh_gw4,
.flowi4_scope = cfg->fc_scope + 1, .flowi4_scope = cfg->fc_scope + 1,
.flowi4_oif = nh->nh_oif, .flowi4_oif = nh->fib_nh_oif,
.flowi4_iif = LOOPBACK_IFINDEX, .flowi4_iif = LOOPBACK_IFINDEX,
}; };
...@@ -917,9 +918,9 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh, ...@@ -917,9 +918,9 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh,
NL_SET_ERR_MSG(extack, "Nexthop has invalid gateway"); NL_SET_ERR_MSG(extack, "Nexthop has invalid gateway");
goto out; goto out;
} }
nh->nh_scope = res.scope; nh->fib_nh_scope = res.scope;
nh->nh_oif = FIB_RES_OIF(res); nh->fib_nh_oif = FIB_RES_OIF(res);
nh->nh_dev = dev = FIB_RES_DEV(res); nh->fib_nh_dev = dev = FIB_RES_DEV(res);
if (!dev) { if (!dev) {
NL_SET_ERR_MSG(extack, NL_SET_ERR_MSG(extack,
"No egress device for nexthop gateway"); "No egress device for nexthop gateway");
...@@ -927,19 +928,19 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh, ...@@ -927,19 +928,19 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh,
} }
dev_hold(dev); dev_hold(dev);
if (!netif_carrier_ok(dev)) if (!netif_carrier_ok(dev))
nh->nh_flags |= RTNH_F_LINKDOWN; nh->fib_nh_flags |= RTNH_F_LINKDOWN;
err = (dev->flags & IFF_UP) ? 0 : -ENETDOWN; err = (dev->flags & IFF_UP) ? 0 : -ENETDOWN;
} else { } else {
struct in_device *in_dev; struct in_device *in_dev;
if (nh->nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) { if (nh->fib_nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) {
NL_SET_ERR_MSG(extack, NL_SET_ERR_MSG(extack,
"Invalid flags for nexthop - PERVASIVE and ONLINK can not be set"); "Invalid flags for nexthop - PERVASIVE and ONLINK can not be set");
return -EINVAL; return -EINVAL;
} }
rcu_read_lock(); rcu_read_lock();
err = -ENODEV; err = -ENODEV;
in_dev = inetdev_by_index(net, nh->nh_oif); in_dev = inetdev_by_index(net, nh->fib_nh_oif);
if (!in_dev) if (!in_dev)
goto out; goto out;
err = -ENETDOWN; err = -ENETDOWN;
...@@ -947,11 +948,11 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh, ...@@ -947,11 +948,11 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh,
NL_SET_ERR_MSG(extack, "Device for nexthop is not up"); NL_SET_ERR_MSG(extack, "Device for nexthop is not up");
goto out; goto out;
} }
nh->nh_dev = in_dev->dev; nh->fib_nh_dev = in_dev->dev;
dev_hold(nh->nh_dev); dev_hold(nh->fib_nh_dev);
nh->nh_scope = RT_SCOPE_HOST; nh->fib_nh_scope = RT_SCOPE_HOST;
if (!netif_carrier_ok(nh->nh_dev)) if (!netif_carrier_ok(nh->fib_nh_dev))
nh->nh_flags |= RTNH_F_LINKDOWN; nh->fib_nh_flags |= RTNH_F_LINKDOWN;
err = 0; err = 0;
} }
out: out:
...@@ -1043,8 +1044,8 @@ static void fib_info_hash_move(struct hlist_head *new_info_hash, ...@@ -1043,8 +1044,8 @@ static void fib_info_hash_move(struct hlist_head *new_info_hash,
__be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh) __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
{ {
nh->nh_saddr = inet_select_addr(nh->nh_dev, nh->nh_saddr = inet_select_addr(nh->fib_nh_dev,
nh->nh_gw, nh->fib_nh_gw4,
nh->nh_parent->fib_scope); nh->nh_parent->fib_scope);
nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid); nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
...@@ -1198,15 +1199,15 @@ struct fib_info *fib_create_info(struct fib_config *cfg, ...@@ -1198,15 +1199,15 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
"Route with host scope can not have multiple nexthops"); "Route with host scope can not have multiple nexthops");
goto err_inval; goto err_inval;
} }
if (nh->nh_gw) { if (nh->fib_nh_gw4) {
NL_SET_ERR_MSG(extack, NL_SET_ERR_MSG(extack,
"Route with host scope can not have a gateway"); "Route with host scope can not have a gateway");
goto err_inval; goto err_inval;
} }
nh->nh_scope = RT_SCOPE_NOWHERE; nh->fib_nh_scope = RT_SCOPE_NOWHERE;
nh->nh_dev = dev_get_by_index(net, fi->fib_nh->nh_oif); nh->fib_nh_dev = dev_get_by_index(net, fi->fib_nh->fib_nh_oif);
err = -ENODEV; err = -ENODEV;
if (!nh->nh_dev) if (!nh->fib_nh_dev)
goto failure; goto failure;
} else { } else {
int linkdown = 0; int linkdown = 0;
...@@ -1215,7 +1216,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, ...@@ -1215,7 +1216,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
err = fib_check_nh(cfg, nexthop_nh, extack); err = fib_check_nh(cfg, nexthop_nh, extack);
if (err != 0) if (err != 0)
goto failure; goto failure;
if (nexthop_nh->nh_flags & RTNH_F_LINKDOWN) if (nexthop_nh->fib_nh_flags & RTNH_F_LINKDOWN)
linkdown++; linkdown++;
} endfor_nexthops(fi) } endfor_nexthops(fi)
if (linkdown == fi->fib_nhs) if (linkdown == fi->fib_nhs)
...@@ -1257,9 +1258,9 @@ struct fib_info *fib_create_info(struct fib_config *cfg, ...@@ -1257,9 +1258,9 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
struct hlist_head *head; struct hlist_head *head;
unsigned int hash; unsigned int hash;
if (!nexthop_nh->nh_dev) if (!nexthop_nh->fib_nh_dev)
continue; continue;
hash = fib_devindex_hashfn(nexthop_nh->nh_dev->ifindex); hash = fib_devindex_hashfn(nexthop_nh->fib_nh_dev->ifindex);
head = &fib_info_devhash[hash]; head = &fib_info_devhash[hash];
hlist_add_head(&nexthop_nh->nh_hash, head); hlist_add_head(&nexthop_nh->nh_hash, head);
} endfor_nexthops(fi) } endfor_nexthops(fi)
...@@ -1318,27 +1319,27 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event, ...@@ -1318,27 +1319,27 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
nla_put_in_addr(skb, RTA_PREFSRC, fi->fib_prefsrc)) nla_put_in_addr(skb, RTA_PREFSRC, fi->fib_prefsrc))
goto nla_put_failure; goto nla_put_failure;
if (fi->fib_nhs == 1) { if (fi->fib_nhs == 1) {
if (fi->fib_nh->nh_gw && if (fi->fib_nh->fib_nh_gw4 &&
nla_put_in_addr(skb, RTA_GATEWAY, fi->fib_nh->nh_gw)) nla_put_in_addr(skb, RTA_GATEWAY, fi->fib_nh->fib_nh_gw4))
goto nla_put_failure; goto nla_put_failure;
if (fi->fib_nh->nh_oif && if (fi->fib_nh->fib_nh_oif &&
nla_put_u32(skb, RTA_OIF, fi->fib_nh->nh_oif)) nla_put_u32(skb, RTA_OIF, fi->fib_nh->fib_nh_oif))
goto nla_put_failure; goto nla_put_failure;
if (fi->fib_nh->nh_flags & RTNH_F_LINKDOWN) { if (fi->fib_nh->fib_nh_flags & RTNH_F_LINKDOWN) {
rcu_read_lock(); rcu_read_lock();
if (ip_ignore_linkdown(fi->fib_nh->nh_dev)) if (ip_ignore_linkdown(fi->fib_nh->fib_nh_dev))
rtm->rtm_flags |= RTNH_F_DEAD; rtm->rtm_flags |= RTNH_F_DEAD;
rcu_read_unlock(); rcu_read_unlock();
} }
if (fi->fib_nh->nh_flags & RTNH_F_OFFLOAD) if (fi->fib_nh->fib_nh_flags & RTNH_F_OFFLOAD)
rtm->rtm_flags |= RTNH_F_OFFLOAD; rtm->rtm_flags |= RTNH_F_OFFLOAD;
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
if (fi->fib_nh[0].nh_tclassid && if (fi->fib_nh[0].nh_tclassid &&
nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid)) nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid))
goto nla_put_failure; goto nla_put_failure;
#endif #endif
if (fi->fib_nh->nh_lwtstate && if (fi->fib_nh->fib_nh_lws &&
lwtunnel_fill_encap(skb, fi->fib_nh->nh_lwtstate) < 0) lwtunnel_fill_encap(skb, fi->fib_nh->fib_nh_lws) < 0)
goto nla_put_failure; goto nla_put_failure;
} }
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
...@@ -1355,26 +1356,26 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event, ...@@ -1355,26 +1356,26 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
if (!rtnh) if (!rtnh)
goto nla_put_failure; goto nla_put_failure;
rtnh->rtnh_flags = nh->nh_flags & 0xFF; rtnh->rtnh_flags = nh->fib_nh_flags & 0xFF;
if (nh->nh_flags & RTNH_F_LINKDOWN) { if (nh->fib_nh_flags & RTNH_F_LINKDOWN) {
rcu_read_lock(); rcu_read_lock();
if (ip_ignore_linkdown(nh->nh_dev)) if (ip_ignore_linkdown(nh->fib_nh_dev))
rtnh->rtnh_flags |= RTNH_F_DEAD; rtnh->rtnh_flags |= RTNH_F_DEAD;
rcu_read_unlock(); rcu_read_unlock();
} }
rtnh->rtnh_hops = nh->nh_weight - 1; rtnh->rtnh_hops = nh->fib_nh_weight - 1;
rtnh->rtnh_ifindex = nh->nh_oif; rtnh->rtnh_ifindex = nh->fib_nh_oif;
if (nh->nh_gw && if (nh->fib_nh_gw4 &&
nla_put_in_addr(skb, RTA_GATEWAY, nh->nh_gw)) nla_put_in_addr(skb, RTA_GATEWAY, nh->fib_nh_gw4))
goto nla_put_failure; goto nla_put_failure;
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
if (nh->nh_tclassid && if (nh->nh_tclassid &&
nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid))
goto nla_put_failure; goto nla_put_failure;
#endif #endif
if (nh->nh_lwtstate && if (nh->fib_nh_lws &&
lwtunnel_fill_encap(skb, nh->nh_lwtstate) < 0) lwtunnel_fill_encap(skb, nh->fib_nh_lws) < 0)
goto nla_put_failure; goto nla_put_failure;
/* length of rtnetlink header + attributes */ /* length of rtnetlink header + attributes */
...@@ -1422,26 +1423,26 @@ int fib_sync_down_addr(struct net_device *dev, __be32 local) ...@@ -1422,26 +1423,26 @@ int fib_sync_down_addr(struct net_device *dev, __be32 local)
return ret; return ret;
} }
static int call_fib_nh_notifiers(struct fib_nh *fib_nh, static int call_fib_nh_notifiers(struct fib_nh *nh,
enum fib_event_type event_type) enum fib_event_type event_type)
{ {
bool ignore_link_down = ip_ignore_linkdown(fib_nh->nh_dev); bool ignore_link_down = ip_ignore_linkdown(nh->fib_nh_dev);
struct fib_nh_notifier_info info = { struct fib_nh_notifier_info info = {
.fib_nh = fib_nh, .fib_nh = nh,
}; };
switch (event_type) { switch (event_type) {
case FIB_EVENT_NH_ADD: case FIB_EVENT_NH_ADD:
if (fib_nh->nh_flags & RTNH_F_DEAD) if (nh->fib_nh_flags & RTNH_F_DEAD)
break; break;
if (ignore_link_down && fib_nh->nh_flags & RTNH_F_LINKDOWN) if (ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN)
break; break;
return call_fib4_notifiers(dev_net(fib_nh->nh_dev), event_type, return call_fib4_notifiers(dev_net(nh->fib_nh_dev), event_type,
&info.info); &info.info);
case FIB_EVENT_NH_DEL: case FIB_EVENT_NH_DEL:
if ((ignore_link_down && fib_nh->nh_flags & RTNH_F_LINKDOWN) || if ((ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) ||
(fib_nh->nh_flags & RTNH_F_DEAD)) (nh->fib_nh_flags & RTNH_F_DEAD))
return call_fib4_notifiers(dev_net(fib_nh->nh_dev), return call_fib4_notifiers(dev_net(nh->fib_nh_dev),
event_type, &info.info); event_type, &info.info);
default: default:
break; break;
...@@ -1495,7 +1496,7 @@ void fib_sync_mtu(struct net_device *dev, u32 orig_mtu) ...@@ -1495,7 +1496,7 @@ void fib_sync_mtu(struct net_device *dev, u32 orig_mtu)
struct fib_nh *nh; struct fib_nh *nh;
hlist_for_each_entry(nh, head, nh_hash) { hlist_for_each_entry(nh, head, nh_hash) {
if (nh->nh_dev == dev) if (nh->fib_nh_dev == dev)
nh_update_mtu(nh, dev->mtu, orig_mtu); nh_update_mtu(nh, dev->mtu, orig_mtu);
} }
} }
...@@ -1523,22 +1524,22 @@ int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force) ...@@ -1523,22 +1524,22 @@ int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force)
int dead; int dead;
BUG_ON(!fi->fib_nhs); BUG_ON(!fi->fib_nhs);
if (nh->nh_dev != dev || fi == prev_fi) if (nh->fib_nh_dev != dev || fi == prev_fi)
continue; continue;
prev_fi = fi; prev_fi = fi;
dead = 0; dead = 0;
change_nexthops(fi) { change_nexthops(fi) {
if (nexthop_nh->nh_flags & RTNH_F_DEAD) if (nexthop_nh->fib_nh_flags & RTNH_F_DEAD)
dead++; dead++;
else if (nexthop_nh->nh_dev == dev && else if (nexthop_nh->fib_nh_dev == dev &&
nexthop_nh->nh_scope != scope) { nexthop_nh->fib_nh_scope != scope) {
switch (event) { switch (event) {
case NETDEV_DOWN: case NETDEV_DOWN:
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
nexthop_nh->nh_flags |= RTNH_F_DEAD; nexthop_nh->fib_nh_flags |= RTNH_F_DEAD;
/* fall through */ /* fall through */
case NETDEV_CHANGE: case NETDEV_CHANGE:
nexthop_nh->nh_flags |= RTNH_F_LINKDOWN; nexthop_nh->fib_nh_flags |= RTNH_F_LINKDOWN;
break; break;
} }
call_fib_nh_notifiers(nexthop_nh, call_fib_nh_notifiers(nexthop_nh,
...@@ -1547,7 +1548,7 @@ int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force) ...@@ -1547,7 +1548,7 @@ int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force)
} }
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
if (event == NETDEV_UNREGISTER && if (event == NETDEV_UNREGISTER &&
nexthop_nh->nh_dev == dev) { nexthop_nh->fib_nh_dev == dev) {
dead = fi->fib_nhs; dead = fi->fib_nhs;
break; break;
} }
...@@ -1607,8 +1608,8 @@ static void fib_select_default(const struct flowi4 *flp, struct fib_result *res) ...@@ -1607,8 +1608,8 @@ static void fib_select_default(const struct flowi4 *flp, struct fib_result *res)
if (next_fi->fib_scope != res->scope || if (next_fi->fib_scope != res->scope ||
fa->fa_type != RTN_UNICAST) fa->fa_type != RTN_UNICAST)
continue; continue;
if (!next_fi->fib_nh[0].nh_gw || if (!next_fi->fib_nh[0].fib_nh_gw4 ||
next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK) next_fi->fib_nh[0].fib_nh_scope != RT_SCOPE_LINK)
continue; continue;
fib_alias_accessed(fa); fib_alias_accessed(fa);
...@@ -1679,24 +1680,24 @@ int fib_sync_up(struct net_device *dev, unsigned int nh_flags) ...@@ -1679,24 +1680,24 @@ int fib_sync_up(struct net_device *dev, unsigned int nh_flags)
int alive; int alive;
BUG_ON(!fi->fib_nhs); BUG_ON(!fi->fib_nhs);
if (nh->nh_dev != dev || fi == prev_fi) if (nh->fib_nh_dev != dev || fi == prev_fi)
continue; continue;
prev_fi = fi; prev_fi = fi;
alive = 0; alive = 0;
change_nexthops(fi) { change_nexthops(fi) {
if (!(nexthop_nh->nh_flags & nh_flags)) { if (!(nexthop_nh->fib_nh_flags & nh_flags)) {
alive++; alive++;
continue; continue;
} }
if (!nexthop_nh->nh_dev || if (!nexthop_nh->fib_nh_dev ||
!(nexthop_nh->nh_dev->flags & IFF_UP)) !(nexthop_nh->fib_nh_dev->flags & IFF_UP))
continue; continue;
if (nexthop_nh->nh_dev != dev || if (nexthop_nh->fib_nh_dev != dev ||
!__in_dev_get_rtnl(dev)) !__in_dev_get_rtnl(dev))
continue; continue;
alive++; alive++;
nexthop_nh->nh_flags &= ~nh_flags; nexthop_nh->fib_nh_flags &= ~nh_flags;
call_fib_nh_notifiers(nexthop_nh, FIB_EVENT_NH_ADD); call_fib_nh_notifiers(nexthop_nh, FIB_EVENT_NH_ADD);
} endfor_nexthops(fi) } endfor_nexthops(fi)
...@@ -1716,13 +1717,13 @@ static bool fib_good_nh(const struct fib_nh *nh) ...@@ -1716,13 +1717,13 @@ static bool fib_good_nh(const struct fib_nh *nh)
{ {
int state = NUD_REACHABLE; int state = NUD_REACHABLE;
if (nh->nh_scope == RT_SCOPE_LINK) { if (nh->fib_nh_scope == RT_SCOPE_LINK) {
struct neighbour *n; struct neighbour *n;
rcu_read_lock_bh(); rcu_read_lock_bh();
n = __ipv4_neigh_lookup_noref(nh->nh_dev, n = __ipv4_neigh_lookup_noref(nh->fib_nh_dev,
(__force u32)nh->nh_gw); (__force u32)nh->fib_nh_gw4);
if (n) if (n)
state = n->nud_state; state = n->nud_state;
...@@ -1748,7 +1749,7 @@ void fib_select_multipath(struct fib_result *res, int hash) ...@@ -1748,7 +1749,7 @@ void fib_select_multipath(struct fib_result *res, int hash)
} }
} }
if (hash > atomic_read(&nh->nh_upper_bound)) if (hash > atomic_read(&nh->fib_nh_upper_bound))
continue; continue;
res->nh_sel = nhsel; res->nh_sel = nhsel;
......
...@@ -1472,15 +1472,15 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, ...@@ -1472,15 +1472,15 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
for (nhsel = 0; nhsel < fi->fib_nhs; nhsel++) { for (nhsel = 0; nhsel < fi->fib_nhs; nhsel++) {
const struct fib_nh *nh = &fi->fib_nh[nhsel]; const struct fib_nh *nh = &fi->fib_nh[nhsel];
if (nh->nh_flags & RTNH_F_DEAD) if (nh->fib_nh_flags & RTNH_F_DEAD)
continue; continue;
if (ip_ignore_linkdown(nh->nh_dev) && if (ip_ignore_linkdown(nh->fib_nh_dev) &&
nh->nh_flags & RTNH_F_LINKDOWN && nh->fib_nh_flags & RTNH_F_LINKDOWN &&
!(fib_flags & FIB_LOOKUP_IGNORE_LINKSTATE)) !(fib_flags & FIB_LOOKUP_IGNORE_LINKSTATE))
continue; continue;
if (!(flp->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF)) { if (!(flp->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF)) {
if (flp->flowi4_oif && if (flp->flowi4_oif &&
flp->flowi4_oif != nh->nh_oif) flp->flowi4_oif != nh->fib_nh_oif)
continue; continue;
} }
...@@ -2651,7 +2651,7 @@ static unsigned int fib_flag_trans(int type, __be32 mask, const struct fib_info ...@@ -2651,7 +2651,7 @@ static unsigned int fib_flag_trans(int type, __be32 mask, const struct fib_info
if (type == RTN_UNREACHABLE || type == RTN_PROHIBIT) if (type == RTN_UNREACHABLE || type == RTN_PROHIBIT)
flags = RTF_REJECT; flags = RTF_REJECT;
if (fi && fi->fib_nh->nh_gw) if (fi && fi->fib_nh->fib_nh_gw4)
flags |= RTF_GATEWAY; flags |= RTF_GATEWAY;
if (mask == htonl(0xFFFFFFFF)) if (mask == htonl(0xFFFFFFFF))
flags |= RTF_HOST; flags |= RTF_HOST;
...@@ -2702,7 +2702,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) ...@@ -2702,7 +2702,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
"%d\t%08X\t%d\t%u\t%u", "%d\t%08X\t%d\t%u\t%u",
fi->fib_dev ? fi->fib_dev->name : "*", fi->fib_dev ? fi->fib_dev->name : "*",
prefix, prefix,
fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_nh->fib_nh_gw4, flags, 0, 0,
fi->fib_priority, fi->fib_priority,
mask, mask,
(fi->fib_advmss ? (fi->fib_advmss ?
......
...@@ -644,7 +644,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, ...@@ -644,7 +644,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
unsigned int i; unsigned int i;
int depth; int depth;
genid = fnhe_genid(dev_net(nh->nh_dev)); genid = fnhe_genid(dev_net(nh->fib_nh_dev));
hval = fnhe_hashfun(daddr); hval = fnhe_hashfun(daddr);
spin_lock_bh(&fnhe_lock); spin_lock_bh(&fnhe_lock);
...@@ -1356,7 +1356,7 @@ u32 ip_mtu_from_fib_result(struct fib_result *res, __be32 daddr) ...@@ -1356,7 +1356,7 @@ u32 ip_mtu_from_fib_result(struct fib_result *res, __be32 daddr)
{ {
struct fib_info *fi = res->fi; struct fib_info *fi = res->fi;
struct fib_nh *nh = &fi->fib_nh[res->nh_sel]; struct fib_nh *nh = &fi->fib_nh[res->nh_sel];
struct net_device *dev = nh->nh_dev; struct net_device *dev = nh->fib_nh_dev;
u32 mtu = 0; u32 mtu = 0;
if (dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu || if (dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu ||
...@@ -1374,7 +1374,7 @@ u32 ip_mtu_from_fib_result(struct fib_result *res, __be32 daddr) ...@@ -1374,7 +1374,7 @@ u32 ip_mtu_from_fib_result(struct fib_result *res, __be32 daddr)
if (likely(!mtu)) if (likely(!mtu))
mtu = min(READ_ONCE(dev->mtu), IP_MAX_MTU); mtu = min(READ_ONCE(dev->mtu), IP_MAX_MTU);
return mtu - lwtunnel_headroom(nh->nh_lwtstate, mtu); return mtu - lwtunnel_headroom(nh->fib_nh_lws, mtu);
} }
static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
...@@ -1531,8 +1531,8 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr, ...@@ -1531,8 +1531,8 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr,
if (fi) { if (fi) {
struct fib_nh *nh = &FIB_RES_NH(*res); struct fib_nh *nh = &FIB_RES_NH(*res);
if (nh->nh_gw && nh->nh_scope == RT_SCOPE_LINK) { if (nh->fib_nh_gw4 && nh->fib_nh_scope == RT_SCOPE_LINK) {
rt->rt_gateway = nh->nh_gw; rt->rt_gateway = nh->fib_nh_gw4;
rt->rt_uses_gateway = 1; rt->rt_uses_gateway = 1;
} }
ip_dst_init_metrics(&rt->dst, fi->fib_metrics); ip_dst_init_metrics(&rt->dst, fi->fib_metrics);
...@@ -1540,7 +1540,7 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr, ...@@ -1540,7 +1540,7 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr,
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
rt->dst.tclassid = nh->nh_tclassid; rt->dst.tclassid = nh->nh_tclassid;
#endif #endif
rt->dst.lwtstate = lwtstate_get(nh->nh_lwtstate); rt->dst.lwtstate = lwtstate_get(nh->fib_nh_lws);
if (unlikely(fnhe)) if (unlikely(fnhe))
cached = rt_bind_exception(rt, fnhe, daddr, do_cache); cached = rt_bind_exception(rt, fnhe, daddr, do_cache);
else if (do_cache) else if (do_cache)
...@@ -2075,7 +2075,7 @@ out: return err; ...@@ -2075,7 +2075,7 @@ out: return err;
if (do_cache) { if (do_cache) {
struct fib_nh *nh = &FIB_RES_NH(*res); struct fib_nh *nh = &FIB_RES_NH(*res);
rth->dst.lwtstate = lwtstate_get(nh->nh_lwtstate); rth->dst.lwtstate = lwtstate_get(nh->fib_nh_lws);
if (lwtunnel_input_redirect(rth->dst.lwtstate)) { if (lwtunnel_input_redirect(rth->dst.lwtstate)) {
WARN_ON(rth->dst.input == lwtunnel_input); WARN_ON(rth->dst.input == lwtunnel_input);
rth->dst.lwtstate->orig_input = rth->dst.input; rth->dst.lwtstate->orig_input = rth->dst.input;
...@@ -2264,8 +2264,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res, ...@@ -2264,8 +2264,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
} else { } else {
if (unlikely(fl4->flowi4_flags & if (unlikely(fl4->flowi4_flags &
FLOWI_FLAG_KNOWN_NH && FLOWI_FLAG_KNOWN_NH &&
!(nh->nh_gw && !(nh->fib_nh_gw4 &&
nh->nh_scope == RT_SCOPE_LINK))) { nh->fib_nh_scope == RT_SCOPE_LINK))) {
do_cache = false; do_cache = false;
goto add; goto add;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment