From owner-freebsd-stable@FreeBSD.ORG Tue Nov 15 22:38:29 2011 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 18A12106566B; Tue, 15 Nov 2011 22:38:29 +0000 (UTC) (envelope-from gleb.kurtsou@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 6E1B18FC1A; Tue, 15 Nov 2011 22:38:27 +0000 (UTC) Received: by bkbzs8 with SMTP id zs8so10681670bkb.13 for ; Tue, 15 Nov 2011 14:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=L3rIWCPylJ7R9pp8VVSBFwG9hjYgAgwt/8Sbmb/2ba4=; b=GSFMKHDQ21YukXfJlnXiORDZiNZ/WOVFMPvwdmutTqaVFxw/jWZtVPUzPxxLjNftkZ Z2lUjMTOeBPmWDNeWqZuRudCP/jLx8+T2BxCl8vlbmd+Va3qGErw1q5M8MAQIB9SyvE2 5iRXgbOnF/dQXSZBjr8ZbairEm0YCjCrMJpDA= Received: by 10.204.141.8 with SMTP id k8mr26417959bku.14.1321395232056; Tue, 15 Nov 2011 14:13:52 -0800 (PST) Received: from localhost ([78.157.92.5]) by mx.google.com with ESMTPS id q6sm37479428bka.6.2011.11.15.14.13.50 (version=SSLv3 cipher=OTHER); Tue, 15 Nov 2011 14:13:50 -0800 (PST) Date: Wed, 16 Nov 2011 00:13:49 +0200 From: Gleb Kurtsou To: GR Message-ID: <20111115221349.GA8701@reks> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-current@freebsd.org, freebsd-stable@freebsd.org Subject: Re: SIOCGIFADDR broken on 9.0-RC1? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Nov 2011 22:38:29 -0000 On (15/11/2011 18:10), GR wrote: > 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? Your test case looks ok and works as expexted for me on 10-CURRENT, both without aliases and after adding alias to interface. Perhaps it's the way you add aliases (libdnet ?). I've used: ifconfing em0 alias OTHERIP Thanks, Gleb. > > 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/ <---+ > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"