Page MenuHomeFreeBSD

carp: allow commands to use interface name rather than index
ClosedPublic

Authored by kp on Mar 31 2023, 2:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 21 2024, 4:44 AM
Unknown Object (File)
Mar 12 2024, 3:56 PM
Unknown Object (File)
Mar 12 2024, 3:56 PM
Unknown Object (File)
Mar 12 2024, 3:56 PM
Unknown Object (File)
Mar 8 2024, 7:49 AM
Unknown Object (File)
Jan 3 2024, 3:35 PM
Unknown Object (File)
Jan 2 2024, 3:41 AM
Unknown Object (File)
Dec 24 2023, 2:14 AM
Subscribers

Details

Summary

Get/set commands can now choose to provide the interface name rather
than the interface index. This allows userspace to avoid a call to
if_nametoindex().

Suggested by: melifaro
Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kp requested review of this revision.Mar 31 2023, 2:56 AM
zlei added inline comments.
sys/netinet/ip_carp.c
2354

Is it valid that both ifname and ifindex provided ?

And ifindex have default value 0, can not simply assert ifindex is provided.

sys/netinet/ip_carp.c
2354

And ifindex have default value 0, can not simply assert ifindex is provided.

Sorry that is not true.

if (ifindex == 0) {
		ifconfig_error(h, NETLINK, ENOENT);
		return (-1);
	}
sys/netinet/ip_carp.c
2354

Userspace could provide both, but we're only going to use one of them. In this case, we'd use the name and ignore the index.

It wouldn't break anything, but it's obviously a silly thing for userspace to do.

LGTM, thank you!

sys/netinet/ip_carp.c
2352

Nit; to mark the preference/intent, I’d check if the attribute is set

This revision is now accepted and ready to land.Mar 31 2023, 6:39 AM