Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Sending a routing message (RTM_ADD) on adding an llentry
details: https://anonhg.NetBSD.org/src/rev/24de848a6b2f
branches: trunk
changeset: 824730:24de848a6b2f
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Jun 16 02:24:54 2017 +0000
description:
Sending a routing message (RTM_ADD) on adding an llentry
A message used to be sent on adding a cloned route. Restore the
behavior for backward compatibility.
Requested by ryo@
diffstat:
sys/net/route.h | 6 +++++-
sys/net/rtsock.c | 42 ++++++++++++++++++++++++++++++++++++++++--
sys/netinet/if_arp.c | 11 ++++++++---
sys/netinet6/nd6.c | 9 +++++++--
4 files changed, 60 insertions(+), 8 deletions(-)
diffs (153 lines):
diff -r f43cc5e2d7ff -r 24de848a6b2f sys/net/route.h
--- a/sys/net/route.h Fri Jun 16 02:01:10 2017 +0000
+++ b/sys/net/route.h Fri Jun 16 02:24:54 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.h,v 1.112 2017/04/11 13:55:54 roy Exp $ */
+/* $NetBSD: route.h,v 1.113 2017/06/16 02:24:54 ozaki-r Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -500,6 +500,10 @@
void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
void route_enqueue(struct mbuf *, int);
+struct llentry;
+void rt_clonedmsg(const struct sockaddr *, const struct ifnet *,
+ const struct rtentry *);
+
/* rtbl */
int rt_addaddr(rtbl_t *, struct rtentry *, const struct sockaddr *);
void rt_assert_inactive(const struct rtentry *);
diff -r f43cc5e2d7ff -r 24de848a6b2f sys/net/rtsock.c
--- a/sys/net/rtsock.c Fri Jun 16 02:01:10 2017 +0000
+++ b/sys/net/rtsock.c Fri Jun 16 02:24:54 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.214 2017/06/15 02:51:45 ozaki-r Exp $ */
+/* $NetBSD: rtsock.c,v 1.215 2017/06/16 02:24:54 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.214 2017/06/15 02:51:45 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.215 2017/06/16 02:24:54 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1628,6 +1628,44 @@
COMPATNAME(route_enqueue)(m, 0);
}
+#ifndef COMPAT_RTSOCK
+/*
+ * Send a routing message as mimicing that a cloned route is added.
+ */
+void
+rt_clonedmsg(const struct sockaddr *dst, const struct ifnet *ifp,
+ const struct rtentry *rt)
+{
+ struct rt_addrinfo info;
+ /* Mimic flags exactly */
+#define RTF_LLINFO 0x400
+#define RTF_CLONED 0x2000
+ int flags = RTF_UP | RTF_HOST | RTF_DONE | RTF_LLINFO | RTF_CLONED;
+ union {
+ struct sockaddr sa;
+ struct sockaddr_storage ss;
+ struct sockaddr_dl sdl;
+ } u;
+ uint8_t namelen = strlen(ifp->if_xname);
+ uint8_t addrlen = ifp->if_addrlen;
+
+ if (rt == NULL)
+ return; /* XXX */
+
+ memset(&info, 0, sizeof(info));
+ info.rti_info[RTAX_DST] = dst;
+ sockaddr_dl_init(&u.sdl, sizeof(u.ss), ifp->if_index, ifp->if_type,
+ NULL, namelen, NULL, addrlen);
+ info.rti_info[RTAX_GATEWAY] = &u.sa;
+ info.rti_info[RTAX_IFP] = rt->rt_ifp->if_dl->ifa_addr;
+ info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
+
+ rt_missmsg(RTM_ADD, &info, flags, 0);
+#undef RTF_LLINFO
+#undef RTF_CLONED
+}
+#endif /* COMPAT_RTSOCK */
+
/*
* This is used in dumping the kernel table via sysctl().
*/
diff -r f43cc5e2d7ff -r 24de848a6b2f sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c Fri Jun 16 02:01:10 2017 +0000
+++ b/sys/netinet/if_arp.c Fri Jun 16 02:24:54 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arp.c,v 1.250 2017/05/18 06:33:11 ozaki-r Exp $ */
+/* $NetBSD: if_arp.c,v 1.251 2017/06/16 02:24:54 ozaki-r Exp $ */
/*-
* Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.250 2017/05/18 06:33:11 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.251 2017/06/16 02:24:54 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -760,8 +760,13 @@
IF_AFDATA_WUNLOCK(ifp);
if (la == NULL)
ARP_STATINC(ARP_STAT_ALLOCFAIL);
- else
+ else {
+ struct sockaddr_in sin;
+
arp_init_llentry(ifp, la);
+ sockaddr_in_init(&sin, &la->r_l3addr.addr4, 0);
+ rt_clonedmsg(sintosa(&sin), ifp, rt);
+ }
} else if (LLE_TRY_UPGRADE(la) == 0) {
create_lookup = "lookup";
LLE_RUNLOCK(la);
diff -r f43cc5e2d7ff -r 24de848a6b2f sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c Fri Jun 16 02:01:10 2017 +0000
+++ b/sys/netinet6/nd6.c Fri Jun 16 02:24:54 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.c,v 1.232 2017/06/01 02:45:14 chs Exp $ */
+/* $NetBSD: nd6.c,v 1.233 2017/06/16 02:24:54 ozaki-r Exp $ */
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.232 2017/06/01 02:45:14 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.233 2017/06/16 02:24:54 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -2298,6 +2298,7 @@
/* Slow path */
ln = nd6_lookup(&dst->sin6_addr, ifp, true);
if (ln == NULL && nd6_is_addr_neighbor(dst, ifp)) {
+ struct sockaddr_in6 sin6;
/*
* Since nd6_is_addr_neighbor() internally calls nd6_lookup(),
* the condition below is not very efficient. But we believe
@@ -2313,6 +2314,10 @@
m_freem(m);
return ENOBUFS;
}
+
+ sockaddr_in6_init(&sin6, &ln->r_l3addr.addr6, 0, 0, 0);
+ rt_clonedmsg(sin6tosa(&sin6), ifp, rt);
+
created = true;
}
Home |
Main Index |
Thread Index |
Old Index