diff options
author | ru <ru@FreeBSD.org> | 2001-03-19 09:16:16 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2001-03-19 09:16:16 +0000 |
commit | 38387221cd67a6d9b58b81feee97e876a9832d42 (patch) | |
tree | 96d2016274b574dd4e5a5aed21f96a33799eb0f9 /sys | |
parent | dabce43c5b93b638113eb1b7059ca91b32eb3607 (diff) | |
download | FreeBSD-src-38387221cd67a6d9b58b81feee97e876a9832d42.zip FreeBSD-src-38387221cd67a6d9b58b81feee97e876a9832d42.tar.gz |
Invalidate cached forwarding route (ipforward_rt) whenever a new route
is added to the routing table, otherwise we may end up using the wrong
route when forwarding.
PR: kern/10778
Reviewed by: silence on -net
Diffstat (limited to 'sys')
-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 */ |