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
This commit is contained in:
parent
ffb2a3bc42
commit
8e9c5ae863
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user