Compute MTU only with usable paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
21
mud.c
21
mud.c
@@ -449,9 +449,9 @@ mud_get_path(struct mud *mud, struct sockaddr_storage *local_addr,
|
|||||||
for (unsigned i = 0; i < mud->count; i++) {
|
for (unsigned i = 0; i < mud->count; i++) {
|
||||||
struct mud_path *path = &mud->paths[i];
|
struct mud_path *path = &mud->paths[i];
|
||||||
|
|
||||||
if (path->state &&
|
if ((path->state != MUD_EMPTY) &&
|
||||||
!mud_cmp_addr(local_addr, &path->local_addr) &&
|
(!mud_cmp_addr(local_addr, &path->local_addr)) &&
|
||||||
!mud_cmp_addr(addr, &path->addr))
|
(!mud_cmp_addr(addr, &path->addr)))
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,20 +673,23 @@ mud_set_state(struct mud *mud, struct sockaddr *peer, enum mud_state state)
|
|||||||
size_t
|
size_t
|
||||||
mud_get_mtu(struct mud *mud)
|
mud_get_mtu(struct mud *mud)
|
||||||
{
|
{
|
||||||
size_t mtu;
|
size_t mtu = MUD_PACKET_MAX_SIZE;
|
||||||
|
unsigned count = 0;
|
||||||
if (mud->count) {
|
|
||||||
mtu = MUD_PACKET_MAX_SIZE;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < mud->count; i++) {
|
for (unsigned i = 0; i < mud->count; i++) {
|
||||||
struct mud_path *path = &mud->paths[i];
|
struct mud_path *path = &mud->paths[i];
|
||||||
|
|
||||||
|
if (path->state <= MUD_DOWN)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
count++;
|
||||||
|
|
||||||
if (mtu > path->mtu.ok)
|
if (mtu > path->mtu.ok)
|
||||||
mtu = path->mtu.ok;
|
mtu = path->mtu.ok;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
if (!count)
|
||||||
mtu = mud->mtu;
|
mtu = mud->mtu;
|
||||||
}
|
|
||||||
|
|
||||||
if (mtu > MUD_PACKET_MAX_SIZE)
|
if (mtu > MUD_PACKET_MAX_SIZE)
|
||||||
mtu = MUD_PACKET_MAX_SIZE;
|
mtu = MUD_PACKET_MAX_SIZE;
|
||||||
|
|||||||
Reference in New Issue
Block a user