int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, unsigned long when);
 void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive,
                        unsigned long when);
-int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid,
+int lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway_nid,
                   unsigned int priority);
 int lnet_check_routes(void);
 int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
 
        __u32                    lr_net;        /* remote network number */
        int                      lr_seq;        /* sequence for round-robin */
        unsigned int             lr_downis;     /* number of down NIs */
-       unsigned int             lr_hops;       /* how far I am */
+       __u32                    lr_hops;       /* how far I am */
        unsigned int             lr_priority;   /* route priority */
 } lnet_route_t;
 
 
        char *token = str;
        int ntokens = 0;
        int myrc = -1;
-       unsigned int hops;
+       __u32 hops;
        int got_hops = 0;
        unsigned int priority = 0;
 
                }
        }
 
+       /**
+        * if there are no hops set then we want to flag this value as
+        * unset since hops is an optional parameter
+        */
        if (!got_hops)
-               hops = 1;
+               hops = LNET_UNDEFINED_HOPS;
 
        LASSERT(!list_empty(&nets));
        LASSERT(!list_empty(&gateways));
 
 {
        lnet_peer_t *p1 = r1->lr_gateway;
        lnet_peer_t *p2 = r2->lr_gateway;
+       int r1_hops = (r1->lr_hops == LNET_UNDEFINED_HOPS) ? 1 : r1->lr_hops;
+       int r2_hops = (r2->lr_hops == LNET_UNDEFINED_HOPS) ? 1 : r2->lr_hops;
 
        if (r1->lr_priority < r2->lr_priority)
                return 1;
        if (r1->lr_priority > r2->lr_priority)
                return -1;
 
-       if (r1->lr_hops < r2->lr_hops)
+       if (r1_hops < r2_hops)
                return 1;
 
-       if (r1->lr_hops > r2->lr_hops)
+       if (r1_hops > r2_hops)
                return -1;
 
        if (p1->lp_txqnob < p2->lp_txqnob)
                if (rnet->lrn_net == dstnet) {
                        lnet_route_t *route;
                        lnet_route_t *shortest = NULL;
+                       __u32 shortest_hops = LNET_UNDEFINED_HOPS;
+                       __u32 route_hops;
 
                        LASSERT(!list_empty(&rnet->lrn_routes));
 
                        list_for_each_entry(route, &rnet->lrn_routes,
                                            lr_list) {
+                               route_hops = route->lr_hops;
+                               if (route_hops == LNET_UNDEFINED_HOPS)
+                                       route_hops = 1;
                                if (!shortest ||
-                                   route->lr_hops < shortest->lr_hops)
+                                   route_hops < shortest_hops) {
                                        shortest = route;
+                                       shortest_hops = route_hops;
+                               }
                        }
 
                        LASSERT(shortest);
-                       hops = shortest->lr_hops;
+                       hops = shortest_hops;
                        if (srcnidp)
                                *srcnidp = shortest->lr_gateway->lp_ni->ni_nid;
                        if (orderp)
 
 }
 
 int
-lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
+lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway,
               unsigned int priority)
 {
        struct list_head *e;
        int add_route;
        int rc;
 
-       CDEBUG(D_NET, "Add route: net %s hops %u priority %u gw %s\n",
+       CDEBUG(D_NET, "Add route: net %s hops %d priority %u gw %s\n",
               libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway));
 
        if (gateway == LNET_NID_ANY ||
            net == LNET_NIDNET(LNET_NID_ANY) ||
            LNET_NETTYP(net) == LOLND ||
            LNET_NIDNET(gateway) == net ||
-           hops < 1 || hops > 255)
+           (hops != LNET_UNDEFINED_HOPS && (hops < 1 || hops > 255)))
                return -EINVAL;
 
        if (lnet_islocalnet(net))              /* it's a local network */
 
 
                if (route) {
                        __u32 net = rnet->lrn_net;
-                       unsigned int hops = route->lr_hops;
+                       __u32 hops = route->lr_hops;
                        unsigned int priority = route->lr_priority;
                        lnet_nid_t nid = route->lr_gateway->lp_nid;
                        int alive = lnet_is_route_alive(route);