Skip to content

Commit

Permalink
Fix routing issue with cache mismatch
Browse files Browse the repository at this point in the history
Summary:
Moving routes from link to unicast and vice versa seems to break
caches. Change it so that if there is a switch, an extra sync happens before
hand.

Reviewed By: ammubhave

Differential Revision: D15438076

fbshipit-source-id: 0e51b8c10f890e1e3f9f393a1398cc8674395831
  • Loading branch information
Mario Flajslik authored and facebook-github-bot committed May 22, 2019
1 parent 8e66fe2 commit a3df8b3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
69 changes: 38 additions & 31 deletions openr/fbmeshd/routing/Routing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,43 @@ Routing::doSyncRoutes() {
VLOG(10) << "No current gate found";
}

auto destination = std::make_pair<folly::IPAddress, uint8_t>(
auto destination =
folly::CIDRNetwork{getTaygaIPV6FromMacAddress(meshMacAddress), 128};
linkRouteDb.emplace(
std::make_pair(destination, kTaygaIfName),
fbnl::RouteBuilder{}
.setDestination(destination)
.setProtocolId(98)
.setRouteIfIndex(taygaIfIndex)
.setRouteIfName(kTaygaIfName)
.buildLinkRoute());

destination = folly::CIDRNetwork{folly::IPAddressV4{"172.16.0.0"}, 16};
linkRouteDb.emplace(
std::make_pair(destination, kTaygaIfName),
fbnl::RouteBuilder{}
.setDestination(destination)
.setProtocolId(98)
.setRouteIfIndex(taygaIfIndex)
.setRouteIfName(kTaygaIfName)
.buildLinkRoute());

mesh0Addrs.push_back(
fbnl::IfAddressBuilder{}
.setPrefix(folly::CIDRNetwork{
getMesh0IPV6FromMacAddress(meshMacAddress), 64})
.setIfIndex(meshIfIndex)
.build());

netlinkSocket_.syncIfAddress(
meshIfIndex, mesh0Addrs, AF_INET6, RT_SCOPE_UNIVERSE);

if (isGateBeforeRouteSync_ != isGate_) {
netlinkSocket_.syncUnicastRoutes(98, std::move(unicastRouteDb)).get();
netlinkSocket_.syncLinkRoutes(98, std::move(linkRouteDb)).get();
}

destination = std::make_pair<folly::IPAddress, uint8_t>(
folly::IPAddressV6{"fd00:ffff::"}, 96);

if (isGate_) {
Expand Down Expand Up @@ -263,37 +299,8 @@ Routing::doSyncRoutes() {
.build())
.build());
}
isGateBeforeRouteSync_ = isGate_;

destination =
folly::CIDRNetwork{getTaygaIPV6FromMacAddress(meshMacAddress), 128};
linkRouteDb.emplace(
std::make_pair(destination, kTaygaIfName),
fbnl::RouteBuilder{}
.setDestination(destination)
.setProtocolId(98)
.setRouteIfIndex(taygaIfIndex)
.setRouteIfName(kTaygaIfName)
.buildLinkRoute());

destination = folly::CIDRNetwork{folly::IPAddressV4{"172.16.0.0"}, 16};
linkRouteDb.emplace(
std::make_pair(destination, kTaygaIfName),
fbnl::RouteBuilder{}
.setDestination(destination)
.setProtocolId(98)
.setRouteIfIndex(taygaIfIndex)
.setRouteIfName(kTaygaIfName)
.buildLinkRoute());

mesh0Addrs.push_back(
fbnl::IfAddressBuilder{}
.setPrefix(folly::CIDRNetwork{
getMesh0IPV6FromMacAddress(meshMacAddress), 64})
.setIfIndex(meshIfIndex)
.build());

netlinkSocket_.syncIfAddress(
meshIfIndex, mesh0Addrs, AF_INET6, RT_SCOPE_UNIVERSE);
netlinkSocket_.syncUnicastRoutes(98, std::move(unicastRouteDb)).get();
netlinkSocket_.syncLinkRoutes(98, std::move(linkRouteDb)).get();
});
Expand Down
1 change: 1 addition & 0 deletions openr/fbmeshd/routing/Routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class Routing : public folly::EventBase,
bool isRoot_{false};
std::chrono::milliseconds rootPannInterval_{5000};
bool isGate_{false};
bool isGateBeforeRouteSync_{false};

/*
* Path state
Expand Down

0 comments on commit a3df8b3

Please sign in to comment.