Skip to content

When receiving packets, the network interface looks for general associations before specific associations #2608

@stevenengler

Description

@stevenengler

In _networkinterface_process_packet_in, the network interface first checks for an association with the key _networkinterface_getAssociationKey(interface, ptype, bindPort, 0, 0), then if an association isn't found checks again with the key _networkinterface_getAssociationKey(interface, ptype, bindPort, peerIP, peerPort).

/* the first check is for servers who don't associate with specific destinations */
gchar* key = _networkinterface_getAssociationKey(interface, ptype, bindPort, 0, 0);
trace("looking for socket associated with general key %s", key);
CompatSocket socket = _boundsockets_lookup(interface->boundSockets, key);
g_free(key);
if (socket.type == CST_NONE) {
/* now check the destination-specific key */
in_addr_t peerIP = packet_getSourceIP(packet);
in_port_t peerPort = packet_getSourcePort(packet);
key = _networkinterface_getAssociationKey(interface, ptype, bindPort, peerIP, peerPort);
trace("looking for socket associated with specific key %s", key);
socket = _boundsockets_lookup(interface->boundSockets, key);
g_free(key);
}

This seems backwards, and we should be checking for the more specific association first before the wildcard association. This would also allow us to associate child TCP sockets and have those sockets receive packets directly, rather than the current method of having the server socket receive all packets and forward them to the corresponding child socket.

This affects #2593.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugError or flaw producing unexpected results

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions