NetBSD Problem Report #45675

From river@RT.UK.EU.ORG  Fri Dec  2 00:29:42 2011
Return-Path: <river@RT.UK.EU.ORG>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 4517D63D8EB
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  2 Dec 2011 00:29:42 +0000 (UTC)
Message-Id: <20111202002938.EA05340FBF@TAMARA.RT.UK.EU.ORG>
Date: Fri,  2 Dec 2011 00:29:38 +0000 (GMT)
From: river@rt.uk.eu.org
Reply-To: river@rt.uk.eu.org
To: gnats-bugs@gnats.NetBSD.org
Subject: 'ifconfig intf netmask 0xnnnnnnnn' silently fails
X-Send-Pr-Version: 3.95

>Number:         45675
>Category:       kern
>Synopsis:       'ifconfig intf netmask 0xnnnnnnnn' silently fails
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 02 00:30:01 +0000 2011
>Last-Modified:  Tue Jul 07 14:30:00 +0000 2015
>Originator:     River Tarnell
>Release:        NetBSD 5.1.0_PATCH
>Organization:
RT.UK.EU.ORG
>Environment:
System: NetBSD tamara.rt.uk.eu.org 5.1.0_PATCH NetBSD 5.1.0_PATCH (TAMARA) #2: Thu Aug 4 18:30:08 UTC 2011 root@tamara.tcx.org.uk:/usr/src/sys/arch/amd64/compile/TAMARA amd64
Architecture: x86_64
Machine: amd64
>Description:
Setting netmask on an interface with ifconfig fails if no address is specified:

vpn# ifconfig xennet0 inet
xennet0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
        enabled=0
        address: 00:16:3e:00:00:84
        inet 46.17.56.132 netmask 0xfffffff8 broadcast 46.17.56.135
vpn# ifconfig xennet0 inet netmask 0xfffffff0
vpn# ifconfig xennet0 inet                   
xennet0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
        enabled=0
        address: 00:16:3e:00:00:84
        inet 46.17.56.132 netmask 0xfffffff8 broadcast 46.17.56.135

If an address is specified, the change works:

vpn# ifconfig xennet0 inet 46.17.56.132 netmask 0xfffffff0
vpn# ifconfig xennet0 inet                                
xennet0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
        enabled=0
        address: 00:16:3e:00:00:84
        inet 46.17.56.132 netmask 0xfffffff0 broadcast 46.17.56.143

If this is not intended to work, then ifconfig should emit an error message 
rather than failing silently.  However, a better fix would be for the command 
to work.
>How-To-Repeat:
See description.
>Fix:
N/A

>Audit-Trail:
From: Miwa Susumu <miwarin@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/45675
Date: Tue, 7 Jul 2015 23:26:21 +0900

 I just added the message.

 By the way, it will be an error in FreeBSD "Invalid argument"

 % diff -u sbin/ifconfig/af_inetany.c.orig sbin/ifconfig/af_inetany.c
 --- sbin/ifconfig/af_inetany.c.orig     2015-07-07 22:58:36.000000000 +0900
 +++ sbin/ifconfig/af_inetany.c  2015-07-07 23:08:10.000000000 +0900
 @@ -89,8 +89,10 @@
         if ((d = (prop_data_t)prop_dictionary_get(env, "address")) != NULL)
                 addr = prop_data_data_nocopy(d);
         else if (!prop_dictionary_get_bool(env, "alias", &alias) || alias ||
 -           param->gifaddr.cmd == 0)
 +           param->gifaddr.cmd == 0) {
 +               err(EXIT_FAILURE, "Please set address");
                 return;
 +       }
         else if (prog_ioctl(s, param->gifaddr.cmd, param->dgreq.buf) == -1)
                 err(EXIT_FAILURE, "%s", param->gifaddr.desc);
         else if (prog_ioctl(s, param->difaddr.cmd, param->dgreq.buf) == -1)


 If we try to seriously deal.
 'addr' is a fixed value(const). therefore once we set value to 'env',
 and acquires its value.
 following procedure.

   1. get IF address.
   2. create working prop_data_t .
   3. add prop_data_t to dictionary 'env' (I do not know Is it possible.).
   4. get prop_data_t from 'env' (This is because, env because it is a
 fixed value)
   5. set prop_data_t to 'addr'

 -- 
 miwarin

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.