From owner-freebsd-current@FreeBSD.ORG Tue Nov 15 17:10:18 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F9C6106564A for ; Tue, 15 Nov 2011 17:10:18 +0000 (UTC) (envelope-from gr@ubuntu64.secure-side.com) Received: from admin.secure-side.com (admin.secure-side.com [213.251.166.100]) by mx1.freebsd.org (Postfix) with SMTP id 933708FC19 for ; Tue, 15 Nov 2011 17:10:17 +0000 (UTC) Received: (qmail 52672 invoked from network); 15 Nov 2011 17:10:20 -0000 Received: from localhost (HELO ubuntu64.secure-side.com) (@127.0.0.1) by qmail with SMTP; 15 Nov 2011 17:10:20 -0000 Received: from localhost (localhost [127.0.0.1]) by ubuntu64.secure-side.com (Postfix) with ESMTP id 3FCC246A39; Tue, 15 Nov 2011 18:10:08 +0100 (CET) Received: from ubuntu64.secure-side.com ([127.0.0.1]) by localhost (ubuntu64.secure-side.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CfNBsByakRu4; Tue, 15 Nov 2011 18:10:01 +0100 (CET) Received: from ubuntu64.secure-side.com (ubuntu64.secure-side.com [192.168.1.146]) by ubuntu64.secure-side.com (Postfix) with ESMTP id 4455746A38; Tue, 15 Nov 2011 18:10:01 +0100 (CET) Date: Tue, 15 Nov 2011 18:10:01 +0100 (CET) From: GR To: freebsd-current@freebsd.org Message-ID: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-Originating-IP: [90.32.174.62] X-Mailer: Zimbra 7.1.3_GA_3346 (ZimbraWebClient - GC14 (Linux)/7.1.3_GA_3346) Cc: freebsd-stable@freebsd.org Subject: SIOCGIFADDR broken on 9.0-RC1? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Nov 2011 17:10:18 -0000 Hello list, more insights since my last post. Here is a small code to trigger the bug (end of email). When you run it on 9.0-RC1, it gets an alias address instead of the main inet address: % ./get-ip re0 inet: 192.168.2.10 # Main address being 192.168.1.148 On 8.2-RELEASE, all goes well: % ./get-ip re0 inet: PUBLIC_IP4 Is something broken, or a behaviour has changed since 8.2-RELEASE? Best regards, --8<-- #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int fd; struct ifreq ifr; const struct sockaddr_in *sa; fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { perror("socket"); exit(-1); } memset(&ifr, 0, sizeof(struct ifreq)); strlcpy(ifr.ifr_name, argv[1], sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { sa = (const struct sockaddr_in *) &ifr.ifr_addr; printf("inet: %s\n", inet_ntoa(sa->sin_addr)); } else { perror("ioctl"); exit(-1); } exit(0); } --8<-- -- ^ ___ ___ http://www.GomoR.org/ <-+ | / __ |__/ Senior Security Engineer | | \__/ | \ ---[ zsh$ alias psed='perl -pe ' ]--- | +--> Net::Frame <=> http://search.cpan.org/~gomor/ <---+