summaryrefslogtreecommitdiff
path: root/vendor/github.com/vishvananda/netlink/route.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-01-08 14:52:57 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-01-11 13:38:11 +0100
commitbd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87 (patch)
tree5f06e4e289f16d9164d692590a3fe6541b5384cf /vendor/github.com/vishvananda/netlink/route.go
parent545f24421247c9f6251a634764db3f8f8070a812 (diff)
downloadpodman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.tar.gz
podman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.tar.bz2
podman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.zip
vendor: update everything
* If possible, update each dependency to the latest available version. * Use releases over commit IDs and avoid vendoring branches. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/vishvananda/netlink/route.go')
-rw-r--r--vendor/github.com/vishvananda/netlink/route.go64
1 files changed, 63 insertions, 1 deletions
diff --git a/vendor/github.com/vishvananda/netlink/route.go b/vendor/github.com/vishvananda/netlink/route.go
index 03ac4b239..2cd58ee33 100644
--- a/vendor/github.com/vishvananda/netlink/route.go
+++ b/vendor/github.com/vishvananda/netlink/route.go
@@ -16,6 +16,7 @@ type Destination interface {
Decode([]byte) error
Encode() ([]byte, error)
String() string
+ Equal(Destination) bool
}
type Encap interface {
@@ -23,6 +24,7 @@ type Encap interface {
Decode([]byte) error
Encode() ([]byte, error)
String() string
+ Equal(Encap) bool
}
// Route represents a netlink route.
@@ -43,6 +45,8 @@ type Route struct {
MPLSDst *int
NewDst Destination
Encap Encap
+ MTU int
+ AdvMSS int
}
func (r Route) String() string {
@@ -72,6 +76,25 @@ func (r Route) String() string {
return fmt.Sprintf("{%s}", strings.Join(elems, " "))
}
+func (r Route) Equal(x Route) bool {
+ return r.LinkIndex == x.LinkIndex &&
+ r.ILinkIndex == x.ILinkIndex &&
+ r.Scope == x.Scope &&
+ ipNetEqual(r.Dst, x.Dst) &&
+ r.Src.Equal(x.Src) &&
+ r.Gw.Equal(x.Gw) &&
+ nexthopInfoSlice(r.MultiPath).Equal(x.MultiPath) &&
+ r.Protocol == x.Protocol &&
+ r.Priority == x.Priority &&
+ r.Table == x.Table &&
+ r.Type == x.Type &&
+ r.Tos == x.Tos &&
+ r.Flags == x.Flags &&
+ (r.MPLSDst == x.MPLSDst || (r.MPLSDst != nil && x.MPLSDst != nil && *r.MPLSDst == *x.MPLSDst)) &&
+ (r.NewDst == x.NewDst || (r.NewDst != nil && r.NewDst.Equal(x.NewDst))) &&
+ (r.Encap == x.Encap || (r.Encap != nil && r.Encap.Equal(x.Encap)))
+}
+
func (r *Route) SetFlag(flag NextHopFlag) {
r.Flags |= int(flag)
}
@@ -110,7 +133,46 @@ func (n *NexthopInfo) String() string {
elems = append(elems, fmt.Sprintf("Encap: %s", n.Encap))
}
elems = append(elems, fmt.Sprintf("Weight: %d", n.Hops+1))
- elems = append(elems, fmt.Sprintf("Gw: %d", n.Gw))
+ elems = append(elems, fmt.Sprintf("Gw: %s", n.Gw))
elems = append(elems, fmt.Sprintf("Flags: %s", n.ListFlags()))
return fmt.Sprintf("{%s}", strings.Join(elems, " "))
}
+
+func (n NexthopInfo) Equal(x NexthopInfo) bool {
+ return n.LinkIndex == x.LinkIndex &&
+ n.Hops == x.Hops &&
+ n.Gw.Equal(x.Gw) &&
+ n.Flags == x.Flags &&
+ (n.NewDst == x.NewDst || (n.NewDst != nil && n.NewDst.Equal(x.NewDst))) &&
+ (n.Encap == x.Encap || (n.Encap != nil && n.Encap.Equal(x.Encap)))
+}
+
+type nexthopInfoSlice []*NexthopInfo
+
+func (n nexthopInfoSlice) Equal(x []*NexthopInfo) bool {
+ if len(n) != len(x) {
+ return false
+ }
+ for i := range n {
+ if n[i] == nil || x[i] == nil {
+ return false
+ }
+ if !n[i].Equal(*x[i]) {
+ return false
+ }
+ }
+ return true
+}
+
+// ipNetEqual returns true iff both IPNet are equal
+func ipNetEqual(ipn1 *net.IPNet, ipn2 *net.IPNet) bool {
+ if ipn1 == ipn2 {
+ return true
+ }
+ if ipn1 == nil || ipn2 == nil {
+ return false
+ }
+ m1, _ := ipn1.Mask.Size()
+ m2, _ := ipn2.Mask.Size()
+ return m1 == m2 && ipn1.IP.Equal(ipn2.IP)
+}