Module Name: src
Committed By: jakllsch
Date: Tue Sep 15 23:24:34 UTC 2009
Modified Files:
src/sys/net: if.c
Log Message:
When working with address preferences, sockaddr_externalize() both
addresses before comparing them.
This allows IPv6 link-local addresses (which have an embedded scope id)
to have a preference set on them.
ok dyoung
To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/sys/net/if.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.235 src/sys/net/if.c:1.236
--- src/sys/net/if.c:1.235 Fri Sep 11 22:06:29 2009
+++ src/sys/net/if.c Tue Sep 15 23:24:34 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.235 2009/09/11 22:06:29 dyoung Exp $ */
+/* $NetBSD: if.c,v 1.236 2009/09/15 23:24:34 jakllsch Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.235 2009/09/11 22:06:29 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.236 2009/09/15 23:24:34 jakllsch Exp $");
#include "opt_inet.h"
@@ -1583,7 +1583,7 @@
union {
struct sockaddr sa;
struct sockaddr_storage ss;
- } u;
+ } u, v;
switch (cmd) {
case SIOCSIFADDRPREF:
@@ -1610,11 +1610,13 @@
if ((any = sockaddr_any(sa)) == NULL || sa->sa_len != any->sa_len)
return EINVAL;
+ sockaddr_externalize(&v.sa, sizeof(v.ss), sa);
+
IFADDR_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family != sa->sa_family)
continue;
sockaddr_externalize(&u.sa, sizeof(u.ss), ifa->ifa_addr);
- if (sockaddr_cmp(&u.sa, sa) == 0)
+ if (sockaddr_cmp(&u.sa, &v.sa) == 0)
break;
}
if (ifa == NULL)