Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing default table route management to work in all dual-stack cases #205

Merged
merged 1 commit into from
Apr 1, 2020
Merged
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: 6 additions & 6 deletions pkg/danmep/ep.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ func addIpToLink(ip string, iface netlink.Link) error {

func addIpRoutes(ep *danmtypes.DanmEp, dnet *danmtypes.DanmNet) error {
defaultRoutingTable := 0
err := addRoutes(dnet.Spec.Options.Routes, defaultRoutingTable)
err := addRoutes(dnet.Spec.Options.Routes, ep.Spec.Iface.Address, defaultRoutingTable)
if err != nil {
return err
}
err = addRoutes(dnet.Spec.Options.Routes6, defaultRoutingTable)
err = addRoutes(dnet.Spec.Options.Routes6, ep.Spec.Iface.AddressIPv6, defaultRoutingTable)
if err != nil {
return err
}
Expand All @@ -156,8 +156,8 @@ func addIpRoutes(ep *danmtypes.DanmEp, dnet *danmtypes.DanmNet) error {
return nil
}

func addRoutes(routes map[string]string, rtable int) error {
if routes == nil {
func addRoutes(routes map[string]string, allocatedIp string, rtable int) error {
if routes == nil || allocatedIp == "" || allocatedIp == ipam.NoneAllocType {
return nil
}
for key, value := range routes {
Expand Down Expand Up @@ -189,7 +189,7 @@ func addRoutes(routes map[string]string, rtable int) error {
}

func addPolicyRoute(rtable int, cidr string, proutes map[string]string) error {
if rtable == 0 || cidr == "" || cidr == ipam.NoneAllocType || proutes == nil {
if rtable == 0 || cidr == "" || cidr == ipam.NoneAllocType || proutes == nil {
return nil
}
srcIp, srcNet, _ := net.ParseCIDR(cidr)
Expand All @@ -201,7 +201,7 @@ func addPolicyRoute(rtable int, cidr string, proutes map[string]string) error {
if err != nil {
return errors.New("cannot add rule for policy-based IP routes because:" + err.Error())
}
err = addRoutes(proutes, rtable)
err = addRoutes(proutes, cidr, rtable)
if err != nil {
return err
}
Expand Down