polachok / pnetlink

netlink library for rust
43 stars 13 forks source link

Added support for nested attributes #32

Closed elij closed 6 years ago

elij commented 6 years ago

Good Afternoon,

I've added the following code to use this library for creating VETH pairs -- it specifically allows nesting of attributes.

However I'm not sure if this is inline with code from this project.

Is it possible to get feedback?

Thanks

elij commented 6 years ago

Thanks I would also like to avoid adding the enum but outside of pnetlink I can't access the payload.

I need a way with a RtAttr to have a payload of an array mixed of IfInfoMsg and RtAttr (see use here: https://github.com/lypy/andover/blob/master/src/main.rs#L102)

VETH_INFO_PEER (RtAttr)

Do you have any suggestions? I'll do the heavy lifting outside and limit the pull request to just the ifinfo payload.

bkchr commented 6 years ago

Did you tried:

let mut link_info_data : Vec<&ToPayload> = Vec::new();
link_info_data.push(&n1);
link_info_data.push(&n2);

let info_peer = RtAttrPacket::create_with_payload(VETH_INFO_PEER, &link_info_data[..]);

Look here to see what I'm doing to create a big package.

elij commented 6 years ago

Thank you very much :)

I'll create a new pull request