Modify

Opened 2 years ago

Last modified 2 years ago

#20987 new defect

Number precision of busybox awk is too low for x86-kvm_guest

Reported by: yousong Owned by: developers
Priority: high Milestone:
Component: base system Version: Trunk
Keywords: Cc:

Description

It looks like the busybox awk is broken for x86-kvm_guest in that it can not even handle 32 bit integers arithmetic properly. It's bad because ipcalc.sh depends on it and we need it to generate configs for dnsmasq.

Here are the related output in kvm_guest.

root@OpenWrt:/# ipcalc.sh 192.168.1.1 24 100 149
IP=0.0.0.1
NETMASK=0.0.0.255
BROADCAST=0.0.0.255
NETWORK=0.0.0.1
PREFIX=24
START=0.0.0.101
END=0.0.0.250
root@OpenWrt:/# echo | awk -e 'END { v=3232235776; print v "," lshift(v,8) }'
3.23224e+09,0

Expected output from an ar71xx target

root@OpenWrt:~# ipcalc.sh 192.168.1.1 24 100 149
IP=192.168.1.1
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
NETWORK=192.168.1.0
PREFIX=24
START=192.168.1.100
END=192.168.1.249
root@OpenWrt:~# echo | awk -e 'END { v=3232235776; print v "," lshift(v,8) }'
3232235776,2818637824

Attachments (0)

Change History (1)

comment:1 Changed 2 years ago by yousong

Not sure what has changed, but kvm-guest is working fine right now with r48503. Thanks.

Something python snippet when debugging this, may be useful should the issue re-surfaces next time.

import struct
import socket
ntoa=lambda n: socket.inet_ntoa(struct.pack('!L', n))

v = 3232235776
v8 = (v<<8)&0xffffffff
v16 = (v<<16)&0xffffffff
v24 = (v<<24)&0xffffffff
v32 = (v<<32)&0xffffffff
print v8, v16, v24, v32
print ntoa(v)
print ntoa(v8)
print ntoa(v16)
print ntoa(v24)
print ntoa(v32)
Last edited 2 years ago by yousong (previous) (diff)

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.