[ovs-dev] [PATCH] datapath: Define net_device_ops->ndo_get_stats64() for internal_dev.

Jesse Gross jesse at nicira.com
Thu Nov 3 10:57:18 PDT 2011


On Wed, Nov 2, 2011 at 5:32 PM, Pravin B Shelar <pshelar at nicira.com> wrote:
> Signed-off-by: Pravin Shelar <pshelar at nicira.com>

I got a whitespace error when applying this:
Applying: datapath: Define net_device_ops->ndo_get_stats64() for internal_dev.
/home/jesse/openvswitch/.git/rebase-apply/patch:19: space before tab in indent.
 		 * switch and host OS have opposite perspectives. */	\
warning: 1 line adds whitespace errors.

> diff --git a/datapath/vport-internal_dev.c b/datapath/vport-internal_dev.c
> index a468ac8..fa30161 100644
> --- a/datapath/vport-internal_dev.c
> +++ b/datapath/vport-internal_dev.c
> +static struct rtnl_link_stats64 *internal_dev_get_stats64(struct net_device *netdev,
> +                                       struct rtnl_link_stats64 *stats64)
> +{
> +       struct vport *vport = internal_dev_get_vport(netdev);
> +
> +       if (vport)

I don't think that there's a need for this check since this function
will never be called on a non-internal device.

I think you can write this in a simpler way without macros and less
code duplication by just putting the #if on the function prototype
i.e:

 /* This function is only called by the kernel network layer.*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
static struct rtnl_link_stats64 *internal_dev_get_stats64(struct
net_device *netdev,
                                       struct rtnl_link_stats64 *stats)
#else
 static struct net_device_stats *internal_dev_sys_stats(struct
net_device *netdev)
struct net_device_stats *stats = &internal_dev_priv(netdev)->stats;
#endif
...function...

We should also #if out the stats in struct internal_dev on newer
kernels.  In fact, I think that you can kill it off even before 2.6.36
because you can use dev->stats for storage (although not all the way
back to 2.6.18).



More information about the dev mailing list