Date: Fri, 28 Aug 2009 11:01:59 +0200 From: =?ISO-8859-1?Q?Michael_T=FCxen?= <Michael.Tuexen@lurchi.franken.de> To: "Bjoern A. Zeeb" <bz@FreeBSD.org>, Qing Li <qingli@speakeasy.net>, Randall Stewart <rrs@lakerest.net>, net@freebsd.org Subject: Re: routing message problem Message-ID: <5467E669-F6F3-46E6-9978-111E42DAB328@lurchi.franken.de> In-Reply-To: <BFC746D7-9E88-43AD-8320-96928633C532@lurchi.franken.de> References: <BFC746D7-9E88-43AD-8320-96928633C532@lurchi.franken.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <sys/types.h> #include <sys/socket.h> #include <net/route.h> #include <net/if.h> #include <stdio.h> #include <stdlib.h> #include <sys/uio.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5467E669-F6F3-46E6-9978-111E42DAB328>