On 22 April 2013 09:20, YAMAMOTO Takashi <y...@mwd.biglobe.ne.jp> wrote:
>
> Signed-off-by: YAMAMOTO Takashi <y...@mwd.biglobe.ne.jp>
> ---
>  lib/netdev-bsd.c | 47 +++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 43 insertions(+), 4 deletions(-)
>
...
> +#elif defined(__NetBSD__)
> +    struct netdev_dev_bsd *netdev_dev =
> +        netdev_dev_bsd_cast(netdev_get_dev(netdev_));
> +    struct ifdatareq ifdr;
> +    struct if_data *ifd;
> +    int saved_errno;
> +    int ret;
> +
> +    memset(&ifdr, 0, sizeof(ifdr));
> +    strncpy(ifdr.ifdr_name, netdev_dev->kernel_name, sizeof(ifdr.ifdr_name));
> +    ret = ioctl(af_link_sock, SIOCGIFDATA, &ifdr);
> +    saved_errno = errno;
> +    if (ret == -1) {
> +        return saved_errno;
> +    }
> +    ifd = &ifdr.ifdr_data;

I'd like to propose that we factor out the common code to update each
stats member, in order to eliminate the almost-but-not-quite identical
code.  For the FreeBSD case struct if_data *ifd can just be set to
&ifmd.ifmd_data. (As an aside, it looks like I should consider adding
SIOCGIFDATA to FreeBSD -- OpenBSD, NetBSD, and DragonFly all have it.)

> +    /*
> +     * note: UINT64_MAX means unsupported
> +     */

Is this checked anywhere (e.g., to avoid displaying unsupported
stats)?  Or will it result in the display of bogus values?

> +    stats->multicast = ifd->ifi_imcasts;

Does Linux count in & out multicast frames in the same counter?
Perhaps this should be imcasts + omcasts (and if so, on FreeBSD too).
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to