mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
net: do not advance stack index from dev_fwd_path()
Update stack index from dev_fill_forward_path() instead, once the forward path slot has been populated. Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
5be6e044be
commit
5deda60c56
|
|
@ -742,12 +742,10 @@ EXPORT_SYMBOL_GPL(dev_fill_metadata_dst);
|
|||
|
||||
static struct net_device_path *dev_fwd_path(struct net_device_path_stack *stack)
|
||||
{
|
||||
int k = stack->num_paths++;
|
||||
|
||||
if (k >= NET_DEVICE_PATH_STACK_MAX)
|
||||
if (stack->num_paths + 1 > NET_DEVICE_PATH_STACK_MAX)
|
||||
return NULL;
|
||||
|
||||
return &stack->path[k];
|
||||
return &stack->path[stack->num_paths];
|
||||
}
|
||||
|
||||
int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,
|
||||
|
|
@ -773,6 +771,7 @@ int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,
|
|||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
stack->num_paths++;
|
||||
if (WARN_ON_ONCE(last_dev == ctx.dev))
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -785,6 +784,7 @@ int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,
|
|||
return -1;
|
||||
path->type = DEV_PATH_ETHERNET;
|
||||
path->dev = ctx.dev;
|
||||
stack->num_paths++;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user