History

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.

Nicolas Dichtel committed 13 years ago

Commit adfa85e1 parent 70b386a3 files · +21 −0Browse files

Unified · Split

3 files
  1. include/uapi/linux/rtnetlink.h +7 −0
  2. net/ipv4/ipmr.c +7 −0
  3. net/ipv6/ip6mr.c +7 −0
include/uapi/linux/rtnetlink.h+7−0
@@ -288,6 +288,7 @@ enum rtattr_type_t { · 287 unmodified lines
288288 RTA_MP_ALGO, /* no longer used */
289289 RTA_TABLE,
290290 RTA_MARK,
291+ RTA_MFC_STATS,
291292 __RTA_MAX
292293 };
293294
@@ -408,6 +409,12 @@ struct rta_session { · 114 unmodified lines
408409 } u;
409410 };
410411
412+struct rta_mfc_stats {
413+ __u64 mfcs_packets;
414+ __u64 mfcs_bytes;
415+ __u64 mfcs_wrong_if;
416+};
417+
411418 /****
412419 * General form of address family dependent message.
413420 ****/
net/ipv4/ipmr.c+7−0
@@ -2046,6 +2046,7 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, · 2045 unmodified lines
20462046 int ct;
20472047 struct rtnexthop *nhp;
20482048 struct nlattr *mp_attr;
2049+ struct rta_mfc_stats mfcs;
20492050
20502051 /* If cache is unresolved, don't try to parse IIF and OIF */
20512052 if (c->mfc_parent >= MAXVIFS)
@@ -2074,6 +2075,12 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, · 22 unmodified lines
20742075
20752076 nla_nest_end(skb, mp_attr);
20762077
2078+ mfcs.mfcs_packets = c->mfc_un.res.pkt;
2079+ mfcs.mfcs_bytes = c->mfc_un.res.bytes;
2080+ mfcs.mfcs_wrong_if = c->mfc_un.res.wrong_if;
2081+ if (nla_put(skb, RTA_MFC_STATS, sizeof(mfcs), &mfcs) < 0)
2082+ return -EMSGSIZE;
2083+
20772084 rtm->rtm_type = RTN_MULTICAST;
20782085 return 1;
20792086 }
net/ipv6/ip6mr.c+7−0
@@ -2120,6 +2120,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, · 2119 unmodified lines
21202120 int ct;
21212121 struct rtnexthop *nhp;
21222122 struct nlattr *mp_attr;
2123+ struct rta_mfc_stats mfcs;
21232124
21242125 /* If cache is unresolved, don't try to parse IIF and OIF */
21252126 if (c->mf6c_parent >= MAXMIFS)
@@ -2149,6 +2150,12 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, · 23 unmodified lines
21492150
21502151 nla_nest_end(skb, mp_attr);
21512152
2153+ mfcs.mfcs_packets = c->mfc_un.res.pkt;
2154+ mfcs.mfcs_bytes = c->mfc_un.res.bytes;
2155+ mfcs.mfcs_wrong_if = c->mfc_un.res.wrong_if;
2156+ if (nla_put(skb, RTA_MFC_STATS, sizeof(mfcs), &mfcs) < 0)
2157+ return -EMSGSIZE;
2158+
21522159 rtm->rtm_type = RTN_MULTICAST;
21532160 return 1;
21542161 }