Skip to content

Commit

Permalink
tunnel interface names cannot be longer than 15 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsykim committed Jan 5, 2018
1 parent 5155c8d commit 641bf63
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions app/controllers/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ func (nrc *NetworkRoutingController) injectRoute(path *table.Path) error {

// check if the neighbour is in same subnet
if !nrc.nodeSubnet.Contains(nexthop) {
tunnelName := "tun-" + strings.Replace(nexthop.String(), ".", "", -1)
tunnelName := "tun" + strings.Replace(nexthop.String(), ".", "", -1)
glog.Infof("Found node: " + nexthop.String() + " to be in different subnet.")

// if overlay is not enabled then skip creating tunnels and adding route
Expand All @@ -785,17 +785,18 @@ func (nrc *NetworkRoutingController) injectRoute(path *table.Path) error {
link, err = netlink.LinkByName(tunnelName)
if err != nil {
glog.Infof("Found node: " + nexthop.String() + " to be in different subnet. Creating tunnel: " + tunnelName)
cmd := exec.Command("ip", "tunnel", "add", tunnelName, "mode", "ipip", "local", nrc.nodeIP.String(),
"remote", nexthop.String(), "dev", nrc.nodeInterface)
err = cmd.Run()
out, err := exec.Command("ip", "tunnel", "add", tunnelName, "mode", "ipip", "local", nrc.nodeIP.String(),
"remote", nexthop.String(), "dev", nrc.nodeInterface).CombinedOutput()
if err != nil {
return errors.New("Route not injected for the route advertised by the node " + nexthop.String() +
". Failed to create tunnel interface " + tunnelName)
return fmt.Errorf("Route not injected for the route advertised by the node %s "+
"Failed to create tunnel interface %s. error: %s, output: %s",
nexthop.String(), tunnelName, err, string(out))
}

link, err = netlink.LinkByName(tunnelName)
if err != nil {
return errors.New("Route not injected for the route advertised by the node " + nexthop.String() +
". Failed to create tunnel interface " + tunnelName)
return fmt.Errorf("Route not injected for the route advertised by the node %s "+
"Failed to get tunnel interface by name error: %s", tunnelName, err)
}
if err := netlink.LinkSetUp(link); err != nil {
return errors.New("Failed to bring tunnel interface " + tunnelName + " up due to: " + err.Error())
Expand All @@ -808,15 +809,15 @@ func (nrc *NetworkRoutingController) injectRoute(path *table.Path) error {
glog.Infof("Tunnel interface: " + tunnelName + " for the node " + nexthop.String() + " already exists.")
}

out, err := exec.Command("ip", "route", "list", "table", customRouteTableID).Output()
out, err := exec.Command("ip", "route", "list", "table", customRouteTableID).CombinedOutput()
if err != nil {
return fmt.Errorf("Failed to verify if route already exists in %s table: %s",
customRouteTableName, err.Error())
}
if !strings.Contains(string(out), tunnelName) {
if err = exec.Command("ip", "route", "add", nexthop.String(), "dev", tunnelName, "table",
customRouteTableID).Run(); err != nil {
return errors.New("Failed to add route in custom route table due to: " + err.Error())
if out, err = exec.Command("ip", "route", "add", nexthop.String(), "dev", tunnelName, "table",
customRouteTableID).CombinedOutput(); err != nil {
return fmt.Errorf("failed to add route in custom route table, err: %s, output: %s", err, string(out))
}
}

Expand Down

0 comments on commit 641bf63

Please sign in to comment.