From 50a545a34becd2fee62b3e8c6433249059880b7d Mon Sep 17 00:00:00 2001 From: itojun Date: Tue, 12 Nov 2002 02:10:13 +0000 Subject: [PATCH] remove all entries in rt timer queue on ip_mtudisc change, instead of destroying the queue. --- sys/net/route.c | 18 ++++++++++++++---- sys/net/route.h | 3 ++- sys/netinet/ip_input.c | 15 +++++---------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 18cb9e575f34..f19b39b37389 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.54 2002/11/12 01:37:30 itojun Exp $ */ +/* $NetBSD: route.c,v 1.55 2002/11/12 02:10:13 itojun Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -102,7 +102,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.54 2002/11/12 01:37:30 itojun Exp $"); +__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.55 2002/11/12 02:10:13 itojun Exp $"); #include "opt_ns.h" @@ -918,7 +918,7 @@ rt_timer_queue_change(rtq, timeout) } void -rt_timer_queue_destroy(rtq, destroy) +rt_timer_queue_remove_all(rtq, destroy) struct rttimer_queue *rtq; int destroy; { @@ -933,8 +933,18 @@ rt_timer_queue_destroy(rtq, destroy) if (rtq->rtq_count > 0) rtq->rtq_count--; else - printf("rt_timer_queue_destroy: rtq_count reached 0\n"); + printf("rt_timer_queue_remove_all: " + "rtq_count reached 0\n"); } +} + +void +rt_timer_queue_destroy(rtq, destroy) + struct rttimer_queue *rtq; + int destroy; +{ + + rt_timer_queue_remove_all(rtq, destroy); LIST_REMOVE(rtq, rtq_link); diff --git a/sys/net/route.h b/sys/net/route.h index 65e57f3a8c5f..291466fdd8d6 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $NetBSD: route.h,v 1.31 2002/11/12 01:37:30 itojun Exp $ */ +/* $NetBSD: route.h,v 1.32 2002/11/12 02:10:13 itojun Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -302,6 +302,7 @@ void rt_timer_init __P((void)); struct rttimer_queue * rt_timer_queue_create __P((u_int)); void rt_timer_queue_change __P((struct rttimer_queue *, long)); +void rt_timer_queue_remove_all __P((struct rttimer_queue *, int)); void rt_timer_queue_destroy __P((struct rttimer_queue *, int)); void rt_timer_remove_all __P((struct rtentry *, int)); unsigned long rt_timer_count __P((struct rttimer_queue *)); diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index bc2139e82526..42d60973e929 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.162 2002/11/12 01:57:07 itojun Exp $ */ +/* $NetBSD: ip_input.c,v 1.163 2002/11/12 02:10:13 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -102,7 +102,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.162 2002/11/12 01:57:07 itojun Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.163 2002/11/12 02:10:13 itojun Exp $"); #include "opt_gateway.h" #include "opt_pfil_hooks.h" @@ -1826,13 +1826,8 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen) case IPCTL_MTUDISC: error = sysctl_int(oldp, oldlenp, newp, newlen, &ip_mtudisc); - if (ip_mtudisc != 0 && ip_mtudisc_timeout_q == NULL) { - ip_mtudisc_timeout_q = - rt_timer_queue_create(ip_mtudisc_timeout); - } else if (ip_mtudisc == 0 && ip_mtudisc_timeout_q != NULL) { - rt_timer_queue_destroy(ip_mtudisc_timeout_q, TRUE); - ip_mtudisc_timeout_q = NULL; - } + if (error == 0 && ip_mtudisc == 0) + rt_timer_queue_remove_all(ip_mtudisc_timeout_q, TRUE); return error; case IPCTL_ANONPORTMIN: old = anonportmin; @@ -1868,7 +1863,7 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen) ip_mtudisc_timeout = old; return (EINVAL); } - if (ip_mtudisc_timeout_q != NULL) + if (error == 0) rt_timer_queue_change(ip_mtudisc_timeout_q, ip_mtudisc_timeout); return (error);