From 4080edd5323ac678c2cee67964f9a1f7c97ae9e8 Mon Sep 17 00:00:00 2001 From: yasuoka Date: Thu, 8 Jan 2015 07:34:05 +0000 Subject: [PATCH] Count number of sessions correctly. --- usr.sbin/npppd/npppd/npppd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.sbin/npppd/npppd/npppd.c b/usr.sbin/npppd/npppd/npppd.c index d7ed9414e43..7cd60c66909 100644 --- a/usr.sbin/npppd/npppd/npppd.c +++ b/usr.sbin/npppd/npppd/npppd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npppd.c,v 1.38 2014/11/13 04:03:53 yasuoka Exp $ */ +/* $OpenBSD: npppd.c,v 1.39 2015/01/08 07:34:05 yasuoka Exp $ */ /*- * Copyright (c) 2005-2008,2009 Internet Initiative Japan Inc. @@ -29,7 +29,7 @@ * Next pppd(nppd). This file provides a npppd daemon process and operations * for npppd instance. * @author Yasuoka Masahiko - * $Id: npppd.c,v 1.38 2014/11/13 04:03:53 yasuoka Exp $ + * $Id: npppd.c,v 1.39 2015/01/08 07:34:05 yasuoka Exp $ */ #include "version.h" #include @@ -2131,13 +2131,14 @@ npppd_ppp_bind_iface(npppd *_this, npppd_ppp *ppp) return 1; if (_this->conf.max_session > 0 && - _this->nsession++ >= _this->conf.max_session) { + _this->nsession >= _this->conf.max_session) { ppp_log(ppp, LOG_WARNING, "Number of sessions reaches out of the limit=%d", _this->conf.max_session); return 1; } ppp->ifidx = ifidx; + _this->nsession++; return 0; } @@ -2146,7 +2147,8 @@ npppd_ppp_bind_iface(npppd *_this, npppd_ppp *ppp) void npppd_ppp_unbind_iface(npppd *_this, npppd_ppp *ppp) { - _this->nsession--; + if (ppp->ifidx >= 0) + _this->nsession--; ppp->ifidx = -1; } -- 2.20.1