- /* avoid applying a less specific route */
- xmp = (u_char *)rt_mask(rt->rt_parent);
- mlen = rt_key(rt->rt_parent)->sa_len;
- if (mlen > rt_key(rt0)->sa_len) {
- RT_UNLOCK(rt);
- return (0);
- }
-
- for (i = rnh->rnh_treetop->rn_offset; i < mlen; i++) {
- if ((xmp[i] & ~(xmp[i] ^ xm1[i])) != xmp[i]) {
+ /*
+ * Avoid applying a less specific route; do this only if the parent
+ * route (rt->rt_parent) is a network route, since otherwise its mask
+ * will be NULL if it is a cloning host route.
+ */
+ if ((xmp = (u_char *)rt_mask(rt->rt_parent)) != NULL) {
+ int mlen = rt_mask(rt->rt_parent)->sa_len;
+ if (mlen > rt_mask(rt0)->sa_len) {