summaryrefslogtreecommitdiffstats
path: root/sbin/ping6
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committersjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit65145fa4c81da358fcbc3b650156dab705dfa34e (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /sbin/ping6
parent60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip
FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz
Merge sync of head
Diffstat (limited to 'sbin/ping6')
-rw-r--r--sbin/ping6/Makefile3
-rw-r--r--sbin/ping6/ping6.c17
2 files changed, 14 insertions, 6 deletions
diff --git a/sbin/ping6/Makefile b/sbin/ping6/Makefile
index e40dc6e..35a76e4 100644
--- a/sbin/ping6/Makefile
+++ b/sbin/ping6/Makefile
@@ -10,7 +10,6 @@ WARNS?= 3
BINOWN= root
BINMODE=4555
-LDADD= -lipsec -lm -lmd
-DPADD= ${LIBIPSEC} ${LIBM} ${LIBMD}
+LIBADD= ipsec m md
.include <bsd.prog.mk>
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index fa314f6..d71c021 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -648,11 +648,20 @@ main(int argc, char *argv[])
err(1, "socket");
/* set the source address if specified. */
- if ((options & F_SRCADDR) &&
- bind(s, (struct sockaddr *)&src, srclen) != 0) {
- err(1, "bind");
+ if ((options & F_SRCADDR) != 0) {
+ /* properly fill sin6_scope_id */
+ if (IN6_IS_ADDR_LINKLOCAL(&src.sin6_addr) && (
+ IN6_IS_ADDR_LINKLOCAL(&dst.sin6_addr) ||
+ IN6_IS_ADDR_MC_LINKLOCAL(&dst.sin6_addr) ||
+ IN6_IS_ADDR_MC_NODELOCAL(&dst.sin6_addr))) {
+ if (src.sin6_scope_id == 0)
+ src.sin6_scope_id = dst.sin6_scope_id;
+ if (dst.sin6_scope_id == 0)
+ dst.sin6_scope_id = src.sin6_scope_id;
+ }
+ if (bind(s, (struct sockaddr *)&src, srclen) != 0)
+ err(1, "bind");
}
-
/* set the gateway (next hop) if specified */
if (gateway) {
memset(&hints, 0, sizeof(hints));
OpenPOWER on IntegriCloud