diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2013-03-16 08:30:57 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2013-03-16 08:30:57 +0400 |
commit | 01a5e3ac3436460aeee2f12654e1e86a041f0a39 (patch) | |
tree | 88fd0ebb862b3860dcaa9cd7df363de57dadeb60 /accel-pppd/session.c | |
parent | d38ee4ecee74f47a7fdbff7a5d77b7c6371776d6 (diff) | |
download | accel-ppp-01a5e3ac3436460aeee2f12654e1e86a041f0a39.tar.gz accel-ppp-01a5e3ac3436460aeee2f12654e1e86a041f0a39.zip |
ipoe: fixed shared=1 mode
Diffstat (limited to 'accel-pppd/session.c')
-rw-r--r-- | accel-pppd/session.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/accel-pppd/session.c b/accel-pppd/session.c index 666544d..22c2744 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -57,15 +57,28 @@ void __export ap_session_init(struct ap_session *ses) ses->ifindex = -1; } +void __export ap_session_set_ifindex(struct ap_session *ses) +{ + struct rtnl_link_stats stats; + + if (iplink_get_stats(ses->ifindex, &stats)) + log_ppp_warn("failed to get interface statistics\n"); + else { + ses->acct_rx_packets_i = stats.rx_packets; + ses->acct_tx_packets_i = stats.tx_packets; + ses->acct_rx_bytes_i = stats.rx_bytes; + ses->acct_tx_bytes_i = stats.tx_bytes; + } +} + int __export ap_session_starting(struct ap_session *ses) { struct ifreq ifr; - struct rtnl_link_stats stats; if (ap_shutdown) return -1; - if (ses->ifindex == -1) { + if (ses->ifindex == -1 && ses->ifname[0]) { memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, ses->ifname); @@ -75,15 +88,9 @@ int __export ap_session_starting(struct ap_session *ses) } ses->ifindex = ifr.ifr_ifindex; } - - if (iplink_get_stats(ses->ifindex, &stats)) - log_ppp_warn("failed to get interface statistics\n"); - else { - ses->acct_rx_packets_i = stats.rx_packets; - ses->acct_tx_packets_i = stats.tx_packets; - ses->acct_rx_bytes_i = stats.rx_bytes; - ses->acct_tx_bytes_i = stats.tx_bytes; - } + + if (ses->ifindex != -1) + ap_session_set_ifindex(ses); if (ses->state != AP_STATE_RESTORE) { ses->start_time = time(NULL); |