Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163348514
D39359.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D39359.id.diff
View Options
diff --git a/lib/libifconfig/libifconfig_carp.c b/lib/libifconfig/libifconfig_carp.c
--- a/lib/libifconfig/libifconfig_carp.c
+++ b/lib/libifconfig/libifconfig_carp.c
@@ -73,17 +73,10 @@
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 @@
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 @@
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 @@
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),
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -2301,6 +2301,7 @@
struct nl_carp_parsed {
unsigned int ifindex;
+ char *ifname;
uint32_t state;
uint32_t vhid;
int32_t advbase;
@@ -2322,6 +2323,7 @@
{ .type = CARP_NL_IFINDEX, .off = _OUT(ifindex), .cb = nlattr_get_uint32 },
{ .type = CARP_NL_ADDR, .off = _OUT(addr), .cb = nlattr_get_in_addr },
{ .type = CARP_NL_ADDR6, .off = _OUT(addr6), .cb = nlattr_get_in6_addr },
+ { .type = CARP_NL_IFNAME, .off = _OUT(ifname), .cb = nlattr_get_string },
};
static const struct nlfield_parser nlf_p_set[] = {
};
@@ -2337,7 +2339,7 @@
struct carp_nl_send_args args;
struct carpreq carpr = { };
struct epoch_tracker et;
- if_t ifp;
+ if_t ifp = NULL;
int error;
error = nl_parse_nlmsg(hdr, &carp_parser, npt, &attrs);
@@ -2345,7 +2347,10 @@
return (error);
NET_EPOCH_ENTER(et);
- ifp = ifnet_byindex_ref(attrs.ifindex);
+ if (attrs.ifname != NULL)
+ ifp = ifunit_ref(attrs.ifname);
+ else if (attrs.ifindex != 0)
+ ifp = ifnet_byindex_ref(attrs.ifindex);
NET_EPOCH_EXIT(et);
if ((error = carp_is_supported_if(ifp)) != 0)
@@ -2379,7 +2384,7 @@
struct nl_carp_parsed attrs = { };
struct carpkreq carpr;
struct epoch_tracker et;
- if_t ifp;
+ if_t ifp = NULL;
int error;
error = nl_parse_nlmsg(hdr, &carp_parser, npt, &attrs);
@@ -2398,7 +2403,10 @@
return (EINVAL);
NET_EPOCH_ENTER(et);
- ifp = ifnet_byindex_ref(attrs.ifindex);
+ if (attrs.ifname != NULL)
+ ifp = ifunit_ref(attrs.ifname);
+ else if (attrs.ifindex != 0)
+ ifp = ifnet_byindex_ref(attrs.ifindex);
NET_EPOCH_EXIT(et);
if ((error = carp_is_supported_if(ifp)) != 0)
diff --git a/sys/netinet/ip_carp_nl.h b/sys/netinet/ip_carp_nl.h
--- a/sys/netinet/ip_carp_nl.h
+++ b/sys/netinet/ip_carp_nl.h
@@ -31,6 +31,7 @@
CARP_NL_IFINDEX = 6, /* u32 */
CARP_NL_ADDR = 7, /* in_addr_t */
CARP_NL_ADDR6 = 8, /* in6_addr_t */
+ CARP_NL_IFNAME = 9, /* string */
};
#endif
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 23, 9:29 AM (5 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35397479
Default Alt Text
D39359.id.diff (3 KB)
Attached To
Mode
D39359: carp: allow commands to use interface name rather than index
Attached
Detach File
Event Timeline
Log In to Comment