lib/route: add rx_nohandler link stats field

A new counter rx_nohandler was added to the link stats in kernel commit
6e7333d315a7 ("net: add rx_nohandler stat counter"). Wire it up in the
libnl link stats as well.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
This commit is contained in:
Tobias Klauser 2016-11-29 08:50:31 +01:00
parent 4618b88dca
commit 5040fc8a49
2 changed files with 11 additions and 3 deletions

View File

@ -98,6 +98,7 @@ typedef enum {
RTNL_LINK_IP6_ECT1PKTS, /*!< IPv6 SNMP InECT1Pkts */
RTNL_LINK_IP6_ECT0PKTS, /*!< IPv6 SNMP InECT0Pkts */
RTNL_LINK_IP6_CEPKTS, /*!< IPv6 SNMP InCEPkts */
RTNL_LINK_RX_NOHANDLER, /*!< Received packets dropped on inactive device */
__RTNL_LINK_STATS_MAX,
} rtnl_link_stat_id_t;

View File

@ -400,6 +400,11 @@ int rtnl_link_info_parse(struct rtnl_link *link, struct nlattr **tb)
/* beware: @st might not be the full struct, only fields up to
* tx_compressed are present. See _nl_offset_plus_sizeof() above. */
if (nla_len(tb[IFLA_STATS]) > _nl_offset_plus_sizeof (struct rtnl_link_stats, tx_compressed))
link->l_stats[RTNL_LINK_RX_NOHANDLER] = st->rx_nohandler;
else
link->l_stats[RTNL_LINK_RX_NOHANDLER] = 0;
link->ce_mask |= LINK_ATTR_STATS;
}
@ -411,10 +416,9 @@ int rtnl_link_info_parse(struct rtnl_link *link, struct nlattr **tb)
* Therefore, copy the data to the stack and access it from
* there, where it will be aligned to 8.
*/
struct rtnl_link_stats64 st;
struct rtnl_link_stats64 st = { 0 };
nla_memcpy(&st, tb[IFLA_STATS64],
sizeof(struct rtnl_link_stats64));
nla_memcpy(&st, tb[IFLA_STATS64], nla_len(tb[IFLA_STATS64]));
link->l_stats[RTNL_LINK_RX_PACKETS] = st.rx_packets;
link->l_stats[RTNL_LINK_TX_PACKETS] = st.tx_packets;
@ -446,6 +450,8 @@ int rtnl_link_info_parse(struct rtnl_link *link, struct nlattr **tb)
/* beware: @st might not be the full struct, only fields up to
* tx_compressed are present. See _nl_offset_plus_sizeof() above. */
link->l_stats[RTNL_LINK_RX_NOHANDLER] = st.rx_nohandler;
link->ce_mask |= LINK_ATTR_STATS;
}
@ -2851,6 +2857,7 @@ static const struct trans_tbl link_stats[] = {
__ADD(RTNL_LINK_IP6_ECT1PKTS, Ip6_InECT1Pkts),
__ADD(RTNL_LINK_IP6_ECT0PKTS, Ip6_InECT0Pkts),
__ADD(RTNL_LINK_IP6_CEPKTS, Ip6_InCEPkts),
__ADD(RTNL_LINK_RX_NOHANDLER, rx_nohandler),
};
char *rtnl_link_stat2str(int st, char *buf, size_t len)