Unsafe route reload (#1083)

This commit is contained in:
Nate Brown 2024-03-28 15:17:28 -05:00 committed by GitHub
parent 8b68a08723
commit bbb15f8cb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 1088 additions and 317 deletions

View file

@ -1,6 +1,7 @@
package overlay
import (
"bytes"
"fmt"
"math"
"net"
@ -21,6 +22,35 @@ type Route struct {
Install bool
}
// Equal determines if a route that could be installed in the system route table is equal to another
// Via is ignored since that is only consumed within nebula itself
func (r Route) Equal(t Route) bool {
if !r.Cidr.IP.Equal(t.Cidr.IP) {
return false
}
if !bytes.Equal(r.Cidr.Mask, t.Cidr.Mask) {
return false
}
if r.Metric != t.Metric {
return false
}
if r.MTU != t.MTU {
return false
}
if r.Install != t.Install {
return false
}
return true
}
func (r Route) String() string {
s := r.Cidr.String()
if r.Metric != 0 {
s += fmt.Sprintf(" metric: %v", r.Metric)
}
return s
}
func makeRouteTree(l *logrus.Logger, routes []Route, allowMTU bool) (*cidr.Tree4[iputil.VpnIp], error) {
routeTree := cidr.NewTree4[iputil.VpnIp]()
for _, r := range routes {