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
[-- Attachment #1 --]
... I forgot to attach the program...
[-- Attachment #2 --]
#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;
}
[-- Attachment #3 --]
On Aug 28, 2009, at 11:00 AM, Michael Tüxen wrote:
> Dear all,
>
> via a bug report from Preethi I figured out that there are no
> 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
> RELEASE.
>
> Any idea how to fix the problem?
>
> Best regards
> Michael
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5467E669-F6F3-46E6-9978-111E42DAB328>
