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>
-bool relayd_handle_dhcp_packet(struct relayd_interface *rif, void *data, int len, bool forward)
+bool relayd_handle_dhcp_packet(struct relayd_interface *rif, void *data, int len, bool forward, bool parse)
{
struct ip_packet *pkt = data;
struct udphdr *udp;
{
struct ip_packet *pkt = data;
struct udphdr *udp;
if (dhcp->op == 2) {
host = relayd_refresh_host(rif, pkt->eth.ether_shost, (void *) &pkt->iph.saddr);
if (dhcp->op == 2) {
host = relayd_refresh_host(rif, pkt->eth.ether_shost, (void *) &pkt->iph.saddr);
parse_dhcp_options(host, dhcp, udplen - sizeof(struct udphdr));
}
parse_dhcp_options(host, dhcp, udplen - sizeof(struct udphdr));
}
static int inet_sock;
static int forward_bcast;
static int forward_dhcp;
static int inet_sock;
static int forward_bcast;
static int forward_dhcp;
uint8_t local_addr[4];
int local_route_table;
uint8_t local_addr[4];
int local_route_table;
if (!forward_bcast && !forward_dhcp)
continue;
if (!forward_bcast && !forward_dhcp)
continue;
- if (relayd_handle_dhcp_packet(rif, pktbuf, pktlen, forward_dhcp))
+ if (relayd_handle_dhcp_packet(rif, pktbuf, pktlen, forward_dhcp, parse_dhcp))
continue;
if (forward_bcast)
continue;
if (forward_bcast)
" -T <table> Set routing table number for automatically added routes\n"
" -B Enable broadcast forwarding\n"
" -D Enable DHCP forwarding\n"
" -T <table> Set routing table number for automatically added routes\n"
" -B Enable broadcast forwarding\n"
" -D Enable DHCP forwarding\n"
+ " -P Disable DHCP options parsing\n"
" -L <ipaddr> Enable local access using <ipaddr> as source address\n"
"\n",
progname);
" -L <ipaddr> Enable local access using <ipaddr> as source address\n"
"\n",
progname);
host_ping_tries = 5;
forward_bcast = 0;
local_route_table = 0;
host_ping_tries = 5;
forward_bcast = 0;
local_route_table = 0;
- while ((ch = getopt(argc, argv, "I:i:t:p:BDdT:G:R:L:")) != -1) {
+ while ((ch = getopt(argc, argv, "I:i:t:p:BDPdT:G:R:L:")) != -1) {
switch(ch) {
case 'I':
managed = true;
switch(ch) {
case 'I':
managed = true;
case 'D':
forward_dhcp = 1;
break;
case 'D':
forward_dhcp = 1;
break;
+ case 'P':
+ parse_dhcp = 0;
+ break;
case 'T':
route_table = atoi(optarg);
if (route_table <= 0)
case 'T':
route_table = atoi(optarg);
if (route_table <= 0)
void relayd_add_pending_route(const uint8_t *gateway, const uint8_t *dest, uint8_t mask, int timeout);
void relayd_forward_bcast_packet(struct relayd_interface *from_rif, void *packet, int len);
void relayd_add_pending_route(const uint8_t *gateway, const uint8_t *dest, uint8_t mask, int timeout);
void relayd_forward_bcast_packet(struct relayd_interface *from_rif, void *packet, int len);
-bool relayd_handle_dhcp_packet(struct relayd_interface *rif, void *data, int len, bool forward);
+bool relayd_handle_dhcp_packet(struct relayd_interface *rif, void *data, int len, bool forward, bool parse);