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

Commit 725d1e1b authored by David S. Miller's avatar David S. Miller
Browse files

ipv4: Attach FIB info to dst_default_metrics when possible



If there are no explicit metrics attached to a route, hook
fi->fib_info up to dst_default_metrics.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9c150e82
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ struct dst_entry {
#ifdef __KERNEL__

extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
extern const u32 dst_default_metrics[RTAX_MAX];

#define DST_METRICS_READ_ONLY	0x1UL
#define __DST_METRICS_PTR(Y)	\
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ int dst_discard(struct sk_buff *skb)
}
EXPORT_SYMBOL(dst_discard);

static const u32 dst_default_metrics[RTAX_MAX];
const u32 dst_default_metrics[RTAX_MAX];

void *dst_alloc(struct dst_ops *ops)
{
+8 −4
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ static void free_fib_info_rcu(struct rcu_head *head)
{
	struct fib_info *fi = container_of(head, struct fib_info, rcu);

	if (fi->fib_metrics != (u32 *) dst_default_metrics)
		kfree(fi->fib_metrics);
	kfree(fi);
}
@@ -743,9 +744,12 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
	fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
	if (fi == NULL)
		goto failure;
	if (cfg->fc_mx) {
		fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL);
		if (!fi->fib_metrics)
			goto failure;
	} else
		fi->fib_metrics = (u32 *) dst_default_metrics;
	fib_info_cnt++;

	fi->fib_net = hold_net(net);