All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 7ae51e19 authored by Alex Wang's avatar Alex Wang

netdev-linux: Cache the result of previous reading of in4 address.

This commit makes netdev_linux_set_in4() cache the result of previous
reading of in4 address (successful or not).
Signed-off-by: default avatarAlex Wang <alexw@nicira.com>
Acked-by: default avatarBen Pfaff <blp@nicira.com>
parent 11df5f06
......@@ -458,6 +458,7 @@ struct netdev_linux {
int netdev_policing_error; /* Cached error code from set policing. */
int get_features_error; /* Cached error code from ETHTOOL_GSET. */
int get_ifindex_error; /* Cached error code from SIOCGIFINDEX. */
int in4_error; /* Cached error code from reading in4 addr. */
int in6_error; /* Cached error code from reading in6 addr. */
enum netdev_features current; /* Cached from ETHTOOL_GSET. */
......@@ -2422,12 +2423,11 @@ netdev_linux_get_in4(const struct netdev *netdev_,
if (!error) {
error = netdev_linux_get_ipv4(netdev_, &netdev->netmask,
SIOCGIFNETMASK, "SIOCGIFNETMASK");
if (!error) {
netdev->cache_valid |= VALID_IN4;
}
}
netdev->in4_error = error;
netdev->cache_valid |= VALID_IN4;
} else {
error = 0;
error = netdev->in4_error;
}
if (!error) {
......@@ -2453,7 +2453,6 @@ netdev_linux_set_in4(struct netdev *netdev_, struct in_addr address,
ovs_mutex_lock(&netdev->mutex);
error = do_set_addr(netdev_, SIOCSIFADDR, "SIOCSIFADDR", address);
if (!error) {
netdev->cache_valid |= VALID_IN4;
netdev->address = address;
netdev->netmask = netmask;
if (address.s_addr != INADDR_ANY) {
......@@ -2461,6 +2460,13 @@ netdev_linux_set_in4(struct netdev *netdev_, struct in_addr address,
"SIOCSIFNETMASK", netmask);
}
}
if (!error) {
netdev->cache_valid |= VALID_IN4;
netdev->in4_error = 0;
} else {
netdev->cache_valid &= ~VALID_IN4;
}
ovs_mutex_unlock(&netdev->mutex);
return error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment