summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_carp.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2021-02-08 12:30:11 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2021-02-08 12:30:11 +0000
commitaa8513c7418e5a679de2e5b86aef54503ac9aff2 (patch)
tree9158a0991b06388dece1b2ffc8c81563925baeb6 /sys/netinet/ip_carp.c
parentf7d9b9b5db3018abfef29751f141651163e86de0 (diff)
Start refcounting interface groups with 1. if_creategroup() returns
a new object that is already refcounted, so carp attach does not reach into internal structures. Add kasserts to detect counter overflow or underflow. OK mvs@
Diffstat (limited to 'sys/netinet/ip_carp.c')
-rw-r--r--sys/netinet/ip_carp.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 00d5fe91512..15593a5fbf0 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.351 2021/01/21 13:18:07 mvs Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.352 2021/02/08 12:30:10 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -786,10 +786,7 @@ carp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
void
carpattach(int n)
{
- struct ifg_group *ifg;
-
- if ((ifg = if_creategroup("carp")) != NULL)
- ifg->ifg_refcnt++; /* keep around even if empty */
+ if_creategroup("carp"); /* keep around even if empty */
if_clone_attach(&carp_cloner);
carpcounters = counters_alloc(carps_ncounters);
}