...
- Keep track of the last time the peer was alive,
lpni_last_alive
- Keep track the last time the peer was notified that its state has changed,
lpni_timestamp
- The peer can change state under the following conditions:
- The LND notifies that the peer is down when it fails to send a message to the peer.
- As an example in o2iblnd:
- kiblnd_peer_connect_failed() and kiblnd_disconnect_conn() call kiblnd_peer_notify() which calls lnet_notify() to set the peer to
dead
if there was an error
- kiblnd_peer_connect_failed() and kiblnd_disconnect_conn() call kiblnd_peer_notify() which calls lnet_notify() to set the peer to
- As an example in o2iblnd:
- A message is received in
lnet_parse()
- In this case the peer stat state is set to alive only for gateway peer NIs
- When the router checker ping is responded to or it fails.
- If the router checker ping times out.
- The LND notifies that the peer is down when it fails to send a message to the peer.
- The peer can change state under the following conditions:
- This step only concerns routers: Only send the message if the peer is alive, determined as outlined above.
- On the router if the NI hasn't received any traffic for a period of
router_ping_timeout + MAX(live_router_check_interval, dead_router_check_interval)
then it's marked down.- This is done in order for the peers using the router to mark the peer down when the
avoid_asym_router_failure
is set to 1, which it is by default.
- This is done in order for the peers using the router to mark the peer down when the
...
Code Block |
---|
lnetctl route add --net <remote net> --gateway <gateway-primary-NID> |
When a route is entered the primary NID specified in the gateway parameter A router should be immediately discovered on first use. The discovery process will determine all the interfaces available on the router. There could be multiple interfaces on the same network.
A route should only be marked down if all the interfaces on the primary NID's network are downit can not route message, which means that the route's remote net on the router has no active interface.
Nodes on different networks will use different primary NIDs to refer to the same router. IE a primary NID is only a representation of the router on the peer with the route configured.
...
Some details were documented here: Routing and MR integration
Proposed Changes
Router Discovery
There are two ways to discover a router:
- when it's first added to the system.
- The problem with this is it doesn't work if the router is not up yet. You fail to discover it when its added, so when would you try to discover it again?
- When it's first used
- This is the most reasonable solution, since we check if the router has already been discovered when we first attempt to use and if it has not we initiate discovery. We will need to deal with this as we would discovery final destination in the sense that we'll need to queue the message to be sent once we finish discovery the router.
Option 2 will be implemented.
Jira | ||||||||
---|---|---|---|---|---|---|---|---|
|
Router Peer instead of Peer NI
Multi-Rail considers that a Peer can have multiple interfaces, IE Peer NIs, on different networks.
Gliffy Diagram | ||||
---|---|---|---|---|
|
Currently when a route is added the gateway is one of the leaves of the tree, IE a peer NI. To fully integrate routing with MR the gateway should be considered the tip of the tree, IE the peer.
This change will overhaul the current routing code. There are several fields in the struct lnet_peer_ni
which are used for routing:
Code Block |
---|
/* messages blocking for router credits */
struct list_head lpni_rtrq;
/* chain on router list */
struct list_head lpni_rtr_list;
/* # times router went dead<->alive. Protected with lpni_lock */
int lpni_alive_count;
/* # refs from lnet_route_t::lr_gateway */
int lpni_rtr_refcount;
/* routes on this peer */
struct list_head lpni_routes;
/* router checker state */
struct lnet_rc_data *lpni_rcd |
These fields will need to be transitioned to the peer, and all areas of the code which use them will need to be modified.
Router Ping
Gateways are pinged on a configured interval. If the Gateway is dead, then there is another configuration parameter which governs the frequency of the ping to determine if gateway is back up.
The ping requires somewhat of an extensive infrastructure, including MD/EQ, an event handler and router state management. Much of that can be consolidated with the Discovery code. The Discovery code currently implements all the infrastructure required to manage sending pings and receiving responses. The intent of this proposal is to use this existing infrastructure in place of the router pinger.
The monitor thread calls a function to check if the gateways should be pinged.
The function traverses the list of gateways and sends out a ping if it is required.
Code exists to handle receiving a reply for the ping. When a REPLY is received a function is called to analyze the NIs in the REPLY. This analysis revolves around checking the status of each of the peer interfaces. If the asymmetric router failure is set then the gateway is marked down.
There are a couple of significant improvements/simplifications that can be done in this area:
- Use the discovery mechanism instead of keeping the ping handling code.
- This will reduce the complexity of the router code significantly. All the lnet_rc_data, mdh, event handling will simply go away.
- When a response is received to the ping, the discovery code can simply check if the peer is a router and if so call a routing function to further handle the response.
- This code will need to ensure that this gateway is viable for all the routes which use it.
Router Aliveness and Health
Currently, there is some tricky code to determine the aliveness of a peer. The intent of the code seems to be divided into two categories: Router and Gateway
A router is a node which has routing feature enabled
A gateway is a peer_ni which references a router
Aliveness on a Router
- If a peer NI is dead do not send messages to it
- If a peer NI is dead query it every 1 second to see if it's back up when there is traffic.
- If messages are received on a peer NI set it's aliveness to up
- If a local NI does not receive a message for a configured period of time, then bring down the status of the local NI. That will be discovered when the router is pinged.
Aliveness for a gateway
- Set the gateway peer NI to down if there is a failure to send a message
- The gateway peer NI is pinged every configured period of time.
- Set the gateway peer_ni to down if the routing is not possible through it
- Mark the gateway peer NI as up when it receives a message
Most of these requirements can be consolidated with the Health feature. Here is the proposed solution:
- Turning on sensitivity to > 0 will track the health of the peer NIs
- When sending messages the healthiest peer NI is selected. This reduces the need to drop messages before they are passed to the LND.
- The current code has an UP/DOWN behavior. There is no granularity. Is that a requirement?
- Unhealthy local and peer NIs are placed on their respective queues for recovery. This takes the place of querying peer NIs in the case of Router. Extra functionality can be added to remove the peer-NI from the recovery queue if it has not been used for a peer_timeout length of time
- There will be no need to ping a gateway peer NI separately to determine if it's back up. This will be done by the health code.
- When selecting a gateway peer ni the health of the interfaces will be considered. If the intent is to not use a gateway peer_ni if it's less than fully healthy a configuration parameter can be added to control that.
- When messages are received or sent successfully on any peer_ni it's health value of the NI is incremented, making it more likely to be used.
- If a router does not receive a message for a configured period of time on a local NI, then bring down the status of the local NI. That will be discovered when the router is pinged.
- Instead of marking a gateway as up or down, mark a route as up or down. You can have multiple routes through the same gateway. Depending on which interfaces are up on the gateway a subset of these routes could function through the gateway.
- Allow multiple routes to the same remote network over multiple gateways.
Using this proposal the router and gateway requirements will continue to be achieved, while at the same time, getting rid of lots of code which is currently used to keep track of the aliveness of the peer NIs.