From owner-freebsd-net@FreeBSD.ORG Fri Aug 28 09:02:01 2009 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F7471065676; Fri, 28 Aug 2009 09:02:01 +0000 (UTC) (envelope-from Michael.Tuexen@lurchi.franken.de) Received: from mail-n.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) by mx1.freebsd.org (Postfix) with ESMTP id 314AA8FC23; Fri, 28 Aug 2009 09:02:01 +0000 (UTC) Received: from [IPv6:2002:5481:ebd3::224:36ff:feef:67d1] (unknown [IPv6:2002:5481:ebd3:0:224:36ff:feef:67d1]) by mail-n.franken.de (Postfix) with ESMTP id DC4E51C0B4624; Fri, 28 Aug 2009 11:01:59 +0200 (CEST) Message-Id: <5467E669-F6F3-46E6-9978-111E42DAB328@lurchi.franken.de> From: =?ISO-8859-1?Q?Michael_T=FCxen?= To: "Bjoern A. Zeeb" , Qing Li , Randall Stewart , net@freebsd.org In-Reply-To: Content-Type: multipart/mixed; boundary=Apple-Mail-1-412495865 Mime-Version: 1.0 (Apple Message framework v936) Date: Fri, 28 Aug 2009 11:01:59 +0200 References: X-Mailer: Apple Mail (2.936) Cc: Subject: Re: routing message problem X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 09:02:01 -0000 --Apple-Mail-1-412495865 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit ... I forgot to attach the program... --Apple-Mail-1-412495865 Content-Disposition: attachment; filename=aw.c Content-Type: application/octet-stream; x-mac-creator=534D554C; x-unix-mode=0644; x-mac-type=534D4C64; name="aw.c" Content-Transfer-Encoding: 7bit #include #include #include #include #include #include #include #include #include #include #define BUFFER_LENGTH 1024 #define ROUNDUP(a, size) (((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a)) #define NEXT_SA(ap) ap = (struct sockaddr *) \ ((caddr_t) ap + (ap->sa_len ? ROUNDUP(ap->sa_len, sizeof (u_long)) : sizeof(u_long))) void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) { int i; for (i = 0; i < RTAX_MAX; i++) { if (addrs & (1 << i)) { rti_info[i] = sa; NEXT_SA(sa); } else rti_info[i] = NULL; } } int main (int argc, const char * argv[]) { int fd; struct ifa_msghdr *ifa; char *buffer; struct sockaddr *sa, *rti_info[RTAX_MAX]; char addr[INET6_ADDRSTRLEN]; if ((fd = socket(AF_ROUTE, SOCK_RAW, 0)) <0 ) { perror("socket"); } while (1) { buffer = calloc(1, BUFFER_LENGTH); ifa = (struct ifa_msghdr *) buffer; read(fd, ifa, BUFFER_LENGTH); sa = (struct sockaddr *) (ifa + 1); get_rtaddrs(ifa->ifam_addrs, sa, rti_info); switch(ifa->ifam_type) { case RTM_NEWADDR: if (rti_info[RTAX_IFA]->sa_family == AF_INET) { inet_ntop(AF_INET, &((struct sockaddr_in *)rti_info[RTAX_IFA])->sin_addr, addr, sizeof(addr)); } if (rti_info[RTAX_IFA]->sa_family == AF_INET6) { inet_ntop(AF_INET6, &((struct sockaddr_in6 *)rti_info[RTAX_IFA])->sin6_addr, addr, sizeof(addr)); } printf("Address %s added.\n", addr); break; case RTM_DELADDR: if (rti_info[RTAX_IFA]->sa_family == AF_INET) { inet_ntop(AF_INET, &((struct sockaddr_in *)rti_info[RTAX_IFA])->sin_addr, addr, sizeof(addr)); } if (rti_info[RTAX_IFA]->sa_family == AF_INET6) { inet_ntop(AF_INET6, &((struct sockaddr_in6 *)rti_info[RTAX_IFA])->sin6_addr, addr, sizeof(addr)); } printf("Address %s deleted.\n", addr); break; default: break; } fflush(stdout); } return 0; } --Apple-Mail-1-412495865 Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable On Aug 28, 2009, at 11:00 AM, Michael T=FCxen wrote: > Dear all, > > via a bug report from Preethi I figured out that there are no =20 > RTM_NEWADDR > routing messages generated when an IP address is added to an interface > and there is already an address in the same network configured. > This is a problem for the SCTP stack. > > To reproduce the problem you can > sudo ifconfig em0 192.168.1.1 > sudo ifconfig em0 192.168.1.2 alias > > and use the attached problem. It will only show the first address > being added. This problem applies to FreeBSD 9.0 CURRENT and 7.2 =20 > RELEASE. > > Any idea how to fix the problem? > > Best regards > Michael > --Apple-Mail-1-412495865--