]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
more accurate PPP-over-TLS MTU calculation
authorDaniel Lenski <dlenski@gmail.com>
Mon, 8 Feb 2021 10:08:59 +0000 (02:08 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Mon, 29 Mar 2021 02:27:01 +0000 (19:27 -0700)
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
ppp.c

diff --git a/ppp.c b/ppp.c
index 5628f7aa7ba988555c3684f0c8829df9110c4ecc..405ed30963a93903d199a3f403931e4069b8232d 100644 (file)
--- a/ppp.c
+++ b/ppp.c
@@ -501,13 +501,16 @@ static int queue_config_request(struct openconnect_info *vpninfo, int proto)
        case PPP_LCP:
                ncp = &ppp->lcp;
                if (!vpninfo->ip_info.mtu) {
-                       vpninfo->ip_info.mtu = calculate_mtu(vpninfo, 0 /* not UDP */,
-                                                            /* 1-byte PPP header with ACCOMP, PFCOMP; 4-bytes HDLC framing and FCS */
-                                                            ppp->encap_len + 1 + (ppp->hdlc ? 4 : 0),
-                                                            0, 1); /* no footer or block padding */
-                       /* XX: HDLC fudge factor (average overhead on random payload is 1/128, we'll use more like 2%) */
+                       int overhead = TLS_OVERHEAD + ppp->encap_len        /* TLS and encapsulation overhead */
+                               + (ppp->hdlc ? 4 : 0)                       /* HDLC framing and FCS */
+                               + (ppp->out_lcp_opts & BIT_ACCOMP ? 0 : 2)  /* PPP header AC fields */
+                               + (ppp->out_lcp_opts & BIT_PFCOMP ? 1 : 2); /* PPP header protocol field */
+                       vpninfo->ip_info.mtu = calculate_mtu(vpninfo, 0 /* not UDP */, overhead, 0 /* no footer */, 1 /* no block padding */);
+                       /* XX: HDLC fudge factor (average overhead on random payload is 1/128, we'll use 4x that) */
                        if (ppp->hdlc)
-                               vpninfo->ip_info.mtu -= vpninfo->ip_info.mtu / 50;
+                               vpninfo->ip_info.mtu -= vpninfo->ip_info.mtu >> 5;
+                       vpn_progress(vpninfo, PRG_INFO,
+                                    _("Requesting calculated MTU of %d\n"), vpninfo->ip_info.mtu);
                }
 
                if (ppp->out_lcp_opts & BIT_MRU)