Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions nl/seg6_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ func (s1 *IPv6SrHdr) Equal(s2 IPv6SrHdr) bool {
}

// seg6 encap mode
// from include/uapi/linux/seg6_iptunnel.h
const (
SEG6_IPTUN_MODE_INLINE = iota
SEG6_IPTUN_MODE_ENCAP
SEG6_IPTUN_MODE_L2ENCAP
SEG6_IPTUN_MODE_ENCAP_RED
SEG6_IPTUN_MODE_L2ENCAP_RED
)

// number of nested RTATTR
Expand All @@ -49,6 +53,7 @@ const (
SEG6_IPTUNNEL_SRH
__SEG6_IPTUNNEL_MAX
)

const (
SEG6_IPTUNNEL_MAX = __SEG6_IPTUNNEL_MAX - 1
)
Expand Down Expand Up @@ -121,6 +126,7 @@ func DecodeSEG6Srh(buf []byte) ([]net.IP, error) {
}
return srh.Segments, nil
}

func EncodeSEG6Srh(segments []net.IP) ([]byte, error) {
nsegs := len(segments) // nsegs: number of segments
if nsegs == 0 {
Expand Down Expand Up @@ -149,6 +155,12 @@ func SEG6EncapModeString(mode int) string {
return "inline"
case SEG6_IPTUN_MODE_ENCAP:
return "encap"
case SEG6_IPTUN_MODE_L2ENCAP:
return "l2encap"
case SEG6_IPTUN_MODE_ENCAP_RED:
return "encap.red"
case SEG6_IPTUN_MODE_L2ENCAP_RED:
return "l2encap.red"
Comment on lines +158 to +163
Copy link
Contributor

Choose a reason for hiding this comment

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

These matches https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/iproute_lwtunnel.c?id=2a82227f984b3f97354e4a490d3f172eedf07f63#n133:

static const char *seg6_mode_types[] = {
	[SEG6_IPTUN_MODE_INLINE]	= "inline",
	[SEG6_IPTUN_MODE_ENCAP]		= "encap",
	[SEG6_IPTUN_MODE_L2ENCAP]	= "l2encap",
	[SEG6_IPTUN_MODE_ENCAP_RED]	= "encap.red",
	[SEG6_IPTUN_MODE_L2ENCAP_RED]	= "l2encap.red",
};

}
return "unknown"
}