DPDK usage discussions
 help / color / mirror / Atom feed
* [dpdk-users] Possible race in bonding driver ?
@ 2018-12-17  9:12 Miao Yan
  0 siblings, 0 replies; only message in thread
From: Miao Yan @ 2018-12-17  9:12 UTC (permalink / raw)
  To: users

Hello Experts,

I am currently working on a project to implement a new team policy
based on the bonding driver. Basically, I have lots of 'ports', each of them
has a ID.  I'd like to use the ID to calculate the hash and distribute
the traffic to different slave ports, similar to round-robin, except
the sender ID
is fixed.

And when looking into bonding driver code, the following code looks like racy:

static uint16_t
bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts)
{
...

/* Copy slave list to protect against slave up/down changes during tx
* bursting */
num_of_slaves = internals->active_slave_count;
memcpy(slaves, internals->active_slaves,
sizeof(internals->active_slaves[0]) * num_of_slaves);
[...]
}


void
deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
{
[...]
/* If slave was not at the end of the list
* shift active slaves up active array list */
if (slave_pos < active_count) {
    active_count--;
    memmove(internals->active_slaves + slave_pos,
                      internals->active_slaves + slave_pos + 1,
                      (active_count - slave_pos) *
                      sizeof(internals->active_slaves[0]));
 }
[...]
}

What if a core is dumping packets to the bond device and at the same time
a slave is down and another core is handling the deactivation (or it
could be just
another core calling rte_bond_slave_remove). It seems it's possible
for the TX core to see a partially updated  active_slaves array during memmove.

Is this a problem or am I missing something ? Thank you for the help.

Regards,
Miao

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-17  9:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17  9:12 [dpdk-users] Possible race in bonding driver ? Miao Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).