diff options
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 77eab8f4c7fd..332dd8f436ea 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #define VERSION "1.8" | 55 | #define VERSION "1.8" |
56 | 56 | ||
57 | static int disable_cfc = 0; | 57 | static int disable_cfc = 0; |
58 | static int channel_mtu = -1; | ||
58 | static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU; | 59 | static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU; |
59 | 60 | ||
60 | static struct task_struct *rfcomm_thread; | 61 | static struct task_struct *rfcomm_thread; |
@@ -812,7 +813,10 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d | |||
812 | pn->credits = 0; | 813 | pn->credits = 0; |
813 | } | 814 | } |
814 | 815 | ||
815 | pn->mtu = htobs(d->mtu); | 816 | if (cr && channel_mtu >= 0) |
817 | pn->mtu = htobs(channel_mtu); | ||
818 | else | ||
819 | pn->mtu = htobs(d->mtu); | ||
816 | 820 | ||
817 | *ptr = __fcs(buf); ptr++; | 821 | *ptr = __fcs(buf); ptr++; |
818 | 822 | ||
@@ -1243,7 +1247,10 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn) | |||
1243 | 1247 | ||
1244 | d->priority = pn->priority; | 1248 | d->priority = pn->priority; |
1245 | 1249 | ||
1246 | d->mtu = s->mtu = btohs(pn->mtu); | 1250 | d->mtu = btohs(pn->mtu); |
1251 | |||
1252 | if (cr && d->mtu > s->mtu) | ||
1253 | d->mtu = s->mtu; | ||
1247 | 1254 | ||
1248 | return 0; | 1255 | return 0; |
1249 | } | 1256 | } |
@@ -1770,6 +1777,11 @@ static inline void rfcomm_accept_connection(struct rfcomm_session *s) | |||
1770 | s = rfcomm_session_add(nsock, BT_OPEN); | 1777 | s = rfcomm_session_add(nsock, BT_OPEN); |
1771 | if (s) { | 1778 | if (s) { |
1772 | rfcomm_session_hold(s); | 1779 | rfcomm_session_hold(s); |
1780 | |||
1781 | /* We should adjust MTU on incoming sessions. | ||
1782 | * L2CAP MTU minus UIH header and FCS. */ | ||
1783 | s->mtu = min(l2cap_pi(nsock->sk)->omtu, l2cap_pi(nsock->sk)->imtu) - 5; | ||
1784 | |||
1773 | rfcomm_schedule(RFCOMM_SCHED_RX); | 1785 | rfcomm_schedule(RFCOMM_SCHED_RX); |
1774 | } else | 1786 | } else |
1775 | sock_release(nsock); | 1787 | sock_release(nsock); |
@@ -2087,6 +2099,9 @@ module_exit(rfcomm_exit); | |||
2087 | module_param(disable_cfc, bool, 0644); | 2099 | module_param(disable_cfc, bool, 0644); |
2088 | MODULE_PARM_DESC(disable_cfc, "Disable credit based flow control"); | 2100 | MODULE_PARM_DESC(disable_cfc, "Disable credit based flow control"); |
2089 | 2101 | ||
2102 | module_param(channel_mtu, int, 0644); | ||
2103 | MODULE_PARM_DESC(channel_mtu, "Default MTU for the RFCOMM channel"); | ||
2104 | |||
2090 | module_param(l2cap_mtu, uint, 0644); | 2105 | module_param(l2cap_mtu, uint, 0644); |
2091 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); | 2106 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); |
2092 | 2107 | ||