Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add ifam_pid and ifam_addrflags to ifa_msghdr.
details: https://anonhg.NetBSD.org/src/rev/1d31766fdd05
branches: trunk
changeset: 347884:1d31766fdd05
user: roy <roy%NetBSD.org@localhost>
date: Wed Sep 21 10:50:22 2016 +0000
description:
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.
diffstat:
share/man/man4/route.4 | 23 +++++--
sys/compat/common/Makefile | 4 +-
sys/compat/common/rtsock_70.c | 115 +++++++++++++++++++++++++++++++++++++++
sys/compat/net/if.h | 26 ++++++++-
sys/compat/net/route.h | 3 +-
sys/net/if.h | 8 +-
sys/net/route.h | 11 ++-
sys/net/rtsock.c | 102 ++++++++++++++++++++++++++++++----
sys/rump/net/lib/libnet/Makefile | 6 +-
sys/sys/socket.h | 15 ++--
10 files changed, 274 insertions(+), 39 deletions(-)
diffs (truncated from 605 to 300 lines):
diff -r 8a376e7e7fac -r 1d31766fdd05 share/man/man4/route.4
--- a/share/man/man4/route.4 Wed Sep 21 06:49:39 2016 +0000
+++ b/share/man/man4/route.4 Wed Sep 21 10:50:22 2016 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: route.4,v 1.27 2016/04/04 13:29:12 wiz Exp $
+.\" $NetBSD: route.4,v 1.28 2016/09/21 10:50:23 roy Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)route.4 8.6 (Berkeley) 4/19/94
.\"
-.Dd March 30, 2016
+.Dd September 15, 2016
.Dt ROUTE 4
.Os
.Sh NAME
@@ -196,13 +196,16 @@
#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */
#define RTM_REDIRECT 0x6 /* Told to use different route */
#define RTM_MISS 0x7 /* Lookup failed on this address */
-#define RTM_NEWADDR 0xc /* address being added to iface */
-#define RTM_DELADDR 0xd /* address being removed from iface */
+#define RTM_ONEWADDR 0xc /* Old (pre-8.0) RTM_NEWADDR message */
+#define RTM_ODELADDR 0xd /* Old (pre-8.0) RTM_DELADDR message */
#define RTM_OOIFINFO 0xe /* Old (pre-1.5) RTM_IFINFO message */
#define RTM_OIFINFO 0xf /* Old (pre-6.0) RTM_IFINFO message */
#define RTM_IFANNOUNCE 0x10 /* iface arrival/departure */
#define RTM_IFINFO 0x14 /* iface/link going up/down etc. */
-#define RTM_CHGADDR 0x15 /* address has changed on iface */
+#define RTM_OCHGADDR 0x15 /* Old (pre-8.0) RTM_CHGADDR message */
+#define RTM_NEWADDR 0x16 /* address being added to iface */
+#define RTM_DELADDR 0x17 /* address being removed from iface */
+#define RTM_CHGADDR 0x18 /* address properties changed */
.Ed
.Pp
A message header consists of one of the following:
@@ -236,9 +239,11 @@
u_short ifam_msglen; /* to skip over non-understood messages */
u_char ifam_version; /* future binary compatibility */
u_char ifam_type; /* message type */
- int ifam_addrs; /* like rtm_addrs */
+ u_short ifam_index; /* index for associated ifp */
int ifam_flags; /* value of ifa_flags */
- u_short ifam_index; /* index for associated ifp */
+ int ifam_addrs; /* like rtm_addrs */
+ pid_t ifam_pid; /* identify sender */
+ int ifam_addrflags; /* family specific address flags */
int ifam_metric; /* value of ifa_metric */
};
@@ -367,3 +372,7 @@
.Cm RTF_LLDATA
appeared in
.Nx 8.0 .
+.Pp
+.Vt ifa_msghdr
+gained the fields ifam_pid and ifam_addrflags in
+.Nx 8.0 .
diff -r 8a376e7e7fac -r 1d31766fdd05 sys/compat/common/Makefile
--- a/sys/compat/common/Makefile Wed Sep 21 06:49:39 2016 +0000
+++ b/sys/compat/common/Makefile Wed Sep 21 10:50:22 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.56 2016/04/06 19:45:45 roy Exp $
+# $NetBSD: Makefile,v 1.57 2016/09/21 10:50:23 roy Exp $
LIB= compat
NOPIC= # defined
@@ -48,7 +48,7 @@
SRCS+= kern_sa_60.c tty_60.c kern_time_60.c
# Compatibility code for NetBSD 7.0
-SRCS+= uipc_usrreq_70.c
+SRCS+= rtsock_70.c uipc_usrreq_70.c
# really, all machines where sizeof(int) != sizeof(long) (LP64)
.if (${MACHINE_ARCH} != "alpha" && ${MACHINE_ARCH} != "sparc64" \
diff -r 8a376e7e7fac -r 1d31766fdd05 sys/compat/common/rtsock_70.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/rtsock_70.c Wed Sep 21 10:50:22 2016 +0000
@@ -0,0 +1,115 @@
+/* $NetBSD: rtsock_70.c,v 1.1 2016/09/21 10:50:23 roy Exp $ */
+
+/*
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roy Marples.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: rtsock_70.c,v 1.1 2016/09/21 10:50:23 roy Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/mbuf.h>
+#include <net/if.h>
+#include <net/route.h>
+
+#include <compat/net/if.h>
+#include <compat/net/route.h>
+
+#if defined(COMPAT_70)
+void
+compat_70_rt_newaddrmsg1(int cmd, struct ifaddr *ifa)
+{
+ struct rt_addrinfo info;
+ const struct sockaddr *sa;
+ struct mbuf *m;
+ struct ifnet *ifp;
+ struct ifa_msghdr70 ifam;
+ int ncmd;
+
+ KASSERT(ifa != NULL);
+ ifp = ifa->ifa_ifp;
+
+ switch (cmd) {
+ case RTM_NEWADDR:
+ ncmd = RTM_ONEWADDR;
+ break;
+ case RTM_DELADDR:
+ ncmd = RTM_ODELADDR;
+ break;
+ case RTM_CHGADDR:
+ ncmd = RTM_OCHGADDR;
+ break;
+ default:
+ panic("%s: called with wrong command", __func__);
+ }
+
+ memset(&info, 0, sizeof(info));
+ info.rti_info[RTAX_IFA] = sa = ifa->ifa_addr;
+ KASSERT(ifp->if_dl != NULL);
+ 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;
+
+ memset(&ifam, 0, sizeof(ifam));
+ ifam.ifam_index = ifp->if_index;
+ ifam.ifam_metric = ifa->ifa_metric;
+ ifam.ifam_flags = ifa->ifa_flags;
+
+ m = rt_msg1(ncmd, &info, &ifam, sizeof(ifam));
+ if (m == NULL)
+ return;
+
+ mtod(m, struct ifa_msghdr70 *)->ifam_addrs = info.rti_addrs;
+ route_enqueue(m, sa ? sa->sa_family : 0);
+}
+
+int
+compat_70_iflist_addr(struct rt_walkarg *w, struct ifaddr *ifa,
+ struct rt_addrinfo *info)
+{
+ int len, error;
+
+ if ((error = rt_msg3(RTM_ONEWADDR, info, 0, w, &len)))
+ return error;
+ if (w->w_where && w->w_tmem && w->w_needed <= 0) {
+ struct ifa_msghdr70 *ifam;
+
+ ifam = (struct ifa_msghdr70 *)w->w_tmem;
+ ifam->ifam_index = ifa->ifa_ifp->if_index;
+ ifam->ifam_flags = ifa->ifa_flags;
+ ifam->ifam_metric = ifa->ifa_metric;
+ ifam->ifam_addrs = info->rti_addrs;
+ if ((error = copyout(w->w_tmem, w->w_where, len)) == 0)
+ w->w_where = (char *)w->w_where + len;
+ }
+ return error;
+}
+#endif /* COMPAT_70 */
diff -r 8a376e7e7fac -r 1d31766fdd05 sys/compat/net/if.h
--- a/sys/compat/net/if.h Wed Sep 21 06:49:39 2016 +0000
+++ b/sys/compat/net/if.h Wed Sep 21 10:50:22 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.3 2011/02/01 01:39:20 matt Exp $ */
+/* $NetBSD: if.h,v 1.4 2016/09/21 10:50:23 roy Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -183,4 +183,28 @@
u_short ifan_what; /* what type of announcement */
};
+#if !defined(_KERNEL) || !defined(COMPAT_RTSOCK)
+#define __align64 __aligned(sizeof(uint64_t))
+#else
+#define __align64
+#endif
+/*
+ * Message format for use in obtaining information about interface addresses
+ * from sysctl and the routing socket.
+ */
+struct ifa_msghdr70 {
+ u_short ifam_msglen __align64;
+ /* to skip over non-understood messages */
+ u_char ifam_version; /* future binary compatibility */
+ u_char ifam_type; /* message type */
+ int ifam_addrs; /* like rtm_addrs */
+ int ifam_flags; /* value of ifa_flags */
+ int ifam_metric; /* value of ifa_metric */
+ u_short ifam_index; /* index for associated ifp */
+};
+#undef __align64
+
+int compat_70_iflist_addr(struct rt_walkarg *, struct ifaddr *,
+ struct rt_addrinfo *);
+
#endif /* _COMPAT_NET_IF_H_ */
diff -r 8a376e7e7fac -r 1d31766fdd05 sys/compat/net/route.h
--- a/sys/compat/net/route.h Wed Sep 21 06:49:39 2016 +0000
+++ b/sys/compat/net/route.h Wed Sep 21 10:50:22 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.h,v 1.1 2011/02/01 01:39:20 matt Exp $ */
+/* $NetBSD: route.h,v 1.2 2016/09/21 10:50:23 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_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
+void compat_70_rt_newaddrmsg1(int, struct ifaddr *);
#endif
#define RTM_OVERSION 3 /* Up the ante and ignore older versions */
diff -r 8a376e7e7fac -r 1d31766fdd05 sys/net/if.h
--- a/sys/net/if.h Wed Sep 21 06:49:39 2016 +0000
+++ b/sys/net/if.h Wed Sep 21 10:50:22 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.225 2016/08/10 10:09:42 kre Exp $ */
+/* $NetBSD: if.h,v 1.226 2016/09/21 10:50:22 roy Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -634,10 +634,12 @@
/* to skip over non-understood messages */
u_char ifam_version; /* future binary compatibility */
u_char ifam_type; /* message type */
- int ifam_addrs; /* like rtm_addrs */
+ u_short ifam_index; /* index for associated ifp */
int ifam_flags; /* value of ifa_flags */
+ int ifam_addrs; /* like rtm_addrs */
+ pid_t ifam_pid; /* identify sender */
+ int ifam_addrflags; /* family specific address flags */
int ifam_metric; /* value of ifa_metric */
- u_short ifam_index; /* index for associated ifp */
};
/*
diff -r 8a376e7e7fac -r 1d31766fdd05 sys/net/route.h
--- a/sys/net/route.h Wed Sep 21 06:49:39 2016 +0000
+++ b/sys/net/route.h Wed Sep 21 10:50:22 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.h,v 1.102 2016/08/01 03:15:30 ozaki-r Exp $ */
+/* $NetBSD: route.h,v 1.103 2016/09/21 10:50:22 roy Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -219,8 +219,8 @@
#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */
#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */
// #define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */
-#define RTM_NEWADDR 0xc /* address being added to iface */
-#define RTM_DELADDR 0xd /* address being removed from iface */
+#define RTM_ONEWADDR 0xc /* Old (pre-8.0) RTM_NEWADDR message */
+#define RTM_ODELADDR 0xd /* Old (pre-8.0) RTM_DELADDR message */
#define RTM_OOIFINFO 0xe /* Old (pre-1.5) RTM_IFINFO message */
#define RTM_OIFINFO 0xf /* Old (pre-64bit time) RTM_IFINFO message */
#define RTM_IFANNOUNCE 0x10 /* iface arrival/departure */
@@ -232,7 +232,10 @@
* address has changed
*/
#define RTM_IFINFO 0x14 /* iface/link going up/down etc. */
Home |
Main Index |
Thread Index |
Old Index