Skip to content

Commit 8d836d7

Browse files
Gustavo Padovanholtmann
authored andcommitted
Bluetooth: Access sk_sndtimeo indirectly in l2cap_core.c
As part of the work to remove struct sock from l2cap_core.c and make it more generic we remove in this commit the direct access to sk->sk_sndtimeo member. This objective of this change is purely remove sk usage from l2cap_core.c Now we have a new l2cap ops to get the current value of sk->sndtimeo. A l2cap_chan_no_get_sndtimeo was added for users of L2CAP that doesn't need to set a timeout. Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent f8e7301 commit 8d836d7

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎include/net/bluetooth/l2cap.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ struct l2cap_ops {
555555
void (*ready) (struct l2cap_chan *chan);
556556
void (*defer) (struct l2cap_chan *chan);
557557
void (*resume) (struct l2cap_chan *chan);
558+
long (*get_sndtimeo) (struct l2cap_chan *chan);
558559
struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
559560
unsigned long len, int nb);
560561
};
@@ -795,6 +796,11 @@ static inline void l2cap_chan_no_defer(struct l2cap_chan *chan)
795796
{
796797
}
797798

799+
static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)
800+
{
801+
return 0;
802+
}
803+
798804
extern bool disable_ertm;
799805

800806
int l2cap_init_sockets(void);

‎net/bluetooth/a2mp.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ static struct l2cap_ops a2mp_chan_ops = {
710710
.teardown = l2cap_chan_no_teardown,
711711
.ready = l2cap_chan_no_ready,
712712
.defer = l2cap_chan_no_defer,
713+
.get_sndtimeo = l2cap_chan_no_get_sndtimeo,
713714
};
714715

715716
static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)

‎net/bluetooth/l2cap_core.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
649649
case BT_CONFIG:
650650
if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED &&
651651
conn->hcon->type == ACL_LINK) {
652-
struct sock *sk = chan->sk;
653-
__set_chan_timer(chan, sk->sk_sndtimeo);
652+
__set_chan_timer(chan, chan->ops->get_sndtimeo(chan));
654653
l2cap_send_disconn_req(chan, reason);
655654
} else
656655
l2cap_chan_del(chan, reason);
@@ -1764,7 +1763,6 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
17641763
int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
17651764
bdaddr_t *dst, u8 dst_type)
17661765
{
1767-
struct sock *sk = chan->sk;
17681766
struct l2cap_conn *conn;
17691767
struct hci_conn *hcon;
17701768
struct hci_dev *hdev;
@@ -1876,7 +1874,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
18761874
hci_conn_drop(hcon);
18771875

18781876
l2cap_state_change(chan, BT_CONNECT);
1879-
__set_chan_timer(chan, sk->sk_sndtimeo);
1877+
__set_chan_timer(chan, chan->ops->get_sndtimeo(chan));
18801878

18811879
if (hcon->state == BT_CONNECTED) {
18821880
if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) {
@@ -3817,7 +3815,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
38173815

38183816
dcid = chan->scid;
38193817

3820-
__set_chan_timer(chan, sk->sk_sndtimeo);
3818+
__set_chan_timer(chan, chan->ops->get_sndtimeo(chan));
38213819

38223820
chan->ident = cmd->ident;
38233821

‎net/bluetooth/l2cap_sock.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,13 @@ static void l2cap_sock_resume_cb(struct l2cap_chan *chan)
11361136
sk->sk_state_change(sk);
11371137
}
11381138

1139+
static long l2cap_sock_get_sndtimeo_cb(struct l2cap_chan *chan)
1140+
{
1141+
struct sock *sk = chan->data;
1142+
1143+
return sk->sk_sndtimeo;
1144+
}
1145+
11391146
static struct l2cap_ops l2cap_chan_ops = {
11401147
.name = "L2CAP Socket Interface",
11411148
.new_connection = l2cap_sock_new_connection_cb,
@@ -1146,6 +1153,7 @@ static struct l2cap_ops l2cap_chan_ops = {
11461153
.ready = l2cap_sock_ready_cb,
11471154
.defer = l2cap_sock_defer_cb,
11481155
.resume = l2cap_sock_resume_cb,
1156+
.get_sndtimeo = l2cap_sock_get_sndtimeo_cb,
11491157
.alloc_skb = l2cap_sock_alloc_skb_cb,
11501158
};
11511159

0 commit comments

Comments
 (0)