Commit graph

60 commits

Author SHA1 Message Date
David Cermak
6ace6fbd85 mdns: respond to discovery with the proper pseudo name _services._dns-sd._udp
Closes https://github.com/espressif/esp-idf/issues/4369
Closes IDFGH-2219
2020-01-08 10:22:10 +01:00
Marius Vikhammer
7b7f597cb4 mdns: fix crash for hostname queries
Receiving TXT, PTR, SDPTR and SRV record type queries would crash the application if the hostname
 was used as instance name.

Closes https://github.com/espressif/esp-idf/issues/4224
2019-10-29 10:49:45 +00:00
David Cermak
936b99d756 mdns: fix possible crash when probing on particular interface with duplicated service instances due to naming conflicts on network
Issue: MDNS server initially sends probing packets to resolve naming confilicts with already registered service instances. In case of a conflict, instance name is altered and probing restarts. Original instance however wasnnot removed from the structure and upon service removal only one entry was removed and a dangling service might have been kept in the structure to bring about a crash.
Resolution: Keep only one instance of a service in the probing structure.

Closes IDF-498
2019-03-13 16:10:27 +01:00
David Cermak
c88cc4950e mdns: enable pcbs before starting service thread to avoid updating pcb's internal variables from concurent tasks
possible race condition: user task runs mdns_init, which enables pcbs while mdns-task already created could execute enable/disable of the same pcbs if an appropriate system event received
2019-03-13 16:10:16 +01:00
David Cermak
54e5e440b1 mdns: fix possible deadlock on mdns deinit calling mdns_free()
mnds_free() initiates stop and delete timer tasks, which after locking the mutex could lead to a dead lock in case timer task executed before deleting the task, as it would wait indefinitelly for unlocking the mutex. This condition is fixed by calling _mdns_stop_timer without locking the mutex, because there's no need to protect any data when stopping and deleting the timer task

Closes https://github.com/espressif/esp-idf/issues/1696
2019-03-13 16:10:03 +01:00
David Cermak
e8bcda3512 mdsn: fix race condition in updating packet data from user task when failed to allocate or queue a new service
Issue: mdns_service_add API allocates and queues an action to be processed in mdns task context; when allocation or queueing fails, allocated structure needs to be freed. Function _mdns_free_service did not only fee all the structures, but also updates packet data.
Resolution: Moved removal of packet data outside of _mdns_free_service function.
2019-03-13 16:09:51 +01:00
David Cermak
35a30072f4 mdns: fix possible crash when packet scheduled to transmit contained service which might have been already removed
packets scheduled to transmit are pushed to action queue and removed from tx_queue_head structure, which is searched for all remaining services and while service is removed, then service questions/asnwers are also removed from this structure. This update fixes possible crash when packet is pushed to action queue, and when service is removed, its answers are removed from tx_queue_head, but not from action queue. this could lead to a crash when the packet is poped from action queue containing questions/answers to already removed (freed) service

Closes IDF-504
2019-03-13 16:09:41 +01:00
Ivan Grokhotkov
eef0b5090a mdns: use binary semaphore instead of mutex when searching
mdns_search_once_t::lock is used to synchronize tasks (taken by one
task and given by the other) so it should not be a mutex.
Convert to semaphore, and rename to indicate its purpose.
2019-03-12 09:33:06 +01:00
David Cermak
8462751f95 mdns: fix memory leak in pbuf if tcpipadapter failed to get netif 2019-02-15 15:59:11 +01:00
David Cermak
1a027734af mdns: fix malfuctional query_txt
when running a query for a single txt, result entries were not created and attached to result structure. this issue was introduced when fixing memory leak in txt structure, which worked correctly for PTR queries, but caused trouble for TXT query.
2019-02-15 13:46:51 +01:00
David Cermak
206b47c03a mdns: fix possible crash when mdns_free called while action queue not empty 2019-02-15 13:23:21 +01:00
David Cermak
9a4da97fb4 mdns: fix memory leak when query for service receives multiple ptr entries for one instance
fixes redmine issue 27300
2019-02-15 07:56:03 +01:00
David Cermak
a47768dc4e mdns: fix crash after init if no memory for task
mdns init first starts timer task, then starts service task. if service task failed to be created, timer task needs to be stopped too.
fixed https://ezredmine.espressif.cn:8765/issues/28466
2019-01-30 08:17:37 +01:00
Angus Gratton
784fc51931 Merge branch 'bugfix/mdns_crash_free_strdup' into 'master'
mdns: fixed crash on free undefined ptr if strdup is skipped

See merge request idf/esp-idf!4173
2019-01-30 09:33:12 +08:00
Roland Dobai
37126d3451 Correct Kconfigs according to the coding style 2019-01-29 13:37:01 +01:00
David Cermak
e0a8044a16 mdns: fixed crash on free undefined ptr after skipped strdup
Shortcircuit evaluation may cause skip of _mdns_strdup_check of any further question field, which after clear_rx_packet freed undefined memory.
Fixes https://ezredmine.espressif.cn:8765/issues/28465
2019-01-29 10:10:38 +01:00
David Cermak
f7d4a4be6a mdns: fix networking running udp_sendif from lwip thread 2019-01-03 14:28:29 +01:00
David Cermak
6bb68a5a75 mdns: fixed static memory leak 2018-12-17 12:09:23 +01:00
David Cermak
c8cb4cd3c8 mdns: check all mallocs for failure and add default hook to log error with free heap
solves crash about _mdns_result_txt_create when stress test
2018-12-17 12:09:11 +01:00
David Cermak
a6b2b73f03 mdns: resolve memory leak when txt record received multiple times 2018-12-11 21:59:44 +01:00
David Cermak
31163f02d5 mdns: skip sending search when finished, not properly locked timer task 2018-12-11 21:56:01 +01:00
David Cermak
d16762a036 mdns: sending search packets also in probing and announcing state
mdns queries did not work properly when send imeadiately after set_hostname, which cuased reinit of pcb and therefore restarted probing, so search packets were blocked until probing finished
closes #2507, closes #2593
2018-11-16 07:22:29 +00:00
David Cermak
097282a8e3 mdns: fixed crashes on network changes
1) two events AP_STOP, AP_START shortly after each other may cause IGMP config on already stopped netif
2) not properly locked sending packets to queue from timer task

closes #2580
2018-10-24 12:03:41 +02:00
Ivan Grokhotkov
49125a87bb Merge branch 'bugfix/mdns-lwip-update' into 'master'
Update network code for mDNS to work with newest LwIP

See merge request idf/esp-idf!3268
2018-09-17 10:42:04 +08:00
me-no-dev
3ec0e7e2d2 Update network code for mDNS to work with newest LwIP
- Uses one PCB that listens to all interfaces
- Manages multicast groups for each interface
2018-09-14 11:02:47 +02:00
Liu Han
3d4deb9726 feat(mdns): fix bug when clean action memory 2018-09-14 15:36:52 +08:00
Piyush Shah
e5e2702ca3 bugfix: mdns_service_txt_set() wasn't allocating memory for TXT records
Allocation was happening later, causing possible use of stack variables
of caller function, which could be invalid.

Signed-off-by: Piyush Shah <piyush@espressif.com>
2018-09-11 16:23:56 +05:30
Renz Christian Bagaporo
d9939cedd9 cmake: make main a component again 2018-09-11 09:44:12 +08:00
Angus Gratton
cff2ef695a Merge branch 'master' into feature/cmake 2018-09-06 20:23:04 +08:00
Zhang Yan Jiao
3578fe39e0 Feature/sync lwip as submodule 2018-09-06 19:43:08 +08:00
Angus Gratton
ff2404a272 Merge branch 'master' into feature/cmake 2018-08-16 17:14:17 +10:00
Liu Han
f3f0445f4d mdns: Fix a portion of the queries are issued with the wildcard query type 2018-08-14 07:25:08 +00:00
David Cermak
0c147648f7 added CI job for AFL fuzzer tests 2018-07-20 10:28:12 +02:00
Angus Gratton
fe1ffb3d1c Merge branch 'bugfix/mdns_remove' into 'master'
mdns: Minor fix for mdns_service_remove()

See merge request idf/esp-idf!2760
2018-07-16 16:29:20 +08:00
Piyush Shah
5c7eb7e27b mdns: Minor fix for mdns_service_remove()
Send the Goodbye packet while removing an mDNS service as an "Authoritative" packet so
that the listeners remove the service from their records immediately.
2018-07-12 19:18:54 +05:30
Angus Gratton
a67d5d89e0 Replace all DOS line endings with Unix
Command run was:
git ls-tree -r HEAD --name-only | xargs dos2unix
2018-07-12 19:10:37 +08:00
Liu Han
ba458c69cf fix(mdns): add the maximum number of services 2018-06-21 10:31:09 +08:00
Liu Han
696d733eb0 fix(mdns): fix the exception when remove one of multiple service 2018-06-03 17:29:49 +08:00
Angus Gratton
6b9784cc45 Merge branch 'master' into feature/cmake_update 2018-05-31 14:46:23 +10:00
Ivan Grokhotkov
cb649e452f remove executable permission from source files 2018-05-29 20:07:45 +08:00
David Cermak
fffbf7b750 Fixed nullptr dereference in MDNS.c 2018-05-22 11:23:12 +02:00
David Cermak
e983230be9 MDNS-Fuzzer: AFL fuzzer tests for mdsn packet parser 2018-05-22 11:23:12 +02:00
Angus Gratton
1cb5712463 cmake: Add component dependency support
Components should set the COMPONENT_REQUIRES & COMPONENT_PRIVATE_REQUIRES variables to define their
requirements.
2018-04-30 09:59:20 +10:00
Angus Gratton
4f1a856dbf cmake: Remove defaults for COMPONENT_SRCDIRS, COMPONENT_SRCS, COMPONENT_ADD_INCLUDEDIRS
* Philosophical: "explicit is better than implicit".
* Practical: Allows useful errors if invalid directories given in components as the defaults aren't
  always used. Also trims the -I path from a number of components that have no actual include
  directory.
* Simplifies knowing which components will be header-only and which won't
2018-04-30 09:59:20 +10:00
Angus Gratton
c671a0c3eb build system: Initial cmake support, work in progress 2018-04-30 09:59:20 +10:00
jack
81e4cad615 fix the bug that in mdns test code redefine esp_err_t to uint32_t, which should be int32_t 2018-04-25 21:05:21 +08:00
me-no-dev
421c6f154b Fix exception when service is removed while there are pending packets that depend on it 2018-04-09 09:40:08 +03:00
me-no-dev
4fa130ae4f mdns: Fix case where service is NULL and that will cause exception 2018-01-22 13:56:53 +01:00
me-no-dev
51dde19a76 mdns: Fix issue with some mDNS parsers
Some mDNS parser have issue with zero terminated TXT lists. This fix targets to overcome this issue. Found and tested with jmdns.
2018-01-22 13:56:34 +01:00
me-no-dev
4bddbc031c Import mDNS changes 2018-01-16 10:58:34 +02:00