coturn icon indicating copy to clipboard operation
coturn copied to clipboard

Cumulative port allocation over uptime

Open Cybermilitia opened this issue 11 months ago • 1 comments

We observed an issue where Coturn has a cumulative hard limit over uptime. We created a traffic tool using turnutils_uclient. When I tried to simulate high traffic on the server, I realized that there is hard limit. After this limit, the coturn can not allocate the port since that moment.

In struct _turnports structure, we have two variable as uint32_t: high and low. The potential port number is high - low. When the coturn allocates a port, low value increases by one. When releases, high value increases by one. However, uint32_t can be 0xFFFFFFFF at max. So if we reaches this limit, I mean overflow situation, high is 0 and low is FFFFXXXX. So low is greater than high at this moment.

In turnports_allocate function,

  if (tp->high <= tp->low) {
    TURN_MUTEX_UNLOCK(&tp->mutex);
    return -1;
  }

So, after this moment, the coturn can not allocate ports.

I know this is a huge number. However, it's reachable.

Do you have any idea about this? It can be fixed.

Cybermilitia avatar Mar 03 '25 10:03 Cybermilitia