examples/bond: wait for slaves to become active
PATCH 1/1 examples/bond: wait for slaves to become active
Do not start the packet processing threads until all configured slaves become active.
--- examples/bond/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
examples/bond/main.c +15 -0
@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool)struct rte_eth_rxconf rxq_conf;struct rte_eth_txconf txq_conf;struct rte_eth_conf local_port_conf = port_conf; +uint16_t wait_counter =20 ; retval =rte_eth_bond_create ("net_bonding0" ,BONDING_MODE_ALB ,0 /*SOCKET_ID_ANY*/ );
@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool)if (retval <0 )rte_exit (retval,"Start port %d failed (res=%d)" ,BOND_PORT , retval); +printf ("Waiting for slaves to become active..." ); +while (wait_counter) { +uint16_t act_slaves[16 ] = {0 }; +if (rte_eth_bond_active_slaves_get (BOND_PORT , act_slaves,16 ) == + slaves_count) { +printf ("\n" ); +break ; + } +sleep (1 ); +printf ("..." ); +if (--wait_counter ==0 ) +rte_exit (-1 ,"\nFailed to activate slaves\n" ); + } +rte_eth_promiscuous_enable (BOND_PORT );struct ether_addr addr;
Signature · 1 line
2.7.5
Quoted 4 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Signed-off-by Radu Nicolau <[email protected]>
Quoted 38 lines
--- examples/bond/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)examples/bond/main.c +15
-0@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool)struct rte_eth_rxconf rxq_conf;struct rte_eth_txconf txq_conf;struct rte_eth_conf local_port_conf = port_conf; +uint16_t wait_counter =20 ; retval =rte_eth_bond_create ("net_bonding0" ,BONDING_MODE_ALB ,0 /*SOCKET_ID_ANY*/ );@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool)if (retval <0 )rte_exit (retval,"Start port %d failed (res=%d)" ,BOND_PORT , retval); +printf ("Waiting for slaves to become active..." ); +while (wait_counter) { +uint16_t act_slaves[16 ] = {0 }; +if (rte_eth_bond_active_slaves_get (BOND_PORT , act_slaves,16 ) == + slaves_count) { +printf ("\n" ); +break ; + } +sleep (1 ); +printf ("..." ); +if (--wait_counter ==0 ) +rte_exit (-1 ,"\nFailed to activate slaves\n" ); + } +rte_eth_promiscuous_enable (BOND_PORT );struct ether_addr addr;
Ferruh Yigit
AppliedQuoted 9 lines · Chas Williams
Quoted 4 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Signed-off-by Radu Nicolau <[email protected]>Acked-by Chas Williams <[email protected]>
Applied to dpdk-next-net/master, thanks.
(commit log updated as discussed in mail thread)
Quoted 2 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Hi Radu,
What happens if packet processing threads started before all slaves active? Exit app, error, crash?
So can we say this patch is fixing packet forwarding? (fix in title?)
And do we know what break it, why this was not required previously but required now? (Fixes line ?)
Thanks,
ferruh
Quoted 40 lines
Signed-off-by Radu Nicolau <[email protected]>--- examples/bond/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)examples/bond/main.c +15
-0@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool)struct rte_eth_rxconf rxq_conf;struct rte_eth_txconf txq_conf;struct rte_eth_conf local_port_conf = port_conf; +uint16_t wait_counter =20 ; retval =rte_eth_bond_create ("net_bonding0" ,BONDING_MODE_ALB ,0 /*SOCKET_ID_ANY*/ );@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool)if (retval <0 )rte_exit (retval,"Start port %d failed (res=%d)" ,BOND_PORT , retval); +printf ("Waiting for slaves to become active..." ); +while (wait_counter) { +uint16_t act_slaves[16 ] = {0 }; +if (rte_eth_bond_active_slaves_get (BOND_PORT , act_slaves,16 ) == + slaves_count) { +printf ("\n" ); +break ; + } +sleep (1 ); +printf ("..." ); +if (--wait_counter ==0 ) +rte_exit (-1 ,"\nFailed to activate slaves\n" ); + } +rte_eth_promiscuous_enable (BOND_PORT );struct ether_addr addr;
Hi
Quoted 5 lines · Ferruh Yigit
Quoted 2 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Hi Radu,
Quoted 7 lines
What happens if packet processing threads started before all slaves active? Exit app, error, crash?
So can we say this patch is fixing packet forwarding? (fix in title?)
And do we know what break it, why this was not required previously but required now? (Fixes line ?)
From what I see, the problem was always there: bond_ethdev_rx_burst will cycle through slaves, but if called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault. While this may require a better fix, this patch is an improvement even if that fix comes - the configured slaves needs to be checked, and if none became active there is no point going further.
in bond_ethdev_rx_burst:
slave_count = internals->active_slave_count;
...
if (++internals->active_slave == slave_count)
internals->active_slave = 0;slave_count is zero, the if() will never be true and active_slave will be continuously incremented. It was not written to work with no active slaves.
Quoted 43 lines
Thanks,
ferruhQuoted 39 lines
Signed-off-by Radu Nicolau <[email protected]>--- examples/bond/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)examples/bond/main.c +15
-0@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool)struct rte_eth_rxconf rxq_conf;struct rte_eth_txconf txq_conf;struct rte_eth_conf local_port_conf = port_conf; +uint16_t wait_counter =20 ; retval =rte_eth_bond_create ("net_bonding0" ,BONDING_MODE_ALB ,0 /*SOCKET_ID_ANY*/ );@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool)if (retval <0 )rte_exit (retval,"Start port %d failed (res=%d)" ,BOND_PORT , retval); +printf ("Waiting for slaves to become active..." ); +while (wait_counter) { +uint16_t act_slaves[16 ] = {0 }; +if (rte_eth_bond_active_slaves_get (BOND_PORT , act_slaves,16 ) == + slaves_count) { +printf ("\n" ); +break ; + } +sleep (1 ); +printf ("..." ); +if (--wait_counter ==0 ) +rte_exit (-1 ,"\nFailed to activate slaves\n" ); + } +rte_eth_promiscuous_enable (BOND_PORT );struct ether_addr addr;
Quoted 20 lines · Radu Nicolau
Hi
Quoted 5 lines · Ferruh Yigit
Quoted 2 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Hi Radu,
Quoted 7 lines
What happens if packet processing threads started before all slaves active? Exit app, error, crash?
So can we say this patch is fixing packet forwarding? (fix in title?)
And do we know what break it, why this was not required previously but required now? (Fixes line ?)
From what I see, the problem was always there:
bond_ethdev_rx_burst
will cycle through slaves, but if called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault.
While this may require a better fix, this patch is an improvement even if that fix comes - the configured slaves needs to be checked, and if none became active there is no point going further.
Quoted 7 lines
in
bond_ethdev_rx_burst:
slave_count=internals->active_slave_count;
...if (++internals->active_slave == slave_count) internals->active_slave = 0;
slave_countis zero, theif()will never be true andactive_slavewill be continuously incremented. It was not written to work with no active slaves.
Just create another patch for the rx routines. If the active_slave_count is 0, there's nothing to do really. It should just return and not bother with any of the other work.
Quoted 44 lines
Quoted 43 lines
Thanks,
ferruhQuoted 38 lines
Signed-off-by Radu Nicolau <[email protected]>--- examples/bond/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)examples/bond/main.c +5
-0@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool)struct rte_eth_rxconf rxq_conf;struct rte_eth_txconf txq_conf;struct rte_eth_conf local_port_conf = port_conf; +uint16_t wait_counter =20 ; retval =rte_eth_bond_create ("net_bonding0" ,BONDING_MODE_ALB ,0 /*SOCKET_ID_ANY*/ );@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool)if (retval <0 )rte_exit (retval,"Start port %d failed (res=%d)" ,BOND_PORT , retval); +printf ("Waiting for slaves to become active..." ); +while (wait_counter) { +uint16_t act_slaves[16 ] = {0 }; + if (rte_eth_bond_active_slaves_get(BOND_PORT, act_slaves,16) ==
examples/bond/main.c +10
-0+ slaves_count) { +printf ("\n" ); +break ; + } +sleep (1 ); +printf ("..." ); +if (--wait_counter ==0 ) +rte_exit (-1 ,"\nFailed to activate slaves\n" ); + } +rte_eth_promiscuous_enable (BOND_PORT );struct ether_addr addr;
Quoted 30 lines · Chas Williams
Quoted 19 lines · Radu Nicolau
Hi
Quoted 5 lines · Ferruh Yigit
Quoted 2 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Hi Radu,
Quoted 7 lines
What happens if packet processing threads started before all slaves active? Exit app, error, crash?
So can we say this patch is fixing packet forwarding? (fix in title?)
And do we know what break it, why this was not required previously but required now? (Fixes line ?)
From what I see, the problem was always there:
bond_ethdev_rx_burstwill cycle through slaves, but if called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault. While this may require a better fix, this patch is an improvement even if that fix comes - the configured slaves needs to be checked, and if none became active there is no point going further.Quoted 7 lines
in
bond_ethdev_rx_burst:
slave_count=internals->active_slave_count;
...
if (++internals->active_slave ==slave_count)
internals->active_slave= 0;slave_countis zero, theif()will never be true andactive_slavewill be continuously incremented. It was not written to work with no active slaves.
Quoted 3 lines
Just create another patch for the rx routines. If the
active_slave_countis 0, there's nothing to do really. It should just return and not bother with any of the other work.
I can do that, and it will be the better fix I mentioned.
But I still think this patch makes the sample app better, at least it gives a hint to someone looking to develop its own app to check on the slaves' status before proceeding to rx.
Quoted 44 lines
Quoted 44 lines
Quoted 43 lines
Thanks,
ferruhQuoted 37 lines
Signed-off-by Radu Nicolau <[email protected]>---
examples/bond/main.c| 15 +++++++++++++++1 file changed, 15 insertions(+)examples/bond/main.c +5
-0@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool) struct rte_eth_rxconf rxq_conf; struct rte_eth_txconf txq_conf; struct rte_eth_conf local_port_conf = port_conf; + uint16_t wait_counter = 20; retval = rte_eth_bond_create("net_bonding0", BONDING_MODE_ALB, 0 /*SOCKET_ID_ANY*/);@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool) if (retval < 0) rte_exit(retval, "Start port %d failed (res=%d)", BOND_PORT, retval); + printf("Waiting for slaves to become active..."); + while (wait_counter) { + uint16_t act_slaves[16] = {0}; + if (rte_eth_bond_active_slaves_get(BOND_PORT, act_slaves,16) ==
+slaves_count) {
+printf("\n");
+ break;
+ }
+ sleep(1);
+printf("...");
+ if (--wait_counter == 0)
+rte_exit(-1, "\nFailed to activate slaves\n"); + }
+
rte_eth_promiscuous_enable(BOND_PORT); structether_addraddr;
Quoted 33 lines · Radu Nicolau
Quoted 30 lines · Chas Williams
Quoted 26 lines · Radu Nicolau
Hi
Quoted 5 lines · Ferruh Yigit
Quoted 2 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Hi Radu,
Quoted 7 lines
What happens if packet processing threads started before all slaves active? Exit app, error, crash?
So can we say this patch is fixing packet forwarding? (fix in title?)
And do we know what break it, why this was not required previously but required now? (Fixes line ?)
From what I see, the problem was always there:
bond_ethdev_rx_burstwill cycle through slaves, but if called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault. While this may require a better fix, this patch is an improvement even if that fix comes - the configured slaves needs to be checked, and if none became active there is no point going further.in
bond_ethdev_rx_burst:
slave_count=internals->active_slave_count;
...
if (++internals->active_slave ==slave_count)
internals->active_slave= 0;slave_countis zero, theif()will never be true andactive_slavewill be continuously incremented. It was not written to work with no active slaves.
Quoted 5 lines
Quoted 3 lines
Just create another patch for the rx routines. If the
active_slave_countis 0, there's nothing to do really. It should just return and not bother with any of the other work.I can do that, and it will be the better fix I mentioned.
But I still think this patch makes the sample app better, at least it gives a hint to someone looking to develop its own app to check on the slaves' status before proceeding to rx.
Yes, I agree this patch is still valid. If you are writing some sort of test, you should wait until the bonding interface and slaves are ready before you start sending traffic.
Quoted 45 lines
Quoted 44 lines
Quoted 44 lines
Quoted 43 lines
Thanks,
ferruhQuoted 37 lines
Signed-off-by Radu Nicolau <[email protected]>---
examples/bond/main.c| 15 +++++++++++++++1 file changed, 15 insertions(+)examples/bond/main.c +5
-0@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool) struct rte_eth_rxconf rxq_conf; struct rte_eth_txconf txq_conf; struct rte_eth_conf local_port_conf = port_conf; + uint16_t wait_counter = 20; retval = rte_eth_bond_create("net_bonding0", BONDING_MODE_ALB, 0 /*SOCKET_ID_ANY*/);@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool) if (retval < 0) rte_exit(retval, "Start port %d failed (res=%d)", BOND_PORT, retval); + printf("Waiting for slaves to become active..."); + while (wait_counter) { + uint16_t act_slaves[16] = {0}; + if (rte_eth_bond_active_slaves_get(BOND_PORT, act_slaves,16) ==
+slaves_count) {
+printf("\n");
+ break;
+ }
+ sleep(1);
+printf("...");
+ if (--wait_counter == 0)
+rte_exit(-1, "\nFailed to activate slaves\n"); + }
+
rte_eth_promiscuous_enable(BOND_PORT); structether_addraddr;
PATCH 1/1 examples/bond: wait for slaves to become active
In reply to Radu NicolauQuoted 26 lines · Radu Nicolau
Hi
Quoted 5 lines · Ferruh Yigit
Quoted 2 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Hi Radu,
Quoted 7 lines
What happens if packet processing threads started before all slaves active? Exit app, error, crash?
So can we say this patch is fixing packet forwarding? (fix in title?)
And do we know what break it, why this was not required previously but required now? (Fixes line ?)
From what I see, the problem was always there:
bond_ethdev_rx_burst
will cycle through slaves, but if called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault.
While this may require a better fix, this patch is an improvement even if that fix comes - the configured slaves needs to be checked, and if none became active there is no point going further.in
bond_ethdev_rx_burst:
Quoted 7 lines
slave_count=internals->active_slave_count;
...
if (++internals->active_slave ==slave_count)internals->active_slave= 0;slave_countis zero, theif()will never be true andactive_slavewill be continuously incremented. It was not written to work with no active slaves.
Thanks for clarification, are you OK with below updated commit log:
"
examples/bond: fix crash when there is no active slave
If bond_ethdev_rx_burst() called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault.
The configured slaves needs to be checked, and if none became active there is no point going further.
Do not start the packet processing threads until all configured slaves become active.
mode 6")
Cc: [email protected]
"
Quoted 45 lines
Quoted 44 lines
Thanks,
ferruhQuoted 39 lines
Signed-off-by Radu Nicolau <[email protected]>--- examples/bond/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)examples/bond/main.c +15
-0@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool)struct rte_eth_rxconf rxq_conf;struct rte_eth_txconf txq_conf;struct rte_eth_conf local_port_conf = port_conf; +uint16_t wait_counter =20 ; retval =rte_eth_bond_create ("net_bonding0" ,BONDING_MODE_ALB ,0 /*SOCKET_ID_ANY*/ );@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool)if (retval <0 )rte_exit (retval,"Start port %d failed (res=%d)" ,BOND_PORT , retval); +printf ("Waiting for slaves to become active..." ); +while (wait_counter) { +uint16_t act_slaves[16 ] = {0 }; +if (rte_eth_bond_active_slaves_get (BOND_PORT , act_slaves,16 ) == + slaves_count) { +printf ("\n" ); +break ; + } +sleep (1 ); +printf ("..." ); +if (--wait_counter ==0 ) +rte_exit (-1 ,"\nFailed to activate slaves\n" ); + } +rte_eth_promiscuous_enable (BOND_PORT );struct ether_addr addr;
I'm ok with the updates, thanks!
-----Original Message-----
From: Yigit, Ferruh
Sent: Thursday, November 29, 2018 8:57 AM
To: Nicolau, Radu <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH] examples/bond: wait for slaves to become active
Quoted 24 lines · Radu Nicolau
Hi
Quoted 5 lines · Ferruh Yigit
Quoted 2 lines · Radu Nicolau
Do not start the packet processing threads until all configured slaves become active.
Hi Radu,
Quoted 7 lines
What happens if packet processing threads started before all slaves active? Exit app, error, crash?
So can we say this patch is fixing packet forwarding? (fix in title?)
And do we know what break it, why this was not required previously but required now? (Fixes line ?)
From what I see, the problem was always there:
bond_ethdev_rx_burst
will cycle through slaves, but if called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault.
While this may require a better fix, this patch is an improvement even if that fix comes - the configured slaves needs to be checked, and if none became active there is no point going further.
Quoted 8 lines
in
bond_ethdev_rx_burst:
slave_count=internals->active_slave_count; ...
if (++internals->active_slave ==slave_count)internals->active_slave= 0;slave_countis zero, theif()will never be true andactive_slavewill be continuously incremented. It was not written to work with no active slaves.
Thanks for clarification, are you OK with below updated commit log:
"
examples/bond: fix crash when there is no active slave
If bond_ethdev_rx_burst() called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault. The configured slaves needs to be checked, and if none became active there is no point going further.
Do not start the packet processing threads until all configured slaves become active.
"
Quoted 46 lines
Quoted 45 lines
Thanks,
ferruhQuoted 40 lines
Signed-off-by Radu Nicolau <[email protected]>--- examples/bond/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)examples/bond/main.c index renamed from examples/bond/main.c +0
-0b282e68..6623cae 100644
examples/bond/main.c +15
-0@@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool)struct rte_eth_rxconf rxq_conf;struct rte_eth_txconf txq_conf;struct rte_eth_conf local_port_conf = port_conf; +uint16_t wait_counter =20 ; retval =rte_eth_bond_create ("net_bonding0" ,BONDING_MODE_ALB ,0 /*SOCKET_ID_ANY*/ );@@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool)if (retval <0 )rte_exit (retval,"Start port %d failed (res=%d)" ,BOND_PORT , retval); +printf ("Waiting for slaves to become active..." ); +while (wait_counter) { +uint16_t act_slaves[16 ] = {0 }; +if (rte_eth_bond_active_slaves_get (BOND_PORT , act_slaves,16 ) == + slaves_count) { +printf ("\n" ); +break ; + } +sleep (1 ); +printf ("..." ); +if (--wait_counter ==0 ) +rte_exit (-1 ,"\nFailed to activate slaves\n" ); + } +rte_eth_promiscuous_enable (BOND_PORT );struct
ether_addraddr;