Be less strict on filtering UPnP probe responses
A notable population of upnp devices respond using a non-standard srcport.
This commit removes the check for srcport == targetport for the validity checks,
leaving the decision of validity to the packet processor.
@@ -67,28 +67,6 @@ int upnp_init_perthread(void *buf, macaddr_t *src, macaddr_t *gw,
return EXIT_SUCCESS;
}
-int upnp_validate_packet(const struct ip *ip_hdr, uint32_t len,
- uint32_t *src_ip, uint32_t *validation)
-{
- if (!udp_validate_packet(ip_hdr, len, src_ip, validation)) {
- return 0;
- }
- if (ip_hdr->ip_p == IPPROTO_UDP) {
- struct udphdr *udp =
- (struct udphdr *)((char *)ip_hdr + ip_hdr->ip_hl * 4);
- uint16_t sport = ntohs(udp->uh_sport);
- if (sport != zconf.target_port) {
- return 0;
- }
- size_t expected_length =
- 4 * ip_hdr->ip_hl + ntohs(udp->uh_ulen);
- if (expected_length > len) {
- return 0;
- }
- }
- return 1;
-}
-
void upnp_process_packet(const u_char *packet,
__attribute__((unused)) uint32_t len, fieldset_t *fs,
__attribute__((unused)) uint32_t *validation)
@@ -294,7 +272,7 @@ probe_module_t module_upnp = {
.make_packet = &udp_make_packet,
.print_packet = &udp_print_packet,
.process_packet = &upnp_process_packet,
- .validate_packet = &upnp_validate_packet,
+ .validate_packet = &udp_validate_packet,
// UPnP isn't actually dynamic, however, we don't handle escaping
// properly in the CSV module and this will force users to use JSON.
.output_type = OUTPUT_TYPE_DYNAMIC,
