From: Jan Kiszka <[email protected]> The carrier of our virtual link is supposed to go on only when both sides are in RUN state. So far, it only went on when one side entered RUN by being int READY before and not when RUN was reached via ivshm_net_open().
Fix this by moving the carrier management into ivshm_net_run and ivshm_net_do_stop, respectively. Make sure that netif_carrier_on is only called when the peer in in RUN state already. Reported-by: Jiafei Pan <[email protected]> Signed-off-by: Jan Kiszka <[email protected]> --- drivers/net/ivshmem-net.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/ivshmem-net.c b/drivers/net/ivshmem-net.c index 1b22b1cc5ea3..56c2c87e7498 100644 --- a/drivers/net/ivshmem-net.c +++ b/drivers/net/ivshmem-net.c @@ -549,6 +549,9 @@ static void ivshm_net_run(struct net_device *ndev) if (!netif_running(ndev)) return; + if (in->last_peer_state == IVSHM_NET_STATE_RUN) + netif_carrier_on(ndev); + if (test_and_set_bit(IVSHM_NET_FLAG_RUN, &in->flags)) return; @@ -567,6 +570,7 @@ static void ivshm_net_do_stop(struct net_device *ndev) if (!test_and_clear_bit(IVSHM_NET_FLAG_RUN, &in->flags)) return; + netif_carrier_off(ndev); netif_stop_queue(ndev); napi_disable(&in->napi); } @@ -616,22 +620,18 @@ static void ivshm_net_state_change(struct work_struct *work) break; case IVSHM_NET_STATE_READY: - /* - * Link is up and we are running once the remote is in READY or - * RUN. - */ + case IVSHM_NET_STATE_RUN: if (peer_state >= IVSHM_NET_STATE_READY) { - netif_carrier_on(ndev); + /* + * Link is up and we are running once the remote is in + * READY or RUN. + */ ivshm_net_run(ndev); - break; - } - /* fall through */ - case IVSHM_NET_STATE_RUN: - /* - * If the remote goes to RESET, we need to follow immediately. - */ - if (peer_state == IVSHM_NET_STATE_RESET) { - netif_carrier_off(ndev); + } else if (peer_state == IVSHM_NET_STATE_RESET) { + /* + * If the remote goes to RESET, we need to follow + * immediately. + */ ivshm_net_do_stop(ndev); } break; -- 2.26.2 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/62ae1173-ee15-c179-8fcf-735527a96027%40siemens.com.
