add proto field to Iptun

This commit is contained in:
Tao Li 2021-05-27 16:43:04 +02:00 committed by Vish (Ishaya) Abrams
parent 0639e7e787
commit f24382625b
2 changed files with 4 additions and 0 deletions

View File

@ -1038,6 +1038,7 @@ type Iptun struct {
EncapType uint16 EncapType uint16
EncapFlags uint16 EncapFlags uint16
FlowBased bool FlowBased bool
Proto uint8
} }
func (iptun *Iptun) Attrs() *LinkAttrs { func (iptun *Iptun) Attrs() *LinkAttrs {

View File

@ -2874,6 +2874,7 @@ func addIptunAttrs(iptun *Iptun, linkInfo *nl.RtAttr) {
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_FLAGS, nl.Uint16Attr(iptun.EncapFlags)) data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_FLAGS, nl.Uint16Attr(iptun.EncapFlags))
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_SPORT, htons(iptun.EncapSport)) data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_SPORT, htons(iptun.EncapSport))
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_DPORT, htons(iptun.EncapDport)) data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_DPORT, htons(iptun.EncapDport))
data.AddRtAttr(nl.IFLA_IPTUN_PROTO, nl.Uint8Attr(iptun.Proto))
} }
func parseIptunData(link Link, data []syscall.NetlinkRouteAttr) { func parseIptunData(link Link, data []syscall.NetlinkRouteAttr) {
@ -2904,6 +2905,8 @@ func parseIptunData(link Link, data []syscall.NetlinkRouteAttr) {
iptun.EncapFlags = native.Uint16(datum.Value[0:2]) iptun.EncapFlags = native.Uint16(datum.Value[0:2])
case nl.IFLA_IPTUN_COLLECT_METADATA: case nl.IFLA_IPTUN_COLLECT_METADATA:
iptun.FlowBased = true iptun.FlowBased = true
case nl.IFLA_IPTUN_PROTO:
iptun.Proto = datum.Value[0]
} }
} }
} }