Add option to cancel sessions for only one socket. Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> --- net/can/j1939/j1939-priv.h | 2 +- net/can/j1939/main.c | 2 +- net/can/j1939/transport.c | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/net/can/j1939/j1939-priv.h b/net/can/j1939/j1939-priv.h index 416419890a37..6b8985d40520 100644 --- a/net/can/j1939/j1939-priv.h +++ b/net/can/j1939/j1939-priv.h @@ -208,7 +208,7 @@ void j1939_priv_get(struct j1939_priv *priv); /* notify/alert all j1939 sockets bound to ifindex */ void j1939_sk_netdev_event(struct net_device *ndev, int error_code); -int j1939_cancel_all_active_sessions(struct j1939_priv *priv); +int j1939_cancel_active_session(struct j1939_priv *priv, struct sock *sk); void j1939_tp_init(struct j1939_priv *priv); /* decrement pending skb for a j1939 socket */ diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c index 41908279933c..68f1fa08cd5d 100644 --- a/net/can/j1939/main.c +++ b/net/can/j1939/main.c @@ -357,7 +357,7 @@ static int j1939_netdev_notify(struct notifier_block *nb, break; case NETDEV_DOWN: - j1939_cancel_all_active_sessions(priv); + j1939_cancel_active_session(priv, NULL); j1939_sk_netdev_event(ndev, ENETDOWN); j1939_ecu_unmap_all(priv); break; diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c index e8b638e87dca..0af861485649 100644 --- a/net/can/j1939/transport.c +++ b/net/can/j1939/transport.c @@ -1983,18 +1983,20 @@ void j1939_simple_recv(struct j1939_priv *priv, struct sk_buff *skb) j1939_session_put(session); } -int j1939_cancel_all_active_sessions(struct j1939_priv *priv) +int j1939_cancel_active_session(struct j1939_priv *priv, struct sock *sk) { struct j1939_session *session, *saved; - netdev_dbg(priv->ndev, "%s\n", __func__); + netdev_dbg(priv->ndev, "%s, sk: %p\n", __func__, sk); j1939_session_list_lock(priv); list_for_each_entry_safe(session, saved, &priv->active_session_list, active_session_list_entry) { - j1939_session_timers_cancel(session); - session->err = ESHUTDOWN; - j1939_session_deactivate_locked(session); + if (!sk || sk == session->sk) { + j1939_session_timers_cancel(session); + session->err = ESHUTDOWN; + j1939_session_deactivate_locked(session); + } } j1939_session_list_unlock(priv); return NOTIFY_DONE; -- 2.20.1