diff options
author | Ryan Moeller <freqlabs@FreeBSD.org> | 2021-02-28 10:30:09 +0000 |
---|---|---|
committer | Ryan Moeller <freqlabs@FreeBSD.org> | 2021-03-03 02:15:40 +0000 |
commit | 8b22242550c98d0a59b6589f2be0beb1dc2eac13 (patch) | |
tree | 6998207bc32681118cd102780cc0fecca4bc2ad9 /sbin/ifconfig/sfp.c | |
parent | 21802a127d83e8a8c721d69b697e7ddb223d7797 (diff) | |
download | src-8b22242550c98d0a59b6589f2be0beb1dc2eac13.tar.gz src-8b22242550c98d0a59b6589f2be0beb1dc2eac13.zip |
sbin/ifconfig: Use a global libifconfig handle
This should eventually replace the socket passed to the various
handlers. In the meantime, making it global avoids repeatedly opening
and closing handles.
Reported by: kp
Reviewed by: kp (earlier version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28990
Diffstat (limited to 'sbin/ifconfig/sfp.c')
-rw-r--r-- | sbin/ifconfig/sfp.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c index 15ff22639060..4900b18ff2c8 100644 --- a/sbin/ifconfig/sfp.c +++ b/sbin/ifconfig/sfp.c @@ -61,15 +61,10 @@ sfp_status(int s, struct ifreq *ifr, int verbose) struct ifconfig_sfp_info_strings strings; struct ifconfig_sfp_vendor_info vendor_info; struct ifconfig_sfp_status status; - ifconfig_handle_t *lifh; size_t channel_count; - lifh = ifconfig_open(); - if (lifh == NULL) - return; - if (ifconfig_sfp_get_sfp_info(lifh, name, &info) == -1) - goto close; + return; ifconfig_sfp_get_sfp_info_strings(&info, &strings); @@ -79,7 +74,7 @@ sfp_status(int s, struct ifreq *ifr, int verbose) strings.sfp_conn); if (ifconfig_sfp_get_sfp_vendor_info(lifh, name, &vendor_info) == -1) - goto close; + return; printf("\tvendor: %s PN: %s SN: %s DATE: %s\n", vendor_info.name, vendor_info.pn, vendor_info.sn, vendor_info.date); @@ -118,7 +113,7 @@ sfp_status(int s, struct ifreq *ifr, int verbose) struct ifconfig_sfp_dump dump; if (ifconfig_sfp_get_sfp_dump(lifh, name, &dump) == -1) - goto close; + return; if (ifconfig_sfp_id_is_qsfp(info.sfp_id)) { printf("\n\tSFF8436 DUMP (0xA0 128..255 range):\n"); @@ -133,7 +128,4 @@ sfp_status(int s, struct ifreq *ifr, int verbose) "\t", HD_OMIT_COUNT | HD_OMIT_CHARS); } } - -close: - ifconfig_close(lifh); } |