[Asterisk-code-review] websocket / pjsip: Increase maximum packet size. (asterisk[master])

Joshua Colp asteriskteam at digium.com
Wed Jul 22 13:01:16 CDT 2020


Joshua Colp has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14692 )


Change subject: websocket / pjsip: Increase maximum packet size.
......................................................................

websocket / pjsip: Increase maximum packet size.

When dealing with a lot of video streams on WebRTC
the resulting SDPS can grow to be quite large. This
effectively doubles the maximum size to allow more
streams to exist.

Change-Id: I31d4351d70c8e2c11564807a7528b984f3fbdd01
---
M res/res_http_websocket.c
M res/res_pjsip_pubsub.c
M third-party/pjproject/patches/config_site.h
3 files changed, 8 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/92/14692/1

diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index ffb6dbc..f5fee5a 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -63,15 +63,15 @@
 #define MAXIMUM_RECONSTRUCTION_CEILING 8192
 #else
 /*! \brief Size of the pre-determined buffer for WebSocket frames */
-#define MAXIMUM_FRAME_SIZE 32768
+#define MAXIMUM_FRAME_SIZE 65535
 
 /*! \brief Default reconstruction size for multi-frame payload reconstruction. If exceeded the next frame will start a
  *         payload.
  */
-#define DEFAULT_RECONSTRUCTION_CEILING 32768
+#define DEFAULT_RECONSTRUCTION_CEILING MAXIMUM_FRAME_SIZE
 
 /*! \brief Maximum reconstruction size for multi-frame payload reconstruction. */
-#define MAXIMUM_RECONSTRUCTION_CEILING 32768
+#define MAXIMUM_RECONSTRUCTION_CEILING MAXIMUM_FRAME_SIZE
 #endif
 
 /*! \brief Maximum size of a websocket frame header
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index be1eb39..1142bbd 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -146,8 +146,8 @@
 					that a server has to process.</para>
 					<note>
 						<para>Current limitations limit the size of SIP NOTIFY requests that Asterisk sends
-						to 64000 bytes. If your resource list notifications are larger than this maximum, you
-						will need to make adjustments.</para>
+						to double that of the PJSIP maximum packet length. If your resource list notifications
+						are larger than this maximum, you will need to make adjustments.</para>
 					</note>
 				</description>
 				<configOption name="type">
@@ -1950,15 +1950,7 @@
  * we instead take the strategy of pre-allocating the buffer, testing for ourselves
  * if the message will fit, and resizing the buffer as required.
  *
- * RFC 3261 says that a SIP UDP request can be up to 65535 bytes long. We're capping
- * it at 64000 for a couple of reasons:
- * 1) Allocating more than 64K at a time is hard to justify
- * 2) If the message goes through proxies, those proxies will want to add Via and
- *    Record-Route headers, making the message even larger. Giving some space for
- *    those headers is a nice thing to do.
- *
- * RFC 3261 does not place an upper limit on the size of TCP requests, but we are
- * going to impose the same 64K limit as a memory savings.
+ * The limit we impose is double that of the maximum packet length.
  *
  * \param tdata The tdata onto which to allocate a buffer
  * \retval 0 Success
@@ -1970,7 +1962,7 @@
 	int size = -1;
 	char *buf;
 
-	for (buf_size = PJSIP_MAX_PKT_LEN; size == -1 && buf_size < 64000; buf_size *= 2) {
+	for (buf_size = PJSIP_MAX_PKT_LEN; size == -1 && buf_size < (PJSIP_MAX_PKT_LEN * 2); buf_size *= 2) {
 		buf = pj_pool_alloc(tdata->pool, buf_size);
 		size = pjsip_msg_print(tdata->msg, buf, buf_size);
 	}
diff --git a/third-party/pjproject/patches/config_site.h b/third-party/pjproject/patches/config_site.h
index aea7d0d..5884108 100644
--- a/third-party/pjproject/patches/config_site.h
+++ b/third-party/pjproject/patches/config_site.h
@@ -65,7 +65,7 @@
   Enabling it will result in SEGFAULTS when URIs containing escape sequences are encountered.
 */
 #undef PJSIP_UNESCAPE_IN_PLACE
-#define PJSIP_MAX_PKT_LEN			32000
+#define PJSIP_MAX_PKT_LEN			65535
 
 #undef PJ_TODO
 #define PJ_TODO(x)

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14692
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I31d4351d70c8e2c11564807a7528b984f3fbdd01
Gerrit-Change-Number: 14692
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200722/595243b7/attachment.html>


More information about the asterisk-code-review mailing list