aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2023-03-30 23:34:03 +0000
committerKristof Provost <kp@FreeBSD.org>2023-03-31 09:29:58 +0000
commit28921c4f7de6d8641b4deaa8942526309018668a (patch)
tree714b127c359a80c5aaeaed75ea87b9f9ab5e76e9 /lib
parent3a0cc6fe61ea29334c17dfb71bf24ba9e604ab4c (diff)
Diffstat (limited to 'lib')
-rw-r--r--lib/libifconfig/libifconfig_carp.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/lib/libifconfig/libifconfig_carp.c b/lib/libifconfig/libifconfig_carp.c
index 5729362ffef9..501ca81782eb 100644
--- a/lib/libifconfig/libifconfig_carp.c
+++ b/lib/libifconfig/libifconfig_carp.c
@@ -73,17 +73,10 @@ _ifconfig_carp_get(ifconfig_handle_t *h, const char *name,
struct nlmsghdr *hdr;
size_t i = 0;
uint32_t seq_id;
- unsigned int ifindex;
int family_id;
ifconfig_error_clear(h);
- ifindex = if_nametoindex(name);
- if (ifindex == 0) {
- ifconfig_error(h, NETLINK, ENOENT);
- return (-1);
- }
-
if (! snl_init(&ss, NETLINK_GENERIC)) {
ifconfig_error(h, NETLINK, ENOTSUP);
return (-1);
@@ -100,7 +93,7 @@ _ifconfig_carp_get(ifconfig_handle_t *h, const char *name,
hdr = snl_create_genl_msg_request(&nw, family_id, CARP_NL_CMD_GET);
hdr->nlmsg_flags |= NLM_F_DUMP;
- snl_add_msg_attr_u32(&nw, CARP_NL_IFINDEX, ifindex);
+ snl_add_msg_attr_string(&nw, CARP_NL_IFNAME, name);
if (vhid != 0)
snl_add_msg_attr_u32(&nw, CARP_NL_VHID, vhid);
@@ -153,18 +146,11 @@ ifconfig_carp_set_info(ifconfig_handle_t *h, const char *name,
struct snl_state ss = {};
struct snl_writer nw;
struct nlmsghdr *hdr;
- unsigned int ifindex;
int family_id;
uint32_t seq_id;
ifconfig_error_clear(h);
- ifindex = if_nametoindex(name);
- if (ifindex == 0) {
- ifconfig_error(h, NETLINK, ENOENT);
- return (-1);
- }
-
if (! snl_init(&ss, NETLINK_GENERIC)) {
ifconfig_error(h, NETLINK, ENOTSUP);
return (-1);
@@ -183,7 +169,7 @@ ifconfig_carp_set_info(ifconfig_handle_t *h, const char *name,
snl_add_msg_attr_u32(&nw, CARP_NL_STATE, carpr->carpr_state);
snl_add_msg_attr_s32(&nw, CARP_NL_ADVBASE, carpr->carpr_advbase);
snl_add_msg_attr_s32(&nw, CARP_NL_ADVSKEW, carpr->carpr_advskew);
- snl_add_msg_attr_u32(&nw, CARP_NL_IFINDEX, ifindex);
+ snl_add_msg_attr_string(&nw, CARP_NL_IFNAME, name);
snl_add_msg_attr(&nw, CARP_NL_ADDR, sizeof(carpr->carpr_addr),
&carpr->carpr_addr);
snl_add_msg_attr(&nw, CARP_NL_ADDR6, sizeof(carpr->carpr_addr6),