-
Notifications
You must be signed in to change notification settings - Fork 269
When receiving packets, the network interface looks for general associations before specific associations #2608
Description
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).
shadow/src/main/host/network_interface.c
Lines 258 to 274 in c44c5d7
| /* 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.