2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-02 15:25:22 +00:00

netdev: Really set output values to 0 on failure in netdev_get_features().

The comment on netdev_get_features() claimed that all of the passed-in
values were set to 0 on failure, but the implementation didn't live up
to the promise.

CC: Paul Ingram <paul@nicira.com>
This commit is contained in:
Ben Pfaff
2009-11-19 11:06:14 -08:00
parent 9af9e2e8cf
commit 7671589afb
2 changed files with 22 additions and 7 deletions

View File

@@ -720,8 +720,7 @@ netdev_linux_get_stats(const struct netdev *netdev_, struct netdev_stats *stats)
/* Stores the features supported by 'netdev' into each of '*current', /* Stores the features supported by 'netdev' into each of '*current',
* '*advertised', '*supported', and '*peer' that are non-null. Each value is a * '*advertised', '*supported', and '*peer' that are non-null. Each value is a
* bitmap of "enum ofp_port_features" bits, in host byte order. Returns 0 if * bitmap of "enum ofp_port_features" bits, in host byte order. Returns 0 if
* successful, otherwise a positive errno value. On failure, all of the * successful, otherwise a positive errno value. */
* passed-in values are set to 0. */
static int static int
netdev_linux_get_features(struct netdev *netdev, netdev_linux_get_features(struct netdev *netdev,
uint32_t *current, uint32_t *advertised, uint32_t *current, uint32_t *advertised,

View File

@@ -377,11 +377,27 @@ netdev_get_features(struct netdev *netdev,
uint32_t *supported, uint32_t *peer) uint32_t *supported, uint32_t *peer)
{ {
uint32_t dummy[4]; uint32_t dummy[4];
return netdev->class->get_features(netdev, int error;
current ? current : &dummy[0],
advertised ? advertised : &dummy[1], if (!current) {
supported ? supported : &dummy[2], current = &dummy[0];
peer ? peer : &dummy[3]); }
if (!advertised) {
advertised = &dummy[1];
}
if (!supported) {
supported = &dummy[2];
}
if (!peer) {
peer = &dummy[3];
}
error = netdev->class->get_features(netdev, current, advertised, supported,
peer);
if (error) {
*current = *advertised = *supported = *peer = 0;
}
return error;
} }
/* Set the features advertised by 'netdev' to 'advertise'. Returns 0 if /* Set the features advertised by 'netdev' to 'advertise'. Returns 0 if