[ovs-dev] [PATCH] netdev-linux: Zero feature flags on error.
Justin Pettit
jpettit at nicira.com
Thu Nov 19 08:53:03 UTC 2009
Looks good to me.
--Justin
On Nov 18, 2009, at 7:13 PM, Jesse Gross wrote:
> We claimed that if we got an error when retrieving the features
> for an interface we would zero out all the flags. We weren't
> doing this, which lead to random data for pseudo-devices.
>
> CC: Paul Ingram <paul at nicira.com>
> ---
> lib/netdev-linux.c | 12 +++++++-----
> 1 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
> index 7324703..e1328a4 100644
> --- a/lib/netdev-linux.c
> +++ b/lib/netdev-linux.c
> @@ -730,6 +730,12 @@ netdev_linux_get_features(struct netdev *netdev,
> struct ethtool_cmd ecmd;
> int error;
>
> + /* Zero out features ahead of time in case we have an error. */
> + *supported = 0;
> + *advertised = 0;
> + *current = 0;
> + *peer = 0;
> +
> memset(&ecmd, 0, sizeof ecmd);
> error = netdev_linux_do_ethtool(netdev, &ecmd,
> ETHTOOL_GSET, "ETHTOOL_GSET");
> @@ -738,7 +744,6 @@ netdev_linux_get_features(struct netdev *netdev,
> }
>
> /* Supported features. */
> - *supported = 0;
> if (ecmd.supported & SUPPORTED_10baseT_Half) {
> *supported |= OFPPF_10MB_HD;
> }
> @@ -777,7 +782,6 @@ netdev_linux_get_features(struct netdev *netdev,
> }
>
> /* Advertised features. */
> - *advertised = 0;
> if (ecmd.advertising & ADVERTISED_10baseT_Half) {
> *advertised |= OFPPF_10MB_HD;
> }
> @@ -824,8 +828,6 @@ netdev_linux_get_features(struct netdev *netdev,
> *current = ecmd.duplex ? OFPPF_1GB_FD : OFPPF_1GB_HD;
> } else if (ecmd.speed == SPEED_10000) {
> *current = OFPPF_10GB_FD;
> - } else {
> - *current = 0;
> }
>
> if (ecmd.port == PORT_TP) {
> @@ -839,7 +841,7 @@ netdev_linux_get_features(struct netdev *netdev,
> }
>
> /* Peer advertisements. */
> - *peer = 0; /* XXX */
> + /* XXX */
>
> return 0;
> }
> --
> 1.6.0.4
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
More information about the dev
mailing list