Repository navigation
ifconfig, ip, AROSTCP: show IPv4 aliases, with their own netmask and broadcast - #2284
Merged
Kalamatee merged 3 commits intoNov 15, 2026
Merged
Conversation
SIOCGIFNETMASK, SIOCGIFBRDADDR and SIOCGIFDSTADDR answered for an interface's first IPv4 address whatever ifr_addr held, so a program could not learn an alias's mask or broadcast address. They now answer for the address in ifr_addr when the interface has it, as NetBSD's in_control() does and as IPv6's SIOCGIFNETMASK_IN6 already does here. Anything else in ifr_addr - nothing, or what an earlier request left there: a program asking SIOCGIFADDR, SIOCGIFNETMASK and SIOCGIFBRDADDR with one ifreq has the mask in it by the third (ifconfig, arda_netdiag), or another interface's address - still names the first address, without the EADDRNOTAVAIL NetBSD gives: no caller in the tree changes. SIOCGIFADDR is the first address, as before. cunit-net-ifalias: an alias named (10.77.0.1/16 on eth0) gives its own mask and broadcast (master: the first address's, 2 asserts fail); the first address named, or nothing, the first's; a mask or 127.0.0.1 in ifr_addr, the first's; SIOCGIFADDR the first address. The whole cunit suite, 69 of 69. bsdsocket.library 5.48 (kernel v0.87).
ifconfig and ip addr printed one IPv4 address per interface, the one SIOCGIFADDR gives - the first - and used SIOCGIFCONF only for the interfaces' names: an alias, added with "ifconfig eth0 A netmask M alias" (SIOCAIFADDR), was on the interface and in the list but never shown, so it looked as if it had not been added. Both now print the first address, then the interface's other AF_INET entries of the list, each with its own netmask, broadcast (or destination) address and conflict detection state: SIOCGIFNETMASK, SIOCGIFBRDADDR, SIOCGIFDSTADDR and SIOCGIFAFLAG_IN are asked for that address, which the stack answers for the address named in ifr_addr (AROSTCP, the commit before; a stack that does not gives the first address's mask and broadcast for every alias). ifconfig with an interface named shows them too; its interface list is one function, getifconf(), which printall() uses as well.
ip addr and ip route showed every IPv4 prefix as /0 (192.168.166.2/0, 192.168.166.0/0 via ...): the stack gives a netmask, from SIOCGIFNETMASK and in routing messages, with no family, laid out as a sockaddr of the destination's family and cut after its last non-zero byte - BSD's convention - and mask2prefix() read such a mask from just after its family byte, where a sockaddr_in has sin_port, zero. It now takes the family the mask is for, and reads from sin_addr (IPv4) or sin6_addr (IPv6), what lies past sa_len being zero; ip addr passes AF_INET or AF_INET6, ip route the destination's family.
JJDSNT
force-pushed
the
review/ipv4-aliases
branch
from
November 14, 2026 23:36
9573fde to
0d575e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The follow-up noted on #2277: IPv4 aliases are shown, each with its own netmask and broadcast address. Three commits:
SIOCGIFNETMASK,SIOCGIFBRDADDRandSIOCGIFDSTADDRanswered for an interface's first IPv4 address whateverifr_addrheld. They now answer for the address inifr_addrwhen the interface has it, as NetBSD'sin_control()does and as IPv6'sSIOCGIFNETMASK_IN6already does here. Anything else there - nothing, or what an earlier request left (a program askingSIOCGIFADDR,SIOCGIFNETMASKandSIOCGIFBRDADDRwith oneifreqhas the mask in it by the third: ifconfig, arda_netdiag), or another interface's address - still names the first address, without NetBSD'sEADDRNOTAVAIL: no caller in the tree changes.cunit-net-ifalias(master: 2 asserts fail). bsdsocket.library 5.48 (kernel v0.87).SIOCGIFADDRgives and usedSIOCGIFCONFonly for the interfaces' names. They now print the first address, then the interface's otherAF_INETentries, each with its own mask, broadcast (or destination) and conflict detection state, asked for that address.ifconfigwith an interface named shows them too; its interface list is one function,getifconf(), whichprintall()uses as well.ip addrandip routeshowed every IPv4 prefix as/0:mask2prefix()read a mask without a family from just after its family byte, where asockaddr_inhassin_port. It now takes the family the mask is for (BSD's convention: laid out as the destination's sockaddr), and reads fromsin_addrorsin6_addr.Tested on hosted (eth0, eth1) and on AROS m68k on an emulated A3000:
ifconfig -a,ip addrwith 300/32aliases on eth0 (hosted)/32/16alias next to eth0's/2410.77.0.1 netmask 0xffff0000 broadcast 10.77.255.255,10.77.0.1/16 brd 10.77.255.255ip addr,ip routeprefixes192.168.166.2/0,192.168.166.0/0/24, routes/24and/16; IPv6 unchanged/32aliases and a/16The whole cunit suite passes, with cunit-net-ifalias.