-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[API break] link: Reorganize the code base
* This patch is first preparation on stable release 1.0 for submodule link. The detailed checklist for developer is stated in README.md file. * Stored constants into where it been used. Will remove `constants.rs` once all components finished. * Replace `pub use self::*` to explicit expose. * Removed `data` folder, `README.md` file has expanded to hold steps to capture netlink packets. * Removed `Unspec` as kernel not use it. * Removed `benches` folder as never used. * Removed dependency on `libc` and `lazy_static`. * Added dependency on `log`. Considering `rtnetlink` also has it, no burden added to end user. * Many member of `InfoVxlan` changed from u8 to bool after confirmed with kernel code. * Changed API: * Rename: * `link::Nla` to `link::LinkAttribute` because `Nla` is a trait * `link:Info` to `link::LinkInfo` * `link::VethInfo` to `link::InfoVeth` * `link::InfoXfrmTun` to `link::InfoXfrm` * The AfSpec for ipv4 and ipv6 is rework. Please check `AfSpecUnspec` * Removed `link::Nla::AltIfName`. Use `link::LinkAttribute::PropList<vec![link::Prop::AltIfName]>` instead. * Changed `InfoVlan::Protocol<u16>` to `InfoVlan::Protocol<VlanProtocol>`. * Added: * `link::LinkFlag` and `LinkFlags` for `IFF_UP` and etc * `link::LinkLayerType` for `ARPHRD_ETHER` and etc * `crate::AddressFamily` for `AF_UNSPEC` and etc Unit test cases included. Signed-off-by: Gris Ge <[email protected]>
- Loading branch information
Showing
82 changed files
with
6,002 additions
and
5,018 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,59 @@ | ||
# netlink-packet-route | ||
# Rust crate for Netlink Route Protocol | ||
|
||
Rust crate providing netlink message parsing and generating support for the | ||
[netlink route protocol][1]. | ||
The `netlink-packet-route` crate is designed to abstract Netlink route | ||
protocol([`rtnetlink`][rtnetlink_man]) packet into Rust data types. The goal of | ||
this crate is saving netlink user from reading Kernel Netlink codes. | ||
|
||
Rust crate document could be found at [docs.rs][2]. | ||
This crate grouped Netlink route protocol into these modules: | ||
* `link`: NIC interface, similar to to `ip link` command. | ||
* `address`: IP address, similar to `ip address` command. | ||
* `route`: Route, similar to `ip route` command. | ||
* `rule`: Route rule, similar to `ip rule` command. | ||
* `tc`: Traffic control, similar to `tc` command. | ||
* `neighbour`: Neighbour, similar to `ip neighbour` command. | ||
* `neighbour_table`: Neighbour table, similar to `ip ntable` command. | ||
* `nsid`: Namespace, similar to `ip netns` command. | ||
|
||
[1]: https://www.man7.org/linux/man-pages/man7/rtnetlink.7.html | ||
[2]: https://docs.rs/netlink-packet-route/ | ||
Normally, you should use [`rtnetlink`][rtnetlink_url] instead of using this | ||
crate directly. | ||
|
||
## Development | ||
* Please use `git commit --signoff` to append Signed-off-by trailer to commit | ||
message. | ||
|
||
* For new source file, please append `// SPDX-License-Identifier: MIT` at | ||
the beginning with content of license new code to MIT license. | ||
|
||
* No panic is allowed, please use `Result<>` instead of `unwrap()` or | ||
`expect()`. | ||
|
||
* Please run `cargo fmt` and `cargo clippy` before creating pull request. | ||
|
||
* All struct/enum should be decorated by | ||
[`#[non_exhaustive]`][non_exhaustive_doc] to preserve | ||
API backwards compatibility unless explicit approval from maintainer. | ||
|
||
* Unknown netlink attribute should be stored into `Other(DefaultNla)` instead | ||
of breaking decoding. | ||
|
||
* Please use unit test case to cover the serialize and deserialize of the | ||
changed netlink attribute. To capture the netlink raw bytes, you may use | ||
tcpdump/wireshark again the `nlmon` interface. For example: | ||
|
||
* The integration test(play with linux kernel netlink interface) should be | ||
placed into `rtnetlink` crate. Current(netlink-packet-route) crate should | ||
only unit test case only. | ||
|
||
```bash | ||
modprobe nlmon | ||
ip link add nl0 type nlmon | ||
ip link set nl0 up | ||
tcpdump -i nl0 -w netlink_capture_file.cap | ||
``` | ||
|
||
* For certain netlink message which cannot captured by nlmon, please use | ||
Rust Debug and explain every bits in comment. | ||
|
||
[rtnetlink_man]: https://www.man7.org/linux/man-pages/man7/rtnetlink.7.html | ||
[rtnetlink_url]: https://docs.rs/rtnetlink | ||
[non_exhaustive_doc]: https://doc.rust-lang.org/stable/reference/attributes/type_system.html#the-non_exhaustive-attribute |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.