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.
This commit is contained in:
parent
46ef072377
commit
98b0d70fff
|
@ -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 @@ The messages are:
|
|||
#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 @@ struct ifa_msghdr {
|
|||
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 */
|
||||
int ifam_flags; /* value of ifa_flags */
|
||||
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 */
|
||||
};
|
||||
|
||||
|
@ -367,3 +372,7 @@ and
|
|||
.Cm RTF_LLDATA
|
||||
appeared in
|
||||
.Nx 8.0 .
|
||||
.Pp
|
||||
.Vt ifa_msghdr
|
||||
gained the fields ifam_pid and ifam_addrflags in
|
||||
.Nx 8.0 .
|
||||
|
|
|
@ -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_50.c kern_time_50.c kern_select_50.c rndpseudo_50.c rtsock_50.c \
|
|||
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" \
|
||||
|
|
|
@ -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 */
|
|
@ -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 @@ struct if_announcemsghdr50 {
|
|||
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_ */
|
||||
|
|
|
@ -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 @@ void compat_50_rt_missmsg(int, const struct rt_addrinfo *, int, int);
|
|||
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 */
|
||||
|
|
10
sys/net/if.h
10
sys/net/if.h
|
@ -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 @@ struct ifa_msghdr {
|
|||
/* 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 */
|
||||
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 */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -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 @@ struct rt_msghdr {
|
|||
#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 @@ struct rt_msghdr {
|
|||
* address has changed
|
||||
*/
|
||||
#define RTM_IFINFO 0x14 /* iface/link going up/down etc. */
|
||||
#define RTM_CHGADDR 0x15 /* address properties changed */
|
||||
#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 */
|
||||
|
||||
#define RTV_MTU 0x1 /* init or lock _mtu */
|
||||
#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */
|
||||
|
|
102
sys/net/rtsock.c
102
sys/net/rtsock.c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rtsock.c,v 1.195 2016/09/01 19:04:30 roy Exp $ */
|
||||
/* $NetBSD: rtsock.c,v 1.196 2016/09/21 10:50:22 roy 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.195 2016/09/01 19:04:30 roy Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.196 2016/09/21 10:50:22 roy Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -98,12 +98,15 @@ extern void sctp_add_ip_address(struct ifaddr *);
|
|||
extern void sctp_delete_ip_address(struct ifaddr *);
|
||||
#endif
|
||||
|
||||
#if defined(COMPAT_14) || defined(COMPAT_50)
|
||||
#if defined(COMPAT_14) || defined(COMPAT_50) || defined(COMPAT_70)
|
||||
#include <compat/net/if.h>
|
||||
#include <compat/net/route.h>
|
||||
#endif
|
||||
#ifdef COMPAT_RTSOCK
|
||||
#define RTM_XVERSION RTM_OVERSION
|
||||
#define RTM_XNEWADDR RTM_ONEWADDR
|
||||
#define RTM_XDELADDR RTM_ODELADDR
|
||||
#define RTM_XCHGADDR RTM_OCHGADDR
|
||||
#define RT_XADVANCE(a,b) RT_OADVANCE(a,b)
|
||||
#define RT_XROUNDUP(n) RT_OROUNDUP(n)
|
||||
#define PF_XROUTE PF_OROUTE
|
||||
|
@ -115,8 +118,12 @@ extern void sctp_delete_ip_address(struct ifaddr *);
|
|||
#define DOMAINNAME "oroute"
|
||||
CTASSERT(sizeof(struct ifa_xmsghdr) == 20);
|
||||
DOMAIN_DEFINE(compat_50_routedomain); /* forward declare and add to link set */
|
||||
#undef COMPAT_70
|
||||
#else /* COMPAT_RTSOCK */
|
||||
#define RTM_XVERSION RTM_VERSION
|
||||
#define RTM_XNEWADDR RTM_NEWADDR
|
||||
#define RTM_XDELADDR RTM_DELADDR
|
||||
#define RTM_XCHGADDR RTM_CHGADDR
|
||||
#define RT_XADVANCE(a,b) RT_ADVANCE(a,b)
|
||||
#define RT_XROUNDUP(n) RT_ROUNDUP(n)
|
||||
#define PF_XROUTE PF_ROUTE
|
||||
|
@ -126,7 +133,7 @@ DOMAIN_DEFINE(compat_50_routedomain); /* forward declare and add to link set */
|
|||
#define if_xannouncemsghdr if_announcemsghdr
|
||||
#define COMPATNAME(x) x
|
||||
#define DOMAINNAME "route"
|
||||
CTASSERT(sizeof(struct ifa_xmsghdr) == 24);
|
||||
CTASSERT(sizeof(struct ifa_xmsghdr) == 32);
|
||||
#ifdef COMPAT_50
|
||||
#define COMPATCALL(name, args) compat_50_ ## name args
|
||||
#endif
|
||||
|
@ -1028,6 +1035,17 @@ rt_getlen(int type)
|
|||
#endif
|
||||
|
||||
switch (type) {
|
||||
case RTM_ODELADDR:
|
||||
case RTM_ONEWADDR:
|
||||
case RTM_OCHGADDR:
|
||||
#ifdef COMPAT_70
|
||||
return sizeof(struct ifa_msghdr70);
|
||||
#else
|
||||
#ifdef DIAGNOSTIC
|
||||
printf("RTM_ONEWADDR\n");
|
||||
#endif
|
||||
return -1;
|
||||
#endif
|
||||
case RTM_DELADDR:
|
||||
case RTM_NEWADDR:
|
||||
case RTM_CHGADDR:
|
||||
|
@ -1278,6 +1296,25 @@ COMPATNAME(rt_ifmsg)(struct ifnet *ifp)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef COMPAT_RTSOCK
|
||||
static int
|
||||
if_addrflags(struct ifaddr *ifa)
|
||||
{
|
||||
|
||||
switch (ifa->ifa_addr->sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
return ((struct in_ifaddr *)ifa)->ia4_flags;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
return ((struct in6_ifaddr *)ifa)->ia6_flags;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is called to generate messages from the routing socket
|
||||
|
@ -1302,6 +1339,7 @@ COMPATNAME(rt_newaddrmsg)(int cmd, struct ifaddr *ifa, int error,
|
|||
int ncmd;
|
||||
|
||||
KASSERT(ifa != NULL);
|
||||
KASSERT(ifa->ifa_addr != NULL);
|
||||
ifp = ifa->ifa_ifp;
|
||||
#ifdef SCTP
|
||||
if (cmd == RTM_ADD) {
|
||||
|
@ -1325,17 +1363,29 @@ COMPATNAME(rt_newaddrmsg)(int cmd, struct ifaddr *ifa, int error,
|
|||
case cmdpass(RTM_CHGADDR, 1):
|
||||
switch (cmd) {
|
||||
case RTM_ADD:
|
||||
ncmd = RTM_NEWADDR;
|
||||
ncmd = RTM_XNEWADDR;
|
||||
break;
|
||||
case RTM_DELETE:
|
||||
ncmd = RTM_DELADDR;
|
||||
ncmd = RTM_XDELADDR;
|
||||
break;
|
||||
case RTM_CHANGE:
|
||||
ncmd = RTM_CHGADDR;
|
||||
ncmd = RTM_XCHGADDR;
|
||||
break;
|
||||
case RTM_NEWADDR:
|
||||
ncmd = RTM_XNEWADDR;
|
||||
break;
|
||||
case RTM_DELADDR:
|
||||
ncmd = RTM_XDELADDR;
|
||||
break;
|
||||
case RTM_CHGADDR:
|
||||
ncmd = RTM_XCHGADDR;
|
||||
break;
|
||||
default:
|
||||
ncmd = cmd;
|
||||
panic("%s: unknown command %d", __func__, cmd);
|
||||
}
|
||||
#ifdef COMPAT_70
|
||||
compat_70_rt_newaddrmsg1(ncmd, ifa);
|
||||
#endif
|
||||
info.rti_info[RTAX_IFA] = sa = ifa->ifa_addr;
|
||||
KASSERT(ifp->if_dl != NULL);
|
||||
info.rti_info[RTAX_IFP] = ifp->if_dl->ifa_addr;
|
||||
|
@ -1345,6 +1395,10 @@ COMPATNAME(rt_newaddrmsg)(int cmd, struct ifaddr *ifa, int error,
|
|||
ifam.ifam_index = ifp->if_index;
|
||||
ifam.ifam_metric = ifa->ifa_metric;
|
||||
ifam.ifam_flags = ifa->ifa_flags;
|
||||
#ifndef COMPAT_RTSOCK
|
||||
ifam.ifam_pid = curproc->p_pid;
|
||||
ifam.ifam_addrflags = if_addrflags(ifa);
|
||||
#endif
|
||||
m = COMPATNAME(rt_msg1)(ncmd, &info, &ifam, sizeof(ifam));
|
||||
if (m == NULL)
|
||||
continue;
|
||||
|
@ -1379,6 +1433,7 @@ COMPATNAME(rt_newaddrmsg)(int cmd, struct ifaddr *ifa, int error,
|
|||
COMPATNAME(route_enqueue)(m, sa ? sa->sa_family : 0);
|
||||
}
|
||||
#undef cmdpass
|
||||
|
||||
}
|
||||
|
||||
static struct mbuf *
|
||||
|
@ -1530,7 +1585,7 @@ sysctl_iflist_addr(struct rt_walkarg *w, struct ifaddr *ifa,
|
|||
{
|
||||
int len, error;
|
||||
|
||||
if ((error = rt_msg2(RTM_NEWADDR, info, 0, w, &len)))
|
||||
if ((error = rt_msg2(RTM_XNEWADDR, info, 0, w, &len)))
|
||||
return error;
|
||||
if (w->w_where && w->w_tmem && w->w_needed <= 0) {
|
||||
struct ifa_xmsghdr *ifam;
|
||||
|
@ -1540,6 +1595,10 @@ sysctl_iflist_addr(struct rt_walkarg *w, struct ifaddr *ifa,
|
|||
ifam->ifam_flags = ifa->ifa_flags;
|
||||
ifam->ifam_metric = ifa->ifa_metric;
|
||||
ifam->ifam_addrs = info->rti_addrs;
|
||||
#ifndef COMPAT_RTSOCK
|
||||
ifam->ifam_pid = 0;
|
||||
ifam->ifam_addrflags = if_addrflags(ifa);
|
||||
#endif
|
||||
if ((error = copyout(w->w_tmem, w->w_where, len)) == 0)
|
||||
w->w_where = (char *)w->w_where + len;
|
||||
}
|
||||
|
@ -1555,6 +1614,8 @@ sysctl_iflist(int af, struct rt_walkarg *w, int type)
|
|||
int cmd, len, error = 0;
|
||||
int (*iflist_if)(struct ifnet *, struct rt_walkarg *,
|
||||
struct rt_addrinfo *, size_t);
|
||||
int (*iflist_addr)(struct rt_walkarg *, struct ifaddr *,
|
||||
struct rt_addrinfo *);
|
||||
int s;
|
||||
struct psref psref;
|
||||
int bound = curlwp_bind();
|
||||
|
@ -1563,17 +1624,27 @@ sysctl_iflist(int af, struct rt_walkarg *w, int type)
|
|||
case NET_RT_IFLIST:
|
||||
cmd = RTM_IFINFO;
|
||||
iflist_if = sysctl_iflist_if;
|
||||
iflist_addr = sysctl_iflist_addr;
|
||||
break;
|
||||
#ifdef COMPAT_14
|
||||
case NET_RT_OOIFLIST:
|
||||
case NET_RT_OOOIFLIST:
|
||||
cmd = RTM_OOIFINFO;
|
||||
iflist_if = compat_14_iflist;
|
||||
iflist_addr = compat_70_iflist_addr;
|
||||
break;
|
||||
#endif
|
||||
#ifdef COMPAT_50
|
||||
case NET_RT_OIFLIST:
|
||||
case NET_RT_OOIFLIST:
|
||||
cmd = RTM_OIFINFO;
|
||||
iflist_if = compat_50_iflist;
|
||||
iflist_addr = compat_70_iflist_addr;
|
||||
break;
|
||||
#endif
|
||||
#ifdef COMPAT_70
|
||||
case NET_RT_OIFLIST:
|
||||
cmd = RTM_IFINFO;
|
||||
iflist_if = sysctl_iflist_if;
|
||||
iflist_addr = compat_70_iflist_addr;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -1609,7 +1680,7 @@ sysctl_iflist(int af, struct rt_walkarg *w, int type)
|
|||
info.rti_info[RTAX_IFA] = ifa->ifa_addr;
|
||||
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
|
||||
info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
|
||||
if ((error = sysctl_iflist_addr(w, ifa, &info)) != 0)
|
||||
if ((error = iflist_addr(w, ifa, &info)) != 0)
|
||||
goto release_exit;
|
||||
}
|
||||
info.rti_info[RTAX_IFA] = info.rti_info[RTAX_NETMASK] =
|
||||
|
@ -1689,11 +1760,16 @@ again:
|
|||
break;
|
||||
|
||||
#ifdef COMPAT_14
|
||||
case NET_RT_OOIFLIST:
|
||||
case NET_RT_OOOIFLIST:
|
||||
error = sysctl_iflist(af, &w, w.w_op);
|
||||
break;
|
||||
#endif
|
||||
#ifdef COMPAT_50
|
||||
case NET_RT_OOIFLIST:
|
||||
error = sysctl_iflist(af, &w, w.w_op);
|
||||
break;
|
||||
#endif
|
||||
#ifdef COMPAT_70
|
||||
case NET_RT_OIFLIST:
|
||||
error = sysctl_iflist(af, &w, w.w_op);
|
||||
break;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.28 2016/04/15 01:35:26 ozaki-r Exp $
|
||||
# $NetBSD: Makefile,v 1.29 2016/09/21 10:50:23 roy Exp $
|
||||
#
|
||||
|
||||
|
||||
|
@ -22,6 +22,10 @@ SRCS+= net_component.c
|
|||
SRCS+= rtsock_50.c uipc_syscalls_50.c
|
||||
.endif
|
||||
|
||||
.if !empty(RUMP_NBCOMPAT:M70)
|
||||
SRCS+= rtsock_70.c uipc_usrreq_70.c
|
||||
.endif
|
||||
|
||||
.include "${.CURDIR}/../libnetinet/Makefile.inc"
|
||||
.include "${.CURDIR}/../libnetinet6/Makefile.inc"
|
||||
.include "${.CURDIR}/../libnetmpls/Makefile.inc"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: socket.h,v 1.119 2016/04/06 19:45:46 roy Exp $ */
|
||||
/* $NetBSD: socket.h,v 1.120 2016/09/21 10:50:23 roy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -474,10 +474,11 @@ struct kinfo_pcb {
|
|||
*/
|
||||
#define NET_RT_DUMP 1 /* dump; may limit to a.f. */
|
||||
#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
|
||||
#define NET_RT_OOIFLIST 3 /* old NET_RT_IFLIST (pre 1.5) */
|
||||
#define NET_RT_OIFLIST 4 /* survey interface list */
|
||||
#define NET_RT_IFLIST 5
|
||||
#define NET_RT_MAXID 6
|
||||
#define NET_RT_OOOIFLIST 3 /* old NET_RT_IFLIST (pre 1.5) */
|
||||
#define NET_RT_OOIFLIST 4 /* old NET_RT_IFLIST (pre-64bit time) */
|
||||
#define NET_RT_OIFLIST 5 /* old NET_RT_IFLIST (pre 8.0) */
|
||||
#define NET_RT_IFLIST 6 /* survey interface list */
|
||||
#define NET_RT_MAXID 7
|
||||
|
||||
#define CTL_NET_RT_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
|
|
Loading…
Reference in New Issue