-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fixes to route mirroring #40099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fixes to route mirroring #40099
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,10 @@ void RoutingTable::ModifyRouteImpl(const Route& route, Operation action) | |
| { | ||
| ModifyLoopbackRouteImpl<TAddr>(route, operation, flags); | ||
| } | ||
| else if (route.defaultRoute && route.IsOnlink()) | ||
| { | ||
| ModifyDefaultLinkLocalRouteImpl<TAddr>(route, operation, flags); | ||
| } | ||
| else if (route.defaultRoute) | ||
| { | ||
| ModifyDefaultRouteImpl<TAddr>(route, operation, flags); | ||
|
|
@@ -193,8 +197,8 @@ void RoutingTable::ModifyLoopbackRouteImpl(const Route& route, int operation, in | |
|
|
||
| GNS_LOG_INFO( | ||
| "SendMessage Route (to {}, via {}), operation ({}), netLinkflags ({})", | ||
| route.to.has_value() ? route.to.value().Addr().c_str() : "[empty]", | ||
| route.via.has_value() ? route.via.value().Addr().c_str() : "[empty]", | ||
| route.to.value().Addr().c_str(), | ||
| route.via.value().Addr().c_str(), | ||
| RouteOperationToString(operation), | ||
| NetLinkFormatFlagsToString(flags).c_str()); | ||
|
|
||
|
|
@@ -222,14 +226,33 @@ void RoutingTable::ModifyLoopbackRouteImpl(const Route& route, int operation, in | |
|
|
||
| message.route.rtm_flags |= RTNH_F_ONLINK; | ||
| GNS_LOG_INFO( | ||
| "InitializeAddressAttribute RTA_DST ({}) RTA_GATEWAY ({}) RTA_PRIORITY ([not set])", | ||
| "Netlink message configuration: RTA_DST ({}) RTA_GATEWAY ({}) RTA_PRIORITY ([not set])", | ||
| route.to.value().Addr().c_str(), | ||
| route.via.value().Addr().c_str()); | ||
| utils::InitializeAddressAttribute<TAddr>(message.to, route.to.value(), RTA_DST); | ||
| utils::InitializeAddressAttribute<TAddr>(message.via, route.via.value(), RTA_GATEWAY); | ||
| }); | ||
| } | ||
|
|
||
| template <typename TAddr> | ||
| void RoutingTable::ModifyDefaultLinkLocalRouteImpl(const Route& route, int operation, int flags) | ||
| { | ||
| struct Message : RouteMessage | ||
| { | ||
| utils::IntegerAttribute metric; | ||
| } __attribute__((packed)); | ||
|
|
||
| GNS_LOG_INFO( | ||
| "SendMessage Route (default onlink), operation ({}), netLinkflags ({})", | ||
| RouteOperationToString(operation), | ||
| NetLinkFormatFlagsToString(flags).c_str()); | ||
|
|
||
| SendMessage<Message>(route, operation, flags, [&](Message& message) { | ||
| GNS_LOG_INFO("Netlink message configuration: RTA_DST ([not set]) RTA_GATEWAY ([not set]), RTA_PRIORITY ({})", route.metric); | ||
| utils::InitializeIntegerAttribute(message.metric, route.metric, RTA_PRIORITY); | ||
| }); | ||
| } | ||
|
|
||
| template <typename TAddr> | ||
| void RoutingTable::ModifyDefaultRouteImpl(const Route& route, int operation, int flags) | ||
| { | ||
|
|
@@ -246,15 +269,15 @@ void RoutingTable::ModifyDefaultRouteImpl(const Route& route, int operation, int | |
|
|
||
| GNS_LOG_INFO( | ||
| "SendMessage Route (to {}, via {}), operation ({}), netLinkflags ({})", | ||
| route.to.has_value() ? route.to.value().Addr().c_str() : "[empty]", | ||
| route.via.has_value() ? route.via.value().Addr().c_str() : "[empty]", | ||
| "[empty]", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it guaranteed that route.to is always empty? |
||
| route.via.value().Addr().c_str(), | ||
| RouteOperationToString(operation), | ||
| NetLinkFormatFlagsToString(flags).c_str()); | ||
|
|
||
| SendMessage<Message>(route, operation, flags, [&](Message& message) { | ||
| GNS_LOG_INFO( | ||
| "InitializeAddressAttribute RTA_DST ([not set]) RTA_GATEWAY ({}), RTA_PRIORITY ({})", | ||
| route.to.has_value() ? route.to.value().Addr().c_str() : "[empty]", | ||
| "Netlink message configuration: RTA_DST ([not set]) RTA_GATEWAY ({}), RTA_PRIORITY ({})", | ||
| route.via.value().Addr().c_str(), | ||
| route.metric); | ||
| utils::InitializeAddressAttribute<TAddr>(message.via, route.via.value(), RTA_GATEWAY); | ||
keith-horton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| utils::InitializeIntegerAttribute(message.metric, route.metric, RTA_PRIORITY); | ||
|
|
@@ -264,6 +287,11 @@ void RoutingTable::ModifyDefaultRouteImpl(const Route& route, int operation, int | |
| template <typename TAddr> | ||
| void RoutingTable::ModifyLinkLocalRouteImpl(const Route& route, int operation, int flags) | ||
| { | ||
| if (!route.to.has_value()) | ||
| { | ||
| throw RuntimeErrorWithSourceLocation("Link-local route is missing its destination address"); | ||
| } | ||
|
|
||
| struct Message : RouteMessage | ||
| { | ||
| utils::AddressAttribute<TAddr> to; | ||
|
|
@@ -272,15 +300,15 @@ void RoutingTable::ModifyLinkLocalRouteImpl(const Route& route, int operation, i | |
|
|
||
| GNS_LOG_INFO( | ||
| "SendMessage Route (to {}, via {}), operation ({}), netLinkflags ({})", | ||
| route.to.has_value() ? route.to.value().Addr().c_str() : "[empty]", | ||
| route.via.has_value() ? route.via.value().Addr().c_str() : "[empty]", | ||
| route.to.value().Addr().c_str(), | ||
| "[empty]", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. route.via might have a value, right?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's guaranteed in all possible paths that calling ModifyLinkLocalRouteImpl can never have a route.via?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if so, we should fail the request if route.via.has_value(). |
||
| RouteOperationToString(operation), | ||
| NetLinkFormatFlagsToString(flags).c_str()); | ||
|
|
||
| SendMessage<Message>(route, operation, flags, [&](Message& message) { | ||
| GNS_LOG_INFO( | ||
| "InitializeAddressAttribute RTA_DST ({}) RTA_GATEWAY ([not set]), RTA_PRIORITY ({})", | ||
| route.to.has_value() ? route.to.value().Addr().c_str() : "[empty]", | ||
| "Netlink message configuration: RTA_DST ({}) RTA_GATEWAY ([not set]), RTA_PRIORITY ({})", | ||
| route.to.value().Addr().c_str(), | ||
| route.metric); | ||
| utils::InitializeAddressAttribute<TAddr>(message.to, route.to.value(), RTA_DST); | ||
| utils::InitializeIntegerAttribute(message.metric, route.metric, RTA_PRIORITY); | ||
|
|
@@ -294,6 +322,10 @@ void RoutingTable::ModifyOfflinkRouteImpl(const Route& route, int operation, int | |
| { | ||
| throw RuntimeErrorWithSourceLocation("Offlink route is missing its next hop"); | ||
| } | ||
| if (!route.to.has_value()) | ||
FetoiuCatalin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| throw RuntimeErrorWithSourceLocation("Offlink route is missing its destination address"); | ||
| } | ||
|
|
||
| struct Message : RouteMessage | ||
| { | ||
|
|
@@ -304,16 +336,16 @@ void RoutingTable::ModifyOfflinkRouteImpl(const Route& route, int operation, int | |
|
|
||
| GNS_LOG_INFO( | ||
| "SendMessage Route (to {}, via {}), operation ({}), netLinkflags ({})", | ||
| route.to.has_value() ? route.to.value().Addr().c_str() : "[empty]", | ||
| route.via.has_value() ? route.via.value().Addr().c_str() : "[empty]", | ||
| route.to.value().Addr().c_str(), | ||
| route.via.value().Addr().c_str(), | ||
| RouteOperationToString(operation), | ||
| NetLinkFormatFlagsToString(flags).c_str()); | ||
|
|
||
| SendMessage<Message>(route, operation, flags, [&](Message& message) { | ||
| GNS_LOG_INFO( | ||
| "InitializeAddressAttribute RTA_DST ({}) RTA_GATEWAY ({}), RTA_PRIORITY ({})", | ||
| route.to.has_value() ? route.to.value().Addr().c_str() : "[empty]", | ||
| route.via.has_value() ? route.via.value().Addr().c_str() : "[empty]", | ||
| "Netlink message configuration: RTA_DST ({}) RTA_GATEWAY ({}), RTA_PRIORITY ({})", | ||
| route.to.value().Addr().c_str(), | ||
| route.via.value().Addr().c_str(), | ||
| route.metric); | ||
| utils::InitializeAddressAttribute<TAddr>(message.to, route.to.value(), RTA_DST); | ||
| utils::InitializeAddressAttribute<TAddr>(message.via, route.via.value(), RTA_GATEWAY); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.