<p></p>
<p dir="auto">I have been exploring the code to find a place to send with a lower MTU than the MRU for a socket.  That is probably more efficient than learning about Path MTU on every sending attempt.  <strong>Feedback welcomed!</strong></p>
<p dir="auto">I think an extension to <code class="notranslate">struct socket_info</code> with <code class="notranslate">socket</code> as default socket and a new field <code class="notranslate">socket_mtu</code> as an outbound override could help.  It could be setup when <code class="notranslate">udp_mtu</code> is set (or maybe when <code class="notranslate">listen</code> has an extra <code class="notranslate">mtu 1234</code> parameter).  Cleanup would recognise <code class="notranslate">socket != socket_mtu</code> as a special case in which the secondary needed cleanup.  The extra field could be setup in <code class="notranslate">udp_init()</code> and trivially copied in the other <code class="notranslate">core/xxx_server.c</code> variants, so sending can always use <code class="notranslate">socket_mtu</code> instead of the receiving side, <code class="notranslate">socket</code> itself, with its unbounded MTU.</p>
<p dir="auto">My work now is to construct dual sockets, set different MTUs and see this idea work.  I will do that in the <a href="https://gitlab.com/0cpm/mtugames/-/blob/master/veth/experiment.md" rel="nofollow">MTU games</a> repo.</p>
<h3 dir="auto">Notes:</h3>
<ul dir="auto">
<li>It is not currently meaningful to configure <code class="notranslate">udp_mtu</code> but not <code class="notranslate">udp_mtu_try_proto</code>.  Indeed, the <a href="https://github.com/kamailio/kamailio/blob/d5c1b4693b6e47b4123b5f9417b5fd88d4dafd1f/src/core/msg_translator.c#L126-L129">code confirms</a> ignoring that situation.  Precisely this configuration could give rise to transmission over a secondary socket with reduced MTU.  This code might therefore set  a flag <code class="notranslate">FL_MTU_UDP_FB</code> (that is part of the <code class="notranslate">FL_MTU_FB_MASK</code>).</li>
<li>This flag is used to <a href="https://github.com/kamailio/kamailio/blob/d5c1b4693b6e47b4123b5f9417b5fd88d4dafd1f/src/core/msg_translator.c#L2177-L2217">determine the sending socket</a> for a message, via <code class="notranslate">di.proto</code> and <code class="notranslate">di.send_sock</code> and delivered into <code class="notranslate">send_info->proto</code> and <code class="notranslate">send_info->send_sock</code>.  An extra case for <code class="notranslate">FL_MTU_UDP_FB</code> could be added here.</li>
<li>The routine <a href="https://github.com/kamailio/kamailio/blob/c282b5812c9e9badb4c99fe8ce3bd5cce927044f/src/core/forward.c#L210"><code class="notranslate">get_send_socket2()</code></a> finds a <a href="https://github.com/kamailio/kamailio/blob/a0d89214cf8296d30bacdf10a8732bc8826b2418/src/core/ip_addr.h#L111-L135"><code class="notranslate">struct socket_info</code></a> to send over.  Assuming non-forced socket, for single-homed systems, this is the static value in <code class="notranslate">sendipv6</code>, for multi-homed systems it is determined with <code class="notranslate">get_out_socket()</code> which uses <a href="https://github.com/kamailio/kamailio/blob/a1ea2c0d49f56154af5ba1028d7340ea3ed1ae42/src/core/socket_info.c#L1011"><code class="notranslate">find_si()</code></a> to locate a configured socket.</li>
<li>It would be possible to have <a href="https://github.com/kamailio/kamailio/blob/a0d89214cf8296d30bacdf10a8732bc8826b2418/src/core/ip_addr.h#L112"><code class="notranslate">socket</code></a> for its current use, but for UDP allow an alternative socket <code class="notranslate">socket_mtu</code> to be set to the same coordinates (in the remainder of the structure) but a lower MTU value, namely to the <code class="notranslate">udp_mtu</code> value.  Sending would prefer this socket (if set, that is, if >= 0) but receiving would continue to use the default MRU (namely the interface MTU).  <em>Being conservative in what we send, liberal in what we accept.</em></li>
<li>This additional <code class="notranslate">socket_mtu</code> element would be added in <a href="https://github.com/kamailio/kamailio/blob/a0d89214cf8296d30bacdf10a8732bc8826b2418/src/core/udp_server.c#L277"><code class="notranslate">udp_init()</code></a> when <code class="notranslate">udp_mtu</code> is set.</li>
<li>Future options <code class="notranslate">mtu 1234</code> after a <code class="notranslate">listen</code> declaration may set a socket-specific MTU (and leave the MRU unchanged).</li>
<li>I doubt if such conservative-low MTU knowledge would benefit TCP and TLS.  If it is, then this approach could be replicated.  But more likely is that the interactive nature of these protocols benefits from an explicit in-situ learning process.</li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/3119#issuecomment-1140227414">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZLR2ZAKZYWDY5QV2SLVMHWA5ANCNFSM5WOTUNDA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZLDVPQO4433JNXP3ATVMHWA5A5CNFSM5WOTUNDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIP3H2VQ.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/issues/3119/1140227414</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/3119#issuecomment-1140227414",
"url": "https://github.com/kamailio/kamailio/issues/3119#issuecomment-1140227414",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>