# radix_mpath -- Dead Gateway Detection



## Elusive (Dec 6, 2019)

We have a server that performs ECMP routing across multiple gateways. It appears as if FreeBSD does not perform dead gateway detection when determining which gateway to utilize:

src/freebsd-d/sys/net/radix_mpath.c

```
200 void
    201 rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum) . 
.
.
    227         n = rn_mpath_count(rn0);
    228 
    229         /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */
    230         hash += hashjitter;
    231         hash %= n;
    232         for (weight = abs((int32_t)hash), rt = ro->ro_rt;
    233              weight >= rt->rt_weight && rn;
    234              weight -= rt->rt_weight) {
    235
    236                 /* stay within the multipath routes */
    237                 if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask)
    238                         break;
    239                 rn = rn->rn_dupedkey;
    240                 rt = (struct rtentry *)rn;
    241         }
```
Looking at the code you can see there is no checking if the gateway is up when picking which gateway to send the packet to.

Does anyone know of any mechanism to enforce dead gateway detection in FreeBSD?

Thank you.


----------

