Skip to contentSkip to conversation

Why we need add :: at the last when encap seg6 with inline mode?

DISCUSSION Hangbin Liu 1 participant 2 messages Jun 27, 2023 – Jul 4, 2023 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi David,

When I tried encap seg6 inline mode via iproute, I saw it added a :: address at the last.

# ip -6 route add 1234::1234 encap seg6 mode inline segs 1::1 dev dum1
# ip -6 route show dev dum1
1234::1234  encap seg6 mode inline segs 2 [ 1::1 :: ] metric 1024 pref medium

In the iproute2 code

```
static struct ipv6_sr_hdr *parse_srh(char *segbuf, int hmac, bool encap)
{
        ...
        if (!encap)
                nsegs++;
        ...
```

So is there any reason we add this?

Thanks
Hangbin

#2 lore raw

Re: R: Why we need add :: at the last when encap seg6 with inline mode?

In reply to a message not in the archive

Hi Paolo,

Quoted 19 lines · paolo lungaroni

Just for the sake of clarity let's consider Example 1 where the SID List is built as follows: <S3,S2,S1>.

Before applying H.Insert
IPv6 DA=B2

After applying H.Insert:

   IPv6 DA=S1 | SRH <B2,S3,S2,S1>

In this representation, we stick with the draft conventions where the SID List is represented in the reversed order. That means that S1 will be the first SID, S2 the second one, etc. B2 is the original IPv6 DA that is pushed into the SID List and will be restored once the SRH is removed.

Now let's consider the H.Insert implementation in Linux.

User space
=========

Quoted 9 lines

Currently, when a H.Insert tunnel is instantiated the userspace (iproute2, in this case) acquires all the info (e.g. inline, segs, etc) from the CLI and builds directly the required SRH header [2].
Considering the H.Insert tunnel (i.e. inline mode), parse_srh() (line 894) accommodates for an extra space required to store the original IPv6 DA (i.e. B2 considering the Example 1) which is not known at the moment of the tunnel creation.
For this reason, iproute2 fills the reserved space with 16 bytes set to zero (and that's why we see ::).

Thanks for the explanation. Compared with dealing each segment route and adding the original DA in the middle of struct ipv6_sr_hdr, this way looks more easier. Although the users may feel a little confused :)

Regards
Hangbin