Skip to content

Commit

Permalink
fix: replace replace with add to override existing route (#2061)
Browse files Browse the repository at this point in the history
  • Loading branch information
lut777 committed Nov 23, 2022
1 parent 06d2231 commit d1bd047
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/daemon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ func (c *Controller) reconcileRouters(event subnetEvent) error {
}
// add new routes first
for _, r := range routesToAdd {
if err = netlink.RouteAdd(&r); err != nil && !errors.Is(err, syscall.EEXIST) {
klog.Errorf("failed to add route for subnet %s: %v", newSubnet.Name, err)
if err = netlink.RouteReplace(&r); err != nil && !errors.Is(err, syscall.EEXIST) {
klog.Errorf("failed to replace route for subnet %s: %v", newSubnet.Name, err)
return err
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/daemon/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ func (c *Controller) addPolicyRouting(family int, gateway string, priority, tabl
Gw: net.ParseIP(gateway),
Table: int(tableID),
}
if err := netlink.RouteAdd(route); err != nil && !errors.Is(err, syscall.EEXIST) {
err = fmt.Errorf("failed to add route in table %d: %+v", tableID, err)
if err := netlink.RouteReplace(route); err != nil && !errors.Is(err, syscall.EEXIST) {
err = fmt.Errorf("failed to replace route in table %d: %+v", tableID, err)
klog.Error(err)
return err
}
Expand Down Expand Up @@ -817,8 +817,8 @@ func (c *Controller) getOtherNodes(protocol string) ([]string, error) {
return ret, nil
}

//Generally, the MTU of the interface is set to 1400. But in special cases, a special pod (docker indocker) will introduce the docker0 interface to the pod. The MTU of docker0 is 1500.
//The network application in pod will calculate the TCP MSS according to the MTU of docker0, and then initiate communication with others. After the other party sends a response, the kernel protocol stack of Linux host will send ICMP unreachable message to the other party, indicating that IP fragmentation is needed, which is not supported by the other party, resulting in communication failure.
// Generally, the MTU of the interface is set to 1400. But in special cases, a special pod (docker indocker) will introduce the docker0 interface to the pod. The MTU of docker0 is 1500.
// The network application in pod will calculate the TCP MSS according to the MTU of docker0, and then initiate communication with others. After the other party sends a response, the kernel protocol stack of Linux host will send ICMP unreachable message to the other party, indicating that IP fragmentation is needed, which is not supported by the other party, resulting in communication failure.
func (c *Controller) appendMssRule() {
if c.config.Iface != "" && c.config.MSS > 0 {
iface, err := findInterface(c.config.Iface)
Expand Down

0 comments on commit d1bd047

Please sign in to comment.