Seg6 tunnel support

81 views
Skip to first unread message

Pier Luigi Ventre

unread,
Sep 21, 2017, 8:36:21 AM9/21/17
to pyroute2-dev
Hi all,
I was trying to create a segment routing v6 tunnel (seg6) with pyroute2 library but my tentative failed.
With ip route command is possible to create a tunnel in this way:

ip -6 route  add 2001:0:0:10::2/128 encap seg6 mode encap segs 2000::5,2000::6 dev eth0

Instead, this is what I did with my example script:

# Get iface
idx = ip.link_lookup(ifname=iface_name)[0]
# create SR tunnel 2001:0:0:10::2/128 encap seg6 mode encap segs 2000::5,2000::6 dev hnyc-eth0
ip.route(
'add',
dst='2001:0:0:10::2/128',
oif=idx,
encap={'type': 'seg6', 'mode': 'encap', 'segs':['2000::5', '2000::6']}
)
# release Netlink socket
ip.close()

Running this script adds a new static route for 2001:0:0:10::2/128 but not the expected tunnel, it looks like the encapsulation seg6 is silently discarded.
If I am right, I would like to add the support for seg6 tunnel mode to pyroute2 library, can someone point me where to start ?

Thanks
Pier

Peter Saveliev

unread,
Sep 21, 2017, 8:52:32 AM9/21/17
to Pier Luigi Ventre, pyroute2-dev
There is an issue with seg6 encap, since the current code tries to work with any encap as with MPLS.

I'll try to play with it on the weekend.

--
You received this message because you are subscribed to the Google Groups "pyroute2-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pier Luigi Ventre

unread,
Sep 21, 2017, 8:58:38 AM9/21/17
to pyroute2-dev
Hi Peter,
thanks for your prompt reply. In the meanwhile, could you kindly point me where to give a look in the library just to understand how encap
works ?

Thanks
Pier
To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev...@googlegroups.com.

Peter Saveliev

unread,
Sep 21, 2017, 9:30:17 AM9/21/17
to Pier Luigi Ventre, pyroute2-dev
RTA_ENCAP points to `encap_info`, that should be a class (simple mapping) or a method (conditional mapping). It is a method now, but ut does no choice, simply returning `mpls_encap_info` class.

The rtmsg messages with RTA_ENCAP have RTA_ENCAP_TYPE that should be used as the condition to choose the way to decode the RTA_ENCAP NLA, but the issue is that it goes after RTA_ENCAP, thus the RTA_ENCAP decoding should be properly postponed until RTA_ENCAP_TYPE is met in the NLA chain.



To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.

Pier Luigi Ventre

unread,
Sep 21, 2017, 9:45:39 AM9/21/17
to pyroute2-dev
Thanks a ton !!!
Pier

Peter Saveliev

unread,
Sep 21, 2017, 11:18:19 AM9/21/17
to Pier Luigi Ventre, pyroute2-dev
I prepared the code to support different lwtunnel types — https://github.com/svinota/pyroute2/commit/74db7d344f8dba8cd81f1713f77b5dafbb0fb579

So you can try to play with it already. I will also, but on the weekend.

To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.

Pier Luigi Ventre

unread,
Sep 22, 2017, 9:31:55 AM9/22/17
to pyroute2-dev
Hi Peter,
thanks for the commit. I was playing a little bit with code, now the technical difficulties for me are how I can encode this (I did not have too much time to dig into the code of pyroute2 library):

Do you have any suggestion for me ? I was looking MPLS code but MPLS encapsulation is managed in a different way and uses different structures.

Thanks
Pier

Peter Saveliev

unread,
Sep 22, 2017, 11:28:30 AM9/22/17
to Pier Luigi Ventre, pyroute2-dev
I committed a stub code for the NLA. Now we should decode the SRH structure.

To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.

Pier Luigi Ventre

unread,
Sep 23, 2017, 8:31:17 AM9/23/17
to pyroute2-dev
Hi Peter,
thanks for the commit. Starting from your code I was able to create a seg6 tunnel, the change is very quick and dirty (for now) but I think I can finish the work with the right suggestions.
The question is, do you plan to work on this in the next future or do you want me finish the patch ? If yes, how do you want to proceed ? PR on github ?

Thanks
Pier 

Peter Saveliev

unread,
Sep 23, 2017, 8:56:49 AM9/23/17
to Pier Luigi Ventre, pyroute2-dev
Open a PR, please, we'll discuss the code on GitHub. You know how to work with SRH, I know the library, we'll get it working in the right way.

To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages