Hi,
On Wed, 2013-10-23 at 12:30 +0300, Jukka Rissanen wrote:
> @@ -428,15 +447,20 @@ static void update_stats(struct connman_ipdevice
> *ipdevice,
> struct rtnl_link_stats *stats)
> {
> struct connman_service *service;
> + char *ifname;
>
> if (stats->rx_packets == 0 && stats->tx_packets == 0)
> return;
>
> - connman_info("%s {RX} %u packets %u bytes", ipdevice->ifname,
> + ifname = connman_inet_ifname(ipdevice->index);
> +
> + connman_info("%s {RX} %u packets %u bytes", ifname,
> stats->rx_packets, stats->rx_bytes);
> - connman_info("%s {TX} %u packets %u bytes", ipdevice->ifname,
> + connman_info("%s {TX} %u packets %u bytes", ifname,
> stats->tx_packets, stats->tx_bytes);
>
> + g_free(ifname);
> +
> if (!ipdevice->config_ipv4 && !ipdevice->config_ipv6)
> return;
By changing the function to e.g. update_stats(struct connman_ipdevice
*ipdevice, char *ifname, struct rtnl_link_stats *stats) the extra ifname
allocation and creation can be avoided. In both cases where update_stats
is called, ifname is already being worked on in the same function.
> @@ -1516,7 +1533,7 @@ static void disable_ipv6(struct connman_ipconfig
> *ipconfig)
> if (!ipdevice)
> return;
>
> - set_ipv6_state(ipdevice->ifname, false);
> + set_ipv6_state_by_index(ipdevice->index, false);
> }
>
> static void enable_ipv6(struct connman_ipconfig *ipconfig)
> @@ -1531,10 +1548,10 @@ static void enable_ipv6(struct connman_ipconfig
> *ipconfig)
> return;
>
> if (ipconfig->method == CONNMAN_IPCONFIG_METHOD_AUTO)
> - set_ipv6_privacy(ipdevice->ifname,
> + set_ipv6_privacy_by_index(ipdevice->index,
> ipconfig->ipv6_privacy_config);
>
> - set_ipv6_state(ipdevice->ifname, true);
> + set_ipv6_state_by_index(ipdevice->index, true);
> }
The only cases where the *_by_index functions are used is here. If the
ifname is allocated here instead, the existing set_ipv6_state() and
set_ipv6_privacy() can be used directly.
Cheers,
Patrik
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman