diff options
author | David Lamparter <equinox@diac24.net> | 2010-02-03 20:05:09 +0100 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2010-02-04 02:52:32 +0100 |
commit | 85e53d51f723112b44075c658431d9700facd4c0 (patch) | |
tree | 9caa82e27309a1690d8c55e3bf740fac92ecd8f9 /zebra/kernel_socket.c | |
parent | 316ef35ac30edcd56be22a551897f47ebeb91b29 (diff) | |
download | quagga-85e53d51f723112b44075c658431d9700facd4c0.tar.bz2 quagga-85e53d51f723112b44075c658431d9700facd4c0.tar.xz |
zebra: NetBSD: get IPSRCSEL preference value from kernel
fetch the address preference value from the kernel through
SIOCGIFADDRPREF and pass it to quagga through connected_add_ipv4,
which stores it in struct connected->preference.
IPSRCSEL is a NetBSD kernel option(4), documented in in_getifa(9) and
is available since NetBSD 4.0 but not enabled in default GENERIC.
Diffstat (limited to 'zebra/kernel_socket.c')
-rw-r--r-- | zebra/kernel_socket.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 5a0359ea..aa962a35 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -253,6 +253,25 @@ rtm_flag_dump (int flag) zlog_debug ("Kernel: %s", buf); } +/* NetBSD IPSRCSEL preference readback */ +static int +if_get_addrpref (const char *ifname, struct sockaddr_in *addr) +{ +#ifdef SIOCSIFADDRPREF + int ret; + struct if_addrprefreq ifapr; + + memset (&ifapr, 0, sizeof ifapr); + strncpy ((char *)&ifapr.ifap_name, ifname, sizeof ifapr.ifap_name); + memcpy (&ifapr.ifap_addr, addr, sizeof (struct sockaddr_in)); + + ret = if_ioctl (SIOCGIFADDRPREF, (caddr_t) &ifapr); + if (ret == 0) + return ifapr.ifap_preference; +#endif + return 0; +} + #ifdef RTM_IFANNOUNCE /* Interface adding function */ static int @@ -619,6 +638,7 @@ ifam_read (struct ifa_msghdr *ifam) short ifnlen = 0; char isalias = 0; int flags = 0; + int preference = 0; ifname[0] = ifname[INTERFACE_NAMSIZ - 1] = '\0'; @@ -649,6 +669,9 @@ ifam_read (struct ifa_msghdr *ifam) */ ifp->metric = ifam->ifam_metric; #endif + if (sockunion_family (&addr) == AF_INET + && ifam->ifam_type == RTM_NEWADDR) + preference = if_get_addrpref (ifp->name, &addr.sin); /* Add connected address. */ switch (sockunion_family (&addr)) @@ -658,7 +681,7 @@ ifam_read (struct ifa_msghdr *ifam) connected_add_ipv4 (ifp, flags, &addr.sin.sin_addr, ip_masklen (mask.sin.sin_addr), &brd.sin.sin_addr, - (isalias ? ifname : NULL), 0); + (isalias ? ifname : NULL), 0, preference); else connected_delete_ipv4 (ifp, flags, &addr.sin.sin_addr, ip_masklen (mask.sin.sin_addr), |