Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Introduce rt_addrmsg_src which adds RTA_AUTHOR to the me...
details: https://anonhg.NetBSD.org/src/rev/2237fbccb4c6
branches: trunk
changeset: 450913:2237fbccb4c6
user: roy <roy%NetBSD.org@localhost>
date: Mon Apr 29 16:12:30 2019 +0000
description:
Introduce rt_addrmsg_src which adds RTA_AUTHOR to the message.
Use this when we notify userland of a duplicate address
and set RTA_AUTHOR to the hardware address of the sender.
While here, match the logging diagnostic of INET6 to the simpler one
of INET so it's consistent.
diffstat:
sys/compat/common/rtsock_50.c | 7 +++-
sys/compat/net/route.h | 3 +-
sys/kern/compat_stub.c | 3 +-
sys/net/route.h | 3 +-
sys/net/rtsock_shared.c | 29 ++++++++++++++---
sys/netinet/if_arp.c | 39 +++++++++++++++---------
sys/netinet6/nd6_nbr.c | 67 +++++++++++++++++++++++++++---------------
sys/sys/compat_stub.h | 5 ++-
8 files changed, 105 insertions(+), 51 deletions(-)
diffs (truncated from 434 to 300 lines):
diff -r f022fd687152 -r 2237fbccb4c6 sys/compat/common/rtsock_50.c
--- a/sys/compat/common/rtsock_50.c Mon Apr 29 16:05:46 2019 +0000
+++ b/sys/compat/common/rtsock_50.c Mon Apr 29 16:12:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock_50.c,v 1.12 2019/04/29 11:57:22 roy Exp $ */
+/* $NetBSD: rtsock_50.c,v 1.13 2019/04/29 16:12:30 roy Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.12 2019/04/29 11:57:22 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.13 2019/04/29 16:12:30 roy Exp $");
#define COMPAT_RTSOCK /* Use the COMPATNAME/COMPATCALL macros and the
* various other compat definitions - see
@@ -162,6 +162,8 @@
MODULE_HOOK_SET(rtsock_rt_ifmsg_50_hook, "rts_50", compat_50_rt_ifmsg);
MODULE_HOOK_SET(rtsock_rt_addrmsg_rt_50_hook, "rts_50",
compat_50_rt_addrmsg_rt);
+ MODULE_HOOK_SET(rtsock_rt_addrmsg_src_50_hook, "rts_50",
+ compat_50_rt_addrmsg_src);
MODULE_HOOK_SET(rtsock_rt_addrmsg_50_hook, "rts_50",
compat_50_rt_addrmsg);
MODULE_HOOK_SET(rtsock_rt_ifannouncemsg_50_hook, "rts_50",
@@ -181,6 +183,7 @@
MODULE_HOOK_UNSET(rtsock_rt_missmsg_50_hook);
MODULE_HOOK_UNSET(rtsock_rt_ifmsg_50_hook);
MODULE_HOOK_UNSET(rtsock_rt_addrmsg_rt_50_hook);
+ MODULE_HOOK_UNSET(rtsock_rt_addrmsg_src_50_hook);
MODULE_HOOK_UNSET(rtsock_rt_addrmsg_50_hook);
MODULE_HOOK_UNSET(rtsock_rt_ifannouncemsg_50_hook);
MODULE_HOOK_UNSET(rtsock_rt_ieee80211msg_50_hook);
diff -r f022fd687152 -r 2237fbccb4c6 sys/compat/net/route.h
--- a/sys/compat/net/route.h Mon Apr 29 16:05:46 2019 +0000
+++ b/sys/compat/net/route.h Mon Apr 29 16:12:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.h,v 1.3 2019/04/29 11:57:22 roy Exp $ */
+/* $NetBSD: route.h,v 1.4 2019/04/29 16:12:30 roy Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -88,6 +88,7 @@
struct mbuf *
compat_50_rt_msg1(int, struct rt_addrinfo *, void *, int);
void compat_50_rt_addrmsg_rt(int, struct ifaddr *, int, struct rtentry *);
+void compat_50_rt_addrmsg_src(int, struct ifaddr *, const struct sockaddr *);
void compat_50_rt_addrmsg(int, struct ifaddr *);
void compat_70_rt_newaddrmsg1(int, struct ifaddr *);
#endif
diff -r f022fd687152 -r 2237fbccb4c6 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c Mon Apr 29 16:05:46 2019 +0000
+++ b/sys/kern/compat_stub.c Mon Apr 29 16:12:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.10 2019/04/29 11:57:22 roy Exp $ */
+/* $NetBSD: compat_stub.c,v 1.11 2019/04/29 16:12:30 roy Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -204,6 +204,7 @@
struct rtsock_rt_ifmsg_50_hook_t rtsock_rt_ifmsg_50_hook;
struct rtsock_rt_ifannouncemsg_50_hook_t rtsock_rt_ifannouncemsg_50_hook;
struct rtsock_rt_addrmsg_rt_50_hook_t rtsock_rt_addrmsg_rt_50_hook;
+struct rtsock_rt_addrmsg_src_50_hook_t rtsock_rt_addrmsg_src_50_hook;
struct rtsock_rt_addrmsg_50_hook_t rtsock_rt_addrmsg_50_hook;
struct rtsock_rt_ieee80211msg_50_hook_t rtsock_rt_ieee80211msg_50_hook;
diff -r f022fd687152 -r 2237fbccb4c6 sys/net/route.h
--- a/sys/net/route.h Mon Apr 29 16:05:46 2019 +0000
+++ b/sys/net/route.h Mon Apr 29 16:12:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.h,v 1.122 2019/04/29 11:57:22 roy Exp $ */
+/* $NetBSD: route.h,v 1.123 2019/04/29 16:12:30 roy Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -516,6 +516,7 @@
rt_msg1(int, struct rt_addrinfo *, void *, int);
int rt_msg3(int, struct rt_addrinfo *, void *, struct rt_walkarg *, int *);
void rt_addrmsg(int, struct ifaddr *);
+void rt_addrmsg_src(int, struct ifaddr *, const struct sockaddr *);
void rt_addrmsg_rt(int, struct ifaddr *, int, struct rtentry *);
void route_enqueue(struct mbuf *, int);
diff -r f022fd687152 -r 2237fbccb4c6 sys/net/rtsock_shared.c
--- a/sys/net/rtsock_shared.c Mon Apr 29 16:05:46 2019 +0000
+++ b/sys/net/rtsock_shared.c Mon Apr 29 16:12:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock_shared.c,v 1.7 2019/04/29 11:57:22 roy Exp $ */
+/* $NetBSD: rtsock_shared.c,v 1.8 2019/04/29 16:12:30 roy Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.7 2019/04/29 11:57:22 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.8 2019/04/29 16:12:30 roy Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1364,9 +1364,9 @@
* be unnecessary as the routing socket will automatically generate
* copies of it.
*/
-void
-COMPATNAME(rt_addrmsg_rt)(int cmd, struct ifaddr *ifa, int error,
- struct rtentry *rt)
+static void
+COMPATNAME(rt_addrmsg0)(int cmd, struct ifaddr *ifa, int error,
+ struct rtentry *rt, const struct sockaddr *src)
{
#define cmdpass(__cmd, __pass) (((__cmd) << 2) | (__pass))
struct rt_addrinfo info;
@@ -1428,6 +1428,7 @@
info.rti_info[RTAX_IFP] = ifp->if_dl->ifa_addr;
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
+ info.rti_info[RTAX_AUTHOR] = src;
memset(&ifam, 0, sizeof(ifam));
ifam.ifam_index = ifp->if_index;
ifam.ifam_metric = ifa->ifa_metric;
@@ -1473,7 +1474,23 @@
COMPATNAME(rt_addrmsg)(int cmd, struct ifaddr *ifa)
{
- COMPATNAME(rt_addrmsg_rt)(cmd, ifa, 0, NULL);
+ COMPATNAME(rt_addrmsg0)(cmd, ifa, 0, NULL, NULL);
+}
+
+void
+COMPATNAME(rt_addrmsg_rt)(int cmd, struct ifaddr *ifa, int error,
+ struct rtentry *rt)
+{
+
+ COMPATNAME(rt_addrmsg0)(cmd, ifa, error, rt, NULL);
+}
+
+void
+COMPATNAME(rt_addrmsg_src)(int cmd, struct ifaddr *ifa,
+ const struct sockaddr *src)
+{
+
+ COMPATNAME(rt_addrmsg0)(cmd, ifa, 0, NULL, src);
}
static struct mbuf *
diff -r f022fd687152 -r 2237fbccb4c6 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c Mon Apr 29 16:05:46 2019 +0000
+++ b/sys/netinet/if_arp.c Mon Apr 29 16:12:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arp.c,v 1.281 2019/04/29 16:05:46 roy Exp $ */
+/* $NetBSD: if_arp.c,v 1.282 2019/04/29 16:12:30 roy 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.281 2019/04/29 16:05:46 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282 2019/04/29 16:12:30 roy Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -176,7 +176,7 @@
static void arp_dad_timer(struct dadq *);
static void arp_dad_start(struct ifaddr *);
static void arp_dad_stop(struct ifaddr *);
-static void arp_dad_duplicated(struct ifaddr *, const char *);
+static void arp_dad_duplicated(struct ifaddr *, const struct sockaddr_dl *);
static void arp_init_llentry(struct ifnet *, struct llentry *);
#if NTOKEN > 0
@@ -1005,7 +1005,6 @@
uint64_t *arps;
struct psref psref, psref_ia;
int s;
- char llabuf[LLA_ADDRSTRLEN], *llastr;
char ipbuf[INET_ADDRSTRLEN];
bool do_dad;
@@ -1149,9 +1148,12 @@
(in_nullhost(isaddr) && in_hosteq(itaddr, myaddr) &&
m->m_flags & M_BCAST)))
{
- llastr = lla_snprintf(llabuf, sizeof(llabuf),
- ar_sha(ah), ah->ar_hln);
- arp_dad_duplicated((struct ifaddr *)ia, llastr);
+ struct sockaddr_dl sdl, *sdlp;
+
+ sdlp = sockaddr_dl_init(&sdl, sizeof(sdl),
+ ifp->if_index, ifp->if_type,
+ NULL, 0, ar_sha(ah), ah->ar_hln);
+ arp_dad_duplicated((struct ifaddr *)ia, sdlp);
goto out;
}
@@ -1176,6 +1178,8 @@
if ((la->la_flags & LLE_VALID) &&
memcmp(ar_sha(ah), &la->ll_addr, ifp->if_addrlen))
{
+ char llabuf[LLA_ADDRSTRLEN], *llastr;
+
llastr = lla_snprintf(llabuf, sizeof(llabuf),
ar_sha(ah), ah->ar_hln);
@@ -1753,38 +1757,43 @@
}
static void
-arp_dad_duplicated(struct ifaddr *ifa, const char *sha)
+arp_dad_duplicated(struct ifaddr *ifa, const struct sockaddr_dl *from)
{
struct in_ifaddr *ia = (struct in_ifaddr *)ifa;
struct ifnet *ifp = ifa->ifa_ifp;
- char ipbuf[INET_ADDRSTRLEN];
- const char *iastr;
+ char ipbuf[INET_ADDRSTRLEN], llabuf[LLA_ADDRSTRLEN];
+ const char *iastr, *llastr;
iastr = IN_PRINT(ipbuf, &ia->ia_addr.sin_addr);
+ if (__predict_false(from == NULL))
+ llastr = NULL;
+ else
+ llastr = lla_snprintf(llabuf, sizeof(llabuf),
+ CLLADDR(from), from->sdl_alen);
if (ia->ia4_flags & (IN_IFF_TENTATIVE|IN_IFF_DUPLICATED)) {
log(LOG_ERR,
"%s: DAD duplicate address %s from %s\n",
- if_name(ifp), iastr, sha);
+ if_name(ifp), iastr, llastr);
} else if (ia->ia_dad_defended == 0 ||
ia->ia_dad_defended < time_uptime - DEFEND_INTERVAL) {
ia->ia_dad_defended = time_uptime;
arpannounce1(ifa);
log(LOG_ERR,
"%s: DAD defended address %s from %s\n",
- if_name(ifp), iastr, sha);
+ if_name(ifp), iastr, llastr);
return;
} else {
/* If DAD is disabled, just report the duplicate. */
if (!ip_dad_enabled()) {
log(LOG_ERR,
"%s: DAD ignoring duplicate address %s from %s\n",
- if_name(ifp), iastr, sha);
+ if_name(ifp), iastr, llastr);
return;
}
log(LOG_ERR,
"%s: DAD defence failed for %s from %s\n",
- if_name(ifp), iastr, sha);
+ if_name(ifp), iastr, llastr);
}
arp_dad_stop(ifa);
@@ -1793,7 +1802,7 @@
if ((ia->ia4_flags & IN_IFF_DUPLICATED) == 0) {
ia->ia4_flags |= IN_IFF_DUPLICATED;
/* Inform the routing socket of the duplicate address */
- rt_addrmsg(RTM_NEWADDR, ifa);
+ rt_addrmsg_src(RTM_NEWADDR, ifa, (const struct sockaddr *)from);
}
}
diff -r f022fd687152 -r 2237fbccb4c6 sys/netinet6/nd6_nbr.c
--- a/sys/netinet6/nd6_nbr.c Mon Apr 29 16:05:46 2019 +0000
+++ b/sys/netinet6/nd6_nbr.c Mon Apr 29 16:12:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6_nbr.c,v 1.165 2019/04/29 11:57:22 roy Exp $ */
+/* $NetBSD: nd6_nbr.c,v 1.166 2019/04/29 16:12:30 roy Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.165 2019/04/29 11:57:22 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.166 2019/04/29 16:12:30 roy Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -82,8 +82,10 @@
static void nd6_dad_destroytimer(struct dadq *);
static void nd6_dad_timer(struct dadq *);
static void nd6_dad_ns_output(struct dadq *, struct ifaddr *);
-static void nd6_dad_input(struct ifaddr *, struct nd_opt_nonce *);
-static void nd6_dad_duplicated(struct ifaddr *, struct dadq *);
+static void nd6_dad_input(struct ifaddr *, struct nd_opt_nonce *,
+ const struct sockaddr_dl *);
+static void nd6_dad_duplicated(struct ifaddr *, struct dadq *,
+ const struct sockaddr_dl *);
static int dad_maxtry = 15; /* max # of *tries* to transmit DAD packet */
Home |
Main Index |
Thread Index |
Old Index