+bool mtu_info_h(connection_t *c, const char *request) {
+ char from_name[MAX_STRING_SIZE];
+ char to_name[MAX_STRING_SIZE];
+ int mtu;
+
+ if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" %d", from_name, to_name, &mtu) != 3) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "MTU_INFO", c->name, c->hostname);
+ return false;
+ }
+
+ if(mtu < 512) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "MTU_INFO", c->name, c->hostname, "invalid MTU");
+ return false;
+ }
+
+ mtu = MIN(mtu, MTU);
+
+ if(!check_id(from_name) || !check_id(to_name)) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "MTU_INFO", c->name, c->hostname, "invalid name");
+ return false;
+ }
+
+ node_t *from = lookup_node(from_name);
+
+ if(!from) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", "MTU_INFO", c->name, c->hostname, from_name);
+ return true;
+ }
+
+ /* If we don't know the current MTU for that node, use the one we received.
+ Even if we're about to make our own measurements, the value we got from downstream nodes should be pretty close
+ so it's a good idea to use it in the mean time. */
+ if(from->mtu != mtu && from->minmtu != from->maxmtu) {
+ logger(DEBUG_TRAFFIC, LOG_INFO, "Using provisional MTU %d for node %s (%s)", mtu, from->name, from->hostname);
+ from->mtu = mtu;
+ }