ipmr, ip6mr: add RTNH_F_UNRESOLVED flag to unresolved cache entries
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Tue, 3 Jan 2017 11:13:39 +0000 (12:13 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Jan 2017 15:04:31 +0000 (10:04 -0500)
While working with ipmr, we noticed that it is impossible to determine
if an entry is actually unresolved or its IIF interface has disappeared
(e.g. virtual interface got deleted). These entries look almost
identical to user-space when dumping or receiving notifications. So in
order to recognize them add a new RTNH_F_UNRESOLVED flag which is set when
sending an unresolved cache entry to user-space.

Suggested-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/rtnetlink.h
net/ipv4/ipmr.c
net/ipv6/ip6mr.c

index e14377f2ec273a183ae3b2e3da887ef2f893f7d1..8c93ad1ef9abee1b539459d237036b18dab536e2 100644 (file)
@@ -350,6 +350,7 @@ struct rtnexthop {
 #define RTNH_F_ONLINK          4       /* Gateway is forced on link    */
 #define RTNH_F_OFFLOAD         8       /* offloaded route */
 #define RTNH_F_LINKDOWN                16      /* carrier-down on nexthop */
+#define RTNH_F_UNRESOLVED      32      /* The entry is unresolved (ipmr) */
 
 #define RTNH_COMPARE_MASK      (RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD)
 
index efc1e76d49770994f065c1bbad1ef8f93fa99bc7..b35dda57586bc59668172eac965caf9cd202b15a 100644 (file)
@@ -2091,8 +2091,10 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
        int ct;
 
        /* If cache is unresolved, don't try to parse IIF and OIF */
-       if (c->mfc_parent >= MAXVIFS)
+       if (c->mfc_parent >= MAXVIFS) {
+               rtm->rtm_flags |= RTNH_F_UNRESOLVED;
                return -ENOENT;
+       }
 
        if (VIF_EXISTS(mrt, c->mfc_parent) &&
            nla_put_u32(skb, RTA_IIF, mrt->vif_table[c->mfc_parent].dev->ifindex) < 0)
index 604d8953c775966872969a9a5d828d1d9d99067a..e275077e8af2604efb91bba5c0a9cd846277a28a 100644 (file)
@@ -2243,8 +2243,10 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
        int ct;
 
        /* If cache is unresolved, don't try to parse IIF and OIF */
-       if (c->mf6c_parent >= MAXMIFS)
+       if (c->mf6c_parent >= MAXMIFS) {
+               rtm->rtm_flags |= RTNH_F_UNRESOLVED;
                return -ENOENT;
+       }
 
        if (MIF_EXISTS(mrt, c->mf6c_parent) &&
            nla_put_u32(skb, RTA_IIF, mrt->vif6_table[c->mf6c_parent].dev->ifindex) < 0)