- lnet_ping_info_t *info = rcd->rcd_pinginfo;
- struct lnet_peer *gw = rcd->rcd_gateway;
- lnet_route_t *rtr;
-
- if (!gw->lp_alive)
- return;
-
- if (info->pi_magic == __swab32(LNET_PROTO_PING_MAGIC))
- lnet_swap_pinginfo(info);
-
- /* NB always racing with network! */
- if (info->pi_magic != LNET_PROTO_PING_MAGIC) {
- CDEBUG(D_NET, "%s: Unexpected magic %08x\n",
- libcfs_nid2str(gw->lp_nid), info->pi_magic);
- gw->lp_ping_version = LNET_PROTO_PING_UNKNOWN;
- return;
- }
-
- gw->lp_ping_version = info->pi_version;
- if (gw->lp_ping_version == LNET_PROTO_PING_VERSION_1)
- return; /* v1 doesn't carry NI status info */
-
- if (gw->lp_ping_version != LNET_PROTO_PING_VERSION) {
- CDEBUG(D_NET, "%s: Unexpected version 0x%x\n",
- libcfs_nid2str(gw->lp_nid), gw->lp_ping_version);
- gw->lp_ping_version = LNET_PROTO_PING_UNKNOWN;
- return;
- }
-
- cfs_list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) {
- int ptl_status = LNET_NI_STATUS_INVALID;
- int down = 0;
- int up = 0;
- int i;
-
- for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) {
- lnet_ni_status_t *stat = &info->pi_ni[i];
- lnet_nid_t nid = stat->ns_nid;
-
- if (nid == LNET_NID_ANY) {
- CDEBUG(D_NET, "%s: unexpected LNET_NID_ANY\n",
- libcfs_nid2str(gw->lp_nid));
- gw->lp_ping_version = LNET_PROTO_PING_UNKNOWN;
- return;
- }
-
- if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
- continue;
-
- if (stat->ns_status == LNET_NI_STATUS_DOWN) {
- if (LNET_NETTYP(LNET_NIDNET(nid)) != PTLLND)
- down++;
- else if (ptl_status != LNET_NI_STATUS_UP)
- ptl_status = LNET_NI_STATUS_DOWN;
- continue;
- }
-
- if (stat->ns_status == LNET_NI_STATUS_UP) {
- if (LNET_NIDNET(nid) == rtr->lr_net) {
- up = 1;
- break;
- }
- /* ptl NIs are considered down only when
- * they're all down */
- if (LNET_NETTYP(LNET_NIDNET(nid)) == PTLLND)
- ptl_status = LNET_NI_STATUS_UP;
- continue;
- }
-
- CDEBUG(D_NET, "%s: Unexpected status 0x%x\n",
- libcfs_nid2str(gw->lp_nid), stat->ns_status);
- gw->lp_ping_version = LNET_PROTO_PING_UNKNOWN;
- return;
- }
-
- if (up) { /* ignore downed NIs if NI for dest network is up */
- rtr->lr_downis = 0;
- continue;
- }
- rtr->lr_downis = down + (ptl_status == LNET_NI_STATUS_DOWN);
- }