summaryrefslogtreecommitdiff
path: root/vendor/github.com/vishvananda/netlink/link_linux.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-22 11:37:45 -0400
committerGitHub <noreply@github.com>2021-09-22 11:37:45 -0400
commite92b3830339cc9c8240d4553ccd23b3ec5578e4b (patch)
treeeb32501e758aed50f09d7a5bd23bde99e555ce61 /vendor/github.com/vishvananda/netlink/link_linux.go
parentd88ed478cb6e422ee21a7ab9c99ece2d45bdfcab (diff)
parentaf49810a6e08ed084294ce03e1c8a5efb8d1a705 (diff)
downloadpodman-e92b3830339cc9c8240d4553ccd23b3ec5578e4b.tar.gz
podman-e92b3830339cc9c8240d4553ccd23b3ec5578e4b.tar.bz2
podman-e92b3830339cc9c8240d4553ccd23b3ec5578e4b.zip
Merge pull request #11629 from Luap99/CNI-1.0
Bump CNI to v1.0.1
Diffstat (limited to 'vendor/github.com/vishvananda/netlink/link_linux.go')
-rw-r--r--vendor/github.com/vishvananda/netlink/link_linux.go131
1 files changed, 128 insertions, 3 deletions
diff --git a/vendor/github.com/vishvananda/netlink/link_linux.go b/vendor/github.com/vishvananda/netlink/link_linux.go
index c02fa63b8..3b959299c 100644
--- a/vendor/github.com/vishvananda/netlink/link_linux.go
+++ b/vendor/github.com/vishvananda/netlink/link_linux.go
@@ -34,6 +34,21 @@ const (
TUNTAP_MULTI_QUEUE_DEFAULTS TuntapFlag = TUNTAP_MULTI_QUEUE | TUNTAP_NO_PI
)
+var StringToTuntapModeMap = map[string]TuntapMode{
+ "tun": TUNTAP_MODE_TUN,
+ "tap": TUNTAP_MODE_TAP,
+}
+
+func (ttm TuntapMode) String() string {
+ switch ttm {
+ case TUNTAP_MODE_TUN:
+ return "tun"
+ case TUNTAP_MODE_TAP:
+ return "tap"
+ }
+ return "unknown"
+}
+
const (
VF_LINK_STATE_AUTO uint32 = 0
VF_LINK_STATE_ENABLE uint32 = 1
@@ -1046,8 +1061,8 @@ func addBondAttrs(bond *Bond, linkInfo *nl.RtAttr) {
if bond.LpInterval >= 0 {
data.AddRtAttr(nl.IFLA_BOND_LP_INTERVAL, nl.Uint32Attr(uint32(bond.LpInterval)))
}
- if bond.PackersPerSlave >= 0 {
- data.AddRtAttr(nl.IFLA_BOND_PACKETS_PER_SLAVE, nl.Uint32Attr(uint32(bond.PackersPerSlave)))
+ if bond.PacketsPerSlave >= 0 {
+ data.AddRtAttr(nl.IFLA_BOND_PACKETS_PER_SLAVE, nl.Uint32Attr(uint32(bond.PacketsPerSlave)))
}
if bond.LacpRate >= 0 {
data.AddRtAttr(nl.IFLA_BOND_AD_LACP_RATE, nl.Uint8Attr(uint8(bond.LacpRate)))
@@ -1404,6 +1419,8 @@ func (h *Handle) linkModify(link Link, flags int) error {
data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)
data.AddRtAttr(nl.IFLA_MACVLAN_MODE, nl.Uint32Attr(macvlanModes[link.Mode]))
}
+ case *Geneve:
+ addGeneveAttrs(link, linkInfo)
case *Gretap:
addGretapAttrs(link, linkInfo)
case *Iptun:
@@ -1667,6 +1684,8 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
link = &Macvlan{}
case "macvtap":
link = &Macvtap{}
+ case "geneve":
+ link = &Geneve{}
case "gretap":
link = &Gretap{}
case "ip6gretap":
@@ -1693,6 +1712,8 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
link = &Tuntap{}
case "ipoib":
link = &IPoIB{}
+ case "can":
+ link = &Can{}
default:
link = &GenericLink{LinkType: linkType}
}
@@ -1714,6 +1735,8 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
parseMacvlanData(link, data)
case "macvtap":
parseMacvtapData(link, data)
+ case "geneve":
+ parseGeneveData(link, data)
case "gretap":
parseGretapData(link, data)
case "ip6gretap":
@@ -1742,6 +1765,8 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
parseTuntapData(link, data)
case "ipoib":
parseIPoIBData(link, data)
+ case "can":
+ parseCanData(link, data)
}
case nl.IFLA_INFO_SLAVE_KIND:
slaveType = string(info.Value[:len(info.Value)-1])
@@ -2299,7 +2324,7 @@ func parseBondData(link Link, data []syscall.NetlinkRouteAttr) {
case nl.IFLA_BOND_LP_INTERVAL:
bond.LpInterval = int(native.Uint32(data[i].Value[0:4]))
case nl.IFLA_BOND_PACKETS_PER_SLAVE:
- bond.PackersPerSlave = int(native.Uint32(data[i].Value[0:4]))
+ bond.PacketsPerSlave = int(native.Uint32(data[i].Value[0:4]))
case nl.IFLA_BOND_AD_LACP_RATE:
bond.LacpRate = BondLacpRate(data[i].Value[0])
case nl.IFLA_BOND_AD_SELECT:
@@ -2448,6 +2473,58 @@ func linkFlags(rawFlags uint32) net.Flags {
return f
}
+func addGeneveAttrs(geneve *Geneve, linkInfo *nl.RtAttr) {
+ data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)
+
+ if geneve.FlowBased {
+ // In flow based mode, no other attributes need to be configured
+ linkInfo.AddRtAttr(nl.IFLA_GENEVE_COLLECT_METADATA, boolAttr(geneve.FlowBased))
+ return
+ }
+
+ if ip := geneve.Remote; ip != nil {
+ if ip4 := ip.To4(); ip4 != nil {
+ data.AddRtAttr(nl.IFLA_GENEVE_REMOTE, ip.To4())
+ } else {
+ data.AddRtAttr(nl.IFLA_GENEVE_REMOTE6, []byte(ip))
+ }
+ }
+
+ if geneve.ID != 0 {
+ data.AddRtAttr(nl.IFLA_GENEVE_ID, nl.Uint32Attr(geneve.ID))
+ }
+
+ if geneve.Dport != 0 {
+ data.AddRtAttr(nl.IFLA_GENEVE_PORT, htons(geneve.Dport))
+ }
+
+ if geneve.Ttl != 0 {
+ data.AddRtAttr(nl.IFLA_GENEVE_TTL, nl.Uint8Attr(geneve.Ttl))
+ }
+
+ if geneve.Tos != 0 {
+ data.AddRtAttr(nl.IFLA_GENEVE_TOS, nl.Uint8Attr(geneve.Tos))
+ }
+}
+
+func parseGeneveData(link Link, data []syscall.NetlinkRouteAttr) {
+ geneve := link.(*Geneve)
+ for _, datum := range data {
+ switch datum.Attr.Type {
+ case nl.IFLA_GENEVE_ID:
+ geneve.ID = native.Uint32(datum.Value[0:4])
+ case nl.IFLA_GENEVE_REMOTE, nl.IFLA_GENEVE_REMOTE6:
+ geneve.Remote = datum.Value
+ case nl.IFLA_GENEVE_PORT:
+ geneve.Dport = ntohs(datum.Value[0:2])
+ case nl.IFLA_GENEVE_TTL:
+ geneve.Ttl = uint8(datum.Value[0])
+ case nl.IFLA_GENEVE_TOS:
+ geneve.Tos = uint8(datum.Value[0])
+ }
+ }
+}
+
func addGretapAttrs(gretap *Gretap, linkInfo *nl.RtAttr) {
data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)
@@ -3172,6 +3249,54 @@ func parseIPoIBData(link Link, data []syscall.NetlinkRouteAttr) {
}
}
+func parseCanData(link Link, data []syscall.NetlinkRouteAttr) {
+ can := link.(*Can)
+ for _, datum := range data {
+
+ switch datum.Attr.Type {
+ case nl.IFLA_CAN_BITTIMING:
+ can.BitRate = native.Uint32(datum.Value)
+ can.SamplePoint = native.Uint32(datum.Value[4:])
+ can.TimeQuanta = native.Uint32(datum.Value[8:])
+ can.PropagationSegment = native.Uint32(datum.Value[12:])
+ can.PhaseSegment1 = native.Uint32(datum.Value[16:])
+ can.PhaseSegment2 = native.Uint32(datum.Value[20:])
+ can.SyncJumpWidth = native.Uint32(datum.Value[24:])
+ can.BitRatePreScaler = native.Uint32(datum.Value[28:])
+ case nl.IFLA_CAN_BITTIMING_CONST:
+ can.Name = string(datum.Value[:16])
+ can.TimeSegment1Min = native.Uint32(datum.Value[16:])
+ can.TimeSegment1Max = native.Uint32(datum.Value[20:])
+ can.TimeSegment2Min = native.Uint32(datum.Value[24:])
+ can.TimeSegment2Max = native.Uint32(datum.Value[28:])
+ can.SyncJumpWidthMax = native.Uint32(datum.Value[32:])
+ can.BitRatePreScalerMin = native.Uint32(datum.Value[36:])
+ can.BitRatePreScalerMax = native.Uint32(datum.Value[40:])
+ can.BitRatePreScalerInc = native.Uint32(datum.Value[44:])
+ case nl.IFLA_CAN_CLOCK:
+ can.ClockFrequency = native.Uint32(datum.Value)
+ case nl.IFLA_CAN_STATE:
+ can.State = native.Uint32(datum.Value)
+ case nl.IFLA_CAN_CTRLMODE:
+ can.Mask = native.Uint32(datum.Value)
+ can.Flags = native.Uint32(datum.Value[4:])
+ case nl.IFLA_CAN_BERR_COUNTER:
+ can.TxError = native.Uint16(datum.Value)
+ can.RxError = native.Uint16(datum.Value[2:])
+ case nl.IFLA_CAN_RESTART_MS:
+ can.RestartMs = native.Uint32(datum.Value)
+ case nl.IFLA_CAN_DATA_BITTIMING_CONST:
+ case nl.IFLA_CAN_RESTART:
+ case nl.IFLA_CAN_DATA_BITTIMING:
+ case nl.IFLA_CAN_TERMINATION:
+ case nl.IFLA_CAN_TERMINATION_CONST:
+ case nl.IFLA_CAN_BITRATE_CONST:
+ case nl.IFLA_CAN_DATA_BITRATE_CONST:
+ case nl.IFLA_CAN_BITRATE_MAX:
+ }
+ }
+}
+
func addIPoIBAttrs(ipoib *IPoIB, linkInfo *nl.RtAttr) {
data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)
data.AddRtAttr(nl.IFLA_IPOIB_PKEY, nl.Uint16Attr(uint16(ipoib.Pkey)))