Skip to content

Commit 59eb228

Browse files
committed
can: isotp: remove re-binding of bound socket
JIRA: https://issues.redhat.com/browse/RHEL-80832 commit 72ed3ee Author: Oliver Hartkopp <socketcan@hartkopp.net> Date: Fri Apr 22 10:23:37 2022 +0200 can: isotp: remove re-binding of bound socket As a carry over from the CAN_RAW socket (which allows to change the CAN interface while mantaining the filter setup) the re-binding of the CAN_ISOTP socket needs to take care about CAN ID address information and subscriptions. It turned out that this feature is so limited (e.g. the sockopts remain fix) that it finally has never been needed/used. In opposite to the stateless CAN_RAW socket the switching of the CAN ID subscriptions might additionally lead to an interrupted ongoing PDU reception. So better remove this unneeded complexity. Fixes: e057dd3 ("can: add ISO 15765-2:2016 transport protocol") Link: https://lore.kernel.org/all/20220422082337.1676-1-socketcan@hartkopp.net Cc: stable@vger.kernel.org Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Radu Rendec <rrendec@redhat.com>
1 parent c0a8bff commit 59eb228

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

net/can/isotp.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,11 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
11821182

11831183
lock_sock(sk);
11841184

1185+
if (so->bound) {
1186+
err = -EINVAL;
1187+
goto out;
1188+
}
1189+
11851190
/* do not register frame reception for functional addressing */
11861191
if (so->opt.flags & CAN_ISOTP_SF_BROADCAST)
11871192
do_rx_reg = 0;
@@ -1192,10 +1197,6 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
11921197
goto out;
11931198
}
11941199

1195-
if (so->bound && addr->can_ifindex == so->ifindex &&
1196-
rx_id == so->rxid && tx_id == so->txid)
1197-
goto out;
1198-
11991200
dev = dev_get_by_index(net, addr->can_ifindex);
12001201
if (!dev) {
12011202
err = -ENODEV;
@@ -1230,22 +1231,6 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
12301231

12311232
dev_put(dev);
12321233

1233-
if (so->bound && do_rx_reg) {
1234-
/* unregister old filter */
1235-
if (so->ifindex) {
1236-
dev = dev_get_by_index(net, so->ifindex);
1237-
if (dev) {
1238-
can_rx_unregister(net, dev, so->rxid,
1239-
SINGLE_MASK(so->rxid),
1240-
isotp_rcv, sk);
1241-
can_rx_unregister(net, dev, so->txid,
1242-
SINGLE_MASK(so->txid),
1243-
isotp_rcv_echo, sk);
1244-
dev_put(dev);
1245-
}
1246-
}
1247-
}
1248-
12491234
/* switch to new settings */
12501235
so->ifindex = ifindex;
12511236
so->rxid = rx_id;

0 commit comments

Comments
 (0)