Skip to content

Commit

Permalink
fix: rm bridge route, add rule with priority 2048; issue #515
Browse files Browse the repository at this point in the history
  • Loading branch information
abstractmj committed Jul 6, 2020
1 parent f857f0f commit 1e79253
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 41 deletions.
4 changes: 0 additions & 4 deletions bcs-services/bcs-network/qcloud-eip/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ type NetConf struct {
UUID string `json:"uuid"`
SubnetID string `json:"subnetId,omitempty"`
MTU int `json:"mtu,omitempty"`
// Design: If both bridge network mode and elastic network card mode exist
// copy route to bridge into each eni route table, otherwise pod with eni can
// not communicate with the bridge-mode pod
BridgeName string `json:"bridgeName"`
NetService *NetArgs `json:"netservice,omitempty"`
Args *bcsconf.CNIArgs
}
Expand Down
39 changes: 2 additions & 37 deletions bcs-services/bcs-network/qcloud-eip/eip/eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,25 +232,6 @@ func (eip *EIP) Init(file string, eniNum int, ipNum int) {
blog.Errorf("add default route %v for table %d failed, err %s", defaultRouteRule, id, err.Error())
os.Exit(1)
}

// if bridgeName is not null, copy bridge route into each eni route table
if len(netConf.BridgeName) != 0 {
// get routes in main route table about bridge
bridgeRoutes, err := getBridgeRoutes(mainRouteTableID, netConf.BridgeName)
if err != nil {
blog.Warnf("get bridge %s routes failed, err %s", netConf.BridgeName)
continue
}
for _, r := range bridgeRoutes {
r.Table = id
blog.Info("add bridge route %+v for bridge %s", r, netConf.BridgeName)
err = netlink.RouteAdd(&r)
if err != nil {
blog.Errorf("add bridge route failed, err %s", err.Error())
continue
}
}
}
}

// register ip pool for eni
Expand Down Expand Up @@ -457,24 +438,6 @@ func (eip *EIP) Recover(file string, eniNum int) {
blog.Errorf("add default route %v for table %d failed, err %s", defaultRouteRule, id, err.Error())
os.Exit(1)
}

// if bridgeName is not null, copy bridge route into each eni route table
if len(netConf.BridgeName) != 0 {
bridgeRoutes, err := getBridgeRoutes(mainRouteTableID, netConf.BridgeName)
if err != nil {
blog.Warnf("get bridge %s routes failed, err %s", netConf.BridgeName)
continue
}
for _, r := range bridgeRoutes {
r.Table = id
blog.Info("add bridge route %+v for bridge %s", r, netConf.BridgeName)
err = netlink.RouteAdd(&r)
if err != nil {
blog.Errorf("add bridge route failed, err %s", err.Error())
continue
}
}
}
}

blog.Infof("congratulations, node recovery successfully!")
Expand Down Expand Up @@ -752,6 +715,7 @@ func configureHostNS(hostIfName string, ipNet *net.IPNet, routeTableID int) erro
ruleToTable := netlink.NewRule()
ruleToTable.Dst = ipNet
ruleToTable.Table = routeTableID
ruleToTable.Priority = 2048
err = netlink.RuleDel(ruleToTable)
if err != nil {
blog.Warnf("clean old rule to table %s failed, err %s", ruleToTable.String(), err.Error())
Expand All @@ -765,6 +729,7 @@ func configureHostNS(hostIfName string, ipNet *net.IPNet, routeTableID int) erro
ruleFromTaskgroup := netlink.NewRule()
ruleFromTaskgroup.Src = ipNet
ruleFromTaskgroup.Table = routeTableID
ruleFromTaskgroup.Priority = 2048
err = netlink.RuleDel(ruleFromTaskgroup)
if err != nil {
blog.Warnf("clean old rule from taskgroup %s failed, err %s", ruleToTable.String(), err.Error())
Expand Down

0 comments on commit 1e79253

Please sign in to comment.