Skip to content

Commit de62338

Browse files
zooknoticcathay4t
authored andcommitted
Provide the ability to set the underlying link ID when adding xfrm link types
Signed-off-by: Scott Zuk <zooknotic@proton.me>
1 parent 6d77e01 commit de62338

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/link/add.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ impl LinkAddRequest {
729729
/// Create xfrm tunnel
730730
/// This is equivalent to `ip link add name NAME type xfrm if_id NUMBER`,
731731
/// The NUMBER is a XFRM if_id which may be connected to IPsec policy
732+
#[deprecated(note = "Please use `xfrmtun_link` instead")]
732733
pub fn xfrmtun(self, name: String, ifid: u32) -> Self {
733734
self.name(name)
734735
.link_info(
@@ -738,6 +739,24 @@ impl LinkAddRequest {
738739
.up()
739740
}
740741

742+
/// Create xfrm tunnel
743+
/// This is equivalent to `ip link add name NAME type xfrm if_id NUMBER dev
744+
/// LINK`. The NUMBER is a XFRM if_id which may be connected to IPsec
745+
/// policy. The LINK is the underlying link ID to attach the tunnel to,
746+
/// but instead of specifying a link name (`LINK`), we specify a link
747+
/// index. A LINK of `0` can be used to specify `NONE`.
748+
pub fn xfrmtun_link(self, name: String, ifid: u32, link: u32) -> Self {
749+
self.name(name)
750+
.link_info(
751+
InfoKind::Xfrm,
752+
Some(InfoData::Xfrm(vec![
753+
InfoXfrm::IfId(ifid),
754+
InfoXfrm::Link(link),
755+
])),
756+
)
757+
.up()
758+
}
759+
741760
/// Create a new bond.
742761
/// This is equivalent to `ip link add link NAME type bond`.
743762
pub fn bond(self, name: String) -> BondAddRequest {

0 commit comments

Comments
 (0)