Re: [PATCH net-next,v3 3/9] net: resolve forwarding path from virtual netdevice and HW destination address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 11 Nov 2020 20:37:31 +0100 Pablo Neira Ayuso wrote:
> +int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,
> +			  struct net_device_path_stack *stack)
> +{
> +	const struct net_device *last_dev;
> +	struct net_device_path_ctx ctx;
> +	struct net_device_path *path;
> +	int ret = 0;
> +
> +	memset(&ctx, 0, sizeof(ctx));
> +	ctx.dev = dev;
> +	ctx.daddr = daddr;
> +
> +	while (ctx.dev && ctx.dev->netdev_ops->ndo_fill_forward_path) {
> +		last_dev = ctx.dev;
> +
> +		path = &stack->path[stack->num_paths++];

I don't see you checking that this stack doesn't overflow.

What am I missing?

> +		ret = ctx.dev->netdev_ops->ndo_fill_forward_path(&ctx, path);
> +		if (ret < 0)
> +			return -1;
> +
> +		if (WARN_ON_ONCE(last_dev == ctx.dev))
> +			return -1;
> +	}
> +	path = &stack->path[stack->num_paths++];
> +	path->type = DEV_PATH_ETHERNET;
> +	path->dev = ctx.dev;
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(dev_fill_forward_path);




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux