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

Add ipip tunnel support#264

Open
tomjshine wants to merge 1 commit intolittle-dude:masterfrom
tomjshine:master
Open

Add ipip tunnel support#264
tomjshine wants to merge 1 commit intolittle-dude:masterfrom
tomjshine:master

Conversation

@tomjshine
Copy link
Copy Markdown

Adding support to create/get ipip tunnels. This has been modeled off the previous VxLAN work. No experience with Rust, so any feedback welcome :).

Before:

% ip tun
tunl0: any/ip remote any local any ttl inherit nopmtudisc

After: (running ./create_ipip)

% ip tun
tunl0: any/ip remote any local any ttl inherit nopmtudisc
my-ip-tun-1: ip/ip remote 1.2.3.4 local any ttl 64

Copy link
Copy Markdown
Collaborator

@cathay4t cathay4t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IFLA_IPTUN_COLLECT_METADATA should be fixed and also expose Ipv4Addr instead of Vec<u8>

// pub const IPVLAN_MODE_L3S: int = 2;
// pub const IPVLAN_MODE_MAX: int = 3;
//
// FROM https://elixir.bootlin.com/linux/v5.9.8/source/include/uapi/linux/if_tunnel.h#L58
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not official kernel website and there is no need to mention it.

pub const IFLA_IPTUN_ENCAP_DPORT: u16 = 18;
pub const IFLA_IPTUN_COLLECT_METADATA: u16 = 19;
pub const IFLA_IPTUN_FWMARK: u16 = 20;
pub const __IFLA_IPTUN_MAX: u16 = 21;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this constant. It is changing and private to kernel only.

Comment on lines +732 to +733
Local(Vec<u8>),
Remote(Vec<u8>),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing Vec<u8> is not helping user. Please parse them into Ipv4Addr.

// https://elixir.bootlin.com/linux/v5.9.8/source/net/ipv4/ipip.c#L598
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum InfoIpTun {
Unspec(Vec<u8>),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to expose it. Kernel is not using it anyway.

EncapFlags(u16),
EncapSport(u16),
EncapDport(u16),
CollectMetadata(u8),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kernel has if (nla_put_flag(skb, IFLA_IPTUN_COLLECT_METADATA)) which indicate this is a boolean with 0 size in data.

| Tos(ref value)
| Proto(ref value)
| Pmtudisc(ref value)
| CollectMetadata(ref value)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kernel indicate CollectMetadata should emit no data at all.

EncapDport(parse_u16_be(payload).context("invalid IFLA_IPTUN_ENCAP_DPORT value")?)
}
IFLA_IPTUN_COLLECT_METADATA => CollectMetadata(
parse_u8(payload).context("invalid IFLA_IPTUN_COLLECT_METADATA value")?,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kernel code indicate, once IFLA_IPTUN_COLLECT_METADATA exist in netlink message, it means CollectMeta(true).

@cathay4t
Copy link
Copy Markdown
Collaborator

@tomjshine It has been a while. We are splitting this project into small parts.

Besides fixing above change requests, could you move your PR to https://github.com/rust-netlink/netlink-packet-route

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants