Skip to content

Commit

Permalink
Merge pull request #8988 from sridhartigera/auto-pick-of-#8983-upstre…
Browse files Browse the repository at this point in the history
…am-release-v3.28

[release-v3.28] Auto pick #8983: In BPF dataplane, we add routes to UDP services, so that
  • Loading branch information
matthewdupre authored Jul 8, 2024
2 parents 6a4b97b + ff78f0e commit e965247
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
6 changes: 5 additions & 1 deletion felix/routetable/route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,11 @@ func (r *RouteTable) fullResyncRoutesForLink(logCxt *log.Entry, ifaceName string
routeProblems = append(routeProblems, "unexpected route")
}
if dest != ipV6LinkLocalCIDR {
if !r.deviceRouteSourceAddress.Equal(route.Src) {
expectedSrc := r.deviceRouteSourceAddress
if expectedTargetFound && expectedTarget.Src != nil {
expectedSrc = expectedTarget.Src.AsNetIP()
}
if !expectedSrc.Equal(route.Src) {
routeProblems = append(routeProblems, "incorrect source address")
}
if r.deviceRouteProtocol != route.Protocol {
Expand Down
42 changes: 42 additions & 0 deletions felix/routetable/route_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,48 @@ var _ = Describe("RouteTable", func() {
Expect(dataplane.RouteKeyToRoute[mocknetlink.KeyForRoute(&updateRoute)]).To(Equal(fixedRoute))
Expect(dataplane.HasStaticArpEntry(ip.MustParseCIDROrIP("10.0.0.5/32"), mac1, "cali5")).To(BeTrue())
})

It("should not delete route with source address if target has the same source", func() {
noopLink := dataplane.AddIface(7, "cali7", true, true)
noopRoute := netlink.Route{
LinkIndex: noopLink.LinkAttrs.Index,
Dst: mustParseCIDR("10.0.0.5/32"),
Type: syscall.RTN_UNICAST,
Protocol: FelixRouteProtocol,
Scope: netlink.SCOPE_LINK,
Src: net.ParseIP("192.168.0.2"),
Table: unix.RT_TABLE_MAIN,
}
rt.SetRoutes(noopLink.LinkAttrs.Name, []Target{
{CIDR: ip.MustParseCIDROrIP("10.0.0.5"), DestMAC: mac1, Src: ip.FromString("192.168.0.2")},
})
dataplane.AddMockRoute(&noopRoute)
err := rt.Apply()
Expect(err).ToNot(HaveOccurred())
Expect(dataplane.DeletedRouteKeys).ToNot(HaveKey(mocknetlink.KeyForRoute(&noopRoute)))
Expect(dataplane.UpdatedRouteKeys).ToNot(HaveKey(mocknetlink.KeyForRoute(&noopRoute)))
})

It("should delete route with different source address", func() {
noopLink := dataplane.AddIface(8, "cali8", true, true)
noopRoute := netlink.Route{
LinkIndex: noopLink.LinkAttrs.Index,
Dst: mustParseCIDR("10.0.0.5/32"),
Type: syscall.RTN_UNICAST,
Protocol: FelixRouteProtocol,
Scope: netlink.SCOPE_LINK,
Src: net.ParseIP("192.168.0.2"),
Table: unix.RT_TABLE_MAIN,
}
rt.SetRoutes(noopLink.LinkAttrs.Name, []Target{
{CIDR: ip.MustParseCIDROrIP("10.0.0.5"), DestMAC: mac1, Src: ip.FromString("192.168.0.3")},
})
dataplane.AddMockRoute(&noopRoute)
err := rt.Apply()
Expect(err).ToNot(HaveOccurred())
Expect(dataplane.DeletedRouteKeys).To(HaveKey(mocknetlink.KeyForRoute(&noopRoute)))
})

})

Describe("With a device route protocol set", func() {
Expand Down

0 comments on commit e965247

Please sign in to comment.