Skip to content
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

Add add_route and del_route commands #8

Open
gluxon opened this issue Oct 6, 2019 · 2 comments
Open

Add add_route and del_route commands #8

gluxon opened this issue Oct 6, 2019 · 2 comments

Comments

@gluxon
Copy link
Owner

gluxon commented Oct 6, 2019

A helpful strace:

sudo strace ip -4 route add 127.3.1.1/32 dev test
sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=44, type=RTM_NEWROUTE, flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_EXCL|NLM_F_CREATE, seq=1570389827, pid=0}, {rtm_family=AF_INET, rtm_dst_len=32, rtm_src_len=0, rtm_tos=0, rtm_table=RT_TABLE_MAIN, rtm_protocol=RTPROT_BOOT, rtm_scope=RT_SCOPE_LINK, rtm_type=RTN_UNICAST, rtm_flags=0}, [{{nla_len=8, nla_type=RTA_DST}, 127.3.1.1}, {{nla_len=8, nla_type=RTA_OIF}, if_nametoindex("test")}]}, iov_len=44}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 44
recvmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=NULL, iov_len=0}], msg_iovlen=1, msg_controllen=0, msg_flags=MSG_TRUNC}, MSG_PEEK|MSG_TRUNC) = 36
recvmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=36, type=NLMSG_ERROR, flags=NLM_F_CAPPED, seq=1570389827, pid=28982}, {error=0, msg={len=44, type=RTM_NEWROUTE, flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_EXCL|NLM_F_CREATE, seq=1570389827, pid=0}}}, iov_len=36}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 36

This is necessary for host -> peer communication through the internal VPN subnet. peer -> host works fine so this issue is lower priority.

@jamesmcm
Copy link

jamesmcm commented Mar 2, 2021

Is this equivalent to rtnetlink's route add? https://docs.rs/rtnetlink/0.7.0/rtnetlink/struct.RouteAddRequest.html

It might be useful to combine some of the functionality, at the moment for libvopono I'm looking at using a combination of rtnetlink for ip address assignment and routing, nftnl for adding nftables rules, and this crate for creating Wireguard tunnels (parsing wg-quick config files). But they all share a lot of Netlink calls fundamentally.

@gluxon
Copy link
Owner Author

gluxon commented Mar 3, 2021

Yup! They're the same thing. That's partly why I haven't prioritized adding these calls to this library.

If they are added it'll likely be behind a feature flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants