1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-10 14:02:43 +00:00

When adding a route fails because there is already a route with the same

(mask,value) in the tree, don't immediately return EEXIST.  Instead, check
to see if the pre-existing route was generated by protcol-cloning.  If so,
then it is OK to simply blow away the old route and re-attempt the insertion.
If not, then fall back to the same error code as before.
This commit is contained in:
Garrett Wollman 1995-10-16 19:09:40 +00:00
parent 81e236a01c
commit aca1a47cb4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=11539

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)route.c 8.2 (Berkeley) 11/15/93
* $Id: route.c,v 1.24 1995/07/10 15:22:37 wollman Exp $
* $Id: route.c,v 1.25 1995/07/29 11:41:02 bde Exp $
*/
#include <sys/param.h>
@ -464,6 +464,28 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
rn = rnh->rnh_addaddr((caddr_t)ndst, (caddr_t)netmask,
rnh, rt->rt_nodes);
if (rn == 0) {
struct rtentry *rt2;
/*
* Uh-oh, we already have one of these in the tree.
* We do a special hack: if the route that's already
* there was generated by the protocol-cloning
* mechanism, then we just blow it away and retry
* the insertion of the new one.
*/
rt2 = rtalloc1(dst, 0, RTF_PRCLONING);
if (rt2 && rt2->rt_parent) {
rtrequest(RTM_DELETE,
(struct sockaddr *)rt_key(rt2),
rt2->rt_gateway,
rt_mask(rt2), rt2->rt_flags, 0);
RTFREE(rt2);
rn = rnh->rnh_addaddr((caddr_t)ndst,
(caddr_t)netmask,
rnh, rt->rt_nodes);
}
}
if (rn == 0) {
if (rt->rt_gwroute)
rtfree(rt->rt_gwroute);