[netcf-devel] [PATCH 1/2] Don't attempt SIOCGIFADDR/NETMASK on downed interfaces.
David Lutterkort
lutter at redhat.com
Wed Oct 7 18:25:42 UTC 2009
On Wed, 2009-10-07 at 09:50 -0400, Laine Stump wrote:
> Both of these ioctls return an error if the interface is down.
Looks good. There were a few minor nits that I fixed up before
committing:
> ---
> src/dutil.c | 20 ++++++++++++++++++--
> 1 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/src/dutil.c b/src/dutil.c
> index a7dbbcf..6b9d279 100644
> --- a/src/dutil.c
> +++ b/src/dutil.c
> @@ -444,14 +444,23 @@ int if_is_active(struct netcf *ncf, const char *intf) {
> return ((ifr.ifr_flags & IFF_UP) == IFF_UP);
> }
>
> +#include <errno.h>
> +
includes should only be at the very top of the file. Moving this include
there causes an error since dutil.c still contained a ERR_COND_BAIL(r <
0, ncf, ENOMEM) - that should be replaced by ERR_NOMEM(r < 0, ncf)
anywhere you see it. The conflict with errno.h is the reason why I
introduced ERR_NOMEM.
> unsigned int if_ipv4_address(struct netcf *ncf, const char *intf) {
> struct ifreq ifr;
>
> + if (!if_is_active(ncf, intf)) {
> + /* SIOCGIFADDR fails on a device that is down */
> + return 0;
> + }
Indentation of the '}' is off.
> @@ -461,11 +470,18 @@ unsigned int if_ipv4_address(struct netcf *ncf, const char *intf) {
> unsigned int if_ipv4_netmask(struct netcf *ncf, const char *intf) {
> struct ifreq ifr;
>
> + if (!if_is_active(ncf, intf)) {
> + /* SIOCGIFNETMASK fails on a device that is down */
> + return 0;
> + }
Indentation of the '}' is off.
David
More information about the netcf-devel
mailing list