port: should check the new phc_index before switching
In logic, when we want to switch phc, we should check if the new phc index is valid instead of checking the previous one. In reality, if we use linux team interface with activebackup mode. As teamd is a userspace tool, it sets the new slave as active port after receiving link change message. If we set current active port down and another slave up. There is a race that we receive the new slave's link up message while active port(ts_index) is still the old one. This means we may use a link down interface as ts_index and get phc_index with -1. If we update the p->phc_index to -1, there will be no possibility to change it back to other value as we swith phc only when p->phc_index >= 0. With this fix, we will not switch phc_index until receiving the real active port(p->iface->ts_info.phc_index >= 0) update message. Reported-by: Miroslav Lichvar <mlichvar@redhat.com> Fixes: 536a71031d5c ("ptp4l: use ts label to get ts info") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
This commit is contained in:
parent
6b61ba29c7
commit
51d76bdfb7
2
port.c
2
port.c
@ -2442,7 +2442,7 @@ void port_link_status(void *ctx, int linkup, int ts_index)
|
|||||||
sk_get_ts_info(p->iface->ts_label, &p->iface->ts_info);
|
sk_get_ts_info(p->iface->ts_label, &p->iface->ts_info);
|
||||||
|
|
||||||
/* Only switch phc with HW time stamping mode */
|
/* Only switch phc with HW time stamping mode */
|
||||||
if (p->phc_index >= 0 && p->iface->ts_info.valid) {
|
if (p->iface->ts_info.valid && p->iface->ts_info.phc_index >= 0) {
|
||||||
required_modes = clock_required_modes(p->clock);
|
required_modes = clock_required_modes(p->clock);
|
||||||
if ((p->iface->ts_info.so_timestamping & required_modes) != required_modes) {
|
if ((p->iface->ts_info.so_timestamping & required_modes) != required_modes) {
|
||||||
pr_err("interface '%s' does not support requested "
|
pr_err("interface '%s' does not support requested "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user