@@ -, +, @@ --- dhcp.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) --- a/dhcp.c +++ a/dhcp.c @@ -228,6 +228,37 @@ static int initial_setup_interface(char * device, int s) { return 0; } +static int interface_cleanup(char * device, int s) { + /* + * Removing the auxiliary route + * made by initial_setup_interface() + */ + struct rtentry route; + struct sockaddr_in* address; + + memset(&route, 0, sizeof(route)); + + route.rt_dev = device; + route.rt_flags = RTF_UP | RTF_GATEWAY; + route.rt_metric = 0; + + address = &route.rt_dst; + address->sin_family = AF_INET; + + address = &route.rt_gateway; + address->sin_family = AF_INET; + + address = &route.rt_genmask; + address->sin_family = AF_INET; + + if (ioctl(s, SIOCDELRT, &route)) { + close(s); + log_perror("SIOCDELRT"); + return -1; + } + + return 0; +} void set_missing_ip_info(struct interface_info * intf) { @@ -669,6 +700,7 @@ enum return_type perform_dhcp(struct interface_info * intf) } lease = ntohl(lease); + interface_cleanup(intf->device, s); close(s); free(vendorClass); --