Commit adfa85e4 authored by Nicolas Dichtel's avatar Nicolas Dichtel Committed by David S. Miller

ipmr/ip6mr: advertise mfc stats via rtnetlink

These statistics can be checked only via /proc/net/ip_mr_cache or
SIOCGETSGCNT[_IN6] and thus only for the table RT_TABLE_DEFAULT.
Advertising them via rtnetlink allows to get statistics for all cache entries,
whatever the table is.
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 70b386a0
...@@ -288,6 +288,7 @@ enum rtattr_type_t { ...@@ -288,6 +288,7 @@ enum rtattr_type_t {
RTA_MP_ALGO, /* no longer used */ RTA_MP_ALGO, /* no longer used */
RTA_TABLE, RTA_TABLE,
RTA_MARK, RTA_MARK,
RTA_MFC_STATS,
__RTA_MAX __RTA_MAX
}; };
...@@ -408,6 +409,12 @@ struct rta_session { ...@@ -408,6 +409,12 @@ struct rta_session {
} u; } u;
}; };
struct rta_mfc_stats {
__u64 mfcs_packets;
__u64 mfcs_bytes;
__u64 mfcs_wrong_if;
};
/**** /****
* General form of address family dependent message. * General form of address family dependent message.
****/ ****/
......
...@@ -2046,6 +2046,7 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, ...@@ -2046,6 +2046,7 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
int ct; int ct;
struct rtnexthop *nhp; struct rtnexthop *nhp;
struct nlattr *mp_attr; struct nlattr *mp_attr;
struct rta_mfc_stats mfcs;
/* If cache is unresolved, don't try to parse IIF and OIF */ /* If cache is unresolved, don't try to parse IIF and OIF */
if (c->mfc_parent >= MAXVIFS) if (c->mfc_parent >= MAXVIFS)
...@@ -2074,6 +2075,12 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, ...@@ -2074,6 +2075,12 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
nla_nest_end(skb, mp_attr); nla_nest_end(skb, mp_attr);
mfcs.mfcs_packets = c->mfc_un.res.pkt;
mfcs.mfcs_bytes = c->mfc_un.res.bytes;
mfcs.mfcs_wrong_if = c->mfc_un.res.wrong_if;
if (nla_put(skb, RTA_MFC_STATS, sizeof(mfcs), &mfcs) < 0)
return -EMSGSIZE;
rtm->rtm_type = RTN_MULTICAST; rtm->rtm_type = RTN_MULTICAST;
return 1; return 1;
} }
......
...@@ -2120,6 +2120,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, ...@@ -2120,6 +2120,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
int ct; int ct;
struct rtnexthop *nhp; struct rtnexthop *nhp;
struct nlattr *mp_attr; struct nlattr *mp_attr;
struct rta_mfc_stats mfcs;
/* If cache is unresolved, don't try to parse IIF and OIF */ /* If cache is unresolved, don't try to parse IIF and OIF */
if (c->mf6c_parent >= MAXMIFS) if (c->mf6c_parent >= MAXMIFS)
...@@ -2149,6 +2150,12 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, ...@@ -2149,6 +2150,12 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
nla_nest_end(skb, mp_attr); nla_nest_end(skb, mp_attr);
mfcs.mfcs_packets = c->mfc_un.res.pkt;
mfcs.mfcs_bytes = c->mfc_un.res.bytes;
mfcs.mfcs_wrong_if = c->mfc_un.res.wrong_if;
if (nla_put(skb, RTA_MFC_STATS, sizeof(mfcs), &mfcs) < 0)
return -EMSGSIZE;
rtm->rtm_type = RTN_MULTICAST; rtm->rtm_type = RTN_MULTICAST;
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment