From: David Ahern <dsah...@gmail.com> Remove direct accesses to fi->fib_nh in favor of the helpers added in the previous patch.
Signed-off-by: David Ahern <dsah...@gmail.com> --- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 +++- drivers/net/ethernet/rocker/rocker_ofdpa.c | 20 ++++++++++++++------ include/net/ip_fib.h | 1 - net/ipv4/fib_frontend.c | 3 ++- net/ipv4/fib_rules.c | 3 ++- net/ipv4/fib_semantics.c | 12 ++++++++---- net/ipv4/fib_trie.c | 19 +++++++++++-------- 7 files changed, 40 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 2ab9cf25a08a..3fcac0b6fa92 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -28,6 +28,7 @@ #include <net/ipv6.h> #include <net/fib_notifier.h> #include <net/switchdev.h> +#include <net/nexthop.h> #include "spectrum.h" #include "core.h" @@ -4121,12 +4122,13 @@ mlxsw_sp_fib4_entry_type_set(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fib_entry *fib_entry) { union mlxsw_sp_l3addr dip = { .addr4 = htonl(fen_info->dst) }; - struct net_device *dev = fen_info->fi->fib_dev; struct mlxsw_sp_ipip_entry *ipip_entry; struct fib_info *fi = fen_info->fi; + struct net_device *dev; switch (fen_info->type) { case RTN_LOCAL: + dev = fib_info_nh_dev(fi); ipip_entry = mlxsw_sp_ipip_entry_find_by_decap(mlxsw_sp, dev, MLXSW_SP_L3_PROTO_IPV4, dip); if (ipip_entry && ipip_entry->ol_dev->flags & IFF_UP) { diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c index 6473cc68c2d5..c05d35945ea7 100644 --- a/drivers/net/ethernet/rocker/rocker_ofdpa.c +++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c @@ -23,6 +23,7 @@ #include <net/switchdev.h> #include <net/ip_fib.h> #include <net/arp.h> +#include <net/nexthop.h> #include "rocker.h" #include "rocker_tlv.h" @@ -2286,8 +2287,8 @@ static int ofdpa_port_fib_ipv4(struct ofdpa_port *ofdpa_port, __be32 dst, /* XXX support ECMP */ - nh = fi->fib_nh; - nh_on_port = (fi->fib_dev == ofdpa_port->dev); + nh = fib_info_nh(fi, 0); + nh_on_port = (nh->nh_dev == ofdpa_port->dev); has_gw = !!nh->nh_gw; if (has_gw && nh_on_port) { @@ -2747,11 +2748,13 @@ static int ofdpa_fib4_add(struct rocker *rocker, { struct ofdpa *ofdpa = rocker->wpriv; struct ofdpa_port *ofdpa_port; + struct net_device *dev; int err; if (ofdpa->fib_aborted) return 0; - ofdpa_port = ofdpa_port_dev_lower_find(fen_info->fi->fib_dev, rocker); + dev = fib_info_nh_dev(fen_info->fi); + ofdpa_port = ofdpa_port_dev_lower_find(dev, rocker); if (!ofdpa_port) return 0; err = ofdpa_port_fib_ipv4(ofdpa_port, htonl(fen_info->dst), @@ -2768,10 +2771,12 @@ static int ofdpa_fib4_del(struct rocker *rocker, { struct ofdpa *ofdpa = rocker->wpriv; struct ofdpa_port *ofdpa_port; + struct net_device *dev; if (ofdpa->fib_aborted) return 0; - ofdpa_port = ofdpa_port_dev_lower_find(fen_info->fi->fib_dev, rocker); + dev = fib_info_nh_dev(fen_info->fi); + ofdpa_port = ofdpa_port_dev_lower_find(dev, rocker); if (!ofdpa_port) return 0; fen_info->fi->fib_nh->nh_flags &= ~RTNH_F_OFFLOAD; @@ -2794,11 +2799,14 @@ static void ofdpa_fib4_abort(struct rocker *rocker) spin_lock_irqsave(&ofdpa->flow_tbl_lock, flags); hash_for_each_safe(ofdpa->flow_tbl, bkt, tmp, flow_entry, entry) { + struct net_device *dev; + if (flow_entry->key.tbl_id != ROCKER_OF_DPA_TABLE_ID_UNICAST_ROUTING) continue; - ofdpa_port = ofdpa_port_dev_lower_find(flow_entry->fi->fib_dev, - rocker); + + dev = fib_info_nh_dev(flow_entry->fi); + ofdpa_port = ofdpa_port_dev_lower_find(dev, rocker); if (!ofdpa_port) continue; flow_entry->fi->fib_nh->nh_flags &= ~RTNH_F_OFFLOAD; diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index e39f55f3c3d8..c59e0f1ba59b 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -129,7 +129,6 @@ struct fib_info { int fib_nhs; struct rcu_head rcu; struct fib_nh fib_nh[0]; -#define fib_dev fib_nh[0].nh_dev }; diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index ec6ae186d4b0..c483453bf037 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -35,6 +35,7 @@ #include <linux/init.h> #include <linux/list.h> #include <linux/slab.h> +#include <net/nexthop.h> #include <net/ip.h> #include <net/protocol.h> @@ -234,7 +235,7 @@ static inline unsigned int __inet_dev_addr_type(struct net *net, if (table) { ret = RTN_UNICAST; if (!fib_table_lookup(table, &fl4, &res, FIB_LOOKUP_NOREF)) { - if (!dev || dev == res.fi->fib_dev) + if (!dev || dev == fib_info_nh_dev(res.fi)) ret = res.type; } } diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index f8eb78d042a4..6808883af694 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c @@ -32,6 +32,7 @@ #include <net/tcp.h> #include <net/ip_fib.h> #include <net/fib_rules.h> +#include <net/nexthop.h> struct fib4_rule { struct fib_rule common; @@ -146,7 +147,7 @@ static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg struct net_device *dev = NULL; if (result->fi) - dev = result->fi->fib_dev; + dev = fib_info_nh_dev(result->fi); /* do not accept result if the route does * not meet the required prefix length diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 53e38ecfdd58..0cd536ad1761 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -45,6 +45,7 @@ #include <net/rtnh.h> #include <net/lwtunnel.h> #include <net/fib_notifier.h> +#include <net/nexthop.h> #include "fib_lookup.h" @@ -447,10 +448,11 @@ static int fib_detect_death(struct fib_info *fi, int order, struct fib_info **last_resort, int *last_idx, int dflt) { + struct fib_nh *fnh = fib_info_nh(fi, 0); struct neighbour *n; int state = NUD_NONE; - n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].nh_gw, fi->fib_dev); + n = neigh_lookup(&arp_tbl, &fnh->nh_gw, fnh->nh_dev); if (n) { state = n->nud_state; neigh_release(n); @@ -713,7 +715,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, if (cfg->fc_oif || cfg->fc_gw) { if (cfg->fc_encap) { if (fib_encap_match(cfg->fc_encap_type, cfg->fc_encap, - fi->fib_nh, cfg, extack)) + fib_info_nh(fi, 0), cfg, extack)) return 1; } #ifdef CONFIG_IP_ROUTE_CLASSID @@ -1571,6 +1573,7 @@ static void fib_select_default(const struct flowi4 *flp, struct fib_result *res) hlist_for_each_entry_rcu(fa, fa_head, fa_list) { struct fib_info *next_fi = fa->fa_info; + struct fib_nh *fnh; if (fa->fa_slen != slen) continue; @@ -1592,8 +1595,9 @@ static void fib_select_default(const struct flowi4 *flp, struct fib_result *res) if (next_fi->fib_scope != res->scope || fa->fa_type != RTN_UNICAST) continue; - if (!next_fi->fib_nh[0].nh_gw || - next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK) + + fnh = fib_info_nh(next_fi, 0); + if (!fnh->nh_gw || fnh->nh_scope != RT_SCOPE_LINK) continue; fib_alias_accessed(fa); diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 51e7b38f3a7b..c6aab049a4ac 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -83,6 +83,7 @@ #include <net/sock.h> #include <net/ip_fib.h> #include <net/fib_notifier.h> +#include <net/nexthop.h> #include <trace/events/fib.h> #include "fib_lookup.h" @@ -2621,13 +2622,13 @@ static void fib_route_seq_stop(struct seq_file *seq, void *v) rcu_read_unlock(); } -static unsigned int fib_flag_trans(int type, __be32 mask, const struct fib_info *fi) +static unsigned int fib_flag_trans(int type, __be32 mask, struct fib_info *fi) { unsigned int flags = 0; if (type == RTN_UNREACHABLE || type == RTN_PROHIBIT) flags = RTF_REJECT; - if (fi && fi->fib_nh->nh_gw) + if (fi && fib_info_nh_gw(fi)) flags |= RTF_GATEWAY; if (mask == htonl(0xFFFFFFFF)) flags |= RTF_HOST; @@ -2659,7 +2660,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) prefix = htonl(l->key); hlist_for_each_entry_rcu(fa, &l->leaf, fa_list) { - const struct fib_info *fi = fa->fa_info; + struct fib_info *fi = fa->fa_info; __be32 mask = inet_make_mask(KEYLENGTH - fa->fa_slen); unsigned int flags = fib_flag_trans(fa->fa_type, mask, fi); @@ -2672,26 +2673,28 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) seq_setwidth(seq, 127); - if (fi) + if (fi) { + struct net_device *dev = fib_info_nh_dev(fi); + seq_printf(seq, "%s\t%08X\t%08X\t%04X\t%d\t%u\t" "%d\t%08X\t%d\t%u\t%u", - fi->fib_dev ? fi->fib_dev->name : "*", + dev ? dev->name : "*", prefix, - fi->fib_nh->nh_gw, flags, 0, 0, + fib_info_nh_gw(fi), flags, 0, 0, fi->fib_priority, mask, (fi->fib_advmss ? fi->fib_advmss + 40 : 0), fi->fib_window, fi->fib_rtt >> 3); - else + } else { seq_printf(seq, "*\t%08X\t%08X\t%04X\t%d\t%u\t" "%d\t%08X\t%d\t%u\t%u", prefix, 0, flags, 0, 0, 0, mask, 0, 0, 0); - + } seq_pad(seq, '\n'); } -- 2.11.0