aboutsummaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorRyan Moeller <freqlabs@FreeBSD.org>2021-02-26 23:40:58 +0000
committerRyan Moeller <freqlabs@FreeBSD.org>2021-02-28 02:20:38 +0000
commitda393346ac47b22b5f8af4040a59971faadd2c5c (patch)
treeb160ec5535fa090fc185bd0e37e9264513741de5 /sbin/ifconfig
parent3fe2c68ba20fb3365ef91e0b85f88237b5369f38 (diff)
downloadsrc-da393346ac47b22b5f8af4040a59971faadd2c5c.tar.gz
src-da393346ac47b22b5f8af4040a59971faadd2c5c.zip
sbin/ifconfig: Get carp status with libifconfig
A trivial change now that ifconfig is already using libifconfig. Reviewed by: kp (earlier version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28955
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/carp.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c
index dcf966d873ee..d6f8d78ba920 100644
--- a/sbin/ifconfig/carp.c
+++ b/sbin/ifconfig/carp.c
@@ -50,6 +50,8 @@
#include <err.h>
#include <errno.h>
+#include <libifconfig.h>
+
#include "ifconfig.h"
static const char *carp_states[] = { CARP_STATES };
@@ -71,16 +73,16 @@ static void
carp_status(int s)
{
struct carpreq carpr[CARP_MAXVHID];
- int i;
+ ifconfig_handle_t *lifh;
- bzero(carpr, sizeof(struct carpreq) * CARP_MAXVHID);
- carpr[0].carpr_count = CARP_MAXVHID;
- ifr.ifr_data = (caddr_t)&carpr;
-
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ lifh = ifconfig_open();
+ if (lifh == NULL)
return;
- for (i = 0; i < carpr[0].carpr_count; i++) {
+ if (ifconfig_carp_get_info(lifh, name, carpr, CARP_MAXVHID) == -1)
+ goto close;
+
+ for (size_t i = 0; i < carpr[0].carpr_count; i++) {
printf("\tcarp: %s vhid %d advbase %d advskew %d",
carp_states[carpr[i].carpr_state], carpr[i].carpr_vhid,
carpr[i].carpr_advbase, carpr[i].carpr_advskew);
@@ -89,6 +91,8 @@ carp_status(int s)
else
printf("\n");
}
+close:
+ ifconfig_close(lifh);
}
static void