-
Notifications
You must be signed in to change notification settings - Fork 565
net_util: misc improvements #7279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net_util: misc improvements #7279
Conversation
| .unwrap_or(&[]); | ||
| // 1: No sane user-space tool would generate non-ASCII interface names. | ||
| // 2: We only allow the creation from UTF-8 strings (`&str`). | ||
| std::str::from_utf8(nul_terminated).expect("Tap interface name should be valid UTF-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are on it, can you please also add proper error handling? It is a user-error and should be handled and reported back to user, rather than terminating the CH process with a panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I like the idea @likebreath. However, in this case I'm in favor of keeping the panic. Users are only able to provide the name as Rust string, thus UTF-8. In case no name is provided, CHV generates a name from a Rust string itself.
So in case we have non-UTF8 here, it is a hard programming error or the kernel messed things up. Are we on the same page?
I will update the comment to reflect that better, tho. Is this okay to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. The root problem is Tap::if_name is Vec<u8> and can only be changed by the kernel with user inputs that are always valid utf-8. Perhaps, a better way is to make Tap::if_name as String, and panic from the place where kernel creates non utf-8 for if_name. This will be a separate work.
One can call `to_vec()` anyway if one needs an owned copy. This change further helps to prevent needless copies in upcoming changes. Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
1eede8f to
e75dbb6
Compare
Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
e75dbb6 to
6242237
Compare
Part of #7291 to work towards live-migration with FDs for virtio-net devices.
About
Misc improvements in
net_util.