summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* 1.8 releaseHEADv1.8masterJiri Pirko2021-05-201-4/+4
| | | | Signed-off-by: Jiri Pirko <jiri@nvidia.com>
* libndp,ndptool: use poll() instead of select()Beniamino Galvani2021-03-053-25/+19
| | | | | | | | | | | select() doesn't support file descriptors greater than 1023. If the program has many files open, the socket descriptor can be > 1023 and then FD_SET(fd, &rfds) causes a buffer overflow. Switch to poll() and ppoll() which don't have this limitation. Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
* libndp: avoid static buffer for debug string in ndp_sock_recv()Thomas Haller2021-01-281-5/+4
| | | | | | | | libndp should be thread safe. There is really no need to use a static buffer in this case. Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
* ndptool: avoid static buffer for string in ndptoolThomas Haller2021-01-281-8/+7
| | | | | | | | | ndptool is of single threaded, so there is no actual problem here. However, I think it not best to use static variables, and in this case it can be easily avoided. Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
* libndp: use thread local variables for static return argumentsThomas Haller2021-01-272-3/+4
| | | | | | | | | | | | | | | | | | | | | libndp should be thread safe. That doesn't mean, that one "struct ndp" can be used by multiple threads without locking. But it should be reasonably possible to use the library in a multi threaded scenario. Some API functions return values that are cached in static variables. That makes these function (and the entire library) not thread safe. Fix that by using gcc's __thread specifier for thread local storage. This is also supported by clang. Currently, it's not clear whether all compiler that libndp supports, support this. I expect that to be the case. Hence, the NDP_THREAD define does not try to workaround such (yet unknown) build environments. However, if the need arises, we can easily extend the NDP_THREAD define with some conditional compilation. Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
* ndptool: don't use static variable for local context in msgrcv_handler_func()Thomas Haller2021-01-271-1/+1
| | | | | | | | ndptool is single threaded, so this isn't an actual issue. But it's ugly and unnecessary. Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
* ndptool: fix printing dnssl lifetime in ndptoolThomas Haller2021-01-271-1/+1
| | | | | Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
* ndptool: fix potential memory leak caused by strdupHangbin Liu2019-09-241-3/+8
| | | | | | | | | We use strdup to copy the parameters. As strdup will call malloc when obtain the memory, we need to free them before exit, or there will be memory leak. This is found by covscan. Signed-off-by: Hangbin Liu <haliu@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* ndptool: add -D dest supportHangbin Liu2019-09-164-25/+73
| | | | | | | | | | | | | | This patch add -D dest option, with this option a user could set the dest address in IPv6 header for solicited NS/NA message For function ndp_msg_addrto_adjust_solicit_multi(), I moved the check in ndp_msg_target_set() instead of in the function itself. I also use reverse christmas tree variable order in the main() function of ndptool.c. Signed-off-by: Hangbin Liu <haliu@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndp: fix nd_msg typo when setting target addressHangbin Liu2019-09-121-2/+2
| | | | | | | | When setting the target address of nd_msg, I set the ns/na type reversed. Fixes: acccd780df517 ("ndptool: add -T target support") Signed-off-by: Hangbin Liu <haliu@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndp: close sockfd after using to avoid handle leakHangbin Liu2019-01-071-4/+8
| | | | | | Fixes: acccd780df517 ("ndptool: add -T target support") Signed-off-by: Hangbin Liu <haliu@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* ndptool: fix target parameter typoHangbin Liu2018-12-171-1/+1
| | | | | | | | | In my last commit acccd780df517 ("ndptool: add -T target support"), after renaming parameter -d to -T. I forgot to change the name in switch opt. Fixes: acccd780df517 ("ndptool: add -T target support") Signed-off-by: Hangbin Liu <haliu@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* ndptool: add -T target supportHangbin Liu2018-08-064-3/+145
| | | | | | | | | | | | | | | | Currently ndptool can send a Neighbour Solicitation, but does not target an IP address, so the NS packet doesn't really make sense. Extend ndptool to target a destination for Neighbour Solicitation. v2: 1) remove function ipv6_addr_is_multicast() 2) inline some help functions. 3) update code style. 4) rename parameter -d/--dest to -T/--target Signed-off-by: Hangbin Liu <haliu@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* 1.7 releasev1.7Jiri Pirko2018-06-081-2/+2
| | | | Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndp: apply filter to raw socket to only accept ND messagesBeniamino Galvani2016-08-291-1/+13
| | | | | | | | | Use setsockopt() to set a filter on the socket and accept only Neighbor discover packets. This avoids wasting processing power on frames we're not interested in. Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndp: move ndp_sock_{open,close}() after msg parsing functionsBeniamino Galvani2016-08-291-53/+60
| | | | | | | | | In a following commit ndp_sock_open() will refer to ndp_msg_type_info_list to add a filter on handled ICMP types. Move the open and close functions below in a dedicated section. Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* ndptool: Fix compilation on musl libcKylie McClain2016-06-151-0/+1
| | | | | | | FD_ZERO, fd_set, etc are defined within sys/select.h on musl. Signed-off-by: Kylie McClain <somasis@exherbo.org> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* 1.6 releasev1.6Jiri Pirko2016-05-171-4/+4
| | | | Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndb: reject redirect and router advertisements from non-link-localLubomir Rintel2016-05-171-1/+13
| | | | | | | | | | RFC4861 suggests that these messages should only originate from link-local addresses in 6.1.2 (RA) and 8.1. (redirect): Mitigates CVE-2016-3698. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndp: validate the IPv6 hop limitLubomir Rintel2016-05-171-11/+40
| | | | | | | | | | | | | | | None of the NDP messages should ever come from a non-local network; as stated in RFC4861's 6.1.1 (RS), 6.1.2 (RA), 7.1.1 (NS), 7.1.2 (NA), and 8.1. (redirect): - The IP Hop Limit field has a value of 255, i.e., the packet could not possibly have been forwarded by a router. This fixes CVE-2016-3698. Reported by: Julien BERNARD <julien.bernard@viagenie.ca> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndp: revert API change for ndp_msg_send() and add ndp_msg_send_with_flags()Thomas Haller2016-03-103-3/+19
| | | | | | Fixes: cb1ab5fc8b ("libndp: add option flags to send messages") Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndp: fix type of field "na" in "struct ndp_msgna"Thomas Haller2016-03-101-1/+1
| | | | | | | | | | | | Otherwise, compilation fails since commit cb1ab5fc8b: libndp.c: In function ‘ndp_msgna_flag_router’: libndp.c:992:18: error: ‘struct nd_neighbor_solicit’ has no member named ‘nd_na_hdr’ return msgna->na->nd_na_flags_reserved & ND_NA_FLAG_ROUTER; Fixes: dfed476eee ("lib: setup first pointer in all type-specific structures at once") Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* ndptool: add option to send messages typesJamie Bainbridge2016-03-102-2/+14
| | | | | | | | | Use the new flags interface of message sending, implement sending Unsolicited NA in ndptool. -U was chosen to mirror established convention of unsolicited ARP in arping. Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* libndp: add option flags to send messagesJamie Bainbridge2016-03-102-3/+124
| | | | | | | | | | | | Within NA and RA message types, there are flags such as Solicited and Override (RFC-4861 Section 4). RA flags are currently implemented but not NA flags, so add remaining NA flag getters/setters. Set Solicited/Override flag on NA when appropriate, add a flags interface to the send API, and implement ability to send Unsolicited NA. Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* Add SubmittingPatches howtoJiri Pirko2015-12-051-0/+45
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* 1.5 releasev1.5Jiri Pirko2015-04-021-1/+1
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* update copyright datesJiri Pirko2015-04-026-6/+6
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* ndptool: use conventional signal handlers instead of signalfdAndrew Ayer2015-04-021-37/+31
| | | | | | | | signalfd() is Linux-specific. Using conventional signal handlers will allow ndptool to compile on non-Linux systems and old versions of Linux. Signed-off-by: Andrew Ayer <agwa@andrewayer.name> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* 1.4 releasev1.4Jiri Pirko2014-07-291-2/+2
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* libndp: fix buffer overflow in ndp_msg_opt_dnssl_domain()Andrew Ayer2014-07-291-6/+9
| | | | | | | | | | | The buf array would overflow when processing a malformed DNSSL option containing a domain name whose labels' combined length exceeded 255 bytes. To facilitate the bounds checking, the code has been restructured slightly to be simpler and avoid repeated calls to strlen and strcat. Signed-off-by: Andrew Ayer <agwa@andrewayer.name> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* 1.3 releasev1.3Jiri Pirko2014-06-261-2/+2
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* Add missing <stdarg.h> include for va_listYegor Yefremov2014-04-231-0/+1
| | | | | | Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* libndp: fix [cppcheck] Undefined behavior: Variable 'buf' is used as ↵Jiri Pirko2013-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | parameter and destination in s[n]printf() cppcheck --enable=all --inconclusive --std=posix . ndp_msg_opt_dnssl_domain(): if (dom_len > len) return NULL; if (strlen(buf)) ----> sprintf(buf, "%s.", buf); buf[strlen(buf) + dom_len] = '\0'; memcpy(buf + strlen(buf), ptr, dom_len); So just use strcat instead. Reported-by: Dan Williams <dcbw@redhat.com> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* 1.2 releasev1.2Jiri Pirko2013-10-151-1/+1
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* libndp: silently ignore packets with optlen 0Jiri Pirko2013-10-071-3/+10
| | | | | | as RFC 2461 requires. Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* libndp: fix processing for larger optionsJiri Pirko2013-10-071-2/+2
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* libndp: do not fail on receiving non-ndp packetsJiri Pirko2013-10-071-1/+3
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* 1.1 releasev1.1Jiri Pirko2013-10-041-1/+1
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* fix cflags path in pc fileJiri Pirko2013-08-161-1/+1
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* ndptool: fix -v argumentYanko Kaneti2013-08-081-1/+1
| | | | | Signed-off-by: Yanko Kaneti <yaneti@declera.com> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* README: remove copy&paste leftoversJiri Pirko2013-08-081-3/+0
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* update READMEJiri Pirko2013-08-081-6/+29
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* 1.0 releasev1.0Jiri Pirko2013-08-081-1/+1
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* put utils/ndptool into .gitignoreJiri Pirko2013-08-021-0/+1
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* fix configure.acJiri Pirko2013-07-192-2/+4
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* add flag getters for prefix optionJiri Pirko2013-06-133-0/+69
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* libndp: allow mysendto6() to fail when iface is down and for other errorsJiri Pirko2013-06-071-5/+0
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* libndp: add ndp_callall_eventfd_handler()Jiri Pirko2013-06-072-0/+35
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* fix compile error on ia32Jiri Pirko2013-05-042-2/+2
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>
* add missing list.h into Makefile.amJiri Pirko2013-04-171-1/+1
| | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us>