Skip to content

Commit 00b82fb

Browse files
authored
Merge pull request #887 from champtar/route-CHECK
Fix ValidateExpectedRoute with non default routes and nil GW
2 parents c795a3c + c347755 commit 00b82fb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/ip/utils_linux.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ func ValidateExpectedRoute(resultRoutes []*types.Route) error {
8383
// Ensure that each static route in prevResults is found in the routing table
8484
for _, route := range resultRoutes {
8585
find := &netlink.Route{Dst: &route.Dst, Gw: route.GW}
86-
routeFilter := netlink.RT_FILTER_DST | netlink.RT_FILTER_GW
86+
routeFilter := netlink.RT_FILTER_DST
87+
if route.GW != nil {
88+
routeFilter |= netlink.RT_FILTER_GW
89+
}
8790
var family int
8891

8992
switch {

plugins/main/ptp/ptp_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ var _ = Describe("ptp Operations", func() {
368368
doTest(conf, ver, 1, dnsConf, targetNS)
369369
})
370370

371-
It(fmt.Sprintf("[%s] configures and deconfigures a dual-stack ptp link with ADD/DEL", ver), func() {
371+
It(fmt.Sprintf("[%s] configures and deconfigures a dual-stack ptp link + routes with ADD/DEL", ver), func() {
372372
conf := fmt.Sprintf(`{
373373
"cniVersion": "%s",
374374
"name": "mynet",
@@ -381,6 +381,11 @@ var _ = Describe("ptp Operations", func() {
381381
[{ "subnet": "10.1.2.0/24"}],
382382
[{ "subnet": "2001:db8:1::0/66"}]
383383
],
384+
"routes": [
385+
{ "dst": "0.0.0.0/0" },
386+
{ "dst": "192.168.0.0/16" },
387+
{ "dst": "1.2.3.4/32" }
388+
],
384389
"dataDir": "%s"
385390
}
386391
}`, ver, dataDir)

0 commit comments

Comments
 (0)