diff options
-rw-r--r-- | sys/netinet/in_rmx.c | 12 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 2 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 1 |
3 files changed, 14 insertions, 1 deletions
diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c index 51a5846..16ea5be 100644 --- a/sys/netinet/in_rmx.c +++ b/sys/netinet/in_rmx.c @@ -54,6 +54,7 @@ #include <net/route.h> #include <netinet/in.h> #include <netinet/in_var.h> +#include <netinet/ip_var.h> extern int in_inithead __P((void **head, int off)); @@ -137,6 +138,17 @@ in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, RTFREE(rt2); } } + + /* + * If the new route created successfully, and we are forwarding, + * and there is a cached route, free it. Otherwise, we may end + * up using the wrong route. + */ + if (ret != NULL && ipforwarding && ipforward_rt.ro_rt) { + RTFREE(ipforward_rt.ro_rt); + ipforward_rt.ro_rt = 0; + } + return ret; } diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 7ee78dd..0963a0a 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -257,7 +257,7 @@ ip_init() } static struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; -static struct route ipforward_rt; +struct route ipforward_rt; /* * Ip input routine. Checksum and byte swap header. If fragmented diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index e821f0a..bc8b797 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -141,6 +141,7 @@ extern struct ipstat ipstat; extern u_short ip_id; /* ip packet ctr, for ids */ extern int ip_defttl; /* default IP ttl */ extern int ipforwarding; /* ip forwarding */ +extern struct route ipforward_rt; /* ip forwarding cached route */ extern u_char ip_protox[]; extern struct socket *ip_rsvpd; /* reservation protocol daemon */ extern struct socket *ip_mrouter; /* multicast routing daemon */ |