Fri Apr 1 09:52:39 2016 UTC ()
Don't request returning rtentry if not use it


(ozaki-r)
diff -r1.156 -r1.157 src/sys/net/route.c

cvs diff -r1.156 -r1.157 src/sys/net/route.c (expand / switch to unified diff)

--- src/sys/net/route.c 2016/04/01 09:00:27 1.156
+++ src/sys/net/route.c 2016/04/01 09:52:39 1.157
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: route.c,v 1.156 2016/04/01 09:00:27 ozaki-r Exp $ */ 1/* $NetBSD: route.c,v 1.157 2016/04/01 09:52:39 ozaki-r Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Kevin M. Lahey of the Numerical Aerospace Simulation Facility, 8 * by Kevin M. Lahey of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -86,27 +86,27 @@ @@ -86,27 +86,27 @@
86 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 86 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88 * SUCH DAMAGE. 88 * SUCH DAMAGE.
89 * 89 *
90 * @(#)route.c 8.3 (Berkeley) 1/9/95 90 * @(#)route.c 8.3 (Berkeley) 1/9/95
91 */ 91 */
92 92
93#ifdef _KERNEL_OPT 93#ifdef _KERNEL_OPT
94#include "opt_inet.h" 94#include "opt_inet.h"
95#include "opt_route.h" 95#include "opt_route.h"
96#endif 96#endif
97 97
98#include <sys/cdefs.h> 98#include <sys/cdefs.h>
99__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.156 2016/04/01 09:00:27 ozaki-r Exp $"); 99__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.157 2016/04/01 09:52:39 ozaki-r Exp $");
100 100
101#include <sys/param.h> 101#include <sys/param.h>
102#ifdef RTFLUSH_DEBUG 102#ifdef RTFLUSH_DEBUG
103#include <sys/sysctl.h> 103#include <sys/sysctl.h>
104#endif 104#endif
105#include <sys/systm.h> 105#include <sys/systm.h>
106#include <sys/callout.h> 106#include <sys/callout.h>
107#include <sys/proc.h> 107#include <sys/proc.h>
108#include <sys/mbuf.h> 108#include <sys/mbuf.h>
109#include <sys/socket.h> 109#include <sys/socket.h>
110#include <sys/socketvar.h> 110#include <sys/socketvar.h>
111#include <sys/domain.h> 111#include <sys/domain.h>
112#include <sys/protosw.h> 112#include <sys/protosw.h>
@@ -558,44 +558,41 @@ out: @@ -558,44 +558,41 @@ out:
558 info.rti_info[RTAX_AUTHOR] = src; 558 info.rti_info[RTAX_AUTHOR] = src;
559 rt_missmsg(RTM_REDIRECT, &info, flags, error); 559 rt_missmsg(RTM_REDIRECT, &info, flags, error);
560} 560}
561 561
562/* 562/*
563 * Delete a route and generate a message. 563 * Delete a route and generate a message.
564 * It doesn't free a passed rt. 564 * It doesn't free a passed rt.
565 */ 565 */
566static int 566static int
567rtdeletemsg(struct rtentry *rt) 567rtdeletemsg(struct rtentry *rt)
568{ 568{
569 int error; 569 int error;
570 struct rt_addrinfo info; 570 struct rt_addrinfo info;
571 struct rtentry *retrt; 
572 571
573 /* 572 /*
574 * Request the new route so that the entry is not actually 573 * Request the new route so that the entry is not actually
575 * deleted. That will allow the information being reported to 574 * deleted. That will allow the information being reported to
576 * be accurate (and consistent with route_output()). 575 * be accurate (and consistent with route_output()).
577 */ 576 */
578 memset(&info, 0, sizeof(info)); 577 memset(&info, 0, sizeof(info));
579 info.rti_info[RTAX_DST] = rt_getkey(rt); 578 info.rti_info[RTAX_DST] = rt_getkey(rt);
580 info.rti_info[RTAX_NETMASK] = rt_mask(rt); 579 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
581 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; 580 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
582 info.rti_flags = rt->rt_flags; 581 info.rti_flags = rt->rt_flags;
583 error = rtrequest1(RTM_DELETE, &info, &retrt); 582 error = rtrequest1(RTM_DELETE, &info, NULL);
584 583
585 rt_missmsg(RTM_DELETE, &info, info.rti_flags, error); 584 rt_missmsg(RTM_DELETE, &info, info.rti_flags, error);
586 585
587 if (error == 0) 
588 rtfree(retrt); 
589 return error; 586 return error;
590} 587}
591 588
592static int 589static int
593rtflushclone1(struct rtentry *rt, void *arg) 590rtflushclone1(struct rtentry *rt, void *arg)
594{ 591{
595 struct rtentry *parent; 592 struct rtentry *parent;
596 593
597 parent = (struct rtentry *)arg; 594 parent = (struct rtentry *)arg;
598 if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent == parent) 595 if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent == parent)
599 rtdeletemsg(rt); 596 rtdeletemsg(rt);
600 return 0; 597 return 0;
601} 598}