common/mlx5: fix mac deletion on Linux
PATCH 1/1 common/mlx5: fix mac deletion on Linux
Re-enable debug logs unconditionally, this helps understanding why mac deletions were silently failing (while a bridge fdb del command was working fine).
testpmd> mac_addr add 0 FA:35:44:3F:58:31
testpmd> mac_addr remove 0 FA:35:44:3F:58:31mlx5_common: Interface 35 cannot remove MAC address FA:35:44:3F:58:31
Operation not supported
Then, fix mac deletion as the NLM_F_CREATE == 0x200 flag is relevant with a RTM_NEWNEIGH op.
For a RTM_DELNEIGH op, 0x200 == NLM_F_BULK and passing this flag makes the deletion fail miserably for a single mac.
--- drivers/common/mlx5/linux/mlx5_nl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/common/mlx5/linux/mlx5_nl.c +2 -4
@@ -581,8 +581,8 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, } req = { .hdr = { .nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)), - .nlmsg_flags =NLM_F_REQUEST |NLM_F_CREATE | - NLM_F_EXCL | NLM_F_ACK, + .nlmsg_flags =NLM_F_REQUEST |NLM_F_ACK | + add ? NLM_F_CREATE | NLM_F_EXCL : 0, .nlmsg_type = add ? RTM_NEWNEIGH : RTM_DELNEIGH, }, .ndm = {
@@ -612,7 +612,6 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, goto error;return 0 ; error: -#ifdef RTE_PMD_MLX5_DEBUG {char m[RTE_ETHER_ADDR_FMT_SIZE ];
@@ -622,7 +621,6 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, iface_idx, add ? "add" : "remove", m, strerror(rte_errno)); } -#endif return -rte_errno; }
Signature · 1 line
2.53.0
Quoted 10 lines · David Marchand
Re-enable debug logs unconditionally, this helps understanding why mac deletions were silently failing (while a bridge fdb del command was working fine).
testpmd>
mac_addradd 0 FA:35:44:3F:58:31
testpmd>mac_addrremove 0 FA:35:44:3F:58:31mlx5_common: Interface 35 cannot remove MAC address FA:35:44:3F:58:31
Operation not supported
Quoted 4 lines
Then, fix mac deletion as the
NLM_F_CREATE==0x200flag is relevant with aRTM_NEWNEIGHop.
For aRTM_DELNEIGHop,0x200==NLM_F_BULKand passing this flag makes the deletion fail miserably for a single mac.
This issue is actually triggered after a change in the kernel uapi.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=545528d788556
So the DPDK bug can be seen with kernels >= 5.19 (and in my case, RHEL9).
Probably worth adding in the commitlog.
Quoted 4 lines
Fixes ccdcba53a3f4 ("net/mlx5: use Netlink to add/remove MAC addresses")Signed-off-by David Marchand <[email protected]>
Signature · 1 line
David Marchand
Quoted 27 lines · David Marchand
Re-enable debug logs unconditionally, this helps understanding why mac deletions were silently failing (while a bridge fdb del command was working fine).
testpmd>
mac_addradd 0 FA:35:44:3F:58:31
testpmd>mac_addrremove 0 FA:35:44:3F:58:31mlx5_common: Interface 35 cannot remove MAC address FA:35:44:3F:58:31
Operation not supportedThen, fix mac deletion as the
NLM_F_CREATE==0x200flag is relevant with aRTM_NEWNEIGHop.
For aRTM_DELNEIGHop,0x200==NLM_F_BULKand passing this flag makes the deletion fail miserably for a single mac.Fixes ccdcba53a3f4 ("net/mlx5: use Netlink to add/remove MAC addresses")Signed-off-by David Marchand <[email protected]>--- drivers/common/mlx5/linux/mlx5_nl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/common/mlx5/linux/mlx5_nl.c +0
-0
drivers/common/mlx5/linux/mlx5_nl.c mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, · line 585
Quoted 7 lines
drivers/common/mlx5/linux/mlx5_nl.c +2
-2@@ -581,8 +581,8 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, } req = { .hdr = { .nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)), - .nlmsg_flags =NLM_F_REQUEST |NLM_F_CREATE | - NLM_F_EXCL | NLM_F_ACK, + .nlmsg_flags =NLM_F_REQUEST |NLM_F_ACK | + add ? NLM_F_CREATE | NLM_F_EXCL : 0,
It seems that this expression is constructed incorrectly. IIUC this will be "parenthesised" as follows:
((NLM_F_REQUEST | NLM_F_ACK) | add) ? (NLM_F_CREATE | NLM_F_EXCL) : 0
Since bitwise OR has higher precendence.
So "add" value will be ignored and only "NLM_F_CREATE | NLM_F_EXCL" will be returned.
Could you please add parenthesis around the ternary?
Quoted 12 lines
drivers/common/mlx5/linux/mlx5_nl.c +0
-1.nlmsg_type = add ? RTM_NEWNEIGH : RTM_DELNEIGH, }, .ndm = {@@ -612,7 +612,6 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, goto error;return 0 ; error: -#ifdef RTE_PMD_MLX5_DEBUG {char m[RTE_ETHER_ADDR_FMT_SIZE ];
drivers/common/mlx5/linux/mlx5_nl.c mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, · line 626
Quoted 7 lines
drivers/common/mlx5/linux/mlx5_nl.c +0
-1@@ -622,7 +621,6 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, iface_idx, add ? "add" : "remove", m, strerror(rte_errno)); } -#endif return -rte_errno; }
Best regards,
Dariusz Sosnowski
Quoted 40 lines · Dariusz Sosnowski
Quoted 27 lines · David Marchand
Re-enable debug logs unconditionally, this helps understanding why mac deletions were silently failing (while a bridge fdb del command was working fine).
testpmd>
mac_addradd 0 FA:35:44:3F:58:31
testpmd>mac_addrremove 0 FA:35:44:3F:58:31mlx5_common: Interface 35 cannot remove MAC address FA:35:44:3F:58:31
Operation not supportedThen, fix mac deletion as the
NLM_F_CREATE==0x200flag is relevant with aRTM_NEWNEIGHop.
For aRTM_DELNEIGHop,0x200==NLM_F_BULKand passing this flag makes the deletion fail miserably for a single mac.Fixes ccdcba53a3f4 ("net/mlx5: use Netlink to add/remove MAC addresses")Signed-off-by David Marchand <[email protected]>--- drivers/common/mlx5/linux/mlx5_nl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/common/mlx5/linux/mlx5_nl.c +0
-0drivers/common/mlx5/linux/mlx5_nl.c mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, · line 585
Quoted 7 lines
drivers/common/mlx5/linux/mlx5_nl.c +2
-2@@ -581,8 +581,8 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, } req = { .hdr = { .nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)), - .nlmsg_flags =NLM_F_REQUEST |NLM_F_CREATE | - NLM_F_EXCL | NLM_F_ACK, + .nlmsg_flags =NLM_F_REQUEST |NLM_F_ACK | + add ? NLM_F_CREATE | NLM_F_EXCL : 0,It seems that this expression is constructed incorrectly. IIUC this will be "parenthesised" as follows:
Quoted 7 lines
((NLM_F_REQUEST | NLM_F_ACK) | add) ? (NLM_F_CREATE | NLM_F_EXCL) : 0Since bitwise OR has higher precendence.
So "add" value will be ignored and only "NLM_F_CREATE|NLM_F_EXCL" will be returned.Could you please add parenthesis around the ternary?
Ugh.
That's what happens when doing a last minute change with a ternary and not testing the new patch...
I will send the right fix.
Signature · 1 line
David Marchand
PATCH v2 1/1 common/mlx5: fix mac deletion on Linux
In reply to David MarchandRe-enable debug logs unconditionally, this helps understanding why mac deletions were silently failing (while a bridge fdb del command was working fine).
testpmd> mac_addr add 0 FA:35:44:3F:58:31
testpmd> mac_addr remove 0 FA:35:44:3F:58:31mlx5_common: Interface 35 cannot remove MAC address FA:35:44:3F:58:31
Operation not supported
Then, fix mac deletion as the NLM_F_CREATE == 0x200 flag is relevant with a RTM_NEWNEIGH op.
Since kernel v5.19 though, for a RTM_DELNEIGH op, 0x200 == NLM_F_BULK and passing this flag makes the deletion fail miserably for a single mac.
---
Changes since v1:
- fixed ternary usage... (thanks Dariusz),
- updated commitlog with a mention of Linux version when it got broken,
--- drivers/common/mlx5/linux/mlx5_nl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/common/mlx5/linux/mlx5_nl.c +2 -4
@@ -581,8 +581,8 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, } req = { .hdr = { .nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)), - .nlmsg_flags =NLM_F_REQUEST |NLM_F_CREATE | - NLM_F_EXCL | NLM_F_ACK, + .nlmsg_flags =NLM_F_REQUEST |NLM_F_ACK | + (add ? NLM_F_CREATE | NLM_F_EXCL : 0), .nlmsg_type = add ? RTM_NEWNEIGH : RTM_DELNEIGH, }, .ndm = {
@@ -612,7 +612,6 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, goto error;return 0 ; error: -#ifdef RTE_PMD_MLX5_DEBUG {char m[RTE_ETHER_ADDR_FMT_SIZE ];
@@ -622,7 +621,6 @@ mlx5_nl_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, iface_idx, add ? "add" : "remove", m, strerror(rte_errno)); } -#endif return -rte_errno; }
Signature · 1 line
2.53.0
Quoted 12 lines · David Marchand
Re-enable debug logs unconditionally, this helps understanding why mac deletions were silently failing (while a bridge fdb del command was working fine).
testpmd>
mac_addradd 0 FA:35:44:3F:58:31
testpmd>mac_addrremove 0 FA:35:44:3F:58:31mlx5_common: Interface 35 cannot remove MAC address FA:35:44:3F:58:31
Operation not supportedThen, fix mac deletion as the
NLM_F_CREATE==0x200flag is relevant with aRTM_NEWNEIGHop.
Quoted 7 lines
Since kernel v5.19 though, for a
RTM_DELNEIGHop,0x200==NLM_F_BULKand passing this flag makes the deletion fail miserably for a single mac.Fixes ccdcba53a3f4 ("net/mlx5: use Netlink to add/remove MAC addresses")Signed-off-by David Marchand <[email protected]>
Best regards,
Dariusz Sosnowski
Hi,
Quoted 12 lines · David Marchand
Re-enable debug logs unconditionally, this helps understanding why mac deletions were silently failing (while a bridge fdb del command was working fine).
testpmd>
mac_addradd 0 FA:35:44:3F:58:31
testpmd>mac_addrremove 0 FA:35:44:3F:58:31mlx5_common: Interface 35 cannot remove MAC address FA:35:44:3F:58:31
Operation not supportedThen, fix mac deletion as the
NLM_F_CREATE==0x200flag is relevant with aRTM_NEWNEIGHop.
Quoted 7 lines
Since kernel v5.19 though, for a
RTM_DELNEIGHop,0x200==NLM_F_BULKand passing this flag makes the deletion fail miserably for a single mac.Fixes ccdcba53a3f4 ("net/mlx5: use Netlink to add/remove MAC addresses")Signed-off-by David Marchand <[email protected]>
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh