50 Commits

Author SHA1 Message Date
Hauke Mehrtens
708a76faa7 build: require CMake >= 3.10 due to dropped legacy support
CMake version 4.0 and later require minimum version of 3.5 or later.
Update to minimum version 3.10 which is the last not deprecated minimum
version.

CMake 3.10 was released in November 2017 and is included in Ubuntu 18.04.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-10-04 13:37:32 +02:00
Hauke Mehrtens
f646ba4048 route: Fix compile warning with glibc
This fixes the following compile problem:
````
/route.c: In function 'rtnl_flush':
/route.c:45:15: error: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Werror=unused-result]
   45 |         (void)write(fd, "-1", 2);
      |               ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.
````

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2023-01-21 18:48:09 +01:00
Kevin Darbyshire-Bryant
f4d759be54 dhcp.c: further improve validation
Add 2 more length/bounds checks with thanks to
Guido Vranken <guido@guidovranken.com>

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
2020-04-24 11:18:34 +01:00
Kevin Darbyshire-Bryant
796da66abd dhcp.c: improve input validation & length checks
Improve data & structure length validation.

Addresses CVE-2020-11752

Thanks to Guido Vranken <guido@guidovranken.com> for the report who
requested credit be given to 'ForAllSecure Mayhem'.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
2020-04-19 21:51:38 +01:00
Felix Fietkau
ad0b25ad74 relayd: put rule requests on stack
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-02-07 21:34:33 +01:00
Felix Fietkau
033df370f7 fix attribute alignment for rules
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-02-07 20:46:03 +01:00
Felix Fietkau
35cc60dc4d rules: process rules after the local table to ensure that local access still works
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-02-05 16:54:27 +01:00
Markus
5bd3096cf8 main: avoid adding redundant interfaces
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-02-03 14:35:48 +01:00
Felix Fietkau
83dba5d525 main: fix ip address copy length in send_arp_request
Detected by Coverity CID 1331153, 1331152, 1331125

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-10-29 15:28:31 +01:00
Felix Fietkau
336dc6465e route: fix an uninitialized variable
Detected by Coverity CID 1331189

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-10-29 15:24:35 +01:00
Felix Fietkau
cb92ddd6c2 main: fix uninitialized variable
Detected by Coverity CID 1331190

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-10-29 15:24:16 +01:00
Alejandro Enrique
2970ff60ba Add command line argument to disable DHCP options parsing
Default routes added when parsing DHCP options are problematic on
setups where there are more interfaces than those being managed by
relayd. A default route on the routing table used for locally
generated traffic makes the traffic addressed to not managed local
networks to be sent out using that default route instead of being
properly routed.

Disabling DHCP options parsing prevents the introduction of a default
route, that way the traffic addressed to not managed local networks is
routed using the main routing table.

Signed-off-by: Alejandro Enrique <alejandro.enrique@fon.com>
2015-03-13 00:23:14 +01:00
Alejandro Enrique
a1ecc7303a Fix deletion of routing policy rules when terminating due to a signal
This patch fix routing policy rules not being deleted on termination
due to SIGTERM, SIGHUP, SIGUSR1 or SIGUSR2.
Calling uloop_end makes the call to uloop_run on main to finish and
the process to exit calling the proper cleaning functions.

Signed-off-by: Alejandro Enrique <alejandro.enrique@fon.com>
2015-02-13 11:02:28 +11:00
Alejandro Enrique
b12322b8e1 improve host detection on interface change
This patch improve host detection and refresh when it moves from and
interface to another by pinging for it on all managed interfaces.

Previous to this patch host expiration was done by pinging for it on
the last interface it was known to be. If it does not reply after a
number of retries it will be expired and its entries
deleted. Nevertheless, if the host has moved to another managed
interface it will not be detected until there is some ARP packet sent
by the host.

This detection can be improved by pinging for the host on all managed
interfaces instead of just the one where it is supposed to be
connected, as it will reply to the ARP ping on the new interface it is
connected to and a host refresh will be triggered.

Signed-off-by: Alejandro Enrique <alejandro.enrique@fon.com>
2015-02-11 21:08:35 +11:00
Alejandro Enrique
d49528ef9c fix missing -p command line argument
Option -p was not being accepted as it was missing in getopt parameter
list

Signed-off-by: Alejandro Enrique <alejandro.enrique@fon.com>
2015-02-11 21:08:28 +11:00
Alejandro Enrique
b00da24550 add host route on local ip arp request
This patch fixes relayd not adding a host on an ARP request for the local
IP address.
When relayd is launched using the -L option, it was not adding the
necessary host routes when it receives an ARP request for the local
IP address.

This issue makes a host not able to connect to the device running
relayd until there is ARP traffic involving a third host.

Signed-off-by: Alejandro Enrique <alejandro.enrique@fon.com>
2015-02-11 21:08:22 +11:00
Felix Fietkau
767c54d595 route: fix an error with strict-aliasing
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-10-05 13:01:17 +02:00
Felix Fietkau
8b20ffae06 dhcp.c: add _GNU_SOURCE define to fix build error with musl
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-06-29 22:59:05 +02:00
Felix Fietkau
713258fb9a relay multicast packets along with broadcast packets
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-06-13 12:09:04 +02:00
Jo-Philipp Wich
4e8f1fa4ca route.c: include time.h, required for eglibc and glibc based systems 2011-10-24 19:01:28 +02:00
Felix Fietkau
40fa5c7dfb do not include linux/neighbour.h, it is unused 2011-08-28 18:21:59 +02:00
Felix Fietkau
aeb49d61c2 add cmake, use libubox for uloop and list.h 2011-02-07 19:11:44 +01:00
Felix Fietkau
caf4d30c66 uloop timer: update the timeout->next->prev when adding timeout to the list 2010-10-11 17:12:03 +02:00
Felix Fietkau
57371a9511 improve the reliability of gratuitous arp by sending both request and reply, also set the target hardware address to broadcast 2010-08-30 14:56:25 +02:00
Felix Fietkau
70672f4277 reset mac addresses when relaying arp requests 2010-08-30 11:19:10 +02:00
Felix Fietkau
d724a61b09 send gratuitous ARP whenever a host entry is refreshed 2010-08-27 21:55:36 +02:00
Felix Fietkau
d515c3bc3b use requests only for creating new host entries, not for refreshing them 2010-08-27 21:43:39 +02:00
Felix Fietkau
931b54fa98 decrease host timeout, add more ping tries and make them configurable 2010-08-27 21:34:16 +02:00
Felix Fietkau
3771bad14d send gratuitous arp on refresh cycles 2010-08-27 21:30:50 +02:00
Felix Fietkau
bdc7dd27a9 respond to arp requests to the local address 2010-08-27 21:09:36 +02:00
Felix Fietkau
ac87fbca7d implement local ip access through policy routing 2010-08-27 21:09:19 +02:00
Felix Fietkau
82c536bbfc rule: two boolean parameters with a flags field 2010-08-27 19:20:11 +02:00
Felix Fietkau
35e76b5535 split off code for sending an rtnl dump request 2010-08-27 00:01:23 +02:00
Felix Fietkau
a3f86cd20c Implement an option for setting static routes with gateway 2010-08-17 19:46:41 +02:00
Felix Fietkau
71986c610a Implement a workaround for the policy routing gateway bug
A host route must be reachable from the default rule lookup when using it
to set a gateway, so before we can add a route with a gateway, we temporarily
inject a bogus IP rule pointing at the correct table.
As soon as the route is set, we can remove the bogus IP rule.
2010-08-17 19:31:15 +02:00
Felix Fietkau
000bd94557 Add default gateway and DHCP handling (not fully working yet because of a kernel bug) 2010-08-17 19:31:14 +02:00
Felix Fietkau
11104933ca Split DHCP code off into a separate source code file 2010-08-16 21:45:52 +02:00
Felix Fietkau
05a40ea28d Use policy routing to limit the scope of the host routes to affected interfaces 2010-08-11 18:56:01 +02:00
Felix Fietkau
c4d021d680 Cancel pending timeouts before freeing hosts 2010-08-11 18:41:43 +02:00
Felix Fietkau
374b6a36ab Fix interface list definition 2010-08-11 18:21:18 +02:00
Felix Fietkau
eac0b3af3c Preinitialize more fields of the RTNL request 2010-08-11 18:21:14 +02:00
Felix Fietkau
6a7581ccbd Flush the route cache after changing routes 2010-08-11 17:47:54 +02:00
Felix Fietkau
b4ba9ff8cb Move the rtnl code to a separate source file 2010-08-11 12:41:24 +02:00
Felix Fietkau
1ee606df2f Move some data structures and definitions to a header file 2010-08-11 12:31:02 +02:00
Felix Fietkau
50aa78eaed Do not forward ARP responses to the interface that they came from 2010-08-11 11:12:12 +02:00
Felix Fietkau
fba3e8d167 Learn the ARP entry of the DHCP server directly from the DHCP response 2010-08-11 04:12:17 +02:00
Felix Fietkau
3f423febf3 CFLAGS: use -Os instead of -O2 2010-08-11 01:58:41 +02:00
Felix Fietkau
e4e00ebf1e Add a copyright header (GPL v2) 2010-08-11 01:58:19 +02:00
Felix Fietkau
bb8bc49b9f Add LDFLAGS to the Makefile 2010-08-11 01:49:11 +02:00
Felix Fietkau
5455abb3e5 Initial import 2010-08-11 01:44:32 +02:00