Skip to content

Commit c31176e

Browse files
committed
feat: remove addition of custom routes
1 parent 7cc5010 commit c31176e

File tree

1 file changed

+6
-41
lines changed

1 file changed

+6
-41
lines changed

network/transparent_vlan_endpointclient_linux.go

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -544,16 +544,13 @@ func (client *TransparentVlanEndpointClient) ConfigureContainerInterfacesAndRout
544544
}
545545

546546
if epInfo.SkipDefaultRoutes {
547-
logger.Info("Skipping adding default routes in container ns as requested")
548-
if err := client.addCustomRoutes(client.containerVethName, epInfo.Subnets[0].Gateway, epInfo.Subnets[0].Prefix, 0); err != nil {
549-
return errors.Wrap(err, "failed container ns add custom routes")
550-
}
547+
logger.Info("Skipping adding routes in container ns as requested")
551548
return nil
552-
} else {
553-
logger.Info("Adding default routes in container ns")
554-
if err := client.addDefaultRoutes(client.containerVethName, 0); err != nil {
555-
return errors.Wrap(err, "failed container ns add default routes")
556-
}
549+
}
550+
551+
logger.Info("Adding default routes in container ns")
552+
if err := client.addDefaultRoutes(client.containerVethName, 0); err != nil {
553+
return errors.Wrap(err, "failed container ns add default routes")
557554
}
558555

559556
if err := client.AddDefaultArp(client.containerVethName, client.vnetMac.String()); err != nil {
@@ -648,38 +645,6 @@ func (client *TransparentVlanEndpointClient) addDefaultRoutes(linkToName string,
648645
return nil
649646
}
650647

651-
// Helper that creates routing rules for the current NS which direct packets
652-
// to the subnet gateway ip on linkToName device interface
653-
// Route 1: <gatewayIP> dev <linkToName>
654-
// Route 2: <subnetCIDR> via <gatewayIP> dev <linkToName>
655-
func (client *TransparentVlanEndpointClient) addCustomRoutes(linkToName string, gatewayIP net.IP, subnetCIDR net.IPNet, table int) error {
656-
// Add route for subnetgwIP (ip route add <gatewayIP> dev <linkToName>)
657-
gWIP, gwNet, _ := net.ParseCIDR(gatewayIP.String() + "/32")
658-
routeInfo := RouteInfo{
659-
Dst: *gwNet,
660-
Scope: netlink.RT_SCOPE_LINK,
661-
Table: table,
662-
}
663-
// Difference between interface name in addRoutes and DevName: in RouteInfo?
664-
if err := addRoutes(client.netlink, client.netioshim, linkToName, []RouteInfo{routeInfo}); err != nil {
665-
return err
666-
}
667-
668-
// Add subnet route (ip route add <subnetCIDR> via <gatewayIP> dev <linkToName>)
669-
subnetPrefix, subnetIPNet, _ := net.ParseCIDR(subnetCIDR.String())
670-
dstIP := net.IPNet{IP: subnetPrefix, Mask: subnetIPNet.Mask}
671-
routeInfo = RouteInfo{
672-
Dst: dstIP,
673-
Gw: gWIP,
674-
Table: table,
675-
}
676-
677-
if err := addRoutes(client.netlink, client.netioshim, linkToName, []RouteInfo{routeInfo}); err != nil {
678-
return err
679-
}
680-
return nil
681-
}
682-
683648
// Helper that creates arp entry for the current NS which maps the virtual
684649
// gateway (169.254.2.1) to destMac on a particular interfaceName
685650
// Example: (169.254.2.1) at 12:34:56:78:9a:bc [ether] PERM on <interfaceName>

0 commit comments

Comments
 (0)