Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

rtnl/link: change add_name_filter to match_name #208

Merged
merged 1 commit into from
Nov 30, 2021

Conversation

Tuetuopay
Copy link
Contributor

Since kernel commit a3d1289126e7b, it is possible to set the IFLA_IFNAME attribute in a RTM_GETLINK message, allowing to get a link by its name without dumping the whole link list.

In large setups, this speeds up massively the library, going from "painfully slow" to "really quick" (in my application with thousands of links, a lookup by name went from hundreds of ms to hundreds of µs).

This is based off the equivalent function in libnl.

@Tuetuopay Tuetuopay force-pushed the add-get-by-name branch 4 times, most recently from 031d8ac to 2fdf367 Compare November 29, 2021 10:21
@little-dude
Copy link
Owner

This is great! I was not really satisfied with the filtering thing.

Since we're on this, would you mind adding some doc on the name filter to explain that if users only want to filter on the name, they should rather use match_name?

Also out of curiosity, is the application you mentioned public?

@Tuetuopay
Copy link
Contributor Author

Well since I removed the old set_name_filter, there's no more doc to add :D Though I'll add the same doc as libnl, telling this requires a recent-ish kernel (2009 vintage) for the option to work. Maybe you'd like to keep the function for precisely those people?

And sadly not, the application is not public, I'm doing this for work. Though I think I can talk a bit about it: it's managing lots (thousands) of VXLAN networks across several netns in a cloud provider environment.

@little-dude
Copy link
Owner

Ah yes sorry. Maybe we can just remove the FilterBuilder entirely then.

it's managing lots (thousands) of VXLAN networks across several netns in a cloud provider environment.
Merge state

Sounds cool! The network namespaces are a dark corner for me.

Since kernel commit [a3d1289126e7b][1], it is possible to set the
IFLA_IFNAME attribute in a RTM_GETLINK message, allowing to get a link
by its name without dumping the whole link list. In large setups, this
speeds up massively the library, going from "painfully slow" to "really
quick" (in my application with thousands of links, a lookup by name
went from hundreds of ms to hundreds of µs).

This is based off the equivalent function in [libnl][2].

[1]: torvalds/linux@a3d1289
[2]: https://github.com/thom311/libnl/blob/master/lib/route/link.c#L1376
@Tuetuopay
Copy link
Contributor Author

@little-dude removed the whole LinkFilterBuilder then, with the appropriate warning on match_name, regarding kernel version.

Sounds cool! The network namespaces are a dark corner for me.

Yeah control plane stuff is fun! And namespaces are too, and very very useful. Just takes a little while to get used to...

@little-dude
Copy link
Owner

This is great, thank you!

@little-dude little-dude merged commit 8a47322 into little-dude:master Nov 30, 2021
@Tuetuopay Tuetuopay deleted the add-get-by-name branch November 30, 2021 17:05
@mcr
Copy link
Contributor

mcr commented Dec 27, 2021

Well since I removed the old set_name_filter, there's no more doc to add :D Though I'll add the same doc as libnl, telling this requires a recent-ish kernel (2009 vintage) for the option to work. Maybe you'd like to keep the function for precisely those people?

I would have prefered that set_name_filter() was deprecated before being removed.
This was rather puzzling to solve.

@little-dude little-dude mentioned this pull request Dec 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants