Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 460268

Summary: sys-apps/openrc: convert hex netmasks to decimal for freebsd
Product: Gentoo Hosted Projects Reporter: Dmitri Bogomolov <4glitch>
Component: OpenRCAssignee: OpenRC Team <openrc>
Status: RESOLVED FIXED    
Severity: enhancement CC: bsd+disabled
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: FreeBSD   
Whiteboard: openrc:oldnet
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 439098    
Attachments: sample patch for openrc-0.11.8

Description Dmitri Bogomolov 2013-03-04 13:35:06 UTC
At boot time, I always see this messages:

 *    Running dhcpcd ...
dhcpcd[262]: version 5.5.6 starting
dhcpcd[262]: Kernel is not configured to accept IPv6 RAs
dhcpcd[262]: em0: broadcasting for a lease
dhcpcd[262]: em0: offered 192.168.122.136 from 192.168.122.1
dhcpcd[262]: em0: acknowledged 192.168.122.136 from 192.168.122.1
dhcpcd[262]: em0: checking for 192.168.122.136
dhcpcd[262]: em0: leased 192.168.122.136 for 3600 seconds
dhcpcd[262]: forked to background, child pid 298                          [ ok ]
[: 0xff: bad number
[: 0xff: bad number
[: 0xff: bad number
[: 0xff: bad number
 *    received address 192.168.122.136/

Network connection works well. But here is definitely a portability issue. Please tell me where I can find more information.

I am unsure, maybe I should write to Roy Marples trac?

Reproducible: Always
Comment 1 Yuta SATOH 2013-03-05 10:55:05 UTC
(In reply to comment #0)
> [: 0xff: bad number
> [: 0xff: bad number
> [: 0xff: bad number
> [: 0xff: bad number
>  *    received address 192.168.122.136/
> 
> Network connection works well. But here is definitely a portability issue.
> Please tell me where I can find more information.
> 
> I am unsure, maybe I should write to Roy Marples trac?

It's openrc script bug.

Netmask must be decimal number.
However, FreeBSD returns hexadecimal number.

Fails to numerical comparison in conditional branching, you have found a message is displayed.

I'll attach a sample patch.


NOTE,
Please don't forget to etc-update !


FYI, ifconfig results

on Linux)
netmask 255.255.255.0

on FreeBSD)
netmask 0xffffff00
Comment 2 Yuta SATOH 2013-03-05 10:57:10 UTC
Created attachment 341008 [details, diff]
sample patch for openrc-0.11.8
Comment 3 William Hubbs gentoo-dev 2013-03-07 21:57:35 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > [: 0xff: bad number
> > [: 0xff: bad number
> > [: 0xff: bad number
> > [: 0xff: bad number
> >  *    received address 192.168.122.136/
> > 
> > Network connection works well. But here is definitely a portability issue.
> > Please tell me where I can find more information.
> > 
> > I am unsure, maybe I should write to Roy Marples trac?
> 
> It's openrc script bug.
> 
> Netmask must be decimal number.
> However, FreeBSD returns hexadecimal number.

Where is the hex number coming from? I can apply the patch to OpenRC, but I would like to know where the hex number is from; that might need to be fixed to give us the expected return value.
Comment 4 Naohiro Aota gentoo-dev 2013-03-08 03:48:42 UTC
(In reply to comment #3)
> Where is the hex number coming from? I can apply the patch to OpenRC, but I
> would like to know where the hex number is from; that might need to be fixed
> to give us the expected return value.

The output of "ifconfig em0" is this:

em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
        ether 52:54:00:fb:f7:a7
        inet6 fe80::5054:ff:fefb:f7a7%em0 prefixlen 64 scopeid 0x2 
        inet 192.168.0.6 netmask 0xffffff00 broadcast 192.168.0.255
<snip>

and from

/lib/rc/net/ifconfig.sh:

_get_inet_address()
{
        local inet= address= n= netmask= rest=
        LC_ALL=C ifconfig "${IFACE}" | while read inet address n netmask rest; do
                if [ "${inet}" = "inet" ]; then
                        echo "${address}/$(_netmask2cidr "${netmask}")"
                        return 0
...

It calls "_netmask2cidr 0xffffff00"

/etc/init.d/net.lo's _netmask2cidr() convert "0xffffff00" to "0xff.0xff.0xff.0x00" and passed to the patch lines.
Comment 5 William Hubbs gentoo-dev 2013-03-08 21:37:08 UTC
This is applied in commit f1ae896 and will be part of openrc-0.12.
Thanks for the report.