From owner-dev-commits-src-all@freebsd.org Sun Mar 14 09:09:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A7C375789A8; Sun, 14 Mar 2021 09:09:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dytzb4HBqz3Fsk; Sun, 14 Mar 2021 09:09:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C29BD1AF1C; Sun, 14 Mar 2021 09:09:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12E99kR4078335; Sun, 14 Mar 2021 09:09:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12E99k6g078334; Sun, 14 Mar 2021 09:09:46 GMT (envelope-from git) Date: Sun, 14 Mar 2021 09:09:46 GMT Message-Id: <202103140909.12E99k6g078334@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ryan Moeller Subject: git: f42188552c77 - stable/13 - sbin/ifconfig: Get carp status with libifconfig MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: freqlabs X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f42188552c7784b6a0e14d591d0e3951164b5326 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2021 09:09:49 -0000 The branch stable/13 has been updated by freqlabs: URL: https://cgit.FreeBSD.org/src/commit/?id=f42188552c7784b6a0e14d591d0e3951164b5326 commit f42188552c7784b6a0e14d591d0e3951164b5326 Author: Ryan Moeller AuthorDate: 2021-02-26 23:40:58 +0000 Commit: Ryan Moeller CommitDate: 2021-03-14 08:07:35 +0000 sbin/ifconfig: Get carp status with libifconfig A trivial change now that ifconfig is already using libifconfig. Reviewed by: kp (earlier version) Differential Revision: https://reviews.freebsd.org/D28955 (cherry picked from commit da393346ac47b22b5f8af4040a59971faadd2c5c) --- sbin/ifconfig/carp.c | 18 +++++++++++------- 1 file 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 #include +#include + #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