Skip to content

Commit 3f4fe75

Browse files
committed
Merge branch 'ipv6-followup-to-fib6_info-change'
David Ahern says: ==================== net/ipv6: followup to fib6_info change Followup to fib change for IPv6. First 2 patches rename fib6_info struct elements to match its name, and rename addrconf_dst_alloc to match what it returns. Patches 3-7 refactor the code to remove the need for fib6_idev reducing fib6_info by another 8 bytes to 200 bytes. Patch 8 fixes the gfp flags argument to addrconf_prefix_route in a couple of places. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 88078d9 + 27b1060 commit 3f4fe75

File tree

9 files changed

+375
-369
lines changed

9 files changed

+375
-369
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4705,17 +4705,17 @@ static bool mlxsw_sp_fib6_rt_should_ignore(const struct fib6_info *rt)
47054705
* are trapped to the CPU, so no need to program specific routes
47064706
* for them.
47074707
*/
4708-
if (ipv6_addr_type(&rt->rt6i_dst.addr) & IPV6_ADDR_LINKLOCAL)
4708+
if (ipv6_addr_type(&rt->fib6_dst.addr) & IPV6_ADDR_LINKLOCAL)
47094709
return true;
47104710

47114711
/* Multicast routes aren't supported, so ignore them. Neighbour
47124712
* Discovery packets are specifically trapped.
47134713
*/
4714-
if (ipv6_addr_type(&rt->rt6i_dst.addr) & IPV6_ADDR_MULTICAST)
4714+
if (ipv6_addr_type(&rt->fib6_dst.addr) & IPV6_ADDR_MULTICAST)
47154715
return true;
47164716

47174717
/* Cloned routes are irrelevant in the forwarding path. */
4718-
if (rt->rt6i_flags & RTF_CACHE)
4718+
if (rt->fib6_flags & RTF_CACHE)
47194719
return true;
47204720

47214721
return false;
@@ -4759,7 +4759,7 @@ static void mlxsw_sp_rt6_destroy(struct mlxsw_sp_rt6 *mlxsw_sp_rt6)
47594759
static bool mlxsw_sp_fib6_rt_can_mp(const struct fib6_info *rt)
47604760
{
47614761
/* RTF_CACHE routes are ignored */
4762-
return (rt->rt6i_flags & (RTF_GATEWAY | RTF_ADDRCONF)) == RTF_GATEWAY;
4762+
return (rt->fib6_flags & (RTF_GATEWAY | RTF_ADDRCONF)) == RTF_GATEWAY;
47634763
}
47644764

47654765
static struct fib6_info *
@@ -4784,16 +4784,16 @@ mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
47844784
/* RT6_TABLE_LOCAL and RT6_TABLE_MAIN share the same
47854785
* virtual router.
47864786
*/
4787-
if (rt->rt6i_table->tb6_id > nrt->rt6i_table->tb6_id)
4787+
if (rt->fib6_table->tb6_id > nrt->fib6_table->tb6_id)
47884788
continue;
4789-
if (rt->rt6i_table->tb6_id != nrt->rt6i_table->tb6_id)
4789+
if (rt->fib6_table->tb6_id != nrt->fib6_table->tb6_id)
47904790
break;
4791-
if (rt->rt6i_metric < nrt->rt6i_metric)
4791+
if (rt->fib6_metric < nrt->fib6_metric)
47924792
continue;
4793-
if (rt->rt6i_metric == nrt->rt6i_metric &&
4793+
if (rt->fib6_metric == nrt->fib6_metric &&
47944794
mlxsw_sp_fib6_rt_can_mp(rt))
47954795
return fib6_entry;
4796-
if (rt->rt6i_metric > nrt->rt6i_metric)
4796+
if (rt->fib6_metric > nrt->fib6_metric)
47974797
break;
47984798
}
47994799

@@ -4899,7 +4899,7 @@ static void mlxsw_sp_nexthop6_fini(struct mlxsw_sp *mlxsw_sp,
48994899
static bool mlxsw_sp_rt6_is_gateway(const struct mlxsw_sp *mlxsw_sp,
49004900
const struct fib6_info *rt)
49014901
{
4902-
return rt->rt6i_flags & RTF_GATEWAY ||
4902+
return rt->fib6_flags & RTF_GATEWAY ||
49034903
mlxsw_sp_nexthop6_ipip_type(mlxsw_sp, rt, NULL);
49044904
}
49054905

@@ -5092,9 +5092,9 @@ static void mlxsw_sp_fib6_entry_type_set(struct mlxsw_sp *mlxsw_sp,
50925092
* local, which will cause them to be trapped with a lower
50935093
* priority than packets that need to be locally received.
50945094
*/
5095-
if (rt->rt6i_flags & (RTF_LOCAL | RTF_ANYCAST))
5095+
if (rt->fib6_flags & (RTF_LOCAL | RTF_ANYCAST))
50965096
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_TRAP;
5097-
else if (rt->rt6i_flags & RTF_REJECT)
5097+
else if (rt->fib6_flags & RTF_REJECT)
50985098
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_LOCAL;
50995099
else if (mlxsw_sp_rt6_is_gateway(mlxsw_sp, rt))
51005100
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_REMOTE;
@@ -5175,18 +5175,18 @@ mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node,
51755175
list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
51765176
struct fib6_info *rt = mlxsw_sp_fib6_entry_rt(fib6_entry);
51775177

5178-
if (rt->rt6i_table->tb6_id > nrt->rt6i_table->tb6_id)
5178+
if (rt->fib6_table->tb6_id > nrt->fib6_table->tb6_id)
51795179
continue;
5180-
if (rt->rt6i_table->tb6_id != nrt->rt6i_table->tb6_id)
5180+
if (rt->fib6_table->tb6_id != nrt->fib6_table->tb6_id)
51815181
break;
5182-
if (replace && rt->rt6i_metric == nrt->rt6i_metric) {
5182+
if (replace && rt->fib6_metric == nrt->fib6_metric) {
51835183
if (mlxsw_sp_fib6_rt_can_mp(rt) ==
51845184
mlxsw_sp_fib6_rt_can_mp(nrt))
51855185
return fib6_entry;
51865186
if (mlxsw_sp_fib6_rt_can_mp(nrt))
51875187
fallback = fallback ?: fib6_entry;
51885188
}
5189-
if (rt->rt6i_metric > nrt->rt6i_metric)
5189+
if (rt->fib6_metric > nrt->fib6_metric)
51905190
return fallback ?: fib6_entry;
51915191
}
51925192

@@ -5215,7 +5215,7 @@ mlxsw_sp_fib6_node_list_insert(struct mlxsw_sp_fib6_entry *new6_entry,
52155215
list_for_each_entry(last, &fib_node->entry_list, common.list) {
52165216
struct fib6_info *rt = mlxsw_sp_fib6_entry_rt(last);
52175217

5218-
if (nrt->rt6i_table->tb6_id > rt->rt6i_table->tb6_id)
5218+
if (nrt->fib6_table->tb6_id > rt->fib6_table->tb6_id)
52195219
break;
52205220
fib6_entry = last;
52215221
}
@@ -5275,22 +5275,22 @@ mlxsw_sp_fib6_entry_lookup(struct mlxsw_sp *mlxsw_sp,
52755275
struct mlxsw_sp_fib *fib;
52765276
struct mlxsw_sp_vr *vr;
52775277

5278-
vr = mlxsw_sp_vr_find(mlxsw_sp, rt->rt6i_table->tb6_id);
5278+
vr = mlxsw_sp_vr_find(mlxsw_sp, rt->fib6_table->tb6_id);
52795279
if (!vr)
52805280
return NULL;
52815281
fib = mlxsw_sp_vr_fib(vr, MLXSW_SP_L3_PROTO_IPV6);
52825282

5283-
fib_node = mlxsw_sp_fib_node_lookup(fib, &rt->rt6i_dst.addr,
5284-
sizeof(rt->rt6i_dst.addr),
5285-
rt->rt6i_dst.plen);
5283+
fib_node = mlxsw_sp_fib_node_lookup(fib, &rt->fib6_dst.addr,
5284+
sizeof(rt->fib6_dst.addr),
5285+
rt->fib6_dst.plen);
52865286
if (!fib_node)
52875287
return NULL;
52885288

52895289
list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
52905290
struct fib6_info *iter_rt = mlxsw_sp_fib6_entry_rt(fib6_entry);
52915291

5292-
if (rt->rt6i_table->tb6_id == iter_rt->rt6i_table->tb6_id &&
5293-
rt->rt6i_metric == iter_rt->rt6i_metric &&
5292+
if (rt->fib6_table->tb6_id == iter_rt->fib6_table->tb6_id &&
5293+
rt->fib6_metric == iter_rt->fib6_metric &&
52945294
mlxsw_sp_fib6_entry_rt_find(fib6_entry, rt))
52955295
return fib6_entry;
52965296
}
@@ -5325,16 +5325,16 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
53255325
if (mlxsw_sp->router->aborted)
53265326
return 0;
53275327

5328-
if (rt->rt6i_src.plen)
5328+
if (rt->fib6_src.plen)
53295329
return -EINVAL;
53305330

53315331
if (mlxsw_sp_fib6_rt_should_ignore(rt))
53325332
return 0;
53335333

5334-
fib_node = mlxsw_sp_fib_node_get(mlxsw_sp, rt->rt6i_table->tb6_id,
5335-
&rt->rt6i_dst.addr,
5336-
sizeof(rt->rt6i_dst.addr),
5337-
rt->rt6i_dst.plen,
5334+
fib_node = mlxsw_sp_fib_node_get(mlxsw_sp, rt->fib6_table->tb6_id,
5335+
&rt->fib6_dst.addr,
5336+
sizeof(rt->fib6_dst.addr),
5337+
rt->fib6_dst.plen,
53385338
MLXSW_SP_L3_PROTO_IPV6);
53395339
if (IS_ERR(fib_node))
53405340
return PTR_ERR(fib_node);

include/net/if_inet6.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ struct ipv6_ac_socklist {
143143

144144
struct ifacaddr6 {
145145
struct in6_addr aca_addr;
146-
struct inet6_dev *aca_idev;
147146
struct fib6_info *aca_rt;
148147
struct ifacaddr6 *aca_next;
149148
int aca_users;

include/net/ip6_fib.h

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,34 +134,33 @@ struct fib6_nh {
134134
};
135135

136136
struct fib6_info {
137-
struct fib6_table *rt6i_table;
137+
struct fib6_table *fib6_table;
138138
struct fib6_info __rcu *rt6_next;
139-
struct fib6_node __rcu *rt6i_node;
139+
struct fib6_node __rcu *fib6_node;
140140

141141
/* Multipath routes:
142142
* siblings is a list of fib6_info that have the the same metric/weight,
143143
* destination, but not the same gateway. nsiblings is just a cache
144144
* to speed up lookup.
145145
*/
146-
struct list_head rt6i_siblings;
147-
unsigned int rt6i_nsiblings;
146+
struct list_head fib6_siblings;
147+
unsigned int fib6_nsiblings;
148148

149-
atomic_t rt6i_ref;
150-
struct inet6_dev *rt6i_idev;
149+
atomic_t fib6_ref;
151150
unsigned long expires;
152151
struct dst_metrics *fib6_metrics;
153152
#define fib6_pmtu fib6_metrics->metrics[RTAX_MTU-1]
154153

155-
struct rt6key rt6i_dst;
156-
u32 rt6i_flags;
157-
struct rt6key rt6i_src;
158-
struct rt6key rt6i_prefsrc;
154+
struct rt6key fib6_dst;
155+
u32 fib6_flags;
156+
struct rt6key fib6_src;
157+
struct rt6key fib6_prefsrc;
159158

160159
struct rt6_info * __percpu *rt6i_pcpu;
161160
struct rt6_exception_bucket __rcu *rt6i_exception_bucket;
162161

163-
u32 rt6i_metric;
164-
u8 rt6i_protocol;
162+
u32 fib6_metric;
163+
u8 fib6_protocol;
165164
u8 fib6_type;
166165
u8 exception_bucket_flushed:1,
167166
should_flush:1,
@@ -206,20 +205,20 @@ static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
206205

207206
static inline void fib6_clean_expires(struct fib6_info *f6i)
208207
{
209-
f6i->rt6i_flags &= ~RTF_EXPIRES;
208+
f6i->fib6_flags &= ~RTF_EXPIRES;
210209
f6i->expires = 0;
211210
}
212211

213212
static inline void fib6_set_expires(struct fib6_info *f6i,
214213
unsigned long expires)
215214
{
216215
f6i->expires = expires;
217-
f6i->rt6i_flags |= RTF_EXPIRES;
216+
f6i->fib6_flags |= RTF_EXPIRES;
218217
}
219218

220219
static inline bool fib6_check_expired(const struct fib6_info *f6i)
221220
{
222-
if (f6i->rt6i_flags & RTF_EXPIRES)
221+
if (f6i->fib6_flags & RTF_EXPIRES)
223222
return time_after(jiffies, f6i->expires);
224223
return false;
225224
}
@@ -250,14 +249,14 @@ static inline void rt6_update_expires(struct rt6_info *rt0, int timeout)
250249
* Return true if we can get cookie safely
251250
* Return false if not
252251
*/
253-
static inline bool rt6_get_cookie_safe(const struct fib6_info *rt,
252+
static inline bool rt6_get_cookie_safe(const struct fib6_info *f6i,
254253
u32 *cookie)
255254
{
256255
struct fib6_node *fn;
257256
bool status = false;
258257

259258
rcu_read_lock();
260-
fn = rcu_dereference(rt->rt6i_node);
259+
fn = rcu_dereference(f6i->fib6_node);
261260

262261
if (fn) {
263262
*cookie = fn->fn_sernum;
@@ -295,12 +294,12 @@ void fib6_info_destroy(struct fib6_info *f6i);
295294

296295
static inline void fib6_info_hold(struct fib6_info *f6i)
297296
{
298-
atomic_inc(&f6i->rt6i_ref);
297+
atomic_inc(&f6i->fib6_ref);
299298
}
300299

301300
static inline void fib6_info_release(struct fib6_info *f6i)
302301
{
303-
if (f6i && atomic_dec_and_test(&f6i->rt6i_ref))
302+
if (f6i && atomic_dec_and_test(&f6i->fib6_ref))
304303
fib6_info_destroy(f6i);
305304
}
306305

@@ -410,6 +409,11 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,
410409
struct nl_info *info, struct netlink_ext_ack *extack);
411410
int fib6_del(struct fib6_info *rt, struct nl_info *info);
412411

412+
static inline struct net_device *fib6_info_nh_dev(const struct fib6_info *f6i)
413+
{
414+
return f6i->fib6_nh.nh_dev;
415+
}
416+
413417
void inet6_rt_notify(int event, struct fib6_info *rt, struct nl_info *info,
414418
unsigned int flags);
415419

include/net/ip6_route.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ static inline bool rt6_need_strict(const struct in6_addr *daddr)
6666
(IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK);
6767
}
6868

69-
static inline bool rt6_qualify_for_ecmp(const struct fib6_info *rt)
69+
static inline bool rt6_qualify_for_ecmp(const struct fib6_info *f6i)
7070
{
71-
return (rt->rt6i_flags & (RTF_GATEWAY|RTF_ADDRCONF|RTF_DYNAMIC)) ==
71+
return (f6i->fib6_flags & (RTF_GATEWAY|RTF_ADDRCONF|RTF_DYNAMIC)) ==
7272
RTF_GATEWAY;
7373
}
7474

@@ -102,26 +102,27 @@ int ipv6_route_ioctl(struct net *net, unsigned int cmd, void __user *arg);
102102

103103
int ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags,
104104
struct netlink_ext_ack *extack);
105-
int ip6_ins_rt(struct net *net, struct fib6_info *rt);
106-
int ip6_del_rt(struct net *net, struct fib6_info *rt);
105+
int ip6_ins_rt(struct net *net, struct fib6_info *f6i);
106+
int ip6_del_rt(struct net *net, struct fib6_info *f6i);
107107

108-
void rt6_flush_exceptions(struct fib6_info *rt);
109-
void rt6_age_exceptions(struct fib6_info *rt, struct fib6_gc_args *gc_args,
108+
void rt6_flush_exceptions(struct fib6_info *f6i);
109+
void rt6_age_exceptions(struct fib6_info *f6i, struct fib6_gc_args *gc_args,
110110
unsigned long now);
111111

112-
static inline int ip6_route_get_saddr(struct net *net, struct fib6_info *rt,
112+
static inline int ip6_route_get_saddr(struct net *net, struct fib6_info *f6i,
113113
const struct in6_addr *daddr,
114114
unsigned int prefs,
115115
struct in6_addr *saddr)
116116
{
117-
struct inet6_dev *idev = rt ? rt->rt6i_idev : NULL;
118117
int err = 0;
119118

120-
if (rt && rt->rt6i_prefsrc.plen)
121-
*saddr = rt->rt6i_prefsrc.addr;
122-
else
123-
err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
124-
daddr, prefs, saddr);
119+
if (f6i && f6i->fib6_prefsrc.plen) {
120+
*saddr = f6i->fib6_prefsrc.addr;
121+
} else {
122+
struct net_device *dev = f6i ? fib6_info_nh_dev(f6i) : NULL;
123+
124+
err = ipv6_dev_get_saddr(net, dev, daddr, prefs, saddr);
125+
}
125126

126127
return err;
127128
}
@@ -136,7 +137,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev, struct flowi6 *fl6);
136137

137138
void fib6_force_start_gc(struct net *net);
138139

139-
struct fib6_info *addrconf_dst_alloc(struct net *net, struct inet6_dev *idev,
140+
struct fib6_info *addrconf_f6i_alloc(struct net *net, struct inet6_dev *idev,
140141
const struct in6_addr *addr, bool anycast,
141142
gfp_t gfp_flags);
142143

@@ -176,14 +177,14 @@ struct rt6_rtnl_dump_arg {
176177
struct net *net;
177178
};
178179

179-
int rt6_dump_route(struct fib6_info *rt, void *p_arg);
180+
int rt6_dump_route(struct fib6_info *f6i, void *p_arg);
180181
void rt6_mtu_change(struct net_device *dev, unsigned int mtu);
181182
void rt6_remove_prefsrc(struct inet6_ifaddr *ifp);
182183
void rt6_clean_tohost(struct net *net, struct in6_addr *gateway);
183184
void rt6_sync_up(struct net_device *dev, unsigned int nh_flags);
184185
void rt6_disable_ip(struct net_device *dev, unsigned long event);
185186
void rt6_sync_down_dev(struct net_device *dev, unsigned long event);
186-
void rt6_multipath_rebalance(struct fib6_info *rt);
187+
void rt6_multipath_rebalance(struct fib6_info *f6i);
187188

188189
void rt6_uncached_list_add(struct rt6_info *rt);
189190
void rt6_uncached_list_del(struct rt6_info *rt);
@@ -274,7 +275,6 @@ static inline struct in6_addr *rt6_nexthop(struct rt6_info *rt,
274275
static inline bool rt6_duplicate_nexthop(struct fib6_info *a, struct fib6_info *b)
275276
{
276277
return a->fib6_nh.nh_dev == b->fib6_nh.nh_dev &&
277-
a->rt6i_idev == b->rt6i_idev &&
278278
ipv6_addr_equal(&a->fib6_nh.nh_gw, &b->fib6_nh.nh_gw) &&
279279
!lwtunnel_cmp_encap(a->fib6_nh.nh_lwtstate, b->fib6_nh.nh_lwtstate);
280280
}

0 commit comments

Comments
 (0)