-/* $OpenBSD: if.c,v 1.394 2015/10/24 10:52:05 reyk Exp $ */
+/* $OpenBSD: if.c,v 1.395 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
M_TEMP, M_WAITOK);
TAILQ_INIT(ifp->if_detachhooks);
+ ifp->if_rtrequest = if_rtrequest_dummy;
ifp->if_slowtimo = malloc(sizeof(*ifp->if_slowtimo), M_TEMP,
M_WAITOK|M_ZERO);
ifp->if_watchdogtask = malloc(sizeof(*ifp->if_watchdogtask),
return (ifa_maybe);
}
+void
+if_rtrequest_dummy(struct ifnet *ifp, int req, struct rtentry *rt)
+{
+}
+
/*
* Default action when installing a local route on a point-to-point
* interface.
*/
void
-p2p_rtrequest(int req, struct rtentry *rt)
+p2p_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt)
{
- struct ifnet *ifp = rt->rt_ifp;
struct ifaddr *ifa, *lo0ifa;
switch (req) {
-/* $OpenBSD: if_ethersubr.c,v 1.229 2015/10/22 15:37:47 bluhm Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.230 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
return (error);
}
+
+void
+ether_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt)
+{
+ switch (rt_key(rt)->sa_family) {
+ case AF_INET:
+ arp_rtrequest(ifp, req, rt);
+ break;
+#ifdef INET6
+ case AF_INET6:
+ nd6_rtrequest(ifp, req, rt);
+ break;
+#endif
+ default:
+ break;
+ }
+}
/*
* Ethernet output routine.
* Encapsulate a packet of type family for the local net.
ifp->if_hdrlen = ETHER_HDR_LEN;
ifp->if_mtu = ETHERMTU;
ifp->if_output = ether_output;
+ ifp->if_rtrequest = ether_rtrequest;
if_ih_insert(ifp, ether_input, NULL);
-/* $OpenBSD: if_gif.c,v 1.80 2015/09/28 08:32:05 mpi Exp $ */
+/* $OpenBSD: if_gif.c,v 1.81 2015/10/25 11:58:11 mpi Exp $ */
/* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */
/*
sc->gif_if.if_ioctl = gif_ioctl;
sc->gif_if.if_start = gif_start;
sc->gif_if.if_output = gif_output;
+ sc->gif_if.if_rtrequest = p2p_rtrequest;
sc->gif_if.if_type = IFT_GIF;
IFQ_SET_MAXLEN(&sc->gif_if.if_snd, IFQ_MAXLEN);
IFQ_SET_READY(&sc->gif_if.if_snd);
{
struct gif_softc *sc = (struct gif_softc*)ifp;
struct ifreq *ifr = (struct ifreq *)data;
- struct ifaddr *ifa = (struct ifaddr *)data;
int error = 0, size;
struct sockaddr *dst, *src;
struct sockaddr *sa;
switch (cmd) {
case SIOCSIFADDR:
- ifa->ifa_rtrequest = p2p_rtrequest;
break;
case SIOCSIFDSTADDR:
-/* $OpenBSD: if_gre.c,v 1.75 2015/07/16 16:12:15 mpi Exp $ */
+/* $OpenBSD: if_gre.c,v 1.76 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
sc->sc_if.if_flags = IFF_POINTOPOINT|IFF_MULTICAST;
sc->sc_if.if_output = gre_output;
sc->sc_if.if_ioctl = gre_ioctl;
+ sc->sc_if.if_rtrequest = p2p_rtrequest;
sc->sc_if.if_collisions = 0;
sc->sc_if.if_ierrors = 0;
sc->sc_if.if_oerrors = 0;
{
struct ifreq *ifr = (struct ifreq *)data;
- struct ifaddr *ifa = (struct ifaddr *)data;
struct if_laddrreq *lifr = (struct if_laddrreq *)data;
struct ifkalivereq *ikar = (struct ifkalivereq *)data;
struct gre_softc *sc = ifp->if_softc;
switch(cmd) {
case SIOCSIFADDR:
ifp->if_flags |= IFF_UP;
- ifa->ifa_rtrequest = p2p_rtrequest;
break;
case SIOCSIFDSTADDR:
break;
-/* $OpenBSD: if_loop.c,v 1.71 2015/09/12 13:34:12 mpi Exp $ */
+/* $OpenBSD: if_loop.c,v 1.72 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */
/*
ifp->if_softc = NULL;
ifp->if_mtu = LOMTU;
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
+ ifp->if_rtrequest = lortrequest;
ifp->if_ioctl = loioctl;
ifp->if_output = looutput;
ifp->if_type = IFT_LOOP;
/* ARGSUSED */
void
-lortrequest(int cmd, struct rtentry *rt)
+lortrequest(struct ifnet *ifp, int cmd, struct rtentry *rt)
{
if (rt && rt->rt_rmx.rmx_mtu == 0)
rt->rt_rmx.rmx_mtu = LOMTU;
int
loioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
- struct ifaddr *ifa;
struct ifreq *ifr;
int error = 0;
case SIOCSIFADDR:
ifp->if_flags |= IFF_RUNNING;
if_up(ifp); /* send up RTM_IFINFO */
-
- ifa = (struct ifaddr *)data;
- if (ifa != 0)
- ifa->ifa_rtrequest = lortrequest;
/*
* Everything else is done at a higher level.
*/
-/* $OpenBSD: if_ppp.c,v 1.90 2015/10/12 13:17:58 dlg Exp $ */
+/* $OpenBSD: if_ppp.c,v 1.91 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */
/*
sc->sc_if.if_ioctl = pppsioctl;
sc->sc_if.if_output = pppoutput;
sc->sc_if.if_start = ppp_ifstart;
+ sc->sc_if.if_rtrequest = p2p_rtrequest;
IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN);
mq_init(&sc->sc_inq, IFQ_MAXLEN, IPL_NET);
IFQ_SET_MAXLEN(&sc->sc_fastq, IFQ_MAXLEN);
case SIOCSIFADDR:
if (ifa->ifa_addr->sa_family != AF_INET)
error = EAFNOSUPPORT;
- ifa->ifa_rtrequest = p2p_rtrequest;
break;
case SIOCSIFDSTADDR:
-/* $OpenBSD: if_pppoe.c,v 1.48 2015/09/13 17:53:44 mpi Exp $ */
+/* $OpenBSD: if_pppoe.c,v 1.49 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if_pppoe.c,v 1.51 2003/11/28 08:56:48 keihan Exp $ */
/*
sc->sc_sppp.pp_framebytes = PPPOE_HEADERLEN; /* framing added to ppp packets */
sc->sc_sppp.pp_if.if_ioctl = pppoe_ioctl;
sc->sc_sppp.pp_if.if_start = pppoe_start;
+ sc->sc_sppp.pp_if.if_rtrequest = p2p_rtrequest;
sc->sc_sppp.pp_tls = pppoe_tls;
sc->sc_sppp.pp_tlf = pppoe_tlf;
IFQ_SET_MAXLEN(&sc->sc_sppp.pp_if.if_snd, IFQ_MAXLEN);
-/* $OpenBSD: if_pppx.c,v 1.43 2015/09/06 12:59:20 kettenis Exp $ */
+/* $OpenBSD: if_pppx.c,v 1.44 2015/10/25 11:58:11 mpi Exp $ */
/*
* Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org>
ifp->if_start = pppx_if_start;
ifp->if_output = pppx_if_output;
ifp->if_ioctl = pppx_if_ioctl;
+ ifp->if_rtrequest = p2p_rtrequest;
ifp->if_type = IFT_PPP;
IFQ_SET_MAXLEN(&ifp->if_snd, 1);
IFQ_SET_READY(&ifp->if_snd);
{
struct pppx_if *pxi = (struct pppx_if *)ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)addr;
- struct ifaddr *ifa = (struct ifaddr *)addr;
int error = 0;
switch (cmd) {
case SIOCSIFADDR:
- ifa->ifa_rtrequest = p2p_rtrequest;
break;
case SIOCSIFFLAGS:
-/* $OpenBSD: if_spppsubr.c,v 1.142 2015/10/24 11:58:46 mpi Exp $ */
+/* $OpenBSD: if_spppsubr.c,v 1.143 2015/10/25 11:58:11 mpi Exp $ */
/*
* Synchronous PPP link level subroutines.
*
sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct ifreq *ifr = data;
- struct ifaddr *ifa = data;
struct sppp *sp = (struct sppp*) ifp;
int s, rv, going_up, going_down, newmode;
case SIOCSIFADDR:
if_up(ifp);
- ifa->ifa_rtrequest = p2p_rtrequest;
/* FALLTHROUGH */
case SIOCSIFFLAGS:
-/* $OpenBSD: if_tun.c,v 1.157 2015/10/24 04:12:24 dlg Exp $ */
+/* $OpenBSD: if_tun.c,v 1.158 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
ifp->if_flags = IFF_POINTOPOINT;
ifp->if_type = IFT_TUNNEL;
ifp->if_hdrlen = sizeof(u_int32_t);
+ ifp->if_rtrequest = p2p_rtrequest;
if_attach(ifp);
if_alloc_sadl(ifp);
default:
break;
}
- } else {
- ifa->ifa_rtrequest = p2p_rtrequest;
}
break;
case SIOCSIFDSTADDR:
-/* $OpenBSD: if_var.h,v 1.50 2015/10/24 10:52:05 reyk Exp $ */
+/* $OpenBSD: if_var.h,v 1.51 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
struct hook_desc_head *if_addrhooks; /* address change callbacks */
struct hook_desc_head *if_linkstatehooks; /* link change callbacks */
struct hook_desc_head *if_detachhooks; /* detach callbacks */
+ /* check or clean routes (+ or -)'d */
+ void (*if_rtrequest)(struct ifnet *, int, struct rtentry *);
char if_xname[IFNAMSIZ]; /* external name (name + unit) */
int if_pcount; /* number of promiscuous listeners */
caddr_t if_bpf; /* packet filter structure */
struct sockaddr *ifa_netmask; /* used to determine subnet */
struct ifnet *ifa_ifp; /* back-pointer to interface */
TAILQ_ENTRY(ifaddr) ifa_list; /* list of addresses for interface */
- /* check or clean routes (+ or -)'d */
- void (*ifa_rtrequest)(int, struct rtentry *);
u_int ifa_flags; /* interface flags, see below */
u_int ifa_refcnt; /* number of `rt_ifa` references */
int ifa_metric; /* cost of going out this interface */
int if_enqueue(struct ifnet *, struct mbuf *);
void if_input(struct ifnet *, struct mbuf_list *);
int if_input_local(struct ifnet *, struct mbuf *, sa_family_t);
+void if_rtrequest_dummy(struct ifnet *, int, struct rtentry *);
+void p2p_rtrequest(struct ifnet *, int, struct rtentry *);
void ether_ifattach(struct ifnet *);
void ether_ifdetach(struct ifnet *);
int ether_input(struct ifnet *, struct mbuf *, void *);
int ether_output(struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *);
+void ether_rtrequest(struct ifnet *, int, struct rtentry *);
char *ether_sprintf(u_char *);
struct ifaddr *ifa_ifwithaddr(struct sockaddr *, u_int);
struct ifaddr *ifa_ifwithnet(struct sockaddr *, u_int);
struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *);
void ifafree(struct ifaddr *);
-void p2p_rtrequest(int, struct rtentry *);
void if_clone_attach(struct if_clone *);
void if_clone_detach(struct if_clone *);
void loopattach(int);
int looutput(struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *);
-void lortrequest(int, struct rtentry *);
+void lortrequest(struct ifnet *, int, struct rtentry *);
void ifa_add(struct ifnet *, struct ifaddr *);
void ifa_del(struct ifnet *, struct ifaddr *);
-/* $OpenBSD: route.c,v 1.261 2015/10/25 10:05:09 bluhm Exp $ */
+/* $OpenBSD: route.c,v 1.262 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
rt->rt_parent = NULL;
rt->rt_flags &= ~RTF_UP;
- if ((ifa = rt->rt_ifa) && ifa->ifa_rtrequest)
- ifa->ifa_rtrequest(RTM_DELETE, rt);
+ rt->rt_ifp->if_rtrequest(rt->rt_ifp, RTM_DELETE, rt);
atomic_inc_int(&rttrash);
if (ret_nrt != NULL)
if ((*ret_nrt)->rt_ifa->ifa_ifp == NULL) {
printf("rtrequest1 RTM_RESOLVE: wrong ifa (%p) "
"was (%p)\n", ifa, (*ret_nrt)->rt_ifa);
- if ((*ret_nrt)->rt_ifa->ifa_rtrequest)
- (*ret_nrt)->rt_ifa->ifa_rtrequest(
- RTM_DELETE, *ret_nrt);
+ (*ret_nrt)->rt_ifp->if_rtrequest(rt->rt_ifp,
+ RTM_DELETE, *ret_nrt);
ifafree((*ret_nrt)->rt_ifa);
(*ret_nrt)->rt_ifa = ifa;
(*ret_nrt)->rt_ifp = ifa->ifa_ifp;
ifa->ifa_refcnt++;
- if (ifa->ifa_rtrequest)
- ifa->ifa_rtrequest(RTM_ADD, *ret_nrt);
+ (*ret_nrt)->rt_ifp->if_rtrequest(rt->rt_ifp,
+ RTM_ADD, *ret_nrt);
}
/*
* Copy both metrics and a back pointer to the cloned
pool_put(&rtentry_pool, rt);
return (EEXIST);
}
-
- if (ifa->ifa_rtrequest)
- ifa->ifa_rtrequest(req, rt);
+ rt->rt_ifp->if_rtrequest(rt->rt_ifp, req, rt);
if ((rt->rt_flags & RTF_CLONING) != 0) {
/* clean up any cloned children */
-/* $OpenBSD: rtsock.c,v 1.177 2015/10/25 10:05:09 bluhm Exp $ */
+/* $OpenBSD: rtsock.c,v 1.178 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
goto flush;
if (ifa) {
if (rt->rt_ifa != ifa) {
- if (rt->rt_ifa->ifa_rtrequest)
- rt->rt_ifa->ifa_rtrequest(
- RTM_DELETE, rt);
+ rt->rt_ifp->if_rtrequest(
+ rt->rt_ifp, RTM_DELETE, rt);
ifafree(rt->rt_ifa);
rt->rt_ifa = ifa;
ifa->ifa_refcnt++;
rtm->rtm_index = rt->rt_ifidx;
rtm->rtm_priority = rt->rt_priority & RTP_MASK;
rtm->rtm_flags = rt->rt_flags;
- if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
- rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt);
+ rt->rt_ifp->if_rtrequest(rt->rt_ifp, RTM_ADD, rt);
if (info.rti_info[RTAX_LABEL] != NULL) {
char *rtlabel = ((struct sockaddr_rtlabel *)
info.rti_info[RTAX_LABEL])->sr_label;
-/* $OpenBSD: if_ether.c,v 1.176 2015/10/22 18:14:53 mpi Exp $ */
+/* $OpenBSD: if_ether.c,v 1.177 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
}
void
-arp_rtrequest(int req, struct rtentry *rt)
+arp_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt)
{
struct sockaddr *gate = rt->rt_gateway;
struct llinfo_arp *la = (struct llinfo_arp *)rt->rt_llinfo;
- struct ifnet *ifp = rt->rt_ifp;
struct ifaddr *ifa;
struct mbuf *m;
void
arp_ifinit(struct arpcom *ac, struct ifaddr *ifa)
{
- ifa->ifa_rtrequest = arp_rtrequest;
}
/*
-/* $OpenBSD: if_ether.h,v 1.60 2015/09/27 16:50:40 stsp Exp $ */
+/* $OpenBSD: if_ether.h,v 1.61 2015/10/25 11:58:11 mpi Exp $ */
/* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */
/*
int arpresolve(struct ifnet *,
struct rtentry *, struct mbuf *, struct sockaddr *, u_char *);
void arp_ifinit(struct arpcom *, struct ifaddr *);
-void arp_rtrequest(int, struct rtentry *);
+void arp_rtrequest(struct ifnet *, int, struct rtentry *);
int ether_addmulti(struct ifreq *, struct arpcom *);
int ether_delmulti(struct ifreq *, struct arpcom *);
-/* $OpenBSD: ip_carp.c,v 1.277 2015/10/22 13:30:29 mpi Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.278 2015/10/25 11:58:11 mpi Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
switch (ifa->ifa_addr->sa_family) {
case AF_INET:
sc->sc_if.if_flags |= IFF_UP;
- ifa->ifa_rtrequest = arp_rtrequest;
error = carp_set_addr(sc, satosin(ifa->ifa_addr));
break;
#ifdef INET6
-/* $OpenBSD: in6.c,v 1.175 2015/09/12 20:50:17 mpi Exp $ */
+/* $OpenBSD: in6.c,v 1.176 2015/10/25 11:58:11 mpi Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
ia6->ia_flags |= IFA_ROUTE;
}
- /* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */
- if (newhost) {
- /* set the rtrequest function to create llinfo */
- if ((ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) == 0)
- ia6->ia_ifa.ifa_rtrequest = nd6_rtrequest;
-
+ if (newhost)
rt_ifa_addlocal(&(ia6->ia_ifa));
- }
return (error);
}
-/* $OpenBSD: nd6.c,v 1.159 2015/10/24 16:08:48 mpi Exp $ */
+/* $OpenBSD: nd6.c,v 1.160 2015/10/25 11:58:11 mpi Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
* Create a new route. RTF_LLINFO is necessary
* to create a Neighbor Cache entry for the
* destination in nd6_rtrequest which will be
- * called in rtrequest1 via ifa->ifa_rtrequest.
+ * called in rtrequest1.
*/
bzero(&info, sizeof(info));
info.rti_flags = RTF_HOST | RTF_LLINFO;
}
void
-nd6_rtrequest(int req, struct rtentry *rt)
+nd6_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt)
{
struct sockaddr *gate = rt->rt_gateway;
struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo;
- struct ifnet *ifp = rt->rt_ifp;
struct ifaddr *ifa;
struct nd_defrouter *dr;
-/* $OpenBSD: nd6.h,v 1.50 2015/10/24 16:08:48 mpi Exp $ */
+/* $OpenBSD: nd6.h,v 1.51 2015/10/25 11:58:11 mpi Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
void nd6_nud_hint(struct rtentry *, u_int);
int nd6_resolve(struct ifnet *, struct rtentry *,
struct mbuf *, struct sockaddr *, u_char *);
-void nd6_rtrequest(int, struct rtentry *);
+void nd6_rtrequest(struct ifnet *, int, struct rtentry *);
int nd6_ioctl(u_long, caddr_t, struct ifnet *);
void nd6_cache_lladdr(struct ifnet *, struct in6_addr *, char *, int, int, int);
int nd6_output(struct ifnet *, struct mbuf *, struct sockaddr_in6 *,
-/* $OpenBSD: nd6_rtr.c,v 1.127 2015/10/24 16:08:48 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.128 2015/10/25 11:58:11 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
return (0);
}
- /*
- * in6_ifinit() sets nd6_rtrequest to ifa_rtrequest for all ifaddrs.
- * ifa->ifa_rtrequest = nd6_rtrequest;
- */
bzero(&mask6, sizeof(mask6));
mask6.sin6_len = sizeof(mask6);
mask6.sin6_addr = pr->ndpr_mask;